cloudstack/ui/scripts/plugins.js
Brian Federle 347ac311a0 UI Plugin: Use new format
Define plugins as namespaced objects instead of as function calls. This
is easier to implement and manage by the framework.

New format changes for defining plugins:

Now create 2 JS files in plugin folder:
  -config.js
  -[pluginName].js

plugins.js (listing) format:

  cloudStack.plugins = [
    'testPlugin'
  ];

config.js format:

  cloudStack.plugins.testPlugin.config = {
    title: 'Test Plugin',
    desc: 'Sample plugin'
  };

[pluginName].js format:

  cloudStack.plugins.testPlugin = function(plugin) {
    //
    // Plugin code goes here
    //
  };
2012-12-20 11:55:44 -08:00

27 lines
648 B
JavaScript

(function($, cloudStack, require) {
cloudStack.sections.plugins = {
title: 'Plugins',
show: cloudStack.uiCustom.plugins
};
// Load plugins
$(cloudStack.plugins).map(function(index, pluginID) {
var basePath = 'plugins/' + pluginID + '/';
var pluginJS = basePath + pluginID + '.js';
var configJS = basePath + 'config.js';
require([pluginJS], function() {
require([configJS]);
// Execute plugin
cloudStack.plugins[pluginID]({
ui: {
extend: function(obj) {
$.extend(true, cloudStack, obj);
}
}
});
});
});
}(jQuery, cloudStack, require));