Changeset 17192 for extensions/Autosize/js/autosize.dimensions.js
- Timestamp:
- Jul 28, 2012, 8:48:54 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Autosize/js/autosize.dimensions.js
r16931 r17192 49 49 * 50 50 */ 51 jQuery.each(['Left', 'Top' ],51 jQuery.each(['Left', 'Top', 'Right', 'Bottom', 'All'], 52 52 function (i, name) { 53 //========== scroll ================= 53 54 jQuery.fn['scroll' + name] = function (val) { 54 55 if (!this[0]) return; … … 58 59 }) : this[0] == window || this[0] == document ? self[(name == 'Left' ? 'pageXOffset' : 'pageYOffset')] || jQuery.boxModel && document.documentElement['scroll' + name] || document.body['scroll' + name] : this[0]['scroll' + name]; 59 60 }; 60 //========= =======================================61 jQuery.fn['absolute' + name] = function ( val) {62 if (!this[0]) return ;61 //========= Absolute ===================== 62 jQuery.fn['absolute' + name] = function (Args) { 63 if (!this[0]) return 0; 63 64 a = jQuery(this[0]); 64 m = 0; 65 while (a.length > 0) { 66 val = jQuery(a).infos(); 67 if (val.position != "absolute") { 68 m += name == 'Left' ? val.left : val.top; 69 m += name == 'Left' ? val.margin.left : val.margin.top; 70 m += name == 'Left' ? val.margin.right : val.margin.bottom; 71 m += name == 'Left' ? val.borderwidth.left : val.borderwidth.top; 72 // m += name == 'Left' ? val.borderwidth.right : val.borderwidth.bottom; 73 // m += name == 'Left' ? val.padding.left : val.padding.top; 74 // m += name == 'Left' ? val.padding.right : val.padding.bottom; 75 a = jQuery(a).offsetParent(); 76 } else 77 break; 65 m = { Left: 0, Top: 0, Right: 0, Bottom: 0, 66 All: { 67 Left: 0, Top: 0, Right: 0, Bottom: 0 68 } 69 }; 70 pos = jQuery(this).offset(); 71 pos.top = Math.ceil(pos.top); 72 pos.left = Math.ceil(pos.left); 73 74 size = { width: jQuery(this).outerWidth(), height: jQuery(this).outerHeight() }; 75 76 if (name == "All") { 77 m[name]['Left'] = pos.left; 78 m[name]['Top'] = pos.top; 79 m[name]['Right'] = pos.left + size.width; 80 m[name]['Bottom'] = pos.top + size.height; 81 } else { 82 83 if (name == 'Left' || name == 'Top') { 84 m[name] = name == 'Left' ? pos.left : (pos.top); 85 } else { 86 m[name] = name == 'Right' ? pos.left + size.width : pos.top + size.height; 87 } 88 78 89 79 90 } 80 //306 81 82 83 return m; 91 92 93 return m[name]; 84 94 85 95 … … 91 101 jQuery.fn.extend({ 92 102 93 infos: function () { 103 infos: function (Arguments) { 104 if (!Arguments) { 105 Arguments = { pos_absolute: false, pos_externe: false }; 106 107 } 108 Args = { pos_absolute: Arguments.pos_absolute || false, pos_externe: Arguments.pos_externe || false }; 109 94 110 var width = 0, height = 0; 95 111 var elem = jQuery(this).get(0); … … 118 134 myposition = ""; 119 135 results = { 120 visible: false,136 visible: false, 121 137 position: "", 122 138 top: 0, … … 136 152 bottom: 0 137 153 }, 138 154 139 155 exterieur: { 140 156 width: 0, … … 143 159 bottom: 0 144 160 }, 145 161 146 162 general: { 147 163 width: 0, … … 149 165 right: 0, 150 166 bottom: 0, 151 marges: { height: 0,152 153 154 155 156 157 158 159 src: "",160 useMap : "",167 marges: { height: 0, 168 top: 0, 169 bottom: 0, 170 width: 0, 171 left: 0, 172 right: 0 173 } 174 }, 175 src: "", 176 useMap: "", 161 177 id: "", 162 178 nodeName: "" … … 177 193 out_width = width; 178 194 out_height = height; 195 in_width = width; ; 196 in_height = height; 197 179 198 } else { 180 199 … … 183 202 out_width = jQuery(elem).outerWidth(); 184 203 out_height = jQuery(elem).outerHeight(); 204 in_width = jQuery(elem).innerWidth(); 205 in_height = jQuery(elem).innerHeight(); 185 206 elem_parent = elem.parentElement; 186 207 if (typeof elem_parent == "undefined") { 187 208 elem_parent = window; 188 209 } 189 out_width = jQuery(elem).outerWidth(); 190 out_height = jQuery(elem).outerHeight(); 191 in_width = jQuery(elem).innerWidth(); 192 in_height = jQuery(elem).innerHeight(); 210 193 211 if (typeof Css.width != "undefined") 194 212 width = Get_Val_int(Css.width, jQuery(elem_parent).width(), 0); … … 236 254 } else { 237 255 Cl_Position = jQuery(elem).d_position(); 256 257 /* 258 margin: 5px; 259 border: 10px ; 260 padding: 20px; 261 262 */ 263 s_elem = elem; 264 Left = Cl_Position.left; // 291 265 Top = Cl_Position.top; // 812 266 if (Args.pos_absolute == true) { 267 268 all = jQuery(elem).absoluteAll(); 269 270 Top = all.Top; 271 Left = all.Left; 272 Args.pos_externe = false; 273 } 274 275 if (Args.pos_externe == true) { 276 if (elem.tagName != "BODY") { 277 nodeName = nodeName || ""; 278 L1 = jQuery(elem).position(); // sans les marges ; 279 L2 = jQuery(elem).position(true); // 296 x 817 280 Left = L1.left; 281 Top = L1.top; 282 } 283 284 } 285 286 elem = s_elem; 238 287 } 239 Left = Cl_Position.left;240 Top = Cl_Position.top;241 242 288 visible = jQuery(elem).is(':visible'); 243 results = { 244 useMap 289 results = { 290 useMap: elem.useMap || "none", 245 291 src: elem.src || "none", 246 292 visible: visible || false, … … 279 325 margin.bottom + borderwidth.bottom + 280 326 padding.bottom, 281 top:margin.top +327 top: margin.top + 282 328 borderwidth.top + 283 329 padding.top, 284 330 bottom: margin.bottom + 285 331 borderwidth.bottom + 286 332 padding.bottom, 287 width:margin.left +333 width: margin.left + 288 334 borderwidth.left + 289 335 padding.left + … … 291 337 borderwidth.right + 292 338 padding.right, 293 339 left: margin.left + 294 340 borderwidth.left + 295 341 padding.left, 296 342 right: margin.right + 297 343 borderwidth.right + 298 344 padding.right 299 345 } 300 346 }, 301 347 id: id, 302 nodeName: nodeName 348 nodeName: nodeName || "" 303 349 }; 304 350 … … 350 396 */ 351 397 offsetParent: function () { 352 var offsetParent = this[0].offsetParent; 353 while (offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static')) 354 offsetParent = offsetParent.offsetParent; 355 return jQuery(offsetParent); 398 if (this[0] == window) return; 399 try { 400 401 n1 = this[0].nodeName; 402 var offsetParent = this[0].offsetParent; 403 404 while (offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static')) 405 offsetParent = offsetParent.offsetParent; 406 return jQuery(offsetParent); 407 } catch (e) { 408 jQuery(offsetParent); 409 } 356 410 }, 357 411 // getStyles(Obj) Récupérer la valeur CSS … … 485 539 }; 486 540 487 // myjQuery = jQuery;488 // my$ = $;541 // myjQuery = jQuery; 542 // my$ = $; 489 543 490 544 })(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.