mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +03:00
CommonJS (research/2)
This commit is contained in:
parent
56607de87c
commit
586abbb802
115 changed files with 16201 additions and 9943 deletions
|
|
@ -1,118 +1,138 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsActivateViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsActivate');
|
||||
(function (module) {
|
||||
|
||||
var self = this;
|
||||
'use strict';
|
||||
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
this.licenseTrigger = RL.data().licenseTrigger;
|
||||
|
||||
this.activateProcess = ko.observable(false);
|
||||
this.activateText = ko.observable('');
|
||||
this.activateText.isError = ko.observable(false);
|
||||
Data = require('../../Storages/AdminDataStorage.js'),
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
this.key.subscribe(function () {
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
}, this);
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsActivateViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsActivate');
|
||||
|
||||
this.activationSuccessed.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
}, this);
|
||||
var self = this;
|
||||
|
||||
this.activateCommand = Utils.createCommand(this, function () {
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey())
|
||||
{
|
||||
RL.remote().licensingActivate(function (sResult, oData) {
|
||||
this.licenseTrigger = Data.licenseTrigger;
|
||||
|
||||
self.activateProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
if (true === oData.Result)
|
||||
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)
|
||||
{
|
||||
self.activationSuccessed(true);
|
||||
self.activateText('Subscription Key Activated Successfully');
|
||||
self.activateText.isError(false);
|
||||
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
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
self.activateText(oData.Result);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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.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(RL.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
this.key('');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsActivateViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
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();
|
||||
});
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsActivateViewModel', PopupsActivateViewModel);
|
||||
|
||||
PopupsActivateViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.domain(RL.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess())
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
PopupsActivateViewModel.prototype.validateSubscriptionKey = function ()
|
||||
{
|
||||
this.key('');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
}
|
||||
};
|
||||
var sValue = this.key();
|
||||
return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue));
|
||||
};
|
||||
|
||||
module.exports = new PopupsActivateViewModel();
|
||||
|
||||
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));
|
||||
|
|
@ -1,95 +1,115 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAddAccountViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddAccount');
|
||||
(function (module) {
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
'use strict';
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAddAccountViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddAccount');
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
|
||||
this.addAccountCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.accountAdd(_.bind(function (sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AccountAdd' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.email(), '', this.password());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel('PopupsAddAccountViewModel', PopupsAddAccountViewModel);
|
||||
|
||||
PopupsAddAccountViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.email('');
|
||||
this.password('');
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
PopupsAddAccountViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
this.addAccountCommand = Utils.createCommand(this, function () {
|
||||
PopupsAddAccountViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.emailFocus(true);
|
||||
};
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
module.exports = new PopupsAddAccountViewModel();
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
RL.remote().accountAdd(_.bind(function (sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AccountAdd' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.email(), '', this.password());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsAddAccountViewModel', PopupsAddAccountViewModel);
|
||||
|
||||
PopupsAddAccountViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.email('');
|
||||
this.password('');
|
||||
|
||||
this.emailError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
PopupsAddAccountViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsAddAccountViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.emailFocus(true);
|
||||
};
|
||||
}(module));
|
||||
|
|
@ -1,90 +1,109 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAddOpenPgpKeyViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey');
|
||||
(function (module) {
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.key.error = ko.observable(false);
|
||||
this.key.focus = ko.observable(false);
|
||||
'use strict';
|
||||
|
||||
this.key.subscribe(function () {
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAddOpenPgpKeyViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey');
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.key.error = ko.observable(false);
|
||||
this.key.focus = ko.observable(false);
|
||||
|
||||
this.key.subscribe(function () {
|
||||
this.key.error(false);
|
||||
}, this);
|
||||
|
||||
this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
iCount = 30,
|
||||
aMatch = null,
|
||||
sKey = Utils.trim(this.key()),
|
||||
oReg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi,
|
||||
oOpenpgpKeyring = Data.openpgpKeyring
|
||||
;
|
||||
|
||||
sKey = sKey.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g, '\n$1!-!N!-!$2')
|
||||
.replace(/[\n\r]+/g, '\n').replace(/!-!N!-!/g, '\n\n');
|
||||
|
||||
this.key.error('' === sKey);
|
||||
|
||||
if (!oOpenpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
aMatch = oReg.exec(sKey);
|
||||
if (!aMatch || 0 > iCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (aMatch[0] && aMatch[1] && aMatch[2] && aMatch[1] === aMatch[2])
|
||||
{
|
||||
if ('PRIVATE' === aMatch[1])
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(aMatch[0]);
|
||||
}
|
||||
else if ('PUBLIC' === aMatch[1])
|
||||
{
|
||||
oOpenpgpKeyring.publicKeys.importKey(aMatch[0]);
|
||||
}
|
||||
}
|
||||
|
||||
iCount--;
|
||||
}
|
||||
while (true);
|
||||
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
RL.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(this, 'cancelCommand');
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel('PopupsAddOpenPgpKeyViewModel', PopupsAddOpenPgpKeyViewModel);
|
||||
|
||||
PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.key('');
|
||||
this.key.error(false);
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
PopupsAddOpenPgpKeyViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
var
|
||||
iCount = 30,
|
||||
aMatch = null,
|
||||
sKey = Utils.trim(this.key()),
|
||||
oReg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi,
|
||||
oOpenpgpKeyring = RL.data().openpgpKeyring
|
||||
;
|
||||
PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.key.focus(true);
|
||||
};
|
||||
|
||||
sKey = sKey.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g, '\n$1!-!N!-!$2')
|
||||
.replace(/[\n\r]+/g, '\n').replace(/!-!N!-!/g, '\n\n');
|
||||
module.exports = new PopupsAddOpenPgpKeyViewModel();
|
||||
|
||||
this.key.error('' === sKey);
|
||||
|
||||
if (!oOpenpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
aMatch = oReg.exec(sKey);
|
||||
if (!aMatch || 0 > iCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (aMatch[0] && aMatch[1] && aMatch[2] && aMatch[1] === aMatch[2])
|
||||
{
|
||||
if ('PRIVATE' === aMatch[1])
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(aMatch[0]);
|
||||
}
|
||||
else if ('PUBLIC' === aMatch[1])
|
||||
{
|
||||
oOpenpgpKeyring.publicKeys.importKey(aMatch[0]);
|
||||
}
|
||||
}
|
||||
|
||||
iCount--;
|
||||
}
|
||||
while (true);
|
||||
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
RL.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(this, 'cancelCommand');
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsAddOpenPgpKeyViewModel', PopupsAddOpenPgpKeyViewModel);
|
||||
|
||||
PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.key('');
|
||||
this.key.error(false);
|
||||
};
|
||||
|
||||
PopupsAddOpenPgpKeyViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.key.focus(true);
|
||||
};
|
||||
}(module));
|
||||
|
|
@ -1,137 +1,157 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAdvancedSearchViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAdvancedSearch');
|
||||
(function (module) {
|
||||
|
||||
this.fromFocus = ko.observable(false);
|
||||
|
||||
this.from = ko.observable('');
|
||||
this.to = ko.observable('');
|
||||
this.subject = ko.observable('');
|
||||
this.text = ko.observable('');
|
||||
this.selectedDateValue = ko.observable(-1);
|
||||
'use strict';
|
||||
|
||||
this.hasAttachment = ko.observable(false);
|
||||
this.starred = ko.observable(false);
|
||||
this.unseen = ko.observable(false);
|
||||
|
||||
this.searchCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var sSearch = this.buildSearchString();
|
||||
if ('' !== sSearch)
|
||||
{
|
||||
RL.data().mainMessageListSearch(sSearch);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
});
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsAdvancedSearchViewModel', PopupsAdvancedSearchViewModel);
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.buildSearchStringValue = function (sValue)
|
||||
{
|
||||
if (-1 < sValue.indexOf(' '))
|
||||
{
|
||||
sValue = '"' + sValue + '"';
|
||||
}
|
||||
|
||||
return sValue;
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.buildSearchString = function ()
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
sFrom = Utils.trim(this.from()),
|
||||
sTo = Utils.trim(this.to()),
|
||||
sSubject = Utils.trim(this.subject()),
|
||||
sText = Utils.trim(this.text()),
|
||||
aIs = [],
|
||||
aHas = []
|
||||
ko = require('../../External/ko.js'),
|
||||
moment = require('../../External/moment.js'),
|
||||
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
if (sFrom && '' !== sFrom)
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAdvancedSearchViewModel()
|
||||
{
|
||||
aResult.push('from:' + this.buildSearchStringValue(sFrom));
|
||||
}
|
||||
|
||||
if (sTo && '' !== sTo)
|
||||
{
|
||||
aResult.push('to:' + this.buildSearchStringValue(sTo));
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAdvancedSearch');
|
||||
|
||||
this.fromFocus = ko.observable(false);
|
||||
|
||||
this.from = ko.observable('');
|
||||
this.to = ko.observable('');
|
||||
this.subject = ko.observable('');
|
||||
this.text = ko.observable('');
|
||||
this.selectedDateValue = ko.observable(-1);
|
||||
|
||||
this.hasAttachment = ko.observable(false);
|
||||
this.starred = ko.observable(false);
|
||||
this.unseen = ko.observable(false);
|
||||
|
||||
this.searchCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var sSearch = this.buildSearchString();
|
||||
if ('' !== sSearch)
|
||||
{
|
||||
Data.mainMessageListSearch(sSearch);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
if (sSubject && '' !== sSubject)
|
||||
kn.extendAsViewModel('PopupsAdvancedSearchViewModel', PopupsAdvancedSearchViewModel);
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.buildSearchStringValue = function (sValue)
|
||||
{
|
||||
aResult.push('subject:' + this.buildSearchStringValue(sSubject));
|
||||
}
|
||||
|
||||
if (this.hasAttachment())
|
||||
if (-1 < sValue.indexOf(' '))
|
||||
{
|
||||
sValue = '"' + sValue + '"';
|
||||
}
|
||||
|
||||
return sValue;
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.buildSearchString = function ()
|
||||
{
|
||||
aHas.push('attachment');
|
||||
}
|
||||
|
||||
if (this.unseen())
|
||||
var
|
||||
aResult = [],
|
||||
sFrom = Utils.trim(this.from()),
|
||||
sTo = Utils.trim(this.to()),
|
||||
sSubject = Utils.trim(this.subject()),
|
||||
sText = Utils.trim(this.text()),
|
||||
aIs = [],
|
||||
aHas = []
|
||||
;
|
||||
|
||||
if (sFrom && '' !== sFrom)
|
||||
{
|
||||
aResult.push('from:' + this.buildSearchStringValue(sFrom));
|
||||
}
|
||||
|
||||
if (sTo && '' !== sTo)
|
||||
{
|
||||
aResult.push('to:' + this.buildSearchStringValue(sTo));
|
||||
}
|
||||
|
||||
if (sSubject && '' !== sSubject)
|
||||
{
|
||||
aResult.push('subject:' + this.buildSearchStringValue(sSubject));
|
||||
}
|
||||
|
||||
if (this.hasAttachment())
|
||||
{
|
||||
aHas.push('attachment');
|
||||
}
|
||||
|
||||
if (this.unseen())
|
||||
{
|
||||
aIs.push('unseen');
|
||||
}
|
||||
|
||||
if (this.starred())
|
||||
{
|
||||
aIs.push('flagged');
|
||||
}
|
||||
|
||||
if (0 < aHas.length)
|
||||
{
|
||||
aResult.push('has:' + aHas.join(','));
|
||||
}
|
||||
|
||||
if (0 < aIs.length)
|
||||
{
|
||||
aResult.push('is:' + aIs.join(','));
|
||||
}
|
||||
|
||||
if (-1 < this.selectedDateValue())
|
||||
{
|
||||
aResult.push('date:' + moment().subtract('days', this.selectedDateValue()).format('YYYY.MM.DD') + '/');
|
||||
}
|
||||
|
||||
if (sText && '' !== sText)
|
||||
{
|
||||
aResult.push('text:' + this.buildSearchStringValue(sText));
|
||||
}
|
||||
|
||||
return Utils.trim(aResult.join(' '));
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
aIs.push('unseen');
|
||||
}
|
||||
this.from('');
|
||||
this.to('');
|
||||
this.subject('');
|
||||
this.text('');
|
||||
|
||||
if (this.starred())
|
||||
this.selectedDateValue(-1);
|
||||
this.hasAttachment(false);
|
||||
this.starred(false);
|
||||
this.unseen(false);
|
||||
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.onShow = function ()
|
||||
{
|
||||
aIs.push('flagged');
|
||||
}
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
if (0 < aHas.length)
|
||||
PopupsAdvancedSearchViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
aResult.push('has:' + aHas.join(','));
|
||||
}
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
if (0 < aIs.length)
|
||||
{
|
||||
aResult.push('is:' + aIs.join(','));
|
||||
}
|
||||
module.exports = new PopupsAdvancedSearchViewModel();
|
||||
|
||||
if (-1 < this.selectedDateValue())
|
||||
{
|
||||
aResult.push('date:' + moment().subtract('days', this.selectedDateValue()).format('YYYY.MM.DD') + '/');
|
||||
}
|
||||
|
||||
if (sText && '' !== sText)
|
||||
{
|
||||
aResult.push('text:' + this.buildSearchStringValue(sText));
|
||||
}
|
||||
|
||||
return Utils.trim(aResult.join(' '));
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.from('');
|
||||
this.to('');
|
||||
this.subject('');
|
||||
this.text('');
|
||||
|
||||
this.selectedDateValue(-1);
|
||||
this.hasAttachment(false);
|
||||
this.starred(false);
|
||||
this.unseen(false);
|
||||
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsAdvancedSearchViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.fromFocus(true);
|
||||
};
|
||||
}(module));
|
||||
|
|
@ -1,112 +1,128 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAskViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAsk');
|
||||
(function (module) {
|
||||
|
||||
this.askDesc = ko.observable('');
|
||||
this.yesButton = ko.observable('');
|
||||
this.noButton = ko.observable('');
|
||||
'use strict';
|
||||
|
||||
this.yesFocus = ko.observable(false);
|
||||
this.noFocus = ko.observable(false);
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
key = require('../../External/key.js'),
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.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))
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsAskViewModel()
|
||||
{
|
||||
this.fYesAction.call(null);
|
||||
}
|
||||
};
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAsk');
|
||||
|
||||
PopupsAskViewModel.prototype.noClick = function ()
|
||||
{
|
||||
this.cancelCommand();
|
||||
this.askDesc = ko.observable('');
|
||||
this.yesButton = ko.observable('');
|
||||
this.noButton = ko.observable('');
|
||||
|
||||
if (Utils.isFunc(this.fNoAction))
|
||||
{
|
||||
this.fNoAction.call(null);
|
||||
}
|
||||
};
|
||||
this.yesFocus = ko.observable(false);
|
||||
this.noFocus = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @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.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
|
||||
this.askDesc(sAskDesc || '');
|
||||
if (sYesButton)
|
||||
{
|
||||
this.yesButton(sYesButton);
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
if (sYesButton)
|
||||
kn.extendAsViewModel('PopupsAskViewModel', PopupsAskViewModel);
|
||||
|
||||
PopupsAskViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.yesButton(sNoButton);
|
||||
}
|
||||
};
|
||||
this.askDesc('');
|
||||
this.yesButton(Utils.i18n('POPUPS_ASK/BUTTON_YES'));
|
||||
this.noButton(Utils.i18n('POPUPS_ASK/BUTTON_NO'));
|
||||
|
||||
PopupsAskViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.yesFocus(true);
|
||||
};
|
||||
this.yesFocus(false);
|
||||
this.noFocus(false);
|
||||
|
||||
PopupsAskViewModel.prototype.onBuild = function ()
|
||||
{
|
||||
key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function () {
|
||||
if (this.yesFocus())
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
};
|
||||
|
||||
PopupsAskViewModel.prototype.yesClick = function ()
|
||||
{
|
||||
this.cancelCommand();
|
||||
|
||||
if (Utils.isFunc(this.fYesAction))
|
||||
{
|
||||
this.noFocus(true);
|
||||
this.fYesAction.call(null);
|
||||
}
|
||||
else
|
||||
};
|
||||
|
||||
PopupsAskViewModel.prototype.noClick = function ()
|
||||
{
|
||||
this.cancelCommand();
|
||||
|
||||
if (Utils.isFunc(this.fNoAction))
|
||||
{
|
||||
this.yesFocus(true);
|
||||
this.fNoAction.call(null);
|
||||
}
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
|
||||
key('esc', Enums.KeyState.PopupAsk, _.bind(function () {
|
||||
this.noClick();
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
/**
|
||||
* @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 = new PopupsAskViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,241 +1,262 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsComposeOpenPgpViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsComposeOpenPgp');
|
||||
(function (module) {
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.sign = ko.observable(true);
|
||||
this.encrypt = ko.observable(true);
|
||||
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
|
||||
this.from = ko.observable('');
|
||||
this.to = ko.observableArray([]);
|
||||
this.text = ko.observable('');
|
||||
|
||||
this.resultCallback = null;
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
// commands
|
||||
this.doCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
bResult = true,
|
||||
oData = RL.data(),
|
||||
oPrivateKey = null,
|
||||
aPublicKeys = []
|
||||
;
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
if (bResult && this.sign() && '' === this.from())
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_FROM_EMAIL'));
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
if (bResult && this.sign())
|
||||
{
|
||||
oPrivateKey = oData.findPrivateKeyByEmail(this.from(), this.password());
|
||||
if (!oPrivateKey)
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.from()
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult && this.encrypt() && 0 === this.to().length)
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_AT_LEAST_ONE_RECIPIENT'));
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
if (bResult && this.encrypt())
|
||||
{
|
||||
aPublicKeys = [];
|
||||
_.each(this.to(), function (sEmail) {
|
||||
var aKeys = oData.findPublicKeysByEmail(sEmail);
|
||||
if (0 === aKeys.length && bResult)
|
||||
{
|
||||
self.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
'EMAIL': sEmail
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
aPublicKeys = aPublicKeys.concat(aKeys);
|
||||
});
|
||||
|
||||
if (bResult && (0 === aPublicKeys.length || this.to().length !== aPublicKeys.length))
|
||||
{
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
if (self.resultCallback && bResult)
|
||||
{
|
||||
try {
|
||||
|
||||
if (oPrivateKey && 0 === aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
window.openpgp.signClearMessage([oPrivateKey], self.text())
|
||||
);
|
||||
}
|
||||
else if (oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
window.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, self.text())
|
||||
);
|
||||
}
|
||||
else if (!oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
window.openpgp.encryptMessage(aPublicKeys, self.text())
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
self.notification(Utils.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
self.cancelCommand();
|
||||
}
|
||||
|
||||
self.submitRequest(false);
|
||||
|
||||
}, 10);
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && (this.sign() || this.encrypt());
|
||||
});
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsComposeOpenPgpViewModel', PopupsComposeOpenPgpViewModel);
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.notification('');
|
||||
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
|
||||
this.from('');
|
||||
this.to([]);
|
||||
this.text('');
|
||||
|
||||
this.submitRequest(false);
|
||||
|
||||
this.resultCallback = null;
|
||||
};
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.onBuild = function ()
|
||||
{
|
||||
key('tab,shift+tab', Enums.KeyState.PopupComposeOpenPGP, _.bind(function () {
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case this.password.focus():
|
||||
this.buttonFocus(true);
|
||||
break;
|
||||
case this.buttonFocus():
|
||||
this.password.focus(true);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}, this));
|
||||
};
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.onHide = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
if (this.sign())
|
||||
{
|
||||
this.password.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buttonFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc)
|
||||
{
|
||||
this.clearPopup();
|
||||
'use strict';
|
||||
|
||||
var
|
||||
oEmail = new EmailModel(),
|
||||
sResultFromEmail = '',
|
||||
aRec = []
|
||||
window = require('../../External/window.js'),
|
||||
ko = require('../../External/ko.js'),
|
||||
key = require('../../External/key.js'),
|
||||
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(sFromEmail);
|
||||
if ('' !== oEmail.email)
|
||||
{
|
||||
sResultFromEmail = oEmail.email;
|
||||
}
|
||||
|
||||
if ('' !== sTo)
|
||||
{
|
||||
aRec.push(sTo);
|
||||
}
|
||||
|
||||
if ('' !== sCc)
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsComposeOpenPgpViewModel()
|
||||
{
|
||||
aRec.push(sCc);
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsComposeOpenPgp');
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.sign = ko.observable(true);
|
||||
this.encrypt = ko.observable(true);
|
||||
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
|
||||
this.from = ko.observable('');
|
||||
this.to = ko.observableArray([]);
|
||||
this.text = ko.observable('');
|
||||
|
||||
this.resultCallback = null;
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
// commands
|
||||
this.doCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
bResult = true,
|
||||
oPrivateKey = null,
|
||||
aPublicKeys = []
|
||||
;
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
if (bResult && this.sign() && '' === this.from())
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_FROM_EMAIL'));
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
if (bResult && this.sign())
|
||||
{
|
||||
oPrivateKey = Data.findPrivateKeyByEmail(this.from(), this.password());
|
||||
if (!oPrivateKey)
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.from()
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult && this.encrypt() && 0 === this.to().length)
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_AT_LEAST_ONE_RECIPIENT'));
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
if (bResult && this.encrypt())
|
||||
{
|
||||
aPublicKeys = [];
|
||||
_.each(this.to(), function (sEmail) {
|
||||
var aKeys = Data.findPublicKeysByEmail(sEmail);
|
||||
if (0 === aKeys.length && bResult)
|
||||
{
|
||||
self.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
'EMAIL': sEmail
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
aPublicKeys = aPublicKeys.concat(aKeys);
|
||||
});
|
||||
|
||||
if (bResult && (0 === aPublicKeys.length || this.to().length !== aPublicKeys.length))
|
||||
{
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
if (self.resultCallback && bResult)
|
||||
{
|
||||
try {
|
||||
|
||||
if (oPrivateKey && 0 === aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
window.openpgp.signClearMessage([oPrivateKey], self.text())
|
||||
);
|
||||
}
|
||||
else if (oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
window.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, self.text())
|
||||
);
|
||||
}
|
||||
else if (!oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
window.openpgp.encryptMessage(aPublicKeys, self.text())
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
self.notification(Utils.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
self.cancelCommand();
|
||||
}
|
||||
|
||||
self.submitRequest(false);
|
||||
|
||||
}, 10);
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && (this.sign() || this.encrypt());
|
||||
});
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
if ('' !== sBcc)
|
||||
{
|
||||
aRec.push(sBcc);
|
||||
}
|
||||
kn.extendAsViewModel('PopupsComposeOpenPgpViewModel', PopupsComposeOpenPgpViewModel);
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.notification('');
|
||||
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
|
||||
this.from('');
|
||||
this.to([]);
|
||||
this.text('');
|
||||
|
||||
this.submitRequest(false);
|
||||
|
||||
this.resultCallback = null;
|
||||
};
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.onBuild = function ()
|
||||
{
|
||||
key('tab,shift+tab', Enums.KeyState.PopupComposeOpenPGP, _.bind(function () {
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case this.password.focus():
|
||||
this.buttonFocus(true);
|
||||
break;
|
||||
case this.buttonFocus():
|
||||
this.password.focus(true);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}, this));
|
||||
};
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.onHide = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
if (this.sign())
|
||||
{
|
||||
this.password.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buttonFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
var
|
||||
oEmail = new EmailModel(),
|
||||
sResultFromEmail = '',
|
||||
aRec = []
|
||||
;
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
|
||||
aRec = aRec.join(', ').split(',');
|
||||
aRec = _.compact(_.map(aRec, function (sValue) {
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(Utils.trim(sValue));
|
||||
return '' === oEmail.email ? false : oEmail.email;
|
||||
}));
|
||||
oEmail.mailsoParse(sFromEmail);
|
||||
if ('' !== oEmail.email)
|
||||
{
|
||||
sResultFromEmail = oEmail.email;
|
||||
}
|
||||
|
||||
this.from(sResultFromEmail);
|
||||
this.to(aRec);
|
||||
this.text(sText);
|
||||
};
|
||||
if ('' !== sTo)
|
||||
{
|
||||
aRec.push(sTo);
|
||||
}
|
||||
|
||||
if ('' !== sCc)
|
||||
{
|
||||
aRec.push(sCc);
|
||||
}
|
||||
|
||||
if ('' !== sBcc)
|
||||
{
|
||||
aRec.push(sBcc);
|
||||
}
|
||||
|
||||
aRec = aRec.join(', ').split(',');
|
||||
aRec = _.compact(_.map(aRec, function (sValue) {
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(Utils.trim(sValue));
|
||||
return '' === oEmail.email ? false : oEmail.email;
|
||||
}));
|
||||
|
||||
this.from(sResultFromEmail);
|
||||
this.to(aRec);
|
||||
this.text(sText);
|
||||
};
|
||||
|
||||
module.exports = new PopupsComposeOpenPgpViewModel();
|
||||
|
||||
}(module));
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,296 +1,318 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsDomainViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsDomain');
|
||||
(function (module) {
|
||||
|
||||
this.edit = ko.observable(false);
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.whiteListPage = ko.observable(false);
|
||||
'use strict';
|
||||
|
||||
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('');
|
||||
var
|
||||
_ = require('../../External/underscore.js'),
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Consts = require('../../Common/Consts.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
this.testingImapError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @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.testingImapErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
this.testingDone(true);
|
||||
this.testingImapError(true !== oData.Result.Imap);
|
||||
this.testingSmtpError(true !== oData.Result.Smtp);
|
||||
|
||||
this.testingSmtpError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
if (this.testingImapError() && oData.Result.Imap)
|
||||
{
|
||||
this.testingImapErrorDesc(oData.Result.Imap);
|
||||
}
|
||||
|
||||
if (this.testingSmtpError() && oData.Result.Smtp)
|
||||
{
|
||||
this.testingSmtpErrorDesc(oData.Result.Smtp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
this.testingImapError(true);
|
||||
this.testingSmtpError(true);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
this.testingImapErrorDesc = ko.observable('');
|
||||
this.testingSmtpErrorDesc = ko.observable('');
|
||||
PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError('Domain already exists');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError('Unknown error');
|
||||
}
|
||||
};
|
||||
|
||||
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);
|
||||
RL.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 () {
|
||||
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.testing(true);
|
||||
RL.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.clearForm();
|
||||
if (oDomain)
|
||||
{
|
||||
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
|
||||
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));
|
||||
}
|
||||
}, 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);
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsDomainViewModel', PopupsDomainViewModel);
|
||||
|
||||
PopupsDomainViewModel.prototype.onTestConnectionResponse = function (sResult, oData)
|
||||
{
|
||||
this.testing(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
PopupsDomainViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.testingDone(true);
|
||||
this.testingImapError(true !== oData.Result.Imap);
|
||||
this.testingSmtpError(true !== oData.Result.Smtp);
|
||||
|
||||
if (this.testingImapError() && oData.Result.Imap)
|
||||
if ('' === this.name())
|
||||
{
|
||||
this.testingImapErrorDesc(oData.Result.Imap);
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
if (this.testingSmtpError() && oData.Result.Smtp)
|
||||
{
|
||||
this.testingSmtpErrorDesc(oData.Result.Smtp);
|
||||
}
|
||||
}
|
||||
else
|
||||
PopupsDomainViewModel.prototype.clearForm = function ()
|
||||
{
|
||||
this.testingImapError(true);
|
||||
this.testingSmtpError(true);
|
||||
}
|
||||
};
|
||||
this.edit(false);
|
||||
this.whiteListPage(false);
|
||||
|
||||
PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError('Domain already exists');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError('Unknown error');
|
||||
}
|
||||
};
|
||||
this.savingError('');
|
||||
|
||||
PopupsDomainViewModel.prototype.onHide = function ()
|
||||
{
|
||||
this.whiteListPage(false);
|
||||
};
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
PopupsDomainViewModel.prototype.onShow = function (oDomain)
|
||||
{
|
||||
this.saving(false);
|
||||
this.whiteListPage(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('');
|
||||
};
|
||||
|
||||
this.testing(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSmtpError(false);
|
||||
module.exports = new PopupsDomainViewModel();
|
||||
|
||||
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));
|
||||
|
|
@ -1,37 +1,57 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFilterViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFilter');
|
||||
(function (module) {
|
||||
|
||||
this.filter = ko.observable(null);
|
||||
'use strict';
|
||||
|
||||
this.selectedFolderValue = ko.observable(Consts.Values.UnuseOptionValue);
|
||||
this.folderSelectList = RL.data().folderMenuForMove;
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
Consts = require('../../Common/Consts.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
|
||||
Utils.extendAsViewModel('PopupsFilterViewModel', PopupsFilterViewModel);
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
PopupsFilterViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFilterViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFilter');
|
||||
|
||||
};
|
||||
this.filter = ko.observable(null);
|
||||
|
||||
PopupsFilterViewModel.prototype.onShow = function (oFilter)
|
||||
{
|
||||
this.clearPopup();
|
||||
this.selectedFolderValue = ko.observable(Consts.Values.UnuseOptionValue);
|
||||
this.folderSelectList = Data.folderMenuForMove;
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
this.filter(oFilter);
|
||||
};
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
PopupsFilterViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
kn.extendAsViewModel('PopupsFilterViewModel', PopupsFilterViewModel);
|
||||
|
||||
};
|
||||
PopupsFilterViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
// TODO
|
||||
};
|
||||
|
||||
PopupsFilterViewModel.prototype.onShow = function (oFilter)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.filter(oFilter);
|
||||
};
|
||||
|
||||
// PopupsFilterViewModel.prototype.onFocus = function ()
|
||||
// {
|
||||
//
|
||||
// };
|
||||
|
||||
module.exports = new PopupsFilterViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,97 +1,120 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderClearViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderClear');
|
||||
|
||||
this.selectedFolder = ko.observable(null);
|
||||
this.clearingProcess = ko.observable(false);
|
||||
this.clearingError = ko.observable('');
|
||||
(function (module) {
|
||||
|
||||
this.folderFullNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.printableFullName() : '';
|
||||
}, this);
|
||||
'use strict';
|
||||
|
||||
this.folderNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.localName() : '';
|
||||
}, this);
|
||||
|
||||
this.dangerDescHtml = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', {
|
||||
'FOLDER': this.folderNameForClear()
|
||||
});
|
||||
}, this);
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
oFolderToClear = this.selectedFolder()
|
||||
;
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Cache = require('../../Storages/WebMailCacheStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
if (oFolderToClear)
|
||||
{
|
||||
RL.data().message(null);
|
||||
RL.data().messageList([]);
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
this.clearingProcess(true);
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderClearViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderClear');
|
||||
|
||||
RL.cache().setFolderHash(oFolderToClear.fullNameRaw, '');
|
||||
RL.remote().folderClear(function (sResult, oData) {
|
||||
|
||||
self.clearingProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
RL.reloadMessageList(true);
|
||||
self.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData && oData.ErrorCode)
|
||||
this.selectedFolder = ko.observable(null);
|
||||
this.clearingProcess = ko.observable(false);
|
||||
this.clearingError = ko.observable('');
|
||||
|
||||
this.folderFullNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.printableFullName() : '';
|
||||
}, this);
|
||||
|
||||
this.folderNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.localName() : '';
|
||||
}, this);
|
||||
|
||||
this.dangerDescHtml = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', {
|
||||
'FOLDER': this.folderNameForClear()
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
oFolderToClear = this.selectedFolder()
|
||||
;
|
||||
|
||||
if (oFolderToClear)
|
||||
{
|
||||
Data.message(null);
|
||||
Data.messageList([]);
|
||||
|
||||
this.clearingProcess(true);
|
||||
|
||||
Cache.setFolderHash(oFolderToClear.fullNameRaw, '');
|
||||
Remote.folderClear(function (sResult, oData) {
|
||||
|
||||
self.clearingProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
self.clearingError(Utils.getNotification(oData.ErrorCode));
|
||||
RL.reloadMessageList(true);
|
||||
self.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
self.clearingError(Utils.getNotification(Enums.Notification.MailServerError));
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
self.clearingError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
self.clearingError(Utils.getNotification(Enums.Notification.MailServerError));
|
||||
}
|
||||
}
|
||||
}
|
||||
}, oFolderToClear.fullNameRaw);
|
||||
}
|
||||
}, oFolderToClear.fullNameRaw);
|
||||
}
|
||||
|
||||
}, function () {
|
||||
}, function () {
|
||||
|
||||
var
|
||||
oFolder = this.selectedFolder(),
|
||||
bIsClearing = this.clearingProcess()
|
||||
;
|
||||
var
|
||||
oFolder = this.selectedFolder(),
|
||||
bIsClearing = this.clearingProcess()
|
||||
;
|
||||
|
||||
return !bIsClearing && null !== oFolder;
|
||||
return !bIsClearing && null !== oFolder;
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsFolderClearViewModel', PopupsFolderClearViewModel);
|
||||
|
||||
PopupsFolderClearViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.clearingProcess(false);
|
||||
this.selectedFolder(null);
|
||||
};
|
||||
|
||||
PopupsFolderClearViewModel.prototype.onShow = function (oFolder)
|
||||
{
|
||||
this.clearPopup();
|
||||
if (oFolder)
|
||||
{
|
||||
this.selectedFolder(oFolder);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
};
|
||||
|
||||
kn.extendAsViewModel('PopupsFolderClearViewModel', PopupsFolderClearViewModel);
|
||||
|
||||
PopupsFolderClearViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.clearingProcess(false);
|
||||
this.selectedFolder(null);
|
||||
};
|
||||
|
||||
PopupsFolderClearViewModel.prototype.onShow = function (oFolder)
|
||||
{
|
||||
this.clearPopup();
|
||||
if (oFolder)
|
||||
{
|
||||
this.selectedFolder(oFolder);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = new PopupsFolderClearViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
|
|||
|
|
@ -1,111 +1,128 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderCreateViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderCreate');
|
||||
(function (module) {
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sNoParentText = Utils.i18n('POPUPS_CREATE_FOLDER/SELECT_NO_PARENT');
|
||||
}, this);
|
||||
'use strict';
|
||||
|
||||
this.folderName = ko.observable('');
|
||||
this.folderName.focused = ko.observable(false);
|
||||
|
||||
this.selectedParentValue = ko.observable(Consts.Values.UnuseOptionValue);
|
||||
|
||||
this.parentFolderSelectList = ko.computed(function () {
|
||||
|
||||
var
|
||||
oData = RL.data(),
|
||||
aTop = [],
|
||||
fDisableCallback = null,
|
||||
fVisibleCallback = null,
|
||||
aList = oData.folderList(),
|
||||
fRenameCallback = function (oItem) {
|
||||
return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '';
|
||||
}
|
||||
;
|
||||
|
||||
aTop.push(['', this.sNoParentText]);
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
if ('' !== oData.namespace)
|
||||
{
|
||||
fDisableCallback = function (oItem)
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Consts = require('../../Common/Consts.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderCreateViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderCreate');
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sNoParentText = Utils.i18n('POPUPS_CREATE_FOLDER/SELECT_NO_PARENT');
|
||||
}, this);
|
||||
|
||||
this.folderName = ko.observable('');
|
||||
this.folderName.focused = ko.observable(false);
|
||||
|
||||
this.selectedParentValue = ko.observable(Consts.Values.UnuseOptionValue);
|
||||
|
||||
this.parentFolderSelectList = ko.computed(function () {
|
||||
|
||||
var
|
||||
aTop = [],
|
||||
fDisableCallback = null,
|
||||
fVisibleCallback = null,
|
||||
aList = Data.folderList(),
|
||||
fRenameCallback = function (oItem) {
|
||||
return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '';
|
||||
}
|
||||
;
|
||||
|
||||
aTop.push(['', this.sNoParentText]);
|
||||
|
||||
if ('' !== Data.namespace)
|
||||
{
|
||||
return oData.namespace !== oItem.fullNameRaw.substr(0, oData.namespace.length);
|
||||
};
|
||||
}
|
||||
|
||||
return RL.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback);
|
||||
|
||||
}, this);
|
||||
|
||||
// commands
|
||||
this.createFolder = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
oData = RL.data(),
|
||||
sParentFolderName = this.selectedParentValue()
|
||||
;
|
||||
|
||||
if ('' === sParentFolderName && 1 < oData.namespace.length)
|
||||
{
|
||||
sParentFolderName = oData.namespace.substr(0, oData.namespace.length - 1);
|
||||
}
|
||||
|
||||
oData.foldersCreating(true);
|
||||
RL.remote().folderCreate(function (sResult, oData) {
|
||||
|
||||
RL.data().foldersCreating(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
RL.folders();
|
||||
fDisableCallback = function (oItem)
|
||||
{
|
||||
return Data.namespace !== oItem.fullNameRaw.substr(0, Data.namespace.length);
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
return RL.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback);
|
||||
|
||||
}, this);
|
||||
|
||||
// commands
|
||||
this.createFolder = Utils.createCommand(this, function () {
|
||||
|
||||
var sParentFolderName = this.selectedParentValue();
|
||||
if ('' === sParentFolderName && 1 < Data.namespace.length)
|
||||
{
|
||||
RL.data().foldersListError(
|
||||
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER'));
|
||||
sParentFolderName = Data.namespace.substr(0, Data.namespace.length - 1);
|
||||
}
|
||||
|
||||
}, this.folderName(), sParentFolderName);
|
||||
|
||||
this.cancelCommand();
|
||||
|
||||
}, function () {
|
||||
return this.simpleFolderNameValidation(this.folderName());
|
||||
});
|
||||
Data.foldersCreating(true);
|
||||
Remote.folderCreate(function (sResult, oData) {
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
Data.foldersCreating(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
RL.folders();
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.foldersListError(
|
||||
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER'));
|
||||
}
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
}, this.folderName(), sParentFolderName);
|
||||
|
||||
Utils.extendAsViewModel('PopupsFolderCreateViewModel', PopupsFolderCreateViewModel);
|
||||
this.cancelCommand();
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.sNoParentText = '';
|
||||
}, function () {
|
||||
return this.simpleFolderNameValidation(this.folderName());
|
||||
});
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.simpleFolderNameValidation = function (sName)
|
||||
{
|
||||
return (/^[^\\\/]+$/g).test(Utils.trim(sName));
|
||||
};
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.folderName('');
|
||||
this.selectedParentValue('');
|
||||
this.folderName.focused(false);
|
||||
};
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
kn.extendAsViewModel('PopupsFolderCreateViewModel', PopupsFolderCreateViewModel);
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.folderName.focused(true);
|
||||
};
|
||||
PopupsFolderCreateViewModel.prototype.sNoParentText = '';
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.simpleFolderNameValidation = function (sName)
|
||||
{
|
||||
return (/^[^\\\/]+$/g).test(Utils.trim(sName));
|
||||
};
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.folderName('');
|
||||
this.selectedParentValue('');
|
||||
this.folderName.focused(false);
|
||||
};
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsFolderCreateViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.folderName.focused(true);
|
||||
};
|
||||
|
||||
module.exports = new PopupsFolderCreateViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,114 +1,134 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderSystemViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderSystem');
|
||||
(function (module) {
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sChooseOnText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
|
||||
this.sUnuseText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
|
||||
}, this);
|
||||
'use strict';
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.folderSelectList = ko.computed(function () {
|
||||
return RL.folderListOptionsBuilder([], RL.data().folderList(), RL.data().folderListSystemNames(), [
|
||||
['', this.sChooseOnText],
|
||||
[Consts.Values.UnuseOptionValue, this.sUnuseText]
|
||||
]);
|
||||
}, this);
|
||||
|
||||
var
|
||||
oData = RL.data(),
|
||||
self = this,
|
||||
fSaveSystemFolders = null,
|
||||
fCallback = null
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Consts = require('../../Common/Consts.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
this.sentFolder = oData.sentFolder;
|
||||
this.draftFolder = oData.draftFolder;
|
||||
this.spamFolder = oData.spamFolder;
|
||||
this.trashFolder = oData.trashFolder;
|
||||
this.archiveFolder = oData.archiveFolder;
|
||||
|
||||
fSaveSystemFolders = _.debounce(function () {
|
||||
|
||||
RL.settingsSet('SentFolder', self.sentFolder());
|
||||
RL.settingsSet('DraftFolder', self.draftFolder());
|
||||
RL.settingsSet('SpamFolder', self.spamFolder());
|
||||
RL.settingsSet('TrashFolder', self.trashFolder());
|
||||
RL.settingsSet('ArchiveFolder', self.archiveFolder());
|
||||
|
||||
RL.remote().saveSystemFolders(Utils.emptyFunction, {
|
||||
'SentFolder': self.sentFolder(),
|
||||
'DraftFolder': self.draftFolder(),
|
||||
'SpamFolder': self.spamFolder(),
|
||||
'TrashFolder': self.trashFolder(),
|
||||
'ArchiveFolder': self.archiveFolder(),
|
||||
'NullFolder': 'NullFolder'
|
||||
});
|
||||
|
||||
}, 1000);
|
||||
|
||||
fCallback = function () {
|
||||
|
||||
RL.settingsSet('SentFolder', self.sentFolder());
|
||||
RL.settingsSet('DraftFolder', self.draftFolder());
|
||||
RL.settingsSet('SpamFolder', self.spamFolder());
|
||||
RL.settingsSet('TrashFolder', self.trashFolder());
|
||||
RL.settingsSet('ArchiveFolder', self.archiveFolder());
|
||||
|
||||
fSaveSystemFolders();
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fCallback);
|
||||
this.draftFolder.subscribe(fCallback);
|
||||
this.spamFolder.subscribe(fCallback);
|
||||
this.trashFolder.subscribe(fCallback);
|
||||
this.archiveFolder.subscribe(fCallback);
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsFolderSystemViewModel', PopupsFolderSystemViewModel);
|
||||
|
||||
PopupsFolderSystemViewModel.prototype.sChooseOnText = '';
|
||||
PopupsFolderSystemViewModel.prototype.sUnuseText = '';
|
||||
|
||||
/**
|
||||
* @param {number=} iNotificationType = Enums.SetSystemFoldersNotification.None
|
||||
*/
|
||||
PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType)
|
||||
{
|
||||
var sNotification = '';
|
||||
|
||||
iNotificationType = Utils.isUnd(iNotificationType) ? Enums.SetSystemFoldersNotification.None : iNotificationType;
|
||||
|
||||
switch (iNotificationType)
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsFolderSystemViewModel()
|
||||
{
|
||||
case Enums.SetSystemFoldersNotification.Sent:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Draft:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Spam:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Trash:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Archive:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE');
|
||||
break;
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderSystem');
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sChooseOnText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
|
||||
this.sUnuseText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
|
||||
}, this);
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.folderSelectList = ko.computed(function () {
|
||||
return RL.folderListOptionsBuilder([], Data.folderList(), Data.folderListSystemNames(), [
|
||||
['', this.sChooseOnText],
|
||||
[Consts.Values.UnuseOptionValue, this.sUnuseText]
|
||||
]);
|
||||
}, this);
|
||||
|
||||
var
|
||||
self = this,
|
||||
fSaveSystemFolders = null,
|
||||
fCallback = null
|
||||
;
|
||||
|
||||
this.sentFolder = Data.sentFolder;
|
||||
this.draftFolder = Data.draftFolder;
|
||||
this.spamFolder = Data.spamFolder;
|
||||
this.trashFolder = Data.trashFolder;
|
||||
this.archiveFolder = Data.archiveFolder;
|
||||
|
||||
fSaveSystemFolders = _.debounce(function () {
|
||||
|
||||
RL.settingsSet('SentFolder', self.sentFolder());
|
||||
RL.settingsSet('DraftFolder', self.draftFolder());
|
||||
RL.settingsSet('SpamFolder', self.spamFolder());
|
||||
RL.settingsSet('TrashFolder', self.trashFolder());
|
||||
RL.settingsSet('ArchiveFolder', self.archiveFolder());
|
||||
|
||||
Remote.saveSystemFolders(Utils.emptyFunction, {
|
||||
'SentFolder': self.sentFolder(),
|
||||
'DraftFolder': self.draftFolder(),
|
||||
'SpamFolder': self.spamFolder(),
|
||||
'TrashFolder': self.trashFolder(),
|
||||
'ArchiveFolder': self.archiveFolder(),
|
||||
'NullFolder': 'NullFolder'
|
||||
});
|
||||
|
||||
}, 1000);
|
||||
|
||||
fCallback = function () {
|
||||
|
||||
RL.settingsSet('SentFolder', self.sentFolder());
|
||||
RL.settingsSet('DraftFolder', self.draftFolder());
|
||||
RL.settingsSet('SpamFolder', self.spamFolder());
|
||||
RL.settingsSet('TrashFolder', self.trashFolder());
|
||||
RL.settingsSet('ArchiveFolder', self.archiveFolder());
|
||||
|
||||
fSaveSystemFolders();
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fCallback);
|
||||
this.draftFolder.subscribe(fCallback);
|
||||
this.spamFolder.subscribe(fCallback);
|
||||
this.trashFolder.subscribe(fCallback);
|
||||
this.archiveFolder.subscribe(fCallback);
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
this.notification(sNotification);
|
||||
};
|
||||
kn.extendAsViewModel('PopupsFolderSystemViewModel', PopupsFolderSystemViewModel);
|
||||
|
||||
PopupsFolderSystemViewModel.prototype.sChooseOnText = '';
|
||||
PopupsFolderSystemViewModel.prototype.sUnuseText = '';
|
||||
|
||||
/**
|
||||
* @param {number=} iNotificationType = Enums.SetSystemFoldersNotification.None
|
||||
*/
|
||||
PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType)
|
||||
{
|
||||
var sNotification = '';
|
||||
|
||||
iNotificationType = Utils.isUnd(iNotificationType) ? Enums.SetSystemFoldersNotification.None : iNotificationType;
|
||||
|
||||
switch (iNotificationType)
|
||||
{
|
||||
case Enums.SetSystemFoldersNotification.Sent:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Draft:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Spam:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Trash:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Archive:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE');
|
||||
break;
|
||||
}
|
||||
|
||||
this.notification(sNotification);
|
||||
};
|
||||
|
||||
module.exports = new PopupsFolderSystemViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,95 +1,115 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsGenerateNewOpenPgpKeyViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsGenerateNewOpenPgpKey');
|
||||
(function (module) {
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.email.focus = ko.observable('');
|
||||
this.email.error = ko.observable(false);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.keyBitLength = ko.observable(2048);
|
||||
'use strict';
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
var
|
||||
window = require('../../External/window.js'),
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.email.error(false);
|
||||
}, this);
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
|
||||
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
var
|
||||
self = this,
|
||||
sUserID = '',
|
||||
mKeyPair = null,
|
||||
oOpenpgpKeyring = RL.data().openpgpKeyring
|
||||
;
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsGenerateNewOpenPgpKeyViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsGenerateNewOpenPgpKey');
|
||||
|
||||
this.email.error('' === Utils.trim(this.email()));
|
||||
if (!oOpenpgpKeyring || this.email.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.email = ko.observable('');
|
||||
this.email.focus = ko.observable('');
|
||||
this.email.error = ko.observable(false);
|
||||
|
||||
sUserID = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
sUserID = this.name() + ' <' + sUserID + '>';
|
||||
}
|
||||
this.name = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.keyBitLength = ko.observable(2048);
|
||||
|
||||
this.submitRequest(true);
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
_.delay(function () {
|
||||
// mKeyPair = window.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password()));
|
||||
mKeyPair = window.openpgp.generateKeyPair({
|
||||
'userId': sUserID,
|
||||
'numBits': Utils.pInt(self.keyBitLength()),
|
||||
'passphrase': Utils.trim(self.password())
|
||||
});
|
||||
|
||||
if (mKeyPair && mKeyPair.privateKeyArmored)
|
||||
this.email.subscribe(function () {
|
||||
this.email.error(false);
|
||||
}, this);
|
||||
|
||||
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
sUserID = '',
|
||||
mKeyPair = null,
|
||||
oOpenpgpKeyring = Data.openpgpKeyring
|
||||
;
|
||||
|
||||
this.email.error('' === Utils.trim(this.email()));
|
||||
if (!oOpenpgpKeyring || this.email.error())
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored);
|
||||
oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored);
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
RL.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
return false;
|
||||
}
|
||||
|
||||
self.submitRequest(false);
|
||||
}, 100);
|
||||
sUserID = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
sUserID = this.name() + ' <' + sUserID + '>';
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
this.submitRequest(true);
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
_.delay(function () {
|
||||
// mKeyPair = window.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password()));
|
||||
mKeyPair = window.openpgp.generateKeyPair({
|
||||
'userId': sUserID,
|
||||
'numBits': Utils.pInt(self.keyBitLength()),
|
||||
'passphrase': Utils.trim(self.password())
|
||||
});
|
||||
|
||||
Utils.extendAsViewModel('PopupsGenerateNewOpenPgpKeyViewModel', PopupsGenerateNewOpenPgpKeyViewModel);
|
||||
if (mKeyPair && mKeyPair.privateKeyArmored)
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored);
|
||||
oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored);
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
PopupsGenerateNewOpenPgpKeyViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.name('');
|
||||
this.password('');
|
||||
|
||||
this.email('');
|
||||
this.email.error(false);
|
||||
this.keyBitLength(2048);
|
||||
};
|
||||
RL.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
|
||||
PopupsGenerateNewOpenPgpKeyViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
self.submitRequest(false);
|
||||
}, 100);
|
||||
|
||||
PopupsGenerateNewOpenPgpKeyViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.email.focus(true);
|
||||
};
|
||||
return true;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel('PopupsGenerateNewOpenPgpKeyViewModel', PopupsGenerateNewOpenPgpKeyViewModel);
|
||||
|
||||
PopupsGenerateNewOpenPgpKeyViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.name('');
|
||||
this.password('');
|
||||
|
||||
this.email('');
|
||||
this.email.error(false);
|
||||
this.keyBitLength(2048);
|
||||
};
|
||||
|
||||
PopupsGenerateNewOpenPgpKeyViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsGenerateNewOpenPgpKeyViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.email.focus(true);
|
||||
};
|
||||
|
||||
module.exports = new PopupsGenerateNewOpenPgpKeyViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,149 +1,170 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsIdentityViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsIdentity');
|
||||
(function (module) {
|
||||
|
||||
this.id = '';
|
||||
this.edit = ko.observable(false);
|
||||
this.owner = ko.observable(false);
|
||||
|
||||
this.email = ko.observable('').validateEmail();
|
||||
this.email.focused = ko.observable(false);
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
this.replyTo = ko.observable('').validateSimpleEmail();
|
||||
this.replyTo.focused = ko.observable(false);
|
||||
this.bcc = ko.observable('').validateSimpleEmail();
|
||||
this.bcc.focused = ko.observable(false);
|
||||
'use strict';
|
||||
|
||||
// this.email.subscribe(function () {
|
||||
// this.email.hasError(false);
|
||||
// }, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.addOrEditIdentityCommand = Utils.createCommand(this, function () {
|
||||
|
||||
if (!this.email.hasError())
|
||||
{
|
||||
this.email.hasError('' === Utils.trim(this.email()));
|
||||
}
|
||||
|
||||
if (this.email.hasError())
|
||||
{
|
||||
if (!this.owner())
|
||||
{
|
||||
this.email.focused(true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.replyTo.hasError())
|
||||
{
|
||||
this.replyTo.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.bcc.hasError())
|
||||
{
|
||||
this.bcc.focused(true);
|
||||
return false;
|
||||
}
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
this.submitRequest(true);
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
|
||||
RL.remote().identityUpdate(_.bind(function (sResult, oData) {
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsIdentityViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsIdentity');
|
||||
|
||||
this.id = '';
|
||||
this.edit = ko.observable(false);
|
||||
this.owner = ko.observable(false);
|
||||
|
||||
this.email = ko.observable('').validateEmail();
|
||||
this.email.focused = ko.observable(false);
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
this.replyTo = ko.observable('').validateSimpleEmail();
|
||||
this.replyTo.focused = ko.observable(false);
|
||||
this.bcc = ko.observable('').validateSimpleEmail();
|
||||
this.bcc.focused = ko.observable(false);
|
||||
|
||||
// this.email.subscribe(function () {
|
||||
// this.email.hasError(false);
|
||||
// }, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.addOrEditIdentityCommand = Utils.createCommand(this, function () {
|
||||
|
||||
if (!this.email.hasError())
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
this.email.hasError('' === Utils.trim(this.email()));
|
||||
}
|
||||
|
||||
}, this), this.id, this.email(), this.name(), this.replyTo(), this.bcc());
|
||||
if (this.email.hasError())
|
||||
{
|
||||
if (!this.owner())
|
||||
{
|
||||
this.email.focused(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
if (this.replyTo.hasError())
|
||||
{
|
||||
this.replyTo.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.label = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'TITLE_UPDATE_IDENTITY': 'TITLE_ADD_IDENTITY'));
|
||||
}, this);
|
||||
if (this.bcc.hasError())
|
||||
{
|
||||
this.bcc.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.button = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'BUTTON_UPDATE_IDENTITY': 'BUTTON_ADD_IDENTITY'));
|
||||
}, this);
|
||||
this.submitRequest(true);
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
Remote.identityUpdate(_.bind(function (sResult, oData) {
|
||||
|
||||
Utils.extendAsViewModel('PopupsIdentityViewModel', PopupsIdentityViewModel);
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
PopupsIdentityViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.id = '';
|
||||
this.edit(false);
|
||||
this.owner(false);
|
||||
}, this), this.id, this.email(), this.name(), this.replyTo(), this.bcc());
|
||||
|
||||
this.name('');
|
||||
this.email('');
|
||||
this.replyTo('');
|
||||
this.bcc('');
|
||||
return true;
|
||||
|
||||
this.email.hasError(false);
|
||||
this.replyTo.hasError(false);
|
||||
this.bcc.hasError(false);
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
this.label = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'TITLE_UPDATE_IDENTITY': 'TITLE_ADD_IDENTITY'));
|
||||
}, this);
|
||||
|
||||
/**
|
||||
* @param {?IdentityModel} oIdentity
|
||||
*/
|
||||
PopupsIdentityViewModel.prototype.onShow = function (oIdentity)
|
||||
{
|
||||
this.clearPopup();
|
||||
this.button = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'BUTTON_UPDATE_IDENTITY': 'BUTTON_ADD_IDENTITY'));
|
||||
}, this);
|
||||
|
||||
if (oIdentity)
|
||||
{
|
||||
this.edit(true);
|
||||
|
||||
this.id = oIdentity.id;
|
||||
this.name(oIdentity.name());
|
||||
this.email(oIdentity.email());
|
||||
this.replyTo(oIdentity.replyTo());
|
||||
this.bcc(oIdentity.bcc());
|
||||
|
||||
this.owner(this.id === RL.data().accountEmail());
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsIdentityViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.owner())
|
||||
kn.extendAsViewModel('PopupsIdentityViewModel', PopupsIdentityViewModel);
|
||||
|
||||
PopupsIdentityViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.email.focused(true);
|
||||
}
|
||||
};
|
||||
this.id = '';
|
||||
this.edit(false);
|
||||
this.owner(false);
|
||||
|
||||
this.name('');
|
||||
this.email('');
|
||||
this.replyTo('');
|
||||
this.bcc('');
|
||||
|
||||
this.email.hasError(false);
|
||||
this.replyTo.hasError(false);
|
||||
this.bcc.hasError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?IdentityModel} oIdentity
|
||||
*/
|
||||
PopupsIdentityViewModel.prototype.onShow = function (oIdentity)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
if (oIdentity)
|
||||
{
|
||||
this.edit(true);
|
||||
|
||||
this.id = oIdentity.id;
|
||||
this.name(oIdentity.name());
|
||||
this.email(oIdentity.email());
|
||||
this.replyTo(oIdentity.replyTo());
|
||||
this.bcc(oIdentity.bcc());
|
||||
|
||||
this.owner(this.id === Data.accountEmail());
|
||||
}
|
||||
};
|
||||
|
||||
PopupsIdentityViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.owner())
|
||||
{
|
||||
this.email.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = new PopupsIdentityViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,46 +1,63 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsKeyboardShortcutsHelpViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp');
|
||||
(function (module) {
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupKeyboardShortcutsHelp;
|
||||
'use strict';
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
var
|
||||
_ = require('../../External/underscore.js'),
|
||||
key = require('../../External/key.js'),
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
Utils.extendAsViewModel('PopupsKeyboardShortcutsHelpViewModel', PopupsKeyboardShortcutsHelpViewModel);
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsKeyboardShortcutsHelpViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp');
|
||||
|
||||
PopupsKeyboardShortcutsHelpViewModel.prototype.onBuild = function (oDom)
|
||||
{
|
||||
key('tab, shift+tab, left, right', Enums.KeyState.PopupKeyboardShortcutsHelp, _.bind(function (event, handler) {
|
||||
if (event && handler)
|
||||
{
|
||||
var
|
||||
$tabs = oDom.find('.nav.nav-tabs > li'),
|
||||
bNext = handler && ('tab' === handler.shortcut || 'right' === handler.shortcut),
|
||||
iIndex = $tabs.index($tabs.filter('.active'))
|
||||
;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupKeyboardShortcutsHelp;
|
||||
|
||||
if (!bNext && iIndex > 0)
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel('PopupsKeyboardShortcutsHelpViewModel', PopupsKeyboardShortcutsHelpViewModel);
|
||||
|
||||
PopupsKeyboardShortcutsHelpViewModel.prototype.onBuild = function (oDom)
|
||||
{
|
||||
key('tab, shift+tab, left, right', Enums.KeyState.PopupKeyboardShortcutsHelp, _.bind(function (event, handler) {
|
||||
if (event && handler)
|
||||
{
|
||||
iIndex--;
|
||||
}
|
||||
else if (bNext && iIndex < $tabs.length - 1)
|
||||
{
|
||||
iIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iIndex = bNext ? 0 : $tabs.length - 1;
|
||||
}
|
||||
var
|
||||
$tabs = oDom.find('.nav.nav-tabs > li'),
|
||||
bNext = handler && ('tab' === handler.shortcut || 'right' === handler.shortcut),
|
||||
iIndex = $tabs.index($tabs.filter('.active'))
|
||||
;
|
||||
|
||||
$tabs.eq(iIndex).find('a[data-toggle="tab"]').tab('show');
|
||||
return false;
|
||||
}
|
||||
}, this));
|
||||
};
|
||||
if (!bNext && iIndex > 0)
|
||||
{
|
||||
iIndex--;
|
||||
}
|
||||
else if (bNext && iIndex < $tabs.length - 1)
|
||||
{
|
||||
iIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iIndex = bNext ? 0 : $tabs.length - 1;
|
||||
}
|
||||
|
||||
$tabs.eq(iIndex).find('a[data-toggle="tab"]').tab('show');
|
||||
return false;
|
||||
}
|
||||
}, this));
|
||||
};
|
||||
|
||||
module.exports = new AdminPaneViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,61 +1,81 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsLanguagesViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsLanguages');
|
||||
(function (module) {
|
||||
|
||||
this.exp = ko.observable(false);
|
||||
'use strict';
|
||||
|
||||
this.languages = ko.computed(function () {
|
||||
return _.map(RL.data().languages(), function (sLanguage) {
|
||||
return {
|
||||
'key': sLanguage,
|
||||
'selected': ko.observable(false),
|
||||
'fullName': Utils.convertLangName(sLanguage)
|
||||
};
|
||||
var
|
||||
_ = require('../../External/underscore.js'),
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @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)
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
RL.data().mainLanguage.subscribe(function () {
|
||||
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();
|
||||
}, this);
|
||||
};
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
PopupsLanguagesViewModel.prototype.onHide = function ()
|
||||
{
|
||||
this.exp(false);
|
||||
};
|
||||
|
||||
Utils.extendAsViewModel('PopupsLanguagesViewModel', PopupsLanguagesViewModel);
|
||||
PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
|
||||
{
|
||||
Data.mainLanguage(sLang);
|
||||
this.cancelCommand();
|
||||
};
|
||||
|
||||
PopupsLanguagesViewModel.prototype.languageEnName = function (sLanguage)
|
||||
{
|
||||
return Utils.convertLangName(sLanguage, true);
|
||||
};
|
||||
module.exports = new PopupsLanguagesViewModel();
|
||||
|
||||
PopupsLanguagesViewModel.prototype.resetMainLanguage = function ()
|
||||
{
|
||||
var sCurrent = RL.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)
|
||||
{
|
||||
RL.data().mainLanguage(sLang);
|
||||
this.cancelCommand();
|
||||
};
|
||||
}(module));
|
||||
|
|
@ -1,143 +1,165 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsPluginViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsPlugin');
|
||||
(function (module) {
|
||||
|
||||
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([]);
|
||||
'use strict';
|
||||
|
||||
this.hasReadme = ko.computed(function () {
|
||||
return '' !== this.readme();
|
||||
}, this);
|
||||
|
||||
this.hasConfiguration = ko.computed(function () {
|
||||
return 0 < this.configures().length;
|
||||
}, this);
|
||||
var
|
||||
_ = require('../../External/underscore.js'),
|
||||
ko = require('../../External/ko.js'),
|
||||
key = require('../../External/key.js'),
|
||||
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
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;
|
||||
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @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.saveError('');
|
||||
RL.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, oList);
|
||||
|
||||
}, this.hasConfiguration);
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.All;
|
||||
this.hasConfiguration = ko.computed(function () {
|
||||
return 0 < this.configures().length;
|
||||
}, this);
|
||||
|
||||
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
|
||||
this.readmePopoverConf = {
|
||||
'placement': 'top',
|
||||
'trigger': 'hover',
|
||||
'title': 'About',
|
||||
'content': function () {
|
||||
return self.readme();
|
||||
}
|
||||
};
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
this.saveCommand = Utils.createCommand(this, function () {
|
||||
|
||||
Utils.extendAsViewModel('PopupsPluginViewModel', PopupsPluginViewModel);
|
||||
var oList = {};
|
||||
|
||||
PopupsPluginViewModel.prototype.onPluginSettingsUpdateResponse = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
this.cancelCommand();
|
||||
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);
|
||||
}
|
||||
else
|
||||
|
||||
kn.extendAsViewModel('PopupsPluginViewModel', PopupsPluginViewModel);
|
||||
|
||||
PopupsPluginViewModel.prototype.onPluginSettingsUpdateResponse = function (sResult, oData)
|
||||
{
|
||||
this.saveError('');
|
||||
if (oData && oData.ErrorCode)
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
this.saveError(Utils.getNotification(oData.ErrorCode));
|
||||
this.cancelCommand();
|
||||
}
|
||||
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;
|
||||
if (!kn.isPopupVisible(PopupsAskViewModel))
|
||||
{
|
||||
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
|
||||
if (self.modalVisibility())
|
||||
this.saveError('');
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
this.saveError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveError(Utils.getNotification(Enums.Notification.CantSavePluginSettings));
|
||||
}
|
||||
}]);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsPluginViewModel.prototype.onBuild = function ()
|
||||
{
|
||||
key('esc', Enums.KeyState.All, _.bind(function () {
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
this.tryToClosePopup();
|
||||
}
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
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 = new PopupsPluginViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,55 +1,75 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsTwoFactorTestViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsTwoFactorTest');
|
||||
(function (module) {
|
||||
|
||||
var self = this;
|
||||
'use strict';
|
||||
|
||||
this.code = ko.observable('');
|
||||
this.code.focused = ko.observable(false);
|
||||
this.code.status = ko.observable(null);
|
||||
|
||||
this.testing = ko.observable(false);
|
||||
|
||||
// commands
|
||||
this.testCode = Utils.createCommand(this, function () {
|
||||
|
||||
this.testing(true);
|
||||
RL.remote().testTwoFactor(function (sResult, oData) {
|
||||
|
||||
self.testing(false);
|
||||
self.code.status(Enums.StorageResultType.Success === sResult && oData && oData.Result ? true : false);
|
||||
|
||||
}, this.code());
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
|
||||
}, function () {
|
||||
return '' !== this.code() && !this.testing();
|
||||
});
|
||||
Enums = require('../../Common/Enums.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
Utils.extendAsViewModel('PopupsTwoFactorTestViewModel', PopupsTwoFactorTestViewModel);
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsTwoFactorTestViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsTwoFactorTest');
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.code('');
|
||||
this.code.focused(false);
|
||||
this.code.status(null);
|
||||
this.testing(false);
|
||||
};
|
||||
var self = this;
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
this.code = ko.observable('');
|
||||
this.code.focused = ko.observable(false);
|
||||
this.code.status = ko.observable(null);
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.code.focused(true);
|
||||
};
|
||||
this.testing = ko.observable(false);
|
||||
|
||||
// commands
|
||||
this.testCode = Utils.createCommand(this, function () {
|
||||
|
||||
this.testing(true);
|
||||
Remote.testTwoFactor(function (sResult, oData) {
|
||||
|
||||
self.testing(false);
|
||||
self.code.status(Enums.StorageResultType.Success === sResult && oData && oData.Result ? true : false);
|
||||
|
||||
}, this.code());
|
||||
|
||||
}, function () {
|
||||
return '' !== this.code() && !this.testing();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel('PopupsTwoFactorTestViewModel', PopupsTwoFactorTestViewModel);
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.code('');
|
||||
this.code.focused(false);
|
||||
this.code.status(null);
|
||||
this.testing(false);
|
||||
};
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
PopupsTwoFactorTestViewModel.prototype.onFocus = function ()
|
||||
{
|
||||
this.code.focused(true);
|
||||
};
|
||||
|
||||
module.exports = new PopupsTwoFactorTestViewModel();
|
||||
|
||||
}(module));
|
||||
|
|
@ -1,41 +1,56 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsViewOpenPgpKeyViewModel()
|
||||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsViewOpenPgpKey');
|
||||
(function (module) {
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.keyDom = ko.observable(null);
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
'use strict';
|
||||
|
||||
Utils.extendAsViewModel('PopupsViewOpenPgpKeyViewModel', PopupsViewOpenPgpKeyViewModel);
|
||||
var
|
||||
ko = require('../../External/ko.js'),
|
||||
Utils = require('../../Common/Utils.js'),
|
||||
kn = require('../../Knoin/Knoin.js'),
|
||||
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
|
||||
;
|
||||
|
||||
PopupsViewOpenPgpKeyViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.key('');
|
||||
};
|
||||
|
||||
PopupsViewOpenPgpKeyViewModel.prototype.selectKey = function ()
|
||||
{
|
||||
var oEl = this.keyDom();
|
||||
if (oEl)
|
||||
/**
|
||||
* @constructor
|
||||
* @extends KnoinAbstractViewModel
|
||||
*/
|
||||
function PopupsViewOpenPgpKeyViewModel()
|
||||
{
|
||||
Utils.selectElement(oEl);
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsViewOpenPgpKey');
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.keyDom = ko.observable(null);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsViewOpenPgpKeyViewModel.prototype.onShow = function (oOpenPgpKey)
|
||||
{
|
||||
this.clearPopup();
|
||||
kn.extendAsViewModel('PopupsViewOpenPgpKeyViewModel', PopupsViewOpenPgpKeyViewModel);
|
||||
|
||||
if (oOpenPgpKey)
|
||||
PopupsViewOpenPgpKeyViewModel.prototype.clearPopup = function ()
|
||||
{
|
||||
this.key(oOpenPgpKey.armor);
|
||||
}
|
||||
};
|
||||
this.key('');
|
||||
};
|
||||
|
||||
PopupsViewOpenPgpKeyViewModel.prototype.selectKey = function ()
|
||||
{
|
||||
var oEl = this.keyDom();
|
||||
if (oEl)
|
||||
{
|
||||
Utils.selectElement(oEl);
|
||||
}
|
||||
};
|
||||
|
||||
PopupsViewOpenPgpKeyViewModel.prototype.onShow = function (oOpenPgpKey)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
if (oOpenPgpKey)
|
||||
{
|
||||
this.key(oOpenPgpKey.armor);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = new PopupsViewOpenPgpKeyViewModel();
|
||||
|
||||
}(module));
|
||||
Loading…
Add table
Add a link
Reference in a new issue