mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +03:00
Plugin system enhancements (Custom user's settings tabs)
This commit is contained in:
parent
a3f28b09f6
commit
9a58fd0a66
13 changed files with 398 additions and 16 deletions
|
|
@ -16,8 +16,10 @@
|
|||
function Plugins()
|
||||
{
|
||||
this.oSettings = require('Storage/Settings');
|
||||
this.oViewModelsHooks = {};
|
||||
this.oSimpleHooks = {};
|
||||
|
||||
this.aUserViewModelsHooks = [];
|
||||
this.aAdminViewModelsHooks = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -26,9 +28,14 @@
|
|||
Plugins.prototype.oSettings = {};
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
* @type {Array}
|
||||
*/
|
||||
Plugins.prototype.oViewModelsHooks = {};
|
||||
Plugins.prototype.aUserViewModelsHooks = [];
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
Plugins.prototype.aAdminViewModelsHooks = [];
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
|
|
@ -82,17 +89,44 @@
|
|||
* @param {string} sAction
|
||||
* @param {Object=} oParameters
|
||||
* @param {?number=} iTimeout
|
||||
* @param {string=} sGetAdd = ''
|
||||
* @param {Array=} aAbortActions = []
|
||||
*/
|
||||
Plugins.prototype.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
|
||||
Plugins.prototype.remoteRequest = function (fCallback, sAction, oParameters, iTimeout)
|
||||
{
|
||||
if (Globals.__APP__)
|
||||
{
|
||||
Globals.__APP__.remote().defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions);
|
||||
Globals.__APP__.remote().defaultRequest(fCallback, 'Plugin' + sAction, oParameters, iTimeout);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} SettingsViewModelClass
|
||||
* @param {string} sLabelName
|
||||
* @param {string} sTemplate
|
||||
* @param {string} sRoute
|
||||
*/
|
||||
Plugins.prototype.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute)
|
||||
{
|
||||
this.aViewModelsHooks.push([SettingsViewModelClass, sTemplate, sLabelName, sRoute]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} SettingsViewModelClass
|
||||
* @param {string} sLabelName
|
||||
* @param {string} sTemplate
|
||||
* @param {string} sRoute
|
||||
*/
|
||||
Plugins.prototype.addSettingsViewModelForAdmin = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute)
|
||||
{
|
||||
this.aAdminViewModelsHooks.push([SettingsViewModelClass, sTemplate, sLabelName, sRoute]);
|
||||
};
|
||||
|
||||
Plugins.prototype.runSettingsViewModelHooks = function (bAdmin)
|
||||
{
|
||||
_.each(bAdmin ? this.aAdminViewModelsHooks : this.aViewModelsHooks, function (aView) {
|
||||
require('Knoin/Knoin').addSettingsViewModel(aView[0], aView[1], aView[2], aView[3]);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sPluginSection
|
||||
* @param {string} sName
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
kn = require('Knoin/Knoin'),
|
||||
|
||||
Plugins = require('Common/Plugins'),
|
||||
|
||||
AbstractSettings = require('Screen/AbstractSettings')
|
||||
;
|
||||
|
||||
|
|
@ -63,6 +65,8 @@
|
|||
kn.addSettingsViewModel(require('Settings/Admin/About'),
|
||||
'AdminSettingsAbout', 'About', 'about');
|
||||
|
||||
Plugins.runSettingsViewModelHooks(true);
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
Globals = require('Common/Globals'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Plugins = require('Common/Plugins'),
|
||||
|
||||
AppStore = require('Stores/User/App'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
|
|
@ -101,6 +103,8 @@
|
|||
'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
|
||||
}
|
||||
|
||||
Plugins.runSettingsViewModelHooks(false);
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
|
|
|
|||
8
dev/bootstrap.js
vendored
8
dev/bootstrap.js
vendored
|
|
@ -39,12 +39,16 @@
|
|||
// export
|
||||
window['rl'] = window['rl'] || {};
|
||||
window['rl']['i18n'] = _.bind(Translator.i18n, Translator);
|
||||
|
||||
window['rl']['addHook'] = _.bind(Plugins.addHook, Plugins);
|
||||
window['rl']['settingsGet'] = _.bind(Plugins.mainSettingsGet, Plugins);
|
||||
window['rl']['remoteRequest'] = _.bind(Plugins.remoteRequest, Plugins);
|
||||
window['rl']['pluginSettingsGet'] = _.bind(Plugins.settingsGet, Plugins);
|
||||
window['rl']['createCommand'] = Utils.createCommand;
|
||||
|
||||
window['rl']['addSettingsViewModel'] = _.bind(Plugins.addSettingsViewModel, Plugins);
|
||||
|
||||
window['rl']['pluginRemoteRequest'] = _.bind(Plugins.remoteRequest, Plugins);
|
||||
window['rl']['pluginSettingsGet'] = _.bind(Plugins.settingsGet, Plugins);
|
||||
|
||||
window['rl']['EmailModel'] = EmailModel;
|
||||
window['rl']['Enums'] = Enums;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue