mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 06:57:03 +03:00
CommonJS (research/3)
This commit is contained in:
parent
586abbb802
commit
06bb124379
99 changed files with 51037 additions and 42961 deletions
|
|
@ -7,46 +7,33 @@
|
|||
var
|
||||
$ = require('../External/jquery.js'),
|
||||
_ = require('../External/underscore.js'),
|
||||
ko = require('../External/ko.js'),
|
||||
window = require('../External/window.js'),
|
||||
$html = require('../External/$html.js'),
|
||||
$window = require('../External/$window.js'),
|
||||
$doc = require('../External/$doc.js'),
|
||||
AppData = require('../External/AppData.js'),
|
||||
|
||||
Globals = require('../Common/Globals.js'),
|
||||
Utils = require('../Common/Utils.js'),
|
||||
Plugins = require('../Common/Plugins.js'),
|
||||
LinkBuilder = require('../Common/LinkBuilder.js'),
|
||||
Events = require('../Common/Events.js'),
|
||||
|
||||
Remote = require('../Remote.js'),
|
||||
AppSettings = require('../Storages/AppSettings.js'),
|
||||
|
||||
kn = require('../Knoin/Knoin.js'),
|
||||
KnoinAbstractBoot = require('../Knoin/KnoinAbstractBoot.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @param {*} Remote
|
||||
* @constructor
|
||||
* @extends KnoinAbstractBoot
|
||||
*/
|
||||
function AbstractApp()
|
||||
function AbstractApp(Remote)
|
||||
{
|
||||
KnoinAbstractBoot.call(this);
|
||||
|
||||
this.oSettings = null;
|
||||
this.oPlugins = null;
|
||||
this.oLocal = null;
|
||||
this.oLink = null;
|
||||
this.oSubs = {};
|
||||
|
||||
this.isLocalAutocomplete = true;
|
||||
|
||||
this.popupVisibilityNames = ko.observableArray([]);
|
||||
|
||||
this.popupVisibility = ko.computed(function () {
|
||||
return 0 < this.popupVisibilityNames().length;
|
||||
}, this);
|
||||
|
||||
this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');
|
||||
|
||||
$window.on('error', function (oEvent) {
|
||||
|
|
@ -55,7 +42,7 @@
|
|||
'Script error.', 'Uncaught Error: Error calling method on NPObject.'
|
||||
]))
|
||||
{
|
||||
Remote().jsError(
|
||||
Remote.jsError(
|
||||
Utils.emptyFunction,
|
||||
oEvent.originalEvent.message,
|
||||
oEvent.originalEvent.filename,
|
||||
|
|
@ -82,11 +69,20 @@
|
|||
|
||||
_.extend(AbstractApp.prototype, KnoinAbstractBoot.prototype);
|
||||
|
||||
AbstractApp.prototype.oSettings = null;
|
||||
AbstractApp.prototype.oPlugins = null;
|
||||
AbstractApp.prototype.oLocal = null;
|
||||
AbstractApp.prototype.oLink = null;
|
||||
AbstractApp.prototype.oSubs = {};
|
||||
AbstractApp.prototype.remote = function ()
|
||||
{
|
||||
return null;
|
||||
};
|
||||
|
||||
AbstractApp.prototype.data = function ()
|
||||
{
|
||||
return null;
|
||||
};
|
||||
|
||||
AbstractApp.prototype.setupSettings = function ()
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sLink
|
||||
|
|
@ -131,38 +127,10 @@
|
|||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @return {?}
|
||||
*/
|
||||
AbstractApp.prototype.settingsGet = function (sName)
|
||||
{
|
||||
if (null === this.oSettings)
|
||||
{
|
||||
this.oSettings = Utils.isNormal(AppData) ? AppData : {};
|
||||
}
|
||||
|
||||
return Utils.isUnd(this.oSettings[sName]) ? null : this.oSettings[sName];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {?} mValue
|
||||
*/
|
||||
AbstractApp.prototype.settingsSet = function (sName, mValue)
|
||||
{
|
||||
if (null === this.oSettings)
|
||||
{
|
||||
this.oSettings = Utils.isNormal(AppData) ? AppData : {};
|
||||
}
|
||||
|
||||
this.oSettings[sName] = mValue;
|
||||
};
|
||||
|
||||
AbstractApp.prototype.setTitle = function (sTitle)
|
||||
{
|
||||
sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') +
|
||||
this.settingsGet('Title') || '';
|
||||
AppSettings.settingsGet('Title') || '';
|
||||
|
||||
window.document.title = '_';
|
||||
window.document.title = sTitle;
|
||||
|
|
@ -175,8 +143,8 @@
|
|||
AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose)
|
||||
{
|
||||
var
|
||||
sCustomLogoutLink = Utils.pString(this.settingsGet('CustomLogoutLink')),
|
||||
bInIframe = !!this.settingsGet('InIframe')
|
||||
sCustomLogoutLink = Utils.pString(AppSettings.settingsGet('CustomLogoutLink')),
|
||||
bInIframe = !!AppSettings.settingsGet('InIframe')
|
||||
;
|
||||
|
||||
bLogout = Utils.isUnd(bLogout) ? false : !!bLogout;
|
||||
|
|
@ -233,61 +201,11 @@
|
|||
fCallback([], sQuery);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Function} fFunc
|
||||
* @param {Object=} oContext
|
||||
* @return {AbstractApp}
|
||||
*/
|
||||
AbstractApp.prototype.sub = function (sName, fFunc, oContext)
|
||||
{
|
||||
if (Utils.isUnd(this.oSubs[sName]))
|
||||
{
|
||||
this.oSubs[sName] = [];
|
||||
}
|
||||
|
||||
this.oSubs[sName].push([fFunc, oContext]);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Array=} aArgs
|
||||
* @return {AbstractApp}
|
||||
*/
|
||||
AbstractApp.prototype.pub = function (sName, aArgs)
|
||||
{
|
||||
Plugins.runHook('rl-pub', [sName, aArgs]);
|
||||
if (!Utils.isUnd(this.oSubs[sName]))
|
||||
{
|
||||
_.each(this.oSubs[sName], function (aItem) {
|
||||
if (aItem[0])
|
||||
{
|
||||
aItem[0].apply(aItem[1] || null, aArgs || []);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @return {boolean}
|
||||
*/
|
||||
AbstractApp.prototype.capa = function (sName)
|
||||
{
|
||||
var mCapa = this.settingsGet('Capa');
|
||||
return Utils.isArray(mCapa) && Utils.isNormal(sName) && -1 < Utils.inArray(sName, mCapa);
|
||||
};
|
||||
|
||||
AbstractApp.prototype.bootstart = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
ssm = require('../External/ssm.js')
|
||||
;
|
||||
Events.pub('rl.bootstart');
|
||||
|
||||
var ssm = require('../External/ssm.js');
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
Utils.initNotificationLanguage();
|
||||
|
|
@ -302,11 +220,11 @@
|
|||
'maxWidth': 767,
|
||||
'onEnter': function() {
|
||||
$html.addClass('ssm-state-mobile');
|
||||
self.pub('ssm.mobile-enter');
|
||||
Events.pub('ssm.mobile-enter');
|
||||
},
|
||||
'onLeave': function() {
|
||||
$html.removeClass('ssm-state-mobile');
|
||||
self.pub('ssm.mobile-leave');
|
||||
Events.pub('ssm.mobile-leave');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -345,15 +263,15 @@
|
|||
}
|
||||
});
|
||||
|
||||
this.sub('ssm.mobile-enter', function () {
|
||||
RL.data().leftPanelDisabled(true); // TODO cjs
|
||||
Events.sub('ssm.mobile-enter', function () {
|
||||
Globals.leftPanelDisabled(true);
|
||||
});
|
||||
|
||||
this.sub('ssm.mobile-leave', function () {
|
||||
RL.data().leftPanelDisabled(false); // TODO cjs
|
||||
Events.sub('ssm.mobile-leave', function () {
|
||||
Globals.leftPanelDisabled(false);
|
||||
});
|
||||
|
||||
RL.data().leftPanelDisabled.subscribe(function (bValue) { // TODO cjs
|
||||
Globals.leftPanelDisabled.subscribe(function (bValue) {
|
||||
$html.toggleClass('rl-left-panel-disabled', bValue);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,12 @@
|
|||
|
||||
kn = require('../Knoin/Knoin.js'),
|
||||
|
||||
AppSettings = require('../Storages/AppSettings.js'),
|
||||
Data = require('../Storages/AdminDataStorage.js'),
|
||||
Remote = require('../Storages/AdminAjaxRemoteStorage.js'),
|
||||
|
||||
AdminSettingsScreen = require('../Screens/AdminSettingsScreen.js'),
|
||||
AdminLoginScreen = require('../Screens/AdminLoginScreen.js'),
|
||||
|
||||
AbstractApp = require('./AbstractApp.js')
|
||||
;
|
||||
|
|
@ -27,49 +31,80 @@
|
|||
*/
|
||||
function AdminApp()
|
||||
{
|
||||
AbstractApp.call(this);
|
||||
|
||||
this.oData = null;
|
||||
this.oRemote = null;
|
||||
this.oCache = null;
|
||||
AbstractApp.call(this, Remote);
|
||||
}
|
||||
|
||||
_.extend(AdminApp.prototype, AbstractApp.prototype);
|
||||
|
||||
AdminApp.prototype.oData = null;
|
||||
AdminApp.prototype.oRemote = null;
|
||||
AdminApp.prototype.oCache = null;
|
||||
|
||||
/**
|
||||
* @return {AdminDataStorage}
|
||||
*/
|
||||
AdminApp.prototype.data = function ()
|
||||
{
|
||||
if (null === this.oData)
|
||||
{
|
||||
this.oData = new AdminDataStorage(); // TODO cjs
|
||||
}
|
||||
|
||||
return this.oData;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {AdminAjaxRemoteStorage}
|
||||
*/
|
||||
AdminApp.prototype.remote = function ()
|
||||
{
|
||||
if (null === this.oRemote)
|
||||
return Remote;
|
||||
};
|
||||
|
||||
AdminApp.prototype.data = function ()
|
||||
{
|
||||
return Data;
|
||||
};
|
||||
|
||||
AdminApp.prototype.setupSettings = function ()
|
||||
{
|
||||
var
|
||||
AdminSettingsGeneral = require('../Admin/AdminSettingsGeneral.js'),
|
||||
AdminSettingsLogin = require('../Admin/AdminSettingsLogin.js'),
|
||||
AdminSettingsBranding = require('../Admin/AdminSettingsBranding.js'),
|
||||
AdminSettingsContacts = require('../Admin/AdminSettingsContacts.js'),
|
||||
AdminSettingsDomains = require('../Admin/AdminSettingsDomains.js'),
|
||||
AdminSettingsSecurity = require('../Admin/AdminSettingsSecurity.js'),
|
||||
AdminSettingsSocial = require('../Admin/AdminSettingsSocial.js'),
|
||||
AdminSettingsPlugins = require('../Admin/AdminSettingsPlugins.js'),
|
||||
AdminSettingsPackages = require('../Admin/AdminSettingsPackages.js'),
|
||||
AdminSettingsLicensing = require('../Admin/AdminSettingsLicensing.js'),
|
||||
AdminSettingsAbout = require('../Admin/AdminSettingsAbout.js')
|
||||
;
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsGeneral,
|
||||
'AdminSettingsGeneral', 'General', 'general', true);
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsLogin,
|
||||
'AdminSettingsLogin', 'Login', 'login');
|
||||
|
||||
if (AppSettings.capa(Enums.Capa.Prem))
|
||||
{
|
||||
this.oRemote = new AdminAjaxRemoteStorage(); // TODO cjs
|
||||
kn.addSettingsViewModel(AdminSettingsBranding,
|
||||
'AdminSettingsBranding', 'Branding', 'branding');
|
||||
}
|
||||
|
||||
return this.oRemote;
|
||||
kn.addSettingsViewModel(AdminSettingsContacts,
|
||||
'AdminSettingsContacts', 'Contacts', 'contacts');
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsDomains,
|
||||
'AdminSettingsDomains', 'Domains', 'domains');
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsSecurity,
|
||||
'AdminSettingsSecurity', 'Security', 'security');
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsSocial,
|
||||
'AdminSettingsSocial', 'Social', 'social');
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsPlugins,
|
||||
'AdminSettingsPlugins', 'Plugins', 'plugins');
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsPackages,
|
||||
'AdminSettingsPackages', 'Packages', 'packages');
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsLicensing,
|
||||
'AdminSettingsLicensing', 'Licensing', 'licensing');
|
||||
|
||||
kn.addSettingsViewModel(AdminSettingsAbout,
|
||||
'AdminSettingsAbout', 'About', 'about');
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadDomainList = function ()
|
||||
{
|
||||
// TODO cjs
|
||||
Data.domainsLoading(true);
|
||||
|
||||
Remote.domainList(function (sResult, oData) {
|
||||
Data.domainsLoading(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
|
|
@ -89,10 +124,11 @@
|
|||
|
||||
AdminApp.prototype.reloadPluginList = function ()
|
||||
{
|
||||
// TODO cjs
|
||||
Data.pluginsLoading(true);
|
||||
Remote.pluginList(function (sResult, oData) {
|
||||
|
||||
Data.pluginsLoading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
var aList = _.map(oData.Result, function (oItem) {
|
||||
|
|
@ -110,7 +146,6 @@
|
|||
|
||||
AdminApp.prototype.reloadPackagesList = function ()
|
||||
{
|
||||
// TODO cjs
|
||||
Data.packagesLoading(true);
|
||||
Data.packagesReal(true);
|
||||
|
||||
|
|
@ -215,7 +250,6 @@
|
|||
{
|
||||
bForce = Utils.isUnd(bForce) ? false : !!bForce;
|
||||
|
||||
// TODO cjs
|
||||
Data.licensingProcess(true);
|
||||
Data.licenseError('');
|
||||
|
||||
|
|
@ -263,7 +297,7 @@
|
|||
|
||||
kn.hideLoading();
|
||||
|
||||
if (!RL.settingsGet('AllowAdminPanel'))
|
||||
if (!AppSettings.settingsGet('AllowAdminPanel'))
|
||||
{
|
||||
kn.routeOff();
|
||||
kn.setHash(LinkBuilder.root(), true);
|
||||
|
|
@ -275,21 +309,8 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
// kn.removeSettingsViewModel(AdminAbout);
|
||||
|
||||
if (!RL.capa(Enums.Capa.Prem))
|
||||
if (!!AppSettings.settingsGet('Auth'))
|
||||
{
|
||||
kn.removeSettingsViewModel(AdminBranding);
|
||||
}
|
||||
|
||||
if (!!RL.settingsGet('Auth'))
|
||||
{
|
||||
// TODO
|
||||
// if (!RL.settingsGet('AllowPackages') && AdminPackages)
|
||||
// {
|
||||
// kn.disableSettingsViewModel(AdminPackages);
|
||||
// }
|
||||
|
||||
kn.startScreens([AdminSettingsScreen]);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
77
dev/Boots/Boot.js
Normal file
77
dev/Boots/Boot.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('../External/window.js'),
|
||||
$ = require('../External/jquery.js'),
|
||||
$window = require('../External/$window.js'),
|
||||
$html = require('../External/$html.js'),
|
||||
|
||||
Globals = require('../Common/Globals.js'),
|
||||
Plugins = require('../Common/Plugins.js'),
|
||||
Utils = require('../Common/Utils.js')
|
||||
;
|
||||
|
||||
module.exports = function (RL) {
|
||||
|
||||
Globals.__RL = RL;
|
||||
|
||||
RL.setupSettings();
|
||||
|
||||
Plugins.__boot = RL;
|
||||
Plugins.__remote = RL.remote();
|
||||
Plugins.__data = RL.data();
|
||||
|
||||
$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile');
|
||||
|
||||
$window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS);
|
||||
$window.unload(function () {
|
||||
Globals.bUnload = true;
|
||||
});
|
||||
|
||||
$html.on('click.dropdown.data-api', function () {
|
||||
Utils.detectDropdownVisibility();
|
||||
});
|
||||
|
||||
// export
|
||||
window['rl'] = window['rl'] || {};
|
||||
window['rl']['addHook'] = Plugins.addHook;
|
||||
window['rl']['settingsGet'] = Plugins.mainSettingsGet;
|
||||
window['rl']['remoteRequest'] = Plugins.remoteRequest;
|
||||
window['rl']['pluginSettingsGet'] = Plugins.settingsGet;
|
||||
window['rl']['createCommand'] = Utils.createCommand;
|
||||
|
||||
window['rl']['EmailModel'] = require('../Models/EmailModel.js');
|
||||
window['rl']['Enums'] = require('../Common/Enums.js');
|
||||
|
||||
window['__RLBOOT'] = function (fCall) {
|
||||
|
||||
// boot
|
||||
$(function () {
|
||||
|
||||
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
|
||||
{
|
||||
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
RL.bootstart();
|
||||
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
|
||||
|
||||
}, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
fCall(false);
|
||||
}
|
||||
|
||||
window['__RLBOOT'] = null;
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}(module));
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue