Changeset 16638 for extensions/Autosize/js/autosize.dimensions.js
- Timestamp:
- Jul 12, 2012, 12:33:43 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Autosize/js/autosize.dimensions.js
r16624 r16638 8 8 * $LastChangedDate: 2010-10-23 08:43:48 -0600 (Thu, 20 Dec 2007) $ 9 9 * By cljosse 10 * Version: 1. 210 * Version: 1.3 11 11 * 12 12 * Requires: jQuery 1.2+ … … 135 135 if (elem.nodeName) nodeName = elem.nodeName; 136 136 137 137 width = jQuery(elem).width(); 138 height = jQuery(elem).height(); 138 139 if (elem == window) { 139 140 … … 141 142 width = jQuery(elem).width(); 142 143 height = jQuery(elem).height(); 144 out_width = width; 145 out_height = height; 143 146 } else { 144 147 145 148 Css = jQuery(elem).getStyles(elem); 146 149 myposition = Css.position.toString() || ""; 147 width = jQuery(elem).outerWidth();148 height = jQuery(elem).outerHeight();150 out_width = jQuery(elem).outerWidth(); 151 out_height = jQuery(elem).outerHeight(); 149 152 elem_parent =elem.parentElement; 150 153 if (typeof elem_parent == "undefined") { 151 154 elem_parent = window; 152 155 } 156 out_width = jQuery(elem).outerWidth(); 157 out_height = jQuery(elem).outerHeight(); 158 in_width = jQuery(elem).innerWidth(); 159 in_height = jQuery(elem).innerHeight(); 153 160 if (typeof Css.width != "undefined") 154 width = jQuery(elem).Get_Val_int(Css.width, jQuery(elem_parent).width(), 0);161 width = Get_Val_int(Css.width, jQuery(elem_parent).width(), 0); 155 162 156 163 if (typeof Css.height != "undefined") 157 height = jQuery(elem).Get_Val_int(Css.height, jQuery(elem_parent).height(), 0); 158 159 160 161 162 163 164 borderwidth.left = jQuery(elem).Get_Val_int(Css.borderLeftWidth, "", "", 'borderLeftWidth'); 165 borderwidth.right = jQuery(elem).Get_Val_int(Css.borderRightWidth, "", "", 'borderRightWidth'); 166 borderwidth.top = jQuery(elem).Get_Val_int(Css.borderTopWidth, "", "", 'borderTopWidth'); 167 borderwidth.bottom = jQuery(elem).Get_Val_int(Css.borderBottomWidth, "", "", 'borderBottomWidth'); 164 height = Get_Val_int(Css.height, jQuery(elem_parent).height(), 0); 165 166 167 borderwidth.left = Get_Val_int(Css.borderLeftWidth, "", "", { elem: elem, prop: 'borderLeftWidth' }); 168 borderwidth.right = Get_Val_int(Css.borderRightWidth, "", "", { elem: elem, prop: 'borderRightWidth' }); 169 borderwidth.top = Get_Val_int(Css.borderTopWidth, "", "", { elem: elem, prop: 'borderTopWidth' }); 170 borderwidth.bottom = Get_Val_int(Css.borderBottomWidth, "", "", { elem: elem, prop: 'borderBottomWidth' }); 168 171 try { 169 172 borderwidth.width = Css.borderWidth; … … 172 175 } 173 176 174 175 176 margin.left = jQuery(elem).Get_Val_int(Css.marginLeft, "", "", 'marginLeft'); 177 margin.right = jQuery(elem).Get_Val_int(Css.marginRight, "", "", 'marginRight'); 178 margin.top = jQuery(elem).Get_Val_int(Css.marginTop, "", "", 'marginTop'); 179 margin.bottom = jQuery(elem).Get_Val_int(Css.marginBottom, "", "", 'marginBottom'); 177 margin.left = Get_Val_int(Css.marginLeft, "", "", { elem: elem, prop: 'marginLeft' }); 178 margin.right = Get_Val_int(Css.marginRight, "", "", { elem: elem, prop: 'marginRight' }); 179 margin.top = Get_Val_int(Css.marginTop, "", "", { elem: elem, prop: 'marginTop' }); 180 margin.bottom = Get_Val_int(Css.marginBottom, "", "", { elem: elem, prop: 'marginBottom' }); 180 181 181 182 … … 187 188 188 189 189 padding.left = jQuery(elem).Get_Val_int(Css.paddingLeft, "", "", 'paddingLeft');190 padding.right = jQuery(elem).Get_Val_int(Css.paddingRight, "", "", 'paddingRight');191 padding.top = jQuery(elem).Get_Val_int(Css.paddingTop, "", "", 'paddingTop');192 padding.bottom = jQuery(elem).Get_Val_int(Css.paddingBottom, "", "", 'paddingBottom');190 padding.left = Get_Val_int(Css.paddingLeft, "", "", { elem: elem, prop: 'paddingLeft' }); 191 padding.right = Get_Val_int(Css.paddingRight, "", "", { elem: elem, prop: 'paddingRight' }); 192 padding.top = Get_Val_int(Css.paddingTop, "", "", { elem: elem, prop: 'paddingTop' }); 193 padding.bottom = Get_Val_int(Css.paddingBottom, "", "", { elem: elem, prop: 'paddingBottom' }); 193 194 194 195 try { … … 208 209 visible= jQuery(elem).is(':visible'); 209 210 results = {src: elem.src || "none", 210 visible: visible || "false",211 visible: visible || false, 211 212 position: myposition, 212 213 top: Top, 213 214 left: Left, 214 width: width, 215 width: width, // valeur interieur 215 216 height: height, 216 217 right: Left + width, 217 218 bottom: Top + height, 219 220 padding: padding, 221 222 out: { 223 width: in_width, 224 height: in_height, 225 right: Left + in_width, 226 bottom: Top + in_height 227 }, 218 228 borderwidth: borderwidth, 229 exterieur: { 230 width: out_width, 231 height: out_height, 232 right: Left + out_width, 233 bottom: Top + out_height 234 }, 219 235 margin: margin, 220 padding: padding, 236 general: { 237 width: out_width + margin.left + margin.right, 238 height: out_height + margin.top + margin.bottom, 239 right: Left + out_width + margin.left + margin.right, 240 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 252 }, 221 253 id: id, 222 254 nodeName: nodeName … … 295 327 return propriete; 296 328 }, 297 /* 329 Get_Val_int: function (myObj, Maxi_val, Mini_val, prop) { 330 331 return Get_Val_int(myObj, Maxi_val, Mini_val, prop); 332 } 333 }); 334 335 /************************** 298 336 * Get_val_int 299 337 * params: element,valeur maxi 300 338 * return: valeur entiere 301 302 303 Get_Val_int: function (myObj, Maxi_val, Mini_val, prop) { 339 ******************************/ 340 Get_Val_int = function (myObj, Maxi_val, Mini_val, prop) { 341 304 342 var val = 0; 305 343 Maxi_val = parseInt(Maxi_val || "0"); … … 336 374 break; 337 375 } 338 el = this.get(0); 376 339 377 var reg1 = new RegExp("auto", "g"); 340 378 if (myObj.match(reg1)) { 341 379 return Maxi_val; 342 380 } 343 if (prop) 344 myObj = num(el, prop); 345 else { 381 382 if (prop) { 383 384 myObj = num(prop.elem, prop.prop); 385 } else { 346 386 reg1 = new RegExp("px", "g"); 347 387 if (myObj.match(reg1)) { 348 388 349 myObj = parseInt(myObj);389 myObj = Parse_Int(myObj); 350 390 351 391 } else { … … 356 396 return val; 357 397 } 358 359 } 360 361 } 362 398 } 399 } 363 400 if (Mini_val) 364 401 if (myObj < Mini_val) return Maxi_val; 365 366 367 val = parseInt(myObj); 402 val = Parse_Int(myObj); 368 403 369 404 } else { 370 val = parseInt(myObj);405 val = Parse_Int(myObj); 371 406 } 372 if (typeof (val) == "NaN") return Maxi_val; 407 if (typeof (val) == "NaN") 408 return Maxi_val; 373 409 return val; 410 374 411 } 375 }); 412 376 413 /* 377 414 * 378 415 */ 416 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)) { 421 valeur_num = valeur_num.replace(reg1, ""); 422 } else { 423 valeur_num = valeur_num.replace(reg1, ""); 424 } 425 } 426 valeur_num = Math.ceil(valeur_num); 427 return valeur_num || 0; 428 } 429 379 430 function num(el, prop) { 380 return parseInt(jQuery.curCSS(el.jquery ? el[0] : el, prop, true)) || 0; 431 valeur_num = jQuery.curCSS(el.jquery ? el[0] : el, prop, true); 432 433 return Parse_Int(valeur_num); 381 434 }; 382 435
Note: See TracChangeset
for help on using the changeset viewer.