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