]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs);
sText = '\n' + $.trim(sText) + '\n';
}
return sText;
}
return '';
},
convertPre = function () {
return (arguments && 1 < arguments.length) ? arguments[1].toString().replace(/[\n]/gm, '
') : '';
},
fixAttibuteValue = function () {
return (arguments && 1 < arguments.length) ?
'' + arguments[1] + arguments[2].replace(//g, '>') : '';
},
convertLinks = function () {
return (arguments && 1 < arguments.length) ? $.trim(arguments[1]) : '';
}
;
sText = sHtml
.replace(/
]*>([\s\S\r\n]*)<\/pre>/gmi, convertPre)
.replace(/[\s]+/gm, ' ')
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
.replace(/
]*>/gmi, '\n')
.replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n')
.replace(/<\/td>/gi, '\n')
.replace(/<\/tr>/gi, '\n')
.replace(/
]*>/gmi, '\n_______________________________\n\n')
.replace(/]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs)
.replace(/
]*>/gmi, '\n__bq__start__\n')
.replace(/<\/blockquote>/gmi, '\n__bq__end__\n')
.replace(/]*>([\s\S\r\n]*?)<\/a>/gmi, convertLinks)
.replace(/<\/div>/gi, '\n')
.replace(/ /gi, ' ')
.replace(/"/gi, '"')
.replace(/<[^>]*>/gm, '')
;
sText = $div.html(sText).text();
sText = sText
.replace(/\n[ \t]+/gm, '\n')
.replace(/[\n]{3,}/gm, '\n\n')
.replace(/>/gi, '>')
.replace(/</gi, '<')
.replace(/&/gi, '&')
;
iPos = 0;
iLimit = 100;
while (0 < iLimit)
{
iLimit--;
iP1 = sText.indexOf('__bq__start__', iPos);
if (-1 < iP1)
{
iP2 = sText.indexOf('__bq__start__', iP1 + 5);
iP3 = sText.indexOf('__bq__end__', iP1 + 5);
if ((-1 === iP2 || iP3 < iP2) && iP1 < iP3)
{
sText = sText.substring(0, iP1) +
convertBlockquote(sText.substring(iP1 + 13, iP3)) +
sText.substring(iP3 + 11);
iPos = 0;
}
else if (-1 < iP2 && iP2 < iP3)
{
iPos = iP2 - 1;
}
else
{
iPos = 0;
}
}
else
{
break;
}
}
sText = sText
.replace(/__bq__start__/gm, '')
.replace(/__bq__end__/gm, '')
;
return sText;
};
/**
* @param {string} sPlain
* @param {boolean} bLinkify = false
* @return {string}
*/
Utils.plainToHtml = function (sPlain, bLinkify)
{
sPlain = sPlain.toString().replace(/\r/g, '');
var
bIn = false,
bDo = true,
bStart = true,
aNextText = [],
sLine = '',
iIndex = 0,
aText = sPlain.split("\n")
;
do
{
bDo = false;
aNextText = [];
for (iIndex = 0; iIndex < aText.length; iIndex++)
{
sLine = aText[iIndex];
bStart = '>' === sLine.substr(0, 1);
if (bStart && !bIn)
{
bDo = true;
bIn = true;
aNextText.push('~~~blockquote~~~');
aNextText.push(sLine.substr(1));
}
else if (!bStart && bIn)
{
bIn = false;
aNextText.push('~~~/blockquote~~~');
aNextText.push(sLine);
}
else if (bStart && bIn)
{
aNextText.push(sLine.substr(1));
}
else
{
aNextText.push(sLine);
}
}
if (bIn)
{
bIn = false;
aNextText.push('~~~/blockquote~~~');
}
aText = aNextText;
}
while (bDo);
sPlain = aText.join("\n");
sPlain = sPlain
.replace(/&/g, '&')
.replace(/>/g, '>').replace(/')
.replace(/[\s]*~~~\/blockquote~~~/g, '
')
.replace(/[\-_~]{10,}/g, '
')
.replace(/\n/g, '
');
return bLinkify ? Utils.linkify(sPlain) : sPlain;
};
window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain;
window.rainloop_Utils_plainToHtml = Utils.plainToHtml;
/**
* @param {string} sHtml
* @return {string}
*/
Utils.linkify = function (sHtml)
{
if ($.fn && $.fn.linkify)
{
sHtml = $div.html(sHtml.replace(/&/ig, 'amp_amp_12345_amp_amp'))
.linkify()
.find('.linkified').removeClass('linkified').end()
.html()
.replace(/amp_amp_12345_amp_amp/g, '&')
;
}
return sHtml;
};
Utils.resizeAndCrop = function (sUrl, iValue, fCallback)
{
var oTempImg = new window.Image();
oTempImg.onload = function() {
var
aDiff = [0, 0],
oCanvas = window.document.createElement('canvas'),
oCtx = oCanvas.getContext('2d')
;
oCanvas.width = iValue;
oCanvas.height = iValue;
if (this.width > this.height)
{
aDiff = [this.width - this.height, 0];
}
else
{
aDiff = [0, this.height - this.width];
}
oCtx.fillStyle = '#fff';
oCtx.fillRect(0, 0, iValue, iValue);
oCtx.drawImage(this, aDiff[0] / 2, aDiff[1] / 2, this.width - aDiff[0], this.height - aDiff[1], 0, 0, iValue, iValue);
fCallback(oCanvas.toDataURL('image/jpeg'));
};
oTempImg.src = sUrl;
};
/**
* @param {Array} aSystem
* @param {Array} aList
* @param {Array=} aDisabled
* @param {Array=} aHeaderLines
* @param {?number=} iUnDeep
* @param {Function=} fDisableCallback
* @param {Function=} fVisibleCallback
* @param {Function=} fRenameCallback
* @param {boolean=} bSystem
* @param {boolean=} bBuildUnvisible
* @return {Array}
*/
Utils.folderListOptionsBuilder = function (aSystem, aList, aDisabled, aHeaderLines, iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible)
{
var
/**
* @type {?FolderModel}
*/
oItem = null,
bSep = false,
iIndex = 0,
iLen = 0,
sDeepPrefix = '\u00A0\u00A0\u00A0',
aResult = []
;
bSystem = !Utils.isNormal(bSystem) ? 0 < aSystem.length : bSystem;
bBuildUnvisible = Utils.isUnd(bBuildUnvisible) ? false : !!bBuildUnvisible;
iUnDeep = !Utils.isNormal(iUnDeep) ? 0 : iUnDeep;
fDisableCallback = Utils.isNormal(fDisableCallback) ? fDisableCallback : null;
fVisibleCallback = Utils.isNormal(fVisibleCallback) ? fVisibleCallback : null;
fRenameCallback = Utils.isNormal(fRenameCallback) ? fRenameCallback : null;
if (!Utils.isArray(aDisabled))
{
aDisabled = [];
}
if (!Utils.isArray(aHeaderLines))
{
aHeaderLines = [];
}
for (iIndex = 0, iLen = aHeaderLines.length; iIndex < iLen; iIndex++)
{
aResult.push({
'id': aHeaderLines[iIndex][0],
'name': aHeaderLines[iIndex][1],
'system': false,
'seporator': false,
'disabled': false
});
}
bSep = true;
for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++)
{
oItem = aSystem[iIndex];
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true)
{
if (bSep && 0 < aResult.length)
{
aResult.push({
'id': '---',
'name': '---',
'system': false,
'seporator': true,
'disabled': true
});
}
bSep = false;
aResult.push({
'id': oItem.fullNameRaw,
'name': fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name(),
'system': true,
'seporator': false,
'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false)
});
}
}
bSep = true;
for (iIndex = 0, iLen = aList.length; iIndex < iLen; iIndex++)
{
oItem = aList[iIndex];
if (oItem.subScribed() || !oItem.existen)
{
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true)
{
if (Enums.FolderType.User === oItem.type() || !bSystem || 0 < oItem.subFolders().length)
{
if (bSep && 0 < aResult.length)
{
aResult.push({
'id': '---',
'name': '---',
'system': false,
'seporator': true,
'disabled': true
});
}
bSep = false;
aResult.push({
'id': oItem.fullNameRaw,
'name': (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) +
(fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name()),
'system': false,
'seporator': false,
'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false)
});
}
}
}
if (oItem.subScribed() && 0 < oItem.subFolders().length)
{
aResult = aResult.concat(Utils.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [],
iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible));
}
}
return aResult;
};
Utils.computedPagenatorHelper = function (koCurrentPage, koPageCount)
{
return function() {
var
iPrev = 0,
iNext = 0,
iLimit = 2,
aResult = [],
iCurrentPage = koCurrentPage(),
iPageCount = koPageCount(),
/**
* @param {number} iIndex
* @param {boolean=} bPush
* @param {string=} sCustomName
*/
fAdd = function (iIndex, bPush, sCustomName) {
var oData = {
'current': iIndex === iCurrentPage,
'name': Utils.isUnd(sCustomName) ? iIndex.toString() : sCustomName.toString(),
'custom': Utils.isUnd(sCustomName) ? false : true,
'title': Utils.isUnd(sCustomName) ? '' : iIndex.toString(),
'value': iIndex.toString()
};
if (Utils.isUnd(bPush) ? true : !!bPush)
{
aResult.push(oData);
}
else
{
aResult.unshift(oData);
}
}
;
if (1 < iPageCount || (0 < iPageCount && iPageCount < iCurrentPage))
// if (0 < iPageCount && 0 < iCurrentPage)
{
if (iPageCount < iCurrentPage)
{
fAdd(iPageCount);
iPrev = iPageCount;
iNext = iPageCount;
}
else
{
if (3 >= iCurrentPage || iPageCount - 2 <= iCurrentPage)
{
iLimit += 2;
}
fAdd(iCurrentPage);
iPrev = iCurrentPage;
iNext = iCurrentPage;
}
while (0 < iLimit) {
iPrev -= 1;
iNext += 1;
if (0 < iPrev)
{
fAdd(iPrev, false);
iLimit--;
}
if (iPageCount >= iNext)
{
fAdd(iNext, true);
iLimit--;
}
else if (0 >= iPrev)
{
break;
}
}
if (3 === iPrev)
{
fAdd(2, false);
}
else if (3 < iPrev)
{
fAdd(window.Math.round((iPrev - 1) / 2), false, '...');
}
if (iPageCount - 2 === iNext)
{
fAdd(iPageCount - 1, true);
}
else if (iPageCount - 2 > iNext)
{
fAdd(window.Math.round((iPageCount + iNext) / 2), true, '...');
}
// first and last
if (1 < iPrev)
{
fAdd(1, false);
}
if (iPageCount > iNext)
{
fAdd(iPageCount, true);
}
}
return aResult;
};
};
Utils.selectElement = function (element)
{
/* jshint onevar: false */
if (window.getSelection)
{
var sel = window.getSelection();
sel.removeAllRanges();
var range = window.document.createRange();
range.selectNodeContents(element);
sel.addRange(range);
}
else if (window.document.selection)
{
var textRange = window.document.body.createTextRange();
textRange.moveToElementText(element);
textRange.select();
}
/* jshint onevar: true */
};
Utils.detectDropdownVisibility = _.debounce(function () {
Globals.dropdownVisibility(!!_.find(Globals.aBootstrapDropdowns, function (oItem) {
return oItem.hasClass('open');
}));
}, 50);
Utils.triggerAutocompleteInputChange = function (bDelay) {
var fFunc = function () {
$('.checkAutocomplete').trigger('change');
};
if (bDelay)
{
_.delay(fFunc, 100);
}
else
{
fFunc();
}
};
module.exports = Utils;
}(module, require));
},{"$":21,"$div":12,"$doc":13,"$html":14,"$win":15,"Consts":5,"Enums":6,"Globals":8,"NotificationClass":18,"_":26,"ko":23,"window":27}],12:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = require('$')('
');
},{"$":21}],13:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = require('$')(window.document);
},{"$":21}],14:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = require('$')('html');
},{"$":21}],15:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = require('$')(window);
},{"$":21}],16:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = require('window')['rainloopAppData'] || {};
},{"window":27}],17:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = JSON;
},{}],18:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
var w = require('window');
module.exports = w.Notification && w.Notification.requestPermission ? w.Notification : null;
},{"window":27}],19:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = crossroads;
},{}],20:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = hasher;
},{}],21:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = $;
},{}],22:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = key;
},{}],23:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, ko) {
'use strict';
var
window = require('window'),
_ = require('_'),
$ = require('$'),
$win = require('$win'),
$doc = require('$doc')
;
ko.bindingHandlers.tooltip = {
'init': function (oElement, fValueAccessor) {
var
Globals = require('Globals'),
Utils = require('Utils')
;
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() ? '' : '
' +
Utils.i18n(ko.utils.unwrapObservable(fValueAccessor())) + '';
}
}).click(function () {
$oEl.tooltip('hide');
});
Globals.tooltipTrigger.subscribe(function () {
$oEl.tooltip('hide');
});
}
}
};
ko.bindingHandlers.tooltip2 = {
'init': function (oElement, fValueAccessor) {
var
Globals = require('Globals'),
$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() ? '' :
'
' + fValueAccessor()() + '';
}
}).click(function () {
$oEl.tooltip('hide');
});
Globals.tooltipTrigger.subscribe(function () {
$oEl.tooltip('hide');
});
}
};
ko.bindingHandlers.tooltip3 = {
'init': function (oElement) {
var
$oEl = $(oElement),
Globals = require('Globals')
;
$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) {
var Globals = require('Globals');
Globals.aBootstrapDropdowns.push($(oElement));
}
};
ko.bindingHandlers.openDropdownTrigger = {
'update': function (oElement, fValueAccessor) {
if (ko.utils.unwrapObservable(fValueAccessor()))
{
var
$el = $(oElement),
Utils = require('Utils')
;
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) {
var Utils = require('Utils');
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) {
var Utils = require('Utils');
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) {
var
Globals = require('Globals'),
Utils = require('Utils')
;
$(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) {
var Utils = require('Utils');
Utils.i18nToNode(oElement);
}
};
ko.bindingHandlers.i18nUpdate = {
'update': function (oElement, fValueAccessor) {
var Utils = require('Utils');
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
Utils = require('Utils'),
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 = $win.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) {
var
Globals = require('Globals'),
Utils = require('Utils')
;
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) {
var Globals = require('Globals');
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) {
var Globals = require('Globals');
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(
'
'
).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, fAllBindingsAccessor) {
var
Utils = require('Utils'),
EmailModel = require('Model:Email'),
$oEl = $(oElement),
fValue = fValueAccessor(),
fAllBindings = fAllBindingsAccessor(),
fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null,
fFocusCallback = function (bValue) {
if (fValue && fValue.focusTrigger)
{
fValue.focusTrigger(bValue);
}
}
;
$oEl.inputosaurus({
'parseOnBlur': true,
'allowDragAndDrop': true,
'focusCallback': fFocusCallback,
'inputDelimiters': [',', ';'],
'autoCompleteSource': fAutoCompleteSource,
'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, fAllBindingsAccessor) {
var
Utils = require('Utils'),
ContactTagModel = require('Model:ContactTag'),
$oEl = $(oElement),
fValue = fValueAccessor(),
fAllBindings = fAllBindingsAccessor(),
fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null,
fFocusCallback = function (bValue) {
if (fValue && fValue.focusTrigger)
{
fValue.focusTrigger(bValue);
}
}
;
$oEl.inputosaurus({
'parseOnBlur': true,
'allowDragAndDrop': false,
'focusCallback': fFocusCallback,
'inputDelimiters': [',', ';'],
'outputDelimiter': ',',
'autoCompleteSource': fAutoCompleteSource,
'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
Utils = require('Utils'),
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
Utils = require('Utils'),
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)
{
var Utils = require('Utils');
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 ()
{
var Utils = require('Utils');
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 ()
{
var Utils = require('Utils');
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)
{
var Utils = require('Utils');
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, ko));
},{"$":21,"$doc":13,"$win":15,"Globals":8,"Model:ContactTag":33,"Model:Email":34,"Utils":11,"_":26,"window":27}],24:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = moment;
},{}],25:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = ssm;
},{}],26:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = _;
},{}],27:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
module.exports = window;
},{}],28:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
$ = require('$'),
_ = require('_'),
ko = require('ko'),
hasher = require('hasher'),
crossroads = require('crossroads'),
$html = require('$html'),
Globals = require('Globals'),
Plugins = require('Plugins'),
Utils = require('Utils'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
*/
function Knoin()
{
this.oScreens = {};
this.sDefaultScreenName = '';
this.oCurrentScreen = null;
}
Knoin.prototype.oScreens = {};
Knoin.prototype.sDefaultScreenName = '';
Knoin.prototype.oCurrentScreen = null;
Knoin.prototype.hideLoading = function ()
{
$('#rl-loading').hide();
};
/**
* @param {Object} thisObject
*/
Knoin.prototype.constructorEnd = function (thisObject)
{
if (Utils.isFunc(thisObject['__constructor_end']))
{
thisObject['__constructor_end'].call(thisObject);
}
};
/**
* @param {string} sName
* @param {Function} ViewModelClass
* @param {Function=} AbstractViewModel = KnoinAbstractViewModel
*/
Knoin.prototype.extendAsViewModel = function (sName, ViewModelClass, AbstractViewModel)
{
if (ViewModelClass)
{
if (!AbstractViewModel)
{
AbstractViewModel = KnoinAbstractViewModel;
}
ViewModelClass.__name = sName;
Plugins.regViewModelHook(sName, ViewModelClass);
_.extend(ViewModelClass.prototype, AbstractViewModel.prototype);
}
};
/**
* @param {Function} SettingsViewModelClass
* @param {string} sLabelName
* @param {string} sTemplate
* @param {string} sRoute
* @param {boolean=} bDefault
*/
Knoin.prototype.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute, bDefault)
{
SettingsViewModelClass.__rlSettingsData = {
'Label': sLabelName,
'Template': sTemplate,
'Route': sRoute,
'IsDefault': !!bDefault
};
Globals.aViewModels['settings'].push(SettingsViewModelClass);
};
/**
* @param {Function} SettingsViewModelClass
*/
Knoin.prototype.removeSettingsViewModel = function (SettingsViewModelClass)
{
Globals.aViewModels['settings-removed'].push(SettingsViewModelClass);
};
/**
* @param {Function} SettingsViewModelClass
*/
Knoin.prototype.disableSettingsViewModel = function (SettingsViewModelClass)
{
Globals.aViewModels['settings-disabled'].push(SettingsViewModelClass);
};
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
kn = this,
oViewModel = new ViewModelClass(oScreen),
sPosition = oViewModel.viewModelPosition(),
oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()),
oViewModelDom = null
;
ViewModelClass.__builded = true;
ViewModelClass.__vm = oViewModel;
oViewModel.viewModelName = ViewModelClass.__name;
if (oViewModelPlace && 1 === oViewModelPlace.length)
{
oViewModelDom = $('
').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);
});
oViewModel.modalVisibility.subscribe(function (bValue) {
var self = this;
if (bValue)
{
this.viewModelDom.show();
this.storeAndSetKeyScope();
Globals.popupVisibilityNames.push(this.viewModelName);
oViewModel.viewModelDom.css('z-index', 3000 + Globals.popupVisibilityNames().length + 10);
Utils.delegateRun(this, 'onFocus', [], 500);
}
else
{
Utils.delegateRun(this, 'onHide');
this.restoreKeyScope();
Globals.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]);
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]);
}
else
{
Utils.log('Cannot find view model position: ' + sPosition);
}
}
return ViewModelClass ? ViewModelClass.__vm : null;
};
/**
* @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]);
}
};
/**
* @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 || []]);
}
}
};
/**
* @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
self = this,
oScreen = null,
oCross = null
;
if ('' === Utils.pString(sScreenName))
{
sScreenName = this.sDefaultScreenName;
}
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()))
{
_.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]);
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 ? oScreen.__cross() : null;
if (oCross)
{
oCross.parse(sSubPart);
}
});
}
}
};
/**
* @param {Array} aScreensClasses
*/
Knoin.prototype.startScreens = function (aScreensClasses)
{
$('#rl-content').css({
'visibility': 'hidden'
});
_.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);
}
};
module.exports = new Knoin();
}(module, require));
},{"$":21,"$html":14,"Globals":8,"Knoin:AbstractViewModel":31,"Plugins":10,"Utils":11,"_":26,"crossroads":19,"hasher":20,"ko":23}],29:[function(require,module,exports){
/* 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, require));
},{}],30:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
crossroads = require('crossroads'),
Utils = require('Utils')
;
/**
* @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, require));
},{"Utils":11,"crossroads":19}],31:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
ko = require('ko'),
$win = require('$win'),
Enums = require('Enums'),
Globals = require('Globals'),
Utils = require('Utils')
;
/**
* @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 = function () {};
KnoinAbstractViewModel.prototype.closeCommand = function () {};
KnoinAbstractViewModel.prototype.storeAndSetKeyScope = function ()
{
this.sCurrentKeyScope = Globals.keyScope();
Globals.keyScope(this.sDefaultKeyScope);
};
KnoinAbstractViewModel.prototype.restoreKeyScope = function ()
{
Globals.keyScope(this.sCurrentKeyScope);
};
KnoinAbstractViewModel.prototype.registerPopupKeyDown = function ()
{
var self = this;
$win.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, require));
},{"$win":15,"Enums":6,"Globals":8,"Utils":11,"ko":23}],32:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
window = require('window'),
Globals = require('Globals'),
Utils = require('Utils'),
LinkBuilder = require('LinkBuilder')
;
/**
* @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 = '';
}
/**
* @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 LinkBuilder.attachmentDownload(this.download);
};
/**
* @return {string}
*/
AttachmentModel.prototype.linkPreview = function ()
{
return LinkBuilder.attachmentPreview(this.download);
};
/**
* @return {string}
*/
AttachmentModel.prototype.linkPreviewAsPlain = function ()
{
return LinkBuilder.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, require));
},{"Globals":8,"LinkBuilder":9,"Utils":11,"window":27}],33:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
ko = require('ko'),
Utils = require('Utils')
;
/**
* @constructor
*/
function ContactTagModel()
{
this.idContactTag = 0;
this.name = ko.observable('');
this.readOnly = false;
}
ContactTagModel.prototype.parse = function (oItem)
{
var bResult = false;
if (oItem && 'Object/Tag' === oItem['@Object'])
{
this.idContact = Utils.pInt(oItem['IdContactTag']);
this.name(Utils.pString(oItem['Name']));
this.readOnly = !!oItem['ReadOnly'];
bResult = true;
}
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, require));
},{"Utils":11,"ko":23}],34:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
Enums = require('Enums'),
Utils = require('Utils')
;
/**
* @param {string=} sEmail
* @param {string=} sName
*
* @constructor
*/
function EmailModel(sEmail, sName)
{
this.email = sEmail || '';
this.name = sName || '';
this.privateType = null;
this.clearDuplicateName();
}
/**
* @static
* @param {AjaxJsonEmail} oJsonEmail
* @return {?EmailModel}
*/
EmailModel.newInstanceFromJson = function (oJsonEmail)
{
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)
{
if (this.email && '@facebook.com' === this.email.substr(-13))
{
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 ? '
') +
'" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.name) + '' :
(bEncodeHtml ? Utils.encodeHtml(this.name) : this.name);
}
else
{
sResult = this.email;
if ('' !== this.name)
{
if (bWrapWithLink)
{
sResult = Utils.encodeHtml('"' + this.name + '" <') +
'
') + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(sResult) + '' + Utils.encodeHtml('>');
}
else
{
sResult = '"' + this.name + '" <' + sResult + '>';
if (bEncodeHtml)
{
sResult = Utils.encodeHtml(sResult);
}
}
}
else if (bWrapWithLink)
{
sResult = '
' + Utils.encodeHtml(this.email) + '';
}
}
}
return sResult;
};
/**
* @param {string} $sEmailAddress
* @return {boolean}
*/
EmailModel.prototype.mailsoParse = function ($sEmailAddress)
{
$sEmailAddress = Utils.trim($sEmailAddress);
if ('' === $sEmailAddress)
{
return false;
}
var
substr = function (str, start, len) {
str += '';
var end = str.length;
if (start < 0) {
start += end;
}
end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start);
return start >= str.length || start < 0 || start > end ? false : str.slice(start, end);
},
substr_replace = function (str, replace, start, length) {
if (start < 0) {
start = start + str.length;
}
length = length !== undefined ? length : str.length;
if (length < 0) {
length = length + str.length - start;
}
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);
},
$sName = '',
$sEmail = '',
$sComment = '',
$bInName = false,
$bInAddress = false,
$bInComment = false,
$aRegs = null,
$iStartIndex = 0,
$iEndIndex = 0,
$iCurrentIndex = 0
;
while ($iCurrentIndex < $sEmailAddress.length)
{
switch ($sEmailAddress.substr($iCurrentIndex, 1))
{
case '"':
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
{
$bInName = true;
$iStartIndex = $iCurrentIndex;
}
else if ((!$bInAddress) && (!$bInComment))
{
$iEndIndex = $iCurrentIndex;
$sName = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
$iEndIndex = 0;
$iCurrentIndex = 0;
$iStartIndex = 0;
$bInName = false;
}
break;
case '<':
if ((!$bInName) && (!$bInAddress) && (!$bInComment))
{
if ($iCurrentIndex > 0 && $sName.length === 0)
{
$sName = substr($sEmailAddress, 0, $iCurrentIndex);
}
$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++;
}
if ($sEmail.length === 0)
{
$aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i);
if ($aRegs && $aRegs[0])
{
$sEmail = $aRegs[0];
}
else
{
$sName = $sEmailAddress;
}
}
if ($sEmail.length > 0 && $sName.length === 0 && $sComment.length === 0)
{
$sName = $sEmailAddress.replace($sEmail, '');
}
$sEmail = Utils.trim($sEmail).replace(/^[<]+/, '').replace(/[>]+$/, '');
$sName = Utils.trim($sName).replace(/^["']+/, '').replace(/["']+$/, '');
$sComment = Utils.trim($sComment).replace(/^[(]+/, '').replace(/[)]+$/, '');
// Remove backslash
$sName = $sName.replace(/\\\\(.)/g, '$1');
$sComment = $sComment.replace(/\\\\(.)/g, '$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.exports = EmailModel;
}(module, require));
},{"Enums":6,"Utils":11}],35:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
window = require('window'),
$ = require('$'),
_ = require('_'),
ko = require('ko'),
moment = require('moment'),
$win = require('$win'),
$div = require('$div'),
Enums = require('Enums'),
Utils = require('Utils'),
LinkBuilder = require('LinkBuilder'),
EmailModel = require('Model:Email'),
AttachmentModel = require('Model:Attachment')
;
/**
* @constructor
*/
function MessageModel()
{
this.folderFullNameRaw = '';
this.uid = '';
this.hash = '';
this.requestHash = '';
this.subject = ko.observable('');
this.subjectPrefix = ko.observable('');
this.subjectSuffix = ko.observable('');
this.size = ko.observable(0);
this.dateTimeStampInUTC = ko.observable(0);
this.priority = ko.observable(Enums.MessagePriority.Normal);
this.proxy = false;
this.fromEmailString = ko.observable('');
this.fromClearEmailString = ko.observable('');
this.toEmailsString = ko.observable('');
this.toClearEmailsString = ko.observable('');
this.senderEmailsString = ko.observable('');
this.senderClearEmailsString = ko.observable('');
this.emails = [];
this.from = [];
this.to = [];
this.cc = [];
this.bcc = [];
this.replyTo = [];
this.deliveredTo = [];
this.newForAnimation = ko.observable(false);
this.deleted = ko.observable(false);
this.unseen = ko.observable(false);
this.flagged = ko.observable(false);
this.answered = ko.observable(false);
this.forwarded = ko.observable(false);
this.isReadReceipt = ko.observable(false);
this.focused = ko.observable(false);
this.selected = ko.observable(false);
this.checked = ko.observable(false);
this.hasAttachments = ko.observable(false);
this.attachmentsMainType = ko.observable('');
this.moment = ko.observable(moment(moment.unix(0)));
this.attachmentIconClass = ko.computed(function () {
var sClass = '';
if (this.hasAttachments())
{
sClass = 'icon-attachment';
switch (this.attachmentsMainType())
{
case 'image':
sClass = 'icon-image';
break;
case 'archive':
sClass = 'icon-file-zip';
break;
case 'doc':
sClass = 'icon-file-text';
break;
// case 'pdf':
// sClass = 'icon-file-pdf';
// break;
}
}
return sClass;
}, this);
this.fullFormatDateValue = ko.computed(function () {
return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
}, this);
this.momentDate = Utils.createMomentDate(this);
this.momentShortDate = Utils.createMomentShortDate(this);
this.dateTimeStampInUTC.subscribe(function (iValue) {
var iNow = moment().unix();
this.moment(moment.unix(iNow < iValue ? iNow : iValue));
}, this);
this.body = null;
this.plainRaw = '';
this.isHtml = ko.observable(false);
this.hasImages = ko.observable(false);
this.attachments = ko.observableArray([]);
this.isPgpSigned = ko.observable(false);
this.isPgpEncrypted = ko.observable(false);
this.pgpSignedVerifyStatus = ko.observable(Enums.SignedVerifyStatus.None);
this.pgpSignedVerifyUser = ko.observable('');
this.priority = ko.observable(Enums.MessagePriority.Normal);
this.readReceipt = ko.observable('');
this.aDraftInfo = [];
this.sMessageId = '';
this.sInReplyTo = '';
this.sReferences = '';
this.parentUid = ko.observable(0);
this.threads = ko.observableArray([]);
this.threadsLen = ko.observable(0);
this.hasUnseenSubMessage = ko.observable(false);
this.hasFlaggedSubMessage = ko.observable(false);
this.lastInCollapsedThread = ko.observable(false);
this.lastInCollapsedThreadLoading = ko.observable(false);
this.threadsLenResult = ko.computed(function () {
var iCount = this.threadsLen();
return 0 === this.parentUid() && 0 < iCount ? iCount + 1 : '';
}, this);
}
/**
* @static
* @param {AjaxJsonMessage} oJsonMessage
* @return {?MessageModel}
*/
MessageModel.newInstanceFromJson = function (oJsonMessage)
{
var oMessageModel = new MessageModel();
return oMessageModel.initByJson(oJsonMessage) ? oMessageModel : null;
};
/**
* @static
* @param {number} iTimeStampInUTC
* @return {string}
*/
MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC)
{
return 0 < iTimeStampInUTC ? moment.unix(iTimeStampInUTC).format('LLL') : '';
};
/**
* @static
* @param {Array} aEmail
* @param {boolean=} bFriendlyView
* @param {boolean=} bWrapWithLink = false
* @return {string}
*/
MessageModel.emailsToLine = function (aEmail, bFriendlyView, bWrapWithLink)
{
var
aResult = [],
iIndex = 0,
iLen = 0
;
if (Utils.isNonEmptyArray(aEmail))
{
for (iIndex = 0, iLen = aEmail.length; iIndex < iLen; iIndex++)
{
aResult.push(aEmail[iIndex].toLine(bFriendlyView, bWrapWithLink));
}
}
return aResult.join(', ');
};
/**
* @static
* @param {Array} aEmail
* @return {string}
*/
MessageModel.emailsToLineClear = function (aEmail)
{
var
aResult = [],
iIndex = 0,
iLen = 0
;
if (Utils.isNonEmptyArray(aEmail))
{
for (iIndex = 0, iLen = aEmail.length; iIndex < iLen; iIndex++)
{
if (aEmail[iIndex] && aEmail[iIndex].email && '' !== aEmail[iIndex].name)
{
aResult.push(aEmail[iIndex].email);
}
}
}
return aResult.join(', ');
};
/**
* @static
* @param {?Array} aJsonEmails
* @return {Array.
}
*/
MessageModel.initEmailsFromJson = function (aJsonEmails)
{
var
iIndex = 0,
iLen = 0,
oEmailModel = null,
aResult = []
;
if (Utils.isNonEmptyArray(aJsonEmails))
{
for (iIndex = 0, iLen = aJsonEmails.length; iIndex < iLen; iIndex++)
{
oEmailModel = EmailModel.newInstanceFromJson(aJsonEmails[iIndex]);
if (oEmailModel)
{
aResult.push(oEmailModel);
}
}
}
return aResult;
};
/**
* @static
* @param {Array.} aMessageEmails
* @param {Object} oLocalUnic
* @param {Array} aLocalEmails
*/
MessageModel.replyHelper = function (aMessageEmails, oLocalUnic, aLocalEmails)
{
if (aMessageEmails && 0 < aMessageEmails.length)
{
var
iIndex = 0,
iLen = aMessageEmails.length
;
for (; iIndex < iLen; iIndex++)
{
if (Utils.isUnd(oLocalUnic[aMessageEmails[iIndex].email]))
{
oLocalUnic[aMessageEmails[iIndex].email] = true;
aLocalEmails.push(aMessageEmails[iIndex]);
}
}
}
};
MessageModel.prototype.clear = function ()
{
this.folderFullNameRaw = '';
this.uid = '';
this.hash = '';
this.requestHash = '';
this.subject('');
this.subjectPrefix('');
this.subjectSuffix('');
this.size(0);
this.dateTimeStampInUTC(0);
this.priority(Enums.MessagePriority.Normal);
this.proxy = false;
this.fromEmailString('');
this.fromClearEmailString('');
this.toEmailsString('');
this.toClearEmailsString('');
this.senderEmailsString('');
this.senderClearEmailsString('');
this.emails = [];
this.from = [];
this.to = [];
this.cc = [];
this.bcc = [];
this.replyTo = [];
this.deliveredTo = [];
this.newForAnimation(false);
this.deleted(false);
this.unseen(false);
this.flagged(false);
this.answered(false);
this.forwarded(false);
this.isReadReceipt(false);
this.selected(false);
this.checked(false);
this.hasAttachments(false);
this.attachmentsMainType('');
this.body = null;
this.isHtml(false);
this.hasImages(false);
this.attachments([]);
this.isPgpSigned(false);
this.isPgpEncrypted(false);
this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);
this.pgpSignedVerifyUser('');
this.priority(Enums.MessagePriority.Normal);
this.readReceipt('');
this.aDraftInfo = [];
this.sMessageId = '';
this.sInReplyTo = '';
this.sReferences = '';
this.parentUid(0);
this.threads([]);
this.threadsLen(0);
this.hasUnseenSubMessage(false);
this.hasFlaggedSubMessage(false);
this.lastInCollapsedThread(false);
this.lastInCollapsedThreadLoading(false);
};
MessageModel.prototype.computeSenderEmail = function ()
{
var
Data = require('Storage:RainLoop:Data'),
sSent = Data.sentFolder(),
sDraft = Data.draftFolder()
;
this.senderEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ?
this.toEmailsString() : this.fromEmailString());
this.senderClearEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ?
this.toClearEmailsString() : this.fromClearEmailString());
};
/**
* @param {AjaxJsonMessage} oJsonMessage
* @return {boolean}
*/
MessageModel.prototype.initByJson = function (oJsonMessage)
{
var bResult = false;
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
{
this.folderFullNameRaw = oJsonMessage.Folder;
this.uid = oJsonMessage.Uid;
this.hash = oJsonMessage.Hash;
this.requestHash = oJsonMessage.RequestHash;
this.proxy = !!oJsonMessage.ExternalProxy;
this.size(Utils.pInt(oJsonMessage.Size));
this.from = MessageModel.initEmailsFromJson(oJsonMessage.From);
this.to = MessageModel.initEmailsFromJson(oJsonMessage.To);
this.cc = MessageModel.initEmailsFromJson(oJsonMessage.Cc);
this.bcc = MessageModel.initEmailsFromJson(oJsonMessage.Bcc);
this.replyTo = MessageModel.initEmailsFromJson(oJsonMessage.ReplyTo);
this.deliveredTo = MessageModel.initEmailsFromJson(oJsonMessage.DeliveredTo);
this.subject(oJsonMessage.Subject);
if (Utils.isArray(oJsonMessage.SubjectParts))
{
this.subjectPrefix(oJsonMessage.SubjectParts[0]);
this.subjectSuffix(oJsonMessage.SubjectParts[1]);
}
else
{
this.subjectPrefix('');
this.subjectSuffix(this.subject());
}
this.dateTimeStampInUTC(Utils.pInt(oJsonMessage.DateTimeStampInUTC));
this.hasAttachments(!!oJsonMessage.HasAttachments);
this.attachmentsMainType(oJsonMessage.AttachmentsMainType);
this.fromEmailString(MessageModel.emailsToLine(this.from, true));
this.fromClearEmailString(MessageModel.emailsToLineClear(this.from));
this.toEmailsString(MessageModel.emailsToLine(this.to, true));
this.toClearEmailsString(MessageModel.emailsToLineClear(this.to));
this.parentUid(Utils.pInt(oJsonMessage.ParentThread));
this.threads(Utils.isArray(oJsonMessage.Threads) ? oJsonMessage.Threads : []);
this.threadsLen(Utils.pInt(oJsonMessage.ThreadsLen));
this.initFlagsByJson(oJsonMessage);
this.computeSenderEmail();
bResult = true;
}
return bResult;
};
/**
* @param {AjaxJsonMessage} oJsonMessage
* @return {boolean}
*/
MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage)
{
var
Data = require('Storage:RainLoop:Data'),
bResult = false,
iPriority = Enums.MessagePriority.Normal
;
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
{
iPriority = Utils.pInt(oJsonMessage.Priority);
this.priority(-1 < Utils.inArray(iPriority, [Enums.MessagePriority.High, Enums.MessagePriority.Low]) ?
iPriority : Enums.MessagePriority.Normal);
this.aDraftInfo = oJsonMessage.DraftInfo;
this.sMessageId = oJsonMessage.MessageId;
this.sInReplyTo = oJsonMessage.InReplyTo;
this.sReferences = oJsonMessage.References;
this.proxy = !!oJsonMessage.ExternalProxy;
if (Data.capaOpenPGP())
{
this.isPgpSigned(!!oJsonMessage.PgpSigned);
this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted);
}
this.hasAttachments(!!oJsonMessage.HasAttachments);
this.attachmentsMainType(oJsonMessage.AttachmentsMainType);
this.foundedCIDs = Utils.isArray(oJsonMessage.FoundedCIDs) ? oJsonMessage.FoundedCIDs : [];
this.attachments(this.initAttachmentsFromJson(oJsonMessage.Attachments));
this.readReceipt(oJsonMessage.ReadReceipt || '');
this.computeSenderEmail();
bResult = true;
}
return bResult;
};
/**
* @param {(AjaxJsonAttachment|null)} oJsonAttachments
* @return {Array}
*/
MessageModel.prototype.initAttachmentsFromJson = function (oJsonAttachments)
{
var
iIndex = 0,
iLen = 0,
oAttachmentModel = null,
aResult = []
;
if (oJsonAttachments && 'Collection/AttachmentCollection' === oJsonAttachments['@Object'] &&
Utils.isNonEmptyArray(oJsonAttachments['@Collection']))
{
for (iIndex = 0, iLen = oJsonAttachments['@Collection'].length; iIndex < iLen; iIndex++)
{
oAttachmentModel = AttachmentModel.newInstanceFromJson(oJsonAttachments['@Collection'][iIndex]);
if (oAttachmentModel)
{
if ('' !== oAttachmentModel.cidWithOutTags && 0 < this.foundedCIDs.length &&
0 <= Utils.inArray(oAttachmentModel.cidWithOutTags, this.foundedCIDs))
{
oAttachmentModel.isLinked = true;
}
aResult.push(oAttachmentModel);
}
}
}
return aResult;
};
/**
* @param {AjaxJsonMessage} oJsonMessage
* @return {boolean}
*/
MessageModel.prototype.initFlagsByJson = function (oJsonMessage)
{
var bResult = false;
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
{
this.unseen(!oJsonMessage.IsSeen);
this.flagged(!!oJsonMessage.IsFlagged);
this.answered(!!oJsonMessage.IsAnswered);
this.forwarded(!!oJsonMessage.IsForwarded);
this.isReadReceipt(!!oJsonMessage.IsReadReceipt);
bResult = true;
}
return bResult;
};
/**
* @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false
* @return {string}
*/
MessageModel.prototype.fromToLine = function (bFriendlyView, bWrapWithLink)
{
return MessageModel.emailsToLine(this.from, bFriendlyView, bWrapWithLink);
};
/**
* @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false
* @return {string}
*/
MessageModel.prototype.toToLine = function (bFriendlyView, bWrapWithLink)
{
return MessageModel.emailsToLine(this.to, bFriendlyView, bWrapWithLink);
};
/**
* @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false
* @return {string}
*/
MessageModel.prototype.ccToLine = function (bFriendlyView, bWrapWithLink)
{
return MessageModel.emailsToLine(this.cc, bFriendlyView, bWrapWithLink);
};
/**
* @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false
* @return {string}
*/
MessageModel.prototype.bccToLine = function (bFriendlyView, bWrapWithLink)
{
return MessageModel.emailsToLine(this.bcc, bFriendlyView, bWrapWithLink);
};
/**
* @return string
*/
MessageModel.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.flagged())
{
aResult.push('flagged');
}
if (this.unseen())
{
aResult.push('unseen');
}
if (this.answered())
{
aResult.push('answered');
}
if (this.forwarded())
{
aResult.push('forwarded');
}
if (this.focused())
{
aResult.push('focused');
}
if (this.hasAttachments())
{
aResult.push('withAttachments');
switch (this.attachmentsMainType())
{
case 'image':
aResult.push('imageOnlyAttachments');
break;
case 'archive':
aResult.push('archiveOnlyAttachments');
break;
}
}
if (this.newForAnimation())
{
aResult.push('new');
}
if ('' === this.subject())
{
aResult.push('emptySubject');
}
if (0 < this.parentUid())
{
aResult.push('hasParentMessage');
}
if (0 < this.threadsLen() && 0 === this.parentUid())
{
aResult.push('hasChildrenMessage');
}
if (this.hasUnseenSubMessage())
{
aResult.push('hasUnseenSubMessage');
}
if (this.hasFlaggedSubMessage())
{
aResult.push('hasFlaggedSubMessage');
}
return aResult.join(' ');
};
/**
* @return {boolean}
*/
MessageModel.prototype.hasVisibleAttachments = function ()
{
return !!_.find(this.attachments(), function (oAttachment) {
return !oAttachment.isLinked;
});
};
/**
* @param {string} sCid
* @return {*}
*/
MessageModel.prototype.findAttachmentByCid = function (sCid)
{
var
oResult = null,
aAttachments = this.attachments()
;
if (Utils.isNonEmptyArray(aAttachments))
{
sCid = sCid.replace(/^<+/, '').replace(/>+$/, '');
oResult = _.find(aAttachments, function (oAttachment) {
return sCid === oAttachment.cidWithOutTags;
});
}
return oResult || null;
};
/**
* @param {string} sContentLocation
* @return {*}
*/
MessageModel.prototype.findAttachmentByContentLocation = function (sContentLocation)
{
var
oResult = null,
aAttachments = this.attachments()
;
if (Utils.isNonEmptyArray(aAttachments))
{
oResult = _.find(aAttachments, function (oAttachment) {
return sContentLocation === oAttachment.contentLocation;
});
}
return oResult || null;
};
/**
* @return {string}
*/
MessageModel.prototype.messageId = function ()
{
return this.sMessageId;
};
/**
* @return {string}
*/
MessageModel.prototype.inReplyTo = function ()
{
return this.sInReplyTo;
};
/**
* @return {string}
*/
MessageModel.prototype.references = function ()
{
return this.sReferences;
};
/**
* @return {string}
*/
MessageModel.prototype.fromAsSingleEmail = function ()
{
return Utils.isArray(this.from) && this.from[0] ? this.from[0].email : '';
};
/**
* @return {string}
*/
MessageModel.prototype.viewLink = function ()
{
return LinkBuilder.messageViewLink(this.requestHash);
};
/**
* @return {string}
*/
MessageModel.prototype.downloadLink = function ()
{
return LinkBuilder.messageDownloadLink(this.requestHash);
};
/**
* @param {Object} oExcludeEmails
* @return {Array}
*/
MessageModel.prototype.replyEmails = function (oExcludeEmails)
{
var
aResult = [],
oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails
;
MessageModel.replyHelper(this.replyTo, oUnic, aResult);
if (0 === aResult.length)
{
MessageModel.replyHelper(this.from, oUnic, aResult);
}
return aResult;
};
/**
* @param {Object} oExcludeEmails
* @return {Array.}
*/
MessageModel.prototype.replyAllEmails = function (oExcludeEmails)
{
var
aToResult = [],
aCcResult = [],
oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails
;
MessageModel.replyHelper(this.replyTo, oUnic, aToResult);
if (0 === aToResult.length)
{
MessageModel.replyHelper(this.from, oUnic, aToResult);
}
MessageModel.replyHelper(this.to, oUnic, aToResult);
MessageModel.replyHelper(this.cc, oUnic, aCcResult);
return [aToResult, aCcResult];
};
/**
* @return {string}
*/
MessageModel.prototype.textBodyToString = function ()
{
return this.body ? this.body.html() : '';
};
/**
* @return {string}
*/
MessageModel.prototype.attachmentsToStringLine = function ()
{
var aAttachLines = _.map(this.attachments(), function (oItem) {
return oItem.fileName + ' (' + oItem.friendlySize + ')';
});
return aAttachLines && 0 < aAttachLines.length ? aAttachLines.join(', ') : '';
};
/**
* @return {Object}
*/
MessageModel.prototype.getDataForWindowPopup = function ()
{
return {
'popupFrom': this.fromToLine(false),
'popupTo': this.toToLine(false),
'popupCc': this.ccToLine(false),
'popupBcc': this.bccToLine(false),
'popupSubject': this.subject(),
'popupDate': this.fullFormatDateValue(),
'popupAttachments': this.attachmentsToStringLine(),
'popupBody': this.textBodyToString()
};
};
/**
* @param {boolean=} bPrint = false
*/
MessageModel.prototype.viewPopupMessage = function (bPrint)
{
Utils.windowPopupKnockout(this.getDataForWindowPopup(), 'PopupsWindowSimpleMessage', this.subject(), function (oPopupWin) {
if (oPopupWin && oPopupWin.document && oPopupWin.document.body)
{
$('img.lazy', oPopupWin.document.body).each(function (iIndex, oImg) {
var
$oImg = $(oImg),
sOrig = $oImg.data('original'),
sSrc = $oImg.attr('src')
;
if (0 <= iIndex && sOrig && !sSrc)
{
$oImg.attr('src', sOrig);
}
});
if (bPrint)
{
window.setTimeout(function () {
oPopupWin.print();
}, 100);
}
}
});
};
MessageModel.prototype.printMessage = function ()
{
this.viewPopupMessage(true);
};
/**
* @returns {string}
*/
MessageModel.prototype.generateUid = function ()
{
return this.folderFullNameRaw + '/' + this.uid;
};
/**
* @param {MessageModel} oMessage
* @return {MessageModel}
*/
MessageModel.prototype.populateByMessageListItem = function (oMessage)
{
this.folderFullNameRaw = oMessage.folderFullNameRaw;
this.uid = oMessage.uid;
this.hash = oMessage.hash;
this.requestHash = oMessage.requestHash;
this.subject(oMessage.subject());
this.subjectPrefix(this.subjectPrefix());
this.subjectSuffix(this.subjectSuffix());
this.size(oMessage.size());
this.dateTimeStampInUTC(oMessage.dateTimeStampInUTC());
this.priority(oMessage.priority());
this.proxy = oMessage.proxy;
this.fromEmailString(oMessage.fromEmailString());
this.fromClearEmailString(oMessage.fromClearEmailString());
this.toEmailsString(oMessage.toEmailsString());
this.toClearEmailsString(oMessage.toClearEmailsString());
this.emails = oMessage.emails;
this.from = oMessage.from;
this.to = oMessage.to;
this.cc = oMessage.cc;
this.bcc = oMessage.bcc;
this.replyTo = oMessage.replyTo;
this.deliveredTo = oMessage.deliveredTo;
this.unseen(oMessage.unseen());
this.flagged(oMessage.flagged());
this.answered(oMessage.answered());
this.forwarded(oMessage.forwarded());
this.isReadReceipt(oMessage.isReadReceipt());
this.selected(oMessage.selected());
this.checked(oMessage.checked());
this.hasAttachments(oMessage.hasAttachments());
this.attachmentsMainType(oMessage.attachmentsMainType());
this.moment(oMessage.moment());
this.body = null;
this.priority(Enums.MessagePriority.Normal);
this.aDraftInfo = [];
this.sMessageId = '';
this.sInReplyTo = '';
this.sReferences = '';
this.parentUid(oMessage.parentUid());
this.threads(oMessage.threads());
this.threadsLen(oMessage.threadsLen());
this.computeSenderEmail();
return this;
};
MessageModel.prototype.showExternalImages = function (bLazy)
{
if (this.body && this.body.data('rl-has-images'))
{
var sAttr = '';
bLazy = Utils.isUnd(bLazy) ? false : bLazy;
this.hasImages(false);
this.body.data('rl-has-images', false);
sAttr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
$('[' + sAttr + ']', this.body).each(function () {
if (bLazy && $(this).is('img'))
{
$(this)
.addClass('lazy')
.attr('data-original', $(this).attr(sAttr))
.removeAttr(sAttr)
;
}
else
{
$(this).attr('src', $(this).attr(sAttr)).removeAttr(sAttr);
}
});
sAttr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url';
$('[' + sAttr + ']', this.body).each(function () {
var sStyle = Utils.trim($(this).attr('style'));
sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
$(this).attr('style', sStyle + $(this).attr(sAttr)).removeAttr(sAttr);
});
if (bLazy)
{
$('img.lazy', this.body).addClass('lazy-inited').lazyload({
'threshold' : 400,
'effect' : 'fadeIn',
'skip_invisible' : false,
'container': $('.RL-MailMessageView .messageView .messageItem .content')[0]
});
$win.resize();
}
Utils.windowResize(500);
}
};
MessageModel.prototype.showInternalImages = function (bLazy)
{
if (this.body && !this.body.data('rl-init-internal-images'))
{
this.body.data('rl-init-internal-images', true);
bLazy = Utils.isUnd(bLazy) ? false : bLazy;
var self = this;
$('[data-x-src-cid]', this.body).each(function () {
var oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-cid'));
if (oAttachment && oAttachment.download)
{
if (bLazy && $(this).is('img'))
{
$(this)
.addClass('lazy')
.attr('data-original', oAttachment.linkPreview());
}
else
{
$(this).attr('src', oAttachment.linkPreview());
}
}
});
$('[data-x-src-location]', this.body).each(function () {
var oAttachment = self.findAttachmentByContentLocation($(this).attr('data-x-src-location'));
if (!oAttachment)
{
oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-location'));
}
if (oAttachment && oAttachment.download)
{
if (bLazy && $(this).is('img'))
{
$(this)
.addClass('lazy')
.attr('data-original', oAttachment.linkPreview());
}
else
{
$(this).attr('src', oAttachment.linkPreview());
}
}
});
$('[data-x-style-cid]', this.body).each(function () {
var
sStyle = '',
sName = '',
oAttachment = self.findAttachmentByCid($(this).attr('data-x-style-cid'))
;
if (oAttachment && oAttachment.linkPreview)
{
sName = $(this).attr('data-x-style-cid-name');
if ('' !== sName)
{
sStyle = Utils.trim($(this).attr('style'));
sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
$(this).attr('style', sStyle + sName + ': url(\'' + oAttachment.linkPreview() + '\')');
}
}
});
if (bLazy)
{
(function ($oImg, oContainer) {
_.delay(function () {
$oImg.addClass('lazy-inited').lazyload({
'threshold' : 400,
'effect' : 'fadeIn',
'skip_invisible' : false,
'container': oContainer
});
}, 300);
}($('img.lazy', self.body), $('.RL-MailMessageView .messageView .messageItem .content')[0]));
}
Utils.windowResize(500);
}
};
MessageModel.prototype.storeDataToDom = function ()
{
if (this.body)
{
this.body.data('rl-is-html', !!this.isHtml());
this.body.data('rl-has-images', !!this.hasImages());
this.body.data('rl-plain-raw', this.plainRaw);
var Data = require('Storage:RainLoop:Data');
if (Data.capaOpenPGP())
{
this.body.data('rl-plain-pgp-signed', !!this.isPgpSigned());
this.body.data('rl-plain-pgp-encrypted', !!this.isPgpEncrypted());
this.body.data('rl-pgp-verify-status', this.pgpSignedVerifyStatus());
this.body.data('rl-pgp-verify-user', this.pgpSignedVerifyUser());
}
}
};
MessageModel.prototype.storePgpVerifyDataToDom = function ()
{
var Data = require('Storage:RainLoop:Data');
if (this.body && Data.capaOpenPGP())
{
this.body.data('rl-pgp-verify-status', this.pgpSignedVerifyStatus());
this.body.data('rl-pgp-verify-user', this.pgpSignedVerifyUser());
}
};
MessageModel.prototype.fetchDataToDom = function ()
{
if (this.body)
{
this.isHtml(!!this.body.data('rl-is-html'));
this.hasImages(!!this.body.data('rl-has-images'));
this.plainRaw = Utils.pString(this.body.data('rl-plain-raw'));
var Data = require('Storage:RainLoop:Data');
if (Data.capaOpenPGP())
{
this.isPgpSigned(!!this.body.data('rl-plain-pgp-signed'));
this.isPgpEncrypted(!!this.body.data('rl-plain-pgp-encrypted'));
this.pgpSignedVerifyStatus(this.body.data('rl-pgp-verify-status'));
this.pgpSignedVerifyUser(this.body.data('rl-pgp-verify-user'));
}
else
{
this.isPgpSigned(false);
this.isPgpEncrypted(false);
this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);
this.pgpSignedVerifyUser('');
}
}
};
MessageModel.prototype.verifyPgpSignedClearMessage = function ()
{
if (this.isPgpSigned())
{
var
aRes = [],
mPgpMessage = null,
Data = require('Storage:RainLoop:Data'),
sFrom = this.from && this.from[0] && this.from[0].email ? this.from[0].email : '',
aPublicKeys = Data.findPublicKeysByEmail(sFrom),
oValidKey = null,
oValidSysKey = null,
sPlain = ''
;
this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Error);
this.pgpSignedVerifyUser('');
try
{
mPgpMessage = window.openpgp.cleartext.readArmored(this.plainRaw);
if (mPgpMessage && mPgpMessage.getText)
{
this.pgpSignedVerifyStatus(
aPublicKeys.length ? Enums.SignedVerifyStatus.Unverified : Enums.SignedVerifyStatus.UnknownPublicKeys);
aRes = mPgpMessage.verify(aPublicKeys);
if (aRes && 0 < aRes.length)
{
oValidKey = _.find(aRes, function (oItem) {
return oItem && oItem.keyid && oItem.valid;
});
if (oValidKey)
{
oValidSysKey = Data.findPublicKeyByHex(oValidKey.keyid.toHex());
if (oValidSysKey)
{
sPlain = mPgpMessage.getText();
this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Success);
this.pgpSignedVerifyUser(oValidSysKey.user);
sPlain =
$div.empty().append(
$('').text(sPlain)
).html()
;
$div.empty();
this.replacePlaneTextBody(sPlain);
}
}
}
}
}
catch (oExc) {}
this.storePgpVerifyDataToDom();
}
};
MessageModel.prototype.decryptPgpEncryptedMessage = function (sPassword)
{
if (this.isPgpEncrypted())
{
var
aRes = [],
mPgpMessage = null,
mPgpMessageDecrypted = null,
Data = require('Storage:RainLoop:Data'),
sFrom = this.from && this.from[0] && this.from[0].email ? this.from[0].email : '',
aPublicKey = Data.findPublicKeysByEmail(sFrom),
oPrivateKey = Data.findSelfPrivateKey(sPassword),
oValidKey = null,
oValidSysKey = null,
sPlain = ''
;
this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Error);
this.pgpSignedVerifyUser('');
if (!oPrivateKey)
{
this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.UnknownPrivateKey);
}
try
{
mPgpMessage = window.openpgp.message.readArmored(this.plainRaw);
if (mPgpMessage && oPrivateKey && mPgpMessage.decrypt)
{
this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Unverified);
mPgpMessageDecrypted = mPgpMessage.decrypt(oPrivateKey);
if (mPgpMessageDecrypted)
{
aRes = mPgpMessageDecrypted.verify(aPublicKey);
if (aRes && 0 < aRes.length)
{
oValidKey = _.find(aRes, function (oItem) {
return oItem && oItem.keyid && oItem.valid;
});
if (oValidKey)
{
oValidSysKey = Data.findPublicKeyByHex(oValidKey.keyid.toHex());
if (oValidSysKey)
{
this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Success);
this.pgpSignedVerifyUser(oValidSysKey.user);
}
}
}
sPlain = mPgpMessageDecrypted.getText();
sPlain =
$div.empty().append(
$('').text(sPlain)
).html()
;
$div.empty();
this.replacePlaneTextBody(sPlain);
}
}
}
catch (oExc) {}
this.storePgpVerifyDataToDom();
}
};
MessageModel.prototype.replacePlaneTextBody = function (sPlain)
{
if (this.body)
{
this.body.html(sPlain).addClass('b-text-part plain');
}
};
/**
* @return {string}
*/
MessageModel.prototype.flagHash = function ()
{
return [this.deleted(), this.unseen(), this.flagged(), this.answered(), this.forwarded(),
this.isReadReceipt()].join('');
};
module.exports = MessageModel;
}(module, require));
},{"$":21,"$div":12,"$win":15,"Enums":6,"LinkBuilder":9,"Model:Attachment":32,"Model:Email":34,"Storage:RainLoop:Data":55,"Utils":11,"_":26,"ko":23,"moment":24,"window":27}],36:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
$ = require('$'),
_ = require('_'),
ko = require('ko'),
Globals = require('Globals'),
Utils = require('Utils'),
LinkBuilder = require('LinkBuilder'),
kn = require('App:Knoin'),
KnoinAbstractScreen = require('Knoin:AbstractScreen')
;
/**
* @param {Array} aViewModels
* @constructor
* @extends KnoinAbstractScreen
*/
function AbstractSettings(aViewModels)
{
KnoinAbstractScreen.call(this, 'settings', aViewModels);
this.menu = ko.observableArray([]);
this.oCurrentSubScreen = null;
this.oViewModelPlace = null;
}
_.extend(AbstractSettings.prototype, KnoinAbstractScreen.prototype);
AbstractSettings.prototype.onRoute = function (sSubName)
{
var
self = this,
oSettingsScreen = null,
RoutedSettingsViewModel = null,
oViewModelPlace = null,
oViewModelDom = null
;
RoutedSettingsViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) {
return SettingsViewModel && SettingsViewModel.__rlSettingsData &&
sSubName === SettingsViewModel.__rlSettingsData.Route;
});
if (RoutedSettingsViewModel)
{
if (_.find(Globals.aViewModels['settings-removed'], function (DisabledSettingsViewModel) {
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
}))
{
RoutedSettingsViewModel = null;
}
if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
}))
{
RoutedSettingsViewModel = null;
}
}
if (RoutedSettingsViewModel)
{
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
{
oSettingsScreen = RoutedSettingsViewModel.__vm;
}
else
{
oViewModelPlace = this.oViewModelPlace;
if (oViewModelPlace && 1 === oViewModelPlace.length)
{
oSettingsScreen = new RoutedSettingsViewModel();
oViewModelDom = $('').addClass('rl-settings-view-model').hide();
oViewModelDom.appendTo(oViewModelPlace);
oSettingsScreen.viewModelDom = oViewModelDom;
oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData;
RoutedSettingsViewModel.__dom = oViewModelDom;
RoutedSettingsViewModel.__builded = true;
RoutedSettingsViewModel.__vm = oSettingsScreen;
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
'i18nInit': true,
'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; }
}, oSettingsScreen);
Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
}
else
{
Utils.log('Cannot find sub settings view model position: SettingsSubScreen');
}
}
if (oSettingsScreen)
{
_.defer(function () {
// hide
if (self.oCurrentSubScreen)
{
Utils.delegateRun(self.oCurrentSubScreen, 'onHide');
self.oCurrentSubScreen.viewModelDom.hide();
}
// --
self.oCurrentSubScreen = oSettingsScreen;
// show
if (self.oCurrentSubScreen)
{
self.oCurrentSubScreen.viewModelDom.show();
Utils.delegateRun(self.oCurrentSubScreen, 'onShow');
Utils.delegateRun(self.oCurrentSubScreen, 'onFocus', [], 200);
_.each(self.menu(), function (oItem) {
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
});
$('#rl-content .b-settings .b-content .content').scrollTop(0);
}
// --
Utils.windowResize();
});
}
}
else
{
kn.setHash(LinkBuilder.settings(), false, true);
}
};
AbstractSettings.prototype.onHide = function ()
{
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
{
Utils.delegateRun(this.oCurrentSubScreen, 'onHide');
this.oCurrentSubScreen.viewModelDom.hide();
}
};
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);
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, require));
},{"$":21,"App:Knoin":28,"Globals":8,"Knoin:AbstractScreen":30,"LinkBuilder":9,"Utils":11,"_":26,"ko":23}],37:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
KnoinAbstractScreen = require('Knoin:AbstractScreen')
;
/**
* @constructor
* @extends KnoinAbstractScreen
*/
function AdminLoginScreen()
{
KnoinAbstractScreen.call(this, 'login', [
require('View:Admin:Login')
]);
}
_.extend(AdminLoginScreen.prototype, KnoinAbstractScreen.prototype);
AdminLoginScreen.prototype.onShow = function ()
{
require('App:Admin').setTitle('');
};
module.exports = AdminLoginScreen;
}(module, require));
},{"App:Admin":3,"Knoin:AbstractScreen":30,"View:Admin:Login":60,"_":26}],38:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
AbstractSettings = require('Screen:AbstractSettings')
;
/**
* @constructor
* @extends AbstractSettings
*/
function AdminSettingsScreen()
{
AbstractSettings.call(this, [
require('View:Admin:SettingsMenu'),
require('View:Admin:SettingsPane')
]);
}
_.extend(AdminSettingsScreen.prototype, AbstractSettings.prototype);
AdminSettingsScreen.prototype.onShow = function ()
{
require('App:Admin').setTitle('');
};
module.exports = AdminSettingsScreen;
}(module, require));
},{"App:Admin":3,"Screen:AbstractSettings":36,"View:Admin:SettingsMenu":61,"View:Admin:SettingsPane":62,"_":26}],39:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
ko = require('ko')
;
/**
* @constructor
*/
function AdminSettingsAbout()
{
var
Settings = require('Storage:Settings'),
Data = require('Storage:Admin:Data')
;
this.version = ko.observable(Settings.settingsGet('Version'));
this.access = ko.observable(!!Settings.settingsGet('CoreAccess'));
this.errorDesc = ko.observable('');
this.coreReal = Data.coreReal;
this.coreUpdatable = Data.coreUpdatable;
this.coreAccess = Data.coreAccess;
this.coreChecking = Data.coreChecking;
this.coreUpdating = Data.coreUpdating;
this.coreRemoteVersion = Data.coreRemoteVersion;
this.coreRemoteRelease = Data.coreRemoteRelease;
this.coreVersionCompare = Data.coreVersionCompare;
this.statusType = ko.computed(function () {
var
sType = '',
iVersionCompare = this.coreVersionCompare(),
bChecking = this.coreChecking(),
bUpdating = this.coreUpdating(),
bReal = this.coreReal()
;
if (bChecking)
{
sType = 'checking';
}
else if (bUpdating)
{
sType = 'updating';
}
else if (bReal && 0 === iVersionCompare)
{
sType = 'up-to-date';
}
else if (bReal && -1 === iVersionCompare)
{
sType = 'available';
}
else if (!bReal)
{
sType = 'error';
this.errorDesc('Cannot access the repository at the moment.');
}
return sType;
}, this);
}
AdminSettingsAbout.prototype.onBuild = function ()
{
if (this.access())
{
require('App:Admin').reloadCoreData();
}
};
AdminSettingsAbout.prototype.updateCoreData = function ()
{
if (!this.coreUpdating())
{
require('App:Admin').updateCoreData();
}
};
module.exports = AdminSettingsAbout;
}(module, require));
},{"App:Admin":3,"Storage:Admin:Data":52,"Storage:Settings":59,"ko":23}],40:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Utils = require('Utils')
;
/**
* @constructor
*/
function AdminSettingsBranding()
{
var
Enums = require('Enums'),
Settings = require('Storage:Settings')
;
this.title = ko.observable(Settings.settingsGet('Title'));
this.title.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loadingDesc = ko.observable(Settings.settingsGet('LoadingDescription'));
this.loadingDesc.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginLogo = ko.observable(Settings.settingsGet('LoginLogo'));
this.loginLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginDescription = ko.observable(Settings.settingsGet('LoginDescription'));
this.loginDescription.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginCss = ko.observable(Settings.settingsGet('LoginCss'));
this.loginCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
AdminSettingsBranding.prototype.onBuild = function ()
{
var
self = this,
Remote = require('Storage:Admin:Remote')
;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self)
;
self.title.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'Title': Utils.trim(sValue)
});
});
self.loadingDesc.subscribe(function (sValue) {
Remote.saveAdminConfig(f2, {
'LoadingDescription': Utils.trim(sValue)
});
});
self.loginLogo.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'LoginLogo': Utils.trim(sValue)
});
});
self.loginDescription.subscribe(function (sValue) {
Remote.saveAdminConfig(f4, {
'LoginDescription': Utils.trim(sValue)
});
});
self.loginCss.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'LoginCss': Utils.trim(sValue)
});
});
}, 50);
};
module.exports = AdminSettingsBranding;
}(module, require));
},{"Enums":6,"Storage:Admin:Remote":53,"Storage:Settings":59,"Utils":11,"_":26,"ko":23}],41:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils'),
Settings = require('Storage:Settings')
;
/**
* @constructor
*/
function AdminSettingsContacts()
{
var
Remote = require('Storage:Admin:Remote')
;
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
this.enableContacts = ko.observable(!!Settings.settingsGet('ContactsEnable'));
this.contactsSharing = ko.observable(!!Settings.settingsGet('ContactsSharing'));
this.contactsSync = ko.observable(!!Settings.settingsGet('ContactsSync'));
var
aTypes = ['sqlite', 'mysql', 'pgsql'],
aSupportedTypes = [],
getTypeName = function(sName) {
switch (sName)
{
case 'sqlite':
sName = 'SQLite';
break;
case 'mysql':
sName = 'MySQL';
break;
case 'pgsql':
sName = 'PostgreSQL';
break;
}
return sName;
}
;
if (!!Settings.settingsGet('SQLiteIsSupported'))
{
aSupportedTypes.push('sqlite');
}
if (!!Settings.settingsGet('MySqlIsSupported'))
{
aSupportedTypes.push('mysql');
}
if (!!Settings.settingsGet('PostgreSqlIsSupported'))
{
aSupportedTypes.push('pgsql');
}
this.contactsSupported = 0 < aSupportedTypes.length;
this.contactsTypes = ko.observableArray([]);
this.contactsTypesOptions = this.contactsTypes.map(function (sValue) {
var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes);
return {
'id': sValue,
'name': getTypeName(sValue) + (bDisabled ? ' (not supported)' : ''),
'disabled': bDisabled
};
});
this.contactsTypes(aTypes);
this.contactsType = ko.observable('');
this.mainContactsType = ko.computed({
'owner': this,
'read': this.contactsType,
'write': function (sValue) {
if (sValue !== this.contactsType())
{
if (-1 < Utils.inArray(sValue, aSupportedTypes))
{
this.contactsType(sValue);
}
else if (0 < aSupportedTypes.length)
{
this.contactsType('');
}
}
else
{
this.contactsType.valueHasMutated();
}
}
});
this.contactsType.subscribe(function () {
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
}, this);
this.pdoDsn = ko.observable(Settings.settingsGet('ContactsPdoDsn'));
this.pdoUser = ko.observable(Settings.settingsGet('ContactsPdoUser'));
this.pdoPassword = ko.observable(Settings.settingsGet('ContactsPdoPassword'));
this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.testing = ko.observable(false);
this.testContactsSuccess = ko.observable(false);
this.testContactsError = ko.observable(false);
this.testContactsErrorMessage = ko.observable('');
this.testContactsCommand = Utils.createCommand(this, function () {
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
this.testing(true);
Remote.testContacts(this.onTestContactsResponse, {
'ContactsPdoType': this.contactsType(),
'ContactsPdoDsn': this.pdoDsn(),
'ContactsPdoUser': this.pdoUser(),
'ContactsPdoPassword': this.pdoPassword()
});
}, function () {
return '' !== this.pdoDsn() && '' !== this.pdoUser();
});
this.contactsType(Settings.settingsGet('ContactsPdoType'));
this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this);
}
AdminSettingsContacts.prototype.onTestContactsResponse = function (sResult, oData)
{
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Result)
{
this.testContactsSuccess(true);
}
else
{
this.testContactsError(true);
if (oData && oData.Result)
{
this.testContactsErrorMessage(oData.Result.Message || '');
}
else
{
this.testContactsErrorMessage('');
}
}
this.testing(false);
};
AdminSettingsContacts.prototype.onShow = function ()
{
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
};
AdminSettingsContacts.prototype.onBuild = function ()
{
var
self = this,
Remote = require('Storage:Admin:Remote')
;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self)
;
self.enableContacts.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'ContactsEnable': bValue ? '1' : '0'
});
});
self.contactsSharing.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'ContactsSharing': bValue ? '1' : '0'
});
});
self.contactsSync.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'ContactsSync': bValue ? '1' : '0'
});
});
self.contactsType.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'ContactsPdoType': sValue
});
});
self.pdoDsn.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'ContactsPdoDsn': Utils.trim(sValue)
});
});
self.pdoUser.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'ContactsPdoUser': Utils.trim(sValue)
});
});
self.pdoPassword.subscribe(function (sValue) {
Remote.saveAdminConfig(f4, {
'ContactsPdoPassword': Utils.trim(sValue)
});
});
self.contactsType(Settings.settingsGet('ContactsPdoType'));
}, 50);
};
module.exports = AdminSettingsContacts;
}(module, require));
},{"Enums":6,"Storage:Admin:Remote":53,"Storage:Settings":59,"Utils":11,"_":26,"ko":23}],42:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
window = require('window'),
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
PopupsDomainViewModel = require('View:Popup:Domain'),
Data = require('Storage:Admin:Data'),
Remote = require('Storage:Admin:Remote')
;
/**
* @constructor
*/
function AdminSettingsDomains()
{
this.domains = Data.domains;
this.domainsLoading = Data.domainsLoading;
this.iDomainForDeletionTimeout = 0;
this.visibility = ko.computed(function () {
return Data.domainsLoading() ? 'visible' : 'hidden';
}, this);
this.domainForDeletion = ko.observable(null).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
this.startDomainForDeletionTimeout();
}
}
]});
}
AdminSettingsDomains.prototype.startDomainForDeletionTimeout = function ()
{
var self = this;
window.clearInterval(this.iDomainForDeletionTimeout);
this.iDomainForDeletionTimeout = window.setTimeout(function () {
self.domainForDeletion(null);
}, 1000 * 3);
};
AdminSettingsDomains.prototype.createDomain = function ()
{
require('App:Knoin').showScreenPopup(PopupsDomainViewModel);
};
AdminSettingsDomains.prototype.deleteDomain = function (oDomain)
{
this.domains.remove(oDomain);
Remote.domainDelete(_.bind(this.onDomainListChangeRequest, this), oDomain.name);
};
AdminSettingsDomains.prototype.disableDomain = function (oDomain)
{
oDomain.disabled(!oDomain.disabled());
Remote.domainDisable(_.bind(this.onDomainListChangeRequest, this), oDomain.name, oDomain.disabled());
};
AdminSettingsDomains.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.b-admin-domains-list-table .e-item .e-action', function () {
var oDomainItem = ko.dataFor(this);
if (oDomainItem)
{
Remote.domain(_.bind(self.onDomainLoadRequest, self), oDomainItem.name);
}
})
;
require('App:Admin').reloadDomainList();
};
AdminSettingsDomains.prototype.onDomainLoadRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
require('App:Knoin').showScreenPopup(PopupsDomainViewModel, [oData.Result]);
}
};
AdminSettingsDomains.prototype.onDomainListChangeRequest = function ()
{
require('App:Admin').reloadDomainList();
};
module.exports = AdminSettingsDomains;
}(module, require));
},{"App:Admin":3,"App:Knoin":28,"Enums":6,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"View:Popup:Domain":65,"_":26,"ko":23,"window":27}],43:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils'),
LinkBuilder = require('LinkBuilder'),
Settings = require('Storage:Settings'),
Data = require('Storage:Admin:Data')
;
/**
* @constructor
*/
function AdminSettingsGeneral()
{
this.mainLanguage = Data.mainLanguage;
this.mainTheme = Data.mainTheme;
this.language = Data.language;
this.theme = Data.theme;
this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings;
this.capaThemes = Data.capaThemes;
this.capaGravatar = Data.capaGravatar;
this.capaAdditionalAccounts = Data.capaAdditionalAccounts;
this.capaAdditionalIdentities = Data.capaAdditionalIdentities;
this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
this.uploadData = Settings.settingsGet('PhpUploadSizes');
this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ?
[
this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '',
this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : ''
].join('')
: '';
this.themesOptions = ko.computed(function () {
return _.map(Data.themes(), function (sTheme) {
return {
'optValue': sTheme,
'optText': Utils.convertThemeName(sTheme)
};
});
});
this.mainLanguageFullName = ko.computed(function () {
return Utils.convertLangName(this.mainLanguage());
}, this);
this.weakPassword = !!Settings.settingsGet('WeakPassword');
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
AdminSettingsGeneral.prototype.onBuild = function ()
{
var
self = this,
Remote = require('Storage:Admin:Remote')
;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self)
;
self.mainAttachmentLimit.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'AttachmentLimit': Utils.pInt(sValue)
});
});
self.language.subscribe(function (sValue) {
Remote.saveAdminConfig(f2, {
'Language': Utils.trim(sValue)
});
});
self.theme.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'Theme': Utils.trim(sValue)
});
});
self.capaAdditionalAccounts.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'CapaAdditionalAccounts': bValue ? '1' : '0'
});
});
self.capaAdditionalIdentities.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'CapaAdditionalIdentities': bValue ? '1' : '0'
});
});
self.capaGravatar.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'CapaGravatar': bValue ? '1' : '0'
});
});
self.capaThemes.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'CapaThemes': bValue ? '1' : '0'
});
});
self.allowLanguagesOnSettings.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'AllowLanguagesOnSettings': bValue ? '1' : '0'
});
});
}, 50);
};
AdminSettingsGeneral.prototype.selectLanguage = function ()
{
require('App:Knoin').showScreenPopup(require('View:Popup:Languages'));
};
/**
* @return {string}
*/
AdminSettingsGeneral.prototype.phpInfoLink = function ()
{
return LinkBuilder.phpInfo();
};
module.exports = AdminSettingsGeneral;
}(module, require));
},{"App:Knoin":28,"Enums":6,"LinkBuilder":9,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"Storage:Settings":59,"Utils":11,"View:Popup:Languages":66,"_":26,"ko":23}],44:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
ko = require('ko'),
moment = require('moment'),
Settings = require('Storage:Settings'),
Data = require('Storage:Admin:Data')
;
/**
* @constructor
*/
function AdminSettingsLicensing()
{
this.licensing = Data.licensing;
this.licensingProcess = Data.licensingProcess;
this.licenseValid = Data.licenseValid;
this.licenseExpired = Data.licenseExpired;
this.licenseError = Data.licenseError;
this.licenseTrigger = Data.licenseTrigger;
this.adminDomain = ko.observable('');
this.subscriptionEnabled = ko.observable(!!Settings.settingsGet('SubscriptionEnabled'));
this.licenseTrigger.subscribe(function () {
if (this.subscriptionEnabled())
{
require('App:Admin').reloadLicensing(true);
}
}, this);
}
AdminSettingsLicensing.prototype.onBuild = function ()
{
if (this.subscriptionEnabled())
{
require('App:Admin').reloadLicensing(false);
}
};
AdminSettingsLicensing.prototype.onShow = function ()
{
this.adminDomain(Settings.settingsGet('AdminDomain'));
};
AdminSettingsLicensing.prototype.showActivationForm = function ()
{
require('App:Knoin').showScreenPopup(require('View:Popup:Activate'));
};
/**
* @returns {string}
*/
AdminSettingsLicensing.prototype.licenseExpiredMomentValue = function ()
{
var
iTime = this.licenseExpired(),
oDate = moment.unix(iTime)
;
return iTime && 1898625600 === iTime ? 'Never' : (oDate.format('LL') + ' (' + oDate.from(moment()) + ')');
};
module.exports = AdminSettingsLicensing;
}(module, require));
},{"App:Admin":3,"App:Knoin":28,"Storage:Admin:Data":52,"Storage:Settings":59,"View:Popup:Activate":63,"ko":23,"moment":24}],45:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils'),
Settings = require('Storage:Settings'),
Data = require('Storage:Admin:Data')
;
/**
* @constructor
*/
function AdminSettingsLogin()
{
this.determineUserLanguage = Data.determineUserLanguage;
this.determineUserDomain = Data.determineUserDomain;
this.defaultDomain = ko.observable(Settings.settingsGet('LoginDefaultDomain'));
this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin;
this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
AdminSettingsLogin.prototype.onBuild = function ()
{
var
self = this,
Remote = require('Storage:Admin:Remote')
;
_.delay(function () {
var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self);
self.determineUserLanguage.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'DetermineUserLanguage': bValue ? '1' : '0'
});
});
self.determineUserDomain.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'DetermineUserDomain': bValue ? '1' : '0'
});
});
self.allowLanguagesOnLogin.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'AllowLanguagesOnLogin': bValue ? '1' : '0'
});
});
self.defaultDomain.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'LoginDefaultDomain': Utils.trim(sValue)
});
});
}, 50);
};
module.exports = AdminSettingsLogin;
}(module, require));
},{"Enums":6,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"Storage:Settings":59,"Utils":11,"_":26,"ko":23}],46:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
window = require('window'),
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils'),
Data = require('Storage:Admin:Data'),
Remote = require('Storage:Admin:Remote')
;
/**
* @constructor
*/
function AdminSettingsPackages()
{
this.packagesError = ko.observable('');
this.packages = Data.packages;
this.packagesLoading = Data.packagesLoading;
this.packagesReal = Data.packagesReal;
this.packagesMainUpdatable = Data.packagesMainUpdatable;
this.packagesCurrent = this.packages.filter(function (oItem) {
return oItem && '' !== oItem['installed'] && !oItem['compare'];
});
this.packagesAvailableForUpdate = this.packages.filter(function (oItem) {
return oItem && '' !== oItem['installed'] && !!oItem['compare'];
});
this.packagesAvailableForInstallation = this.packages.filter(function (oItem) {
return oItem && '' === oItem['installed'];
});
this.visibility = ko.computed(function () {
return Data.packagesLoading() ? 'visible' : 'hidden';
}, this);
}
AdminSettingsPackages.prototype.onShow = function ()
{
this.packagesError('');
};
AdminSettingsPackages.prototype.onBuild = function ()
{
require('App:Admin').reloadPackagesList();
};
AdminSettingsPackages.prototype.requestHelper = function (oPackage, bInstall)
{
var self = this;
return function (sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
if (oData && oData.ErrorCode)
{
self.packagesError(Utils.getNotification(oData.ErrorCode));
}
else
{
self.packagesError(Utils.getNotification(
bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage));
}
}
_.each(Data.packages(), function (oItem) {
if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file'])
{
oPackage['loading'](false);
oItem['loading'](false);
}
});
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result['Reload'])
{
window.location.reload();
}
else
{
require('App:Admin').reloadPackagesList();
}
};
};
AdminSettingsPackages.prototype.deletePackage = function (oPackage)
{
if (oPackage)
{
oPackage['loading'](true);
Remote.packageDelete(this.requestHelper(oPackage, false), oPackage);
}
};
AdminSettingsPackages.prototype.installPackage = function (oPackage)
{
if (oPackage)
{
oPackage['loading'](true);
Remote.packageInstall(this.requestHelper(oPackage, true), oPackage);
}
};
module.exports = AdminSettingsPackages;
}(module, require));
},{"App:Admin":3,"Enums":6,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"Utils":11,"ko":23,"window":27}],47:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils'),
Settings = require('Storage:Settings'),
Data = require('Storage:Admin:Data'),
Remote = require('Storage:Admin:Remote')
;
/**
* @constructor
*/
function AdminSettingsPlugins()
{
this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins'));
this.pluginsError = ko.observable('');
this.plugins = Data.plugins;
this.pluginsLoading = Data.pluginsLoading;
this.visibility = ko.computed(function () {
return Data.pluginsLoading() ? 'visible' : 'hidden';
}, this);
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this);
}
AdminSettingsPlugins.prototype.disablePlugin = function (oPlugin)
{
oPlugin.disabled(!oPlugin.disabled());
Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled());
};
AdminSettingsPlugins.prototype.configurePlugin = function (oPlugin)
{
Remote.plugin(this.onPluginLoadRequest, oPlugin.name);
};
AdminSettingsPlugins.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.e-item .configure-plugin-action', function () {
var oPlugin = ko.dataFor(this);
if (oPlugin)
{
self.configurePlugin(oPlugin);
}
})
.on('click', '.e-item .disabled-plugin', function () {
var oPlugin = ko.dataFor(this);
if (oPlugin)
{
self.disablePlugin(oPlugin);
}
})
;
this.enabledPlugins.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'EnabledPlugins': bValue ? '1' : '0'
});
});
};
AdminSettingsPlugins.prototype.onShow = function ()
{
this.pluginsError('');
require('App:Admin').reloadPluginList();
};
AdminSettingsPlugins.prototype.onPluginLoadRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
require('App:Knoin').showScreenPopup(require('View:Popup:Plugin'), [oData.Result]);
}
};
AdminSettingsPlugins.prototype.onPluginDisableRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData)
{
if (!oData.Result && oData.ErrorCode)
{
if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage)
{
this.pluginsError(oData.ErrorMessage);
}
else
{
this.pluginsError(Utils.getNotification(oData.ErrorCode));
}
}
}
require('App:Admin').reloadPluginList();
};
module.exports = AdminSettingsPlugins;
}(module, require));
},{"App:Admin":3,"App:Knoin":28,"Enums":6,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"Storage:Settings":59,"Utils":11,"View:Popup:Plugin":67,"_":26,"ko":23}],48:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils'),
LinkBuilder = require('LinkBuilder'),
Settings = require('Storage:Settings'),
Data = require('Storage:Admin:Data'),
Remote = require('Storage:Admin:Remote')
;
/**
* @constructor
*/
function AdminSettingsSecurity()
{
this.useLocalProxyForExternalImages = Data.useLocalProxyForExternalImages;
this.capaOpenPGP = ko.observable(Settings.capa(Enums.Capa.OpenPGP));
this.capaTwoFactorAuth = ko.observable(Settings.capa(Enums.Capa.TwoFactor));
this.adminLogin = ko.observable(Settings.settingsGet('AdminLogin'));
this.adminPassword = ko.observable('');
this.adminPasswordNew = ko.observable('');
this.adminPasswordNew2 = ko.observable('');
this.adminPasswordNewError = ko.observable(false);
this.adminPasswordUpdateError = ko.observable(false);
this.adminPasswordUpdateSuccess = ko.observable(false);
this.adminPassword.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
}, this);
this.adminPasswordNew.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
this.adminPasswordNew2.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
this.saveNewAdminPasswordCommand = Utils.createCommand(this, function () {
if (this.adminPasswordNew() !== this.adminPasswordNew2())
{
this.adminPasswordNewError(true);
return false;
}
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, {
'Password': this.adminPassword(),
'NewPassword': this.adminPasswordNew()
});
}, function () {
return '' !== this.adminPassword() && '' !== this.adminPasswordNew() && '' !== this.adminPasswordNew2();
});
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
}
AdminSettingsSecurity.prototype.onNewAdminPasswordResponse = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
this.adminPasswordUpdateSuccess(true);
}
else
{
this.adminPasswordUpdateError(true);
}
};
AdminSettingsSecurity.prototype.onBuild = function ()
{
var
Remote = require('Storage:Admin:Remote')
;
this.capaOpenPGP.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'CapaOpenPGP': bValue ? '1' : '0'
});
});
this.capaTwoFactorAuth.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'CapaTwoFactorAuth': bValue ? '1' : '0'
});
});
this.useLocalProxyForExternalImages.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'UseLocalProxyForExternalImages': bValue ? '1' : '0'
});
});
};
AdminSettingsSecurity.prototype.onHide = function ()
{
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
};
/**
* @return {string}
*/
AdminSettingsSecurity.prototype.phpInfoLink = function ()
{
return LinkBuilder.phpInfo();
};
module.exports = AdminSettingsSecurity;
}(module, require));
},{"Enums":6,"LinkBuilder":9,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"Storage:Settings":59,"Utils":11,"_":26,"ko":23}],49:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils')
;
/**
* @constructor
*/
function AdminSettingsSocial()
{
var Data = require('Storage:Admin:Data');
this.googleEnable = Data.googleEnable;
this.googleClientID = Data.googleClientID;
this.googleApiKey = Data.googleApiKey;
this.googleClientSecret = Data.googleClientSecret;
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookSupported = Data.facebookSupported;
this.facebookEnable = Data.facebookEnable;
this.facebookAppID = Data.facebookAppID;
this.facebookAppSecret = Data.facebookAppSecret;
this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterEnable = Data.twitterEnable;
this.twitterConsumerKey = Data.twitterConsumerKey;
this.twitterConsumerSecret = Data.twitterConsumerSecret;
this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.dropboxEnable = Data.dropboxEnable;
this.dropboxApiKey = Data.dropboxApiKey;
this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
}
AdminSettingsSocial.prototype.onBuild = function ()
{
var
self = this,
Remote = require('Storage:Admin:Remote')
;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger2, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger1, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self),
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self)
;
self.facebookEnable.subscribe(function (bValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(Utils.emptyFunction, {
'FacebookEnable': bValue ? '1' : '0'
});
}
});
self.facebookAppID.subscribe(function (sValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(f1, {
'FacebookAppID': Utils.trim(sValue)
});
}
});
self.facebookAppSecret.subscribe(function (sValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(f2, {
'FacebookAppSecret': Utils.trim(sValue)
});
}
});
self.twitterEnable.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'TwitterEnable': bValue ? '1' : '0'
});
});
self.twitterConsumerKey.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'TwitterConsumerKey': Utils.trim(sValue)
});
});
self.twitterConsumerSecret.subscribe(function (sValue) {
Remote.saveAdminConfig(f4, {
'TwitterConsumerSecret': Utils.trim(sValue)
});
});
self.googleEnable.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'GoogleEnable': bValue ? '1' : '0'
});
});
self.googleClientID.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'GoogleClientID': Utils.trim(sValue)
});
});
self.googleClientSecret.subscribe(function (sValue) {
Remote.saveAdminConfig(f6, {
'GoogleClientSecret': Utils.trim(sValue)
});
});
self.googleApiKey.subscribe(function (sValue) {
Remote.saveAdminConfig(f7, {
'GoogleApiKey': Utils.trim(sValue)
});
});
self.dropboxEnable.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'DropboxEnable': bValue ? '1' : '0'
});
});
self.dropboxApiKey.subscribe(function (sValue) {
Remote.saveAdminConfig(f8, {
'DropboxApiKey': Utils.trim(sValue)
});
});
}, 50);
};
module.exports = AdminSettingsSocial;
}(module, require));
},{"Enums":6,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"Utils":11,"_":26,"ko":23}],50:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
Enums = require('Enums'),
Utils = require('Utils'),
Settings = require('Storage:Settings')
;
/**
* @constructor
*/
function AbstractData()
{
Utils.initDataConstructorBySettings(this);
}
AbstractData.prototype.populateDataOnStart = function()
{
var
mLayout = Utils.pInt(Settings.settingsGet('Layout')),
aLanguages = Settings.settingsGet('Languages'),
aThemes = Settings.settingsGet('Themes')
;
if (Utils.isArray(aLanguages))
{
this.languages(aLanguages);
}
if (Utils.isArray(aThemes))
{
this.themes(aThemes);
}
this.mainLanguage(Settings.settingsGet('Language'));
this.mainTheme(Settings.settingsGet('Theme'));
this.capaAdditionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts));
this.capaAdditionalIdentities(Settings.capa(Enums.Capa.AdditionalIdentities));
this.capaGravatar(Settings.capa(Enums.Capa.Gravatar));
this.determineUserLanguage(!!Settings.settingsGet('DetermineUserLanguage'));
this.determineUserDomain(!!Settings.settingsGet('DetermineUserDomain'));
this.capaThemes(Settings.capa(Enums.Capa.Themes));
this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin'));
this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings'));
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
this.showImages(!!Settings.settingsGet('ShowImages'));
this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave'));
this.interfaceAnimation(Settings.settingsGet('InterfaceAnimation'));
this.mainMessagesPerPage(Settings.settingsGet('MPP'));
this.desktopNotifications(!!Settings.settingsGet('DesktopNotifications'));
this.useThreads(!!Settings.settingsGet('UseThreads'));
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
this.layout(Enums.Layout.SidePreview);
if (-1 < Utils.inArray(mLayout, [Enums.Layout.NoPreview, Enums.Layout.SidePreview, Enums.Layout.BottomPreview]))
{
this.layout(mLayout);
}
this.facebookSupported(!!Settings.settingsGet('SupportedFacebookSocial'));
this.facebookEnable(!!Settings.settingsGet('AllowFacebookSocial'));
this.facebookAppID(Settings.settingsGet('FacebookAppID'));
this.facebookAppSecret(Settings.settingsGet('FacebookAppSecret'));
this.twitterEnable(!!Settings.settingsGet('AllowTwitterSocial'));
this.twitterConsumerKey(Settings.settingsGet('TwitterConsumerKey'));
this.twitterConsumerSecret(Settings.settingsGet('TwitterConsumerSecret'));
this.googleEnable(!!Settings.settingsGet('AllowGoogleSocial'));
this.googleClientID(Settings.settingsGet('GoogleClientID'));
this.googleClientSecret(Settings.settingsGet('GoogleClientSecret'));
this.googleApiKey(Settings.settingsGet('GoogleApiKey'));
this.dropboxEnable(!!Settings.settingsGet('AllowDropboxSocial'));
this.dropboxApiKey(Settings.settingsGet('DropboxApiKey'));
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
};
module.exports = AbstractData;
}(module, require));
},{"Enums":6,"Storage:Settings":59,"Utils":11}],51:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
window = require('window'),
$ = require('$'),
_ = require('_'),
Consts = require('Consts'),
Enums = require('Enums'),
Globals = require('Globals'),
Utils = require('Utils'),
Plugins = require('Plugins'),
LinkBuilder = require('LinkBuilder'),
Settings = require('Storage:Settings')
;
/**
* @constructor
*/
function AbstractRemoteStorage()
{
this.oRequests = {};
}
AbstractRemoteStorage.prototype.oRequests = {};
/**
* @param {?Function} fCallback
* @param {string} sRequestAction
* @param {string} sType
* @param {?AjaxJsonDefaultResponse} oData
* @param {boolean} bCached
* @param {*=} oRequestParameters
*/
AbstractRemoteStorage.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)
{
if (Globals.__APP)
{
Globals.__APP.loginAndLogoutReload(true);
}
}
if (oData.Logout || Consts.Values.AjaxErrorLimit < Globals.iAjaxErrorCount)
{
if (window.__rlah_clear)
{
window.__rlah_clear();
}
if (Globals.__APP)
{
Globals.__APP.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}
*/
AbstractRemoteStorage.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'] = Settings.settingsGet('Token');
}
oDefAjax = $.ajax({
'type': bPost ? 'POST' : 'GET',
'url': LinkBuilder.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 = []
*/
AbstractRemoteStorage.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
*/
AbstractRemoteStorage.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
*/
AbstractRemoteStorage.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
*/
AbstractRemoteStorage.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
*/
AbstractRemoteStorage.prototype.getPublicKey = function (fCallback)
{
this.defaultRequest(fCallback, 'GetPublicKey');
};
/**
* @param {?Function} fCallback
* @param {string} sVersion
*/
AbstractRemoteStorage.prototype.jsVersion = function (fCallback, sVersion)
{
this.defaultRequest(fCallback, 'Version', {
'Version': sVersion
});
};
module.exports = AbstractRemoteStorage;
}(module, require));
},{"$":21,"Consts":5,"Enums":6,"Globals":8,"LinkBuilder":9,"Plugins":10,"Storage:Settings":59,"Utils":11,"_":26,"window":27}],52:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
AbstractData = require('Storage:Abstract:Data')
;
/**
* @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 = new AdminDataStorage();
}(module, require));
},{"Storage:Abstract:Data":50,"_":26,"ko":23}],53:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
AbstractRemoteStorage = require('Storage:Abstract:Remote')
;
/**
* @constructor
* @extends AbstractRemoteStorage
*/
function AdminRemoteStorage()
{
AbstractRemoteStorage.call(this);
this.oRequests = {};
}
_.extend(AdminRemoteStorage.prototype, AbstractRemoteStorage.prototype);
/**
* @param {?Function} fCallback
* @param {string} sLogin
* @param {string} sPassword
*/
AdminRemoteStorage.prototype.adminLogin = function (fCallback, sLogin, sPassword)
{
this.defaultRequest(fCallback, 'AdminLogin', {
'Login': sLogin,
'Password': sPassword
});
};
/**
* @param {?Function} fCallback
*/
AdminRemoteStorage.prototype.adminLogout = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminLogout');
};
/**
* @param {?Function} fCallback
* @param {?} oData
*/
AdminRemoteStorage.prototype.saveAdminConfig = function (fCallback, oData)
{
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
};
/**
* @param {?Function} fCallback
*/
AdminRemoteStorage.prototype.domainList = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminDomainList');
};
/**
* @param {?Function} fCallback
*/
AdminRemoteStorage.prototype.pluginList = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminPluginList');
};
/**
* @param {?Function} fCallback
*/
AdminRemoteStorage.prototype.packagesList = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminPackagesList');
};
/**
* @param {?Function} fCallback
*/
AdminRemoteStorage.prototype.coreData = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminCoreData');
};
/**
* @param {?Function} fCallback
*/
AdminRemoteStorage.prototype.updateCoreData = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
};
/**
* @param {?Function} fCallback
* @param {Object} oPackage
*/
AdminRemoteStorage.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
*/
AdminRemoteStorage.prototype.packageDelete = function (fCallback, oPackage)
{
this.defaultRequest(fCallback, 'AdminPackageDelete', {
'Id': oPackage.id
});
};
/**
* @param {?Function} fCallback
* @param {string} sName
*/
AdminRemoteStorage.prototype.domain = function (fCallback, sName)
{
this.defaultRequest(fCallback, 'AdminDomainLoad', {
'Name': sName
});
};
/**
* @param {?Function} fCallback
* @param {string} sName
*/
AdminRemoteStorage.prototype.plugin = function (fCallback, sName)
{
this.defaultRequest(fCallback, 'AdminPluginLoad', {
'Name': sName
});
};
/**
* @param {?Function} fCallback
* @param {string} sName
*/
AdminRemoteStorage.prototype.domainDelete = function (fCallback, sName)
{
this.defaultRequest(fCallback, 'AdminDomainDelete', {
'Name': sName
});
};
/**
* @param {?Function} fCallback
* @param {string} sName
* @param {boolean} bDisabled
*/
AdminRemoteStorage.prototype.domainDisable = function (fCallback, sName, bDisabled)
{
return this.defaultRequest(fCallback, 'AdminDomainDisable', {
'Name': sName,
'Disabled': !!bDisabled ? '1' : '0'
});
};
/**
* @param {?Function} fCallback
* @param {Object} oConfig
*/
AdminRemoteStorage.prototype.pluginSettingsUpdate = function (fCallback, oConfig)
{
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
};
/**
* @param {?Function} fCallback
* @param {boolean} bForce
*/
AdminRemoteStorage.prototype.licensing = function (fCallback, bForce)
{
return this.defaultRequest(fCallback, 'AdminLicensing', {
'Force' : bForce ? '1' : '0'
});
};
/**
* @param {?Function} fCallback
* @param {string} sDomain
* @param {string} sKey
*/
AdminRemoteStorage.prototype.licensingActivate = function (fCallback, sDomain, sKey)
{
return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
'Domain' : sDomain,
'Key' : sKey
});
};
/**
* @param {?Function} fCallback
* @param {string} sName
* @param {boolean} bDisabled
*/
AdminRemoteStorage.prototype.pluginDisable = function (fCallback, sName, bDisabled)
{
return this.defaultRequest(fCallback, 'AdminPluginDisable', {
'Name': sName,
'Disabled': !!bDisabled ? '1' : '0'
});
};
AdminRemoteStorage.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
});
};
AdminRemoteStorage.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
*/
AdminRemoteStorage.prototype.testContacts = function (fCallback, oData)
{
this.defaultRequest(fCallback, 'AdminContactsTest', oData);
};
/**
* @param {?Function} fCallback
* @param {?} oData
*/
AdminRemoteStorage.prototype.saveNewAdminPassword = function (fCallback, oData)
{
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
};
/**
* @param {?Function} fCallback
*/
AdminRemoteStorage.prototype.adminPing = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminPing');
};
module.exports = new AdminRemoteStorage();
}(module, require));
},{"Storage:Abstract:Remote":51,"_":26}],54:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
Enums = require('Enums'),
Utils = require('Utils'),
LinkBuilder = require('LinkBuilder'),
Settings = require('Storage:Settings')
;
/**
* @constructor
*/
function CacheStorage()
{
this.oFoldersCache = {};
this.oFoldersNamesCache = {};
this.oFolderHashCache = {};
this.oFolderUidNextCache = {};
this.oMessageListHashCache = {};
this.oMessageFlagsCache = {};
this.oNewMessage = {};
this.oRequestedMessage = {};
this.bCapaGravatar = Settings.capa(Enums.Capa.Gravatar);
}
/**
* @type {boolean}
*/
CacheStorage.prototype.bCapaGravatar = false;
/**
* @type {Object}
*/
CacheStorage.prototype.oFoldersCache = {};
/**
* @type {Object}
*/
CacheStorage.prototype.oFoldersNamesCache = {};
/**
* @type {Object}
*/
CacheStorage.prototype.oFolderHashCache = {};
/**
* @type {Object}
*/
CacheStorage.prototype.oFolderUidNextCache = {};
/**
* @type {Object}
*/
CacheStorage.prototype.oMessageListHashCache = {};
/**
* @type {Object}
*/
CacheStorage.prototype.oMessageFlagsCache = {};
/**
* @type {Object}
*/
CacheStorage.prototype.oBodies = {};
/**
* @type {Object}
*/
CacheStorage.prototype.oNewMessage = {};
/**
* @type {Object}
*/
CacheStorage.prototype.oRequestedMessage = {};
CacheStorage.prototype.clear = function ()
{
this.oFoldersCache = {};
this.oFoldersNamesCache = {};
this.oFolderHashCache = {};
this.oFolderUidNextCache = {};
this.oMessageListHashCache = {};
this.oMessageFlagsCache = {};
this.oBodies = {};
};
/**
* @param {string} sEmail
* @param {Function} fCallback
* @return {string}
*/
CacheStorage.prototype.getUserPic = function (sEmail, fCallback)
{
sEmail = Utils.trim(sEmail);
fCallback(this.bCapaGravatar && '' !== sEmail ? LinkBuilder.avatarLink(sEmail) : '', sEmail);
};
/**
* @param {string} sFolderFullNameRaw
* @param {string} sUid
* @return {string}
*/
CacheStorage.prototype.getMessageKey = function (sFolderFullNameRaw, sUid)
{
return sFolderFullNameRaw + '#' + sUid;
};
/**
* @param {string} sFolder
* @param {string} sUid
*/
CacheStorage.prototype.addRequestedMessage = function (sFolder, sUid)
{
this.oRequestedMessage[this.getMessageKey(sFolder, sUid)] = true;
};
/**
* @param {string} sFolder
* @param {string} sUid
* @return {boolean}
*/
CacheStorage.prototype.hasRequestedMessage = function (sFolder, sUid)
{
return true === this.oRequestedMessage[this.getMessageKey(sFolder, sUid)];
};
/**
* @param {string} sFolderFullNameRaw
* @param {string} sUid
*/
CacheStorage.prototype.addNewMessageCache = function (sFolderFullNameRaw, sUid)
{
this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = true;
};
/**
* @param {string} sFolderFullNameRaw
* @param {string} sUid
*/
CacheStorage.prototype.hasNewMessageAndRemoveFromCache = function (sFolderFullNameRaw, sUid)
{
if (this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)])
{
this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = null;
return true;
}
return false;
};
CacheStorage.prototype.clearNewMessageCache = function ()
{
this.oNewMessage = {};
};
/**
* @param {string} sFolderHash
* @return {string}
*/
CacheStorage.prototype.getFolderFullNameRaw = function (sFolderHash)
{
return '' !== sFolderHash && this.oFoldersNamesCache[sFolderHash] ? this.oFoldersNamesCache[sFolderHash] : '';
};
/**
* @param {string} sFolderHash
* @param {string} sFolderFullNameRaw
*/
CacheStorage.prototype.setFolderFullNameRaw = function (sFolderHash, sFolderFullNameRaw)
{
this.oFoldersNamesCache[sFolderHash] = sFolderFullNameRaw;
};
/**
* @param {string} sFolderFullNameRaw
* @return {string}
*/
CacheStorage.prototype.getFolderHash = function (sFolderFullNameRaw)
{
return '' !== sFolderFullNameRaw && this.oFolderHashCache[sFolderFullNameRaw] ? this.oFolderHashCache[sFolderFullNameRaw] : '';
};
/**
* @param {string} sFolderFullNameRaw
* @param {string} sFolderHash
*/
CacheStorage.prototype.setFolderHash = function (sFolderFullNameRaw, sFolderHash)
{
this.oFolderHashCache[sFolderFullNameRaw] = sFolderHash;
};
/**
* @param {string} sFolderFullNameRaw
* @return {string}
*/
CacheStorage.prototype.getFolderUidNext = function (sFolderFullNameRaw)
{
return '' !== sFolderFullNameRaw && this.oFolderUidNextCache[sFolderFullNameRaw] ? this.oFolderUidNextCache[sFolderFullNameRaw] : '';
};
/**
* @param {string} sFolderFullNameRaw
* @param {string} sUidNext
*/
CacheStorage.prototype.setFolderUidNext = function (sFolderFullNameRaw, sUidNext)
{
this.oFolderUidNextCache[sFolderFullNameRaw] = sUidNext;
};
/**
* @param {string} sFolderFullNameRaw
* @return {?FolderModel}
*/
CacheStorage.prototype.getFolderFromCacheList = function (sFolderFullNameRaw)
{
return '' !== sFolderFullNameRaw && this.oFoldersCache[sFolderFullNameRaw] ? this.oFoldersCache[sFolderFullNameRaw] : null;
};
/**
* @param {string} sFolderFullNameRaw
* @param {?FolderModel} oFolder
*/
CacheStorage.prototype.setFolderToCacheList = function (sFolderFullNameRaw, oFolder)
{
this.oFoldersCache[sFolderFullNameRaw] = oFolder;
};
/**
* @param {string} sFolderFullNameRaw
*/
CacheStorage.prototype.removeFolderFromCacheList = function (sFolderFullNameRaw)
{
this.setFolderToCacheList(sFolderFullNameRaw, null);
};
/**
* @param {string} sFolderFullName
* @param {string} sUid
* @return {?Array}
*/
CacheStorage.prototype.getMessageFlagsFromCache = function (sFolderFullName, sUid)
{
return this.oMessageFlagsCache[sFolderFullName] && this.oMessageFlagsCache[sFolderFullName][sUid] ?
this.oMessageFlagsCache[sFolderFullName][sUid] : null;
};
/**
* @param {string} sFolderFullName
* @param {string} sUid
* @param {Array} aFlagsCache
*/
CacheStorage.prototype.setMessageFlagsToCache = function (sFolderFullName, sUid, aFlagsCache)
{
if (!this.oMessageFlagsCache[sFolderFullName])
{
this.oMessageFlagsCache[sFolderFullName] = {};
}
this.oMessageFlagsCache[sFolderFullName][sUid] = aFlagsCache;
};
/**
* @param {string} sFolderFullName
*/
CacheStorage.prototype.clearMessageFlagsFromCacheByFolder = function (sFolderFullName)
{
this.oMessageFlagsCache[sFolderFullName] = {};
};
/**
* @param {(MessageModel|null)} oMessage
*/
CacheStorage.prototype.initMessageFlagsFromCache = function (oMessage)
{
if (oMessage)
{
var
self = this,
aFlags = this.getMessageFlagsFromCache(oMessage.folderFullNameRaw, oMessage.uid),
mUnseenSubUid = null,
mFlaggedSubUid = null
;
if (aFlags && 0 < aFlags.length)
{
oMessage.unseen(!!aFlags[0]);
oMessage.flagged(!!aFlags[1]);
oMessage.answered(!!aFlags[2]);
oMessage.forwarded(!!aFlags[3]);
oMessage.isReadReceipt(!!aFlags[4]);
}
if (0 < oMessage.threads().length)
{
mUnseenSubUid = _.find(oMessage.threads(), function (iSubUid) {
var aFlags = self.getMessageFlagsFromCache(oMessage.folderFullNameRaw, iSubUid);
return aFlags && 0 < aFlags.length && !!aFlags[0];
});
mFlaggedSubUid = _.find(oMessage.threads(), function (iSubUid) {
var aFlags = self.getMessageFlagsFromCache(oMessage.folderFullNameRaw, iSubUid);
return aFlags && 0 < aFlags.length && !!aFlags[1];
});
oMessage.hasUnseenSubMessage(mUnseenSubUid && 0 < Utils.pInt(mUnseenSubUid));
oMessage.hasFlaggedSubMessage(mFlaggedSubUid && 0 < Utils.pInt(mFlaggedSubUid));
}
}
};
/**
* @param {(MessageModel|null)} oMessage
*/
CacheStorage.prototype.storeMessageFlagsToCache = function (oMessage)
{
if (oMessage)
{
this.setMessageFlagsToCache(
oMessage.folderFullNameRaw,
oMessage.uid,
[oMessage.unseen(), oMessage.flagged(), oMessage.answered(), oMessage.forwarded(), oMessage.isReadReceipt()]
);
}
};
/**
* @param {string} sFolder
* @param {string} sUid
* @param {Array} aFlags
*/
CacheStorage.prototype.storeMessageFlagsToCacheByFolderAndUid = function (sFolder, sUid, aFlags)
{
if (Utils.isArray(aFlags) && 0 < aFlags.length)
{
this.setMessageFlagsToCache(sFolder, sUid, aFlags);
}
};
module.exports = new CacheStorage();
}(module, require));
},{"Enums":6,"LinkBuilder":9,"Storage:Settings":59,"Utils":11,"_":26}],55:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
window = require('window'),
$ = require('$'),
_ = require('_'),
ko = require('ko'),
moment = require('moment'),
$div = require('$div'),
NotificationClass = require('NotificationClass'),
Consts = require('Consts'),
Enums = require('Enums'),
Globals = require('Globals'),
Utils = require('Utils'),
LinkBuilder = require('LinkBuilder'),
Settings = require('Storage:Settings'),
Cache = require('Storage:RainLoop:Cache'),
kn = require('App:Knoin'),
MessageModel = require('Model:Message'),
LocalStorage = require('Storage:LocalStorage'),
AbstractData = require('Storage:Abstract:Data')
;
/**
* @constructor
* @extends AbstractData
*/
function DataStorage()
{
AbstractData.call(this);
var
fRemoveSystemFolderType = function (observable) {
return function () {
var oFolder = Cache.getFolderFromCacheList(observable());
if (oFolder)
{
oFolder.type(Enums.FolderType.User);
}
};
},
fSetSystemFolderType = function (iType) {
return function (sValue) {
var oFolder = Cache.getFolderFromCacheList(sValue);
if (oFolder)
{
oFolder.type(iType);
}
};
}
;
this.devEmail = '';
this.devPassword = '';
this.accountEmail = ko.observable('');
this.accountIncLogin = ko.observable('');
this.accountOutLogin = ko.observable('');
this.projectHash = ko.observable('');
this.threading = ko.observable(false);
this.lastFoldersHash = '';
this.remoteSuggestions = false;
// system folders
this.sentFolder = ko.observable('');
this.draftFolder = ko.observable('');
this.spamFolder = ko.observable('');
this.trashFolder = ko.observable('');
this.archiveFolder = ko.observable('');
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
this.spamFolder.subscribe(fRemoveSystemFolderType(this.spamFolder), this, 'beforeChange');
this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange');
this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange');
this.sentFolder.subscribe(fSetSystemFolderType(Enums.FolderType.SentItems), this);
this.draftFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Draft), this);
this.spamFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Spam), this);
this.trashFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Trash), this);
this.archiveFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Archive), this);
this.draftFolderNotEnabled = ko.computed(function () {
return '' === this.draftFolder() || Consts.Values.UnuseOptionValue === this.draftFolder();
}, this);
// personal
this.displayName = ko.observable('');
this.signature = ko.observable('');
this.signatureToAll = ko.observable(false);
this.replyTo = ko.observable('');
// security
this.enableTwoFactor = ko.observable(false);
// accounts
this.accounts = ko.observableArray([]);
this.accountsLoading = ko.observable(false).extend({'throttle': 100});
// identities
this.defaultIdentityID = ko.observable('');
this.identities = ko.observableArray([]);
this.identitiesLoading = ko.observable(false).extend({'throttle': 100});
// contacts
this.contactTags = ko.observableArray([]);
this.contacts = ko.observableArray([]);
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200});
this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200});
this.allowContactsSync = ko.observable(false);
this.enableContactsSync = ko.observable(false);
this.contactsSyncUrl = ko.observable('');
this.contactsSyncUser = ko.observable('');
this.contactsSyncPass = ko.observable('');
this.allowContactsSync = ko.observable(!!Settings.settingsGet('ContactsSyncIsAllowed'));
this.enableContactsSync = ko.observable(!!Settings.settingsGet('EnableContactsSync'));
this.contactsSyncUrl = ko.observable(Settings.settingsGet('ContactsSyncUrl'));
this.contactsSyncUser = ko.observable(Settings.settingsGet('ContactsSyncUser'));
this.contactsSyncPass = ko.observable(Settings.settingsGet('ContactsSyncPassword'));
// folders
this.namespace = '';
this.folderList = ko.observableArray([]);
this.folderList.focused = ko.observable(false);
this.foldersListError = ko.observable('');
this.foldersLoading = ko.observable(false);
this.foldersCreating = ko.observable(false);
this.foldersDeleting = ko.observable(false);
this.foldersRenaming = ko.observable(false);
this.foldersChanging = ko.computed(function () {
var
bLoading = this.foldersLoading(),
bCreating = this.foldersCreating(),
bDeleting = this.foldersDeleting(),
bRenaming = this.foldersRenaming()
;
return bLoading || bCreating || bDeleting || bRenaming;
}, this);
this.foldersInboxUnreadCount = ko.observable(0);
this.currentFolder = ko.observable(null).extend({'toggleSubscribe': [null,
function (oPrev) {
if (oPrev)
{
oPrev.selected(false);
}
}, function (oNext) {
if (oNext)
{
oNext.selected(true);
}
}
]});
this.currentFolderFullNameRaw = ko.computed(function () {
return this.currentFolder() ? this.currentFolder().fullNameRaw : '';
}, this);
this.currentFolderFullName = ko.computed(function () {
return this.currentFolder() ? this.currentFolder().fullName : '';
}, this);
this.currentFolderFullNameHash = ko.computed(function () {
return this.currentFolder() ? this.currentFolder().fullNameHash : '';
}, this);
this.currentFolderName = ko.computed(function () {
return this.currentFolder() ? this.currentFolder().name() : '';
}, this);
this.folderListSystemNames = ko.computed(function () {
var
aList = ['INBOX'],
aFolders = this.folderList(),
sSentFolder = this.sentFolder(),
sDraftFolder = this.draftFolder(),
sSpamFolder = this.spamFolder(),
sTrashFolder = this.trashFolder(),
sArchiveFolder = this.archiveFolder()
;
if (Utils.isArray(aFolders) && 0 < aFolders.length)
{
if ('' !== sSentFolder && Consts.Values.UnuseOptionValue !== sSentFolder)
{
aList.push(sSentFolder);
}
if ('' !== sDraftFolder && Consts.Values.UnuseOptionValue !== sDraftFolder)
{
aList.push(sDraftFolder);
}
if ('' !== sSpamFolder && Consts.Values.UnuseOptionValue !== sSpamFolder)
{
aList.push(sSpamFolder);
}
if ('' !== sTrashFolder && Consts.Values.UnuseOptionValue !== sTrashFolder)
{
aList.push(sTrashFolder);
}
if ('' !== sArchiveFolder && Consts.Values.UnuseOptionValue !== sArchiveFolder)
{
aList.push(sArchiveFolder);
}
}
return aList;
}, this);
this.folderListSystem = ko.computed(function () {
return _.compact(_.map(this.folderListSystemNames(), function (sName) {
return Cache.getFolderFromCacheList(sName);
}));
}, this);
this.folderMenuForMove = ko.computed(function () {
return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(), [
this.currentFolderFullNameRaw()
], null, null, null, null, function (oItem) {
return oItem ? oItem.localName() : '';
});
}, this);
// message list
this.staticMessageList = [];
this.messageList = ko.observableArray([]).extend({'rateLimit': 0});
this.messageListCount = ko.observable(0);
this.messageListSearch = ko.observable('');
this.messageListPage = ko.observable(1);
this.messageListThreadFolder = ko.observable('');
this.messageListThreadUids = ko.observableArray([]);
this.messageListThreadFolder.subscribe(function () {
this.messageListThreadUids([]);
}, this);
this.messageListEndFolder = ko.observable('');
this.messageListEndSearch = ko.observable('');
this.messageListEndPage = ko.observable(1);
this.messageListEndHash = ko.computed(function () {
return this.messageListEndFolder() + '|' + this.messageListEndSearch() + '|' + this.messageListEndPage();
}, this);
this.messageListPageCount = ko.computed(function () {
var iPage = window.Math.ceil(this.messageListCount() / this.messagesPerPage());
return 0 >= iPage ? 1 : iPage;
}, this);
this.mainMessageListSearch = ko.computed({
'read': this.messageListSearch,
'write': function (sValue) {
kn.setHash(LinkBuilder.mailBox(
this.currentFolderFullNameHash(), 1, Utils.trim(sValue.toString())
));
},
'owner': this
});
this.messageListError = ko.observable('');
this.messageListLoading = ko.observable(false);
this.messageListIsNotCompleted = ko.observable(false);
this.messageListCompleteLoadingThrottle = ko.observable(false).extend({'throttle': 200});
this.messageListCompleteLoading = ko.computed(function () {
var
bOne = this.messageListLoading(),
bTwo = this.messageListIsNotCompleted()
;
return bOne || bTwo;
}, this);
this.messageListCompleteLoading.subscribe(function (bValue) {
this.messageListCompleteLoadingThrottle(bValue);
}, this);
this.messageList.subscribe(_.debounce(function (aList) {
_.each(aList, function (oItem) {
if (oItem.newForAnimation())
{
oItem.newForAnimation(false);
}
});
}, 500));
// message preview
this.staticMessageList = new MessageModel();
this.message = ko.observable(null);
this.messageLoading = ko.observable(false);
this.messageLoadingThrottle = ko.observable(false).extend({'throttle': 50});
this.message.focused = ko.observable(false);
this.message.subscribe(function (oMessage) {
if (!oMessage)
{
this.message.focused(false);
this.messageFullScreenMode(false);
this.hideMessageBodies();
if (Enums.Layout.NoPreview === this.layout() &&
-1 < window.location.hash.indexOf('message-preview'))
{
if (Globals.__APP)
{
Globals.__APP.historyBack();
}
}
}
else if (Enums.Layout.NoPreview === this.layout())
{
this.message.focused(true);
}
}, this);
this.message.focused.subscribe(function (bValue) {
if (bValue)
{
this.folderList.focused(false);
Globals.keyScope(Enums.KeyState.MessageView);
}
else if (Enums.KeyState.MessageView === Globals.keyScope())
{
if (Enums.Layout.NoPreview === this.layout() && this.message())
{
Globals.keyScope(Enums.KeyState.MessageView);
}
else
{
Globals.keyScope(Enums.KeyState.MessageList);
}
}
}, this);
this.folderList.focused.subscribe(function (bValue) {
if (bValue)
{
Globals.keyScope(Enums.KeyState.FolderList);
}
else if (Enums.KeyState.FolderList === Globals.keyScope())
{
Globals.keyScope(Enums.KeyState.MessageList);
}
});
this.messageLoading.subscribe(function (bValue) {
this.messageLoadingThrottle(bValue);
}, this);
this.messageFullScreenMode = ko.observable(false);
this.messageError = ko.observable('');
this.messagesBodiesDom = ko.observable(null);
this.messagesBodiesDom.subscribe(function (oDom) {
if (oDom && !(oDom instanceof $))
{
this.messagesBodiesDom($(oDom));
}
}, this);
this.messageActiveDom = ko.observable(null);
this.isMessageSelected = ko.computed(function () {
return null !== this.message();
}, this);
this.currentMessage = ko.observable(null);
this.messageListChecked = ko.computed(function () {
return _.filter(this.messageList(), function (oItem) {
return oItem.checked();
});
}, this).extend({'rateLimit': 0});
this.hasCheckedMessages = ko.computed(function () {
return 0 < this.messageListChecked().length;
}, this).extend({'rateLimit': 0});
this.messageListCheckedOrSelected = ko.computed(function () {
var
aChecked = this.messageListChecked(),
oSelectedMessage = this.currentMessage()
;
return _.union(aChecked, oSelectedMessage ? [oSelectedMessage] : []);
}, this);
this.messageListCheckedOrSelectedUidsWithSubMails = ko.computed(function () {
var aList = [];
_.each(this.messageListCheckedOrSelected(), function (oMessage) {
if (oMessage)
{
aList.push(oMessage.uid);
if (0 < oMessage.threadsLen() && 0 === oMessage.parentUid() && oMessage.lastInCollapsedThread())
{
aList = _.union(aList, oMessage.threads());
}
}
});
return aList;
}, this);
// quota
this.userQuota = ko.observable(0);
this.userUsageSize = ko.observable(0);
this.userUsageProc = ko.computed(function () {
var
iQuota = this.userQuota(),
iUsed = this.userUsageSize()
;
return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0;
}, this);
// other
this.capaOpenPGP = ko.observable(false);
this.openpgpkeys = ko.observableArray([]);
this.openpgpKeyring = null;
this.openpgpkeysPublic = this.openpgpkeys.filter(function (oItem) {
return !!(oItem && !oItem.isPrivate);
});
this.openpgpkeysPrivate = this.openpgpkeys.filter(function (oItem) {
return !!(oItem && oItem.isPrivate);
});
// google
this.googleActions = ko.observable(false);
this.googleLoggined = ko.observable(false);
this.googleUserName = ko.observable('');
// facebook
this.facebookActions = ko.observable(false);
this.facebookLoggined = ko.observable(false);
this.facebookUserName = ko.observable('');
// twitter
this.twitterActions = ko.observable(false);
this.twitterLoggined = ko.observable(false);
this.twitterUserName = ko.observable('');
this.customThemeType = ko.observable(Enums.CustomThemeType.Light);
this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, 1000 * 30);
}
_.extend(DataStorage.prototype, AbstractData.prototype);
DataStorage.prototype.purgeMessageBodyCache = function()
{
var
iCount = 0,
oMessagesBodiesDom = null,
iEnd = Globals.iMessageBodyCacheCount - Consts.Values.MessageBodyCacheLimit
;
if (0 < iEnd)
{
oMessagesBodiesDom = this.messagesBodiesDom();
if (oMessagesBodiesDom)
{
oMessagesBodiesDom.find('.rl-cache-class').each(function () {
var oItem = $(this);
if (iEnd > oItem.data('rl-cache-count'))
{
oItem.addClass('rl-cache-purge');
iCount++;
}
});
if (0 < iCount)
{
_.delay(function () {
oMessagesBodiesDom.find('.rl-cache-purge').remove();
}, 300);
}
}
}
};
DataStorage.prototype.populateDataOnStart = function()
{
AbstractData.prototype.populateDataOnStart.call(this);
this.accountEmail(Settings.settingsGet('Email'));
this.accountIncLogin(Settings.settingsGet('IncLogin'));
this.accountOutLogin(Settings.settingsGet('OutLogin'));
this.projectHash(Settings.settingsGet('ProjectHash'));
this.defaultIdentityID(Settings.settingsGet('DefaultIdentityID'));
this.displayName(Settings.settingsGet('DisplayName'));
this.replyTo(Settings.settingsGet('ReplyTo'));
this.signature(Settings.settingsGet('Signature'));
this.signatureToAll(!!Settings.settingsGet('SignatureToAll'));
this.enableTwoFactor(!!Settings.settingsGet('EnableTwoFactor'));
this.lastFoldersHash = LocalStorage.get(Enums.ClientSideKeyName.FoldersLashHash) || '';
this.remoteSuggestions = !!Settings.settingsGet('RemoteSuggestions');
this.devEmail = Settings.settingsGet('DevEmail');
this.devPassword = Settings.settingsGet('DevPassword');
};
DataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUidNext, aNewMessages)
{
if ('INBOX' === sFolder && Utils.isNormal(sUidNext) && sUidNext !== '')
{
if (Utils.isArray(aNewMessages) && 0 < aNewMessages.length)
{
var
self = this,
iIndex = 0,
iLen = aNewMessages.length,
fNotificationHelper = function (sImageSrc, sTitle, sText)
{
var oNotification = null;
if (NotificationClass && self.useDesktopNotifications())
{
oNotification = new NotificationClass(sTitle, {
'body': sText,
'icon': sImageSrc
});
if (oNotification)
{
if (oNotification.show)
{
oNotification.show();
}
window.setTimeout((function (oLocalNotifications) {
return function () {
if (oLocalNotifications.cancel)
{
oLocalNotifications.cancel();
}
else if (oLocalNotifications.close)
{
oLocalNotifications.close();
}
};
}(oNotification)), 7000);
}
}
}
;
_.each(aNewMessages, function (oItem) {
Cache.addNewMessageCache(sFolder, oItem.Uid);
});
if (3 < iLen)
{
fNotificationHelper(
LinkBuilder.notificationMailIcon(),
this.accountEmail(),
Utils.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', {
'COUNT': iLen
})
);
}
else
{
for (; iIndex < iLen; iIndex++)
{
fNotificationHelper(
LinkBuilder.notificationMailIcon(),
MessageModel.emailsToLine(MessageModel.initEmailsFromJson(aNewMessages[iIndex].From), false),
aNewMessages[iIndex].Subject
);
}
}
}
Cache.setFolderUidNext(sFolder, sUidNext);
}
};
DataStorage.prototype.hideMessageBodies = function ()
{
var oMessagesBodiesDom = this.messagesBodiesDom();
if (oMessagesBodiesDom)
{
oMessagesBodiesDom.find('.b-text-part').hide();
}
};
/**
* @param {boolean=} bBoot = false
* @returns {Array}
*/
DataStorage.prototype.getNextFolderNames = function (bBoot)
{
bBoot = Utils.isUnd(bBoot) ? false : !!bBoot;
var
aResult = [],
iLimit = 10,
iUtc = moment().unix(),
iTimeout = iUtc - 60 * 5,
aTimeouts = [],
fSearchFunction = function (aList) {
_.each(aList, function (oFolder) {
if (oFolder && 'INBOX' !== oFolder.fullNameRaw &&
oFolder.selectable && oFolder.existen &&
iTimeout > oFolder.interval &&
(!bBoot || oFolder.subScribed()))
{
aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]);
}
if (oFolder && 0 < oFolder.subFolders().length)
{
fSearchFunction(oFolder.subFolders());
}
});
}
;
fSearchFunction(this.folderList());
aTimeouts.sort(function(a, b) {
if (a[0] < b[0])
{
return -1;
}
else if (a[0] > b[0])
{
return 1;
}
return 0;
});
_.find(aTimeouts, function (aItem) {
var oFolder = Cache.getFolderFromCacheList(aItem[1]);
if (oFolder)
{
oFolder.interval = iUtc;
aResult.push(aItem[1]);
}
return iLimit <= aResult.length;
});
return _.uniq(aResult);
};
/**
* @param {string} sFromFolderFullNameRaw
* @param {Array} aUidForRemove
* @param {string=} sToFolderFullNameRaw = ''
* @param {bCopy=} bCopy = false
*/
DataStorage.prototype.removeMessagesFromList = function (
sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy)
{
sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : '';
bCopy = Utils.isUnd(bCopy) ? false : !!bCopy;
aUidForRemove = _.map(aUidForRemove, function (mValue) {
return Utils.pInt(mValue);
});
var
self = this,
iUnseenCount = 0,
aMessageList = this.messageList(),
oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw),
oToFolder = '' === sToFolderFullNameRaw ? null : Cache.getFolderFromCacheList(sToFolderFullNameRaw || ''),
sCurrentFolderFullNameRaw = this.currentFolderFullNameRaw(),
oCurrentMessage = this.message(),
aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(aMessageList, function (oMessage) {
return oMessage && -1 < Utils.inArray(Utils.pInt(oMessage.uid), aUidForRemove);
}) : []
;
_.each(aMessages, function (oMessage) {
if (oMessage && oMessage.unseen())
{
iUnseenCount++;
}
});
if (oFromFolder && !bCopy)
{
oFromFolder.messageCountAll(0 <= oFromFolder.messageCountAll() - aUidForRemove.length ?
oFromFolder.messageCountAll() - aUidForRemove.length : 0);
if (0 < iUnseenCount)
{
oFromFolder.messageCountUnread(0 <= oFromFolder.messageCountUnread() - iUnseenCount ?
oFromFolder.messageCountUnread() - iUnseenCount : 0);
}
}
if (oToFolder)
{
oToFolder.messageCountAll(oToFolder.messageCountAll() + aUidForRemove.length);
if (0 < iUnseenCount)
{
oToFolder.messageCountUnread(oToFolder.messageCountUnread() + iUnseenCount);
}
oToFolder.actionBlink(true);
}
if (0 < aMessages.length)
{
if (bCopy)
{
_.each(aMessages, function (oMessage) {
oMessage.checked(false);
});
}
else
{
this.messageListIsNotCompleted(true);
_.each(aMessages, function (oMessage) {
if (oCurrentMessage && oCurrentMessage.hash === oMessage.hash)
{
oCurrentMessage = null;
self.message(null);
}
oMessage.deleted(true);
});
_.delay(function () {
_.each(aMessages, function (oMessage) {
self.messageList.remove(oMessage);
});
}, 400);
}
}
if ('' !== sFromFolderFullNameRaw)
{
Cache.setFolderHash(sFromFolderFullNameRaw, '');
}
if ('' !== sToFolderFullNameRaw)
{
Cache.setFolderHash(sToFolderFullNameRaw, '');
}
};
DataStorage.prototype.setMessage = function (oData, bCached)
{
var
bIsHtml = false,
bHasExternals = false,
bHasInternals = false,
oBody = null,
oTextBody = null,
sId = '',
sResultHtml = '',
bPgpSigned = false,
bPgpEncrypted = false,
oMessagesBodiesDom = this.messagesBodiesDom(),
oMessage = this.message()
;
if (oData && oMessage && oData.Result && 'Object/Message' === oData.Result['@Object'] &&
oMessage.folderFullNameRaw === oData.Result.Folder && oMessage.uid === oData.Result.Uid)
{
this.messageError('');
oMessage.initUpdateByMessageJson(oData.Result);
Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
if (!bCached)
{
oMessage.initFlagsByJson(oData.Result);
}
oMessagesBodiesDom = oMessagesBodiesDom && oMessagesBodiesDom[0] ? oMessagesBodiesDom : null;
if (oMessagesBodiesDom)
{
sId = 'rl-mgs-' + oMessage.hash.replace(/[^a-zA-Z0-9]/g, '');
oTextBody = oMessagesBodiesDom.find('#' + sId);
if (!oTextBody || !oTextBody[0])
{
bHasExternals = !!oData.Result.HasExternals;
bHasInternals = !!oData.Result.HasInternals;
oBody = $('').hide().addClass('rl-cache-class');
oBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html)
{
bIsHtml = true;
sResultHtml = oData.Result.Html.toString();
}
else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain)
{
bIsHtml = false;
sResultHtml = Utils.plainToHtml(oData.Result.Plain.toString(), false);
if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && this.capaOpenPGP())
{
oMessage.plainRaw = Utils.pString(oData.Result.Plain);
bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oMessage.plainRaw);
if (!bPgpEncrypted)
{
bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oMessage.plainRaw) &&
/-----BEGIN PGP SIGNATURE-----/.test(oMessage.plainRaw);
}
$div.empty();
if (bPgpSigned && oMessage.isPgpSigned())
{
sResultHtml =
$div.append(
$('').text(oMessage.plainRaw)
).html()
;
}
else if (bPgpEncrypted && oMessage.isPgpEncrypted())
{
sResultHtml =
$div.append(
$('').text(oMessage.plainRaw)
).html()
;
}
$div.empty();
oMessage.isPgpSigned(bPgpSigned);
oMessage.isPgpEncrypted(bPgpEncrypted);
}
}
else
{
bIsHtml = false;
}
oBody
.html(Utils.linkify(sResultHtml))
.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'))
;
oMessage.isHtml(!!bIsHtml);
oMessage.hasImages(!!bHasExternals);
oMessage.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);
oMessage.pgpSignedVerifyUser('');
oMessage.body = oBody;
if (oMessage.body)
{
oMessagesBodiesDom.append(oMessage.body);
}
oMessage.storeDataToDom();
if (bHasInternals)
{
oMessage.showInternalImages(true);
}
if (oMessage.hasImages() && this.showImages())
{
oMessage.showExternalImages(true);
}
this.purgeMessageBodyCacheThrottle();
}
else
{
oMessage.body = oTextBody;
if (oMessage.body)
{
oMessage.body.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
oMessage.fetchDataToDom();
}
}
this.messageActiveDom(oMessage.body);
this.hideMessageBodies();
oMessage.body.show();
if (oBody)
{
Utils.initBlockquoteSwitcher(oBody);
}
}
Cache.initMessageFlagsFromCache(oMessage);
if (oMessage.unseen())
{
if (Globals.__APP)
{
Globals.__APP.setMessageSeen(oMessage);
}
}
Utils.windowResize();
}
};
/**
* @param {Array} aList
* @returns {string}
*/
DataStorage.prototype.calculateMessageListHash = function (aList)
{
return _.map(aList, function (oMessage) {
return '' + oMessage.hash + '_' + oMessage.threadsLen() + '_' + oMessage.flagHash();
}).join('|');
};
DataStorage.prototype.findPublicKeyByHex = function (sHash)
{
return _.find(this.openpgpkeysPublic(), function (oItem) {
return oItem && sHash === oItem.id;
});
};
DataStorage.prototype.findPublicKeysByEmail = function (sEmail)
{
return _.compact(_.map(this.openpgpkeysPublic(), function (oItem) {
var oKey = null;
if (oItem && sEmail === oItem.email)
{
try
{
oKey = window.openpgp.key.readArmored(oItem.armor);
if (oKey && !oKey.err && oKey.keys && oKey.keys[0])
{
return oKey.keys[0];
}
}
catch (e) {}
}
return null;
}));
};
/**
* @param {string} sEmail
* @param {string=} sPassword
* @returns {?}
*/
DataStorage.prototype.findPrivateKeyByEmail = function (sEmail, sPassword)
{
var
oPrivateKey = null,
oKey = _.find(this.openpgpkeysPrivate(), function (oItem) {
return oItem && sEmail === oItem.email;
})
;
if (oKey)
{
try
{
oPrivateKey = window.openpgp.key.readArmored(oKey.armor);
if (oPrivateKey && !oPrivateKey.err && oPrivateKey.keys && oPrivateKey.keys[0])
{
oPrivateKey = oPrivateKey.keys[0];
oPrivateKey.decrypt(Utils.pString(sPassword));
}
else
{
oPrivateKey = null;
}
}
catch (e)
{
oPrivateKey = null;
}
}
return oPrivateKey;
};
/**
* @param {string=} sPassword
* @returns {?}
*/
DataStorage.prototype.findSelfPrivateKey = function (sPassword)
{
return this.findPrivateKeyByEmail(this.accountEmail(), sPassword);
};
module.exports = new DataStorage();
}(module, require));
},{"$":21,"$div":12,"App:Knoin":28,"Consts":5,"Enums":6,"Globals":8,"LinkBuilder":9,"Model:Message":35,"NotificationClass":18,"Storage:Abstract:Data":50,"Storage:LocalStorage":56,"Storage:RainLoop:Cache":54,"Storage:Settings":59,"Utils":11,"_":26,"ko":23,"moment":24,"window":27}],56:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
/**
* @constructor
*/
function LocalStorage()
{
var
_ = require('_'),
NextStorageDriver = _.find([
require('Storage:LocalStorage:Cookie'),
require('Storage:LocalStorage:LocalStorage')
], function (NextStorageDriver) {
return NextStorageDriver.supported();
})
;
this.oDriver = null;
if (NextStorageDriver)
{
this.oDriver = new NextStorageDriver();
}
}
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
* @return {*}
*/
LocalStorage.prototype.get = function (iKey)
{
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
};
module.exports = new LocalStorage();
}(module, require));
},{"Storage:LocalStorage:Cookie":57,"Storage:LocalStorage:LocalStorage":58,"_":26}],57:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
$ = require('$'),
JSON = require('JSON'),
Consts = require('Consts'),
Utils = require('Utils')
;
/**
* @constructor
*/
function CookieDriver()
{
}
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
;
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, require));
},{"$":21,"Consts":5,"JSON":17,"Utils":11}],58:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
window = require('window'),
JSON = require('JSON'),
Consts = require('Consts'),
Utils = require('Utils')
;
/**
* @constructor
*/
function LocalStorageDriver()
{
}
LocalStorageDriver.supported = function ()
{
return !!window.localStorage;
};
/**
* @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, require));
},{"Consts":5,"JSON":17,"Utils":11,"window":27}],59:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
Utils = require('Utils')
;
/**
* @constructor
*/
function SettingsStorage()
{
this.oSettings = require('AppData');
this.oSettings = Utils.isNormal(this.oSettings) ? this.oSettings : {};
}
SettingsStorage.prototype.oSettings = null;
/**
* @param {string} sName
* @return {?}
*/
SettingsStorage.prototype.settingsGet = function (sName)
{
return Utils.isUnd(this.oSettings[sName]) ? null : this.oSettings[sName];
};
/**
* @param {string} sName
* @param {?} mValue
*/
SettingsStorage.prototype.settingsSet = function (sName, mValue)
{
this.oSettings[sName] = mValue;
};
/**
* @param {string} sName
* @return {boolean}
*/
SettingsStorage.prototype.capa = function (sName)
{
var mCapa = this.settingsGet('Capa');
return Utils.isArray(mCapa) && Utils.isNormal(sName) && -1 < Utils.inArray(sName, mCapa);
};
module.exports = new SettingsStorage();
}(module, require));
},{"AppData":16,"Utils":11}],60:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils'),
Remote = require('Storage:Admin:Remote'),
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminLoginViewModel()
{
KnoinAbstractViewModel.call(this, 'Center', 'AdminLogin');
this.login = ko.observable('');
this.password = ko.observable('');
this.loginError = ko.observable(false);
this.passwordError = ko.observable(false);
this.loginFocus = ko.observable(false);
this.login.subscribe(function () {
this.loginError(false);
}, this);
this.password.subscribe(function () {
this.passwordError(false);
}, this);
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.submitCommand = Utils.createCommand(this, function () {
Utils.triggerAutocompleteInputChange();
this.loginError('' === Utils.trim(this.login()));
this.passwordError('' === Utils.trim(this.password()));
if (this.loginError() || this.passwordError())
{
return false;
}
this.submitRequest(true);
Remote.adminLogin(_.bind(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
{
if (oData.Result)
{
require('App:Admin').loginAndLogoutReload();
}
else if (oData.ErrorCode)
{
this.submitRequest(false);
this.submitError(Utils.getNotification(oData.ErrorCode));
}
}
else
{
this.submitRequest(false);
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
}
}, this), this.login(), this.password());
return true;
}, function () {
return !this.submitRequest();
});
kn.constructorEnd(this);
}
kn.extendAsViewModel('AdminLoginViewModel', AdminLoginViewModel);
AdminLoginViewModel.prototype.onShow = function ()
{
kn.routeOff();
_.delay(_.bind(function () {
this.loginFocus(true);
}, this), 100);
};
AdminLoginViewModel.prototype.onHide = function ()
{
this.loginFocus(false);
};
AdminLoginViewModel.prototype.onBuild = function ()
{
Utils.triggerAutocompleteInputChange(true);
};
AdminLoginViewModel.prototype.submitForm = function ()
{
this.submitCommand();
};
module.exports = AdminLoginViewModel;
}(module, require));
},{"App:Admin":3,"App:Knoin":28,"Enums":6,"Knoin:AbstractViewModel":31,"Storage:Admin:Remote":53,"Utils":11,"_":26,"ko":23}],61:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
kn = require('App:Knoin'),
Globals = require('Globals'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @param {?} oScreen
*
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminMenuViewModel(oScreen)
{
KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu');
this.leftPanelDisabled = Globals.leftPanelDisabled;
this.menu = oScreen.menu;
kn.constructorEnd(this);
}
kn.extendAsViewModel('AdminMenuViewModel', AdminMenuViewModel);
AdminMenuViewModel.prototype.link = function (sRoute)
{
return '#/' + sRoute;
};
module.exports = AdminMenuViewModel;
}(module, require));
},{"App:Knoin":28,"Globals":8,"Knoin:AbstractViewModel":31}],62:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
ko = require('ko'),
Settings = require('Storage:Settings'),
Data = require('Storage:Admin:Data'),
Remote = require('Storage:Admin:Remote'),
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminPaneViewModel()
{
KnoinAbstractViewModel.call(this, 'Right', 'AdminPane');
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
this.version = ko.observable(Settings.settingsGet('Version'));
this.adminManLoadingVisibility = Data.adminManLoadingVisibility;
kn.constructorEnd(this);
}
kn.extendAsViewModel('AdminPaneViewModel', AdminPaneViewModel);
AdminPaneViewModel.prototype.logoutClick = function ()
{
Remote.adminLogout(function () {
require('App:Admin').loginAndLogoutReload();
});
};
module.exports = AdminPaneViewModel;
}(module, require));
},{"App:Admin":3,"App:Knoin":28,"Knoin:AbstractViewModel":31,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"Storage:Settings":59,"ko":23}],63:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
ko = require('ko'),
Enums = require('Enums'),
Utils = require('Utils'),
Settings = require('Storage:Settings'),
Data = require('Storage:Admin:Data'),
Remote = require('Storage:Admin:Remote'),
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsActivateViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsActivate');
var self = this;
this.domain = ko.observable('');
this.key = ko.observable('');
this.key.focus = ko.observable(false);
this.activationSuccessed = ko.observable(false);
this.licenseTrigger = Data.licenseTrigger;
this.activateProcess = ko.observable(false);
this.activateText = ko.observable('');
this.activateText.isError = ko.observable(false);
this.key.subscribe(function () {
this.activateText('');
this.activateText.isError(false);
}, this);
this.activationSuccessed.subscribe(function (bValue) {
if (bValue)
{
this.licenseTrigger(!this.licenseTrigger());
}
}, this);
this.activateCommand = Utils.createCommand(this, function () {
this.activateProcess(true);
if (this.validateSubscriptionKey())
{
Remote.licensingActivate(function (sResult, oData) {
self.activateProcess(false);
if (Enums.StorageResultType.Success === sResult && oData.Result)
{
if (true === oData.Result)
{
self.activationSuccessed(true);
self.activateText('Subscription Key Activated Successfully');
self.activateText.isError(false);
}
else
{
self.activateText(oData.Result);
self.activateText.isError(true);
self.key.focus(true);
}
}
else if (oData.ErrorCode)
{
self.activateText(Utils.getNotification(oData.ErrorCode));
self.activateText.isError(true);
self.key.focus(true);
}
else
{
self.activateText(Utils.getNotification(Enums.Notification.UnknownError));
self.activateText.isError(true);
self.key.focus(true);
}
}, this.domain(), this.key());
}
else
{
this.activateProcess(false);
this.activateText('Invalid Subscription Key');
this.activateText.isError(true);
this.key.focus(true);
}
}, function () {
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
});
kn.constructorEnd(this);
}
kn.extendAsViewModel('PopupsActivateViewModel', PopupsActivateViewModel);
PopupsActivateViewModel.prototype.onShow = function ()
{
this.domain(Settings.settingsGet('AdminDomain'));
if (!this.activateProcess())
{
this.key('');
this.activateText('');
this.activateText.isError(false);
this.activationSuccessed(false);
}
};
PopupsActivateViewModel.prototype.onFocus = function ()
{
if (!this.activateProcess())
{
this.key.focus(true);
}
};
/**
* @returns {boolean}
*/
PopupsActivateViewModel.prototype.validateSubscriptionKey = function ()
{
var sValue = this.key();
return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue));
};
module.exports = PopupsActivateViewModel;
}(module, require));
},{"App:Knoin":28,"Enums":6,"Knoin:AbstractViewModel":31,"Storage:Admin:Data":52,"Storage:Admin:Remote":53,"Storage:Settings":59,"Utils":11,"ko":23}],64:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
ko = require('ko'),
key = require('key'),
Enums = require('Enums'),
Utils = require('Utils'),
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsAskViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAsk');
this.askDesc = ko.observable('');
this.yesButton = ko.observable('');
this.noButton = ko.observable('');
this.yesFocus = ko.observable(false);
this.noFocus = ko.observable(false);
this.fYesAction = null;
this.fNoAction = null;
this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
kn.constructorEnd(this);
}
kn.extendAsViewModel('PopupsAskViewModel', PopupsAskViewModel);
PopupsAskViewModel.prototype.clearPopup = function ()
{
this.askDesc('');
this.yesButton(Utils.i18n('POPUPS_ASK/BUTTON_YES'));
this.noButton(Utils.i18n('POPUPS_ASK/BUTTON_NO'));
this.yesFocus(false);
this.noFocus(false);
this.fYesAction = null;
this.fNoAction = null;
};
PopupsAskViewModel.prototype.yesClick = function ()
{
this.cancelCommand();
if (Utils.isFunc(this.fYesAction))
{
this.fYesAction.call(null);
}
};
PopupsAskViewModel.prototype.noClick = function ()
{
this.cancelCommand();
if (Utils.isFunc(this.fNoAction))
{
this.fNoAction.call(null);
}
};
/**
* @param {string} sAskDesc
* @param {Function=} fYesFunc
* @param {Function=} fNoFunc
* @param {string=} sYesButton
* @param {string=} sNoButton
*/
PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton)
{
this.clearPopup();
this.fYesAction = fYesFunc || null;
this.fNoAction = fNoFunc || null;
this.askDesc(sAskDesc || '');
if (sYesButton)
{
this.yesButton(sYesButton);
}
if (sYesButton)
{
this.yesButton(sNoButton);
}
};
PopupsAskViewModel.prototype.onFocus = function ()
{
this.yesFocus(true);
};
PopupsAskViewModel.prototype.onBuild = function ()
{
key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function () {
if (this.yesFocus())
{
this.noFocus(true);
}
else
{
this.yesFocus(true);
}
return false;
}, this));
key('esc', Enums.KeyState.PopupAsk, _.bind(function () {
this.noClick();
return false;
}, this));
};
module.exports = PopupsAskViewModel;
}(module, require));
},{"App:Knoin":28,"Enums":6,"Knoin:AbstractViewModel":31,"Utils":11,"key":22,"ko":23}],65:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Enums = require('Enums'),
Consts = require('Consts'),
Utils = require('Utils'),
Remote = require('Storage:Admin:Remote'),
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsDomainViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsDomain');
this.edit = ko.observable(false);
this.saving = ko.observable(false);
this.savingError = ko.observable('');
this.whiteListPage = ko.observable(false);
this.testing = ko.observable(false);
this.testingDone = ko.observable(false);
this.testingImapError = ko.observable(false);
this.testingSmtpError = ko.observable(false);
this.testingImapErrorDesc = ko.observable('');
this.testingSmtpErrorDesc = ko.observable('');
this.testingImapError.subscribe(function (bValue) {
if (!bValue)
{
this.testingImapErrorDesc('');
}
}, this);
this.testingSmtpError.subscribe(function (bValue) {
if (!bValue)
{
this.testingSmtpErrorDesc('');
}
}, this);
this.testingImapErrorDesc = ko.observable('');
this.testingSmtpErrorDesc = ko.observable('');
this.imapServerFocus = ko.observable(false);
this.smtpServerFocus = ko.observable(false);
this.name = ko.observable('');
this.name.focused = ko.observable(false);
this.imapServer = ko.observable('');
this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort);
this.imapSecure = ko.observable(Enums.ServerSecure.None);
this.imapShortLogin = ko.observable(false);
this.smtpServer = ko.observable('');
this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
this.smtpShortLogin = ko.observable(false);
this.smtpAuth = ko.observable(true);
this.whiteList = ko.observable('');
this.headerText = ko.computed(function () {
var sName = this.name();
return this.edit() ? 'Edit Domain "' + sName + '"' :
'Add Domain' + ('' === sName ? '' : ' "' + sName + '"');
}, this);
this.domainIsComputed = ko.computed(function () {
return '' !== this.name() &&
'' !== this.imapServer() &&
'' !== this.imapPort() &&
'' !== this.smtpServer() &&
'' !== this.smtpPort();
}, this);
this.canBeTested = ko.computed(function () {
return !this.testing() && this.domainIsComputed();
}, this);
this.canBeSaved = ko.computed(function () {
return !this.saving() && this.domainIsComputed();
}, this);
this.createOrAddCommand = Utils.createCommand(this, function () {
this.saving(true);
Remote.createOrUpdateDomain(
_.bind(this.onDomainCreateOrSaveResponse, this),
!this.edit(),
this.name(),
this.imapServer(),
Utils.pInt(this.imapPort()),
this.imapSecure(),
this.imapShortLogin(),
this.smtpServer(),
Utils.pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpShortLogin(),
this.smtpAuth(),
this.whiteList()
);
}, this.canBeSaved);
this.testConnectionCommand = Utils.createCommand(this, function () {
this.whiteListPage(false);
this.testingDone(false);
this.testingImapError(false);
this.testingSmtpError(false);
this.testing(true);
Remote.testConnectionForDomain(
_.bind(this.onTestConnectionResponse, this),
this.name(),
this.imapServer(),
Utils.pInt(this.imapPort()),
this.imapSecure(),
this.smtpServer(),
Utils.pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpAuth()
);
}, this.canBeTested);
this.whiteListCommand = Utils.createCommand(this, function () {
this.whiteListPage(!this.whiteListPage());
});
// smart form improvements
this.imapServerFocus.subscribe(function (bValue) {
if (bValue && '' !== this.name() && '' === this.imapServer())
{
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
}
}, this);
this.smtpServerFocus.subscribe(function (bValue) {
if (bValue && '' !== this.imapServer() && '' === this.smtpServer())
{
this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp'));
}
}, this);
this.imapSecure.subscribe(function (sValue) {
var iPort = Utils.pInt(this.imapPort());
sValue = Utils.pString(sValue);
switch (sValue)
{
case '0':
if (993 === iPort)
{
this.imapPort('143');
}
break;
case '1':
if (143 === iPort)
{
this.imapPort('993');
}
break;
}
}, this);
this.smtpSecure.subscribe(function (sValue) {
var iPort = Utils.pInt(this.smtpPort());
sValue = Utils.pString(sValue);
switch (sValue)
{
case '0':
if (465 === iPort || 587 === iPort)
{
this.smtpPort('25');
}
break;
case '1':
if (25 === iPort || 587 === iPort)
{
this.smtpPort('465');
}
break;
case '2':
if (25 === iPort || 465 === iPort)
{
this.smtpPort('587');
}
break;
}
}, this);
kn.constructorEnd(this);
}
kn.extendAsViewModel('PopupsDomainViewModel', PopupsDomainViewModel);
PopupsDomainViewModel.prototype.onTestConnectionResponse = function (sResult, oData)
{
this.testing(false);
if (Enums.StorageResultType.Success === sResult && oData.Result)
{
this.testingDone(true);
this.testingImapError(true !== oData.Result.Imap);
this.testingSmtpError(true !== oData.Result.Smtp);
if (this.testingImapError() && oData.Result.Imap)
{
this.testingImapErrorDesc(oData.Result.Imap);
}
if (this.testingSmtpError() && oData.Result.Smtp)
{
this.testingSmtpErrorDesc(oData.Result.Smtp);
}
}
else
{
this.testingImapError(true);
this.testingSmtpError(true);
}
};
PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult, oData)
{
this.saving(false);
if (Enums.StorageResultType.Success === sResult && oData)
{
if (oData.Result)
{
require('App:Admin').reloadDomainList();
this.closeCommand();
}
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
{
this.savingError('Domain already exists');
}
}
else
{
this.savingError('Unknown error');
}
};
PopupsDomainViewModel.prototype.onHide = function ()
{
this.whiteListPage(false);
};
PopupsDomainViewModel.prototype.onShow = function (oDomain)
{
this.saving(false);
this.whiteListPage(false);
this.testing(false);
this.testingDone(false);
this.testingImapError(false);
this.testingSmtpError(false);
this.clearForm();
if (oDomain)
{
this.edit(true);
this.name(Utils.trim(oDomain.Name));
this.imapServer(Utils.trim(oDomain.IncHost));
this.imapPort('' + Utils.pInt(oDomain.IncPort));
this.imapSecure(Utils.trim(oDomain.IncSecure));
this.imapShortLogin(!!oDomain.IncShortLogin);
this.smtpServer(Utils.trim(oDomain.OutHost));
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
this.smtpSecure(Utils.trim(oDomain.OutSecure));
this.smtpShortLogin(!!oDomain.OutShortLogin);
this.smtpAuth(!!oDomain.OutAuth);
this.whiteList(Utils.trim(oDomain.WhiteList));
}
};
PopupsDomainViewModel.prototype.onFocus = function ()
{
if ('' === this.name())
{
this.name.focused(true);
}
};
PopupsDomainViewModel.prototype.clearForm = function ()
{
this.edit(false);
this.whiteListPage(false);
this.savingError('');
this.name('');
this.name.focused(false);
this.imapServer('');
this.imapPort('' + Consts.Values.ImapDefaulPort);
this.imapSecure(Enums.ServerSecure.None);
this.imapShortLogin(false);
this.smtpServer('');
this.smtpPort('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure(Enums.ServerSecure.None);
this.smtpShortLogin(false);
this.smtpAuth(true);
this.whiteList('');
};
module.exports = PopupsDomainViewModel;
}(module, require));
},{"App:Admin":3,"App:Knoin":28,"Consts":5,"Enums":6,"Knoin:AbstractViewModel":31,"Storage:Admin:Remote":53,"Utils":11,"_":26,"ko":23}],66:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Utils = require('Utils'),
Data = require('Storage:RainLoop:Data'),
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsLanguagesViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsLanguages');
this.exp = ko.observable(false);
this.languages = ko.computed(function () {
return _.map(Data.languages(), function (sLanguage) {
return {
'key': sLanguage,
'selected': ko.observable(false),
'fullName': Utils.convertLangName(sLanguage)
};
});
});
Data.mainLanguage.subscribe(function () {
this.resetMainLanguage();
}, this);
kn.constructorEnd(this);
}
kn.extendAsViewModel('PopupsLanguagesViewModel', PopupsLanguagesViewModel);
PopupsLanguagesViewModel.prototype.languageEnName = function (sLanguage)
{
return Utils.convertLangName(sLanguage, true);
};
PopupsLanguagesViewModel.prototype.resetMainLanguage = function ()
{
var sCurrent = Data.mainLanguage();
_.each(this.languages(), function (oItem) {
oItem['selected'](oItem['key'] === sCurrent);
});
};
PopupsLanguagesViewModel.prototype.onShow = function ()
{
this.exp(true);
this.resetMainLanguage();
};
PopupsLanguagesViewModel.prototype.onHide = function ()
{
this.exp(false);
};
PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
{
Data.mainLanguage(sLang);
this.cancelCommand();
};
module.exports = PopupsLanguagesViewModel;
}(module, require));
},{"App:Knoin":28,"Knoin:AbstractViewModel":31,"Storage:RainLoop:Data":55,"Utils":11,"_":26,"ko":23}],67:[function(require,module,exports){
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module, require) {
'use strict';
var
_ = require('_'),
ko = require('ko'),
key = require('key'),
Enums = require('Enums'),
Utils = require('Utils'),
Remote = require('Storage:Admin:Remote'),
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function PopupsPluginViewModel()
{
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsPlugin');
var self = this;
this.onPluginSettingsUpdateResponse = _.bind(this.onPluginSettingsUpdateResponse, this);
this.saveError = ko.observable('');
this.name = ko.observable('');
this.readme = ko.observable('');
this.configures = ko.observableArray([]);
this.hasReadme = ko.computed(function () {
return '' !== this.readme();
}, this);
this.hasConfiguration = ko.computed(function () {
return 0 < this.configures().length;
}, this);
this.readmePopoverConf = {
'placement': 'top',
'trigger': 'hover',
'title': 'About',
'content': function () {
return self.readme();
}
};
this.saveCommand = Utils.createCommand(this, function () {
var oList = {};
oList['Name'] = this.name();
_.each(this.configures(), function (oItem) {
var mValue = oItem.value();
if (false === mValue || true === mValue)
{
mValue = mValue ? '1' : '0';
}
oList['_' + oItem['Name']] = mValue;
}, this);
this.saveError('');
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, oList);
}, this.hasConfiguration);
this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.All;
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
kn.constructorEnd(this);
}
kn.extendAsViewModel('PopupsPluginViewModel', PopupsPluginViewModel);
PopupsPluginViewModel.prototype.onPluginSettingsUpdateResponse = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.cancelCommand();
}
else
{
this.saveError('');
if (oData && oData.ErrorCode)
{
this.saveError(Utils.getNotification(oData.ErrorCode));
}
else
{
this.saveError(Utils.getNotification(Enums.Notification.CantSavePluginSettings));
}
}
};
PopupsPluginViewModel.prototype.onShow = function (oPlugin)
{
this.name();
this.readme();
this.configures([]);
if (oPlugin)
{
this.name(oPlugin['Name']);
this.readme(oPlugin['Readme']);
var aConfig = oPlugin['Config'];
if (Utils.isNonEmptyArray(aConfig))
{
this.configures(_.map(aConfig, function (aItem) {
return {
'value': ko.observable(aItem[0]),
'Name': aItem[1],
'Type': aItem[2],
'Label': aItem[3],
'Default': aItem[4],
'Desc': aItem[5]
};
}));
}
}
};
PopupsPluginViewModel.prototype.tryToClosePopup = function ()
{
var
self = this,
PopupsAskViewModel = require('View:Popup:Ask')
;
if (!kn.isPopupVisible(PopupsAskViewModel))
{
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
if (self.modalVisibility())
{
Utils.delegateRun(self, 'cancelCommand');
}
}]);
}
};
PopupsPluginViewModel.prototype.onBuild = function ()
{
key('esc', Enums.KeyState.All, _.bind(function () {
if (this.modalVisibility())
{
this.tryToClosePopup();
}
return false;
}, this));
};
module.exports = PopupsPluginViewModel;
}(module, require));
},{"App:Knoin":28,"Enums":6,"Knoin:AbstractViewModel":31,"Storage:Admin:Remote":53,"Utils":11,"View:Popup:Ask":64,"_":26,"key":22,"ko":23}]},{},[1]);