Mercurial Hosting > sceditor
comparison src/sceditor.js @ 29:ea32a44b5a6e
remove more oo
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 11 Aug 2022 19:54:03 -0600 |
parents | f227fdfebded |
children | db061869f28f |
comparison
equal
deleted
inserted
replaced
28:f227fdfebded | 29:ea32a44b5a6e |
---|---|
2877 * @param {boolean} returnAtFirst | 2877 * @param {boolean} returnAtFirst |
2878 * @return {*} | 2878 * @return {*} |
2879 * @private | 2879 * @private |
2880 */ | 2880 */ |
2881 var callHandlers = function (args, returnAtFirst) { | 2881 var callHandlers = function (args, returnAtFirst) { |
2882 args = [].slice.call(args); | 2882 if( args.length > 3 ) throw 'too many args'; |
2883 | 2883 |
2884 var idx, ret, | 2884 var idx, ret, |
2885 signal = formatSignalName(args.shift()); | 2885 signal = formatSignalName(args[0]); |
2886 | 2886 |
2887 for (idx = 0; idx < registeredPlugins.length; idx++) { | 2887 for (idx = 0; idx < registeredPlugins.length; idx++) { |
2888 if (signal in registeredPlugins[idx]) { | 2888 if (signal in registeredPlugins[idx]) { |
2889 ret = registeredPlugins[idx][signal].apply(thisObj, args); | 2889 ret = registeredPlugins[idx][signal](thisObj, args[1], args[2]); |
2890 | 2890 |
2891 if (returnAtFirst) { | 2891 if (returnAtFirst) { |
2892 return ret; | 2892 return ret; |
2893 } | 2893 } |
2894 } | 2894 } |
2994 * @return {boolean} | 2994 * @return {boolean} |
2995 * @function | 2995 * @function |
2996 * @name register | 2996 * @name register |
2997 * @memberOf PluginManager.prototype | 2997 * @memberOf PluginManager.prototype |
2998 */ | 2998 */ |
2999 base.register = function (plugin) { | 2999 base.register = function (pluginName) { |
3000 if (!base.exists(plugin) || base.isRegistered(plugin)) { | 3000 if (!base.exists(pluginName) || base.isRegistered(pluginName)) { |
3001 return false; | 3001 return false; |
3002 } | 3002 } |
3003 | 3003 |
3004 plugin = new plugins[plugin](); | 3004 let plugin = plugins[pluginName](); |
3005 if(!plugin) throw pluginName; | |
3005 registeredPlugins.push(plugin); | 3006 registeredPlugins.push(plugin); |
3006 | 3007 |
3007 if ('init' in plugin) { | 3008 if ('init' in plugin) { |
3008 plugin.init.call(thisObj); | 3009 plugin.init(thisObj); |
3009 } | 3010 } |
3010 | 3011 |
3011 return true; | 3012 return true; |
3012 }; | 3013 }; |
3013 | 3014 |
3033 if (registeredPlugins[pluginIdx] instanceof plugins[plugin]) { | 3034 if (registeredPlugins[pluginIdx] instanceof plugins[plugin]) { |
3034 removedPlugin = registeredPlugins.splice(pluginIdx, 1)[0]; | 3035 removedPlugin = registeredPlugins.splice(pluginIdx, 1)[0]; |
3035 removed = true; | 3036 removed = true; |
3036 | 3037 |
3037 if ('destroy' in removedPlugin) { | 3038 if ('destroy' in removedPlugin) { |
3038 removedPlugin.destroy.call(thisObj); | 3039 removedPlugin.destroy(thisObj); |
3039 } | 3040 } |
3040 } | 3041 } |
3041 } | 3042 } |
3042 | 3043 |
3043 return removed; | 3044 return removed; |
3055 base.destroy = function () { | 3056 base.destroy = function () { |
3056 var i = registeredPlugins.length; | 3057 var i = registeredPlugins.length; |
3057 | 3058 |
3058 while (i--) { | 3059 while (i--) { |
3059 if ('destroy' in registeredPlugins[i]) { | 3060 if ('destroy' in registeredPlugins[i]) { |
3060 registeredPlugins[i].destroy.call(thisObj); | 3061 registeredPlugins[i].destroy(thisObj); |
3061 } | 3062 } |
3062 } | 3063 } |
3063 | 3064 |
3064 registeredPlugins = []; | 3065 registeredPlugins = []; |
3065 thisObj = null; | 3066 thisObj = null; |