[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 | |
---|
[10845] | 119 | var Left = 0, Top = 0, offset, parentOffset, offsetParent, results; |
---|
| 120 | var borderwidth = { width: "0 0 0 0", |
---|
| 121 | top: 0, |
---|
| 122 | left: 0, |
---|
| 123 | right: 0, |
---|
| 124 | bottom: 0 |
---|
| 125 | } |
---|
| 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 xHeight = jQuery(document).height(); |
---|
| 199 | var x2Height = jQuery(window).height(); |
---|
| 200 | |
---|
| 201 | if (typeof (window.innerWidth) == 'number') { |
---|
| 202 | //Non-IE |
---|
| 203 | myWidth = window.innerWidth; |
---|
| 204 | myHeight = window.innerHeight; |
---|
| 205 | } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { |
---|
| 206 | //IE 6+ in 'standards compliant mode' |
---|
| 207 | myWidth = document.documentElement.clientWidth; |
---|
| 208 | myHeight = document.documentElement.clientHeight; |
---|
| 209 | } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { |
---|
| 210 | //IE 4 compatible |
---|
| 211 | myWidth = document.body.clientWidth; |
---|
| 212 | myHeight = document.body.clientHeight; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | if (myHeight != x2Height) { |
---|
| 216 | width = myWidth; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | width = myWidth; |
---|
| 220 | height = myHeight; |
---|
| 221 | out_width = myWidth; |
---|
| 222 | out_height = myHeight; |
---|
| 223 | in_width = myWidth; ; |
---|
| 224 | in_height = myHeight; |
---|
| 225 | |
---|
[10845] | 226 | } else { |
---|
[8729] | 227 | |
---|
[10845] | 228 | Css = jQuery(elem).getStyles(elem); |
---|
| 229 | myposition = Css.position.toString() || ""; |
---|
[16638] | 230 | out_width = jQuery(elem).outerWidth(); |
---|
| 231 | out_height = jQuery(elem).outerHeight(); |
---|
[17192] | 232 | in_width = jQuery(elem).innerWidth(); |
---|
| 233 | in_height = jQuery(elem).innerHeight(); |
---|
[16931] | 234 | elem_parent = elem.parentElement; |
---|
[11961] | 235 | if (typeof elem_parent == "undefined") { |
---|
| 236 | elem_parent = window; |
---|
| 237 | } |
---|
[17192] | 238 | |
---|
[11961] | 239 | if (typeof Css.width != "undefined") |
---|
[16638] | 240 | width = Get_Val_int(Css.width, jQuery(elem_parent).width(), 0); |
---|
[7353] | 241 | |
---|
[11961] | 242 | if (typeof Css.height != "undefined") |
---|
[16638] | 243 | height = Get_Val_int(Css.height, jQuery(elem_parent).height(), 0); |
---|
[7353] | 244 | |
---|
[11961] | 245 | |
---|
[16638] | 246 | borderwidth.left = Get_Val_int(Css.borderLeftWidth, "", "", { elem: elem, prop: 'borderLeftWidth' }); |
---|
| 247 | borderwidth.right = Get_Val_int(Css.borderRightWidth, "", "", { elem: elem, prop: 'borderRightWidth' }); |
---|
| 248 | borderwidth.top = Get_Val_int(Css.borderTopWidth, "", "", { elem: elem, prop: 'borderTopWidth' }); |
---|
| 249 | borderwidth.bottom = Get_Val_int(Css.borderBottomWidth, "", "", { elem: elem, prop: 'borderBottomWidth' }); |
---|
[10845] | 250 | try { |
---|
| 251 | borderwidth.width = Css.borderWidth; |
---|
| 252 | } catch (e) { |
---|
| 253 | borderwidth.width = '"' + borderwidth.left + ' ' + borderwidth.top + ' ' + borderwidth.right + ' ' + borderwidth.bottom + '"'; |
---|
| 254 | } |
---|
[7805] | 255 | |
---|
[16638] | 256 | margin.left = Get_Val_int(Css.marginLeft, "", "", { elem: elem, prop: 'marginLeft' }); |
---|
| 257 | margin.right = Get_Val_int(Css.marginRight, "", "", { elem: elem, prop: 'marginRight' }); |
---|
| 258 | margin.top = Get_Val_int(Css.marginTop, "", "", { elem: elem, prop: 'marginTop' }); |
---|
| 259 | margin.bottom = Get_Val_int(Css.marginBottom, "", "", { elem: elem, prop: 'marginBottom' }); |
---|
[8536] | 260 | |
---|
[8729] | 261 | |
---|
[10845] | 262 | try { |
---|
| 263 | margin.margin = Css.margin; |
---|
| 264 | } catch (e) { |
---|
| 265 | margin.margin = '"' + margin.left + ' ' + margin.top + ' ' + margin.right + ' ' + margin.bottom + '"'; |
---|
| 266 | } |
---|
[8729] | 267 | |
---|
| 268 | |
---|
[16638] | 269 | padding.left = Get_Val_int(Css.paddingLeft, "", "", { elem: elem, prop: 'paddingLeft' }); |
---|
| 270 | padding.right = Get_Val_int(Css.paddingRight, "", "", { elem: elem, prop: 'paddingRight' }); |
---|
| 271 | padding.top = Get_Val_int(Css.paddingTop, "", "", { elem: elem, prop: 'paddingTop' }); |
---|
| 272 | padding.bottom = Get_Val_int(Css.paddingBottom, "", "", { elem: elem, prop: 'paddingBottom' }); |
---|
[7816] | 273 | |
---|
[10845] | 274 | try { |
---|
| 275 | padding.padding = Css.padding; |
---|
| 276 | } catch (e) { |
---|
| 277 | padding.padding = '"' + padding.left + ' ' + padding.top + ' ' + padding.right + ' ' + padding.bottom + '"'; |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | if (elem == window) { |
---|
[11277] | 281 | Cl_Position = { top: 0, left: 0 }; |
---|
[10845] | 282 | } else { |
---|
| 283 | Cl_Position = jQuery(elem).d_position(); |
---|
[17192] | 284 | |
---|
| 285 | /* |
---|
| 286 | margin: 5px; |
---|
| 287 | border: 10px ; |
---|
| 288 | padding: 20px; |
---|
| 289 | |
---|
| 290 | */ |
---|
| 291 | s_elem = elem; |
---|
| 292 | Left = Cl_Position.left; // 291 |
---|
| 293 | Top = Cl_Position.top; // 812 |
---|
[18716] | 294 | if (Args.absolute == true) { |
---|
[17192] | 295 | |
---|
| 296 | all = jQuery(elem).absoluteAll(); |
---|
| 297 | |
---|
| 298 | Top = all.Top; |
---|
| 299 | Left = all.Left; |
---|
[18716] | 300 | Args.externe = false; |
---|
[17192] | 301 | } |
---|
| 302 | |
---|
[18716] | 303 | if (Args.externe == true) { |
---|
[17192] | 304 | if (elem.tagName != "BODY") { |
---|
| 305 | nodeName = nodeName || ""; |
---|
| 306 | L1 = jQuery(elem).position(); // sans les marges ; |
---|
| 307 | L2 = jQuery(elem).position(true); // 296 x 817 |
---|
| 308 | Left = L1.left; |
---|
| 309 | Top = L1.top; |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | elem = s_elem; |
---|
[10845] | 315 | } |
---|
[16931] | 316 | visible = jQuery(elem).is(':visible'); |
---|
[17192] | 317 | results = { |
---|
| 318 | useMap: elem.useMap || "none", |
---|
[16931] | 319 | src: elem.src || "none", |
---|
[16638] | 320 | visible: visible || false, |
---|
[10845] | 321 | position: myposition, |
---|
| 322 | top: Top, |
---|
| 323 | left: Left, |
---|
[16638] | 324 | width: width, // valeur interieur |
---|
[10845] | 325 | height: height, |
---|
| 326 | right: Left + width, |
---|
| 327 | bottom: Top + height, |
---|
[16638] | 328 | |
---|
| 329 | padding: padding, |
---|
| 330 | |
---|
| 331 | out: { |
---|
| 332 | width: in_width, |
---|
| 333 | height: in_height, |
---|
| 334 | right: Left + in_width, |
---|
| 335 | bottom: Top + in_height |
---|
| 336 | }, |
---|
[10845] | 337 | borderwidth: borderwidth, |
---|
[16638] | 338 | exterieur: { |
---|
| 339 | width: out_width, |
---|
| 340 | height: out_height, |
---|
| 341 | right: Left + out_width, |
---|
| 342 | bottom: Top + out_height |
---|
| 343 | }, |
---|
[10845] | 344 | margin: margin, |
---|
[16638] | 345 | general: { |
---|
| 346 | width: out_width + margin.left + margin.right, |
---|
| 347 | height: out_height + margin.top + margin.bottom, |
---|
| 348 | right: Left + out_width + margin.left + margin.right, |
---|
| 349 | bottom: Top + out_height + margin.top + margin.bottom, |
---|
[16931] | 350 | marges: { height: margin.top + |
---|
| 351 | borderwidth.top + |
---|
| 352 | padding.top + |
---|
| 353 | margin.bottom + borderwidth.bottom + |
---|
| 354 | padding.bottom, |
---|
[17192] | 355 | top: margin.top + |
---|
[16931] | 356 | borderwidth.top + |
---|
| 357 | padding.top, |
---|
[17192] | 358 | bottom: margin.bottom + |
---|
[16931] | 359 | borderwidth.bottom + |
---|
| 360 | padding.bottom, |
---|
[17192] | 361 | width: margin.left + |
---|
[16931] | 362 | borderwidth.left + |
---|
| 363 | padding.left + |
---|
| 364 | margin.right + |
---|
| 365 | borderwidth.right + |
---|
| 366 | padding.right, |
---|
[17192] | 367 | left: margin.left + |
---|
[16931] | 368 | borderwidth.left + |
---|
| 369 | padding.left, |
---|
[17192] | 370 | right: margin.right + |
---|
[16931] | 371 | borderwidth.right + |
---|
| 372 | padding.right |
---|
[17192] | 373 | } |
---|
[16638] | 374 | }, |
---|
[10845] | 375 | id: id, |
---|
[17192] | 376 | nodeName: nodeName || "" |
---|
[10845] | 377 | }; |
---|
[7702] | 378 | |
---|
[10845] | 379 | return results |
---|
| 380 | } return results; |
---|
| 381 | }, |
---|
| 382 | /* |
---|
| 383 | * Cl_Position de l'object elem |
---|
| 384 | */ |
---|
| 385 | d_position: function () { |
---|
| 386 | var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results; |
---|
[11277] | 387 | l1 = jQuery(elem).css("left"); |
---|
[10845] | 388 | if (elem) { |
---|
| 389 | offsetParent = this.offsetParent(); |
---|
| 390 | offset = this.offset(); |
---|
[18716] | 391 | offset_j = jQuery(this).offset(); |
---|
[7353] | 392 | |
---|
[18716] | 393 | |
---|
[10845] | 394 | if (offsetParent) { |
---|
| 395 | if (elem == window) { |
---|
| 396 | parentOffset = { top: 0, left: 0 }; |
---|
| 397 | } else if (typeof (offsetParent.offset) != "undefined") |
---|
| 398 | parentOffset = offsetParent.offset(); |
---|
| 399 | else |
---|
| 400 | parentOffset = { top: 0, left: 0 }; |
---|
[7702] | 401 | |
---|
[10845] | 402 | if (!offset) |
---|
| 403 | offset = { top: 0, left: 0 }; |
---|
[7353] | 404 | |
---|
[10845] | 405 | offset.top -= num(elem, 'marginTop'); |
---|
| 406 | offset.left -= num(elem, 'marginLeft'); |
---|
[7353] | 407 | |
---|
[10845] | 408 | if (offsetParent.length > 0) { |
---|
| 409 | parentOffset.top += num(offsetParent, 'borderTopWidth'); |
---|
| 410 | parentOffset.left += num(offsetParent, 'borderLeftWidth'); |
---|
| 411 | } else { |
---|
| 412 | parentOffset = { top: 0, left: 0 }; |
---|
[7816] | 413 | |
---|
[10845] | 414 | } |
---|
| 415 | } else { |
---|
| 416 | parentOffset = { top: 0, left: 0 }; |
---|
| 417 | } |
---|
[8536] | 418 | |
---|
[10845] | 419 | results = { |
---|
| 420 | top: Math.ceil(offset.top - parentOffset.top), left: Math.ceil(offset.left - parentOffset.left) |
---|
| 421 | }; |
---|
| 422 | } return results; |
---|
| 423 | }, |
---|
| 424 | /* |
---|
| 425 | * offsetParent |
---|
| 426 | */ |
---|
| 427 | offsetParent: function () { |
---|
[17192] | 428 | if (this[0] == window) return; |
---|
| 429 | try { |
---|
| 430 | |
---|
| 431 | n1 = this[0].nodeName; |
---|
| 432 | var offsetParent = this[0].offsetParent; |
---|
| 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 | { |
---|
| 449 | var propriete = window.getComputedStyle(element, null); |
---|
| 450 | } |
---|
| 451 | else if (element.currentStyle) // Microsoft Internet Explorer |
---|
| 452 | { |
---|
[7394] | 453 | |
---|
[16931] | 454 | var propriete = element.currentStyle; |
---|
| 455 | } |
---|
| 456 | } catch (e) { |
---|
| 457 | |
---|
[10845] | 458 | } |
---|
| 459 | return propriete; |
---|
| 460 | }, |
---|
[16638] | 461 | Get_Val_int: function (myObj, Maxi_val, Mini_val, prop) { |
---|
| 462 | |
---|
| 463 | return Get_Val_int(myObj, Maxi_val, Mini_val, prop); |
---|
| 464 | } |
---|
| 465 | }); |
---|
| 466 | |
---|
| 467 | /************************** |
---|
[16931] | 468 | * Get_val_int |
---|
| 469 | * params: element,valeur maxi |
---|
| 470 | * return: valeur entiere |
---|
[16638] | 471 | ******************************/ |
---|
| 472 | Get_Val_int = function (myObj, Maxi_val, Mini_val, prop) { |
---|
[7394] | 473 | |
---|
[16931] | 474 | var val = 0; |
---|
| 475 | Maxi_val = parseInt(Maxi_val || "0"); |
---|
[7394] | 476 | |
---|
[16931] | 477 | /* |
---|
| 478 | - numérique suivie de px ou % ou pt ou em, |
---|
| 479 | - thin, bordure mince, |
---|
| 480 | - medium, bordure moyenne (valeur par défaut), |
---|
| 481 | - thick, bordure épaisse, |
---|
| 482 | - inherit, hérite de son parent (css2). |
---|
| 483 | */ |
---|
[7816] | 484 | |
---|
[16931] | 485 | if (!myObj) { |
---|
| 486 | return Maxi_val; |
---|
| 487 | } |
---|
| 488 | |
---|
| 489 | if (typeof (myObj) == "string") { |
---|
| 490 | switch (myObj) { |
---|
| 491 | case 'thin': |
---|
| 492 | return 1; |
---|
| 493 | break; |
---|
| 494 | case 'medium': |
---|
| 495 | return 2; |
---|
| 496 | break; |
---|
| 497 | case 'thick': |
---|
| 498 | return 4; |
---|
| 499 | break; |
---|
| 500 | case 'inherit': |
---|
| 501 | break; |
---|
| 502 | case 'none': |
---|
| 503 | return Maxi_val; |
---|
| 504 | break; |
---|
| 505 | default: |
---|
| 506 | break; |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | var reg1 = new RegExp("auto", "g"); |
---|
| 510 | if (myObj.match(reg1)) { |
---|
[10845] | 511 | return Maxi_val; |
---|
| 512 | } |
---|
[7394] | 513 | |
---|
[16638] | 514 | if (prop) { |
---|
| 515 | |
---|
| 516 | myObj = num(prop.elem, prop.prop); |
---|
| 517 | } else { |
---|
[16931] | 518 | reg1 = new RegExp("px", "g"); |
---|
| 519 | if (myObj.match(reg1)) { |
---|
[7394] | 520 | |
---|
[16638] | 521 | myObj = Parse_Int(myObj); |
---|
[7394] | 522 | |
---|
[16931] | 523 | } else { |
---|
| 524 | reg1 = new RegExp("%", "g"); |
---|
| 525 | if (myObj.match(reg1)) { |
---|
| 526 | myObj = myObj.replace(reg1, ""); |
---|
| 527 | val = Math.ceil(myObj * Maxi_val / 100); |
---|
| 528 | return val; |
---|
[10845] | 529 | } |
---|
| 530 | } |
---|
[16931] | 531 | } |
---|
| 532 | if (Mini_val) |
---|
| 533 | if (myObj < Mini_val) return Maxi_val; |
---|
[16638] | 534 | val = Parse_Int(myObj); |
---|
[8729] | 535 | |
---|
[16931] | 536 | } else { |
---|
[16638] | 537 | val = Parse_Int(myObj); |
---|
[16931] | 538 | } |
---|
[16638] | 539 | if (typeof (val) == "NaN") |
---|
| 540 | return Maxi_val; |
---|
[16931] | 541 | return val; |
---|
[16638] | 542 | |
---|
[16931] | 543 | } |
---|
[16638] | 544 | |
---|
[10845] | 545 | /* |
---|
| 546 | * |
---|
| 547 | */ |
---|
[16638] | 548 | function Parse_Int(valeur_num) { |
---|
[16931] | 549 | if (!jQuery.isNumeric(valeur_num)) { |
---|
| 550 | valeur_num = valeur_num.toString(); |
---|
| 551 | reg1 = new RegExp("px", "gi"); |
---|
| 552 | if (valeur_num.match(reg1)) { |
---|
[16638] | 553 | valeur_num = valeur_num.replace(reg1, ""); |
---|
[16931] | 554 | } if (valeur_num.match(RegExp("%", "gi"))) { |
---|
[16638] | 555 | valeur_num = valeur_num.replace(reg1, ""); |
---|
[16931] | 556 | valeur_num = Math.ceil(valeur_num * Maxi_val / 100); |
---|
| 557 | } else { |
---|
| 558 | valeur_num = valeur_num.replace(reg1, ""); |
---|
| 559 | } |
---|
[16638] | 560 | } |
---|
| 561 | valeur_num = Math.ceil(valeur_num); |
---|
| 562 | return valeur_num || 0; |
---|
| 563 | } |
---|
| 564 | |
---|
[10845] | 565 | function num(el, prop) { |
---|
[16638] | 566 | valeur_num = jQuery.curCSS(el.jquery ? el[0] : el, prop, true); |
---|
| 567 | |
---|
| 568 | return Parse_Int(valeur_num); |
---|
[10845] | 569 | }; |
---|
[7394] | 570 | |
---|
[17192] | 571 | // myjQuery = jQuery; |
---|
| 572 | // my$ = $; |
---|
[10845] | 573 | |
---|
[7353] | 574 | })(jQuery); |
---|