plugins: create PluginManager service
This commit is contained in:
parent
1fd6e1b0b6
commit
cc2eda7057
2 changed files with 31 additions and 30 deletions
|
@ -11,15 +11,11 @@ plugins.service('plugins', function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
var PluginManagerObject = function() {
|
||||||
|
|
||||||
|
var plugins = [];
|
||||||
|
|
||||||
plugins.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', function(youtubePlugin, urlPlugin, imagePlugin) {
|
var addPlugin = function(plugin) {
|
||||||
|
|
||||||
|
|
||||||
var plugins = [youtubePlugin, urlPlugin, imagePlugin]
|
|
||||||
|
|
||||||
var hookPlugin = function(plugin) {
|
|
||||||
plugins.push(plugin);
|
plugins.push(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,9 +38,14 @@ plugins.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', f
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hookPlugin: hookPlugin,
|
addPlugin: addPlugin,
|
||||||
contentForMessage: contentForMessage
|
contentForMessage: contentForMessage
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.PluginManager = new PluginManagerObject();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
|
@ -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 handleBufferClosing = function(message) {
|
||||||
var bufferMessage = message['objects'][0]['content'][0];
|
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 message = new models.BufferLine(message);
|
||||||
var buffer = models.getBuffer(message.buffer);
|
var buffer = models.getBuffer(message.buffer);
|
||||||
message.metadata = pluginManager.contentForMessage(message.text);
|
message.metadata = plugins.PluginManager.contentForMessage(message.text);
|
||||||
buffer.addLine(message);
|
buffer.addLine(message);
|
||||||
|
|
||||||
if (!buffer.active) {
|
if (!buffer.active) {
|
||||||
|
|
Loading…
Reference in a new issue