|
21 | 21 | // Browser globals |
22 | 22 | factory( jQuery ); |
23 | 23 | } |
24 | | -})( function( $ ) { |
| 24 | +} )( function( $ ) { |
25 | 25 |
|
26 | | - var props = { |
27 | | - "animation": {}, |
28 | | - "transition": {} |
29 | | - }, |
30 | | - testElement = document.createElement( "a" ), |
31 | | - vendorPrefixes = [ "", "webkit-", "moz-", "o-" ]; |
| 26 | +var props = { |
| 27 | + "animation": {}, |
| 28 | + "transition": {} |
| 29 | + }, |
| 30 | + testElement = document.createElement( "a" ), |
| 31 | + vendorPrefixes = [ "", "webkit-", "moz-", "o-" ]; |
32 | 32 |
|
33 | | - $.each( [ "animation", "transition" ], function( i, test ) { |
| 33 | +$.each( [ "animation", "transition" ], function( i, test ) { |
34 | 34 |
|
35 | | - // Get correct name for test |
36 | | - var testName = ( i === 0 ) ? test + "-" + "name" : test; |
| 35 | + // Get correct name for test |
| 36 | + var testName = ( i === 0 ) ? test + "-" + "name" : test; |
37 | 37 |
|
38 | | - $.each( vendorPrefixes, function( j, prefix ) { |
39 | | - if ( testElement.style[ $.camelCase( prefix + testName ) ] !== undefined ) { |
40 | | - props[ test ][ "prefix" ] = prefix; |
41 | | - return false; |
42 | | - } |
43 | | - }); |
| 38 | + $.each( vendorPrefixes, function( j, prefix ) { |
| 39 | + if ( testElement.style[ $.camelCase( prefix + testName ) ] !== undefined ) { |
| 40 | + props[ test ][ "prefix" ] = prefix; |
| 41 | + return false; |
| 42 | + } |
| 43 | + } ); |
44 | 44 |
|
45 | | - // Set event and duration names for later use |
46 | | - props[ test ][ "duration" ] = |
47 | | - $.camelCase( props[ test ][ "prefix" ] + test + "-" + "duration" ); |
48 | | - props[ test ][ "event" ] = |
49 | | - $.camelCase( props[ test ][ "prefix" ] + test + "-" + "end" ); |
| 45 | + // Set event and duration names for later use |
| 46 | + props[ test ][ "duration" ] = |
| 47 | + $.camelCase( props[ test ][ "prefix" ] + test + "-" + "duration" ); |
| 48 | + props[ test ][ "event" ] = |
| 49 | + $.camelCase( props[ test ][ "prefix" ] + test + "-" + "end" ); |
50 | 50 |
|
51 | | - // All lower case if not a vendor prop |
52 | | - if ( props[ test ][ "prefix" ] === "" ) { |
53 | | - props[ test ][ "event" ] = props[ test ][ "event" ].toLowerCase(); |
54 | | - } |
55 | | - }); |
| 51 | + // All lower case if not a vendor prop |
| 52 | + if ( props[ test ][ "prefix" ] === "" ) { |
| 53 | + props[ test ][ "event" ] = props[ test ][ "event" ].toLowerCase(); |
| 54 | + } |
| 55 | +} ); |
56 | 56 |
|
57 | | - // If a valid prefix was found then the it is supported by the browser |
58 | | - $.support.cssTransitions = ( props[ "transition" ][ "prefix" ] !== undefined ); |
59 | | - $.support.cssAnimations = ( props[ "animation" ][ "prefix" ] !== undefined ); |
| 57 | +// If a valid prefix was found then the it is supported by the browser |
| 58 | +$.support.cssTransitions = ( props[ "transition" ][ "prefix" ] !== undefined ); |
| 59 | +$.support.cssAnimations = ( props[ "animation" ][ "prefix" ] !== undefined ); |
60 | 60 |
|
61 | | - // Remove the testElement |
62 | | - $( testElement ).remove(); |
| 61 | +// Remove the testElement |
| 62 | +$( testElement ).remove(); |
63 | 63 |
|
64 | | - // Animation complete callback |
65 | | - $.fn.animationComplete = function( callback, type, fallbackTime ) { |
66 | | - var timer, duration, |
67 | | - that = this, |
68 | | - eventBinding = function() { |
| 64 | +// Animation complete callback |
| 65 | +$.fn.animationComplete = function( callback, type, fallbackTime ) { |
| 66 | + var timer, duration, |
| 67 | + that = this, |
| 68 | + eventBinding = function() { |
69 | 69 |
|
70 | | - // Clear the timer so we don't call callback twice |
71 | | - clearTimeout( timer ); |
72 | | - callback.apply( this, arguments ); |
73 | | - }, |
74 | | - animationType = ( !type || type === "animation" ) ? "animation" : "transition"; |
| 70 | + // Clear the timer so we don't call callback twice |
| 71 | + clearTimeout( timer ); |
| 72 | + callback.apply( this, arguments ); |
| 73 | + }, |
| 74 | + animationType = ( !type || type === "animation" ) ? "animation" : "transition"; |
75 | 75 |
|
76 | | - if ( !this.length ) { |
77 | | - return this; |
78 | | - } |
| 76 | + if ( !this.length ) { |
| 77 | + return this; |
| 78 | + } |
79 | 79 |
|
80 | | - // Make sure selected type is supported by browser |
81 | | - if ( ( $.support.cssTransitions && animationType === "transition" ) || |
| 80 | + // Make sure selected type is supported by browser |
| 81 | + if ( ( $.support.cssTransitions && animationType === "transition" ) || |
82 | 82 | ( $.support.cssAnimations && animationType === "animation" ) ) { |
83 | 83 |
|
84 | | - // If a fallback time was not passed set one |
85 | | - if ( fallbackTime === undefined ) { |
| 84 | + // If a fallback time was not passed set one |
| 85 | + if ( fallbackTime === undefined ) { |
86 | 86 |
|
87 | | - // Make sure the was not bound to document before checking .css |
88 | | - if ( this.context !== document ) { |
| 87 | + // Make sure the was not bound to document before checking .css |
| 88 | + if ( this.context !== document ) { |
89 | 89 |
|
90 | | - // Parse the durration since its in second multiple by 1000 for milliseconds |
91 | | - // Multiply by 3 to make sure we give the animation plenty of time. |
92 | | - duration = parseFloat( |
| 90 | + // Parse the durration since its in second multiple by 1000 for milliseconds |
| 91 | + // Multiply by 3 to make sure we give the animation plenty of time. |
| 92 | + duration = parseFloat( |
93 | 93 | this.css( props[ animationType ].duration ) |
94 | 94 | ) * 3000; |
95 | | - } |
| 95 | + } |
96 | 96 |
|
97 | | - // If we could not read a duration use the default |
98 | | - if ( duration === 0 || duration === undefined || isNaN( duration ) ) { |
99 | | - duration = $.fn.animationComplete.defaultDuration; |
100 | | - } |
| 97 | + // If we could not read a duration use the default |
| 98 | + if ( duration === 0 || duration === undefined || isNaN( duration ) ) { |
| 99 | + duration = $.fn.animationComplete.defaultDuration; |
101 | 100 | } |
| 101 | + } |
102 | 102 |
|
103 | | - // Sets up the fallback if event never comes |
104 | | - timer = setTimeout( function() { |
105 | | - that |
106 | | - .off( props[ animationType ].event, eventBinding ) |
107 | | - .each( function() { |
108 | | - callback.apply( this ); |
109 | | - }); |
110 | | - }, duration ); |
111 | | - |
112 | | - // Bind the event |
113 | | - return this.one( props[ animationType ].event, eventBinding ); |
114 | | - } else { |
115 | | - |
116 | | - // CSS animation / transitions not supported |
117 | | - // Defer execution for consistency between webkit/non webkit |
118 | | - setTimeout( function() { |
119 | | - that.each( function() { |
| 103 | + // Sets up the fallback if event never comes |
| 104 | + timer = setTimeout( function() { |
| 105 | + that |
| 106 | + .off( props[ animationType ].event, eventBinding ) |
| 107 | + .each( function() { |
120 | 108 | callback.apply( this ); |
121 | | - }); |
122 | | - }, 0 ); |
123 | | - return this; |
124 | | - } |
125 | | - }; |
| 109 | + } ); |
| 110 | + }, duration ); |
| 111 | + |
| 112 | + // Bind the event |
| 113 | + return this.one( props[ animationType ].event, eventBinding ); |
| 114 | + } else { |
| 115 | + |
| 116 | + // CSS animation / transitions not supported |
| 117 | + // Defer execution for consistency between webkit/non webkit |
| 118 | + setTimeout( function() { |
| 119 | + that.each( function() { |
| 120 | + callback.apply( this ); |
| 121 | + } ); |
| 122 | + }, 0 ); |
| 123 | + return this; |
| 124 | + } |
| 125 | +}; |
126 | 126 |
|
127 | | - // Allow default callback to be configured on mobileInit |
128 | | - $.fn.animationComplete.defaultDuration = 1000; |
| 127 | +// Allow default callback to be configured on mobileInit |
| 128 | +$.fn.animationComplete.defaultDuration = 1000; |
129 | 129 |
|
130 | | - return $.fn.animationComplete; |
131 | | -}); |
| 130 | +return $.fn.animationComplete; |
| 131 | +} ); |
0 commit comments