mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Code refactoring (2) (es5 -> es2015)
This commit is contained in:
parent
38a1041a73
commit
a2308e251b
23 changed files with 760 additions and 821 deletions
|
|
@ -19,6 +19,9 @@ import PackageStore from 'Stores/Admin/Package';
|
|||
import CoreStore from 'Stores/Admin/Core';
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import {SettingsAdminScreen} from 'Screen/Admin/Settings';
|
||||
import {LoginAdminScreen} from 'Screen/Admin/Login';
|
||||
|
||||
import kn from 'Knoin/Knoin';
|
||||
|
||||
import {AbstractApp} from 'App/Abstract';
|
||||
|
|
@ -236,13 +239,13 @@ class AdminApp extends AbstractApp
|
|||
if (Settings.settingsGet('Auth'))
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/Admin/Settings')
|
||||
SettingsAdminScreen
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/Admin/Login')
|
||||
LoginAdminScreen
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ import {IdentityModel} from 'Model/Identity';
|
|||
import {TemplateModel} from 'Model/Template';
|
||||
import {OpenPgpKeyModel} from 'Model/OpenPgpKey';
|
||||
|
||||
// import {AboutUserScreen} from 'Screen/User/About';
|
||||
import {LoginUserScreen} from 'Screen/User/Login';
|
||||
import {MailBoxUserScreen} from 'Screen/User/MailBox';
|
||||
import {SettingsUserScreen} from 'Screen/User/Settings';
|
||||
|
||||
import kn from 'Knoin/Knoin';
|
||||
|
||||
import {AbstractApp} from 'App/Abstract';
|
||||
|
|
@ -1210,7 +1215,7 @@ class AppUser extends AbstractApp
|
|||
if (!customLoginLink)
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/User/Login')
|
||||
LoginUserScreen
|
||||
]);
|
||||
|
||||
Plugins.runHook('rl-start-login-screens');
|
||||
|
|
@ -1345,9 +1350,9 @@ class AppUser extends AbstractApp
|
|||
}
|
||||
|
||||
kn.startScreens([
|
||||
require('Screen/User/MailBox'),
|
||||
Settings.capa(Capa.Settings) ? require('Screen/User/Settings') : null
|
||||
// false ? require('Screen/User/About') : null
|
||||
MailBoxUserScreen,
|
||||
Settings.capa(Capa.Settings) ? SettingsUserScreen : null
|
||||
// false ? AboutUserScreen : null
|
||||
]);
|
||||
|
||||
if (bGoogle || bFacebook || bTwitter)
|
||||
|
|
|
|||
|
|
@ -199,31 +199,30 @@ export function initNotificationLanguage()
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
* @param {Object} scope
|
||||
* @param {Function} startCallback
|
||||
* @param {Function=} langCallback = null
|
||||
*/
|
||||
export function initOnStartOrLangChange(callback, scope, langCallback = null)
|
||||
export function initOnStartOrLangChange(startCallback, langCallback = null)
|
||||
{
|
||||
if (callback)
|
||||
if (startCallback)
|
||||
{
|
||||
callback.call(scope);
|
||||
startCallback();
|
||||
}
|
||||
|
||||
if (langCallback)
|
||||
{
|
||||
trigger.subscribe(() => {
|
||||
if (callback)
|
||||
if (startCallback)
|
||||
{
|
||||
callback.call(scope);
|
||||
startCallback();
|
||||
}
|
||||
|
||||
langCallback.call(scope);
|
||||
langCallback();
|
||||
});
|
||||
}
|
||||
else if (callback)
|
||||
else if (startCallback)
|
||||
{
|
||||
trigger.subscribe(callback, scope);
|
||||
trigger.subscribe(startCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,24 @@ export function decodeURIComponent(component)
|
|||
return window.decodeURIComponent(component);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @returns {string}
|
||||
*/
|
||||
export function decodeURI(url)
|
||||
{
|
||||
return window.decodeURI(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @returns {string}
|
||||
*/
|
||||
export function encodeURI(url)
|
||||
{
|
||||
return window.encodeURI(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} queryString
|
||||
* @returns {Object}
|
||||
|
|
|
|||
|
|
@ -1,83 +0,0 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
crossroads = require('crossroads'),
|
||||
|
||||
Utils = require('Common/Utils');
|
||||
|
||||
/**
|
||||
* @param {string} sScreenName
|
||||
* @param {?=} aViewModels = []
|
||||
* @constructor
|
||||
*/
|
||||
function AbstractScreen(sScreenName, aViewModels)
|
||||
{
|
||||
this.sScreenName = sScreenName;
|
||||
this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
AbstractScreen.prototype.oCross = null;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
AbstractScreen.prototype.sScreenName = '';
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
AbstractScreen.prototype.aViewModels = [];
|
||||
|
||||
/**
|
||||
* @returns {Array}
|
||||
*/
|
||||
AbstractScreen.prototype.viewModels = function()
|
||||
{
|
||||
return this.aViewModels;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
AbstractScreen.prototype.screenName = function()
|
||||
{
|
||||
return this.sScreenName;
|
||||
};
|
||||
|
||||
AbstractScreen.prototype.routes = function()
|
||||
{
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {?Object}
|
||||
*/
|
||||
AbstractScreen.prototype.__cross = function()
|
||||
{
|
||||
return this.oCross;
|
||||
};
|
||||
|
||||
AbstractScreen.prototype.__start = function()
|
||||
{
|
||||
var
|
||||
aRoutes = this.routes(),
|
||||
oRoute = null,
|
||||
fMatcher = null;
|
||||
|
||||
if (Utils.isNonEmptyArray(aRoutes))
|
||||
{
|
||||
fMatcher = _.bind(this.onRoute || Utils.noop, this);
|
||||
oRoute = crossroads.create();
|
||||
|
||||
_.each(aRoutes, function(aItem) {
|
||||
oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1];
|
||||
});
|
||||
|
||||
this.oCross = oRoute;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = AbstractScreen;
|
||||
66
dev/Knoin/AbstractScreen.jsx
Normal file
66
dev/Knoin/AbstractScreen.jsx
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
import _ from '_';
|
||||
import crossroads from 'crossroads';
|
||||
import {isArray, isNonEmptyArray, noop} from 'Common/Utils';
|
||||
|
||||
class AbstractScreen
|
||||
{
|
||||
constructor(screenName, viewModels = [])
|
||||
{
|
||||
this.oCross = null;
|
||||
this.sScreenName = screenName;
|
||||
this.aViewModels = isArray(viewModels) ? viewModels : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array}
|
||||
*/
|
||||
viewModels() {
|
||||
return this.aViewModels;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
screenName() {
|
||||
return this.sScreenName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {?Array)}
|
||||
*/
|
||||
routes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {?Object}
|
||||
*/
|
||||
__cross() {
|
||||
return this.oCross;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
__start() {
|
||||
let
|
||||
route = null,
|
||||
fMatcher = null;
|
||||
const routes = this.routes();
|
||||
|
||||
if (isNonEmptyArray(routes))
|
||||
{
|
||||
fMatcher = _.bind(this.onRoute || noop, this);
|
||||
route = crossroads.create();
|
||||
|
||||
_.each(routes, (aItem) => {
|
||||
route.addRoute(aItem[0], fMatcher).rules = aItem[1];
|
||||
});
|
||||
|
||||
this.oCross = route;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {AbstractScreen, AbstractScreen as default};
|
||||
|
|
@ -1,209 +0,0 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractScreen = require('Knoin/AbstractScreen');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Array} aViewModels
|
||||
* @extends AbstractScreen
|
||||
*/
|
||||
function AbstractSettingsScreen(aViewModels)
|
||||
{
|
||||
AbstractScreen.call(this, 'settings', aViewModels);
|
||||
|
||||
this.menu = ko.observableArray([]);
|
||||
|
||||
this.oCurrentSubScreen = null;
|
||||
this.oViewModelPlace = null;
|
||||
|
||||
this.setupSettings();
|
||||
}
|
||||
|
||||
_.extend(AbstractSettingsScreen.prototype, AbstractScreen.prototype);
|
||||
|
||||
/**
|
||||
* @param {Function=} fCallback
|
||||
*/
|
||||
AbstractSettingsScreen.prototype.setupSettings = function(fCallback)
|
||||
{
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSettingsScreen.prototype.onRoute = function(sSubName)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oSettingsScreen = null,
|
||||
RoutedSettingsViewModel = null,
|
||||
oViewModelPlace = null,
|
||||
oViewModelDom = null;
|
||||
|
||||
RoutedSettingsViewModel = _.find(Globals.aViewModels.settings, function(SettingsViewModel) {
|
||||
return SettingsViewModel && SettingsViewModel.__rlSettingsData &&
|
||||
sSubName === SettingsViewModel.__rlSettingsData.Route;
|
||||
});
|
||||
|
||||
if (RoutedSettingsViewModel)
|
||||
{
|
||||
if (_.find(Globals.aViewModels['settings-removed'], function(DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
||||
}))
|
||||
{
|
||||
RoutedSettingsViewModel = null;
|
||||
}
|
||||
|
||||
if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function(DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
||||
}))
|
||||
{
|
||||
RoutedSettingsViewModel = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (RoutedSettingsViewModel)
|
||||
{
|
||||
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
|
||||
{
|
||||
oSettingsScreen = RoutedSettingsViewModel.__vm;
|
||||
}
|
||||
else
|
||||
{
|
||||
oViewModelPlace = this.oViewModelPlace;
|
||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
||||
{
|
||||
oSettingsScreen = new RoutedSettingsViewModel();
|
||||
|
||||
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
||||
oViewModelDom.appendTo(oViewModelPlace);
|
||||
|
||||
oSettingsScreen.viewModelDom = oViewModelDom;
|
||||
|
||||
oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData;
|
||||
|
||||
RoutedSettingsViewModel.__dom = oViewModelDom;
|
||||
RoutedSettingsViewModel.__builded = true;
|
||||
RoutedSettingsViewModel.__vm = oSettingsScreen;
|
||||
|
||||
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
||||
translatorInit: true,
|
||||
template: function() {
|
||||
return {
|
||||
name: RoutedSettingsViewModel.__rlSettingsData.Template
|
||||
};
|
||||
}
|
||||
}, oSettingsScreen);
|
||||
|
||||
Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.log('Cannot find sub settings view model position: SettingsSubScreen');
|
||||
}
|
||||
}
|
||||
|
||||
if (oSettingsScreen)
|
||||
{
|
||||
_.defer(function() {
|
||||
// hide
|
||||
if (self.oCurrentSubScreen)
|
||||
{
|
||||
Utils.delegateRun(self.oCurrentSubScreen, 'onHide');
|
||||
self.oCurrentSubScreen.viewModelDom.hide();
|
||||
}
|
||||
// --
|
||||
|
||||
self.oCurrentSubScreen = oSettingsScreen;
|
||||
|
||||
// show
|
||||
if (self.oCurrentSubScreen)
|
||||
{
|
||||
Utils.delegateRun(self.oCurrentSubScreen, 'onBeforeShow');
|
||||
self.oCurrentSubScreen.viewModelDom.show();
|
||||
Utils.delegateRun(self.oCurrentSubScreen, 'onShow');
|
||||
Utils.delegateRun(self.oCurrentSubScreen, 'onShowWithDelay', [], 200);
|
||||
|
||||
_.each(self.menu(), function(oItem) {
|
||||
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
|
||||
});
|
||||
|
||||
$('#rl-content .b-settings .b-content .content').scrollTop(0);
|
||||
}
|
||||
// --
|
||||
|
||||
Utils.windowResize();
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.setHash(Links.settings(), false, true);
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSettingsScreen.prototype.onHide = function()
|
||||
{
|
||||
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
|
||||
{
|
||||
Utils.delegateRun(this.oCurrentSubScreen, 'onHide');
|
||||
this.oCurrentSubScreen.viewModelDom.hide();
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSettingsScreen.prototype.onBuild = function()
|
||||
{
|
||||
_.each(Globals.aViewModels.settings, function(SettingsViewModel) {
|
||||
if (SettingsViewModel && SettingsViewModel.__rlSettingsData &&
|
||||
!_.find(Globals.aViewModels['settings-removed'], function(RemoveSettingsViewModel) {
|
||||
return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel;
|
||||
}))
|
||||
{
|
||||
this.menu.push({
|
||||
route: SettingsViewModel.__rlSettingsData.Route,
|
||||
label: SettingsViewModel.__rlSettingsData.Label,
|
||||
selected: ko.observable(false),
|
||||
disabled: !!_.find(Globals.aViewModels['settings-disabled'], function(DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel;
|
||||
})
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.oViewModelPlace = $('#rl-content #rl-settings-subscreen');
|
||||
};
|
||||
|
||||
AbstractSettingsScreen.prototype.routes = function()
|
||||
{
|
||||
var
|
||||
DefaultViewModel = _.find(Globals.aViewModels.settings, function(SettingsViewModel) {
|
||||
return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData.IsDefault;
|
||||
}),
|
||||
sDefaultRoute = DefaultViewModel && DefaultViewModel.__rlSettingsData ?
|
||||
DefaultViewModel.__rlSettingsData.Route : 'general',
|
||||
oRules = {
|
||||
subname: /^(.*)$/,
|
||||
normalize_: function(oRequest, oVals) {
|
||||
oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname);
|
||||
return [oVals.subname];
|
||||
}
|
||||
};
|
||||
|
||||
return [
|
||||
['{subname}/', oRules],
|
||||
['{subname}', oRules],
|
||||
['', oRules]
|
||||
];
|
||||
};
|
||||
|
||||
module.exports = AbstractSettingsScreen;
|
||||
189
dev/Screen/AbstractSettings.jsx
Normal file
189
dev/Screen/AbstractSettings.jsx
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
|
||||
import {aViewModels as VIEW_MODELS} from 'Common/Globals';
|
||||
import {delegateRun, windowResize, log, isUnd, pString} from 'Common/Utils';
|
||||
import {settings} from 'Common/Links';
|
||||
|
||||
import kn from 'Knoin/Knoin';
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
|
||||
class AbstractSettingsScreen extends AbstractScreen
|
||||
{
|
||||
/**
|
||||
* @param {Array} viewModels
|
||||
*/
|
||||
constructor(viewModels)
|
||||
{
|
||||
super('settings', viewModels);
|
||||
|
||||
this.menu = ko.observableArray([]);
|
||||
|
||||
this.oCurrentSubScreen = null;
|
||||
this.oViewModelPlace = null;
|
||||
|
||||
this.setupSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function=} fCallback
|
||||
*/
|
||||
setupSettings(fCallback = null) {
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
}
|
||||
}
|
||||
|
||||
onRoute(sSubName) {
|
||||
var
|
||||
self = this,
|
||||
oSettingsScreen = null,
|
||||
RoutedSettingsViewModel = null,
|
||||
oViewModelPlace = null,
|
||||
oViewModelDom = null;
|
||||
|
||||
RoutedSettingsViewModel = _.find(VIEW_MODELS.settings,
|
||||
(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && sSubName === SettingsViewModel.__rlSettingsData.Route
|
||||
);
|
||||
|
||||
if (RoutedSettingsViewModel)
|
||||
{
|
||||
if (_.find(VIEW_MODELS['settings-removed'], (DisabledSettingsViewModel) => DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel))
|
||||
{
|
||||
RoutedSettingsViewModel = null;
|
||||
}
|
||||
|
||||
if (RoutedSettingsViewModel && _.find(VIEW_MODELS['settings-disabled'],
|
||||
(DisabledSettingsViewModel) => DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel))
|
||||
{
|
||||
RoutedSettingsViewModel = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (RoutedSettingsViewModel)
|
||||
{
|
||||
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
|
||||
{
|
||||
oSettingsScreen = RoutedSettingsViewModel.__vm;
|
||||
}
|
||||
else
|
||||
{
|
||||
oViewModelPlace = this.oViewModelPlace;
|
||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
||||
{
|
||||
oSettingsScreen = new RoutedSettingsViewModel();
|
||||
|
||||
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
||||
oViewModelDom.appendTo(oViewModelPlace);
|
||||
|
||||
oSettingsScreen.viewModelDom = oViewModelDom;
|
||||
|
||||
oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData;
|
||||
|
||||
RoutedSettingsViewModel.__dom = oViewModelDom;
|
||||
RoutedSettingsViewModel.__builded = true;
|
||||
RoutedSettingsViewModel.__vm = oSettingsScreen;
|
||||
|
||||
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
||||
translatorInit: true,
|
||||
template: () => ({name: RoutedSettingsViewModel.__rlSettingsData.Template})
|
||||
}, oSettingsScreen);
|
||||
|
||||
delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
|
||||
}
|
||||
else
|
||||
{
|
||||
log('Cannot find sub settings view model position: SettingsSubScreen');
|
||||
}
|
||||
}
|
||||
|
||||
if (oSettingsScreen)
|
||||
{
|
||||
_.defer(function() {
|
||||
// hide
|
||||
if (self.oCurrentSubScreen)
|
||||
{
|
||||
delegateRun(self.oCurrentSubScreen, 'onHide');
|
||||
self.oCurrentSubScreen.viewModelDom.hide();
|
||||
}
|
||||
// --
|
||||
|
||||
self.oCurrentSubScreen = oSettingsScreen;
|
||||
|
||||
// show
|
||||
if (self.oCurrentSubScreen)
|
||||
{
|
||||
delegateRun(self.oCurrentSubScreen, 'onBeforeShow');
|
||||
self.oCurrentSubScreen.viewModelDom.show();
|
||||
delegateRun(self.oCurrentSubScreen, 'onShow');
|
||||
delegateRun(self.oCurrentSubScreen, 'onShowWithDelay', [], 200);
|
||||
|
||||
_.each(self.menu(), (oItem) => {
|
||||
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
|
||||
});
|
||||
|
||||
$('#rl-content .b-settings .b-content .content').scrollTop(0);
|
||||
}
|
||||
// --
|
||||
|
||||
windowResize();
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.setHash(settings(), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
onHide() {
|
||||
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
|
||||
{
|
||||
delegateRun(this.oCurrentSubScreen, 'onHide');
|
||||
this.oCurrentSubScreen.viewModelDom.hide();
|
||||
}
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
_.each(VIEW_MODELS.settings, (SettingsViewModel) => {
|
||||
if (SettingsViewModel && SettingsViewModel.__rlSettingsData && !_.find(VIEW_MODELS['settings-removed'],
|
||||
(RemoveSettingsViewModel) => RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel))
|
||||
{
|
||||
this.menu.push({
|
||||
route: SettingsViewModel.__rlSettingsData.Route,
|
||||
label: SettingsViewModel.__rlSettingsData.Label,
|
||||
selected: ko.observable(false),
|
||||
disabled: !!_.find(VIEW_MODELS['settings-disabled'],
|
||||
(DisabledSettingsViewModel) => DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.oViewModelPlace = $('#rl-content #rl-settings-subscreen');
|
||||
}
|
||||
|
||||
routes() {
|
||||
var
|
||||
DefaultViewModel = _.find(VIEW_MODELS.settings,
|
||||
(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData.IsDefault),
|
||||
defaultRoute = DefaultViewModel && DefaultViewModel.__rlSettingsData ? DefaultViewModel.__rlSettingsData.Route : 'general',
|
||||
oRules = {
|
||||
subname: /^(.*)$/,
|
||||
normalize_: (oRequest, oVals) => {
|
||||
oVals.subname = isUnd(oVals.subname) ? defaultRoute : pString(oVals.subname);
|
||||
return [oVals.subname];
|
||||
}
|
||||
};
|
||||
|
||||
return [
|
||||
['{subname}/', oRules],
|
||||
['{subname}', oRules],
|
||||
['', oRules]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
export {AbstractSettingsScreen, AbstractSettingsScreen as default};
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
AbstractScreen = require('Knoin/AbstractScreen');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractScreen
|
||||
*/
|
||||
function LoginAdminScreen()
|
||||
{
|
||||
AbstractScreen.call(this, 'login', [
|
||||
require('View/Admin/Login')
|
||||
]);
|
||||
}
|
||||
|
||||
_.extend(LoginAdminScreen.prototype, AbstractScreen.prototype);
|
||||
|
||||
LoginAdminScreen.prototype.onShow = function()
|
||||
{
|
||||
require('App/Admin').default.setWindowTitle('');
|
||||
};
|
||||
|
||||
module.exports = LoginAdminScreen;
|
||||
19
dev/Screen/Admin/Login.jsx
Normal file
19
dev/Screen/Admin/Login.jsx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
import App from 'App/Admin';
|
||||
|
||||
class LoginAdminScreen extends AbstractScreen
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('login', [
|
||||
require('View/Admin/Login')
|
||||
]);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
App.setWindowTitle('');
|
||||
}
|
||||
}
|
||||
|
||||
export {LoginAdminScreen, LoginAdminScreen as default};
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
|
||||
Plugins = require('Common/Plugins'),
|
||||
|
||||
AbstractSettings = require('Screen/AbstractSettings');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSettings
|
||||
*/
|
||||
function SettingsAdminScreen()
|
||||
{
|
||||
AbstractSettings.call(this, [
|
||||
require('View/Admin/Settings/Menu'),
|
||||
require('View/Admin/Settings/Pane')
|
||||
]);
|
||||
}
|
||||
|
||||
_.extend(SettingsAdminScreen.prototype, AbstractSettings.prototype);
|
||||
|
||||
/**
|
||||
* @param {Function=} fCallback
|
||||
*/
|
||||
SettingsAdminScreen.prototype.setupSettings = function(fCallback)
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/Admin/General'),
|
||||
'AdminSettingsGeneral', 'TABS_LABELS/LABEL_GENERAL_NAME', 'general', true);
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Login'),
|
||||
'AdminSettingsLogin', 'TABS_LABELS/LABEL_LOGIN_NAME', 'login');
|
||||
|
||||
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');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Domains'),
|
||||
'AdminSettingsDomains', 'TABS_LABELS/LABEL_DOMAINS_NAME', 'domains');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Security'),
|
||||
'AdminSettingsSecurity', 'TABS_LABELS/LABEL_SECURITY_NAME', 'security');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Social'),
|
||||
'AdminSettingsSocial', 'TABS_LABELS/LABEL_INTEGRATION_NAME', 'integrations');
|
||||
|
||||
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/Licensing'),
|
||||
'AdminSettingsLicensing', 'TABS_LABELS/LABEL_LICENSING_NAME', 'licensing');
|
||||
}
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/About'),
|
||||
'AdminSettingsAbout', 'TABS_LABELS/LABEL_ABOUT_NAME', 'about');
|
||||
|
||||
Plugins.runSettingsViewModelHooks(true);
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
}
|
||||
};
|
||||
|
||||
SettingsAdminScreen.prototype.onShow = function()
|
||||
{
|
||||
require('App/Admin').default.setWindowTitle('');
|
||||
};
|
||||
|
||||
module.exports = SettingsAdminScreen;
|
||||
81
dev/Screen/Admin/Settings.jsx
Normal file
81
dev/Screen/Admin/Settings.jsx
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
import kn from 'Knoin/Knoin';
|
||||
import {runSettingsViewModelHooks} from 'Common/Plugins';
|
||||
|
||||
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
||||
import App from 'App/Admin';
|
||||
|
||||
class SettingsAdminScreen extends AbstractSettingsScreen
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super([
|
||||
require('View/Admin/Settings/Menu'),
|
||||
require('View/Admin/Settings/Pane')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function=} fCallback = null
|
||||
*/
|
||||
setupSettings(fCallback = null) {
|
||||
kn.addSettingsViewModel(require('Settings/Admin/General'),
|
||||
'AdminSettingsGeneral', 'TABS_LABELS/LABEL_GENERAL_NAME', 'general', true);
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Login'),
|
||||
'AdminSettingsLogin', 'TABS_LABELS/LABEL_LOGIN_NAME', 'login');
|
||||
|
||||
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');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Domains'),
|
||||
'AdminSettingsDomains', 'TABS_LABELS/LABEL_DOMAINS_NAME', 'domains');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Security'),
|
||||
'AdminSettingsSecurity', 'TABS_LABELS/LABEL_SECURITY_NAME', 'security');
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/Social'),
|
||||
'AdminSettingsSocial', 'TABS_LABELS/LABEL_INTEGRATION_NAME', 'integrations');
|
||||
|
||||
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/Licensing'),
|
||||
'AdminSettingsLicensing', 'TABS_LABELS/LABEL_LICENSING_NAME', 'licensing');
|
||||
}
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/Admin/About'),
|
||||
'AdminSettingsAbout', 'TABS_LABELS/LABEL_ABOUT_NAME', 'about');
|
||||
|
||||
runSettingsViewModelHooks(true);
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
}
|
||||
}
|
||||
|
||||
onShow() {
|
||||
App.setWindowTitle('');
|
||||
}
|
||||
}
|
||||
|
||||
export {SettingsAdminScreen, SettingsAdminScreen as default};
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
AbstractScreen = require('Knoin/AbstractScreen');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractScreen
|
||||
*/
|
||||
function AboutUserScreen()
|
||||
{
|
||||
AbstractScreen.call(this, 'about', [
|
||||
require('View/User/About')
|
||||
]);
|
||||
}
|
||||
|
||||
_.extend(AboutUserScreen.prototype, AbstractScreen.prototype);
|
||||
|
||||
AboutUserScreen.prototype.onShow = function()
|
||||
{
|
||||
require('App/User').default.setWindowTitle('RainLoop');
|
||||
};
|
||||
|
||||
module.exports = AboutUserScreen;
|
||||
19
dev/Screen/User/About.jsx
Normal file
19
dev/Screen/User/About.jsx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
import App from 'App/User';
|
||||
|
||||
class AboutUserScreen extends AbstractScreen
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('about', [
|
||||
require('View/User/About')
|
||||
]);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
App.setWindowTitle('RainLoop');
|
||||
}
|
||||
}
|
||||
|
||||
export {AboutUserScreen, AboutUserScreen as default};
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
AbstractScreen = require('Knoin/AbstractScreen');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractScreen
|
||||
*/
|
||||
function LoginUserScreen()
|
||||
{
|
||||
AbstractScreen.call(this, 'login', [
|
||||
require('View/User/Login')
|
||||
]);
|
||||
}
|
||||
|
||||
_.extend(LoginUserScreen.prototype, AbstractScreen.prototype);
|
||||
|
||||
LoginUserScreen.prototype.onShow = function()
|
||||
{
|
||||
require('App/User').default.setWindowTitle('');
|
||||
};
|
||||
|
||||
module.exports = LoginUserScreen;
|
||||
19
dev/Screen/User/Login.jsx
Normal file
19
dev/Screen/User/Login.jsx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
import App from 'App/User';
|
||||
|
||||
class LoginUserScreen extends AbstractScreen
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('login', [
|
||||
require('View/User/Login')
|
||||
]);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
App.setWindowTitle('');
|
||||
}
|
||||
}
|
||||
|
||||
export {LoginUserScreen, LoginUserScreen as default};
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Events = require('Common/Events'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Cache = require('Common/Cache'),
|
||||
|
||||
AppStore = require('Stores/User/App'),
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
SettingsStore = require('Stores/User/Settings'),
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
AbstractScreen = require('Knoin/AbstractScreen');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractScreen
|
||||
*/
|
||||
function MailBoxUserScreen()
|
||||
{
|
||||
AbstractScreen.call(this, 'mailbox', [
|
||||
require('View/User/MailBox/SystemDropDown'),
|
||||
require('View/User/MailBox/FolderList'),
|
||||
require('View/User/MailBox/MessageList'),
|
||||
require('View/User/MailBox/MessageView')
|
||||
]);
|
||||
|
||||
this.oLastRoute = {};
|
||||
}
|
||||
|
||||
_.extend(MailBoxUserScreen.prototype, AbstractScreen.prototype);
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
MailBoxUserScreen.prototype.oLastRoute = {};
|
||||
|
||||
MailBoxUserScreen.prototype.updateWindowTitle = function()
|
||||
{
|
||||
var
|
||||
sEmail = AccountStore.email(),
|
||||
nFoldersInboxUnreadCount = FolderStore.foldersInboxUnreadCount();
|
||||
|
||||
if (Settings.appSettingsGet('listPermanentFiltered'))
|
||||
{
|
||||
nFoldersInboxUnreadCount = 0;
|
||||
}
|
||||
|
||||
require('App/User').default.setWindowTitle(('' === sEmail ? '' : '' +
|
||||
(0 < nFoldersInboxUnreadCount ? '(' + nFoldersInboxUnreadCount + ') ' : ' ') +
|
||||
sEmail + ' - ') + Translator.i18n('TITLES/MAILBOX'));
|
||||
};
|
||||
|
||||
MailBoxUserScreen.prototype.onShow = function()
|
||||
{
|
||||
this.updateWindowTitle();
|
||||
|
||||
AppStore.focusedState(Enums.Focused.None);
|
||||
AppStore.focusedState(Enums.Focused.MessageList);
|
||||
|
||||
if (Settings.appSettingsGet('mobile'))
|
||||
{
|
||||
Globals.leftPanelDisabled(true);
|
||||
}
|
||||
|
||||
if (!Settings.capa(Enums.Capa.Folders))
|
||||
{
|
||||
Globals.leftPanelType(
|
||||
Settings.capa(Enums.Capa.Composer) || Settings.capa(Enums.Capa.Contacts) ? 'short' : 'none');
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.leftPanelType('');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFolderHash
|
||||
* @param {number} iPage
|
||||
* @param {string} sSearch
|
||||
*/
|
||||
MailBoxUserScreen.prototype.onRoute = function(sFolderHash, iPage, sSearch)
|
||||
{
|
||||
var
|
||||
sThreadUid = sFolderHash.replace(/^(.+)~([\d]+)$/, '$2'),
|
||||
oFolder = Cache.getFolderFromCacheList(Cache.getFolderFullNameRaw(
|
||||
sFolderHash.replace(/~([\d]+)$/, '')));
|
||||
|
||||
if (oFolder)
|
||||
{
|
||||
if (sFolderHash === sThreadUid)
|
||||
{
|
||||
sThreadUid = '';
|
||||
}
|
||||
|
||||
FolderStore.currentFolder(oFolder);
|
||||
|
||||
MessageStore.messageListPage(iPage);
|
||||
MessageStore.messageListSearch(sSearch);
|
||||
MessageStore.messageListThreadUid(sThreadUid);
|
||||
|
||||
require('App/User').default.reloadMessageList();
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxUserScreen.prototype.onStart = function()
|
||||
{
|
||||
FolderStore.folderList.subscribe(Utils.windowResizeCallback);
|
||||
|
||||
MessageStore.messageList.subscribe(Utils.windowResizeCallback);
|
||||
MessageStore.message.subscribe(Utils.windowResizeCallback);
|
||||
|
||||
_.delay(function() {
|
||||
SettingsStore.layout.valueHasMutated();
|
||||
}, 50);
|
||||
|
||||
Events.sub('mailbox.inbox-unread-count', _.bind(function(iCount) {
|
||||
|
||||
FolderStore.foldersInboxUnreadCount(iCount);
|
||||
|
||||
var sEmail = AccountStore.email();
|
||||
|
||||
_.each(AccountStore.accounts(), function(oItem) {
|
||||
if (oItem && sEmail === oItem.email)
|
||||
{
|
||||
oItem.count(iCount);
|
||||
}
|
||||
});
|
||||
|
||||
this.updateWindowTitle();
|
||||
|
||||
}, this));
|
||||
};
|
||||
|
||||
MailBoxUserScreen.prototype.onBuild = function()
|
||||
{
|
||||
if (!Globals.bMobileDevice && !Settings.appSettingsGet('mobile'))
|
||||
{
|
||||
_.defer(function() {
|
||||
require('App/User').default.initHorizontalLayoutResizer(Enums.ClientSideKeyName.MessageListSize);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Array}
|
||||
*/
|
||||
MailBoxUserScreen.prototype.routes = function()
|
||||
{
|
||||
var
|
||||
sInboxFolderName = Cache.getFolderInboxName(),
|
||||
fNormS = function(oRequest, oVals) {
|
||||
oVals[0] = Utils.pString(oVals[0]);
|
||||
oVals[1] = Utils.pInt(oVals[1]);
|
||||
oVals[1] = 0 >= oVals[1] ? 1 : oVals[1];
|
||||
oVals[2] = Utils.pString(oVals[2]);
|
||||
|
||||
if ('' === oRequest)
|
||||
{
|
||||
oVals[0] = sInboxFolderName;
|
||||
oVals[1] = 1;
|
||||
}
|
||||
|
||||
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2])];
|
||||
},
|
||||
fNormD = function(oRequest, oVals) {
|
||||
oVals[0] = Utils.pString(oVals[0]);
|
||||
oVals[1] = Utils.pString(oVals[1]);
|
||||
|
||||
if ('' === oRequest)
|
||||
{
|
||||
oVals[0] = sInboxFolderName;
|
||||
}
|
||||
|
||||
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1])];
|
||||
};
|
||||
|
||||
return [
|
||||
[/^([a-zA-Z0-9~]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}],
|
||||
[/^([a-zA-Z0-9~]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}],
|
||||
[/^([a-zA-Z0-9~]+)\/(.+)\/?$/, {'normalize_': fNormD}],
|
||||
[/^([^\/]*)$/, {'normalize_': fNormS}]
|
||||
];
|
||||
};
|
||||
|
||||
module.exports = MailBoxUserScreen;
|
||||
180
dev/Screen/User/MailBox.jsx
Normal file
180
dev/Screen/User/MailBox.jsx
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
|
||||
import _ from '_';
|
||||
|
||||
import {Focused, Capa, ClientSideKeyName, Magics} from 'Common/Enums';
|
||||
import {leftPanelDisabled, leftPanelType, bMobileDevice} from 'Common/Globals';
|
||||
import {pString, pInt, decodeURI, windowResizeCallback} from 'Common/Utils';
|
||||
import {getFolderFromCacheList, getFolderFullNameRaw, getFolderInboxName} from 'Common/Cache';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
import * as Events from 'Common/Events';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
import AppStore from 'Stores/User/App';
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
import SettingsStore from 'Stores/User/Settings';
|
||||
import FolderStore from 'Stores/User/Folder';
|
||||
import MessageStore from 'Stores/User/Message';
|
||||
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
import App from 'App/User';
|
||||
|
||||
class MailBoxUserScreen extends AbstractScreen
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super('mailbox', [
|
||||
require('View/User/MailBox/SystemDropDown'),
|
||||
require('View/User/MailBox/FolderList'),
|
||||
require('View/User/MailBox/MessageList'),
|
||||
require('View/User/MailBox/MessageView')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
updateWindowTitle() {
|
||||
let foldersInboxUnreadCount = FolderStore.foldersInboxUnreadCount();
|
||||
const email = AccountStore.email();
|
||||
|
||||
if (Settings.appSettingsGet('listPermanentFiltered'))
|
||||
{
|
||||
foldersInboxUnreadCount = 0;
|
||||
}
|
||||
|
||||
App.setWindowTitle(('' === email ? '' : '' + (0 < foldersInboxUnreadCount ? '(' + foldersInboxUnreadCount + ') ' : ' ') + email + ' - ') + i18n('TITLES/MAILBOX'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
onShow() {
|
||||
this.updateWindowTitle();
|
||||
|
||||
AppStore.focusedState(Focused.None);
|
||||
AppStore.focusedState(Focused.MessageList);
|
||||
|
||||
if (Settings.appSettingsGet('mobile'))
|
||||
{
|
||||
leftPanelDisabled(true);
|
||||
}
|
||||
|
||||
if (!Settings.capa(Capa.Folders))
|
||||
{
|
||||
leftPanelType(Settings.capa(Capa.Composer) || Settings.capa(Capa.Contacts) ? 'short' : 'none');
|
||||
}
|
||||
else
|
||||
{
|
||||
leftPanelType('');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} folderHash
|
||||
* @param {number} page
|
||||
* @param {string} search
|
||||
*/
|
||||
onRoute(folderHash, page, search) {
|
||||
let threadUid = folderHash.replace(/^(.+)~([\d]+)$/, '$2');
|
||||
const folder = getFolderFromCacheList(getFolderFullNameRaw(folderHash.replace(/~([\d]+)$/, '')));
|
||||
|
||||
if (folder)
|
||||
{
|
||||
if (folderHash === threadUid)
|
||||
{
|
||||
threadUid = '';
|
||||
}
|
||||
|
||||
FolderStore.currentFolder(folder);
|
||||
|
||||
MessageStore.messageListPage(page);
|
||||
MessageStore.messageListSearch(search);
|
||||
MessageStore.messageListThreadUid(threadUid);
|
||||
|
||||
App.reloadMessageList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
onStart() {
|
||||
FolderStore.folderList.subscribe(windowResizeCallback);
|
||||
|
||||
MessageStore.messageList.subscribe(windowResizeCallback);
|
||||
MessageStore.message.subscribe(windowResizeCallback);
|
||||
|
||||
_.delay(() => {
|
||||
SettingsStore.layout.valueHasMutated();
|
||||
}, Magics.Time50ms);
|
||||
|
||||
Events.sub('mailbox.inbox-unread-count', (count) => {
|
||||
FolderStore.foldersInboxUnreadCount(count);
|
||||
|
||||
const email = AccountStore.email();
|
||||
_.each(AccountStore.accounts(), (item) => {
|
||||
if (item && email === item.email)
|
||||
{
|
||||
item.count(count);
|
||||
}
|
||||
});
|
||||
|
||||
this.updateWindowTitle();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
onBuild() {
|
||||
if (!bMobileDevice && !Settings.appSettingsGet('mobile'))
|
||||
{
|
||||
_.defer(() => {
|
||||
App.initHorizontalLayoutResizer(ClientSideKeyName.MessageListSize);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array}
|
||||
*/
|
||||
routes() {
|
||||
var
|
||||
inboxFolderName = getFolderInboxName(),
|
||||
fNormS = (request, vals) => {
|
||||
vals[0] = pString(vals[0]);
|
||||
vals[1] = pInt(vals[1]);
|
||||
vals[1] = 0 >= vals[1] ? 1 : vals[1];
|
||||
vals[2] = pString(vals[2]);
|
||||
|
||||
if ('' === request)
|
||||
{
|
||||
vals[0] = inboxFolderName;
|
||||
vals[1] = 1;
|
||||
}
|
||||
|
||||
return [decodeURI(vals[0]), vals[1], decodeURI(vals[2])];
|
||||
},
|
||||
fNormD = (request, vals) => {
|
||||
vals[0] = pString(vals[0]);
|
||||
vals[1] = pString(vals[1]);
|
||||
|
||||
if ('' === request)
|
||||
{
|
||||
vals[0] = inboxFolderName;
|
||||
}
|
||||
|
||||
return [decodeURI(vals[0]), 1, decodeURI(vals[1])];
|
||||
};
|
||||
|
||||
return [
|
||||
[/^([a-zA-Z0-9~]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}],
|
||||
[/^([a-zA-Z0-9~]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}],
|
||||
[/^([a-zA-Z0-9~]+)\/(.+)\/?$/, {'normalize_': fNormD}],
|
||||
[/^([^\/]*)$/, {'normalize_': fNormS}]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
export {MailBoxUserScreen, MailBoxUserScreen as default};
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Plugins = require('Common/Plugins'),
|
||||
|
||||
AppStore = require('Stores/User/App'),
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
|
||||
AbstractSettingsScreen = require('Screen/AbstractSettings');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSettingsScreen
|
||||
*/
|
||||
function SettingsUserScreen()
|
||||
{
|
||||
AbstractSettingsScreen.call(this, [
|
||||
require('View/User/Settings/SystemDropDown'),
|
||||
require('View/User/Settings/Menu'),
|
||||
require('View/User/Settings/Pane')
|
||||
]);
|
||||
|
||||
Translator.initOnStartOrLangChange(function() {
|
||||
this.sSettingsTitle = Translator.i18n('TITLES/SETTINGS');
|
||||
}, this, function() {
|
||||
this.setSettingsTitle();
|
||||
});
|
||||
}
|
||||
|
||||
_.extend(SettingsUserScreen.prototype, AbstractSettingsScreen.prototype);
|
||||
|
||||
/**
|
||||
* @param {Function=} fCallback
|
||||
*/
|
||||
SettingsUserScreen.prototype.setupSettings = function(fCallback)
|
||||
{
|
||||
if (!Settings.capa(Enums.Capa.Settings))
|
||||
{
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/User/General'),
|
||||
'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
|
||||
|
||||
if (AppStore.contactsIsAllowed())
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Contacts'),
|
||||
'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
|
||||
}
|
||||
|
||||
if (Settings.capa(Enums.Capa.AdditionalAccounts) || Settings.capa(Enums.Capa.Identities))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Accounts'), 'SettingsAccounts',
|
||||
Settings.capa(Enums.Capa.AdditionalAccounts) ?
|
||||
'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME' : 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'accounts');
|
||||
}
|
||||
|
||||
if (Settings.capa(Enums.Capa.Sieve))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Filters'),
|
||||
'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
|
||||
}
|
||||
|
||||
if (Settings.capa(Enums.Capa.AutoLogout) || Settings.capa(Enums.Capa.TwoFactor))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Security'),
|
||||
'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
|
||||
}
|
||||
|
||||
if (AccountStore.isRootAccount() && (
|
||||
(Settings.settingsGet('AllowGoogleSocial') && Settings.settingsGet('AllowGoogleSocialAuth')) ||
|
||||
Settings.settingsGet('AllowFacebookSocial') ||
|
||||
Settings.settingsGet('AllowTwitterSocial')))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Social'),
|
||||
'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');
|
||||
}
|
||||
|
||||
if (Settings.settingsGet('ChangePasswordIsAllowed'))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/ChangePassword'),
|
||||
'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
|
||||
}
|
||||
|
||||
if (Settings.capa(Enums.Capa.Templates))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Templates'),
|
||||
'SettingsTemplates', 'SETTINGS_LABELS/LABEL_TEMPLATES_NAME', 'templates');
|
||||
}
|
||||
|
||||
if (Settings.capa(Enums.Capa.Folders))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Folders'),
|
||||
'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
|
||||
}
|
||||
|
||||
if (Settings.capa(Enums.Capa.Themes))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Themes'),
|
||||
'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
|
||||
}
|
||||
|
||||
if (Settings.capa(Enums.Capa.OpenPGP))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/OpenPgp'),
|
||||
'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
|
||||
}
|
||||
|
||||
Plugins.runSettingsViewModelHooks(false);
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
SettingsUserScreen.prototype.onShow = function()
|
||||
{
|
||||
this.setSettingsTitle();
|
||||
Globals.keyScope(Enums.KeyState.Settings);
|
||||
Globals.leftPanelType('');
|
||||
|
||||
if (Settings.appSettingsGet('mobile'))
|
||||
{
|
||||
Globals.leftPanelDisabled(true);
|
||||
}
|
||||
};
|
||||
|
||||
SettingsUserScreen.prototype.setSettingsTitle = function()
|
||||
{
|
||||
var sEmail = AccountStore.email();
|
||||
require('App/User').default.setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle);
|
||||
};
|
||||
|
||||
module.exports = SettingsUserScreen;
|
||||
141
dev/Screen/User/Settings.jsx
Normal file
141
dev/Screen/User/Settings.jsx
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
|
||||
import {Capa, KeyState} from 'Common/Enums';
|
||||
import {keyScope, leftPanelType, leftPanelDisabled} from 'Common/Globals';
|
||||
import {runSettingsViewModelHooks} from 'Common/Plugins';
|
||||
import {initOnStartOrLangChange, i18n} from 'Common/Translator';
|
||||
|
||||
import AppStore from 'Stores/User/App';
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
import kn from 'Knoin/Knoin';
|
||||
|
||||
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
||||
import App from 'App/User';
|
||||
|
||||
class SettingsUserScreen extends AbstractSettingsScreen
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super([
|
||||
require('View/User/Settings/SystemDropDown'),
|
||||
require('View/User/Settings/Menu'),
|
||||
require('View/User/Settings/Pane')
|
||||
]);
|
||||
|
||||
initOnStartOrLangChange(() => {
|
||||
this.sSettingsTitle = i18n('TITLES/SETTINGS');
|
||||
}, () => {
|
||||
this.setSettingsTitle();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function=} fCallback
|
||||
*/
|
||||
setupSettings(fCallback = null) {
|
||||
if (!Settings.capa(Capa.Settings))
|
||||
{
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
kn.addSettingsViewModel(require('Settings/User/General'),
|
||||
'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
|
||||
|
||||
if (AppStore.contactsIsAllowed())
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Contacts'),
|
||||
'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
|
||||
}
|
||||
|
||||
if (Settings.capa(Capa.AdditionalAccounts) || Settings.capa(Capa.Identities))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Accounts'), 'SettingsAccounts',
|
||||
Settings.capa(Capa.AdditionalAccounts) ? 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME' : 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'accounts');
|
||||
}
|
||||
|
||||
if (Settings.capa(Capa.Sieve))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Filters'),
|
||||
'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
|
||||
}
|
||||
|
||||
if (Settings.capa(Capa.AutoLogout) || Settings.capa(Capa.TwoFactor))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Security'),
|
||||
'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
|
||||
}
|
||||
|
||||
if (AccountStore.isRootAccount() && (
|
||||
(Settings.settingsGet('AllowGoogleSocial') && Settings.settingsGet('AllowGoogleSocialAuth')) ||
|
||||
Settings.settingsGet('AllowFacebookSocial') ||
|
||||
Settings.settingsGet('AllowTwitterSocial')))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Social'),
|
||||
'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');
|
||||
}
|
||||
|
||||
if (Settings.settingsGet('ChangePasswordIsAllowed'))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/ChangePassword'),
|
||||
'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
|
||||
}
|
||||
|
||||
if (Settings.capa(Capa.Templates))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Templates'),
|
||||
'SettingsTemplates', 'SETTINGS_LABELS/LABEL_TEMPLATES_NAME', 'templates');
|
||||
}
|
||||
|
||||
if (Settings.capa(Capa.Folders))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Folders'),
|
||||
'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
|
||||
}
|
||||
|
||||
if (Settings.capa(Capa.Themes))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/Themes'),
|
||||
'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
|
||||
}
|
||||
|
||||
if (Settings.capa(Capa.OpenPGP))
|
||||
{
|
||||
kn.addSettingsViewModel(require('Settings/User/OpenPgp'),
|
||||
'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
|
||||
}
|
||||
|
||||
runSettingsViewModelHooks(false);
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.setSettingsTitle();
|
||||
keyScope(KeyState.Settings);
|
||||
leftPanelType('');
|
||||
|
||||
if (Settings.appSettingsGet('mobile'))
|
||||
{
|
||||
leftPanelDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
setSettingsTitle() {
|
||||
const sEmail = AccountStore.email();
|
||||
App.setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle);
|
||||
}
|
||||
}
|
||||
|
||||
export {SettingsUserScreen, SettingsUserScreen as default};
|
||||
|
|
@ -75,7 +75,7 @@ function FilterPopupView()
|
|||
this.typeOptions = ko.observableArray([]);
|
||||
this.typeOptionsSize = ko.observableArray([]);
|
||||
|
||||
Translator.initOnStartOrLangChange(this.populateOptions, this);
|
||||
Translator.initOnStartOrLangChange(_.bind(this.populateOptions, this));
|
||||
|
||||
this.modules.subscribe(this.populateOptions, this);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ function FolderSystemPopupView()
|
|||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderSystem');
|
||||
|
||||
Translator.initOnStartOrLangChange(function() {
|
||||
Translator.initOnStartOrLangChange(_.bind(function() {
|
||||
this.sChooseOnText = Translator.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
|
||||
this.sUnuseText = Translator.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
|
||||
}, this);
|
||||
}, this));
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
|
|
|
|||
|
|
@ -84,9 +84,9 @@ function MessageListMailBoxUserView()
|
|||
this.messageListCompleteLoadingThrottle = MessageStore.messageListCompleteLoadingThrottle;
|
||||
this.messageListCompleteLoadingThrottleForAnimation = MessageStore.messageListCompleteLoadingThrottleForAnimation;
|
||||
|
||||
Translator.initOnStartOrLangChange(function() {
|
||||
Translator.initOnStartOrLangChange(_.bind(function() {
|
||||
this.emptySubjectValue = Translator.i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT');
|
||||
}, this);
|
||||
}, this));
|
||||
|
||||
this.userQuota = QuotaStore.quota;
|
||||
this.userUsageSize = QuotaStore.usage;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue