a1a3bc73
Luigi Serra
graphs updates
|
1
|
define( [
|
74249687
Luigi Serra
Cross browser con...
|
2
|
"../core",
|
a1a3bc73
Luigi Serra
graphs updates
|
3
|
"../var/document",
|
74249687
Luigi Serra
Cross browser con...
|
4
5
|
"../core/init",
"../deferred"
|
a1a3bc73
Luigi Serra
graphs updates
|
6
|
], function( jQuery, document ) {
|
74249687
Luigi Serra
Cross browser con...
|
7
8
9
10
11
|
// The deferred used on DOM ready
var readyList;
jQuery.fn.ready = function( fn ) {
|
a1a3bc73
Luigi Serra
graphs updates
|
12
|
|
74249687
Luigi Serra
Cross browser con...
|
13
14
15
16
17
18
|
// Add the callback
jQuery.ready.promise().done( fn );
return this;
};
|
a1a3bc73
Luigi Serra
graphs updates
|
19
20
|
jQuery.extend( {
|
74249687
Luigi Serra
Cross browser con...
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
// A counter to track how many items to wait for before
// the ready event fires. See #6781
readyWait: 1,
// Hold (or release) the ready event
holdReady: function( hold ) {
if ( hold ) {
jQuery.readyWait++;
} else {
jQuery.ready( true );
}
},
// Handle when the DOM is ready
ready: function( wait ) {
// Abort if there are pending holds or we're already ready
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
return;
}
// Remember that the DOM is ready
jQuery.isReady = true;
// If a normal DOM Ready event fired, decrement, and wait if need be
if ( wait !== true && --jQuery.readyWait > 0 ) {
return;
}
// If there are functions bound, to execute
readyList.resolveWith( document, [ jQuery ] );
// Trigger any bound ready events
if ( jQuery.fn.triggerHandler ) {
jQuery( document ).triggerHandler( "ready" );
jQuery( document ).off( "ready" );
}
}
|
a1a3bc73
Luigi Serra
graphs updates
|
62
|
} );
|
74249687
Luigi Serra
Cross browser con...
|
63
64
65
66
67
|
/**
* The ready event handler and self cleanup method
*/
function completed() {
|
a1a3bc73
Luigi Serra
graphs updates
|
68
69
|
document.removeEventListener( "DOMContentLoaded", completed );
window.removeEventListener( "load", completed );
|
74249687
Luigi Serra
Cross browser con...
|
70
71
72
73
74
75
76
77
|
jQuery.ready();
}
jQuery.ready.promise = function( obj ) {
if ( !readyList ) {
readyList = jQuery.Deferred();
|
a1a3bc73
Luigi Serra
graphs updates
|
78
79
80
81
82
83
84
|
// Catch cases where $(document).ready() is called
// after the browser event has already occurred.
// Support: IE9-10 only
// Older IE sometimes signals "interactive" too soon
if ( document.readyState === "complete" ||
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
|
74249687
Luigi Serra
Cross browser con...
|
85
|
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
a1a3bc73
Luigi Serra
graphs updates
|
86
|
window.setTimeout( jQuery.ready );
|
74249687
Luigi Serra
Cross browser con...
|
87
88
89
90
|
} else {
// Use the handy event callback
|
a1a3bc73
Luigi Serra
graphs updates
|
91
|
document.addEventListener( "DOMContentLoaded", completed );
|
74249687
Luigi Serra
Cross browser con...
|
92
93
|
// A fallback to window.onload, that will always work
|
a1a3bc73
Luigi Serra
graphs updates
|
94
|
window.addEventListener( "load", completed );
|
74249687
Luigi Serra
Cross browser con...
|
95
96
97
98
99
100
101
102
|
}
}
return readyList.promise( obj );
};
// Kick off the DOM ready check even if the user does not
jQuery.ready.promise();
|
a1a3bc73
Luigi Serra
graphs updates
|
103
|
} );
|