You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/04/19 13:28:30 UTC
[16/35] git commit: updated refs/heads/marvin_refactor to 4abd929
UI Plugin/module API: Fix load order, refactor
-Fixes issue with load order, where plugin's initialization function were not called
in order of the list
-Refactor so that modules and plugins are loaded via the same block,
to avoid redundant code
-Load modules before plugins
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/73d87f1a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/73d87f1a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/73d87f1a
Branch: refs/heads/marvin_refactor
Commit: 73d87f1ad21c7312517f04038b54a0ec084a5d64
Parents: a51b566
Author: Brian Federle <br...@citrix.com>
Authored: Thu Apr 18 13:49:43 2013 -0700
Committer: Brian Federle <br...@citrix.com>
Committed: Thu Apr 18 13:59:20 2013 -0700
----------------------------------------------------------------------
ui/scripts/plugins.js | 77 ++++++++++++++++++++------------------------
1 files changed, 35 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/73d87f1a/ui/scripts/plugins.js
----------------------------------------------------------------------
diff --git a/ui/scripts/plugins.js b/ui/scripts/plugins.js
index 9d1991c..122f4a0 100644
--- a/ui/scripts/plugins.js
+++ b/ui/scripts/plugins.js
@@ -15,7 +15,9 @@
// specific language governing permissions and limitations
// under the License.
(function($, cloudStack, require) {
- if (!cloudStack.pluginAPI) cloudStack.pluginAPI = {};
+ if (!cloudStack.pluginAPI) {
+ cloudStack.pluginAPI = {};
+ }
var loadCSS = function(path) {
var $link = $('<link>');
@@ -40,7 +42,7 @@
error: function(json) {
args.error(parseXMLHttpResponse(json));
}
- })
+ });
},
addSection: function(section) {
cloudStack.sections[section.id] = $.extend(section, {
@@ -58,49 +60,40 @@
show: cloudStack.uiCustom.pluginListing
};
- // Load plugins
- $(cloudStack.plugins).map(function(index, pluginID) {
- var basePath = 'plugins/' + pluginID + '/';
- var pluginJS = basePath + pluginID + '.js';
- var configJS = basePath + 'config.js';
- var pluginCSS = basePath + pluginID + '.css';
+ // Load
+ $(['modules', 'plugins']).each(function() {
+ var type = this;
+ var paths = $(cloudStack[type]).map(function(index, id) {
+ return type + '/' + id + '/' + id;
+ }).toArray();
- require([pluginJS], function() {
- require([configJS]);
- loadCSS(pluginCSS);
+ // Load modules
+ require(
+ paths,
+ function() {
+ $(cloudStack[type]).map(function(index, id) {
+ var basePath = type + '/' + id + '/';
+ var css = basePath + id + '.css';
+ var configJS = type == 'plugins' ? basePath + 'config' : null;
- // Execute plugin
- cloudStack.plugins[pluginID](
- $.extend(true, {}, cloudStack.pluginAPI, {
- pluginAPI: {
- extend: function(api) {
- cloudStack.pluginAPI[pluginID] = api;
- }
+ if (configJS) {
+ // Load config metadata
+ require([configJS]);
}
- })
- );
- });
- });
-
- // Load modules
- $(cloudStack.modules).map(function(index, moduleID) {
- var basePath = 'modules/' + moduleID + '/';
- var moduleJS = basePath + moduleID + '.js';
- var moduleCSS = basePath + moduleID + '.css';
-
- require([moduleJS], function() {
- loadCSS(moduleCSS);
- // Execute module
- cloudStack.modules[moduleID](
- $.extend(true, {}, cloudStack.pluginAPI, {
- pluginAPI: {
- extend: function(api) {
- cloudStack.pluginAPI[moduleID] = api;
- }
- }
- })
- );
- });
+ // Execute module
+ cloudStack[type][id](
+ $.extend(true, {}, cloudStack.pluginAPI, {
+ pluginAPI: {
+ extend: function(api) {
+ cloudStack.pluginAPI[id] = api;
+ }
+ }
+ })
+ );
+ loadCSS(css);
+ });
+ }
+ );
});
}(jQuery, cloudStack, require));