a1a3bc73
Luigi Serra
graphs updates
|
1
|
define( [
|
74249687
Luigi Serra
Cross browser con...
|
2
3
4
5
|
"./core",
"./var/pnum",
"./core/access",
"./css/var/rmargin",
|
a1a3bc73
Luigi Serra
graphs updates
|
6
7
|
"./var/document",
"./var/rcssNum",
|
74249687
Luigi Serra
Cross browser con...
|
8
9
10
11
|
"./css/var/rnumnonpx",
"./css/var/cssExpand",
"./css/var/isHidden",
"./css/var/getStyles",
|
a1a3bc73
Luigi Serra
graphs updates
|
12
|
"./css/var/swap",
|
74249687
Luigi Serra
Cross browser con...
|
13
|
"./css/curCSS",
|
a1a3bc73
Luigi Serra
graphs updates
|
14
|
"./css/adjustCSS",
|
74249687
Luigi Serra
Cross browser con...
|
15
16
17
|
"./css/defaultDisplay",
"./css/addGetHookIf",
"./css/support",
|
a1a3bc73
Luigi Serra
graphs updates
|
18
|
"./data/var/dataPriv",
|
74249687
Luigi Serra
Cross browser con...
|
19
20
|
"./core/init",
|
74249687
Luigi Serra
Cross browser con...
|
21
22
|
"./core/ready",
"./selector" // contains
|
a1a3bc73
Luigi Serra
graphs updates
|
23
24
|
], function( jQuery, pnum, access, rmargin, document, rcssNum, rnumnonpx, cssExpand, isHidden,
getStyles, swap, curCSS, adjustCSS, defaultDisplay, addGetHookIf, support, dataPriv ) {
|
74249687
Luigi Serra
Cross browser con...
|
25
26
|
var
|
a1a3bc73
Luigi Serra
graphs updates
|
27
28
29
|
// Swappable if display is none or starts with table
// except "table", "table-cell", or "table-caption"
|
74249687
Luigi Serra
Cross browser con...
|
30
31
|
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
|
74249687
Luigi Serra
Cross browser con...
|
32
33
34
35
36
37
38
|
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform = {
letterSpacing: "0",
fontWeight: "400"
},
|
a1a3bc73
Luigi Serra
graphs updates
|
39
40
|
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
emptyStyle = document.createElement( "div" ).style;
|
74249687
Luigi Serra
Cross browser con...
|
41
42
|
// Return a css property mapped to a potentially vendor prefixed property
|
a1a3bc73
Luigi Serra
graphs updates
|
43
|
function vendorPropName( name ) {
|
74249687
Luigi Serra
Cross browser con...
|
44
45
|
// Shortcut for names that are not vendor prefixed
|
a1a3bc73
Luigi Serra
graphs updates
|
46
|
if ( name in emptyStyle ) {
|
74249687
Luigi Serra
Cross browser con...
|
47
48
49
50
|
return name;
}
// Check for vendor prefixed names
|
a1a3bc73
Luigi Serra
graphs updates
|
51
|
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
|
74249687
Luigi Serra
Cross browser con...
|
52
53
54
55
|
i = cssPrefixes.length;
while ( i-- ) {
name = cssPrefixes[ i ] + capName;
|
a1a3bc73
Luigi Serra
graphs updates
|
56
|
if ( name in emptyStyle ) {
|
74249687
Luigi Serra
Cross browser con...
|
57
58
59
|
return name;
}
}
|
74249687
Luigi Serra
Cross browser con...
|
60
61
62
|
}
function setPositiveNumber( elem, value, subtract ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
63
64
65
66
|
// Any relative (+/-) values have already been
// normalized at this point
var matches = rcssNum.exec( value );
|
74249687
Luigi Serra
Cross browser con...
|
67
|
return matches ?
|
a1a3bc73
Luigi Serra
graphs updates
|
68
|
|
74249687
Luigi Serra
Cross browser con...
|
69
|
// Guard against undefined "subtract", e.g., when used as in cssHooks
|
a1a3bc73
Luigi Serra
graphs updates
|
70
|
Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
|
74249687
Luigi Serra
Cross browser con...
|
71
72
73
74
75
|
value;
}
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
var i = extra === ( isBorderBox ? "border" : "content" ) ?
|
a1a3bc73
Luigi Serra
graphs updates
|
76
|
|
74249687
Luigi Serra
Cross browser con...
|
77
78
|
// If we already have the right measurement, avoid augmentation
4 :
|
a1a3bc73
Luigi Serra
graphs updates
|
79
|
|
74249687
Luigi Serra
Cross browser con...
|
80
81
82
83
84
85
|
// Otherwise initialize for horizontal or vertical properties
name === "width" ? 1 : 0,
val = 0;
for ( ; i < 4; i += 2 ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
86
|
|
74249687
Luigi Serra
Cross browser con...
|
87
88
89
90
91
92
|
// Both box models exclude margin, so add it if we want it
if ( extra === "margin" ) {
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
}
if ( isBorderBox ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
93
|
|
74249687
Luigi Serra
Cross browser con...
|
94
95
96
97
98
99
100
101
102
103
|
// border-box includes padding, so remove it if we want content
if ( extra === "content" ) {
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
}
// At this point, extra isn't border nor margin, so remove border
if ( extra !== "margin" ) {
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
}
} else {
|
a1a3bc73
Luigi Serra
graphs updates
|
104
|
|
74249687
Luigi Serra
Cross browser con...
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// At this point, extra isn't content, so add padding
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
// At this point, extra isn't content nor padding, so add border
if ( extra !== "padding" ) {
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
}
}
}
return val;
}
function getWidthOrHeight( elem, name, extra ) {
// Start with offset property, which is equivalent to the border-box value
var valueIsBorderBox = true,
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
|
a1a3bc73
Luigi Serra
graphs updates
|
126
127
128
129
130
131
132
133
134
135
136
137
138
|
// Support: IE11 only
// In IE 11 fullscreen elements inside of an iframe have
// 100x too small dimensions (gh-1764).
if ( document.msFullscreenElement && window.top !== window ) {
// Support: IE11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
if ( elem.getClientRects().length ) {
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
}
}
|
74249687
Luigi Serra
Cross browser con...
|
139
140
141
142
|
// Some non-html elements return undefined for offsetWidth, so check for null/undefined
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
if ( val <= 0 || val == null ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
143
|
|
74249687
Luigi Serra
Cross browser con...
|
144
145
146
147
148
149
150
|
// Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name, styles );
if ( val < 0 || val == null ) {
val = elem.style[ name ];
}
// Computed unit is not pixels. Stop here and return.
|
a1a3bc73
Luigi Serra
graphs updates
|
151
|
if ( rnumnonpx.test( val ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
return val;
}
// Check for style in case a browser which returns unreliable values
// for getComputedStyle silently falls back to the reliable elem.style
valueIsBorderBox = isBorderBox &&
( support.boxSizingReliable() || val === elem.style[ name ] );
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;
}
// Use the active box-sizing model to add/subtract irrelevant styles
return ( val +
augmentWidthOrHeight(
elem,
name,
extra || ( isBorderBox ? "border" : "content" ),
valueIsBorderBox,
styles
)
) + "px";
}
function showHide( elements, show ) {
var display, elem, hidden,
values = [],
index = 0,
length = elements.length;
for ( ; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
|
a1a3bc73
Luigi Serra
graphs updates
|
188
|
values[ index ] = dataPriv.get( elem, "olddisplay" );
|
74249687
Luigi Serra
Cross browser con...
|
189
190
|
display = elem.style.display;
if ( show ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
191
|
|
74249687
Luigi Serra
Cross browser con...
|
192
193
194
195
196
197
198
199
200
201
|
// Reset the inline display of this element to learn if it is
// being hidden by cascaded rules or not
if ( !values[ index ] && display === "none" ) {
elem.style.display = "";
}
// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// for such an element
if ( elem.style.display === "" && isHidden( elem ) ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
202
203
204
205
206
|
values[ index ] = dataPriv.access(
elem,
"olddisplay",
defaultDisplay( elem.nodeName )
);
|
74249687
Luigi Serra
Cross browser con...
|
207
208
209
210
211
|
}
} else {
hidden = isHidden( elem );
if ( display !== "none" || !hidden ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
212
213
214
215
216
|
dataPriv.set(
elem,
"olddisplay",
hidden ? display : jQuery.css( elem, "display" )
);
|
74249687
Luigi Serra
Cross browser con...
|
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
}
}
}
// Set the display of most of the elements in a second loop
// to avoid the constant reflow
for ( index = 0; index < length; index++ ) {
elem = elements[ index ];
if ( !elem.style ) {
continue;
}
if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
elem.style.display = show ? values[ index ] || "" : "none";
}
}
return elements;
}
|
a1a3bc73
Luigi Serra
graphs updates
|
236
|
jQuery.extend( {
|
74249687
Luigi Serra
Cross browser con...
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
// Add in style property hooks for overriding the default
// behavior of getting and setting a style property
cssHooks: {
opacity: {
get: function( elem, computed ) {
if ( computed ) {
// We should always get a number back from opacity
var ret = curCSS( elem, "opacity" );
return ret === "" ? "1" : ret;
}
}
}
},
// Don't automatically add "px" to these possibly-unitless properties
cssNumber: {
|
a1a3bc73
Luigi Serra
graphs updates
|
255
|
"animationIterationCount": true,
|
74249687
Luigi Serra
Cross browser con...
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
"columnCount": true,
"fillOpacity": true,
"flexGrow": true,
"flexShrink": true,
"fontWeight": true,
"lineHeight": true,
"opacity": true,
"order": true,
"orphans": true,
"widows": true,
"zIndex": true,
"zoom": true
},
// Add in properties whose names you wish to fix before
// setting or getting the value
cssProps: {
"float": "cssFloat"
},
// Get and set the style property on a DOM Node
style: function( elem, name, value, extra ) {
// Don't set styles on text and comment nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
return;
}
// Make sure that we're working with the right name
var ret, type, hooks,
origName = jQuery.camelCase( name ),
style = elem.style;
|
a1a3bc73
Luigi Serra
graphs updates
|
289
290
|
name = jQuery.cssProps[ origName ] ||
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
|
74249687
Luigi Serra
Cross browser con...
|
291
292
293
294
295
296
297
298
299
|
// Gets hook for the prefixed version, then unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// Check if we're setting a value
if ( value !== undefined ) {
type = typeof value;
// Convert "+=" or "-=" to relative numbers (#7345)
|
a1a3bc73
Luigi Serra
graphs updates
|
300
301
302
|
if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
value = adjustCSS( elem, name, ret );
|
74249687
Luigi Serra
Cross browser con...
|
303
304
305
306
307
308
309
310
311
|
// Fixes bug #9237
type = "number";
}
// Make sure that null and NaN values aren't set (#7116)
if ( value == null || value !== value ) {
return;
}
|
a1a3bc73
Luigi Serra
graphs updates
|
312
313
314
|
// If a number was passed in, add the unit (except for certain CSS properties)
if ( type === "number" ) {
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
|
74249687
Luigi Serra
Cross browser con...
|
315
316
317
318
319
320
321
322
323
|
}
// Support: IE9-11+
// background-* props affect original clone's values
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
style[ name ] = "inherit";
}
// If a hook was provided, use that value, otherwise just set the specified value
|
a1a3bc73
Luigi Serra
graphs updates
|
324
325
326
|
if ( !hooks || !( "set" in hooks ) ||
( value = hooks.set( elem, value, extra ) ) !== undefined ) {
|
74249687
Luigi Serra
Cross browser con...
|
327
328
329
330
|
style[ name ] = value;
}
} else {
|
a1a3bc73
Luigi Serra
graphs updates
|
331
|
|
74249687
Luigi Serra
Cross browser con...
|
332
|
// If a hook was provided get the non-computed value from there
|
a1a3bc73
Luigi Serra
graphs updates
|
333
334
335
|
if ( hooks && "get" in hooks &&
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
|
74249687
Luigi Serra
Cross browser con...
|
336
337
338
339
340
341
342
343
344
345
346
347
348
|
return ret;
}
// Otherwise just get the value from the style object
return style[ name ];
}
},
css: function( elem, name, extra, styles ) {
var val, num, hooks,
origName = jQuery.camelCase( name );
// Make sure that we're working with the right name
|
a1a3bc73
Luigi Serra
graphs updates
|
349
350
|
name = jQuery.cssProps[ origName ] ||
( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
|
74249687
Luigi Serra
Cross browser con...
|
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
// Try prefixed name followed by the unprefixed name
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// If a hook was provided get the computed value from there
if ( hooks && "get" in hooks ) {
val = hooks.get( elem, true, extra );
}
// Otherwise, if a way to get the computed value exists, use that
if ( val === undefined ) {
val = curCSS( elem, name, styles );
}
// Convert "normal" to computed value
if ( val === "normal" && name in cssNormalTransform ) {
val = cssNormalTransform[ name ];
}
// Make numeric if forced or a qualifier was provided and val looks numeric
if ( extra === "" || extra ) {
num = parseFloat( val );
|
a1a3bc73
Luigi Serra
graphs updates
|
373
|
return extra === true || isFinite( num ) ? num || 0 : val;
|
74249687
Luigi Serra
Cross browser con...
|
374
375
376
|
}
return val;
}
|
a1a3bc73
Luigi Serra
graphs updates
|
377
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
378
|
|
a1a3bc73
Luigi Serra
graphs updates
|
379
|
jQuery.each( [ "height", "width" ], function( i, name ) {
|
74249687
Luigi Serra
Cross browser con...
|
380
381
382
383
384
385
|
jQuery.cssHooks[ name ] = {
get: function( elem, computed, extra ) {
if ( computed ) {
// Certain elements can have dimension info if we invisibly show them
// but it must have a current display style that would benefit
|
a1a3bc73
Luigi Serra
graphs updates
|
386
387
388
389
390
391
|
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
elem.offsetWidth === 0 ?
swap( elem, cssShow, function() {
return getWidthOrHeight( elem, name, extra );
} ) :
getWidthOrHeight( elem, name, extra );
|
74249687
Luigi Serra
Cross browser con...
|
392
393
394
395
|
}
},
set: function( elem, value, extra ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
396
397
398
|
var matches,
styles = extra && getStyles( elem ),
subtract = extra && augmentWidthOrHeight(
|
74249687
Luigi Serra
Cross browser con...
|
399
400
401
402
403
|
elem,
name,
extra,
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
styles
|
a1a3bc73
Luigi Serra
graphs updates
|
404
405
406
407
408
409
410
411
412
413
414
|
);
// Convert to pixels if value adjustment is needed
if ( subtract && ( matches = rcssNum.exec( value ) ) &&
( matches[ 3 ] || "px" ) !== "px" ) {
elem.style[ name ] = value;
value = jQuery.css( elem, name );
}
return setPositiveNumber( elem, value, subtract );
|
74249687
Luigi Serra
Cross browser con...
|
415
416
|
}
};
|
a1a3bc73
Luigi Serra
graphs updates
|
417
418
419
420
421
422
423
424
425
426
427
428
429
430
|
} );
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
function( elem, computed ) {
if ( computed ) {
return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
elem.getBoundingClientRect().left -
swap( elem, { marginLeft: 0 }, function() {
return elem.getBoundingClientRect().left;
} )
) + "px";
}
}
);
|
74249687
Luigi Serra
Cross browser con...
|
431
432
433
434
435
|
// Support: Android 2.3
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
function( elem, computed ) {
if ( computed ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
436
|
return swap( elem, { "display": "inline-block" },
|
74249687
Luigi Serra
Cross browser con...
|
437
438
439
440
441
442
|
curCSS, [ elem, "marginRight" ] );
}
}
);
// These hooks are used by animate to expand properties
|
a1a3bc73
Luigi Serra
graphs updates
|
443
|
jQuery.each( {
|
74249687
Luigi Serra
Cross browser con...
|
444
445
446
447
448
449
450
451
452
453
|
margin: "",
padding: "",
border: "Width"
}, function( prefix, suffix ) {
jQuery.cssHooks[ prefix + suffix ] = {
expand: function( value ) {
var i = 0,
expanded = {},
// Assumes a single number if not a string
|
a1a3bc73
Luigi Serra
graphs updates
|
454
|
parts = typeof value === "string" ? value.split( " " ) : [ value ];
|
74249687
Luigi Serra
Cross browser con...
|
455
456
457
458
459
460
461
462
463
464
465
466
467
|
for ( ; i < 4; i++ ) {
expanded[ prefix + cssExpand[ i ] + suffix ] =
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
}
return expanded;
}
};
if ( !rmargin.test( prefix ) ) {
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
}
|
a1a3bc73
Luigi Serra
graphs updates
|
468
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
469
|
|
a1a3bc73
Luigi Serra
graphs updates
|
470
|
jQuery.fn.extend( {
|
74249687
Luigi Serra
Cross browser con...
|
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
|
css: function( name, value ) {
return access( this, function( elem, name, value ) {
var styles, len,
map = {},
i = 0;
if ( jQuery.isArray( name ) ) {
styles = getStyles( elem );
len = name.length;
for ( ; i < len; i++ ) {
map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
}
return map;
}
return value !== undefined ?
jQuery.style( elem, name, value ) :
jQuery.css( elem, name );
}, name, value, arguments.length > 1 );
},
show: function() {
return showHide( this, true );
},
hide: function() {
return showHide( this );
},
toggle: function( state ) {
if ( typeof state === "boolean" ) {
return state ? this.show() : this.hide();
}
|
a1a3bc73
Luigi Serra
graphs updates
|
504
|
return this.each( function() {
|
74249687
Luigi Serra
Cross browser con...
|
505
506
507
508
509
|
if ( isHidden( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
|
a1a3bc73
Luigi Serra
graphs updates
|
510
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
511
|
}
|
a1a3bc73
Luigi Serra
graphs updates
|
512
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
513
514
|
return jQuery;
|
a1a3bc73
Luigi Serra
graphs updates
|
515
|
} );
|