scratch – Blame information for rev 58

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