Blame | Last modification | View Log | RSS feed
define(["../core","../core/init","../deferred"], function( jQuery ) {// The deferred used on DOM readyvar readyList;jQuery.fn.ready = function( fn ) {// Add the callbackjQuery.ready.promise().done( fn );return this;};jQuery.extend({// 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 #6781readyWait: 1,// Hold (or release) the ready eventholdReady: function( hold ) {if ( hold ) {jQuery.readyWait++;} else {jQuery.ready( true );}},// Handle when the DOM is readyready: function( wait ) {// Abort if there are pending holds or we're already readyif ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {return;}// Remember that the DOM is readyjQuery.isReady = true;// If a normal DOM Ready event fired, decrement, and wait if need beif ( wait !== true && --jQuery.readyWait > 0 ) {return;}// If there are functions bound, to executereadyList.resolveWith( document, [ jQuery ] );// Trigger any bound ready eventsif ( jQuery.fn.triggerHandler ) {jQuery( document ).triggerHandler( "ready" );jQuery( document ).off( "ready" );}}});/*** The ready event handler and self cleanup method*/function completed() {document.removeEventListener( "DOMContentLoaded", completed, false );window.removeEventListener( "load", completed, false );jQuery.ready();}jQuery.ready.promise = function( obj ) {if ( !readyList ) {readyList = jQuery.Deferred();// Catch cases where $(document).ready() is called after the browser event has already occurred.// We once tried to use readyState "interactive" here, but it caused issues like the one// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15if ( document.readyState === "complete" ) {// Handle it asynchronously to allow scripts the opportunity to delay readysetTimeout( jQuery.ready );} else {// Use the handy event callbackdocument.addEventListener( "DOMContentLoaded", completed, false );// A fallback to window.onload, that will always workwindow.addEventListener( "load", completed, false );}}return readyList.promise( obj );};// Kick off the DOM ready check even if the user does notjQuery.ready.promise();});