scratch – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
58 | office | 1 | define( [ |
2 | "../core", |
||
3 | "../var/document" |
||
4 | ], function( jQuery, document ) { |
||
5 | |||
6 | "use strict"; |
||
7 | |||
8 | var readyCallbacks = [], |
||
9 | whenReady = function( fn ) { |
||
10 | readyCallbacks.push( fn ); |
||
11 | }, |
||
12 | executeReady = function( fn ) { |
||
13 | |||
14 | // Prevent errors from freezing future callback execution (gh-1823) |
||
15 | // Not backwards-compatible as this does not execute sync |
||
16 | window.setTimeout( function() { |
||
17 | fn.call( document, jQuery ); |
||
18 | } ); |
||
19 | }; |
||
20 | |||
21 | jQuery.fn.ready = function( fn ) { |
||
22 | whenReady( fn ); |
||
23 | return this; |
||
24 | }; |
||
25 | |||
26 | jQuery.extend( { |
||
27 | |||
28 | // Is the DOM ready to be used? Set to true once it occurs. |
||
29 | isReady: false, |
||
30 | |||
31 | // A counter to track how many items to wait for before |
||
32 | // the ready event fires. See #6781 |
||
33 | readyWait: 1, |
||
34 | |||
35 | // Hold (or release) the ready event |
||
36 | holdReady: function( hold ) { |
||
37 | if ( hold ) { |
||
38 | jQuery.readyWait++; |
||
39 | } else { |
||
40 | jQuery.ready( true ); |
||
41 | } |
||
42 | }, |
||
43 | |||
44 | ready: function( wait ) { |
||
45 | |||
46 | // Abort if there are pending holds or we're already ready |
||
47 | if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { |
||
48 | return; |
||
49 | } |
||
50 | |||
51 | // Remember that the DOM is ready |
||
52 | jQuery.isReady = true; |
||
53 | |||
54 | // If a normal DOM Ready event fired, decrement, and wait if need be |
||
55 | if ( wait !== true && --jQuery.readyWait > 0 ) { |
||
56 | return; |
||
57 | } |
||
58 | |||
59 | whenReady = function( fn ) { |
||
60 | readyCallbacks.push( fn ); |
||
61 | |||
62 | while ( readyCallbacks.length ) { |
||
63 | fn = readyCallbacks.shift(); |
||
64 | if ( jQuery.isFunction( fn ) ) { |
||
65 | executeReady( fn ); |
||
66 | } |
||
67 | } |
||
68 | }; |
||
69 | |||
70 | whenReady(); |
||
71 | } |
||
72 | } ); |
||
73 | |||
74 | // Make jQuery.ready Promise consumable (gh-1778) |
||
75 | jQuery.ready.then = jQuery.fn.ready; |
||
76 | |||
77 | /** |
||
78 | * The ready event handler and self cleanup method |
||
79 | */ |
||
80 | function completed() { |
||
81 | document.removeEventListener( "DOMContentLoaded", completed ); |
||
82 | window.removeEventListener( "load", completed ); |
||
83 | jQuery.ready(); |
||
84 | } |
||
85 | |||
86 | // Catch cases where $(document).ready() is called |
||
87 | // after the browser event has already occurred. |
||
88 | // Support: IE9-10 only |
||
89 | // Older IE sometimes signals "interactive" too soon |
||
90 | if ( document.readyState === "complete" || |
||
91 | ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { |
||
92 | |||
93 | // Handle it asynchronously to allow scripts the opportunity to delay ready |
||
94 | window.setTimeout( jQuery.ready ); |
||
95 | |||
96 | } else { |
||
97 | |||
98 | // Use the handy event callback |
||
99 | document.addEventListener( "DOMContentLoaded", completed ); |
||
100 | |||
101 | // A fallback to window.onload, that will always work |
||
102 | window.addEventListener( "load", completed ); |
||
103 | } |
||
104 | |||
105 | } ); |