Hi guys, I was thinking about improving JavaScript plugin API so that each time a plugin calls WebAdmin, the plugin name will be part of the call. This way, PluginManager (WebAdmin) can validate the call before doing any further actions, e.g. "plugin invocation must be allowed && plugin must be initialized". In other words, this is just to ensure consistent behavior for "plugin -> WebAdmin" calls.
Here's a draft of new JavaScript API in action: http://jsfiddle.net/tHk5n/ (see the code below the comment saying "ACTUAL TEST CODE") (I took my inspiration from jQuery source code, even though I don't fully understand JavaScript prototype OOP concept, seems a bit weird to me.) For comparison, here's some plugin code that uses current plugin API: // Register our plugin object (containing event handler functions) into pluginApi.plugins pluginApi.plugins['myPlugin'] = { UiInit: function() { pluginApi.ui.addMainTab('Custom Tab', 'custom-tab', 'http://www.example.com/'); } }; // Tell WebAdmin that we are ready, we need the plugin name to identify this plugin pluginApi.ready('myPlugin'); And here's an equivalent plugin code that uses new plugin API: // Plugin API instance for our plugin var myPlugin = pluginApi('myPlugin'); // Register our plugin object (containing event handler functions) into myPlugin myPlugin.register({ UiInit: function() { myPlugin.ui.addMainTab('Custom Tab', 'custom-tab', 'http://www.example.com/'); } }); // Tell WebAdmin that we are ready , plugin name is already part of myPlugin myPlugin.ready(); // Note: the above line is equivalent to: pluginApi('myPlugin').ready() ; Let me know what you think. Cheers, Vojtech
_______________________________________________ Engine-devel mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-devel
