Skip to content

Instantly share code, notes, and snippets.

@brianjmiller
Created March 2, 2012 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjmiller/1959701 to your computer and use it in GitHub Desktop.
Save brianjmiller/1959701 to your computer and use it in GitHub Desktop.
YUI example
YUI().use(
"console",
"ep-ui-builder",
function (Y) {
Y.on(
"domready",
function () {
Y.log("index - building UI");
try {
Y.EP.UI.Build ();
}
catch (ex) {
Y.log("index - in UI build catch");
Y.one("#ui-loading").remove();
Y.one("body").setContent("Failed to build UI: " + ex);
throw(ex);
return;
}
// hide our loading screen
Y.log("index - hiding loading message");
Y.on(
'contentready',
function () {
Y.log("index - contentready");
Y.one("#ui-loading").remove();
},
'#ep-ui-window'
);
}
);
}
);
YUI.add(
"ep-ui-builder",
function (Y) {
var Clazz = Y.Base.create (
"ep_ui_builder",
Y.Base,
[],
{
_left: null,
_right: null,
initializer: function (config) {
Y.log(Clazz.NAME + "::initializer");
this._right = new Y.EP.UI.Right (
{
render: true
}
);
this._left = new Y.EP.UI.Left (
{
render: true
}
);
},
destructor: function () {
Y.log(Clazz.NAME + "::destructor");
this._left.destroy();
this._left = null;
this._right.destroy();
this._right = null;
},
{
ATTRS: {}
}
);
//
// set up a function to build a singleton to wrap access to the UI builder
// by creating an instance if one doesn't already exist, otherwise returns
// the existing one the build method should then only ever be called once
//
var instance = null;
Y.namespace("EP.UI").Build = function (config) {
if (! instance) {
instance = new Clazz (config);
}
return instance;
};
},
"@VERSION@",
{
requires: [
"base-build"
,"ep-ui-left"
,"ep-ui-right"
]
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment