CommonJS (research/2)

This commit is contained in:
RainLoop Team 2014-08-21 19:08:34 +04:00
parent 56607de87c
commit 586abbb802
115 changed files with 16201 additions and 9943 deletions

View file

@ -1,97 +1,121 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function AbstractSystemDropDownViewModel()
{
KnoinAbstractViewModel.call(this, 'Right', 'SystemDropDown');
(function (module) {
var oData = RL.data();
'use strict';
this.accounts = oData.accounts;
this.accountEmail = oData.accountEmail;
this.accountsLoading = oData.accountsLoading;
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
window = require('../External/window.js'),
key = require('../External/key.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
this.accountMenuDropdownTrigger = ko.observable(false);
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
this.capaAdditionalAccounts = RL.capa(Enums.Capa.AdditionalAccounts);
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
this.loading = ko.computed(function () {
return this.accountsLoading();
}, this);
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function AbstractSystemDropDownViewModel()
{
KnoinAbstractViewModel.call(this, 'Right', 'SystemDropDown');
this.accountClick = _.bind(this.accountClick, this);
}
var oData = RL.data();
_.extend(AbstractSystemDropDownViewModel.prototype, KnoinAbstractViewModel.prototype);
this.accounts = oData.accounts;
this.accountEmail = oData.accountEmail;
this.accountsLoading = oData.accountsLoading;
AbstractSystemDropDownViewModel.prototype.accountClick = function (oAccount, oEvent)
{
if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
this.accountMenuDropdownTrigger = ko.observable(false);
this.capaAdditionalAccounts = RL.capa(Enums.Capa.AdditionalAccounts);
this.loading = ko.computed(function () {
return this.accountsLoading();
}, this);
this.accountClick = _.bind(this.accountClick, this);
}
_.extend(AbstractSystemDropDownViewModel.prototype, KnoinAbstractViewModel.prototype);
AbstractSystemDropDownViewModel.prototype.accountClick = function (oAccount, oEvent)
{
if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
{
var self = this;
this.accountsLoading(true);
_.delay(function () {
self.accountsLoading(false);
}, 1000);
}
return true;
};
AbstractSystemDropDownViewModel.prototype.emailTitle = function ()
{
return RL.data().accountEmail();
};
AbstractSystemDropDownViewModel.prototype.settingsClick = function ()
{
kn.setHash(LinkBuilder.settings());
};
AbstractSystemDropDownViewModel.prototype.settingsHelp = function ()
{
kn.showScreenPopup(PopupsKeyboardShortcutsHelpViewModel);
};
AbstractSystemDropDownViewModel.prototype.addAccountClick = function ()
{
if (this.capaAdditionalAccounts)
{
kn.showScreenPopup(PopupsAddAccountViewModel);
}
};
AbstractSystemDropDownViewModel.prototype.logoutClick = function ()
{
Remote.logout(function () {
if (window.__rlah_clear)
{
window.__rlah_clear();
}
RL.loginAndLogoutReload(true, RL.settingsGet('ParentEmail') && 0 < RL.settingsGet('ParentEmail').length);
});
};
AbstractSystemDropDownViewModel.prototype.onBuild = function ()
{
var self = this;
this.accountsLoading(true);
_.delay(function () {
self.accountsLoading(false);
}, 1000);
}
key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
if (self.viewModelVisibility())
{
self.accountMenuDropdownTrigger(true);
}
});
return true;
};
// shortcuts help
key('shift+/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
if (self.viewModelVisibility())
{
kn.showScreenPopup(PopupsKeyboardShortcutsHelpViewModel);
return false;
}
});
};
AbstractSystemDropDownViewModel.prototype.emailTitle = function ()
{
return RL.data().accountEmail();
};
module.exports = new AbstractSystemDropDownViewModel();
AbstractSystemDropDownViewModel.prototype.settingsClick = function ()
{
kn.setHash(RL.link().settings());
};
AbstractSystemDropDownViewModel.prototype.settingsHelp = function ()
{
kn.showScreenPopup(PopupsKeyboardShortcutsHelpViewModel);
};
AbstractSystemDropDownViewModel.prototype.addAccountClick = function ()
{
if (this.capaAdditionalAccounts)
{
kn.showScreenPopup(PopupsAddAccountViewModel);
}
};
AbstractSystemDropDownViewModel.prototype.logoutClick = function ()
{
RL.remote().logout(function () {
if (window.__rlah_clear)
{
window.__rlah_clear();
}
RL.loginAndLogoutReload(true, RL.settingsGet('ParentEmail') && 0 < RL.settingsGet('ParentEmail').length);
});
};
AbstractSystemDropDownViewModel.prototype.onBuild = function ()
{
var self = this;
key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
if (self.viewModelVisibility())
{
self.accountMenuDropdownTrigger(true);
}
});
// shortcuts help
key('shift+/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
if (self.viewModelVisibility())
{
kn.showScreenPopup(PopupsKeyboardShortcutsHelpViewModel);
return false;
}
});
};
}(module));

View file

@ -1,100 +1,121 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminLoginViewModel()
{
KnoinAbstractViewModel.call(this, 'Center', 'AdminLogin');
(function (module) {
this.login = ko.observable('');
this.password = ko.observable('');
'use strict';
this.loginError = ko.observable(false);
this.passwordError = ko.observable(false);
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
this.loginFocus = ko.observable(false);
Remote = require('../Storages/AdminAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
this.login.subscribe(function () {
this.loginError(false);
}, this);
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminLoginViewModel()
{
KnoinAbstractViewModel.call(this, 'Center', 'AdminLogin');
this.password.subscribe(function () {
this.passwordError(false);
}, this);
this.login = ko.observable('');
this.password = ko.observable('');
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.loginError = ko.observable(false);
this.passwordError = ko.observable(false);
this.submitCommand = Utils.createCommand(this, function () {
this.loginFocus = ko.observable(false);
Utils.triggerAutocompleteInputChange();
this.login.subscribe(function () {
this.loginError(false);
}, this);
this.loginError('' === Utils.trim(this.login()));
this.passwordError('' === Utils.trim(this.password()));
this.password.subscribe(function () {
this.passwordError(false);
}, this);
if (this.loginError() || this.passwordError())
{
return false;
}
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.submitRequest(true);
this.submitCommand = Utils.createCommand(this, function () {
RL.remote().adminLogin(_.bind(function (sResult, oData) {
Utils.triggerAutocompleteInputChange();
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
this.loginError('' === Utils.trim(this.login()));
this.passwordError('' === Utils.trim(this.password()));
if (this.loginError() || this.passwordError())
{
if (oData.Result)
return false;
}
this.submitRequest(true);
Remote.adminLogin(_.bind(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
{
RL.loginAndLogoutReload();
if (oData.Result)
{
RL.loginAndLogoutReload();
}
else if (oData.ErrorCode)
{
this.submitRequest(false);
this.submitError(Utils.getNotification(oData.ErrorCode));
}
}
else if (oData.ErrorCode)
else
{
this.submitRequest(false);
this.submitError(Utils.getNotification(oData.ErrorCode));
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
}
}
else
{
this.submitRequest(false);
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
}
}, this), this.login(), this.password());
}, this), this.login(), this.password());
return true;
return true;
}, function () {
return !this.submitRequest();
});
}, function () {
return !this.submitRequest();
});
Knoin.constructorEnd(this);
}
kn.constructorEnd(this);
}
Utils.extendAsViewModel('AdminLoginViewModel', AdminLoginViewModel);
kn.extendAsViewModel('AdminLoginViewModel', AdminLoginViewModel);
AdminLoginViewModel.prototype.onShow = function ()
{
kn.routeOff();
AdminLoginViewModel.prototype.onShow = function ()
{
kn.routeOff();
_.delay(_.bind(function () {
this.loginFocus(true);
}, this), 100);
_.delay(_.bind(function () {
this.loginFocus(true);
}, this), 100);
};
};
AdminLoginViewModel.prototype.onHide = function ()
{
this.loginFocus(false);
};
AdminLoginViewModel.prototype.onHide = function ()
{
this.loginFocus(false);
};
AdminLoginViewModel.prototype.onBuild = function ()
{
Utils.triggerAutocompleteInputChange(true);
};
AdminLoginViewModel.prototype.onBuild = function ()
{
Utils.triggerAutocompleteInputChange(true);
};
AdminLoginViewModel.prototype.submitForm = function ()
{
this.submitCommand();
};
AdminLoginViewModel.prototype.submitForm = function ()
{
this.submitCommand();
};
module.exports = new AdminLoginViewModel();
}(module));

View file

@ -1,25 +1,38 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @param {?} oScreen
*
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminMenuViewModel(oScreen)
{
KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu');
(function (module) {
this.leftPanelDisabled = RL.data().leftPanelDisabled;
'use strict';
this.menu = oScreen.menu;
var
kn = require('../External/kn.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
/**
* @param {?} oScreen
*
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminMenuViewModel(oScreen)
{
KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu');
Knoin.constructorEnd(this);
}
this.leftPanelDisabled = RL.data().leftPanelDisabled;
Utils.extendAsViewModel('AdminMenuViewModel', AdminMenuViewModel);
this.menu = oScreen.menu;
AdminMenuViewModel.prototype.link = function (sRoute)
{
return '#/' + sRoute;
};
kn.constructorEnd(this);
}
kn.extendAsViewModel('AdminMenuViewModel', AdminMenuViewModel);
AdminMenuViewModel.prototype.link = function (sRoute)
{
return '#/' + sRoute;
};
module.exports = new AdminMenuViewModel();
}(module));

View file

@ -1,26 +1,43 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminPaneViewModel()
{
KnoinAbstractViewModel.call(this, 'Right', 'AdminPane');
(function (module) {
this.adminDomain = ko.observable(RL.settingsGet('AdminDomain'));
this.version = ko.observable(RL.settingsGet('Version'));
'use strict';
this.adminManLoadingVisibility = RL.data().adminManLoadingVisibility;
var
ko = require('../External/ko.js'),
Knoin.constructorEnd(this);
}
Remote = require('../Storages/AdminAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
Utils.extendAsViewModel('AdminPaneViewModel', AdminPaneViewModel);
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function AdminPaneViewModel()
{
KnoinAbstractViewModel.call(this, 'Right', 'AdminPane');
AdminPaneViewModel.prototype.logoutClick = function ()
{
RL.remote().adminLogout(function () {
RL.loginAndLogoutReload();
});
};
this.adminDomain = ko.observable(RL.settingsGet('AdminDomain'));
this.version = ko.observable(RL.settingsGet('Version'));
this.adminManLoadingVisibility = RL.data().adminManLoadingVisibility;
kn.constructorEnd(this);
}
kn.extendAsViewModel('AdminPaneViewModel', AdminPaneViewModel);
AdminPaneViewModel.prototype.logoutClick = function ()
{
Remote.adminLogout(function () {
RL.loginAndLogoutReload();
});
};
module.exports = new AdminPaneViewModel();
}(module));

View file

@ -1,344 +1,366 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function LoginViewModel()
{
KnoinAbstractViewModel.call(this, 'Center', 'Login');
(function (module) {
var oData = RL.data();
'use strict';
this.email = ko.observable('');
this.password = ko.observable('');
this.signMe = ko.observable(false);
var
window = require('../External/window.js'),
$ = require('../External/jquery.js'),
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Utils = require('../Common/Utils.js'),
Enums = require('../Common/Enums.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
this.additionalCode = ko.observable('');
this.additionalCode.error = ko.observable(false);
this.additionalCode.focused = ko.observable(false);
this.additionalCode.visibility = ko.observable(false);
this.additionalCodeSignMe = ko.observable(false);
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
this.logoImg = Utils.trim(RL.settingsGet('LoginLogo'));
this.loginDescription = Utils.trim(RL.settingsGet('LoginDescription'));
this.logoCss = Utils.trim(RL.settingsGet('LoginCss'));
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
this.emailError = ko.observable(false);
this.passwordError = ko.observable(false);
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function LoginViewModel()
{
KnoinAbstractViewModel.call(this, 'Center', 'Login');
this.emailFocus = ko.observable(false);
this.submitFocus = ko.observable(false);
var oData = RL.data();
this.email.subscribe(function () {
this.emailError(false);
this.additionalCode('');
this.additionalCode.visibility(false);
}, this);
this.email = ko.observable('');
this.password = ko.observable('');
this.signMe = ko.observable(false);
this.password.subscribe(function () {
this.passwordError(false);
}, this);
this.additionalCode = ko.observable('');
this.additionalCode.error = ko.observable(false);
this.additionalCode.focused = ko.observable(false);
this.additionalCode.visibility = ko.observable(false);
this.additionalCodeSignMe = ko.observable(false);
this.additionalCode.subscribe(function () {
this.additionalCode.error(false);
}, this);
this.logoImg = Utils.trim(RL.settingsGet('LoginLogo'));
this.loginDescription = Utils.trim(RL.settingsGet('LoginDescription'));
this.logoCss = Utils.trim(RL.settingsGet('LoginCss'));
this.additionalCode.visibility.subscribe(function () {
this.additionalCode.error(false);
}, this);
this.emailError = ko.observable(false);
this.passwordError = ko.observable(false);
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.emailFocus = ko.observable(false);
this.submitFocus = ko.observable(false);
this.allowLanguagesOnLogin = oData.allowLanguagesOnLogin;
this.email.subscribe(function () {
this.emailError(false);
this.additionalCode('');
this.additionalCode.visibility(false);
}, this);
this.langRequest = ko.observable(false);
this.mainLanguage = oData.mainLanguage;
this.bSendLanguage = false;
this.password.subscribe(function () {
this.passwordError(false);
}, this);
this.mainLanguageFullName = ko.computed(function () {
return Utils.convertLangName(this.mainLanguage());
}, this);
this.additionalCode.subscribe(function () {
this.additionalCode.error(false);
}, this);
this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
this.additionalCode.visibility.subscribe(function () {
this.additionalCode.error(false);
}, this);
this.signMeType.subscribe(function (iValue) {
this.signMe(Enums.LoginSignMeType.DefaultOn === iValue);
}, this);
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.signMeVisibility = ko.computed(function () {
return Enums.LoginSignMeType.Unused !== this.signMeType();
}, this);
this.allowLanguagesOnLogin = oData.allowLanguagesOnLogin;
this.submitCommand = Utils.createCommand(this, function () {
this.langRequest = ko.observable(false);
this.mainLanguage = oData.mainLanguage;
this.bSendLanguage = false;
Utils.triggerAutocompleteInputChange();
this.mainLanguageFullName = ko.computed(function () {
return Utils.convertLangName(this.mainLanguage());
}, this);
this.emailError('' === Utils.trim(this.email()));
this.passwordError('' === Utils.trim(this.password()));
this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
if (this.additionalCode.visibility())
{
this.additionalCode.error('' === Utils.trim(this.additionalCode()));
}
this.signMeType.subscribe(function (iValue) {
this.signMe(Enums.LoginSignMeType.DefaultOn === iValue);
}, this);
if (this.emailError() || this.passwordError() || this.additionalCode.error())
{
return false;
}
this.signMeVisibility = ko.computed(function () {
return Enums.LoginSignMeType.Unused !== this.signMeType();
}, this);
this.submitRequest(true);
this.submitCommand = Utils.createCommand(this, function () {
var
sPassword = this.password(),
Utils.triggerAutocompleteInputChange();
fLoginRequest = _.bind(function (sPassword) {
this.emailError('' === Utils.trim(this.email()));
this.passwordError('' === Utils.trim(this.password()));
RL.remote().login(_.bind(function (sResult, oData) {
if (this.additionalCode.visibility())
{
this.additionalCode.error('' === Utils.trim(this.additionalCode()));
}
if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
{
if (oData.Result)
if (this.emailError() || this.passwordError() || this.additionalCode.error())
{
return false;
}
this.submitRequest(true);
var
sPassword = this.password(),
fLoginRequest = _.bind(function (sPassword) {
Remote.login(_.bind(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
{
if (oData.TwoFactorAuth)
if (oData.Result)
{
this.additionalCode('');
this.additionalCode.visibility(true);
this.additionalCode.focused(true);
if (oData.TwoFactorAuth)
{
this.additionalCode('');
this.additionalCode.visibility(true);
this.additionalCode.focused(true);
this.submitRequest(false);
}
else
{
RL.loginAndLogoutReload();
}
}
else if (oData.ErrorCode)
{
this.submitRequest(false);
this.submitError(Utils.getNotification(oData.ErrorCode));
if ('' === this.submitError())
{
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
}
}
else
{
RL.loginAndLogoutReload();
}
}
else if (oData.ErrorCode)
{
this.submitRequest(false);
this.submitError(Utils.getNotification(oData.ErrorCode));
if ('' === this.submitError())
{
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
this.submitRequest(false);
}
}
else
{
this.submitRequest(false);
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
}
}, this), this.email(), '', sPassword, !!this.signMe(),
this.bSendLanguage ? this.mainLanguage() : '',
this.additionalCode.visibility() ? this.additionalCode() : '',
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
);
}, this)
;
if (!!RL.settingsGet('UseRsaEncryption') && Utils.rsaEncode.supported)
{
Remote.getPublicKey(_.bind(function (sResult, oData) {
var bRequest = false;
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
Utils.isArray(oData.Result) && oData.Result[0] && oData.Result[1] && oData.Result[2])
{
var sEncryptedPassword = Utils.rsaEncode(sPassword, oData.Result[0], oData.Result[1], oData.Result[2]);
if (sEncryptedPassword)
{
fLoginRequest(sEncryptedPassword);
bRequest = true;
}
}
else
if (!bRequest)
{
this.submitRequest(false);
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
}
}, this), this.email(), '', sPassword, !!this.signMe(),
this.bSendLanguage ? this.mainLanguage() : '',
this.additionalCode.visibility() ? this.additionalCode() : '',
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
);
}, this)
;
if (!!RL.settingsGet('UseRsaEncryption') && Utils.rsaEncode.supported)
{
RL.remote().getPublicKey(_.bind(function (sResult, oData) {
var bRequest = false;
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
Utils.isArray(oData.Result) && oData.Result[0] && oData.Result[1] && oData.Result[2])
{
var sEncryptedPassword = Utils.rsaEncode(sPassword, oData.Result[0], oData.Result[1], oData.Result[2]);
if (sEncryptedPassword)
{
fLoginRequest(sEncryptedPassword);
bRequest = true;
}
}
if (!bRequest)
{
this.submitRequest(false);
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
}
}, this));
}
else
{
fLoginRequest(sPassword);
}
return true;
}, function () {
return !this.submitRequest();
});
this.facebookLoginEnabled = ko.observable(false);
this.facebookCommand = Utils.createCommand(this, function () {
window.open(RL.link().socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function () {
return !this.submitRequest() && this.facebookLoginEnabled();
});
this.googleLoginEnabled = ko.observable(false);
this.googleCommand = Utils.createCommand(this, function () {
window.open(RL.link().socialGoogle(), 'Google', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function () {
return !this.submitRequest() && this.googleLoginEnabled();
});
this.twitterLoginEnabled = ko.observable(false);
this.twitterCommand = Utils.createCommand(this, function () {
window.open(RL.link().socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function () {
return !this.submitRequest() && this.twitterLoginEnabled();
});
this.socialLoginEnabled = ko.computed(function () {
var
bF = this.facebookLoginEnabled(),
bG = this.googleLoginEnabled(),
bT = this.twitterLoginEnabled()
;
return bF || bG || bT;
}, this);
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('LoginViewModel', LoginViewModel);
LoginViewModel.prototype.onShow = function ()
{
kn.routeOff();
_.delay(_.bind(function () {
if ('' !== this.email() && '' !== this.password())
{
this.submitFocus(true);
}
else
{
this.emailFocus(true);
}
if (RL.settingsGet('UserLanguage'))
{
$.cookie('rllang', RL.data().language(), {'expires': 30});
}
}, this), 100);
};
LoginViewModel.prototype.onHide = function ()
{
this.submitFocus(false);
this.emailFocus(false);
};
LoginViewModel.prototype.onBuild = function ()
{
var
self = this,
sJsHash = RL.settingsGet('JsHash'),
fSocial = function (iErrorCode) {
iErrorCode = Utils.pInt(iErrorCode);
if (0 === iErrorCode)
{
self.submitRequest(true);
RL.loginAndLogoutReload();
}, this));
}
else
{
self.submitError(Utils.getNotification(iErrorCode));
fLoginRequest(sPassword);
}
}
;
this.facebookLoginEnabled(!!RL.settingsGet('AllowFacebookSocial'));
this.twitterLoginEnabled(!!RL.settingsGet('AllowTwitterSocial'));
this.googleLoginEnabled(!!RL.settingsGet('AllowGoogleSocial'));
return true;
switch ((RL.settingsGet('SignMe') || 'unused').toLowerCase())
{
case Enums.LoginSignMeTypeAsString.DefaultOff:
this.signMeType(Enums.LoginSignMeType.DefaultOff);
break;
case Enums.LoginSignMeTypeAsString.DefaultOn:
this.signMeType(Enums.LoginSignMeType.DefaultOn);
break;
default:
case Enums.LoginSignMeTypeAsString.Unused:
this.signMeType(Enums.LoginSignMeType.Unused);
break;
}
this.email(RL.data().devEmail);
this.password(RL.data().devPassword);
if (this.googleLoginEnabled())
{
window['rl_' + sJsHash + '_google_login_service'] = fSocial;
}
if (this.facebookLoginEnabled())
{
window['rl_' + sJsHash + '_facebook_login_service'] = fSocial;
}
if (this.twitterLoginEnabled())
{
window['rl_' + sJsHash + '_twitter_login_service'] = fSocial;
}
_.delay(function () {
RL.data().language.subscribe(function (sValue) {
self.langRequest(true);
$.ajax({
'url': RL.link().langLink(sValue),
'dataType': 'script',
'cache': true
}).done(function() {
self.bSendLanguage = true;
Utils.i18nReload();
$.cookie('rllang', RL.data().language(), {'expires': 30});
}).always(function() {
self.langRequest(false);
});
}, function () {
return !this.submitRequest();
});
}, 50);
Utils.triggerAutocompleteInputChange(true);
this.facebookLoginEnabled = ko.observable(false);
};
this.facebookCommand = Utils.createCommand(this, function () {
LoginViewModel.prototype.submitForm = function ()
{
this.submitCommand();
};
window.open(LinkBuilder.socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
LoginViewModel.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
}, function () {
return !this.submitRequest() && this.facebookLoginEnabled();
});
this.googleLoginEnabled = ko.observable(false);
this.googleCommand = Utils.createCommand(this, function () {
window.open(LinkBuilder.socialGoogle(), 'Google', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function () {
return !this.submitRequest() && this.googleLoginEnabled();
});
this.twitterLoginEnabled = ko.observable(false);
this.twitterCommand = Utils.createCommand(this, function () {
window.open(LinkBuilder.socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function () {
return !this.submitRequest() && this.twitterLoginEnabled();
});
this.socialLoginEnabled = ko.computed(function () {
var
bF = this.facebookLoginEnabled(),
bG = this.googleLoginEnabled(),
bT = this.twitterLoginEnabled()
;
return bF || bG || bT;
}, this);
kn.constructorEnd(this);
}
kn.extendAsViewModel('LoginViewModel', LoginViewModel);
LoginViewModel.prototype.onShow = function ()
{
kn.routeOff();
_.delay(_.bind(function () {
if ('' !== this.email() && '' !== this.password())
{
this.submitFocus(true);
}
else
{
this.emailFocus(true);
}
if (RL.settingsGet('UserLanguage'))
{
$.cookie('rllang', RL.data().language(), {'expires': 30});
}
}, this), 100);
};
LoginViewModel.prototype.onHide = function ()
{
this.submitFocus(false);
this.emailFocus(false);
};
LoginViewModel.prototype.onBuild = function ()
{
var
self = this,
sJsHash = RL.settingsGet('JsHash'),
fSocial = function (iErrorCode) {
iErrorCode = Utils.pInt(iErrorCode);
if (0 === iErrorCode)
{
self.submitRequest(true);
RL.loginAndLogoutReload();
}
else
{
self.submitError(Utils.getNotification(iErrorCode));
}
}
;
this.facebookLoginEnabled(!!RL.settingsGet('AllowFacebookSocial'));
this.twitterLoginEnabled(!!RL.settingsGet('AllowTwitterSocial'));
this.googleLoginEnabled(!!RL.settingsGet('AllowGoogleSocial'));
switch ((RL.settingsGet('SignMe') || 'unused').toLowerCase())
{
case Enums.LoginSignMeTypeAsString.DefaultOff:
this.signMeType(Enums.LoginSignMeType.DefaultOff);
break;
case Enums.LoginSignMeTypeAsString.DefaultOn:
this.signMeType(Enums.LoginSignMeType.DefaultOn);
break;
default:
case Enums.LoginSignMeTypeAsString.Unused:
this.signMeType(Enums.LoginSignMeType.Unused);
break;
}
this.email(RL.data().devEmail);
this.password(RL.data().devPassword);
if (this.googleLoginEnabled())
{
window['rl_' + sJsHash + '_google_login_service'] = fSocial;
}
if (this.facebookLoginEnabled())
{
window['rl_' + sJsHash + '_facebook_login_service'] = fSocial;
}
if (this.twitterLoginEnabled())
{
window['rl_' + sJsHash + '_twitter_login_service'] = fSocial;
}
_.delay(function () {
RL.data().language.subscribe(function (sValue) {
self.langRequest(true);
$.ajax({
'url': LinkBuilder.langLink(sValue),
'dataType': 'script',
'cache': true
}).done(function() {
self.bSendLanguage = true;
Utils.i18nReload();
$.cookie('rllang', RL.data().language(), {'expires': 30});
}).always(function() {
self.langRequest(false);
});
});
}, 50);
Utils.triggerAutocompleteInputChange(true);
};
LoginViewModel.prototype.submitForm = function ()
{
this.submitCommand();
};
LoginViewModel.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
module.exports = new LoginViewModel();
}(module));

View file

@ -1,249 +1,274 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function MailBoxFolderListViewModel()
{
KnoinAbstractViewModel.call(this, 'Left', 'MailFolderList');
(function (module) {
var oData = RL.data();
this.oContentVisible = null;
this.oContentScrollable = null;
this.messageList = oData.messageList;
this.folderList = oData.folderList;
this.folderListSystem = oData.folderListSystem;
this.foldersChanging = oData.foldersChanging;
this.leftPanelDisabled = oData.leftPanelDisabled;
this.iDropOverTimer = 0;
this.allowContacts = !!RL.settingsGet('ContactsIsAllowed');
Knoin.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxFolderListViewModel', MailBoxFolderListViewModel);
MailBoxFolderListViewModel.prototype.onBuild = function (oDom)
{
this.oContentVisible = $('.b-content', oDom);
this.oContentScrollable = $('.content', this.oContentVisible);
var self = this;
oDom
.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function (oEvent) {
var
oFolder = ko.dataFor(this),
bCollapsed = false
;
if (oFolder && oEvent)
{
bCollapsed = oFolder.collapsed();
Utils.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
oFolder.collapsed(!bCollapsed);
oEvent.preventDefault();
oEvent.stopPropagation();
}
})
.on('click', '.b-folders .e-item .e-link.selectable', function (oEvent) {
oEvent.preventDefault();
var
oData = RL.data(),
oFolder = ko.dataFor(this)
;
if (oFolder)
{
if (Enums.Layout.NoPreview === oData.layout())
{
oData.message(null);
}
if (oFolder.fullNameRaw === oData.currentFolderFullNameRaw())
{
RL.cache().setFolderHash(oFolder.fullNameRaw, '');
}
kn.setHash(RL.link().mailBox(oFolder.fullNameHash));
}
})
;
key('up, down', Enums.KeyState.FolderList, function (event, handler) {
var
iIndex = -1,
iKeyCode = handler && 'up' === handler.shortcut ? 38 : 40,
$items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom)
;
if (event && $items.length)
{
iIndex = $items.index($items.filter('.focused'));
if (-1 < iIndex)
{
$items.eq(iIndex).removeClass('focused');
}
if (iKeyCode === 38 && iIndex > 0)
{
iIndex--;
}
else if (iKeyCode === 40 && iIndex < $items.length - 1)
{
iIndex++;
}
$items.eq(iIndex).addClass('focused');
self.scrollToFocused();
}
return false;
});
key('enter', Enums.KeyState.FolderList, function () {
var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0])
{
self.folderList.focused(false);
$items.click();
}
return false;
});
key('space', Enums.KeyState.FolderList, function () {
var bCollapsed = true, oFolder = null, $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0])
{
oFolder = ko.dataFor($items[0]);
if (oFolder)
{
bCollapsed = oFolder.collapsed();
Utils.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
oFolder.collapsed(!bCollapsed);
}
}
return false;
});
key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function () {
self.folderList.focused(false);
return false;
});
self.folderList.focused.subscribe(function (bValue) {
$('.b-folders .e-item .e-link.focused', oDom).removeClass('focused');
if (bValue)
{
$('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
}
});
};
MailBoxFolderListViewModel.prototype.messagesDropOver = function (oFolder)
{
window.clearTimeout(this.iDropOverTimer);
if (oFolder && oFolder.collapsed())
{
this.iDropOverTimer = window.setTimeout(function () {
oFolder.collapsed(false);
Utils.setExpandedFolder(oFolder.fullNameHash, true);
Utils.windowResize();
}, 500);
}
};
MailBoxFolderListViewModel.prototype.messagesDropOut = function ()
{
window.clearTimeout(this.iDropOverTimer);
};
MailBoxFolderListViewModel.prototype.scrollToFocused = function ()
{
if (!this.oContentVisible || !this.oContentScrollable)
{
return false;
}
'use strict';
var
iOffset = 20,
oFocused = $('.e-item .e-link.focused', this.oContentScrollable),
oPos = oFocused.position(),
iVisibleHeight = this.oContentVisible.height(),
iFocusedHeight = oFocused.outerHeight()
window = require('../External/window.js'),
$ = require('../External/jquery.js'),
ko = require('../External/ko.js'),
key = require('../External/key.js'),
$html = require('../External/$html.js'),
Utils = require('../Common/Utils.js'),
Enums = require('../Common/Enums.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight))
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function MailBoxFolderListViewModel()
{
if (oPos.top < 0)
{
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
}
else
{
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
}
KnoinAbstractViewModel.call(this, 'Left', 'MailFolderList');
return true;
var oData = RL.data();
this.oContentVisible = null;
this.oContentScrollable = null;
this.messageList = oData.messageList;
this.folderList = oData.folderList;
this.folderListSystem = oData.folderListSystem;
this.foldersChanging = oData.foldersChanging;
this.leftPanelDisabled = oData.leftPanelDisabled;
this.iDropOverTimer = 0;
this.allowContacts = !!RL.settingsGet('ContactsIsAllowed');
kn.constructorEnd(this);
}
return false;
};
kn.extendAsViewModel('MailBoxFolderListViewModel', MailBoxFolderListViewModel);
/**
*
* @param {FolderModel} oToFolder
* @param {{helper:jQuery}} oUi
*/
MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi)
{
if (oToFolder && oUi && oUi.helper)
MailBoxFolderListViewModel.prototype.onBuild = function (oDom)
{
var
sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
bCopy = $html.hasClass('rl-ctrl-key-pressed'),
aUids = oUi.helper.data('rl-uids')
this.oContentVisible = $('.b-content', oDom);
this.oContentScrollable = $('.content', this.oContentVisible);
var self = this;
oDom
.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function (oEvent) {
var
oFolder = ko.dataFor(this),
bCollapsed = false
;
if (oFolder && oEvent)
{
bCollapsed = oFolder.collapsed();
Utils.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
oFolder.collapsed(!bCollapsed);
oEvent.preventDefault();
oEvent.stopPropagation();
}
})
.on('click', '.b-folders .e-item .e-link.selectable', function (oEvent) {
oEvent.preventDefault();
var
oData = RL.data(),
oFolder = ko.dataFor(this)
;
if (oFolder)
{
if (Enums.Layout.NoPreview === oData.layout())
{
oData.message(null);
}
if (oFolder.fullNameRaw === oData.currentFolderFullNameRaw())
{
Cache.setFolderHash(oFolder.fullNameRaw, '');
}
kn.setHash(LinkBuilder.mailBox(oFolder.fullNameHash));
}
})
;
if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
{
RL.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
}
}
};
key('up, down', Enums.KeyState.FolderList, function (event, handler) {
MailBoxFolderListViewModel.prototype.composeClick = function ()
{
kn.showScreenPopup(PopupsComposeViewModel);
};
var
iIndex = -1,
iKeyCode = handler && 'up' === handler.shortcut ? 38 : 40,
$items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom)
;
MailBoxFolderListViewModel.prototype.createFolder = function ()
{
kn.showScreenPopup(PopupsFolderCreateViewModel);
};
if (event && $items.length)
{
iIndex = $items.index($items.filter('.focused'));
if (-1 < iIndex)
{
$items.eq(iIndex).removeClass('focused');
}
MailBoxFolderListViewModel.prototype.configureFolders = function ()
{
kn.setHash(RL.link().settings('folders'));
};
if (iKeyCode === 38 && iIndex > 0)
{
iIndex--;
}
else if (iKeyCode === 40 && iIndex < $items.length - 1)
{
iIndex++;
}
MailBoxFolderListViewModel.prototype.contactsClick = function ()
{
if (this.allowContacts)
$items.eq(iIndex).addClass('focused');
self.scrollToFocused();
}
return false;
});
key('enter', Enums.KeyState.FolderList, function () {
var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0])
{
self.folderList.focused(false);
$items.click();
}
return false;
});
key('space', Enums.KeyState.FolderList, function () {
var bCollapsed = true, oFolder = null, $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0])
{
oFolder = ko.dataFor($items[0]);
if (oFolder)
{
bCollapsed = oFolder.collapsed();
Utils.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
oFolder.collapsed(!bCollapsed);
}
}
return false;
});
key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function () {
self.folderList.focused(false);
return false;
});
self.folderList.focused.subscribe(function (bValue) {
$('.b-folders .e-item .e-link.focused', oDom).removeClass('focused');
if (bValue)
{
$('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
}
});
};
MailBoxFolderListViewModel.prototype.messagesDropOver = function (oFolder)
{
kn.showScreenPopup(PopupsContactsViewModel);
}
};
window.clearTimeout(this.iDropOverTimer);
if (oFolder && oFolder.collapsed())
{
this.iDropOverTimer = window.setTimeout(function () {
oFolder.collapsed(false);
Utils.setExpandedFolder(oFolder.fullNameHash, true);
Utils.windowResize();
}, 500);
}
};
MailBoxFolderListViewModel.prototype.messagesDropOut = function ()
{
window.clearTimeout(this.iDropOverTimer);
};
MailBoxFolderListViewModel.prototype.scrollToFocused = function ()
{
if (!this.oContentVisible || !this.oContentScrollable)
{
return false;
}
var
iOffset = 20,
oFocused = $('.e-item .e-link.focused', this.oContentScrollable),
oPos = oFocused.position(),
iVisibleHeight = this.oContentVisible.height(),
iFocusedHeight = oFocused.outerHeight()
;
if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight))
{
if (oPos.top < 0)
{
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
}
else
{
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
}
return true;
}
return false;
};
/**
*
* @param {FolderModel} oToFolder
* @param {{helper:jQuery}} oUi
*/
MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi)
{
if (oToFolder && oUi && oUi.helper)
{
var
sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
bCopy = $html.hasClass('rl-ctrl-key-pressed'),
aUids = oUi.helper.data('rl-uids')
;
if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
{
RL.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
}
}
};
MailBoxFolderListViewModel.prototype.composeClick = function ()
{
kn.showScreenPopup(PopupsComposeViewModel);
};
MailBoxFolderListViewModel.prototype.createFolder = function ()
{
kn.showScreenPopup(PopupsFolderCreateViewModel);
};
MailBoxFolderListViewModel.prototype.configureFolders = function ()
{
kn.setHash(LinkBuilder.settings('folders'));
};
MailBoxFolderListViewModel.prototype.contactsClick = function ()
{
if (this.allowContacts)
{
kn.showScreenPopup(PopupsContactsViewModel);
}
};
module.exports = new MailBoxFolderListViewModel();
}(module));

File diff suppressed because it is too large Load diff

View file

@ -8,9 +8,14 @@
ko = require('../External/ko.js'),
key = require('../External/key.js'),
$html = require('../External/$html.js'),
Consts = require('../Common/Consts.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
@ -188,7 +193,7 @@
this.viewDownloadLink(oMessage.downloadLink());
sLastEmail = oMessage.fromAsSingleEmail();
RL.cache().getUserPic(sLastEmail, function (sPic, $sEmail) {
Cache.getUserPic(sLastEmail, function (sPic, $sEmail) {
if (sPic !== self.viewUserPic() && sLastEmail === $sEmail)
{
self.viewUserPicVisible(false);
@ -240,7 +245,7 @@
kn.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxMessageViewViewModel', MailBoxMessageViewViewModel);
kn.extendAsViewModel('MailBoxMessageViewViewModel', MailBoxMessageViewViewModel);
MailBoxMessageViewViewModel.prototype.isPgpActionVisible = function ()
{
@ -695,14 +700,14 @@
{
if (oMessage && '' !== oMessage.readReceipt())
{
RL.remote().sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
Remote.sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
oMessage.readReceipt(),
Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': RL.data().accountEmail()}));
oMessage.isReadReceipt(true);
RL.cache().storeMessageFlagsToCache(oMessage);
Cache.storeMessageFlagsToCache(oMessage);
RL.reloadFlagsCurrentMessageListAndMessageFromCache();
}
};

View file

@ -20,7 +20,7 @@
kn.constructorEnd(this);
}
Utils.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel);
kn.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel);
module.exports = MailBoxSystemDropDownViewModel;

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -5,7 +5,10 @@
'use strict';
var
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Data = require('../Storages/WebMailDataStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
@ -20,23 +23,23 @@
{
KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu');
this.leftPanelDisabled = RL.data().leftPanelDisabled; // TODO cjs
this.leftPanelDisabled = Data.leftPanelDisabled;
this.menu = oScreen.menu;
kn.constructorEnd(this);
}
Utils.extendAsViewModel('SettingsMenuViewModel', SettingsMenuViewModel);
kn.extendAsViewModel('SettingsMenuViewModel', SettingsMenuViewModel);
SettingsMenuViewModel.prototype.link = function (sRoute)
{
return RL.link().settings(sRoute);// TODO cjs
return LinkBuilder.settings(sRoute);
};
SettingsMenuViewModel.prototype.backToMailBoxClick = function ()
{
kn.setHash(RL.link().inbox()); // TODO cjs
kn.setHash(LinkBuilder.inbox());
};
module.exports = SettingsMenuViewModel;

View file

@ -6,8 +6,12 @@
var
key = require('../External/key.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Data = require('../Storages/WebMailDataStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
@ -23,7 +27,7 @@
kn.constructorEnd(this);
}
Utils.extendAsViewModel('SettingsPaneViewModel', SettingsPaneViewModel);
kn.extendAsViewModel('SettingsPaneViewModel', SettingsPaneViewModel);
SettingsPaneViewModel.prototype.onBuild = function ()
{
@ -35,12 +39,12 @@
SettingsPaneViewModel.prototype.onShow = function ()
{
RL.data().message(null); // TODO cjs
Data.message(null);
};
SettingsPaneViewModel.prototype.backToMailBoxClick = function ()
{
kn.setHash(RL.link().inbox()); // TODO cjs
kn.setHash(LinkBuilder.inbox());
};
module.exports = SettingsPaneViewModel;

View file

@ -5,7 +5,6 @@
'use strict';
var
Utils = require('../Common/Utils.js'),
kn = require('./Knoin/Knoin.js'),
AbstractSystemDropDownViewModel = require('./AbstractSystemDropDownViewModel.js')
;
@ -20,7 +19,7 @@
kn.constructorEnd(this);
}
Utils.extendAsViewModel('SettingsSystemDropDownViewModel', SettingsSystemDropDownViewModel, AbstractSystemDropDownViewModel);
kn.extendAsViewModel('SettingsSystemDropDownViewModel', SettingsSystemDropDownViewModel, AbstractSystemDropDownViewModel);
module.exports = SettingsSystemDropDownViewModel;