plugins: create PluginManager service

This commit is contained in:
David Cormier 2013-10-08 17:55:30 -04:00
parent 1fd6e1b0b6
commit cc2eda7057
2 changed files with 31 additions and 30 deletions

View file

@ -11,15 +11,11 @@ plugins.service('plugins', function() {
}
}
});
var PluginManagerObject = function() {
var plugins = [];
plugins.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', function(youtubePlugin, urlPlugin, imagePlugin) {
var plugins = [youtubePlugin, urlPlugin, imagePlugin]
var hookPlugin = function(plugin) {
var addPlugin = function(plugin) {
plugins.push(plugin);
}
@ -42,9 +38,14 @@ plugins.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', f
}
return {
hookPlugin: hookPlugin,
addPlugin: addPlugin,
contentForMessage: contentForMessage
}
}
this.PluginManager = new PluginManagerObject();
});
}]);

View file

@ -110,7 +110,7 @@ weechat.factory('colors', [function($scope) {
}]);
weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'pluginManager', function($rootScope, colors, models, pluginManager) {
weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', function($rootScope, colors, models, plugins) {
var handleBufferClosing = function(message) {
var bufferMessage = message['objects'][0]['content'][0];
@ -124,7 +124,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'pluginManager',
var message = new models.BufferLine(message);
var buffer = models.getBuffer(message.buffer);
message.metadata = pluginManager.contentForMessage(message.text);
message.metadata = plugins.PluginManager.contentForMessage(message.text);
buffer.addLine(message);
if (!buffer.active) {