diff options
author | Leif Åstrand <leif@vaadin.com> | 2011-11-28 12:59:34 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2011-11-28 12:59:34 +0200 |
commit | cb5f080e5337c081f22eea86c0cf170ef88a2257 (patch) | |
tree | a80548e5b83d0128e7a7d8cee2669f87b0bd0a9a /WebContent/VAADIN/vaadinBootstrap.js | |
parent | 55948aefe8ead5054a83ec84d2e3624ffc1e7427 (diff) | |
download | vaadin-framework-cb5f080e5337c081f22eea86c0cf170ef88a2257.tar.gz vaadin-framework-cb5f080e5337c081f22eea86c0cf170ef88a2257.zip |
Rework bootstrap to support loading widgetset without application
Diffstat (limited to 'WebContent/VAADIN/vaadinBootstrap.js')
-rw-r--r-- | WebContent/VAADIN/vaadinBootstrap.js | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js index 2178e2abe2..cc9829b6e4 100644 --- a/WebContent/VAADIN/vaadinBootstrap.js +++ b/WebContent/VAADIN/vaadinBootstrap.js @@ -2,8 +2,7 @@ var defaults; var apps = {}; var themesLoaded = {}; - var widgetsetsRequested = {} - var widgetsetApps = {}; + var widgetsets = {}; var log = function() { @@ -30,8 +29,7 @@ } var loadWidgetset = function(basePath, widgetset) { - if (widgetsetsRequested[widgetset]) { - //TODO Tell the widgetset to load another application + if (widgetsets[widgetset]) { return; } log("load widgetset", basePath, widgetset) @@ -48,7 +46,9 @@ scriptTag.setAttribute('src', url); document.getElementsByTagName('head')[0].appendChild(scriptTag); - widgetsetsRequested[widgetset] = true; + widgetsets[widgetset] = { + pendingApps: [] + }; } window.vaadin = window.vaadin || { @@ -127,15 +127,17 @@ var widgetset = getConfig('widgetset'); if (widgetset && widgetsetBase) { loadWidgetset(widgetsetBase, widgetset); - if (widgetsetApps[widgetset]) { - widgetsetApps[widgetset].push(appId); + if (widgetsets[widgetset].callback) { + log("Starting from bootstrap", appId); + widgetsets[widgetset].callback(appId); } else { - widgetsetApps[widgetset] = [appId]; + log("Setting pending startup of ", appId); + widgetsets[widgetset].pendingApps.push(appId); } } else if (mayDefer) { fetchRootConfig(); } else { - throw "Widgetset not defined"; + throw "Widgetset not defined: " + widgetsetBase + " -> " + widgetset; } } bootstrapApp(true); @@ -151,12 +153,15 @@ var app = apps[appId]; return app; }, - popWidgetsetApp: function(widgetset) { - if (widgetsetApps[widgetset]) { - return widgetsetApps[widgetset].pop(); - } else { - return null; + registerWidgetset: function(widgetset, callback) { + log("Widgetset registered", widgetset) + widgetsets[widgetset].callback = callback; + for(var i = 0; i < widgetsets[widgetset].pendingApps.length; i++) { + var appId = widgetsets[widgetset].pendingApps[i]; + log("Starting from register widgetset", appId); + callback(appId); } + widgetsets[widgetset].pendingApps = null; } }; |