forked from davglass/davglass.github.com
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
<html> | ||
<head> | ||
<title>QuickYUI Example</title> | ||
</head> | ||
<body> | ||
|
||
|
||
<script src="http://yui.yahooapis.com/combo?3.1.0pr2/build/yui/yui-min.js&3.1.0pr2/build/oop/oop-min.js&3.1.0pr2/build/dom/dom-min.js&3.1.0pr2/build/event/event-min.js&3.1.0pr2/build/event-custom/event-custom-min.js&3.1.0pr2/build/event/event-base-min.js&3.1.0pr2/build/pluginhost/pluginhost-min.js&3.1.0pr2/build/node/node-min.js&3.1.0pr2/build/event/event-delegate-min.js&3.1.0pr2/build/attribute/attribute-base-min.js&3.1.0pr2/build/base/base-min.js&3.1.0pr2/build/event/event-resize-min.js&3.1.0pr2/build/dd/dd-min.js"></script> | ||
<script src="./quickyui.js"></script> | ||
<script> | ||
|
||
Y.ready(function() { | ||
Y.one('body').setStyle('backgroundColor', 'red').append('<p>Ready #1 called</p>'); | ||
}); | ||
|
||
Y.ready(function() { | ||
Y.one('body').setStyle('backgroundColor', 'blue').append('<p>Ready #2 called</p>'); | ||
}); | ||
Y.ready(function() { | ||
Y.one('body').setStyle('color', 'white').append('<p>Ready #3 called</p>'); | ||
}); | ||
|
||
</script> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* @property Y | ||
* A single global instance of YUI | ||
*/ | ||
Y = YUI(); | ||
/** | ||
* @property _cbs | ||
* @private | ||
* @type Array | ||
* A simple array of callbacks passed to Y.ready | ||
*/ | ||
Y._cbs = []; | ||
/** | ||
* @property _ready | ||
* @private | ||
* @type Boolean | ||
* Flag to determine if the callback from use has fired. | ||
*/ | ||
Y._ready = false; | ||
/** | ||
* @method _fireReady | ||
* @private | ||
* Fire all the stored callbacks from the .use callback. | ||
*/ | ||
|
||
Y._fireReady = function() { | ||
if (Y._cbs.length) { | ||
Y.each(Y._cbs, function(v, k) { | ||
if (v) { | ||
v.call(Y, Y); | ||
Y._cbs[k] = null; | ||
} | ||
}); | ||
Y._cbs = []; | ||
} | ||
}; | ||
|
||
/** | ||
* @method ready | ||
* Default listener for the .use callback. | ||
* @param {Function} fn The function to execute when the .use callback is fired | ||
*/ | ||
Y.ready = function(fn) { | ||
if (Y._ready) { | ||
fn.call(Y, Y); | ||
} else { | ||
Y._cbs.push(fn); | ||
} | ||
}; | ||
|
||
/* | ||
* Here we use everything on the page and fire the .ready callbacks | ||
*/ | ||
Y.use('*', function(Y) { | ||
Y._ready = true; | ||
Y._fireReady(); | ||
}); |