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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractBoot
|
||||
*/
|
||||
function AbstractApp()
|
||||
{
|
||||
KnoinAbstractBoot.call(this);
|
||||
(function (module) {
|
||||
|
||||
this.oSettings = null;
|
||||
this.oPlugins = null;
|
||||
this.oLocal = null;
|
||||
this.oLink = null;
|
||||
this.oSubs = {};
|
||||
'use strict';
|
||||
|
||||
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
|
||||
oLink = null,
|
||||
oE = null,
|
||||
sUserAgent = navigator.userAgent.toLowerCase()
|
||||
$ = require('../External/jquery.js'),
|
||||
_ = require('../External/underscore.js'),
|
||||
ko = require('../External/ko.js'),
|
||||
window = require('../External/window.js'),
|
||||
$html = require('../External/$html.js'),
|
||||
$window = require('../External/$window.js'),
|
||||
$doc = require('../External/$doc.js'),
|
||||
AppData = require('../External/AppData.js'),
|
||||
Globals = require('../Common/Globals.js'),
|
||||
Utils = require('../Common/Utils.js'),
|
||||
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');
|
||||
oLink['href'] = sLink;
|
||||
KnoinAbstractBoot.call(this);
|
||||
|
||||
if (document['createEvent'])
|
||||
{
|
||||
oE = document['createEvent']('MouseEvents');
|
||||
if (oE && oE['initEvent'] && oLink['dispatchEvent'])
|
||||
this.oSettings = null;
|
||||
this.oPlugins = null;
|
||||
this.oLocal = null;
|
||||
this.oLink = null;
|
||||
this.oSubs = {};
|
||||
|
||||
this.isLocalAutocomplete = true;
|
||||
|
||||
this.popupVisibilityNames = ko.observableArray([]);
|
||||
|
||||
this.popupVisibility = ko.computed(function () {
|
||||
return 0 < this.popupVisibilityNames().length;
|
||||
}, this);
|
||||
|
||||
this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');
|
||||
|
||||
$window.on('error', function (oEvent) {
|
||||
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);
|
||||
oLink['dispatchEvent'](oE);
|
||||
return true;
|
||||
// TODO cjs
|
||||
RL.remote().jsError(
|
||||
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)
|
||||
{
|
||||
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)
|
||||
$doc.on('keydown', function (oEvent) {
|
||||
if (oEvent && oEvent.ctrlKey)
|
||||
{
|
||||
window.parent.location.href = sCustomLogoutLink;
|
||||
$html.addClass('rl-ctrl-key-pressed');
|
||||
}
|
||||
else
|
||||
}).on('keyup', function (oEvent) {
|
||||
if (oEvent && !oEvent.ctrlKey)
|
||||
{
|
||||
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 || []);
|
||||
$html.removeClass('rl-ctrl-key-pressed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
_.extend(AbstractApp.prototype, KnoinAbstractBoot.prototype);
|
||||
|
||||
/**
|
||||
* @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.oSettings = null;
|
||||
AbstractApp.prototype.oPlugins = null;
|
||||
AbstractApp.prototype.oLocal = null;
|
||||
AbstractApp.prototype.oLink = null;
|
||||
AbstractApp.prototype.oSubs = {};
|
||||
|
||||
AbstractApp.prototype.bootstart = function ()
|
||||
{
|
||||
var self = this;
|
||||
/**
|
||||
* @param {string} sLink
|
||||
* @return {boolean}
|
||||
*/
|
||||
AbstractApp.prototype.download = function (sLink)
|
||||
{
|
||||
var
|
||||
oE = null,
|
||||
oLink = null,
|
||||
sUserAgent = window.navigator.userAgent.toLowerCase()
|
||||
;
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
Utils.initNotificationLanguage();
|
||||
}, null);
|
||||
if (sUserAgent && (sUserAgent.indexOf('chrome') > -1 || sUserAgent.indexOf('chrome') > -1))
|
||||
{
|
||||
oLink = window.document.createElement('a');
|
||||
oLink['href'] = sLink;
|
||||
|
||||
_.delay(function () {
|
||||
Utils.windowResize();
|
||||
}, 1000);
|
||||
|
||||
ssm.addState({
|
||||
'id': 'mobile',
|
||||
'maxWidth': 767,
|
||||
'onEnter': function() {
|
||||
$html.addClass('ssm-state-mobile');
|
||||
self.pub('ssm.mobile-enter');
|
||||
},
|
||||
'onLeave': function() {
|
||||
$html.removeClass('ssm-state-mobile');
|
||||
self.pub('ssm.mobile-leave');
|
||||
if (window.document['createEvent'])
|
||||
{
|
||||
oE = window.document['createEvent']('MouseEvents');
|
||||
if (oE && oE['initEvent'] && oLink['dispatchEvent'])
|
||||
{
|
||||
oE['initEvent']('click', true, true);
|
||||
oLink['dispatchEvent'](oE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ssm.addState({
|
||||
'id': 'tablet',
|
||||
'minWidth': 768,
|
||||
'maxWidth': 999,
|
||||
'onEnter': function() {
|
||||
$html.addClass('ssm-state-tablet');
|
||||
},
|
||||
'onLeave': function() {
|
||||
$html.removeClass('ssm-state-tablet');
|
||||
if (Globals.bMobileDevice)
|
||||
{
|
||||
window.open(sLink, '_self');
|
||||
window.focus();
|
||||
}
|
||||
});
|
||||
|
||||
ssm.addState({
|
||||
'id': 'desktop',
|
||||
'minWidth': 1000,
|
||||
'maxWidth': 1400,
|
||||
'onEnter': function() {
|
||||
$html.addClass('ssm-state-desktop');
|
||||
},
|
||||
'onLeave': function() {
|
||||
$html.removeClass('ssm-state-desktop');
|
||||
else
|
||||
{
|
||||
this.iframe.attr('src', sLink);
|
||||
// window.document.location.href = sLink;
|
||||
}
|
||||
});
|
||||
|
||||
ssm.addState({
|
||||
'id': 'desktop-large',
|
||||
'minWidth': 1400,
|
||||
'onEnter': function() {
|
||||
$html.addClass('ssm-state-desktop-large');
|
||||
},
|
||||
'onLeave': function() {
|
||||
$html.removeClass('ssm-state-desktop-large');
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {LinkBuilder}
|
||||
*/
|
||||
AbstractApp.prototype.link = function ()
|
||||
{
|
||||
if (null === this.oLink)
|
||||
{
|
||||
this.oLink = new LinkBuilder(); // TODO cjs
|
||||
}
|
||||
});
|
||||
|
||||
RL.sub('ssm.mobile-enter', function () {
|
||||
RL.data().leftPanelDisabled(true);
|
||||
});
|
||||
return this.oLink;
|
||||
};
|
||||
|
||||
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) {
|
||||
$html.toggleClass('rl-left-panel-disabled', bValue);
|
||||
});
|
||||
return this.oLocal;
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractApp
|
||||
*/
|
||||
function AdminApp()
|
||||
{
|
||||
AbstractApp.call(this);
|
||||
(function (module) {
|
||||
|
||||
this.oData = null;
|
||||
this.oRemote = null;
|
||||
this.oCache = null;
|
||||
}
|
||||
'use strict';
|
||||
|
||||
_.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;
|
||||
AdminApp.prototype.oCache = null;
|
||||
|
||||
/**
|
||||
* @return {AdminDataStorage}
|
||||
*/
|
||||
AdminApp.prototype.data = function ()
|
||||
{
|
||||
if (null === this.oData)
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractApp
|
||||
*/
|
||||
function AdminApp()
|
||||
{
|
||||
this.oData = new AdminDataStorage();
|
||||
AbstractApp.call(this);
|
||||
|
||||
this.oData = null;
|
||||
this.oRemote = null;
|
||||
this.oCache = null;
|
||||
}
|
||||
|
||||
return this.oData;
|
||||
};
|
||||
_.extend(AdminApp.prototype, AbstractApp.prototype);
|
||||
|
||||
/**
|
||||
* @return {AdminAjaxRemoteStorage}
|
||||
*/
|
||||
AdminApp.prototype.remote = function ()
|
||||
{
|
||||
if (null === this.oRemote)
|
||||
AdminApp.prototype.oData = null;
|
||||
AdminApp.prototype.oRemote = null;
|
||||
AdminApp.prototype.oCache = null;
|
||||
|
||||
/**
|
||||
* @return {AdminDataStorage}
|
||||
*/
|
||||
AdminApp.prototype.data = function ()
|
||||
{
|
||||
this.oRemote = new AdminAjaxRemoteStorage();
|
||||
}
|
||||
|
||||
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)
|
||||
if (null === this.oData)
|
||||
{
|
||||
var aList = _.map(oData.Result, function (bEnabled, sName) {
|
||||
return {
|
||||
'name': sName,
|
||||
'disabled': ko.observable(!bEnabled),
|
||||
'deleteAccess': ko.observable(false)
|
||||
};
|
||||
}, this);
|
||||
|
||||
RL.data().domains(aList);
|
||||
this.oData = new AdminDataStorage(); // TODO cjs
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadPluginList = function ()
|
||||
{
|
||||
RL.data().pluginsLoading(true);
|
||||
RL.remote().pluginList(function (sResult, oData) {
|
||||
RL.data().pluginsLoading(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
return this.oData;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {AdminAjaxRemoteStorage}
|
||||
*/
|
||||
AdminApp.prototype.remote = function ()
|
||||
{
|
||||
if (null === this.oRemote)
|
||||
{
|
||||
var aList = _.map(oData.Result, function (oItem) {
|
||||
return {
|
||||
'name': oItem['Name'],
|
||||
'disabled': ko.observable(!oItem['Enabled']),
|
||||
'configured': ko.observable(!!oItem['Configured'])
|
||||
};
|
||||
}, this);
|
||||
|
||||
RL.data().plugins(aList);
|
||||
this.oRemote = new AdminAjaxRemoteStorage(); // TODO cjs
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadPackagesList = function ()
|
||||
{
|
||||
RL.data().packagesLoading(true);
|
||||
RL.data().packagesReal(true);
|
||||
return this.oRemote;
|
||||
};
|
||||
|
||||
RL.remote().packagesList(function (sResult, oData) {
|
||||
|
||||
RL.data().packagesLoading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
/**
|
||||
* @return {AdminCacheStorage}
|
||||
*/
|
||||
AdminApp.prototype.cache = function ()
|
||||
{
|
||||
if (null === this.oCache)
|
||||
{
|
||||
RL.data().packagesReal(!!oData.Result.Real);
|
||||
RL.data().packagesMainUpdatable(!!oData.Result.MainUpdatable);
|
||||
this.oCache = new AdminCacheStorage(); // TODO cjs
|
||||
}
|
||||
|
||||
var
|
||||
aList = [],
|
||||
aLoading = {}
|
||||
;
|
||||
return this.oCache;
|
||||
};
|
||||
|
||||
_.each(RL.data().packages(), function (oItem) {
|
||||
if (oItem && oItem['loading']())
|
||||
{
|
||||
aLoading[oItem['file']] = oItem;
|
||||
}
|
||||
});
|
||||
|
||||
if (Utils.isArray(oData.Result.List))
|
||||
AdminApp.prototype.reloadDomainList = function ()
|
||||
{
|
||||
// TODO cjs
|
||||
RL.data().domainsLoading(true);
|
||||
RL.remote().domainList(function (sResult, oData) {
|
||||
RL.data().domainsLoading(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
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;
|
||||
}));
|
||||
var aList = _.map(oData.Result, function (bEnabled, sName) {
|
||||
return {
|
||||
'name': sName,
|
||||
'disabled': ko.observable(!bEnabled),
|
||||
'deleteAccess': ko.observable(false)
|
||||
};
|
||||
}, this);
|
||||
|
||||
RL.data().domains(aList);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
RL.data().packages(aList);
|
||||
}
|
||||
else
|
||||
{
|
||||
RL.data().packagesReal(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
AdminApp.prototype.reloadPluginList = function ()
|
||||
{
|
||||
// TODO cjs
|
||||
RL.data().pluginsLoading(true);
|
||||
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 ()
|
||||
{
|
||||
var oRainData = RL.data();
|
||||
RL.data().plugins(aList);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
oRainData.coreUpdating(true);
|
||||
RL.remote().updateCoreData(function (sResult, oData) {
|
||||
AdminApp.prototype.reloadPackagesList = function ()
|
||||
{
|
||||
// TODO cjs
|
||||
RL.data().packagesLoading(true);
|
||||
RL.data().packagesReal(true);
|
||||
|
||||
oRainData.coreUpdating(false);
|
||||
oRainData.coreRemoteVersion('');
|
||||
oRainData.coreRemoteRelease('');
|
||||
oRainData.coreVersionCompare(-2);
|
||||
RL.remote().packagesList(function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
oRainData.coreReal(true);
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
oRainData.coreReal(false);
|
||||
}
|
||||
});
|
||||
RL.data().packagesLoading(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 oRainData = RL.data();
|
||||
var
|
||||
aList = [],
|
||||
aLoading = {}
|
||||
;
|
||||
|
||||
oRainData.coreChecking(true);
|
||||
oRainData.coreReal(true);
|
||||
_.each(RL.data().packages(), function (oItem) {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
AdminApp.prototype.updateCoreData = function ()
|
||||
{
|
||||
// TODO cjs
|
||||
var oRainData = RL.data();
|
||||
|
||||
oRainData.coreUpdating(true);
|
||||
RL.remote().updateCoreData(function (sResult, oData) {
|
||||
|
||||
oRainData.coreUpdating(false);
|
||||
oRainData.coreRemoteVersion('');
|
||||
oRainData.coreRemoteRelease('');
|
||||
oRainData.coreVersionCompare(-2);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @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
|
||||
]))
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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 ()
|
||||
{
|
||||
AbstractApp.prototype.bootstart.call(this);
|
||||
|
||||
RL.data().populateDataOnStart();
|
||||
|
||||
kn.hideLoading();
|
||||
|
||||
if (!RL.settingsGet('AllowAdminPanel'))
|
||||
AdminApp.prototype.bootstart = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
kn.setHash(RL.link().root(), true);
|
||||
kn.routeOff();
|
||||
AbstractApp.prototype.bootstart.call(this);
|
||||
|
||||
_.defer(function () {
|
||||
window.location.href = '/';
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Utils.removeSettingsViewModel(AdminAbout);
|
||||
RL.data().populateDataOnStart();
|
||||
|
||||
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'))
|
||||
{
|
||||
// TODO
|
||||
// if (!RL.settingsGet('AllowPackages') && AdminPackages)
|
||||
// {
|
||||
// Utils.disableSettingsViewModel(AdminPackages);
|
||||
// }
|
||||
|
||||
kn.startScreens([AdminSettingsScreen]);
|
||||
_.defer(function () {
|
||||
window.location.href = '/';
|
||||
});
|
||||
}
|
||||
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)
|
||||
{
|
||||
window.SimplePace.set(100);
|
||||
}
|
||||
};
|
||||
if (window.SimplePace)
|
||||
{
|
||||
window.SimplePace.set(100);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @type {AdminApp}
|
||||
*/
|
||||
RL = new AdminApp();
|
||||
module.exports = new AdminApp();
|
||||
|
||||
}(module));
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,164 +1,171 @@
|
|||
/*jslint bitwise: true*/
|
||||
// Base64 encode / decode
|
||||
// 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 */
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.StorageResultType = {
|
||||
'Success': 'success',
|
||||
'Abort': 'abort',
|
||||
'Error': 'error',
|
||||
'Unload': 'unload'
|
||||
};
|
||||
(function (module) {
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.State = {
|
||||
'Empty': 10,
|
||||
'Login': 20,
|
||||
'Auth': 30
|
||||
};
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.StateType = {
|
||||
'Webmail': 0,
|
||||
'Admin': 1
|
||||
};
|
||||
var Enums = {};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.Capa = {
|
||||
'Prem': 'PREM',
|
||||
'TwoFactor': 'TWO_FACTOR',
|
||||
'OpenPGP': 'OPEN_PGP',
|
||||
'Prefetch': 'PREFETCH',
|
||||
'Gravatar': 'GRAVATAR',
|
||||
'Themes': 'THEMES',
|
||||
'Filters': 'FILTERS',
|
||||
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
|
||||
'AdditionalIdentities': 'ADDITIONAL_IDENTITIES'
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.StorageResultType = {
|
||||
'Success': 'success',
|
||||
'Abort': 'abort',
|
||||
'Error': 'error',
|
||||
'Unload': 'unload'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.KeyState = {
|
||||
'All': 'all',
|
||||
'None': 'none',
|
||||
'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 {number}
|
||||
*/
|
||||
Enums.State = {
|
||||
'Empty': 10,
|
||||
'Login': 20,
|
||||
'Auth': 30
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.FolderType = {
|
||||
'Inbox': 10,
|
||||
'SentItems': 11,
|
||||
'Draft': 12,
|
||||
'Trash': 13,
|
||||
'Spam': 14,
|
||||
'Archive': 15,
|
||||
'NotSpam': 80,
|
||||
'User': 99
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.StateType = {
|
||||
'Webmail': 0,
|
||||
'Admin': 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.LoginSignMeTypeAsString = {
|
||||
'DefaultOff': 'defaultoff',
|
||||
'DefaultOn': 'defaulton',
|
||||
'Unused': 'unused'
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.Capa = {
|
||||
'Prem': 'PREM',
|
||||
'TwoFactor': 'TWO_FACTOR',
|
||||
'OpenPGP': 'OPEN_PGP',
|
||||
'Prefetch': 'PREFETCH',
|
||||
'Gravatar': 'GRAVATAR',
|
||||
'Themes': 'THEMES',
|
||||
'Filters': 'FILTERS',
|
||||
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
|
||||
'AdditionalIdentities': 'ADDITIONAL_IDENTITIES'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.LoginSignMeType = {
|
||||
'DefaultOff': 0,
|
||||
'DefaultOn': 1,
|
||||
'Unused': 2
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.KeyState = {
|
||||
'All': 'all',
|
||||
'None': 'none',
|
||||
'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}
|
||||
*/
|
||||
Enums.ComposeType = {
|
||||
'Empty': 'empty',
|
||||
'Reply': 'reply',
|
||||
'ReplyAll': 'replyall',
|
||||
'Forward': 'forward',
|
||||
'ForwardAsAttachment': 'forward-as-attachment',
|
||||
'Draft': 'draft',
|
||||
'EditAsNew': 'editasnew'
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.FolderType = {
|
||||
'Inbox': 10,
|
||||
'SentItems': 11,
|
||||
'Draft': 12,
|
||||
'Trash': 13,
|
||||
'Spam': 14,
|
||||
'Archive': 15,
|
||||
'NotSpam': 80,
|
||||
'User': 99
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.UploadErrorCode = {
|
||||
'Normal': 0,
|
||||
'FileIsTooBig': 1,
|
||||
'FilePartiallyUploaded': 2,
|
||||
'FileNoUploaded': 3,
|
||||
'MissingTempFolder': 4,
|
||||
'FileOnSaveingError': 5,
|
||||
'FileType': 98,
|
||||
'Unknown': 99
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.LoginSignMeTypeAsString = {
|
||||
'DefaultOff': 'defaultoff',
|
||||
'DefaultOn': 'defaulton',
|
||||
'Unused': 'unused'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SetSystemFoldersNotification = {
|
||||
'None': 0,
|
||||
'Sent': 1,
|
||||
'Draft': 2,
|
||||
'Spam': 3,
|
||||
'Trash': 4,
|
||||
'Archive': 5
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.LoginSignMeType = {
|
||||
'DefaultOff': 0,
|
||||
'DefaultOn': 1,
|
||||
'Unused': 2
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ClientSideKeyName = {
|
||||
'FoldersLashHash': 0,
|
||||
'MessagesInboxLastHash': 1,
|
||||
'MailBoxListSize': 2,
|
||||
'ExpandedFolders': 3,
|
||||
'FolderListSize': 4
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.ComposeType = {
|
||||
'Empty': 'empty',
|
||||
'Reply': 'reply',
|
||||
'ReplyAll': 'replyall',
|
||||
'Forward': 'forward',
|
||||
'ForwardAsAttachment': 'forward-as-attachment',
|
||||
'Draft': 'draft',
|
||||
'EditAsNew': 'editasnew'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.EventKeyCode = {
|
||||
'Backspace': 8,
|
||||
'Tab': 9,
|
||||
'Enter': 13,
|
||||
'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}
|
||||
*/
|
||||
Enums.UploadErrorCode = {
|
||||
'Normal': 0,
|
||||
'FileIsTooBig': 1,
|
||||
'FilePartiallyUploaded': 2,
|
||||
'FileNoUploaded': 3,
|
||||
'MissingTempFolder': 4,
|
||||
'FileOnSaveingError': 5,
|
||||
'FileType': 98,
|
||||
'Unknown': 99
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.MessageSetAction = {
|
||||
'SetSeen': 0,
|
||||
'UnsetSeen': 1,
|
||||
'SetFlag': 2,
|
||||
'UnsetFlag': 3
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SetSystemFoldersNotification = {
|
||||
'None': 0,
|
||||
'Sent': 1,
|
||||
'Draft': 2,
|
||||
'Spam': 3,
|
||||
'Trash': 4,
|
||||
'Archive': 5
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.MessageSelectAction = {
|
||||
'All': 0,
|
||||
'None': 1,
|
||||
'Invert': 2,
|
||||
'Unseen': 3,
|
||||
'Seen': 4,
|
||||
'Flagged': 5,
|
||||
'Unflagged': 6
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ClientSideKeyName = {
|
||||
'FoldersLashHash': 0,
|
||||
'MessagesInboxLastHash': 1,
|
||||
'MailBoxListSize': 2,
|
||||
'ExpandedFolders': 3,
|
||||
'FolderListSize': 4
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.DesktopNotifications = {
|
||||
'Allowed': 0,
|
||||
'NotAllowed': 1,
|
||||
'Denied': 2,
|
||||
'NotSupported': 9
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.EventKeyCode = {
|
||||
'Backspace': 8,
|
||||
'Tab': 9,
|
||||
'Enter': 13,
|
||||
'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}
|
||||
*/
|
||||
Enums.MessagePriority = {
|
||||
'Low': 5,
|
||||
'Normal': 3,
|
||||
'High': 1
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.MessageSetAction = {
|
||||
'SetSeen': 0,
|
||||
'UnsetSeen': 1,
|
||||
'SetFlag': 2,
|
||||
'UnsetFlag': 3
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.EditorDefaultType = {
|
||||
'Html': 'Html',
|
||||
'Plain': 'Plain'
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.MessageSelectAction = {
|
||||
'All': 0,
|
||||
'None': 1,
|
||||
'Invert': 2,
|
||||
'Unseen': 3,
|
||||
'Seen': 4,
|
||||
'Flagged': 5,
|
||||
'Unflagged': 6
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.CustomThemeType = {
|
||||
'Light': 'Light',
|
||||
'Dark': 'Dark'
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.DesktopNotifications = {
|
||||
'Allowed': 0,
|
||||
'NotAllowed': 1,
|
||||
'Denied': 2,
|
||||
'NotSupported': 9
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ServerSecure = {
|
||||
'None': 0,
|
||||
'SSL': 1,
|
||||
'TLS': 2
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.MessagePriority = {
|
||||
'Low': 5,
|
||||
'Normal': 3,
|
||||
'High': 1
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SearchDateType = {
|
||||
'All': -1,
|
||||
'Days3': 3,
|
||||
'Days7': 7,
|
||||
'Month': 30
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.EditorDefaultType = {
|
||||
'Html': 'Html',
|
||||
'Plain': 'Plain'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.EmailType = {
|
||||
'Defailt': 0,
|
||||
'Facebook': 1,
|
||||
'Google': 2
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.CustomThemeType = {
|
||||
'Light': 'Light',
|
||||
'Dark': 'Dark'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SaveSettingsStep = {
|
||||
'Animate': -2,
|
||||
'Idle': -1,
|
||||
'TrueResult': 1,
|
||||
'FalseResult': 0
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ServerSecure = {
|
||||
'None': 0,
|
||||
'SSL': 1,
|
||||
'TLS': 2
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.InterfaceAnimation = {
|
||||
'None': 'None',
|
||||
'Normal': 'Normal',
|
||||
'Full': 'Full'
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SearchDateType = {
|
||||
'All': -1,
|
||||
'Days3': 3,
|
||||
'Days7': 7,
|
||||
'Month': 30
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.Layout = {
|
||||
'NoPreview': 0,
|
||||
'SidePreview': 1,
|
||||
'BottomPreview': 2
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.EmailType = {
|
||||
'Defailt': 0,
|
||||
'Facebook': 1,
|
||||
'Google': 2
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FilterConditionField = {
|
||||
'From': 'From',
|
||||
'To': 'To',
|
||||
'Recipient': 'Recipient',
|
||||
'Subject': 'Subject'
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SaveSettingsStep = {
|
||||
'Animate': -2,
|
||||
'Idle': -1,
|
||||
'TrueResult': 1,
|
||||
'FalseResult': 0
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FilterConditionType = {
|
||||
'Contains': 'Contains',
|
||||
'NotContains': 'NotContains',
|
||||
'EqualTo': 'EqualTo',
|
||||
'NotEqualTo': 'NotEqualTo'
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.InterfaceAnimation = {
|
||||
'None': 'None',
|
||||
'Normal': 'Normal',
|
||||
'Full': 'Full'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FiltersAction = {
|
||||
'None': 'None',
|
||||
'Move': 'Move',
|
||||
'Discard': 'Discard',
|
||||
'Forward': 'Forward',
|
||||
};
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.Layout = {
|
||||
'NoPreview': 0,
|
||||
'SidePreview': 1,
|
||||
'BottomPreview': 2
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FilterRulesType = {
|
||||
'And': 'And',
|
||||
'Or': 'Or'
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FilterConditionField = {
|
||||
'From': 'From',
|
||||
'To': 'To',
|
||||
'Recipient': 'Recipient',
|
||||
'Subject': 'Subject'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.SignedVerifyStatus = {
|
||||
'UnknownPublicKeys': -4,
|
||||
'UnknownPrivateKey': -3,
|
||||
'Unverified': -2,
|
||||
'Error': -1,
|
||||
'None': 0,
|
||||
'Success': 1
|
||||
};
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
Enums.FilterConditionType = {
|
||||
'Contains': 'Contains',
|
||||
'NotContains': 'NotContains',
|
||||
'EqualTo': 'EqualTo',
|
||||
'NotEqualTo': 'NotEqualTo'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ContactPropertyType = {
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
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,
|
||||
'MiddleName': 16,
|
||||
'Nick': 18,
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ContactPropertyType = {
|
||||
|
||||
'NamePrefix': 20,
|
||||
'NameSuffix': 21,
|
||||
'Unknown': 0,
|
||||
|
||||
'Email': 30,
|
||||
'Phone': 31,
|
||||
'Web': 32,
|
||||
'FullName': 10,
|
||||
|
||||
'Birthday': 40,
|
||||
'FirstName': 15,
|
||||
'LastName': 16,
|
||||
'MiddleName': 16,
|
||||
'Nick': 18,
|
||||
|
||||
'Facebook': 90,
|
||||
'Skype': 91,
|
||||
'GitHub': 92,
|
||||
'NamePrefix': 20,
|
||||
'NameSuffix': 21,
|
||||
|
||||
'Note': 110,
|
||||
'Email': 30,
|
||||
'Phone': 31,
|
||||
'Web': 32,
|
||||
|
||||
'Custom': 250
|
||||
};
|
||||
'Birthday': 40,
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.Notification = {
|
||||
'InvalidToken': 101,
|
||||
'AuthError': 102,
|
||||
'AccessError': 103,
|
||||
'ConnectionError': 104,
|
||||
'CaptchaError': 105,
|
||||
'SocialFacebookLoginAccessDisable': 106,
|
||||
'SocialTwitterLoginAccessDisable': 107,
|
||||
'SocialGoogleLoginAccessDisable': 108,
|
||||
'DomainNotAllowed': 109,
|
||||
'AccountNotAllowed': 110,
|
||||
'Facebook': 90,
|
||||
'Skype': 91,
|
||||
'GitHub': 92,
|
||||
|
||||
'AccountTwoFactorAuthRequired': 120,
|
||||
'AccountTwoFactorAuthError': 121,
|
||||
'Note': 110,
|
||||
|
||||
'CouldNotSaveNewPassword': 130,
|
||||
'CurrentPasswordIncorrect': 131,
|
||||
'NewPasswordShort': 132,
|
||||
'NewPasswordWeak': 133,
|
||||
'NewPasswordForbidden': 134,
|
||||
'Custom': 250
|
||||
};
|
||||
|
||||
'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,
|
||||
'CantGetMessage': 202,
|
||||
'CantDeleteMessage': 203,
|
||||
'CantMoveMessage': 204,
|
||||
'CantCopyMessage': 205,
|
||||
'AccountTwoFactorAuthRequired': 120,
|
||||
'AccountTwoFactorAuthError': 121,
|
||||
|
||||
'CantSaveMessage': 301,
|
||||
'CantSendMessage': 302,
|
||||
'InvalidRecipients': 303,
|
||||
'CouldNotSaveNewPassword': 130,
|
||||
'CurrentPasswordIncorrect': 131,
|
||||
'NewPasswordShort': 132,
|
||||
'NewPasswordWeak': 133,
|
||||
'NewPasswordForbidden': 134,
|
||||
|
||||
'CantCreateFolder': 400,
|
||||
'CantRenameFolder': 401,
|
||||
'CantDeleteFolder': 402,
|
||||
'CantSubscribeFolder': 403,
|
||||
'CantUnsubscribeFolder': 404,
|
||||
'CantDeleteNonEmptyFolder': 405,
|
||||
'ContactsSyncError': 140,
|
||||
|
||||
'CantSaveSettings': 501,
|
||||
'CantSavePluginSettings': 502,
|
||||
'CantGetMessageList': 201,
|
||||
'CantGetMessage': 202,
|
||||
'CantDeleteMessage': 203,
|
||||
'CantMoveMessage': 204,
|
||||
'CantCopyMessage': 205,
|
||||
|
||||
'DomainAlreadyExists': 601,
|
||||
'CantSaveMessage': 301,
|
||||
'CantSendMessage': 302,
|
||||
'InvalidRecipients': 303,
|
||||
|
||||
'CantInstallPackage': 701,
|
||||
'CantDeletePackage': 702,
|
||||
'InvalidPluginPackage': 703,
|
||||
'UnsupportedPluginPackage': 704,
|
||||
'CantCreateFolder': 400,
|
||||
'CantRenameFolder': 401,
|
||||
'CantDeleteFolder': 402,
|
||||
'CantSubscribeFolder': 403,
|
||||
'CantUnsubscribeFolder': 404,
|
||||
'CantDeleteNonEmptyFolder': 405,
|
||||
|
||||
'LicensingServerIsUnavailable': 710,
|
||||
'LicensingExpired': 711,
|
||||
'LicensingBanned': 712,
|
||||
'CantSaveSettings': 501,
|
||||
'CantSavePluginSettings': 502,
|
||||
|
||||
'DemoSendMessageError': 750,
|
||||
'DomainAlreadyExists': 601,
|
||||
|
||||
'AccountAlreadyExists': 801,
|
||||
'CantInstallPackage': 701,
|
||||
'CantDeletePackage': 702,
|
||||
'InvalidPluginPackage': 703,
|
||||
'UnsupportedPluginPackage': 704,
|
||||
|
||||
'MailServerError': 901,
|
||||
'ClientViewError': 902,
|
||||
'InvalidInputArgument': 903,
|
||||
'UnknownNotification': 999,
|
||||
'UnknownError': 999
|
||||
};
|
||||
'LicensingServerIsUnavailable': 710,
|
||||
'LicensingExpired': 711,
|
||||
'LicensingBanned': 712,
|
||||
|
||||
'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 */
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.now = (new Date()).getTime();
|
||||
(function (module) {
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.momentTrigger = ko.observable(true);
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.dropdownVisibility = ko.observable(false).extend({'rateLimit': 0});
|
||||
var
|
||||
Globals = {},
|
||||
window = require('../External/window.js'),
|
||||
ko = require('../External/ko.js'),
|
||||
$html = require('../External/$html.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.tooltipTrigger = ko.observable(false).extend({'rateLimit': 0});
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.now = (new window.Date()).getTime();
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.langChangeTrigger = ko.observable(true);
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.momentTrigger = ko.observable(true);
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Globals.iAjaxErrorCount = 0;
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.dropdownVisibility = ko.observable(false).extend({'rateLimit': 0});
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Globals.iTokenErrorCount = 0;
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.tooltipTrigger = ko.observable(false).extend({'rateLimit': 0});
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Globals.iMessageBodyCacheCount = 0;
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.langChangeTrigger = ko.observable(true);
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bUnload = false;
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Globals.iAjaxErrorCount = 0;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
Globals.sUserAgent = (navigator.userAgent || '').toLowerCase();
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Globals.iTokenErrorCount = 0;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bIsiOSDevice = -1 < Globals.sUserAgent.indexOf('iphone') || -1 < Globals.sUserAgent.indexOf('ipod') || -1 < Globals.sUserAgent.indexOf('ipad');
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
Globals.iMessageBodyCacheCount = 0;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bUnload = false;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
Globals.sUserAgent = (window.navigator.userAgent || '').toLowerCase();
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bIsiOSDevice = -1 < Globals.sUserAgent.indexOf('iphone') || -1 < Globals.sUserAgent.indexOf('ipod') || -1 < Globals.sUserAgent.indexOf('ipad');
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bXMLHttpRequestSupported = !!window.XMLHttpRequest;
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
Globals.sAnimationType = '';
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||
|
||||
/**
|
||||
* @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']}
|
||||
],
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
||||
|
||||
'removePlugins': 'contextmenu', //blockquote
|
||||
'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll',
|
||||
'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced',
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
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',
|
||||
'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'
|
||||
};
|
||||
'removePlugins': 'contextmenu', //blockquote
|
||||
'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll',
|
||||
'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced',
|
||||
|
||||
/**
|
||||
* @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'
|
||||
};
|
||||
'extraPlugins': 'plain',
|
||||
|
||||
if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
|
||||
{
|
||||
Globals.bAllowPdfPreview = !!_.find(navigator.mimeTypes, function (oType) {
|
||||
return oType && 'application/pdf' === oType.type;
|
||||
});
|
||||
}
|
||||
'allowedContent': true,
|
||||
'autoParagraph': false,
|
||||
|
||||
'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 */
|
||||
|
||||
/**
|
||||
* @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/';
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.root = function ()
|
||||
{
|
||||
return this.sBase;
|
||||
};
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.attachmentDownload = function (sDownload)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @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)
|
||||
var
|
||||
window = require('../External/window.js'),
|
||||
Utils = require('./Utils.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LinkBuilder()
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
* @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)
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.root = function ()
|
||||
{
|
||||
sResult += encodeURI(sFolder);
|
||||
}
|
||||
if (1 < iPage)
|
||||
return this.sBase;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.attachmentDownload = function (sDownload)
|
||||
{
|
||||
sResult = sResult.replace(/[\/]+$/, '');
|
||||
sResult += '/p' + iPage;
|
||||
}
|
||||
if ('' !== sSearch)
|
||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.attachmentPreview = function (sDownload)
|
||||
{
|
||||
sResult = sResult.replace(/[\/]+$/, '');
|
||||
sResult += '/' + encodeURI(sSearch);
|
||||
}
|
||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/View/' + sDownload;
|
||||
};
|
||||
|
||||
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))
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.attachmentPreviewAsPlain = function (sDownload)
|
||||
{
|
||||
sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7));
|
||||
sPrefix = '';
|
||||
}
|
||||
return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sDownload;
|
||||
};
|
||||
|
||||
return sPrefix + 'themes/' + encodeURI(sTheme) + '/images/preview.png';
|
||||
};
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.upload = function ()
|
||||
{
|
||||
return this.sServer + '/Upload/' + this.sSpecSuffix + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.notificationMailIcon = function ()
|
||||
{
|
||||
return this.sStaticPrefix + 'css/images/icom-message-notification.png';
|
||||
};
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.uploadContacts = function ()
|
||||
{
|
||||
return this.sServer + '/UploadContacts/' + this.sSpecSuffix + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.openPgpJs = function ()
|
||||
{
|
||||
return this.sStaticPrefix + 'js/openpgp.min.js';
|
||||
};
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.uploadBackground = function ()
|
||||
{
|
||||
return this.sServer + '/UploadBackground/' + this.sSpecSuffix + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.socialGoogle = function ()
|
||||
{
|
||||
return this.sServer + 'SocialGoogle' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
||||
};
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.append = function ()
|
||||
{
|
||||
return this.sServer + '/Append/' + this.sSpecSuffix + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.socialTwitter = function ()
|
||||
{
|
||||
return this.sServer + 'SocialTwitter' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
||||
};
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.change = function (sEmail)
|
||||
{
|
||||
return this.sServer + '/Change/' + this.sSpecSuffix + '/' + window.encodeURIComponent(sEmail) + '/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LinkBuilder.prototype.socialFacebook = function ()
|
||||
{
|
||||
return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
|
||||
};
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @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;
|
||||
(function (module) {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
NewHtmlEditorWrapper.prototype.blurTrigger = function ()
|
||||
{
|
||||
if (this.fOnBlur)
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} oElement
|
||||
* @param {Function=} fOnBlur
|
||||
* @param {Function=} fOnReady
|
||||
* @param {Function=} fOnModeChange
|
||||
*/
|
||||
function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady, fOnModeChange)
|
||||
{
|
||||
var self = this;
|
||||
window.clearTimeout(self.iBlurTimer);
|
||||
self.iBlurTimer = window.setTimeout(function () {
|
||||
self.fOnBlur();
|
||||
}, 200);
|
||||
self.editor = null;
|
||||
self.iBlurTimer = 0;
|
||||
self.fOnBlur = fOnBlur || null;
|
||||
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 ()
|
||||
{
|
||||
if (this.fOnBlur)
|
||||
NewHtmlEditorWrapper.prototype.blurTrigger = function ()
|
||||
{
|
||||
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)
|
||||
if (this.fOnBlur)
|
||||
{
|
||||
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 ?
|
||||
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
|
||||
this.editor.getData() + '</div>' : this.editor.getData();
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
NewHtmlEditorWrapper.prototype.modeToggle = function (bPlain)
|
||||
{
|
||||
if (this.editor)
|
||||
NewHtmlEditorWrapper.prototype.modeToggle = function (bPlain)
|
||||
{
|
||||
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.setHtml = function (sHtml, bFocus)
|
||||
{
|
||||
if (this.editor)
|
||||
NewHtmlEditorWrapper.prototype.init = function ()
|
||||
{
|
||||
this.modeToggle(true);
|
||||
this.editor.setData(sHtml);
|
||||
|
||||
if (bFocus)
|
||||
if (this.$element && this.$element[0])
|
||||
{
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
var
|
||||
self = this,
|
||||
fInit = function () {
|
||||
|
||||
NewHtmlEditorWrapper.prototype.setPlain = function (sPlain, bFocus)
|
||||
{
|
||||
if (this.editor)
|
||||
{
|
||||
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);
|
||||
}
|
||||
var
|
||||
oConfig = Globals.oHtmlEditorDefaultConfig,
|
||||
sLanguage = RL.settingsGet('Language'), // TODO cjs
|
||||
bSource = !!RL.settingsGet('AllowHtmlEditorSourceButton')
|
||||
;
|
||||
|
||||
if (bFocus)
|
||||
{
|
||||
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)
|
||||
if (bSource && oConfig.toolbarGroups && !oConfig.toolbarGroups.__SourceInited)
|
||||
{
|
||||
return false;
|
||||
oConfig.toolbarGroups.__SourceInited = true;
|
||||
oConfig.toolbarGroups.push({name: 'document', groups: ['mode', 'document', 'doctools']});
|
||||
}
|
||||
});
|
||||
|
||||
self.editor.on('blur', function() {
|
||||
self.blurTrigger();
|
||||
});
|
||||
oConfig.enterMode = window.CKEDITOR.ENTER_BR;
|
||||
oConfig.shiftEnterMode = window.CKEDITOR.ENTER_BR;
|
||||
|
||||
self.editor.on('mode', function() {
|
||||
|
||||
self.blurTrigger();
|
||||
|
||||
if (self.fOnModeChange)
|
||||
oConfig.language = Globals.oHtmlEditorLangsMap[sLanguage] || 'en';
|
||||
if (window.CKEDITOR.env)
|
||||
{
|
||||
self.fOnModeChange('plain' !== self.editor.mode);
|
||||
window.CKEDITOR.env.isCompatible = true;
|
||||
}
|
||||
});
|
||||
|
||||
self.editor.on('focus', function() {
|
||||
self.focusTrigger();
|
||||
});
|
||||
self.editor = window.CKEDITOR.appendTo(self.$element[0], oConfig);
|
||||
|
||||
if (self.fOnReady)
|
||||
{
|
||||
self.editor.on('instanceReady', function () {
|
||||
|
||||
self.editor.setKeystroke(window.CKEDITOR.CTRL + 65 /* A */, 'selectAll');
|
||||
|
||||
self.fOnReady();
|
||||
self.__resizable = true;
|
||||
self.resize();
|
||||
self.editor.on('key', function(oEvent) {
|
||||
if (oEvent && oEvent.data && 9 /* Tab */ === oEvent.data.keyCode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
self.editor.on('blur', function() {
|
||||
self.blurTrigger();
|
||||
});
|
||||
|
||||
self.editor.on('mode', function() {
|
||||
|
||||
self.blurTrigger();
|
||||
|
||||
if (self.fOnModeChange)
|
||||
{
|
||||
self.fOnModeChange('plain' !== self.editor.mode);
|
||||
}
|
||||
});
|
||||
|
||||
self.editor.on('focus', function() {
|
||||
self.focusTrigger();
|
||||
});
|
||||
|
||||
if (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 ()
|
||||
{
|
||||
if (this.editor)
|
||||
NewHtmlEditorWrapper.prototype.blur = function ()
|
||||
{
|
||||
this.editor.focus();
|
||||
}
|
||||
};
|
||||
|
||||
NewHtmlEditorWrapper.prototype.blur = function ()
|
||||
{
|
||||
if (this.editor)
|
||||
{
|
||||
this.editor.focusManager.blur(true);
|
||||
}
|
||||
};
|
||||
|
||||
NewHtmlEditorWrapper.prototype.resize = function ()
|
||||
{
|
||||
if (this.editor && this.__resizable)
|
||||
{
|
||||
try
|
||||
if (this.editor)
|
||||
{
|
||||
this.editor.resize(this.$element.width(), this.$element.innerHeight());
|
||||
this.editor.focusManager.blur(true);
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
NewHtmlEditorWrapper.prototype.clear = function (bFocus)
|
||||
{
|
||||
this.setHtml('', bFocus);
|
||||
};
|
||||
NewHtmlEditorWrapper.prototype.resize = function ()
|
||||
{
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
Plugins.oViewModelsHooks = {};
|
||||
(function (module) {
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
Plugins.oSimpleHooks = {};
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Function} ViewModel
|
||||
*/
|
||||
Plugins.regViewModelHook = function (sName, ViewModel)
|
||||
{
|
||||
if (ViewModel)
|
||||
var
|
||||
Plugins = {},
|
||||
Utils = require('./Utils.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
Plugins.oViewModelsHooks = {};
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
Plugins.oSimpleHooks = {};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Function} ViewModel
|
||||
*/
|
||||
Plugins.regViewModelHook = function (sName, ViewModel)
|
||||
{
|
||||
ViewModel.__hookName = sName;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Function} fCallback
|
||||
*/
|
||||
Plugins.addHook = function (sName, fCallback)
|
||||
{
|
||||
if (Utils.isFunc(fCallback))
|
||||
{
|
||||
if (!Utils.isArray(Plugins.oSimpleHooks[sName]))
|
||||
if (ViewModel)
|
||||
{
|
||||
Plugins.oSimpleHooks[sName] = [];
|
||||
ViewModel.__hookName = sName;
|
||||
}
|
||||
|
||||
Plugins.oSimpleHooks[sName].push(fCallback);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Array=} aArguments
|
||||
*/
|
||||
Plugins.runHook = function (sName, aArguments)
|
||||
{
|
||||
if (Utils.isArray(Plugins.oSimpleHooks[sName]))
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Function} fCallback
|
||||
*/
|
||||
Plugins.addHook = function (sName, fCallback)
|
||||
{
|
||||
aArguments = aArguments || [];
|
||||
|
||||
_.each(Plugins.oSimpleHooks[sName], function (fCallback) {
|
||||
fCallback.apply(null, aArguments);
|
||||
});
|
||||
}
|
||||
};
|
||||
if (Utils.isFunc(fCallback))
|
||||
{
|
||||
if (!Utils.isArray(Plugins.oSimpleHooks[sName]))
|
||||
{
|
||||
Plugins.oSimpleHooks[sName] = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @return {?}
|
||||
*/
|
||||
Plugins.mainSettingsGet = function (sName)
|
||||
{
|
||||
return RL ? RL.settingsGet(sName) : null;
|
||||
};
|
||||
Plugins.oSimpleHooks[sName].push(fCallback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @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)
|
||||
/**
|
||||
* @param {string} sName
|
||||
* @param {Array=} aArguments
|
||||
*/
|
||||
Plugins.runHook = function (sName, aArguments)
|
||||
{
|
||||
RL.remote().defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions);
|
||||
}
|
||||
};
|
||||
if (Utils.isArray(Plugins.oSimpleHooks[sName]))
|
||||
{
|
||||
aArguments = aArguments || [];
|
||||
|
||||
/**
|
||||
* @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;
|
||||
};
|
||||
_.each(Plugins.oSimpleHooks[sName], function (fCallback) {
|
||||
fCallback.apply(null, aArguments);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Knoin()
|
||||
{
|
||||
this.sDefaultScreenName = '';
|
||||
this.oScreens = {};
|
||||
this.oBoot = null;
|
||||
this.oCurrentScreen = null;
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
/**
|
||||
* @param {Object} thisObject
|
||||
*/
|
||||
Knoin.constructorEnd = function (thisObject)
|
||||
{
|
||||
if (Utils.isFunc(thisObject['__constructor_end']))
|
||||
'use strict';
|
||||
|
||||
var
|
||||
$ = require('../External/jquery.js'),
|
||||
_ = require('../External/underscore.js'),
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
this.sDefaultScreenName = '';
|
||||
this.oScreens = {};
|
||||
this.oBoot = null;
|
||||
this.oCurrentScreen = null;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* @param {Object} thisObject
|
||||
*/
|
||||
Knoin.constructorEnd = function (thisObject)
|
||||
{
|
||||
if (Utils.isFunc(thisObject['__constructor_end']))
|
||||
{
|
||||
thisObject['__constructor_end'].call(thisObject);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sScreenName
|
||||
* @return {?Object}
|
||||
*/
|
||||
Knoin.prototype.screen = function (sScreenName)
|
||||
{
|
||||
return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null;
|
||||
};
|
||||
Knoin.prototype.sDefaultScreenName = '';
|
||||
Knoin.prototype.oScreens = {};
|
||||
Knoin.prototype.oBoot = null;
|
||||
Knoin.prototype.oCurrentScreen = null;
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClass
|
||||
* @param {Object=} oScreen
|
||||
*/
|
||||
Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
|
||||
{
|
||||
if (ViewModelClass && !ViewModelClass.__builded)
|
||||
Knoin.prototype.hideLoading = function ()
|
||||
{
|
||||
$('#rl-loading').hide();
|
||||
};
|
||||
|
||||
Knoin.prototype.rl = function ()
|
||||
{
|
||||
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
|
||||
oViewModel = new ViewModelClass(oScreen),
|
||||
sPosition = oViewModel.viewModelPosition(),
|
||||
oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()),
|
||||
oViewModelDom = null
|
||||
self = this,
|
||||
oScreen = null,
|
||||
oCross = null
|
||||
;
|
||||
|
||||
ViewModelClass.__builded = true;
|
||||
ViewModelClass.__vm = oViewModel;
|
||||
oViewModel.data = RL.data();
|
||||
|
||||
oViewModel.viewModelName = ViewModelClass.__name;
|
||||
|
||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
||||
if ('' === Utils.pString(sScreenName))
|
||||
{
|
||||
oViewModelDom = $('<div></div>').addClass('rl-view-model').addClass('RL-' + oViewModel.viewModelTemplate()).hide();
|
||||
oViewModelDom.appendTo(oViewModelPlace);
|
||||
sScreenName = this.sDefaultScreenName;
|
||||
}
|
||||
|
||||
oViewModel.viewModelDom = oViewModelDom;
|
||||
ViewModelClass.__dom = oViewModelDom;
|
||||
|
||||
if ('Popups' === sPosition)
|
||||
if ('' !== sScreenName)
|
||||
{
|
||||
oScreen = this.screen(sScreenName);
|
||||
if (!oScreen)
|
||||
{
|
||||
oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, function () {
|
||||
kn.hideScreenPopup(ViewModelClass);
|
||||
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) {
|
||||
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], {
|
||||
'i18nInit': true,
|
||||
'template': function () { return {'name': oViewModel.viewModelTemplate()};}
|
||||
}, oViewModel);
|
||||
_.each(aScreensClasses, function (CScreen) {
|
||||
|
||||
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
|
||||
if (oViewModel && 'Popups' === sPosition)
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oViewModel
|
||||
* @param {Object} oViewModelDom
|
||||
*/
|
||||
Knoin.prototype.applyExternal = function (oViewModel, oViewModelDom)
|
||||
{
|
||||
if (oViewModel && oViewModelDom)
|
||||
/**
|
||||
* @return {Knoin}
|
||||
*/
|
||||
Knoin.prototype.bootstart = function (RL)
|
||||
{
|
||||
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');
|
||||
|
||||
/**
|
||||
* @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]);
|
||||
}
|
||||
};
|
||||
$window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS);
|
||||
$window.unload(function () {
|
||||
Globals.bUnload = true;
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClassToShow
|
||||
* @param {Array=} aParameters
|
||||
*/
|
||||
Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters)
|
||||
{
|
||||
if (ViewModelClassToShow)
|
||||
{
|
||||
this.buildViewModel(ViewModelClassToShow);
|
||||
$html.on('click.dropdown.data-api', function () {
|
||||
Utils.detectDropdownVisibility();
|
||||
});
|
||||
|
||||
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 || []]);
|
||||
}
|
||||
}
|
||||
};
|
||||
// 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;
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClassToShow
|
||||
* @return {boolean}
|
||||
*/
|
||||
Knoin.prototype.isPopupVisible = function (ViewModelClassToShow)
|
||||
{
|
||||
return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false;
|
||||
};
|
||||
window['rl']['EmailModel'] = EmailModel;
|
||||
window['rl']['Enums'] = Enums;
|
||||
|
||||
/**
|
||||
* @param {string} sScreenName
|
||||
* @param {string} sSubPart
|
||||
*/
|
||||
Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oScreen = null,
|
||||
oCross = null
|
||||
;
|
||||
window['__RLBOOT'] = function (fCall) {
|
||||
|
||||
if ('' === Utils.pString(sScreenName))
|
||||
{
|
||||
sScreenName = this.sDefaultScreenName;
|
||||
}
|
||||
// boot
|
||||
$(function () {
|
||||
|
||||
if ('' !== sScreenName)
|
||||
{
|
||||
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()))
|
||||
if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0])
|
||||
{
|
||||
_.each(oScreen.viewModels(), function (ViewModelClass) {
|
||||
this.buildViewModel(ViewModelClass, oScreen);
|
||||
}, this);
|
||||
$('#rl-templates').html(window['rainloopTEMPLATES'][0]);
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
RL.bootstart();
|
||||
|
||||
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted');
|
||||
}, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
fCall(false);
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
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);
|
||||
}
|
||||
window['__RLBOOT'] = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Array} aScreensClasses
|
||||
*/
|
||||
Knoin.prototype.startScreens = function (aScreensClasses)
|
||||
{
|
||||
$('#rl-content').css({
|
||||
'visibility': 'hidden'
|
||||
});
|
||||
module.exports = new Knoin();
|
||||
|
||||
_.each(aScreensClasses, function (CScreen) {
|
||||
|
||||
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();
|
||||
}(module));
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
AccountModel.prototype.email = '';
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AccountModel.prototype.changeAccountLink = function ()
|
||||
{
|
||||
return RL.link().change(this.email);
|
||||
};
|
||||
var
|
||||
ko = require('../External/ko.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
|
||||
/**
|
||||
* @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 = '';
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {AjaxJsonAttachment} oJsonAttachment
|
||||
* @return {?AttachmentModel}
|
||||
*/
|
||||
AttachmentModel.newInstanceFromJson = function (oJsonAttachment)
|
||||
{
|
||||
var oAttachmentModel = new AttachmentModel();
|
||||
return oAttachmentModel.initByJson(oJsonAttachment) ? oAttachmentModel : null;
|
||||
};
|
||||
'use strict';
|
||||
|
||||
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
|
||||
aParts = this.mimeType.toLocaleString().split('/'),
|
||||
sClass = 'icon-file'
|
||||
window = require('../External/window.js'),
|
||||
Globals = require('../Common/Globals.js'),
|
||||
Utils = require('../Common/Utils.js')
|
||||
;
|
||||
|
||||
if (aParts && aParts[1])
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AttachmentModel()
|
||||
{
|
||||
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';
|
||||
}
|
||||
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 = '';
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @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;
|
||||
(function (module) {
|
||||
|
||||
this.fileName = ko.observable(sFileName);
|
||||
this.size = ko.observable(Utils.isUnd(nSize) ? null : nSize);
|
||||
this.tempName = ko.observable('');
|
||||
'use strict';
|
||||
|
||||
this.progress = ko.observable('');
|
||||
this.error = ko.observable('');
|
||||
this.waiting = ko.observable(true);
|
||||
this.uploading = ko.observable(false);
|
||||
this.enabled = ko.observable(true);
|
||||
var
|
||||
ko = require('../External/ko.js'),
|
||||
Utils = require('../Common/Utils.js')
|
||||
;
|
||||
|
||||
this.friendlySize = ko.computed(function () {
|
||||
var mSize = this.size();
|
||||
return null === mSize ? '' : Utils.friendlySize(this.size());
|
||||
}, this);
|
||||
}
|
||||
|
||||
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)
|
||||
/**
|
||||
* @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.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;
|
||||
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;
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ContactModel()
|
||||
{
|
||||
this.idContact = 0;
|
||||
this.display = '';
|
||||
this.properties = [];
|
||||
this.tags = '';
|
||||
this.readOnly = false;
|
||||
(function (module) {
|
||||
|
||||
this.focused = ko.observable(false);
|
||||
this.selected = ko.observable(false);
|
||||
this.checked = ko.observable(false);
|
||||
this.deleted = ko.observable(false);
|
||||
}
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @return {Array|null}
|
||||
*/
|
||||
ContactModel.prototype.getNameAndEmailHelper = function ()
|
||||
{
|
||||
var
|
||||
sName = '',
|
||||
sEmail = ''
|
||||
_ = require('../External/underscore.js'),
|
||||
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) {
|
||||
if (aProperty)
|
||||
{
|
||||
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.idContact = 0;
|
||||
this.display = '';
|
||||
this.properties = [];
|
||||
this.tags = '';
|
||||
this.readOnly = false;
|
||||
|
||||
this.focused = ko.observable(false);
|
||||
this.selected = ko.observable(false);
|
||||
this.checked = ko.observable(false);
|
||||
this.deleted = ko.observable(false);
|
||||
}
|
||||
|
||||
return '' === sEmail ? null : [sEmail, sName];
|
||||
};
|
||||
|
||||
ContactModel.prototype.parse = function (oItem)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oItem && 'Object/Contact' === oItem['@Object'])
|
||||
/**
|
||||
* @return {Array|null}
|
||||
*/
|
||||
ContactModel.prototype.getNameAndEmailHelper = function ()
|
||||
{
|
||||
this.idContact = Utils.pInt(oItem['IdContact']);
|
||||
this.display = Utils.pString(oItem['Display']);
|
||||
this.readOnly = !!oItem['ReadOnly'];
|
||||
this.tags = '';
|
||||
var
|
||||
sName = '',
|
||||
sEmail = ''
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(oItem['Properties']))
|
||||
if (Utils.isNonEmptyArray(this.properties))
|
||||
{
|
||||
_.each(oItem['Properties'], function (oProperty) {
|
||||
if (oProperty && oProperty['Type'] && Utils.isNormal(oProperty['Value']) && Utils.isNormal(oProperty['TypeStr']))
|
||||
_.each(this.properties, function (aProperty) {
|
||||
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);
|
||||
}
|
||||
|
||||
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 RL.link().emptyContactPic();
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
ContactModel.prototype.generateUid = function ()
|
||||
{
|
||||
return '' + this.idContact;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
ContactModel.prototype.lineAsCcc = function ()
|
||||
{
|
||||
var aResult = [];
|
||||
if (this.deleted())
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
ContactModel.prototype.srcAttr = function ()
|
||||
{
|
||||
aResult.push('deleted');
|
||||
}
|
||||
if (this.selected())
|
||||
{
|
||||
aResult.push('selected');
|
||||
}
|
||||
if (this.checked())
|
||||
{
|
||||
aResult.push('checked');
|
||||
}
|
||||
if (this.focused())
|
||||
{
|
||||
aResult.push('focused');
|
||||
}
|
||||
return RL.link().emptyContactPic(); // TODO cjs
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @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));
|
||||
(function (module) {
|
||||
|
||||
this.placeholder = ko.observable(sPlaceholder || '');
|
||||
'use strict';
|
||||
|
||||
this.placeholderValue = ko.computed(function () {
|
||||
var sPlaceholder = this.placeholder();
|
||||
return sPlaceholder ? Utils.i18n(sPlaceholder) : '';
|
||||
}, this);
|
||||
var
|
||||
ko = require('../External/ko.js'),
|
||||
Enums = require('../Common/Enums.js'),
|
||||
Utils = require('../Common/Utils.js')
|
||||
;
|
||||
|
||||
this.largeValue = ko.computed(function () {
|
||||
return Enums.ContactPropertyType.Note === this.type();
|
||||
}, this);
|
||||
/**
|
||||
* @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 || '');
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ContactTagModel()
|
||||
{
|
||||
this.idContactTag = 0;
|
||||
this.name = ko.observable('');
|
||||
this.readOnly = false;
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
ContactTagModel.prototype.parse = function (oItem)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oItem && 'Object/Tag' === oItem['@Object'])
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('../External/ko.js'),
|
||||
Utils = require('../Common/Utils.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ContactTagModel()
|
||||
{
|
||||
this.idContact = Utils.pInt(oItem['IdContactTag']);
|
||||
this.name(Utils.pString(oItem['Name']));
|
||||
this.readOnly = !!oItem['ReadOnly'];
|
||||
|
||||
bResult = true;
|
||||
this.idContactTag = 0;
|
||||
this.name = ko.observable('');
|
||||
this.readOnly = false;
|
||||
}
|
||||
|
||||
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'];
|
||||
|
||||
/**
|
||||
* @param {string} sSearch
|
||||
* @return {boolean}
|
||||
*/
|
||||
ContactTagModel.prototype.filterHelper = function (sSearch)
|
||||
{
|
||||
return this.name().toLowerCase().indexOf(sSearch.toLowerCase()) !== -1;
|
||||
};
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean=} bEncodeHtml = false
|
||||
* @return {string}
|
||||
*/
|
||||
ContactTagModel.prototype.toLine = function (bEncodeHtml)
|
||||
{
|
||||
return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ?
|
||||
Utils.encodeHtml(this.name()) : this.name();
|
||||
};
|
||||
return bResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sSearch
|
||||
* @return {boolean}
|
||||
*/
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @param {string=} sEmail
|
||||
* @param {string=} sName
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function EmailModel(sEmail, sName)
|
||||
{
|
||||
this.email = sEmail || '';
|
||||
this.name = sName || '';
|
||||
this.privateType = null;
|
||||
(function (module) {
|
||||
|
||||
this.clearDuplicateName();
|
||||
}
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @param {AjaxJsonEmail} oJsonEmail
|
||||
* @return {?EmailModel}
|
||||
*/
|
||||
EmailModel.newInstanceFromJson = function (oJsonEmail)
|
||||
{
|
||||
var oEmailModel = new EmailModel();
|
||||
return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null;
|
||||
};
|
||||
var
|
||||
Enums = require('../Common/Enums.js'),
|
||||
Utils = require('../Common/Utils.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @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)
|
||||
/**
|
||||
* @param {string=} sEmail
|
||||
* @param {string=} sName
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function EmailModel(sEmail, sName)
|
||||
{
|
||||
this.name = '';
|
||||
this.email = sEmail || '';
|
||||
this.name = sName || '';
|
||||
this.privateType = null;
|
||||
|
||||
this.clearDuplicateName();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
EmailModel.prototype.type = function ()
|
||||
{
|
||||
if (null === this.privateType)
|
||||
/**
|
||||
* @static
|
||||
* @param {AjaxJsonEmail} oJsonEmail
|
||||
* @return {?EmailModel}
|
||||
*/
|
||||
EmailModel.newInstanceFromJson = function (oJsonEmail)
|
||||
{
|
||||
if (this.email && '@facebook.com' === this.email.substr(-13))
|
||||
{
|
||||
this.privateType = Enums.EmailType.Facebook;
|
||||
}
|
||||
var oEmailModel = new EmailModel();
|
||||
return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
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)
|
||||
if (this.email && '@facebook.com' === this.email.substr(-13))
|
||||
{
|
||||
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 + '" <') +
|
||||
'<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)
|
||||
if (bWrapWithLink)
|
||||
{
|
||||
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>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
case '"':
|
||||
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
||||
{
|
||||
$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;
|
||||
$iStartIndex = $iCurrentIndex;
|
||||
}
|
||||
break;
|
||||
case '>':
|
||||
if ($bInAddress)
|
||||
{
|
||||
$iEndIndex = $iCurrentIndex;
|
||||
$sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
||||
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
||||
$iEndIndex = 0;
|
||||
$iCurrentIndex = 0;
|
||||
$iStartIndex = 0;
|
||||
$bInAddress = false;
|
||||
}
|
||||
break;
|
||||
case '(':
|
||||
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
||||
{
|
||||
$bInComment = true;
|
||||
$iStartIndex = $iCurrentIndex;
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
if ($bInComment)
|
||||
{
|
||||
$iEndIndex = $iCurrentIndex;
|
||||
$sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
||||
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
||||
$iEndIndex = 0;
|
||||
$iCurrentIndex = 0;
|
||||
$iStartIndex = 0;
|
||||
$bInComment = false;
|
||||
}
|
||||
break;
|
||||
case '\\':
|
||||
$iCurrentIndex++;
|
||||
break;
|
||||
$bInAddress = true;
|
||||
$iStartIndex = $iCurrentIndex;
|
||||
}
|
||||
break;
|
||||
case '>':
|
||||
if ($bInAddress)
|
||||
{
|
||||
$iEndIndex = $iCurrentIndex;
|
||||
$sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
||||
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
||||
$iEndIndex = 0;
|
||||
$iCurrentIndex = 0;
|
||||
$iStartIndex = 0;
|
||||
$bInAddress = false;
|
||||
}
|
||||
break;
|
||||
case '(':
|
||||
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
|
||||
{
|
||||
$bInComment = true;
|
||||
$iStartIndex = $iCurrentIndex;
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
if ($bInComment)
|
||||
{
|
||||
$iEndIndex = $iCurrentIndex;
|
||||
$sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
|
||||
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
|
||||
$iEndIndex = 0;
|
||||
$iCurrentIndex = 0;
|
||||
$iStartIndex = 0;
|
||||
$bInComment = false;
|
||||
}
|
||||
break;
|
||||
case '\\':
|
||||
$iCurrentIndex++;
|
||||
break;
|
||||
}
|
||||
|
||||
$iCurrentIndex++;
|
||||
}
|
||||
|
||||
$iCurrentIndex++;
|
||||
}
|
||||
|
||||
if ($sEmail.length === 0)
|
||||
{
|
||||
$aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i);
|
||||
if ($aRegs && $aRegs[0])
|
||||
if ($sEmail.length === 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(/[>]+$/, '');
|
||||
$sName = Utils.trim($sName).replace(/^["']+/, '').replace(/["']+$/, '');
|
||||
$sComment = Utils.trim($sComment).replace(/^[(]+/, '').replace(/[)]+$/, '');
|
||||
module.exports = EmailModel;
|
||||
|
||||
// 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 ()
|
||||
{
|
||||
return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
|
||||
};
|
||||
}(module));
|
||||
|
|
@ -1,48 +1,62 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterConditionModel(oKoList)
|
||||
{
|
||||
this.parentList = oKoList;
|
||||
(function (module) {
|
||||
|
||||
this.field = ko.observable(Enums.FilterConditionField.From);
|
||||
'use strict';
|
||||
|
||||
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
|
||||
ko = require('../External/ko.js'),
|
||||
Enums = require('../Common/Enums.js')
|
||||
;
|
||||
|
||||
this.type = ko.observable(Enums.FilterConditionType.EqualTo);
|
||||
|
||||
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'}
|
||||
];
|
||||
/**
|
||||
* @param {*} oKoList
|
||||
* @constructor
|
||||
*/
|
||||
function FilterConditionModel(oKoList)
|
||||
{
|
||||
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 = '';
|
||||
switch (this.type())
|
||||
{
|
||||
default:
|
||||
sTemplate = 'SettingsFiltersConditionDefault';
|
||||
break;
|
||||
}
|
||||
this.type = ko.observable(Enums.FilterConditionType.EqualTo);
|
||||
|
||||
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.parentList.remove(this);
|
||||
};
|
||||
this.template = ko.computed(function () {
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterModel()
|
||||
{
|
||||
this.new = ko.observable(true);
|
||||
this.enabled = ko.observable(true);
|
||||
(function (module) {
|
||||
|
||||
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([]);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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'])
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterModel()
|
||||
{
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FolderModel()
|
||||
{
|
||||
this.name = ko.observable('');
|
||||
this.fullName = '';
|
||||
this.fullNameRaw = '';
|
||||
this.fullNameHash = '';
|
||||
this.delimiter = '';
|
||||
this.namespace = '';
|
||||
this.deep = 0;
|
||||
this.interval = 0;
|
||||
(function (module) {
|
||||
|
||||
this.selectable = false;
|
||||
this.existen = true;
|
||||
'use strict';
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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'])
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FolderModel()
|
||||
{
|
||||
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.name = ko.observable('');
|
||||
this.fullName = '';
|
||||
this.fullNameRaw = '';
|
||||
this.fullNameHash = '';
|
||||
this.delimiter = '';
|
||||
this.namespace = '';
|
||||
this.deep = 0;
|
||||
this.interval = 0;
|
||||
|
||||
this.subScribed(!!oJsonFolder.IsSubscribed);
|
||||
this.type('INBOX' === this.fullNameRaw ? Enums.FolderType.Inbox : Enums.FolderType.User);
|
||||
this.selectable = false;
|
||||
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}
|
||||
*/
|
||||
FolderModel.prototype.printableFullName = function ()
|
||||
{
|
||||
return this.fullName.split(this.delimiter).join(' / ');
|
||||
};
|
||||
/**
|
||||
* @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); // 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 */
|
||||
|
||||
/**
|
||||
* @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('');
|
||||
(function (module) {
|
||||
|
||||
this.deleteAccess = ko.observable(false);
|
||||
this.canBeDalete = ko.observable(bCanBeDelete);
|
||||
}
|
||||
'use strict';
|
||||
|
||||
IdentityModel.prototype.formattedName = function ()
|
||||
{
|
||||
var sName = this.name();
|
||||
return '' === sName ? this.email() : sName + ' <' + this.email() + '>';
|
||||
};
|
||||
var
|
||||
ko = require('../External/ko.js'),
|
||||
Utils = require('../Common/Utils.js')
|
||||
;
|
||||
|
||||
IdentityModel.prototype.formattedNameForCompose = function ()
|
||||
{
|
||||
var sName = this.name();
|
||||
return '' === sName ? this.email() : sName + ' (' + this.email() + ')';
|
||||
};
|
||||
/**
|
||||
* @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('');
|
||||
|
||||
IdentityModel.prototype.formattedNameForEmail = function ()
|
||||
{
|
||||
var sName = this.name();
|
||||
return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>';
|
||||
};
|
||||
this.deleteAccess = ko.observable(false);
|
||||
this.canBeDalete = ko.observable(bCanBeDelete);
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
OpenPgpKeyModel.prototype.index = 0;
|
||||
OpenPgpKeyModel.prototype.id = '';
|
||||
OpenPgpKeyModel.prototype.guid = '';
|
||||
OpenPgpKeyModel.prototype.user = '';
|
||||
OpenPgpKeyModel.prototype.email = '';
|
||||
OpenPgpKeyModel.prototype.armor = '';
|
||||
OpenPgpKeyModel.prototype.isPrivate = false;
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('./ko.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
|
||||
/**
|
||||
* @param {Array} aViewModels
|
||||
* @constructor
|
||||
* @extends KnoinAbstractScreen
|
||||
*/
|
||||
function AbstractSettings(aViewModels)
|
||||
{
|
||||
KnoinAbstractScreen.call(this, 'settings', aViewModels);
|
||||
|
||||
this.menu = ko.observableArray([]);
|
||||
(function (module) {
|
||||
|
||||
this.oCurrentSubScreen = null;
|
||||
this.oViewModelPlace = null;
|
||||
}
|
||||
'use strict';
|
||||
|
||||
_.extend(AbstractSettings.prototype, KnoinAbstractScreen.prototype);
|
||||
|
||||
AbstractSettings.prototype.onRoute = function (sSubName)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oSettingsScreen = null,
|
||||
RoutedSettingsViewModel = null,
|
||||
oViewModelPlace = null,
|
||||
oViewModelDom = null
|
||||
$ = require('./External/jquery.js'),
|
||||
_ = require('./External/underscore.js'),
|
||||
ko = require('./External/ko.js'),
|
||||
Globals = require('./Common/Globals.js'),
|
||||
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 &&
|
||||
sSubName === SettingsViewModel.__rlSettingsData.Route;
|
||||
});
|
||||
|
||||
if (RoutedSettingsViewModel)
|
||||
/**
|
||||
* @param {Array} aViewModels
|
||||
* @constructor
|
||||
* @extends KnoinAbstractScreen
|
||||
*/
|
||||
function AbstractSettings(aViewModels)
|
||||
{
|
||||
if (_.find(ViewModels['settings-removed'], function (DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
||||
}))
|
||||
{
|
||||
RoutedSettingsViewModel = null;
|
||||
}
|
||||
|
||||
if (RoutedSettingsViewModel && _.find(ViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
||||
}))
|
||||
{
|
||||
RoutedSettingsViewModel = null;
|
||||
}
|
||||
KnoinAbstractScreen.call(this, 'settings', aViewModels);
|
||||
|
||||
this.menu = ko.observableArray([]);
|
||||
|
||||
this.oCurrentSubScreen = null;
|
||||
this.oViewModelPlace = 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;
|
||||
}
|
||||
else
|
||||
{
|
||||
oViewModelPlace = this.oViewModelPlace;
|
||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
||||
if (_.find(Globals.aViewModels['settings-removed'], function (DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
||||
}))
|
||||
{
|
||||
RoutedSettingsViewModel = /** @type {?Function} */ RoutedSettingsViewModel;
|
||||
oSettingsScreen = new RoutedSettingsViewModel();
|
||||
RoutedSettingsViewModel = null;
|
||||
}
|
||||
|
||||
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
||||
oViewModelDom.appendTo(oViewModelPlace);
|
||||
|
||||
oSettingsScreen.data = RL.data();
|
||||
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);
|
||||
if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
|
||||
}))
|
||||
{
|
||||
RoutedSettingsViewModel = null;
|
||||
}
|
||||
}
|
||||
|
||||
Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
|
||||
if (RoutedSettingsViewModel)
|
||||
{
|
||||
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
|
||||
{
|
||||
oSettingsScreen = RoutedSettingsViewModel.__vm;
|
||||
}
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (oSettingsScreen)
|
||||
else
|
||||
{
|
||||
_.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();
|
||||
});
|
||||
kn.setHash(RL.link().settings(), false, true); // TODO cjs
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.setHash(RL.link().settings(), false, true);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
AbstractSettings.prototype.onHide = function ()
|
||||
{
|
||||
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
|
||||
AbstractSettings.prototype.onHide = function ()
|
||||
{
|
||||
Utils.delegateRun(this.oCurrentSubScreen, 'onHide');
|
||||
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;
|
||||
}))
|
||||
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
|
||||
{
|
||||
this.menu.push({
|
||||
'route': SettingsViewModel.__rlSettingsData.Route,
|
||||
'label': SettingsViewModel.__rlSettingsData.Label,
|
||||
'selected': ko.observable(false),
|
||||
'disabled': !!_.find(ViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel;
|
||||
})
|
||||
});
|
||||
Utils.delegateRun(this.oCurrentSubScreen, 'onHide');
|
||||
this.oCurrentSubScreen.viewModelDom.hide();
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.oViewModelPlace = $('#rl-content #rl-settings-subscreen');
|
||||
};
|
||||
|
||||
AbstractSettings.prototype.routes = function ()
|
||||
{
|
||||
var
|
||||
DefaultViewModel = _.find(ViewModels['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];
|
||||
AbstractSettings.prototype.onBuild = function ()
|
||||
{
|
||||
_.each(Globals.aViewModels['settings'], function (SettingsViewModel) {
|
||||
if (SettingsViewModel && SettingsViewModel.__rlSettingsData &&
|
||||
!_.find(Globals.aViewModels['settings-removed'], function (RemoveSettingsViewModel) {
|
||||
return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel;
|
||||
}))
|
||||
{
|
||||
this.menu.push({
|
||||
'route': SettingsViewModel.__rlSettingsData.Route,
|
||||
'label': SettingsViewModel.__rlSettingsData.Label,
|
||||
'selected': ko.observable(false),
|
||||
'disabled': !!_.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
|
||||
return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel;
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
;
|
||||
}, this);
|
||||
|
||||
return [
|
||||
['{subname}/', oRules],
|
||||
['{subname}', oRules],
|
||||
['', oRules]
|
||||
];
|
||||
};
|
||||
this.oViewModelPlace = $('#rl-content #rl-settings-subscreen');
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractScreen
|
||||
*/
|
||||
function AdminLoginScreen()
|
||||
{
|
||||
KnoinAbstractScreen.call(this, 'login', [AdminLoginViewModel]);
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
_.extend(AdminLoginScreen.prototype, KnoinAbstractScreen.prototype);
|
||||
'use strict';
|
||||
|
||||
AdminLoginScreen.prototype.onShow = function ()
|
||||
{
|
||||
RL.setTitle('');
|
||||
};
|
||||
var
|
||||
_ = require('./External/underscore.js'),
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSettings
|
||||
*/
|
||||
function AdminSettingsScreen()
|
||||
{
|
||||
AbstractSettings.call(this, [
|
||||
AdminMenuViewModel,
|
||||
AdminPaneViewModel
|
||||
]);
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
_.extend(AdminSettingsScreen.prototype, AbstractSettings.prototype);
|
||||
'use strict';
|
||||
|
||||
AdminSettingsScreen.prototype.onShow = function ()
|
||||
{
|
||||
RL.setTitle('');
|
||||
};
|
||||
var
|
||||
_ = require('./External/underscore.js'),
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractScreen
|
||||
*/
|
||||
function LoginScreen()
|
||||
{
|
||||
KnoinAbstractScreen.call(this, 'login', [LoginViewModel]);
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
_.extend(LoginScreen.prototype, KnoinAbstractScreen.prototype);
|
||||
'use strict';
|
||||
|
||||
LoginScreen.prototype.onShow = function ()
|
||||
{
|
||||
RL.setTitle('');
|
||||
};
|
||||
var
|
||||
_ = require('./External/underscore.js'),
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractScreen
|
||||
*/
|
||||
function MailBoxScreen()
|
||||
{
|
||||
KnoinAbstractScreen.call(this, 'mailbox', [
|
||||
MailBoxSystemDropDownViewModel,
|
||||
MailBoxFolderListViewModel,
|
||||
MailBoxMessageListViewModel,
|
||||
MailBoxMessageViewViewModel
|
||||
]);
|
||||
(function (module) {
|
||||
|
||||
this.oLastRoute = {};
|
||||
}
|
||||
'use strict';
|
||||
|
||||
_.extend(MailBoxScreen.prototype, KnoinAbstractScreen.prototype);
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
MailBoxScreen.prototype.oLastRoute = {};
|
||||
|
||||
MailBoxScreen.prototype.setNewTitle = function ()
|
||||
{
|
||||
var
|
||||
sEmail = RL.data().accountEmail(),
|
||||
ifoldersInboxUnreadCount = RL.data().foldersInboxUnreadCount()
|
||||
_ = require('./External/underscore.js'),
|
||||
$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'));
|
||||
};
|
||||
|
||||
MailBoxScreen.prototype.onShow = function ()
|
||||
{
|
||||
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)
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractScreen
|
||||
*/
|
||||
function MailBoxScreen()
|
||||
{
|
||||
if (Enums.Layout.NoPreview === RL.data().layout() && !RL.data().message())
|
||||
{
|
||||
RL.historyBack();
|
||||
}
|
||||
KnoinAbstractScreen.call(this, 'mailbox', [
|
||||
MailBoxSystemDropDownViewModel,
|
||||
MailBoxFolderListViewModel,
|
||||
MailBoxMessageListViewModel,
|
||||
MailBoxMessageViewViewModel
|
||||
]);
|
||||
|
||||
this.oLastRoute = {};
|
||||
}
|
||||
else
|
||||
|
||||
_.extend(MailBoxScreen.prototype, KnoinAbstractScreen.prototype);
|
||||
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
MailBoxScreen.prototype.oLastRoute = {};
|
||||
|
||||
MailBoxScreen.prototype.setNewTitle = function ()
|
||||
{
|
||||
var
|
||||
oData = RL.data(),
|
||||
sFolderFullNameRaw = RL.cache().getFolderFullNameRaw(sFolderHash),
|
||||
oFolder = RL.cache().getFolderFromCacheList(sFolderFullNameRaw)
|
||||
sEmail = RL.data().accountEmail(), // TODO cjs
|
||||
ifoldersInboxUnreadCount = RL.data().foldersInboxUnreadCount() // TODO cjs
|
||||
;
|
||||
// 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
|
||||
.currentFolder(oFolder)
|
||||
.messageListPage(iPage)
|
||||
.messageListSearch(sSearch)
|
||||
if (Enums.Layout.NoPreview === RL.data().layout() && !RL.data().message())// TODO cjs
|
||||
{
|
||||
RL.historyBack();// TODO cjs
|
||||
}
|
||||
}
|
||||
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 ()
|
||||
{
|
||||
var
|
||||
oData = RL.data(),
|
||||
fResizeFunction = function () {
|
||||
Utils.windowResize();
|
||||
}
|
||||
;
|
||||
|
||||
if (RL.capa(Enums.Capa.AdditionalAccounts) || RL.capa(Enums.Capa.AdditionalIdentities))
|
||||
MailBoxScreen.prototype.onStart = function ()
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
}
|
||||
var
|
||||
oData = RL.data(),// TODO cjs
|
||||
fResizeFunction = function () {
|
||||
Utils.windowResize();
|
||||
}
|
||||
;
|
||||
|
||||
_.delay(function () {
|
||||
if ('INBOX' !== oData.currentFolderFullNameRaw())
|
||||
if (RL.capa(Enums.Capa.AdditionalAccounts) || RL.capa(Enums.Capa.AdditionalIdentities))// TODO cjs
|
||||
{
|
||||
RL.folderInformation('INBOX');
|
||||
RL.accountsAndIdentities();// TODO cjs
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
_.delay(function () {
|
||||
RL.quota();
|
||||
}, 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)
|
||||
_.delay(function () {
|
||||
if ('INBOX' !== oData.currentFolderFullNameRaw())
|
||||
{
|
||||
oVals[0] = 'Inbox';
|
||||
oVals[1] = 1;
|
||||
RL.folderInformation('INBOX');// TODO cjs
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
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]);
|
||||
_.delay(function () {
|
||||
RL.quota();// TODO cjs
|
||||
}, 5000);
|
||||
|
||||
if ('' === oRequest)
|
||||
{
|
||||
oVals[0] = 'Inbox';
|
||||
_.delay(function () {
|
||||
RL.remote().appDelayStart(Utils.emptyFunction);// TODO cjs
|
||||
}, 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 [
|
||||
[/^([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}]
|
||||
];
|
||||
};
|
||||
module.exports = MailBoxScreen;
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,28 +1,46 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSettings
|
||||
*/
|
||||
function SettingsScreen()
|
||||
{
|
||||
AbstractSettings.call(this, [
|
||||
SettingsSystemDropDownViewModel,
|
||||
SettingsMenuViewModel,
|
||||
SettingsPaneViewModel
|
||||
]);
|
||||
(function (module) {
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sSettingsTitle = Utils.i18n('TITLES/SETTINGS');
|
||||
}, this, function () {
|
||||
RL.setTitle(this.sSettingsTitle);
|
||||
});
|
||||
}
|
||||
'use strict';
|
||||
|
||||
_.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 ()
|
||||
{
|
||||
RL.setTitle(this.sSettingsTitle);
|
||||
RL.data().keyScope(Enums.KeyState.Settings);
|
||||
};
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSettings
|
||||
*/
|
||||
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',
|
||||
'cache': true
|
||||
}).done(function() {
|
||||
Utils.i18nToDoc();
|
||||
Utils.i18nReload();
|
||||
self.languageTrigger(Enums.SaveSettingsStep.TrueResult);
|
||||
}).fail(function() {
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AbstractData()
|
||||
{
|
||||
this.leftPanelDisabled = ko.observable(false);
|
||||
this.useKeyboardShortcuts = ko.observable(true);
|
||||
(function (module) {
|
||||
|
||||
this.keyScopeReal = ko.observable(Enums.KeyState.All);
|
||||
this.keyScopeFake = ko.observable(Enums.KeyState.All);
|
||||
'use strict';
|
||||
|
||||
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
|
||||
mLayout = Utils.pInt(RL.settingsGet('Layout')),
|
||||
aLanguages = RL.settingsGet('Languages'),
|
||||
aThemes = RL.settingsGet('Themes')
|
||||
ko = require('./External/ko.js'),
|
||||
key = require('./External/key.js'),
|
||||
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'));
|
||||
this.mainTheme(RL.settingsGet('Theme'));
|
||||
if (Utils.isArray(aLanguages))
|
||||
{
|
||||
this.languages(aLanguages);
|
||||
}
|
||||
|
||||
this.capaAdditionalAccounts(RL.capa(Enums.Capa.AdditionalAccounts));
|
||||
this.capaAdditionalIdentities(RL.capa(Enums.Capa.AdditionalIdentities));
|
||||
this.capaGravatar(RL.capa(Enums.Capa.Gravatar));
|
||||
this.determineUserLanguage(!!RL.settingsGet('DetermineUserLanguage'));
|
||||
this.determineUserDomain(!!RL.settingsGet('DetermineUserDomain'));
|
||||
if (Utils.isArray(aThemes))
|
||||
{
|
||||
this.themes(aThemes);
|
||||
}
|
||||
|
||||
this.capaThemes(RL.capa(Enums.Capa.Themes));
|
||||
this.allowLanguagesOnLogin(!!RL.settingsGet('AllowLanguagesOnLogin'));
|
||||
this.allowLanguagesOnSettings(!!RL.settingsGet('AllowLanguagesOnSettings'));
|
||||
this.useLocalProxyForExternalImages(!!RL.settingsGet('UseLocalProxyForExternalImages'));
|
||||
this.mainLanguage(RL.settingsGet('Language'));
|
||||
this.mainTheme(RL.settingsGet('Theme'));
|
||||
|
||||
this.editorDefaultType(RL.settingsGet('EditorDefaultType'));
|
||||
this.showImages(!!RL.settingsGet('ShowImages'));
|
||||
this.contactsAutosave(!!RL.settingsGet('ContactsAutosave'));
|
||||
this.interfaceAnimation(RL.settingsGet('InterfaceAnimation'));
|
||||
this.capaAdditionalAccounts(RL.capa(Enums.Capa.AdditionalAccounts));
|
||||
this.capaAdditionalIdentities(RL.capa(Enums.Capa.AdditionalIdentities));
|
||||
this.capaGravatar(RL.capa(Enums.Capa.Gravatar));
|
||||
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.useThreads(!!RL.settingsGet('UseThreads'));
|
||||
this.replySameFolder(!!RL.settingsGet('ReplySameFolder'));
|
||||
this.useCheckboxesInList(!!RL.settingsGet('UseCheckboxesInList'));
|
||||
this.editorDefaultType(RL.settingsGet('EditorDefaultType'));
|
||||
this.showImages(!!RL.settingsGet('ShowImages'));
|
||||
this.contactsAutosave(!!RL.settingsGet('ContactsAutosave'));
|
||||
this.interfaceAnimation(RL.settingsGet('InterfaceAnimation'));
|
||||
|
||||
this.layout(Enums.Layout.SidePreview);
|
||||
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.mainMessagesPerPage(RL.settingsGet('MPP'));
|
||||
|
||||
this.twitterEnable(!!RL.settingsGet('AllowTwitterSocial'));
|
||||
this.twitterConsumerKey(RL.settingsGet('TwitterConsumerKey'));
|
||||
this.twitterConsumerSecret(RL.settingsGet('TwitterConsumerSecret'));
|
||||
this.desktopNotifications(!!RL.settingsGet('DesktopNotifications'));
|
||||
this.useThreads(!!RL.settingsGet('UseThreads'));
|
||||
this.replySameFolder(!!RL.settingsGet('ReplySameFolder'));
|
||||
this.useCheckboxesInList(!!RL.settingsGet('UseCheckboxesInList'));
|
||||
|
||||
this.googleEnable(!!RL.settingsGet('AllowGoogleSocial'));
|
||||
this.googleClientID(RL.settingsGet('GoogleClientID'));
|
||||
this.googleClientSecret(RL.settingsGet('GoogleClientSecret'));
|
||||
this.googleApiKey(RL.settingsGet('GoogleApiKey'));
|
||||
this.layout(Enums.Layout.SidePreview);
|
||||
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.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
||||
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
||||
this.twitterEnable(!!RL.settingsGet('AllowTwitterSocial'));
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LocalStorage()
|
||||
{
|
||||
(function (module) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
sStorages = [
|
||||
LocalStorageDriver,
|
||||
CookieDriver
|
||||
],
|
||||
NextStorageDriver = _.find(sStorages, function (NextStorageDriver) {
|
||||
return NextStorageDriver.supported();
|
||||
})
|
||||
_ = require('./External/underscore.js'),
|
||||
CookieDriver = require('./Storages/LocalStorages/CookieDriver.js'),
|
||||
LocalStorageDriver = require('./Storages/LocalStorages/LocalStorageDriver.js')
|
||||
;
|
||||
|
||||
if (NextStorageDriver)
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LocalStorage()
|
||||
{
|
||||
NextStorageDriver = /** @type {?Function} */ NextStorageDriver;
|
||||
this.oDriver = new NextStorageDriver();
|
||||
var
|
||||
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 {*} mData
|
||||
* @return {boolean}
|
||||
*/
|
||||
LocalStorage.prototype.set = function (iKey, mData)
|
||||
{
|
||||
return this.oDriver ? this.oDriver.set('p' + iKey, mData) : false;
|
||||
};
|
||||
/**
|
||||
* @param {number} iKey
|
||||
* @param {*} mData
|
||||
* @return {boolean}
|
||||
*/
|
||||
LocalStorage.prototype.set = function (iKey, mData)
|
||||
{
|
||||
return this.oDriver ? this.oDriver.set('p' + iKey, mData) : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} iKey
|
||||
* @return {*}
|
||||
*/
|
||||
LocalStorage.prototype.get = function (iKey)
|
||||
{
|
||||
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
|
||||
};
|
||||
/**
|
||||
* @param {number} iKey
|
||||
* @return {*}
|
||||
*/
|
||||
LocalStorage.prototype.get = function (iKey)
|
||||
{
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function CookieDriver()
|
||||
{
|
||||
(function (module) {
|
||||
|
||||
}
|
||||
'use strict';
|
||||
|
||||
CookieDriver.supported = function ()
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {*} mData
|
||||
* @returns {boolean}
|
||||
*/
|
||||
CookieDriver.prototype.set = function (sKey, mData)
|
||||
{
|
||||
var
|
||||
mCokieValue = $.cookie(Consts.Values.ClientSideCookieIndexName),
|
||||
bResult = false,
|
||||
mResult = null
|
||||
$ = require('./External/jquery.js'),
|
||||
JSON = require('./External/JSON.js'),
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @returns {*}
|
||||
*/
|
||||
CookieDriver.prototype.get = function (sKey)
|
||||
{
|
||||
var
|
||||
mCokieValue = $.cookie(Consts.Values.ClientSideCookieIndexName),
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
CookieDriver.supported = function ()
|
||||
{
|
||||
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
|
||||
if (mResult && !Utils.isUnd(mResult[sKey]))
|
||||
{
|
||||
mResult = mResult[sKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
mResult = null;
|
||||
}
|
||||
}
|
||||
catch (oException) {}
|
||||
return true;
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LocalStorageDriver()
|
||||
{
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
LocalStorageDriver.supported = function ()
|
||||
{
|
||||
return !!window.localStorage;
|
||||
};
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @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
|
||||
window = require('./External/window.js'),
|
||||
JSON = require('./External/JSON.js'),
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @returns {*}
|
||||
*/
|
||||
LocalStorageDriver.prototype.get = function (sKey)
|
||||
{
|
||||
var
|
||||
mCokieValue = window.localStorage[Consts.Values.ClientSideCookieIndexName] || null,
|
||||
mResult = null
|
||||
;
|
||||
|
||||
try
|
||||
LocalStorageDriver.supported = function ()
|
||||
{
|
||||
mResult = null === mCokieValue ? null : JSON.parse(mCokieValue);
|
||||
if (mResult && !Utils.isUnd(mResult[sKey]))
|
||||
{
|
||||
mResult = mResult[sKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
mResult = null;
|
||||
}
|
||||
}
|
||||
catch (oException) {}
|
||||
return !!window.localStorage;
|
||||
};
|
||||
|
||||
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
|
||||
}).done(function() {
|
||||
self.bSendLanguage = true;
|
||||
Utils.i18nToDoc();
|
||||
Utils.i18nReload();
|
||||
$.cookie('rllang', RL.data().language(), {'expires': 30});
|
||||
}).always(function() {
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownViewModel
|
||||
*/
|
||||
function MailBoxSystemDropDownViewModel()
|
||||
{
|
||||
AbstractSystemDropDownViewModel.call(this);
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function SettingsMenuViewModel(oScreen)
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu');
|
||||
(function (module) {
|
||||
|
||||
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)
|
||||
{
|
||||
return RL.link().settings(sRoute);
|
||||
};
|
||||
this.menu = oScreen.menu;
|
||||
|
||||
SettingsMenuViewModel.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(RL.link().inbox());
|
||||
};
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function SettingsPaneViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane');
|
||||
(function (module) {
|
||||
|
||||
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 ()
|
||||
{
|
||||
var self = this;
|
||||
key('esc', Enums.KeyState.Settings, function () {
|
||||
self.backToMailBoxClick();
|
||||
});
|
||||
};
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function SettingsPaneViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane');
|
||||
|
||||
SettingsPaneViewModel.prototype.onShow = function ()
|
||||
{
|
||||
RL.data().message(null);
|
||||
};
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
SettingsPaneViewModel.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(RL.link().inbox());
|
||||
};
|
||||
Utils.extendAsViewModel('SettingsPaneViewModel', SettingsPaneViewModel);
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownViewModel
|
||||
*/
|
||||
function SettingsSystemDropDownViewModel()
|
||||
{
|
||||
AbstractSystemDropDownViewModel.call(this);
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
(function (module) {
|
||||
|
||||
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('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": "*",
|
||||
"jshint-summary": "*",
|
||||
|
||||
"browserify": "*",
|
||||
"vinyl-source-stream": "latest",
|
||||
|
||||
"gulp": "*",
|
||||
"gulp-util": "*",
|
||||
"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