Permalink
Browse files

Updated code to take advantage of load/wait pattern

Added a loadfirst package that is loaded and executed before the
page-specific package is loaded
  • Loading branch information...
ten1seven committed Apr 26, 2012
1 parent 0351c89 commit 3a4dcf6cb9bbfb0c044e79f0d392e3f81a793c92
Showing with 18 additions and 9 deletions.
  1. +3 −1 js/bootstrap.js
  2. +7 −5 js/bundles.js
  3. +2 −2 js/global.js
  4. +5 −0 js/init.js
  5. +1 −1 js/pages/home.js
View
@@ -14,5 +14,7 @@ var PB = PB || {};
})();
PB.loadScripts = function(controller,action) {
- $LAB.script([_base._global,pages[controller][action].depends],pages[controller][action].url);
+ $LAB
+ .script([base.loadfirst.depends],base.loadfirst.url).wait() // load and run the global scripts first
+ .script([pages[controller][action].depends],pages[controller][action].url);
};
View
@@ -4,12 +4,14 @@
Author: Jeremy Fields, Viget Labs
*/
-var _base = {
+var base = {
- _global: [
- 'js/plugins.js',
- 'js/global.js'
- ]
+ loadfirst: {
+ url: 'js/global.js',
+ depends: [
+ 'js/plugins.js'
+ ]
+ }
};
View
@@ -23,13 +23,13 @@ var PB = PB || {};
PB.Global = {
vars: {
- var1: 'global.js init'
+ var1: 'init global.js'
},
'init': function() {
// do stuff here
- console.log(PB.Global.var1);
+ console.log(PB.Global.vars.var1);
},
View
@@ -4,6 +4,11 @@
Author: Jeremy Fields, Viget Labs
*/
+// remove for production!!!
+$LAB.setGlobalDefaults({
+ 'CacheBust': true
+});
+
$LAB.script('//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js','js/bootstrap.js','js/bundles.js').wait(function() {
if (typeof window.jQuery === 'undefined') {
View
@@ -13,7 +13,7 @@ var PB = PB || {};
PB.Home = {
vars: {
- var1: 'home.js init'
+ var1: 'init home.js'
},
'init': function() {

0 comments on commit 3a4dcf6

Please sign in to comment.