Permalink
Browse files

new folder structure ready, adding also yui_bootstrap object is ready.

  • Loading branch information...
1 parent 0b78427 commit 6902207fe85703dc04fae000fc2a350a92b61646 @caridy committed May 21, 2009
View
12 .project
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bootstrap</name>
+ <comment></comment>
+ <projects>
+ <project>bubbling-examples</project>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
View
242 build/bootstrap/bootstrap-debug.js
@@ -0,0 +1,242 @@
+/**
+ * Provides Bootstrap definition based on YUI 2.x.
+ *
+ * ---
+ *
+ * @module bootstrap
+ */
+
+/**
+ * Provides Bootstrap methods.
+ *
+ * @class Bootstrap
+ * @static
+ */
+(function() {
+
+ var _config = null,
+ _loaderObj = null,
+ _loaderQueue = [];
+ /**
+ * Continue with the loading process, removing the first set from the list,
+ * and continue with the next in line.
+ * @method _loaderNext
+ * @private
+ * @static
+ * @param {Boolean} notify Whether or not the callback method should be called.
+ * @return void
+ */
+ function _loaderNext (notify) {
+ var i = _loaderQueue.pop();
+ /* we want to speed up the loading process, so, the first thing we do
+ is actually starting the loading process for the next region */
+ _loaderDispatch();
+ if (notify && i) {
+ /* notifying thru the callback function that everything was ok */
+ i.callback.call();
+ }
+ }
+ /**
+ * Finishing with the current item int queue, and starting with the next one
+ * @method _loaderDispatch
+ * @private
+ * @static
+ * @return void
+ */
+ function _loaderDispatch () {
+ var c;
+ if (_loaderQueue.length > 0) {
+ c = _loaderQueue[0];
+ c.require = c.require || [];
+ console.log ('[Bootstrap] [Loader Queue] loading... ', c.require);
+ _loaderObj.require(c.require);
+ _loaderObj.insert({
+ onSuccess: function () {
+ console.log ('[Bootstrap] [Loader Queue] success...');
+ _loaderNext(true);
+ (c.config.onSuccess || function(){}).call();
+ },
+ onFailure: function(){
+ console.log ('[Bootstrap] [Loader Queue] failure...');
+ _loaderNext();
+ (c.config.onFailure || function(){}).call();
+ },
+ onTimeout: function () {
+ console.log ('[Bootstrap] [Loader Queue] timeout...');
+ _loaderNext();
+ (c.config.onTimeout || function(){}).call();
+ }
+ }, c.type);
+ }
+ }
+ /**
+ * <p>
+ * execute the internal initialization process for the region
+ * </p>
+ * @method init
+ * @return {Object} region reference to support chaining
+ */
+ function _initLoader (l) {
+ console.log ('[Bootstrap] creating: ', l);
+ /* creating the loader object for this region */
+ l = l || {};
+ l.combine = (l.hasOwnProperty('combine')?l.combine:true); /* using the Combo Handle */
+ l.combine = !this._debug;
+ l.filter = l.filter || 'min'; /* you can switch between YUI branch */
+ l.filter = (this._debug?'debug':l.filter);
+
+ // more config here ...
+
+ _loaderObj = _loaderObj || new YAHOO.util.YUILoader(l);
+ }
+
+ function _addMods (m) {
+ var i;
+ if (m && (typeof m === 'object')) {
+ for (i in m) {
+ if (m.hasOwnProperty(i)) {
+ m[i].name = i;
+ _loaderObj.addModule (m[i]);
+ }
+ }
+ }
+ }
+
+ /**
+ * YAHOO_bootstrap function. If YAHOO_bootstrap is already defined, the
+ * existing YAHOO_bootstrap functino will not be overwritten to preserve
+ * the state of the bootstrap.
+ *
+ * @class YAHOO_bootstrap
+ * @constructor
+ * @global
+ * @param o Optional configuration object. Options:
+ * <ul>
+ * <li>------------------------------------------------------------------------</li>
+ * <li>Global:</li>
+ * <li>------------------------------------------------------------------------</li>
+ * <li>debug: Turn debug statements on or off</li>
+ * <li>injected: set to true if the yui seed file was dynamically loaded in
+ * order to bootstrap components relying on the window load event and onDOMReady
+ * (former injecting on YAHOO_config).</li>
+ * <li>locale: default locale</li>
+ * <li>-------------------------------------------------------------------------</li>
+ * <li>For loader:</li>
+ * <li>-------------------------------------------------------------------------</li>
+ * <li>base: The base dir</li>
+ * <li>comboBase: The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
+ * <li>root: The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li>
+ * <li>filter:
+ *
+ * A filter to apply to result urls. This filter will modify the default
+ * path for all modules. The default path for the YUI library is the
+ * minified version of the files (e.g., event-min.js). The filter property
+ * can be a predefined filter or a custom filter. The valid predefined
+ * filters are:
+ * <dl>
+ * <dt>DEBUG</dt>
+ * <dd>Selects the debug versions of the library (e.g., event-debug.js).
+ * This option will automatically include the Logger widget</dd>
+ * <dt>RAW</dt>
+ * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
+ * </dl>
+ * You can also define a custom filter, which must be an object literal
+ * containing a search expression and a replace string:
+ * <pre>
+ * myFilter: &#123;
+ * 'searchExp': "-min\\.js",
+ * 'replaceStr': "-debug.js"
+ * &#125;
+ * </pre>
+ *
+ * </li>
+ * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li>
+ * <li>combine:
+ * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
+ * <li>ignore:
+ * A list of modules that should never be dynamically loaded</li>
+ * <li>force:
+ * A list of modules that should always be loaded when required, even if already present on the page</li>
+ * <li>insertBefore:
+ * Node or id for a node that should be used as the insertion point for new nodes</li>
+ * <li>charset:
+ * charset for dynamic nodes</li>
+ * <li>timeout:
+ * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
+ * <li>onSuccess:
+ * callback for the 'success' event</li>
+ * <li>onFailure:
+ * callback for the 'failure' event</li>
+ * <li>onTimeout:
+ * callback for the 'timeout' event</li>
+ * <li>onProgress:
+ * callback executed each time a script or css file is loaded</li>
+ * <li>modules:
+ * A list of module definitions. See Loader.addModule for the supported module metadata</li>
+ * </ul>
+ */
+ YAHOO_bootstrap = function (o) {
+
+ // analyzing "o"
+ o = o || _config || {};
+
+ // initializing the bootstrap only once
+ if (!_loaderObj) {
+ _initLoader(o);
+ }
+
+ // adding the
+ _addMods (o.modules);
+
+ return {
+ /**
+ * Load a set of modules and notify thru the callback method.
+ * @param modules* {string} 1-n modules to bind (uses arguments array)
+ * @param *callback {function} callback function executed when
+ * the instance has the required functionality. If included, it
+ * must be the last parameter.
+ *
+ * YAHOO_bootstrap().use('tabview')
+ *
+ * @return void
+ */
+ use: function () {
+ var a=Array.prototype.slice.call(arguments, 0),
+ callback = a.pop ();
+ if (callback) {
+ if (a && a.length > 0) {
+ // using the YUI loader utility to load the requirements...
+ _loaderQueue.push ({
+ require: a,
+ config: o,
+ callback: callback
+ });
+ if (_loaderQueue.length == 1) {
+ _loaderDispatch();
+ }
+ } else {
+ callback.call ();
+ }
+ }
+ },
+ /**
+ * Set the default configuration for the loader.
+ * @param o {object} default configuration object for the bootstrap,
+ * basically "o" can be used to define the global configuration once in
+ * your application, instead of including the configuration for each single
+ * bootstrap call.
+ *
+ * YAHOO_bootstrap(o).setAsDefault()
+ *
+ * @return void
+ */
+ setAsDefault: function (o) {
+ if (o) {
+ _config = o || {};
+ }
+ }
+ };
+ };
+
+})();
+YAHOO.register("bootstrap", YAHOO_bootstrap, {version: "@VERSION@", build: "@BUILD@"});
View
1 build/bootstrap/bootstrap-min.js
@@ -0,0 +1 @@
+(function(){var E=null,G=null,A=[];function D(I){var H=A.pop();C();if(I&&H){H.callback.call();}}function C(){var H;if(A.length>0){H=A[0];H.require=H.require||[];console.log("[Bootstrap] [Loader Queue] loading... ",H.require);G.require(H.require);G.insert({onSuccess:function(){console.log("[Bootstrap] [Loader Queue] success...");D(true);(H.config.onSuccess||function(){}).call();},onFailure:function(){console.log("[Bootstrap] [Loader Queue] failure...");D();(H.config.onFailure||function(){}).call();},onTimeout:function(){console.log("[Bootstrap] [Loader Queue] timeout...");D();(H.config.onTimeout||function(){}).call();}},H.type);}}function F(H){console.log("[Bootstrap] creating: ",H);H=H||{};H.combine=(H.hasOwnProperty("combine")?H.combine:true);H.combine=!this._debug;H.filter=H.filter||"min";H.filter=(this._debug?"debug":H.filter);G=G||new YAHOO.util.YUILoader(H);}function B(H){var I;if(H&&(typeof H==="object")){for(I in H){if(H.hasOwnProperty(I)){H[I].name=I;G.addModule(H[I]);}}}}YAHOO_bootstrap=function(H){H=H||E||{};if(!G){F(H);}B(H.modules);return{use:function(){var I=Array.prototype.slice.call(arguments,0),J=I.pop();if(J){if(I&&I.length>0){A.push({require:I,config:H,callback:J});if(A.length==1){C();}}else{J.call();}}},setAsDefault:function(I){if(I){E=I||{};}}};};})();YAHOO.register("bootstrap",YAHOO_bootstrap,{version:"@VERSION@",build:"@BUILD@"});
View
242 build/bootstrap/bootstrap.js
@@ -0,0 +1,242 @@
+/**
+ * Provides Bootstrap definition based on YUI 2.x.
+ *
+ * ---
+ *
+ * @module bootstrap
+ */
+
+/**
+ * Provides Bootstrap methods.
+ *
+ * @class Bootstrap
+ * @static
+ */
+(function() {
+
+ var _config = null,
+ _loaderObj = null,
+ _loaderQueue = [];
+ /**
+ * Continue with the loading process, removing the first set from the list,
+ * and continue with the next in line.
+ * @method _loaderNext
+ * @private
+ * @static
+ * @param {Boolean} notify Whether or not the callback method should be called.
+ * @return void
+ */
+ function _loaderNext (notify) {
+ var i = _loaderQueue.pop();
+ /* we want to speed up the loading process, so, the first thing we do
+ is actually starting the loading process for the next region */
+ _loaderDispatch();
+ if (notify && i) {
+ /* notifying thru the callback function that everything was ok */
+ i.callback.call();
+ }
+ }
+ /**
+ * Finishing with the current item int queue, and starting with the next one
+ * @method _loaderDispatch
+ * @private
+ * @static
+ * @return void
+ */
+ function _loaderDispatch () {
+ var c;
+ if (_loaderQueue.length > 0) {
+ c = _loaderQueue[0];
+ c.require = c.require || [];
+ console.log ('[Bootstrap] [Loader Queue] loading... ', c.require);
+ _loaderObj.require(c.require);
+ _loaderObj.insert({
+ onSuccess: function () {
+ console.log ('[Bootstrap] [Loader Queue] success...');
+ _loaderNext(true);
+ (c.config.onSuccess || function(){}).call();
+ },
+ onFailure: function(){
+ console.log ('[Bootstrap] [Loader Queue] failure...');
+ _loaderNext();
+ (c.config.onFailure || function(){}).call();
+ },
+ onTimeout: function () {
+ console.log ('[Bootstrap] [Loader Queue] timeout...');
+ _loaderNext();
+ (c.config.onTimeout || function(){}).call();
+ }
+ }, c.type);
+ }
+ }
+ /**
+ * <p>
+ * execute the internal initialization process for the region
+ * </p>
+ * @method init
+ * @return {Object} region reference to support chaining
+ */
+ function _initLoader (l) {
+ console.log ('[Bootstrap] creating: ', l);
+ /* creating the loader object for this region */
+ l = l || {};
+ l.combine = (l.hasOwnProperty('combine')?l.combine:true); /* using the Combo Handle */
+ l.combine = !this._debug;
+ l.filter = l.filter || 'min'; /* you can switch between YUI branch */
+ l.filter = (this._debug?'debug':l.filter);
+
+ // more config here ...
+
+ _loaderObj = _loaderObj || new YAHOO.util.YUILoader(l);
+ }
+
+ function _addMods (m) {
+ var i;
+ if (m && (typeof m === 'object')) {
+ for (i in m) {
+ if (m.hasOwnProperty(i)) {
+ m[i].name = i;
+ _loaderObj.addModule (m[i]);
+ }
+ }
+ }
+ }
+
+ /**
+ * YAHOO_bootstrap function. If YAHOO_bootstrap is already defined, the
+ * existing YAHOO_bootstrap functino will not be overwritten to preserve
+ * the state of the bootstrap.
+ *
+ * @class YAHOO_bootstrap
+ * @constructor
+ * @global
+ * @param o Optional configuration object. Options:
+ * <ul>
+ * <li>------------------------------------------------------------------------</li>
+ * <li>Global:</li>
+ * <li>------------------------------------------------------------------------</li>
+ * <li>debug: Turn debug statements on or off</li>
+ * <li>injected: set to true if the yui seed file was dynamically loaded in
+ * order to bootstrap components relying on the window load event and onDOMReady
+ * (former injecting on YAHOO_config).</li>
+ * <li>locale: default locale</li>
+ * <li>-------------------------------------------------------------------------</li>
+ * <li>For loader:</li>
+ * <li>-------------------------------------------------------------------------</li>
+ * <li>base: The base dir</li>
+ * <li>comboBase: The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
+ * <li>root: The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li>
+ * <li>filter:
+ *
+ * A filter to apply to result urls. This filter will modify the default
+ * path for all modules. The default path for the YUI library is the
+ * minified version of the files (e.g., event-min.js). The filter property
+ * can be a predefined filter or a custom filter. The valid predefined
+ * filters are:
+ * <dl>
+ * <dt>DEBUG</dt>
+ * <dd>Selects the debug versions of the library (e.g., event-debug.js).
+ * This option will automatically include the Logger widget</dd>
+ * <dt>RAW</dt>
+ * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
+ * </dl>
+ * You can also define a custom filter, which must be an object literal
+ * containing a search expression and a replace string:
+ * <pre>
+ * myFilter: &#123;
+ * 'searchExp': "-min\\.js",
+ * 'replaceStr': "-debug.js"
+ * &#125;
+ * </pre>
+ *
+ * </li>
+ * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li>
+ * <li>combine:
+ * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
+ * <li>ignore:
+ * A list of modules that should never be dynamically loaded</li>
+ * <li>force:
+ * A list of modules that should always be loaded when required, even if already present on the page</li>
+ * <li>insertBefore:
+ * Node or id for a node that should be used as the insertion point for new nodes</li>
+ * <li>charset:
+ * charset for dynamic nodes</li>
+ * <li>timeout:
+ * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
+ * <li>onSuccess:
+ * callback for the 'success' event</li>
+ * <li>onFailure:
+ * callback for the 'failure' event</li>
+ * <li>onTimeout:
+ * callback for the 'timeout' event</li>
+ * <li>onProgress:
+ * callback executed each time a script or css file is loaded</li>
+ * <li>modules:
+ * A list of module definitions. See Loader.addModule for the supported module metadata</li>
+ * </ul>
+ */
+ YAHOO_bootstrap = function (o) {
+
+ // analyzing "o"
+ o = o || _config || {};
+
+ // initializing the bootstrap only once
+ if (!_loaderObj) {
+ _initLoader(o);
+ }
+
+ // adding the
+ _addMods (o.modules);
+
+ return {
+ /**
+ * Load a set of modules and notify thru the callback method.
+ * @param modules* {string} 1-n modules to bind (uses arguments array)
+ * @param *callback {function} callback function executed when
+ * the instance has the required functionality. If included, it
+ * must be the last parameter.
+ *
+ * YAHOO_bootstrap().use('tabview')
+ *
+ * @return void
+ */
+ use: function () {
+ var a=Array.prototype.slice.call(arguments, 0),
+ callback = a.pop ();
+ if (callback) {
+ if (a && a.length > 0) {
+ // using the YUI loader utility to load the requirements...
+ _loaderQueue.push ({
+ require: a,
+ config: o,
+ callback: callback
+ });
+ if (_loaderQueue.length == 1) {
+ _loaderDispatch();
+ }
+ } else {
+ callback.call ();
+ }
+ }
+ },
+ /**
+ * Set the default configuration for the loader.
+ * @param o {object} default configuration object for the bootstrap,
+ * basically "o" can be used to define the global configuration once in
+ * your application, instead of including the configuration for each single
+ * bootstrap call.
+ *
+ * YAHOO_bootstrap(o).setAsDefault()
+ *
+ * @return void
+ */
+ setAsDefault: function (o) {
+ if (o) {
+ _config = o || {};
+ }
+ }
+ };
+ };
+
+})();
+YAHOO.register("bootstrap", YAHOO_bootstrap, {version: "@VERSION@", build: "@BUILD@"});
View
8 src/bootstrap/README
@@ -0,0 +1,8 @@
+YUI 2.x Bootstrap Object:
+-------------------------
+Namespace: YAHOO_bootstrap
+
+
+YUI 3.x Bootstrap Object:
+-------------------------
+Namespace: YUI_bootstrap
View
6 src/bootstrap/build.properties
@@ -0,0 +1,6 @@
+builddir=../../../builder/componentbuild
+
+component=bootstrap
+component.mainclass=YAHOO_bootstrap
+component.jsfiles=bootstrap.js
+component.logger.regex.skip=true
View
6 src/bootstrap/build.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="YuiBuild" default="local">
+ <description>Bootstrap Build File</description>
+ <property file="build.properties" />
+ <import file="${builddir}/2.x/bootstrap.xml" description="Default Build Properties and Targets" />
+</project>
View
236 src/bootstrap/js/yahoo_bootstrap.js
@@ -0,0 +1,236 @@
+/**
+ * Provides Bootstrap definition based on YUI 2.x.
+ *
+ * ---
+ *
+ * @module bootstrap
+ */
+
+/**
+ * Provides YAHOO_bootstrap methods.
+ *
+ * @class YAHOO_bootstrap
+ * @static
+ */
+(function() {
+
+ var _config = null,
+ _loaderObj = null,
+ _loaderQueue = [];
+ /**
+ * Continue with the loading process, removing the first set from the list,
+ * and continue with the next in line.
+ * @method _loaderNext
+ * @private
+ * @static
+ * @param {Boolean} notify Whether or not the callback method should be called.
+ * @return void
+ */
+ function _loaderNext (notify) {
+ var i = _loaderQueue.pop();
+ /* we want to speed up the loading process, so, the first thing we do
+ is actually starting the loading process for the next region */
+ _loaderDispatch();
+ if (notify && i) {
+ /* notifying thru the callback function that everything was ok */
+ i.callback.call();
+ }
+ }
+ /**
+ * Finishing with the current item int queue, and starting with the next one
+ * @method _loaderDispatch
+ * @private
+ * @static
+ * @return void
+ */
+ function _loaderDispatch () {
+ var c;
+ if (_loaderQueue.length > 0) {
+ c = _loaderQueue[0];
+ c.require = c.require || [];
+ _loaderObj.require(c.require);
+ _loaderObj.insert({
+ onSuccess: function () {
+ _loaderNext(true);
+ (c.config.onSuccess || function(){}).call();
+ },
+ onFailure: function(){
+ _loaderNext();
+ (c.config.onFailure || function(){}).call();
+ },
+ onTimeout: function () {
+ _loaderNext();
+ (c.config.onTimeout || function(){}).call();
+ }
+ }, c.type);
+ }
+ }
+ /**
+ * <p>
+ * execute the internal initialization process for the region
+ * </p>
+ * @method init
+ * @return {Object} region reference to support chaining
+ */
+ function _initLoader (l) {
+ /* creating the loader object for this region */
+ l = l || {};
+ l.combine = (l.hasOwnProperty('combine')?l.combine:true); /* using the Combo Handle */
+ l.combine = !this._debug;
+ l.filter = l.filter || 'min'; /* you can switch between YUI branch */
+ l.filter = (this._debug?'debug':l.filter);
+
+ // more config here ...
+
+ _loaderObj = _loaderObj || new YAHOO.util.YUILoader(l);
+ }
+
+ function _addMods (m) {
+ var i;
+ if (m && (typeof m === 'object')) {
+ for (i in m) {
+ if (m.hasOwnProperty(i)) {
+ m[i].name = i;
+ _loaderObj.addModule (m[i]);
+ }
+ }
+ }
+ }
+
+ /**
+ * YAHOO_bootstrap function. If YAHOO_bootstrap is already defined, the
+ * existing YAHOO_bootstrap functino will not be overwritten to preserve
+ * the state of the bootstrap.
+ *
+ * @class YAHOO_bootstrap
+ * @constructor
+ * @global
+ * @param o Optional configuration object. Options:
+ * <ul>
+ * <li>------------------------------------------------------------------------</li>
+ * <li>Global:</li>
+ * <li>------------------------------------------------------------------------</li>
+ * <li>debug: Turn debug statements on or off</li>
+ * <li>injected: set to true if the yui seed file was dynamically loaded in
+ * order to bootstrap components relying on the window load event and onDOMReady
+ * (former injecting on YAHOO_config).</li>
+ * <li>locale: default locale</li>
+ * <li>-------------------------------------------------------------------------</li>
+ * <li>For loader:</li>
+ * <li>-------------------------------------------------------------------------</li>
+ * <li>base: The base dir</li>
+ * <li>comboBase: The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
+ * <li>root: The root path to prepend to module names for the combo service. Ex: 2.5.2/build/</li>
+ * <li>filter:
+ *
+ * A filter to apply to result urls. This filter will modify the default
+ * path for all modules. The default path for the YUI library is the
+ * minified version of the files (e.g., event-min.js). The filter property
+ * can be a predefined filter or a custom filter. The valid predefined
+ * filters are:
+ * <dl>
+ * <dt>DEBUG</dt>
+ * <dd>Selects the debug versions of the library (e.g., event-debug.js).
+ * This option will automatically include the Logger widget</dd>
+ * <dt>RAW</dt>
+ * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
+ * </dl>
+ * You can also define a custom filter, which must be an object literal
+ * containing a search expression and a replace string:
+ * <pre>
+ * myFilter: &#123;
+ * 'searchExp': "-min\\.js",
+ * 'replaceStr': "-debug.js"
+ * &#125;
+ * </pre>
+ *
+ * </li>
+ * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li>
+ * <li>combine:
+ * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
+ * <li>ignore:
+ * A list of modules that should never be dynamically loaded</li>
+ * <li>force:
+ * A list of modules that should always be loaded when required, even if already present on the page</li>
+ * <li>insertBefore:
+ * Node or id for a node that should be used as the insertion point for new nodes</li>
+ * <li>charset:
+ * charset for dynamic nodes</li>
+ * <li>timeout:
+ * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
+ * <li>onSuccess:
+ * callback for the 'success' event</li>
+ * <li>onFailure:
+ * callback for the 'failure' event</li>
+ * <li>onTimeout:
+ * callback for the 'timeout' event</li>
+ * <li>onProgress:
+ * callback executed each time a script or css file is loaded</li>
+ * <li>modules:
+ * A list of module definitions. See Loader.addModule for the supported module metadata</li>
+ * </ul>
+ */
+ YAHOO_bootstrap = function (o) {
+
+ // analyzing "o"
+ o = o || _config || {};
+
+ // initializing the bootstrap only once
+ if (!_loaderObj) {
+ _initLoader(o);
+ }
+
+ // adding the
+ _addMods (o.modules);
+
+ return {
+ /**
+ * Load a set of modules and notify thru the callback method.
+ * @param modules* {string} 1-n modules to bind (uses arguments array)
+ * @param *callback {function} callback function executed when
+ * the instance has the required functionality. If included, it
+ * must be the last parameter.
+ *
+ * YAHOO_bootstrap().use('tabview')
+ *
+ * @return void
+ */
+ use: function () {
+ var a=Array.prototype.slice.call(arguments, 0),
+ callback = a.pop ();
+ if (callback) {
+ if (a && a.length > 0) {
+ // using the YUI loader utility to load the requirements...
+ _loaderQueue.push ({
+ require: a,
+ config: o,
+ callback: callback
+ });
+ if (_loaderQueue.length == 1) {
+ _loaderDispatch();
+ }
+ } else {
+ callback.call ();
+ }
+ }
+ },
+ /**
+ * Set the default configuration for the loader.
+ * @param o {object} default configuration object for the bootstrap,
+ * basically "o" can be used to define the global configuration once in
+ * your application, instead of including the configuration for each single
+ * bootstrap call.
+ *
+ * YAHOO_bootstrap(o).setAsDefault()
+ *
+ * @return void
+ */
+ setAsDefault: function (o) {
+ if (o) {
+ _config = o || {};
+ }
+ }
+ };
+ };
+
+})();
View
130 src/bootstrap/js/yui_bootstrap.js
@@ -0,0 +1,130 @@
+/**
+ * Provides Bootstrap definition based on YUI 3.x.
+ *
+ * @module bootstrap
+ */
+
+/**
+ * Provides YUI_bootstrap methods.
+ *
+ * @class YUI_bootstrap
+ * @static
+ */
+(function() {
+
+ var _config = null;
+
+ /**
+ * YUI_bootstrap function. If YUI_bootstrap is already defined, the
+ * existing YUI_bootstrap functino will not be overwritten to preserve
+ * the state of the bootstrap.
+ *
+ * @class YUI_bootstrap
+ * @constructor
+ * @global
+ * @param o Optional configuration object. Options:
+ * <ul>
+ * <li>------------------------------------------------------------------------</li>
+ * <li>Global:</li>
+ * <li>------------------------------------------------------------------------</li>
+ * <li>debug: Turn debug statements on or off</li>
+ * <li>injected: set to true if the yui seed file was dynamically loaded in
+ * order to bootstrap components relying on the window load event and onDOMReady
+ * (former injecting on YAHOO_config).</li>
+ * <li>locale: default locale</li>
+ * <li>-------------------------------------------------------------------------</li>
+ * <li>For loader:</li>
+ * <li>-------------------------------------------------------------------------</li>
+ * <li>base: The base dir</li>
+ * <li>comboBase: The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
+ * <li>root: The root path to prepend to module names for the combo service. Ex\\: 2\\.5\\.2\\/build\\/</li>
+ * <li>filter:
+ *
+ * A filter to apply to result urls. This filter will modify the default
+ * path for all modules. The default path for the YUI library is the
+ * minified version of the files (e.g., event-min.js). The filter property
+ * can be a predefined filter or a custom filter. The valid predefined
+ * filters are:
+ * <dl>
+ * <dt>DEBUG</dt>
+ * <dd>Selects the debug versions of the library (e.g., event-debug.js).
+ * This option will automatically include the Logger widget</dd>
+ * <dt>RAW</dt>
+ * <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
+ * </dl>
+ * You can also define a custom filter, which must be an object literal
+ * containing a search expression and a replace string:
+ * <pre>
+ * myFilter: &#123;
+ * 'searchExp': "-min\\.js",
+ * 'replaceStr': "-debug.js"
+ * &#125;
+ * </pre>
+ *
+ * </li>
+ * <li>filters: per-component filter specification. If specified for a given component, this overrides the filter config</li>
+ * <li>combine:
+ * Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
+ * <li>ignore:
+ * A list of modules that should never be dynamically loaded</li>
+ * <li>force:
+ * A list of modules that should always be loaded when required, even if already present on the page</li>
+ * <li>insertBefore:
+ * Node or id for a node that should be used as the insertion point for new nodes</li>
+ * <li>charset:
+ * charset for dynamic nodes</li>
+ * <li>timeout:
+ * number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
+ * <li>onSuccess:
+ * callback for the 'success' event</li>
+ * <li>onFailure:
+ * callback for the 'failure' event</li>
+ * <li>onTimeout:
+ * callback for the 'timeout' event</li>
+ * <li>onProgress:
+ * callback executed each time a script or css file is loaded</li>
+ * <li>modules:
+ * A list of module definitions. See Loader.addModule for the supported module metadata</li>
+ * </ul>
+ */
+ YUI_bootstrap = function (o) {
+
+ // analyzing "o"
+ o = o || _config || {};
+
+ return {
+ /**
+ * Load a set of modules and notify thru the callback method.
+ * @param modules* {string} 1-n modules to bind (uses arguments array)
+ * @param *callback {function} callback function executed when
+ * the instance has the required functionality. If included, it
+ * must be the last parameter.
+ *
+ * YUI_bootstrap().use('dd')
+ *
+ * @return void
+ */
+ use: function () {
+ var Y = YUI(o);
+ Y.use.apply (Y, arguments);
+ },
+ /**
+ * Set the default configuration for the loader.
+ * @param o {object} default configuration object for the bootstrap,
+ * basically "o" can be used to define the global configuration once in
+ * your application, instead of including the configuration for each single
+ * bootstrap call.
+ *
+ * YUI_bootstrap(o).setAsDefault()
+ *
+ * @return void
+ */
+ setAsDefault: function (o) {
+ if (o) {
+ _config = o || {};
+ }
+ }
+ };
+ };
+
+})();
View
100 src/bootstrap/tests/bootstrap.html
@@ -0,0 +1,100 @@
+<!doctype html>
+<html>
+<head>
+ <title>Test Page</title>
+</head>
+<body class="yui-skin-sam">
+ <div id="doc">
+
+ <div id="demo">
+ <div class="hd"><h3 class="title">H3 - Title</h3></div>
+ <div class="bd">
+ <p>&nbsp;</p>
+ </div>
+ </div>
+
+ </div>
+ <!-- YUI3 Core //-->
+ <script type="text/javascript" src="../../../../yui3/build/yui/yui-debug.js"></script>
+
+ <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yuiloader/yuiloader-min.js" ></script>
+ <!-- Scripts to test //-->
+ <script type="text/javascript" src="../../../build/bootstrap/bootstrap-debug.js"></script>
+ <!-- Initialization process //-->
+ <script type="text/javascript">
+ YUI({
+ base:'../../../../yui3/build/',
+ filter: 'debug',
+ logExclude:{
+ base:true,
+ event:true,
+ attribute:true,
+ widget:true,
+ node: true,
+ yui: true,
+ get: true
+ }
+ }).use('dump', 'console', 'test', function (Y) {
+
+ // creating the console...
+ (new Y.Console()).render();
+
+ // starting the testing process
+
+ // add the test cases and suites
+ Y.Test.Runner.add(new Y.Test.Case({
+
+ name: "Bootstrap TestSuite",
+
+ test_bootstrap_init_process: function(){
+
+ var foo = false;
+
+ YAHOO_bootstrap({
+ filter: 'debug'
+ }).use('dom', function () {
+ foo = true;
+ });
+
+ // waiting for the loading of all the requirements
+ this.wait(function(){
+ Y.Assert.areEqual(foo, true, "the loading process fail");
+ }, 1000);
+ },
+
+ test_bootstrap_loading_external_modules: function(){
+
+ var foo = false;
+
+ YAHOO_bootstrap({
+ filter: 'debug',
+ modules: {
+ 'bubbling': {
+ name: 'bubbling',
+ type: "js",
+ fullpath: 'http://js.bubbling-library.com/2.1/build/bubbling/bubbling.js',
+ requires: ['event', 'dom']
+ }
+ }
+ }).use('connection', 'bubbling', function () {
+ foo = true;
+ });
+
+ // waiting for the loading of all the requirements
+ this.wait(function(){
+ Y.Assert.areEqual(foo, true, "something happen with the loading process, and the requirements fails");
+ Y.Assert.isObject(YAHOO.Bubbling, "Bubbling custom module was not loaded correctly");
+ }, 1000);
+ }
+
+ }));
+
+ //run all tests
+ Y.Test.Runner.run();
+
+ /* finishing the testing process */
+
+ });
+ </script>
+</body>
+</html>
View
73 src/bootstrap/tests/bootstrapping-from-scratch.html
@@ -0,0 +1,73 @@
+<!doctype html>
+<html>
+<head>
+ <title>Test Page</title>
+</head>
+<body class="yui-skin-sam">
+ <div id="doc">
+
+ <div id="demo">
+ <div class="hd"><h3 class="title">H3 - Title</h3></div>
+ <div class="bd">
+ <p>&nbsp;</p>
+ </div>
+ </div>
+
+ </div>
+ <!-- YUI3 Core //-->
+ <script type="text/javascript" src="../../../../yui3/build/yui/yui-debug.js"></script>
+ <!-- Scripts to test //-->
+ <script type="text/javascript" src="../../../build/bootstrap/bootstrap-debug.js"></script>
+ <!-- Initialization process //-->
+ <script type="text/javascript">
+ YUI({
+ base:'../../../../yui3/build/',
+ filter: 'debug',
+ logExclude:{
+ base:true,
+ event:true,
+ attribute:true,
+ widget:true,
+ node: true,
+ yui: true,
+ get: true
+ }
+ }).use('dump', 'console', 'test', function (Y) {
+
+ // creating the console...
+ (new Y.Console()).render();
+
+ // starting the testing process
+
+ // add the test cases and suites
+ Y.Test.Runner.add(new Y.Test.Case({
+
+ name: "Bootstrap TestSuite",
+
+ test_bootstrap_init_process: function(){
+
+ var foo = false;
+
+ YAHOO_bootstrap({
+ filter: 'debug'
+ }).use('dom', function () {
+ foo = true;
+ });
+
+ // waiting for the loading of all the requirements
+ this.wait(function(){
+ Y.Assert.areEqual(foo, true, "was great...");
+ }, 1000);
+ }
+
+ }));
+
+ //run all tests
+ Y.Test.Runner.run();
+
+ /* finishing the testing process */
+
+ });
+ </script>
+</body>
+</html>

0 comments on commit 6902207

Please sign in to comment.