Sha256: 701ec0425ca8e424daa3395d420c1dead2bc0b8ad8ee24cdb6b8445dc05f0185

Contents?: true

Size: 1.29 KB

Versions: 24

Compression:

Stored size: 1.29 KB

Contents

//>>excludeStart("exclude", pragmas.exclude);
define([ "shoestring" ], function(){
//>>excludeEnd("exclude");

  /**
	 * Bind callbacks to be run when the DOM is "ready".
	 *
	 * @param {function} fn The callback to be run
	 * @return shoestring
	 * @this shoestring
	 */
	shoestring.ready = function( fn ){
		if( ready && fn ){
			fn.call( doc );
		}
		else if( fn ){
			readyQueue.push( fn );
		}
		else {
			runReady();
		}

		return [doc];
	};

	// TODO necessary?
	shoestring.fn.ready = function( fn ){
		shoestring.ready( fn );
		return this;
	};

	// Empty and exec the ready queue
	var ready = false,
		readyQueue = [],
		runReady = function(){
			if( !ready ){
				while( readyQueue.length ){
					readyQueue.shift().call( doc );
				}
				ready = true;
			}
		};

	// If DOM is already ready at exec time, depends on the browser.
	// From: https://github.com/mobify/mobifyjs/blob/526841be5509e28fc949038021799e4223479f8d/src/capture.js#L128
	if (doc.attachEvent ? doc.readyState === "complete" : doc.readyState !== "loading") {
		runReady();
	} else {
		doc.addEventListener( "DOMContentLoaded", runReady, false );
		doc.addEventListener( "readystatechange", runReady, false );
		win.addEventListener( "load", runReady, false );
	}

//>>excludeStart("exclude", pragmas.exclude);
});
//>>excludeEnd("exclude");

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/shoestring/src/core/ready.js
trusty-cms-5.0.7 node_modules/shoestring/src/core/ready.js
trusty-cms-5.0.6 node_modules/shoestring/src/core/ready.js
trusty-cms-5.0.5 node_modules/shoestring/src/core/ready.js
trusty-cms-5.0.4 node_modules/shoestring/src/core/ready.js
trusty-cms-5.0.3 node_modules/shoestring/src/core/ready.js
trusty-cms-5.0.2 node_modules/shoestring/src/core/ready.js
trusty-cms-5.0.1 node_modules/shoestring/src/core/ready.js
trusty-cms-4.3.5 node_modules/shoestring/src/core/ready.js
trusty-cms-5.0.0 node_modules/shoestring/src/core/ready.js
trusty-cms-4.3.4 node_modules/shoestring/src/core/ready.js
trusty-cms-4.3.3 node_modules/shoestring/src/core/ready.js
trusty-cms-4.3.2 node_modules/shoestring/src/core/ready.js
trusty-cms-4.3.1 node_modules/shoestring/src/core/ready.js
trusty-cms-4.3 node_modules/shoestring/src/core/ready.js
trusty-cms-4.2.3 node_modules/shoestring/src/core/ready.js
trusty-cms-4.2.2 node_modules/shoestring/src/core/ready.js
trusty-cms-4.2.1 node_modules/shoestring/src/core/ready.js
trusty-cms-4.2 node_modules/shoestring/src/core/ready.js
trusty-cms-4.1.9 node_modules/shoestring/src/core/ready.js