mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
babeljs: step 2
This commit is contained in:
parent
007a03b8d4
commit
53cf543795
74 changed files with 2551 additions and 2963 deletions
3
.babelrc
3
.babelrc
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
plugins: []
|
|
||||||
}
|
|
||||||
|
|
@ -1,36 +1,27 @@
|
||||||
|
|
||||||
(function () {
|
import {window, _, $, key} from 'common';
|
||||||
|
import Globals from 'Common/Globals';
|
||||||
|
import * as Enums from 'Common/Enums';
|
||||||
|
import Utils from 'Common/Utils';
|
||||||
|
import Links from 'Common/Links';
|
||||||
|
import Events from 'Common/Events';
|
||||||
|
import Translator from 'Common/Translator';
|
||||||
|
import Settings from 'Storage/Settings';
|
||||||
|
|
||||||
'use strict';
|
import {AbstractBoot} from 'Knoin/AbstractBoot';
|
||||||
|
|
||||||
var
|
class AbstractApp extends AbstractBoot
|
||||||
window = require('window'),
|
{
|
||||||
_ = require('_'),
|
googlePreviewSupportedCache = null;
|
||||||
$ = require('$'),
|
isLocalAutocomplete = true;
|
||||||
key = require('key'),
|
iframe = null;
|
||||||
|
|
||||||
Globals = require('Common/Globals'),
|
|
||||||
Enums = require('Common/Enums'),
|
|
||||||
Utils = require('Common/Utils'),
|
|
||||||
Links = require('Common/Links'),
|
|
||||||
Events = require('Common/Events'),
|
|
||||||
Translator = require('Common/Translator'),
|
|
||||||
|
|
||||||
Settings = require('Storage/Settings'),
|
|
||||||
|
|
||||||
AbstractBoot = require('Knoin/AbstractBoot')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
|
||||||
* @param {RemoteStorage|AdminRemoteStorage} Remote
|
* @param {RemoteStorage|AdminRemoteStorage} Remote
|
||||||
* @extends AbstractBoot
|
|
||||||
*/
|
*/
|
||||||
function AbstractApp(Remote)
|
constructor(Remote)
|
||||||
{
|
{
|
||||||
AbstractBoot.call(this);
|
super();
|
||||||
|
|
||||||
this.isLocalAutocomplete = true;
|
|
||||||
|
|
||||||
this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');
|
this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');
|
||||||
|
|
||||||
|
|
@ -104,37 +95,28 @@
|
||||||
}, this));
|
}, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
_.extend(AbstractApp.prototype, AbstractBoot.prototype);
|
remote() {
|
||||||
|
|
||||||
AbstractApp.prototype.remote = function ()
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractApp.prototype.data = function ()
|
data() {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sLink
|
* @param {string} link
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
AbstractApp.prototype.download = function (sLink)
|
download(link) {
|
||||||
{
|
|
||||||
var
|
|
||||||
oE = null,
|
|
||||||
oLink = null
|
|
||||||
;
|
|
||||||
|
|
||||||
if (Globals.sUserAgent && (Globals.sUserAgent.indexOf('chrome') > -1 || Globals.sUserAgent.indexOf('chrome') > -1))
|
if (Globals.sUserAgent && (Globals.sUserAgent.indexOf('chrome') > -1 || Globals.sUserAgent.indexOf('chrome') > -1))
|
||||||
{
|
{
|
||||||
oLink = window.document.createElement('a');
|
const oLink = window.document.createElement('a');
|
||||||
oLink['href'] = sLink;
|
oLink['href'] = link;
|
||||||
|
|
||||||
if (window.document['createEvent'])
|
if (window.document['createEvent'])
|
||||||
{
|
{
|
||||||
oE = window.document['createEvent']('MouseEvents');
|
const oE = window.document['createEvent']('MouseEvents');
|
||||||
if (oE && oE['initEvent'] && oLink['dispatchEvent'])
|
if (oE && oE['initEvent'] && oLink['dispatchEvent'])
|
||||||
{
|
{
|
||||||
oE['initEvent']('click', true, true);
|
oE['initEvent']('click', true, true);
|
||||||
|
|
@ -146,25 +128,22 @@
|
||||||
|
|
||||||
if (Globals.bMobileDevice)
|
if (Globals.bMobileDevice)
|
||||||
{
|
{
|
||||||
window.open(sLink, '_self');
|
window.open(link, '_self');
|
||||||
window.focus();
|
window.focus();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.iframe.attr('src', sLink);
|
this.iframe.attr('src', link);
|
||||||
// window.document.location.href = sLink;
|
// window.document.location.href = link;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractApp.prototype.googlePreviewSupportedCache = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
AbstractApp.prototype.googlePreviewSupported = function ()
|
googlePreviewSupported() {
|
||||||
{
|
|
||||||
if (null === this.googlePreviewSupportedCache)
|
if (null === this.googlePreviewSupportedCache)
|
||||||
{
|
{
|
||||||
this.googlePreviewSupportedCache = !!Settings.settingsGet('AllowGoogleSocial') &&
|
this.googlePreviewSupportedCache = !!Settings.settingsGet('AllowGoogleSocial') &&
|
||||||
|
|
@ -172,90 +151,82 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.googlePreviewSupportedCache;
|
return this.googlePreviewSupportedCache;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sTitle
|
* @param {string} title
|
||||||
*/
|
*/
|
||||||
AbstractApp.prototype.setWindowTitle = function (sTitle)
|
setWindowTitle(title) {
|
||||||
{
|
title = ((Utils.isNormal(title) && 0 < title.length) ? '' + title : '');
|
||||||
sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? '' + sTitle : '');
|
|
||||||
if (Settings.settingsGet('Title'))
|
if (Settings.settingsGet('Title'))
|
||||||
{
|
{
|
||||||
sTitle += (sTitle ? ' - ' : '') + Settings.settingsGet('Title');
|
title += (title ? ' - ' : '') + Settings.settingsGet('Title');
|
||||||
}
|
}
|
||||||
|
|
||||||
window.document.title = sTitle + ' ...';
|
window.document.title = title + ' ...';
|
||||||
window.document.title = sTitle;
|
window.document.title = title;
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractApp.prototype.redirectToAdminPanel = function ()
|
redirectToAdminPanel() {
|
||||||
{
|
_.delay(() => window.location.href = Links.rootAdmin(), 100);
|
||||||
_.delay(function () {
|
}
|
||||||
window.location.href = Links.rootAdmin();
|
|
||||||
}, 100);
|
|
||||||
};
|
|
||||||
|
|
||||||
AbstractApp.prototype.clearClientSideToken = function ()
|
clearClientSideToken() {
|
||||||
{
|
|
||||||
if (window.__rlah_clear)
|
if (window.__rlah_clear)
|
||||||
{
|
{
|
||||||
window.__rlah_clear();
|
window.__rlah_clear();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sKey
|
* @param {string} key
|
||||||
*/
|
*/
|
||||||
AbstractApp.prototype.setClientSideToken = function (sKey)
|
setClientSideToken(key) {
|
||||||
{
|
|
||||||
if (window.__rlah_set)
|
if (window.__rlah_set)
|
||||||
{
|
{
|
||||||
window.__rlah_set(sKey);
|
window.__rlah_set(key);
|
||||||
|
|
||||||
require('Storage/Settings').settingsSet('AuthAccountHash', sKey);
|
require('Storage/Settings').settingsSet('AuthAccountHash', key);
|
||||||
require('Common/Links').populateAuthSuffix();
|
require('Common/Links').populateAuthSuffix();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean=} bAdmin = false
|
* @param {boolean=} admin = false
|
||||||
* @param {boolean=} bLogout = false
|
* @param {boolean=} logout = false
|
||||||
* @param {boolean=} bClose = false
|
* @param {boolean=} close = false
|
||||||
*/
|
*/
|
||||||
AbstractApp.prototype.loginAndLogoutReload = function (bAdmin, bLogout, bClose)
|
loginAndLogoutReload(admin = false, logout = false, close = false) {
|
||||||
{
|
|
||||||
var
|
const
|
||||||
kn = require('Knoin/Knoin'),
|
kn = require('Knoin/Knoin'),
|
||||||
sCustomLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')),
|
inIframe = !!Settings.settingsGet('InIframe')
|
||||||
bInIframe = !!Settings.settingsGet('InIframe')
|
|
||||||
;
|
;
|
||||||
|
|
||||||
bLogout = Utils.isUnd(bLogout) ? false : !!bLogout;
|
let customLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink'))
|
||||||
bClose = Utils.isUnd(bClose) ? false : !!bClose;
|
|
||||||
|
|
||||||
if (bLogout)
|
if (logout)
|
||||||
{
|
{
|
||||||
this.clearClientSideToken();
|
this.clearClientSideToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bLogout && bClose && window.close)
|
if (logout && close && window.close)
|
||||||
{
|
{
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
sCustomLogoutLink = sCustomLogoutLink || (bAdmin ? Links.rootAdmin() : Links.rootUser());
|
customLogoutLink = customLogoutLink || (admin ? Links.rootAdmin() : Links.rootUser());
|
||||||
|
|
||||||
if (bLogout && window.location.href !== sCustomLogoutLink)
|
if (logout && window.location.href !== customLogoutLink)
|
||||||
{
|
{
|
||||||
_.delay(function () {
|
_.delay(() => {
|
||||||
if (bInIframe && window.parent)
|
if (inIframe && window.parent)
|
||||||
{
|
{
|
||||||
window.parent.location.href = sCustomLogoutLink;
|
window.parent.location.href = customLogoutLink;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.location.href = sCustomLogoutLink;
|
window.location.href = customLogoutLink;
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
@ -265,8 +236,8 @@
|
||||||
kn.setHash(Links.root(), true);
|
kn.setHash(Links.root(), true);
|
||||||
kn.routeOff();
|
kn.routeOff();
|
||||||
|
|
||||||
_.delay(function () {
|
_.delay(() => {
|
||||||
if (bInIframe && window.parent)
|
if (inIframe && window.parent)
|
||||||
{
|
{
|
||||||
window.parent.location.reload();
|
window.parent.location.reload();
|
||||||
}
|
}
|
||||||
|
|
@ -276,20 +247,19 @@
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractApp.prototype.historyBack = function ()
|
historyBack() {
|
||||||
{
|
|
||||||
window.history.back();
|
window.history.back();
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractApp.prototype.bootstart = function ()
|
bootstart() {
|
||||||
{
|
|
||||||
Utils.log('Ps' + 'ss, hac' + 'kers! The' + 're\'s not' + 'hing inte' + 'resting :' + ')');
|
// Utils.log('Ps' + 'ss, hac' + 'kers! The' + 're\'s not' + 'hing inte' + 'resting :' + ')');
|
||||||
|
|
||||||
Events.pub('rl.bootstart');
|
Events.pub('rl.bootstart');
|
||||||
|
|
||||||
var
|
const
|
||||||
ssm = require('ssm'),
|
ssm = require('ssm'),
|
||||||
ko = require('ko')
|
ko = require('ko')
|
||||||
;
|
;
|
||||||
|
|
@ -323,11 +293,11 @@
|
||||||
ssm.addState({
|
ssm.addState({
|
||||||
'id': 'mobile',
|
'id': 'mobile',
|
||||||
'maxWidth': 767,
|
'maxWidth': 767,
|
||||||
'onEnter': function() {
|
'onEnter': () => {
|
||||||
Globals.$html.addClass('ssm-state-mobile');
|
Globals.$html.addClass('ssm-state-mobile');
|
||||||
Events.pub('ssm.mobile-enter');
|
Events.pub('ssm.mobile-enter');
|
||||||
},
|
},
|
||||||
'onLeave': function() {
|
'onLeave': () => {
|
||||||
Globals.$html.removeClass('ssm-state-mobile');
|
Globals.$html.removeClass('ssm-state-mobile');
|
||||||
Events.pub('ssm.mobile-leave');
|
Events.pub('ssm.mobile-leave');
|
||||||
}
|
}
|
||||||
|
|
@ -349,10 +319,10 @@
|
||||||
'id': 'desktop',
|
'id': 'desktop',
|
||||||
'minWidth': 1000,
|
'minWidth': 1000,
|
||||||
'maxWidth': 1400,
|
'maxWidth': 1400,
|
||||||
'onEnter': function() {
|
'onEnter': () => {
|
||||||
Globals.$html.addClass('ssm-state-desktop');
|
Globals.$html.addClass('ssm-state-desktop');
|
||||||
},
|
},
|
||||||
'onLeave': function() {
|
'onLeave': () => {
|
||||||
Globals.$html.removeClass('ssm-state-desktop');
|
Globals.$html.removeClass('ssm-state-desktop');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -360,27 +330,27 @@
|
||||||
ssm.addState({
|
ssm.addState({
|
||||||
'id': 'desktop-large',
|
'id': 'desktop-large',
|
||||||
'minWidth': 1400,
|
'minWidth': 1400,
|
||||||
'onEnter': function() {
|
'onEnter': () => {
|
||||||
Globals.$html.addClass('ssm-state-desktop-large');
|
Globals.$html.addClass('ssm-state-desktop-large');
|
||||||
},
|
},
|
||||||
'onLeave': function() {
|
'onLeave': () => {
|
||||||
Globals.$html.removeClass('ssm-state-desktop-large');
|
Globals.$html.removeClass('ssm-state-desktop-large');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.sub('ssm.mobile-enter', function () {
|
Events.sub('ssm.mobile-enter', () => {
|
||||||
Globals.leftPanelDisabled(true);
|
Globals.leftPanelDisabled(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.sub('ssm.mobile-leave', function () {
|
Events.sub('ssm.mobile-leave', () => {
|
||||||
Globals.leftPanelDisabled(false);
|
Globals.leftPanelDisabled(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
Globals.leftPanelDisabled.subscribe(function (bValue) {
|
Globals.leftPanelDisabled.subscribe((bValue) => {
|
||||||
Globals.$html.toggleClass('rl-left-panel-disabled', bValue);
|
Globals.$html.toggleClass('rl-left-panel-disabled', bValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
Globals.leftPanelType.subscribe(function (sValue) {
|
Globals.leftPanelType.subscribe((sValue) => {
|
||||||
Globals.$html.toggleClass('rl-left-panel-none', 'none' === sValue);
|
Globals.$html.toggleClass('rl-left-panel-none', 'none' === sValue);
|
||||||
Globals.$html.toggleClass('rl-left-panel-short', 'short' === sValue);
|
Globals.$html.toggleClass('rl-left-panel-short', 'short' === sValue);
|
||||||
});
|
});
|
||||||
|
|
@ -391,7 +361,6 @@
|
||||||
require('Stores/Theme').populate();
|
require('Stores/Theme').populate();
|
||||||
require('Stores/Social').populate();
|
require('Stores/Social').populate();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = AbstractApp;
|
export {AbstractApp, AbstractApp as default};
|
||||||
|
|
||||||
}());
|
|
||||||
301
dev/App/Admin.js
301
dev/App/Admin.js
|
|
@ -1,301 +0,0 @@
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var
|
|
||||||
window = require('window'),
|
|
||||||
_ = require('_'),
|
|
||||||
ko = require('ko'),
|
|
||||||
progressJs = require('progressJs'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
|
||||||
Utils = require('Common/Utils'),
|
|
||||||
Links = require('Common/Links'),
|
|
||||||
Translator = require('Common/Translator'),
|
|
||||||
|
|
||||||
Settings = require('Storage/Settings'),
|
|
||||||
AppStore = require('Stores/Admin/App'),
|
|
||||||
DomainStore = require('Stores/Admin/Domain'),
|
|
||||||
PluginStore = require('Stores/Admin/Plugin'),
|
|
||||||
LicenseStore = require('Stores/Admin/License'),
|
|
||||||
PackageStore = require('Stores/Admin/Package'),
|
|
||||||
CoreStore = require('Stores/Admin/Core'),
|
|
||||||
Remote = require('Remote/Admin/Ajax'),
|
|
||||||
|
|
||||||
kn = require('Knoin/Knoin'),
|
|
||||||
AbstractApp = require('App/Abstract')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends AbstractApp
|
|
||||||
*/
|
|
||||||
function AdminApp()
|
|
||||||
{
|
|
||||||
AbstractApp.call(this, Remote);
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AdminApp.prototype, AbstractApp.prototype);
|
|
||||||
|
|
||||||
AdminApp.prototype.remote = function ()
|
|
||||||
{
|
|
||||||
return Remote;
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.reloadDomainList = function ()
|
|
||||||
{
|
|
||||||
DomainStore.domains.loading(true);
|
|
||||||
|
|
||||||
Remote.domainList(function (sResult, oData) {
|
|
||||||
DomainStore.domains.loading(false);
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
|
||||||
{
|
|
||||||
var aList = _.map(oData.Result, function (bEnabled, sName) {
|
|
||||||
return {
|
|
||||||
'name': sName,
|
|
||||||
'disabled': ko.observable(!bEnabled),
|
|
||||||
'deleteAccess': ko.observable(false)
|
|
||||||
};
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
DomainStore.domains(aList);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.reloadPluginList = function ()
|
|
||||||
{
|
|
||||||
PluginStore.plugins.loading(true);
|
|
||||||
|
|
||||||
Remote.pluginList(function (sResult, oData) {
|
|
||||||
|
|
||||||
PluginStore.plugins.loading(false);
|
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
|
||||||
{
|
|
||||||
var aList = _.map(oData.Result, function (oItem) {
|
|
||||||
return {
|
|
||||||
'name': oItem['Name'],
|
|
||||||
'disabled': ko.observable(!oItem['Enabled']),
|
|
||||||
'configured': ko.observable(!!oItem['Configured'])
|
|
||||||
};
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
PluginStore.plugins(aList);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.reloadPackagesList = function ()
|
|
||||||
{
|
|
||||||
PackageStore.packages.loading(true);
|
|
||||||
PackageStore.packagesReal(true);
|
|
||||||
|
|
||||||
Remote.packagesList(function (sResult, oData) {
|
|
||||||
|
|
||||||
PackageStore.packages.loading(false);
|
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
|
||||||
{
|
|
||||||
PackageStore.packagesReal(!!oData.Result.Real);
|
|
||||||
PackageStore.packagesMainUpdatable(!!oData.Result.MainUpdatable);
|
|
||||||
|
|
||||||
var
|
|
||||||
aList = [],
|
|
||||||
aLoading = {}
|
|
||||||
;
|
|
||||||
|
|
||||||
_.each(PackageStore.packages(), function (oItem) {
|
|
||||||
if (oItem && oItem['loading']())
|
|
||||||
{
|
|
||||||
aLoading[oItem['file']] = oItem;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (Utils.isArray(oData.Result.List))
|
|
||||||
{
|
|
||||||
aList = _.compact(_.map(oData.Result.List, function (oItem) {
|
|
||||||
if (oItem)
|
|
||||||
{
|
|
||||||
oItem['loading'] = ko.observable(!Utils.isUnd(aLoading[oItem['file']]));
|
|
||||||
return 'core' === oItem['type'] && !oItem['canBeInstalled'] ? null : oItem;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
PackageStore.packages(aList);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PackageStore.packagesReal(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.updateCoreData = function ()
|
|
||||||
{
|
|
||||||
CoreStore.coreUpdating(true);
|
|
||||||
Remote.updateCoreData(function (sResult, oData) {
|
|
||||||
|
|
||||||
CoreStore.coreUpdating(false);
|
|
||||||
CoreStore.coreVersion('');
|
|
||||||
CoreStore.coreRemoteVersion('');
|
|
||||||
CoreStore.coreRemoteRelease('');
|
|
||||||
CoreStore.coreVersionCompare(-2);
|
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
|
||||||
{
|
|
||||||
CoreStore.coreReal(true);
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CoreStore.coreReal(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.reloadCoreData = function ()
|
|
||||||
{
|
|
||||||
CoreStore.coreChecking(true);
|
|
||||||
CoreStore.coreReal(true);
|
|
||||||
|
|
||||||
Remote.coreData(function (sResult, oData) {
|
|
||||||
|
|
||||||
CoreStore.coreChecking(false);
|
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
|
||||||
{
|
|
||||||
CoreStore.coreReal(!!oData.Result.Real);
|
|
||||||
CoreStore.coreChannel(oData.Result.Channel || 'stable');
|
|
||||||
CoreStore.coreType(oData.Result.Type || 'stable');
|
|
||||||
CoreStore.coreUpdatable(!!oData.Result.Updatable);
|
|
||||||
CoreStore.coreAccess(!!oData.Result.Access);
|
|
||||||
CoreStore.coreWarning(!!oData.Result.Warning);
|
|
||||||
CoreStore.coreVersion(oData.Result.Version || '');
|
|
||||||
CoreStore.coreRemoteVersion(oData.Result.RemoteVersion || '');
|
|
||||||
CoreStore.coreRemoteRelease(oData.Result.RemoteRelease || '');
|
|
||||||
CoreStore.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CoreStore.coreReal(false);
|
|
||||||
CoreStore.coreChannel('stable');
|
|
||||||
CoreStore.coreType('stable');
|
|
||||||
CoreStore.coreWarning(false);
|
|
||||||
CoreStore.coreVersion('');
|
|
||||||
CoreStore.coreRemoteVersion('');
|
|
||||||
CoreStore.coreRemoteRelease('');
|
|
||||||
CoreStore.coreVersionCompare(-2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {boolean=} bForce = false
|
|
||||||
*/
|
|
||||||
AdminApp.prototype.reloadLicensing = function (bForce)
|
|
||||||
{
|
|
||||||
bForce = Utils.isUnd(bForce) ? false : !!bForce;
|
|
||||||
|
|
||||||
LicenseStore.licensingProcess(true);
|
|
||||||
LicenseStore.licenseError('');
|
|
||||||
|
|
||||||
Remote.licensing(function (sResult, oData) {
|
|
||||||
|
|
||||||
LicenseStore.licensingProcess(false);
|
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired']))
|
|
||||||
{
|
|
||||||
LicenseStore.licenseValid(true);
|
|
||||||
LicenseStore.licenseExpired(Utils.pInt(oData.Result['Expired']));
|
|
||||||
LicenseStore.licenseError('');
|
|
||||||
|
|
||||||
LicenseStore.licensing(true);
|
|
||||||
|
|
||||||
AppStore.prem(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (oData && oData.ErrorCode && -1 < Utils.inArray(Utils.pInt(oData.ErrorCode), [
|
|
||||||
Enums.Notification.LicensingServerIsUnavailable,
|
|
||||||
Enums.Notification.LicensingExpired
|
|
||||||
]))
|
|
||||||
{
|
|
||||||
LicenseStore.licenseError(Translator.getNotification(Utils.pInt(oData.ErrorCode)));
|
|
||||||
LicenseStore.licensing(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Enums.StorageResultType.Abort === sResult)
|
|
||||||
{
|
|
||||||
LicenseStore.licenseError(Translator.getNotification(Enums.Notification.LicensingServerIsUnavailable));
|
|
||||||
LicenseStore.licensing(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LicenseStore.licensing(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, bForce);
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.bootend = function (callback)
|
|
||||||
{
|
|
||||||
if (progressJs)
|
|
||||||
{
|
|
||||||
progressJs.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callback)
|
|
||||||
{
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.bootstart = function ()
|
|
||||||
{
|
|
||||||
AbstractApp.prototype.bootstart.call(this);
|
|
||||||
|
|
||||||
require('Stores/Admin/App').populate();
|
|
||||||
require('Stores/Admin/Capa').populate();
|
|
||||||
|
|
||||||
kn.hideLoading();
|
|
||||||
|
|
||||||
if (!Settings.settingsGet('AllowAdminPanel'))
|
|
||||||
{
|
|
||||||
kn.routeOff();
|
|
||||||
kn.setHash(Links.root(), true);
|
|
||||||
kn.routeOff();
|
|
||||||
|
|
||||||
_.defer(function () {
|
|
||||||
window.location.href = '/';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!!Settings.settingsGet('Auth'))
|
|
||||||
{
|
|
||||||
kn.startScreens([
|
|
||||||
require('Screen/Admin/Settings')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
kn.startScreens([
|
|
||||||
require('Screen/Admin/Login')
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.bootend();
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = new AdminApp();
|
|
||||||
|
|
||||||
}());
|
|
||||||
259
dev/App/Admin.jsx
Normal file
259
dev/App/Admin.jsx
Normal file
|
|
@ -0,0 +1,259 @@
|
||||||
|
|
||||||
|
import {window, _} from 'common';
|
||||||
|
import ko from 'ko';
|
||||||
|
import progressJs from 'progressJs';
|
||||||
|
|
||||||
|
import * as Enums from 'Common/Enums';
|
||||||
|
import Utils from 'Common/Utils';
|
||||||
|
import Links from 'Common/Links';
|
||||||
|
import Translator from 'Common/Translator';
|
||||||
|
|
||||||
|
import Settings from 'Storage/Settings';
|
||||||
|
|
||||||
|
import AppStore from 'Stores/Admin/App';
|
||||||
|
import DomainStore from 'Stores/Admin/Domain';
|
||||||
|
import PluginStore from 'Stores/Admin/Plugin';
|
||||||
|
import LicenseStore from 'Stores/Admin/License';
|
||||||
|
import PackageStore from 'Stores/Admin/Package';
|
||||||
|
import CoreStore from 'Stores/Admin/Core';
|
||||||
|
import Remote from 'Remote/Admin/Ajax';
|
||||||
|
|
||||||
|
import kn from 'Knoin/Knoin';
|
||||||
|
|
||||||
|
import {AbstractApp} from 'App/Abstract';
|
||||||
|
|
||||||
|
class AdminApp extends AbstractApp
|
||||||
|
{
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
super(Remote);
|
||||||
|
}
|
||||||
|
|
||||||
|
remote() {
|
||||||
|
return Remote;
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadDomainList() {
|
||||||
|
DomainStore.domains.loading(true);
|
||||||
|
Remote.domainList((result, data) => {
|
||||||
|
DomainStore.domains.loading(false);
|
||||||
|
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||||
|
{
|
||||||
|
DomainStore.domains(_.map(data.Result, (enabled, name) => {
|
||||||
|
return {
|
||||||
|
'name': name,
|
||||||
|
'disabled': ko.observable(!enabled),
|
||||||
|
'deleteAccess': ko.observable(false)
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadPluginList() {
|
||||||
|
PluginStore.plugins.loading(true);
|
||||||
|
Remote.pluginList((result, data) => {
|
||||||
|
PluginStore.plugins.loading(false);
|
||||||
|
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||||
|
{
|
||||||
|
PluginStore.plugins(_.map(data.Result, (item) => {
|
||||||
|
return {
|
||||||
|
'name': item['Name'],
|
||||||
|
'disabled': ko.observable(!item['Enabled']),
|
||||||
|
'configured': ko.observable(!!item['Configured'])
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadPackagesList() {
|
||||||
|
PackageStore.packages.loading(true);
|
||||||
|
PackageStore.packagesReal(true);
|
||||||
|
Remote.packagesList((result, data) => {
|
||||||
|
PackageStore.packages.loading(false);
|
||||||
|
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||||
|
{
|
||||||
|
PackageStore.packagesReal(!!data.Result.Real);
|
||||||
|
PackageStore.packagesMainUpdatable(!!data.Result.MainUpdatable);
|
||||||
|
|
||||||
|
let
|
||||||
|
list = [],
|
||||||
|
loading = {}
|
||||||
|
;
|
||||||
|
|
||||||
|
_.each(PackageStore.packages(), (item) => {
|
||||||
|
if (item && item['loading']())
|
||||||
|
{
|
||||||
|
loading[item['file']] = item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Utils.isArray(data.Result.List))
|
||||||
|
{
|
||||||
|
list = _.compact(_.map(data.Result.List, (item) => {
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
item['loading'] = ko.observable(!Utils.isUnd(loading[item['file']]));
|
||||||
|
return 'core' === item['type'] && !item['canBeInstalled'] ? null : item;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageStore.packages(list);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PackageStore.packagesReal(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCoreData() {
|
||||||
|
CoreStore.coreUpdating(true);
|
||||||
|
Remote.updateCoreData((result, data) => {
|
||||||
|
CoreStore.coreUpdating(false);
|
||||||
|
CoreStore.coreVersion('');
|
||||||
|
CoreStore.coreRemoteVersion('');
|
||||||
|
CoreStore.coreRemoteRelease('');
|
||||||
|
CoreStore.coreVersionCompare(-2);
|
||||||
|
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||||
|
{
|
||||||
|
CoreStore.coreReal(true);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CoreStore.coreReal(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadCoreData() {
|
||||||
|
CoreStore.coreChecking(true);
|
||||||
|
CoreStore.coreReal(true);
|
||||||
|
Remote.coreData((result, data) => {
|
||||||
|
CoreStore.coreChecking(false);
|
||||||
|
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||||
|
{
|
||||||
|
CoreStore.coreReal(!!data.Result.Real);
|
||||||
|
CoreStore.coreChannel(data.Result.Channel || 'stable');
|
||||||
|
CoreStore.coreType(data.Result.Type || 'stable');
|
||||||
|
CoreStore.coreUpdatable(!!data.Result.Updatable);
|
||||||
|
CoreStore.coreAccess(!!data.Result.Access);
|
||||||
|
CoreStore.coreWarning(!!data.Result.Warning);
|
||||||
|
CoreStore.coreVersion(data.Result.Version || '');
|
||||||
|
CoreStore.coreRemoteVersion(data.Result.RemoteVersion || '');
|
||||||
|
CoreStore.coreRemoteRelease(data.Result.RemoteRelease || '');
|
||||||
|
CoreStore.coreVersionCompare(Utils.pInt(data.Result.VersionCompare));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CoreStore.coreReal(false);
|
||||||
|
CoreStore.coreChannel('stable');
|
||||||
|
CoreStore.coreType('stable');
|
||||||
|
CoreStore.coreWarning(false);
|
||||||
|
CoreStore.coreVersion('');
|
||||||
|
CoreStore.coreRemoteVersion('');
|
||||||
|
CoreStore.coreRemoteRelease('');
|
||||||
|
CoreStore.coreVersionCompare(-2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean=} force = false
|
||||||
|
*/
|
||||||
|
reloadLicensing(force = false) {
|
||||||
|
LicenseStore.licensingProcess(true);
|
||||||
|
LicenseStore.licenseError('');
|
||||||
|
Remote.licensing((result, data) => {
|
||||||
|
LicenseStore.licensingProcess(false);
|
||||||
|
if (Enums.StorageResultType.Success === result && data && data.Result && Utils.isNormal(data.Result['Expired']))
|
||||||
|
{
|
||||||
|
LicenseStore.licenseValid(true);
|
||||||
|
LicenseStore.licenseExpired(Utils.pInt(data.Result['Expired']));
|
||||||
|
LicenseStore.licenseError('');
|
||||||
|
LicenseStore.licensing(true);
|
||||||
|
AppStore.prem(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (data && data.ErrorCode && -1 < Utils.inArray(Utils.pInt(data.ErrorCode), [
|
||||||
|
Enums.Notification.LicensingServerIsUnavailable,
|
||||||
|
Enums.Notification.LicensingExpired
|
||||||
|
]))
|
||||||
|
{
|
||||||
|
LicenseStore.licenseError(Translator.getNotification(Utils.pInt(data.ErrorCode)));
|
||||||
|
LicenseStore.licensing(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Enums.StorageResultType.Abort === result)
|
||||||
|
{
|
||||||
|
LicenseStore.licenseError(Translator.getNotification(Enums.Notification.LicensingServerIsUnavailable));
|
||||||
|
LicenseStore.licensing(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LicenseStore.licensing(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, force);
|
||||||
|
}
|
||||||
|
|
||||||
|
bootend(callback = null) {
|
||||||
|
if (progressJs)
|
||||||
|
{
|
||||||
|
progressJs.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
{
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstart() {
|
||||||
|
|
||||||
|
super.bootstart();
|
||||||
|
|
||||||
|
require('Stores/Admin/App').populate();
|
||||||
|
require('Stores/Admin/Capa').populate();
|
||||||
|
|
||||||
|
kn.hideLoading();
|
||||||
|
|
||||||
|
if (!Settings.settingsGet('AllowAdminPanel'))
|
||||||
|
{
|
||||||
|
kn.routeOff();
|
||||||
|
kn.setHash(Links.root(), true);
|
||||||
|
kn.routeOff();
|
||||||
|
|
||||||
|
_.defer(() => {
|
||||||
|
window.location.href = '/';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!!Settings.settingsGet('Auth'))
|
||||||
|
{
|
||||||
|
kn.startScreens([
|
||||||
|
require('Screen/Admin/Settings')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
kn.startScreens([
|
||||||
|
require('Screen/Admin/Login')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bootend();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const App = new AdminApp();
|
||||||
|
export default App;
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -7,15 +7,17 @@ import Events from 'Common/Events';
|
||||||
|
|
||||||
class Audio
|
class Audio
|
||||||
{
|
{
|
||||||
|
player = null;
|
||||||
|
notificator = null;
|
||||||
|
|
||||||
|
supported = false;
|
||||||
|
supportedMp3 = false;
|
||||||
|
supportedOgg = false;
|
||||||
|
supportedWav = false;
|
||||||
|
supportedNotification = false;
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
{
|
{
|
||||||
this.notificator = null;
|
|
||||||
|
|
||||||
this.supportedMp3 = false;
|
|
||||||
this.supportedOgg = false;
|
|
||||||
this.supportedWav = false;
|
|
||||||
this.supportedNotification = false;
|
|
||||||
|
|
||||||
this.player = this.createNewObject();
|
this.player = this.createNewObject();
|
||||||
|
|
||||||
this.supported = !Globals.bMobileDevice && !Globals.bSafari && !!this.player && !!this.player.play;
|
this.supported = !Globals.bMobileDevice && !Globals.bSafari && !!this.player && !!this.player.play;
|
||||||
|
|
@ -38,13 +40,9 @@ class Audio
|
||||||
|
|
||||||
if (this.supported)
|
if (this.supported)
|
||||||
{
|
{
|
||||||
$(this.player).on('ended error', () => {
|
$(this.player).on('ended error', () => this.stop());
|
||||||
this.stop();
|
|
||||||
});
|
|
||||||
|
|
||||||
Events.sub('audio.api.stop', () => {
|
Events.sub('audio.api.stop', () => this.stop());
|
||||||
this.stop();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,8 @@ const BASE_64_CHR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456
|
||||||
const Base64 = {
|
const Base64 = {
|
||||||
|
|
||||||
// public method for urlsafe encoding
|
// public method for urlsafe encoding
|
||||||
urlsafe_encode: (input) => {
|
urlsafe_encode: (input) => Base64.encode(input)
|
||||||
return Base64.encode(input).replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.');
|
.replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.'),
|
||||||
},
|
|
||||||
|
|
||||||
// public method for encoding
|
// public method for encoding
|
||||||
encode: (input) => {
|
encode: (input) => {
|
||||||
|
|
|
||||||
|
|
@ -1,412 +0,0 @@
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var
|
|
||||||
_ = require('_'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
|
||||||
Utils = require('Common/Utils'),
|
|
||||||
Links = require('Common/Links'),
|
|
||||||
|
|
||||||
Settings = require('Storage/Settings')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function CacheUserStorage()
|
|
||||||
{
|
|
||||||
this.oFoldersCache = {};
|
|
||||||
this.oFoldersNamesCache = {};
|
|
||||||
this.oFolderHashCache = {};
|
|
||||||
this.oFolderUidNextCache = {};
|
|
||||||
this.oMessageListHashCache = {};
|
|
||||||
this.oMessageFlagsCache = {};
|
|
||||||
this.oNewMessage = {};
|
|
||||||
this.oRequestedMessage = {};
|
|
||||||
|
|
||||||
this.bCapaGravatar = Settings.capa(Enums.Capa.Gravatar);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.bCapaGravatar = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.oFoldersCache = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.oFoldersNamesCache = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.oFolderHashCache = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.oFolderUidNextCache = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.oMessageListHashCache = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.oMessageFlagsCache = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.oNewMessage = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.oRequestedMessage = {};
|
|
||||||
|
|
||||||
CacheUserStorage.prototype.clear = function ()
|
|
||||||
{
|
|
||||||
this.oFoldersCache = {};
|
|
||||||
this.oFoldersNamesCache = {};
|
|
||||||
this.oFolderHashCache = {};
|
|
||||||
this.oFolderUidNextCache = {};
|
|
||||||
this.oMessageListHashCache = {};
|
|
||||||
this.oMessageFlagsCache = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sEmail
|
|
||||||
* @param {Function} fCallback
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.getUserPic = function (sEmail, fCallback)
|
|
||||||
{
|
|
||||||
sEmail = Utils.trim(sEmail);
|
|
||||||
fCallback(this.bCapaGravatar && '' !== sEmail ? Links.avatarLink(sEmail) : '', sEmail);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @param {string} sUid
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.getMessageKey = function (sFolderFullNameRaw, sUid)
|
|
||||||
{
|
|
||||||
return sFolderFullNameRaw + '#' + sUid;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolder
|
|
||||||
* @param {string} sUid
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.addRequestedMessage = function (sFolder, sUid)
|
|
||||||
{
|
|
||||||
this.oRequestedMessage[this.getMessageKey(sFolder, sUid)] = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolder
|
|
||||||
* @param {string} sUid
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.hasRequestedMessage = function (sFolder, sUid)
|
|
||||||
{
|
|
||||||
return true === this.oRequestedMessage[this.getMessageKey(sFolder, sUid)];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @param {string} sUid
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.addNewMessageCache = function (sFolderFullNameRaw, sUid)
|
|
||||||
{
|
|
||||||
this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @param {string} sUid
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.hasNewMessageAndRemoveFromCache = function (sFolderFullNameRaw, sUid)
|
|
||||||
{
|
|
||||||
if (this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)])
|
|
||||||
{
|
|
||||||
this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
CacheUserStorage.prototype.clearNewMessageCache = function ()
|
|
||||||
{
|
|
||||||
this.oNewMessage = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.sInboxFolderName = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.getFolderInboxName = function ()
|
|
||||||
{
|
|
||||||
return '' === this.sInboxFolderName ? 'INBOX' : this.sInboxFolderName;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderHash
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.getFolderFullNameRaw = function (sFolderHash)
|
|
||||||
{
|
|
||||||
return '' !== sFolderHash && this.oFoldersNamesCache[sFolderHash] ? this.oFoldersNamesCache[sFolderHash] : '';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderHash
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.setFolderFullNameRaw = function (sFolderHash, sFolderFullNameRaw)
|
|
||||||
{
|
|
||||||
this.oFoldersNamesCache[sFolderHash] = sFolderFullNameRaw;
|
|
||||||
if ('INBOX' === sFolderFullNameRaw || '' === this.sInboxFolderName)
|
|
||||||
{
|
|
||||||
this.sInboxFolderName = sFolderFullNameRaw;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.getFolderHash = function (sFolderFullNameRaw)
|
|
||||||
{
|
|
||||||
return '' !== sFolderFullNameRaw && this.oFolderHashCache[sFolderFullNameRaw] ? this.oFolderHashCache[sFolderFullNameRaw] : '';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @param {string} sFolderHash
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.setFolderHash = function (sFolderFullNameRaw, sFolderHash)
|
|
||||||
{
|
|
||||||
if ('' !== sFolderFullNameRaw)
|
|
||||||
{
|
|
||||||
this.oFolderHashCache[sFolderFullNameRaw] = sFolderHash;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.getFolderUidNext = function (sFolderFullNameRaw)
|
|
||||||
{
|
|
||||||
return '' !== sFolderFullNameRaw && this.oFolderUidNextCache[sFolderFullNameRaw] ? this.oFolderUidNextCache[sFolderFullNameRaw] : '';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @param {string} sUidNext
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.setFolderUidNext = function (sFolderFullNameRaw, sUidNext)
|
|
||||||
{
|
|
||||||
this.oFolderUidNextCache[sFolderFullNameRaw] = sUidNext;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @return {?FolderModel}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.getFolderFromCacheList = function (sFolderFullNameRaw)
|
|
||||||
{
|
|
||||||
return '' !== sFolderFullNameRaw && this.oFoldersCache[sFolderFullNameRaw] ? this.oFoldersCache[sFolderFullNameRaw] : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
* @param {?FolderModel} oFolder
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.setFolderToCacheList = function (sFolderFullNameRaw, oFolder)
|
|
||||||
{
|
|
||||||
this.oFoldersCache[sFolderFullNameRaw] = oFolder;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullNameRaw
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.removeFolderFromCacheList = function (sFolderFullNameRaw)
|
|
||||||
{
|
|
||||||
this.setFolderToCacheList(sFolderFullNameRaw, null);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullName
|
|
||||||
* @param {string} sUid
|
|
||||||
* @return {?Array}
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.getMessageFlagsFromCache = function (sFolderFullName, sUid)
|
|
||||||
{
|
|
||||||
return this.oMessageFlagsCache[sFolderFullName] && this.oMessageFlagsCache[sFolderFullName][sUid] ?
|
|
||||||
this.oMessageFlagsCache[sFolderFullName][sUid] : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullName
|
|
||||||
* @param {string} sUid
|
|
||||||
* @param {Array} aFlagsCache
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.setMessageFlagsToCache = function (sFolderFullName, sUid, aFlagsCache)
|
|
||||||
{
|
|
||||||
if (!this.oMessageFlagsCache[sFolderFullName])
|
|
||||||
{
|
|
||||||
this.oMessageFlagsCache[sFolderFullName] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.oMessageFlagsCache[sFolderFullName][sUid] = aFlagsCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderFullName
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.clearMessageFlagsFromCacheByFolder = function (sFolderFullName)
|
|
||||||
{
|
|
||||||
this.oMessageFlagsCache[sFolderFullName] = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {(MessageModel|null)} oMessage
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.initMessageFlagsFromCache = function (oMessage)
|
|
||||||
{
|
|
||||||
if (oMessage)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
self = this,
|
|
||||||
sUid = oMessage.uid,
|
|
||||||
aFlags = this.getMessageFlagsFromCache(oMessage.folderFullNameRaw, sUid),
|
|
||||||
mUnseenSubUid = null,
|
|
||||||
mFlaggedSubUid = null
|
|
||||||
;
|
|
||||||
|
|
||||||
if (aFlags && 0 < aFlags.length)
|
|
||||||
{
|
|
||||||
oMessage.flagged(!!aFlags[1]);
|
|
||||||
|
|
||||||
if (!oMessage.__simple_message__)
|
|
||||||
{
|
|
||||||
oMessage.unseen(!!aFlags[0]);
|
|
||||||
oMessage.answered(!!aFlags[2]);
|
|
||||||
oMessage.forwarded(!!aFlags[3]);
|
|
||||||
oMessage.isReadReceipt(!!aFlags[4]);
|
|
||||||
oMessage.deletedMark(!!aFlags[5]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 < oMessage.threads().length)
|
|
||||||
{
|
|
||||||
mUnseenSubUid = _.find(oMessage.threads(), function (sSubUid) {
|
|
||||||
if (sUid === sSubUid){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var aFlags = self.getMessageFlagsFromCache(oMessage.folderFullNameRaw, sSubUid);
|
|
||||||
return aFlags && 0 < aFlags.length && !!aFlags[0];
|
|
||||||
});
|
|
||||||
|
|
||||||
mFlaggedSubUid = _.find(oMessage.threads(), function (sSubUid) {
|
|
||||||
if (sUid === sSubUid){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var aFlags = self.getMessageFlagsFromCache(oMessage.folderFullNameRaw, sSubUid);
|
|
||||||
return aFlags && 0 < aFlags.length && !!aFlags[1];
|
|
||||||
});
|
|
||||||
|
|
||||||
oMessage.hasUnseenSubMessage(mUnseenSubUid && 0 < Utils.pInt(mUnseenSubUid));
|
|
||||||
oMessage.hasFlaggedSubMessage(mFlaggedSubUid && 0 < Utils.pInt(mFlaggedSubUid));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {(MessageModel|null)} oMessage
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.storeMessageFlagsToCache = function (oMessage)
|
|
||||||
{
|
|
||||||
if (oMessage)
|
|
||||||
{
|
|
||||||
this.setMessageFlagsToCache(
|
|
||||||
oMessage.folderFullNameRaw,
|
|
||||||
oMessage.uid,
|
|
||||||
[oMessage.unseen(), oMessage.flagged(), oMessage.answered(), oMessage.forwarded(),
|
|
||||||
oMessage.isReadReceipt(), oMessage.deletedMark()]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolder
|
|
||||||
* @param {string} sUid
|
|
||||||
* @param {Array} aFlags
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.storeMessageFlagsToCacheByFolderAndUid = function (sFolder, sUid, aFlags)
|
|
||||||
{
|
|
||||||
if (Utils.isArray(aFlags) && 0 < aFlags.length)
|
|
||||||
{
|
|
||||||
this.setMessageFlagsToCache(sFolder, sUid, aFlags);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolder
|
|
||||||
* @param {string} sUid
|
|
||||||
* @param {number} iSetAction
|
|
||||||
*/
|
|
||||||
CacheUserStorage.prototype.storeMessageFlagsToCacheBySetAction = function (sFolder, sUid, iSetAction)
|
|
||||||
{
|
|
||||||
var iUnread = 0, aFlags = this.getMessageFlagsFromCache(sFolder, sUid);
|
|
||||||
if (Utils.isArray(aFlags) && 0 < aFlags.length)
|
|
||||||
{
|
|
||||||
if (aFlags[0])
|
|
||||||
{
|
|
||||||
iUnread = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (iSetAction)
|
|
||||||
{
|
|
||||||
case Enums.MessageSetAction.SetSeen:
|
|
||||||
aFlags[0] = false;
|
|
||||||
break;
|
|
||||||
case Enums.MessageSetAction.UnsetSeen:
|
|
||||||
aFlags[0] = true;
|
|
||||||
break;
|
|
||||||
case Enums.MessageSetAction.SetFlag:
|
|
||||||
aFlags[1] = true;
|
|
||||||
break;
|
|
||||||
case Enums.MessageSetAction.UnsetFlag:
|
|
||||||
aFlags[1] = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setMessageFlagsToCache(sFolder, sUid, aFlags);
|
|
||||||
}
|
|
||||||
|
|
||||||
return iUnread;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = new CacheUserStorage();
|
|
||||||
|
|
||||||
}());
|
|
||||||
329
dev/Common/Cache.jsx
Normal file
329
dev/Common/Cache.jsx
Normal file
|
|
@ -0,0 +1,329 @@
|
||||||
|
|
||||||
|
|
||||||
|
import {_} from 'common';
|
||||||
|
import {Capa, MessageSetAction} from 'Common/Enums';
|
||||||
|
import Utils from 'Common/Utils';
|
||||||
|
import Links from 'Common/Links';
|
||||||
|
import Settings from 'Storage/Settings';
|
||||||
|
|
||||||
|
class CacheUserStorage
|
||||||
|
{
|
||||||
|
oFoldersCache = {};
|
||||||
|
oFoldersNamesCache = {};
|
||||||
|
oFolderHashCache = {};
|
||||||
|
oFolderUidNextCache = {};
|
||||||
|
oMessageListHashCache = {};
|
||||||
|
oMessageFlagsCache = {};
|
||||||
|
oNewMessage = {};
|
||||||
|
oRequestedMessage = {};
|
||||||
|
bCapaGravatar = false;
|
||||||
|
inboxFolderName = '';
|
||||||
|
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
this.bCapaGravatar = Settings.capa(Capa.Gravatar);
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.oFoldersCache = {};
|
||||||
|
this.oFoldersNamesCache = {};
|
||||||
|
this.oFolderHashCache = {};
|
||||||
|
this.oFolderUidNextCache = {};
|
||||||
|
this.oMessageListHashCache = {};
|
||||||
|
this.oMessageFlagsCache = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} email
|
||||||
|
* @param {Function} callback
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getUserPic(email, callback) {
|
||||||
|
email = Utils.trim(email);
|
||||||
|
callback(this.bCapaGravatar && '' !== email ? Links.avatarLink(email) : '', email);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @param {string} uid
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getMessageKey(folderFullNameRaw, uid) {
|
||||||
|
return `${folderFullNameRaw}#${uid}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folder
|
||||||
|
* @param {string} uid
|
||||||
|
*/
|
||||||
|
addRequestedMessage(folder, uid) {
|
||||||
|
this.oRequestedMessage[this.getMessageKey(folder, uid)] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folder
|
||||||
|
* @param {string} uid
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
hasRequestedMessage(folder, uid) {
|
||||||
|
return true === this.oRequestedMessage[this.getMessageKey(folder, uid)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @param {string} uid
|
||||||
|
*/
|
||||||
|
addNewMessageCache(folderFullNameRaw, uid) {
|
||||||
|
this.oNewMessage[this.getMessageKey(folderFullNameRaw, uid)] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @param {string} uid
|
||||||
|
*/
|
||||||
|
hasNewMessageAndRemoveFromCache(folderFullNameRaw, uid) {
|
||||||
|
if (this.oNewMessage[this.getMessageKey(folderFullNameRaw, uid)])
|
||||||
|
{
|
||||||
|
this.oNewMessage[this.getMessageKey(folderFullNameRaw, uid)] = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearNewMessageCache() {
|
||||||
|
this.oNewMessage = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getFolderInboxName() {
|
||||||
|
return '' === this.inboxFolderName ? 'INBOX' : this.inboxFolderName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderHash
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getFolderFullNameRaw(folderHash) {
|
||||||
|
return '' !== folderHash && this.oFoldersNamesCache[folderHash] ? this.oFoldersNamesCache[folderHash] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderHash
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
*/
|
||||||
|
setFolderFullNameRaw(folderHash, folderFullNameRaw) {
|
||||||
|
this.oFoldersNamesCache[folderHash] = folderFullNameRaw;
|
||||||
|
if ('INBOX' === folderFullNameRaw || '' === this.inboxFolderName)
|
||||||
|
{
|
||||||
|
this.inboxFolderName = folderFullNameRaw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getFolderHash(folderFullNameRaw) {
|
||||||
|
return '' !== folderFullNameRaw && this.oFolderHashCache[folderFullNameRaw] ? this.oFolderHashCache[folderFullNameRaw] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @param {string} folderHash
|
||||||
|
*/
|
||||||
|
setFolderHash(folderFullNameRaw, folderHash) {
|
||||||
|
if ('' !== folderFullNameRaw)
|
||||||
|
{
|
||||||
|
this.oFolderHashCache[folderFullNameRaw] = folderHash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getFolderUidNext(folderFullNameRaw) {
|
||||||
|
return '' !== folderFullNameRaw && this.oFolderUidNextCache[folderFullNameRaw] ? this.oFolderUidNextCache[folderFullNameRaw] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @param {string} uidNext
|
||||||
|
*/
|
||||||
|
setFolderUidNext(folderFullNameRaw, uidNext) {
|
||||||
|
this.oFolderUidNextCache[folderFullNameRaw] = uidNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @return {?FolderModel}
|
||||||
|
*/
|
||||||
|
getFolderFromCacheList(folderFullNameRaw) {
|
||||||
|
return '' !== folderFullNameRaw && this.oFoldersCache[folderFullNameRaw] ? this.oFoldersCache[folderFullNameRaw] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
* @param {?FolderModel} folder
|
||||||
|
*/
|
||||||
|
setFolderToCacheList(folderFullNameRaw, folder) {
|
||||||
|
this.oFoldersCache[folderFullNameRaw] = folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullNameRaw
|
||||||
|
*/
|
||||||
|
removeFolderFromCacheList(folderFullNameRaw) {
|
||||||
|
this.setFolderToCacheList(folderFullNameRaw, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullName
|
||||||
|
* @param {string} uid
|
||||||
|
* @return {?Array}
|
||||||
|
*/
|
||||||
|
getMessageFlagsFromCache(folderFullName, uid) {
|
||||||
|
return this.oMessageFlagsCache[folderFullName] && this.oMessageFlagsCache[folderFullName][uid] ?
|
||||||
|
this.oMessageFlagsCache[folderFullName][uid] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullName
|
||||||
|
* @param {string} uid
|
||||||
|
* @param {Array} flagsCache
|
||||||
|
*/
|
||||||
|
setMessageFlagsToCache(folderFullName, uid, flagsCache) {
|
||||||
|
if (!this.oMessageFlagsCache[folderFullName])
|
||||||
|
{
|
||||||
|
this.oMessageFlagsCache[folderFullName] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.oMessageFlagsCache[folderFullName][uid] = flagsCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folderFullName
|
||||||
|
*/
|
||||||
|
clearMessageFlagsFromCacheByFolder(folderFullName) {
|
||||||
|
this.oMessageFlagsCache[folderFullName] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {(MessageModel|null)} message
|
||||||
|
*/
|
||||||
|
initMessageFlagsFromCache(message) {
|
||||||
|
|
||||||
|
if (message)
|
||||||
|
{
|
||||||
|
const
|
||||||
|
uid = message.uid,
|
||||||
|
flags = this.getMessageFlagsFromCache(message.folderFullNameRaw, uid)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (flags && 0 < flags.length)
|
||||||
|
{
|
||||||
|
message.flagged(!!flags[1]);
|
||||||
|
|
||||||
|
if (!message.__simple_message__)
|
||||||
|
{
|
||||||
|
message.unseen(!!flags[0]);
|
||||||
|
message.answered(!!flags[2]);
|
||||||
|
message.forwarded(!!flags[3]);
|
||||||
|
message.isReadReceipt(!!flags[4]);
|
||||||
|
message.deletedMark(!!flags[5]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 < message.threads().length)
|
||||||
|
{
|
||||||
|
const unseenSubUid = _.find(message.threads(), (sSubUid) => {
|
||||||
|
if (uid !== sSubUid){
|
||||||
|
const flags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid);
|
||||||
|
return flags && 0 < flags.length && !!flags[0];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
const flaggedSubUid = _.find(message.threads(), (sSubUid) => {
|
||||||
|
if (uid !== sSubUid) {
|
||||||
|
const flags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid);
|
||||||
|
return flags && 0 < flags.length && !!flags[1];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
message.hasUnseenSubMessage(unseenSubUid && 0 < Utils.pInt(unseenSubUid));
|
||||||
|
message.hasFlaggedSubMessage(flaggedSubUid && 0 < Utils.pInt(flaggedSubUid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {(MessageModel|null)} message
|
||||||
|
*/
|
||||||
|
storeMessageFlagsToCache(message) {
|
||||||
|
if (message)
|
||||||
|
{
|
||||||
|
this.setMessageFlagsToCache(
|
||||||
|
message.folderFullNameRaw, message.uid,
|
||||||
|
[message.unseen(), message.flagged(), message.answered(), message.forwarded(),
|
||||||
|
message.isReadReceipt(), message.deletedMark()]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folder
|
||||||
|
* @param {string} uid
|
||||||
|
* @param {Array} flags
|
||||||
|
*/
|
||||||
|
storeMessageFlagsToCacheByFolderAndUid(folder, uid, flags) {
|
||||||
|
if (Utils.isArray(flags) && 0 < flags.length)
|
||||||
|
{
|
||||||
|
this.setMessageFlagsToCache(folder, uid, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} folder
|
||||||
|
* @param {string} uid
|
||||||
|
* @param {number} setAction
|
||||||
|
*/
|
||||||
|
storeMessageFlagsToCacheBySetAction(folder, uid, setAction) {
|
||||||
|
|
||||||
|
let unread = 0;
|
||||||
|
const flags = this.getMessageFlagsFromCache(folder, uid);
|
||||||
|
|
||||||
|
if (Utils.isArray(flags) && 0 < flags.length)
|
||||||
|
{
|
||||||
|
if (flags[0])
|
||||||
|
{
|
||||||
|
unread = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (setAction)
|
||||||
|
{
|
||||||
|
case MessageSetAction.SetSeen:
|
||||||
|
flags[0] = false;
|
||||||
|
break;
|
||||||
|
case MessageSetAction.UnsetSeen:
|
||||||
|
flags[0] = true;
|
||||||
|
break;
|
||||||
|
case MessageSetAction.SetFlag:
|
||||||
|
flags[1] = true;
|
||||||
|
break;
|
||||||
|
case MessageSetAction.UnsetFlag:
|
||||||
|
flags[1] = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setMessageFlagsToCache(folder, uid, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
return unread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new CacheUserStorage();
|
||||||
|
|
@ -5,9 +5,9 @@ import Plugins from 'Common/Plugins';
|
||||||
|
|
||||||
class Events
|
class Events
|
||||||
{
|
{
|
||||||
constructor() {
|
subs = {};
|
||||||
this.subs = {};
|
|
||||||
}
|
constructor() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string|Object} name
|
* @param {string|Object} name
|
||||||
|
|
|
||||||
|
|
@ -1,435 +0,0 @@
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var
|
|
||||||
window = require('window'),
|
|
||||||
_ = require('_'),
|
|
||||||
|
|
||||||
Globals = require('Common/Globals'),
|
|
||||||
|
|
||||||
Settings = require('Storage/Settings')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {Object} oElement
|
|
||||||
* @param {Function=} fOnBlur
|
|
||||||
* @param {Function=} fOnReady
|
|
||||||
* @param {Function=} fOnModeChange
|
|
||||||
*/
|
|
||||||
function HtmlEditor(oElement, fOnBlur, fOnReady, fOnModeChange)
|
|
||||||
{
|
|
||||||
this.editor = null;
|
|
||||||
this.iBlurTimer = 0;
|
|
||||||
this.fOnBlur = fOnBlur || null;
|
|
||||||
this.fOnReady = fOnReady || null;
|
|
||||||
this.fOnModeChange = fOnModeChange || null;
|
|
||||||
|
|
||||||
this.$element = $(oElement);
|
|
||||||
|
|
||||||
this.resize = _.throttle(_.bind(this.resize, this), 100);
|
|
||||||
|
|
||||||
this.__inited = false;
|
|
||||||
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
HtmlEditor.prototype.blurTrigger = function ()
|
|
||||||
{
|
|
||||||
if (this.fOnBlur)
|
|
||||||
{
|
|
||||||
var self = this;
|
|
||||||
window.clearTimeout(this.iBlurTimer);
|
|
||||||
this.iBlurTimer = window.setTimeout(function () {
|
|
||||||
self.fOnBlur();
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.focusTrigger = function ()
|
|
||||||
{
|
|
||||||
if (this.fOnBlur)
|
|
||||||
{
|
|
||||||
window.clearTimeout(this.iBlurTimer);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
HtmlEditor.prototype.isHtml = function ()
|
|
||||||
{
|
|
||||||
return this.editor ? 'wysiwyg' === this.editor.mode : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sSignature
|
|
||||||
* @param {bool} bHtml
|
|
||||||
* @param {bool} bInsertBefore
|
|
||||||
*/
|
|
||||||
HtmlEditor.prototype.setSignature = function (sSignature, bHtml, bInsertBefore)
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
this.editor.execCommand('insertSignature', {
|
|
||||||
'isHtml': bHtml,
|
|
||||||
'insertBefore': bInsertBefore,
|
|
||||||
'signature': sSignature
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
HtmlEditor.prototype.checkDirty = function ()
|
|
||||||
{
|
|
||||||
return this.editor ? this.editor.checkDirty() : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.resetDirty = function ()
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
this.editor.resetDirty();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sText
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
HtmlEditor.prototype.clearSignatureSigns = function (sText)
|
|
||||||
{
|
|
||||||
return sText.replace(/(\u200C|\u0002)/g, '');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean=} bWrapIsHtml = false
|
|
||||||
* @param {boolean=} bClearSignatureSigns = false
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
HtmlEditor.prototype.getData = function (bWrapIsHtml, bClearSignatureSigns)
|
|
||||||
{
|
|
||||||
var sResult = '';
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
|
||||||
{
|
|
||||||
sResult = this.editor.__plain.getRawData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sResult = bWrapIsHtml ?
|
|
||||||
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
|
|
||||||
this.editor.getData() + '</div>' : this.editor.getData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {}
|
|
||||||
|
|
||||||
if (bClearSignatureSigns)
|
|
||||||
{
|
|
||||||
sResult = this.clearSignatureSigns(sResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean=} bWrapIsHtml = false
|
|
||||||
* @param {boolean=} bClearSignatureSigns = false
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
HtmlEditor.prototype.getDataWithHtmlMark = function (bWrapIsHtml, bClearSignatureSigns)
|
|
||||||
{
|
|
||||||
return (this.isHtml() ? ':HTML:' : '') + this.getData(bWrapIsHtml, bClearSignatureSigns);
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.modeToggle = function (bPlain, bResize)
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
if (bPlain)
|
|
||||||
{
|
|
||||||
if ('plain' === this.editor.mode)
|
|
||||||
{
|
|
||||||
this.editor.setMode('wysiwyg');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ('wysiwyg' === this.editor.mode)
|
|
||||||
{
|
|
||||||
this.editor.setMode('plain');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(e) {}
|
|
||||||
|
|
||||||
if (bResize)
|
|
||||||
{
|
|
||||||
this.resize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.setHtmlOrPlain = function (sText, bFocus)
|
|
||||||
{
|
|
||||||
if (':HTML:' === sText.substr(0, 6))
|
|
||||||
{
|
|
||||||
this.setHtml(sText.substr(6), bFocus);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.setPlain(sText, bFocus);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.setHtml = function (sHtml, bFocus)
|
|
||||||
{
|
|
||||||
if (this.editor && this.__inited)
|
|
||||||
{
|
|
||||||
this.modeToggle(true);
|
|
||||||
|
|
||||||
sHtml = sHtml.replace(/<p[^>]*><\/p>/ig, '');
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.editor.setData(sHtml);
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
if (bFocus)
|
|
||||||
{
|
|
||||||
this.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.replaceHtml = function (mFind, sReplaceHtml)
|
|
||||||
{
|
|
||||||
if (this.editor && this.__inited && 'wysiwyg' === this.editor.mode)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
this.editor.setData(
|
|
||||||
this.editor.getData().replace(mFind, sReplaceHtml));
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.setPlain = function (sPlain, bFocus)
|
|
||||||
{
|
|
||||||
if (this.editor && this.__inited)
|
|
||||||
{
|
|
||||||
this.modeToggle(false);
|
|
||||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
|
||||||
{
|
|
||||||
return this.editor.__plain.setRawData(sPlain);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
this.editor.setData(sPlain);
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bFocus)
|
|
||||||
{
|
|
||||||
this.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.init = function ()
|
|
||||||
{
|
|
||||||
if (this.$element && this.$element[0] && !this.editor)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
self = this,
|
|
||||||
fInit = function () {
|
|
||||||
|
|
||||||
var
|
|
||||||
oConfig = Globals.oHtmlEditorDefaultConfig,
|
|
||||||
sLanguage = Settings.settingsGet('Language'),
|
|
||||||
bSource = !!Settings.settingsGet('AllowHtmlEditorSourceButton'),
|
|
||||||
bBiti = !!Settings.settingsGet('AllowHtmlEditorBitiButtons')
|
|
||||||
;
|
|
||||||
|
|
||||||
if ((bSource || !bBiti) && !oConfig.toolbarGroups.__cfgInited)
|
|
||||||
{
|
|
||||||
oConfig.toolbarGroups.__cfgInited = true;
|
|
||||||
|
|
||||||
if (bSource)
|
|
||||||
{
|
|
||||||
oConfig.removeButtons = oConfig.removeButtons.replace(',Source', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bBiti)
|
|
||||||
{
|
|
||||||
oConfig.removePlugins += (oConfig.removePlugins ? ',' : '') + 'bidi';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
oConfig.enterMode = window.CKEDITOR.ENTER_BR;
|
|
||||||
oConfig.shiftEnterMode = window.CKEDITOR.ENTER_P;
|
|
||||||
|
|
||||||
oConfig.language = Globals.oHtmlEditorLangsMap[sLanguage] || 'en';
|
|
||||||
if (window.CKEDITOR.env)
|
|
||||||
{
|
|
||||||
window.CKEDITOR.env.isCompatible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.editor = window.CKEDITOR.appendTo(self.$element[0], oConfig);
|
|
||||||
|
|
||||||
self.editor.on('key', function(oEvent) {
|
|
||||||
if (oEvent && oEvent.data && 9 /* Tab */ === oEvent.data.keyCode)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
self.editor.on('blur', function() {
|
|
||||||
self.blurTrigger();
|
|
||||||
});
|
|
||||||
|
|
||||||
self.editor.on('mode', function() {
|
|
||||||
|
|
||||||
self.blurTrigger();
|
|
||||||
|
|
||||||
if (self.fOnModeChange)
|
|
||||||
{
|
|
||||||
self.fOnModeChange('plain' !== self.editor.mode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
self.editor.on('focus', function() {
|
|
||||||
self.focusTrigger();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (window.FileReader)
|
|
||||||
{
|
|
||||||
self.editor.on('drop', function(evt) {
|
|
||||||
if (0 < evt.data.dataTransfer.getFilesCount())
|
|
||||||
{
|
|
||||||
var file = evt.data.dataTransfer.getFile(0);
|
|
||||||
if (file && window.FileReader && evt.data.dataTransfer.id &&
|
|
||||||
file.type && file.type.match(/^image/i))
|
|
||||||
{
|
|
||||||
var
|
|
||||||
id = evt.data.dataTransfer.id,
|
|
||||||
imageId = '[img=' + id +']',
|
|
||||||
reader = new window.FileReader()
|
|
||||||
;
|
|
||||||
|
|
||||||
reader.onloadend = function () {
|
|
||||||
if (reader.result)
|
|
||||||
{
|
|
||||||
self.replaceHtml(imageId, '<img src="' + reader.result + '" />');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
|
|
||||||
evt.data.dataTransfer.setData('text/html', imageId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
self.editor.on('instanceReady', function () {
|
|
||||||
|
|
||||||
if (self.editor.removeMenuItem)
|
|
||||||
{
|
|
||||||
self.editor.removeMenuItem('cut');
|
|
||||||
self.editor.removeMenuItem('copy');
|
|
||||||
self.editor.removeMenuItem('paste');
|
|
||||||
}
|
|
||||||
|
|
||||||
self.__resizable = true;
|
|
||||||
self.__inited = true;
|
|
||||||
|
|
||||||
self.resize();
|
|
||||||
|
|
||||||
if (self.fOnReady)
|
|
||||||
{
|
|
||||||
self.fOnReady();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
if (window.CKEDITOR)
|
|
||||||
{
|
|
||||||
fInit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
window.__initEditor = fInit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.focus = function ()
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
this.editor.focus();
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.hasFocus = function ()
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return !!this.editor.focusManager.hasFocus;
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.blur = function ()
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
this.editor.focusManager.blur(true);
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.resize = function ()
|
|
||||||
{
|
|
||||||
if (this.editor && this.__resizable)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
this.editor.resize(this.$element.width(), this.$element.innerHeight());
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.setReadOnly = function (bValue)
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
this.editor.setReadOnly(!!bValue);
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HtmlEditor.prototype.clear = function (bFocus)
|
|
||||||
{
|
|
||||||
this.setHtml('', bFocus);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = HtmlEditor;
|
|
||||||
|
|
||||||
}());
|
|
||||||
412
dev/Common/HtmlEditor.jsx
Normal file
412
dev/Common/HtmlEditor.jsx
Normal file
|
|
@ -0,0 +1,412 @@
|
||||||
|
|
||||||
|
import {window, _} from 'common';
|
||||||
|
import Globals from 'Common/Globals';
|
||||||
|
import Settings from 'Storage/Settings';
|
||||||
|
|
||||||
|
class HtmlEditor
|
||||||
|
{
|
||||||
|
editor = null;
|
||||||
|
$element = null;
|
||||||
|
|
||||||
|
blurTimer = 0;
|
||||||
|
|
||||||
|
onBlur = null;
|
||||||
|
onReady = null;
|
||||||
|
onModeChange = null;
|
||||||
|
|
||||||
|
__inited = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} element
|
||||||
|
* @param {Function=} onBlur
|
||||||
|
* @param {Function=} onReady
|
||||||
|
* @param {Function=} onModeChange
|
||||||
|
*/
|
||||||
|
constructor(element, onBlur = null, onReady = null, onModeChange = null)
|
||||||
|
{
|
||||||
|
this.onBlur = onBlur;
|
||||||
|
this.onReady = onReady;
|
||||||
|
this.onModeChange = onModeChange;
|
||||||
|
|
||||||
|
this.$element = $(element);
|
||||||
|
|
||||||
|
this.resize = _.throttle(_.bind(this.resize, this), 100);
|
||||||
|
|
||||||
|
this.__inited = false;
|
||||||
|
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
blurTrigger() {
|
||||||
|
if (this.onBlur)
|
||||||
|
{
|
||||||
|
window.clearTimeout(this.blurTimer);
|
||||||
|
this.blurTimer = window.setTimeout(() => {
|
||||||
|
this.onBlur();
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
focusTrigger() {
|
||||||
|
if (this.onBlur)
|
||||||
|
{
|
||||||
|
window.clearTimeout(this.blurTimer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
isHtml() {
|
||||||
|
return this.editor ? 'wysiwyg' === this.editor.mode : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} signature
|
||||||
|
* @param {bool} html
|
||||||
|
* @param {bool} insertBefore
|
||||||
|
*/
|
||||||
|
setSignature(signature, html, insertBefore) {
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
this.editor.execCommand('insertSignature', {
|
||||||
|
'isHtml': html,
|
||||||
|
'insertBefore': insertBefore,
|
||||||
|
'signature': signature
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
checkDirty() {
|
||||||
|
return this.editor ? this.editor.checkDirty() : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
resetDirty() {
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
this.editor.resetDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} text
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
clearSignatureSigns(text) {
|
||||||
|
return text.replace(/(\u200C|\u0002)/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean=} wrapIsHtml = false
|
||||||
|
* @param {boolean=} clearSignatureSigns = false
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getData(wrapIsHtml = false, clearSignatureSigns = false) {
|
||||||
|
|
||||||
|
let result = '';
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
||||||
|
{
|
||||||
|
result = this.editor.__plain.getRawData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = wrapIsHtml ?
|
||||||
|
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
|
||||||
|
this.editor.getData() + '</div>' : this.editor.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
|
||||||
|
if (clearSignatureSigns)
|
||||||
|
{
|
||||||
|
result = this.clearSignatureSigns(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean=} wrapIsHtml = false
|
||||||
|
* @param {boolean=} clearSignatureSigns = false
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getDataWithHtmlMark(wrapIsHtml = false, clearSignatureSigns = false) {
|
||||||
|
return (this.isHtml() ? ':HTML:' : '') + this.getData(wrapIsHtml, clearSignatureSigns);
|
||||||
|
}
|
||||||
|
|
||||||
|
modeToggle(plain, resize) {
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (plain)
|
||||||
|
{
|
||||||
|
if ('plain' === this.editor.mode)
|
||||||
|
{
|
||||||
|
this.editor.setMode('wysiwyg');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ('wysiwyg' === this.editor.mode)
|
||||||
|
{
|
||||||
|
this.editor.setMode('plain');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
|
|
||||||
|
if (resize)
|
||||||
|
{
|
||||||
|
this.resize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setHtmlOrPlain(text, focus) {
|
||||||
|
if (':HTML:' === text.substr(0, 6))
|
||||||
|
{
|
||||||
|
this.setHtml(text.substr(6), focus);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setPlain(text, focus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setHtml(html, focus) {
|
||||||
|
if (this.editor && this.__inited)
|
||||||
|
{
|
||||||
|
this.modeToggle(true);
|
||||||
|
|
||||||
|
html = html.replace(/<p[^>]*><\/p>/ig, '');
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.editor.setData(html);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
if (focus)
|
||||||
|
{
|
||||||
|
this.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceHtml(find, replaceHtml) {
|
||||||
|
if (this.editor && this.__inited && 'wysiwyg' === this.editor.mode)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
this.editor.setData(
|
||||||
|
this.editor.getData().replace(find, replaceHtml));
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setPlain(plain, focus) {
|
||||||
|
if (this.editor && this.__inited)
|
||||||
|
{
|
||||||
|
this.modeToggle(false);
|
||||||
|
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
||||||
|
{
|
||||||
|
return this.editor.__plain.setRawData(plain);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
this.editor.setData(plain);
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focus)
|
||||||
|
{
|
||||||
|
this.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
if (this.$element && this.$element[0] && !this.editor)
|
||||||
|
{
|
||||||
|
const
|
||||||
|
initFunc = () => {
|
||||||
|
|
||||||
|
const
|
||||||
|
config = Globals.oHtmlEditorDefaultConfig,
|
||||||
|
language = Settings.settingsGet('Language'),
|
||||||
|
allowSource = !!Settings.settingsGet('AllowHtmlEditorSourceButton'),
|
||||||
|
biti = !!Settings.settingsGet('AllowHtmlEditorBitiButtons')
|
||||||
|
;
|
||||||
|
|
||||||
|
if ((allowSource || !biti) && !config.toolbarGroups.__cfgInited)
|
||||||
|
{
|
||||||
|
config.toolbarGroups.__cfgInited = true;
|
||||||
|
|
||||||
|
if (allowSource)
|
||||||
|
{
|
||||||
|
config.removeButtons = config.removeButtons.replace(',Source', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!biti)
|
||||||
|
{
|
||||||
|
config.removePlugins += (config.removePlugins ? ',' : '') + 'bidi';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.enterMode = window.CKEDITOR.ENTER_BR;
|
||||||
|
config.shiftEnterMode = window.CKEDITOR.ENTER_P;
|
||||||
|
|
||||||
|
config.language = Globals.oHtmlEditorLangsMap[language] || 'en';
|
||||||
|
if (window.CKEDITOR.env)
|
||||||
|
{
|
||||||
|
window.CKEDITOR.env.isCompatible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.editor = window.CKEDITOR.appendTo(this.$element[0], config);
|
||||||
|
|
||||||
|
this.editor.on('key', (event) => {
|
||||||
|
if (event && event.data && 9 /* Tab */ === event.data.keyCode)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.editor.on('blur', () => {
|
||||||
|
this.blurTrigger();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.editor.on('mode', () => {
|
||||||
|
this.blurTrigger();
|
||||||
|
if (this.onModeChange)
|
||||||
|
{
|
||||||
|
this.onModeChange('plain' !== this.editor.mode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.editor.on('focus', () => {
|
||||||
|
this.focusTrigger();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (window.FileReader)
|
||||||
|
{
|
||||||
|
this.editor.on('drop', (event) => {
|
||||||
|
if (0 < event.data.dataTransfer.getFilesCount())
|
||||||
|
{
|
||||||
|
const file = event.data.dataTransfer.getFile(0);
|
||||||
|
if (file && window.FileReader && event.data.dataTransfer.id &&
|
||||||
|
file.type && file.type.match(/^image/i))
|
||||||
|
{
|
||||||
|
var
|
||||||
|
id = event.data.dataTransfer.id,
|
||||||
|
imageId = `[img=${id}]`,
|
||||||
|
reader = new window.FileReader()
|
||||||
|
;
|
||||||
|
|
||||||
|
reader.onloadend = () => {
|
||||||
|
if (reader.result)
|
||||||
|
{
|
||||||
|
this.replaceHtml(imageId, `<img src="${reader.result}" />`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
|
||||||
|
event.data.dataTransfer.setData('text/html', imageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.editor.on('instanceReady', () => {
|
||||||
|
|
||||||
|
if (this.editor.removeMenuItem)
|
||||||
|
{
|
||||||
|
this.editor.removeMenuItem('cut');
|
||||||
|
this.editor.removeMenuItem('copy');
|
||||||
|
this.editor.removeMenuItem('paste');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.__resizable = true;
|
||||||
|
this.__inited = true;
|
||||||
|
|
||||||
|
this.resize();
|
||||||
|
|
||||||
|
if (this.onReady)
|
||||||
|
{
|
||||||
|
this.onReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
if (window.CKEDITOR)
|
||||||
|
{
|
||||||
|
initFunc();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.__initEditor = initFunc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
focus() {
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
this.editor.focus();
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hasFocus() {
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return !!this.editor.focusManager.hasFocus;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
blur() {
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
this.editor.focusManager.blur(true);
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resize() {
|
||||||
|
if (this.editor && this.__resizable)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
this.editor.resize(this.$element.width(), this.$element.innerHeight());
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setReadOnly(value) {
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
this.editor.setReadOnly(!!value);
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clear(focus) {
|
||||||
|
this.setHtml('', focus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {HtmlEditor, HtmlEditor as default};
|
||||||
|
module.exports = HtmlEditor;
|
||||||
|
|
@ -4,11 +4,11 @@ import Translator from 'Common/Translator';
|
||||||
|
|
||||||
class Momentor
|
class Momentor
|
||||||
{
|
{
|
||||||
|
_moment = null;
|
||||||
|
_momentNow = 0;
|
||||||
|
|
||||||
constructor()
|
constructor()
|
||||||
{
|
{
|
||||||
this._moment = null;
|
|
||||||
this._momentNow = 0;
|
|
||||||
|
|
||||||
this.updateMomentNow = _.debounce(() => {
|
this.updateMomentNow = _.debounce(() => {
|
||||||
this._moment = moment();
|
this._moment = moment();
|
||||||
}, 500, true);
|
}, 500, true);
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ import Settings from 'Storage/Settings';
|
||||||
|
|
||||||
class Plugins
|
class Plugins
|
||||||
{
|
{
|
||||||
constructor() {
|
oSimpleHooks = {};
|
||||||
this.oSimpleHooks = {};
|
aUserViewModelsHooks = [];
|
||||||
this.aUserViewModelsHooks = [];
|
aAdminViewModelsHooks = [];
|
||||||
this.aAdminViewModelsHooks = [];
|
|
||||||
}
|
constructor() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
|
|
|
||||||
|
|
@ -1,801 +0,0 @@
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var
|
|
||||||
_ = require('_'),
|
|
||||||
$ = require('$'),
|
|
||||||
ko = require('ko'),
|
|
||||||
key = require('key'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
|
||||||
Utils = require('Common/Utils')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param {koProperty} oKoList
|
|
||||||
* @param {koProperty} oKoSelectedItem
|
|
||||||
* @param {koProperty} oKoFocusedItem
|
|
||||||
* @param {string} sItemSelector
|
|
||||||
* @param {string} sItemSelectedSelector
|
|
||||||
* @param {string} sItemCheckedSelector
|
|
||||||
* @param {string} sItemFocusedSelector
|
|
||||||
*/
|
|
||||||
function Selector(oKoList, oKoSelectedItem, oKoFocusedItem,
|
|
||||||
sItemSelector, sItemSelectedSelector, sItemCheckedSelector, sItemFocusedSelector)
|
|
||||||
{
|
|
||||||
this.list = oKoList;
|
|
||||||
|
|
||||||
this.listChecked = ko.computed(function () {
|
|
||||||
return _.filter(this.list(), function (oItem) {
|
|
||||||
return oItem.checked();
|
|
||||||
});
|
|
||||||
}, this).extend({'rateLimit': 0});
|
|
||||||
|
|
||||||
this.isListChecked = ko.computed(function () {
|
|
||||||
return 0 < this.listChecked().length;
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.focusedItem = oKoFocusedItem || ko.observable(null);
|
|
||||||
this.selectedItem = oKoSelectedItem || ko.observable(null);
|
|
||||||
this.selectedItemUseCallback = true;
|
|
||||||
|
|
||||||
this.itemSelectedThrottle = _.debounce(_.bind(this.itemSelected, this), 300);
|
|
||||||
|
|
||||||
this.listChecked.subscribe(function (aItems) {
|
|
||||||
if (0 < aItems.length)
|
|
||||||
{
|
|
||||||
if (null === this.selectedItem())
|
|
||||||
{
|
|
||||||
if (this.selectedItem.valueHasMutated)
|
|
||||||
{
|
|
||||||
this.selectedItem.valueHasMutated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.selectedItem(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this.autoSelect() && this.focusedItem())
|
|
||||||
{
|
|
||||||
this.selectedItem(this.focusedItem());
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.selectedItem.subscribe(function (oItem) {
|
|
||||||
|
|
||||||
if (oItem)
|
|
||||||
{
|
|
||||||
if (this.isListChecked())
|
|
||||||
{
|
|
||||||
_.each(this.listChecked(), function (oSubItem) {
|
|
||||||
oSubItem.checked(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.selectedItemUseCallback)
|
|
||||||
{
|
|
||||||
this.itemSelectedThrottle(oItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this.selectedItemUseCallback)
|
|
||||||
{
|
|
||||||
this.itemSelected(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.selectedItem = this.selectedItem.extend({'toggleSubscribe': [null,
|
|
||||||
function (oPrev) {
|
|
||||||
if (oPrev)
|
|
||||||
{
|
|
||||||
oPrev.selected(false);
|
|
||||||
}
|
|
||||||
}, function (oNext) {
|
|
||||||
if (oNext)
|
|
||||||
{
|
|
||||||
oNext.selected(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]});
|
|
||||||
|
|
||||||
this.focusedItem = this.focusedItem.extend({'toggleSubscribe': [null,
|
|
||||||
function (oPrev) {
|
|
||||||
if (oPrev)
|
|
||||||
{
|
|
||||||
oPrev.focused(false);
|
|
||||||
}
|
|
||||||
}, function (oNext) {
|
|
||||||
if (oNext)
|
|
||||||
{
|
|
||||||
oNext.focused(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]});
|
|
||||||
|
|
||||||
this.iSelectNextHelper = 0;
|
|
||||||
this.iFocusedNextHelper = 0;
|
|
||||||
this.oContentVisible = null;
|
|
||||||
this.oContentScrollable = null;
|
|
||||||
|
|
||||||
this.sItemSelector = sItemSelector;
|
|
||||||
this.sItemSelectedSelector = sItemSelectedSelector;
|
|
||||||
this.sItemCheckedSelector = sItemCheckedSelector;
|
|
||||||
this.sItemFocusedSelector = sItemFocusedSelector;
|
|
||||||
|
|
||||||
this.sLastUid = '';
|
|
||||||
this.oCallbacks = {};
|
|
||||||
|
|
||||||
this.emptyFunction = function () {};
|
|
||||||
this.emptyTrueFunction = function () { return true; };
|
|
||||||
|
|
||||||
this.focusedItem.subscribe(function (oItem) {
|
|
||||||
if (oItem)
|
|
||||||
{
|
|
||||||
this.sLastUid = this.getItemUid(oItem);
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
var
|
|
||||||
aCache = [],
|
|
||||||
aCheckedCache = [],
|
|
||||||
mFocused = null,
|
|
||||||
mSelected = null
|
|
||||||
;
|
|
||||||
|
|
||||||
this.list.subscribe(function (aItems) {
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
if (Utils.isArray(aItems))
|
|
||||||
{
|
|
||||||
_.each(aItems, function (oItem) {
|
|
||||||
if (oItem)
|
|
||||||
{
|
|
||||||
var sUid = self.getItemUid(oItem);
|
|
||||||
|
|
||||||
aCache.push(sUid);
|
|
||||||
if (oItem.checked())
|
|
||||||
{
|
|
||||||
aCheckedCache.push(sUid);
|
|
||||||
}
|
|
||||||
if (null === mFocused && oItem.focused())
|
|
||||||
{
|
|
||||||
mFocused = sUid;
|
|
||||||
}
|
|
||||||
if (null === mSelected && oItem.selected())
|
|
||||||
{
|
|
||||||
mSelected = sUid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, this, 'beforeChange');
|
|
||||||
|
|
||||||
this.list.subscribe(function (aItems) {
|
|
||||||
|
|
||||||
var
|
|
||||||
self = this,
|
|
||||||
oTemp = null,
|
|
||||||
bGetNext = false,
|
|
||||||
aUids = [],
|
|
||||||
mNextFocused = mFocused,
|
|
||||||
bChecked = false,
|
|
||||||
bSelected = false,
|
|
||||||
iLen = 0
|
|
||||||
;
|
|
||||||
|
|
||||||
this.selectedItemUseCallback = false;
|
|
||||||
|
|
||||||
this.focusedItem(null);
|
|
||||||
this.selectedItem(null);
|
|
||||||
|
|
||||||
if (Utils.isArray(aItems))
|
|
||||||
{
|
|
||||||
iLen = aCheckedCache.length;
|
|
||||||
|
|
||||||
_.each(aItems, function (oItem) {
|
|
||||||
|
|
||||||
var sUid = self.getItemUid(oItem);
|
|
||||||
aUids.push(sUid);
|
|
||||||
|
|
||||||
if (null !== mFocused && mFocused === sUid)
|
|
||||||
{
|
|
||||||
self.focusedItem(oItem);
|
|
||||||
mFocused = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 < iLen && -1 < Utils.inArray(sUid, aCheckedCache))
|
|
||||||
{
|
|
||||||
bChecked = true;
|
|
||||||
oItem.checked(true);
|
|
||||||
iLen--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bChecked && null !== mSelected && mSelected === sUid)
|
|
||||||
{
|
|
||||||
bSelected = true;
|
|
||||||
self.selectedItem(oItem);
|
|
||||||
mSelected = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.selectedItemUseCallback = true;
|
|
||||||
|
|
||||||
if (!bChecked && !bSelected && this.autoSelect())
|
|
||||||
{
|
|
||||||
if (self.focusedItem())
|
|
||||||
{
|
|
||||||
self.selectedItem(self.focusedItem());
|
|
||||||
}
|
|
||||||
else if (0 < aItems.length)
|
|
||||||
{
|
|
||||||
if (null !== mNextFocused)
|
|
||||||
{
|
|
||||||
bGetNext = false;
|
|
||||||
mNextFocused = _.find(aCache, function (sUid) {
|
|
||||||
if (bGetNext && -1 < Utils.inArray(sUid, aUids))
|
|
||||||
{
|
|
||||||
return sUid;
|
|
||||||
}
|
|
||||||
else if (mNextFocused === sUid)
|
|
||||||
{
|
|
||||||
bGetNext = true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (mNextFocused)
|
|
||||||
{
|
|
||||||
oTemp = _.find(aItems, function (oItem) {
|
|
||||||
return mNextFocused === self.getItemUid(oItem);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.selectedItem(oTemp || null);
|
|
||||||
self.focusedItem(self.selectedItem());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) && 0 < aItems.length && !self.focusedItem())
|
|
||||||
{
|
|
||||||
oTemp = null;
|
|
||||||
if (0 !== this.iFocusedNextHelper)
|
|
||||||
{
|
|
||||||
oTemp = aItems[-1 === this.iFocusedNextHelper ? aItems.length - 1 : 0] || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!oTemp && 0 !== this.iSelectNextHelper)
|
|
||||||
{
|
|
||||||
oTemp = aItems[-1 === this.iSelectNextHelper ? aItems.length - 1 : 0] || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oTemp)
|
|
||||||
{
|
|
||||||
if (0 !== this.iSelectNextHelper)
|
|
||||||
{
|
|
||||||
self.selectedItem(oTemp || null);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.focusedItem(oTemp || null);
|
|
||||||
|
|
||||||
self.scrollToFocused();
|
|
||||||
|
|
||||||
_.delay(function () {
|
|
||||||
self.scrollToFocused();
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.iSelectNextHelper = 0;
|
|
||||||
this.iFocusedNextHelper = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
aCache = [];
|
|
||||||
aCheckedCache = [];
|
|
||||||
mFocused = null;
|
|
||||||
mSelected = null;
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Selector.prototype.itemSelected = function (oItem)
|
|
||||||
{
|
|
||||||
if (this.isListChecked())
|
|
||||||
{
|
|
||||||
if (!oItem)
|
|
||||||
{
|
|
||||||
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem || null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (oItem)
|
|
||||||
{
|
|
||||||
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Selector.prototype.goDown = function (bForceSelect)
|
|
||||||
{
|
|
||||||
this.newSelectPosition(Enums.EventKeyCode.Down, false, bForceSelect);
|
|
||||||
};
|
|
||||||
|
|
||||||
Selector.prototype.goUp = function (bForceSelect)
|
|
||||||
{
|
|
||||||
this.newSelectPosition(Enums.EventKeyCode.Up, false, bForceSelect);
|
|
||||||
};
|
|
||||||
|
|
||||||
Selector.prototype.unselect = function ()
|
|
||||||
{
|
|
||||||
this.selectedItem(null);
|
|
||||||
this.focusedItem(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeyScope)
|
|
||||||
{
|
|
||||||
this.oContentVisible = oContentVisible;
|
|
||||||
this.oContentScrollable = oContentScrollable;
|
|
||||||
|
|
||||||
sKeyScope = sKeyScope || 'all';
|
|
||||||
|
|
||||||
if (this.oContentVisible && this.oContentScrollable)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
self = this
|
|
||||||
;
|
|
||||||
|
|
||||||
$(this.oContentVisible)
|
|
||||||
.on('selectstart', function (oEvent) {
|
|
||||||
if (oEvent && oEvent.preventDefault)
|
|
||||||
{
|
|
||||||
oEvent.preventDefault();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on('click', this.sItemSelector, function (oEvent) {
|
|
||||||
self.actionClick(ko.dataFor(this), oEvent);
|
|
||||||
})
|
|
||||||
.on('click', this.sItemCheckedSelector, function (oEvent) {
|
|
||||||
var oItem = ko.dataFor(this);
|
|
||||||
if (oItem)
|
|
||||||
{
|
|
||||||
if (oEvent && oEvent.shiftKey)
|
|
||||||
{
|
|
||||||
self.actionClick(oItem, oEvent);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
self.focusedItem(oItem);
|
|
||||||
oItem.checked(!oItem.checked());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
;
|
|
||||||
|
|
||||||
key('enter', sKeyScope, function () {
|
|
||||||
if (self.focusedItem() && !self.focusedItem().selected())
|
|
||||||
{
|
|
||||||
self.actionClick(self.focusedItem());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
key('ctrl+up, command+up, ctrl+down, command+down', sKeyScope, function () {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
key('up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space', sKeyScope, function (event, handler) {
|
|
||||||
if (event && handler && handler.shortcut)
|
|
||||||
{
|
|
||||||
var iKey = 0;
|
|
||||||
switch (handler.shortcut)
|
|
||||||
{
|
|
||||||
case 'up':
|
|
||||||
case 'shift+up':
|
|
||||||
iKey = Enums.EventKeyCode.Up;
|
|
||||||
break;
|
|
||||||
case 'down':
|
|
||||||
case 'shift+down':
|
|
||||||
iKey = Enums.EventKeyCode.Down;
|
|
||||||
break;
|
|
||||||
case 'insert':
|
|
||||||
iKey = Enums.EventKeyCode.Insert;
|
|
||||||
break;
|
|
||||||
case 'space':
|
|
||||||
iKey = Enums.EventKeyCode.Space;
|
|
||||||
break;
|
|
||||||
case 'home':
|
|
||||||
iKey = Enums.EventKeyCode.Home;
|
|
||||||
break;
|
|
||||||
case 'end':
|
|
||||||
iKey = Enums.EventKeyCode.End;
|
|
||||||
break;
|
|
||||||
case 'pageup':
|
|
||||||
iKey = Enums.EventKeyCode.PageUp;
|
|
||||||
break;
|
|
||||||
case 'pagedown':
|
|
||||||
iKey = Enums.EventKeyCode.PageDown;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 < iKey)
|
|
||||||
{
|
|
||||||
self.newSelectPosition(iKey, key.shift);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
Selector.prototype.autoSelect = function ()
|
|
||||||
{
|
|
||||||
return !!(this.oCallbacks['onAutoSelect'] || this.emptyTrueFunction)();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean}
|
|
||||||
*/
|
|
||||||
Selector.prototype.doUpUpOrDownDown = function (bUp)
|
|
||||||
{
|
|
||||||
(this.oCallbacks['onUpUpOrDownDown'] || this.emptyTrueFunction)(!!bUp);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Object} oItem
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
Selector.prototype.getItemUid = function (oItem)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
sUid = '',
|
|
||||||
fGetItemUidCallback = this.oCallbacks['onItemGetUid'] || null
|
|
||||||
;
|
|
||||||
|
|
||||||
if (fGetItemUidCallback && oItem)
|
|
||||||
{
|
|
||||||
sUid = fGetItemUidCallback(oItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sUid.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {number} iEventKeyCode
|
|
||||||
* @param {boolean} bShiftKey
|
|
||||||
* @param {boolean=} bForceSelect = false
|
|
||||||
*/
|
|
||||||
Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForceSelect)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
iIndex = 0,
|
|
||||||
iPageStep = 10,
|
|
||||||
bNext = false,
|
|
||||||
bStop = false,
|
|
||||||
oResult = null,
|
|
||||||
aList = this.list(),
|
|
||||||
iListLen = aList ? aList.length : 0,
|
|
||||||
oFocused = this.focusedItem()
|
|
||||||
;
|
|
||||||
|
|
||||||
if (0 < iListLen)
|
|
||||||
{
|
|
||||||
if (!oFocused)
|
|
||||||
{
|
|
||||||
if (Enums.EventKeyCode.Down === iEventKeyCode || Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode || Enums.EventKeyCode.Home === iEventKeyCode || Enums.EventKeyCode.PageUp === iEventKeyCode)
|
|
||||||
{
|
|
||||||
oResult = aList[0];
|
|
||||||
}
|
|
||||||
else if (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.End === iEventKeyCode || Enums.EventKeyCode.PageDown === iEventKeyCode)
|
|
||||||
{
|
|
||||||
oResult = aList[aList.length - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (oFocused)
|
|
||||||
{
|
|
||||||
if (Enums.EventKeyCode.Down === iEventKeyCode || Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode)
|
|
||||||
{
|
|
||||||
_.each(aList, function (oItem) {
|
|
||||||
if (!bStop)
|
|
||||||
{
|
|
||||||
switch (iEventKeyCode) {
|
|
||||||
case Enums.EventKeyCode.Up:
|
|
||||||
if (oFocused === oItem)
|
|
||||||
{
|
|
||||||
bStop = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
oResult = oItem;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Enums.EventKeyCode.Down:
|
|
||||||
case Enums.EventKeyCode.Insert:
|
|
||||||
if (bNext)
|
|
||||||
{
|
|
||||||
oResult = oItem;
|
|
||||||
bStop = true;
|
|
||||||
}
|
|
||||||
else if (oFocused === oItem)
|
|
||||||
{
|
|
||||||
bNext = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!oResult && (Enums.EventKeyCode.Down === iEventKeyCode || Enums.EventKeyCode.Up === iEventKeyCode))
|
|
||||||
{
|
|
||||||
this.doUpUpOrDownDown(Enums.EventKeyCode.Up === iEventKeyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Enums.EventKeyCode.Home === iEventKeyCode || Enums.EventKeyCode.End === iEventKeyCode)
|
|
||||||
{
|
|
||||||
if (Enums.EventKeyCode.Home === iEventKeyCode)
|
|
||||||
{
|
|
||||||
oResult = aList[0];
|
|
||||||
}
|
|
||||||
else if (Enums.EventKeyCode.End === iEventKeyCode)
|
|
||||||
{
|
|
||||||
oResult = aList[aList.length - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Enums.EventKeyCode.PageDown === iEventKeyCode)
|
|
||||||
{
|
|
||||||
for (; iIndex < iListLen; iIndex++)
|
|
||||||
{
|
|
||||||
if (oFocused === aList[iIndex])
|
|
||||||
{
|
|
||||||
iIndex += iPageStep;
|
|
||||||
iIndex = iListLen - 1 < iIndex ? iListLen - 1 : iIndex;
|
|
||||||
oResult = aList[iIndex];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Enums.EventKeyCode.PageUp === iEventKeyCode)
|
|
||||||
{
|
|
||||||
for (iIndex = iListLen; iIndex >= 0; iIndex--)
|
|
||||||
{
|
|
||||||
if (oFocused === aList[iIndex])
|
|
||||||
{
|
|
||||||
iIndex -= iPageStep;
|
|
||||||
iIndex = 0 > iIndex ? 0 : iIndex;
|
|
||||||
oResult = aList[iIndex];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oResult)
|
|
||||||
{
|
|
||||||
this.focusedItem(oResult);
|
|
||||||
|
|
||||||
if (oFocused)
|
|
||||||
{
|
|
||||||
if (bShiftKey)
|
|
||||||
{
|
|
||||||
if (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.Down === iEventKeyCode)
|
|
||||||
{
|
|
||||||
oFocused.checked(!oFocused.checked());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode)
|
|
||||||
{
|
|
||||||
oFocused.checked(!oFocused.checked());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this.autoSelect() || !!bForceSelect) &&
|
|
||||||
!this.isListChecked() && Enums.EventKeyCode.Space !== iEventKeyCode)
|
|
||||||
{
|
|
||||||
this.selectedItem(oResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.scrollToFocused();
|
|
||||||
}
|
|
||||||
else if (oFocused)
|
|
||||||
{
|
|
||||||
if (bShiftKey && (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.Down === iEventKeyCode))
|
|
||||||
{
|
|
||||||
oFocused.checked(!oFocused.checked());
|
|
||||||
}
|
|
||||||
else if (Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode)
|
|
||||||
{
|
|
||||||
oFocused.checked(!oFocused.checked());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.focusedItem(oFocused);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
Selector.prototype.scrollToFocused = function ()
|
|
||||||
{
|
|
||||||
if (!this.oContentVisible || !this.oContentScrollable)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var
|
|
||||||
iOffset = 20,
|
|
||||||
aList = this.list(),
|
|
||||||
oFocused = $(this.sItemFocusedSelector, this.oContentScrollable),
|
|
||||||
oPos = oFocused.position(),
|
|
||||||
iVisibleHeight = this.oContentVisible.height(),
|
|
||||||
iFocusedHeight = oFocused.outerHeight()
|
|
||||||
;
|
|
||||||
|
|
||||||
if (aList && aList[0] && aList[0].focused())
|
|
||||||
{
|
|
||||||
this.oContentScrollable.scrollTop(0);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight))
|
|
||||||
{
|
|
||||||
if (oPos.top < 0)
|
|
||||||
{
|
|
||||||
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean=} bFast = false
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
Selector.prototype.scrollToTop = function (bFast)
|
|
||||||
{
|
|
||||||
if (!this.oContentVisible || !this.oContentScrollable)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bFast || 50 > this.oContentScrollable.scrollTop())
|
|
||||||
{
|
|
||||||
this.oContentScrollable.scrollTop(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.oContentScrollable.stop().animate({'scrollTop': 0}, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
Selector.prototype.eventClickFunction = function (oItem, oEvent)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
sUid = this.getItemUid(oItem),
|
|
||||||
iIndex = 0,
|
|
||||||
iLength = 0,
|
|
||||||
oListItem = null,
|
|
||||||
sLineUid = '',
|
|
||||||
bChangeRange = false,
|
|
||||||
bIsInRange = false,
|
|
||||||
aList = [],
|
|
||||||
bChecked = false
|
|
||||||
;
|
|
||||||
|
|
||||||
if (oEvent && oEvent.shiftKey)
|
|
||||||
{
|
|
||||||
if ('' !== sUid && '' !== this.sLastUid && sUid !== this.sLastUid)
|
|
||||||
{
|
|
||||||
aList = this.list();
|
|
||||||
bChecked = oItem.checked();
|
|
||||||
|
|
||||||
for (iIndex = 0, iLength = aList.length; iIndex < iLength; iIndex++)
|
|
||||||
{
|
|
||||||
oListItem = aList[iIndex];
|
|
||||||
sLineUid = this.getItemUid(oListItem);
|
|
||||||
|
|
||||||
bChangeRange = false;
|
|
||||||
if (sLineUid === this.sLastUid || sLineUid === sUid)
|
|
||||||
{
|
|
||||||
bChangeRange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bChangeRange)
|
|
||||||
{
|
|
||||||
bIsInRange = !bIsInRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bIsInRange || bChangeRange)
|
|
||||||
{
|
|
||||||
oListItem.checked(bChecked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sLastUid = '' === sUid ? '' : sUid;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Object} oItem
|
|
||||||
* @param {Object=} oEvent
|
|
||||||
*/
|
|
||||||
Selector.prototype.actionClick = function (oItem, oEvent)
|
|
||||||
{
|
|
||||||
if (oItem)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
bClick = true,
|
|
||||||
sUid = this.getItemUid(oItem)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (oEvent)
|
|
||||||
{
|
|
||||||
if (oEvent.shiftKey && !(oEvent.ctrlKey || oEvent.metaKey) && !oEvent.altKey)
|
|
||||||
{
|
|
||||||
bClick = false;
|
|
||||||
if ('' === this.sLastUid)
|
|
||||||
{
|
|
||||||
this.sLastUid = sUid;
|
|
||||||
}
|
|
||||||
|
|
||||||
oItem.checked(!oItem.checked());
|
|
||||||
this.eventClickFunction(oItem, oEvent);
|
|
||||||
|
|
||||||
this.focusedItem(oItem);
|
|
||||||
}
|
|
||||||
else if ((oEvent.ctrlKey || oEvent.metaKey) && !oEvent.shiftKey && !oEvent.altKey)
|
|
||||||
{
|
|
||||||
bClick = false;
|
|
||||||
this.focusedItem(oItem);
|
|
||||||
|
|
||||||
if (this.selectedItem() && oItem !== this.selectedItem())
|
|
||||||
{
|
|
||||||
this.selectedItem().checked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
oItem.checked(!oItem.checked());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bClick)
|
|
||||||
{
|
|
||||||
this.selectMessageItem(oItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Selector.prototype.on = function (sEventName, fCallback)
|
|
||||||
{
|
|
||||||
this.oCallbacks[sEventName] = fCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
Selector.prototype.selectMessageItem = function (oMessageItem)
|
|
||||||
{
|
|
||||||
this.focusedItem(oMessageItem);
|
|
||||||
this.selectedItem(oMessageItem);
|
|
||||||
|
|
||||||
this.scrollToFocused();
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Selector;
|
|
||||||
|
|
||||||
}());
|
|
||||||
763
dev/Common/Selector.jsx
Normal file
763
dev/Common/Selector.jsx
Normal file
|
|
@ -0,0 +1,763 @@
|
||||||
|
|
||||||
|
import {$, _, key} from 'common';
|
||||||
|
import ko from 'ko';
|
||||||
|
import {EventKeyCode} from 'Common/Enums';
|
||||||
|
import Utils from 'Common/Utils';
|
||||||
|
|
||||||
|
class Selector
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {koProperty} koList
|
||||||
|
* @param {koProperty} koSelectedItem
|
||||||
|
* @param {koProperty} koFocusedItem
|
||||||
|
* @param {string} sItemSelector
|
||||||
|
* @param {string} sItemSelectedSelector
|
||||||
|
* @param {string} sItemCheckedSelector
|
||||||
|
* @param {string} sItemFocusedSelector
|
||||||
|
*/
|
||||||
|
constructor(koList, koSelectedItem, koFocusedItem,
|
||||||
|
sItemSelector, sItemSelectedSelector, sItemCheckedSelector, sItemFocusedSelector)
|
||||||
|
{
|
||||||
|
this.list = koList;
|
||||||
|
|
||||||
|
this.listChecked = ko.computed(() => {
|
||||||
|
return _.filter(this.list(), (item) => item.checked());
|
||||||
|
}, this).extend({'rateLimit': 0});
|
||||||
|
|
||||||
|
this.isListChecked = ko.computed(() => 0 < this.listChecked().length);
|
||||||
|
|
||||||
|
this.focusedItem = koFocusedItem || ko.observable(null);
|
||||||
|
this.selectedItem = koSelectedItem || ko.observable(null);
|
||||||
|
this.selectedItemUseCallback = true;
|
||||||
|
|
||||||
|
this.itemSelectedThrottle = _.debounce(_.bind(this.itemSelected, this), 300);
|
||||||
|
|
||||||
|
this.listChecked.subscribe((items) => {
|
||||||
|
if (0 < items.length)
|
||||||
|
{
|
||||||
|
if (null === this.selectedItem())
|
||||||
|
{
|
||||||
|
if (this.selectedItem.valueHasMutated)
|
||||||
|
{
|
||||||
|
this.selectedItem.valueHasMutated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.selectedItem(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.autoSelect() && this.focusedItem())
|
||||||
|
{
|
||||||
|
this.selectedItem(this.focusedItem());
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.selectedItem.subscribe((item) => {
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
if (this.isListChecked())
|
||||||
|
{
|
||||||
|
_.each(this.listChecked(), (subItem) => {
|
||||||
|
subItem.checked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.selectedItemUseCallback)
|
||||||
|
{
|
||||||
|
this.itemSelectedThrottle(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.selectedItemUseCallback)
|
||||||
|
{
|
||||||
|
this.itemSelected(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.selectedItem = this.selectedItem.extend({'toggleSubscribe': [null,
|
||||||
|
(prev) => {
|
||||||
|
if (prev)
|
||||||
|
{
|
||||||
|
prev.selected(false);
|
||||||
|
}
|
||||||
|
}, (next) => {
|
||||||
|
if (next)
|
||||||
|
{
|
||||||
|
next.selected(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]});
|
||||||
|
|
||||||
|
this.focusedItem = this.focusedItem.extend({'toggleSubscribe': [null,
|
||||||
|
(prev) => {
|
||||||
|
if (prev)
|
||||||
|
{
|
||||||
|
prev.focused(false);
|
||||||
|
}
|
||||||
|
}, (next) => {
|
||||||
|
if (next)
|
||||||
|
{
|
||||||
|
next.focused(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]});
|
||||||
|
|
||||||
|
this.iSelectNextHelper = 0;
|
||||||
|
this.iFocusedNextHelper = 0;
|
||||||
|
this.oContentVisible = null;
|
||||||
|
this.oContentScrollable = null;
|
||||||
|
|
||||||
|
this.sItemSelector = sItemSelector;
|
||||||
|
this.sItemSelectedSelector = sItemSelectedSelector;
|
||||||
|
this.sItemCheckedSelector = sItemCheckedSelector;
|
||||||
|
this.sItemFocusedSelector = sItemFocusedSelector;
|
||||||
|
|
||||||
|
this.sLastUid = '';
|
||||||
|
this.oCallbacks = {};
|
||||||
|
|
||||||
|
this.emptyFunction = () => {};
|
||||||
|
this.emptyTrueFunction = () => true;
|
||||||
|
|
||||||
|
this.focusedItem.subscribe((item) => {
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
this.sLastUid = this.getItemUid(item);
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
let
|
||||||
|
aCache = [],
|
||||||
|
aCheckedCache = [],
|
||||||
|
mFocused = null,
|
||||||
|
mSelected = null
|
||||||
|
;
|
||||||
|
|
||||||
|
this.list.subscribe((items) => {
|
||||||
|
|
||||||
|
if (Utils.isArray(items))
|
||||||
|
{
|
||||||
|
_.each(items, (item) => {
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
const uid = this.getItemUid(item);
|
||||||
|
|
||||||
|
aCache.push(uid);
|
||||||
|
if (item.checked())
|
||||||
|
{
|
||||||
|
aCheckedCache.push(uid);
|
||||||
|
}
|
||||||
|
if (null === mFocused && item.focused())
|
||||||
|
{
|
||||||
|
mFocused = uid;
|
||||||
|
}
|
||||||
|
if (null === mSelected && item.selected())
|
||||||
|
{
|
||||||
|
mSelected = uid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, this, 'beforeChange');
|
||||||
|
|
||||||
|
this.list.subscribe((aItems) => {
|
||||||
|
|
||||||
|
var
|
||||||
|
oTemp = null,
|
||||||
|
bGetNext = false,
|
||||||
|
aUids = [],
|
||||||
|
mNextFocused = mFocused,
|
||||||
|
bChecked = false,
|
||||||
|
bSelected = false,
|
||||||
|
iLen = 0
|
||||||
|
;
|
||||||
|
|
||||||
|
this.selectedItemUseCallback = false;
|
||||||
|
|
||||||
|
this.focusedItem(null);
|
||||||
|
this.selectedItem(null);
|
||||||
|
|
||||||
|
if (Utils.isArray(aItems))
|
||||||
|
{
|
||||||
|
iLen = aCheckedCache.length;
|
||||||
|
|
||||||
|
_.each(aItems, (oItem) => {
|
||||||
|
|
||||||
|
var sUid = this.getItemUid(oItem);
|
||||||
|
aUids.push(sUid);
|
||||||
|
|
||||||
|
if (null !== mFocused && mFocused === sUid)
|
||||||
|
{
|
||||||
|
this.focusedItem(oItem);
|
||||||
|
mFocused = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 < iLen && -1 < Utils.inArray(sUid, aCheckedCache))
|
||||||
|
{
|
||||||
|
bChecked = true;
|
||||||
|
oItem.checked(true);
|
||||||
|
iLen--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bChecked && null !== mSelected && mSelected === sUid)
|
||||||
|
{
|
||||||
|
bSelected = true;
|
||||||
|
this.selectedItem(oItem);
|
||||||
|
mSelected = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.selectedItemUseCallback = true;
|
||||||
|
|
||||||
|
if (!bChecked && !bSelected && this.autoSelect())
|
||||||
|
{
|
||||||
|
if (this.focusedItem())
|
||||||
|
{
|
||||||
|
this.selectedItem(this.focusedItem());
|
||||||
|
}
|
||||||
|
else if (0 < aItems.length)
|
||||||
|
{
|
||||||
|
if (null !== mNextFocused)
|
||||||
|
{
|
||||||
|
bGetNext = false;
|
||||||
|
mNextFocused = _.find(aCache, (sUid) => {
|
||||||
|
if (bGetNext && -1 < Utils.inArray(sUid, aUids))
|
||||||
|
{
|
||||||
|
return sUid;
|
||||||
|
}
|
||||||
|
else if (mNextFocused === sUid)
|
||||||
|
{
|
||||||
|
bGetNext = true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (mNextFocused)
|
||||||
|
{
|
||||||
|
oTemp = _.find(aItems, (oItem) => mNextFocused === this.getItemUid(oItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectedItem(oTemp || null);
|
||||||
|
this.focusedItem(this.selectedItem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) && 0 < aItems.length && !this.focusedItem())
|
||||||
|
{
|
||||||
|
oTemp = null;
|
||||||
|
if (0 !== this.iFocusedNextHelper)
|
||||||
|
{
|
||||||
|
oTemp = aItems[-1 === this.iFocusedNextHelper ? aItems.length - 1 : 0] || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!oTemp && 0 !== this.iSelectNextHelper)
|
||||||
|
{
|
||||||
|
oTemp = aItems[-1 === this.iSelectNextHelper ? aItems.length - 1 : 0] || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oTemp)
|
||||||
|
{
|
||||||
|
if (0 !== this.iSelectNextHelper)
|
||||||
|
{
|
||||||
|
this.selectedItem(oTemp || null);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.focusedItem(oTemp || null);
|
||||||
|
|
||||||
|
this.scrollToFocused();
|
||||||
|
|
||||||
|
_.delay(() => this.scrollToFocused(), 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.iSelectNextHelper = 0;
|
||||||
|
this.iFocusedNextHelper = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aCache = [];
|
||||||
|
aCheckedCache = [];
|
||||||
|
mFocused = null;
|
||||||
|
mSelected = null;
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemSelected(item) {
|
||||||
|
|
||||||
|
if (this.isListChecked())
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(item || null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} forceSelect
|
||||||
|
*/
|
||||||
|
goDown(forceSelect) {
|
||||||
|
this.newSelectPosition(EventKeyCode.Down, false, forceSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} forceSelect
|
||||||
|
*/
|
||||||
|
goUp(forceSelect) {
|
||||||
|
this.newSelectPosition(EventKeyCode.Up, false, forceSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
unselect() {
|
||||||
|
this.selectedItem(null);
|
||||||
|
this.focusedItem(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
init(contentVisible, contentScrollable, keyScope = 'all') {
|
||||||
|
|
||||||
|
this.oContentVisible = contentVisible;
|
||||||
|
this.oContentScrollable = contentScrollable;
|
||||||
|
|
||||||
|
if (this.oContentVisible && this.oContentScrollable)
|
||||||
|
{
|
||||||
|
$(this.oContentVisible)
|
||||||
|
.on('selectstart', (event) => {
|
||||||
|
if (event && event.preventDefault)
|
||||||
|
{
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('click', this.sItemSelector, (event) => {
|
||||||
|
this.actionClick(ko.dataFor(event.currentTarget), event);
|
||||||
|
})
|
||||||
|
.on('click', this.sItemCheckedSelector, (event) => {
|
||||||
|
const item = ko.dataFor(event.currentTarget);
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
if (event && event.shiftKey)
|
||||||
|
{
|
||||||
|
this.actionClick(item, event);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.focusedItem(item);
|
||||||
|
item.checked(!item.checked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
;
|
||||||
|
|
||||||
|
key('enter', keyScope, () => {
|
||||||
|
if (this.focusedItem() && !this.focusedItem().selected())
|
||||||
|
{
|
||||||
|
this.actionClick(this.focusedItem());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
key('ctrl+up, command+up, ctrl+down, command+down', keyScope, () => false);
|
||||||
|
|
||||||
|
key('up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space', keyScope, (event, handler) => {
|
||||||
|
if (event && handler && handler.shortcut)
|
||||||
|
{
|
||||||
|
let eventKey = 0;
|
||||||
|
switch (handler.shortcut)
|
||||||
|
{
|
||||||
|
case 'up':
|
||||||
|
case 'shift+up':
|
||||||
|
eventKey = EventKeyCode.Up;
|
||||||
|
break;
|
||||||
|
case 'down':
|
||||||
|
case 'shift+down':
|
||||||
|
eventKey = EventKeyCode.Down;
|
||||||
|
break;
|
||||||
|
case 'insert':
|
||||||
|
eventKey = EventKeyCode.Insert;
|
||||||
|
break;
|
||||||
|
case 'space':
|
||||||
|
eventKey = EventKeyCode.Space;
|
||||||
|
break;
|
||||||
|
case 'home':
|
||||||
|
eventKey = EventKeyCode.Home;
|
||||||
|
break;
|
||||||
|
case 'end':
|
||||||
|
eventKey = EventKeyCode.End;
|
||||||
|
break;
|
||||||
|
case 'pageup':
|
||||||
|
eventKey = EventKeyCode.PageUp;
|
||||||
|
break;
|
||||||
|
case 'pagedown':
|
||||||
|
eventKey = EventKeyCode.PageDown;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 < eventKey)
|
||||||
|
{
|
||||||
|
this.newSelectPosition(eventKey, key.shift);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
autoSelect() {
|
||||||
|
return !!(this.oCallbacks['onAutoSelect'] || this.emptyTrueFunction)();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} up
|
||||||
|
*/
|
||||||
|
doUpUpOrDownDown(up) {
|
||||||
|
(this.oCallbacks['onUpUpOrDownDown'] || this.emptyTrueFunction)(!!up);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} oItem
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getItemUid(item) {
|
||||||
|
|
||||||
|
let uid = '';
|
||||||
|
|
||||||
|
const getItemUidCallback = this.oCallbacks['onItemGetUid'] || null;
|
||||||
|
if (getItemUidCallback && item)
|
||||||
|
{
|
||||||
|
uid = getItemUidCallback(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return uid.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} iEventKeyCode
|
||||||
|
* @param {boolean} bShiftKey
|
||||||
|
* @param {boolean=} bForceSelect = false
|
||||||
|
*/
|
||||||
|
newSelectPosition(iEventKeyCode, bShiftKey, bForceSelect) {
|
||||||
|
|
||||||
|
var
|
||||||
|
iIndex = 0,
|
||||||
|
iPageStep = 10,
|
||||||
|
bNext = false,
|
||||||
|
bStop = false,
|
||||||
|
oResult = null,
|
||||||
|
aList = this.list(),
|
||||||
|
iListLen = aList ? aList.length : 0,
|
||||||
|
oFocused = this.focusedItem()
|
||||||
|
;
|
||||||
|
|
||||||
|
if (0 < iListLen)
|
||||||
|
{
|
||||||
|
if (!oFocused)
|
||||||
|
{
|
||||||
|
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode || EventKeyCode.Home === iEventKeyCode || EventKeyCode.PageUp === iEventKeyCode)
|
||||||
|
{
|
||||||
|
oResult = aList[0];
|
||||||
|
}
|
||||||
|
else if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.End === iEventKeyCode || EventKeyCode.PageDown === iEventKeyCode)
|
||||||
|
{
|
||||||
|
oResult = aList[aList.length - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (oFocused)
|
||||||
|
{
|
||||||
|
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||||
|
{
|
||||||
|
_.each(aList, (item) => {
|
||||||
|
if (!bStop)
|
||||||
|
{
|
||||||
|
switch (iEventKeyCode) {
|
||||||
|
case EventKeyCode.Up:
|
||||||
|
if (oFocused === item)
|
||||||
|
{
|
||||||
|
bStop = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oResult = item;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EventKeyCode.Down:
|
||||||
|
case EventKeyCode.Insert:
|
||||||
|
if (bNext)
|
||||||
|
{
|
||||||
|
oResult = item;
|
||||||
|
bStop = true;
|
||||||
|
}
|
||||||
|
else if (oFocused === item)
|
||||||
|
{
|
||||||
|
bNext = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!oResult && (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode))
|
||||||
|
{
|
||||||
|
this.doUpUpOrDownDown(EventKeyCode.Up === iEventKeyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (EventKeyCode.Home === iEventKeyCode || EventKeyCode.End === iEventKeyCode)
|
||||||
|
{
|
||||||
|
if (EventKeyCode.Home === iEventKeyCode)
|
||||||
|
{
|
||||||
|
oResult = aList[0];
|
||||||
|
}
|
||||||
|
else if (EventKeyCode.End === iEventKeyCode)
|
||||||
|
{
|
||||||
|
oResult = aList[aList.length - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (EventKeyCode.PageDown === iEventKeyCode)
|
||||||
|
{
|
||||||
|
for (; iIndex < iListLen; iIndex++)
|
||||||
|
{
|
||||||
|
if (oFocused === aList[iIndex])
|
||||||
|
{
|
||||||
|
iIndex += iPageStep;
|
||||||
|
iIndex = iListLen - 1 < iIndex ? iListLen - 1 : iIndex;
|
||||||
|
oResult = aList[iIndex];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (EventKeyCode.PageUp === iEventKeyCode)
|
||||||
|
{
|
||||||
|
for (iIndex = iListLen; iIndex >= 0; iIndex--)
|
||||||
|
{
|
||||||
|
if (oFocused === aList[iIndex])
|
||||||
|
{
|
||||||
|
iIndex -= iPageStep;
|
||||||
|
iIndex = 0 > iIndex ? 0 : iIndex;
|
||||||
|
oResult = aList[iIndex];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oResult)
|
||||||
|
{
|
||||||
|
this.focusedItem(oResult);
|
||||||
|
|
||||||
|
if (oFocused)
|
||||||
|
{
|
||||||
|
if (bShiftKey)
|
||||||
|
{
|
||||||
|
if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode)
|
||||||
|
{
|
||||||
|
oFocused.checked(!oFocused.checked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||||
|
{
|
||||||
|
oFocused.checked(!oFocused.checked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((this.autoSelect() || !!bForceSelect) &&
|
||||||
|
!this.isListChecked() && EventKeyCode.Space !== iEventKeyCode)
|
||||||
|
{
|
||||||
|
this.selectedItem(oResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scrollToFocused();
|
||||||
|
}
|
||||||
|
else if (oFocused)
|
||||||
|
{
|
||||||
|
if (bShiftKey && (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode))
|
||||||
|
{
|
||||||
|
oFocused.checked(!oFocused.checked());
|
||||||
|
}
|
||||||
|
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||||
|
{
|
||||||
|
oFocused.checked(!oFocused.checked());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.focusedItem(oFocused);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
scrollToFocused() {
|
||||||
|
|
||||||
|
if (!this.oContentVisible || !this.oContentScrollable)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const
|
||||||
|
offset = 20,
|
||||||
|
list = this.list(),
|
||||||
|
$focused = $(this.sItemFocusedSelector, this.oContentScrollable),
|
||||||
|
pos = $focused.position(),
|
||||||
|
visibleHeight = this.oContentVisible.height(),
|
||||||
|
focusedHeight = $focused.outerHeight()
|
||||||
|
;
|
||||||
|
|
||||||
|
if (list && list[0] && list[0].focused())
|
||||||
|
{
|
||||||
|
this.oContentScrollable.scrollTop(0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (pos && (pos.top < 0 || pos.top + focusedHeight > visibleHeight))
|
||||||
|
{
|
||||||
|
this.oContentScrollable.scrollTop(pos.top < 0 ?
|
||||||
|
this.oContentScrollable.scrollTop() + pos.top - offset :
|
||||||
|
this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean=} fast = false
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
scrollToTop(fast = false) {
|
||||||
|
|
||||||
|
if (!this.oContentVisible || !this.oContentScrollable)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fast || 50 > this.oContentScrollable.scrollTop())
|
||||||
|
{
|
||||||
|
this.oContentScrollable.scrollTop(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.oContentScrollable.stop().animate({'scrollTop': 0}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventClickFunction(item, event) {
|
||||||
|
|
||||||
|
let
|
||||||
|
index = 0,
|
||||||
|
length = 0,
|
||||||
|
changeRange = false,
|
||||||
|
isInRange = false,
|
||||||
|
list = [],
|
||||||
|
checked = false,
|
||||||
|
listItem = null,
|
||||||
|
lineUid = ''
|
||||||
|
;
|
||||||
|
|
||||||
|
const uid = this.getItemUid(item);
|
||||||
|
if (event && event.shiftKey)
|
||||||
|
{
|
||||||
|
if ('' !== uid && '' !== this.sLastUid && uid !== this.sLastUid)
|
||||||
|
{
|
||||||
|
list = this.list();
|
||||||
|
checked = item.checked();
|
||||||
|
|
||||||
|
for (index = 0, length = list.length; index < length; index++)
|
||||||
|
{
|
||||||
|
listItem = list[index];
|
||||||
|
lineUid = this.getItemUid(listItem);
|
||||||
|
|
||||||
|
changeRange = false;
|
||||||
|
if (lineUid === this.sLastUid || lineUid === uid)
|
||||||
|
{
|
||||||
|
changeRange = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changeRange)
|
||||||
|
{
|
||||||
|
isInRange = !isInRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInRange || changeRange)
|
||||||
|
{
|
||||||
|
listItem.checked(checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sLastUid = '' === uid ? '' : uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} item
|
||||||
|
* @param {Object=} event
|
||||||
|
*/
|
||||||
|
actionClick = function (item, event = null) {
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
let click = true;
|
||||||
|
if (event)
|
||||||
|
{
|
||||||
|
if (event.shiftKey && !(event.ctrlKey || event.metaKey) && !event.altKey)
|
||||||
|
{
|
||||||
|
click = false;
|
||||||
|
if ('' === this.sLastUid)
|
||||||
|
{
|
||||||
|
this.sLastUid = this.getItemUid(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
item.checked(!item.checked());
|
||||||
|
this.eventClickFunction(item, event);
|
||||||
|
|
||||||
|
this.focusedItem(item);
|
||||||
|
}
|
||||||
|
else if ((event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey)
|
||||||
|
{
|
||||||
|
click = false;
|
||||||
|
this.focusedItem(item);
|
||||||
|
|
||||||
|
if (this.selectedItem() && item !== this.selectedItem())
|
||||||
|
{
|
||||||
|
this.selectedItem().checked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
item.checked(!item.checked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (click)
|
||||||
|
{
|
||||||
|
this.selectMessageItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
on(eventName, callback) {
|
||||||
|
this.oCallbacks[eventName] = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectMessageItem(messageItem) {
|
||||||
|
this.focusedItem(messageItem);
|
||||||
|
this.selectedItem(messageItem);
|
||||||
|
this.scrollToFocused();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {Selector, Selector as default};
|
||||||
|
module.exports = Selector;
|
||||||
|
|
@ -7,9 +7,11 @@ import Globals from 'Common/Globals';
|
||||||
|
|
||||||
class Translator
|
class Translator
|
||||||
{
|
{
|
||||||
|
data = {};
|
||||||
|
notificationI18N = {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.data = window['rainloopI18N'] || {};
|
this.data = window['rainloopI18N'] || {};
|
||||||
this.notificationI18N = {};
|
|
||||||
this.trigger = ko.observable(false);
|
this.trigger = ko.observable(false);
|
||||||
this.i18n = _.bind(this.i18n, this);
|
this.i18n = _.bind(this.i18n, this);
|
||||||
this.init();
|
this.init();
|
||||||
|
|
@ -185,7 +187,7 @@ class Translator
|
||||||
|
|
||||||
this.notificationI18N = this.notificationI18N || {};
|
this.notificationI18N = this.notificationI18N || {};
|
||||||
|
|
||||||
_.each(map, (item) => {
|
map.forEach((item) => {
|
||||||
this.notificationI18N[item[0]] = this.i18n(item[1]);
|
this.notificationI18N[item[0]] = this.i18n(item[1]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ import {AbstractComponent} from 'Component/Abstract';
|
||||||
class AbstracCheckbox extends AbstractComponent
|
class AbstracCheckbox extends AbstractComponent
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param {Object} params
|
* @param {Object} params = {}
|
||||||
*/
|
*/
|
||||||
constructor(params) {
|
constructor(params = {}) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,7 @@ class AbstracRadio extends AbstractComponent
|
||||||
if (params.values)
|
if (params.values)
|
||||||
{
|
{
|
||||||
this.values(_.map(params.values, (label, value) => {
|
this.values(_.map(params.values, (label, value) => {
|
||||||
return {
|
return {'label': label, 'value': value};
|
||||||
'label': label,
|
|
||||||
'value': value
|
|
||||||
};
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
|
|
||||||
import {_} from 'common';
|
import {$} from 'common';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import Utils from 'Common/Utils';
|
import Utils from 'Common/Utils';
|
||||||
|
|
||||||
class AbstractComponent
|
class AbstractComponent
|
||||||
{
|
{
|
||||||
constructor() {
|
disposable = [];
|
||||||
this.disposable = [];
|
|
||||||
}
|
constructor() {}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
_.each(this.disposable, (funcToDispose) => {
|
this.disposable.forEach((funcToDispose) => {
|
||||||
if (funcToDispose && funcToDispose.dispose)
|
if (funcToDispose && funcToDispose.dispose)
|
||||||
{
|
{
|
||||||
funcToDispose.dispose();
|
funcToDispose.dispose();
|
||||||
|
|
@ -21,10 +21,10 @@ class AbstractComponent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} ClassObject
|
* @param {*} ClassObject
|
||||||
* @param {string} templateID
|
* @param {string} templateID = ''
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
const componentExportHelper = (ClassObject, templateID) => {
|
const componentExportHelper = (ClassObject, templateID = '') => {
|
||||||
return {
|
return {
|
||||||
template: templateID ? {element: templateID} : '<b></b>',
|
template: templateID ? {element: templateID} : '<b></b>',
|
||||||
viewModel: {
|
viewModel: {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class ScriptComponent extends AbstractComponent
|
||||||
params.element[0] && params.element[0].outerHTML)
|
params.element[0] && params.element[0].outerHTML)
|
||||||
{
|
{
|
||||||
let script = params.element[0].outerHTML;
|
let script = params.element[0].outerHTML;
|
||||||
script = script
|
script = !script ? '' : script
|
||||||
.replace(/<x-script/i, '<script')
|
.replace(/<x-script/i, '<script')
|
||||||
.replace(/<b><\/b><\/x-script>/i, '</script>')
|
.replace(/<b><\/b><\/x-script>/i, '</script>')
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AbstractBoot()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractBoot.prototype.bootstart = function ()
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = AbstractBoot;
|
|
||||||
|
|
||||||
}());
|
|
||||||
7
dev/Knoin/AbstractBoot.jsx
Normal file
7
dev/Knoin/AbstractBoot.jsx
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
class AbstractBoot
|
||||||
|
{
|
||||||
|
bootstart(Remote) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {AbstractBoot, AbstractBoot as default};
|
||||||
|
|
@ -479,7 +479,7 @@
|
||||||
}
|
}
|
||||||
else if (SettingsStore.useThreads())
|
else if (SettingsStore.useThreads())
|
||||||
{
|
{
|
||||||
require('App/User').reloadFlagsCurrentMessageListAndMessageFromCache();
|
require('App/User').default.default.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
LoginAdminScreen.prototype.onShow = function ()
|
LoginAdminScreen.prototype.onShow = function ()
|
||||||
{
|
{
|
||||||
require('App/Admin').setWindowTitle('');
|
require('App/Admin').default.setWindowTitle('');
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = LoginAdminScreen;
|
module.exports = LoginAdminScreen;
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@
|
||||||
|
|
||||||
SettingsAdminScreen.prototype.onShow = function ()
|
SettingsAdminScreen.prototype.onShow = function ()
|
||||||
{
|
{
|
||||||
require('App/Admin').setWindowTitle('');
|
require('App/Admin').default.setWindowTitle('');
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = SettingsAdminScreen;
|
module.exports = SettingsAdminScreen;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
AboutUserScreen.prototype.onShow = function ()
|
AboutUserScreen.prototype.onShow = function ()
|
||||||
{
|
{
|
||||||
require('App/User').setWindowTitle('RainLoop');
|
require('App/User').default.setWindowTitle('RainLoop');
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = AboutUserScreen;
|
module.exports = AboutUserScreen;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
LoginUserScreen.prototype.onShow = function ()
|
LoginUserScreen.prototype.onShow = function ()
|
||||||
{
|
{
|
||||||
require('App/User').setWindowTitle('');
|
require('App/User').default.setWindowTitle('');
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = LoginUserScreen;
|
module.exports = LoginUserScreen;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
nFoldersInboxUnreadCount = 0;
|
nFoldersInboxUnreadCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
require('App/User').setWindowTitle(('' === sEmail ? '' : '' +
|
require('App/User').default.setWindowTitle(('' === sEmail ? '' : '' +
|
||||||
(0 < nFoldersInboxUnreadCount ? '(' + nFoldersInboxUnreadCount + ') ' : ' ') +
|
(0 < nFoldersInboxUnreadCount ? '(' + nFoldersInboxUnreadCount + ') ' : ' ') +
|
||||||
sEmail + ' - ') + Translator.i18n('TITLES/MAILBOX'));
|
sEmail + ' - ') + Translator.i18n('TITLES/MAILBOX'));
|
||||||
};
|
};
|
||||||
|
|
@ -109,7 +109,7 @@
|
||||||
MessageStore.messageListSearch(sSearch);
|
MessageStore.messageListSearch(sSearch);
|
||||||
MessageStore.messageListThreadUid(sThreadUid);
|
MessageStore.messageListThreadUid(sThreadUid);
|
||||||
|
|
||||||
require('App/User').reloadMessageList();
|
require('App/User').default.reloadMessageList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@
|
||||||
if (!Globals.bMobileDevice)
|
if (!Globals.bMobileDevice)
|
||||||
{
|
{
|
||||||
_.defer(function () {
|
_.defer(function () {
|
||||||
require('App/User').initHorizontalLayoutResizer(Enums.ClientSideKeyName.MessageListSize);
|
require('App/User').default.initHorizontalLayoutResizer(Enums.ClientSideKeyName.MessageListSize);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@
|
||||||
SettingsUserScreen.prototype.setSettingsTitle = function ()
|
SettingsUserScreen.prototype.setSettingsTitle = function ()
|
||||||
{
|
{
|
||||||
var sEmail = AccountStore.email();
|
var sEmail = AccountStore.email();
|
||||||
require('App/User').setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle);
|
require('App/User').default.setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = SettingsUserScreen;
|
module.exports = SettingsUserScreen;
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@
|
||||||
{
|
{
|
||||||
if (this.access() && !this.community)
|
if (this.access() && !this.community)
|
||||||
{
|
{
|
||||||
require('App/Admin').reloadCoreData();
|
require('App/Admin').default.reloadCoreData();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@
|
||||||
{
|
{
|
||||||
if (!this.coreUpdating() && !this.community)
|
if (!this.coreUpdating() && !this.community)
|
||||||
{
|
{
|
||||||
require('App/Admin').updateCoreData();
|
require('App/Admin').default.updateCoreData();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
require('App/Admin').reloadDomainList();
|
require('App/Admin').default.reloadDomainList();
|
||||||
};
|
};
|
||||||
|
|
||||||
DomainsAdminSettings.prototype.onDomainLoadRequest = function (sResult, oData)
|
DomainsAdminSettings.prototype.onDomainLoadRequest = function (sResult, oData)
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
|
|
||||||
DomainsAdminSettings.prototype.onDomainListChangeRequest = function ()
|
DomainsAdminSettings.prototype.onDomainListChangeRequest = function ()
|
||||||
{
|
{
|
||||||
require('App/Admin').reloadDomainList();
|
require('App/Admin').default.reloadDomainList();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = DomainsAdminSettings;
|
module.exports = DomainsAdminSettings;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
PackagesAdminSettings.prototype.onBuild = function ()
|
PackagesAdminSettings.prototype.onBuild = function ()
|
||||||
{
|
{
|
||||||
require('App/Admin').reloadPackagesList();
|
require('App/Admin').default.reloadPackagesList();
|
||||||
};
|
};
|
||||||
|
|
||||||
PackagesAdminSettings.prototype.requestHelper = function (oPackage, bInstall)
|
PackagesAdminSettings.prototype.requestHelper = function (oPackage, bInstall)
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
require('App/Admin').reloadPackagesList();
|
require('App/Admin').default.reloadPackagesList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@
|
||||||
PluginsAdminSettings.prototype.onShow = function ()
|
PluginsAdminSettings.prototype.onShow = function ()
|
||||||
{
|
{
|
||||||
PluginStore.plugins.error('');
|
PluginStore.plugins.error('');
|
||||||
require('App/Admin').reloadPluginList();
|
require('App/Admin').default.reloadPluginList();
|
||||||
};
|
};
|
||||||
|
|
||||||
PluginsAdminSettings.prototype.onPluginLoadRequest = function (sResult, oData)
|
PluginsAdminSettings.prototype.onPluginLoadRequest = function (sResult, oData)
|
||||||
|
|
@ -109,7 +109,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require('App/Admin').reloadPluginList();
|
require('App/Admin').default.reloadPluginList();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = PluginsAdminSettings;
|
module.exports = PluginsAdminSettings;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
require('App/User').accountsAndIdentities();
|
require('App/User').default.accountsAndIdentities();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, oAccountToRemove.email);
|
}, oAccountToRemove.email);
|
||||||
|
|
@ -124,7 +124,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
Remote.identityDelete(function () {
|
Remote.identityDelete(function () {
|
||||||
require('App/User').accountsAndIdentities();
|
require('App/User').default.accountsAndIdentities();
|
||||||
}, oIdentityToRemove.id);
|
}, oIdentityToRemove.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@
|
||||||
this.passwordUpdateSuccess(true);
|
this.passwordUpdateSuccess(true);
|
||||||
this.currentPassword.error(false);
|
this.currentPassword.error(false);
|
||||||
|
|
||||||
require('App/User').setClientSideToken(oData.Result);
|
require('App/User').default.setClientSideToken(oData.Result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
{
|
{
|
||||||
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
|
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
|
||||||
|
|
||||||
require('App/User').foldersPromisesActionHelper(
|
require('App/User').default.foldersPromisesActionHelper(
|
||||||
Promises.folderRename(oFolder.fullNameRaw, sEditName, FolderStore.foldersRenaming),
|
Promises.folderRename(oFolder.fullNameRaw, sEditName, FolderStore.foldersRenaming),
|
||||||
Enums.Notification.CantRenameFolder);
|
Enums.Notification.CantRenameFolder);
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@
|
||||||
|
|
||||||
FolderStore.folderList.remove(fRemoveFolder);
|
FolderStore.folderList.remove(fRemoveFolder);
|
||||||
|
|
||||||
require('App/User').foldersPromisesActionHelper(
|
require('App/User').default.foldersPromisesActionHelper(
|
||||||
Promises.folderDelete(oFolderToRemove.fullNameRaw, FolderStore.foldersDeleting),
|
Promises.folderDelete(oFolderToRemove.fullNameRaw, FolderStore.foldersDeleting),
|
||||||
Enums.Notification.CantDeleteFolder);
|
Enums.Notification.CantDeleteFolder);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
PgpStore.openpgpKeyring.store();
|
PgpStore.openpgpKeyring.store();
|
||||||
}
|
}
|
||||||
|
|
||||||
require('App/User').reloadOpenPgpKeys();
|
require('App/User').default.reloadOpenPgpKeys();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,40 +38,40 @@
|
||||||
this.connectGoogle = Utils.createCommand(this, function () {
|
this.connectGoogle = Utils.createCommand(this, function () {
|
||||||
if (!this.googleLoggined())
|
if (!this.googleLoggined())
|
||||||
{
|
{
|
||||||
require('App/User').googleConnect();
|
require('App/User').default.googleConnect();
|
||||||
}
|
}
|
||||||
}, function () {
|
}, function () {
|
||||||
return !this.googleLoggined() && !this.googleActions();
|
return !this.googleLoggined() && !this.googleActions();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.disconnectGoogle = Utils.createCommand(this, function () {
|
this.disconnectGoogle = Utils.createCommand(this, function () {
|
||||||
require('App/User').googleDisconnect();
|
require('App/User').default.googleDisconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.connectFacebook = Utils.createCommand(this, function () {
|
this.connectFacebook = Utils.createCommand(this, function () {
|
||||||
if (!this.facebookLoggined())
|
if (!this.facebookLoggined())
|
||||||
{
|
{
|
||||||
require('App/User').facebookConnect();
|
require('App/User').default.facebookConnect();
|
||||||
}
|
}
|
||||||
}, function () {
|
}, function () {
|
||||||
return !this.facebookLoggined() && !this.facebookActions();
|
return !this.facebookLoggined() && !this.facebookActions();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.disconnectFacebook = Utils.createCommand(this, function () {
|
this.disconnectFacebook = Utils.createCommand(this, function () {
|
||||||
require('App/User').facebookDisconnect();
|
require('App/User').default.facebookDisconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.connectTwitter = Utils.createCommand(this, function () {
|
this.connectTwitter = Utils.createCommand(this, function () {
|
||||||
if (!this.twitterLoggined())
|
if (!this.twitterLoggined())
|
||||||
{
|
{
|
||||||
require('App/User').twitterConnect();
|
require('App/User').default.twitterConnect();
|
||||||
}
|
}
|
||||||
}, function () {
|
}, function () {
|
||||||
return !this.twitterLoggined() && !this.twitterActions();
|
return !this.twitterLoggined() && !this.twitterActions();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.disconnectTwitter = Utils.createCommand(this, function () {
|
this.disconnectTwitter = Utils.createCommand(this, function () {
|
||||||
require('App/User').twitterDisconnect();
|
require('App/User').default.twitterDisconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
|
|
||||||
TemplatesUserSettings.prototype.reloadTemplates = function ()
|
TemplatesUserSettings.prototype.reloadTemplates = function ()
|
||||||
{
|
{
|
||||||
require('App/User').templates();
|
require('App/User').default.templates();
|
||||||
};
|
};
|
||||||
|
|
||||||
TemplatesUserSettings.prototype.onBuild = function (oDom)
|
TemplatesUserSettings.prototype.onBuild = function (oDom)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ import {LocalStorage} from 'Common/ClientStorageDriver/LocalStorage';
|
||||||
class ClientStorage
|
class ClientStorage
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
const SupportedStorageDriver = _.find([LocalStorage, Cookie], (StorageDriver) => StorageDriver && StorageDriver.supported());
|
const SupportedStorageDriver = _.find([LocalStorage, Cookie],
|
||||||
|
(StorageDriver) => StorageDriver && StorageDriver.supported());
|
||||||
this.driver = SupportedStorageDriver ? new SupportedStorageDriver() : null;
|
this.driver = SupportedStorageDriver ? new SupportedStorageDriver() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,11 @@
|
||||||
|
|
||||||
(function () {
|
import ko from 'ko';
|
||||||
|
import Globals from 'Common/Globals';
|
||||||
|
import Settings from 'Storage/Settings';
|
||||||
|
|
||||||
'use strict';
|
class AbstractAppStore
|
||||||
|
{
|
||||||
var
|
constructor()
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Globals = require('Common/Globals'),
|
|
||||||
|
|
||||||
Settings = require('Storage/Settings')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AppStore()
|
|
||||||
{
|
{
|
||||||
this.allowLanguagesOnSettings = ko.observable(true);
|
this.allowLanguagesOnSettings = ko.observable(true);
|
||||||
this.allowLanguagesOnLogin = ko.observable(true);
|
this.allowLanguagesOnLogin = ko.observable(true);
|
||||||
|
|
@ -22,7 +13,7 @@
|
||||||
this.interfaceAnimation = ko.observable(true);
|
this.interfaceAnimation = ko.observable(true);
|
||||||
|
|
||||||
this.interfaceAnimation.subscribe(function (bValue) {
|
this.interfaceAnimation.subscribe(function (bValue) {
|
||||||
var bAnim = Globals.bMobileDevice || !bValue;
|
const bAnim = Globals.bMobileDevice || !bValue;
|
||||||
Globals.$html.toggleClass('rl-anim', !bAnim).toggleClass('no-rl-anim', bAnim);
|
Globals.$html.toggleClass('rl-anim', !bAnim).toggleClass('no-rl-anim', bAnim);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -32,8 +23,7 @@
|
||||||
this.community = ko.observable(true);
|
this.community = ko.observable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppStore.prototype.populate = function()
|
populate() {
|
||||||
{
|
|
||||||
this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin'));
|
this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin'));
|
||||||
this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings'));
|
this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings'));
|
||||||
|
|
||||||
|
|
@ -41,8 +31,7 @@
|
||||||
|
|
||||||
this.prem(!!Settings.settingsGet('PremType'));
|
this.prem(!!Settings.settingsGet('PremType'));
|
||||||
this.community(!!Settings.settingsGet('Community'));
|
this.community(!!Settings.settingsGet('Community'));
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = AppStore;
|
export {AbstractAppStore, AbstractAppStore as default};
|
||||||
|
|
||||||
}());
|
|
||||||
|
|
@ -1,22 +1,14 @@
|
||||||
|
|
||||||
(function () {
|
import ko from 'ko';
|
||||||
|
import Settings from 'Storage/Settings';
|
||||||
|
|
||||||
'use strict';
|
import {AbstractAppStore} from 'Stores/AbstractApp';
|
||||||
|
|
||||||
var
|
class AppAdminStore extends AbstractAppStore
|
||||||
ko = require('ko'),
|
{
|
||||||
|
constructor()
|
||||||
Settings = require('Storage/Settings'),
|
|
||||||
|
|
||||||
AppStore = require('Stores/App')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AppAdminStore()
|
|
||||||
{
|
{
|
||||||
AppStore.call(this);
|
super();
|
||||||
|
|
||||||
this.determineUserLanguage = ko.observable(false);
|
this.determineUserLanguage = ko.observable(false);
|
||||||
this.determineUserDomain = ko.observable(false);
|
this.determineUserDomain = ko.observable(false);
|
||||||
|
|
@ -25,9 +17,9 @@
|
||||||
this.useLocalProxyForExternalImages = ko.observable(false);
|
this.useLocalProxyForExternalImages = ko.observable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppAdminStore.prototype.populate = function()
|
populate() {
|
||||||
{
|
|
||||||
AppStore.prototype.populate.call(this);
|
super.populate();
|
||||||
|
|
||||||
this.determineUserLanguage(!!Settings.settingsGet('DetermineUserLanguage'));
|
this.determineUserLanguage(!!Settings.settingsGet('DetermineUserLanguage'));
|
||||||
this.determineUserDomain(!!Settings.settingsGet('DetermineUserDomain'));
|
this.determineUserDomain(!!Settings.settingsGet('DetermineUserDomain'));
|
||||||
|
|
@ -35,7 +27,6 @@
|
||||||
this.weakPassword(!!Settings.settingsGet('WeakPassword'));
|
this.weakPassword(!!Settings.settingsGet('WeakPassword'));
|
||||||
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
|
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new AppAdminStore();
|
module.exports = new AppAdminStore();
|
||||||
|
|
||||||
}());
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var
|
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
|
||||||
Globals = require('Common/Globals'),
|
|
||||||
Utils = require('Common/Utils'),
|
|
||||||
|
|
||||||
Settings = require('Storage/Settings'),
|
|
||||||
|
|
||||||
AppStore = require('Stores/App')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AppUserStore()
|
|
||||||
{
|
|
||||||
AppStore.call(this);
|
|
||||||
|
|
||||||
this.currentAudio = ko.observable('');
|
|
||||||
|
|
||||||
this.focusedState = ko.observable(Enums.Focused.None);
|
|
||||||
|
|
||||||
this.focusedState.subscribe(function (mValue) {
|
|
||||||
|
|
||||||
switch (mValue)
|
|
||||||
{
|
|
||||||
case Enums.Focused.MessageList:
|
|
||||||
Globals.keyScope(Enums.KeyState.MessageList);
|
|
||||||
break;
|
|
||||||
case Enums.Focused.MessageView:
|
|
||||||
Globals.keyScope(Enums.KeyState.MessageView);
|
|
||||||
break;
|
|
||||||
case Enums.Focused.FolderList:
|
|
||||||
Globals.keyScope(Enums.KeyState.FolderList);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.projectHash = ko.observable('');
|
|
||||||
this.threadsAllowed = ko.observable(false);
|
|
||||||
|
|
||||||
this.composeInEdit = ko.observable(false);
|
|
||||||
|
|
||||||
this.contactsAutosave = ko.observable(false);
|
|
||||||
this.useLocalProxyForExternalImages = ko.observable(false);
|
|
||||||
|
|
||||||
this.contactsIsAllowed = ko.observable(false);
|
|
||||||
|
|
||||||
this.attachmentsActions = ko.observableArray([]);
|
|
||||||
|
|
||||||
this.devEmail = '';
|
|
||||||
this.devPassword = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
AppUserStore.prototype.populate = function()
|
|
||||||
{
|
|
||||||
AppStore.prototype.populate.call(this);
|
|
||||||
|
|
||||||
this.projectHash(Settings.settingsGet('ProjectHash'));
|
|
||||||
|
|
||||||
this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave'));
|
|
||||||
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
|
|
||||||
|
|
||||||
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
|
|
||||||
|
|
||||||
var mAttachmentsActions = Settings.settingsGet('AttachmentsActions');
|
|
||||||
this.attachmentsActions(Utils.isNonEmptyArray(mAttachmentsActions) ? mAttachmentsActions : []);
|
|
||||||
|
|
||||||
this.devEmail = Settings.settingsGet('DevEmail');
|
|
||||||
this.devPassword = Settings.settingsGet('DevPassword');
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = new AppUserStore();
|
|
||||||
|
|
||||||
}());
|
|
||||||
72
dev/Stores/User/App.jsx
Normal file
72
dev/Stores/User/App.jsx
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
|
||||||
|
import ko from 'ko';
|
||||||
|
import {Focused, KeyState} from 'Common/Enums';
|
||||||
|
import Globals from 'Common/Globals';
|
||||||
|
import Utils from 'Common/Utils';
|
||||||
|
import Settings from 'Storage/Settings';
|
||||||
|
|
||||||
|
import {AbstractAppStore} from 'Stores/AbstractApp';
|
||||||
|
|
||||||
|
class AppUserStore extends AbstractAppStore
|
||||||
|
{
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.currentAudio = ko.observable('');
|
||||||
|
|
||||||
|
this.focusedState = ko.observable(Focused.None);
|
||||||
|
|
||||||
|
this.focusedState.subscribe(function (value) {
|
||||||
|
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case Focused.MessageList:
|
||||||
|
Globals.keyScope(KeyState.MessageList);
|
||||||
|
break;
|
||||||
|
case Focused.MessageView:
|
||||||
|
Globals.keyScope(KeyState.MessageView);
|
||||||
|
break;
|
||||||
|
case Focused.FolderList:
|
||||||
|
Globals.keyScope(KeyState.FolderList);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.projectHash = ko.observable('');
|
||||||
|
this.threadsAllowed = ko.observable(false);
|
||||||
|
|
||||||
|
this.composeInEdit = ko.observable(false);
|
||||||
|
|
||||||
|
this.contactsAutosave = ko.observable(false);
|
||||||
|
this.useLocalProxyForExternalImages = ko.observable(false);
|
||||||
|
|
||||||
|
this.contactsIsAllowed = ko.observable(false);
|
||||||
|
|
||||||
|
this.attachmentsActions = ko.observableArray([]);
|
||||||
|
|
||||||
|
this.devEmail = '';
|
||||||
|
this.devPassword = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
populate() {
|
||||||
|
|
||||||
|
super.populate();
|
||||||
|
|
||||||
|
this.projectHash(Settings.settingsGet('ProjectHash'));
|
||||||
|
|
||||||
|
this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave'));
|
||||||
|
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
|
||||||
|
|
||||||
|
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
|
||||||
|
|
||||||
|
const attachmentsActions = Settings.settingsGet('AttachmentsActions');
|
||||||
|
this.attachmentsActions(Utils.isNonEmptyArray(attachmentsActions) ? attachmentsActions : []);
|
||||||
|
|
||||||
|
this.devEmail = Settings.settingsGet('DevEmail');
|
||||||
|
this.devPassword = Settings.settingsGet('DevPassword');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new AppUserStore();
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var
|
|
||||||
_ = require('_'),
|
|
||||||
ko = require('ko')
|
|
||||||
;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function IdentityUserStore()
|
|
||||||
{
|
|
||||||
this.identities = ko.observableArray([]);
|
|
||||||
this.identities.loading = ko.observable(false).extend({'throttle': 100});
|
|
||||||
|
|
||||||
this.identitiesIDS = ko.computed(function () {
|
|
||||||
return _.compact(_.map(this.identities(), function (oItem) {
|
|
||||||
return oItem ? oItem.id : null;
|
|
||||||
}));
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = new IdentityUserStore();
|
|
||||||
|
|
||||||
}());
|
|
||||||
18
dev/Stores/User/Identity.jsx
Normal file
18
dev/Stores/User/Identity.jsx
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
import {_} from 'common';
|
||||||
|
import ko from 'ko';
|
||||||
|
|
||||||
|
class IdentityUserStore
|
||||||
|
{
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
this.identities = ko.observableArray([]);
|
||||||
|
this.identities.loading = ko.observable(false).extend({'throttle': 100});
|
||||||
|
|
||||||
|
this.identitiesIDS = ko.computed(() => {
|
||||||
|
return _.compact(_.map(this.identities(), (item) => item ? item.id : null));
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new IdentityUserStore();
|
||||||
|
|
@ -703,7 +703,7 @@
|
||||||
Cache.initMessageFlagsFromCache(oMessage);
|
Cache.initMessageFlagsFromCache(oMessage);
|
||||||
if (oMessage.unseen() || oMessage.hasUnseenSubMessage())
|
if (oMessage.unseen() || oMessage.hasUnseenSubMessage())
|
||||||
{
|
{
|
||||||
require('App/User').messageListAction(oMessage.folderFullNameRaw,
|
require('App/User').default.messageListAction(oMessage.folderFullNameRaw,
|
||||||
oMessage.uid, Enums.MessageSetAction.SetSeen, [oMessage]);
|
oMessage.uid, Enums.MessageSetAction.SetSeen, [oMessage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -928,7 +928,7 @@
|
||||||
|
|
||||||
if (oFolder && (bCached || bUnreadCountChange || SettingsStore.useThreads()))
|
if (oFolder && (bCached || bUnreadCountChange || SettingsStore.useThreads()))
|
||||||
{
|
{
|
||||||
require('App/User').folderInformation(oFolder.fullNameRaw, aList);
|
require('App/User').default.folderInformation(oFolder.fullNameRaw, aList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (oData.Result)
|
||||||
{
|
{
|
||||||
require('App/Admin').loginAndLogoutReload(true);
|
require('App/Admin').default.loginAndLogoutReload(true);
|
||||||
}
|
}
|
||||||
else if (oData.ErrorCode)
|
else if (oData.ErrorCode)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
PaneSettingsAdminView.prototype.logoutClick = function ()
|
PaneSettingsAdminView.prototype.logoutClick = function ()
|
||||||
{
|
{
|
||||||
Remote.adminLogout(function () {
|
Remote.adminLogout(function () {
|
||||||
require('App/Admin').loginAndLogoutReload(true, true);
|
require('App/Admin').default.loginAndLogoutReload(true, true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (oData.Result)
|
||||||
{
|
{
|
||||||
require('App/User').accountsAndIdentities();
|
require('App/User').default.accountsAndIdentities();
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
|
|
||||||
oOpenpgpKeyring.store();
|
oOpenpgpKeyring.store();
|
||||||
|
|
||||||
require('App/User').reloadOpenPgpKeys();
|
require('App/User').default.reloadOpenPgpKeys();
|
||||||
Utils.delegateRun(this, 'cancelCommand');
|
Utils.delegateRun(this, 'cancelCommand');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,7 @@
|
||||||
|
|
||||||
this.deleteCommand = Utils.createCommand(this, function () {
|
this.deleteCommand = Utils.createCommand(this, function () {
|
||||||
|
|
||||||
require('App/User').deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]);
|
require('App/User').default.deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]);
|
||||||
kn.hideScreenPopup(ComposePopupView);
|
kn.hideScreenPopup(ComposePopupView);
|
||||||
|
|
||||||
}, function () {
|
}, function () {
|
||||||
|
|
@ -407,7 +407,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache.setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], aFlagsCache);
|
Cache.setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], aFlagsCache);
|
||||||
require('App/User').reloadFlagsCurrentMessageListAndMessageFromCache();
|
require('App/User').default.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||||
Cache.setFolderHash(this.aDraftInfo[2], '');
|
Cache.setFolderHash(this.aDraftInfo[2], '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -616,7 +616,7 @@
|
||||||
|
|
||||||
ComposePopupView.prototype.emailsSource = function (oData, fResponse)
|
ComposePopupView.prototype.emailsSource = function (oData, fResponse)
|
||||||
{
|
{
|
||||||
require('App/User').getAutocomplete(oData.term, function (aData) {
|
require('App/User').default.getAutocomplete(oData.term, function (aData) {
|
||||||
fResponse(_.map(aData, function (oEmailItem) {
|
fResponse(_.map(aData, function (oEmailItem) {
|
||||||
return oEmailItem.toLine(false);
|
return oEmailItem.toLine(false);
|
||||||
}));
|
}));
|
||||||
|
|
@ -654,11 +654,11 @@
|
||||||
Cache.setFolderHash(sDraftFolder, '');
|
Cache.setFolderHash(sDraftFolder, '');
|
||||||
if (FolderStore.currentFolderFullNameRaw() === sDraftFolder)
|
if (FolderStore.currentFolderFullNameRaw() === sDraftFolder)
|
||||||
{
|
{
|
||||||
require('App/User').reloadMessageList(true);
|
require('App/User').default.reloadMessageList(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
require('App/User').folderInformation(sDraftFolder);
|
require('App/User').default.folderInformation(sDraftFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -371,7 +371,7 @@
|
||||||
this.syncCommand = Utils.createCommand(this, function () {
|
this.syncCommand = Utils.createCommand(this, function () {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
require('App/User').contactsSync(function (sResult, oData) {
|
require('App/User').default.contactsSync(function (sResult, oData) {
|
||||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||||
{
|
{
|
||||||
window.alert(Translator.getNotification(
|
window.alert(Translator.getNotification(
|
||||||
|
|
@ -485,12 +485,12 @@
|
||||||
|
|
||||||
ContactsPopupView.prototype.exportVcf = function ()
|
ContactsPopupView.prototype.exportVcf = function ()
|
||||||
{
|
{
|
||||||
require('App/User').download(Links.exportContactsVcf());
|
require('App/User').default.download(Links.exportContactsVcf());
|
||||||
};
|
};
|
||||||
|
|
||||||
ContactsPopupView.prototype.exportCsv = function ()
|
ContactsPopupView.prototype.exportCsv = function ()
|
||||||
{
|
{
|
||||||
require('App/User').download(Links.exportContactsCsv());
|
require('App/User').default.download(Links.exportContactsCsv());
|
||||||
};
|
};
|
||||||
|
|
||||||
ContactsPopupView.prototype.initUploader = function ()
|
ContactsPopupView.prototype.initUploader = function ()
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (oData.Result)
|
||||||
{
|
{
|
||||||
require('App/Admin').reloadDomainList();
|
require('App/Admin').default.reloadDomainList();
|
||||||
this.closeCommand();
|
this.closeCommand();
|
||||||
}
|
}
|
||||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
self.clearingProcess(false);
|
self.clearingProcess(false);
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||||
{
|
{
|
||||||
require('App/User').reloadMessageList(true);
|
require('App/User').default.reloadMessageList(true);
|
||||||
self.cancelCommand();
|
self.cancelCommand();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
sParentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1);
|
sParentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require('App/User').foldersPromisesActionHelper(
|
require('App/User').default.foldersPromisesActionHelper(
|
||||||
Promises.folderCreate(this.folderName(), sParentFolderName, FolderStore.foldersCreating),
|
Promises.folderCreate(this.folderName(), sParentFolderName, FolderStore.foldersCreating),
|
||||||
Enums.Notification.CantCreateFolder);
|
Enums.Notification.CantCreateFolder);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (oData.Result)
|
||||||
{
|
{
|
||||||
require('App/User').accountsAndIdentities();
|
require('App/User').default.accountsAndIdentities();
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
}
|
}
|
||||||
else if (oData.ErrorCode)
|
else if (oData.ErrorCode)
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
|
|
||||||
oOpenpgpKeyring.store();
|
oOpenpgpKeyring.store();
|
||||||
|
|
||||||
require('App/User').reloadOpenPgpKeys();
|
require('App/User').default.reloadOpenPgpKeys();
|
||||||
Utils.delegateRun(self, 'cancelCommand');
|
Utils.delegateRun(self, 'cancelCommand');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (oData.Result)
|
||||||
{
|
{
|
||||||
require('App/User').templates();
|
require('App/User').default.templates();
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
}
|
}
|
||||||
else if (oData.ErrorCode)
|
else if (oData.ErrorCode)
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@
|
||||||
|
|
||||||
TwoFactorConfigurationPopupView.prototype.logout = function ()
|
TwoFactorConfigurationPopupView.prototype.logout = function ()
|
||||||
{
|
{
|
||||||
require('App/User').logout();
|
require('App/User').default.logout();
|
||||||
};
|
};
|
||||||
|
|
||||||
TwoFactorConfigurationPopupView.prototype.testTwoFactor = function ()
|
TwoFactorConfigurationPopupView.prototype.testTwoFactor = function ()
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@
|
||||||
|
|
||||||
AbstractSystemDropDownUserView.prototype.logoutClick = function ()
|
AbstractSystemDropDownUserView.prototype.logoutClick = function ()
|
||||||
{
|
{
|
||||||
require('App/User').logout();
|
require('App/User').default.logout();
|
||||||
};
|
};
|
||||||
|
|
||||||
AbstractSystemDropDownUserView.prototype.onBuild = function ()
|
AbstractSystemDropDownUserView.prototype.onBuild = function ()
|
||||||
|
|
|
||||||
|
|
@ -215,11 +215,11 @@
|
||||||
}
|
}
|
||||||
else if (oData.Admin)
|
else if (oData.Admin)
|
||||||
{
|
{
|
||||||
require('App/User').redirectToAdminPanel();
|
require('App/User').default.redirectToAdminPanel();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
require('App/User').loginAndLogoutReload(false);
|
require('App/User').default.loginAndLogoutReload(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (oData.ErrorCode)
|
else if (oData.ErrorCode)
|
||||||
|
|
@ -399,7 +399,7 @@
|
||||||
if (0 === iErrorCode)
|
if (0 === iErrorCode)
|
||||||
{
|
{
|
||||||
self.submitRequest(true);
|
self.submitRequest(true);
|
||||||
require('App/User').loginAndLogoutReload(false);
|
require('App/User').default.loginAndLogoutReload(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
if (oFolder && oEvent)
|
if (oFolder && oEvent)
|
||||||
{
|
{
|
||||||
bCollapsed = oFolder.collapsed();
|
bCollapsed = oFolder.collapsed();
|
||||||
require('App/User').setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||||
|
|
||||||
oFolder.collapsed(!bCollapsed);
|
oFolder.collapsed(!bCollapsed);
|
||||||
oEvent.preventDefault();
|
oEvent.preventDefault();
|
||||||
|
|
@ -167,7 +167,7 @@
|
||||||
if (oFolder)
|
if (oFolder)
|
||||||
{
|
{
|
||||||
bCollapsed = oFolder.collapsed();
|
bCollapsed = oFolder.collapsed();
|
||||||
require('App/User').setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||||
oFolder.collapsed(!bCollapsed);
|
oFolder.collapsed(!bCollapsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -196,7 +196,7 @@
|
||||||
{
|
{
|
||||||
this.iDropOverTimer = window.setTimeout(function () {
|
this.iDropOverTimer = window.setTimeout(function () {
|
||||||
oFolder.collapsed(false);
|
oFolder.collapsed(false);
|
||||||
require('App/User').setExpandedFolder(oFolder.fullNameHash, true);
|
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, true);
|
||||||
Utils.windowResize();
|
Utils.windowResize();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
@ -256,7 +256,7 @@
|
||||||
|
|
||||||
if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
|
if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
|
||||||
{
|
{
|
||||||
require('App/User').moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
|
require('App/User').default.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -222,32 +222,32 @@
|
||||||
this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
|
this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
|
||||||
if (Settings.capa(Enums.Capa.DangerousActions))
|
if (Settings.capa(Enums.Capa.DangerousActions))
|
||||||
{
|
{
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||||
FolderStore.currentFolderFullNameRaw(),
|
FolderStore.currentFolderFullNameRaw(),
|
||||||
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), false);
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), false);
|
||||||
}
|
}
|
||||||
}, this.canBeMoved);
|
}, this.canBeMoved);
|
||||||
|
|
||||||
this.deleteCommand = Utils.createCommand(this, function () {
|
this.deleteCommand = Utils.createCommand(this, function () {
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||||
FolderStore.currentFolderFullNameRaw(),
|
FolderStore.currentFolderFullNameRaw(),
|
||||||
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||||
}, this.canBeMoved);
|
}, this.canBeMoved);
|
||||||
|
|
||||||
this.archiveCommand = Utils.createCommand(this, function () {
|
this.archiveCommand = Utils.createCommand(this, function () {
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Archive,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Archive,
|
||||||
FolderStore.currentFolderFullNameRaw(),
|
FolderStore.currentFolderFullNameRaw(),
|
||||||
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||||
}, this.canBeMoved);
|
}, this.canBeMoved);
|
||||||
|
|
||||||
this.spamCommand = Utils.createCommand(this, function () {
|
this.spamCommand = Utils.createCommand(this, function () {
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Spam,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Spam,
|
||||||
FolderStore.currentFolderFullNameRaw(),
|
FolderStore.currentFolderFullNameRaw(),
|
||||||
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||||
}, this.canBeMoved);
|
}, this.canBeMoved);
|
||||||
|
|
||||||
this.notSpamCommand = Utils.createCommand(this, function () {
|
this.notSpamCommand = Utils.createCommand(this, function () {
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.NotSpam,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.NotSpam,
|
||||||
FolderStore.currentFolderFullNameRaw(),
|
FolderStore.currentFolderFullNameRaw(),
|
||||||
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||||
}, this.canBeMoved);
|
}, this.canBeMoved);
|
||||||
|
|
@ -257,7 +257,7 @@
|
||||||
this.reloadCommand = Utils.createCommand(this, function () {
|
this.reloadCommand = Utils.createCommand(this, function () {
|
||||||
if (!MessageStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload)
|
if (!MessageStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload)
|
||||||
{
|
{
|
||||||
require('App/User').reloadMessageList(false, true);
|
require('App/User').default.reloadMessageList(false, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -456,7 +456,7 @@
|
||||||
{
|
{
|
||||||
if (this.canBeMoved())
|
if (this.canBeMoved())
|
||||||
{
|
{
|
||||||
require('App/User').moveMessagesToFolder(
|
require('App/User').default.moveMessagesToFolder(
|
||||||
FolderStore.currentFolderFullNameRaw(),
|
FolderStore.currentFolderFullNameRaw(),
|
||||||
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw, bCopy);
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw, bCopy);
|
||||||
}
|
}
|
||||||
|
|
@ -498,7 +498,7 @@
|
||||||
*/
|
*/
|
||||||
MessageListMailBoxUserView.prototype.setAction = function (sFolderFullNameRaw, mUid, iSetAction, aMessages)
|
MessageListMailBoxUserView.prototype.setAction = function (sFolderFullNameRaw, mUid, iSetAction, aMessages)
|
||||||
{
|
{
|
||||||
require('App/User').messageListAction(sFolderFullNameRaw, mUid, iSetAction, aMessages);
|
require('App/User').default.messageListAction(sFolderFullNameRaw, mUid, iSetAction, aMessages);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -548,7 +548,7 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
require('App/User').reloadFlagsCurrentMessageListAndMessageFromCache();
|
require('App/User').default.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1032,7 +1032,7 @@
|
||||||
|
|
||||||
}, this))
|
}, this))
|
||||||
.on('onComplete', _.bind(function () {
|
.on('onComplete', _.bind(function () {
|
||||||
require('App/User').reloadMessageList(true, true);
|
require('App/User').default.reloadMessageList(true, true);
|
||||||
}, this))
|
}, this))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@
|
||||||
if (oMessage && this.allowMessageListActions)
|
if (oMessage && this.allowMessageListActions)
|
||||||
{
|
{
|
||||||
this.message(null);
|
this.message(null);
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||||
oMessage.folderFullNameRaw, [oMessage.uid], true);
|
oMessage.folderFullNameRaw, [oMessage.uid], true);
|
||||||
}
|
}
|
||||||
}, this.messageVisibility);
|
}, this.messageVisibility);
|
||||||
|
|
@ -236,7 +236,7 @@
|
||||||
if (oMessage && this.allowMessageListActions)
|
if (oMessage && this.allowMessageListActions)
|
||||||
{
|
{
|
||||||
this.message(null);
|
this.message(null);
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||||
oMessage.folderFullNameRaw, [oMessage.uid], false);
|
oMessage.folderFullNameRaw, [oMessage.uid], false);
|
||||||
}
|
}
|
||||||
}, this.messageVisibility);
|
}, this.messageVisibility);
|
||||||
|
|
@ -246,7 +246,7 @@
|
||||||
if (oMessage && this.allowMessageListActions)
|
if (oMessage && this.allowMessageListActions)
|
||||||
{
|
{
|
||||||
this.message(null);
|
this.message(null);
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Archive,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Archive,
|
||||||
oMessage.folderFullNameRaw, [oMessage.uid], true);
|
oMessage.folderFullNameRaw, [oMessage.uid], true);
|
||||||
}
|
}
|
||||||
}, this.messageVisibility);
|
}, this.messageVisibility);
|
||||||
|
|
@ -256,7 +256,7 @@
|
||||||
if (oMessage && this.allowMessageListActions)
|
if (oMessage && this.allowMessageListActions)
|
||||||
{
|
{
|
||||||
this.message(null);
|
this.message(null);
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Spam,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.Spam,
|
||||||
oMessage.folderFullNameRaw, [oMessage.uid], true);
|
oMessage.folderFullNameRaw, [oMessage.uid], true);
|
||||||
}
|
}
|
||||||
}, this.messageVisibility);
|
}, this.messageVisibility);
|
||||||
|
|
@ -266,7 +266,7 @@
|
||||||
if (oMessage && this.allowMessageListActions)
|
if (oMessage && this.allowMessageListActions)
|
||||||
{
|
{
|
||||||
this.message(null);
|
this.message(null);
|
||||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.NotSpam,
|
require('App/User').default.deleteMessagesFromFolder(Enums.FolderType.NotSpam,
|
||||||
oMessage.folderFullNameRaw, [oMessage.uid], true);
|
oMessage.folderFullNameRaw, [oMessage.uid], true);
|
||||||
}
|
}
|
||||||
}, this.messageVisibility);
|
}, this.messageVisibility);
|
||||||
|
|
@ -746,14 +746,14 @@
|
||||||
|
|
||||||
if (oAttachment && oAttachment.download)
|
if (oAttachment && oAttachment.download)
|
||||||
{
|
{
|
||||||
require('App/User').download(oAttachment.linkDownload());
|
require('App/User').default.download(oAttachment.linkDownload());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on('click', '.messageItemHeader .subjectParent .flagParent', function () {
|
.on('click', '.messageItemHeader .subjectParent .flagParent', function () {
|
||||||
var oMessage = self.message();
|
var oMessage = self.message();
|
||||||
if (oMessage)
|
if (oMessage)
|
||||||
{
|
{
|
||||||
require('App/User').messageListAction(oMessage.folderFullNameRaw, oMessage.uid,
|
require('App/User').default.messageListAction(oMessage.folderFullNameRaw, oMessage.uid,
|
||||||
oMessage.flagged() ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oMessage]);
|
oMessage.flagged() ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oMessage]);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -761,7 +761,7 @@
|
||||||
var oMessage = ko.dataFor(this);
|
var oMessage = ko.dataFor(this);
|
||||||
if (oMessage && oMessage.folder && oMessage.uid)
|
if (oMessage && oMessage.folder && oMessage.uid)
|
||||||
{
|
{
|
||||||
require('App/User').messageListAction(
|
require('App/User').default.messageListAction(
|
||||||
oMessage.folder, oMessage.uid,
|
oMessage.folder, oMessage.uid,
|
||||||
oMessage.flagged() ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oMessage]);
|
oMessage.flagged() ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oMessage]);
|
||||||
}
|
}
|
||||||
|
|
@ -1060,7 +1060,7 @@
|
||||||
if (oResult && oResult.Result && oResult.Result.Files &&
|
if (oResult && oResult.Result && oResult.Result.Files &&
|
||||||
oResult.Result.Files[0] && oResult.Result.Files[0].Hash)
|
oResult.Result.Files[0] && oResult.Result.Files[0].Hash)
|
||||||
{
|
{
|
||||||
require('App/User').download(
|
require('App/User').default.download(
|
||||||
Links.attachmentDownload(oResult.Result.Files[0].Hash));
|
Links.attachmentDownload(oResult.Result.Files[0].Hash));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1197,7 +1197,7 @@
|
||||||
|
|
||||||
Cache.storeMessageFlagsToCache(oMessage);
|
Cache.storeMessageFlagsToCache(oMessage);
|
||||||
|
|
||||||
require('App/User').reloadFlagsCurrentMessageListAndMessageFromCache();
|
require('App/User').default.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.checkHeaderHeight();
|
this.checkHeaderHeight();
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
require('bootstrap')(require('App/Admin'));
|
|
||||||
5
dev/admin.jsx
Normal file
5
dev/admin.jsx
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
import bootstrap from 'bootstrap';
|
||||||
|
import App from 'App/Admin';
|
||||||
|
|
||||||
|
bootstrap(App);
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
require('bootstrap')(require('App/User'));
|
|
||||||
5
dev/app.jsx
Normal file
5
dev/app.jsx
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
import bootstrap from 'bootstrap';
|
||||||
|
import App from 'App/User';
|
||||||
|
|
||||||
|
bootstrap(App);
|
||||||
92
dev/bootstrap.js
vendored
92
dev/bootstrap.js
vendored
|
|
@ -1,92 +0,0 @@
|
||||||
|
|
||||||
(function () {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = function (App) {
|
|
||||||
|
|
||||||
var
|
|
||||||
window = require('window'),
|
|
||||||
_ = require('_'),
|
|
||||||
$ = require('$'),
|
|
||||||
|
|
||||||
Globals = require('Common/Globals'),
|
|
||||||
Plugins = require('Common/Plugins'),
|
|
||||||
Utils = require('Common/Utils'),
|
|
||||||
Enums = require('Common/Enums'),
|
|
||||||
Translator = require('Common/Translator'),
|
|
||||||
|
|
||||||
EmailModel = require('Model/Email')
|
|
||||||
;
|
|
||||||
|
|
||||||
Globals.__APP__ = App;
|
|
||||||
|
|
||||||
Globals.$win
|
|
||||||
.keydown(Utils.kill_CtrlA_CtrlS)
|
|
||||||
.unload(function () {
|
|
||||||
Globals.bUnload = true;
|
|
||||||
})
|
|
||||||
;
|
|
||||||
|
|
||||||
Globals.$html
|
|
||||||
.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile')
|
|
||||||
.on('click.dropdown.data-api', function () {
|
|
||||||
Utils.detectDropdownVisibility();
|
|
||||||
})
|
|
||||||
;
|
|
||||||
|
|
||||||
// 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']['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;
|
|
||||||
|
|
||||||
window['__APP_BOOT'] = function (fCall) {
|
|
||||||
|
|
||||||
$(_.delay(function () {
|
|
||||||
|
|
||||||
if (!$('#rl-check').is(':visible'))
|
|
||||||
{
|
|
||||||
Globals.$html.addClass('no-css');
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#rl-check').remove();
|
|
||||||
|
|
||||||
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
|
|
||||||
{
|
|
||||||
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
|
|
||||||
|
|
||||||
_.delay(function () {
|
|
||||||
|
|
||||||
App.bootstart();
|
|
||||||
|
|
||||||
Globals.$html
|
|
||||||
.removeClass('no-js rl-booted-trigger')
|
|
||||||
.addClass('rl-booted')
|
|
||||||
;
|
|
||||||
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fCall(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
window['__APP_BOOT'] = null;
|
|
||||||
|
|
||||||
}, 10));
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}());
|
|
||||||
85
dev/bootstrap.jsx
Normal file
85
dev/bootstrap.jsx
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
|
||||||
|
export default (App) => {
|
||||||
|
|
||||||
|
const
|
||||||
|
window = require('window'),
|
||||||
|
_ = require('_'),
|
||||||
|
$ = require('$'),
|
||||||
|
|
||||||
|
Globals = require('Common/Globals'),
|
||||||
|
Plugins = require('Common/Plugins'),
|
||||||
|
Utils = require('Common/Utils'),
|
||||||
|
Enums = require('Common/Enums'),
|
||||||
|
Translator = require('Common/Translator'),
|
||||||
|
|
||||||
|
EmailModel = require('Model/Email')
|
||||||
|
;
|
||||||
|
|
||||||
|
Globals.__APP__ = App;
|
||||||
|
|
||||||
|
Globals.$win
|
||||||
|
.keydown(Utils.kill_CtrlA_CtrlS)
|
||||||
|
.unload(function () {
|
||||||
|
Globals.bUnload = true;
|
||||||
|
})
|
||||||
|
;
|
||||||
|
|
||||||
|
Globals.$html
|
||||||
|
.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile')
|
||||||
|
.on('click.dropdown.data-api', function () {
|
||||||
|
Utils.detectDropdownVisibility();
|
||||||
|
})
|
||||||
|
;
|
||||||
|
|
||||||
|
// 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']['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;
|
||||||
|
|
||||||
|
window['__APP_BOOT'] = function (fCall) {
|
||||||
|
|
||||||
|
$(_.delay(function () {
|
||||||
|
|
||||||
|
if (!$('#rl-check').is(':visible'))
|
||||||
|
{
|
||||||
|
Globals.$html.addClass('no-css');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#rl-check').remove();
|
||||||
|
|
||||||
|
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
|
||||||
|
{
|
||||||
|
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
|
||||||
|
|
||||||
|
_.delay(function () {
|
||||||
|
|
||||||
|
App.bootstart();
|
||||||
|
|
||||||
|
Globals.$html
|
||||||
|
.removeClass('no-js rl-booted-trigger')
|
||||||
|
.addClass('rl-booted')
|
||||||
|
;
|
||||||
|
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fCall(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
window['__APP_BOOT'] = null;
|
||||||
|
|
||||||
|
}, 10));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -48,7 +48,10 @@
|
||||||
"babel-core": "^6.1.4",
|
"babel-core": "^6.1.4",
|
||||||
"babel-eslint": "^4.1.5",
|
"babel-eslint": "^4.1.5",
|
||||||
"babel-loader": "^6.1.0",
|
"babel-loader": "^6.1.0",
|
||||||
|
"babel-plugin-transform-runtime": "^6.1.18",
|
||||||
"babel-preset-es2015": "^6.1.4",
|
"babel-preset-es2015": "^6.1.4",
|
||||||
|
"babel-preset-stage-0": "^6.1.18",
|
||||||
|
"babel-runtime": "^6.1.18",
|
||||||
"eslint": "^1.9.0",
|
"eslint": "^1.9.0",
|
||||||
"gulp": "~3.9.0",
|
"gulp": "~3.9.0",
|
||||||
"gulp-autoprefixer": "*",
|
"gulp-autoprefixer": "*",
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
var webpack = require('webpack');
|
|
||||||
|
var
|
||||||
|
path = require('path'),
|
||||||
|
webpack = require('webpack')
|
||||||
|
;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
'app': __dirname + '/dev/app.js',
|
'app': __dirname + '/dev/app.jsx',
|
||||||
'admin': __dirname + '/dev/admin.js'
|
'admin': __dirname + '/dev/admin.jsx'
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
pathinfo: true,
|
pathinfo: true,
|
||||||
|
|
@ -18,7 +22,7 @@ module.exports = {
|
||||||
new webpack.optimize.OccurenceOrderPlugin()
|
new webpack.optimize.OccurenceOrderPlugin()
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
modulesDirectories: [__dirname + '/dev/'],
|
root: path.resolve(__dirname, 'dev'),
|
||||||
extensions: ['', '.js', '.jsx'],
|
extensions: ['', '.js', '.jsx'],
|
||||||
alias: {
|
alias: {
|
||||||
'Opentip': __dirname + '/dev/External/Opentip.js',
|
'Opentip': __dirname + '/dev/External/Opentip.js',
|
||||||
|
|
@ -33,7 +37,8 @@ module.exports = {
|
||||||
exclude: /(node_modules|bower_components)/,
|
exclude: /(node_modules|bower_components)/,
|
||||||
query: {
|
query: {
|
||||||
cacheDirectory: true,
|
cacheDirectory: true,
|
||||||
presets: ['es2015']
|
// plugins: ['transform-runtime'],
|
||||||
|
presets: ['es2015', 'stage-0']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue