mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 03:59:21 +03:00
Source refactoring
This commit is contained in:
parent
09b04740e7
commit
104ac0806a
27 changed files with 204 additions and 715 deletions
|
|
@ -28,6 +28,11 @@
|
|||
*/
|
||||
Globals.startMicrotime = (new window.Date()).getTime();
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.community = RL_COMMUNITY;
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@
|
|||
*/
|
||||
HtmlEditor.prototype.clearSignatureSigns = function (sText)
|
||||
{
|
||||
return sText.replace(/(\u0002|\u0003|\u200C|\u200D)/g, '');
|
||||
return sText.replace(/(\u200C|<x-signature>|<\/x-signature>)/g, '');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -861,10 +861,7 @@
|
|||
;
|
||||
|
||||
sText = sHtml
|
||||
// specials for signature
|
||||
.replace(/\u0002\u0002/g, '\u200C\u200C')
|
||||
.replace(/\u0003\u0003/g, '\u200D\u200D')
|
||||
|
||||
.replace(/<x-signature>([\s\S]*)<\/x-signature>/gm, '\u200C$1\u200C')
|
||||
.replace(/<pre[^>]*>([\s\S\r\n]*)<\/pre>/gmi, convertPre)
|
||||
.replace(/[\s]+/gm, ' ')
|
||||
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
|
||||
|
|
@ -1012,16 +1009,12 @@
|
|||
sPlain = aText.join("\n");
|
||||
|
||||
sPlain = sPlain
|
||||
|
||||
// specials for signature
|
||||
.replace(/\u200C\u200C/g, '\u0002\u0002')
|
||||
.replace(/\u200D\u200D/g, '\u0003\u0003')
|
||||
|
||||
// .replace(/~~~\/blockquote~~~\n~~~blockquote~~~/g, '\n')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/>/g, '>').replace(/</g, '<')
|
||||
.replace(/~~~blockquote~~~[\s]*/g, '<blockquote>')
|
||||
.replace(/[\s]*~~~\/blockquote~~~/g, '</blockquote>')
|
||||
.replace(/\u200C([\s\S]*)\u200C/g, '<x-signature>$1</x-signature>')
|
||||
.replace(/\n/g, '<br />')
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,16 @@
|
|||
kn.addSettingsViewModel(require('Settings/Admin/Login'),
|
||||
'AdminSettingsLogin', 'TABS_LABELS/LABEL_LOGIN_NAME', 'login');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Branding'),
|
||||
'AdminSettingsBranding', 'TABS_LABELS/LABEL_BRANDING_NAME', 'branding');
|
||||
if (RL_COMMUNITY)
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Branding'),
|
||||
'AdminSettingsBranding', 'TABS_LABELS/LABEL_BRANDING_NAME', 'branding');
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Prem/Branding'),
|
||||
'AdminSettingsBranding', 'TABS_LABELS/LABEL_BRANDING_NAME', 'branding');
|
||||
}
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Contacts'),
|
||||
'AdminSettingsContacts', 'TABS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
|
||||
|
|
@ -56,11 +64,14 @@
|
|||
kn.addSettingsViewModel(require('Settings/Admin/Plugins'),
|
||||
'AdminSettingsPlugins', 'TABS_LABELS/LABEL_PLUGINS_NAME', 'plugins');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Packages'),
|
||||
'AdminSettingsPackages', 'TABS_LABELS/LABEL_PACKAGES_NAME', 'packages');
|
||||
if (!RL_COMMUNITY)
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Prem/Packages'),
|
||||
'AdminSettingsPackages', 'TABS_LABELS/LABEL_PACKAGES_NAME', 'packages');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Licensing'),
|
||||
'AdminSettingsLicensing', 'TABS_LABELS/LABEL_LICENSING_NAME', 'licensing');
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Prem/Licensing'),
|
||||
'AdminSettingsLicensing', 'TABS_LABELS/LABEL_LICENSING_NAME', 'licensing');
|
||||
}
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/About'),
|
||||
'AdminSettingsAbout', 'TABS_LABELS/LABEL_ABOUT_NAME', 'about');
|
||||
|
|
|
|||
2
dev/Settings/.gitignore
vendored
Normal file
2
dev/Settings/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/Admin/Prem/**
|
||||
/Admin/_Prem/**
|
||||
|
|
@ -9,7 +9,8 @@
|
|||
Translator = require('Common/Translator'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
CoreStore = require('Stores/Admin/Core')
|
||||
CoreStore = require('Stores/Admin/Core'),
|
||||
AppStore = require('Stores/Admin/App')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -34,6 +35,8 @@
|
|||
this.coreRemoteRelease = CoreStore.coreRemoteRelease;
|
||||
this.coreVersionCompare = CoreStore.coreVersionCompare;
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
|
||||
this.coreRemoteVersionHtmlDesc = ko.computed(function () {
|
||||
Translator.trigger();
|
||||
return Translator.i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
|
||||
|
|
@ -78,7 +81,7 @@
|
|||
|
||||
AboutAdminSettings.prototype.onBuild = function ()
|
||||
{
|
||||
if (this.access())
|
||||
if (this.access() && !this.community)
|
||||
{
|
||||
require('App/Admin').reloadCoreData();
|
||||
}
|
||||
|
|
@ -86,7 +89,7 @@
|
|||
|
||||
AboutAdminSettings.prototype.updateCoreData = function ()
|
||||
{
|
||||
if (!this.coreUpdating())
|
||||
if (!this.coreUpdating() && !this.community)
|
||||
{
|
||||
require('App/Admin').updateCoreData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@
|
|||
});
|
||||
|
||||
this.loginPowered = ko.observable(!!Settings.settingsGet('LoginPowered'));
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
}
|
||||
|
||||
BrandingAdminSettings.prototype.onBuild = function ()
|
||||
|
|
@ -76,85 +78,6 @@
|
|||
Remote = require('Remote/Admin/Ajax')
|
||||
;
|
||||
|
||||
if (this.capa())
|
||||
{
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self),
|
||||
f4 = Utils.settingsSaveHelperSimpleFunction(self.userLogo.trigger, self),
|
||||
f5 = Utils.settingsSaveHelperSimpleFunction(self.userLogoTitle.trigger, self),
|
||||
f6 = Utils.settingsSaveHelperSimpleFunction(self.loginBackground.trigger, self),
|
||||
f7 = Utils.settingsSaveHelperSimpleFunction(self.userCss.trigger, self),
|
||||
f8 = Utils.settingsSaveHelperSimpleFunction(self.welcomePageUrl.trigger, self),
|
||||
f9 = Utils.settingsSaveHelperSimpleFunction(self.welcomePageDisplay.trigger, self)
|
||||
;
|
||||
|
||||
self.loginLogo.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f1, {
|
||||
'LoginLogo': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginDescription.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f2, {
|
||||
'LoginDescription': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginCss.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f3, {
|
||||
'LoginCss': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.userLogo.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f4, {
|
||||
'UserLogo': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.userLogoTitle.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f5, {
|
||||
'UserLogoTitle': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginBackground.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f6, {
|
||||
'LoginBackground': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.userCss.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f7, {
|
||||
'UserCss': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.welcomePageUrl.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f8, {
|
||||
'WelcomePageUrl': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.welcomePageDisplay.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f9, {
|
||||
'WelcomePageDisplay': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginPowered.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'LoginPowered': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
LicenseStore = require('Stores/Admin/License')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LicensingAdminSettings()
|
||||
{
|
||||
this.licensing = LicenseStore.licensing;
|
||||
this.licensingProcess = LicenseStore.licensingProcess;
|
||||
this.licenseValid = LicenseStore.licenseValid;
|
||||
this.licenseExpired = LicenseStore.licenseExpired;
|
||||
this.licenseError = LicenseStore.licenseError;
|
||||
this.licenseTrigger = LicenseStore.licenseTrigger;
|
||||
|
||||
this.adminDomain = ko.observable('');
|
||||
this.subscriptionEnabled = ko.observable(!!Settings.settingsGet('SubscriptionEnabled'));
|
||||
|
||||
this.licenseTrigger.subscribe(function () {
|
||||
if (this.subscriptionEnabled())
|
||||
{
|
||||
require('App/Admin').reloadLicensing(true);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
LicensingAdminSettings.prototype.onBuild = function ()
|
||||
{
|
||||
if (this.subscriptionEnabled())
|
||||
{
|
||||
require('App/Admin').reloadLicensing(false);
|
||||
}
|
||||
};
|
||||
|
||||
LicensingAdminSettings.prototype.onShow = function ()
|
||||
{
|
||||
this.adminDomain(Settings.settingsGet('AdminDomain'));
|
||||
};
|
||||
|
||||
LicensingAdminSettings.prototype.showActivationForm = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Activate'));
|
||||
};
|
||||
|
||||
LicensingAdminSettings.prototype.showTrialForm = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Activate'), [true]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
LicensingAdminSettings.prototype.licenseIsUnlim = function ()
|
||||
{
|
||||
return 1898625600 === this.licenseExpired() || 1898625700 === this.licenseExpired();
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LicensingAdminSettings.prototype.licenseExpiredMomentValue = function ()
|
||||
{
|
||||
var
|
||||
moment = require('moment'),
|
||||
iTime = this.licenseExpired(),
|
||||
oM = moment.unix(iTime)
|
||||
;
|
||||
|
||||
return this.licenseIsUnlim() ? 'Never' :
|
||||
(iTime && (oM.format('LL') + ' (' + oM.from(moment()) + ')'));
|
||||
};
|
||||
|
||||
module.exports = LicensingAdminSettings;
|
||||
|
||||
}());
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
PackageStore = require('Stores/Admin/Package'),
|
||||
Remote = require('Remote/Admin/Ajax')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PackagesAdminSettings()
|
||||
{
|
||||
this.packagesError = ko.observable('');
|
||||
|
||||
this.packages = PackageStore.packages;
|
||||
this.packagesReal = PackageStore.packagesReal;
|
||||
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
|
||||
|
||||
this.packagesCurrent = this.packages.filter(function (oItem) {
|
||||
return oItem && '' !== oItem['installed'] && !oItem['compare'];
|
||||
});
|
||||
|
||||
this.packagesAvailableForUpdate = this.packages.filter(function (oItem) {
|
||||
return oItem && '' !== oItem['installed'] && !!oItem['compare'];
|
||||
});
|
||||
|
||||
this.packagesAvailableForInstallation = this.packages.filter(function (oItem) {
|
||||
return oItem && '' === oItem['installed'];
|
||||
});
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
return PackageStore.packages.loading() ? 'visible' : 'hidden';
|
||||
}, this);
|
||||
}
|
||||
|
||||
PackagesAdminSettings.prototype.onShow = function ()
|
||||
{
|
||||
this.packagesError('');
|
||||
};
|
||||
|
||||
PackagesAdminSettings.prototype.onBuild = function ()
|
||||
{
|
||||
require('App/Admin').reloadPackagesList();
|
||||
};
|
||||
|
||||
PackagesAdminSettings.prototype.requestHelper = function (oPackage, bInstall)
|
||||
{
|
||||
var self = this;
|
||||
return function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
self.packagesError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
self.packagesError(Translator.getNotification(
|
||||
bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage));
|
||||
}
|
||||
}
|
||||
|
||||
_.each(self.packages(), function (oItem) {
|
||||
if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file'])
|
||||
{
|
||||
oPackage['loading'](false);
|
||||
oItem['loading'](false);
|
||||
}
|
||||
});
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result['Reload'])
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
require('App/Admin').reloadPackagesList();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
PackagesAdminSettings.prototype.deletePackage = function (oPackage)
|
||||
{
|
||||
if (oPackage)
|
||||
{
|
||||
oPackage['loading'](true);
|
||||
Remote.packageDelete(this.requestHelper(oPackage, false), oPackage);
|
||||
}
|
||||
};
|
||||
|
||||
PackagesAdminSettings.prototype.installPackage = function (oPackage)
|
||||
{
|
||||
if (oPackage)
|
||||
{
|
||||
oPackage['loading'](true);
|
||||
Remote.packageInstall(this.requestHelper(oPackage, true), oPackage);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = PackagesAdminSettings;
|
||||
|
||||
}());
|
||||
|
|
@ -12,7 +12,10 @@
|
|||
Translator = require('Common/Translator'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
AppStore = require('Stores/Admin/App'),
|
||||
PluginStore = require('Stores/Admin/Plugin'),
|
||||
|
||||
Remote = require('Remote/Admin/Ajax')
|
||||
;
|
||||
|
||||
|
|
@ -26,6 +29,8 @@
|
|||
this.plugins = PluginStore.plugins;
|
||||
this.pluginsError = PluginStore.plugins.error;
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
return PluginStore.plugins.loading() ? 'visible' : 'hidden';
|
||||
}, this);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
this.interfaceAnimation.valueHasMutated();
|
||||
|
||||
this.prem = ko.observable(false);
|
||||
this.community = ko.observable(true);
|
||||
}
|
||||
|
||||
AppStore.prototype.populate = function()
|
||||
|
|
@ -39,6 +40,7 @@
|
|||
this.interfaceAnimation(!!Settings.settingsGet('InterfaceAnimation'));
|
||||
|
||||
this.prem(!!Settings.settingsGet('PremType'));
|
||||
this.community(!!Settings.settingsGet('Community'));
|
||||
};
|
||||
|
||||
module.exports = AppStore;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
this.version = ko.observable(Settings.settingsGet('Version'));
|
||||
|
||||
this.capa = !!Settings.settingsGet('PremType');
|
||||
this.community = RL_COMMUNITY;
|
||||
|
||||
this.adminManLoading = ko.computed(function () {
|
||||
return '000' !== [
|
||||
|
|
|
|||
|
|
@ -299,6 +299,11 @@
|
|||
{
|
||||
var self = this;
|
||||
|
||||
if (0 < this.messageListChecked().length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
window.clearTimeout(this.iGoToUpUpOrDownDownTimeout);
|
||||
this.iGoToUpUpOrDownDownTimeout = window.setTimeout(function () {
|
||||
|
||||
|
|
|
|||
2
dev/bootstrap.js
vendored
2
dev/bootstrap.js
vendored
|
|
@ -82,7 +82,7 @@
|
|||
}
|
||||
|
||||
window['__APP_BOOT'] = null;
|
||||
|
||||
|
||||
}, 10));
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue