Changeset 16931 for extensions/Autosize/js/autosize.dimensions.js
- Timestamp:
- Jul 23, 2012, 3:01:09 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Autosize/js/autosize.dimensions.js
r16638 r16931 33 33 options = options || false; 34 34 options = jQuery.extend({ margin: options }); 35 35 Maxi_val = this.parent().width(); 36 36 var val = this.is(':visible') ? this[0]['offset' + name] : 37 37 num(this, … … 118 118 myposition = ""; 119 119 results = { 120 visible:false , 120 121 position: "", 121 122 top: 0, … … 127 128 borderwidth: borderwidth, 128 129 padding: padding, 129 margin: margin, id: "", nodeName: "" 130 margin: margin, 131 132 out: { 133 width: 0, 134 height: 0, 135 right: 0, 136 bottom: 0 137 }, 138 139 exterieur: { 140 width: 0, 141 height: 0, 142 right: 0, 143 bottom: 0 144 }, 145 146 general: { 147 width: 0, 148 height: 0, 149 right: 0, 150 bottom: 0, 151 marges: { height:0, 152 top: 0, 153 bottom: 0, 154 width: 0, 155 left: 0, 156 right: 0 157 } 158 }, 159 src:"", 160 useMap : "" , 161 id: "", 162 nodeName: "" 130 163 }; 131 164 ; … … 150 183 out_width = jQuery(elem).outerWidth(); 151 184 out_height = jQuery(elem).outerHeight(); 152 elem_parent = elem.parentElement;185 elem_parent = elem.parentElement; 153 186 if (typeof elem_parent == "undefined") { 154 187 elem_parent = window; … … 207 240 Top = Cl_Position.top; 208 241 209 visible= jQuery(elem).is(':visible'); 210 results = {src: elem.src || "none", 242 visible = jQuery(elem).is(':visible'); 243 results = { 244 useMap : elem.useMap || "none", 245 src: elem.src || "none", 211 246 visible: visible || false, 212 247 position: myposition, … … 239 274 right: Left + out_width + margin.left + margin.right, 240 275 bottom: Top + out_height + margin.top + margin.bottom, 241 marges: { height: margin.top + borderwidth.top + padding.top + 242 margin.bottom + borderwidth.bottom + padding.bottom, 243 top: margin.top + borderwidth.top + padding.top, 244 bottom: margin.bottom + borderwidth.bottom + padding.bottom, 245 width: margin.left + borderwidth.left + padding.left + 246 margin.right + borderwidth.right + padding.right, 247 left: margin.left + borderwidth.left + padding.left, 248 right: margin.right + borderwidth.right + padding.right 249 } 250 251 276 marges: { height: margin.top + 277 borderwidth.top + 278 padding.top + 279 margin.bottom + borderwidth.bottom + 280 padding.bottom, 281 top: margin.top + 282 borderwidth.top + 283 padding.top, 284 bottom: margin.bottom + 285 borderwidth.bottom + 286 padding.bottom, 287 width: margin.left + 288 borderwidth.left + 289 padding.left + 290 margin.right + 291 borderwidth.right + 292 padding.right, 293 left: margin.left + 294 borderwidth.left + 295 padding.left, 296 right: margin.right + 297 borderwidth.right + 298 padding.right 299 } 252 300 }, 253 301 id: id, … … 311 359 var element = jQuery(elt).get(0); 312 360 propriete = []; 313 try {314 if (jQuery(element).length > 0)315 if (window.getComputedStyle) // Mozilla Firefox & cie316 {317 var propriete = window.getComputedStyle(element, null);318 }319 else if (element.currentStyle) // Microsoft Internet Explorer320 {321 322 var propriete = element.currentStyle;323 }324 }catch(e){325 326 361 try { 362 if (jQuery(element).length > 0) 363 if (window.getComputedStyle) // Mozilla Firefox & cie 364 { 365 var propriete = window.getComputedStyle(element, null); 366 } 367 else if (element.currentStyle) // Microsoft Internet Explorer 368 { 369 370 var propriete = element.currentStyle; 371 } 372 } catch (e) { 373 374 } 327 375 return propriete; 328 376 }, … … 334 382 335 383 /************************** 336 337 338 384 * Get_val_int 385 * params: element,valeur maxi 386 * return: valeur entiere 339 387 ******************************/ 340 388 Get_Val_int = function (myObj, Maxi_val, Mini_val, prop) { 341 389 342 var val = 0; 343 Maxi_val = parseInt(Maxi_val || "0"); 344 345 /* 346 - numérique suivie de px ou % ou pt ou em, 347 - thin, bordure mince, 348 - medium, bordure moyenne (valeur par défaut), 349 - thick, bordure épaisse, 350 - inherit, hérite de son parent (css2). 351 */ 352 353 if (!myObj) { 390 var val = 0; 391 Maxi_val = parseInt(Maxi_val || "0"); 392 393 /* 394 - numérique suivie de px ou % ou pt ou em, 395 - thin, bordure mince, 396 - medium, bordure moyenne (valeur par défaut), 397 - thick, bordure épaisse, 398 - inherit, hérite de son parent (css2). 399 */ 400 401 if (!myObj) { 402 return Maxi_val; 403 } 404 405 if (typeof (myObj) == "string") { 406 switch (myObj) { 407 case 'thin': 408 return 1; 409 break; 410 case 'medium': 411 return 2; 412 break; 413 case 'thick': 414 return 4; 415 break; 416 case 'inherit': 417 break; 418 case 'none': 419 return Maxi_val; 420 break; 421 default: 422 break; 423 } 424 425 var reg1 = new RegExp("auto", "g"); 426 if (myObj.match(reg1)) { 354 427 return Maxi_val; 355 428 } 356 357 if (typeof (myObj) == "string") {358 switch (myObj) {359 case 'thin':360 return 1;361 break;362 case 'medium':363 return 2;364 break;365 case 'thick':366 return 4;367 break;368 case 'inherit':369 break;370 case 'none':371 return Maxi_val;372 break;373 default:374 break;375 }376 377 var reg1 = new RegExp("auto", "g");378 if (myObj.match(reg1)) {379 return Maxi_val;380 }381 429 382 430 if (prop) { … … 384 432 myObj = num(prop.elem, prop.prop); 385 433 } else { 386 reg1 = new RegExp("px", "g"); 434 reg1 = new RegExp("px", "g"); 435 if (myObj.match(reg1)) { 436 437 myObj = Parse_Int(myObj); 438 439 } else { 440 reg1 = new RegExp("%", "g"); 387 441 if (myObj.match(reg1)) { 388 389 myObj = Parse_Int(myObj); 390 391 } else { 392 reg1 = new RegExp("%", "g"); 393 if (myObj.match(reg1)) { 394 myObj = myObj.replace(reg1, ""); 395 val = Math.ceil(myObj * Maxi_val / 100); 396 return val; 397 } 442 myObj = myObj.replace(reg1, ""); 443 val = Math.ceil(myObj * Maxi_val / 100); 444 return val; 398 445 } 399 446 } 400 if (Mini_val) 401 if (myObj < Mini_val) return Maxi_val; 447 } 448 if (Mini_val) 449 if (myObj < Mini_val) return Maxi_val; 402 450 val = Parse_Int(myObj); 403 451 404 452 } else { 405 453 val = Parse_Int(myObj); 406 454 } 407 455 if (typeof (val) == "NaN") 408 456 return Maxi_val; 409 410 411 457 return val; 458 459 } 412 460 413 461 /* … … 415 463 */ 416 464 function Parse_Int(valeur_num) { 417 if (!jQuery.isNumeric(valeur_num)){418 valeur_num = valeur_num.toString();419 reg1 = new RegExp("px", "gi");420 if (valeur_num.match(reg1)) {465 if (!jQuery.isNumeric(valeur_num)) { 466 valeur_num = valeur_num.toString(); 467 reg1 = new RegExp("px", "gi"); 468 if (valeur_num.match(reg1)) { 421 469 valeur_num = valeur_num.replace(reg1, ""); 422 } else{470 } if (valeur_num.match(RegExp("%", "gi"))) { 423 471 valeur_num = valeur_num.replace(reg1, ""); 472 valeur_num = Math.ceil(valeur_num * Maxi_val / 100); 473 } else { 474 valeur_num = valeur_num.replace(reg1, ""); 475 } 424 476 } 425 }426 477 valeur_num = Math.ceil(valeur_num); 427 478 return valeur_num || 0; … … 434 485 }; 435 486 436 myjQuery = jQuery;437 my$ = $;487 // myjQuery = jQuery; 488 // my$ = $; 438 489 439 490 })(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.