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