Make sure that jQuery is being exposed outside of core (this will be stripped during...
[jquery.git] / src / core.js
1 var jQuery = (function() {
2
3 // Define a local copy of jQuery
4 var jQuery = function( selector, context ) {
5                 // The jQuery object is actually just the init constructor 'enhanced'
6                 return new jQuery.fn.init( selector, context );
7         },
8
9         // Map over jQuery in case of overwrite
10         _jQuery = window.jQuery,
11
12         // Map over the $ in case of overwrite
13         _$ = window.$,
14
15         // Use the correct document accordingly with window argument (sandbox)
16         //document = window.document,
17
18         // A central reference to the root jQuery(document)
19         rootjQuery,
20
21         // A simple way to check for HTML strings or ID strings
22         // (both of which we optimize for)
23         quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w\-]+)$/,
24
25         // Is it a simple selector
26         isSimple = /^.[^:#\[\.,]*$/,
27
28         // Check if a string has a non-whitespace character in it
29         rnotwhite = /\S/,
30
31         // Used for trimming whitespace
32         trimLeft = /^\s+/,
33         trimRight = /\s+$/,
34
35         // Match a standalone tag
36         rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
37
38         // Keep a UserAgent string for use with jQuery.browser
39         userAgent = navigator.userAgent,
40
41         // For matching the engine and version of the browser
42         browserMatch,
43         
44         // Has the ready events already been bound?
45         readyBound = false,
46         
47         // The functions to execute on DOM ready
48         readyList = [],
49
50         // The ready event handler
51         DOMContentLoaded,
52
53         // Save a reference to some core methods
54         toString = Object.prototype.toString,
55         hasOwn = Object.prototype.hasOwnProperty,
56         push = Array.prototype.push,
57         slice = Array.prototype.slice,
58         trim = String.prototype.trim,
59         indexOf = Array.prototype.indexOf;
60
61 jQuery.fn = jQuery.prototype = {
62         init: function( selector, context ) {
63                 var match, elem, ret, doc;
64
65                 // Handle $(""), $(null), or $(undefined)
66                 if ( !selector ) {
67                         return this;
68                 }
69
70                 // Handle $(DOMElement)
71                 if ( selector.nodeType ) {
72                         this.context = this[0] = selector;
73                         this.length = 1;
74                         return this;
75                 }
76                 
77                 // The body element only exists once, optimize finding it
78                 if ( selector === "body" && !context ) {
79                         this.context = document;
80                         this[0] = document.body;
81                         this.selector = "body";
82                         this.length = 1;
83                         return this;
84                 }
85
86                 // Handle HTML strings
87                 if ( typeof selector === "string" ) {
88                         // Are we dealing with HTML string or an ID?
89                         match = quickExpr.exec( selector );
90
91                         // Verify a match, and that no context was specified for #id
92                         if ( match && (match[1] || !context) ) {
93
94                                 // HANDLE: $(html) -> $(array)
95                                 if ( match[1] ) {
96                                         doc = (context ? context.ownerDocument || context : document);
97
98                                         // If a single string is passed in and it's a single tag
99                                         // just do a createElement and skip the rest
100                                         ret = rsingleTag.exec( selector );
101
102                                         if ( ret ) {
103                                                 if ( jQuery.isPlainObject( context ) ) {
104                                                         selector = [ document.createElement( ret[1] ) ];
105                                                         jQuery.fn.attr.call( selector, context, true );
106
107                                                 } else {
108                                                         selector = [ doc.createElement( ret[1] ) ];
109                                                 }
110
111                                         } else {
112                                                 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
113                                                 selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
114                                         }
115                                         
116                                         return jQuery.merge( this, selector );
117                                         
118                                 // HANDLE: $("#id")
119                                 } else {
120                                         elem = document.getElementById( match[2] );
121
122                                         // Check parentNode to catch when Blackberry 4.6 returns
123                                         // nodes that are no longer in the document #6963
124                                         if ( elem && elem.parentNode ) {
125                                                 // Handle the case where IE and Opera return items
126                                                 // by name instead of ID
127                                                 if ( elem.id !== match[2] ) {
128                                                         return rootjQuery.find( selector );
129                                                 }
130
131                                                 // Otherwise, we inject the element directly into the jQuery object
132                                                 this.length = 1;
133                                                 this[0] = elem;
134                                         }
135
136                                         this.context = document;
137                                         this.selector = selector;
138                                         return this;
139                                 }
140
141                         // HANDLE: $("TAG")
142                         } else if ( !context && /^\w+$/.test( selector ) ) {
143                                 this.selector = selector;
144                                 this.context = document;
145                                 selector = document.getElementsByTagName( selector );
146                                 return jQuery.merge( this, selector );
147
148                         // HANDLE: $(expr, $(...))
149                         } else if ( !context || context.jquery ) {
150                                 return (context || rootjQuery).find( selector );
151
152                         // HANDLE: $(expr, context)
153                         // (which is just equivalent to: $(context).find(expr)
154                         } else {
155                                 return jQuery( context ).find( selector );
156                         }
157
158                 // HANDLE: $(function)
159                 // Shortcut for document ready
160                 } else if ( jQuery.isFunction( selector ) ) {
161                         return rootjQuery.ready( selector );
162                 }
163
164                 if (selector.selector !== undefined) {
165                         this.selector = selector.selector;
166                         this.context = selector.context;
167                 }
168
169                 return jQuery.makeArray( selector, this );
170         },
171
172         // Start with an empty selector
173         selector: "",
174
175         // The current version of jQuery being used
176         jquery: "@VERSION",
177
178         // The default length of a jQuery object is 0
179         length: 0,
180
181         // The number of elements contained in the matched element set
182         size: function() {
183                 return this.length;
184         },
185
186         toArray: function() {
187                 return slice.call( this, 0 );
188         },
189
190         // Get the Nth element in the matched element set OR
191         // Get the whole matched element set as a clean array
192         get: function( num ) {
193                 return num == null ?
194
195                         // Return a 'clean' array
196                         this.toArray() :
197
198                         // Return just the object
199                         ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
200         },
201
202         // Take an array of elements and push it onto the stack
203         // (returning the new matched element set)
204         pushStack: function( elems, name, selector ) {
205                 // Build a new jQuery matched element set
206                 var ret = jQuery();
207
208                 if ( jQuery.isArray( elems ) ) {
209                         push.apply( ret, elems );
210                 
211                 } else {
212                         jQuery.merge( ret, elems );
213                 }
214
215                 // Add the old object onto the stack (as a reference)
216                 ret.prevObject = this;
217
218                 ret.context = this.context;
219
220                 if ( name === "find" ) {
221                         ret.selector = this.selector + (this.selector ? " " : "") + selector;
222                 } else if ( name ) {
223                         ret.selector = this.selector + "." + name + "(" + selector + ")";
224                 }
225
226                 // Return the newly-formed element set
227                 return ret;
228         },
229
230         // Execute a callback for every element in the matched set.
231         // (You can seed the arguments with an array of args, but this is
232         // only used internally.)
233         each: function( callback, args ) {
234                 return jQuery.each( this, callback, args );
235         },
236         
237         ready: function( fn ) {
238                 // Attach the listeners
239                 jQuery.bindReady();
240
241                 // If the DOM is already ready
242                 if ( jQuery.isReady ) {
243                         // Execute the function immediately
244                         fn.call( document, jQuery );
245
246                 // Otherwise, remember the function for later
247                 } else if ( readyList ) {
248                         // Add the function to the wait list
249                         readyList.push( fn );
250                 }
251
252                 return this;
253         },
254         
255         eq: function( i ) {
256                 return i === -1 ?
257                         this.slice( i ) :
258                         this.slice( i, +i + 1 );
259         },
260
261         first: function() {
262                 return this.eq( 0 );
263         },
264
265         last: function() {
266                 return this.eq( -1 );
267         },
268
269         slice: function() {
270                 return this.pushStack( slice.apply( this, arguments ),
271                         "slice", slice.call(arguments).join(",") );
272         },
273
274         map: function( callback ) {
275                 return this.pushStack( jQuery.map(this, function( elem, i ) {
276                         return callback.call( elem, i, elem );
277                 }));
278         },
279         
280         end: function() {
281                 return this.prevObject || jQuery(null);
282         },
283
284         // For internal use only.
285         // Behaves like an Array's method, not like a jQuery method.
286         push: push,
287         sort: [].sort,
288         splice: [].splice
289 };
290
291 // Give the init function the jQuery prototype for later instantiation
292 jQuery.fn.init.prototype = jQuery.fn;
293
294 jQuery.extend = jQuery.fn.extend = function() {
295         // copy reference to target object
296         var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
297
298         // Handle a deep copy situation
299         if ( typeof target === "boolean" ) {
300                 deep = target;
301                 target = arguments[1] || {};
302                 // skip the boolean and the target
303                 i = 2;
304         }
305
306         // Handle case when target is a string or something (possible in deep copy)
307         if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
308                 target = {};
309         }
310
311         // extend jQuery itself if only one argument is passed
312         if ( length === i ) {
313                 target = this;
314                 --i;
315         }
316
317         for ( ; i < length; i++ ) {
318                 // Only deal with non-null/undefined values
319                 if ( (options = arguments[ i ]) != null ) {
320                         // Extend the base object
321                         for ( name in options ) {
322                                 src = target[ name ];
323                                 copy = options[ name ];
324
325                                 // Prevent never-ending loop
326                                 if ( target === copy ) {
327                                         continue;
328                                 }
329
330                                 // Recurse if we're merging object literal values or arrays
331                                 if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
332                                         var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
333                                                 : jQuery.isArray(copy) ? [] : {};
334
335                                         // Never move original objects, clone them
336                                         target[ name ] = jQuery.extend( deep, clone, copy );
337
338                                 // Don't bring in undefined values
339                                 } else if ( copy !== undefined ) {
340                                         target[ name ] = copy;
341                                 }
342                         }
343                 }
344         }
345
346         // Return the modified object
347         return target;
348 };
349
350 jQuery.extend({
351         noConflict: function( deep ) {
352                 window.$ = _$;
353
354                 if ( deep ) {
355                         window.jQuery = _jQuery;
356                 }
357
358                 return jQuery;
359         },
360         
361         // Is the DOM ready to be used? Set to true once it occurs.
362         isReady: false,
363         
364         // Handle when the DOM is ready
365         ready: function() {
366                 // Make sure that the DOM is not already loaded
367                 if ( !jQuery.isReady ) {
368                         // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
369                         if ( !document.body ) {
370                                 return setTimeout( jQuery.ready, 13 );
371                         }
372
373                         // Remember that the DOM is ready
374                         jQuery.isReady = true;
375
376                         // If there are functions bound, to execute
377                         if ( readyList ) {
378                                 // Execute all of them
379                                 var fn, i = 0;
380                                 while ( (fn = readyList[ i++ ]) ) {
381                                         fn.call( document, jQuery );
382                                 }
383
384                                 // Reset the list of functions
385                                 readyList = null;
386                         }
387
388                         // Trigger any bound ready events
389                         if ( jQuery.fn.triggerHandler ) {
390                                 jQuery( document ).triggerHandler( "ready" );
391                         }
392                 }
393         },
394         
395         bindReady: function() {
396                 if ( readyBound ) {
397                         return;
398                 }
399
400                 readyBound = true;
401
402                 // Catch cases where $(document).ready() is called after the
403                 // browser event has already occurred.
404                 if ( document.readyState === "complete" ) {
405                         return jQuery.ready();
406                 }
407
408                 // Mozilla, Opera and webkit nightlies currently support this event
409                 if ( document.addEventListener ) {
410                         // Use the handy event callback
411                         document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
412                         
413                         // A fallback to window.onload, that will always work
414                         window.addEventListener( "load", jQuery.ready, false );
415
416                 // If IE event model is used
417                 } else if ( document.attachEvent ) {
418                         // ensure firing before onload,
419                         // maybe late but safe also for iframes
420                         document.attachEvent("onreadystatechange", DOMContentLoaded);
421                         
422                         // A fallback to window.onload, that will always work
423                         window.attachEvent( "onload", jQuery.ready );
424
425                         // If IE and not a frame
426                         // continually check to see if the document is ready
427                         var toplevel = false;
428
429                         try {
430                                 toplevel = window.frameElement == null;
431                         } catch(e) {}
432
433                         if ( document.documentElement.doScroll && toplevel ) {
434                                 doScrollCheck();
435                         }
436                 }
437         },
438
439         // See test/unit/core.js for details concerning isFunction.
440         // Since version 1.3, DOM methods and functions like alert
441         // aren't supported. They return false on IE (#2968).
442         isFunction: function( obj ) {
443                 return jQuery.type(obj) === "function";
444         },
445
446         isArray: Array.isArray || function( obj ) {
447                 return jQuery.type(obj) === "array";
448         },
449
450         type: function( obj ) {
451                 return obj == null ?
452                         String( obj ) :
453                         toString.call(obj).slice(8, -1).toLowerCase();
454         },
455
456         isPlainObject: function( obj ) {
457                 // Must be an Object.
458                 // Because of IE, we also have to check the presence of the constructor property.
459                 // Make sure that DOM nodes and window objects don't pass through, as well
460                 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || obj.setInterval ) {
461                         return false;
462                 }
463                 
464                 // Not own constructor property must be Object
465                 if ( obj.constructor &&
466                         !hasOwn.call(obj, "constructor") &&
467                         !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
468                         return false;
469                 }
470                 
471                 // Own properties are enumerated firstly, so to speed up,
472                 // if last one is own, then all properties are own.
473         
474                 var key;
475                 for ( key in obj ) {}
476                 
477                 return key === undefined || hasOwn.call( obj, key );
478         },
479
480         isEmptyObject: function( obj ) {
481                 for ( var name in obj ) {
482                         return false;
483                 }
484                 return true;
485         },
486         
487         error: function( msg ) {
488                 throw msg;
489         },
490         
491         parseJSON: function( data ) {
492                 if ( typeof data !== "string" || !data ) {
493                         return null;
494                 }
495
496                 // Make sure leading/trailing whitespace is removed (IE can't handle it)
497                 data = jQuery.trim( data );
498                 
499                 // Make sure the incoming data is actual JSON
500                 // Logic borrowed from http://json.org/json2.js
501                 if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
502                         .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
503                         .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
504
505                         // Try to use the native JSON parser first
506                         return window.JSON && window.JSON.parse ?
507                                 window.JSON.parse( data ) :
508                                 (new Function("return " + data))();
509
510                 } else {
511                         jQuery.error( "Invalid JSON: " + data );
512                 }
513         },
514
515         noop: function() {},
516
517         // Evalulates a script in a global context
518         globalEval: function( data ) {
519                 if ( data && rnotwhite.test(data) ) {
520                         // Inspired by code by Andrea Giammarchi
521                         // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
522                         var head = document.getElementsByTagName("head")[0] || document.documentElement,
523                                 script = document.createElement("script");
524
525                         script.type = "text/javascript";
526
527                         if ( jQuery.support.scriptEval ) {
528                                 script.appendChild( document.createTextNode( data ) );
529                         } else {
530                                 script.text = data;
531                         }
532
533                         // Use insertBefore instead of appendChild to circumvent an IE6 bug.
534                         // This arises when a base node is used (#2709).
535                         head.insertBefore( script, head.firstChild );
536                         head.removeChild( script );
537                 }
538         },
539
540         nodeName: function( elem, name ) {
541                 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
542         },
543
544         // args is for internal usage only
545         each: function( object, callback, args ) {
546                 var name, i = 0,
547                         length = object.length,
548                         isObj = length === undefined || jQuery.isFunction(object);
549
550                 if ( args ) {
551                         if ( isObj ) {
552                                 for ( name in object ) {
553                                         if ( callback.apply( object[ name ], args ) === false ) {
554                                                 break;
555                                         }
556                                 }
557                         } else {
558                                 for ( ; i < length; ) {
559                                         if ( callback.apply( object[ i++ ], args ) === false ) {
560                                                 break;
561                                         }
562                                 }
563                         }
564
565                 // A special, fast, case for the most common use of each
566                 } else {
567                         if ( isObj ) {
568                                 for ( name in object ) {
569                                         if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
570                                                 break;
571                                         }
572                                 }
573                         } else {
574                                 for ( var value = object[0];
575                                         i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
576                         }
577                 }
578
579                 return object;
580         },
581
582         // Use native String.trim function wherever possible
583         trim: trim ?
584                 function( text ) {
585                         return text == null ?
586                                 "" :
587                                 trim.call( text );
588                 } :
589
590                 // Otherwise use our own trimming functionality
591                 function( text ) {
592                         return text == null ?
593                                 "" :
594                                 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
595                 },
596
597         // results is for internal usage only
598         makeArray: function( array, results ) {
599                 var ret = results || [];
600
601                 if ( array != null ) {
602                         // The window, strings (and functions) also have 'length'
603                         // The extra typeof function check is to prevent crashes
604                         // in Safari 2 (See: #3039)
605                         // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
606                         var type = jQuery.type(array);
607
608                         if ( array.length == null || type === "string" || type === "function" || type === "regexp" || "setInterval" in array ) {
609                                 push.call( ret, array );
610                         } else {
611                                 jQuery.merge( ret, array );
612                         }
613                 }
614
615                 return ret;
616         },
617
618         inArray: function( elem, array ) {
619                 if ( array.indexOf ) {
620                         return array.indexOf( elem );
621                 }
622
623                 for ( var i = 0, length = array.length; i < length; i++ ) {
624                         if ( array[ i ] === elem ) {
625                                 return i;
626                         }
627                 }
628
629                 return -1;
630         },
631
632         merge: function( first, second ) {
633                 var i = first.length, j = 0;
634
635                 if ( typeof second.length === "number" ) {
636                         for ( var l = second.length; j < l; j++ ) {
637                                 first[ i++ ] = second[ j ];
638                         }
639                 
640                 } else {
641                         while ( second[j] !== undefined ) {
642                                 first[ i++ ] = second[ j++ ];
643                         }
644                 }
645
646                 first.length = i;
647
648                 return first;
649         },
650
651         grep: function( elems, callback, inv ) {
652                 var ret = [], retVal;
653                 inv = !!inv;
654
655                 // Go through the array, only saving the items
656                 // that pass the validator function
657                 for ( var i = 0, length = elems.length; i < length; i++ ) {
658                         retVal = !!callback( elems[ i ], i );
659                         if ( inv !== retVal ) {
660                                 ret.push( elems[ i ] );
661                         }
662                 }
663
664                 return ret;
665         },
666
667         // arg is for internal usage only
668         map: function( elems, callback, arg ) {
669                 var ret = [], value;
670
671                 // Go through the array, translating each of the items to their
672                 // new value (or values).
673                 for ( var i = 0, length = elems.length; i < length; i++ ) {
674                         value = callback( elems[ i ], i, arg );
675
676                         if ( value != null ) {
677                                 ret[ ret.length ] = value;
678                         }
679                 }
680
681                 return ret.concat.apply( [], ret );
682         },
683
684         // A global GUID counter for objects
685         guid: 1,
686
687         proxy: function( fn, proxy, thisObject ) {
688                 if ( arguments.length === 2 ) {
689                         if ( typeof proxy === "string" ) {
690                                 thisObject = fn;
691                                 fn = thisObject[ proxy ];
692                                 proxy = undefined;
693
694                         } else if ( proxy && !jQuery.isFunction( proxy ) ) {
695                                 thisObject = proxy;
696                                 proxy = undefined;
697                         }
698                 }
699
700                 if ( !proxy && fn ) {
701                         proxy = function() {
702                                 return fn.apply( thisObject || this, arguments );
703                         };
704                 }
705
706                 // Set the guid of unique handler to the same of original handler, so it can be removed
707                 if ( fn ) {
708                         proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
709                 }
710
711                 // So proxy can be declared as an argument
712                 return proxy;
713         },
714
715         // Mutifunctional method to get and set values to a collection
716         // The value/s can be optionally by executed if its a function
717         access: function( elems, key, value, exec, fn, pass ) {
718                 var length = elems.length;
719         
720                 // Setting many attributes
721                 if ( typeof key === "object" ) {
722                         for ( var k in key ) {
723                                 jQuery.access( elems, k, key[k], exec, fn, value );
724                         }
725                         return elems;
726                 }
727         
728                 // Setting one attribute
729                 if ( value !== undefined ) {
730                         // Optionally, function values get executed if exec is true
731                         exec = !pass && exec && jQuery.isFunction(value);
732                 
733                         for ( var i = 0; i < length; i++ ) {
734                                 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
735                         }
736                 
737                         return elems;
738                 }
739         
740                 // Getting an attribute
741                 return length ? fn( elems[0], key ) : undefined;
742         },
743
744         now: function() {
745                 return (new Date()).getTime();
746         },
747
748         // Use of jQuery.browser is frowned upon.
749         // More details: http://docs.jquery.com/Utilities/jQuery.browser
750         uaMatch: function( ua ) {
751                 ua = ua.toLowerCase();
752
753                 var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
754                         /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||
755                         /(msie) ([\w.]+)/.exec( ua ) ||
756                         !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||
757                         [];
758
759                 return { browser: match[1] || "", version: match[2] || "0" };
760         },
761
762         browser: {}
763 });
764
765 browserMatch = jQuery.uaMatch( userAgent );
766 if ( browserMatch.browser ) {
767         jQuery.browser[ browserMatch.browser ] = true;
768         jQuery.browser.version = browserMatch.version;
769 }
770
771 // Deprecated, use jQuery.browser.webkit instead
772 if ( jQuery.browser.webkit ) {
773         jQuery.browser.safari = true;
774 }
775
776 if ( indexOf ) {
777         jQuery.inArray = function( elem, array ) {
778                 return indexOf.call( array, elem );
779         };
780 }
781
782 // Verify that \s matches non-breaking spaces
783 // (IE fails on this test)
784 if ( !/\s/.test( "\xA0" ) ) {
785         trimLeft = /^[\s\xA0]+/;
786         trimRight = /[\s\xA0]+$/;
787 }
788
789 // All jQuery objects should point back to these
790 rootjQuery = jQuery(document);
791
792 // Cleanup functions for the document ready method
793 if ( document.addEventListener ) {
794         DOMContentLoaded = function() {
795                 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
796                 jQuery.ready();
797         };
798
799 } else if ( document.attachEvent ) {
800         DOMContentLoaded = function() {
801                 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
802                 if ( document.readyState === "complete" ) {
803                         document.detachEvent( "onreadystatechange", DOMContentLoaded );
804                         jQuery.ready();
805                 }
806         };
807 }
808
809 // The DOM ready check for Internet Explorer
810 function doScrollCheck() {
811         if ( jQuery.isReady ) {
812                 return;
813         }
814
815         try {
816                 // If IE is used, use the trick by Diego Perini
817                 // http://javascript.nwbox.com/IEContentLoaded/
818                 document.documentElement.doScroll("left");
819         } catch(e) {
820                 setTimeout( doScrollCheck, 1 );
821                 return;
822         }
823
824         // and execute any waiting functions
825         jQuery.ready();
826 }
827
828 // Expose jQuery to the global object
829 return window.jQuery = window.$ = jQuery;
830
831 })();