mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
CommonJS (research)
This commit is contained in:
parent
2fa2cd191e
commit
56607de87c
91 changed files with 20220 additions and 12933 deletions
10
dev/AdminBoot.js
Normal file
10
dev/AdminBoot.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
kn = require('./Knoin/Knoin.js'),
|
||||||
|
RL = require('./Boots/AdminApp.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
kn.bootstart(RL);
|
||||||
|
|
@ -1,359 +1,385 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends KnoinAbstractBoot
|
|
||||||
*/
|
|
||||||
function AbstractApp()
|
|
||||||
{
|
|
||||||
KnoinAbstractBoot.call(this);
|
|
||||||
|
|
||||||
this.oSettings = null;
|
'use strict';
|
||||||
this.oPlugins = null;
|
|
||||||
this.oLocal = null;
|
|
||||||
this.oLink = null;
|
|
||||||
this.oSubs = {};
|
|
||||||
|
|
||||||
this.isLocalAutocomplete = true;
|
|
||||||
|
|
||||||
this.popupVisibilityNames = ko.observableArray([]);
|
|
||||||
|
|
||||||
this.popupVisibility = ko.computed(function () {
|
|
||||||
return 0 < this.popupVisibilityNames().length;
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');
|
|
||||||
|
|
||||||
$window.on('error', function (oEvent) {
|
|
||||||
if (RL && oEvent && oEvent.originalEvent && oEvent.originalEvent.message &&
|
|
||||||
-1 === Utils.inArray(oEvent.originalEvent.message, [
|
|
||||||
'Script error.', 'Uncaught Error: Error calling method on NPObject.'
|
|
||||||
]))
|
|
||||||
{
|
|
||||||
RL.remote().jsError(
|
|
||||||
Utils.emptyFunction,
|
|
||||||
oEvent.originalEvent.message,
|
|
||||||
oEvent.originalEvent.filename,
|
|
||||||
oEvent.originalEvent.lineno,
|
|
||||||
location && location.toString ? location.toString() : '',
|
|
||||||
$html.attr('class'),
|
|
||||||
Utils.microtime() - Globals.now
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$document.on('keydown', function (oEvent) {
|
|
||||||
if (oEvent && oEvent.ctrlKey)
|
|
||||||
{
|
|
||||||
$html.addClass('rl-ctrl-key-pressed');
|
|
||||||
}
|
|
||||||
}).on('keyup', function (oEvent) {
|
|
||||||
if (oEvent && !oEvent.ctrlKey)
|
|
||||||
{
|
|
||||||
$html.removeClass('rl-ctrl-key-pressed');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AbstractApp.prototype, KnoinAbstractBoot.prototype);
|
|
||||||
|
|
||||||
AbstractApp.prototype.oSettings = null;
|
|
||||||
AbstractApp.prototype.oPlugins = null;
|
|
||||||
AbstractApp.prototype.oLocal = null;
|
|
||||||
AbstractApp.prototype.oLink = null;
|
|
||||||
AbstractApp.prototype.oSubs = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sLink
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.download = function (sLink)
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
oLink = null,
|
$ = require('../External/jquery.js'),
|
||||||
oE = null,
|
_ = require('../External/underscore.js'),
|
||||||
sUserAgent = navigator.userAgent.toLowerCase()
|
ko = require('../External/ko.js'),
|
||||||
|
window = require('../External/window.js'),
|
||||||
|
$html = require('../External/$html.js'),
|
||||||
|
$window = require('../External/$window.js'),
|
||||||
|
$doc = require('../External/$doc.js'),
|
||||||
|
AppData = require('../External/AppData.js'),
|
||||||
|
Globals = require('../Common/Globals.js'),
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
KnoinAbstractBoot = require('../Knoin/KnoinAbstractBoot.js'),
|
||||||
|
RL = require('./RL.js')
|
||||||
;
|
;
|
||||||
|
|
||||||
if (sUserAgent && (sUserAgent.indexOf('chrome') > -1 || sUserAgent.indexOf('chrome') > -1))
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends KnoinAbstractBoot
|
||||||
|
*/
|
||||||
|
function AbstractApp()
|
||||||
{
|
{
|
||||||
oLink = document.createElement('a');
|
KnoinAbstractBoot.call(this);
|
||||||
oLink['href'] = sLink;
|
|
||||||
|
|
||||||
if (document['createEvent'])
|
this.oSettings = null;
|
||||||
{
|
this.oPlugins = null;
|
||||||
oE = document['createEvent']('MouseEvents');
|
this.oLocal = null;
|
||||||
if (oE && oE['initEvent'] && oLink['dispatchEvent'])
|
this.oLink = null;
|
||||||
|
this.oSubs = {};
|
||||||
|
|
||||||
|
this.isLocalAutocomplete = true;
|
||||||
|
|
||||||
|
this.popupVisibilityNames = ko.observableArray([]);
|
||||||
|
|
||||||
|
this.popupVisibility = ko.computed(function () {
|
||||||
|
return 0 < this.popupVisibilityNames().length;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');
|
||||||
|
|
||||||
|
$window.on('error', function (oEvent) {
|
||||||
|
if (oEvent && oEvent.originalEvent && oEvent.originalEvent.message &&
|
||||||
|
-1 === Utils.inArray(oEvent.originalEvent.message, [
|
||||||
|
'Script error.', 'Uncaught Error: Error calling method on NPObject.'
|
||||||
|
]))
|
||||||
{
|
{
|
||||||
oE['initEvent']('click', true, true);
|
// TODO cjs
|
||||||
oLink['dispatchEvent'](oE);
|
RL.remote().jsError(
|
||||||
return true;
|
Utils.emptyFunction,
|
||||||
|
oEvent.originalEvent.message,
|
||||||
|
oEvent.originalEvent.filename,
|
||||||
|
oEvent.originalEvent.lineno,
|
||||||
|
window.location && window.location.toString ? window.location.toString() : '',
|
||||||
|
$html.attr('class'),
|
||||||
|
Utils.microtime() - Globals.now
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (Globals.bMobileDevice)
|
$doc.on('keydown', function (oEvent) {
|
||||||
{
|
if (oEvent && oEvent.ctrlKey)
|
||||||
window.open(sLink, '_self');
|
|
||||||
window.focus();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.iframe.attr('src', sLink);
|
|
||||||
// window.document.location.href = sLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {LinkBuilder}
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.link = function ()
|
|
||||||
{
|
|
||||||
if (null === this.oLink)
|
|
||||||
{
|
|
||||||
this.oLink = new LinkBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.oLink;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {LocalStorage}
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.local = function ()
|
|
||||||
{
|
|
||||||
if (null === this.oLocal)
|
|
||||||
{
|
|
||||||
this.oLocal = new LocalStorage();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.oLocal;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sName
|
|
||||||
* @return {?}
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.settingsGet = function (sName)
|
|
||||||
{
|
|
||||||
if (null === this.oSettings)
|
|
||||||
{
|
|
||||||
this.oSettings = Utils.isNormal(AppData) ? AppData : {};
|
|
||||||
}
|
|
||||||
|
|
||||||
return Utils.isUnd(this.oSettings[sName]) ? null : this.oSettings[sName];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sName
|
|
||||||
* @param {?} mValue
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.settingsSet = function (sName, mValue)
|
|
||||||
{
|
|
||||||
if (null === this.oSettings)
|
|
||||||
{
|
|
||||||
this.oSettings = Utils.isNormal(AppData) ? AppData : {};
|
|
||||||
}
|
|
||||||
|
|
||||||
this.oSettings[sName] = mValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
AbstractApp.prototype.setTitle = function (sTitle)
|
|
||||||
{
|
|
||||||
sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') +
|
|
||||||
RL.settingsGet('Title') || '';
|
|
||||||
|
|
||||||
window.document.title = '_';
|
|
||||||
window.document.title = sTitle;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean=} bLogout = false
|
|
||||||
* @param {boolean=} bClose = false
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
sCustomLogoutLink = Utils.pString(RL.settingsGet('CustomLogoutLink')),
|
|
||||||
bInIframe = !!RL.settingsGet('InIframe')
|
|
||||||
;
|
|
||||||
|
|
||||||
bLogout = Utils.isUnd(bLogout) ? false : !!bLogout;
|
|
||||||
bClose = Utils.isUnd(bClose) ? false : !!bClose;
|
|
||||||
|
|
||||||
if (bLogout && bClose && window.close)
|
|
||||||
{
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bLogout && '' !== sCustomLogoutLink && window.location.href !== sCustomLogoutLink)
|
|
||||||
{
|
|
||||||
_.delay(function () {
|
|
||||||
if (bInIframe && window.parent)
|
|
||||||
{
|
{
|
||||||
window.parent.location.href = sCustomLogoutLink;
|
$html.addClass('rl-ctrl-key-pressed');
|
||||||
}
|
}
|
||||||
else
|
}).on('keyup', function (oEvent) {
|
||||||
|
if (oEvent && !oEvent.ctrlKey)
|
||||||
{
|
{
|
||||||
window.location.href = sCustomLogoutLink;
|
$html.removeClass('rl-ctrl-key-pressed');
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
kn.routeOff();
|
|
||||||
kn.setHash(RL.link().root(), true);
|
|
||||||
kn.routeOff();
|
|
||||||
|
|
||||||
_.delay(function () {
|
|
||||||
if (bInIframe && window.parent)
|
|
||||||
{
|
|
||||||
window.parent.location.reload();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AbstractApp.prototype.historyBack = function ()
|
|
||||||
{
|
|
||||||
window.history.back();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sQuery
|
|
||||||
* @param {Function} fCallback
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.getAutocomplete = function (sQuery, fCallback)
|
|
||||||
{
|
|
||||||
fCallback([], sQuery);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sName
|
|
||||||
* @param {Function} fFunc
|
|
||||||
* @param {Object=} oContext
|
|
||||||
* @return {AbstractApp}
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.sub = function (sName, fFunc, oContext)
|
|
||||||
{
|
|
||||||
if (Utils.isUnd(this.oSubs[sName]))
|
|
||||||
{
|
|
||||||
this.oSubs[sName] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this.oSubs[sName].push([fFunc, oContext]);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sName
|
|
||||||
* @param {Array=} aArgs
|
|
||||||
* @return {AbstractApp}
|
|
||||||
*/
|
|
||||||
AbstractApp.prototype.pub = function (sName, aArgs)
|
|
||||||
{
|
|
||||||
Plugins.runHook('rl-pub', [sName, aArgs]);
|
|
||||||
if (!Utils.isUnd(this.oSubs[sName]))
|
|
||||||
{
|
|
||||||
_.each(this.oSubs[sName], function (aItem) {
|
|
||||||
if (aItem[0])
|
|
||||||
{
|
|
||||||
aItem[0].apply(aItem[1] || null, aArgs || []);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
_.extend(AbstractApp.prototype, KnoinAbstractBoot.prototype);
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
AbstractApp.prototype.oSettings = null;
|
||||||
* @param {string} sName
|
AbstractApp.prototype.oPlugins = null;
|
||||||
* @return {boolean}
|
AbstractApp.prototype.oLocal = null;
|
||||||
*/
|
AbstractApp.prototype.oLink = null;
|
||||||
AbstractApp.prototype.capa = function (sName)
|
AbstractApp.prototype.oSubs = {};
|
||||||
{
|
|
||||||
var mCapa = this.settingsGet('Capa');
|
|
||||||
return Utils.isArray(mCapa) && Utils.isNormal(sName) && -1 < Utils.inArray(sName, mCapa);
|
|
||||||
};
|
|
||||||
|
|
||||||
AbstractApp.prototype.bootstart = function ()
|
/**
|
||||||
{
|
* @param {string} sLink
|
||||||
var self = this;
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
AbstractApp.prototype.download = function (sLink)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
oE = null,
|
||||||
|
oLink = null,
|
||||||
|
sUserAgent = window.navigator.userAgent.toLowerCase()
|
||||||
|
;
|
||||||
|
|
||||||
Utils.initOnStartOrLangChange(function () {
|
if (sUserAgent && (sUserAgent.indexOf('chrome') > -1 || sUserAgent.indexOf('chrome') > -1))
|
||||||
Utils.initNotificationLanguage();
|
{
|
||||||
}, null);
|
oLink = window.document.createElement('a');
|
||||||
|
oLink['href'] = sLink;
|
||||||
|
|
||||||
_.delay(function () {
|
if (window.document['createEvent'])
|
||||||
Utils.windowResize();
|
{
|
||||||
}, 1000);
|
oE = window.document['createEvent']('MouseEvents');
|
||||||
|
if (oE && oE['initEvent'] && oLink['dispatchEvent'])
|
||||||
ssm.addState({
|
{
|
||||||
'id': 'mobile',
|
oE['initEvent']('click', true, true);
|
||||||
'maxWidth': 767,
|
oLink['dispatchEvent'](oE);
|
||||||
'onEnter': function() {
|
return true;
|
||||||
$html.addClass('ssm-state-mobile');
|
}
|
||||||
self.pub('ssm.mobile-enter');
|
}
|
||||||
},
|
|
||||||
'onLeave': function() {
|
|
||||||
$html.removeClass('ssm-state-mobile');
|
|
||||||
self.pub('ssm.mobile-leave');
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
ssm.addState({
|
if (Globals.bMobileDevice)
|
||||||
'id': 'tablet',
|
{
|
||||||
'minWidth': 768,
|
window.open(sLink, '_self');
|
||||||
'maxWidth': 999,
|
window.focus();
|
||||||
'onEnter': function() {
|
|
||||||
$html.addClass('ssm-state-tablet');
|
|
||||||
},
|
|
||||||
'onLeave': function() {
|
|
||||||
$html.removeClass('ssm-state-tablet');
|
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
|
{
|
||||||
ssm.addState({
|
this.iframe.attr('src', sLink);
|
||||||
'id': 'desktop',
|
// window.document.location.href = sLink;
|
||||||
'minWidth': 1000,
|
|
||||||
'maxWidth': 1400,
|
|
||||||
'onEnter': function() {
|
|
||||||
$html.addClass('ssm-state-desktop');
|
|
||||||
},
|
|
||||||
'onLeave': function() {
|
|
||||||
$html.removeClass('ssm-state-desktop');
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
ssm.addState({
|
return true;
|
||||||
'id': 'desktop-large',
|
};
|
||||||
'minWidth': 1400,
|
|
||||||
'onEnter': function() {
|
/**
|
||||||
$html.addClass('ssm-state-desktop-large');
|
* @return {LinkBuilder}
|
||||||
},
|
*/
|
||||||
'onLeave': function() {
|
AbstractApp.prototype.link = function ()
|
||||||
$html.removeClass('ssm-state-desktop-large');
|
{
|
||||||
|
if (null === this.oLink)
|
||||||
|
{
|
||||||
|
this.oLink = new LinkBuilder(); // TODO cjs
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
RL.sub('ssm.mobile-enter', function () {
|
return this.oLink;
|
||||||
RL.data().leftPanelDisabled(true);
|
};
|
||||||
});
|
|
||||||
|
|
||||||
RL.sub('ssm.mobile-leave', function () {
|
/**
|
||||||
RL.data().leftPanelDisabled(false);
|
* @return {LocalStorage}
|
||||||
});
|
*/
|
||||||
|
AbstractApp.prototype.local = function ()
|
||||||
|
{
|
||||||
|
if (null === this.oLocal)
|
||||||
|
{
|
||||||
|
this.oLocal = new LocalStorage(); // TODO cjs
|
||||||
|
}
|
||||||
|
|
||||||
RL.data().leftPanelDisabled.subscribe(function (bValue) {
|
return this.oLocal;
|
||||||
$html.toggleClass('rl-left-panel-disabled', bValue);
|
};
|
||||||
});
|
|
||||||
|
|
||||||
ssm.ready();
|
/**
|
||||||
};
|
* @param {string} sName
|
||||||
|
* @return {?}
|
||||||
|
*/
|
||||||
|
AbstractApp.prototype.settingsGet = function (sName)
|
||||||
|
{
|
||||||
|
if (null === this.oSettings)
|
||||||
|
{
|
||||||
|
this.oSettings = Utils.isNormal(AppData) ? AppData : {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Utils.isUnd(this.oSettings[sName]) ? null : this.oSettings[sName];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sName
|
||||||
|
* @param {?} mValue
|
||||||
|
*/
|
||||||
|
AbstractApp.prototype.settingsSet = function (sName, mValue)
|
||||||
|
{
|
||||||
|
if (null === this.oSettings)
|
||||||
|
{
|
||||||
|
this.oSettings = Utils.isNormal(AppData) ? AppData : {};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.oSettings[sName] = mValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
AbstractApp.prototype.setTitle = function (sTitle)
|
||||||
|
{
|
||||||
|
sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') +
|
||||||
|
RL.settingsGet('Title') || ''; // TODO cjs
|
||||||
|
|
||||||
|
window.document.title = '_';
|
||||||
|
window.document.title = sTitle;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean=} bLogout = false
|
||||||
|
* @param {boolean=} bClose = false
|
||||||
|
*/
|
||||||
|
AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
sCustomLogoutLink = Utils.pString(RL.settingsGet('CustomLogoutLink')),
|
||||||
|
bInIframe = !!RL.settingsGet('InIframe')
|
||||||
|
;
|
||||||
|
|
||||||
|
// TODO cjs
|
||||||
|
|
||||||
|
bLogout = Utils.isUnd(bLogout) ? false : !!bLogout;
|
||||||
|
bClose = Utils.isUnd(bClose) ? false : !!bClose;
|
||||||
|
|
||||||
|
if (bLogout && bClose && window.close)
|
||||||
|
{
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bLogout && '' !== sCustomLogoutLink && window.location.href !== sCustomLogoutLink)
|
||||||
|
{
|
||||||
|
_.delay(function () {
|
||||||
|
if (bInIframe && window.parent)
|
||||||
|
{
|
||||||
|
window.parent.location.href = sCustomLogoutLink;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.location.href = sCustomLogoutLink;
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
kn.routeOff();
|
||||||
|
kn.setHash(RL.link().root(), true);
|
||||||
|
kn.routeOff();
|
||||||
|
|
||||||
|
_.delay(function () {
|
||||||
|
if (bInIframe && window.parent)
|
||||||
|
{
|
||||||
|
window.parent.location.reload();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AbstractApp.prototype.historyBack = function ()
|
||||||
|
{
|
||||||
|
window.history.back();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sQuery
|
||||||
|
* @param {Function} fCallback
|
||||||
|
*/
|
||||||
|
AbstractApp.prototype.getAutocomplete = function (sQuery, fCallback)
|
||||||
|
{
|
||||||
|
fCallback([], sQuery);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sName
|
||||||
|
* @param {Function} fFunc
|
||||||
|
* @param {Object=} oContext
|
||||||
|
* @return {AbstractApp}
|
||||||
|
*/
|
||||||
|
AbstractApp.prototype.sub = function (sName, fFunc, oContext)
|
||||||
|
{
|
||||||
|
if (Utils.isUnd(this.oSubs[sName]))
|
||||||
|
{
|
||||||
|
this.oSubs[sName] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.oSubs[sName].push([fFunc, oContext]);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sName
|
||||||
|
* @param {Array=} aArgs
|
||||||
|
* @return {AbstractApp}
|
||||||
|
*/
|
||||||
|
AbstractApp.prototype.pub = function (sName, aArgs)
|
||||||
|
{
|
||||||
|
Plugins.runHook('rl-pub', [sName, aArgs]);
|
||||||
|
if (!Utils.isUnd(this.oSubs[sName]))
|
||||||
|
{
|
||||||
|
_.each(this.oSubs[sName], function (aItem) {
|
||||||
|
if (aItem[0])
|
||||||
|
{
|
||||||
|
aItem[0].apply(aItem[1] || null, aArgs || []);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sName
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
AbstractApp.prototype.capa = function (sName)
|
||||||
|
{
|
||||||
|
var mCapa = this.settingsGet('Capa');
|
||||||
|
return Utils.isArray(mCapa) && Utils.isNormal(sName) && -1 < Utils.inArray(sName, mCapa);
|
||||||
|
};
|
||||||
|
|
||||||
|
AbstractApp.prototype.bootstart = function ()
|
||||||
|
{
|
||||||
|
var ssm = require('../External/ssm.js');
|
||||||
|
|
||||||
|
Utils.initOnStartOrLangChange(function () {
|
||||||
|
Utils.initNotificationLanguage();
|
||||||
|
}, null);
|
||||||
|
|
||||||
|
_.delay(function () {
|
||||||
|
Utils.windowResize();
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
ssm.addState({
|
||||||
|
'id': 'mobile',
|
||||||
|
'maxWidth': 767,
|
||||||
|
'onEnter': function() {
|
||||||
|
$html.addClass('ssm-state-mobile');
|
||||||
|
RL.pub('ssm.mobile-enter');
|
||||||
|
},
|
||||||
|
'onLeave': function() {
|
||||||
|
$html.removeClass('ssm-state-mobile');
|
||||||
|
RL.pub('ssm.mobile-leave');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ssm.addState({
|
||||||
|
'id': 'tablet',
|
||||||
|
'minWidth': 768,
|
||||||
|
'maxWidth': 999,
|
||||||
|
'onEnter': function() {
|
||||||
|
$html.addClass('ssm-state-tablet');
|
||||||
|
},
|
||||||
|
'onLeave': function() {
|
||||||
|
$html.removeClass('ssm-state-tablet');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ssm.addState({
|
||||||
|
'id': 'desktop',
|
||||||
|
'minWidth': 1000,
|
||||||
|
'maxWidth': 1400,
|
||||||
|
'onEnter': function() {
|
||||||
|
$html.addClass('ssm-state-desktop');
|
||||||
|
},
|
||||||
|
'onLeave': function() {
|
||||||
|
$html.removeClass('ssm-state-desktop');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ssm.addState({
|
||||||
|
'id': 'desktop-large',
|
||||||
|
'minWidth': 1400,
|
||||||
|
'onEnter': function() {
|
||||||
|
$html.addClass('ssm-state-desktop-large');
|
||||||
|
},
|
||||||
|
'onLeave': function() {
|
||||||
|
$html.removeClass('ssm-state-desktop-large');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
RL.sub('ssm.mobile-enter', function () { // TODO cjs
|
||||||
|
RL.data().leftPanelDisabled(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
RL.sub('ssm.mobile-leave', function () { // TODO cjs
|
||||||
|
RL.data().leftPanelDisabled(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
RL.data().leftPanelDisabled.subscribe(function (bValue) { // TODO cjs
|
||||||
|
$html.toggleClass('rl-left-panel-disabled', bValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
ssm.ready();
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AbstractApp;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,302 +1,320 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends AbstractApp
|
|
||||||
*/
|
|
||||||
function AdminApp()
|
|
||||||
{
|
|
||||||
AbstractApp.call(this);
|
|
||||||
|
|
||||||
this.oData = null;
|
'use strict';
|
||||||
this.oRemote = null;
|
|
||||||
this.oCache = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AdminApp.prototype, AbstractApp.prototype);
|
var
|
||||||
|
ko = require('../External/ko.js'),
|
||||||
|
_ = require('../External/underscore.js'),
|
||||||
|
window = require('../External/window.js'),
|
||||||
|
Enums = require('../Common/Enums.js'),
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
kn = require('../Knoin/Knoin.js'),
|
||||||
|
AbstractApp = require('./AbstractApp.js')
|
||||||
|
;
|
||||||
|
|
||||||
AdminApp.prototype.oData = null;
|
/**
|
||||||
AdminApp.prototype.oRemote = null;
|
* @constructor
|
||||||
AdminApp.prototype.oCache = null;
|
* @extends AbstractApp
|
||||||
|
*/
|
||||||
/**
|
function AdminApp()
|
||||||
* @return {AdminDataStorage}
|
|
||||||
*/
|
|
||||||
AdminApp.prototype.data = function ()
|
|
||||||
{
|
|
||||||
if (null === this.oData)
|
|
||||||
{
|
{
|
||||||
this.oData = new AdminDataStorage();
|
AbstractApp.call(this);
|
||||||
|
|
||||||
|
this.oData = null;
|
||||||
|
this.oRemote = null;
|
||||||
|
this.oCache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.oData;
|
_.extend(AdminApp.prototype, AbstractApp.prototype);
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
AdminApp.prototype.oData = null;
|
||||||
* @return {AdminAjaxRemoteStorage}
|
AdminApp.prototype.oRemote = null;
|
||||||
*/
|
AdminApp.prototype.oCache = null;
|
||||||
AdminApp.prototype.remote = function ()
|
|
||||||
{
|
/**
|
||||||
if (null === this.oRemote)
|
* @return {AdminDataStorage}
|
||||||
|
*/
|
||||||
|
AdminApp.prototype.data = function ()
|
||||||
{
|
{
|
||||||
this.oRemote = new AdminAjaxRemoteStorage();
|
if (null === this.oData)
|
||||||
}
|
|
||||||
|
|
||||||
return this.oRemote;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {AdminCacheStorage}
|
|
||||||
*/
|
|
||||||
AdminApp.prototype.cache = function ()
|
|
||||||
{
|
|
||||||
if (null === this.oCache)
|
|
||||||
{
|
|
||||||
this.oCache = new AdminCacheStorage();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.oCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.reloadDomainList = function ()
|
|
||||||
{
|
|
||||||
RL.data().domainsLoading(true);
|
|
||||||
RL.remote().domainList(function (sResult, oData) {
|
|
||||||
RL.data().domainsLoading(false);
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
|
||||||
{
|
{
|
||||||
var aList = _.map(oData.Result, function (bEnabled, sName) {
|
this.oData = new AdminDataStorage(); // TODO cjs
|
||||||
return {
|
|
||||||
'name': sName,
|
|
||||||
'disabled': ko.observable(!bEnabled),
|
|
||||||
'deleteAccess': ko.observable(false)
|
|
||||||
};
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
RL.data().domains(aList);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.reloadPluginList = function ()
|
return this.oData;
|
||||||
{
|
};
|
||||||
RL.data().pluginsLoading(true);
|
|
||||||
RL.remote().pluginList(function (sResult, oData) {
|
/**
|
||||||
RL.data().pluginsLoading(false);
|
* @return {AdminAjaxRemoteStorage}
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
*/
|
||||||
|
AdminApp.prototype.remote = function ()
|
||||||
|
{
|
||||||
|
if (null === this.oRemote)
|
||||||
{
|
{
|
||||||
var aList = _.map(oData.Result, function (oItem) {
|
this.oRemote = new AdminAjaxRemoteStorage(); // TODO cjs
|
||||||
return {
|
|
||||||
'name': oItem['Name'],
|
|
||||||
'disabled': ko.observable(!oItem['Enabled']),
|
|
||||||
'configured': ko.observable(!!oItem['Configured'])
|
|
||||||
};
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
RL.data().plugins(aList);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.reloadPackagesList = function ()
|
return this.oRemote;
|
||||||
{
|
};
|
||||||
RL.data().packagesLoading(true);
|
|
||||||
RL.data().packagesReal(true);
|
|
||||||
|
|
||||||
RL.remote().packagesList(function (sResult, oData) {
|
/**
|
||||||
|
* @return {AdminCacheStorage}
|
||||||
RL.data().packagesLoading(false);
|
*/
|
||||||
|
AdminApp.prototype.cache = function ()
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
{
|
||||||
|
if (null === this.oCache)
|
||||||
{
|
{
|
||||||
RL.data().packagesReal(!!oData.Result.Real);
|
this.oCache = new AdminCacheStorage(); // TODO cjs
|
||||||
RL.data().packagesMainUpdatable(!!oData.Result.MainUpdatable);
|
}
|
||||||
|
|
||||||
var
|
return this.oCache;
|
||||||
aList = [],
|
};
|
||||||
aLoading = {}
|
|
||||||
;
|
|
||||||
|
|
||||||
_.each(RL.data().packages(), function (oItem) {
|
AdminApp.prototype.reloadDomainList = function ()
|
||||||
if (oItem && oItem['loading']())
|
{
|
||||||
{
|
// TODO cjs
|
||||||
aLoading[oItem['file']] = oItem;
|
RL.data().domainsLoading(true);
|
||||||
}
|
RL.remote().domainList(function (sResult, oData) {
|
||||||
});
|
RL.data().domainsLoading(false);
|
||||||
|
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||||
if (Utils.isArray(oData.Result.List))
|
|
||||||
{
|
{
|
||||||
aList = _.compact(_.map(oData.Result.List, function (oItem) {
|
var aList = _.map(oData.Result, function (bEnabled, sName) {
|
||||||
if (oItem)
|
return {
|
||||||
{
|
'name': sName,
|
||||||
oItem['loading'] = ko.observable(!Utils.isUnd(aLoading[oItem['file']]));
|
'disabled': ko.observable(!bEnabled),
|
||||||
return 'core' === oItem['type'] && !oItem['canBeInstalled'] ? null : oItem;
|
'deleteAccess': ko.observable(false)
|
||||||
}
|
};
|
||||||
return null;
|
}, this);
|
||||||
}));
|
|
||||||
|
RL.data().domains(aList);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
RL.data().packages(aList);
|
AdminApp.prototype.reloadPluginList = function ()
|
||||||
}
|
{
|
||||||
else
|
// TODO cjs
|
||||||
{
|
RL.data().pluginsLoading(true);
|
||||||
RL.data().packagesReal(false);
|
RL.remote().pluginList(function (sResult, oData) {
|
||||||
}
|
RL.data().pluginsLoading(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);
|
||||||
|
|
||||||
AdminApp.prototype.updateCoreData = function ()
|
RL.data().plugins(aList);
|
||||||
{
|
}
|
||||||
var oRainData = RL.data();
|
});
|
||||||
|
};
|
||||||
|
|
||||||
oRainData.coreUpdating(true);
|
AdminApp.prototype.reloadPackagesList = function ()
|
||||||
RL.remote().updateCoreData(function (sResult, oData) {
|
{
|
||||||
|
// TODO cjs
|
||||||
|
RL.data().packagesLoading(true);
|
||||||
|
RL.data().packagesReal(true);
|
||||||
|
|
||||||
oRainData.coreUpdating(false);
|
RL.remote().packagesList(function (sResult, oData) {
|
||||||
oRainData.coreRemoteVersion('');
|
|
||||||
oRainData.coreRemoteRelease('');
|
|
||||||
oRainData.coreVersionCompare(-2);
|
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
RL.data().packagesLoading(false);
|
||||||
{
|
|
||||||
oRainData.coreReal(true);
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
oRainData.coreReal(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||||
|
{
|
||||||
|
RL.data().packagesReal(!!oData.Result.Real);
|
||||||
|
RL.data().packagesMainUpdatable(!!oData.Result.MainUpdatable);
|
||||||
|
|
||||||
AdminApp.prototype.reloadCoreData = function ()
|
var
|
||||||
{
|
aList = [],
|
||||||
var oRainData = RL.data();
|
aLoading = {}
|
||||||
|
;
|
||||||
|
|
||||||
oRainData.coreChecking(true);
|
_.each(RL.data().packages(), function (oItem) {
|
||||||
oRainData.coreReal(true);
|
if (oItem && oItem['loading']())
|
||||||
|
{
|
||||||
|
aLoading[oItem['file']] = oItem;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
RL.remote().coreData(function (sResult, oData) {
|
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;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
oRainData.coreChecking(false);
|
RL.data().packages(aList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RL.data().packagesReal(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
AdminApp.prototype.updateCoreData = function ()
|
||||||
{
|
{
|
||||||
oRainData.coreReal(!!oData.Result.Real);
|
// TODO cjs
|
||||||
oRainData.coreUpdatable(!!oData.Result.Updatable);
|
var oRainData = RL.data();
|
||||||
oRainData.coreAccess(!!oData.Result.Access);
|
|
||||||
oRainData.coreRemoteVersion(oData.Result.RemoteVersion || '');
|
oRainData.coreUpdating(true);
|
||||||
oRainData.coreRemoteRelease(oData.Result.RemoteRelease || '');
|
RL.remote().updateCoreData(function (sResult, oData) {
|
||||||
oRainData.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare));
|
|
||||||
}
|
oRainData.coreUpdating(false);
|
||||||
else
|
|
||||||
{
|
|
||||||
oRainData.coreReal(false);
|
|
||||||
oRainData.coreRemoteVersion('');
|
oRainData.coreRemoteVersion('');
|
||||||
oRainData.coreRemoteRelease('');
|
oRainData.coreRemoteRelease('');
|
||||||
oRainData.coreVersionCompare(-2);
|
oRainData.coreVersionCompare(-2);
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||||
*
|
|
||||||
* @param {boolean=} bForce = false
|
|
||||||
*/
|
|
||||||
AdminApp.prototype.reloadLicensing = function (bForce)
|
|
||||||
{
|
|
||||||
bForce = Utils.isUnd(bForce) ? false : !!bForce;
|
|
||||||
|
|
||||||
RL.data().licensingProcess(true);
|
|
||||||
RL.data().licenseError('');
|
|
||||||
|
|
||||||
RL.remote().licensing(function (sResult, oData) {
|
|
||||||
RL.data().licensingProcess(false);
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired']))
|
|
||||||
{
|
|
||||||
RL.data().licenseValid(true);
|
|
||||||
RL.data().licenseExpired(Utils.pInt(oData.Result['Expired']));
|
|
||||||
RL.data().licenseError('');
|
|
||||||
|
|
||||||
RL.data().licensing(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (oData && oData.ErrorCode && -1 < Utils.inArray(Utils.pInt(oData.ErrorCode), [
|
|
||||||
Enums.Notification.LicensingServerIsUnavailable,
|
|
||||||
Enums.Notification.LicensingExpired
|
|
||||||
]))
|
|
||||||
{
|
{
|
||||||
RL.data().licenseError(Utils.getNotification(Utils.pInt(oData.ErrorCode)));
|
oRainData.coreReal(true);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oRainData.coreReal(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
AdminApp.prototype.reloadCoreData = function ()
|
||||||
|
{
|
||||||
|
var oRainData = RL.data();
|
||||||
|
|
||||||
|
oRainData.coreChecking(true);
|
||||||
|
oRainData.coreReal(true);
|
||||||
|
|
||||||
|
RL.remote().coreData(function (sResult, oData) {
|
||||||
|
|
||||||
|
oRainData.coreChecking(false);
|
||||||
|
|
||||||
|
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||||
|
{
|
||||||
|
oRainData.coreReal(!!oData.Result.Real);
|
||||||
|
oRainData.coreUpdatable(!!oData.Result.Updatable);
|
||||||
|
oRainData.coreAccess(!!oData.Result.Access);
|
||||||
|
oRainData.coreRemoteVersion(oData.Result.RemoteVersion || '');
|
||||||
|
oRainData.coreRemoteRelease(oData.Result.RemoteRelease || '');
|
||||||
|
oRainData.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oRainData.coreReal(false);
|
||||||
|
oRainData.coreRemoteVersion('');
|
||||||
|
oRainData.coreRemoteRelease('');
|
||||||
|
oRainData.coreVersionCompare(-2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {boolean=} bForce = false
|
||||||
|
*/
|
||||||
|
AdminApp.prototype.reloadLicensing = function (bForce)
|
||||||
|
{
|
||||||
|
bForce = Utils.isUnd(bForce) ? false : !!bForce;
|
||||||
|
|
||||||
|
// TODO cjs
|
||||||
|
RL.data().licensingProcess(true);
|
||||||
|
RL.data().licenseError('');
|
||||||
|
|
||||||
|
RL.remote().licensing(function (sResult, oData) {
|
||||||
|
RL.data().licensingProcess(false);
|
||||||
|
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired']))
|
||||||
|
{
|
||||||
|
RL.data().licenseValid(true);
|
||||||
|
RL.data().licenseExpired(Utils.pInt(oData.Result['Expired']));
|
||||||
|
RL.data().licenseError('');
|
||||||
|
|
||||||
RL.data().licensing(true);
|
RL.data().licensing(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Enums.StorageResultType.Abort === sResult)
|
if (oData && oData.ErrorCode && -1 < Utils.inArray(Utils.pInt(oData.ErrorCode), [
|
||||||
|
Enums.Notification.LicensingServerIsUnavailable,
|
||||||
|
Enums.Notification.LicensingExpired
|
||||||
|
]))
|
||||||
{
|
{
|
||||||
RL.data().licenseError(Utils.getNotification(Enums.Notification.LicensingServerIsUnavailable));
|
RL.data().licenseError(Utils.getNotification(Utils.pInt(oData.ErrorCode)));
|
||||||
RL.data().licensing(true);
|
RL.data().licensing(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RL.data().licensing(false);
|
if (Enums.StorageResultType.Abort === sResult)
|
||||||
|
{
|
||||||
|
RL.data().licenseError(Utils.getNotification(Enums.Notification.LicensingServerIsUnavailable));
|
||||||
|
RL.data().licensing(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RL.data().licensing(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}, bForce);
|
||||||
}, bForce);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
AdminApp.prototype.bootstart = function ()
|
AdminApp.prototype.bootstart = function ()
|
||||||
{
|
|
||||||
AbstractApp.prototype.bootstart.call(this);
|
|
||||||
|
|
||||||
RL.data().populateDataOnStart();
|
|
||||||
|
|
||||||
kn.hideLoading();
|
|
||||||
|
|
||||||
if (!RL.settingsGet('AllowAdminPanel'))
|
|
||||||
{
|
{
|
||||||
kn.routeOff();
|
AbstractApp.prototype.bootstart.call(this);
|
||||||
kn.setHash(RL.link().root(), true);
|
|
||||||
kn.routeOff();
|
|
||||||
|
|
||||||
_.defer(function () {
|
RL.data().populateDataOnStart();
|
||||||
window.location.href = '/';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Utils.removeSettingsViewModel(AdminAbout);
|
|
||||||
|
|
||||||
if (!RL.capa(Enums.Capa.Prem))
|
kn.hideLoading();
|
||||||
|
|
||||||
|
if (!RL.settingsGet('AllowAdminPanel'))
|
||||||
{
|
{
|
||||||
Utils.removeSettingsViewModel(AdminBranding);
|
kn.routeOff();
|
||||||
}
|
kn.setHash(RL.link().root(), true);
|
||||||
|
kn.routeOff();
|
||||||
|
|
||||||
if (!!RL.settingsGet('Auth'))
|
_.defer(function () {
|
||||||
{
|
window.location.href = '/';
|
||||||
// TODO
|
});
|
||||||
// if (!RL.settingsGet('AllowPackages') && AdminPackages)
|
|
||||||
// {
|
|
||||||
// Utils.disableSettingsViewModel(AdminPackages);
|
|
||||||
// }
|
|
||||||
|
|
||||||
kn.startScreens([AdminSettingsScreen]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
kn.startScreens([AdminLoginScreen]);
|
// Utils.removeSettingsViewModel(AdminAbout);
|
||||||
|
|
||||||
|
if (!RL.capa(Enums.Capa.Prem))
|
||||||
|
{
|
||||||
|
Utils.removeSettingsViewModel(AdminBranding);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!!RL.settingsGet('Auth'))
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
// if (!RL.settingsGet('AllowPackages') && AdminPackages)
|
||||||
|
// {
|
||||||
|
// Utils.disableSettingsViewModel(AdminPackages);
|
||||||
|
// }
|
||||||
|
|
||||||
|
kn.startScreens([AdminSettingsScreen]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
kn.startScreens([AdminLoginScreen]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (window.SimplePace)
|
if (window.SimplePace)
|
||||||
{
|
{
|
||||||
window.SimplePace.set(100);
|
window.SimplePace.set(100);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
module.exports = new AdminApp();
|
||||||
* @type {AdminApp}
|
|
||||||
*/
|
}(module));
|
||||||
RL = new AdminApp();
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,164 +1,171 @@
|
||||||
/*jslint bitwise: true*/
|
|
||||||
// Base64 encode / decode
|
// Base64 encode / decode
|
||||||
// http://www.webtoolkit.info/
|
// http://www.webtoolkit.info/
|
||||||
|
|
||||||
Base64 = {
|
|
||||||
|
|
||||||
// private property
|
|
||||||
_keyStr : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
||||||
|
|
||||||
// public method for urlsafe encoding
|
|
||||||
urlsafe_encode : function (input) {
|
|
||||||
return Base64.encode(input).replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.');
|
|
||||||
},
|
|
||||||
|
|
||||||
// public method for encoding
|
|
||||||
encode : function (input) {
|
|
||||||
var
|
|
||||||
output = '',
|
|
||||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
|
||||||
i = 0
|
|
||||||
;
|
|
||||||
|
|
||||||
input = Base64._utf8_encode(input);
|
|
||||||
|
|
||||||
while (i < input.length)
|
|
||||||
{
|
|
||||||
chr1 = input.charCodeAt(i++);
|
|
||||||
chr2 = input.charCodeAt(i++);
|
|
||||||
chr3 = input.charCodeAt(i++);
|
|
||||||
|
|
||||||
enc1 = chr1 >> 2;
|
|
||||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
|
||||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
|
||||||
enc4 = chr3 & 63;
|
|
||||||
|
|
||||||
if (isNaN(chr2))
|
|
||||||
{
|
|
||||||
enc3 = enc4 = 64;
|
|
||||||
}
|
|
||||||
else if (isNaN(chr3))
|
|
||||||
{
|
|
||||||
enc4 = 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
output = output +
|
|
||||||
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
|
|
||||||
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
},
|
|
||||||
|
|
||||||
// public method for decoding
|
|
||||||
decode : function (input) {
|
|
||||||
var
|
|
||||||
output = '',
|
|
||||||
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
|
||||||
i = 0
|
|
||||||
;
|
|
||||||
|
|
||||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
|
||||||
|
|
||||||
while (i < input.length)
|
|
||||||
{
|
|
||||||
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
|
||||||
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
|
||||||
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
|
||||||
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
|
||||||
|
|
||||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
|
||||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
|
||||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
|
||||||
|
|
||||||
output = output + String.fromCharCode(chr1);
|
|
||||||
|
|
||||||
if (enc3 !== 64)
|
|
||||||
{
|
|
||||||
output = output + String.fromCharCode(chr2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enc4 !== 64)
|
|
||||||
{
|
|
||||||
output = output + String.fromCharCode(chr3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Base64._utf8_decode(output);
|
|
||||||
},
|
|
||||||
|
|
||||||
// private method for UTF-8 encoding
|
|
||||||
_utf8_encode : function (string) {
|
|
||||||
|
|
||||||
string = string.replace(/\r\n/g, "\n");
|
|
||||||
|
|
||||||
var
|
|
||||||
utftext = '',
|
|
||||||
n = 0,
|
|
||||||
l = string.length,
|
|
||||||
c = 0
|
|
||||||
;
|
|
||||||
|
|
||||||
for (; n < l; n++) {
|
|
||||||
|
|
||||||
c = string.charCodeAt(n);
|
|
||||||
|
|
||||||
if (c < 128)
|
|
||||||
{
|
|
||||||
utftext += String.fromCharCode(c);
|
|
||||||
}
|
|
||||||
else if ((c > 127) && (c < 2048))
|
|
||||||
{
|
|
||||||
utftext += String.fromCharCode((c >> 6) | 192);
|
|
||||||
utftext += String.fromCharCode((c & 63) | 128);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
utftext += String.fromCharCode((c >> 12) | 224);
|
|
||||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
|
||||||
utftext += String.fromCharCode((c & 63) | 128);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return utftext;
|
|
||||||
},
|
|
||||||
|
|
||||||
// private method for UTF-8 decoding
|
|
||||||
_utf8_decode : function (utftext) {
|
|
||||||
var
|
|
||||||
string = '',
|
|
||||||
i = 0,
|
|
||||||
c = 0,
|
|
||||||
c2 = 0,
|
|
||||||
c3 = 0
|
|
||||||
;
|
|
||||||
|
|
||||||
while ( i < utftext.length )
|
|
||||||
{
|
|
||||||
c = utftext.charCodeAt(i);
|
|
||||||
|
|
||||||
if (c < 128)
|
|
||||||
{
|
|
||||||
string += String.fromCharCode(c);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else if((c > 191) && (c < 224))
|
|
||||||
{
|
|
||||||
c2 = utftext.charCodeAt(i+1);
|
|
||||||
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c2 = utftext.charCodeAt(i+1);
|
|
||||||
c3 = utftext.charCodeAt(i+2);
|
|
||||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
|
||||||
i += 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*jslint bitwise: false*/
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/*jslint bitwise: true*/
|
||||||
|
var Base64 = {
|
||||||
|
|
||||||
|
// private property
|
||||||
|
_keyStr : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
||||||
|
|
||||||
|
// public method for urlsafe encoding
|
||||||
|
urlsafe_encode : function (input) {
|
||||||
|
return Base64.encode(input).replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.');
|
||||||
|
},
|
||||||
|
|
||||||
|
// public method for encoding
|
||||||
|
encode : function (input) {
|
||||||
|
var
|
||||||
|
output = '',
|
||||||
|
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
||||||
|
i = 0
|
||||||
|
;
|
||||||
|
|
||||||
|
input = Base64._utf8_encode(input);
|
||||||
|
|
||||||
|
while (i < input.length)
|
||||||
|
{
|
||||||
|
chr1 = input.charCodeAt(i++);
|
||||||
|
chr2 = input.charCodeAt(i++);
|
||||||
|
chr3 = input.charCodeAt(i++);
|
||||||
|
|
||||||
|
enc1 = chr1 >> 2;
|
||||||
|
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||||
|
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||||
|
enc4 = chr3 & 63;
|
||||||
|
|
||||||
|
if (isNaN(chr2))
|
||||||
|
{
|
||||||
|
enc3 = enc4 = 64;
|
||||||
|
}
|
||||||
|
else if (isNaN(chr3))
|
||||||
|
{
|
||||||
|
enc4 = 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
output = output +
|
||||||
|
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
|
||||||
|
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
},
|
||||||
|
|
||||||
|
// public method for decoding
|
||||||
|
decode : function (input) {
|
||||||
|
var
|
||||||
|
output = '',
|
||||||
|
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
|
||||||
|
i = 0
|
||||||
|
;
|
||||||
|
|
||||||
|
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
||||||
|
|
||||||
|
while (i < input.length)
|
||||||
|
{
|
||||||
|
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
||||||
|
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
||||||
|
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
||||||
|
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
||||||
|
|
||||||
|
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||||
|
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||||
|
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||||
|
|
||||||
|
output = output + String.fromCharCode(chr1);
|
||||||
|
|
||||||
|
if (enc3 !== 64)
|
||||||
|
{
|
||||||
|
output = output + String.fromCharCode(chr2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enc4 !== 64)
|
||||||
|
{
|
||||||
|
output = output + String.fromCharCode(chr3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Base64._utf8_decode(output);
|
||||||
|
},
|
||||||
|
|
||||||
|
// private method for UTF-8 encoding
|
||||||
|
_utf8_encode : function (string) {
|
||||||
|
|
||||||
|
string = string.replace(/\r\n/g, "\n");
|
||||||
|
|
||||||
|
var
|
||||||
|
utftext = '',
|
||||||
|
n = 0,
|
||||||
|
l = string.length,
|
||||||
|
c = 0
|
||||||
|
;
|
||||||
|
|
||||||
|
for (; n < l; n++) {
|
||||||
|
|
||||||
|
c = string.charCodeAt(n);
|
||||||
|
|
||||||
|
if (c < 128)
|
||||||
|
{
|
||||||
|
utftext += String.fromCharCode(c);
|
||||||
|
}
|
||||||
|
else if ((c > 127) && (c < 2048))
|
||||||
|
{
|
||||||
|
utftext += String.fromCharCode((c >> 6) | 192);
|
||||||
|
utftext += String.fromCharCode((c & 63) | 128);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
utftext += String.fromCharCode((c >> 12) | 224);
|
||||||
|
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||||
|
utftext += String.fromCharCode((c & 63) | 128);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return utftext;
|
||||||
|
},
|
||||||
|
|
||||||
|
// private method for UTF-8 decoding
|
||||||
|
_utf8_decode : function (utftext) {
|
||||||
|
var
|
||||||
|
string = '',
|
||||||
|
i = 0,
|
||||||
|
c = 0,
|
||||||
|
c2 = 0,
|
||||||
|
c3 = 0
|
||||||
|
;
|
||||||
|
|
||||||
|
while ( i < utftext.length )
|
||||||
|
{
|
||||||
|
c = utftext.charCodeAt(i);
|
||||||
|
|
||||||
|
if (c < 128)
|
||||||
|
{
|
||||||
|
string += String.fromCharCode(c);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if((c > 191) && (c < 224))
|
||||||
|
{
|
||||||
|
c2 = utftext.charCodeAt(i+1);
|
||||||
|
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c2 = utftext.charCodeAt(i+1);
|
||||||
|
c3 = utftext.charCodeAt(i+2);
|
||||||
|
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||||
|
i += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = Base64;
|
||||||
|
/*jslint bitwise: false*/
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
Consts.Defaults = {};
|
|
||||||
Consts.Values = {};
|
|
||||||
Consts.DataImages = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Defaults.MessagesPerPage = 20;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Defaults.ContactsPerPage = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {Array}
|
|
||||||
*/
|
|
||||||
Consts.Defaults.MessagesPerPageArray = [10, 20, 30, 50, 100/*, 150, 200, 300*/];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Defaults.DefaultAjaxTimeout = 30000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Defaults.SearchAjaxTimeout = 300000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Defaults.SendMessageAjaxTimeout = 300000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Defaults.SaveMessageAjaxTimeout = 200000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Defaults.ContactsSyncAjaxTimeout = 200000;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
Consts.Values.UnuseOptionValue = '__UNUSE__';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
Consts.Values.ClientSideCookieIndexName = 'rlcsc';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Values.ImapDefaulPort = 143;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Values.ImapDefaulSecurePort = 993;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Values.SmtpDefaulPort = 25;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Values.SmtpDefaulSecurePort = 465;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Values.MessageBodyCacheLimit = 15;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Values.AjaxErrorLimit = 7;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
Consts.Values.TokenErrorLimit = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';
|
|
||||||
129
dev/Common/Consts.js
Normal file
129
dev/Common/Consts.js
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Consts = {};
|
||||||
|
|
||||||
|
Consts.Values = {};
|
||||||
|
Consts.DataImages = {};
|
||||||
|
Consts.Defaults = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Defaults.MessagesPerPage = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Defaults.ContactsPerPage = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {Array}
|
||||||
|
*/
|
||||||
|
Consts.Defaults.MessagesPerPageArray = [10, 20, 30, 50, 100/*, 150, 200, 300*/];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Defaults.DefaultAjaxTimeout = 30000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Defaults.SearchAjaxTimeout = 300000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Defaults.SendMessageAjaxTimeout = 300000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Defaults.SaveMessageAjaxTimeout = 200000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Defaults.ContactsSyncAjaxTimeout = 200000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
Consts.Values.UnuseOptionValue = '__UNUSE__';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
Consts.Values.ClientSideCookieIndexName = 'rlcsc';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Values.ImapDefaulPort = 143;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Values.ImapDefaulSecurePort = 993;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Values.SmtpDefaulPort = 25;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Values.SmtpDefaulSecurePort = 465;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Values.MessageBodyCacheLimit = 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Values.AjaxErrorLimit = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
Consts.Values.TokenErrorLimit = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';
|
||||||
|
|
||||||
|
module.exports = Consts;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,430 +1,440 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
Enums.StorageResultType = {
|
|
||||||
'Success': 'success',
|
|
||||||
'Abort': 'abort',
|
|
||||||
'Error': 'error',
|
|
||||||
'Unload': 'unload'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
'use strict';
|
||||||
* @enum {number}
|
|
||||||
*/
|
|
||||||
Enums.State = {
|
|
||||||
'Empty': 10,
|
|
||||||
'Login': 20,
|
|
||||||
'Auth': 30
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
var Enums = {};
|
||||||
* @enum {number}
|
|
||||||
*/
|
|
||||||
Enums.StateType = {
|
|
||||||
'Webmail': 0,
|
|
||||||
'Admin': 1
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.Capa = {
|
Enums.StorageResultType = {
|
||||||
'Prem': 'PREM',
|
'Success': 'success',
|
||||||
'TwoFactor': 'TWO_FACTOR',
|
'Abort': 'abort',
|
||||||
'OpenPGP': 'OPEN_PGP',
|
'Error': 'error',
|
||||||
'Prefetch': 'PREFETCH',
|
'Unload': 'unload'
|
||||||
'Gravatar': 'GRAVATAR',
|
};
|
||||||
'Themes': 'THEMES',
|
|
||||||
'Filters': 'FILTERS',
|
|
||||||
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
|
|
||||||
'AdditionalIdentities': 'ADDITIONAL_IDENTITIES'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.KeyState = {
|
Enums.State = {
|
||||||
'All': 'all',
|
'Empty': 10,
|
||||||
'None': 'none',
|
'Login': 20,
|
||||||
'ContactList': 'contact-list',
|
'Auth': 30
|
||||||
'MessageList': 'message-list',
|
};
|
||||||
'FolderList': 'folder-list',
|
|
||||||
'MessageView': 'message-view',
|
|
||||||
'Compose': 'compose',
|
|
||||||
'Settings': 'settings',
|
|
||||||
'Menu': 'menu',
|
|
||||||
'PopupComposeOpenPGP': 'compose-open-pgp',
|
|
||||||
'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help',
|
|
||||||
'PopupAsk': 'popup-ask'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.FolderType = {
|
Enums.StateType = {
|
||||||
'Inbox': 10,
|
'Webmail': 0,
|
||||||
'SentItems': 11,
|
'Admin': 1
|
||||||
'Draft': 12,
|
};
|
||||||
'Trash': 13,
|
|
||||||
'Spam': 14,
|
|
||||||
'Archive': 15,
|
|
||||||
'NotSpam': 80,
|
|
||||||
'User': 99
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.LoginSignMeTypeAsString = {
|
Enums.Capa = {
|
||||||
'DefaultOff': 'defaultoff',
|
'Prem': 'PREM',
|
||||||
'DefaultOn': 'defaulton',
|
'TwoFactor': 'TWO_FACTOR',
|
||||||
'Unused': 'unused'
|
'OpenPGP': 'OPEN_PGP',
|
||||||
};
|
'Prefetch': 'PREFETCH',
|
||||||
|
'Gravatar': 'GRAVATAR',
|
||||||
|
'Themes': 'THEMES',
|
||||||
|
'Filters': 'FILTERS',
|
||||||
|
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
|
||||||
|
'AdditionalIdentities': 'ADDITIONAL_IDENTITIES'
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.LoginSignMeType = {
|
Enums.KeyState = {
|
||||||
'DefaultOff': 0,
|
'All': 'all',
|
||||||
'DefaultOn': 1,
|
'None': 'none',
|
||||||
'Unused': 2
|
'ContactList': 'contact-list',
|
||||||
};
|
'MessageList': 'message-list',
|
||||||
|
'FolderList': 'folder-list',
|
||||||
|
'MessageView': 'message-view',
|
||||||
|
'Compose': 'compose',
|
||||||
|
'Settings': 'settings',
|
||||||
|
'Menu': 'menu',
|
||||||
|
'PopupComposeOpenPGP': 'compose-open-pgp',
|
||||||
|
'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help',
|
||||||
|
'PopupAsk': 'popup-ask'
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.ComposeType = {
|
Enums.FolderType = {
|
||||||
'Empty': 'empty',
|
'Inbox': 10,
|
||||||
'Reply': 'reply',
|
'SentItems': 11,
|
||||||
'ReplyAll': 'replyall',
|
'Draft': 12,
|
||||||
'Forward': 'forward',
|
'Trash': 13,
|
||||||
'ForwardAsAttachment': 'forward-as-attachment',
|
'Spam': 14,
|
||||||
'Draft': 'draft',
|
'Archive': 15,
|
||||||
'EditAsNew': 'editasnew'
|
'NotSpam': 80,
|
||||||
};
|
'User': 99
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.UploadErrorCode = {
|
Enums.LoginSignMeTypeAsString = {
|
||||||
'Normal': 0,
|
'DefaultOff': 'defaultoff',
|
||||||
'FileIsTooBig': 1,
|
'DefaultOn': 'defaulton',
|
||||||
'FilePartiallyUploaded': 2,
|
'Unused': 'unused'
|
||||||
'FileNoUploaded': 3,
|
};
|
||||||
'MissingTempFolder': 4,
|
|
||||||
'FileOnSaveingError': 5,
|
|
||||||
'FileType': 98,
|
|
||||||
'Unknown': 99
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.SetSystemFoldersNotification = {
|
Enums.LoginSignMeType = {
|
||||||
'None': 0,
|
'DefaultOff': 0,
|
||||||
'Sent': 1,
|
'DefaultOn': 1,
|
||||||
'Draft': 2,
|
'Unused': 2
|
||||||
'Spam': 3,
|
};
|
||||||
'Trash': 4,
|
|
||||||
'Archive': 5
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.ClientSideKeyName = {
|
Enums.ComposeType = {
|
||||||
'FoldersLashHash': 0,
|
'Empty': 'empty',
|
||||||
'MessagesInboxLastHash': 1,
|
'Reply': 'reply',
|
||||||
'MailBoxListSize': 2,
|
'ReplyAll': 'replyall',
|
||||||
'ExpandedFolders': 3,
|
'Forward': 'forward',
|
||||||
'FolderListSize': 4
|
'ForwardAsAttachment': 'forward-as-attachment',
|
||||||
};
|
'Draft': 'draft',
|
||||||
|
'EditAsNew': 'editasnew'
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.EventKeyCode = {
|
Enums.UploadErrorCode = {
|
||||||
'Backspace': 8,
|
'Normal': 0,
|
||||||
'Tab': 9,
|
'FileIsTooBig': 1,
|
||||||
'Enter': 13,
|
'FilePartiallyUploaded': 2,
|
||||||
'Esc': 27,
|
'FileNoUploaded': 3,
|
||||||
'PageUp': 33,
|
'MissingTempFolder': 4,
|
||||||
'PageDown': 34,
|
'FileOnSaveingError': 5,
|
||||||
'Left': 37,
|
'FileType': 98,
|
||||||
'Right': 39,
|
'Unknown': 99
|
||||||
'Up': 38,
|
};
|
||||||
'Down': 40,
|
|
||||||
'End': 35,
|
|
||||||
'Home': 36,
|
|
||||||
'Space': 32,
|
|
||||||
'Insert': 45,
|
|
||||||
'Delete': 46,
|
|
||||||
'A': 65,
|
|
||||||
'S': 83
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.MessageSetAction = {
|
Enums.SetSystemFoldersNotification = {
|
||||||
'SetSeen': 0,
|
'None': 0,
|
||||||
'UnsetSeen': 1,
|
'Sent': 1,
|
||||||
'SetFlag': 2,
|
'Draft': 2,
|
||||||
'UnsetFlag': 3
|
'Spam': 3,
|
||||||
};
|
'Trash': 4,
|
||||||
|
'Archive': 5
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.MessageSelectAction = {
|
Enums.ClientSideKeyName = {
|
||||||
'All': 0,
|
'FoldersLashHash': 0,
|
||||||
'None': 1,
|
'MessagesInboxLastHash': 1,
|
||||||
'Invert': 2,
|
'MailBoxListSize': 2,
|
||||||
'Unseen': 3,
|
'ExpandedFolders': 3,
|
||||||
'Seen': 4,
|
'FolderListSize': 4
|
||||||
'Flagged': 5,
|
};
|
||||||
'Unflagged': 6
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.DesktopNotifications = {
|
Enums.EventKeyCode = {
|
||||||
'Allowed': 0,
|
'Backspace': 8,
|
||||||
'NotAllowed': 1,
|
'Tab': 9,
|
||||||
'Denied': 2,
|
'Enter': 13,
|
||||||
'NotSupported': 9
|
'Esc': 27,
|
||||||
};
|
'PageUp': 33,
|
||||||
|
'PageDown': 34,
|
||||||
|
'Left': 37,
|
||||||
|
'Right': 39,
|
||||||
|
'Up': 38,
|
||||||
|
'Down': 40,
|
||||||
|
'End': 35,
|
||||||
|
'Home': 36,
|
||||||
|
'Space': 32,
|
||||||
|
'Insert': 45,
|
||||||
|
'Delete': 46,
|
||||||
|
'A': 65,
|
||||||
|
'S': 83
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.MessagePriority = {
|
Enums.MessageSetAction = {
|
||||||
'Low': 5,
|
'SetSeen': 0,
|
||||||
'Normal': 3,
|
'UnsetSeen': 1,
|
||||||
'High': 1
|
'SetFlag': 2,
|
||||||
};
|
'UnsetFlag': 3
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.EditorDefaultType = {
|
Enums.MessageSelectAction = {
|
||||||
'Html': 'Html',
|
'All': 0,
|
||||||
'Plain': 'Plain'
|
'None': 1,
|
||||||
};
|
'Invert': 2,
|
||||||
|
'Unseen': 3,
|
||||||
|
'Seen': 4,
|
||||||
|
'Flagged': 5,
|
||||||
|
'Unflagged': 6
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.CustomThemeType = {
|
Enums.DesktopNotifications = {
|
||||||
'Light': 'Light',
|
'Allowed': 0,
|
||||||
'Dark': 'Dark'
|
'NotAllowed': 1,
|
||||||
};
|
'Denied': 2,
|
||||||
|
'NotSupported': 9
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.ServerSecure = {
|
Enums.MessagePriority = {
|
||||||
'None': 0,
|
'Low': 5,
|
||||||
'SSL': 1,
|
'Normal': 3,
|
||||||
'TLS': 2
|
'High': 1
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.SearchDateType = {
|
Enums.EditorDefaultType = {
|
||||||
'All': -1,
|
'Html': 'Html',
|
||||||
'Days3': 3,
|
'Plain': 'Plain'
|
||||||
'Days7': 7,
|
};
|
||||||
'Month': 30
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.EmailType = {
|
Enums.CustomThemeType = {
|
||||||
'Defailt': 0,
|
'Light': 'Light',
|
||||||
'Facebook': 1,
|
'Dark': 'Dark'
|
||||||
'Google': 2
|
};
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.SaveSettingsStep = {
|
Enums.ServerSecure = {
|
||||||
'Animate': -2,
|
'None': 0,
|
||||||
'Idle': -1,
|
'SSL': 1,
|
||||||
'TrueResult': 1,
|
'TLS': 2
|
||||||
'FalseResult': 0
|
};
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.InterfaceAnimation = {
|
Enums.SearchDateType = {
|
||||||
'None': 'None',
|
'All': -1,
|
||||||
'Normal': 'Normal',
|
'Days3': 3,
|
||||||
'Full': 'Full'
|
'Days7': 7,
|
||||||
};
|
'Month': 30
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.Layout = {
|
Enums.EmailType = {
|
||||||
'NoPreview': 0,
|
'Defailt': 0,
|
||||||
'SidePreview': 1,
|
'Facebook': 1,
|
||||||
'BottomPreview': 2
|
'Google': 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.FilterConditionField = {
|
Enums.SaveSettingsStep = {
|
||||||
'From': 'From',
|
'Animate': -2,
|
||||||
'To': 'To',
|
'Idle': -1,
|
||||||
'Recipient': 'Recipient',
|
'TrueResult': 1,
|
||||||
'Subject': 'Subject'
|
'FalseResult': 0
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.FilterConditionType = {
|
Enums.InterfaceAnimation = {
|
||||||
'Contains': 'Contains',
|
'None': 'None',
|
||||||
'NotContains': 'NotContains',
|
'Normal': 'Normal',
|
||||||
'EqualTo': 'EqualTo',
|
'Full': 'Full'
|
||||||
'NotEqualTo': 'NotEqualTo'
|
};
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
Enums.FiltersAction = {
|
Enums.Layout = {
|
||||||
'None': 'None',
|
'NoPreview': 0,
|
||||||
'Move': 'Move',
|
'SidePreview': 1,
|
||||||
'Discard': 'Discard',
|
'BottomPreview': 2
|
||||||
'Forward': 'Forward',
|
};
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.FilterRulesType = {
|
Enums.FilterConditionField = {
|
||||||
'And': 'And',
|
'From': 'From',
|
||||||
'Or': 'Or'
|
'To': 'To',
|
||||||
};
|
'Recipient': 'Recipient',
|
||||||
|
'Subject': 'Subject'
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.SignedVerifyStatus = {
|
Enums.FilterConditionType = {
|
||||||
'UnknownPublicKeys': -4,
|
'Contains': 'Contains',
|
||||||
'UnknownPrivateKey': -3,
|
'NotContains': 'NotContains',
|
||||||
'Unverified': -2,
|
'EqualTo': 'EqualTo',
|
||||||
'Error': -1,
|
'NotEqualTo': 'NotEqualTo'
|
||||||
'None': 0,
|
};
|
||||||
'Success': 1
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Enums.ContactPropertyType = {
|
Enums.FiltersAction = {
|
||||||
|
'None': 'None',
|
||||||
|
'Move': 'Move',
|
||||||
|
'Discard': 'Discard',
|
||||||
|
'Forward': 'Forward',
|
||||||
|
};
|
||||||
|
|
||||||
'Unknown': 0,
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
Enums.FilterRulesType = {
|
||||||
|
'And': 'And',
|
||||||
|
'Or': 'Or'
|
||||||
|
};
|
||||||
|
|
||||||
'FullName': 10,
|
/**
|
||||||
|
* @enum {number}
|
||||||
|
*/
|
||||||
|
Enums.SignedVerifyStatus = {
|
||||||
|
'UnknownPublicKeys': -4,
|
||||||
|
'UnknownPrivateKey': -3,
|
||||||
|
'Unverified': -2,
|
||||||
|
'Error': -1,
|
||||||
|
'None': 0,
|
||||||
|
'Success': 1
|
||||||
|
};
|
||||||
|
|
||||||
'FirstName': 15,
|
/**
|
||||||
'LastName': 16,
|
* @enum {number}
|
||||||
'MiddleName': 16,
|
*/
|
||||||
'Nick': 18,
|
Enums.ContactPropertyType = {
|
||||||
|
|
||||||
'NamePrefix': 20,
|
'Unknown': 0,
|
||||||
'NameSuffix': 21,
|
|
||||||
|
|
||||||
'Email': 30,
|
'FullName': 10,
|
||||||
'Phone': 31,
|
|
||||||
'Web': 32,
|
|
||||||
|
|
||||||
'Birthday': 40,
|
'FirstName': 15,
|
||||||
|
'LastName': 16,
|
||||||
|
'MiddleName': 16,
|
||||||
|
'Nick': 18,
|
||||||
|
|
||||||
'Facebook': 90,
|
'NamePrefix': 20,
|
||||||
'Skype': 91,
|
'NameSuffix': 21,
|
||||||
'GitHub': 92,
|
|
||||||
|
|
||||||
'Note': 110,
|
'Email': 30,
|
||||||
|
'Phone': 31,
|
||||||
|
'Web': 32,
|
||||||
|
|
||||||
'Custom': 250
|
'Birthday': 40,
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
'Facebook': 90,
|
||||||
* @enum {number}
|
'Skype': 91,
|
||||||
*/
|
'GitHub': 92,
|
||||||
Enums.Notification = {
|
|
||||||
'InvalidToken': 101,
|
|
||||||
'AuthError': 102,
|
|
||||||
'AccessError': 103,
|
|
||||||
'ConnectionError': 104,
|
|
||||||
'CaptchaError': 105,
|
|
||||||
'SocialFacebookLoginAccessDisable': 106,
|
|
||||||
'SocialTwitterLoginAccessDisable': 107,
|
|
||||||
'SocialGoogleLoginAccessDisable': 108,
|
|
||||||
'DomainNotAllowed': 109,
|
|
||||||
'AccountNotAllowed': 110,
|
|
||||||
|
|
||||||
'AccountTwoFactorAuthRequired': 120,
|
'Note': 110,
|
||||||
'AccountTwoFactorAuthError': 121,
|
|
||||||
|
|
||||||
'CouldNotSaveNewPassword': 130,
|
'Custom': 250
|
||||||
'CurrentPasswordIncorrect': 131,
|
};
|
||||||
'NewPasswordShort': 132,
|
|
||||||
'NewPasswordWeak': 133,
|
|
||||||
'NewPasswordForbidden': 134,
|
|
||||||
|
|
||||||
'ContactsSyncError': 140,
|
/**
|
||||||
|
* @enum {number}
|
||||||
|
*/
|
||||||
|
Enums.Notification = {
|
||||||
|
'InvalidToken': 101,
|
||||||
|
'AuthError': 102,
|
||||||
|
'AccessError': 103,
|
||||||
|
'ConnectionError': 104,
|
||||||
|
'CaptchaError': 105,
|
||||||
|
'SocialFacebookLoginAccessDisable': 106,
|
||||||
|
'SocialTwitterLoginAccessDisable': 107,
|
||||||
|
'SocialGoogleLoginAccessDisable': 108,
|
||||||
|
'DomainNotAllowed': 109,
|
||||||
|
'AccountNotAllowed': 110,
|
||||||
|
|
||||||
'CantGetMessageList': 201,
|
'AccountTwoFactorAuthRequired': 120,
|
||||||
'CantGetMessage': 202,
|
'AccountTwoFactorAuthError': 121,
|
||||||
'CantDeleteMessage': 203,
|
|
||||||
'CantMoveMessage': 204,
|
|
||||||
'CantCopyMessage': 205,
|
|
||||||
|
|
||||||
'CantSaveMessage': 301,
|
'CouldNotSaveNewPassword': 130,
|
||||||
'CantSendMessage': 302,
|
'CurrentPasswordIncorrect': 131,
|
||||||
'InvalidRecipients': 303,
|
'NewPasswordShort': 132,
|
||||||
|
'NewPasswordWeak': 133,
|
||||||
|
'NewPasswordForbidden': 134,
|
||||||
|
|
||||||
'CantCreateFolder': 400,
|
'ContactsSyncError': 140,
|
||||||
'CantRenameFolder': 401,
|
|
||||||
'CantDeleteFolder': 402,
|
|
||||||
'CantSubscribeFolder': 403,
|
|
||||||
'CantUnsubscribeFolder': 404,
|
|
||||||
'CantDeleteNonEmptyFolder': 405,
|
|
||||||
|
|
||||||
'CantSaveSettings': 501,
|
'CantGetMessageList': 201,
|
||||||
'CantSavePluginSettings': 502,
|
'CantGetMessage': 202,
|
||||||
|
'CantDeleteMessage': 203,
|
||||||
|
'CantMoveMessage': 204,
|
||||||
|
'CantCopyMessage': 205,
|
||||||
|
|
||||||
'DomainAlreadyExists': 601,
|
'CantSaveMessage': 301,
|
||||||
|
'CantSendMessage': 302,
|
||||||
|
'InvalidRecipients': 303,
|
||||||
|
|
||||||
'CantInstallPackage': 701,
|
'CantCreateFolder': 400,
|
||||||
'CantDeletePackage': 702,
|
'CantRenameFolder': 401,
|
||||||
'InvalidPluginPackage': 703,
|
'CantDeleteFolder': 402,
|
||||||
'UnsupportedPluginPackage': 704,
|
'CantSubscribeFolder': 403,
|
||||||
|
'CantUnsubscribeFolder': 404,
|
||||||
|
'CantDeleteNonEmptyFolder': 405,
|
||||||
|
|
||||||
'LicensingServerIsUnavailable': 710,
|
'CantSaveSettings': 501,
|
||||||
'LicensingExpired': 711,
|
'CantSavePluginSettings': 502,
|
||||||
'LicensingBanned': 712,
|
|
||||||
|
|
||||||
'DemoSendMessageError': 750,
|
'DomainAlreadyExists': 601,
|
||||||
|
|
||||||
'AccountAlreadyExists': 801,
|
'CantInstallPackage': 701,
|
||||||
|
'CantDeletePackage': 702,
|
||||||
|
'InvalidPluginPackage': 703,
|
||||||
|
'UnsupportedPluginPackage': 704,
|
||||||
|
|
||||||
'MailServerError': 901,
|
'LicensingServerIsUnavailable': 710,
|
||||||
'ClientViewError': 902,
|
'LicensingExpired': 711,
|
||||||
'InvalidInputArgument': 903,
|
'LicensingBanned': 712,
|
||||||
'UnknownNotification': 999,
|
|
||||||
'UnknownError': 999
|
'DemoSendMessageError': 750,
|
||||||
};
|
|
||||||
|
'AccountAlreadyExists': 801,
|
||||||
|
|
||||||
|
'MailServerError': 901,
|
||||||
|
'ClientViewError': 902,
|
||||||
|
'InvalidInputArgument': 903,
|
||||||
|
'UnknownNotification': 999,
|
||||||
|
'UnknownError': 999
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = Enums;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,157 +1,184 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @type {?}
|
|
||||||
*/
|
|
||||||
Globals.now = (new Date()).getTime();
|
|
||||||
|
|
||||||
/**
|
'use strict';
|
||||||
* @type {?}
|
|
||||||
*/
|
|
||||||
Globals.momentTrigger = ko.observable(true);
|
|
||||||
|
|
||||||
/**
|
var
|
||||||
* @type {?}
|
Globals = {},
|
||||||
*/
|
window = require('../External/window.js'),
|
||||||
Globals.dropdownVisibility = ko.observable(false).extend({'rateLimit': 0});
|
ko = require('../External/ko.js'),
|
||||||
|
$html = require('../External/$html.js')
|
||||||
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {?}
|
* @type {?}
|
||||||
*/
|
*/
|
||||||
Globals.tooltipTrigger = ko.observable(false).extend({'rateLimit': 0});
|
Globals.now = (new window.Date()).getTime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {?}
|
* @type {?}
|
||||||
*/
|
*/
|
||||||
Globals.langChangeTrigger = ko.observable(true);
|
Globals.momentTrigger = ko.observable(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {?}
|
||||||
*/
|
*/
|
||||||
Globals.iAjaxErrorCount = 0;
|
Globals.dropdownVisibility = ko.observable(false).extend({'rateLimit': 0});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {?}
|
||||||
*/
|
*/
|
||||||
Globals.iTokenErrorCount = 0;
|
Globals.tooltipTrigger = ko.observable(false).extend({'rateLimit': 0});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {?}
|
||||||
*/
|
*/
|
||||||
Globals.iMessageBodyCacheCount = 0;
|
Globals.langChangeTrigger = ko.observable(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
Globals.bUnload = false;
|
Globals.iAjaxErrorCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
Globals.sUserAgent = (navigator.userAgent || '').toLowerCase();
|
Globals.iTokenErrorCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
Globals.bIsiOSDevice = -1 < Globals.sUserAgent.indexOf('iphone') || -1 < Globals.sUserAgent.indexOf('ipod') || -1 < Globals.sUserAgent.indexOf('ipad');
|
Globals.iMessageBodyCacheCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
|
Globals.bUnload = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
Globals.sUserAgent = (window.navigator.userAgent || '').toLowerCase();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
Globals.bIsiOSDevice = -1 < Globals.sUserAgent.indexOf('iphone') || -1 < Globals.sUserAgent.indexOf('ipod') || -1 < Globals.sUserAgent.indexOf('ipad');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
Globals.bXMLHttpRequestSupported = !!window.XMLHttpRequest;
|
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
Globals.sAnimationType = '';
|
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
Globals.oHtmlEditorDefaultConfig = {
|
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
||||||
'title': false,
|
|
||||||
'stylesSet': false,
|
|
||||||
'customConfig': '',
|
|
||||||
'contentsCss': '',
|
|
||||||
'toolbarGroups': [
|
|
||||||
{name: 'spec'},
|
|
||||||
{name: 'styles'},
|
|
||||||
{name: 'basicstyles', groups: ['basicstyles', 'cleanup']},
|
|
||||||
{name: 'colors'},
|
|
||||||
{name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align']},
|
|
||||||
{name: 'links'},
|
|
||||||
{name: 'insert'},
|
|
||||||
{name: 'others'}
|
|
||||||
// {name: 'document', groups: ['mode', 'document', 'doctools']}
|
|
||||||
],
|
|
||||||
|
|
||||||
'removePlugins': 'contextmenu', //blockquote
|
/**
|
||||||
'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll',
|
* @type {boolean}
|
||||||
'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced',
|
*/
|
||||||
|
Globals.bXMLHttpRequestSupported = !!window.XMLHttpRequest;
|
||||||
|
|
||||||
'extraPlugins': 'plain',
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
Globals.sAnimationType = '';
|
||||||
|
|
||||||
'allowedContent': true,
|
/**
|
||||||
'autoParagraph': false,
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
Globals.oHtmlEditorDefaultConfig = {
|
||||||
|
'title': false,
|
||||||
|
'stylesSet': false,
|
||||||
|
'customConfig': '',
|
||||||
|
'contentsCss': '',
|
||||||
|
'toolbarGroups': [
|
||||||
|
{name: 'spec'},
|
||||||
|
{name: 'styles'},
|
||||||
|
{name: 'basicstyles', groups: ['basicstyles', 'cleanup']},
|
||||||
|
{name: 'colors'},
|
||||||
|
{name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align']},
|
||||||
|
{name: 'links'},
|
||||||
|
{name: 'insert'},
|
||||||
|
{name: 'others'}
|
||||||
|
// {name: 'document', groups: ['mode', 'document', 'doctools']}
|
||||||
|
],
|
||||||
|
|
||||||
'font_defaultLabel': 'Arial',
|
'removePlugins': 'contextmenu', //blockquote
|
||||||
'fontSize_defaultLabel': '13',
|
'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll',
|
||||||
'fontSize_sizes': '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px'
|
'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced',
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
'extraPlugins': 'plain',
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
Globals.oHtmlEditorLangsMap = {
|
|
||||||
'de': 'de',
|
|
||||||
'es': 'es',
|
|
||||||
'fr': 'fr',
|
|
||||||
'hu': 'hu',
|
|
||||||
'is': 'is',
|
|
||||||
'it': 'it',
|
|
||||||
'ko': 'ko',
|
|
||||||
'ko-kr': 'ko',
|
|
||||||
'lv': 'lv',
|
|
||||||
'nl': 'nl',
|
|
||||||
'no': 'no',
|
|
||||||
'pl': 'pl',
|
|
||||||
'pt': 'pt',
|
|
||||||
'pt-pt': 'pt',
|
|
||||||
'pt-br': 'pt-br',
|
|
||||||
'ru': 'ru',
|
|
||||||
'ro': 'ro',
|
|
||||||
'zh': 'zh',
|
|
||||||
'zh-cn': 'zh-cn'
|
|
||||||
};
|
|
||||||
|
|
||||||
if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
|
'allowedContent': true,
|
||||||
{
|
'autoParagraph': false,
|
||||||
Globals.bAllowPdfPreview = !!_.find(navigator.mimeTypes, function (oType) {
|
|
||||||
return oType && 'application/pdf' === oType.type;
|
'font_defaultLabel': 'Arial',
|
||||||
});
|
'fontSize_defaultLabel': '13',
|
||||||
}
|
'fontSize_sizes': '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px'
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
Globals.oHtmlEditorLangsMap = {
|
||||||
|
'de': 'de',
|
||||||
|
'es': 'es',
|
||||||
|
'fr': 'fr',
|
||||||
|
'hu': 'hu',
|
||||||
|
'is': 'is',
|
||||||
|
'it': 'it',
|
||||||
|
'ko': 'ko',
|
||||||
|
'ko-kr': 'ko',
|
||||||
|
'lv': 'lv',
|
||||||
|
'nl': 'nl',
|
||||||
|
'no': 'no',
|
||||||
|
'pl': 'pl',
|
||||||
|
'pt': 'pt',
|
||||||
|
'pt-pt': 'pt',
|
||||||
|
'pt-br': 'pt-br',
|
||||||
|
'ru': 'ru',
|
||||||
|
'ro': 'ro',
|
||||||
|
'zh': 'zh',
|
||||||
|
'zh-cn': 'zh-cn'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Globals.bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
|
||||||
|
{
|
||||||
|
Globals.bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function (oType) {
|
||||||
|
return oType && 'application/pdf' === oType.type;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Globals.oI18N = {},
|
||||||
|
|
||||||
|
Globals.oNotificationI18N = {},
|
||||||
|
|
||||||
|
Globals.aBootstrapDropdowns = [],
|
||||||
|
|
||||||
|
Globals.aViewModels = {
|
||||||
|
'settings': [],
|
||||||
|
'settings-removed': [],
|
||||||
|
'settings-disabled': []
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = Globals;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,846 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
ko.bindingHandlers.tooltip = {
|
|
||||||
'init': function (oElement, fValueAccessor) {
|
|
||||||
if (!Globals.bMobileDevice)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
$oEl = $(oElement),
|
|
||||||
sClass = $oEl.data('tooltip-class') || '',
|
|
||||||
sPlacement = $oEl.data('tooltip-placement') || 'top'
|
|
||||||
;
|
|
||||||
|
|
||||||
$oEl.tooltip({
|
|
||||||
'delay': {
|
|
||||||
'show': 500,
|
|
||||||
'hide': 100
|
|
||||||
},
|
|
||||||
'html': true,
|
|
||||||
'container': 'body',
|
|
||||||
'placement': sPlacement,
|
|
||||||
'trigger': 'hover',
|
|
||||||
'title': function () {
|
|
||||||
return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' : '<span class="tooltip-class ' + sClass + '">' +
|
|
||||||
Utils.i18n(ko.utils.unwrapObservable(fValueAccessor())) + '</span>';
|
|
||||||
}
|
|
||||||
}).click(function () {
|
|
||||||
$oEl.tooltip('hide');
|
|
||||||
});
|
|
||||||
|
|
||||||
Globals.tooltipTrigger.subscribe(function () {
|
|
||||||
$oEl.tooltip('hide');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.tooltip2 = {
|
|
||||||
'init': function (oElement, fValueAccessor) {
|
|
||||||
var
|
|
||||||
$oEl = $(oElement),
|
|
||||||
sClass = $oEl.data('tooltip-class') || '',
|
|
||||||
sPlacement = $oEl.data('tooltip-placement') || 'top'
|
|
||||||
;
|
|
||||||
|
|
||||||
$oEl.tooltip({
|
|
||||||
'delay': {
|
|
||||||
'show': 500,
|
|
||||||
'hide': 100
|
|
||||||
},
|
|
||||||
'html': true,
|
|
||||||
'container': 'body',
|
|
||||||
'placement': sPlacement,
|
|
||||||
'title': function () {
|
|
||||||
return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' :
|
|
||||||
'<span class="tooltip-class ' + sClass + '">' + fValueAccessor()() + '</span>';
|
|
||||||
}
|
|
||||||
}).click(function () {
|
|
||||||
$oEl.tooltip('hide');
|
|
||||||
});
|
|
||||||
|
|
||||||
Globals.tooltipTrigger.subscribe(function () {
|
|
||||||
$oEl.tooltip('hide');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.tooltip3 = {
|
|
||||||
'init': function (oElement) {
|
|
||||||
|
|
||||||
var $oEl = $(oElement);
|
|
||||||
|
|
||||||
$oEl.tooltip({
|
|
||||||
'container': 'body',
|
|
||||||
'trigger': 'hover manual',
|
|
||||||
'title': function () {
|
|
||||||
return $oEl.data('tooltip3-data') || '';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$document.click(function () {
|
|
||||||
$oEl.tooltip('hide');
|
|
||||||
});
|
|
||||||
|
|
||||||
Globals.tooltipTrigger.subscribe(function () {
|
|
||||||
$oEl.tooltip('hide');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
var sValue = ko.utils.unwrapObservable(fValueAccessor());
|
|
||||||
if ('' === sValue)
|
|
||||||
{
|
|
||||||
$(oElement).data('tooltip3-data', '').tooltip('hide');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$(oElement).data('tooltip3-data', sValue).tooltip('show');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.registrateBootstrapDropdown = {
|
|
||||||
'init': function (oElement) {
|
|
||||||
BootstrapDropdowns.push($(oElement));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.openDropdownTrigger = {
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
if (ko.utils.unwrapObservable(fValueAccessor()))
|
|
||||||
{
|
|
||||||
var $el = $(oElement);
|
|
||||||
if (!$el.hasClass('open'))
|
|
||||||
{
|
|
||||||
$el.find('.dropdown-toggle').dropdown('toggle');
|
|
||||||
Utils.detectDropdownVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
fValueAccessor()(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.dropdownCloser = {
|
|
||||||
'init': function (oElement) {
|
|
||||||
$(oElement).closest('.dropdown').on('click', '.e-item', function () {
|
|
||||||
$(oElement).dropdown('toggle');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.popover = {
|
|
||||||
'init': function (oElement, fValueAccessor) {
|
|
||||||
$(oElement).popover(ko.utils.unwrapObservable(fValueAccessor()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.csstext = {
|
|
||||||
'init': function (oElement, fValueAccessor) {
|
|
||||||
if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText))
|
|
||||||
{
|
|
||||||
oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$(oElement).text(ko.utils.unwrapObservable(fValueAccessor()));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText))
|
|
||||||
{
|
|
||||||
oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$(oElement).text(ko.utils.unwrapObservable(fValueAccessor()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.resizecrop = {
|
|
||||||
'init': function (oElement) {
|
|
||||||
$(oElement).addClass('resizecrop').resizecrop({
|
|
||||||
'width': '100',
|
|
||||||
'height': '100',
|
|
||||||
'wrapperCSS': {
|
|
||||||
'border-radius': '10px'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
fValueAccessor()();
|
|
||||||
$(oElement).resizecrop({
|
|
||||||
'width': '100',
|
|
||||||
'height': '100'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.onEnter = {
|
|
||||||
'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
|
|
||||||
$(oElement).on('keypress', function (oEvent) {
|
|
||||||
if (oEvent && 13 === window.parseInt(oEvent.keyCode, 10))
|
|
||||||
{
|
|
||||||
$(oElement).trigger('change');
|
|
||||||
fValueAccessor().call(oViewModel);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.onEsc = {
|
|
||||||
'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
|
|
||||||
$(oElement).on('keypress', function (oEvent) {
|
|
||||||
if (oEvent && 27 === window.parseInt(oEvent.keyCode, 10))
|
|
||||||
{
|
|
||||||
$(oElement).trigger('change');
|
|
||||||
fValueAccessor().call(oViewModel);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.clickOnTrue = {
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
if (ko.utils.unwrapObservable(fValueAccessor()))
|
|
||||||
{
|
|
||||||
$(oElement).click();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.modal = {
|
|
||||||
'init': function (oElement, fValueAccessor) {
|
|
||||||
|
|
||||||
$(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({
|
|
||||||
'keyboard': false,
|
|
||||||
'show': ko.utils.unwrapObservable(fValueAccessor())
|
|
||||||
})
|
|
||||||
.on('shown', function () {
|
|
||||||
Utils.windowResize();
|
|
||||||
})
|
|
||||||
.find('.close').click(function () {
|
|
||||||
fValueAccessor()(false);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
$(oElement).modal(ko.utils.unwrapObservable(fValueAccessor()) ? 'show' : 'hide');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.i18nInit = {
|
|
||||||
'init': function (oElement) {
|
|
||||||
Utils.i18nToNode(oElement);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.i18nUpdate = {
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
ko.utils.unwrapObservable(fValueAccessor());
|
|
||||||
Utils.i18nToNode(oElement);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.link = {
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
$(oElement).attr('href', ko.utils.unwrapObservable(fValueAccessor()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.title = {
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
$(oElement).attr('title', ko.utils.unwrapObservable(fValueAccessor()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.textF = {
|
|
||||||
'init': function (oElement, fValueAccessor) {
|
|
||||||
$(oElement).text(ko.utils.unwrapObservable(fValueAccessor()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.initDom = {
|
|
||||||
'init': function (oElement, fValueAccessor) {
|
|
||||||
fValueAccessor()(oElement);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.initResizeTrigger = {
|
|
||||||
'init': function (oElement, fValueAccessor) {
|
|
||||||
var aValues = ko.utils.unwrapObservable(fValueAccessor());
|
|
||||||
$(oElement).css({
|
|
||||||
'height': aValues[1],
|
|
||||||
'min-height': aValues[1]
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
var
|
|
||||||
aValues = ko.utils.unwrapObservable(fValueAccessor()),
|
|
||||||
iValue = Utils.pInt(aValues[1]),
|
|
||||||
iSize = 0,
|
|
||||||
iOffset = $(oElement).offset().top
|
|
||||||
;
|
|
||||||
|
|
||||||
if (0 < iOffset)
|
|
||||||
{
|
|
||||||
iOffset += Utils.pInt(aValues[2]);
|
|
||||||
iSize = $window.height() - iOffset;
|
|
||||||
|
|
||||||
if (iValue < iSize)
|
|
||||||
{
|
|
||||||
iValue = iSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(oElement).css({
|
|
||||||
'height': iValue,
|
|
||||||
'min-height': iValue
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.appendDom = {
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
$(oElement).hide().empty().append(ko.utils.unwrapObservable(fValueAccessor())).show();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.draggable = {
|
|
||||||
'init': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
|
||||||
|
|
||||||
if (!Globals.bMobileDevice)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
iTriggerZone = 100,
|
|
||||||
iScrollSpeed = 3,
|
|
||||||
fAllValueFunc = fAllBindingsAccessor(),
|
|
||||||
sDroppableSelector = fAllValueFunc && fAllValueFunc['droppableSelector'] ? fAllValueFunc['droppableSelector'] : '',
|
|
||||||
oConf = {
|
|
||||||
'distance': 20,
|
|
||||||
'handle': '.dragHandle',
|
|
||||||
'cursorAt': {'top': 22, 'left': 3},
|
|
||||||
'refreshPositions': true,
|
|
||||||
'scroll': true
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
if (sDroppableSelector)
|
|
||||||
{
|
|
||||||
oConf['drag'] = function (oEvent) {
|
|
||||||
|
|
||||||
$(sDroppableSelector).each(function () {
|
|
||||||
var
|
|
||||||
moveUp = null,
|
|
||||||
moveDown = null,
|
|
||||||
$this = $(this),
|
|
||||||
oOffset = $this.offset(),
|
|
||||||
bottomPos = oOffset.top + $this.height()
|
|
||||||
;
|
|
||||||
|
|
||||||
window.clearInterval($this.data('timerScroll'));
|
|
||||||
$this.data('timerScroll', false);
|
|
||||||
|
|
||||||
if (oEvent.pageX >= oOffset.left && oEvent.pageX <= oOffset.left + $this.width())
|
|
||||||
{
|
|
||||||
if (oEvent.pageY >= bottomPos - iTriggerZone && oEvent.pageY <= bottomPos)
|
|
||||||
{
|
|
||||||
moveUp = function() {
|
|
||||||
$this.scrollTop($this.scrollTop() + iScrollSpeed);
|
|
||||||
Utils.windowResize();
|
|
||||||
};
|
|
||||||
|
|
||||||
$this.data('timerScroll', window.setInterval(moveUp, 10));
|
|
||||||
moveUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oEvent.pageY >= oOffset.top && oEvent.pageY <= oOffset.top + iTriggerZone)
|
|
||||||
{
|
|
||||||
moveDown = function() {
|
|
||||||
$this.scrollTop($this.scrollTop() - iScrollSpeed);
|
|
||||||
Utils.windowResize();
|
|
||||||
};
|
|
||||||
|
|
||||||
$this.data('timerScroll', window.setInterval(moveDown, 10));
|
|
||||||
moveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
oConf['stop'] = function() {
|
|
||||||
$(sDroppableSelector).each(function () {
|
|
||||||
window.clearInterval($(this).data('timerScroll'));
|
|
||||||
$(this).data('timerScroll', false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
oConf['helper'] = function (oEvent) {
|
|
||||||
return fValueAccessor()(oEvent && oEvent.target ? ko.dataFor(oEvent.target) : null);
|
|
||||||
};
|
|
||||||
|
|
||||||
$(oElement).draggable(oConf).on('mousedown', function () {
|
|
||||||
Utils.removeInFocus();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.droppable = {
|
|
||||||
'init': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
|
||||||
|
|
||||||
if (!Globals.bMobileDevice)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
fValueFunc = fValueAccessor(),
|
|
||||||
fAllValueFunc = fAllBindingsAccessor(),
|
|
||||||
fOverCallback = fAllValueFunc && fAllValueFunc['droppableOver'] ? fAllValueFunc['droppableOver'] : null,
|
|
||||||
fOutCallback = fAllValueFunc && fAllValueFunc['droppableOut'] ? fAllValueFunc['droppableOut'] : null,
|
|
||||||
oConf = {
|
|
||||||
'tolerance': 'pointer',
|
|
||||||
'hoverClass': 'droppableHover'
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
if (fValueFunc)
|
|
||||||
{
|
|
||||||
oConf['drop'] = function (oEvent, oUi) {
|
|
||||||
fValueFunc(oEvent, oUi);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (fOverCallback)
|
|
||||||
{
|
|
||||||
oConf['over'] = function (oEvent, oUi) {
|
|
||||||
fOverCallback(oEvent, oUi);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fOutCallback)
|
|
||||||
{
|
|
||||||
oConf['out'] = function (oEvent, oUi) {
|
|
||||||
fOutCallback(oEvent, oUi);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
$(oElement).droppable(oConf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.nano = {
|
|
||||||
'init': function (oElement) {
|
|
||||||
if (!Globals.bDisableNanoScroll)
|
|
||||||
{
|
|
||||||
$(oElement)
|
|
||||||
.addClass('nano')
|
|
||||||
.nanoScroller({
|
|
||||||
'iOSNativeScrolling': false,
|
|
||||||
'preventPageScrolling': true
|
|
||||||
})
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.saveTrigger = {
|
|
||||||
'init': function (oElement) {
|
|
||||||
|
|
||||||
var $oEl = $(oElement);
|
|
||||||
|
|
||||||
$oEl.data('save-trigger-type', $oEl.is('input[type=text],input[type=email],input[type=password],select,textarea') ? 'input' : 'custom');
|
|
||||||
|
|
||||||
if ('custom' === $oEl.data('save-trigger-type'))
|
|
||||||
{
|
|
||||||
$oEl.append(
|
|
||||||
' <i class="icon-spinner animated"></i><i class="icon-remove error"></i><i class="icon-ok success"></i>'
|
|
||||||
).addClass('settings-saved-trigger');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$oEl.addClass('settings-saved-trigger-input');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
var
|
|
||||||
mValue = ko.utils.unwrapObservable(fValueAccessor()),
|
|
||||||
$oEl = $(oElement)
|
|
||||||
;
|
|
||||||
|
|
||||||
if ('custom' === $oEl.data('save-trigger-type'))
|
|
||||||
{
|
|
||||||
switch (mValue.toString())
|
|
||||||
{
|
|
||||||
case '1':
|
|
||||||
$oEl
|
|
||||||
.find('.animated,.error').hide().removeClass('visible')
|
|
||||||
.end()
|
|
||||||
.find('.success').show().addClass('visible')
|
|
||||||
;
|
|
||||||
break;
|
|
||||||
case '0':
|
|
||||||
$oEl
|
|
||||||
.find('.animated,.success').hide().removeClass('visible')
|
|
||||||
.end()
|
|
||||||
.find('.error').show().addClass('visible')
|
|
||||||
;
|
|
||||||
break;
|
|
||||||
case '-2':
|
|
||||||
$oEl
|
|
||||||
.find('.error,.success').hide().removeClass('visible')
|
|
||||||
.end()
|
|
||||||
.find('.animated').show().addClass('visible')
|
|
||||||
;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$oEl
|
|
||||||
.find('.animated').hide()
|
|
||||||
.end()
|
|
||||||
.find('.error,.success').removeClass('visible')
|
|
||||||
;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (mValue.toString())
|
|
||||||
{
|
|
||||||
case '1':
|
|
||||||
$oEl.addClass('success').removeClass('error');
|
|
||||||
break;
|
|
||||||
case '0':
|
|
||||||
$oEl.addClass('error').removeClass('success');
|
|
||||||
break;
|
|
||||||
case '-2':
|
|
||||||
// $oEl;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$oEl.removeClass('error success');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.emailsTags = {
|
|
||||||
'init': function(oElement, fValueAccessor) {
|
|
||||||
var
|
|
||||||
$oEl = $(oElement),
|
|
||||||
fValue = fValueAccessor(),
|
|
||||||
fFocusCallback = function (bValue) {
|
|
||||||
if (fValue && fValue.focusTrigger)
|
|
||||||
{
|
|
||||||
fValue.focusTrigger(bValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
$oEl.inputosaurus({
|
|
||||||
'parseOnBlur': true,
|
|
||||||
'allowDragAndDrop': true,
|
|
||||||
'focusCallback': fFocusCallback,
|
|
||||||
'inputDelimiters': [',', ';'],
|
|
||||||
'autoCompleteSource': function (oData, fResponse) {
|
|
||||||
RL.getAutocomplete(oData.term, function (aData) {
|
|
||||||
fResponse(_.map(aData, function (oEmailItem) {
|
|
||||||
return oEmailItem.toLine(false);
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'parseHook': function (aInput) {
|
|
||||||
return _.map(aInput, function (sInputValue) {
|
|
||||||
|
|
||||||
var
|
|
||||||
sValue = Utils.trim(sInputValue),
|
|
||||||
oEmail = null
|
|
||||||
;
|
|
||||||
|
|
||||||
if ('' !== sValue)
|
|
||||||
{
|
|
||||||
oEmail = new EmailModel();
|
|
||||||
oEmail.mailsoParse(sValue);
|
|
||||||
oEmail.clearDuplicateName();
|
|
||||||
return [oEmail.toLine(false), oEmail];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [sValue, null];
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'change': _.bind(function (oEvent) {
|
|
||||||
$oEl.data('EmailsTagsValue', oEvent.target.value);
|
|
||||||
fValue(oEvent.target.value);
|
|
||||||
}, this)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
|
||||||
|
|
||||||
var
|
|
||||||
$oEl = $(oElement),
|
|
||||||
fAllValueFunc = fAllBindingsAccessor(),
|
|
||||||
fEmailsTagsFilter = fAllValueFunc['emailsTagsFilter'] || null,
|
|
||||||
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
|
||||||
;
|
|
||||||
|
|
||||||
if ($oEl.data('EmailsTagsValue') !== sValue)
|
|
||||||
{
|
|
||||||
$oEl.val(sValue);
|
|
||||||
$oEl.data('EmailsTagsValue', sValue);
|
|
||||||
$oEl.inputosaurus('refresh');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter))
|
|
||||||
{
|
|
||||||
$oEl.inputosaurus('focus');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.contactTags = {
|
|
||||||
'init': function(oElement, fValueAccessor) {
|
|
||||||
var
|
|
||||||
$oEl = $(oElement),
|
|
||||||
fValue = fValueAccessor(),
|
|
||||||
fFocusCallback = function (bValue) {
|
|
||||||
if (fValue && fValue.focusTrigger)
|
|
||||||
{
|
|
||||||
fValue.focusTrigger(bValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
$oEl.inputosaurus({
|
|
||||||
'parseOnBlur': true,
|
|
||||||
'allowDragAndDrop': false,
|
|
||||||
'focusCallback': fFocusCallback,
|
|
||||||
'inputDelimiters': [',', ';'],
|
|
||||||
'outputDelimiter': ',',
|
|
||||||
'autoCompleteSource': function (oData, fResponse) {
|
|
||||||
RL.getContactTagsAutocomplete(oData.term, function (aData) {
|
|
||||||
fResponse(_.map(aData, function (oTagItem) {
|
|
||||||
return oTagItem.toLine(false);
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'parseHook': function (aInput) {
|
|
||||||
return _.map(aInput, function (sInputValue) {
|
|
||||||
|
|
||||||
var
|
|
||||||
sValue = Utils.trim(sInputValue),
|
|
||||||
oTag = null
|
|
||||||
;
|
|
||||||
|
|
||||||
if ('' !== sValue)
|
|
||||||
{
|
|
||||||
oTag = new ContactTagModel();
|
|
||||||
oTag.name(sValue);
|
|
||||||
return [oTag.toLine(false), oTag];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [sValue, null];
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'change': _.bind(function (oEvent) {
|
|
||||||
$oEl.data('ContactTagsValue', oEvent.target.value);
|
|
||||||
fValue(oEvent.target.value);
|
|
||||||
}, this)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
|
||||||
|
|
||||||
var
|
|
||||||
$oEl = $(oElement),
|
|
||||||
fAllValueFunc = fAllBindingsAccessor(),
|
|
||||||
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
|
|
||||||
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
|
||||||
;
|
|
||||||
|
|
||||||
if ($oEl.data('ContactTagsValue') !== sValue)
|
|
||||||
{
|
|
||||||
$oEl.val(sValue);
|
|
||||||
$oEl.data('ContactTagsValue', sValue);
|
|
||||||
$oEl.inputosaurus('refresh');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
|
|
||||||
{
|
|
||||||
$oEl.inputosaurus('focus');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.bindingHandlers.command = {
|
|
||||||
'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
|
|
||||||
var
|
|
||||||
jqElement = $(oElement),
|
|
||||||
oCommand = fValueAccessor()
|
|
||||||
;
|
|
||||||
|
|
||||||
if (!oCommand || !oCommand.enabled || !oCommand.canExecute)
|
|
||||||
{
|
|
||||||
throw new Error('You are not using command function');
|
|
||||||
}
|
|
||||||
|
|
||||||
jqElement.addClass('command');
|
|
||||||
ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click'].init.apply(oViewModel, arguments);
|
|
||||||
},
|
|
||||||
|
|
||||||
'update': function (oElement, fValueAccessor) {
|
|
||||||
|
|
||||||
var
|
|
||||||
bResult = true,
|
|
||||||
jqElement = $(oElement),
|
|
||||||
oCommand = fValueAccessor()
|
|
||||||
;
|
|
||||||
|
|
||||||
bResult = oCommand.enabled();
|
|
||||||
jqElement.toggleClass('command-not-enabled', !bResult);
|
|
||||||
|
|
||||||
if (bResult)
|
|
||||||
{
|
|
||||||
bResult = oCommand.canExecute();
|
|
||||||
jqElement.toggleClass('command-can-not-be-execute', !bResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
jqElement.toggleClass('command-disabled disable disabled', !bResult).toggleClass('no-disabled', !!bResult);
|
|
||||||
|
|
||||||
if (jqElement.is('input') || jqElement.is('button'))
|
|
||||||
{
|
|
||||||
jqElement.prop('disabled', !bResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.extenders.trimmer = function (oTarget)
|
|
||||||
{
|
|
||||||
var oResult = ko.computed({
|
|
||||||
'read': oTarget,
|
|
||||||
'write': function (sNewValue) {
|
|
||||||
oTarget(Utils.trim(sNewValue.toString()));
|
|
||||||
},
|
|
||||||
'owner': this
|
|
||||||
});
|
|
||||||
|
|
||||||
oResult(oTarget());
|
|
||||||
return oResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.extenders.posInterer = function (oTarget, iDefault)
|
|
||||||
{
|
|
||||||
var oResult = ko.computed({
|
|
||||||
'read': oTarget,
|
|
||||||
'write': function (sNewValue) {
|
|
||||||
var iNew = Utils.pInt(sNewValue.toString(), iDefault);
|
|
||||||
if (0 >= iNew)
|
|
||||||
{
|
|
||||||
iNew = iDefault;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iNew === oTarget() && '' + iNew !== '' + sNewValue)
|
|
||||||
{
|
|
||||||
oTarget(iNew + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
oTarget(iNew);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
oResult(oTarget());
|
|
||||||
return oResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.extenders.reversible = function (oTarget)
|
|
||||||
{
|
|
||||||
var mValue = oTarget();
|
|
||||||
|
|
||||||
oTarget.commit = function ()
|
|
||||||
{
|
|
||||||
mValue = oTarget();
|
|
||||||
};
|
|
||||||
|
|
||||||
oTarget.reverse = function ()
|
|
||||||
{
|
|
||||||
oTarget(mValue);
|
|
||||||
};
|
|
||||||
|
|
||||||
oTarget.commitedValue = function ()
|
|
||||||
{
|
|
||||||
return mValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
return oTarget;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.extenders.toggleSubscribe = function (oTarget, oOptions)
|
|
||||||
{
|
|
||||||
oTarget.subscribe(oOptions[1], oOptions[0], 'beforeChange');
|
|
||||||
oTarget.subscribe(oOptions[2], oOptions[0]);
|
|
||||||
|
|
||||||
return oTarget;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.extenders.falseTimeout = function (oTarget, iOption)
|
|
||||||
{
|
|
||||||
oTarget.iTimeout = 0;
|
|
||||||
oTarget.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
|
||||||
window.clearTimeout(oTarget.iTimeout);
|
|
||||||
oTarget.iTimeout = window.setTimeout(function () {
|
|
||||||
oTarget(false);
|
|
||||||
oTarget.iTimeout = 0;
|
|
||||||
}, Utils.pInt(iOption));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return oTarget;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.observable.fn.validateNone = function ()
|
|
||||||
{
|
|
||||||
this.hasError = ko.observable(false);
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.observable.fn.validateEmail = function ()
|
|
||||||
{
|
|
||||||
this.hasError = ko.observable(false);
|
|
||||||
|
|
||||||
this.subscribe(function (sValue) {
|
|
||||||
sValue = Utils.trim(sValue);
|
|
||||||
this.hasError('' !== sValue && !(/^[^@\s]+@[^@\s]+$/.test(sValue)));
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.valueHasMutated();
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.observable.fn.validateSimpleEmail = function ()
|
|
||||||
{
|
|
||||||
this.hasError = ko.observable(false);
|
|
||||||
|
|
||||||
this.subscribe(function (sValue) {
|
|
||||||
sValue = Utils.trim(sValue);
|
|
||||||
this.hasError('' !== sValue && !(/^.+@.+$/.test(sValue)));
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.valueHasMutated();
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
ko.observable.fn.validateFunc = function (fFunc)
|
|
||||||
{
|
|
||||||
this.hasFuncError = ko.observable(false);
|
|
||||||
|
|
||||||
if (Utils.isFunc(fFunc))
|
|
||||||
{
|
|
||||||
this.subscribe(function (sValue) {
|
|
||||||
this.hasFuncError(!fFunc(sValue));
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.valueHasMutated();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
@ -1,315 +1,328 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function LinkBuilder()
|
|
||||||
{
|
|
||||||
this.sBase = '#/';
|
|
||||||
this.sServer = './?';
|
|
||||||
this.sVersion = RL.settingsGet('Version');
|
|
||||||
this.sSpecSuffix = RL.settingsGet('AuthAccountHash') || '0';
|
|
||||||
this.sStaticPrefix = RL.settingsGet('StaticPrefix') || 'rainloop/v/' + this.sVersion + '/static/';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
'use strict';
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.root = function ()
|
|
||||||
{
|
|
||||||
return this.sBase;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
var
|
||||||
* @param {string} sDownload
|
window = require('../External/window.js'),
|
||||||
* @return {string}
|
Utils = require('./Utils.js')
|
||||||
*/
|
;
|
||||||
LinkBuilder.prototype.attachmentDownload = function (sDownload)
|
|
||||||
{
|
/**
|
||||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sDownload;
|
* @constructor
|
||||||
};
|
*/
|
||||||
|
function LinkBuilder()
|
||||||
/**
|
|
||||||
* @param {string} sDownload
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.attachmentPreview = function (sDownload)
|
|
||||||
{
|
|
||||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/View/' + sDownload;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sDownload
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.attachmentPreviewAsPlain = function (sDownload)
|
|
||||||
{
|
|
||||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sDownload;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.upload = function ()
|
|
||||||
{
|
|
||||||
return this.sServer + '/Upload/' + this.sSpecSuffix + '/';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.uploadContacts = function ()
|
|
||||||
{
|
|
||||||
return this.sServer + '/UploadContacts/' + this.sSpecSuffix + '/';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.uploadBackground = function ()
|
|
||||||
{
|
|
||||||
return this.sServer + '/UploadBackground/' + this.sSpecSuffix + '/';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.append = function ()
|
|
||||||
{
|
|
||||||
return this.sServer + '/Append/' + this.sSpecSuffix + '/';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sEmail
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.change = function (sEmail)
|
|
||||||
{
|
|
||||||
return this.sServer + '/Change/' + this.sSpecSuffix + '/' + window.encodeURIComponent(sEmail) + '/';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string=} sAdd
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.ajax = function (sAdd)
|
|
||||||
{
|
|
||||||
return this.sServer + '/Ajax/' + this.sSpecSuffix + '/' + sAdd;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sRequestHash
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.messageViewLink = function (sRequestHash)
|
|
||||||
{
|
|
||||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sRequestHash;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sRequestHash
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.messageDownloadLink = function (sRequestHash)
|
|
||||||
{
|
|
||||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sRequestHash;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sEmail
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.avatarLink = function (sEmail)
|
|
||||||
{
|
|
||||||
return this.sServer + '/Raw/0/Avatar/' + window.encodeURIComponent(sEmail) + '/';
|
|
||||||
// return '//secure.gravatar.com/avatar/' + Utils.md5(sEmail.toLowerCase()) + '.jpg?s=80&d=mm';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.inbox = function ()
|
|
||||||
{
|
|
||||||
return this.sBase + 'mailbox/Inbox';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.messagePreview = function ()
|
|
||||||
{
|
|
||||||
return this.sBase + 'mailbox/message-preview';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string=} sScreenName
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.settings = function (sScreenName)
|
|
||||||
{
|
|
||||||
var sResult = this.sBase + 'settings';
|
|
||||||
if (!Utils.isUnd(sScreenName) && '' !== sScreenName)
|
|
||||||
{
|
{
|
||||||
sResult += '/' + sScreenName;
|
this.sBase = '#/';
|
||||||
|
this.sServer = './?';
|
||||||
|
this.sVersion = RL.settingsGet('Version');
|
||||||
|
this.sSpecSuffix = RL.settingsGet('AuthAccountHash') || '0';
|
||||||
|
this.sStaticPrefix = RL.settingsGet('StaticPrefix') || 'rainloop/v/' + this.sVersion + '/static/';
|
||||||
}
|
}
|
||||||
|
|
||||||
return sResult;
|
/**
|
||||||
};
|
* @return {string}
|
||||||
|
*/
|
||||||
/**
|
LinkBuilder.prototype.root = function ()
|
||||||
* @param {string} sScreenName
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.admin = function (sScreenName)
|
|
||||||
{
|
|
||||||
var sResult = this.sBase;
|
|
||||||
switch (sScreenName) {
|
|
||||||
case 'AdminDomains':
|
|
||||||
sResult += 'domains';
|
|
||||||
break;
|
|
||||||
case 'AdminSecurity':
|
|
||||||
sResult += 'security';
|
|
||||||
break;
|
|
||||||
case 'AdminLicensing':
|
|
||||||
sResult += 'licensing';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolder
|
|
||||||
* @param {number=} iPage = 1
|
|
||||||
* @param {string=} sSearch = ''
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.mailBox = function (sFolder, iPage, sSearch)
|
|
||||||
{
|
|
||||||
iPage = Utils.isNormal(iPage) ? Utils.pInt(iPage) : 1;
|
|
||||||
sSearch = Utils.pString(sSearch);
|
|
||||||
|
|
||||||
var sResult = this.sBase + 'mailbox/';
|
|
||||||
if ('' !== sFolder)
|
|
||||||
{
|
{
|
||||||
sResult += encodeURI(sFolder);
|
return this.sBase;
|
||||||
}
|
};
|
||||||
if (1 < iPage)
|
|
||||||
|
/**
|
||||||
|
* @param {string} sDownload
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.attachmentDownload = function (sDownload)
|
||||||
{
|
{
|
||||||
sResult = sResult.replace(/[\/]+$/, '');
|
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sDownload;
|
||||||
sResult += '/p' + iPage;
|
};
|
||||||
}
|
|
||||||
if ('' !== sSearch)
|
/**
|
||||||
|
* @param {string} sDownload
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.attachmentPreview = function (sDownload)
|
||||||
{
|
{
|
||||||
sResult = sResult.replace(/[\/]+$/, '');
|
return this.sServer + '/Raw/' + this.sSpecSuffix + '/View/' + sDownload;
|
||||||
sResult += '/' + encodeURI(sSearch);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return sResult;
|
/**
|
||||||
};
|
* @param {string} sDownload
|
||||||
|
* @return {string}
|
||||||
/**
|
*/
|
||||||
* @return {string}
|
LinkBuilder.prototype.attachmentPreviewAsPlain = function (sDownload)
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.phpInfo = function ()
|
|
||||||
{
|
|
||||||
return this.sServer + 'Info';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sLang
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.langLink = function (sLang)
|
|
||||||
{
|
|
||||||
return this.sServer + '/Lang/0/' + encodeURI(sLang) + '/' + this.sVersion + '/';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.exportContactsVcf = function ()
|
|
||||||
{
|
|
||||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsVcf/';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.exportContactsCsv = function ()
|
|
||||||
{
|
|
||||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsCsv/';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.emptyContactPic = function ()
|
|
||||||
{
|
|
||||||
return this.sStaticPrefix + 'css/images/empty-contact.png';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFileName
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.sound = function (sFileName)
|
|
||||||
{
|
|
||||||
return this.sStaticPrefix + 'sounds/' + sFileName;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sTheme
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
LinkBuilder.prototype.themePreviewLink = function (sTheme)
|
|
||||||
{
|
|
||||||
var sPrefix = 'rainloop/v/' + this.sVersion + '/';
|
|
||||||
if ('@custom' === sTheme.substr(-7))
|
|
||||||
{
|
{
|
||||||
sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7));
|
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sDownload;
|
||||||
sPrefix = '';
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return sPrefix + 'themes/' + encodeURI(sTheme) + '/images/preview.png';
|
/**
|
||||||
};
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.upload = function ()
|
||||||
|
{
|
||||||
|
return this.sServer + '/Upload/' + this.sSpecSuffix + '/';
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
LinkBuilder.prototype.notificationMailIcon = function ()
|
LinkBuilder.prototype.uploadContacts = function ()
|
||||||
{
|
{
|
||||||
return this.sStaticPrefix + 'css/images/icom-message-notification.png';
|
return this.sServer + '/UploadContacts/' + this.sSpecSuffix + '/';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
LinkBuilder.prototype.openPgpJs = function ()
|
LinkBuilder.prototype.uploadBackground = function ()
|
||||||
{
|
{
|
||||||
return this.sStaticPrefix + 'js/openpgp.min.js';
|
return this.sServer + '/UploadBackground/' + this.sSpecSuffix + '/';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
LinkBuilder.prototype.socialGoogle = function ()
|
LinkBuilder.prototype.append = function ()
|
||||||
{
|
{
|
||||||
return this.sServer + 'SocialGoogle' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
return this.sServer + '/Append/' + this.sSpecSuffix + '/';
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string}
|
* @param {string} sEmail
|
||||||
*/
|
* @return {string}
|
||||||
LinkBuilder.prototype.socialTwitter = function ()
|
*/
|
||||||
{
|
LinkBuilder.prototype.change = function (sEmail)
|
||||||
return this.sServer + 'SocialTwitter' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
{
|
||||||
};
|
return this.sServer + '/Change/' + this.sSpecSuffix + '/' + window.encodeURIComponent(sEmail) + '/';
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string}
|
* @param {string=} sAdd
|
||||||
*/
|
* @return {string}
|
||||||
LinkBuilder.prototype.socialFacebook = function ()
|
*/
|
||||||
{
|
LinkBuilder.prototype.ajax = function (sAdd)
|
||||||
return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
{
|
||||||
};
|
return this.sServer + '/Ajax/' + this.sSpecSuffix + '/' + sAdd;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sRequestHash
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.messageViewLink = function (sRequestHash)
|
||||||
|
{
|
||||||
|
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sRequestHash;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sRequestHash
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.messageDownloadLink = function (sRequestHash)
|
||||||
|
{
|
||||||
|
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sRequestHash;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sEmail
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.avatarLink = function (sEmail)
|
||||||
|
{
|
||||||
|
return this.sServer + '/Raw/0/Avatar/' + window.encodeURIComponent(sEmail) + '/';
|
||||||
|
// return '//secure.gravatar.com/avatar/' + Utils.md5(sEmail.toLowerCase()) + '.jpg?s=80&d=mm';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.inbox = function ()
|
||||||
|
{
|
||||||
|
return this.sBase + 'mailbox/Inbox';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.messagePreview = function ()
|
||||||
|
{
|
||||||
|
return this.sBase + 'mailbox/message-preview';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string=} sScreenName
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.settings = function (sScreenName)
|
||||||
|
{
|
||||||
|
var sResult = this.sBase + 'settings';
|
||||||
|
if (!Utils.isUnd(sScreenName) && '' !== sScreenName)
|
||||||
|
{
|
||||||
|
sResult += '/' + sScreenName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sScreenName
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.admin = function (sScreenName)
|
||||||
|
{
|
||||||
|
var sResult = this.sBase;
|
||||||
|
switch (sScreenName) {
|
||||||
|
case 'AdminDomains':
|
||||||
|
sResult += 'domains';
|
||||||
|
break;
|
||||||
|
case 'AdminSecurity':
|
||||||
|
sResult += 'security';
|
||||||
|
break;
|
||||||
|
case 'AdminLicensing':
|
||||||
|
sResult += 'licensing';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sFolder
|
||||||
|
* @param {number=} iPage = 1
|
||||||
|
* @param {string=} sSearch = ''
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.mailBox = function (sFolder, iPage, sSearch)
|
||||||
|
{
|
||||||
|
iPage = Utils.isNormal(iPage) ? Utils.pInt(iPage) : 1;
|
||||||
|
sSearch = Utils.pString(sSearch);
|
||||||
|
|
||||||
|
var sResult = this.sBase + 'mailbox/';
|
||||||
|
if ('' !== sFolder)
|
||||||
|
{
|
||||||
|
sResult += encodeURI(sFolder);
|
||||||
|
}
|
||||||
|
if (1 < iPage)
|
||||||
|
{
|
||||||
|
sResult = sResult.replace(/[\/]+$/, '');
|
||||||
|
sResult += '/p' + iPage;
|
||||||
|
}
|
||||||
|
if ('' !== sSearch)
|
||||||
|
{
|
||||||
|
sResult = sResult.replace(/[\/]+$/, '');
|
||||||
|
sResult += '/' + encodeURI(sSearch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.phpInfo = function ()
|
||||||
|
{
|
||||||
|
return this.sServer + 'Info';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sLang
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.langLink = function (sLang)
|
||||||
|
{
|
||||||
|
return this.sServer + '/Lang/0/' + encodeURI(sLang) + '/' + this.sVersion + '/';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.exportContactsVcf = function ()
|
||||||
|
{
|
||||||
|
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsVcf/';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.exportContactsCsv = function ()
|
||||||
|
{
|
||||||
|
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsCsv/';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.emptyContactPic = function ()
|
||||||
|
{
|
||||||
|
return this.sStaticPrefix + 'css/images/empty-contact.png';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sFileName
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.sound = function (sFileName)
|
||||||
|
{
|
||||||
|
return this.sStaticPrefix + 'sounds/' + sFileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sTheme
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.themePreviewLink = function (sTheme)
|
||||||
|
{
|
||||||
|
var sPrefix = 'rainloop/v/' + this.sVersion + '/';
|
||||||
|
if ('@custom' === sTheme.substr(-7))
|
||||||
|
{
|
||||||
|
sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7));
|
||||||
|
sPrefix = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return sPrefix + 'themes/' + encodeURI(sTheme) + '/images/preview.png';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.notificationMailIcon = function ()
|
||||||
|
{
|
||||||
|
return this.sStaticPrefix + 'css/images/icom-message-notification.png';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.openPgpJs = function ()
|
||||||
|
{
|
||||||
|
return this.sStaticPrefix + 'js/openpgp.min.js';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.socialGoogle = function ()
|
||||||
|
{
|
||||||
|
return this.sServer + 'SocialGoogle' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.socialTwitter = function ()
|
||||||
|
{
|
||||||
|
return this.sServer + 'SocialTwitter' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
LinkBuilder.prototype.socialFacebook = function ()
|
||||||
|
{
|
||||||
|
return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = LinkBuilder;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,260 +1,274 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @param {Object} oElement
|
|
||||||
* @param {Function=} fOnBlur
|
|
||||||
* @param {Function=} fOnReady
|
|
||||||
* @param {Function=} fOnModeChange
|
|
||||||
*/
|
|
||||||
function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady, fOnModeChange)
|
|
||||||
{
|
|
||||||
var self = this;
|
|
||||||
self.editor = null;
|
|
||||||
self.iBlurTimer = 0;
|
|
||||||
self.fOnBlur = fOnBlur || null;
|
|
||||||
self.fOnReady = fOnReady || null;
|
|
||||||
self.fOnModeChange = fOnModeChange || null;
|
|
||||||
|
|
||||||
self.$element = $(oElement);
|
'use strict';
|
||||||
|
|
||||||
self.resize = _.throttle(_.bind(self.resize, self), 100);
|
var
|
||||||
|
window = require('../External/window.js'),
|
||||||
|
Globals = require('./Globals.js')
|
||||||
|
;
|
||||||
|
|
||||||
self.init();
|
/**
|
||||||
}
|
* @constructor
|
||||||
|
* @param {Object} oElement
|
||||||
NewHtmlEditorWrapper.prototype.blurTrigger = function ()
|
* @param {Function=} fOnBlur
|
||||||
{
|
* @param {Function=} fOnReady
|
||||||
if (this.fOnBlur)
|
* @param {Function=} fOnModeChange
|
||||||
|
*/
|
||||||
|
function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady, fOnModeChange)
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
window.clearTimeout(self.iBlurTimer);
|
self.editor = null;
|
||||||
self.iBlurTimer = window.setTimeout(function () {
|
self.iBlurTimer = 0;
|
||||||
self.fOnBlur();
|
self.fOnBlur = fOnBlur || null;
|
||||||
}, 200);
|
self.fOnReady = fOnReady || null;
|
||||||
|
self.fOnModeChange = fOnModeChange || null;
|
||||||
|
|
||||||
|
self.$element = $(oElement);
|
||||||
|
|
||||||
|
self.resize = _.throttle(_.bind(self.resize, self), 100);
|
||||||
|
|
||||||
|
self.init();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.focusTrigger = function ()
|
NewHtmlEditorWrapper.prototype.blurTrigger = function ()
|
||||||
{
|
|
||||||
if (this.fOnBlur)
|
|
||||||
{
|
{
|
||||||
window.clearTimeout(this.iBlurTimer);
|
if (this.fOnBlur)
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
NewHtmlEditorWrapper.prototype.isHtml = function ()
|
|
||||||
{
|
|
||||||
return this.editor ? 'wysiwyg' === this.editor.mode : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
NewHtmlEditorWrapper.prototype.checkDirty = function ()
|
|
||||||
{
|
|
||||||
return this.editor ? this.editor.checkDirty() : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.resetDirty = function ()
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
this.editor.resetDirty();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
NewHtmlEditorWrapper.prototype.getData = function (bWrapIsHtml)
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
|
||||||
{
|
{
|
||||||
return this.editor.__plain.getRawData();
|
var self = this;
|
||||||
|
window.clearTimeout(self.iBlurTimer);
|
||||||
|
self.iBlurTimer = window.setTimeout(function () {
|
||||||
|
self.fOnBlur();
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NewHtmlEditorWrapper.prototype.focusTrigger = function ()
|
||||||
|
{
|
||||||
|
if (this.fOnBlur)
|
||||||
|
{
|
||||||
|
window.clearTimeout(this.iBlurTimer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
NewHtmlEditorWrapper.prototype.isHtml = function ()
|
||||||
|
{
|
||||||
|
return this.editor ? 'wysiwyg' === this.editor.mode : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
NewHtmlEditorWrapper.prototype.checkDirty = function ()
|
||||||
|
{
|
||||||
|
return this.editor ? this.editor.checkDirty() : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
NewHtmlEditorWrapper.prototype.resetDirty = function ()
|
||||||
|
{
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
this.editor.resetDirty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
NewHtmlEditorWrapper.prototype.getData = function (bWrapIsHtml)
|
||||||
|
{
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
||||||
|
{
|
||||||
|
return this.editor.__plain.getRawData();
|
||||||
|
}
|
||||||
|
|
||||||
|
return bWrapIsHtml ?
|
||||||
|
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
|
||||||
|
this.editor.getData() + '</div>' : this.editor.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
return bWrapIsHtml ?
|
return '';
|
||||||
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
|
};
|
||||||
this.editor.getData() + '</div>' : this.editor.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
NewHtmlEditorWrapper.prototype.modeToggle = function (bPlain)
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.modeToggle = function (bPlain)
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
{
|
||||||
if (bPlain)
|
if (this.editor)
|
||||||
{
|
{
|
||||||
if ('plain' === this.editor.mode)
|
if (bPlain)
|
||||||
{
|
{
|
||||||
this.editor.setMode('wysiwyg');
|
if ('plain' === this.editor.mode)
|
||||||
|
{
|
||||||
|
this.editor.setMode('wysiwyg');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ('wysiwyg' === this.editor.mode)
|
||||||
|
{
|
||||||
|
this.editor.setMode('plain');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resize();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NewHtmlEditorWrapper.prototype.setHtml = function (sHtml, bFocus)
|
||||||
|
{
|
||||||
|
if (this.editor)
|
||||||
|
{
|
||||||
|
this.modeToggle(true);
|
||||||
|
this.editor.setData(sHtml);
|
||||||
|
|
||||||
|
if (bFocus)
|
||||||
|
{
|
||||||
|
this.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
};
|
||||||
|
|
||||||
|
NewHtmlEditorWrapper.prototype.setPlain = function (sPlain, bFocus)
|
||||||
|
{
|
||||||
|
if (this.editor)
|
||||||
{
|
{
|
||||||
if ('wysiwyg' === this.editor.mode)
|
this.modeToggle(false);
|
||||||
|
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
||||||
{
|
{
|
||||||
this.editor.setMode('plain');
|
return this.editor.__plain.setRawData(sPlain);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.editor.setData(sPlain);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bFocus)
|
||||||
|
{
|
||||||
|
this.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this.resize();
|
NewHtmlEditorWrapper.prototype.init = function ()
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.setHtml = function (sHtml, bFocus)
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
{
|
||||||
this.modeToggle(true);
|
if (this.$element && this.$element[0])
|
||||||
this.editor.setData(sHtml);
|
|
||||||
|
|
||||||
if (bFocus)
|
|
||||||
{
|
{
|
||||||
this.focus();
|
var
|
||||||
}
|
self = this,
|
||||||
}
|
fInit = function () {
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.setPlain = function (sPlain, bFocus)
|
var
|
||||||
{
|
oConfig = Globals.oHtmlEditorDefaultConfig,
|
||||||
if (this.editor)
|
sLanguage = RL.settingsGet('Language'), // TODO cjs
|
||||||
{
|
bSource = !!RL.settingsGet('AllowHtmlEditorSourceButton')
|
||||||
this.modeToggle(false);
|
;
|
||||||
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
|
|
||||||
{
|
|
||||||
return this.editor.__plain.setRawData(sPlain);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.editor.setData(sPlain);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bFocus)
|
if (bSource && oConfig.toolbarGroups && !oConfig.toolbarGroups.__SourceInited)
|
||||||
{
|
|
||||||
this.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.init = function ()
|
|
||||||
{
|
|
||||||
if (this.$element && this.$element[0])
|
|
||||||
{
|
|
||||||
var
|
|
||||||
self = this,
|
|
||||||
fInit = function () {
|
|
||||||
|
|
||||||
var
|
|
||||||
oConfig = Globals.oHtmlEditorDefaultConfig,
|
|
||||||
sLanguage = RL.settingsGet('Language'),
|
|
||||||
bSource = !!RL.settingsGet('AllowHtmlEditorSourceButton')
|
|
||||||
;
|
|
||||||
|
|
||||||
if (bSource && oConfig.toolbarGroups && !oConfig.toolbarGroups.__SourceInited)
|
|
||||||
{
|
|
||||||
oConfig.toolbarGroups.__SourceInited = true;
|
|
||||||
oConfig.toolbarGroups.push({name: 'document', groups: ['mode', 'document', 'doctools']});
|
|
||||||
}
|
|
||||||
|
|
||||||
oConfig.enterMode = window.CKEDITOR.ENTER_BR;
|
|
||||||
oConfig.shiftEnterMode = window.CKEDITOR.ENTER_BR;
|
|
||||||
|
|
||||||
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;
|
oConfig.toolbarGroups.__SourceInited = true;
|
||||||
|
oConfig.toolbarGroups.push({name: 'document', groups: ['mode', 'document', 'doctools']});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
self.editor.on('blur', function() {
|
oConfig.enterMode = window.CKEDITOR.ENTER_BR;
|
||||||
self.blurTrigger();
|
oConfig.shiftEnterMode = window.CKEDITOR.ENTER_BR;
|
||||||
});
|
|
||||||
|
|
||||||
self.editor.on('mode', function() {
|
oConfig.language = Globals.oHtmlEditorLangsMap[sLanguage] || 'en';
|
||||||
|
if (window.CKEDITOR.env)
|
||||||
self.blurTrigger();
|
|
||||||
|
|
||||||
if (self.fOnModeChange)
|
|
||||||
{
|
{
|
||||||
self.fOnModeChange('plain' !== self.editor.mode);
|
window.CKEDITOR.env.isCompatible = true;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
self.editor.on('focus', function() {
|
self.editor = window.CKEDITOR.appendTo(self.$element[0], oConfig);
|
||||||
self.focusTrigger();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (self.fOnReady)
|
self.editor.on('key', function(oEvent) {
|
||||||
{
|
if (oEvent && oEvent.data && 9 /* Tab */ === oEvent.data.keyCode)
|
||||||
self.editor.on('instanceReady', function () {
|
{
|
||||||
|
return false;
|
||||||
self.editor.setKeystroke(window.CKEDITOR.CTRL + 65 /* A */, 'selectAll');
|
}
|
||||||
|
|
||||||
self.fOnReady();
|
|
||||||
self.__resizable = true;
|
|
||||||
self.resize();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 (self.fOnReady)
|
||||||
|
{
|
||||||
|
self.editor.on('instanceReady', function () {
|
||||||
|
|
||||||
|
self.editor.setKeystroke(window.CKEDITOR.CTRL + 65 /* A */, 'selectAll');
|
||||||
|
|
||||||
|
self.fOnReady();
|
||||||
|
self.__resizable = true;
|
||||||
|
self.resize();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
if (window.CKEDITOR)
|
||||||
|
{
|
||||||
|
fInit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.__initEditor = fInit;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
if (window.CKEDITOR)
|
|
||||||
{
|
|
||||||
fInit();
|
|
||||||
}
|
}
|
||||||
else
|
};
|
||||||
|
|
||||||
|
NewHtmlEditorWrapper.prototype.focus = function ()
|
||||||
|
{
|
||||||
|
if (this.editor)
|
||||||
{
|
{
|
||||||
window.__initEditor = fInit;
|
this.editor.focus();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.focus = function ()
|
NewHtmlEditorWrapper.prototype.blur = function ()
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
{
|
||||||
this.editor.focus();
|
if (this.editor)
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.blur = function ()
|
|
||||||
{
|
|
||||||
if (this.editor)
|
|
||||||
{
|
|
||||||
this.editor.focusManager.blur(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.resize = function ()
|
|
||||||
{
|
|
||||||
if (this.editor && this.__resizable)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
this.editor.resize(this.$element.width(), this.$element.innerHeight());
|
this.editor.focusManager.blur(true);
|
||||||
}
|
}
|
||||||
catch (e) {}
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
NewHtmlEditorWrapper.prototype.clear = function (bFocus)
|
NewHtmlEditorWrapper.prototype.resize = function ()
|
||||||
{
|
{
|
||||||
this.setHtml('', bFocus);
|
if (this.editor && this.__resizable)
|
||||||
};
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.editor.resize(this.$element.width(), this.$element.innerHeight());
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NewHtmlEditorWrapper.prototype.clear = function (bFocus)
|
||||||
|
{
|
||||||
|
this.setHtml('', bFocus);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = NewHtmlEditorWrapper;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,95 +1,106 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
Plugins.oViewModelsHooks = {};
|
|
||||||
|
|
||||||
/**
|
'use strict';
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
Plugins.oSimpleHooks = {};
|
|
||||||
|
|
||||||
/**
|
var
|
||||||
* @param {string} sName
|
Plugins = {},
|
||||||
* @param {Function} ViewModel
|
Utils = require('./Utils.js')
|
||||||
*/
|
;
|
||||||
Plugins.regViewModelHook = function (sName, ViewModel)
|
|
||||||
{
|
/**
|
||||||
if (ViewModel)
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
Plugins.oViewModelsHooks = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
Plugins.oSimpleHooks = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sName
|
||||||
|
* @param {Function} ViewModel
|
||||||
|
*/
|
||||||
|
Plugins.regViewModelHook = function (sName, ViewModel)
|
||||||
{
|
{
|
||||||
ViewModel.__hookName = sName;
|
if (ViewModel)
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sName
|
|
||||||
* @param {Function} fCallback
|
|
||||||
*/
|
|
||||||
Plugins.addHook = function (sName, fCallback)
|
|
||||||
{
|
|
||||||
if (Utils.isFunc(fCallback))
|
|
||||||
{
|
|
||||||
if (!Utils.isArray(Plugins.oSimpleHooks[sName]))
|
|
||||||
{
|
{
|
||||||
Plugins.oSimpleHooks[sName] = [];
|
ViewModel.__hookName = sName;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
Plugins.oSimpleHooks[sName].push(fCallback);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sName
|
* @param {string} sName
|
||||||
* @param {Array=} aArguments
|
* @param {Function} fCallback
|
||||||
*/
|
*/
|
||||||
Plugins.runHook = function (sName, aArguments)
|
Plugins.addHook = function (sName, fCallback)
|
||||||
{
|
|
||||||
if (Utils.isArray(Plugins.oSimpleHooks[sName]))
|
|
||||||
{
|
{
|
||||||
aArguments = aArguments || [];
|
if (Utils.isFunc(fCallback))
|
||||||
|
{
|
||||||
_.each(Plugins.oSimpleHooks[sName], function (fCallback) {
|
if (!Utils.isArray(Plugins.oSimpleHooks[sName]))
|
||||||
fCallback.apply(null, aArguments);
|
{
|
||||||
});
|
Plugins.oSimpleHooks[sName] = [];
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
Plugins.oSimpleHooks[sName].push(fCallback);
|
||||||
* @param {string} sName
|
}
|
||||||
* @return {?}
|
};
|
||||||
*/
|
|
||||||
Plugins.mainSettingsGet = function (sName)
|
|
||||||
{
|
|
||||||
return RL ? RL.settingsGet(sName) : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Function} fCallback
|
* @param {string} sName
|
||||||
* @param {string} sAction
|
* @param {Array=} aArguments
|
||||||
* @param {Object=} oParameters
|
*/
|
||||||
* @param {?number=} iTimeout
|
Plugins.runHook = function (sName, aArguments)
|
||||||
* @param {string=} sGetAdd = ''
|
|
||||||
* @param {Array=} aAbortActions = []
|
|
||||||
*/
|
|
||||||
Plugins.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
|
|
||||||
{
|
|
||||||
if (RL)
|
|
||||||
{
|
{
|
||||||
RL.remote().defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions);
|
if (Utils.isArray(Plugins.oSimpleHooks[sName]))
|
||||||
}
|
{
|
||||||
};
|
aArguments = aArguments || [];
|
||||||
|
|
||||||
/**
|
_.each(Plugins.oSimpleHooks[sName], function (fCallback) {
|
||||||
* @param {string} sPluginSection
|
fCallback.apply(null, aArguments);
|
||||||
* @param {string} sName
|
});
|
||||||
* @return {?}
|
}
|
||||||
*/
|
};
|
||||||
Plugins.settingsGet = function (sPluginSection, sName)
|
|
||||||
{
|
|
||||||
var oPlugin = Plugins.mainSettingsGet('Plugins');
|
|
||||||
oPlugin = oPlugin && Utils.isUnd(oPlugin[sPluginSection]) ? null : oPlugin[sPluginSection];
|
|
||||||
return oPlugin ? (Utils.isUnd(oPlugin[sName]) ? null : oPlugin[sName]) : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sName
|
||||||
|
* @return {?}
|
||||||
|
*/
|
||||||
|
Plugins.mainSettingsGet = function (sName)
|
||||||
|
{
|
||||||
|
return RL ? RL.settingsGet(sName) : null; // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Function} fCallback
|
||||||
|
* @param {string} sAction
|
||||||
|
* @param {Object=} oParameters
|
||||||
|
* @param {?number=} iTimeout
|
||||||
|
* @param {string=} sGetAdd = ''
|
||||||
|
* @param {Array=} aAbortActions = []
|
||||||
|
*/
|
||||||
|
Plugins.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
|
||||||
|
{
|
||||||
|
if (RL) // TODO cjs
|
||||||
|
{
|
||||||
|
RL.remote().defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions); // TODO cjs
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sPluginSection
|
||||||
|
* @param {string} sName
|
||||||
|
* @return {?}
|
||||||
|
*/
|
||||||
|
Plugins.settingsGet = function (sPluginSection, sName)
|
||||||
|
{
|
||||||
|
var oPlugin = Plugins.mainSettingsGet('Plugins');
|
||||||
|
oPlugin = oPlugin && Utils.isUnd(oPlugin[sPluginSection]) ? null : oPlugin[sPluginSection];
|
||||||
|
return oPlugin ? (Utils.isUnd(oPlugin[sName]) ? null : oPlugin[sName]) : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = Plugins;
|
||||||
|
|
||||||
|
}(module));
|
||||||
File diff suppressed because it is too large
Load diff
3963
dev/Common/Utils.js
3963
dev/Common/Utils.js
File diff suppressed because it is too large
Load diff
|
|
@ -1,78 +0,0 @@
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
Consts = {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
Enums = {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
NotificationI18N = {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<Function>}
|
|
||||||
*/
|
|
||||||
Utils = {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<Function>}
|
|
||||||
*/
|
|
||||||
Plugins = {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<Function>}
|
|
||||||
*/
|
|
||||||
Base64 = {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
Globals = {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
ViewModels = {
|
|
||||||
'settings': [],
|
|
||||||
'settings-removed': [],
|
|
||||||
'settings-disabled': []
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Array}
|
|
||||||
*/
|
|
||||||
BootstrapDropdowns = [],
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {*}
|
|
||||||
*/
|
|
||||||
kn = null,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
AppData = window['rainloopAppData'] || {},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
I18n = window['rainloopI18N'] || {},
|
|
||||||
|
|
||||||
$html = $('html'),
|
|
||||||
|
|
||||||
// $body = $('body'),
|
|
||||||
|
|
||||||
$window = $(window),
|
|
||||||
|
|
||||||
$document = $(window.document),
|
|
||||||
|
|
||||||
NotificationClass = window.Notification && window.Notification.requestPermission ? window.Notification : null
|
|
||||||
;
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/*jshint onevar: false*/
|
|
||||||
/**
|
|
||||||
* @type {?AdminApp}
|
|
||||||
*/
|
|
||||||
var RL = null;
|
|
||||||
/*jshint onevar: true*/
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/*jshint onevar: false*/
|
|
||||||
/**
|
|
||||||
* @type {?RainLoopApp}
|
|
||||||
*/
|
|
||||||
var
|
|
||||||
RL = null,
|
|
||||||
|
|
||||||
$proxyDiv = $('<div></div>')
|
|
||||||
;
|
|
||||||
/*jshint onevar: true*/
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile');
|
|
||||||
|
|
||||||
$window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS);
|
|
||||||
$window.unload(function () {
|
|
||||||
Globals.bUnload = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
$html.on('click.dropdown.data-api', function () {
|
|
||||||
Utils.detectDropdownVisibility();
|
|
||||||
});
|
|
||||||
|
|
||||||
// export
|
|
||||||
window['rl'] = window['rl'] || {};
|
|
||||||
window['rl']['addHook'] = Plugins.addHook;
|
|
||||||
window['rl']['settingsGet'] = Plugins.mainSettingsGet;
|
|
||||||
window['rl']['remoteRequest'] = Plugins.remoteRequest;
|
|
||||||
window['rl']['pluginSettingsGet'] = Plugins.settingsGet;
|
|
||||||
window['rl']['addSettingsViewModel'] = Utils.addSettingsViewModel;
|
|
||||||
window['rl']['createCommand'] = Utils.createCommand;
|
|
||||||
|
|
||||||
window['rl']['EmailModel'] = EmailModel;
|
|
||||||
window['rl']['Enums'] = Enums;
|
|
||||||
|
|
||||||
window['__RLBOOT'] = function (fCall) {
|
|
||||||
|
|
||||||
// boot
|
|
||||||
$(function () {
|
|
||||||
|
|
||||||
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
|
|
||||||
{
|
|
||||||
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
|
|
||||||
|
|
||||||
_.delay(function () {
|
|
||||||
window['rainloopAppData'] = {};
|
|
||||||
window['rainloopI18N'] = {};
|
|
||||||
window['rainloopTEMPLATES'] = {};
|
|
||||||
|
|
||||||
kn.setBoot(RL).bootstart();
|
|
||||||
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
|
|
||||||
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fCall(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
window['__RLBOOT'] = null;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
5
dev/External/$div.js
vendored
Normal file
5
dev/External/$div.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = require('./jquery.js')('<div></div>');
|
||||||
5
dev/External/$doc.js
vendored
Normal file
5
dev/External/$doc.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = require('./jquery.js')(window.document);
|
||||||
5
dev/External/$html.js
vendored
Normal file
5
dev/External/$html.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = require('./jquery.js')('html');
|
||||||
5
dev/External/$window.js
vendored
Normal file
5
dev/External/$window.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = require('./jquery.js')(window);
|
||||||
5
dev/External/AppData.js
vendored
Normal file
5
dev/External/AppData.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = require('./window.js')['rainloopAppData'] || {};
|
||||||
5
dev/External/JSON.js
vendored
Normal file
5
dev/External/JSON.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = JSON;
|
||||||
9
dev/External/NotificationClass.js
vendored
Normal file
9
dev/External/NotificationClass.js
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
window = require('./window.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
module.exports = window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
||||||
5
dev/External/crossroads.js
vendored
Normal file
5
dev/External/crossroads.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = crossroads;
|
||||||
5
dev/External/hasher.js
vendored
Normal file
5
dev/External/hasher.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = hasher;
|
||||||
5
dev/External/jquery.js
vendored
Normal file
5
dev/External/jquery.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = $;
|
||||||
5
dev/External/key.js
vendored
Normal file
5
dev/External/key.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = key;
|
||||||
864
dev/External/ko.js
vendored
Normal file
864
dev/External/ko.js
vendored
Normal file
|
|
@ -0,0 +1,864 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
$ = require('./jquery.js'),
|
||||||
|
_ = require('./underscore.js'),
|
||||||
|
window = require('./window.js'),
|
||||||
|
$window = require('./$window.js'),
|
||||||
|
$doc = require('./$doc.js'),
|
||||||
|
Globals = require('../Common/Globals.js'),
|
||||||
|
Utils = require('../Common/Utils.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
ko.bindingHandlers.tooltip = {
|
||||||
|
'init': function (oElement, fValueAccessor) {
|
||||||
|
if (!Globals.bMobileDevice)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
$oEl = $(oElement),
|
||||||
|
sClass = $oEl.data('tooltip-class') || '',
|
||||||
|
sPlacement = $oEl.data('tooltip-placement') || 'top'
|
||||||
|
;
|
||||||
|
|
||||||
|
$oEl.tooltip({
|
||||||
|
'delay': {
|
||||||
|
'show': 500,
|
||||||
|
'hide': 100
|
||||||
|
},
|
||||||
|
'html': true,
|
||||||
|
'container': 'body',
|
||||||
|
'placement': sPlacement,
|
||||||
|
'trigger': 'hover',
|
||||||
|
'title': function () {
|
||||||
|
return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' : '<span class="tooltip-class ' + sClass + '">' +
|
||||||
|
Utils.i18n(ko.utils.unwrapObservable(fValueAccessor())) + '</span>';
|
||||||
|
}
|
||||||
|
}).click(function () {
|
||||||
|
$oEl.tooltip('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
Globals.tooltipTrigger.subscribe(function () {
|
||||||
|
$oEl.tooltip('hide');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.tooltip2 = {
|
||||||
|
'init': function (oElement, fValueAccessor) {
|
||||||
|
var
|
||||||
|
$oEl = $(oElement),
|
||||||
|
sClass = $oEl.data('tooltip-class') || '',
|
||||||
|
sPlacement = $oEl.data('tooltip-placement') || 'top'
|
||||||
|
;
|
||||||
|
|
||||||
|
$oEl.tooltip({
|
||||||
|
'delay': {
|
||||||
|
'show': 500,
|
||||||
|
'hide': 100
|
||||||
|
},
|
||||||
|
'html': true,
|
||||||
|
'container': 'body',
|
||||||
|
'placement': sPlacement,
|
||||||
|
'title': function () {
|
||||||
|
return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' :
|
||||||
|
'<span class="tooltip-class ' + sClass + '">' + fValueAccessor()() + '</span>';
|
||||||
|
}
|
||||||
|
}).click(function () {
|
||||||
|
$oEl.tooltip('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
Globals.tooltipTrigger.subscribe(function () {
|
||||||
|
$oEl.tooltip('hide');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.tooltip3 = {
|
||||||
|
'init': function (oElement) {
|
||||||
|
|
||||||
|
var $oEl = $(oElement);
|
||||||
|
|
||||||
|
$oEl.tooltip({
|
||||||
|
'container': 'body',
|
||||||
|
'trigger': 'hover manual',
|
||||||
|
'title': function () {
|
||||||
|
return $oEl.data('tooltip3-data') || '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$doc.click(function () {
|
||||||
|
$oEl.tooltip('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
Globals.tooltipTrigger.subscribe(function () {
|
||||||
|
$oEl.tooltip('hide');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
var sValue = ko.utils.unwrapObservable(fValueAccessor());
|
||||||
|
if ('' === sValue)
|
||||||
|
{
|
||||||
|
$(oElement).data('tooltip3-data', '').tooltip('hide');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$(oElement).data('tooltip3-data', sValue).tooltip('show');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.registrateBootstrapDropdown = {
|
||||||
|
'init': function (oElement) {
|
||||||
|
Globals.aBootstrapDropdowns.push($(oElement));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.openDropdownTrigger = {
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
if (ko.utils.unwrapObservable(fValueAccessor()))
|
||||||
|
{
|
||||||
|
var $el = $(oElement);
|
||||||
|
if (!$el.hasClass('open'))
|
||||||
|
{
|
||||||
|
$el.find('.dropdown-toggle').dropdown('toggle');
|
||||||
|
Utils.detectDropdownVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
fValueAccessor()(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.dropdownCloser = {
|
||||||
|
'init': function (oElement) {
|
||||||
|
$(oElement).closest('.dropdown').on('click', '.e-item', function () {
|
||||||
|
$(oElement).dropdown('toggle');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.popover = {
|
||||||
|
'init': function (oElement, fValueAccessor) {
|
||||||
|
$(oElement).popover(ko.utils.unwrapObservable(fValueAccessor()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.csstext = {
|
||||||
|
'init': function (oElement, fValueAccessor) {
|
||||||
|
if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText))
|
||||||
|
{
|
||||||
|
oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$(oElement).text(ko.utils.unwrapObservable(fValueAccessor()));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText))
|
||||||
|
{
|
||||||
|
oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$(oElement).text(ko.utils.unwrapObservable(fValueAccessor()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.resizecrop = {
|
||||||
|
'init': function (oElement) {
|
||||||
|
$(oElement).addClass('resizecrop').resizecrop({
|
||||||
|
'width': '100',
|
||||||
|
'height': '100',
|
||||||
|
'wrapperCSS': {
|
||||||
|
'border-radius': '10px'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
fValueAccessor()();
|
||||||
|
$(oElement).resizecrop({
|
||||||
|
'width': '100',
|
||||||
|
'height': '100'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.onEnter = {
|
||||||
|
'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
|
||||||
|
$(oElement).on('keypress', function (oEvent) {
|
||||||
|
if (oEvent && 13 === window.parseInt(oEvent.keyCode, 10))
|
||||||
|
{
|
||||||
|
$(oElement).trigger('change');
|
||||||
|
fValueAccessor().call(oViewModel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.onEsc = {
|
||||||
|
'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
|
||||||
|
$(oElement).on('keypress', function (oEvent) {
|
||||||
|
if (oEvent && 27 === window.parseInt(oEvent.keyCode, 10))
|
||||||
|
{
|
||||||
|
$(oElement).trigger('change');
|
||||||
|
fValueAccessor().call(oViewModel);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.clickOnTrue = {
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
if (ko.utils.unwrapObservable(fValueAccessor()))
|
||||||
|
{
|
||||||
|
$(oElement).click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.modal = {
|
||||||
|
'init': function (oElement, fValueAccessor) {
|
||||||
|
|
||||||
|
$(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({
|
||||||
|
'keyboard': false,
|
||||||
|
'show': ko.utils.unwrapObservable(fValueAccessor())
|
||||||
|
})
|
||||||
|
.on('shown', function () {
|
||||||
|
Utils.windowResize();
|
||||||
|
})
|
||||||
|
.find('.close').click(function () {
|
||||||
|
fValueAccessor()(false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
$(oElement).modal(ko.utils.unwrapObservable(fValueAccessor()) ? 'show' : 'hide');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.i18nInit = {
|
||||||
|
'init': function (oElement) {
|
||||||
|
Utils.i18nToNode(oElement);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.i18nUpdate = {
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
ko.utils.unwrapObservable(fValueAccessor());
|
||||||
|
Utils.i18nToNode(oElement);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.link = {
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
$(oElement).attr('href', ko.utils.unwrapObservable(fValueAccessor()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.title = {
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
$(oElement).attr('title', ko.utils.unwrapObservable(fValueAccessor()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.textF = {
|
||||||
|
'init': function (oElement, fValueAccessor) {
|
||||||
|
$(oElement).text(ko.utils.unwrapObservable(fValueAccessor()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.initDom = {
|
||||||
|
'init': function (oElement, fValueAccessor) {
|
||||||
|
fValueAccessor()(oElement);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.initResizeTrigger = {
|
||||||
|
'init': function (oElement, fValueAccessor) {
|
||||||
|
var aValues = ko.utils.unwrapObservable(fValueAccessor());
|
||||||
|
$(oElement).css({
|
||||||
|
'height': aValues[1],
|
||||||
|
'min-height': aValues[1]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
var
|
||||||
|
aValues = ko.utils.unwrapObservable(fValueAccessor()),
|
||||||
|
iValue = Utils.pInt(aValues[1]),
|
||||||
|
iSize = 0,
|
||||||
|
iOffset = $(oElement).offset().top
|
||||||
|
;
|
||||||
|
|
||||||
|
if (0 < iOffset)
|
||||||
|
{
|
||||||
|
iOffset += Utils.pInt(aValues[2]);
|
||||||
|
iSize = $window.height() - iOffset;
|
||||||
|
|
||||||
|
if (iValue < iSize)
|
||||||
|
{
|
||||||
|
iValue = iSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(oElement).css({
|
||||||
|
'height': iValue,
|
||||||
|
'min-height': iValue
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.appendDom = {
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
$(oElement).hide().empty().append(ko.utils.unwrapObservable(fValueAccessor())).show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.draggable = {
|
||||||
|
'init': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||||
|
|
||||||
|
if (!Globals.bMobileDevice)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
iTriggerZone = 100,
|
||||||
|
iScrollSpeed = 3,
|
||||||
|
fAllValueFunc = fAllBindingsAccessor(),
|
||||||
|
sDroppableSelector = fAllValueFunc && fAllValueFunc['droppableSelector'] ? fAllValueFunc['droppableSelector'] : '',
|
||||||
|
oConf = {
|
||||||
|
'distance': 20,
|
||||||
|
'handle': '.dragHandle',
|
||||||
|
'cursorAt': {'top': 22, 'left': 3},
|
||||||
|
'refreshPositions': true,
|
||||||
|
'scroll': true
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
if (sDroppableSelector)
|
||||||
|
{
|
||||||
|
oConf['drag'] = function (oEvent) {
|
||||||
|
|
||||||
|
$(sDroppableSelector).each(function () {
|
||||||
|
var
|
||||||
|
moveUp = null,
|
||||||
|
moveDown = null,
|
||||||
|
$this = $(this),
|
||||||
|
oOffset = $this.offset(),
|
||||||
|
bottomPos = oOffset.top + $this.height()
|
||||||
|
;
|
||||||
|
|
||||||
|
window.clearInterval($this.data('timerScroll'));
|
||||||
|
$this.data('timerScroll', false);
|
||||||
|
|
||||||
|
if (oEvent.pageX >= oOffset.left && oEvent.pageX <= oOffset.left + $this.width())
|
||||||
|
{
|
||||||
|
if (oEvent.pageY >= bottomPos - iTriggerZone && oEvent.pageY <= bottomPos)
|
||||||
|
{
|
||||||
|
moveUp = function() {
|
||||||
|
$this.scrollTop($this.scrollTop() + iScrollSpeed);
|
||||||
|
Utils.windowResize();
|
||||||
|
};
|
||||||
|
|
||||||
|
$this.data('timerScroll', window.setInterval(moveUp, 10));
|
||||||
|
moveUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oEvent.pageY >= oOffset.top && oEvent.pageY <= oOffset.top + iTriggerZone)
|
||||||
|
{
|
||||||
|
moveDown = function() {
|
||||||
|
$this.scrollTop($this.scrollTop() - iScrollSpeed);
|
||||||
|
Utils.windowResize();
|
||||||
|
};
|
||||||
|
|
||||||
|
$this.data('timerScroll', window.setInterval(moveDown, 10));
|
||||||
|
moveDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
oConf['stop'] = function() {
|
||||||
|
$(sDroppableSelector).each(function () {
|
||||||
|
window.clearInterval($(this).data('timerScroll'));
|
||||||
|
$(this).data('timerScroll', false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
oConf['helper'] = function (oEvent) {
|
||||||
|
return fValueAccessor()(oEvent && oEvent.target ? ko.dataFor(oEvent.target) : null);
|
||||||
|
};
|
||||||
|
|
||||||
|
$(oElement).draggable(oConf).on('mousedown', function () {
|
||||||
|
Utils.removeInFocus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.droppable = {
|
||||||
|
'init': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||||
|
|
||||||
|
if (!Globals.bMobileDevice)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
fValueFunc = fValueAccessor(),
|
||||||
|
fAllValueFunc = fAllBindingsAccessor(),
|
||||||
|
fOverCallback = fAllValueFunc && fAllValueFunc['droppableOver'] ? fAllValueFunc['droppableOver'] : null,
|
||||||
|
fOutCallback = fAllValueFunc && fAllValueFunc['droppableOut'] ? fAllValueFunc['droppableOut'] : null,
|
||||||
|
oConf = {
|
||||||
|
'tolerance': 'pointer',
|
||||||
|
'hoverClass': 'droppableHover'
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
if (fValueFunc)
|
||||||
|
{
|
||||||
|
oConf['drop'] = function (oEvent, oUi) {
|
||||||
|
fValueFunc(oEvent, oUi);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (fOverCallback)
|
||||||
|
{
|
||||||
|
oConf['over'] = function (oEvent, oUi) {
|
||||||
|
fOverCallback(oEvent, oUi);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fOutCallback)
|
||||||
|
{
|
||||||
|
oConf['out'] = function (oEvent, oUi) {
|
||||||
|
fOutCallback(oEvent, oUi);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$(oElement).droppable(oConf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.nano = {
|
||||||
|
'init': function (oElement) {
|
||||||
|
if (!Globals.bDisableNanoScroll)
|
||||||
|
{
|
||||||
|
$(oElement)
|
||||||
|
.addClass('nano')
|
||||||
|
.nanoScroller({
|
||||||
|
'iOSNativeScrolling': false,
|
||||||
|
'preventPageScrolling': true
|
||||||
|
})
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.saveTrigger = {
|
||||||
|
'init': function (oElement) {
|
||||||
|
|
||||||
|
var $oEl = $(oElement);
|
||||||
|
|
||||||
|
$oEl.data('save-trigger-type', $oEl.is('input[type=text],input[type=email],input[type=password],select,textarea') ? 'input' : 'custom');
|
||||||
|
|
||||||
|
if ('custom' === $oEl.data('save-trigger-type'))
|
||||||
|
{
|
||||||
|
$oEl.append(
|
||||||
|
' <i class="icon-spinner animated"></i><i class="icon-remove error"></i><i class="icon-ok success"></i>'
|
||||||
|
).addClass('settings-saved-trigger');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$oEl.addClass('settings-saved-trigger-input');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
var
|
||||||
|
mValue = ko.utils.unwrapObservable(fValueAccessor()),
|
||||||
|
$oEl = $(oElement)
|
||||||
|
;
|
||||||
|
|
||||||
|
if ('custom' === $oEl.data('save-trigger-type'))
|
||||||
|
{
|
||||||
|
switch (mValue.toString())
|
||||||
|
{
|
||||||
|
case '1':
|
||||||
|
$oEl
|
||||||
|
.find('.animated,.error').hide().removeClass('visible')
|
||||||
|
.end()
|
||||||
|
.find('.success').show().addClass('visible')
|
||||||
|
;
|
||||||
|
break;
|
||||||
|
case '0':
|
||||||
|
$oEl
|
||||||
|
.find('.animated,.success').hide().removeClass('visible')
|
||||||
|
.end()
|
||||||
|
.find('.error').show().addClass('visible')
|
||||||
|
;
|
||||||
|
break;
|
||||||
|
case '-2':
|
||||||
|
$oEl
|
||||||
|
.find('.error,.success').hide().removeClass('visible')
|
||||||
|
.end()
|
||||||
|
.find('.animated').show().addClass('visible')
|
||||||
|
;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$oEl
|
||||||
|
.find('.animated').hide()
|
||||||
|
.end()
|
||||||
|
.find('.error,.success').removeClass('visible')
|
||||||
|
;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (mValue.toString())
|
||||||
|
{
|
||||||
|
case '1':
|
||||||
|
$oEl.addClass('success').removeClass('error');
|
||||||
|
break;
|
||||||
|
case '0':
|
||||||
|
$oEl.addClass('error').removeClass('success');
|
||||||
|
break;
|
||||||
|
case '-2':
|
||||||
|
// $oEl;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$oEl.removeClass('error success');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.emailsTags = {
|
||||||
|
'init': function(oElement, fValueAccessor) {
|
||||||
|
var
|
||||||
|
$oEl = $(oElement),
|
||||||
|
fValue = fValueAccessor(),
|
||||||
|
fFocusCallback = function (bValue) {
|
||||||
|
if (fValue && fValue.focusTrigger)
|
||||||
|
{
|
||||||
|
fValue.focusTrigger(bValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
$oEl.inputosaurus({
|
||||||
|
'parseOnBlur': true,
|
||||||
|
'allowDragAndDrop': true,
|
||||||
|
'focusCallback': fFocusCallback,
|
||||||
|
'inputDelimiters': [',', ';'],
|
||||||
|
'autoCompleteSource': function (oData, fResponse) {
|
||||||
|
RL.getAutocomplete(oData.term, function (aData) {
|
||||||
|
fResponse(_.map(aData, function (oEmailItem) {
|
||||||
|
return oEmailItem.toLine(false);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'parseHook': function (aInput) {
|
||||||
|
return _.map(aInput, function (sInputValue) {
|
||||||
|
|
||||||
|
var
|
||||||
|
sValue = Utils.trim(sInputValue),
|
||||||
|
oEmail = null
|
||||||
|
;
|
||||||
|
|
||||||
|
if ('' !== sValue)
|
||||||
|
{
|
||||||
|
oEmail = new EmailModel();
|
||||||
|
oEmail.mailsoParse(sValue);
|
||||||
|
oEmail.clearDuplicateName();
|
||||||
|
return [oEmail.toLine(false), oEmail];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [sValue, null];
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'change': _.bind(function (oEvent) {
|
||||||
|
$oEl.data('EmailsTagsValue', oEvent.target.value);
|
||||||
|
fValue(oEvent.target.value);
|
||||||
|
}, this)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||||
|
|
||||||
|
var
|
||||||
|
$oEl = $(oElement),
|
||||||
|
fAllValueFunc = fAllBindingsAccessor(),
|
||||||
|
fEmailsTagsFilter = fAllValueFunc['emailsTagsFilter'] || null,
|
||||||
|
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||||
|
{
|
||||||
|
$oEl.val(sValue);
|
||||||
|
$oEl.data('EmailsTagsValue', sValue);
|
||||||
|
$oEl.inputosaurus('refresh');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter))
|
||||||
|
{
|
||||||
|
$oEl.inputosaurus('focus');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.contactTags = {
|
||||||
|
'init': function(oElement, fValueAccessor) {
|
||||||
|
var
|
||||||
|
$oEl = $(oElement),
|
||||||
|
fValue = fValueAccessor(),
|
||||||
|
fFocusCallback = function (bValue) {
|
||||||
|
if (fValue && fValue.focusTrigger)
|
||||||
|
{
|
||||||
|
fValue.focusTrigger(bValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
$oEl.inputosaurus({
|
||||||
|
'parseOnBlur': true,
|
||||||
|
'allowDragAndDrop': false,
|
||||||
|
'focusCallback': fFocusCallback,
|
||||||
|
'inputDelimiters': [',', ';'],
|
||||||
|
'outputDelimiter': ',',
|
||||||
|
'autoCompleteSource': function (oData, fResponse) {
|
||||||
|
RL.getContactTagsAutocomplete(oData.term, function (aData) { // TODO cjs
|
||||||
|
fResponse(_.map(aData, function (oTagItem) {
|
||||||
|
return oTagItem.toLine(false);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'parseHook': function (aInput) {
|
||||||
|
return _.map(aInput, function (sInputValue) {
|
||||||
|
|
||||||
|
var
|
||||||
|
sValue = Utils.trim(sInputValue),
|
||||||
|
oTag = null
|
||||||
|
;
|
||||||
|
|
||||||
|
if ('' !== sValue)
|
||||||
|
{
|
||||||
|
oTag = new ContactTagModel();
|
||||||
|
oTag.name(sValue);
|
||||||
|
return [oTag.toLine(false), oTag];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [sValue, null];
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'change': _.bind(function (oEvent) {
|
||||||
|
$oEl.data('ContactTagsValue', oEvent.target.value);
|
||||||
|
fValue(oEvent.target.value);
|
||||||
|
}, this)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||||
|
|
||||||
|
var
|
||||||
|
$oEl = $(oElement),
|
||||||
|
fAllValueFunc = fAllBindingsAccessor(),
|
||||||
|
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
|
||||||
|
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($oEl.data('ContactTagsValue') !== sValue)
|
||||||
|
{
|
||||||
|
$oEl.val(sValue);
|
||||||
|
$oEl.data('ContactTagsValue', sValue);
|
||||||
|
$oEl.inputosaurus('refresh');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
|
||||||
|
{
|
||||||
|
$oEl.inputosaurus('focus');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.bindingHandlers.command = {
|
||||||
|
'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
|
||||||
|
var
|
||||||
|
jqElement = $(oElement),
|
||||||
|
oCommand = fValueAccessor()
|
||||||
|
;
|
||||||
|
|
||||||
|
if (!oCommand || !oCommand.enabled || !oCommand.canExecute)
|
||||||
|
{
|
||||||
|
throw new Error('You are not using command function');
|
||||||
|
}
|
||||||
|
|
||||||
|
jqElement.addClass('command');
|
||||||
|
ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click'].init.apply(oViewModel, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
'update': function (oElement, fValueAccessor) {
|
||||||
|
|
||||||
|
var
|
||||||
|
bResult = true,
|
||||||
|
jqElement = $(oElement),
|
||||||
|
oCommand = fValueAccessor()
|
||||||
|
;
|
||||||
|
|
||||||
|
bResult = oCommand.enabled();
|
||||||
|
jqElement.toggleClass('command-not-enabled', !bResult);
|
||||||
|
|
||||||
|
if (bResult)
|
||||||
|
{
|
||||||
|
bResult = oCommand.canExecute();
|
||||||
|
jqElement.toggleClass('command-can-not-be-execute', !bResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
jqElement.toggleClass('command-disabled disable disabled', !bResult).toggleClass('no-disabled', !!bResult);
|
||||||
|
|
||||||
|
if (jqElement.is('input') || jqElement.is('button'))
|
||||||
|
{
|
||||||
|
jqElement.prop('disabled', !bResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.extenders.trimmer = function (oTarget)
|
||||||
|
{
|
||||||
|
var oResult = ko.computed({
|
||||||
|
'read': oTarget,
|
||||||
|
'write': function (sNewValue) {
|
||||||
|
oTarget(Utils.trim(sNewValue.toString()));
|
||||||
|
},
|
||||||
|
'owner': this
|
||||||
|
});
|
||||||
|
|
||||||
|
oResult(oTarget());
|
||||||
|
return oResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.extenders.posInterer = function (oTarget, iDefault)
|
||||||
|
{
|
||||||
|
var oResult = ko.computed({
|
||||||
|
'read': oTarget,
|
||||||
|
'write': function (sNewValue) {
|
||||||
|
var iNew = Utils.pInt(sNewValue.toString(), iDefault);
|
||||||
|
if (0 >= iNew)
|
||||||
|
{
|
||||||
|
iNew = iDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iNew === oTarget() && '' + iNew !== '' + sNewValue)
|
||||||
|
{
|
||||||
|
oTarget(iNew + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
oTarget(iNew);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
oResult(oTarget());
|
||||||
|
return oResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.extenders.reversible = function (oTarget)
|
||||||
|
{
|
||||||
|
var mValue = oTarget();
|
||||||
|
|
||||||
|
oTarget.commit = function ()
|
||||||
|
{
|
||||||
|
mValue = oTarget();
|
||||||
|
};
|
||||||
|
|
||||||
|
oTarget.reverse = function ()
|
||||||
|
{
|
||||||
|
oTarget(mValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
oTarget.commitedValue = function ()
|
||||||
|
{
|
||||||
|
return mValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
return oTarget;
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.extenders.toggleSubscribe = function (oTarget, oOptions)
|
||||||
|
{
|
||||||
|
oTarget.subscribe(oOptions[1], oOptions[0], 'beforeChange');
|
||||||
|
oTarget.subscribe(oOptions[2], oOptions[0]);
|
||||||
|
|
||||||
|
return oTarget;
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.extenders.falseTimeout = function (oTarget, iOption)
|
||||||
|
{
|
||||||
|
oTarget.iTimeout = 0;
|
||||||
|
oTarget.subscribe(function (bValue) {
|
||||||
|
if (bValue)
|
||||||
|
{
|
||||||
|
window.clearTimeout(oTarget.iTimeout);
|
||||||
|
oTarget.iTimeout = window.setTimeout(function () {
|
||||||
|
oTarget(false);
|
||||||
|
oTarget.iTimeout = 0;
|
||||||
|
}, Utils.pInt(iOption));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return oTarget;
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.observable.fn.validateNone = function ()
|
||||||
|
{
|
||||||
|
this.hasError = ko.observable(false);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.observable.fn.validateEmail = function ()
|
||||||
|
{
|
||||||
|
this.hasError = ko.observable(false);
|
||||||
|
|
||||||
|
this.subscribe(function (sValue) {
|
||||||
|
sValue = Utils.trim(sValue);
|
||||||
|
this.hasError('' !== sValue && !(/^[^@\s]+@[^@\s]+$/.test(sValue)));
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.valueHasMutated();
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.observable.fn.validateSimpleEmail = function ()
|
||||||
|
{
|
||||||
|
this.hasError = ko.observable(false);
|
||||||
|
|
||||||
|
this.subscribe(function (sValue) {
|
||||||
|
sValue = Utils.trim(sValue);
|
||||||
|
this.hasError('' !== sValue && !(/^.+@.+$/.test(sValue)));
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.valueHasMutated();
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
ko.observable.fn.validateFunc = function (fFunc)
|
||||||
|
{
|
||||||
|
this.hasFuncError = ko.observable(false);
|
||||||
|
|
||||||
|
if (Utils.isFunc(fFunc))
|
||||||
|
{
|
||||||
|
this.subscribe(function (sValue) {
|
||||||
|
this.hasFuncError(!fFunc(sValue));
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.valueHasMutated();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = ko;
|
||||||
|
|
||||||
|
}(module));
|
||||||
5
dev/External/moment.js
vendored
Normal file
5
dev/External/moment.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = moment;
|
||||||
5
dev/External/ssm.js
vendored
Normal file
5
dev/External/ssm.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = ssm;
|
||||||
5
dev/External/underscore.js
vendored
Normal file
5
dev/External/underscore.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = window;
|
||||||
5
dev/External/window.js
vendored
Normal file
5
dev/External/window.js
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = window;
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function KnoinAbstractBoot()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
KnoinAbstractBoot.prototype.bootstart = function ()
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sScreenName
|
|
||||||
* @param {?=} aViewModels = []
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function KnoinAbstractScreen(sScreenName, aViewModels)
|
|
||||||
{
|
|
||||||
this.sScreenName = sScreenName;
|
|
||||||
this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Array}
|
|
||||||
*/
|
|
||||||
KnoinAbstractScreen.prototype.oCross = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
KnoinAbstractScreen.prototype.sScreenName = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Array}
|
|
||||||
*/
|
|
||||||
KnoinAbstractScreen.prototype.aViewModels = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Array}
|
|
||||||
*/
|
|
||||||
KnoinAbstractScreen.prototype.viewModels = function ()
|
|
||||||
{
|
|
||||||
return this.aViewModels;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
KnoinAbstractScreen.prototype.screenName = function ()
|
|
||||||
{
|
|
||||||
return this.sScreenName;
|
|
||||||
};
|
|
||||||
|
|
||||||
KnoinAbstractScreen.prototype.routes = function ()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {?Object}
|
|
||||||
*/
|
|
||||||
KnoinAbstractScreen.prototype.__cross = function ()
|
|
||||||
{
|
|
||||||
return this.oCross;
|
|
||||||
};
|
|
||||||
|
|
||||||
KnoinAbstractScreen.prototype.__start = function ()
|
|
||||||
{
|
|
||||||
var
|
|
||||||
aRoutes = this.routes(),
|
|
||||||
oRoute = null,
|
|
||||||
fMatcher = null
|
|
||||||
;
|
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(aRoutes))
|
|
||||||
{
|
|
||||||
fMatcher = _.bind(this.onRoute || Utils.emptyFunction, this);
|
|
||||||
oRoute = crossroads.create();
|
|
||||||
|
|
||||||
_.each(aRoutes, function (aItem) {
|
|
||||||
oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1];
|
|
||||||
});
|
|
||||||
|
|
||||||
this.oCross = oRoute;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string=} sPosition = ''
|
|
||||||
* @param {string=} sTemplate = ''
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function KnoinAbstractViewModel(sPosition, sTemplate)
|
|
||||||
{
|
|
||||||
this.bDisabeCloseOnEsc = false;
|
|
||||||
this.sPosition = Utils.pString(sPosition);
|
|
||||||
this.sTemplate = Utils.pString(sTemplate);
|
|
||||||
|
|
||||||
this.sDefaultKeyScope = Enums.KeyState.None;
|
|
||||||
this.sCurrentKeyScope = this.sDefaultKeyScope;
|
|
||||||
|
|
||||||
this.viewModelName = '';
|
|
||||||
this.viewModelVisibility = ko.observable(false);
|
|
||||||
this.modalVisibility = ko.observable(false).extend({'rateLimit': 0});
|
|
||||||
|
|
||||||
this.viewModelDom = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
KnoinAbstractViewModel.prototype.sPosition = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
KnoinAbstractViewModel.prototype.sTemplate = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
KnoinAbstractViewModel.prototype.viewModelName = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {?}
|
|
||||||
*/
|
|
||||||
KnoinAbstractViewModel.prototype.viewModelDom = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
KnoinAbstractViewModel.prototype.viewModelTemplate = function ()
|
|
||||||
{
|
|
||||||
return this.sTemplate;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
KnoinAbstractViewModel.prototype.viewModelPosition = function ()
|
|
||||||
{
|
|
||||||
return this.sPosition;
|
|
||||||
};
|
|
||||||
|
|
||||||
KnoinAbstractViewModel.prototype.cancelCommand = KnoinAbstractViewModel.prototype.closeCommand = function ()
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
KnoinAbstractViewModel.prototype.storeAndSetKeyScope = function ()
|
|
||||||
{
|
|
||||||
this.sCurrentKeyScope = RL.data().keyScope();
|
|
||||||
RL.data().keyScope(this.sDefaultKeyScope);
|
|
||||||
};
|
|
||||||
|
|
||||||
KnoinAbstractViewModel.prototype.restoreKeyScope = function ()
|
|
||||||
{
|
|
||||||
RL.data().keyScope(this.sCurrentKeyScope);
|
|
||||||
};
|
|
||||||
|
|
||||||
KnoinAbstractViewModel.prototype.registerPopupKeyDown = function ()
|
|
||||||
{
|
|
||||||
var self = this;
|
|
||||||
$window.on('keydown', function (oEvent) {
|
|
||||||
if (oEvent && self.modalVisibility && self.modalVisibility())
|
|
||||||
{
|
|
||||||
if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode)
|
|
||||||
{
|
|
||||||
Utils.delegateRun(self, 'cancelCommand');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (Enums.EventKeyCode.Backspace === oEvent.keyCode && !Utils.inFocus())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
@ -1,415 +1,486 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function Knoin()
|
|
||||||
{
|
|
||||||
this.sDefaultScreenName = '';
|
|
||||||
this.oScreens = {};
|
|
||||||
this.oBoot = null;
|
|
||||||
this.oCurrentScreen = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
'use strict';
|
||||||
* @param {Object} thisObject
|
|
||||||
*/
|
var
|
||||||
Knoin.constructorEnd = function (thisObject)
|
$ = require('../External/jquery.js'),
|
||||||
{
|
_ = require('../External/underscore.js'),
|
||||||
if (Utils.isFunc(thisObject['__constructor_end']))
|
ko = require('../External/ko.js'),
|
||||||
|
hasher = require('../External/hasher.js'),
|
||||||
|
crossroads = require('../External/crossroads.js'),
|
||||||
|
$html = require('../External/$html.js'),
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
Globals = require('../Common/Globals.js'),
|
||||||
|
Enums = require('../Common/Enums.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function Knoin()
|
||||||
{
|
{
|
||||||
thisObject['__constructor_end'].call(thisObject);
|
this.sDefaultScreenName = '';
|
||||||
}
|
this.oScreens = {};
|
||||||
};
|
this.oBoot = null;
|
||||||
|
this.oCurrentScreen = null;
|
||||||
Knoin.prototype.sDefaultScreenName = '';
|
|
||||||
Knoin.prototype.oScreens = {};
|
|
||||||
Knoin.prototype.oBoot = null;
|
|
||||||
Knoin.prototype.oCurrentScreen = null;
|
|
||||||
|
|
||||||
Knoin.prototype.hideLoading = function ()
|
|
||||||
{
|
|
||||||
$('#rl-loading').hide();
|
|
||||||
};
|
|
||||||
|
|
||||||
Knoin.prototype.routeOff = function ()
|
|
||||||
{
|
|
||||||
hasher.changed.active = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
Knoin.prototype.routeOn = function ()
|
|
||||||
{
|
|
||||||
hasher.changed.active = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Object} oBoot
|
|
||||||
* @return {Knoin}
|
|
||||||
*/
|
|
||||||
Knoin.prototype.setBoot = function (oBoot)
|
|
||||||
{
|
|
||||||
if (Utils.isNormal(oBoot))
|
|
||||||
{
|
|
||||||
this.oBoot = oBoot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
/**
|
||||||
};
|
* @param {Object} thisObject
|
||||||
|
*/
|
||||||
|
Knoin.constructorEnd = function (thisObject)
|
||||||
|
{
|
||||||
|
if (Utils.isFunc(thisObject['__constructor_end']))
|
||||||
|
{
|
||||||
|
thisObject['__constructor_end'].call(thisObject);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
Knoin.prototype.sDefaultScreenName = '';
|
||||||
* @param {string} sScreenName
|
Knoin.prototype.oScreens = {};
|
||||||
* @return {?Object}
|
Knoin.prototype.oBoot = null;
|
||||||
*/
|
Knoin.prototype.oCurrentScreen = null;
|
||||||
Knoin.prototype.screen = function (sScreenName)
|
|
||||||
{
|
|
||||||
return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
Knoin.prototype.hideLoading = function ()
|
||||||
* @param {Function} ViewModelClass
|
{
|
||||||
* @param {Object=} oScreen
|
$('#rl-loading').hide();
|
||||||
*/
|
};
|
||||||
Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
|
|
||||||
{
|
Knoin.prototype.rl = function ()
|
||||||
if (ViewModelClass && !ViewModelClass.__builded)
|
{
|
||||||
|
return this.oBoot;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} thisObject
|
||||||
|
*/
|
||||||
|
Knoin.prototype.constructorEnd = function (thisObject)
|
||||||
|
{
|
||||||
|
if (Utils.isFunc(thisObject['__constructor_end']))
|
||||||
|
{
|
||||||
|
thisObject['__constructor_end'].call(thisObject);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Knoin.prototype.routeOff = function ()
|
||||||
|
{
|
||||||
|
hasher.changed.active = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Knoin.prototype.routeOn = function ()
|
||||||
|
{
|
||||||
|
hasher.changed.active = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sScreenName
|
||||||
|
* @return {?Object}
|
||||||
|
*/
|
||||||
|
Knoin.prototype.screen = function (sScreenName)
|
||||||
|
{
|
||||||
|
return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Function} ViewModelClass
|
||||||
|
* @param {Object=} oScreen
|
||||||
|
*/
|
||||||
|
Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
|
||||||
|
{
|
||||||
|
if (ViewModelClass && !ViewModelClass.__builded)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
oViewModel = new ViewModelClass(oScreen),
|
||||||
|
sPosition = oViewModel.viewModelPosition(),
|
||||||
|
oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()),
|
||||||
|
oViewModelDom = null
|
||||||
|
;
|
||||||
|
|
||||||
|
ViewModelClass.__builded = true;
|
||||||
|
ViewModelClass.__vm = oViewModel;
|
||||||
|
oViewModel.data = RL.data(); // TODO cjs
|
||||||
|
|
||||||
|
oViewModel.viewModelName = ViewModelClass.__name;
|
||||||
|
|
||||||
|
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
||||||
|
{
|
||||||
|
oViewModelDom = $('<div></div>').addClass('rl-view-model').addClass('RL-' + oViewModel.viewModelTemplate()).hide();
|
||||||
|
oViewModelDom.appendTo(oViewModelPlace);
|
||||||
|
|
||||||
|
oViewModel.viewModelDom = oViewModelDom;
|
||||||
|
ViewModelClass.__dom = oViewModelDom;
|
||||||
|
|
||||||
|
if ('Popups' === sPosition)
|
||||||
|
{
|
||||||
|
oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, function () {
|
||||||
|
kn.hideScreenPopup(ViewModelClass); // TODO cjs
|
||||||
|
});
|
||||||
|
|
||||||
|
oViewModel.modalVisibility.subscribe(function (bValue) {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
if (bValue)
|
||||||
|
{
|
||||||
|
this.viewModelDom.show();
|
||||||
|
this.storeAndSetKeyScope();
|
||||||
|
|
||||||
|
RL.popupVisibilityNames.push(this.viewModelName); // TODO cjs
|
||||||
|
oViewModel.viewModelDom.css('z-index', 3000 + RL.popupVisibilityNames().length + 10); // TODO cjs
|
||||||
|
|
||||||
|
Utils.delegateRun(this, 'onFocus', [], 500);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Utils.delegateRun(this, 'onHide');
|
||||||
|
this.restoreKeyScope();
|
||||||
|
|
||||||
|
RL.popupVisibilityNames.remove(this.viewModelName); // TODO cjs
|
||||||
|
oViewModel.viewModelDom.css('z-index', 2000);
|
||||||
|
|
||||||
|
Globals.tooltipTrigger(!Globals.tooltipTrigger());
|
||||||
|
|
||||||
|
_.delay(function () {
|
||||||
|
self.viewModelDom.hide();
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, oViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
Plugins.runHook('view-model-pre-build', [ViewModelClass.__name, oViewModel, oViewModelDom]); // TODO cjs
|
||||||
|
|
||||||
|
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
||||||
|
'i18nInit': true,
|
||||||
|
'template': function () { return {'name': oViewModel.viewModelTemplate()};}
|
||||||
|
}, oViewModel);
|
||||||
|
|
||||||
|
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
|
||||||
|
if (oViewModel && 'Popups' === sPosition)
|
||||||
|
{
|
||||||
|
oViewModel.registerPopupKeyDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]); // TODO cjs
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Utils.log('Cannot find view model position: ' + sPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ViewModelClass ? ViewModelClass.__vm : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Object} oViewModel
|
||||||
|
* @param {Object} oViewModelDom
|
||||||
|
*/
|
||||||
|
Knoin.prototype.applyExternal = function (oViewModel, oViewModelDom)
|
||||||
|
{
|
||||||
|
if (oViewModel && oViewModelDom)
|
||||||
|
{
|
||||||
|
ko.applyBindings(oViewModel, oViewModelDom);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Function} ViewModelClassToHide
|
||||||
|
*/
|
||||||
|
Knoin.prototype.hideScreenPopup = function (ViewModelClassToHide)
|
||||||
|
{
|
||||||
|
if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom)
|
||||||
|
{
|
||||||
|
ViewModelClassToHide.__vm.modalVisibility(false);
|
||||||
|
Plugins.runHook('view-model-on-hide', [ViewModelClassToHide.__name, ViewModelClassToHide.__vm]); // TODO cjs
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Function} ViewModelClassToShow
|
||||||
|
* @param {Array=} aParameters
|
||||||
|
*/
|
||||||
|
Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters)
|
||||||
|
{
|
||||||
|
if (ViewModelClassToShow)
|
||||||
|
{
|
||||||
|
this.buildViewModel(ViewModelClassToShow);
|
||||||
|
|
||||||
|
if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom)
|
||||||
|
{
|
||||||
|
ViewModelClassToShow.__vm.modalVisibility(true);
|
||||||
|
Utils.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []);
|
||||||
|
Plugins.runHook('view-model-on-show', [ViewModelClassToShow.__name, ViewModelClassToShow.__vm, aParameters || []]); // TODO cjs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Function} ViewModelClassToShow
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
Knoin.prototype.isPopupVisible = function (ViewModelClassToShow)
|
||||||
|
{
|
||||||
|
return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sScreenName
|
||||||
|
* @param {string} sSubPart
|
||||||
|
*/
|
||||||
|
Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
oViewModel = new ViewModelClass(oScreen),
|
self = this,
|
||||||
sPosition = oViewModel.viewModelPosition(),
|
oScreen = null,
|
||||||
oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()),
|
oCross = null
|
||||||
oViewModelDom = null
|
|
||||||
;
|
;
|
||||||
|
|
||||||
ViewModelClass.__builded = true;
|
if ('' === Utils.pString(sScreenName))
|
||||||
ViewModelClass.__vm = oViewModel;
|
|
||||||
oViewModel.data = RL.data();
|
|
||||||
|
|
||||||
oViewModel.viewModelName = ViewModelClass.__name;
|
|
||||||
|
|
||||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
|
||||||
{
|
{
|
||||||
oViewModelDom = $('<div></div>').addClass('rl-view-model').addClass('RL-' + oViewModel.viewModelTemplate()).hide();
|
sScreenName = this.sDefaultScreenName;
|
||||||
oViewModelDom.appendTo(oViewModelPlace);
|
}
|
||||||
|
|
||||||
oViewModel.viewModelDom = oViewModelDom;
|
if ('' !== sScreenName)
|
||||||
ViewModelClass.__dom = oViewModelDom;
|
{
|
||||||
|
oScreen = this.screen(sScreenName);
|
||||||
if ('Popups' === sPosition)
|
if (!oScreen)
|
||||||
{
|
{
|
||||||
oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, function () {
|
oScreen = this.screen(this.sDefaultScreenName);
|
||||||
kn.hideScreenPopup(ViewModelClass);
|
if (oScreen)
|
||||||
|
{
|
||||||
|
sSubPart = sScreenName + '/' + sSubPart;
|
||||||
|
sScreenName = this.sDefaultScreenName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oScreen && oScreen.__started)
|
||||||
|
{
|
||||||
|
if (!oScreen.__builded)
|
||||||
|
{
|
||||||
|
oScreen.__builded = true;
|
||||||
|
|
||||||
|
if (Utils.isNonEmptyArray(oScreen.viewModels()))
|
||||||
|
{
|
||||||
|
_.each(oScreen.viewModels(), function (ViewModelClass) {
|
||||||
|
this.buildViewModel(ViewModelClass, oScreen);
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.delegateRun(oScreen, 'onBuild');
|
||||||
|
}
|
||||||
|
|
||||||
|
_.defer(function () {
|
||||||
|
|
||||||
|
// hide screen
|
||||||
|
if (self.oCurrentScreen)
|
||||||
|
{
|
||||||
|
Utils.delegateRun(self.oCurrentScreen, 'onHide');
|
||||||
|
|
||||||
|
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
|
||||||
|
{
|
||||||
|
_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) {
|
||||||
|
|
||||||
|
if (ViewModelClass.__vm && ViewModelClass.__dom &&
|
||||||
|
'Popups' !== ViewModelClass.__vm.viewModelPosition())
|
||||||
|
{
|
||||||
|
ViewModelClass.__dom.hide();
|
||||||
|
ViewModelClass.__vm.viewModelVisibility(false);
|
||||||
|
Utils.delegateRun(ViewModelClass.__vm, 'onHide');
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// --
|
||||||
|
|
||||||
|
self.oCurrentScreen = oScreen;
|
||||||
|
|
||||||
|
// show screen
|
||||||
|
if (self.oCurrentScreen)
|
||||||
|
{
|
||||||
|
Utils.delegateRun(self.oCurrentScreen, 'onShow');
|
||||||
|
|
||||||
|
Plugins.runHook('screen-on-show', [self.oCurrentScreen.screenName(), self.oCurrentScreen]); // TODO cjs
|
||||||
|
|
||||||
|
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
|
||||||
|
{
|
||||||
|
_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) {
|
||||||
|
|
||||||
|
if (ViewModelClass.__vm && ViewModelClass.__dom &&
|
||||||
|
'Popups' !== ViewModelClass.__vm.viewModelPosition())
|
||||||
|
{
|
||||||
|
ViewModelClass.__dom.show();
|
||||||
|
ViewModelClass.__vm.viewModelVisibility(true);
|
||||||
|
Utils.delegateRun(ViewModelClass.__vm, 'onShow');
|
||||||
|
Utils.delegateRun(ViewModelClass.__vm, 'onFocus', [], 200);
|
||||||
|
|
||||||
|
Plugins.runHook('view-model-on-show', [ViewModelClass.__name, ViewModelClass.__vm]); // TODO cjs
|
||||||
|
}
|
||||||
|
|
||||||
|
}, self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// --
|
||||||
|
|
||||||
|
oCross = oScreen.__cross();
|
||||||
|
if (oCross)
|
||||||
|
{
|
||||||
|
oCross.parse(sSubPart);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
oViewModel.modalVisibility.subscribe(function (bValue) {
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
if (bValue)
|
|
||||||
{
|
|
||||||
this.viewModelDom.show();
|
|
||||||
this.storeAndSetKeyScope();
|
|
||||||
|
|
||||||
RL.popupVisibilityNames.push(this.viewModelName);
|
|
||||||
oViewModel.viewModelDom.css('z-index', 3000 + RL.popupVisibilityNames().length + 10);
|
|
||||||
|
|
||||||
Utils.delegateRun(this, 'onFocus', [], 500);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Utils.delegateRun(this, 'onHide');
|
|
||||||
this.restoreKeyScope();
|
|
||||||
|
|
||||||
RL.popupVisibilityNames.remove(this.viewModelName);
|
|
||||||
oViewModel.viewModelDom.css('z-index', 2000);
|
|
||||||
|
|
||||||
Globals.tooltipTrigger(!Globals.tooltipTrigger());
|
|
||||||
|
|
||||||
_.delay(function () {
|
|
||||||
self.viewModelDom.hide();
|
|
||||||
}, 300);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, oViewModel);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Plugins.runHook('view-model-pre-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
|
/**
|
||||||
|
* @param {Array} aScreensClasses
|
||||||
|
*/
|
||||||
|
Knoin.prototype.startScreens = function (aScreensClasses)
|
||||||
|
{
|
||||||
|
$('#rl-content').css({
|
||||||
|
'visibility': 'hidden'
|
||||||
|
});
|
||||||
|
|
||||||
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
_.each(aScreensClasses, function (CScreen) {
|
||||||
'i18nInit': true,
|
|
||||||
'template': function () { return {'name': oViewModel.viewModelTemplate()};}
|
|
||||||
}, oViewModel);
|
|
||||||
|
|
||||||
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
|
var
|
||||||
if (oViewModel && 'Popups' === sPosition)
|
oScreen = new CScreen(),
|
||||||
|
sScreenName = oScreen ? oScreen.screenName() : ''
|
||||||
|
;
|
||||||
|
|
||||||
|
if (oScreen && '' !== sScreenName)
|
||||||
|
{
|
||||||
|
if ('' === this.sDefaultScreenName)
|
||||||
|
{
|
||||||
|
this.sDefaultScreenName = sScreenName;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.oScreens[sScreenName] = oScreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
|
||||||
|
_.each(this.oScreens, function (oScreen) {
|
||||||
|
if (oScreen && !oScreen.__started && oScreen.__start)
|
||||||
{
|
{
|
||||||
oViewModel.registerPopupKeyDown();
|
oScreen.__started = true;
|
||||||
}
|
oScreen.__start();
|
||||||
|
|
||||||
Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
|
Plugins.runHook('screen-pre-start', [oScreen.screenName(), oScreen]); // TODO cjs
|
||||||
|
Utils.delegateRun(oScreen, 'onStart');
|
||||||
|
Plugins.runHook('screen-post-start', [oScreen.screenName(), oScreen]); // TODO cjs
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
var oCross = crossroads.create();
|
||||||
|
oCross.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/, _.bind(this.screenOnRoute, this));
|
||||||
|
|
||||||
|
hasher.initialized.add(oCross.parse, oCross);
|
||||||
|
hasher.changed.add(oCross.parse, oCross);
|
||||||
|
hasher.init();
|
||||||
|
|
||||||
|
$('#rl-content').css({
|
||||||
|
'visibility': 'visible'
|
||||||
|
});
|
||||||
|
|
||||||
|
_.delay(function () {
|
||||||
|
$html.removeClass('rl-started-trigger').addClass('rl-started');
|
||||||
|
}, 50);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sHash
|
||||||
|
* @param {boolean=} bSilence = false
|
||||||
|
* @param {boolean=} bReplace = false
|
||||||
|
*/
|
||||||
|
Knoin.prototype.setHash = function (sHash, bSilence, bReplace)
|
||||||
|
{
|
||||||
|
sHash = '#' === sHash.substr(0, 1) ? sHash.substr(1) : sHash;
|
||||||
|
sHash = '/' === sHash.substr(0, 1) ? sHash.substr(1) : sHash;
|
||||||
|
|
||||||
|
bReplace = Utils.isUnd(bReplace) ? false : !!bReplace;
|
||||||
|
|
||||||
|
if (Utils.isUnd(bSilence) ? false : !!bSilence)
|
||||||
|
{
|
||||||
|
hasher.changed.active = false;
|
||||||
|
hasher[bReplace ? 'replaceHash' : 'setHash'](sHash);
|
||||||
|
hasher.changed.active = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Utils.log('Cannot find view model position: ' + sPosition);
|
hasher.changed.active = true;
|
||||||
|
hasher[bReplace ? 'replaceHash' : 'setHash'](sHash);
|
||||||
|
hasher.setHash(sHash);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return ViewModelClass ? ViewModelClass.__vm : null;
|
/**
|
||||||
};
|
* @return {Knoin}
|
||||||
|
*/
|
||||||
/**
|
Knoin.prototype.bootstart = function (RL)
|
||||||
* @param {Object} oViewModel
|
|
||||||
* @param {Object} oViewModelDom
|
|
||||||
*/
|
|
||||||
Knoin.prototype.applyExternal = function (oViewModel, oViewModelDom)
|
|
||||||
{
|
|
||||||
if (oViewModel && oViewModelDom)
|
|
||||||
{
|
{
|
||||||
ko.applyBindings(oViewModel, oViewModelDom);
|
this.oBoot = RL;
|
||||||
}
|
|
||||||
};
|
var
|
||||||
|
window = require('../External/window.js'),
|
||||||
|
$window = require('../External/$window.js'),
|
||||||
|
$html = require('../External/$html.js'),
|
||||||
|
Plugins = require('../Common/Plugins.js'),
|
||||||
|
EmailModel = require('../Models/EmailModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile');
|
||||||
|
|
||||||
/**
|
$window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS);
|
||||||
* @param {Function} ViewModelClassToHide
|
$window.unload(function () {
|
||||||
*/
|
Globals.bUnload = true;
|
||||||
Knoin.prototype.hideScreenPopup = function (ViewModelClassToHide)
|
});
|
||||||
{
|
|
||||||
if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom)
|
|
||||||
{
|
|
||||||
ViewModelClassToHide.__vm.modalVisibility(false);
|
|
||||||
Plugins.runHook('view-model-on-hide', [ViewModelClassToHide.__name, ViewModelClassToHide.__vm]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
$html.on('click.dropdown.data-api', function () {
|
||||||
* @param {Function} ViewModelClassToShow
|
Utils.detectDropdownVisibility();
|
||||||
* @param {Array=} aParameters
|
});
|
||||||
*/
|
|
||||||
Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters)
|
|
||||||
{
|
|
||||||
if (ViewModelClassToShow)
|
|
||||||
{
|
|
||||||
this.buildViewModel(ViewModelClassToShow);
|
|
||||||
|
|
||||||
if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom)
|
// export
|
||||||
{
|
window['rl'] = window['rl'] || {};
|
||||||
ViewModelClassToShow.__vm.modalVisibility(true);
|
window['rl']['addHook'] = Plugins.addHook;
|
||||||
Utils.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []);
|
window['rl']['settingsGet'] = Plugins.mainSettingsGet;
|
||||||
Plugins.runHook('view-model-on-show', [ViewModelClassToShow.__name, ViewModelClassToShow.__vm, aParameters || []]);
|
window['rl']['remoteRequest'] = Plugins.remoteRequest;
|
||||||
}
|
window['rl']['pluginSettingsGet'] = Plugins.settingsGet;
|
||||||
}
|
window['rl']['addSettingsViewModel'] = Utils.addSettingsViewModel;
|
||||||
};
|
window['rl']['createCommand'] = Utils.createCommand;
|
||||||
|
|
||||||
/**
|
window['rl']['EmailModel'] = EmailModel;
|
||||||
* @param {Function} ViewModelClassToShow
|
window['rl']['Enums'] = Enums;
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
Knoin.prototype.isPopupVisible = function (ViewModelClassToShow)
|
|
||||||
{
|
|
||||||
return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
window['__RLBOOT'] = function (fCall) {
|
||||||
* @param {string} sScreenName
|
|
||||||
* @param {string} sSubPart
|
|
||||||
*/
|
|
||||||
Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
self = this,
|
|
||||||
oScreen = null,
|
|
||||||
oCross = null
|
|
||||||
;
|
|
||||||
|
|
||||||
if ('' === Utils.pString(sScreenName))
|
// boot
|
||||||
{
|
$(function () {
|
||||||
sScreenName = this.sDefaultScreenName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('' !== sScreenName)
|
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
|
||||||
{
|
|
||||||
oScreen = this.screen(sScreenName);
|
|
||||||
if (!oScreen)
|
|
||||||
{
|
|
||||||
oScreen = this.screen(this.sDefaultScreenName);
|
|
||||||
if (oScreen)
|
|
||||||
{
|
|
||||||
sSubPart = sScreenName + '/' + sSubPart;
|
|
||||||
sScreenName = this.sDefaultScreenName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oScreen && oScreen.__started)
|
|
||||||
{
|
|
||||||
if (!oScreen.__builded)
|
|
||||||
{
|
|
||||||
oScreen.__builded = true;
|
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(oScreen.viewModels()))
|
|
||||||
{
|
{
|
||||||
_.each(oScreen.viewModels(), function (ViewModelClass) {
|
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
|
||||||
this.buildViewModel(ViewModelClass, oScreen);
|
|
||||||
}, this);
|
_.delay(function () {
|
||||||
|
|
||||||
|
RL.bootstart();
|
||||||
|
|
||||||
|
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fCall(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.delegateRun(oScreen, 'onBuild');
|
window['__RLBOOT'] = null;
|
||||||
}
|
|
||||||
|
|
||||||
_.defer(function () {
|
|
||||||
|
|
||||||
// hide screen
|
|
||||||
if (self.oCurrentScreen)
|
|
||||||
{
|
|
||||||
Utils.delegateRun(self.oCurrentScreen, 'onHide');
|
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
|
|
||||||
{
|
|
||||||
_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) {
|
|
||||||
|
|
||||||
if (ViewModelClass.__vm && ViewModelClass.__dom &&
|
|
||||||
'Popups' !== ViewModelClass.__vm.viewModelPosition())
|
|
||||||
{
|
|
||||||
ViewModelClass.__dom.hide();
|
|
||||||
ViewModelClass.__vm.viewModelVisibility(false);
|
|
||||||
Utils.delegateRun(ViewModelClass.__vm, 'onHide');
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
self.oCurrentScreen = oScreen;
|
|
||||||
|
|
||||||
// show screen
|
|
||||||
if (self.oCurrentScreen)
|
|
||||||
{
|
|
||||||
Utils.delegateRun(self.oCurrentScreen, 'onShow');
|
|
||||||
|
|
||||||
Plugins.runHook('screen-on-show', [self.oCurrentScreen.screenName(), self.oCurrentScreen]);
|
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
|
|
||||||
{
|
|
||||||
_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) {
|
|
||||||
|
|
||||||
if (ViewModelClass.__vm && ViewModelClass.__dom &&
|
|
||||||
'Popups' !== ViewModelClass.__vm.viewModelPosition())
|
|
||||||
{
|
|
||||||
ViewModelClass.__dom.show();
|
|
||||||
ViewModelClass.__vm.viewModelVisibility(true);
|
|
||||||
Utils.delegateRun(ViewModelClass.__vm, 'onShow');
|
|
||||||
Utils.delegateRun(ViewModelClass.__vm, 'onFocus', [], 200);
|
|
||||||
|
|
||||||
Plugins.runHook('view-model-on-show', [ViewModelClass.__name, ViewModelClass.__vm]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, self);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
oCross = oScreen.__cross();
|
|
||||||
if (oCross)
|
|
||||||
{
|
|
||||||
oCross.parse(sSubPart);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
module.exports = new Knoin();
|
||||||
* @param {Array} aScreensClasses
|
|
||||||
*/
|
|
||||||
Knoin.prototype.startScreens = function (aScreensClasses)
|
|
||||||
{
|
|
||||||
$('#rl-content').css({
|
|
||||||
'visibility': 'hidden'
|
|
||||||
});
|
|
||||||
|
|
||||||
_.each(aScreensClasses, function (CScreen) {
|
}(module));
|
||||||
|
|
||||||
var
|
|
||||||
oScreen = new CScreen(),
|
|
||||||
sScreenName = oScreen ? oScreen.screenName() : ''
|
|
||||||
;
|
|
||||||
|
|
||||||
if (oScreen && '' !== sScreenName)
|
|
||||||
{
|
|
||||||
if ('' === this.sDefaultScreenName)
|
|
||||||
{
|
|
||||||
this.sDefaultScreenName = sScreenName;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.oScreens[sScreenName] = oScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
|
|
||||||
_.each(this.oScreens, function (oScreen) {
|
|
||||||
if (oScreen && !oScreen.__started && oScreen.__start)
|
|
||||||
{
|
|
||||||
oScreen.__started = true;
|
|
||||||
oScreen.__start();
|
|
||||||
|
|
||||||
Plugins.runHook('screen-pre-start', [oScreen.screenName(), oScreen]);
|
|
||||||
Utils.delegateRun(oScreen, 'onStart');
|
|
||||||
Plugins.runHook('screen-post-start', [oScreen.screenName(), oScreen]);
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
var oCross = crossroads.create();
|
|
||||||
oCross.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/, _.bind(this.screenOnRoute, this));
|
|
||||||
|
|
||||||
hasher.initialized.add(oCross.parse, oCross);
|
|
||||||
hasher.changed.add(oCross.parse, oCross);
|
|
||||||
hasher.init();
|
|
||||||
|
|
||||||
$('#rl-content').css({
|
|
||||||
'visibility': 'visible'
|
|
||||||
});
|
|
||||||
|
|
||||||
_.delay(function () {
|
|
||||||
$html.removeClass('rl-started-trigger').addClass('rl-started');
|
|
||||||
}, 50);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sHash
|
|
||||||
* @param {boolean=} bSilence = false
|
|
||||||
* @param {boolean=} bReplace = false
|
|
||||||
*/
|
|
||||||
Knoin.prototype.setHash = function (sHash, bSilence, bReplace)
|
|
||||||
{
|
|
||||||
sHash = '#' === sHash.substr(0, 1) ? sHash.substr(1) : sHash;
|
|
||||||
sHash = '/' === sHash.substr(0, 1) ? sHash.substr(1) : sHash;
|
|
||||||
|
|
||||||
bReplace = Utils.isUnd(bReplace) ? false : !!bReplace;
|
|
||||||
|
|
||||||
if (Utils.isUnd(bSilence) ? false : !!bSilence)
|
|
||||||
{
|
|
||||||
hasher.changed.active = false;
|
|
||||||
hasher[bReplace ? 'replaceHash' : 'setHash'](sHash);
|
|
||||||
hasher.changed.active = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hasher.changed.active = true;
|
|
||||||
hasher[bReplace ? 'replaceHash' : 'setHash'](sHash);
|
|
||||||
hasher.setHash(sHash);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Knoin}
|
|
||||||
*/
|
|
||||||
Knoin.prototype.bootstart = function ()
|
|
||||||
{
|
|
||||||
if (this.oBoot && this.oBoot.bootstart)
|
|
||||||
{
|
|
||||||
this.oBoot.bootstart();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
kn = new Knoin();
|
|
||||||
22
dev/Knoin/KnoinAbstractBoot.js
Normal file
22
dev/Knoin/KnoinAbstractBoot.js
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function KnoinAbstractBoot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
KnoinAbstractBoot.prototype.bootstart = function ()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = KnoinAbstractBoot;
|
||||||
|
|
||||||
|
}(module));
|
||||||
90
dev/Knoin/KnoinAbstractScreen.js
Normal file
90
dev/Knoin/KnoinAbstractScreen.js
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
crossroads = require('../External/crossroads.js'),
|
||||||
|
Utils = require('../Common/Utils.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sScreenName
|
||||||
|
* @param {?=} aViewModels = []
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function KnoinAbstractScreen(sScreenName, aViewModels)
|
||||||
|
{
|
||||||
|
this.sScreenName = sScreenName;
|
||||||
|
this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array}
|
||||||
|
*/
|
||||||
|
KnoinAbstractScreen.prototype.oCross = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
KnoinAbstractScreen.prototype.sScreenName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array}
|
||||||
|
*/
|
||||||
|
KnoinAbstractScreen.prototype.aViewModels = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Array}
|
||||||
|
*/
|
||||||
|
KnoinAbstractScreen.prototype.viewModels = function ()
|
||||||
|
{
|
||||||
|
return this.aViewModels;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
KnoinAbstractScreen.prototype.screenName = function ()
|
||||||
|
{
|
||||||
|
return this.sScreenName;
|
||||||
|
};
|
||||||
|
|
||||||
|
KnoinAbstractScreen.prototype.routes = function ()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {?Object}
|
||||||
|
*/
|
||||||
|
KnoinAbstractScreen.prototype.__cross = function ()
|
||||||
|
{
|
||||||
|
return this.oCross;
|
||||||
|
};
|
||||||
|
|
||||||
|
KnoinAbstractScreen.prototype.__start = function ()
|
||||||
|
{
|
||||||
|
var
|
||||||
|
aRoutes = this.routes(),
|
||||||
|
oRoute = null,
|
||||||
|
fMatcher = null
|
||||||
|
;
|
||||||
|
|
||||||
|
if (Utils.isNonEmptyArray(aRoutes))
|
||||||
|
{
|
||||||
|
fMatcher = _.bind(this.onRoute || Utils.emptyFunction, this);
|
||||||
|
oRoute = crossroads.create();
|
||||||
|
|
||||||
|
_.each(aRoutes, function (aItem) {
|
||||||
|
oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1];
|
||||||
|
});
|
||||||
|
|
||||||
|
this.oCross = oRoute;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = KnoinAbstractScreen;
|
||||||
|
|
||||||
|
}(module));
|
||||||
109
dev/Knoin/KnoinAbstractViewModel.js
Normal file
109
dev/Knoin/KnoinAbstractViewModel.js
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
ko = require('../External/ko.js'),
|
||||||
|
$window = require('../External/$window.js'),
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
Enums = require('../Common/Enums.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string=} sPosition = ''
|
||||||
|
* @param {string=} sTemplate = ''
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function KnoinAbstractViewModel(sPosition, sTemplate)
|
||||||
|
{
|
||||||
|
this.bDisabeCloseOnEsc = false;
|
||||||
|
this.sPosition = Utils.pString(sPosition);
|
||||||
|
this.sTemplate = Utils.pString(sTemplate);
|
||||||
|
|
||||||
|
this.sDefaultKeyScope = Enums.KeyState.None;
|
||||||
|
this.sCurrentKeyScope = this.sDefaultKeyScope;
|
||||||
|
|
||||||
|
this.viewModelName = '';
|
||||||
|
this.viewModelVisibility = ko.observable(false);
|
||||||
|
this.modalVisibility = ko.observable(false).extend({'rateLimit': 0});
|
||||||
|
|
||||||
|
this.viewModelDom = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
KnoinAbstractViewModel.prototype.sPosition = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
KnoinAbstractViewModel.prototype.sTemplate = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
KnoinAbstractViewModel.prototype.viewModelName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {?}
|
||||||
|
*/
|
||||||
|
KnoinAbstractViewModel.prototype.viewModelDom = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
KnoinAbstractViewModel.prototype.viewModelTemplate = function ()
|
||||||
|
{
|
||||||
|
return this.sTemplate;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
KnoinAbstractViewModel.prototype.viewModelPosition = function ()
|
||||||
|
{
|
||||||
|
return this.sPosition;
|
||||||
|
};
|
||||||
|
|
||||||
|
KnoinAbstractViewModel.prototype.cancelCommand = KnoinAbstractViewModel.prototype.closeCommand = function ()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
KnoinAbstractViewModel.prototype.storeAndSetKeyScope = function ()
|
||||||
|
{
|
||||||
|
this.sCurrentKeyScope = RL.data().keyScope(); // TODO cjs
|
||||||
|
RL.data().keyScope(this.sDefaultKeyScope); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
KnoinAbstractViewModel.prototype.restoreKeyScope = function ()
|
||||||
|
{
|
||||||
|
RL.data().keyScope(this.sCurrentKeyScope); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
KnoinAbstractViewModel.prototype.registerPopupKeyDown = function ()
|
||||||
|
{
|
||||||
|
var self = this;
|
||||||
|
$window.on('keydown', function (oEvent) {
|
||||||
|
if (oEvent && self.modalVisibility && self.modalVisibility())
|
||||||
|
{
|
||||||
|
if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode)
|
||||||
|
{
|
||||||
|
Utils.delegateRun(self, 'cancelCommand');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (Enums.EventKeyCode.Backspace === oEvent.keyCode && !Utils.inFocus())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = KnoinAbstractViewModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,23 +1,35 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @param {string} sEmail
|
|
||||||
* @param {boolean=} bCanBeDelete = true
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AccountModel(sEmail, bCanBeDelete)
|
|
||||||
{
|
|
||||||
this.email = sEmail;
|
|
||||||
this.deleteAccess = ko.observable(false);
|
|
||||||
this.canBeDalete = ko.observable(bCanBeDelete);
|
|
||||||
}
|
|
||||||
|
|
||||||
AccountModel.prototype.email = '';
|
'use strict';
|
||||||
|
|
||||||
/**
|
var
|
||||||
* @return {string}
|
ko = require('../External/ko.js')
|
||||||
*/
|
;
|
||||||
AccountModel.prototype.changeAccountLink = function ()
|
|
||||||
{
|
/**
|
||||||
return RL.link().change(this.email);
|
* @param {string} sEmail
|
||||||
};
|
* @param {boolean=} bCanBeDelete = true
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function AccountModel(sEmail, bCanBeDelete)
|
||||||
|
{
|
||||||
|
this.email = sEmail;
|
||||||
|
this.deleteAccess = ko.observable(false);
|
||||||
|
this.canBeDalete = ko.observable(bCanBeDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountModel.prototype.email = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
AccountModel.prototype.changeAccountLink = function ()
|
||||||
|
{
|
||||||
|
return RL.link().change(this.email); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AccountModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,237 +1,251 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AttachmentModel()
|
|
||||||
{
|
|
||||||
this.mimeType = '';
|
|
||||||
this.fileName = '';
|
|
||||||
this.estimatedSize = 0;
|
|
||||||
this.friendlySize = '';
|
|
||||||
this.isInline = false;
|
|
||||||
this.isLinked = false;
|
|
||||||
this.cid = '';
|
|
||||||
this.cidWithOutTags = '';
|
|
||||||
this.contentLocation = '';
|
|
||||||
this.download = '';
|
|
||||||
this.folder = '';
|
|
||||||
this.uid = '';
|
|
||||||
this.mimeIndex = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
'use strict';
|
||||||
* @static
|
|
||||||
* @param {AjaxJsonAttachment} oJsonAttachment
|
|
||||||
* @return {?AttachmentModel}
|
|
||||||
*/
|
|
||||||
AttachmentModel.newInstanceFromJson = function (oJsonAttachment)
|
|
||||||
{
|
|
||||||
var oAttachmentModel = new AttachmentModel();
|
|
||||||
return oAttachmentModel.initByJson(oJsonAttachment) ? oAttachmentModel : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
AttachmentModel.prototype.mimeType = '';
|
|
||||||
AttachmentModel.prototype.fileName = '';
|
|
||||||
AttachmentModel.prototype.estimatedSize = 0;
|
|
||||||
AttachmentModel.prototype.friendlySize = '';
|
|
||||||
AttachmentModel.prototype.isInline = false;
|
|
||||||
AttachmentModel.prototype.isLinked = false;
|
|
||||||
AttachmentModel.prototype.cid = '';
|
|
||||||
AttachmentModel.prototype.cidWithOutTags = '';
|
|
||||||
AttachmentModel.prototype.contentLocation = '';
|
|
||||||
AttachmentModel.prototype.download = '';
|
|
||||||
AttachmentModel.prototype.folder = '';
|
|
||||||
AttachmentModel.prototype.uid = '';
|
|
||||||
AttachmentModel.prototype.mimeIndex = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {AjaxJsonAttachment} oJsonAttachment
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.initByJson = function (oJsonAttachment)
|
|
||||||
{
|
|
||||||
var bResult = false;
|
|
||||||
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
|
|
||||||
{
|
|
||||||
this.mimeType = (oJsonAttachment.MimeType || '').toLowerCase();
|
|
||||||
this.fileName = oJsonAttachment.FileName;
|
|
||||||
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
|
|
||||||
this.isInline = !!oJsonAttachment.IsInline;
|
|
||||||
this.isLinked = !!oJsonAttachment.IsLinked;
|
|
||||||
this.cid = oJsonAttachment.CID;
|
|
||||||
this.contentLocation = oJsonAttachment.ContentLocation;
|
|
||||||
this.download = oJsonAttachment.Download;
|
|
||||||
|
|
||||||
this.folder = oJsonAttachment.Folder;
|
|
||||||
this.uid = oJsonAttachment.Uid;
|
|
||||||
this.mimeIndex = oJsonAttachment.MimeIndex;
|
|
||||||
|
|
||||||
this.friendlySize = Utils.friendlySize(this.estimatedSize);
|
|
||||||
this.cidWithOutTags = this.cid.replace(/^<+/, '').replace(/>+$/, '');
|
|
||||||
|
|
||||||
bResult = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.isImage = function ()
|
|
||||||
{
|
|
||||||
return -1 < Utils.inArray(this.mimeType.toLowerCase(),
|
|
||||||
['image/png', 'image/jpg', 'image/jpeg', 'image/gif']
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.isText = function ()
|
|
||||||
{
|
|
||||||
return 'text/' === this.mimeType.substr(0, 5) &&
|
|
||||||
-1 === Utils.inArray(this.mimeType, ['text/html']);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.isPdf = function ()
|
|
||||||
{
|
|
||||||
return Globals.bAllowPdfPreview && 'application/pdf' === this.mimeType;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.linkDownload = function ()
|
|
||||||
{
|
|
||||||
return RL.link().attachmentDownload(this.download);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.linkPreview = function ()
|
|
||||||
{
|
|
||||||
return RL.link().attachmentPreview(this.download);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.linkPreviewAsPlain = function ()
|
|
||||||
{
|
|
||||||
return RL.link().attachmentPreviewAsPlain(this.download);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.generateTransferDownloadUrl = function ()
|
|
||||||
{
|
|
||||||
var sLink = this.linkDownload();
|
|
||||||
if ('http' !== sLink.substr(0, 4))
|
|
||||||
{
|
|
||||||
sLink = window.location.protocol + '//' + window.location.host + window.location.pathname + sLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.mimeType + ':' + this.fileName + ':' + sLink;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {AttachmentModel} oAttachment
|
|
||||||
* @param {*} oEvent
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
AttachmentModel.prototype.eventDragStart = function (oAttachment, oEvent)
|
|
||||||
{
|
|
||||||
var oLocalEvent = oEvent.originalEvent || oEvent;
|
|
||||||
if (oAttachment && oLocalEvent && oLocalEvent.dataTransfer && oLocalEvent.dataTransfer.setData)
|
|
||||||
{
|
|
||||||
oLocalEvent.dataTransfer.setData('DownloadURL', this.generateTransferDownloadUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
AttachmentModel.prototype.iconClass = function ()
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
aParts = this.mimeType.toLocaleString().split('/'),
|
window = require('../External/window.js'),
|
||||||
sClass = 'icon-file'
|
Globals = require('../Common/Globals.js'),
|
||||||
|
Utils = require('../Common/Utils.js')
|
||||||
;
|
;
|
||||||
|
|
||||||
if (aParts && aParts[1])
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function AttachmentModel()
|
||||||
{
|
{
|
||||||
if ('image' === aParts[0])
|
this.mimeType = '';
|
||||||
{
|
this.fileName = '';
|
||||||
sClass = 'icon-file-image';
|
this.estimatedSize = 0;
|
||||||
}
|
this.friendlySize = '';
|
||||||
else if ('text' === aParts[0])
|
this.isInline = false;
|
||||||
{
|
this.isLinked = false;
|
||||||
sClass = 'icon-file-text';
|
this.cid = '';
|
||||||
}
|
this.cidWithOutTags = '';
|
||||||
else if ('audio' === aParts[0])
|
this.contentLocation = '';
|
||||||
{
|
this.download = '';
|
||||||
sClass = 'icon-file-music';
|
this.folder = '';
|
||||||
}
|
this.uid = '';
|
||||||
else if ('video' === aParts[0])
|
this.mimeIndex = '';
|
||||||
{
|
|
||||||
sClass = 'icon-file-movie';
|
|
||||||
}
|
|
||||||
else if (-1 < Utils.inArray(aParts[1],
|
|
||||||
['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2', 'x-zip', 'x-7z', 'x-rar', 'x-tar', 'x-gzip', 'x-bzip', 'x-bzip2', 'x-zip-compressed', 'x-7z-compressed', 'x-rar-compressed']))
|
|
||||||
{
|
|
||||||
sClass = 'icon-file-zip';
|
|
||||||
}
|
|
||||||
// else if (-1 < Utils.inArray(aParts[1],
|
|
||||||
// ['pdf', 'x-pdf']))
|
|
||||||
// {
|
|
||||||
// sClass = 'icon-file-pdf';
|
|
||||||
// }
|
|
||||||
// else if (-1 < Utils.inArray(aParts[1], [
|
|
||||||
// 'exe', 'x-exe', 'x-winexe', 'bat'
|
|
||||||
// ]))
|
|
||||||
// {
|
|
||||||
// sClass = 'icon-console';
|
|
||||||
// }
|
|
||||||
else if (-1 < Utils.inArray(aParts[1], [
|
|
||||||
'rtf', 'msword', 'vnd.msword', 'vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
||||||
'vnd.openxmlformats-officedocument.wordprocessingml.template',
|
|
||||||
'vnd.ms-word.document.macroEnabled.12',
|
|
||||||
'vnd.ms-word.template.macroEnabled.12'
|
|
||||||
]))
|
|
||||||
{
|
|
||||||
sClass = 'icon-file-text';
|
|
||||||
}
|
|
||||||
else if (-1 < Utils.inArray(aParts[1], [
|
|
||||||
'excel', 'ms-excel', 'vnd.ms-excel',
|
|
||||||
'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
||||||
'vnd.openxmlformats-officedocument.spreadsheetml.template',
|
|
||||||
'vnd.ms-excel.sheet.macroEnabled.12',
|
|
||||||
'vnd.ms-excel.template.macroEnabled.12',
|
|
||||||
'vnd.ms-excel.addin.macroEnabled.12',
|
|
||||||
'vnd.ms-excel.sheet.binary.macroEnabled.12'
|
|
||||||
]))
|
|
||||||
{
|
|
||||||
sClass = 'icon-file-excel';
|
|
||||||
}
|
|
||||||
else if (-1 < Utils.inArray(aParts[1], [
|
|
||||||
'powerpoint', 'ms-powerpoint', 'vnd.ms-powerpoint',
|
|
||||||
'vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
||||||
'vnd.openxmlformats-officedocument.presentationml.template',
|
|
||||||
'vnd.openxmlformats-officedocument.presentationml.slideshow',
|
|
||||||
'vnd.ms-powerpoint.addin.macroEnabled.12',
|
|
||||||
'vnd.ms-powerpoint.presentation.macroEnabled.12',
|
|
||||||
'vnd.ms-powerpoint.template.macroEnabled.12',
|
|
||||||
'vnd.ms-powerpoint.slideshow.macroEnabled.12'
|
|
||||||
]))
|
|
||||||
{
|
|
||||||
sClass = 'icon-file-chart-graph';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sClass;
|
/**
|
||||||
};
|
* @static
|
||||||
|
* @param {AjaxJsonAttachment} oJsonAttachment
|
||||||
|
* @return {?AttachmentModel}
|
||||||
|
*/
|
||||||
|
AttachmentModel.newInstanceFromJson = function (oJsonAttachment)
|
||||||
|
{
|
||||||
|
var oAttachmentModel = new AttachmentModel();
|
||||||
|
return oAttachmentModel.initByJson(oJsonAttachment) ? oAttachmentModel : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
AttachmentModel.prototype.mimeType = '';
|
||||||
|
AttachmentModel.prototype.fileName = '';
|
||||||
|
AttachmentModel.prototype.estimatedSize = 0;
|
||||||
|
AttachmentModel.prototype.friendlySize = '';
|
||||||
|
AttachmentModel.prototype.isInline = false;
|
||||||
|
AttachmentModel.prototype.isLinked = false;
|
||||||
|
AttachmentModel.prototype.cid = '';
|
||||||
|
AttachmentModel.prototype.cidWithOutTags = '';
|
||||||
|
AttachmentModel.prototype.contentLocation = '';
|
||||||
|
AttachmentModel.prototype.download = '';
|
||||||
|
AttachmentModel.prototype.folder = '';
|
||||||
|
AttachmentModel.prototype.uid = '';
|
||||||
|
AttachmentModel.prototype.mimeIndex = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AjaxJsonAttachment} oJsonAttachment
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.initByJson = function (oJsonAttachment)
|
||||||
|
{
|
||||||
|
var bResult = false;
|
||||||
|
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
|
||||||
|
{
|
||||||
|
this.mimeType = (oJsonAttachment.MimeType || '').toLowerCase();
|
||||||
|
this.fileName = oJsonAttachment.FileName;
|
||||||
|
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
|
||||||
|
this.isInline = !!oJsonAttachment.IsInline;
|
||||||
|
this.isLinked = !!oJsonAttachment.IsLinked;
|
||||||
|
this.cid = oJsonAttachment.CID;
|
||||||
|
this.contentLocation = oJsonAttachment.ContentLocation;
|
||||||
|
this.download = oJsonAttachment.Download;
|
||||||
|
|
||||||
|
this.folder = oJsonAttachment.Folder;
|
||||||
|
this.uid = oJsonAttachment.Uid;
|
||||||
|
this.mimeIndex = oJsonAttachment.MimeIndex;
|
||||||
|
|
||||||
|
this.friendlySize = Utils.friendlySize(this.estimatedSize);
|
||||||
|
this.cidWithOutTags = this.cid.replace(/^<+/, '').replace(/>+$/, '');
|
||||||
|
|
||||||
|
bResult = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.isImage = function ()
|
||||||
|
{
|
||||||
|
return -1 < Utils.inArray(this.mimeType.toLowerCase(),
|
||||||
|
['image/png', 'image/jpg', 'image/jpeg', 'image/gif']
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.isText = function ()
|
||||||
|
{
|
||||||
|
return 'text/' === this.mimeType.substr(0, 5) &&
|
||||||
|
-1 === Utils.inArray(this.mimeType, ['text/html']);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.isPdf = function ()
|
||||||
|
{
|
||||||
|
return Globals.bAllowPdfPreview && 'application/pdf' === this.mimeType;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.linkDownload = function ()
|
||||||
|
{
|
||||||
|
return RL.link().attachmentDownload(this.download); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.linkPreview = function ()
|
||||||
|
{
|
||||||
|
return RL.link().attachmentPreview(this.download); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.linkPreviewAsPlain = function ()
|
||||||
|
{
|
||||||
|
return RL.link().attachmentPreviewAsPlain(this.download);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.generateTransferDownloadUrl = function ()
|
||||||
|
{
|
||||||
|
var sLink = this.linkDownload();
|
||||||
|
if ('http' !== sLink.substr(0, 4))
|
||||||
|
{
|
||||||
|
sLink = window.location.protocol + '//' + window.location.host + window.location.pathname + sLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.mimeType + ':' + this.fileName + ':' + sLink;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AttachmentModel} oAttachment
|
||||||
|
* @param {*} oEvent
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.eventDragStart = function (oAttachment, oEvent)
|
||||||
|
{
|
||||||
|
var oLocalEvent = oEvent.originalEvent || oEvent;
|
||||||
|
if (oAttachment && oLocalEvent && oLocalEvent.dataTransfer && oLocalEvent.dataTransfer.setData)
|
||||||
|
{
|
||||||
|
oLocalEvent.dataTransfer.setData('DownloadURL', this.generateTransferDownloadUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
AttachmentModel.prototype.iconClass = function ()
|
||||||
|
{
|
||||||
|
var
|
||||||
|
aParts = this.mimeType.toLocaleString().split('/'),
|
||||||
|
sClass = 'icon-file'
|
||||||
|
;
|
||||||
|
|
||||||
|
if (aParts && aParts[1])
|
||||||
|
{
|
||||||
|
if ('image' === aParts[0])
|
||||||
|
{
|
||||||
|
sClass = 'icon-file-image';
|
||||||
|
}
|
||||||
|
else if ('text' === aParts[0])
|
||||||
|
{
|
||||||
|
sClass = 'icon-file-text';
|
||||||
|
}
|
||||||
|
else if ('audio' === aParts[0])
|
||||||
|
{
|
||||||
|
sClass = 'icon-file-music';
|
||||||
|
}
|
||||||
|
else if ('video' === aParts[0])
|
||||||
|
{
|
||||||
|
sClass = 'icon-file-movie';
|
||||||
|
}
|
||||||
|
else if (-1 < Utils.inArray(aParts[1],
|
||||||
|
['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2', 'x-zip', 'x-7z', 'x-rar', 'x-tar', 'x-gzip', 'x-bzip', 'x-bzip2', 'x-zip-compressed', 'x-7z-compressed', 'x-rar-compressed']))
|
||||||
|
{
|
||||||
|
sClass = 'icon-file-zip';
|
||||||
|
}
|
||||||
|
// else if (-1 < Utils.inArray(aParts[1],
|
||||||
|
// ['pdf', 'x-pdf']))
|
||||||
|
// {
|
||||||
|
// sClass = 'icon-file-pdf';
|
||||||
|
// }
|
||||||
|
// else if (-1 < Utils.inArray(aParts[1], [
|
||||||
|
// 'exe', 'x-exe', 'x-winexe', 'bat'
|
||||||
|
// ]))
|
||||||
|
// {
|
||||||
|
// sClass = 'icon-console';
|
||||||
|
// }
|
||||||
|
else if (-1 < Utils.inArray(aParts[1], [
|
||||||
|
'rtf', 'msword', 'vnd.msword', 'vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
'vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||||
|
'vnd.ms-word.document.macroEnabled.12',
|
||||||
|
'vnd.ms-word.template.macroEnabled.12'
|
||||||
|
]))
|
||||||
|
{
|
||||||
|
sClass = 'icon-file-text';
|
||||||
|
}
|
||||||
|
else if (-1 < Utils.inArray(aParts[1], [
|
||||||
|
'excel', 'ms-excel', 'vnd.ms-excel',
|
||||||
|
'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
'vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||||
|
'vnd.ms-excel.sheet.macroEnabled.12',
|
||||||
|
'vnd.ms-excel.template.macroEnabled.12',
|
||||||
|
'vnd.ms-excel.addin.macroEnabled.12',
|
||||||
|
'vnd.ms-excel.sheet.binary.macroEnabled.12'
|
||||||
|
]))
|
||||||
|
{
|
||||||
|
sClass = 'icon-file-excel';
|
||||||
|
}
|
||||||
|
else if (-1 < Utils.inArray(aParts[1], [
|
||||||
|
'powerpoint', 'ms-powerpoint', 'vnd.ms-powerpoint',
|
||||||
|
'vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||||
|
'vnd.openxmlformats-officedocument.presentationml.template',
|
||||||
|
'vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||||
|
'vnd.ms-powerpoint.addin.macroEnabled.12',
|
||||||
|
'vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||||
|
'vnd.ms-powerpoint.template.macroEnabled.12',
|
||||||
|
'vnd.ms-powerpoint.slideshow.macroEnabled.12'
|
||||||
|
]))
|
||||||
|
{
|
||||||
|
sClass = 'icon-file-chart-graph';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sClass;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AttachmentModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,63 +1,76 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @param {string} sId
|
|
||||||
* @param {string} sFileName
|
|
||||||
* @param {?number=} nSize
|
|
||||||
* @param {boolean=} bInline
|
|
||||||
* @param {boolean=} bLinked
|
|
||||||
* @param {string=} sCID
|
|
||||||
* @param {string=} sContentLocation
|
|
||||||
*/
|
|
||||||
function ComposeAttachmentModel(sId, sFileName, nSize, bInline, bLinked, sCID, sContentLocation)
|
|
||||||
{
|
|
||||||
this.id = sId;
|
|
||||||
this.isInline = Utils.isUnd(bInline) ? false : !!bInline;
|
|
||||||
this.isLinked = Utils.isUnd(bLinked) ? false : !!bLinked;
|
|
||||||
this.CID = Utils.isUnd(sCID) ? '' : sCID;
|
|
||||||
this.contentLocation = Utils.isUnd(sContentLocation) ? '' : sContentLocation;
|
|
||||||
this.fromMessage = false;
|
|
||||||
|
|
||||||
this.fileName = ko.observable(sFileName);
|
'use strict';
|
||||||
this.size = ko.observable(Utils.isUnd(nSize) ? null : nSize);
|
|
||||||
this.tempName = ko.observable('');
|
|
||||||
|
|
||||||
this.progress = ko.observable('');
|
var
|
||||||
this.error = ko.observable('');
|
ko = require('../External/ko.js'),
|
||||||
this.waiting = ko.observable(true);
|
Utils = require('../Common/Utils.js')
|
||||||
this.uploading = ko.observable(false);
|
;
|
||||||
this.enabled = ko.observable(true);
|
|
||||||
|
|
||||||
this.friendlySize = ko.computed(function () {
|
/**
|
||||||
var mSize = this.size();
|
* @constructor
|
||||||
return null === mSize ? '' : Utils.friendlySize(this.size());
|
* @param {string} sId
|
||||||
}, this);
|
* @param {string} sFileName
|
||||||
}
|
* @param {?number=} nSize
|
||||||
|
* @param {boolean=} bInline
|
||||||
ComposeAttachmentModel.prototype.id = '';
|
* @param {boolean=} bLinked
|
||||||
ComposeAttachmentModel.prototype.isInline = false;
|
* @param {string=} sCID
|
||||||
ComposeAttachmentModel.prototype.isLinked = false;
|
* @param {string=} sContentLocation
|
||||||
ComposeAttachmentModel.prototype.CID = '';
|
*/
|
||||||
ComposeAttachmentModel.prototype.contentLocation = '';
|
function ComposeAttachmentModel(sId, sFileName, nSize, bInline, bLinked, sCID, sContentLocation)
|
||||||
ComposeAttachmentModel.prototype.fromMessage = false;
|
|
||||||
ComposeAttachmentModel.prototype.cancel = Utils.emptyFunction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {AjaxJsonComposeAttachment} oJsonAttachment
|
|
||||||
*/
|
|
||||||
ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment)
|
|
||||||
{
|
|
||||||
var bResult = false;
|
|
||||||
if (oJsonAttachment)
|
|
||||||
{
|
{
|
||||||
this.fileName(oJsonAttachment.Name);
|
this.id = sId;
|
||||||
this.size(Utils.isUnd(oJsonAttachment.Size) ? 0 : Utils.pInt(oJsonAttachment.Size));
|
this.isInline = Utils.isUnd(bInline) ? false : !!bInline;
|
||||||
this.tempName(Utils.isUnd(oJsonAttachment.TempName) ? '' : oJsonAttachment.TempName);
|
this.isLinked = Utils.isUnd(bLinked) ? false : !!bLinked;
|
||||||
this.isInline = false;
|
this.CID = Utils.isUnd(sCID) ? '' : sCID;
|
||||||
|
this.contentLocation = Utils.isUnd(sContentLocation) ? '' : sContentLocation;
|
||||||
|
this.fromMessage = false;
|
||||||
|
|
||||||
bResult = true;
|
this.fileName = ko.observable(sFileName);
|
||||||
|
this.size = ko.observable(Utils.isUnd(nSize) ? null : nSize);
|
||||||
|
this.tempName = ko.observable('');
|
||||||
|
|
||||||
|
this.progress = ko.observable('');
|
||||||
|
this.error = ko.observable('');
|
||||||
|
this.waiting = ko.observable(true);
|
||||||
|
this.uploading = ko.observable(false);
|
||||||
|
this.enabled = ko.observable(true);
|
||||||
|
|
||||||
|
this.friendlySize = ko.computed(function () {
|
||||||
|
var mSize = this.size();
|
||||||
|
return null === mSize ? '' : Utils.friendlySize(this.size());
|
||||||
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bResult;
|
ComposeAttachmentModel.prototype.id = '';
|
||||||
};
|
ComposeAttachmentModel.prototype.isInline = false;
|
||||||
|
ComposeAttachmentModel.prototype.isLinked = false;
|
||||||
|
ComposeAttachmentModel.prototype.CID = '';
|
||||||
|
ComposeAttachmentModel.prototype.contentLocation = '';
|
||||||
|
ComposeAttachmentModel.prototype.fromMessage = false;
|
||||||
|
ComposeAttachmentModel.prototype.cancel = Utils.emptyFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AjaxJsonComposeAttachment} oJsonAttachment
|
||||||
|
*/
|
||||||
|
ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment)
|
||||||
|
{
|
||||||
|
var bResult = false;
|
||||||
|
if (oJsonAttachment)
|
||||||
|
{
|
||||||
|
this.fileName(oJsonAttachment.Name);
|
||||||
|
this.size(Utils.isUnd(oJsonAttachment.Size) ? 0 : Utils.pInt(oJsonAttachment.Size));
|
||||||
|
this.tempName(Utils.isUnd(oJsonAttachment.TempName) ? '' : oJsonAttachment.TempName);
|
||||||
|
this.isInline = false;
|
||||||
|
|
||||||
|
bResult = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = ComposeAttachmentModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,125 +1,140 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function ContactModel()
|
|
||||||
{
|
|
||||||
this.idContact = 0;
|
|
||||||
this.display = '';
|
|
||||||
this.properties = [];
|
|
||||||
this.tags = '';
|
|
||||||
this.readOnly = false;
|
|
||||||
|
|
||||||
this.focused = ko.observable(false);
|
'use strict';
|
||||||
this.selected = ko.observable(false);
|
|
||||||
this.checked = ko.observable(false);
|
|
||||||
this.deleted = ko.observable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Array|null}
|
|
||||||
*/
|
|
||||||
ContactModel.prototype.getNameAndEmailHelper = function ()
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
sName = '',
|
_ = require('../External/underscore.js'),
|
||||||
sEmail = ''
|
ko = require('../External/ko.js'),
|
||||||
|
Enums = require('../Common/Enums.js'),
|
||||||
|
Utils = require('../Common/Utils.js')
|
||||||
;
|
;
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(this.properties))
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function ContactModel()
|
||||||
{
|
{
|
||||||
_.each(this.properties, function (aProperty) {
|
this.idContact = 0;
|
||||||
if (aProperty)
|
this.display = '';
|
||||||
{
|
this.properties = [];
|
||||||
if (Enums.ContactPropertyType.FirstName === aProperty[0])
|
this.tags = '';
|
||||||
{
|
this.readOnly = false;
|
||||||
sName = Utils.trim(aProperty[1] + ' ' + sName);
|
|
||||||
}
|
this.focused = ko.observable(false);
|
||||||
else if (Enums.ContactPropertyType.LastName === aProperty[0])
|
this.selected = ko.observable(false);
|
||||||
{
|
this.checked = ko.observable(false);
|
||||||
sName = Utils.trim(sName + ' ' + aProperty[1]);
|
this.deleted = ko.observable(false);
|
||||||
}
|
|
||||||
else if ('' === sEmail && Enums.ContactPropertyType.Email === aProperty[0])
|
|
||||||
{
|
|
||||||
sEmail = aProperty[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '' === sEmail ? null : [sEmail, sName];
|
/**
|
||||||
};
|
* @return {Array|null}
|
||||||
|
*/
|
||||||
ContactModel.prototype.parse = function (oItem)
|
ContactModel.prototype.getNameAndEmailHelper = function ()
|
||||||
{
|
|
||||||
var bResult = false;
|
|
||||||
if (oItem && 'Object/Contact' === oItem['@Object'])
|
|
||||||
{
|
{
|
||||||
this.idContact = Utils.pInt(oItem['IdContact']);
|
var
|
||||||
this.display = Utils.pString(oItem['Display']);
|
sName = '',
|
||||||
this.readOnly = !!oItem['ReadOnly'];
|
sEmail = ''
|
||||||
this.tags = '';
|
;
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(oItem['Properties']))
|
if (Utils.isNonEmptyArray(this.properties))
|
||||||
{
|
{
|
||||||
_.each(oItem['Properties'], function (oProperty) {
|
_.each(this.properties, function (aProperty) {
|
||||||
if (oProperty && oProperty['Type'] && Utils.isNormal(oProperty['Value']) && Utils.isNormal(oProperty['TypeStr']))
|
if (aProperty)
|
||||||
{
|
{
|
||||||
this.properties.push([Utils.pInt(oProperty['Type']), Utils.pString(oProperty['Value']), Utils.pString(oProperty['TypeStr'])]);
|
if (Enums.ContactPropertyType.FirstName === aProperty[0])
|
||||||
|
{
|
||||||
|
sName = Utils.trim(aProperty[1] + ' ' + sName);
|
||||||
|
}
|
||||||
|
else if (Enums.ContactPropertyType.LastName === aProperty[0])
|
||||||
|
{
|
||||||
|
sName = Utils.trim(sName + ' ' + aProperty[1]);
|
||||||
|
}
|
||||||
|
else if ('' === sEmail && Enums.ContactPropertyType.Email === aProperty[0])
|
||||||
|
{
|
||||||
|
sEmail = aProperty[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.isNonEmptyArray(oItem['Tags']))
|
return '' === sEmail ? null : [sEmail, sName];
|
||||||
|
};
|
||||||
|
|
||||||
|
ContactModel.prototype.parse = function (oItem)
|
||||||
|
{
|
||||||
|
var bResult = false;
|
||||||
|
if (oItem && 'Object/Contact' === oItem['@Object'])
|
||||||
{
|
{
|
||||||
this.tags = oItem['Tags'].join(',');
|
this.idContact = Utils.pInt(oItem['IdContact']);
|
||||||
|
this.display = Utils.pString(oItem['Display']);
|
||||||
|
this.readOnly = !!oItem['ReadOnly'];
|
||||||
|
this.tags = '';
|
||||||
|
|
||||||
|
if (Utils.isNonEmptyArray(oItem['Properties']))
|
||||||
|
{
|
||||||
|
_.each(oItem['Properties'], function (oProperty) {
|
||||||
|
if (oProperty && oProperty['Type'] && Utils.isNormal(oProperty['Value']) && Utils.isNormal(oProperty['TypeStr']))
|
||||||
|
{
|
||||||
|
this.properties.push([Utils.pInt(oProperty['Type']), Utils.pString(oProperty['Value']), Utils.pString(oProperty['TypeStr'])]);
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Utils.isNonEmptyArray(oItem['Tags']))
|
||||||
|
{
|
||||||
|
this.tags = oItem['Tags'].join(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
bResult = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bResult = true;
|
return bResult;
|
||||||
}
|
};
|
||||||
|
|
||||||
return bResult;
|
/**
|
||||||
};
|
* @return {string}
|
||||||
|
*/
|
||||||
/**
|
ContactModel.prototype.srcAttr = function ()
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
ContactModel.prototype.srcAttr = function ()
|
|
||||||
{
|
|
||||||
return RL.link().emptyContactPic();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
ContactModel.prototype.generateUid = function ()
|
|
||||||
{
|
|
||||||
return '' + this.idContact;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
ContactModel.prototype.lineAsCcc = function ()
|
|
||||||
{
|
|
||||||
var aResult = [];
|
|
||||||
if (this.deleted())
|
|
||||||
{
|
{
|
||||||
aResult.push('deleted');
|
return RL.link().emptyContactPic(); // TODO cjs
|
||||||
}
|
};
|
||||||
if (this.selected())
|
|
||||||
{
|
|
||||||
aResult.push('selected');
|
|
||||||
}
|
|
||||||
if (this.checked())
|
|
||||||
{
|
|
||||||
aResult.push('checked');
|
|
||||||
}
|
|
||||||
if (this.focused())
|
|
||||||
{
|
|
||||||
aResult.push('focused');
|
|
||||||
}
|
|
||||||
|
|
||||||
return aResult.join(' ');
|
/**
|
||||||
};
|
* @return {string}
|
||||||
|
*/
|
||||||
|
ContactModel.prototype.generateUid = function ()
|
||||||
|
{
|
||||||
|
return '' + this.idContact;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
ContactModel.prototype.lineAsCcc = function ()
|
||||||
|
{
|
||||||
|
var aResult = [];
|
||||||
|
if (this.deleted())
|
||||||
|
{
|
||||||
|
aResult.push('deleted');
|
||||||
|
}
|
||||||
|
if (this.selected())
|
||||||
|
{
|
||||||
|
aResult.push('selected');
|
||||||
|
}
|
||||||
|
if (this.checked())
|
||||||
|
{
|
||||||
|
aResult.push('checked');
|
||||||
|
}
|
||||||
|
if (this.focused())
|
||||||
|
{
|
||||||
|
aResult.push('focused');
|
||||||
|
}
|
||||||
|
|
||||||
|
return aResult.join(' ');
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = ContactModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,30 +1,43 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @param {number=} iType = Enums.ContactPropertyType.Unknown
|
|
||||||
* @param {string=} sTypeStr = ''
|
|
||||||
* @param {string=} sValue = ''
|
|
||||||
* @param {boolean=} bFocused = false
|
|
||||||
* @param {string=} sPlaceholder = ''
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder)
|
|
||||||
{
|
|
||||||
this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType);
|
|
||||||
this.typeStr = ko.observable(Utils.isUnd(sTypeStr) ? '' : sTypeStr);
|
|
||||||
this.focused = ko.observable(Utils.isUnd(bFocused) ? false : !!bFocused);
|
|
||||||
this.value = ko.observable(Utils.pString(sValue));
|
|
||||||
|
|
||||||
this.placeholder = ko.observable(sPlaceholder || '');
|
'use strict';
|
||||||
|
|
||||||
this.placeholderValue = ko.computed(function () {
|
var
|
||||||
var sPlaceholder = this.placeholder();
|
ko = require('../External/ko.js'),
|
||||||
return sPlaceholder ? Utils.i18n(sPlaceholder) : '';
|
Enums = require('../Common/Enums.js'),
|
||||||
}, this);
|
Utils = require('../Common/Utils.js')
|
||||||
|
;
|
||||||
|
|
||||||
this.largeValue = ko.computed(function () {
|
/**
|
||||||
return Enums.ContactPropertyType.Note === this.type();
|
* @param {number=} iType = Enums.ContactPropertyType.Unknown
|
||||||
}, this);
|
* @param {string=} sTypeStr = ''
|
||||||
|
* @param {string=} sValue = ''
|
||||||
|
* @param {boolean=} bFocused = false
|
||||||
|
* @param {string=} sPlaceholder = ''
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder)
|
||||||
|
{
|
||||||
|
this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType);
|
||||||
|
this.typeStr = ko.observable(Utils.isUnd(sTypeStr) ? '' : sTypeStr);
|
||||||
|
this.focused = ko.observable(Utils.isUnd(bFocused) ? false : !!bFocused);
|
||||||
|
this.value = ko.observable(Utils.pString(sValue));
|
||||||
|
|
||||||
}
|
this.placeholder = ko.observable(sPlaceholder || '');
|
||||||
|
|
||||||
|
this.placeholderValue = ko.computed(function () {
|
||||||
|
var sPlaceholder = this.placeholder();
|
||||||
|
return sPlaceholder ? Utils.i18n(sPlaceholder) : '';
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.largeValue = ko.computed(function () {
|
||||||
|
return Enums.ContactPropertyType.Note === this.type();
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ContactPropertyModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,45 +1,58 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function ContactTagModel()
|
|
||||||
{
|
|
||||||
this.idContactTag = 0;
|
|
||||||
this.name = ko.observable('');
|
|
||||||
this.readOnly = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContactTagModel.prototype.parse = function (oItem)
|
'use strict';
|
||||||
{
|
|
||||||
var bResult = false;
|
var
|
||||||
if (oItem && 'Object/Tag' === oItem['@Object'])
|
ko = require('../External/ko.js'),
|
||||||
|
Utils = require('../Common/Utils.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function ContactTagModel()
|
||||||
{
|
{
|
||||||
this.idContact = Utils.pInt(oItem['IdContactTag']);
|
this.idContactTag = 0;
|
||||||
this.name(Utils.pString(oItem['Name']));
|
this.name = ko.observable('');
|
||||||
this.readOnly = !!oItem['ReadOnly'];
|
this.readOnly = false;
|
||||||
|
|
||||||
bResult = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bResult;
|
ContactTagModel.prototype.parse = function (oItem)
|
||||||
};
|
{
|
||||||
|
var bResult = false;
|
||||||
|
if (oItem && 'Object/Tag' === oItem['@Object'])
|
||||||
|
{
|
||||||
|
this.idContact = Utils.pInt(oItem['IdContactTag']);
|
||||||
|
this.name(Utils.pString(oItem['Name']));
|
||||||
|
this.readOnly = !!oItem['ReadOnly'];
|
||||||
|
|
||||||
/**
|
bResult = true;
|
||||||
* @param {string} sSearch
|
}
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
ContactTagModel.prototype.filterHelper = function (sSearch)
|
|
||||||
{
|
|
||||||
return this.name().toLowerCase().indexOf(sSearch.toLowerCase()) !== -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
return bResult;
|
||||||
* @param {boolean=} bEncodeHtml = false
|
};
|
||||||
* @return {string}
|
|
||||||
*/
|
/**
|
||||||
ContactTagModel.prototype.toLine = function (bEncodeHtml)
|
* @param {string} sSearch
|
||||||
{
|
* @return {boolean}
|
||||||
return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ?
|
*/
|
||||||
Utils.encodeHtml(this.name()) : this.name();
|
ContactTagModel.prototype.filterHelper = function (sSearch)
|
||||||
};
|
{
|
||||||
|
return this.name().toLowerCase().indexOf(sSearch.toLowerCase()) !== -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean=} bEncodeHtml = false
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
ContactTagModel.prototype.toLine = function (bEncodeHtml)
|
||||||
|
{
|
||||||
|
return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ?
|
||||||
|
Utils.encodeHtml(this.name()) : this.name();
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = ContactTagModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,365 +1,378 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @param {string=} sEmail
|
|
||||||
* @param {string=} sName
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function EmailModel(sEmail, sName)
|
|
||||||
{
|
|
||||||
this.email = sEmail || '';
|
|
||||||
this.name = sName || '';
|
|
||||||
this.privateType = null;
|
|
||||||
|
|
||||||
this.clearDuplicateName();
|
'use strict';
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
var
|
||||||
* @static
|
Enums = require('../Common/Enums.js'),
|
||||||
* @param {AjaxJsonEmail} oJsonEmail
|
Utils = require('../Common/Utils.js')
|
||||||
* @return {?EmailModel}
|
;
|
||||||
*/
|
|
||||||
EmailModel.newInstanceFromJson = function (oJsonEmail)
|
|
||||||
{
|
|
||||||
var oEmailModel = new EmailModel();
|
|
||||||
return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string}
|
* @param {string=} sEmail
|
||||||
*/
|
* @param {string=} sName
|
||||||
EmailModel.prototype.name = '';
|
*
|
||||||
|
* @constructor
|
||||||
/**
|
*/
|
||||||
* @type {string}
|
function EmailModel(sEmail, sName)
|
||||||
*/
|
|
||||||
EmailModel.prototype.email = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {(number|null)}
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.privateType = null;
|
|
||||||
|
|
||||||
EmailModel.prototype.clear = function ()
|
|
||||||
{
|
|
||||||
this.email = '';
|
|
||||||
this.name = '';
|
|
||||||
this.privateType = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.validate = function ()
|
|
||||||
{
|
|
||||||
return '' !== this.name || '' !== this.email;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} bWithoutName = false
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.hash = function (bWithoutName)
|
|
||||||
{
|
|
||||||
return '#' + (bWithoutName ? '' : this.name) + '#' + this.email + '#';
|
|
||||||
};
|
|
||||||
|
|
||||||
EmailModel.prototype.clearDuplicateName = function ()
|
|
||||||
{
|
|
||||||
if (this.name === this.email)
|
|
||||||
{
|
{
|
||||||
this.name = '';
|
this.email = sEmail || '';
|
||||||
|
this.name = sName || '';
|
||||||
|
this.privateType = null;
|
||||||
|
|
||||||
|
this.clearDuplicateName();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number}
|
* @static
|
||||||
*/
|
* @param {AjaxJsonEmail} oJsonEmail
|
||||||
EmailModel.prototype.type = function ()
|
* @return {?EmailModel}
|
||||||
{
|
*/
|
||||||
if (null === this.privateType)
|
EmailModel.newInstanceFromJson = function (oJsonEmail)
|
||||||
{
|
{
|
||||||
if (this.email && '@facebook.com' === this.email.substr(-13))
|
var oEmailModel = new EmailModel();
|
||||||
{
|
return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null;
|
||||||
this.privateType = Enums.EmailType.Facebook;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.name = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.email = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {(number|null)}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.privateType = null;
|
||||||
|
|
||||||
|
EmailModel.prototype.clear = function ()
|
||||||
|
{
|
||||||
|
this.email = '';
|
||||||
|
this.name = '';
|
||||||
|
this.privateType = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.validate = function ()
|
||||||
|
{
|
||||||
|
return '' !== this.name || '' !== this.email;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} bWithoutName = false
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.hash = function (bWithoutName)
|
||||||
|
{
|
||||||
|
return '#' + (bWithoutName ? '' : this.name) + '#' + this.email + '#';
|
||||||
|
};
|
||||||
|
|
||||||
|
EmailModel.prototype.clearDuplicateName = function ()
|
||||||
|
{
|
||||||
|
if (this.name === this.email)
|
||||||
|
{
|
||||||
|
this.name = '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.type = function ()
|
||||||
|
{
|
||||||
if (null === this.privateType)
|
if (null === this.privateType)
|
||||||
{
|
{
|
||||||
this.privateType = Enums.EmailType.Default;
|
if (this.email && '@facebook.com' === this.email.substr(-13))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.privateType;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sQuery
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.search = function (sQuery)
|
|
||||||
{
|
|
||||||
return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(sQuery.toLowerCase());
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sString
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.parse = function (sString)
|
|
||||||
{
|
|
||||||
this.clear();
|
|
||||||
|
|
||||||
sString = Utils.trim(sString);
|
|
||||||
|
|
||||||
var
|
|
||||||
mRegex = /(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g,
|
|
||||||
mMatch = mRegex.exec(sString)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (mMatch)
|
|
||||||
{
|
|
||||||
this.name = mMatch[1] || '';
|
|
||||||
this.email = mMatch[2] || '';
|
|
||||||
|
|
||||||
this.clearDuplicateName();
|
|
||||||
}
|
|
||||||
else if ((/^[^@]+@[^@]+$/).test(sString))
|
|
||||||
{
|
|
||||||
this.name = '';
|
|
||||||
this.email = sString;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {AjaxJsonEmail} oJsonEmail
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.initByJson = function (oJsonEmail)
|
|
||||||
{
|
|
||||||
var bResult = false;
|
|
||||||
if (oJsonEmail && 'Object/Email' === oJsonEmail['@Object'])
|
|
||||||
{
|
|
||||||
this.name = Utils.trim(oJsonEmail.Name);
|
|
||||||
this.email = Utils.trim(oJsonEmail.Email);
|
|
||||||
|
|
||||||
bResult = '' !== this.email;
|
|
||||||
this.clearDuplicateName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return bResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {boolean} bFriendlyView
|
|
||||||
* @param {boolean=} bWrapWithLink = false
|
|
||||||
* @param {boolean=} bEncodeHtml = false
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtml)
|
|
||||||
{
|
|
||||||
var sResult = '';
|
|
||||||
if ('' !== this.email)
|
|
||||||
{
|
|
||||||
bWrapWithLink = Utils.isUnd(bWrapWithLink) ? false : !!bWrapWithLink;
|
|
||||||
bEncodeHtml = Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml;
|
|
||||||
|
|
||||||
if (bFriendlyView && '' !== this.name)
|
|
||||||
{
|
|
||||||
sResult = bWrapWithLink ? '<a href="mailto:' + Utils.encodeHtml('"' + this.name + '" <' + this.email + '>') +
|
|
||||||
'" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.name) + '</a>' :
|
|
||||||
(bEncodeHtml ? Utils.encodeHtml(this.name) : this.name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sResult = this.email;
|
|
||||||
if ('' !== this.name)
|
|
||||||
{
|
{
|
||||||
if (bWrapWithLink)
|
this.privateType = Enums.EmailType.Facebook;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === this.privateType)
|
||||||
|
{
|
||||||
|
this.privateType = Enums.EmailType.Default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.privateType;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sQuery
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.search = function (sQuery)
|
||||||
|
{
|
||||||
|
return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(sQuery.toLowerCase());
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sString
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.parse = function (sString)
|
||||||
|
{
|
||||||
|
this.clear();
|
||||||
|
|
||||||
|
sString = Utils.trim(sString);
|
||||||
|
|
||||||
|
var
|
||||||
|
mRegex = /(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g,
|
||||||
|
mMatch = mRegex.exec(sString)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (mMatch)
|
||||||
|
{
|
||||||
|
this.name = mMatch[1] || '';
|
||||||
|
this.email = mMatch[2] || '';
|
||||||
|
|
||||||
|
this.clearDuplicateName();
|
||||||
|
}
|
||||||
|
else if ((/^[^@]+@[^@]+$/).test(sString))
|
||||||
|
{
|
||||||
|
this.name = '';
|
||||||
|
this.email = sString;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AjaxJsonEmail} oJsonEmail
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.initByJson = function (oJsonEmail)
|
||||||
|
{
|
||||||
|
var bResult = false;
|
||||||
|
if (oJsonEmail && 'Object/Email' === oJsonEmail['@Object'])
|
||||||
|
{
|
||||||
|
this.name = Utils.trim(oJsonEmail.Name);
|
||||||
|
this.email = Utils.trim(oJsonEmail.Email);
|
||||||
|
|
||||||
|
bResult = '' !== this.email;
|
||||||
|
this.clearDuplicateName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {boolean} bFriendlyView
|
||||||
|
* @param {boolean=} bWrapWithLink = false
|
||||||
|
* @param {boolean=} bEncodeHtml = false
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtml)
|
||||||
|
{
|
||||||
|
var sResult = '';
|
||||||
|
if ('' !== this.email)
|
||||||
|
{
|
||||||
|
bWrapWithLink = Utils.isUnd(bWrapWithLink) ? false : !!bWrapWithLink;
|
||||||
|
bEncodeHtml = Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml;
|
||||||
|
|
||||||
|
if (bFriendlyView && '' !== this.name)
|
||||||
|
{
|
||||||
|
sResult = bWrapWithLink ? '<a href="mailto:' + Utils.encodeHtml('"' + this.name + '" <' + this.email + '>') +
|
||||||
|
'" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.name) + '</a>' :
|
||||||
|
(bEncodeHtml ? Utils.encodeHtml(this.name) : this.name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sResult = this.email;
|
||||||
|
if ('' !== this.name)
|
||||||
{
|
{
|
||||||
sResult = Utils.encodeHtml('"' + this.name + '" <') +
|
if (bWrapWithLink)
|
||||||
'<a href="mailto:' + Utils.encodeHtml('"' + this.name + '" <' + this.email + '>') + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(sResult) + '</a>' + Utils.encodeHtml('>');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sResult = '"' + this.name + '" <' + sResult + '>';
|
|
||||||
if (bEncodeHtml)
|
|
||||||
{
|
{
|
||||||
sResult = Utils.encodeHtml(sResult);
|
sResult = Utils.encodeHtml('"' + this.name + '" <') +
|
||||||
|
'<a href="mailto:' + Utils.encodeHtml('"' + this.name + '" <' + this.email + '>') + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(sResult) + '</a>' + Utils.encodeHtml('>');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sResult = '"' + this.name + '" <' + sResult + '>';
|
||||||
|
if (bEncodeHtml)
|
||||||
|
{
|
||||||
|
sResult = Utils.encodeHtml(sResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (bWrapWithLink)
|
||||||
|
{
|
||||||
|
sResult = '<a href="mailto:' + Utils.encodeHtml(this.email) + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.email) + '</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (bWrapWithLink)
|
}
|
||||||
|
|
||||||
|
return sResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} $sEmailAddress
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.mailsoParse = function ($sEmailAddress)
|
||||||
|
{
|
||||||
|
$sEmailAddress = Utils.trim($sEmailAddress);
|
||||||
|
if ('' === $sEmailAddress)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var
|
||||||
|
substr = function (str, start, len) {
|
||||||
|
str += '';
|
||||||
|
var end = str.length;
|
||||||
|
|
||||||
|
if (start < 0) {
|
||||||
|
start += end;
|
||||||
|
}
|
||||||
|
|
||||||
|
end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start);
|
||||||
|
|
||||||
|
return start >= str.length || start < 0 || start > end ? false : str.slice(start, end);
|
||||||
|
},
|
||||||
|
|
||||||
|
substr_replace = function (str, replace, start, length) {
|
||||||
|
if (start < 0) {
|
||||||
|
start = start + str.length;
|
||||||
|
}
|
||||||
|
length = length !== undefined ? length : str.length;
|
||||||
|
if (length < 0) {
|
||||||
|
length = length + str.length - start;
|
||||||
|
}
|
||||||
|
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);
|
||||||
|
},
|
||||||
|
|
||||||
|
$sName = '',
|
||||||
|
$sEmail = '',
|
||||||
|
$sComment = '',
|
||||||
|
|
||||||
|
$bInName = false,
|
||||||
|
$bInAddress = false,
|
||||||
|
$bInComment = false,
|
||||||
|
|
||||||
|
$aRegs = null,
|
||||||
|
|
||||||
|
$iStartIndex = 0,
|
||||||
|
$iEndIndex = 0,
|
||||||
|
$iCurrentIndex = 0
|
||||||
|
;
|
||||||
|
|
||||||
|
while ($iCurrentIndex < $sEmailAddress.length)
|
||||||
|
{
|
||||||
|
switch ($sEmailAddress.substr($iCurrentIndex, 1))
|
||||||
{
|
{
|
||||||
sResult = '<a href="mailto:' + Utils.encodeHtml(this.email) + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.email) + '</a>';
|
case '"':
|
||||||
}
|
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} $sEmailAddress
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.mailsoParse = function ($sEmailAddress)
|
|
||||||
{
|
|
||||||
$sEmailAddress = Utils.trim($sEmailAddress);
|
|
||||||
if ('' === $sEmailAddress)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var
|
|
||||||
substr = function (str, start, len) {
|
|
||||||
str += '';
|
|
||||||
var end = str.length;
|
|
||||||
|
|
||||||
if (start < 0) {
|
|
||||||
start += end;
|
|
||||||
}
|
|
||||||
|
|
||||||
end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start);
|
|
||||||
|
|
||||||
return start >= str.length || start < 0 || start > end ? false : str.slice(start, end);
|
|
||||||
},
|
|
||||||
|
|
||||||
substr_replace = function (str, replace, start, length) {
|
|
||||||
if (start < 0) {
|
|
||||||
start = start + str.length;
|
|
||||||
}
|
|
||||||
length = length !== undefined ? length : str.length;
|
|
||||||
if (length < 0) {
|
|
||||||
length = length + str.length - start;
|
|
||||||
}
|
|
||||||
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);
|
|
||||||
},
|
|
||||||
|
|
||||||
$sName = '',
|
|
||||||
$sEmail = '',
|
|
||||||
$sComment = '',
|
|
||||||
|
|
||||||
$bInName = false,
|
|
||||||
$bInAddress = false,
|
|
||||||
$bInComment = false,
|
|
||||||
|
|
||||||
$aRegs = null,
|
|
||||||
|
|
||||||
$iStartIndex = 0,
|
|
||||||
$iEndIndex = 0,
|
|
||||||
$iCurrentIndex = 0
|
|
||||||
;
|
|
||||||
|
|
||||||
while ($iCurrentIndex < $sEmailAddress.length)
|
|
||||||
{
|
|
||||||
switch ($sEmailAddress.substr($iCurrentIndex, 1))
|
|
||||||
{
|
|
||||||
case '"':
|
|
||||||
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
|
||||||
{
|
|
||||||
$bInName = true;
|
|
||||||
$iStartIndex = $iCurrentIndex;
|
|
||||||
}
|
|
||||||
else if ((!$bInAddress) && (!$bInComment))
|
|
||||||
{
|
|
||||||
$iEndIndex = $iCurrentIndex;
|
|
||||||
$sName = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
|
||||||
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
|
||||||
$iEndIndex = 0;
|
|
||||||
$iCurrentIndex = 0;
|
|
||||||
$iStartIndex = 0;
|
|
||||||
$bInName = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '<':
|
|
||||||
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
|
||||||
{
|
|
||||||
if ($iCurrentIndex > 0 && $sName.length === 0)
|
|
||||||
{
|
{
|
||||||
$sName = substr($sEmailAddress, 0, $iCurrentIndex);
|
$bInName = true;
|
||||||
|
$iStartIndex = $iCurrentIndex;
|
||||||
}
|
}
|
||||||
|
else if ((!$bInAddress) && (!$bInComment))
|
||||||
|
{
|
||||||
|
$iEndIndex = $iCurrentIndex;
|
||||||
|
$sName = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
||||||
|
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
||||||
|
$iEndIndex = 0;
|
||||||
|
$iCurrentIndex = 0;
|
||||||
|
$iStartIndex = 0;
|
||||||
|
$bInName = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '<':
|
||||||
|
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
||||||
|
{
|
||||||
|
if ($iCurrentIndex > 0 && $sName.length === 0)
|
||||||
|
{
|
||||||
|
$sName = substr($sEmailAddress, 0, $iCurrentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
$bInAddress = true;
|
$bInAddress = true;
|
||||||
$iStartIndex = $iCurrentIndex;
|
$iStartIndex = $iCurrentIndex;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
if ($bInAddress)
|
if ($bInAddress)
|
||||||
{
|
{
|
||||||
$iEndIndex = $iCurrentIndex;
|
$iEndIndex = $iCurrentIndex;
|
||||||
$sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
$sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
||||||
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
||||||
$iEndIndex = 0;
|
$iEndIndex = 0;
|
||||||
$iCurrentIndex = 0;
|
$iCurrentIndex = 0;
|
||||||
$iStartIndex = 0;
|
$iStartIndex = 0;
|
||||||
$bInAddress = false;
|
$bInAddress = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '(':
|
case '(':
|
||||||
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
||||||
{
|
{
|
||||||
$bInComment = true;
|
$bInComment = true;
|
||||||
$iStartIndex = $iCurrentIndex;
|
$iStartIndex = $iCurrentIndex;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ')':
|
case ')':
|
||||||
if ($bInComment)
|
if ($bInComment)
|
||||||
{
|
{
|
||||||
$iEndIndex = $iCurrentIndex;
|
$iEndIndex = $iCurrentIndex;
|
||||||
$sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
$sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
||||||
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
||||||
$iEndIndex = 0;
|
$iEndIndex = 0;
|
||||||
$iCurrentIndex = 0;
|
$iCurrentIndex = 0;
|
||||||
$iStartIndex = 0;
|
$iStartIndex = 0;
|
||||||
$bInComment = false;
|
$bInComment = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\\':
|
case '\\':
|
||||||
$iCurrentIndex++;
|
$iCurrentIndex++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$iCurrentIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$iCurrentIndex++;
|
if ($sEmail.length === 0)
|
||||||
}
|
|
||||||
|
|
||||||
if ($sEmail.length === 0)
|
|
||||||
{
|
|
||||||
$aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i);
|
|
||||||
if ($aRegs && $aRegs[0])
|
|
||||||
{
|
{
|
||||||
$sEmail = $aRegs[0];
|
$aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i);
|
||||||
|
if ($aRegs && $aRegs[0])
|
||||||
|
{
|
||||||
|
$sEmail = $aRegs[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sName = $sEmailAddress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if ($sEmail.length > 0 && $sName.length === 0 && $sComment.length === 0)
|
||||||
{
|
{
|
||||||
$sName = $sEmailAddress;
|
$sName = $sEmailAddress.replace($sEmail, '');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($sEmail.length > 0 && $sName.length === 0 && $sComment.length === 0)
|
$sEmail = Utils.trim($sEmail).replace(/^[<]+/, '').replace(/[>]+$/, '');
|
||||||
|
$sName = Utils.trim($sName).replace(/^["']+/, '').replace(/["']+$/, '');
|
||||||
|
$sComment = Utils.trim($sComment).replace(/^[(]+/, '').replace(/[)]+$/, '');
|
||||||
|
|
||||||
|
// Remove backslash
|
||||||
|
$sName = $sName.replace(/\\\\(.)/, '$1');
|
||||||
|
$sComment = $sComment.replace(/\\\\(.)/, '$1');
|
||||||
|
|
||||||
|
this.name = $sName;
|
||||||
|
this.email = $sEmail;
|
||||||
|
|
||||||
|
this.clearDuplicateName();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
EmailModel.prototype.inputoTagLine = function ()
|
||||||
{
|
{
|
||||||
$sName = $sEmailAddress.replace($sEmail, '');
|
return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
|
||||||
}
|
};
|
||||||
|
|
||||||
$sEmail = Utils.trim($sEmail).replace(/^[<]+/, '').replace(/[>]+$/, '');
|
module.exports = EmailModel;
|
||||||
$sName = Utils.trim($sName).replace(/^["']+/, '').replace(/["']+$/, '');
|
|
||||||
$sComment = Utils.trim($sComment).replace(/^[(]+/, '').replace(/[)]+$/, '');
|
|
||||||
|
|
||||||
// Remove backslash
|
}(module));
|
||||||
$sName = $sName.replace(/\\\\(.)/, '$1');
|
|
||||||
$sComment = $sComment.replace(/\\\\(.)/, '$1');
|
|
||||||
|
|
||||||
this.name = $sName;
|
|
||||||
this.email = $sEmail;
|
|
||||||
|
|
||||||
this.clearDuplicateName();
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
EmailModel.prototype.inputoTagLine = function ()
|
|
||||||
{
|
|
||||||
return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
|
|
||||||
};
|
|
||||||
|
|
@ -1,48 +1,62 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function FilterConditionModel(oKoList)
|
|
||||||
{
|
|
||||||
this.parentList = oKoList;
|
|
||||||
|
|
||||||
this.field = ko.observable(Enums.FilterConditionField.From);
|
'use strict';
|
||||||
|
|
||||||
this.fieldOptions = [ // TODO i18n
|
var
|
||||||
{'id': Enums.FilterConditionField.From, 'name': 'From'},
|
ko = require('../External/ko.js'),
|
||||||
{'id': Enums.FilterConditionField.Recipient, 'name': 'Recipient (To or CC)'},
|
Enums = require('../Common/Enums.js')
|
||||||
{'id': Enums.FilterConditionField.To, 'name': 'To'},
|
;
|
||||||
{'id': Enums.FilterConditionField.Subject, 'name': 'Subject'}
|
|
||||||
];
|
|
||||||
|
|
||||||
this.type = ko.observable(Enums.FilterConditionType.EqualTo);
|
/**
|
||||||
|
* @param {*} oKoList
|
||||||
this.typeOptions = [ // TODO i18n
|
* @constructor
|
||||||
{'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To'},
|
*/
|
||||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To'},
|
function FilterConditionModel(oKoList)
|
||||||
{'id': Enums.FilterConditionType.Contains, 'name': 'Contains'},
|
{
|
||||||
{'id': Enums.FilterConditionType.NotContains, 'name': 'Not Contains'}
|
this.parentList = oKoList;
|
||||||
];
|
|
||||||
|
|
||||||
this.value = ko.observable('');
|
this.field = ko.observable(Enums.FilterConditionField.From);
|
||||||
|
|
||||||
this.template = ko.computed(function () {
|
this.fieldOptions = [ // TODO i18n
|
||||||
|
{'id': Enums.FilterConditionField.From, 'name': 'From'},
|
||||||
|
{'id': Enums.FilterConditionField.Recipient, 'name': 'Recipient (To or CC)'},
|
||||||
|
{'id': Enums.FilterConditionField.To, 'name': 'To'},
|
||||||
|
{'id': Enums.FilterConditionField.Subject, 'name': 'Subject'}
|
||||||
|
];
|
||||||
|
|
||||||
var sTemplate = '';
|
this.type = ko.observable(Enums.FilterConditionType.EqualTo);
|
||||||
switch (this.type())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
sTemplate = 'SettingsFiltersConditionDefault';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sTemplate;
|
this.typeOptions = [ // TODO i18n
|
||||||
|
{'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To'},
|
||||||
|
{'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To'},
|
||||||
|
{'id': Enums.FilterConditionType.Contains, 'name': 'Contains'},
|
||||||
|
{'id': Enums.FilterConditionType.NotContains, 'name': 'Not Contains'}
|
||||||
|
];
|
||||||
|
|
||||||
}, this);
|
this.value = ko.observable('');
|
||||||
}
|
|
||||||
|
|
||||||
FilterConditionModel.prototype.removeSelf = function ()
|
this.template = ko.computed(function () {
|
||||||
{
|
|
||||||
this.parentList.remove(this);
|
var sTemplate = '';
|
||||||
};
|
switch (this.type())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
sTemplate = 'SettingsFiltersConditionDefault';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sTemplate;
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
FilterConditionModel.prototype.removeSelf = function ()
|
||||||
|
{
|
||||||
|
this.parentList.remove(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = FilterConditionModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,79 +1,94 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function FilterModel()
|
|
||||||
{
|
|
||||||
this.new = ko.observable(true);
|
|
||||||
this.enabled = ko.observable(true);
|
|
||||||
|
|
||||||
this.name = ko.observable('');
|
'use strict';
|
||||||
|
|
||||||
this.conditionsType = ko.observable(Enums.FilterRulesType.And);
|
var
|
||||||
|
ko = require('../External/ko.js'),
|
||||||
|
Enums = require('../Common/Enums.js'),
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
FilterConditionModel = require('./FilterConditionModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
this.conditions = ko.observableArray([]);
|
/**
|
||||||
|
* @constructor
|
||||||
this.conditions.subscribe(function () {
|
*/
|
||||||
Utils.windowResize();
|
function FilterModel()
|
||||||
});
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
this.actionMarkAsRead = ko.observable(false);
|
|
||||||
this.actionSkipOtherFilters = ko.observable(true);
|
|
||||||
this.actionValue = ko.observable('');
|
|
||||||
|
|
||||||
this.actionType = ko.observable(Enums.FiltersAction.Move);
|
|
||||||
this.actionTypeOptions = [ // TODO i18n
|
|
||||||
{'id': Enums.FiltersAction.None, 'name': 'Action - None'},
|
|
||||||
{'id': Enums.FiltersAction.Move, 'name': 'Action - Move to'},
|
|
||||||
// {'id': Enums.FiltersAction.Forward, 'name': 'Action - Forward to'},
|
|
||||||
{'id': Enums.FiltersAction.Discard, 'name': 'Action - Discard'}
|
|
||||||
];
|
|
||||||
|
|
||||||
this.actionMarkAsReadVisiblity = ko.computed(function () {
|
|
||||||
return -1 < Utils.inArray(this.actionType(), [
|
|
||||||
Enums.FiltersAction.None, Enums.FiltersAction.Forward, Enums.FiltersAction.Move
|
|
||||||
]);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.actionTemplate = ko.computed(function () {
|
|
||||||
|
|
||||||
var sTemplate = '';
|
|
||||||
switch (this.actionType())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case Enums.FiltersAction.Move:
|
|
||||||
sTemplate = 'SettingsFiltersActionValueAsFolders';
|
|
||||||
break;
|
|
||||||
case Enums.FiltersAction.Forward:
|
|
||||||
sTemplate = 'SettingsFiltersActionWithValue';
|
|
||||||
break;
|
|
||||||
case Enums.FiltersAction.None:
|
|
||||||
case Enums.FiltersAction.Discard:
|
|
||||||
sTemplate = 'SettingsFiltersActionNoValue';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sTemplate;
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
FilterModel.prototype.addCondition = function ()
|
|
||||||
{
|
|
||||||
this.conditions.push(new FilterConditionModel(this.conditions));
|
|
||||||
};
|
|
||||||
|
|
||||||
FilterModel.prototype.parse = function (oItem)
|
|
||||||
{
|
|
||||||
var bResult = false;
|
|
||||||
if (oItem && 'Object/Filter' === oItem['@Object'])
|
|
||||||
{
|
{
|
||||||
this.name(Utils.pString(oItem['Name']));
|
this.new = ko.observable(true);
|
||||||
|
this.enabled = ko.observable(true);
|
||||||
|
|
||||||
bResult = true;
|
this.name = ko.observable('');
|
||||||
|
|
||||||
|
this.conditionsType = ko.observable(Enums.FilterRulesType.And);
|
||||||
|
|
||||||
|
this.conditions = ko.observableArray([]);
|
||||||
|
|
||||||
|
this.conditions.subscribe(function () {
|
||||||
|
Utils.windowResize();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
this.actionMarkAsRead = ko.observable(false);
|
||||||
|
this.actionSkipOtherFilters = ko.observable(true);
|
||||||
|
this.actionValue = ko.observable('');
|
||||||
|
|
||||||
|
this.actionType = ko.observable(Enums.FiltersAction.Move);
|
||||||
|
this.actionTypeOptions = [ // TODO i18n
|
||||||
|
{'id': Enums.FiltersAction.None, 'name': 'Action - None'},
|
||||||
|
{'id': Enums.FiltersAction.Move, 'name': 'Action - Move to'},
|
||||||
|
// {'id': Enums.FiltersAction.Forward, 'name': 'Action - Forward to'},
|
||||||
|
{'id': Enums.FiltersAction.Discard, 'name': 'Action - Discard'}
|
||||||
|
];
|
||||||
|
|
||||||
|
this.actionMarkAsReadVisiblity = ko.computed(function () {
|
||||||
|
return -1 < Utils.inArray(this.actionType(), [
|
||||||
|
Enums.FiltersAction.None, Enums.FiltersAction.Forward, Enums.FiltersAction.Move
|
||||||
|
]);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.actionTemplate = ko.computed(function () {
|
||||||
|
|
||||||
|
var sTemplate = '';
|
||||||
|
switch (this.actionType())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case Enums.FiltersAction.Move:
|
||||||
|
sTemplate = 'SettingsFiltersActionValueAsFolders';
|
||||||
|
break;
|
||||||
|
case Enums.FiltersAction.Forward:
|
||||||
|
sTemplate = 'SettingsFiltersActionWithValue';
|
||||||
|
break;
|
||||||
|
case Enums.FiltersAction.None:
|
||||||
|
case Enums.FiltersAction.Discard:
|
||||||
|
sTemplate = 'SettingsFiltersActionNoValue';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sTemplate;
|
||||||
|
|
||||||
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bResult;
|
FilterModel.prototype.addCondition = function ()
|
||||||
};
|
{
|
||||||
|
this.conditions.push(new FilterConditionModel(this.conditions));
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterModel.prototype.parse = function (oItem)
|
||||||
|
{
|
||||||
|
var bResult = false;
|
||||||
|
if (oItem && 'Object/Filter' === oItem['@Object'])
|
||||||
|
{
|
||||||
|
this.name(Utils.pString(oItem['Name']));
|
||||||
|
|
||||||
|
bResult = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = FilterModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,333 +1,350 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function FolderModel()
|
|
||||||
{
|
|
||||||
this.name = ko.observable('');
|
|
||||||
this.fullName = '';
|
|
||||||
this.fullNameRaw = '';
|
|
||||||
this.fullNameHash = '';
|
|
||||||
this.delimiter = '';
|
|
||||||
this.namespace = '';
|
|
||||||
this.deep = 0;
|
|
||||||
this.interval = 0;
|
|
||||||
|
|
||||||
this.selectable = false;
|
'use strict';
|
||||||
this.existen = true;
|
|
||||||
|
|
||||||
this.type = ko.observable(Enums.FolderType.User);
|
var
|
||||||
|
_ = require('../External/underscore.js'),
|
||||||
|
ko = require('./External/ko.js'),
|
||||||
|
$window = require('../External/$window.js'),
|
||||||
|
Enums = require('../Common/Enums.js'),
|
||||||
|
Globals = require('../Common/Globals.js'),
|
||||||
|
Utils = require('../Common/Utils.js')
|
||||||
|
;
|
||||||
|
|
||||||
this.focused = ko.observable(false);
|
/**
|
||||||
this.selected = ko.observable(false);
|
* @constructor
|
||||||
this.edited = ko.observable(false);
|
*/
|
||||||
this.collapsed = ko.observable(true);
|
function FolderModel()
|
||||||
this.subScribed = ko.observable(true);
|
|
||||||
this.subFolders = ko.observableArray([]);
|
|
||||||
this.deleteAccess = ko.observable(false);
|
|
||||||
this.actionBlink = ko.observable(false).extend({'falseTimeout': 1000});
|
|
||||||
|
|
||||||
this.nameForEdit = ko.observable('');
|
|
||||||
|
|
||||||
this.name.subscribe(function (sValue) {
|
|
||||||
this.nameForEdit(sValue);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.edited.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
|
||||||
this.nameForEdit(this.name());
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.privateMessageCountAll = ko.observable(0);
|
|
||||||
this.privateMessageCountUnread = ko.observable(0);
|
|
||||||
|
|
||||||
this.collapsedPrivate = ko.observable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @static
|
|
||||||
* @param {AjaxJsonFolder} oJsonFolder
|
|
||||||
* @return {?FolderModel}
|
|
||||||
*/
|
|
||||||
FolderModel.newInstanceFromJson = function (oJsonFolder)
|
|
||||||
{
|
|
||||||
var oFolderModel = new FolderModel();
|
|
||||||
return oFolderModel.initByJson(oJsonFolder) ? oFolderModel.initComputed() : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {FolderModel}
|
|
||||||
*/
|
|
||||||
FolderModel.prototype.initComputed = function ()
|
|
||||||
{
|
|
||||||
this.hasSubScribedSubfolders = ko.computed(function () {
|
|
||||||
return !!_.find(this.subFolders(), function (oFolder) {
|
|
||||||
return oFolder.subScribed() && !oFolder.isSystemFolder();
|
|
||||||
});
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.canBeEdited = ko.computed(function () {
|
|
||||||
return Enums.FolderType.User === this.type() && this.existen && this.selectable;
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.visible = ko.computed(function () {
|
|
||||||
var
|
|
||||||
bSubScribed = this.subScribed(),
|
|
||||||
bSubFolders = this.hasSubScribedSubfolders()
|
|
||||||
;
|
|
||||||
|
|
||||||
return (bSubScribed || (bSubFolders && (!this.existen || !this.selectable)));
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.isSystemFolder = ko.computed(function () {
|
|
||||||
return Enums.FolderType.User !== this.type();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.hidden = ko.computed(function () {
|
|
||||||
var
|
|
||||||
bSystem = this.isSystemFolder(),
|
|
||||||
bSubFolders = this.hasSubScribedSubfolders()
|
|
||||||
;
|
|
||||||
|
|
||||||
return (bSystem && !bSubFolders) || (!this.selectable && !bSubFolders);
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.selectableForFolderList = ko.computed(function () {
|
|
||||||
return !this.isSystemFolder() && this.selectable;
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.messageCountAll = ko.computed({
|
|
||||||
'read': this.privateMessageCountAll,
|
|
||||||
'write': function (iValue) {
|
|
||||||
if (Utils.isPosNumeric(iValue, true))
|
|
||||||
{
|
|
||||||
this.privateMessageCountAll(iValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.privateMessageCountAll.valueHasMutated();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'owner': this
|
|
||||||
});
|
|
||||||
|
|
||||||
this.messageCountUnread = ko.computed({
|
|
||||||
'read': this.privateMessageCountUnread,
|
|
||||||
'write': function (iValue) {
|
|
||||||
if (Utils.isPosNumeric(iValue, true))
|
|
||||||
{
|
|
||||||
this.privateMessageCountUnread(iValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.privateMessageCountUnread.valueHasMutated();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'owner': this
|
|
||||||
});
|
|
||||||
|
|
||||||
this.printableUnreadCount = ko.computed(function () {
|
|
||||||
var
|
|
||||||
iCount = this.messageCountAll(),
|
|
||||||
iUnread = this.messageCountUnread(),
|
|
||||||
iType = this.type()
|
|
||||||
;
|
|
||||||
|
|
||||||
if (Enums.FolderType.Inbox === iType)
|
|
||||||
{
|
|
||||||
RL.data().foldersInboxUnreadCount(iUnread);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 < iCount)
|
|
||||||
{
|
|
||||||
if (Enums.FolderType.Draft === iType)
|
|
||||||
{
|
|
||||||
return '' + iCount;
|
|
||||||
}
|
|
||||||
else if (0 < iUnread && Enums.FolderType.Trash !== iType && Enums.FolderType.Archive !== iType && Enums.FolderType.SentItems !== iType)
|
|
||||||
{
|
|
||||||
return '' + iUnread;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.canBeDeleted = ko.computed(function () {
|
|
||||||
var
|
|
||||||
bSystem = this.isSystemFolder()
|
|
||||||
;
|
|
||||||
return !bSystem && 0 === this.subFolders().length && 'INBOX' !== this.fullNameRaw;
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.canBeSubScribed = ko.computed(function () {
|
|
||||||
return !this.isSystemFolder() && this.selectable && 'INBOX' !== this.fullNameRaw;
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.visible.subscribe(function () {
|
|
||||||
Utils.timeOutAction('folder-list-folder-visibility-change', function () {
|
|
||||||
$window.trigger('folder-list-folder-visibility-change');
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.localName = ko.computed(function () {
|
|
||||||
|
|
||||||
Globals.langChangeTrigger();
|
|
||||||
|
|
||||||
var
|
|
||||||
iType = this.type(),
|
|
||||||
sName = this.name()
|
|
||||||
;
|
|
||||||
|
|
||||||
if (this.isSystemFolder())
|
|
||||||
{
|
|
||||||
switch (iType)
|
|
||||||
{
|
|
||||||
case Enums.FolderType.Inbox:
|
|
||||||
sName = Utils.i18n('FOLDER_LIST/INBOX_NAME');
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.SentItems:
|
|
||||||
sName = Utils.i18n('FOLDER_LIST/SENT_NAME');
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.Draft:
|
|
||||||
sName = Utils.i18n('FOLDER_LIST/DRAFTS_NAME');
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.Spam:
|
|
||||||
sName = Utils.i18n('FOLDER_LIST/SPAM_NAME');
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.Trash:
|
|
||||||
sName = Utils.i18n('FOLDER_LIST/TRASH_NAME');
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.Archive:
|
|
||||||
sName = Utils.i18n('FOLDER_LIST/ARCHIVE_NAME');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sName;
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.manageFolderSystemName = ko.computed(function () {
|
|
||||||
|
|
||||||
Globals.langChangeTrigger();
|
|
||||||
|
|
||||||
var
|
|
||||||
sSuffix = '',
|
|
||||||
iType = this.type(),
|
|
||||||
sName = this.name()
|
|
||||||
;
|
|
||||||
|
|
||||||
if (this.isSystemFolder())
|
|
||||||
{
|
|
||||||
switch (iType)
|
|
||||||
{
|
|
||||||
case Enums.FolderType.Inbox:
|
|
||||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/INBOX_NAME') + ')';
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.SentItems:
|
|
||||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/SENT_NAME') + ')';
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.Draft:
|
|
||||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/DRAFTS_NAME') + ')';
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.Spam:
|
|
||||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/SPAM_NAME') + ')';
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.Trash:
|
|
||||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/TRASH_NAME') + ')';
|
|
||||||
break;
|
|
||||||
case Enums.FolderType.Archive:
|
|
||||||
sSuffix = '(' + Utils.i18n('FOLDER_LIST/ARCHIVE_NAME') + ')';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('' !== sSuffix && '(' + sName + ')' === sSuffix || '(inbox)' === sSuffix.toLowerCase())
|
|
||||||
{
|
|
||||||
sSuffix = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return sSuffix;
|
|
||||||
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.collapsed = ko.computed({
|
|
||||||
'read': function () {
|
|
||||||
return !this.hidden() && this.collapsedPrivate();
|
|
||||||
},
|
|
||||||
'write': function (mValue) {
|
|
||||||
this.collapsedPrivate(mValue);
|
|
||||||
},
|
|
||||||
'owner': this
|
|
||||||
});
|
|
||||||
|
|
||||||
this.hasUnreadMessages = ko.computed(function () {
|
|
||||||
return 0 < this.messageCountUnread();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function () {
|
|
||||||
return !!_.find(this.subFolders(), function (oFolder) {
|
|
||||||
return oFolder.hasUnreadMessages() || oFolder.hasSubScribedUnreadMessagesSubfolders();
|
|
||||||
});
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
FolderModel.prototype.fullName = '';
|
|
||||||
FolderModel.prototype.fullNameRaw = '';
|
|
||||||
FolderModel.prototype.fullNameHash = '';
|
|
||||||
FolderModel.prototype.delimiter = '';
|
|
||||||
FolderModel.prototype.namespace = '';
|
|
||||||
FolderModel.prototype.deep = 0;
|
|
||||||
FolderModel.prototype.interval = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
FolderModel.prototype.collapsedCss = function ()
|
|
||||||
{
|
|
||||||
return this.hasSubScribedSubfolders() ?
|
|
||||||
(this.collapsed() ? 'icon-right-mini e-collapsed-sign' : 'icon-down-mini e-collapsed-sign') : 'icon-none e-collapsed-sign';
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {AjaxJsonFolder} oJsonFolder
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
FolderModel.prototype.initByJson = function (oJsonFolder)
|
|
||||||
{
|
|
||||||
var bResult = false;
|
|
||||||
if (oJsonFolder && 'Object/Folder' === oJsonFolder['@Object'])
|
|
||||||
{
|
{
|
||||||
this.name(oJsonFolder.Name);
|
this.name = ko.observable('');
|
||||||
this.delimiter = oJsonFolder.Delimiter;
|
this.fullName = '';
|
||||||
this.fullName = oJsonFolder.FullName;
|
this.fullNameRaw = '';
|
||||||
this.fullNameRaw = oJsonFolder.FullNameRaw;
|
this.fullNameHash = '';
|
||||||
this.fullNameHash = oJsonFolder.FullNameHash;
|
this.delimiter = '';
|
||||||
this.deep = oJsonFolder.FullNameRaw.split(this.delimiter).length - 1;
|
this.namespace = '';
|
||||||
this.selectable = !!oJsonFolder.IsSelectable;
|
this.deep = 0;
|
||||||
this.existen = !!oJsonFolder.IsExists;
|
this.interval = 0;
|
||||||
|
|
||||||
this.subScribed(!!oJsonFolder.IsSubscribed);
|
this.selectable = false;
|
||||||
this.type('INBOX' === this.fullNameRaw ? Enums.FolderType.Inbox : Enums.FolderType.User);
|
this.existen = true;
|
||||||
|
|
||||||
bResult = true;
|
this.type = ko.observable(Enums.FolderType.User);
|
||||||
|
|
||||||
|
this.focused = ko.observable(false);
|
||||||
|
this.selected = ko.observable(false);
|
||||||
|
this.edited = ko.observable(false);
|
||||||
|
this.collapsed = ko.observable(true);
|
||||||
|
this.subScribed = ko.observable(true);
|
||||||
|
this.subFolders = ko.observableArray([]);
|
||||||
|
this.deleteAccess = ko.observable(false);
|
||||||
|
this.actionBlink = ko.observable(false).extend({'falseTimeout': 1000});
|
||||||
|
|
||||||
|
this.nameForEdit = ko.observable('');
|
||||||
|
|
||||||
|
this.name.subscribe(function (sValue) {
|
||||||
|
this.nameForEdit(sValue);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.edited.subscribe(function (bValue) {
|
||||||
|
if (bValue)
|
||||||
|
{
|
||||||
|
this.nameForEdit(this.name());
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.privateMessageCountAll = ko.observable(0);
|
||||||
|
this.privateMessageCountUnread = ko.observable(0);
|
||||||
|
|
||||||
|
this.collapsedPrivate = ko.observable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bResult;
|
/**
|
||||||
};
|
* @static
|
||||||
|
* @param {AjaxJsonFolder} oJsonFolder
|
||||||
|
* @return {?FolderModel}
|
||||||
|
*/
|
||||||
|
FolderModel.newInstanceFromJson = function (oJsonFolder)
|
||||||
|
{
|
||||||
|
var oFolderModel = new FolderModel();
|
||||||
|
return oFolderModel.initByJson(oJsonFolder) ? oFolderModel.initComputed() : null;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string}
|
* @return {FolderModel}
|
||||||
*/
|
*/
|
||||||
FolderModel.prototype.printableFullName = function ()
|
FolderModel.prototype.initComputed = function ()
|
||||||
{
|
{
|
||||||
return this.fullName.split(this.delimiter).join(' / ');
|
this.hasSubScribedSubfolders = ko.computed(function () {
|
||||||
};
|
return !!_.find(this.subFolders(), function (oFolder) {
|
||||||
|
return oFolder.subScribed() && !oFolder.isSystemFolder();
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.canBeEdited = ko.computed(function () {
|
||||||
|
return Enums.FolderType.User === this.type() && this.existen && this.selectable;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.visible = ko.computed(function () {
|
||||||
|
var
|
||||||
|
bSubScribed = this.subScribed(),
|
||||||
|
bSubFolders = this.hasSubScribedSubfolders()
|
||||||
|
;
|
||||||
|
|
||||||
|
return (bSubScribed || (bSubFolders && (!this.existen || !this.selectable)));
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.isSystemFolder = ko.computed(function () {
|
||||||
|
return Enums.FolderType.User !== this.type();
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.hidden = ko.computed(function () {
|
||||||
|
var
|
||||||
|
bSystem = this.isSystemFolder(),
|
||||||
|
bSubFolders = this.hasSubScribedSubfolders()
|
||||||
|
;
|
||||||
|
|
||||||
|
return (bSystem && !bSubFolders) || (!this.selectable && !bSubFolders);
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.selectableForFolderList = ko.computed(function () {
|
||||||
|
return !this.isSystemFolder() && this.selectable;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.messageCountAll = ko.computed({
|
||||||
|
'read': this.privateMessageCountAll,
|
||||||
|
'write': function (iValue) {
|
||||||
|
if (Utils.isPosNumeric(iValue, true))
|
||||||
|
{
|
||||||
|
this.privateMessageCountAll(iValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.privateMessageCountAll.valueHasMutated();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'owner': this
|
||||||
|
});
|
||||||
|
|
||||||
|
this.messageCountUnread = ko.computed({
|
||||||
|
'read': this.privateMessageCountUnread,
|
||||||
|
'write': function (iValue) {
|
||||||
|
if (Utils.isPosNumeric(iValue, true))
|
||||||
|
{
|
||||||
|
this.privateMessageCountUnread(iValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.privateMessageCountUnread.valueHasMutated();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'owner': this
|
||||||
|
});
|
||||||
|
|
||||||
|
this.printableUnreadCount = ko.computed(function () {
|
||||||
|
var
|
||||||
|
iCount = this.messageCountAll(),
|
||||||
|
iUnread = this.messageCountUnread(),
|
||||||
|
iType = this.type()
|
||||||
|
;
|
||||||
|
|
||||||
|
if (Enums.FolderType.Inbox === iType)
|
||||||
|
{
|
||||||
|
RL.data().foldersInboxUnreadCount(iUnread); // TODO cjs
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 < iCount)
|
||||||
|
{
|
||||||
|
if (Enums.FolderType.Draft === iType)
|
||||||
|
{
|
||||||
|
return '' + iCount;
|
||||||
|
}
|
||||||
|
else if (0 < iUnread && Enums.FolderType.Trash !== iType && Enums.FolderType.Archive !== iType && Enums.FolderType.SentItems !== iType)
|
||||||
|
{
|
||||||
|
return '' + iUnread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.canBeDeleted = ko.computed(function () {
|
||||||
|
var
|
||||||
|
bSystem = this.isSystemFolder()
|
||||||
|
;
|
||||||
|
return !bSystem && 0 === this.subFolders().length && 'INBOX' !== this.fullNameRaw;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.canBeSubScribed = ko.computed(function () {
|
||||||
|
return !this.isSystemFolder() && this.selectable && 'INBOX' !== this.fullNameRaw;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.visible.subscribe(function () {
|
||||||
|
Utils.timeOutAction('folder-list-folder-visibility-change', function () {
|
||||||
|
$window.trigger('folder-list-folder-visibility-change');
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.localName = ko.computed(function () {
|
||||||
|
|
||||||
|
Globals.langChangeTrigger();
|
||||||
|
|
||||||
|
var
|
||||||
|
iType = this.type(),
|
||||||
|
sName = this.name()
|
||||||
|
;
|
||||||
|
|
||||||
|
if (this.isSystemFolder())
|
||||||
|
{
|
||||||
|
switch (iType)
|
||||||
|
{
|
||||||
|
case Enums.FolderType.Inbox:
|
||||||
|
sName = Utils.i18n('FOLDER_LIST/INBOX_NAME');
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.SentItems:
|
||||||
|
sName = Utils.i18n('FOLDER_LIST/SENT_NAME');
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.Draft:
|
||||||
|
sName = Utils.i18n('FOLDER_LIST/DRAFTS_NAME');
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.Spam:
|
||||||
|
sName = Utils.i18n('FOLDER_LIST/SPAM_NAME');
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.Trash:
|
||||||
|
sName = Utils.i18n('FOLDER_LIST/TRASH_NAME');
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.Archive:
|
||||||
|
sName = Utils.i18n('FOLDER_LIST/ARCHIVE_NAME');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sName;
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.manageFolderSystemName = ko.computed(function () {
|
||||||
|
|
||||||
|
Globals.langChangeTrigger();
|
||||||
|
|
||||||
|
var
|
||||||
|
sSuffix = '',
|
||||||
|
iType = this.type(),
|
||||||
|
sName = this.name()
|
||||||
|
;
|
||||||
|
|
||||||
|
if (this.isSystemFolder())
|
||||||
|
{
|
||||||
|
switch (iType)
|
||||||
|
{
|
||||||
|
case Enums.FolderType.Inbox:
|
||||||
|
sSuffix = '(' + Utils.i18n('FOLDER_LIST/INBOX_NAME') + ')';
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.SentItems:
|
||||||
|
sSuffix = '(' + Utils.i18n('FOLDER_LIST/SENT_NAME') + ')';
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.Draft:
|
||||||
|
sSuffix = '(' + Utils.i18n('FOLDER_LIST/DRAFTS_NAME') + ')';
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.Spam:
|
||||||
|
sSuffix = '(' + Utils.i18n('FOLDER_LIST/SPAM_NAME') + ')';
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.Trash:
|
||||||
|
sSuffix = '(' + Utils.i18n('FOLDER_LIST/TRASH_NAME') + ')';
|
||||||
|
break;
|
||||||
|
case Enums.FolderType.Archive:
|
||||||
|
sSuffix = '(' + Utils.i18n('FOLDER_LIST/ARCHIVE_NAME') + ')';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('' !== sSuffix && '(' + sName + ')' === sSuffix || '(inbox)' === sSuffix.toLowerCase())
|
||||||
|
{
|
||||||
|
sSuffix = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return sSuffix;
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.collapsed = ko.computed({
|
||||||
|
'read': function () {
|
||||||
|
return !this.hidden() && this.collapsedPrivate();
|
||||||
|
},
|
||||||
|
'write': function (mValue) {
|
||||||
|
this.collapsedPrivate(mValue);
|
||||||
|
},
|
||||||
|
'owner': this
|
||||||
|
});
|
||||||
|
|
||||||
|
this.hasUnreadMessages = ko.computed(function () {
|
||||||
|
return 0 < this.messageCountUnread();
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function () {
|
||||||
|
return !!_.find(this.subFolders(), function (oFolder) {
|
||||||
|
return oFolder.hasUnreadMessages() || oFolder.hasSubScribedUnreadMessagesSubfolders();
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
FolderModel.prototype.fullName = '';
|
||||||
|
FolderModel.prototype.fullNameRaw = '';
|
||||||
|
FolderModel.prototype.fullNameHash = '';
|
||||||
|
FolderModel.prototype.delimiter = '';
|
||||||
|
FolderModel.prototype.namespace = '';
|
||||||
|
FolderModel.prototype.deep = 0;
|
||||||
|
FolderModel.prototype.interval = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
FolderModel.prototype.collapsedCss = function ()
|
||||||
|
{
|
||||||
|
return this.hasSubScribedSubfolders() ?
|
||||||
|
(this.collapsed() ? 'icon-right-mini e-collapsed-sign' : 'icon-down-mini e-collapsed-sign') : 'icon-none e-collapsed-sign';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AjaxJsonFolder} oJsonFolder
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
FolderModel.prototype.initByJson = function (oJsonFolder)
|
||||||
|
{
|
||||||
|
var bResult = false;
|
||||||
|
if (oJsonFolder && 'Object/Folder' === oJsonFolder['@Object'])
|
||||||
|
{
|
||||||
|
this.name(oJsonFolder.Name);
|
||||||
|
this.delimiter = oJsonFolder.Delimiter;
|
||||||
|
this.fullName = oJsonFolder.FullName;
|
||||||
|
this.fullNameRaw = oJsonFolder.FullNameRaw;
|
||||||
|
this.fullNameHash = oJsonFolder.FullNameHash;
|
||||||
|
this.deep = oJsonFolder.FullNameRaw.split(this.delimiter).length - 1;
|
||||||
|
this.selectable = !!oJsonFolder.IsSelectable;
|
||||||
|
this.existen = !!oJsonFolder.IsExists;
|
||||||
|
|
||||||
|
this.subScribed(!!oJsonFolder.IsSubscribed);
|
||||||
|
this.type('INBOX' === this.fullNameRaw ? Enums.FolderType.Inbox : Enums.FolderType.User);
|
||||||
|
|
||||||
|
bResult = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
FolderModel.prototype.printableFullName = function ()
|
||||||
|
{
|
||||||
|
return this.fullName.split(this.delimiter).join(' / ');
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = FolderModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,37 +1,50 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @param {string} sId
|
|
||||||
* @param {string} sEmail
|
|
||||||
* @param {boolean=} bCanBeDelete = true
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function IdentityModel(sId, sEmail, bCanBeDelete)
|
|
||||||
{
|
|
||||||
this.id = sId;
|
|
||||||
this.email = ko.observable(sEmail);
|
|
||||||
this.name = ko.observable('');
|
|
||||||
this.replyTo = ko.observable('');
|
|
||||||
this.bcc = ko.observable('');
|
|
||||||
|
|
||||||
this.deleteAccess = ko.observable(false);
|
'use strict';
|
||||||
this.canBeDalete = ko.observable(bCanBeDelete);
|
|
||||||
}
|
|
||||||
|
|
||||||
IdentityModel.prototype.formattedName = function ()
|
var
|
||||||
{
|
ko = require('../External/ko.js'),
|
||||||
var sName = this.name();
|
Utils = require('../Common/Utils.js')
|
||||||
return '' === sName ? this.email() : sName + ' <' + this.email() + '>';
|
;
|
||||||
};
|
|
||||||
|
|
||||||
IdentityModel.prototype.formattedNameForCompose = function ()
|
/**
|
||||||
{
|
* @param {string} sId
|
||||||
var sName = this.name();
|
* @param {string} sEmail
|
||||||
return '' === sName ? this.email() : sName + ' (' + this.email() + ')';
|
* @param {boolean=} bCanBeDelete = true
|
||||||
};
|
* @constructor
|
||||||
|
*/
|
||||||
|
function IdentityModel(sId, sEmail, bCanBeDelete)
|
||||||
|
{
|
||||||
|
this.id = sId;
|
||||||
|
this.email = ko.observable(sEmail);
|
||||||
|
this.name = ko.observable('');
|
||||||
|
this.replyTo = ko.observable('');
|
||||||
|
this.bcc = ko.observable('');
|
||||||
|
|
||||||
IdentityModel.prototype.formattedNameForEmail = function ()
|
this.deleteAccess = ko.observable(false);
|
||||||
{
|
this.canBeDalete = ko.observable(bCanBeDelete);
|
||||||
var sName = this.name();
|
}
|
||||||
return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>';
|
|
||||||
};
|
IdentityModel.prototype.formattedName = function ()
|
||||||
|
{
|
||||||
|
var sName = this.name();
|
||||||
|
return '' === sName ? this.email() : sName + ' <' + this.email() + '>';
|
||||||
|
};
|
||||||
|
|
||||||
|
IdentityModel.prototype.formattedNameForCompose = function ()
|
||||||
|
{
|
||||||
|
var sName = this.name();
|
||||||
|
return '' === sName ? this.email() : sName + ' (' + this.email() + ')';
|
||||||
|
};
|
||||||
|
|
||||||
|
IdentityModel.prototype.formattedNameForEmail = function ()
|
||||||
|
{
|
||||||
|
var sName = this.name();
|
||||||
|
return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>';
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = IdentityModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,32 +1,44 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @param {string} iIndex
|
|
||||||
* @param {string} sGuID
|
|
||||||
* @param {string} sID
|
|
||||||
* @param {string} sUserID
|
|
||||||
* @param {string} sEmail
|
|
||||||
* @param {boolean} bIsPrivate
|
|
||||||
* @param {string} sArmor
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function OpenPgpKeyModel(iIndex, sGuID, sID, sUserID, sEmail, bIsPrivate, sArmor)
|
|
||||||
{
|
|
||||||
this.index = iIndex;
|
|
||||||
this.id = sID;
|
|
||||||
this.guid = sGuID;
|
|
||||||
this.user = sUserID;
|
|
||||||
this.email = sEmail;
|
|
||||||
this.armor = sArmor;
|
|
||||||
this.isPrivate = !!bIsPrivate;
|
|
||||||
|
|
||||||
this.deleteAccess = ko.observable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenPgpKeyModel.prototype.index = 0;
|
'use strict';
|
||||||
OpenPgpKeyModel.prototype.id = '';
|
|
||||||
OpenPgpKeyModel.prototype.guid = '';
|
var
|
||||||
OpenPgpKeyModel.prototype.user = '';
|
ko = require('./ko.js')
|
||||||
OpenPgpKeyModel.prototype.email = '';
|
;
|
||||||
OpenPgpKeyModel.prototype.armor = '';
|
|
||||||
OpenPgpKeyModel.prototype.isPrivate = false;
|
/**
|
||||||
|
* @param {string} iIndex
|
||||||
|
* @param {string} sGuID
|
||||||
|
* @param {string} sID
|
||||||
|
* @param {string} sUserID
|
||||||
|
* @param {string} sEmail
|
||||||
|
* @param {boolean} bIsPrivate
|
||||||
|
* @param {string} sArmor
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function OpenPgpKeyModel(iIndex, sGuID, sID, sUserID, sEmail, bIsPrivate, sArmor)
|
||||||
|
{
|
||||||
|
this.index = iIndex;
|
||||||
|
this.id = sID;
|
||||||
|
this.guid = sGuID;
|
||||||
|
this.user = sUserID;
|
||||||
|
this.email = sEmail;
|
||||||
|
this.armor = sArmor;
|
||||||
|
this.isPrivate = !!bIsPrivate;
|
||||||
|
|
||||||
|
this.deleteAccess = ko.observable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenPgpKeyModel.prototype.index = 0;
|
||||||
|
OpenPgpKeyModel.prototype.id = '';
|
||||||
|
OpenPgpKeyModel.prototype.guid = '';
|
||||||
|
OpenPgpKeyModel.prototype.user = '';
|
||||||
|
OpenPgpKeyModel.prototype.email = '';
|
||||||
|
OpenPgpKeyModel.prototype.armor = '';
|
||||||
|
OpenPgpKeyModel.prototype.isPrivate = false;
|
||||||
|
|
||||||
|
module.exports = OpenPgpKeyModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
7
dev/RL.js
Normal file
7
dev/RL.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function () {
|
||||||
|
return require('./Knoin/Knoin.js').rl();
|
||||||
|
};
|
||||||
10
dev/RainLoopBoot.js
Normal file
10
dev/RainLoopBoot.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
kn = require('./Knoin/Knoin.js'),
|
||||||
|
RL = require('./Boots/RainLoopApp.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
kn.bootstart(RL);
|
||||||
|
|
@ -1,181 +1,199 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @param {Array} aViewModels
|
|
||||||
* @constructor
|
|
||||||
* @extends KnoinAbstractScreen
|
|
||||||
*/
|
|
||||||
function AbstractSettings(aViewModels)
|
|
||||||
{
|
|
||||||
KnoinAbstractScreen.call(this, 'settings', aViewModels);
|
|
||||||
|
|
||||||
this.menu = ko.observableArray([]);
|
|
||||||
|
|
||||||
this.oCurrentSubScreen = null;
|
'use strict';
|
||||||
this.oViewModelPlace = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AbstractSettings.prototype, KnoinAbstractScreen.prototype);
|
|
||||||
|
|
||||||
AbstractSettings.prototype.onRoute = function (sSubName)
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
self = this,
|
$ = require('./External/jquery.js'),
|
||||||
oSettingsScreen = null,
|
_ = require('./External/underscore.js'),
|
||||||
RoutedSettingsViewModel = null,
|
ko = require('./External/ko.js'),
|
||||||
oViewModelPlace = null,
|
Globals = require('./Common/Globals.js'),
|
||||||
oViewModelDom = null
|
Utils = require('./Common/Utils.js'),
|
||||||
|
kn = require('./Knoin/Knoin.js'),
|
||||||
|
KnoinAbstractScreen = require('./Knoin/KnoinAbstractScreen.js')
|
||||||
;
|
;
|
||||||
|
|
||||||
RoutedSettingsViewModel = _.find(ViewModels['settings'], function (SettingsViewModel) {
|
/**
|
||||||
return SettingsViewModel && SettingsViewModel.__rlSettingsData &&
|
* @param {Array} aViewModels
|
||||||
sSubName === SettingsViewModel.__rlSettingsData.Route;
|
* @constructor
|
||||||
});
|
* @extends KnoinAbstractScreen
|
||||||
|
*/
|
||||||
if (RoutedSettingsViewModel)
|
function AbstractSettings(aViewModels)
|
||||||
{
|
{
|
||||||
if (_.find(ViewModels['settings-removed'], function (DisabledSettingsViewModel) {
|
KnoinAbstractScreen.call(this, 'settings', aViewModels);
|
||||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
|
||||||
}))
|
this.menu = ko.observableArray([]);
|
||||||
{
|
|
||||||
RoutedSettingsViewModel = null;
|
this.oCurrentSubScreen = null;
|
||||||
}
|
this.oViewModelPlace = null;
|
||||||
|
|
||||||
if (RoutedSettingsViewModel && _.find(ViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
|
|
||||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
RoutedSettingsViewModel = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RoutedSettingsViewModel)
|
_.extend(AbstractSettings.prototype, KnoinAbstractScreen.prototype);
|
||||||
|
|
||||||
|
AbstractSettings.prototype.onRoute = function (sSubName)
|
||||||
{
|
{
|
||||||
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
|
var
|
||||||
|
self = this,
|
||||||
|
oSettingsScreen = null,
|
||||||
|
RoutedSettingsViewModel = null,
|
||||||
|
oViewModelPlace = null,
|
||||||
|
oViewModelDom = null
|
||||||
|
;
|
||||||
|
|
||||||
|
RoutedSettingsViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) {
|
||||||
|
return SettingsViewModel && SettingsViewModel.__rlSettingsData &&
|
||||||
|
sSubName === SettingsViewModel.__rlSettingsData.Route;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (RoutedSettingsViewModel)
|
||||||
{
|
{
|
||||||
oSettingsScreen = RoutedSettingsViewModel.__vm;
|
if (_.find(Globals.aViewModels['settings-removed'], function (DisabledSettingsViewModel) {
|
||||||
}
|
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
||||||
else
|
}))
|
||||||
{
|
|
||||||
oViewModelPlace = this.oViewModelPlace;
|
|
||||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
|
||||||
{
|
{
|
||||||
RoutedSettingsViewModel = /** @type {?Function} */ RoutedSettingsViewModel;
|
RoutedSettingsViewModel = null;
|
||||||
oSettingsScreen = new RoutedSettingsViewModel();
|
}
|
||||||
|
|
||||||
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
|
||||||
oViewModelDom.appendTo(oViewModelPlace);
|
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
||||||
|
}))
|
||||||
oSettingsScreen.data = RL.data();
|
{
|
||||||
oSettingsScreen.viewModelDom = oViewModelDom;
|
RoutedSettingsViewModel = null;
|
||||||
|
}
|
||||||
oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData;
|
}
|
||||||
|
|
||||||
RoutedSettingsViewModel.__dom = oViewModelDom;
|
|
||||||
RoutedSettingsViewModel.__builded = true;
|
|
||||||
RoutedSettingsViewModel.__vm = oSettingsScreen;
|
|
||||||
|
|
||||||
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
|
||||||
'i18nInit': true,
|
|
||||||
'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; }
|
|
||||||
}, oSettingsScreen);
|
|
||||||
|
|
||||||
Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
|
if (RoutedSettingsViewModel)
|
||||||
|
{
|
||||||
|
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
|
||||||
|
{
|
||||||
|
oSettingsScreen = RoutedSettingsViewModel.__vm;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Utils.log('Cannot find sub settings view model position: SettingsSubScreen');
|
oViewModelPlace = this.oViewModelPlace;
|
||||||
|
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
||||||
|
{
|
||||||
|
RoutedSettingsViewModel = /** @type {?Function} */ RoutedSettingsViewModel;
|
||||||
|
oSettingsScreen = new RoutedSettingsViewModel();
|
||||||
|
|
||||||
|
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
||||||
|
oViewModelDom.appendTo(oViewModelPlace);
|
||||||
|
|
||||||
|
oSettingsScreen.data = RL.data(); // TODO cjs
|
||||||
|
oSettingsScreen.viewModelDom = oViewModelDom;
|
||||||
|
|
||||||
|
oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData;
|
||||||
|
|
||||||
|
RoutedSettingsViewModel.__dom = oViewModelDom;
|
||||||
|
RoutedSettingsViewModel.__builded = true;
|
||||||
|
RoutedSettingsViewModel.__vm = oSettingsScreen;
|
||||||
|
|
||||||
|
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
||||||
|
'i18nInit': true,
|
||||||
|
'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; }
|
||||||
|
}, oSettingsScreen);
|
||||||
|
|
||||||
|
Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Utils.log('Cannot find sub settings view model position: SettingsSubScreen');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oSettingsScreen)
|
||||||
|
{
|
||||||
|
_.defer(function () {
|
||||||
|
// hide
|
||||||
|
if (self.oCurrentSubScreen)
|
||||||
|
{
|
||||||
|
Utils.delegateRun(self.oCurrentSubScreen, 'onHide');
|
||||||
|
self.oCurrentSubScreen.viewModelDom.hide();
|
||||||
|
}
|
||||||
|
// --
|
||||||
|
|
||||||
|
self.oCurrentSubScreen = oSettingsScreen;
|
||||||
|
|
||||||
|
// show
|
||||||
|
if (self.oCurrentSubScreen)
|
||||||
|
{
|
||||||
|
self.oCurrentSubScreen.viewModelDom.show();
|
||||||
|
Utils.delegateRun(self.oCurrentSubScreen, 'onShow');
|
||||||
|
Utils.delegateRun(self.oCurrentSubScreen, 'onFocus', [], 200);
|
||||||
|
|
||||||
|
_.each(self.menu(), function (oItem) {
|
||||||
|
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#rl-content .b-settings .b-content .content').scrollTop(0);
|
||||||
|
}
|
||||||
|
// --
|
||||||
|
|
||||||
|
Utils.windowResize();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (oSettingsScreen)
|
|
||||||
{
|
{
|
||||||
_.defer(function () {
|
kn.setHash(RL.link().settings(), false, true); // TODO cjs
|
||||||
// hide
|
|
||||||
if (self.oCurrentSubScreen)
|
|
||||||
{
|
|
||||||
Utils.delegateRun(self.oCurrentSubScreen, 'onHide');
|
|
||||||
self.oCurrentSubScreen.viewModelDom.hide();
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
self.oCurrentSubScreen = oSettingsScreen;
|
|
||||||
|
|
||||||
// show
|
|
||||||
if (self.oCurrentSubScreen)
|
|
||||||
{
|
|
||||||
self.oCurrentSubScreen.viewModelDom.show();
|
|
||||||
Utils.delegateRun(self.oCurrentSubScreen, 'onShow');
|
|
||||||
Utils.delegateRun(self.oCurrentSubScreen, 'onFocus', [], 200);
|
|
||||||
|
|
||||||
_.each(self.menu(), function (oItem) {
|
|
||||||
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#rl-content .b-settings .b-content .content').scrollTop(0);
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
Utils.windowResize();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
else
|
|
||||||
{
|
|
||||||
kn.setHash(RL.link().settings(), false, true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AbstractSettings.prototype.onHide = function ()
|
AbstractSettings.prototype.onHide = function ()
|
||||||
{
|
|
||||||
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
|
|
||||||
{
|
{
|
||||||
Utils.delegateRun(this.oCurrentSubScreen, 'onHide');
|
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
|
||||||
this.oCurrentSubScreen.viewModelDom.hide();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AbstractSettings.prototype.onBuild = function ()
|
|
||||||
{
|
|
||||||
_.each(ViewModels['settings'], function (SettingsViewModel) {
|
|
||||||
if (SettingsViewModel && SettingsViewModel.__rlSettingsData &&
|
|
||||||
!_.find(ViewModels['settings-removed'], function (RemoveSettingsViewModel) {
|
|
||||||
return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel;
|
|
||||||
}))
|
|
||||||
{
|
{
|
||||||
this.menu.push({
|
Utils.delegateRun(this.oCurrentSubScreen, 'onHide');
|
||||||
'route': SettingsViewModel.__rlSettingsData.Route,
|
this.oCurrentSubScreen.viewModelDom.hide();
|
||||||
'label': SettingsViewModel.__rlSettingsData.Label,
|
|
||||||
'selected': ko.observable(false),
|
|
||||||
'disabled': !!_.find(ViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
|
|
||||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel;
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, this);
|
};
|
||||||
|
|
||||||
this.oViewModelPlace = $('#rl-content #rl-settings-subscreen');
|
AbstractSettings.prototype.onBuild = function ()
|
||||||
};
|
{
|
||||||
|
_.each(Globals.aViewModels['settings'], function (SettingsViewModel) {
|
||||||
AbstractSettings.prototype.routes = function ()
|
if (SettingsViewModel && SettingsViewModel.__rlSettingsData &&
|
||||||
{
|
!_.find(Globals.aViewModels['settings-removed'], function (RemoveSettingsViewModel) {
|
||||||
var
|
return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel;
|
||||||
DefaultViewModel = _.find(ViewModels['settings'], function (SettingsViewModel) {
|
}))
|
||||||
return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData['IsDefault'];
|
{
|
||||||
}),
|
this.menu.push({
|
||||||
sDefaultRoute = DefaultViewModel ? DefaultViewModel.__rlSettingsData['Route'] : 'general',
|
'route': SettingsViewModel.__rlSettingsData.Route,
|
||||||
oRules = {
|
'label': SettingsViewModel.__rlSettingsData.Label,
|
||||||
'subname': /^(.*)$/,
|
'selected': ko.observable(false),
|
||||||
'normalize_': function (oRequest, oVals) {
|
'disabled': !!_.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
|
||||||
oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname);
|
return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel;
|
||||||
return [oVals.subname];
|
})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}, this);
|
||||||
;
|
|
||||||
|
|
||||||
return [
|
this.oViewModelPlace = $('#rl-content #rl-settings-subscreen');
|
||||||
['{subname}/', oRules],
|
};
|
||||||
['{subname}', oRules],
|
|
||||||
['', oRules]
|
AbstractSettings.prototype.routes = function ()
|
||||||
];
|
{
|
||||||
};
|
var
|
||||||
|
DefaultViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) {
|
||||||
|
return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData['IsDefault'];
|
||||||
|
}),
|
||||||
|
sDefaultRoute = DefaultViewModel ? DefaultViewModel.__rlSettingsData['Route'] : 'general',
|
||||||
|
oRules = {
|
||||||
|
'subname': /^(.*)$/,
|
||||||
|
'normalize_': function (oRequest, oVals) {
|
||||||
|
oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname);
|
||||||
|
return [oVals.subname];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
return [
|
||||||
|
['{subname}/', oRules],
|
||||||
|
['{subname}', oRules],
|
||||||
|
['', oRules]
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AbstractSettings;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,17 +1,31 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends KnoinAbstractScreen
|
|
||||||
*/
|
|
||||||
function AdminLoginScreen()
|
|
||||||
{
|
|
||||||
KnoinAbstractScreen.call(this, 'login', [AdminLoginViewModel]);
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AdminLoginScreen.prototype, KnoinAbstractScreen.prototype);
|
'use strict';
|
||||||
|
|
||||||
AdminLoginScreen.prototype.onShow = function ()
|
var
|
||||||
{
|
_ = require('./External/underscore.js'),
|
||||||
RL.setTitle('');
|
KnoinAbstractScreen = require('./Knoin/KnoinAbstractScreen.js'),
|
||||||
};
|
AdminLoginViewModel = require('./ViewModels/AdminLoginViewModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends KnoinAbstractScreen
|
||||||
|
*/
|
||||||
|
function AdminLoginScreen()
|
||||||
|
{
|
||||||
|
KnoinAbstractScreen.call(this, 'login', [AdminLoginViewModel]);
|
||||||
|
}
|
||||||
|
|
||||||
|
_.extend(AdminLoginScreen.prototype, KnoinAbstractScreen.prototype);
|
||||||
|
|
||||||
|
AdminLoginScreen.prototype.onShow = function ()
|
||||||
|
{
|
||||||
|
RL.setTitle(''); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AdminLoginScreen;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,20 +1,35 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends AbstractSettings
|
|
||||||
*/
|
|
||||||
function AdminSettingsScreen()
|
|
||||||
{
|
|
||||||
AbstractSettings.call(this, [
|
|
||||||
AdminMenuViewModel,
|
|
||||||
AdminPaneViewModel
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AdminSettingsScreen.prototype, AbstractSettings.prototype);
|
'use strict';
|
||||||
|
|
||||||
AdminSettingsScreen.prototype.onShow = function ()
|
var
|
||||||
{
|
_ = require('./External/underscore.js'),
|
||||||
RL.setTitle('');
|
AbstractSettings = require('./Screens/AbstractSettings.js'),
|
||||||
};
|
AdminMenuViewModel = require('./ViewModels/AdminMenuViewModel.js'),
|
||||||
|
AdminPaneViewModel = require('./ViewModels/AdminPaneViewModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends AbstractSettings
|
||||||
|
*/
|
||||||
|
function AdminSettingsScreen()
|
||||||
|
{
|
||||||
|
AbstractSettings.call(this, [
|
||||||
|
AdminMenuViewModel,
|
||||||
|
AdminPaneViewModel
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
_.extend(AdminSettingsScreen.prototype, AbstractSettings.prototype);
|
||||||
|
|
||||||
|
AdminSettingsScreen.prototype.onShow = function ()
|
||||||
|
{
|
||||||
|
RL.setTitle(''); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AdminSettingsScreen;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,17 +1,31 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends KnoinAbstractScreen
|
|
||||||
*/
|
|
||||||
function LoginScreen()
|
|
||||||
{
|
|
||||||
KnoinAbstractScreen.call(this, 'login', [LoginViewModel]);
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(LoginScreen.prototype, KnoinAbstractScreen.prototype);
|
'use strict';
|
||||||
|
|
||||||
LoginScreen.prototype.onShow = function ()
|
var
|
||||||
{
|
_ = require('./External/underscore.js'),
|
||||||
RL.setTitle('');
|
KnoinAbstractScreen = require('./Knoin/KnoinAbstractScreen.js'),
|
||||||
};
|
LoginViewModel = require('./ViewModels/LoginViewModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends KnoinAbstractScreen
|
||||||
|
*/
|
||||||
|
function LoginScreen()
|
||||||
|
{
|
||||||
|
KnoinAbstractScreen.call(this, 'login', [LoginViewModel]);
|
||||||
|
}
|
||||||
|
|
||||||
|
_.extend(LoginScreen.prototype, KnoinAbstractScreen.prototype);
|
||||||
|
|
||||||
|
LoginScreen.prototype.onShow = function ()
|
||||||
|
{
|
||||||
|
RL.setTitle(''); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = LoginScreen;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,171 +1,191 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends KnoinAbstractScreen
|
|
||||||
*/
|
|
||||||
function MailBoxScreen()
|
|
||||||
{
|
|
||||||
KnoinAbstractScreen.call(this, 'mailbox', [
|
|
||||||
MailBoxSystemDropDownViewModel,
|
|
||||||
MailBoxFolderListViewModel,
|
|
||||||
MailBoxMessageListViewModel,
|
|
||||||
MailBoxMessageViewViewModel
|
|
||||||
]);
|
|
||||||
|
|
||||||
this.oLastRoute = {};
|
'use strict';
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(MailBoxScreen.prototype, KnoinAbstractScreen.prototype);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
MailBoxScreen.prototype.oLastRoute = {};
|
|
||||||
|
|
||||||
MailBoxScreen.prototype.setNewTitle = function ()
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
sEmail = RL.data().accountEmail(),
|
_ = require('./External/underscore.js'),
|
||||||
ifoldersInboxUnreadCount = RL.data().foldersInboxUnreadCount()
|
$html = require('./External/$html.js'),
|
||||||
|
Enums = require('./Common/Enums.js'),
|
||||||
|
Utils = require('./Common/Utils.js'),
|
||||||
|
KnoinAbstractScreen = require('./Knoin/KnoinAbstractScreen.js'),
|
||||||
|
MailBoxSystemDropDownViewModel = require('./ViewModels/MailBoxSystemDropDownViewModel.js'),
|
||||||
|
MailBoxFolderListViewModel = require('./ViewModels/MailBoxFolderListViewModel.js'),
|
||||||
|
MailBoxMessageListViewModel = require('./ViewModels/MailBoxMessageListViewModel.js'),
|
||||||
|
MailBoxMessageViewViewModel = require('./ViewModels/MailBoxMessageViewViewModel.js')
|
||||||
;
|
;
|
||||||
|
|
||||||
RL.setTitle(('' === sEmail ? '' :
|
/**
|
||||||
(0 < ifoldersInboxUnreadCount ? '(' + ifoldersInboxUnreadCount + ') ' : ' ') + sEmail + ' - ') + Utils.i18n('TITLES/MAILBOX'));
|
* @constructor
|
||||||
};
|
* @extends KnoinAbstractScreen
|
||||||
|
*/
|
||||||
MailBoxScreen.prototype.onShow = function ()
|
function MailBoxScreen()
|
||||||
{
|
|
||||||
this.setNewTitle();
|
|
||||||
RL.data().keyScope(Enums.KeyState.MessageList);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sFolderHash
|
|
||||||
* @param {number} iPage
|
|
||||||
* @param {string} sSearch
|
|
||||||
* @param {boolean=} bPreview = false
|
|
||||||
*/
|
|
||||||
MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPreview)
|
|
||||||
{
|
|
||||||
if (Utils.isUnd(bPreview) ? false : !!bPreview)
|
|
||||||
{
|
{
|
||||||
if (Enums.Layout.NoPreview === RL.data().layout() && !RL.data().message())
|
KnoinAbstractScreen.call(this, 'mailbox', [
|
||||||
{
|
MailBoxSystemDropDownViewModel,
|
||||||
RL.historyBack();
|
MailBoxFolderListViewModel,
|
||||||
}
|
MailBoxMessageListViewModel,
|
||||||
|
MailBoxMessageViewViewModel
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.oLastRoute = {};
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
_.extend(MailBoxScreen.prototype, KnoinAbstractScreen.prototype);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
MailBoxScreen.prototype.oLastRoute = {};
|
||||||
|
|
||||||
|
MailBoxScreen.prototype.setNewTitle = function ()
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
oData = RL.data(),
|
sEmail = RL.data().accountEmail(), // TODO cjs
|
||||||
sFolderFullNameRaw = RL.cache().getFolderFullNameRaw(sFolderHash),
|
ifoldersInboxUnreadCount = RL.data().foldersInboxUnreadCount() // TODO cjs
|
||||||
oFolder = RL.cache().getFolderFromCacheList(sFolderFullNameRaw)
|
|
||||||
;
|
;
|
||||||
|
// TODO cjs
|
||||||
|
RL.setTitle(('' === sEmail ? '' :
|
||||||
|
(0 < ifoldersInboxUnreadCount ? '(' + ifoldersInboxUnreadCount + ') ' : ' ') + sEmail + ' - ') + Utils.i18n('TITLES/MAILBOX'));
|
||||||
|
};
|
||||||
|
|
||||||
if (oFolder)
|
MailBoxScreen.prototype.onShow = function ()
|
||||||
|
{
|
||||||
|
this.setNewTitle();
|
||||||
|
RL.data().keyScope(Enums.KeyState.MessageList);// TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sFolderHash
|
||||||
|
* @param {number} iPage
|
||||||
|
* @param {string} sSearch
|
||||||
|
* @param {boolean=} bPreview = false
|
||||||
|
*/
|
||||||
|
MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPreview)
|
||||||
|
{
|
||||||
|
if (Utils.isUnd(bPreview) ? false : !!bPreview)
|
||||||
{
|
{
|
||||||
oData
|
if (Enums.Layout.NoPreview === RL.data().layout() && !RL.data().message())// TODO cjs
|
||||||
.currentFolder(oFolder)
|
{
|
||||||
.messageListPage(iPage)
|
RL.historyBack();// TODO cjs
|
||||||
.messageListSearch(sSearch)
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var
|
||||||
|
oData = RL.data(),// TODO cjs
|
||||||
|
sFolderFullNameRaw = RL.cache().getFolderFullNameRaw(sFolderHash),// TODO cjs
|
||||||
|
oFolder = RL.cache().getFolderFromCacheList(sFolderFullNameRaw)// TODO cjs
|
||||||
;
|
;
|
||||||
|
|
||||||
if (Enums.Layout.NoPreview === oData.layout() && oData.message())
|
if (oFolder)
|
||||||
{
|
{
|
||||||
oData.message(null);
|
oData
|
||||||
|
.currentFolder(oFolder)
|
||||||
|
.messageListPage(iPage)
|
||||||
|
.messageListSearch(sSearch)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (Enums.Layout.NoPreview === oData.layout() && oData.message())
|
||||||
|
{
|
||||||
|
oData.message(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
RL.reloadMessageList();// TODO cjs
|
||||||
}
|
}
|
||||||
|
|
||||||
RL.reloadMessageList();
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
MailBoxScreen.prototype.onStart = function ()
|
MailBoxScreen.prototype.onStart = function ()
|
||||||
{
|
|
||||||
var
|
|
||||||
oData = RL.data(),
|
|
||||||
fResizeFunction = function () {
|
|
||||||
Utils.windowResize();
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
if (RL.capa(Enums.Capa.AdditionalAccounts) || RL.capa(Enums.Capa.AdditionalIdentities))
|
|
||||||
{
|
{
|
||||||
RL.accountsAndIdentities();
|
var
|
||||||
}
|
oData = RL.data(),// TODO cjs
|
||||||
|
fResizeFunction = function () {
|
||||||
|
Utils.windowResize();
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
_.delay(function () {
|
if (RL.capa(Enums.Capa.AdditionalAccounts) || RL.capa(Enums.Capa.AdditionalIdentities))// TODO cjs
|
||||||
if ('INBOX' !== oData.currentFolderFullNameRaw())
|
|
||||||
{
|
{
|
||||||
RL.folderInformation('INBOX');
|
RL.accountsAndIdentities();// TODO cjs
|
||||||
}
|
}
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
_.delay(function () {
|
_.delay(function () {
|
||||||
RL.quota();
|
if ('INBOX' !== oData.currentFolderFullNameRaw())
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
_.delay(function () {
|
|
||||||
RL.remote().appDelayStart(Utils.emptyFunction);
|
|
||||||
}, 35000);
|
|
||||||
|
|
||||||
$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === oData.layout());
|
|
||||||
|
|
||||||
oData.folderList.subscribe(fResizeFunction);
|
|
||||||
oData.messageList.subscribe(fResizeFunction);
|
|
||||||
oData.message.subscribe(fResizeFunction);
|
|
||||||
|
|
||||||
oData.layout.subscribe(function (nValue) {
|
|
||||||
$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue);
|
|
||||||
});
|
|
||||||
|
|
||||||
oData.foldersInboxUnreadCount.subscribe(function () {
|
|
||||||
this.setNewTitle();
|
|
||||||
}, this);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return {Array}
|
|
||||||
*/
|
|
||||||
MailBoxScreen.prototype.routes = function ()
|
|
||||||
{
|
|
||||||
var
|
|
||||||
fNormP = function () {
|
|
||||||
return ['Inbox', 1, '', true];
|
|
||||||
},
|
|
||||||
fNormS = function (oRequest, oVals) {
|
|
||||||
oVals[0] = Utils.pString(oVals[0]);
|
|
||||||
oVals[1] = Utils.pInt(oVals[1]);
|
|
||||||
oVals[1] = 0 >= oVals[1] ? 1 : oVals[1];
|
|
||||||
oVals[2] = Utils.pString(oVals[2]);
|
|
||||||
|
|
||||||
if ('' === oRequest)
|
|
||||||
{
|
{
|
||||||
oVals[0] = 'Inbox';
|
RL.folderInformation('INBOX');// TODO cjs
|
||||||
oVals[1] = 1;
|
|
||||||
}
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2]), false];
|
_.delay(function () {
|
||||||
},
|
RL.quota();// TODO cjs
|
||||||
fNormD = function (oRequest, oVals) {
|
}, 5000);
|
||||||
oVals[0] = Utils.pString(oVals[0]);
|
|
||||||
oVals[1] = Utils.pString(oVals[1]);
|
|
||||||
|
|
||||||
if ('' === oRequest)
|
_.delay(function () {
|
||||||
{
|
RL.remote().appDelayStart(Utils.emptyFunction);// TODO cjs
|
||||||
oVals[0] = 'Inbox';
|
}, 35000);
|
||||||
|
|
||||||
|
$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === oData.layout());
|
||||||
|
|
||||||
|
oData.folderList.subscribe(fResizeFunction);
|
||||||
|
oData.messageList.subscribe(fResizeFunction);
|
||||||
|
oData.message.subscribe(fResizeFunction);
|
||||||
|
|
||||||
|
oData.layout.subscribe(function (nValue) {
|
||||||
|
$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
oData.foldersInboxUnreadCount.subscribe(function () {
|
||||||
|
this.setNewTitle();
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Array}
|
||||||
|
*/
|
||||||
|
MailBoxScreen.prototype.routes = function ()
|
||||||
|
{
|
||||||
|
var
|
||||||
|
fNormP = function () {
|
||||||
|
return ['Inbox', 1, '', true];
|
||||||
|
},
|
||||||
|
fNormS = function (oRequest, oVals) {
|
||||||
|
oVals[0] = Utils.pString(oVals[0]);
|
||||||
|
oVals[1] = Utils.pInt(oVals[1]);
|
||||||
|
oVals[1] = 0 >= oVals[1] ? 1 : oVals[1];
|
||||||
|
oVals[2] = Utils.pString(oVals[2]);
|
||||||
|
|
||||||
|
if ('' === oRequest)
|
||||||
|
{
|
||||||
|
oVals[0] = 'Inbox';
|
||||||
|
oVals[1] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2]), false];
|
||||||
|
},
|
||||||
|
fNormD = function (oRequest, oVals) {
|
||||||
|
oVals[0] = Utils.pString(oVals[0]);
|
||||||
|
oVals[1] = Utils.pString(oVals[1]);
|
||||||
|
|
||||||
|
if ('' === oRequest)
|
||||||
|
{
|
||||||
|
oVals[0] = 'Inbox';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1]), false];
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1]), false];
|
return [
|
||||||
}
|
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}],
|
||||||
;
|
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}],
|
||||||
|
[/^([a-zA-Z0-9]+)\/(.+)\/?$/, {'normalize_': fNormD}],
|
||||||
|
[/^message-preview$/, {'normalize_': fNormP}],
|
||||||
|
[/^([^\/]*)$/, {'normalize_': fNormS}]
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
return [
|
module.exports = MailBoxScreen;
|
||||||
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}],
|
|
||||||
[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}],
|
}(module));
|
||||||
[/^([a-zA-Z0-9]+)\/(.+)\/?$/, {'normalize_': fNormD}],
|
|
||||||
[/^message-preview$/, {'normalize_': fNormP}],
|
|
||||||
[/^([^\/]*)$/, {'normalize_': fNormS}]
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
@ -1,28 +1,46 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends AbstractSettings
|
|
||||||
*/
|
|
||||||
function SettingsScreen()
|
|
||||||
{
|
|
||||||
AbstractSettings.call(this, [
|
|
||||||
SettingsSystemDropDownViewModel,
|
|
||||||
SettingsMenuViewModel,
|
|
||||||
SettingsPaneViewModel
|
|
||||||
]);
|
|
||||||
|
|
||||||
Utils.initOnStartOrLangChange(function () {
|
'use strict';
|
||||||
this.sSettingsTitle = Utils.i18n('TITLES/SETTINGS');
|
|
||||||
}, this, function () {
|
|
||||||
RL.setTitle(this.sSettingsTitle);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(SettingsScreen.prototype, AbstractSettings.prototype);
|
var
|
||||||
|
_ = require('./External/underscore.js'),
|
||||||
|
Enums = require('./Common/Enums.js'),
|
||||||
|
Utils = require('./Common/Utils.js'),
|
||||||
|
AbstractSettings = require('./Screens/AbstractSettings.js'),
|
||||||
|
SettingsSystemDropDownViewModel = require('./ViewModels/SettingsSystemDropDownViewModel.js'),
|
||||||
|
SettingsMenuViewModel = require('./ViewModels/SettingsMenuViewModel.js'),
|
||||||
|
SettingsPaneViewModel = require('./ViewModels/SettingsPaneViewModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
SettingsScreen.prototype.onShow = function ()
|
/**
|
||||||
{
|
* @constructor
|
||||||
RL.setTitle(this.sSettingsTitle);
|
* @extends AbstractSettings
|
||||||
RL.data().keyScope(Enums.KeyState.Settings);
|
*/
|
||||||
};
|
function SettingsScreen()
|
||||||
|
{
|
||||||
|
AbstractSettings.call(this, [
|
||||||
|
SettingsSystemDropDownViewModel,
|
||||||
|
SettingsMenuViewModel,
|
||||||
|
SettingsPaneViewModel
|
||||||
|
]);
|
||||||
|
|
||||||
|
Utils.initOnStartOrLangChange(function () {
|
||||||
|
this.sSettingsTitle = Utils.i18n('TITLES/SETTINGS');
|
||||||
|
}, this, function () {
|
||||||
|
RL.setTitle(this.sSettingsTitle); // TODO cjs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_.extend(SettingsScreen.prototype, AbstractSettings.prototype);
|
||||||
|
|
||||||
|
SettingsScreen.prototype.onShow = function ()
|
||||||
|
{
|
||||||
|
RL.setTitle(this.sSettingsTitle); // TODO cjs
|
||||||
|
RL.data().keyScope(Enums.KeyState.Settings); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = SettingsScreen;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -68,7 +68,7 @@ SettingsGeneral.prototype.onBuild = function ()
|
||||||
'dataType': 'script',
|
'dataType': 'script',
|
||||||
'cache': true
|
'cache': true
|
||||||
}).done(function() {
|
}).done(function() {
|
||||||
Utils.i18nToDoc();
|
Utils.i18nReload();
|
||||||
self.languageTrigger(Enums.SaveSettingsStep.TrueResult);
|
self.languageTrigger(Enums.SaveSettingsStep.TrueResult);
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
self.languageTrigger(Enums.SaveSettingsStep.FalseResult);
|
self.languageTrigger(Enums.SaveSettingsStep.FalseResult);
|
||||||
|
|
|
||||||
|
|
@ -1,283 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AbstractAjaxRemoteStorage()
|
|
||||||
{
|
|
||||||
this.oRequests = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractAjaxRemoteStorage.prototype.oRequests = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sRequestAction
|
|
||||||
* @param {string} sType
|
|
||||||
* @param {?AjaxJsonDefaultResponse} oData
|
|
||||||
* @param {boolean} bCached
|
|
||||||
* @param {*=} oRequestParameters
|
|
||||||
*/
|
|
||||||
AbstractAjaxRemoteStorage.prototype.defaultResponse = function (fCallback, sRequestAction, sType, oData, bCached, oRequestParameters)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
fCall = function () {
|
|
||||||
if (Enums.StorageResultType.Success !== sType && Globals.bUnload)
|
|
||||||
{
|
|
||||||
sType = Enums.StorageResultType.Unload;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sType && oData && !oData.Result)
|
|
||||||
{
|
|
||||||
if (oData && -1 < Utils.inArray(oData.ErrorCode, [
|
|
||||||
Enums.Notification.AuthError, Enums.Notification.AccessError,
|
|
||||||
Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed,
|
|
||||||
Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
|
|
||||||
]))
|
|
||||||
{
|
|
||||||
Globals.iAjaxErrorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oData && Enums.Notification.InvalidToken === oData.ErrorCode)
|
|
||||||
{
|
|
||||||
Globals.iTokenErrorCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Consts.Values.TokenErrorLimit < Globals.iTokenErrorCount)
|
|
||||||
{
|
|
||||||
RL.loginAndLogoutReload(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oData.Logout || Consts.Values.AjaxErrorLimit < Globals.iAjaxErrorCount)
|
|
||||||
{
|
|
||||||
if (window.__rlah_clear)
|
|
||||||
{
|
|
||||||
window.__rlah_clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
RL.loginAndLogoutReload(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Enums.StorageResultType.Success === sType && oData && oData.Result)
|
|
||||||
{
|
|
||||||
Globals.iAjaxErrorCount = 0;
|
|
||||||
Globals.iTokenErrorCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fCallback)
|
|
||||||
{
|
|
||||||
Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]);
|
|
||||||
|
|
||||||
fCallback(
|
|
||||||
sType,
|
|
||||||
Enums.StorageResultType.Success === sType ? oData : null,
|
|
||||||
bCached,
|
|
||||||
sRequestAction,
|
|
||||||
oRequestParameters
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
switch (sType)
|
|
||||||
{
|
|
||||||
case 'success':
|
|
||||||
sType = Enums.StorageResultType.Success;
|
|
||||||
break;
|
|
||||||
case 'abort':
|
|
||||||
sType = Enums.StorageResultType.Abort;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sType = Enums.StorageResultType.Error;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Enums.StorageResultType.Error === sType)
|
|
||||||
{
|
|
||||||
_.delay(fCall, 300);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fCall();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fResultCallback
|
|
||||||
* @param {Object} oParameters
|
|
||||||
* @param {?number=} iTimeOut = 20000
|
|
||||||
* @param {string=} sGetAdd = ''
|
|
||||||
* @param {Array=} aAbortActions = []
|
|
||||||
* @return {jQuery.jqXHR}
|
|
||||||
*/
|
|
||||||
AbstractAjaxRemoteStorage.prototype.ajaxRequest = function (fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
self = this,
|
|
||||||
bPost = '' === sGetAdd,
|
|
||||||
oHeaders = {},
|
|
||||||
iStart = (new window.Date()).getTime(),
|
|
||||||
oDefAjax = null,
|
|
||||||
sAction = ''
|
|
||||||
;
|
|
||||||
|
|
||||||
oParameters = oParameters || {};
|
|
||||||
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000;
|
|
||||||
sGetAdd = Utils.isUnd(sGetAdd) ? '' : Utils.pString(sGetAdd);
|
|
||||||
aAbortActions = Utils.isArray(aAbortActions) ? aAbortActions : [];
|
|
||||||
|
|
||||||
sAction = oParameters.Action || '';
|
|
||||||
|
|
||||||
if (sAction && 0 < aAbortActions.length)
|
|
||||||
{
|
|
||||||
_.each(aAbortActions, function (sActionToAbort) {
|
|
||||||
if (self.oRequests[sActionToAbort])
|
|
||||||
{
|
|
||||||
self.oRequests[sActionToAbort].__aborted = true;
|
|
||||||
if (self.oRequests[sActionToAbort].abort)
|
|
||||||
{
|
|
||||||
self.oRequests[sActionToAbort].abort();
|
|
||||||
}
|
|
||||||
self.oRequests[sActionToAbort] = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bPost)
|
|
||||||
{
|
|
||||||
oParameters['XToken'] = RL.settingsGet('Token');
|
|
||||||
}
|
|
||||||
|
|
||||||
oDefAjax = $.ajax({
|
|
||||||
'type': bPost ? 'POST' : 'GET',
|
|
||||||
'url': RL.link().ajax(sGetAdd),
|
|
||||||
'async': true,
|
|
||||||
'dataType': 'json',
|
|
||||||
'data': bPost ? oParameters : {},
|
|
||||||
'headers': oHeaders,
|
|
||||||
'timeout': iTimeOut,
|
|
||||||
'global': true
|
|
||||||
});
|
|
||||||
|
|
||||||
oDefAjax.always(function (oData, sType) {
|
|
||||||
|
|
||||||
var bCached = false;
|
|
||||||
if (oData && oData['Time'])
|
|
||||||
{
|
|
||||||
bCached = Utils.pInt(oData['Time']) > (new window.Date()).getTime() - iStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sAction && self.oRequests[sAction])
|
|
||||||
{
|
|
||||||
if (self.oRequests[sAction].__aborted)
|
|
||||||
{
|
|
||||||
sType = 'abort';
|
|
||||||
}
|
|
||||||
|
|
||||||
self.oRequests[sAction] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.defaultResponse(fResultCallback, sAction, sType, oData, bCached, oParameters);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (sAction && 0 < aAbortActions.length && -1 < Utils.inArray(sAction, aAbortActions))
|
|
||||||
{
|
|
||||||
if (this.oRequests[sAction])
|
|
||||||
{
|
|
||||||
this.oRequests[sAction].__aborted = true;
|
|
||||||
if (this.oRequests[sAction].abort)
|
|
||||||
{
|
|
||||||
this.oRequests[sAction].abort();
|
|
||||||
}
|
|
||||||
this.oRequests[sAction] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.oRequests[sAction] = oDefAjax;
|
|
||||||
}
|
|
||||||
|
|
||||||
return oDefAjax;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sAction
|
|
||||||
* @param {Object=} oParameters
|
|
||||||
* @param {?number=} iTimeout
|
|
||||||
* @param {string=} sGetAdd = ''
|
|
||||||
* @param {Array=} aAbortActions = []
|
|
||||||
*/
|
|
||||||
AbstractAjaxRemoteStorage.prototype.defaultRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
|
|
||||||
{
|
|
||||||
oParameters = oParameters || {};
|
|
||||||
oParameters.Action = sAction;
|
|
||||||
|
|
||||||
sGetAdd = Utils.pString(sGetAdd);
|
|
||||||
|
|
||||||
Plugins.runHook('ajax-default-request', [sAction, oParameters, sGetAdd]);
|
|
||||||
|
|
||||||
this.ajaxRequest(fCallback, oParameters,
|
|
||||||
Utils.isUnd(iTimeout) ? Consts.Defaults.DefaultAjaxTimeout : Utils.pInt(iTimeout), sGetAdd, aAbortActions);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AbstractAjaxRemoteStorage.prototype.noop = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'Noop');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sMessage
|
|
||||||
* @param {string} sFileName
|
|
||||||
* @param {number} iLineNo
|
|
||||||
* @param {string} sLocation
|
|
||||||
* @param {string} sHtmlCapa
|
|
||||||
* @param {number} iTime
|
|
||||||
*/
|
|
||||||
AbstractAjaxRemoteStorage.prototype.jsError = function (fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'JsError', {
|
|
||||||
'Message': sMessage,
|
|
||||||
'FileName': sFileName,
|
|
||||||
'LineNo': iLineNo,
|
|
||||||
'Location': sLocation,
|
|
||||||
'HtmlCapa': sHtmlCapa,
|
|
||||||
'TimeOnPage': iTime
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sType
|
|
||||||
* @param {Array=} mData = null
|
|
||||||
* @param {boolean=} bIsError = false
|
|
||||||
*/
|
|
||||||
AbstractAjaxRemoteStorage.prototype.jsInfo = function (fCallback, sType, mData, bIsError)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'JsInfo', {
|
|
||||||
'Type': sType,
|
|
||||||
'Data': mData,
|
|
||||||
'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AbstractAjaxRemoteStorage.prototype.getPublicKey = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'GetPublicKey');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sVersion
|
|
||||||
*/
|
|
||||||
AbstractAjaxRemoteStorage.prototype.jsVersion = function (fCallback, sVersion)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'Version', {
|
|
||||||
'Version': sVersion
|
|
||||||
});
|
|
||||||
};
|
|
||||||
301
dev/Storages/AbstractAjaxRemoteStorage.js
Normal file
301
dev/Storages/AbstractAjaxRemoteStorage.js
Normal file
|
|
@ -0,0 +1,301 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
window = require('./External/window.js'),
|
||||||
|
$ = require('./External/jquery.js'),
|
||||||
|
Consts = require('./Common/Consts.js'),
|
||||||
|
Enums = require('./Common/Enums.js'),
|
||||||
|
Globals = require('./Common/Globals.js'),
|
||||||
|
Utils = require('./Common/Utils.js'),
|
||||||
|
Plugins = require('./Common/Plugins.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function AbstractAjaxRemoteStorage()
|
||||||
|
{
|
||||||
|
this.oRequests = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractAjaxRemoteStorage.prototype.oRequests = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sRequestAction
|
||||||
|
* @param {string} sType
|
||||||
|
* @param {?AjaxJsonDefaultResponse} oData
|
||||||
|
* @param {boolean} bCached
|
||||||
|
* @param {*=} oRequestParameters
|
||||||
|
*/
|
||||||
|
AbstractAjaxRemoteStorage.prototype.defaultResponse = function (fCallback, sRequestAction, sType, oData, bCached, oRequestParameters)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
fCall = function () {
|
||||||
|
if (Enums.StorageResultType.Success !== sType && Globals.bUnload)
|
||||||
|
{
|
||||||
|
sType = Enums.StorageResultType.Unload;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Enums.StorageResultType.Success === sType && oData && !oData.Result)
|
||||||
|
{
|
||||||
|
if (oData && -1 < Utils.inArray(oData.ErrorCode, [
|
||||||
|
Enums.Notification.AuthError, Enums.Notification.AccessError,
|
||||||
|
Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed,
|
||||||
|
Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
|
||||||
|
]))
|
||||||
|
{
|
||||||
|
Globals.iAjaxErrorCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oData && Enums.Notification.InvalidToken === oData.ErrorCode)
|
||||||
|
{
|
||||||
|
Globals.iTokenErrorCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Consts.Values.TokenErrorLimit < Globals.iTokenErrorCount)
|
||||||
|
{
|
||||||
|
RL.loginAndLogoutReload(true); // TODO cjs
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oData.Logout || Consts.Values.AjaxErrorLimit < Globals.iAjaxErrorCount)
|
||||||
|
{
|
||||||
|
if (window.__rlah_clear)
|
||||||
|
{
|
||||||
|
window.__rlah_clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
RL.loginAndLogoutReload(true); // TODO cjs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Enums.StorageResultType.Success === sType && oData && oData.Result)
|
||||||
|
{
|
||||||
|
Globals.iAjaxErrorCount = 0;
|
||||||
|
Globals.iTokenErrorCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fCallback)
|
||||||
|
{
|
||||||
|
Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]);
|
||||||
|
|
||||||
|
fCallback(
|
||||||
|
sType,
|
||||||
|
Enums.StorageResultType.Success === sType ? oData : null,
|
||||||
|
bCached,
|
||||||
|
sRequestAction,
|
||||||
|
oRequestParameters
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
switch (sType)
|
||||||
|
{
|
||||||
|
case 'success':
|
||||||
|
sType = Enums.StorageResultType.Success;
|
||||||
|
break;
|
||||||
|
case 'abort':
|
||||||
|
sType = Enums.StorageResultType.Abort;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sType = Enums.StorageResultType.Error;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Enums.StorageResultType.Error === sType)
|
||||||
|
{
|
||||||
|
_.delay(fCall, 300);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fCall();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fResultCallback
|
||||||
|
* @param {Object} oParameters
|
||||||
|
* @param {?number=} iTimeOut = 20000
|
||||||
|
* @param {string=} sGetAdd = ''
|
||||||
|
* @param {Array=} aAbortActions = []
|
||||||
|
* @return {jQuery.jqXHR}
|
||||||
|
*/
|
||||||
|
AbstractAjaxRemoteStorage.prototype.ajaxRequest = function (fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
self = this,
|
||||||
|
bPost = '' === sGetAdd,
|
||||||
|
oHeaders = {},
|
||||||
|
iStart = (new window.Date()).getTime(),
|
||||||
|
oDefAjax = null,
|
||||||
|
sAction = ''
|
||||||
|
;
|
||||||
|
|
||||||
|
oParameters = oParameters || {};
|
||||||
|
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000;
|
||||||
|
sGetAdd = Utils.isUnd(sGetAdd) ? '' : Utils.pString(sGetAdd);
|
||||||
|
aAbortActions = Utils.isArray(aAbortActions) ? aAbortActions : [];
|
||||||
|
|
||||||
|
sAction = oParameters.Action || '';
|
||||||
|
|
||||||
|
if (sAction && 0 < aAbortActions.length)
|
||||||
|
{
|
||||||
|
_.each(aAbortActions, function (sActionToAbort) {
|
||||||
|
if (self.oRequests[sActionToAbort])
|
||||||
|
{
|
||||||
|
self.oRequests[sActionToAbort].__aborted = true;
|
||||||
|
if (self.oRequests[sActionToAbort].abort)
|
||||||
|
{
|
||||||
|
self.oRequests[sActionToAbort].abort();
|
||||||
|
}
|
||||||
|
self.oRequests[sActionToAbort] = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bPost)
|
||||||
|
{
|
||||||
|
oParameters['XToken'] = RL.settingsGet('Token'); // TODO cjs
|
||||||
|
}
|
||||||
|
|
||||||
|
oDefAjax = $.ajax({
|
||||||
|
'type': bPost ? 'POST' : 'GET',
|
||||||
|
'url': RL.link().ajax(sGetAdd), // TODO cjs
|
||||||
|
'async': true,
|
||||||
|
'dataType': 'json',
|
||||||
|
'data': bPost ? oParameters : {},
|
||||||
|
'headers': oHeaders,
|
||||||
|
'timeout': iTimeOut,
|
||||||
|
'global': true
|
||||||
|
});
|
||||||
|
|
||||||
|
oDefAjax.always(function (oData, sType) {
|
||||||
|
|
||||||
|
var bCached = false;
|
||||||
|
if (oData && oData['Time'])
|
||||||
|
{
|
||||||
|
bCached = Utils.pInt(oData['Time']) > (new window.Date()).getTime() - iStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sAction && self.oRequests[sAction])
|
||||||
|
{
|
||||||
|
if (self.oRequests[sAction].__aborted)
|
||||||
|
{
|
||||||
|
sType = 'abort';
|
||||||
|
}
|
||||||
|
|
||||||
|
self.oRequests[sAction] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.defaultResponse(fResultCallback, sAction, sType, oData, bCached, oParameters);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (sAction && 0 < aAbortActions.length && -1 < Utils.inArray(sAction, aAbortActions))
|
||||||
|
{
|
||||||
|
if (this.oRequests[sAction])
|
||||||
|
{
|
||||||
|
this.oRequests[sAction].__aborted = true;
|
||||||
|
if (this.oRequests[sAction].abort)
|
||||||
|
{
|
||||||
|
this.oRequests[sAction].abort();
|
||||||
|
}
|
||||||
|
this.oRequests[sAction] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.oRequests[sAction] = oDefAjax;
|
||||||
|
}
|
||||||
|
|
||||||
|
return oDefAjax;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sAction
|
||||||
|
* @param {Object=} oParameters
|
||||||
|
* @param {?number=} iTimeout
|
||||||
|
* @param {string=} sGetAdd = ''
|
||||||
|
* @param {Array=} aAbortActions = []
|
||||||
|
*/
|
||||||
|
AbstractAjaxRemoteStorage.prototype.defaultRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
|
||||||
|
{
|
||||||
|
oParameters = oParameters || {};
|
||||||
|
oParameters.Action = sAction;
|
||||||
|
|
||||||
|
sGetAdd = Utils.pString(sGetAdd);
|
||||||
|
|
||||||
|
Plugins.runHook('ajax-default-request', [sAction, oParameters, sGetAdd]);
|
||||||
|
|
||||||
|
this.ajaxRequest(fCallback, oParameters,
|
||||||
|
Utils.isUnd(iTimeout) ? Consts.Defaults.DefaultAjaxTimeout : Utils.pInt(iTimeout), sGetAdd, aAbortActions);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AbstractAjaxRemoteStorage.prototype.noop = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'Noop');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sMessage
|
||||||
|
* @param {string} sFileName
|
||||||
|
* @param {number} iLineNo
|
||||||
|
* @param {string} sLocation
|
||||||
|
* @param {string} sHtmlCapa
|
||||||
|
* @param {number} iTime
|
||||||
|
*/
|
||||||
|
AbstractAjaxRemoteStorage.prototype.jsError = function (fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'JsError', {
|
||||||
|
'Message': sMessage,
|
||||||
|
'FileName': sFileName,
|
||||||
|
'LineNo': iLineNo,
|
||||||
|
'Location': sLocation,
|
||||||
|
'HtmlCapa': sHtmlCapa,
|
||||||
|
'TimeOnPage': iTime
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sType
|
||||||
|
* @param {Array=} mData = null
|
||||||
|
* @param {boolean=} bIsError = false
|
||||||
|
*/
|
||||||
|
AbstractAjaxRemoteStorage.prototype.jsInfo = function (fCallback, sType, mData, bIsError)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'JsInfo', {
|
||||||
|
'Type': sType,
|
||||||
|
'Data': mData,
|
||||||
|
'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AbstractAjaxRemoteStorage.prototype.getPublicKey = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'GetPublicKey');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sVersion
|
||||||
|
*/
|
||||||
|
AbstractAjaxRemoteStorage.prototype.jsVersion = function (fCallback, sVersion)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'Version', {
|
||||||
|
'Version': sVersion
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AbstractAjaxRemoteStorage;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AbstractCacheStorage()
|
|
||||||
{
|
|
||||||
this.bCapaGravatar = RL.capa(Enums.Capa.Gravatar);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
AbstractCacheStorage.prototype.oServices = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
AbstractCacheStorage.prototype.bCapaGravatar = false;
|
|
||||||
|
|
||||||
AbstractCacheStorage.prototype.clear = function ()
|
|
||||||
{
|
|
||||||
this.bCapaGravatar = !!this.bCapaGravatar; // TODO
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sEmail
|
|
||||||
* @return {string}
|
|
||||||
*/
|
|
||||||
AbstractCacheStorage.prototype.getUserPic = function (sEmail, fCallback)
|
|
||||||
{
|
|
||||||
sEmail = Utils.trim(sEmail);
|
|
||||||
fCallback(this.bCapaGravatar && '' !== sEmail ? RL.link().avatarLink(sEmail) : '', sEmail);
|
|
||||||
};
|
|
||||||
48
dev/Storages/AbstractCacheStorage.js
Normal file
48
dev/Storages/AbstractCacheStorage.js
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
Enums = require('./Common/Enums.js'),
|
||||||
|
Utils = require('./Common/Utils.js'),
|
||||||
|
RL = require('./RL.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function AbstractCacheStorage()
|
||||||
|
{
|
||||||
|
this.bCapaGravatar = RL().capa(Enums.Capa.Gravatar);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
AbstractCacheStorage.prototype.oServices = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
AbstractCacheStorage.prototype.bCapaGravatar = false;
|
||||||
|
|
||||||
|
AbstractCacheStorage.prototype.clear = function ()
|
||||||
|
{
|
||||||
|
this.bCapaGravatar = !!this.bCapaGravatar; // TODO
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sEmail
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
AbstractCacheStorage.prototype.getUserPic = function (sEmail, fCallback)
|
||||||
|
{
|
||||||
|
sEmail = Utils.trim(sEmail);
|
||||||
|
fCallback(this.bCapaGravatar && '' !== sEmail ? RL().link().avatarLink(sEmail) : '', sEmail);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AbstractCacheStorage;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,134 +1,150 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AbstractData()
|
|
||||||
{
|
|
||||||
this.leftPanelDisabled = ko.observable(false);
|
|
||||||
this.useKeyboardShortcuts = ko.observable(true);
|
|
||||||
|
|
||||||
this.keyScopeReal = ko.observable(Enums.KeyState.All);
|
'use strict';
|
||||||
this.keyScopeFake = ko.observable(Enums.KeyState.All);
|
|
||||||
|
|
||||||
this.keyScope = ko.computed({
|
|
||||||
'owner': this,
|
|
||||||
'read': function () {
|
|
||||||
return this.keyScopeFake();
|
|
||||||
},
|
|
||||||
'write': function (sValue) {
|
|
||||||
|
|
||||||
if (Enums.KeyState.Menu !== sValue)
|
|
||||||
{
|
|
||||||
if (Enums.KeyState.Compose === sValue)
|
|
||||||
{
|
|
||||||
Utils.disableKeyFilter();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Utils.restoreKeyFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.keyScopeFake(sValue);
|
|
||||||
if (Globals.dropdownVisibility())
|
|
||||||
{
|
|
||||||
sValue = Enums.KeyState.Menu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.keyScopeReal(sValue);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.keyScopeReal.subscribe(function (sValue) {
|
|
||||||
// window.console.log(sValue);
|
|
||||||
key.setScope(sValue);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.leftPanelDisabled.subscribe(function (bValue) {
|
|
||||||
RL.pub('left-panel.' + (bValue ? 'off' : 'on'));
|
|
||||||
});
|
|
||||||
|
|
||||||
Globals.dropdownVisibility.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
|
||||||
Globals.tooltipTrigger(!Globals.tooltipTrigger());
|
|
||||||
this.keyScope(Enums.KeyState.Menu);
|
|
||||||
}
|
|
||||||
else if (Enums.KeyState.Menu === key.getScope())
|
|
||||||
{
|
|
||||||
this.keyScope(this.keyScopeFake());
|
|
||||||
}
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
Utils.initDataConstructorBySettings(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractData.prototype.populateDataOnStart = function()
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
mLayout = Utils.pInt(RL.settingsGet('Layout')),
|
ko = require('./External/ko.js'),
|
||||||
aLanguages = RL.settingsGet('Languages'),
|
key = require('./External/key.js'),
|
||||||
aThemes = RL.settingsGet('Themes')
|
Enums = require('./Common/Enums.js'),
|
||||||
|
Globals = require('./Common/Globals.js'),
|
||||||
|
Utils = require('./Common/Utils.js')
|
||||||
;
|
;
|
||||||
|
|
||||||
if (Utils.isArray(aLanguages))
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function AbstractData()
|
||||||
{
|
{
|
||||||
this.languages(aLanguages);
|
this.leftPanelDisabled = ko.observable(false);
|
||||||
|
this.useKeyboardShortcuts = ko.observable(true);
|
||||||
|
|
||||||
|
this.keyScopeReal = ko.observable(Enums.KeyState.All);
|
||||||
|
this.keyScopeFake = ko.observable(Enums.KeyState.All);
|
||||||
|
|
||||||
|
this.keyScope = ko.computed({
|
||||||
|
'owner': this,
|
||||||
|
'read': function () {
|
||||||
|
return this.keyScopeFake();
|
||||||
|
},
|
||||||
|
'write': function (sValue) {
|
||||||
|
|
||||||
|
if (Enums.KeyState.Menu !== sValue)
|
||||||
|
{
|
||||||
|
if (Enums.KeyState.Compose === sValue)
|
||||||
|
{
|
||||||
|
Utils.disableKeyFilter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Utils.restoreKeyFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.keyScopeFake(sValue);
|
||||||
|
if (Globals.dropdownVisibility())
|
||||||
|
{
|
||||||
|
sValue = Enums.KeyState.Menu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.keyScopeReal(sValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.keyScopeReal.subscribe(function (sValue) {
|
||||||
|
// window.console.log(sValue);
|
||||||
|
key.setScope(sValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.leftPanelDisabled.subscribe(function (bValue) {
|
||||||
|
RL.pub('left-panel.' + (bValue ? 'off' : 'on')); // TODO cjs
|
||||||
|
});
|
||||||
|
|
||||||
|
Globals.dropdownVisibility.subscribe(function (bValue) {
|
||||||
|
if (bValue)
|
||||||
|
{
|
||||||
|
Globals.tooltipTrigger(!Globals.tooltipTrigger());
|
||||||
|
this.keyScope(Enums.KeyState.Menu);
|
||||||
|
}
|
||||||
|
else if (Enums.KeyState.Menu === key.getScope())
|
||||||
|
{
|
||||||
|
this.keyScope(this.keyScopeFake());
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
Utils.initDataConstructorBySettings(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.isArray(aThemes))
|
AbstractData.prototype.populateDataOnStart = function()
|
||||||
{
|
{
|
||||||
this.themes(aThemes);
|
var
|
||||||
}
|
mLayout = Utils.pInt(RL.settingsGet('Layout')), // TODO cjs
|
||||||
|
aLanguages = RL.settingsGet('Languages'),
|
||||||
|
aThemes = RL.settingsGet('Themes')
|
||||||
|
;
|
||||||
|
|
||||||
this.mainLanguage(RL.settingsGet('Language'));
|
if (Utils.isArray(aLanguages))
|
||||||
this.mainTheme(RL.settingsGet('Theme'));
|
{
|
||||||
|
this.languages(aLanguages);
|
||||||
|
}
|
||||||
|
|
||||||
this.capaAdditionalAccounts(RL.capa(Enums.Capa.AdditionalAccounts));
|
if (Utils.isArray(aThemes))
|
||||||
this.capaAdditionalIdentities(RL.capa(Enums.Capa.AdditionalIdentities));
|
{
|
||||||
this.capaGravatar(RL.capa(Enums.Capa.Gravatar));
|
this.themes(aThemes);
|
||||||
this.determineUserLanguage(!!RL.settingsGet('DetermineUserLanguage'));
|
}
|
||||||
this.determineUserDomain(!!RL.settingsGet('DetermineUserDomain'));
|
|
||||||
|
|
||||||
this.capaThemes(RL.capa(Enums.Capa.Themes));
|
this.mainLanguage(RL.settingsGet('Language'));
|
||||||
this.allowLanguagesOnLogin(!!RL.settingsGet('AllowLanguagesOnLogin'));
|
this.mainTheme(RL.settingsGet('Theme'));
|
||||||
this.allowLanguagesOnSettings(!!RL.settingsGet('AllowLanguagesOnSettings'));
|
|
||||||
this.useLocalProxyForExternalImages(!!RL.settingsGet('UseLocalProxyForExternalImages'));
|
|
||||||
|
|
||||||
this.editorDefaultType(RL.settingsGet('EditorDefaultType'));
|
this.capaAdditionalAccounts(RL.capa(Enums.Capa.AdditionalAccounts));
|
||||||
this.showImages(!!RL.settingsGet('ShowImages'));
|
this.capaAdditionalIdentities(RL.capa(Enums.Capa.AdditionalIdentities));
|
||||||
this.contactsAutosave(!!RL.settingsGet('ContactsAutosave'));
|
this.capaGravatar(RL.capa(Enums.Capa.Gravatar));
|
||||||
this.interfaceAnimation(RL.settingsGet('InterfaceAnimation'));
|
this.determineUserLanguage(!!RL.settingsGet('DetermineUserLanguage'));
|
||||||
|
this.determineUserDomain(!!RL.settingsGet('DetermineUserDomain'));
|
||||||
|
|
||||||
this.mainMessagesPerPage(RL.settingsGet('MPP'));
|
this.capaThemes(RL.capa(Enums.Capa.Themes));
|
||||||
|
this.allowLanguagesOnLogin(!!RL.settingsGet('AllowLanguagesOnLogin'));
|
||||||
|
this.allowLanguagesOnSettings(!!RL.settingsGet('AllowLanguagesOnSettings'));
|
||||||
|
this.useLocalProxyForExternalImages(!!RL.settingsGet('UseLocalProxyForExternalImages'));
|
||||||
|
|
||||||
this.desktopNotifications(!!RL.settingsGet('DesktopNotifications'));
|
this.editorDefaultType(RL.settingsGet('EditorDefaultType'));
|
||||||
this.useThreads(!!RL.settingsGet('UseThreads'));
|
this.showImages(!!RL.settingsGet('ShowImages'));
|
||||||
this.replySameFolder(!!RL.settingsGet('ReplySameFolder'));
|
this.contactsAutosave(!!RL.settingsGet('ContactsAutosave'));
|
||||||
this.useCheckboxesInList(!!RL.settingsGet('UseCheckboxesInList'));
|
this.interfaceAnimation(RL.settingsGet('InterfaceAnimation'));
|
||||||
|
|
||||||
this.layout(Enums.Layout.SidePreview);
|
this.mainMessagesPerPage(RL.settingsGet('MPP'));
|
||||||
if (-1 < Utils.inArray(mLayout, [Enums.Layout.NoPreview, Enums.Layout.SidePreview, Enums.Layout.BottomPreview]))
|
|
||||||
{
|
|
||||||
this.layout(mLayout);
|
|
||||||
}
|
|
||||||
this.facebookSupported(!!RL.settingsGet('SupportedFacebookSocial'));
|
|
||||||
this.facebookEnable(!!RL.settingsGet('AllowFacebookSocial'));
|
|
||||||
this.facebookAppID(RL.settingsGet('FacebookAppID'));
|
|
||||||
this.facebookAppSecret(RL.settingsGet('FacebookAppSecret'));
|
|
||||||
|
|
||||||
this.twitterEnable(!!RL.settingsGet('AllowTwitterSocial'));
|
this.desktopNotifications(!!RL.settingsGet('DesktopNotifications'));
|
||||||
this.twitterConsumerKey(RL.settingsGet('TwitterConsumerKey'));
|
this.useThreads(!!RL.settingsGet('UseThreads'));
|
||||||
this.twitterConsumerSecret(RL.settingsGet('TwitterConsumerSecret'));
|
this.replySameFolder(!!RL.settingsGet('ReplySameFolder'));
|
||||||
|
this.useCheckboxesInList(!!RL.settingsGet('UseCheckboxesInList'));
|
||||||
|
|
||||||
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
this.layout(Enums.Layout.SidePreview);
|
||||||
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
if (-1 < Utils.inArray(mLayout, [Enums.Layout.NoPreview, Enums.Layout.SidePreview, Enums.Layout.BottomPreview]))
|
||||||
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
{
|
||||||
this.googleApiKey(RL.settingsGet('GoogleApiKey'));
|
this.layout(mLayout);
|
||||||
|
}
|
||||||
|
this.facebookSupported(!!RL.settingsGet('SupportedFacebookSocial'));
|
||||||
|
this.facebookEnable(!!RL.settingsGet('AllowFacebookSocial'));
|
||||||
|
this.facebookAppID(RL.settingsGet('FacebookAppID'));
|
||||||
|
this.facebookAppSecret(RL.settingsGet('FacebookAppSecret'));
|
||||||
|
|
||||||
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
this.twitterEnable(!!RL.settingsGet('AllowTwitterSocial'));
|
||||||
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
this.twitterConsumerKey(RL.settingsGet('TwitterConsumerKey'));
|
||||||
|
this.twitterConsumerSecret(RL.settingsGet('TwitterConsumerSecret'));
|
||||||
|
|
||||||
this.contactsIsAllowed(!!RL.settingsGet('ContactsIsAllowed'));
|
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
||||||
};
|
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
||||||
|
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
||||||
|
this.googleApiKey(RL.settingsGet('GoogleApiKey'));
|
||||||
|
|
||||||
|
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
||||||
|
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
||||||
|
|
||||||
|
this.contactsIsAllowed(!!RL.settingsGet('ContactsIsAllowed'));
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AbstractData;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,262 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends AbstractAjaxRemoteStorage
|
|
||||||
*/
|
|
||||||
function AdminAjaxRemoteStorage()
|
|
||||||
{
|
|
||||||
AbstractAjaxRemoteStorage.call(this);
|
|
||||||
|
|
||||||
this.oRequests = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AdminAjaxRemoteStorage.prototype, AbstractAjaxRemoteStorage.prototype);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sLogin
|
|
||||||
* @param {string} sPassword
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.adminLogin = function (fCallback, sLogin, sPassword)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminLogin', {
|
|
||||||
'Login': sLogin,
|
|
||||||
'Password': sPassword
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.adminLogout = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminLogout');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {?} oData
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.saveAdminConfig = function (fCallback, oData)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.domainList = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainList');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.pluginList = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPluginList');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.packagesList = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPackagesList');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.coreData = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminCoreData');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.updateCoreData = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {Object} oPackage
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.packageInstall = function (fCallback, oPackage)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPackageInstall', {
|
|
||||||
'Id': oPackage.id,
|
|
||||||
'Type': oPackage.type,
|
|
||||||
'File': oPackage.file
|
|
||||||
}, 60000);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {Object} oPackage
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.packageDelete = function (fCallback, oPackage)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPackageDelete', {
|
|
||||||
'Id': oPackage.id
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sName
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.domain = function (fCallback, sName)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainLoad', {
|
|
||||||
'Name': sName
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sName
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.plugin = function (fCallback, sName)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPluginLoad', {
|
|
||||||
'Name': sName
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sName
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.domainDelete = function (fCallback, sName)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainDelete', {
|
|
||||||
'Name': sName
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sName
|
|
||||||
* @param {boolean} bDisabled
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.domainDisable = function (fCallback, sName, bDisabled)
|
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminDomainDisable', {
|
|
||||||
'Name': sName,
|
|
||||||
'Disabled': !!bDisabled ? '1' : '0'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {Object} oConfig
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.pluginSettingsUpdate = function (fCallback, oConfig)
|
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {boolean} bForce
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.licensing = function (fCallback, bForce)
|
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminLicensing', {
|
|
||||||
'Force' : bForce ? '1' : '0'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sDomain
|
|
||||||
* @param {string} sKey
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.licensingActivate = function (fCallback, sDomain, sKey)
|
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
|
|
||||||
'Domain' : sDomain,
|
|
||||||
'Key' : sKey
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {string} sName
|
|
||||||
* @param {boolean} bDisabled
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.pluginDisable = function (fCallback, sName, bDisabled)
|
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminPluginDisable', {
|
|
||||||
'Name': sName,
|
|
||||||
'Disabled': !!bDisabled ? '1' : '0'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminAjaxRemoteStorage.prototype.createOrUpdateDomain = function (fCallback,
|
|
||||||
bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
|
||||||
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, sWhiteList)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainSave', {
|
|
||||||
'Create': bCreate ? '1' : '0',
|
|
||||||
'Name': sName,
|
|
||||||
'IncHost': sIncHost,
|
|
||||||
'IncPort': iIncPort,
|
|
||||||
'IncSecure': sIncSecure,
|
|
||||||
'IncShortLogin': bIncShortLogin ? '1' : '0',
|
|
||||||
'OutHost': sOutHost,
|
|
||||||
'OutPort': iOutPort,
|
|
||||||
'OutSecure': sOutSecure,
|
|
||||||
'OutShortLogin': bOutShortLogin ? '1' : '0',
|
|
||||||
'OutAuth': bOutAuth ? '1' : '0',
|
|
||||||
'WhiteList': sWhiteList
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminAjaxRemoteStorage.prototype.testConnectionForDomain = function (fCallback, sName,
|
|
||||||
sIncHost, iIncPort, sIncSecure,
|
|
||||||
sOutHost, iOutPort, sOutSecure, bOutAuth)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainTest', {
|
|
||||||
'Name': sName,
|
|
||||||
'IncHost': sIncHost,
|
|
||||||
'IncPort': iIncPort,
|
|
||||||
'IncSecure': sIncSecure,
|
|
||||||
'OutHost': sOutHost,
|
|
||||||
'OutPort': iOutPort,
|
|
||||||
'OutSecure': sOutSecure,
|
|
||||||
'OutAuth': bOutAuth ? '1' : '0'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {?} oData
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.testContacts = function (fCallback, oData)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminContactsTest', oData);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
* @param {?} oData
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.saveNewAdminPassword = function (fCallback, oData)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {?Function} fCallback
|
|
||||||
*/
|
|
||||||
AdminAjaxRemoteStorage.prototype.adminPing = function (fCallback)
|
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPing');
|
|
||||||
};
|
|
||||||
275
dev/Storages/AdminAjaxRemoteStorage.js
Normal file
275
dev/Storages/AdminAjaxRemoteStorage.js
Normal file
|
|
@ -0,0 +1,275 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
_ = require('./External/underscore.js'),
|
||||||
|
AbstractAjaxRemoteStorage = require('./Storages/AbstractAjaxRemoteStorage.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends AbstractAjaxRemoteStorage
|
||||||
|
*/
|
||||||
|
function AdminAjaxRemoteStorage()
|
||||||
|
{
|
||||||
|
AbstractAjaxRemoteStorage.call(this);
|
||||||
|
|
||||||
|
this.oRequests = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
_.extend(AdminAjaxRemoteStorage.prototype, AbstractAjaxRemoteStorage.prototype);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sLogin
|
||||||
|
* @param {string} sPassword
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.adminLogin = function (fCallback, sLogin, sPassword)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminLogin', {
|
||||||
|
'Login': sLogin,
|
||||||
|
'Password': sPassword
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.adminLogout = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminLogout');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {?} oData
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.saveAdminConfig = function (fCallback, oData)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.domainList = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminDomainList');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.pluginList = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminPluginList');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.packagesList = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminPackagesList');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.coreData = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminCoreData');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.updateCoreData = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {Object} oPackage
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.packageInstall = function (fCallback, oPackage)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminPackageInstall', {
|
||||||
|
'Id': oPackage.id,
|
||||||
|
'Type': oPackage.type,
|
||||||
|
'File': oPackage.file
|
||||||
|
}, 60000);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {Object} oPackage
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.packageDelete = function (fCallback, oPackage)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminPackageDelete', {
|
||||||
|
'Id': oPackage.id
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sName
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.domain = function (fCallback, sName)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminDomainLoad', {
|
||||||
|
'Name': sName
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sName
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.plugin = function (fCallback, sName)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminPluginLoad', {
|
||||||
|
'Name': sName
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sName
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.domainDelete = function (fCallback, sName)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminDomainDelete', {
|
||||||
|
'Name': sName
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sName
|
||||||
|
* @param {boolean} bDisabled
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.domainDisable = function (fCallback, sName, bDisabled)
|
||||||
|
{
|
||||||
|
return this.defaultRequest(fCallback, 'AdminDomainDisable', {
|
||||||
|
'Name': sName,
|
||||||
|
'Disabled': !!bDisabled ? '1' : '0'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {Object} oConfig
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.pluginSettingsUpdate = function (fCallback, oConfig)
|
||||||
|
{
|
||||||
|
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {boolean} bForce
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.licensing = function (fCallback, bForce)
|
||||||
|
{
|
||||||
|
return this.defaultRequest(fCallback, 'AdminLicensing', {
|
||||||
|
'Force' : bForce ? '1' : '0'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sDomain
|
||||||
|
* @param {string} sKey
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.licensingActivate = function (fCallback, sDomain, sKey)
|
||||||
|
{
|
||||||
|
return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
|
||||||
|
'Domain' : sDomain,
|
||||||
|
'Key' : sKey
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {string} sName
|
||||||
|
* @param {boolean} bDisabled
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.pluginDisable = function (fCallback, sName, bDisabled)
|
||||||
|
{
|
||||||
|
return this.defaultRequest(fCallback, 'AdminPluginDisable', {
|
||||||
|
'Name': sName,
|
||||||
|
'Disabled': !!bDisabled ? '1' : '0'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
AdminAjaxRemoteStorage.prototype.createOrUpdateDomain = function (fCallback,
|
||||||
|
bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
||||||
|
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, sWhiteList)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminDomainSave', {
|
||||||
|
'Create': bCreate ? '1' : '0',
|
||||||
|
'Name': sName,
|
||||||
|
'IncHost': sIncHost,
|
||||||
|
'IncPort': iIncPort,
|
||||||
|
'IncSecure': sIncSecure,
|
||||||
|
'IncShortLogin': bIncShortLogin ? '1' : '0',
|
||||||
|
'OutHost': sOutHost,
|
||||||
|
'OutPort': iOutPort,
|
||||||
|
'OutSecure': sOutSecure,
|
||||||
|
'OutShortLogin': bOutShortLogin ? '1' : '0',
|
||||||
|
'OutAuth': bOutAuth ? '1' : '0',
|
||||||
|
'WhiteList': sWhiteList
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
AdminAjaxRemoteStorage.prototype.testConnectionForDomain = function (fCallback, sName,
|
||||||
|
sIncHost, iIncPort, sIncSecure,
|
||||||
|
sOutHost, iOutPort, sOutSecure, bOutAuth)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminDomainTest', {
|
||||||
|
'Name': sName,
|
||||||
|
'IncHost': sIncHost,
|
||||||
|
'IncPort': iIncPort,
|
||||||
|
'IncSecure': sIncSecure,
|
||||||
|
'OutHost': sOutHost,
|
||||||
|
'OutPort': iOutPort,
|
||||||
|
'OutSecure': sOutSecure,
|
||||||
|
'OutAuth': bOutAuth ? '1' : '0'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {?} oData
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.testContacts = function (fCallback, oData)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminContactsTest', oData);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
* @param {?} oData
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.saveNewAdminPassword = function (fCallback, oData)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {?Function} fCallback
|
||||||
|
*/
|
||||||
|
AdminAjaxRemoteStorage.prototype.adminPing = function (fCallback)
|
||||||
|
{
|
||||||
|
this.defaultRequest(fCallback, 'AdminPing');
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AdminAjaxRemoteStorage;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends AbstractCacheStorage
|
|
||||||
*/
|
|
||||||
function AdminCacheStorage()
|
|
||||||
{
|
|
||||||
AbstractCacheStorage.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AdminCacheStorage.prototype, AbstractCacheStorage.prototype);
|
|
||||||
25
dev/Storages/AdminCacheStorage.js
Normal file
25
dev/Storages/AdminCacheStorage.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
_ = require('./External/underscore.js'),
|
||||||
|
AbstractCacheStorage = require('./Storages/AbstractCacheStorage.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends AbstractCacheStorage
|
||||||
|
*/
|
||||||
|
function AdminCacheStorage()
|
||||||
|
{
|
||||||
|
AbstractCacheStorage.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
_.extend(AdminCacheStorage.prototype, AbstractCacheStorage.prototype);
|
||||||
|
|
||||||
|
module.exports = AdminCacheStorage;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends AbstractData
|
|
||||||
*/
|
|
||||||
function AdminDataStorage()
|
|
||||||
{
|
|
||||||
AbstractData.call(this);
|
|
||||||
|
|
||||||
this.domainsLoading = ko.observable(false).extend({'throttle': 100});
|
|
||||||
this.domains = ko.observableArray([]);
|
|
||||||
|
|
||||||
this.pluginsLoading = ko.observable(false).extend({'throttle': 100});
|
|
||||||
this.plugins = ko.observableArray([]);
|
|
||||||
|
|
||||||
this.packagesReal = ko.observable(true);
|
|
||||||
this.packagesMainUpdatable = ko.observable(true);
|
|
||||||
this.packagesLoading = ko.observable(false).extend({'throttle': 100});
|
|
||||||
this.packages = ko.observableArray([]);
|
|
||||||
|
|
||||||
this.coreReal = ko.observable(true);
|
|
||||||
this.coreUpdatable = ko.observable(true);
|
|
||||||
this.coreAccess = ko.observable(true);
|
|
||||||
this.coreChecking = ko.observable(false).extend({'throttle': 100});
|
|
||||||
this.coreUpdating = ko.observable(false).extend({'throttle': 100});
|
|
||||||
this.coreRemoteVersion = ko.observable('');
|
|
||||||
this.coreRemoteRelease = ko.observable('');
|
|
||||||
this.coreVersionCompare = ko.observable(-2);
|
|
||||||
|
|
||||||
this.licensing = ko.observable(false);
|
|
||||||
this.licensingProcess = ko.observable(false);
|
|
||||||
this.licenseValid = ko.observable(false);
|
|
||||||
this.licenseExpired = ko.observable(0);
|
|
||||||
this.licenseError = ko.observable('');
|
|
||||||
|
|
||||||
this.licenseTrigger = ko.observable(false);
|
|
||||||
|
|
||||||
this.adminManLoading = ko.computed(function () {
|
|
||||||
return '000' !== [this.domainsLoading() ? '1' : '0', this.pluginsLoading() ? '1' : '0', this.packagesLoading() ? '1' : '0'].join('');
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.adminManLoadingVisibility = ko.computed(function () {
|
|
||||||
return this.adminManLoading() ? 'visible' : 'hidden';
|
|
||||||
}, this).extend({'rateLimit': 300});
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(AdminDataStorage.prototype, AbstractData.prototype);
|
|
||||||
|
|
||||||
AdminDataStorage.prototype.populateDataOnStart = function()
|
|
||||||
{
|
|
||||||
AbstractData.prototype.populateDataOnStart.call(this);
|
|
||||||
};
|
|
||||||
67
dev/Storages/AdminDataStorage.js
Normal file
67
dev/Storages/AdminDataStorage.js
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
|
(function (module) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
_ = require('./External/underscore.js'),
|
||||||
|
ko = require('./External/ko.js'),
|
||||||
|
AbstractData = require('./Storages/AbstractData.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends AbstractData
|
||||||
|
*/
|
||||||
|
function AdminDataStorage()
|
||||||
|
{
|
||||||
|
AbstractData.call(this);
|
||||||
|
|
||||||
|
this.domainsLoading = ko.observable(false).extend({'throttle': 100});
|
||||||
|
this.domains = ko.observableArray([]);
|
||||||
|
|
||||||
|
this.pluginsLoading = ko.observable(false).extend({'throttle': 100});
|
||||||
|
this.plugins = ko.observableArray([]);
|
||||||
|
|
||||||
|
this.packagesReal = ko.observable(true);
|
||||||
|
this.packagesMainUpdatable = ko.observable(true);
|
||||||
|
this.packagesLoading = ko.observable(false).extend({'throttle': 100});
|
||||||
|
this.packages = ko.observableArray([]);
|
||||||
|
|
||||||
|
this.coreReal = ko.observable(true);
|
||||||
|
this.coreUpdatable = ko.observable(true);
|
||||||
|
this.coreAccess = ko.observable(true);
|
||||||
|
this.coreChecking = ko.observable(false).extend({'throttle': 100});
|
||||||
|
this.coreUpdating = ko.observable(false).extend({'throttle': 100});
|
||||||
|
this.coreRemoteVersion = ko.observable('');
|
||||||
|
this.coreRemoteRelease = ko.observable('');
|
||||||
|
this.coreVersionCompare = ko.observable(-2);
|
||||||
|
|
||||||
|
this.licensing = ko.observable(false);
|
||||||
|
this.licensingProcess = ko.observable(false);
|
||||||
|
this.licenseValid = ko.observable(false);
|
||||||
|
this.licenseExpired = ko.observable(0);
|
||||||
|
this.licenseError = ko.observable('');
|
||||||
|
|
||||||
|
this.licenseTrigger = ko.observable(false);
|
||||||
|
|
||||||
|
this.adminManLoading = ko.computed(function () {
|
||||||
|
return '000' !== [this.domainsLoading() ? '1' : '0', this.pluginsLoading() ? '1' : '0', this.packagesLoading() ? '1' : '0'].join('');
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.adminManLoadingVisibility = ko.computed(function () {
|
||||||
|
return this.adminManLoading() ? 'visible' : 'hidden';
|
||||||
|
}, this).extend({'rateLimit': 300});
|
||||||
|
}
|
||||||
|
|
||||||
|
_.extend(AdminDataStorage.prototype, AbstractData.prototype);
|
||||||
|
|
||||||
|
AdminDataStorage.prototype.populateDataOnStart = function()
|
||||||
|
{
|
||||||
|
AbstractData.prototype.populateDataOnStart.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = AdminDataStorage;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,44 +1,54 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
'use strict';
|
||||||
function LocalStorage()
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
sStorages = [
|
_ = require('./External/underscore.js'),
|
||||||
LocalStorageDriver,
|
CookieDriver = require('./Storages/LocalStorages/CookieDriver.js'),
|
||||||
CookieDriver
|
LocalStorageDriver = require('./Storages/LocalStorages/LocalStorageDriver.js')
|
||||||
],
|
|
||||||
NextStorageDriver = _.find(sStorages, function (NextStorageDriver) {
|
|
||||||
return NextStorageDriver.supported();
|
|
||||||
})
|
|
||||||
;
|
;
|
||||||
|
|
||||||
if (NextStorageDriver)
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function LocalStorage()
|
||||||
{
|
{
|
||||||
NextStorageDriver = /** @type {?Function} */ NextStorageDriver;
|
var
|
||||||
this.oDriver = new NextStorageDriver();
|
NextStorageDriver = _.find([LocalStorageDriver, CookieDriver], function (NextStorageDriver) {
|
||||||
|
return NextStorageDriver.supported();
|
||||||
|
})
|
||||||
|
;
|
||||||
|
|
||||||
|
if (NextStorageDriver)
|
||||||
|
{
|
||||||
|
NextStorageDriver = /** @type {?Function} */ NextStorageDriver;
|
||||||
|
this.oDriver = new NextStorageDriver();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
LocalStorage.prototype.oDriver = null;
|
LocalStorage.prototype.oDriver = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} iKey
|
* @param {number} iKey
|
||||||
* @param {*} mData
|
* @param {*} mData
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
LocalStorage.prototype.set = function (iKey, mData)
|
LocalStorage.prototype.set = function (iKey, mData)
|
||||||
{
|
{
|
||||||
return this.oDriver ? this.oDriver.set('p' + iKey, mData) : false;
|
return this.oDriver ? this.oDriver.set('p' + iKey, mData) : false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} iKey
|
* @param {number} iKey
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
LocalStorage.prototype.get = function (iKey)
|
LocalStorage.prototype.get = function (iKey)
|
||||||
{
|
{
|
||||||
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
|
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports = LocalStorage;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,75 +1,90 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function CookieDriver()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
'use strict';
|
||||||
|
|
||||||
CookieDriver.supported = function ()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sKey
|
|
||||||
* @param {*} mData
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
CookieDriver.prototype.set = function (sKey, mData)
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
mCokieValue = $.cookie(Consts.Values.ClientSideCookieIndexName),
|
$ = require('./External/jquery.js'),
|
||||||
bResult = false,
|
JSON = require('./External/JSON.js'),
|
||||||
mResult = null
|
Consts = require('./Common/Consts.js'),
|
||||||
|
Utils = require('./Common/Utils.js')
|
||||||
;
|
;
|
||||||
|
|
||||||
try
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function CookieDriver()
|
||||||
{
|
{
|
||||||
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
|
|
||||||
if (!mResult)
|
|
||||||
{
|
|
||||||
mResult = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
mResult[sKey] = mData;
|
|
||||||
$.cookie(Consts.Values.ClientSideCookieIndexName, JSON.stringify(mResult), {
|
|
||||||
'expires': 30
|
|
||||||
});
|
|
||||||
|
|
||||||
bResult = true;
|
|
||||||
}
|
}
|
||||||
catch (oException) {}
|
|
||||||
|
|
||||||
return bResult;
|
CookieDriver.supported = function ()
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sKey
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
CookieDriver.prototype.get = function (sKey)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
mCokieValue = $.cookie(Consts.Values.ClientSideCookieIndexName),
|
|
||||||
mResult = null
|
|
||||||
;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
|
return true;
|
||||||
if (mResult && !Utils.isUnd(mResult[sKey]))
|
};
|
||||||
{
|
|
||||||
mResult = mResult[sKey];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mResult = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (oException) {}
|
|
||||||
|
|
||||||
return mResult;
|
/**
|
||||||
};
|
* @param {string} sKey
|
||||||
|
* @param {*} mData
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
CookieDriver.prototype.set = function (sKey, mData)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
mCokieValue = $.cookie(Consts.Values.ClientSideCookieIndexName),
|
||||||
|
bResult = false,
|
||||||
|
mResult = null
|
||||||
|
;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
|
||||||
|
if (!mResult)
|
||||||
|
{
|
||||||
|
mResult = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
mResult[sKey] = mData;
|
||||||
|
$.cookie(Consts.Values.ClientSideCookieIndexName, JSON.stringify(mResult), {
|
||||||
|
'expires': 30
|
||||||
|
});
|
||||||
|
|
||||||
|
bResult = true;
|
||||||
|
}
|
||||||
|
catch (oException) {}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sKey
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
CookieDriver.prototype.get = function (sKey)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
mCokieValue = $.cookie(Consts.Values.ClientSideCookieIndexName),
|
||||||
|
mResult = null
|
||||||
|
;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
|
||||||
|
if (mResult && !Utils.isUnd(mResult[sKey]))
|
||||||
|
{
|
||||||
|
mResult = mResult[sKey];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mResult = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (oException) {}
|
||||||
|
|
||||||
|
return mResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = CookieDriver;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,72 +1,87 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function LocalStorageDriver()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalStorageDriver.supported = function ()
|
'use strict';
|
||||||
{
|
|
||||||
return !!window.localStorage;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sKey
|
|
||||||
* @param {*} mData
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
LocalStorageDriver.prototype.set = function (sKey, mData)
|
|
||||||
{
|
|
||||||
var
|
var
|
||||||
mCookieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
|
window = require('./External/window.js'),
|
||||||
bResult = false,
|
JSON = require('./External/JSON.js'),
|
||||||
mResult = null
|
Consts = require('./Common/Consts.js'),
|
||||||
|
Utils = require('./Common/Utils.js')
|
||||||
;
|
;
|
||||||
|
|
||||||
try
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function LocalStorageDriver()
|
||||||
{
|
{
|
||||||
mResult = null === mCookieValue ? null : JSON.parse(mCookieValue);
|
|
||||||
if (!mResult)
|
|
||||||
{
|
|
||||||
mResult = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
mResult[sKey] = mData;
|
|
||||||
window.localStorage[Consts.Values.ClientSideCookieIndexName] = JSON.stringify(mResult);
|
|
||||||
|
|
||||||
bResult = true;
|
|
||||||
}
|
}
|
||||||
catch (oException) {}
|
|
||||||
|
|
||||||
return bResult;
|
LocalStorageDriver.supported = function ()
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} sKey
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
LocalStorageDriver.prototype.get = function (sKey)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
mCokieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
|
|
||||||
mResult = null
|
|
||||||
;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
|
return !!window.localStorage;
|
||||||
if (mResult && !Utils.isUnd(mResult[sKey]))
|
};
|
||||||
{
|
|
||||||
mResult = mResult[sKey];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mResult = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (oException) {}
|
|
||||||
|
|
||||||
return mResult;
|
/**
|
||||||
};
|
* @param {string} sKey
|
||||||
|
* @param {*} mData
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
LocalStorageDriver.prototype.set = function (sKey, mData)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
mCookieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
|
||||||
|
bResult = false,
|
||||||
|
mResult = null
|
||||||
|
;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mResult = null === mCookieValue ? null : JSON.parse(mCookieValue);
|
||||||
|
if (!mResult)
|
||||||
|
{
|
||||||
|
mResult = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
mResult[sKey] = mData;
|
||||||
|
window.localStorage[Consts.Values.ClientSideCookieIndexName] = JSON.stringify(mResult);
|
||||||
|
|
||||||
|
bResult = true;
|
||||||
|
}
|
||||||
|
catch (oException) {}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} sKey
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
LocalStorageDriver.prototype.get = function (sKey)
|
||||||
|
{
|
||||||
|
var
|
||||||
|
mCokieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
|
||||||
|
mResult = null
|
||||||
|
;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
|
||||||
|
if (mResult && !Utils.isUnd(mResult[sKey]))
|
||||||
|
{
|
||||||
|
mResult = mResult[sKey];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mResult = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (oException) {}
|
||||||
|
|
||||||
|
return mResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = LocalStorageDriver;
|
||||||
|
|
||||||
|
}(module));
|
||||||
File diff suppressed because it is too large
Load diff
1287
dev/Storages/WebMailDataStorage.js
Normal file
1287
dev/Storages/WebMailDataStorage.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -320,7 +320,7 @@ LoginViewModel.prototype.onBuild = function ()
|
||||||
'cache': true
|
'cache': true
|
||||||
}).done(function() {
|
}).done(function() {
|
||||||
self.bSendLanguage = true;
|
self.bSendLanguage = true;
|
||||||
Utils.i18nToDoc();
|
Utils.i18nReload();
|
||||||
$.cookie('rllang', RL.data().language(), {'expires': 30});
|
$.cookie('rllang', RL.data().language(), {'expires': 30});
|
||||||
}).always(function() {
|
}).always(function() {
|
||||||
self.langRequest(false);
|
self.langRequest(false);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,13 +1,27 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends AbstractSystemDropDownViewModel
|
|
||||||
*/
|
|
||||||
function MailBoxSystemDropDownViewModel()
|
|
||||||
{
|
|
||||||
AbstractSystemDropDownViewModel.call(this);
|
|
||||||
Knoin.constructorEnd(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel);
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
kn = require('../Knoin/Knoin.js'),
|
||||||
|
AbstractSystemDropDownViewModel = require('./AbstractSystemDropDownViewModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends AbstractSystemDropDownViewModel
|
||||||
|
*/
|
||||||
|
function MailBoxSystemDropDownViewModel()
|
||||||
|
{
|
||||||
|
AbstractSystemDropDownViewModel.call(this);
|
||||||
|
kn.constructorEnd(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel);
|
||||||
|
|
||||||
|
module.exports = MailBoxSystemDropDownViewModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,44 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @param {?} oScreen
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
* @extends KnoinAbstractViewModel
|
|
||||||
*/
|
|
||||||
function SettingsMenuViewModel(oScreen)
|
|
||||||
{
|
|
||||||
KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu');
|
|
||||||
|
|
||||||
this.leftPanelDisabled = RL.data().leftPanelDisabled;
|
'use strict';
|
||||||
|
|
||||||
this.menu = oScreen.menu;
|
var
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
kn = require('../Knoin/Knoin.js'),
|
||||||
|
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
Knoin.constructorEnd(this);
|
/**
|
||||||
}
|
* @param {?} oScreen
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
* @extends KnoinAbstractViewModel
|
||||||
|
*/
|
||||||
|
function SettingsMenuViewModel(oScreen)
|
||||||
|
{
|
||||||
|
KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu');
|
||||||
|
|
||||||
Utils.extendAsViewModel('SettingsMenuViewModel', SettingsMenuViewModel);
|
this.leftPanelDisabled = RL.data().leftPanelDisabled; // TODO cjs
|
||||||
|
|
||||||
SettingsMenuViewModel.prototype.link = function (sRoute)
|
this.menu = oScreen.menu;
|
||||||
{
|
|
||||||
return RL.link().settings(sRoute);
|
|
||||||
};
|
|
||||||
|
|
||||||
SettingsMenuViewModel.prototype.backToMailBoxClick = function ()
|
kn.constructorEnd(this);
|
||||||
{
|
}
|
||||||
kn.setHash(RL.link().inbox());
|
|
||||||
};
|
Utils.extendAsViewModel('SettingsMenuViewModel', SettingsMenuViewModel);
|
||||||
|
|
||||||
|
SettingsMenuViewModel.prototype.link = function (sRoute)
|
||||||
|
{
|
||||||
|
return RL.link().settings(sRoute);// TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
SettingsMenuViewModel.prototype.backToMailBoxClick = function ()
|
||||||
|
{
|
||||||
|
kn.setHash(RL.link().inbox()); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = SettingsMenuViewModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,32 +1,48 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends KnoinAbstractViewModel
|
|
||||||
*/
|
|
||||||
function SettingsPaneViewModel()
|
|
||||||
{
|
|
||||||
KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane');
|
|
||||||
|
|
||||||
Knoin.constructorEnd(this);
|
'use strict';
|
||||||
}
|
|
||||||
|
|
||||||
Utils.extendAsViewModel('SettingsPaneViewModel', SettingsPaneViewModel);
|
var
|
||||||
|
key = require('../External/key.js'),
|
||||||
|
Enums = require('../Common/Enums.js'),
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
kn = require('../Knoin/Knoin.js'),
|
||||||
|
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
SettingsPaneViewModel.prototype.onBuild = function ()
|
/**
|
||||||
{
|
* @constructor
|
||||||
var self = this;
|
* @extends KnoinAbstractViewModel
|
||||||
key('esc', Enums.KeyState.Settings, function () {
|
*/
|
||||||
self.backToMailBoxClick();
|
function SettingsPaneViewModel()
|
||||||
});
|
{
|
||||||
};
|
KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane');
|
||||||
|
|
||||||
SettingsPaneViewModel.prototype.onShow = function ()
|
kn.constructorEnd(this);
|
||||||
{
|
}
|
||||||
RL.data().message(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
SettingsPaneViewModel.prototype.backToMailBoxClick = function ()
|
Utils.extendAsViewModel('SettingsPaneViewModel', SettingsPaneViewModel);
|
||||||
{
|
|
||||||
kn.setHash(RL.link().inbox());
|
SettingsPaneViewModel.prototype.onBuild = function ()
|
||||||
};
|
{
|
||||||
|
var self = this;
|
||||||
|
key('esc', Enums.KeyState.Settings, function () {
|
||||||
|
self.backToMailBoxClick();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
SettingsPaneViewModel.prototype.onShow = function ()
|
||||||
|
{
|
||||||
|
RL.data().message(null); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
SettingsPaneViewModel.prototype.backToMailBoxClick = function ()
|
||||||
|
{
|
||||||
|
kn.setHash(RL.link().inbox()); // TODO cjs
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = SettingsPaneViewModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
|
|
@ -1,13 +1,27 @@
|
||||||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||||
|
|
||||||
/**
|
(function (module) {
|
||||||
* @constructor
|
|
||||||
* @extends AbstractSystemDropDownViewModel
|
|
||||||
*/
|
|
||||||
function SettingsSystemDropDownViewModel()
|
|
||||||
{
|
|
||||||
AbstractSystemDropDownViewModel.call(this);
|
|
||||||
Knoin.constructorEnd(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils.extendAsViewModel('SettingsSystemDropDownViewModel', SettingsSystemDropDownViewModel, AbstractSystemDropDownViewModel);
|
'use strict';
|
||||||
|
|
||||||
|
var
|
||||||
|
Utils = require('../Common/Utils.js'),
|
||||||
|
kn = require('./Knoin/Knoin.js'),
|
||||||
|
AbstractSystemDropDownViewModel = require('./AbstractSystemDropDownViewModel.js')
|
||||||
|
;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @extends AbstractSystemDropDownViewModel
|
||||||
|
*/
|
||||||
|
function SettingsSystemDropDownViewModel()
|
||||||
|
{
|
||||||
|
AbstractSystemDropDownViewModel.call(this);
|
||||||
|
kn.constructorEnd(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.extendAsViewModel('SettingsSystemDropDownViewModel', SettingsSystemDropDownViewModel, AbstractSystemDropDownViewModel);
|
||||||
|
|
||||||
|
module.exports = SettingsSystemDropDownViewModel;
|
||||||
|
|
||||||
|
}(module));
|
||||||
17
gulpfile.js
17
gulpfile.js
|
|
@ -607,4 +607,19 @@ gulp.task('build+', ['rainloop+']);
|
||||||
gulp.task('b', ['rainloop']);
|
gulp.task('b', ['rainloop']);
|
||||||
gulp.task('b+', ['rainloop+']);
|
gulp.task('b+', ['rainloop+']);
|
||||||
|
|
||||||
gulp.task('own', ['owncloud']);
|
gulp.task('own', ['owncloud']);
|
||||||
|
|
||||||
|
var browserify = require('browserify');
|
||||||
|
var source = require('vinyl-source-stream');
|
||||||
|
|
||||||
|
gulp.task('bro', function() {
|
||||||
|
return browserify({
|
||||||
|
'basedir': './dev/',
|
||||||
|
'detectGlobals': false,
|
||||||
|
'debug': false
|
||||||
|
})
|
||||||
|
.add('./RainLoopBoot.js')
|
||||||
|
.bundle()
|
||||||
|
.pipe(source('bro.js'))
|
||||||
|
.pipe(gulp.dest(cfg.paths.staticJS));
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@
|
||||||
"node-fs": "*",
|
"node-fs": "*",
|
||||||
"jshint-summary": "*",
|
"jshint-summary": "*",
|
||||||
|
|
||||||
|
"browserify": "*",
|
||||||
|
"vinyl-source-stream": "latest",
|
||||||
|
|
||||||
"gulp": "*",
|
"gulp": "*",
|
||||||
"gulp-util": "*",
|
"gulp-util": "*",
|
||||||
"gulp-uglify": "*",
|
"gulp-uglify": "*",
|
||||||
|
|
|
||||||
6484
rainloop/v/0.0.0/static/js/bro.js
Normal file
6484
rainloop/v/0.0.0/static/js/bro.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue