[7912] | 1 | /* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) |
---|
| 2 | * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) |
---|
| 3 | * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. |
---|
| 4 | * |
---|
| 5 | * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $ |
---|
| 6 | * $Rev: 4257 $ |
---|
| 7 | * |
---|
| 8 | * $LastChangedDate: 2010-10-23 08:43:48 -0600 (Thu, 20 Dec 2007) $ |
---|
| 9 | * By cljosse |
---|
[16638] | 10 | * Version: 1.3 |
---|
[7912] | 11 | * |
---|
| 12 | * Requires: jQuery 1.2+ |
---|
| 13 | * |
---|
[7867] | 14 | */ |
---|
[7353] | 15 | (function (jQuery) { |
---|
[10845] | 16 | jQuery.dimensions = { version: '1.3' }; |
---|
| 17 | /* |
---|
| 18 | * Interception Height, Width |
---|
| 19 | */ |
---|
| 20 | jQuery.each(['Height', 'Width'], |
---|
[8627] | 21 | function (i, name) { |
---|
[10845] | 22 | jQuery.fn['inner' + name] = function () { |
---|
| 23 | if (!this[0]) return; |
---|
| 24 | var torl = name == 'Height' ? 'Top' : 'Left', |
---|
[8627] | 25 | borr = name == 'Height' ? 'Bottom' : 'Right'; |
---|
[10845] | 26 | return this.is(':visible') ? this[0]['client' + name] : num(this, name.toLowerCase()) + num(this, 'padding' + torl) + num(this, 'padding' + borr); |
---|
| 27 | }; |
---|
[7353] | 28 | |
---|
[10845] | 29 | jQuery.fn['outer' + name] = function (options) { |
---|
| 30 | if (!this[0]) return; |
---|
| 31 | var torl = name == 'Height' ? 'Top' : 'Left', |
---|
[8627] | 32 | borr = name == 'Height' ? 'Bottom' : 'Right'; |
---|
[10845] | 33 | options = options || false; |
---|
| 34 | options = jQuery.extend({ margin: options }); |
---|
[16931] | 35 | Maxi_val = this.parent().width(); |
---|
[10845] | 36 | var val = this.is(':visible') ? this[0]['offset' + name] : |
---|
[8627] | 37 | num(this, |
---|
| 38 | name.toLowerCase()) + |
---|
| 39 | num(this, 'border' + torl + 'Width') + |
---|
| 40 | num(this, 'border' + borr + 'Width') + |
---|
| 41 | num(this, 'padding' + torl) + |
---|
| 42 | num(this, 'padding' + borr) |
---|
[7912] | 43 | |
---|
[8627] | 44 | ; |
---|
[10845] | 45 | return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0); |
---|
| 46 | }; |
---|
[8627] | 47 | }); |
---|
[10845] | 48 | /* |
---|
| 49 | * |
---|
| 50 | */ |
---|
[17192] | 51 | jQuery.each(['Left', 'Top', 'Right', 'Bottom', 'All'], |
---|
[8627] | 52 | function (i, name) { |
---|
[17192] | 53 | //========== scroll ================= |
---|
[10845] | 54 | jQuery.fn['scroll' + name] = function (val) { |
---|
| 55 | if (!this[0]) return; |
---|
| 56 | return val != undefined ? this.each(function () { |
---|
| 57 | this == window || this == document ? window.scrollTo(name == 'Left' ? val : $(window)['scrollLeft'](), |
---|
[8627] | 58 | name == 'Top' ? val : $(window)['scrollTop']()) : this['scroll' + name] = val; |
---|
[10845] | 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]; |
---|
| 60 | }; |
---|
[17192] | 61 | //========= Absolute ===================== |
---|
| 62 | jQuery.fn['absolute' + name] = function (Args) { |
---|
| 63 | if (!this[0]) return 0; |
---|
[10845] | 64 | a = jQuery(this[0]); |
---|
[17192] | 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); |
---|
[7353] | 73 | |
---|
[17192] | 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 { |
---|
[17308] | 82 | |
---|
[17192] | 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 | |
---|
| 89 | |
---|
[10845] | 90 | } |
---|
[8807] | 91 | |
---|
| 92 | |
---|
[17192] | 93 | return m[name]; |
---|
[8807] | 94 | |
---|
| 95 | |
---|
[10845] | 96 | }; |
---|
[8807] | 97 | |
---|
| 98 | |
---|
[8627] | 99 | }); |
---|
[10845] | 100 | //===================================================== |
---|
| 101 | jQuery.fn.extend({ |
---|
[7353] | 102 | |
---|
[17192] | 103 | infos: function (Arguments) { |
---|
[17308] | 104 | if (Arguments) { |
---|
| 105 | if (Arguments == true) { |
---|
[18716] | 106 | Args = { absolute: true || false, externe: Arguments.externe || false }; |
---|
[17308] | 107 | } else { |
---|
[18716] | 108 | Args = { absolute: Arguments.absolute || false, externe: Arguments.externe || false }; |
---|
[17308] | 109 | } |
---|
| 110 | } else { |
---|
[18716] | 111 | Args = { absolute: false, externe: false }; |
---|
[17192] | 112 | } |
---|
| 113 | |
---|
[17308] | 114 | |
---|
[10845] | 115 | var width = 0, height = 0; |
---|
| 116 | var elem = jQuery(this).get(0); |
---|
[7353] | 117 | |
---|
| 118 | |
---|
[22218] | 119 | var Left = 0, Top = 0, results; |
---|
[10845] | 120 | var borderwidth = { width: "0 0 0 0", |
---|
| 121 | top: 0, |
---|
| 122 | left: 0, |
---|
| 123 | right: 0, |
---|
| 124 | bottom: 0 |
---|
[22218] | 125 | }; |
---|
[10845] | 126 | var padding = { padding: "0 0 0 0", |
---|
| 127 | top: 0, |
---|
| 128 | left: 0, |
---|
| 129 | right: 0, |
---|
| 130 | bottom: 0 |
---|
| 131 | }; |
---|
| 132 | var margin = { margin: "0 0 0 0", |
---|
| 133 | top: 0, |
---|
| 134 | left: 0, |
---|
| 135 | right: 0, |
---|
| 136 | bottom: 0 |
---|
| 137 | }; |
---|
| 138 | //===================================================================== |
---|
| 139 | myposition = ""; |
---|
| 140 | results = { |
---|
[17192] | 141 | visible: false, |
---|
[10845] | 142 | position: "", |
---|
| 143 | top: 0, |
---|
| 144 | left: 0, |
---|
| 145 | width: 0, |
---|
| 146 | height: 0, |
---|
| 147 | right: 0, |
---|
| 148 | bottom: 0, |
---|
| 149 | borderwidth: borderwidth, |
---|
| 150 | padding: padding, |
---|
[16931] | 151 | margin: margin, |
---|
| 152 | |
---|
| 153 | out: { |
---|
| 154 | width: 0, |
---|
| 155 | height: 0, |
---|
| 156 | right: 0, |
---|
| 157 | bottom: 0 |
---|
| 158 | }, |
---|
[17192] | 159 | |
---|
[16931] | 160 | exterieur: { |
---|
| 161 | width: 0, |
---|
| 162 | height: 0, |
---|
| 163 | right: 0, |
---|
| 164 | bottom: 0 |
---|
| 165 | }, |
---|
[17192] | 166 | |
---|
[16931] | 167 | general: { |
---|
| 168 | width: 0, |
---|
| 169 | height: 0, |
---|
| 170 | right: 0, |
---|
| 171 | bottom: 0, |
---|
[17192] | 172 | marges: { height: 0, |
---|
| 173 | top: 0, |
---|
| 174 | bottom: 0, |
---|
| 175 | width: 0, |
---|
| 176 | left: 0, |
---|
| 177 | right: 0 |
---|
| 178 | } |
---|
| 179 | }, |
---|
| 180 | src: "", |
---|
| 181 | useMap: "", |
---|
[16931] | 182 | id: "", |
---|
| 183 | nodeName: "" |
---|
[10845] | 184 | }; |
---|
| 185 | ; |
---|
| 186 | if (elem) { |
---|
| 187 | id = ""; nodeName = ""; |
---|
| 188 | if (elem.id) id = elem.id; |
---|
| 189 | if (elem.nodeName) nodeName = elem.nodeName; |
---|
[7805] | 190 | |
---|
[16638] | 191 | width = jQuery(elem).width(); |
---|
| 192 | height = jQuery(elem).height(); |
---|
[10845] | 193 | if (elem == window) { |
---|
[7867] | 194 | |
---|
[10845] | 195 | myposition = ""; |
---|
[17503] | 196 | var myWidth = 0, myHeight = 0; |
---|
[17192] | 197 | |
---|
[17503] | 198 | var x2Height = jQuery(window).height(); |
---|
| 199 | |
---|
| 200 | if (typeof (window.innerWidth) == 'number') { |
---|
| 201 | //Non-IE |
---|
| 202 | myWidth = window.innerWidth; |
---|
| 203 | myHeight = window.innerHeight; |
---|
| 204 | } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { |
---|
| 205 | //IE 6+ in 'standards compliant mode' |
---|
| 206 | myWidth = document.documentElement.clientWidth; |
---|
| 207 | myHeight = document.documentElement.clientHeight; |
---|
| 208 | } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { |
---|
| 209 | //IE 4 compatible |
---|
| 210 | myWidth = document.body.clientWidth; |
---|
| 211 | myHeight = document.body.clientHeight; |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | if (myHeight != x2Height) { |
---|
| 215 | width = myWidth; |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | width = myWidth; |
---|
| 219 | height = myHeight; |
---|
| 220 | out_width = myWidth; |
---|
| 221 | out_height = myHeight; |
---|
| 222 | in_width = myWidth; ; |
---|
| 223 | in_height = myHeight; |
---|
| 224 | |
---|
[10845] | 225 | } else { |
---|
[8729] | 226 | |
---|
[10845] | 227 | Css = jQuery(elem).getStyles(elem); |
---|
| 228 | myposition = Css.position.toString() || ""; |
---|
[16638] | 229 | out_width = jQuery(elem).outerWidth(); |
---|
| 230 | out_height = jQuery(elem).outerHeight(); |
---|
[17192] | 231 | in_width = jQuery(elem).innerWidth(); |
---|
| 232 | in_height = jQuery(elem).innerHeight(); |
---|
[16931] | 233 | elem_parent = elem.parentElement; |
---|
[11961] | 234 | if (typeof elem_parent == "undefined") { |
---|
| 235 | elem_parent = window; |
---|
| 236 | } |
---|
[17192] | 237 | |
---|
[11961] | 238 | if (typeof Css.width != "undefined") |
---|
[16638] | 239 | width = Get_Val_int(Css.width, jQuery(elem_parent).width(), 0); |
---|
[7353] | 240 | |
---|
[11961] | 241 | if (typeof Css.height != "undefined") |
---|
[16638] | 242 | height = Get_Val_int(Css.height, jQuery(elem_parent).height(), 0); |
---|
[7353] | 243 | |
---|
[11961] | 244 | |
---|
[16638] | 245 | borderwidth.left = Get_Val_int(Css.borderLeftWidth, "", "", { elem: elem, prop: 'borderLeftWidth' }); |
---|
| 246 | borderwidth.right = Get_Val_int(Css.borderRightWidth, "", "", { elem: elem, prop: 'borderRightWidth' }); |
---|
| 247 | borderwidth.top = Get_Val_int(Css.borderTopWidth, "", "", { elem: elem, prop: 'borderTopWidth' }); |
---|
| 248 | borderwidth.bottom = Get_Val_int(Css.borderBottomWidth, "", "", { elem: elem, prop: 'borderBottomWidth' }); |
---|
[10845] | 249 | try { |
---|
| 250 | borderwidth.width = Css.borderWidth; |
---|
| 251 | } catch (e) { |
---|
| 252 | borderwidth.width = '"' + borderwidth.left + ' ' + borderwidth.top + ' ' + borderwidth.right + ' ' + borderwidth.bottom + '"'; |
---|
| 253 | } |
---|
[7805] | 254 | |
---|
[16638] | 255 | margin.left = Get_Val_int(Css.marginLeft, "", "", { elem: elem, prop: 'marginLeft' }); |
---|
| 256 | margin.right = Get_Val_int(Css.marginRight, "", "", { elem: elem, prop: 'marginRight' }); |
---|
| 257 | margin.top = Get_Val_int(Css.marginTop, "", "", { elem: elem, prop: 'marginTop' }); |
---|
| 258 | margin.bottom = Get_Val_int(Css.marginBottom, "", "", { elem: elem, prop: 'marginBottom' }); |
---|
[8536] | 259 | |
---|
[8729] | 260 | |
---|
[10845] | 261 | try { |
---|
| 262 | margin.margin = Css.margin; |
---|
| 263 | } catch (e) { |
---|
| 264 | margin.margin = '"' + margin.left + ' ' + margin.top + ' ' + margin.right + ' ' + margin.bottom + '"'; |
---|
| 265 | } |
---|
[8729] | 266 | |
---|
| 267 | |
---|
[16638] | 268 | padding.left = Get_Val_int(Css.paddingLeft, "", "", { elem: elem, prop: 'paddingLeft' }); |
---|
| 269 | padding.right = Get_Val_int(Css.paddingRight, "", "", { elem: elem, prop: 'paddingRight' }); |
---|
| 270 | padding.top = Get_Val_int(Css.paddingTop, "", "", { elem: elem, prop: 'paddingTop' }); |
---|
| 271 | padding.bottom = Get_Val_int(Css.paddingBottom, "", "", { elem: elem, prop: 'paddingBottom' }); |
---|
[7816] | 272 | |
---|
[10845] | 273 | try { |
---|
| 274 | padding.padding = Css.padding; |
---|
| 275 | } catch (e) { |
---|
| 276 | padding.padding = '"' + padding.left + ' ' + padding.top + ' ' + padding.right + ' ' + padding.bottom + '"'; |
---|
| 277 | } |
---|
| 278 | } |
---|
| 279 | if (elem == window) { |
---|
[11277] | 280 | Cl_Position = { top: 0, left: 0 }; |
---|
[10845] | 281 | } else { |
---|
| 282 | Cl_Position = jQuery(elem).d_position(); |
---|
[17192] | 283 | |
---|
| 284 | /* |
---|
| 285 | margin: 5px; |
---|
| 286 | border: 10px ; |
---|
| 287 | padding: 20px; |
---|
| 288 | |
---|
| 289 | */ |
---|
| 290 | s_elem = elem; |
---|
| 291 | Left = Cl_Position.left; // 291 |
---|
| 292 | Top = Cl_Position.top; // 812 |
---|
[18716] | 293 | if (Args.absolute == true) { |
---|
[17192] | 294 | |
---|
| 295 | all = jQuery(elem).absoluteAll(); |
---|
| 296 | |
---|
| 297 | Top = all.Top; |
---|
| 298 | Left = all.Left; |
---|
[18716] | 299 | Args.externe = false; |
---|
[17192] | 300 | } |
---|
| 301 | |
---|
[18716] | 302 | if (Args.externe == true) { |
---|
[17192] | 303 | if (elem.tagName != "BODY") { |
---|
| 304 | nodeName = nodeName || ""; |
---|
| 305 | L1 = jQuery(elem).position(); // sans les marges ; |
---|
| 306 | L2 = jQuery(elem).position(true); // 296 x 817 |
---|
| 307 | Left = L1.left; |
---|
| 308 | Top = L1.top; |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | } |
---|
| 312 | |
---|
| 313 | elem = s_elem; |
---|
[10845] | 314 | } |
---|
[16931] | 315 | visible = jQuery(elem).is(':visible'); |
---|
[17192] | 316 | results = { |
---|
| 317 | useMap: elem.useMap || "none", |
---|
[16931] | 318 | src: elem.src || "none", |
---|
[16638] | 319 | visible: visible || false, |
---|
[10845] | 320 | position: myposition, |
---|
| 321 | top: Top, |
---|
| 322 | left: Left, |
---|
[16638] | 323 | width: width, // valeur interieur |
---|
[10845] | 324 | height: height, |
---|
| 325 | right: Left + width, |
---|
| 326 | bottom: Top + height, |
---|
[16638] | 327 | |
---|
| 328 | padding: padding, |
---|
| 329 | |
---|
| 330 | out: { |
---|
| 331 | width: in_width, |
---|
| 332 | height: in_height, |
---|
| 333 | right: Left + in_width, |
---|
| 334 | bottom: Top + in_height |
---|
| 335 | }, |
---|
[10845] | 336 | borderwidth: borderwidth, |
---|
[16638] | 337 | exterieur: { |
---|
| 338 | width: out_width, |
---|
| 339 | height: out_height, |
---|
| 340 | right: Left + out_width, |
---|
| 341 | bottom: Top + out_height |
---|
| 342 | }, |
---|
[10845] | 343 | margin: margin, |
---|
[16638] | 344 | general: { |
---|
| 345 | width: out_width + margin.left + margin.right, |
---|
| 346 | height: out_height + margin.top + margin.bottom, |
---|
| 347 | right: Left + out_width + margin.left + margin.right, |
---|
| 348 | bottom: Top + out_height + margin.top + margin.bottom, |
---|
[16931] | 349 | marges: { height: margin.top + |
---|
| 350 | borderwidth.top + |
---|
| 351 | padding.top + |
---|
| 352 | margin.bottom + borderwidth.bottom + |
---|
| 353 | padding.bottom, |
---|
[17192] | 354 | top: margin.top + |
---|
[16931] | 355 | borderwidth.top + |
---|
| 356 | padding.top, |
---|
[17192] | 357 | bottom: margin.bottom + |
---|
[16931] | 358 | borderwidth.bottom + |
---|
| 359 | padding.bottom, |
---|
[17192] | 360 | width: margin.left + |
---|
[16931] | 361 | borderwidth.left + |
---|
| 362 | padding.left + |
---|
| 363 | margin.right + |
---|
| 364 | borderwidth.right + |
---|
| 365 | padding.right, |
---|
[17192] | 366 | left: margin.left + |
---|
[16931] | 367 | borderwidth.left + |
---|
| 368 | padding.left, |
---|
[17192] | 369 | right: margin.right + |
---|
[16931] | 370 | borderwidth.right + |
---|
| 371 | padding.right |
---|
[17192] | 372 | } |
---|
[16638] | 373 | }, |
---|
[10845] | 374 | id: id, |
---|
[17192] | 375 | nodeName: nodeName || "" |
---|
[10845] | 376 | }; |
---|
[7702] | 377 | |
---|
[22218] | 378 | return results; |
---|
[10845] | 379 | } return results; |
---|
| 380 | }, |
---|
| 381 | /* |
---|
| 382 | * Cl_Position de l'object elem |
---|
| 383 | */ |
---|
| 384 | d_position: function () { |
---|
[22218] | 385 | var elem = this[0], offset, parentOffset, offsetParent, results=null; |
---|
[11277] | 386 | l1 = jQuery(elem).css("left"); |
---|
[10845] | 387 | if (elem) { |
---|
| 388 | offsetParent = this.offsetParent(); |
---|
| 389 | offset = this.offset(); |
---|
[18716] | 390 | offset_j = jQuery(this).offset(); |
---|
[7353] | 391 | |
---|
[18716] | 392 | |
---|
[10845] | 393 | if (offsetParent) { |
---|
| 394 | if (elem == window) { |
---|
| 395 | parentOffset = { top: 0, left: 0 }; |
---|
| 396 | } else if (typeof (offsetParent.offset) != "undefined") |
---|
| 397 | parentOffset = offsetParent.offset(); |
---|
| 398 | else |
---|
| 399 | parentOffset = { top: 0, left: 0 }; |
---|
[7702] | 400 | |
---|
[10845] | 401 | if (!offset) |
---|
| 402 | offset = { top: 0, left: 0 }; |
---|
[7353] | 403 | |
---|
[10845] | 404 | offset.top -= num(elem, 'marginTop'); |
---|
| 405 | offset.left -= num(elem, 'marginLeft'); |
---|
[7353] | 406 | |
---|
[10845] | 407 | if (offsetParent.length > 0) { |
---|
| 408 | parentOffset.top += num(offsetParent, 'borderTopWidth'); |
---|
| 409 | parentOffset.left += num(offsetParent, 'borderLeftWidth'); |
---|
| 410 | } else { |
---|
| 411 | parentOffset = { top: 0, left: 0 }; |
---|
[7816] | 412 | |
---|
[10845] | 413 | } |
---|
| 414 | } else { |
---|
| 415 | parentOffset = { top: 0, left: 0 }; |
---|
| 416 | } |
---|
[8536] | 417 | |
---|
[10845] | 418 | results = { |
---|
| 419 | top: Math.ceil(offset.top - parentOffset.top), left: Math.ceil(offset.left - parentOffset.left) |
---|
| 420 | }; |
---|
| 421 | } return results; |
---|
| 422 | }, |
---|
| 423 | /* |
---|
| 424 | * offsetParent |
---|
| 425 | */ |
---|
| 426 | offsetParent: function () { |
---|
[22218] | 427 | var offsetParent = null; |
---|
[17192] | 428 | if (this[0] == window) return; |
---|
| 429 | try { |
---|
| 430 | |
---|
| 431 | n1 = this[0].nodeName; |
---|
[22218] | 432 | offsetParent = this[0].offsetParent; |
---|
[17192] | 433 | |
---|
| 434 | while (offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static')) |
---|
| 435 | offsetParent = offsetParent.offsetParent; |
---|
| 436 | return jQuery(offsetParent); |
---|
| 437 | } catch (e) { |
---|
| 438 | jQuery(offsetParent); |
---|
| 439 | } |
---|
[10845] | 440 | }, |
---|
| 441 | // getStyles(Obj) Récupérer la valeur CSS |
---|
| 442 | getStyles: function (elt) { |
---|
[12683] | 443 | var element = jQuery(elt).get(0); |
---|
| 444 | propriete = []; |
---|
[16931] | 445 | try { |
---|
| 446 | if (jQuery(element).length > 0) |
---|
| 447 | if (window.getComputedStyle) // Mozilla Firefox & cie |
---|
| 448 | { |
---|
[22218] | 449 | propriete = window.getComputedStyle(element, null); |
---|
[16931] | 450 | } |
---|
| 451 | else if (element.currentStyle) // Microsoft Internet Explorer |
---|
| 452 | { |
---|
[22218] | 453 | propriete = element.currentStyle; |
---|
[16931] | 454 | } |
---|
| 455 | } catch (e) { |
---|
| 456 | |
---|
[10845] | 457 | } |
---|
| 458 | return propriete; |
---|
| 459 | }, |
---|
[16638] | 460 | Get_Val_int: function (myObj, Maxi_val, Mini_val, prop) { |
---|
| 461 | |
---|
| 462 | return Get_Val_int(myObj, Maxi_val, Mini_val, prop); |
---|
| 463 | } |
---|
| 464 | }); |
---|
| 465 | |
---|
| 466 | /************************** |
---|
[16931] | 467 | * Get_val_int |
---|
| 468 | * params: element,valeur maxi |
---|
| 469 | * return: valeur entiere |
---|
[16638] | 470 | ******************************/ |
---|
| 471 | Get_Val_int = function (myObj, Maxi_val, Mini_val, prop) { |
---|
[7394] | 472 | |
---|
[16931] | 473 | var val = 0; |
---|
| 474 | Maxi_val = parseInt(Maxi_val || "0"); |
---|
[7394] | 475 | |
---|
[16931] | 476 | /* |
---|
| 477 | - numérique suivie de px ou % ou pt ou em, |
---|
| 478 | - thin, bordure mince, |
---|
| 479 | - medium, bordure moyenne (valeur par défaut), |
---|
| 480 | - thick, bordure épaisse, |
---|
| 481 | - inherit, hérite de son parent (css2). |
---|
| 482 | */ |
---|
[7816] | 483 | |
---|
[16931] | 484 | if (!myObj) { |
---|
| 485 | return Maxi_val; |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | if (typeof (myObj) == "string") { |
---|
| 489 | switch (myObj) { |
---|
| 490 | case 'thin': |
---|
| 491 | return 1; |
---|
| 492 | break; |
---|
| 493 | case 'medium': |
---|
| 494 | return 2; |
---|
| 495 | break; |
---|
| 496 | case 'thick': |
---|
| 497 | return 4; |
---|
| 498 | break; |
---|
| 499 | case 'inherit': |
---|
| 500 | break; |
---|
| 501 | case 'none': |
---|
| 502 | return Maxi_val; |
---|
| 503 | break; |
---|
| 504 | default: |
---|
| 505 | break; |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | var reg1 = new RegExp("auto", "g"); |
---|
| 509 | if (myObj.match(reg1)) { |
---|
[10845] | 510 | return Maxi_val; |
---|
| 511 | } |
---|
[7394] | 512 | |
---|
[16638] | 513 | if (prop) { |
---|
| 514 | |
---|
| 515 | myObj = num(prop.elem, prop.prop); |
---|
| 516 | } else { |
---|
[16931] | 517 | reg1 = new RegExp("px", "g"); |
---|
| 518 | if (myObj.match(reg1)) { |
---|
[7394] | 519 | |
---|
[16638] | 520 | myObj = Parse_Int(myObj); |
---|
[7394] | 521 | |
---|
[16931] | 522 | } else { |
---|
| 523 | reg1 = new RegExp("%", "g"); |
---|
| 524 | if (myObj.match(reg1)) { |
---|
| 525 | myObj = myObj.replace(reg1, ""); |
---|
| 526 | val = Math.ceil(myObj * Maxi_val / 100); |
---|
| 527 | return val; |
---|
[10845] | 528 | } |
---|
| 529 | } |
---|
[16931] | 530 | } |
---|
| 531 | if (Mini_val) |
---|
| 532 | if (myObj < Mini_val) return Maxi_val; |
---|
[16638] | 533 | val = Parse_Int(myObj); |
---|
[8729] | 534 | |
---|
[16931] | 535 | } else { |
---|
[16638] | 536 | val = Parse_Int(myObj); |
---|
[16931] | 537 | } |
---|
[16638] | 538 | if (typeof (val) == "NaN") |
---|
| 539 | return Maxi_val; |
---|
[16931] | 540 | return val; |
---|
[16638] | 541 | |
---|
[22218] | 542 | }; |
---|
[16638] | 543 | |
---|
[10845] | 544 | /* |
---|
| 545 | * |
---|
| 546 | */ |
---|
[16638] | 547 | function Parse_Int(valeur_num) { |
---|
[16931] | 548 | if (!jQuery.isNumeric(valeur_num)) { |
---|
| 549 | valeur_num = valeur_num.toString(); |
---|
| 550 | reg1 = new RegExp("px", "gi"); |
---|
| 551 | if (valeur_num.match(reg1)) { |
---|
[16638] | 552 | valeur_num = valeur_num.replace(reg1, ""); |
---|
[16931] | 553 | } if (valeur_num.match(RegExp("%", "gi"))) { |
---|
[16638] | 554 | valeur_num = valeur_num.replace(reg1, ""); |
---|
[16931] | 555 | valeur_num = Math.ceil(valeur_num * Maxi_val / 100); |
---|
| 556 | } else { |
---|
| 557 | valeur_num = valeur_num.replace(reg1, ""); |
---|
| 558 | } |
---|
[16638] | 559 | } |
---|
[22218] | 560 | valeur_num = Math.ceil(valeur_num)|| 0; |
---|
| 561 | return valeur_num ; |
---|
[16638] | 562 | } |
---|
| 563 | |
---|
[10845] | 564 | function num(el, prop) { |
---|
[16638] | 565 | |
---|
[22116] | 566 | valeur_num = jQuery.css(el.jquery ? el[0] : el, prop, true); |
---|
| 567 | |
---|
[16638] | 568 | return Parse_Int(valeur_num); |
---|
[10845] | 569 | }; |
---|
[7394] | 570 | |
---|
[17192] | 571 | // myjQuery = jQuery; |
---|
| 572 | // my$ = $; |
---|
[10845] | 573 | |
---|
[7353] | 574 | })(jQuery); |
---|