mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
eslint (additional rules)
This commit is contained in:
parent
77a1d3f3df
commit
8e8a041032
150 changed files with 21911 additions and 23106 deletions
|
|
@ -1,148 +1,141 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginAdminView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'AdminLogin');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.logoPowered = !!Settings.settingsGet('LoginPowered');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginAdminView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'AdminLogin');
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
|
||||
this.logoPowered = !!Settings.settingsGet('LoginPowered');
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.loginErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
this.loginFocus = ko.observable(false);
|
||||
|
||||
this.loginErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.formHidden = ko.observable(false);
|
||||
|
||||
this.loginFocus = ko.observable(false);
|
||||
this.formError = ko.computed(function() {
|
||||
return this.loginErrorAnimation() || this.passwordErrorAnimation();
|
||||
}, this);
|
||||
|
||||
this.formHidden = ko.observable(false);
|
||||
this.login.subscribe(function() {
|
||||
this.loginError(false);
|
||||
}, this);
|
||||
|
||||
this.formError = ko.computed(function () {
|
||||
return this.loginErrorAnimation() || this.passwordErrorAnimation();
|
||||
}, this);
|
||||
this.password.subscribe(function() {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.login.subscribe(function () {
|
||||
this.loginError(false);
|
||||
}, this);
|
||||
this.loginError.subscribe(function(bV) {
|
||||
this.loginErrorAnimation(!!bV);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
this.passwordError.subscribe(function(bV) {
|
||||
this.passwordErrorAnimation(!!bV);
|
||||
}, this);
|
||||
|
||||
this.loginError.subscribe(function (bV) {
|
||||
this.loginErrorAnimation(!!bV);
|
||||
}, this);
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.passwordError.subscribe(function (bV) {
|
||||
this.passwordErrorAnimation(!!bV);
|
||||
}, this);
|
||||
this.submitCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
Utils.triggerAutocompleteInputChange();
|
||||
|
||||
this.submitCommand = Utils.createCommand(this, function () {
|
||||
this.loginError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
Utils.triggerAutocompleteInputChange();
|
||||
this.loginError('' === Utils.trim(this.login()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
this.loginError(false);
|
||||
this.passwordError(false);
|
||||
if (this.loginError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.loginError('' === Utils.trim(this.login()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
this.submitRequest(true);
|
||||
|
||||
if (this.loginError() || this.passwordError())
|
||||
Remote.adminLogin(_.bind(function(sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin(_.bind(function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
||||
if (oData.Result)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').default.loginAndLogoutReload(true);
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
require('App/Admin').default.loginAndLogoutReload(true);
|
||||
}
|
||||
else
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.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();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Login', 'AdminLoginViewModel'], LoginAdminView);
|
||||
_.extend(LoginAdminView.prototype, AbstractView.prototype);
|
||||
kn.extendAsViewModel(['View/Admin/Login', 'AdminLoginViewModel'], LoginAdminView);
|
||||
_.extend(LoginAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
LoginAdminView.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
LoginAdminView.prototype.onShow = function()
|
||||
{
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(_.bind(function () {
|
||||
this.loginFocus(true);
|
||||
}, this), 100);
|
||||
_.delay(_.bind(function() {
|
||||
this.loginFocus(true);
|
||||
}, this), 100);
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.onHide = function ()
|
||||
{
|
||||
this.loginFocus(false);
|
||||
};
|
||||
LoginAdminView.prototype.onHide = function()
|
||||
{
|
||||
this.loginFocus(false);
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.onBuild = function ()
|
||||
{
|
||||
Utils.triggerAutocompleteInputChange(true);
|
||||
};
|
||||
LoginAdminView.prototype.onBuild = function()
|
||||
{
|
||||
Utils.triggerAutocompleteInputChange(true);
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.submitForm = function ()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
LoginAdminView.prototype.submitForm = function()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
|
||||
module.exports = LoginAdminView;
|
||||
|
||||
}());
|
||||
module.exports = LoginAdminView;
|
||||
|
|
|
|||
|
|
@ -1,75 +1,67 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
'use strict';
|
||||
Globals = require('Common/Globals'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
/**
|
||||
* @constructor
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MenuSettingsAdminView(oScreen)
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'AdminMenu');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
/**
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MenuSettingsAdminView(oScreen)
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'AdminMenu');
|
||||
this.menu = oScreen.menu;
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Menu', 'AdminSettingsMenuViewModel'], MenuSettingsAdminView);
|
||||
_.extend(MenuSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
MenuSettingsAdminView.prototype.link = function(sRoute)
|
||||
{
|
||||
return '#/' + sRoute;
|
||||
};
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Menu', 'AdminSettingsMenuViewModel'], MenuSettingsAdminView);
|
||||
_.extend(MenuSettingsAdminView.prototype, AbstractView.prototype);
|
||||
MenuSettingsAdminView.prototype.onBuild = function(oDom)
|
||||
{
|
||||
key('up, down', _.throttle(function(event, handler) {
|
||||
|
||||
MenuSettingsAdminView.prototype.link = function (sRoute)
|
||||
{
|
||||
return '#/' + sRoute;
|
||||
};
|
||||
var
|
||||
sH = '',
|
||||
iIndex = -1,
|
||||
bUp = handler && 'up' === handler.shortcut,
|
||||
$items = $('.b-admin-menu .e-item', oDom);
|
||||
|
||||
MenuSettingsAdminView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
key('up, down', _.throttle(function (event, handler) {
|
||||
|
||||
var
|
||||
sH = '',
|
||||
iIndex = -1,
|
||||
bUp = handler && 'up' === handler.shortcut,
|
||||
$items = $('.b-admin-menu .e-item', oDom)
|
||||
;
|
||||
|
||||
if (event && $items.length)
|
||||
if (event && $items.length)
|
||||
{
|
||||
iIndex = $items.index($items.filter('.selected'));
|
||||
if (bUp && 0 < iIndex)
|
||||
{
|
||||
iIndex = $items.index($items.filter('.selected'));
|
||||
if (bUp && iIndex > 0)
|
||||
{
|
||||
iIndex--;
|
||||
}
|
||||
else if (!bUp && iIndex < $items.length - 1)
|
||||
{
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
sH = $items.eq(iIndex).attr('href');
|
||||
if (sH)
|
||||
{
|
||||
kn.setHash(sH, false, true);
|
||||
}
|
||||
iIndex -= 1;
|
||||
}
|
||||
else if (!bUp && iIndex < $items.length - 1)
|
||||
{
|
||||
iIndex += 1;
|
||||
}
|
||||
|
||||
}, 200));
|
||||
};
|
||||
sH = $items.eq(iIndex).attr('href');
|
||||
if (sH)
|
||||
{
|
||||
kn.setHash(sH, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MenuSettingsAdminView;
|
||||
}, 200));
|
||||
};
|
||||
|
||||
}());
|
||||
module.exports = MenuSettingsAdminView;
|
||||
|
|
|
|||
|
|
@ -1,60 +1,53 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsAdminView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'AdminPane');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsAdminView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'AdminPane');
|
||||
this.capa = !!Settings.settingsGet('PremType');
|
||||
this.community = RL_COMMUNITY;
|
||||
|
||||
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
this.adminManLoading = ko.computed(function() {
|
||||
return '000' !== [
|
||||
require('Stores/Admin/Domain').domains.loading() ? '1' : '0',
|
||||
require('Stores/Admin/Plugin').plugins.loading() ? '1' : '0',
|
||||
require('Stores/Admin/Package').packages.loading() ? '1' : '0'
|
||||
].join('');
|
||||
}, this);
|
||||
|
||||
this.capa = !!Settings.settingsGet('PremType');
|
||||
this.community = RL_COMMUNITY;
|
||||
this.adminManLoadingVisibility = ko.computed(function() {
|
||||
return this.adminManLoading() ? 'visible' : 'hidden';
|
||||
}, this).extend({'rateLimit': 300});
|
||||
|
||||
this.adminManLoading = ko.computed(function () {
|
||||
return '000' !== [
|
||||
require('Stores/Admin/Domain').domains.loading() ? '1' : '0',
|
||||
require('Stores/Admin/Plugin').plugins.loading() ? '1' : '0',
|
||||
require('Stores/Admin/Package').packages.loading() ? '1' : '0'
|
||||
].join('');
|
||||
}, this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
this.adminManLoadingVisibility = ko.computed(function () {
|
||||
return this.adminManLoading() ? 'visible' : 'hidden';
|
||||
}, this).extend({'rateLimit': 300});
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Pane', 'AdminSettingsPaneViewModel'], PaneSettingsAdminView);
|
||||
_.extend(PaneSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
PaneSettingsAdminView.prototype.logoutClick = function()
|
||||
{
|
||||
Remote.adminLogout(function() {
|
||||
require('App/Admin').default.loginAndLogoutReload(true, true);
|
||||
});
|
||||
};
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Pane', 'AdminSettingsPaneViewModel'], PaneSettingsAdminView);
|
||||
_.extend(PaneSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
PaneSettingsAdminView.prototype.logoutClick = function ()
|
||||
{
|
||||
Remote.adminLogout(function () {
|
||||
require('App/Admin').default.loginAndLogoutReload(true, true);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = PaneSettingsAdminView;
|
||||
|
||||
}());
|
||||
module.exports = PaneSettingsAdminView;
|
||||
|
|
|
|||
|
|
@ -1,135 +1,128 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AccountPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAccount');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.isNew = ko.observable(true);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AccountPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAccount');
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.isNew = ko.observable(true);
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.email.subscribe(function() {
|
||||
this.emailError(false);
|
||||
}, this);
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
this.password.subscribe(function() {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
}, this);
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitErrorAdditional = ko.observable('');
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
this.emailFocus = ko.observable(false);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitErrorAdditional = ko.observable('');
|
||||
this.addAccountCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
this.addAccountCommand = Utils.createCommand(this, function () {
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
this.submitRequest(true);
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
Remote.accountSetup(_.bind(function(sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.accountSetup(_.bind(function (sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
if (oData.Result)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/User').default.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
|
||||
Translator.getNotification(Enums.Notification.UnknownError));
|
||||
|
||||
if (oData.ErrorMessageAdditional)
|
||||
{
|
||||
this.submitErrorAdditional(oData.ErrorMessageAdditional);
|
||||
}
|
||||
}
|
||||
require('App/User').default.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
this.submitErrorAdditional('');
|
||||
this.submitError(oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
|
||||
Translator.getNotification(Enums.Notification.UnknownError));
|
||||
|
||||
if (oData.ErrorMessageAdditional)
|
||||
{
|
||||
this.submitErrorAdditional(oData.ErrorMessageAdditional);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
this.submitErrorAdditional('');
|
||||
}
|
||||
|
||||
}, this), this.email(), this.password(), this.isNew());
|
||||
}, this), this.email(), this.password(), this.isNew());
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
}, function() {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Account', 'View/Popup/AddAccount', 'PopupsAddAccountViewModel'], AccountPopupView);
|
||||
_.extend(AccountPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AccountPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.isNew(true);
|
||||
|
||||
this.email('');
|
||||
this.password('');
|
||||
|
||||
this.emailError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
this.submitErrorAdditional('');
|
||||
};
|
||||
|
||||
AccountPopupView.prototype.onShow = function(oAccount)
|
||||
{
|
||||
this.clearPopup();
|
||||
if (oAccount && oAccount.canBeEdit())
|
||||
{
|
||||
this.isNew(false);
|
||||
this.email(oAccount.email);
|
||||
}
|
||||
};
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Account', 'View/Popup/AddAccount', 'PopupsAddAccountViewModel'], AccountPopupView);
|
||||
_.extend(AccountPopupView.prototype, AbstractView.prototype);
|
||||
AccountPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.emailFocus(true);
|
||||
};
|
||||
|
||||
AccountPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.isNew(true);
|
||||
|
||||
this.email('');
|
||||
this.password('');
|
||||
|
||||
this.emailError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
this.submitErrorAdditional('');
|
||||
};
|
||||
|
||||
AccountPopupView.prototype.onShow = function (oAccount)
|
||||
{
|
||||
this.clearPopup();
|
||||
if (oAccount && oAccount.canBeEdit())
|
||||
{
|
||||
this.isNew(false);
|
||||
this.email(oAccount.email);
|
||||
}
|
||||
};
|
||||
|
||||
AccountPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
this.emailFocus(true);
|
||||
};
|
||||
|
||||
module.exports = AccountPopupView;
|
||||
|
||||
}());
|
||||
module.exports = AccountPopupView;
|
||||
|
|
|
|||
|
|
@ -1,151 +1,143 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Consts = require('Common/Consts'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Consts = require('Common/Consts'),
|
||||
Translator = require('Common/Translator'),
|
||||
LicenseStore = require('Stores/Admin/License'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
LicenseStore = require('Stores/Admin/License'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ActivatePopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsActivate');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ActivatePopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsActivate');
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
|
||||
var self = this;
|
||||
this.licenseTrigger = LicenseStore.licenseTrigger;
|
||||
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
this.activateProcess = ko.observable(false);
|
||||
this.activateText = ko.observable('');
|
||||
this.activateText.isError = ko.observable(false);
|
||||
|
||||
this.licenseTrigger = LicenseStore.licenseTrigger;
|
||||
this.htmlDescription = ko.computed(function() {
|
||||
return Translator.i18n('POPUPS_ACTIVATE/HTML_DESC', {'DOMAIN': this.domain()});
|
||||
}, this);
|
||||
|
||||
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.htmlDescription = ko.computed(function () {
|
||||
return Translator.i18n('POPUPS_ACTIVATE/HTML_DESC', {'DOMAIN': this.domain()});
|
||||
}, this);
|
||||
this.activationSuccessed.subscribe(function(bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.key.subscribe(function () {
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
}, this);
|
||||
this.activateCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.activationSuccessed.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
}, this);
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey())
|
||||
{
|
||||
Remote.licensingActivate(function(sResult, oData) {
|
||||
|
||||
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.activateProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
if (true === oData.Result)
|
||||
{
|
||||
if (true === oData.Result)
|
||||
{
|
||||
self.activationSuccessed(true);
|
||||
self.activateText(Translator.i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED'));
|
||||
self.activateText.isError(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(oData.Result);
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
self.activateText(Translator.getNotification(oData.ErrorCode));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
self.activationSuccessed(true);
|
||||
self.activateText(Translator.i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED'));
|
||||
self.activateText.isError(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
self.activateText(oData.Result);
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
self.activateText(Translator.getNotification(oData.ErrorCode));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
|
||||
}, this.domain(), this.key());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.activateProcess(false);
|
||||
this.activateText(Translator.i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY'));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
|
||||
}, function () {
|
||||
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Activate', 'PopupsActivateViewModel'], ActivatePopupView);
|
||||
_.extend(ActivatePopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ActivatePopupView.prototype.onShow = function (bTrial)
|
||||
{
|
||||
this.domain(Settings.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
bTrial = Utils.isUnd(bTrial) ? false : !!bTrial;
|
||||
|
||||
this.key(bTrial ? Consts.RAINLOOP_TRIAL_KEY : '');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
}, this.domain(), this.key());
|
||||
}
|
||||
};
|
||||
|
||||
ActivatePopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if (!this.activateProcess())
|
||||
else
|
||||
{
|
||||
this.activateProcess(false);
|
||||
this.activateText(Translator.i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY'));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
ActivatePopupView.prototype.validateSubscriptionKey = function ()
|
||||
}, function() {
|
||||
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Activate', 'PopupsActivateViewModel'], ActivatePopupView);
|
||||
_.extend(ActivatePopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ActivatePopupView.prototype.onShow = function(bTrial)
|
||||
{
|
||||
this.domain(Settings.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
var sValue = this.key();
|
||||
return '' === sValue || Consts.RAINLOOP_TRIAL_KEY === sValue ||
|
||||
!!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue));
|
||||
};
|
||||
bTrial = Utils.isUnd(bTrial) ? false : !!bTrial;
|
||||
|
||||
module.exports = ActivatePopupView;
|
||||
this.key(bTrial ? Consts.RAINLOOP_TRIAL_KEY : '');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
||||
ActivatePopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
this.key.focus(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
ActivatePopupView.prototype.validateSubscriptionKey = function()
|
||||
{
|
||||
var sValue = this.key();
|
||||
return '' === sValue || Consts.RAINLOOP_TRIAL_KEY === sValue || !!(/^RL[\d]+-[A-Z0-9\-]+Z$/).test(Utils.trim(sValue));
|
||||
};
|
||||
|
||||
module.exports = ActivatePopupView;
|
||||
|
|
|
|||
|
|
@ -1,114 +1,106 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AddOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAddOpenPgpKey');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.key = ko.observable('');
|
||||
this.key.error = ko.observable(false);
|
||||
this.key.focus = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AddOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAddOpenPgpKey');
|
||||
this.key.subscribe(function() {
|
||||
this.key.error(false);
|
||||
}, this);
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.key.error = ko.observable(false);
|
||||
this.key.focus = ko.observable(false);
|
||||
this.addOpenPgpKeyCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.key.subscribe(function () {
|
||||
this.key.error(false);
|
||||
}, this);
|
||||
var
|
||||
count = 30,
|
||||
match = null,
|
||||
key = Utils.trim(this.key()),
|
||||
reg = /[\-]{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,
|
||||
openpgpKeyring = PgpStore.openpgpKeyring,
|
||||
done = false;
|
||||
|
||||
this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
if (/[\n]/.test(key))
|
||||
{
|
||||
key = key.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n');
|
||||
}
|
||||
|
||||
var
|
||||
count = 30,
|
||||
match = null,
|
||||
key = Utils.trim(this.key()),
|
||||
reg = /[\-]{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,
|
||||
openpgpKeyring = PgpStore.openpgpKeyring,
|
||||
done = false
|
||||
;
|
||||
this.key.error('' === key);
|
||||
|
||||
if (/[\n]/.test(key))
|
||||
if (!openpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
match = reg.exec(key);
|
||||
if (match && 0 > count)
|
||||
{
|
||||
key = key.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n');
|
||||
}
|
||||
|
||||
this.key.error('' === key);
|
||||
|
||||
if (!openpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
match = reg.exec(key);
|
||||
if (match && 0 > count)
|
||||
if (match[0] && match[1] && match[2] && match[1] === match[2])
|
||||
{
|
||||
if (match[0] && match[1] && match[2] && match[1] === match[2])
|
||||
if ('PRIVATE' === match[1])
|
||||
{
|
||||
if ('PRIVATE' === match[1])
|
||||
{
|
||||
openpgpKeyring.privateKeys.importKey(match[0]);
|
||||
}
|
||||
else if ('PUBLIC' === match[1])
|
||||
{
|
||||
openpgpKeyring.publicKeys.importKey(match[0]);
|
||||
}
|
||||
openpgpKeyring.privateKeys.importKey(match[0]);
|
||||
}
|
||||
else if ('PUBLIC' === match[1])
|
||||
{
|
||||
openpgpKeyring.publicKeys.importKey(match[0]);
|
||||
}
|
||||
|
||||
count--;
|
||||
}
|
||||
|
||||
done = true;
|
||||
|
||||
count -= 1;
|
||||
}
|
||||
while (done);
|
||||
|
||||
openpgpKeyring.store();
|
||||
done = true;
|
||||
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(this, 'cancelCommand');
|
||||
}
|
||||
while (done);
|
||||
|
||||
return true;
|
||||
});
|
||||
openpgpKeyring.store();
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(this, 'cancelCommand');
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/AddOpenPgpKey', 'PopupsAddOpenPgpKeyViewModel'], AddOpenPgpKeyPopupView);
|
||||
_.extend(AddOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
return true;
|
||||
});
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.key('');
|
||||
this.key.error(false);
|
||||
};
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
kn.extendAsViewModel(['View/Popup/AddOpenPgpKey', 'PopupsAddOpenPgpKeyViewModel'], AddOpenPgpKeyPopupView);
|
||||
_.extend(AddOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
this.key.focus(true);
|
||||
};
|
||||
AddOpenPgpKeyPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.key('');
|
||||
this.key.error(false);
|
||||
};
|
||||
|
||||
module.exports = AddOpenPgpKeyPopupView;
|
||||
AddOpenPgpKeyPopupView.prototype.onShow = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
}());
|
||||
AddOpenPgpKeyPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.key.focus(true);
|
||||
};
|
||||
|
||||
module.exports = AddOpenPgpKeyPopupView;
|
||||
|
|
|
|||
|
|
@ -1,195 +1,187 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AdvancedSearchPopupView()
|
||||
{
|
||||
AbstractView.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)
|
||||
{
|
||||
MessageStore.mainMessageListSearch(sSearch);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
});
|
||||
|
||||
this.selectedDates = ko.computed(function() {
|
||||
Translator.trigger();
|
||||
return [
|
||||
{'id': -1, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_ALL')},
|
||||
{'id': 3, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_3_DAYS')},
|
||||
{'id': 7, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_7_DAYS')},
|
||||
{'id': 30, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_MONTH')},
|
||||
{'id': 90, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_3_MONTHS')},
|
||||
{'id': 180, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_6_MONTHS')},
|
||||
{'id': 365, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_YEAR')}
|
||||
];
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/AdvancedSearch', 'PopupsAdvancedSearchViewModel'], AdvancedSearchPopupView);
|
||||
_.extend(AdvancedSearchPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AdvancedSearchPopupView.prototype.parseSearchStringValue = function(search)
|
||||
{
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
self = this,
|
||||
parts = (search || '').split(/[\s]+/g);
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
_.each(parts, function(part) {
|
||||
switch (part)
|
||||
{
|
||||
case 'has:attachment':
|
||||
self.hasAttachment(true);
|
||||
break;
|
||||
case 'is:unseen,flagged':
|
||||
self.starred(true);
|
||||
/* falls through */
|
||||
case 'is:unseen':
|
||||
self.unseen(true);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AdvancedSearchPopupView()
|
||||
AdvancedSearchPopupView.prototype.buildSearchStringValue = function(sValue)
|
||||
{
|
||||
if (-1 < sValue.indexOf(' '))
|
||||
{
|
||||
AbstractView.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)
|
||||
{
|
||||
MessageStore.mainMessageListSearch(sSearch);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
});
|
||||
|
||||
this.selectedDates = ko.computed(function () {
|
||||
Translator.trigger();
|
||||
return [
|
||||
{'id': -1, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_ALL')},
|
||||
{'id': 3, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_3_DAYS')},
|
||||
{'id': 7, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_7_DAYS')},
|
||||
{'id': 30, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_MONTH')},
|
||||
{'id': 90, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_3_MONTHS')},
|
||||
{'id': 180, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_6_MONTHS')},
|
||||
{'id': 365, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_YEAR')}
|
||||
];
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
sValue = '"' + sValue + '"';
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/AdvancedSearch', 'PopupsAdvancedSearchViewModel'], AdvancedSearchPopupView);
|
||||
_.extend(AdvancedSearchPopupView.prototype, AbstractView.prototype);
|
||||
return sValue;
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.parseSearchStringValue = function (search)
|
||||
AdvancedSearchPopupView.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 = [];
|
||||
|
||||
if (sFrom && '' !== sFrom)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
parts = (search || '').split(/[\s]+/g)
|
||||
;
|
||||
aResult.push('from:' + this.buildSearchStringValue(sFrom));
|
||||
}
|
||||
|
||||
_.each(parts, function(part) {
|
||||
switch (part)
|
||||
{
|
||||
case 'has:attachment':
|
||||
self.hasAttachment(true);
|
||||
break;
|
||||
case 'is:unseen,flagged':
|
||||
self.starred(true);
|
||||
/* falls through */
|
||||
case 'is:unseen':
|
||||
self.unseen(true);
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.buildSearchStringValue = function (sValue)
|
||||
if (sTo && '' !== sTo)
|
||||
{
|
||||
if (-1 < sValue.indexOf(' '))
|
||||
{
|
||||
sValue = '"' + sValue + '"';
|
||||
}
|
||||
aResult.push('to:' + this.buildSearchStringValue(sTo));
|
||||
}
|
||||
|
||||
return sValue;
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.buildSearchString = function ()
|
||||
if (sSubject && '' !== sSubject)
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
sFrom = Utils.trim(this.from()),
|
||||
sTo = Utils.trim(this.to()),
|
||||
sSubject = Utils.trim(this.subject()),
|
||||
sText = Utils.trim(this.text()),
|
||||
aIs = [],
|
||||
aHas = []
|
||||
;
|
||||
aResult.push('subject:' + this.buildSearchStringValue(sSubject));
|
||||
}
|
||||
|
||||
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:' + require('Common/Momentor').searchSubtractFormatDateHelper(this.selectedDateValue()) + '/');
|
||||
}
|
||||
|
||||
if (sText && '' !== sText)
|
||||
{
|
||||
aResult.push('text:' + this.buildSearchStringValue(sText));
|
||||
}
|
||||
|
||||
return Utils.trim(aResult.join(' '));
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.clearPopup = function ()
|
||||
if (this.hasAttachment())
|
||||
{
|
||||
this.from('');
|
||||
this.to('');
|
||||
this.subject('');
|
||||
this.text('');
|
||||
aHas.push('attachment');
|
||||
}
|
||||
|
||||
this.selectedDateValue(-1);
|
||||
this.hasAttachment(false);
|
||||
this.starred(false);
|
||||
this.unseen(false);
|
||||
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.onShow = function (search)
|
||||
if (this.unseen())
|
||||
{
|
||||
this.clearPopup();
|
||||
this.parseSearchStringValue(search);
|
||||
};
|
||||
aIs.push('unseen');
|
||||
}
|
||||
|
||||
AdvancedSearchPopupView.prototype.onShowWithDelay = function ()
|
||||
if (this.starred())
|
||||
{
|
||||
this.fromFocus(true);
|
||||
};
|
||||
aIs.push('flagged');
|
||||
}
|
||||
|
||||
module.exports = AdvancedSearchPopupView;
|
||||
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:' + require('Common/Momentor').searchSubtractFormatDateHelper(this.selectedDateValue()) + '/');
|
||||
}
|
||||
|
||||
if (sText && '' !== sText)
|
||||
{
|
||||
aResult.push('text:' + this.buildSearchStringValue(sText));
|
||||
}
|
||||
|
||||
return Utils.trim(aResult.join(' '));
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.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);
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.onShow = function(search)
|
||||
{
|
||||
this.clearPopup();
|
||||
this.parseSearchStringValue(search);
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
module.exports = AdvancedSearchPopupView;
|
||||
|
|
|
|||
|
|
@ -1,139 +1,134 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AskPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAsk');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.askDesc = ko.observable('');
|
||||
this.yesButton = ko.observable('');
|
||||
this.noButton = ko.observable('');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AskPopupView()
|
||||
this.yesFocus = ko.observable(false);
|
||||
this.noFocus = ko.observable(false);
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
|
||||
this.bFocusYesOnShow = true;
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Ask', 'PopupsAskViewModel'], AskPopupView);
|
||||
_.extend(AskPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AskPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.askDesc('');
|
||||
this.yesButton(Translator.i18n('POPUPS_ASK/BUTTON_YES'));
|
||||
this.noButton(Translator.i18n('POPUPS_ASK/BUTTON_NO'));
|
||||
|
||||
this.yesFocus(false);
|
||||
this.noFocus(false);
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
};
|
||||
|
||||
AskPopupView.prototype.yesClick = function()
|
||||
{
|
||||
this.cancelCommand();
|
||||
|
||||
if (Utils.isFunc(this.fYesAction))
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAsk');
|
||||
this.fYesAction.call(null);
|
||||
}
|
||||
};
|
||||
|
||||
this.askDesc = ko.observable('');
|
||||
this.yesButton = ko.observable('');
|
||||
this.noButton = ko.observable('');
|
||||
AskPopupView.prototype.noClick = function()
|
||||
{
|
||||
this.cancelCommand();
|
||||
|
||||
this.yesFocus = ko.observable(false);
|
||||
this.noFocus = ko.observable(false);
|
||||
if (Utils.isFunc(this.fNoAction))
|
||||
{
|
||||
this.fNoAction.call(null);
|
||||
}
|
||||
};
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
/**
|
||||
* @param {string} sAskDesc
|
||||
* @param {Function=} fYesFunc
|
||||
* @param {Function=} fNoFunc
|
||||
* @param {string=} sYesButton
|
||||
* @param {string=} sNoButton
|
||||
* @param {boolean=} bFocusYesOnShow
|
||||
* @returns {void}
|
||||
*/
|
||||
AskPopupView.prototype.onShow = function(sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton, bFocusYesOnShow)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.bFocusYesOnShow = true;
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
||||
this.fYesAction = fYesFunc || null;
|
||||
this.fNoAction = fNoFunc || null;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
this.askDesc(sAskDesc || '');
|
||||
|
||||
if (sYesButton)
|
||||
{
|
||||
this.yesButton(sYesButton);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Ask', 'PopupsAskViewModel'], AskPopupView);
|
||||
_.extend(AskPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AskPopupView.prototype.clearPopup = function ()
|
||||
if (sNoButton)
|
||||
{
|
||||
this.askDesc('');
|
||||
this.yesButton(Translator.i18n('POPUPS_ASK/BUTTON_YES'));
|
||||
this.noButton(Translator.i18n('POPUPS_ASK/BUTTON_NO'));
|
||||
this.noButton(sNoButton);
|
||||
}
|
||||
|
||||
this.yesFocus(false);
|
||||
this.noFocus(false);
|
||||
this.bFocusYesOnShow = Utils.isUnd(bFocusYesOnShow) ? true : !!bFocusYesOnShow;
|
||||
};
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
};
|
||||
|
||||
AskPopupView.prototype.yesClick = function ()
|
||||
AskPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (this.bFocusYesOnShow)
|
||||
{
|
||||
this.cancelCommand();
|
||||
this.yesFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
if (Utils.isFunc(this.fYesAction))
|
||||
AskPopupView.prototype.onBuild = function()
|
||||
{
|
||||
key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function() {
|
||||
if (this.yesFocus())
|
||||
{
|
||||
this.fYesAction.call(null);
|
||||
this.noFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
AskPopupView.prototype.noClick = function ()
|
||||
{
|
||||
this.cancelCommand();
|
||||
|
||||
if (Utils.isFunc(this.fNoAction))
|
||||
{
|
||||
this.fNoAction.call(null);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sAskDesc
|
||||
* @param {Function=} fYesFunc
|
||||
* @param {Function=} fNoFunc
|
||||
* @param {string=} sYesButton
|
||||
* @param {string=} sNoButton
|
||||
* @param {boolean=} bFocusYesOnShow
|
||||
*/
|
||||
AskPopupView.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton, bFocusYesOnShow)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.fYesAction = fYesFunc || null;
|
||||
this.fNoAction = fNoFunc || null;
|
||||
|
||||
this.askDesc(sAskDesc || '');
|
||||
if (sYesButton)
|
||||
{
|
||||
this.yesButton(sYesButton);
|
||||
}
|
||||
|
||||
if (sYesButton)
|
||||
{
|
||||
this.yesButton(sNoButton);
|
||||
}
|
||||
|
||||
this.bFocusYesOnShow = Utils.isUnd(bFocusYesOnShow) ? true : !!bFocusYesOnShow;
|
||||
};
|
||||
|
||||
AskPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if (this.bFocusYesOnShow)
|
||||
else
|
||||
{
|
||||
this.yesFocus(true);
|
||||
}
|
||||
};
|
||||
return false;
|
||||
}, this));
|
||||
|
||||
AskPopupView.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));
|
||||
};
|
||||
|
||||
key('esc', Enums.KeyState.PopupAsk, _.bind(function () {
|
||||
this.noClick();
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
|
||||
module.exports = AskPopupView;
|
||||
|
||||
}());
|
||||
module.exports = AskPopupView;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,491 +1,479 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
'use strict';
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
Translator = require('Common/Translator'),
|
||||
EmailModel = require('Model/Email'),
|
||||
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
EmailModel = require('Model/Email'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ComposeOpenPgpPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsComposeOpenPgp');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ComposeOpenPgpPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsComposeOpenPgp');
|
||||
this.publicKeysOptionsCaption = Translator.i18n('PGP_NOTIFICATIONS/ADD_A_PUBLICK_KEY');
|
||||
this.privateKeysOptionsCaption = Translator.i18n('PGP_NOTIFICATIONS/SELECT_A_PRIVATE_KEY');
|
||||
|
||||
var self = this;
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.publicKeysOptionsCaption = Translator.i18n('PGP_NOTIFICATIONS/ADD_A_PUBLICK_KEY');
|
||||
this.privateKeysOptionsCaption = Translator.i18n('PGP_NOTIFICATIONS/SELECT_A_PRIVATE_KEY');
|
||||
this.sign = ko.observable(false);
|
||||
this.encrypt = ko.observable(false);
|
||||
|
||||
this.notification = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
|
||||
this.sign = ko.observable(false);
|
||||
this.encrypt = ko.observable(false);
|
||||
this.text = ko.observable('');
|
||||
this.selectedPrivateKey = ko.observable(null);
|
||||
this.selectedPublicKey = ko.observable(null);
|
||||
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
this.signKey = ko.observable(null);
|
||||
this.encryptKeys = ko.observableArray([]);
|
||||
|
||||
this.text = ko.observable('');
|
||||
this.selectedPrivateKey = ko.observable(null);
|
||||
this.selectedPublicKey = ko.observable(null);
|
||||
this.encryptKeysView = ko.computed(function() {
|
||||
return _.compact(_.map(this.encryptKeys(), function(oKey) {
|
||||
return oKey ? oKey.key : null;
|
||||
}));
|
||||
}, this);
|
||||
|
||||
this.signKey = ko.observable(null);
|
||||
this.encryptKeys = ko.observableArray([]);
|
||||
this.privateKeysOptions = ko.computed(function() {
|
||||
return _.compact(_.flatten(_.map(PgpStore.openpgpkeysPrivate(), function(oKey, iIndex) {
|
||||
return self.signKey() && self.signKey().key.id === oKey.id ? null : _.map(oKey.users, function(sUser) {
|
||||
return {
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser,
|
||||
'key': oKey,
|
||||
'class': iIndex % 2 ? 'odd' : 'even'
|
||||
};
|
||||
});
|
||||
}), true));
|
||||
});
|
||||
|
||||
this.encryptKeysView = ko.computed(function () {
|
||||
return _.compact(_.map(this.encryptKeys(), function (oKey) {
|
||||
return oKey ? oKey.key : null;
|
||||
}));
|
||||
}, this);
|
||||
this.publicKeysOptions = ko.computed(function() {
|
||||
return _.compact(_.flatten(_.map(PgpStore.openpgpkeysPublic(), function(oKey, iIndex) {
|
||||
return -1 < Utils.inArray(oKey, self.encryptKeysView()) ? null : _.map(oKey.users, function(sUser) {
|
||||
return {
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser,
|
||||
'key': oKey,
|
||||
'class': iIndex % 2 ? 'odd' : 'even'
|
||||
};
|
||||
});
|
||||
}), true));
|
||||
});
|
||||
|
||||
this.privateKeysOptions = ko.computed(function () {
|
||||
return _.compact(_.flatten(_.map(PgpStore.openpgpkeysPrivate(), function (oKey, iIndex) {
|
||||
return self.signKey() && self.signKey().key.id === oKey.id ? null :
|
||||
_.map(oKey.users, function (sUser) {
|
||||
return {
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser,
|
||||
'key': oKey,
|
||||
'class': iIndex % 2 ? 'odd' : 'even'
|
||||
};
|
||||
});
|
||||
}), true));
|
||||
});
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
this.publicKeysOptions = ko.computed(function () {
|
||||
return _.compact(_.flatten(_.map(PgpStore.openpgpkeysPublic(), function (oKey, iIndex) {
|
||||
return -1 < Utils.inArray(oKey, self.encryptKeysView()) ? null :
|
||||
_.map(oKey.users, function (sUser) {
|
||||
return {
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser,
|
||||
'key': oKey,
|
||||
'class': iIndex % 2 ? 'odd' : 'even'
|
||||
};
|
||||
});
|
||||
}), true));
|
||||
});
|
||||
this.resultCallback = null;
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
// commands
|
||||
this.doCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.resultCallback = null;
|
||||
var
|
||||
bResult = true,
|
||||
oPrivateKey = null,
|
||||
aPrivateKeys = [],
|
||||
aPublicKeys = [];
|
||||
|
||||
// commands
|
||||
this.doCommand = Utils.createCommand(this, function () {
|
||||
this.submitRequest(true);
|
||||
|
||||
var
|
||||
bResult = true,
|
||||
oPrivateKey = null,
|
||||
aPrivateKeys = [],
|
||||
aPublicKeys = []
|
||||
;
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
if (bResult && this.sign())
|
||||
if (bResult && this.sign())
|
||||
{
|
||||
if (!this.signKey())
|
||||
{
|
||||
if (!this.signKey())
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
bResult = false;
|
||||
}
|
||||
else if (!this.signKey().key)
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.signKey().email
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
aPrivateKeys = this.signKey().key.getNativeKeys();
|
||||
oPrivateKey = aPrivateKeys[0] || null;
|
||||
|
||||
try
|
||||
{
|
||||
if (oPrivateKey)
|
||||
{
|
||||
oPrivateKey.decrypt(Utils.pString(this.password()));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
oPrivateKey = null;
|
||||
}
|
||||
|
||||
if (!oPrivateKey)
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
bResult = false;
|
||||
}
|
||||
else if (!this.signKey().key)
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult && this.encrypt())
|
||||
{
|
||||
if (0 === this.encryptKeys().length)
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND'));
|
||||
bResult = false;
|
||||
}
|
||||
else if (this.encryptKeys())
|
||||
{
|
||||
aPublicKeys = [];
|
||||
|
||||
_.each(this.encryptKeys(), function(oKey) {
|
||||
if (oKey && oKey.key)
|
||||
{
|
||||
aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys())));
|
||||
}
|
||||
else if (oKey && oKey.email)
|
||||
{
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
'EMAIL': oKey.email
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (bResult && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length))
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.signKey().email
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult && self.resultCallback)
|
||||
{
|
||||
_.delay(function() {
|
||||
|
||||
var oPromise = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (oPrivateKey && 0 === aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.sign({
|
||||
data: self.text(),
|
||||
privateKeys: [oPrivateKey]
|
||||
});
|
||||
}
|
||||
else if (oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.encrypt({
|
||||
data: self.text(),
|
||||
publicKeys: aPublicKeys,
|
||||
privateKeys: [oPrivateKey]
|
||||
});
|
||||
}
|
||||
else if (!oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.encrypt({
|
||||
data: self.text(),
|
||||
publicKeys: aPublicKeys
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
if (bResult)
|
||||
if (oPromise)
|
||||
{
|
||||
aPrivateKeys = this.signKey().key.getNativeKeys();
|
||||
oPrivateKey = aPrivateKeys[0] || null;
|
||||
|
||||
try
|
||||
{
|
||||
if (oPrivateKey)
|
||||
{
|
||||
oPrivateKey.decrypt(Utils.pString(this.password()));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
oPrivateKey = null;
|
||||
}
|
||||
oPromise.then(function(mData) {
|
||||
|
||||
if (!oPrivateKey)
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.resultCallback(mData.data);
|
||||
self.cancelCommand();
|
||||
|
||||
if (bResult && this.encrypt())
|
||||
{
|
||||
if (0 === this.encryptKeys().length)
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND'));
|
||||
bResult = false;
|
||||
}
|
||||
else if (this.encryptKeys())
|
||||
{
|
||||
aPublicKeys = [];
|
||||
|
||||
_.each(this.encryptKeys(), function (oKey) {
|
||||
if (oKey && oKey.key)
|
||||
{
|
||||
aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys())));
|
||||
}
|
||||
else if (oKey && oKey.email)
|
||||
{
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
'EMAIL': oKey.email
|
||||
}).then(null, function(e) {
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (bResult && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length))
|
||||
{
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult && self.resultCallback)
|
||||
{
|
||||
_.delay(function () {
|
||||
|
||||
var oPromise = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (oPrivateKey && 0 === aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.sign({
|
||||
data: self.text(),
|
||||
privateKeys: [oPrivateKey]
|
||||
});
|
||||
}
|
||||
else if (oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.encrypt({
|
||||
data: self.text(),
|
||||
publicKeys: aPublicKeys,
|
||||
privateKeys: [oPrivateKey]
|
||||
});
|
||||
}
|
||||
else if (!oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.encrypt({
|
||||
data: self.text(),
|
||||
publicKeys: aPublicKeys
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
if (oPromise)
|
||||
{
|
||||
try
|
||||
{
|
||||
oPromise.then(function (mData) {
|
||||
|
||||
self.resultCallback(mData.data);
|
||||
self.cancelCommand();
|
||||
|
||||
}).then(null, function (e) {
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
self.submitRequest(false);
|
||||
|
||||
}, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.submitRequest(false);
|
||||
}
|
||||
|
||||
return bResult;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && (this.sign() || this.encrypt());
|
||||
});
|
||||
|
||||
this.selectCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
sKeyId = this.selectedPrivateKey(),
|
||||
oKey = null,
|
||||
oOption = sKeyId ? _.find(this.privateKeysOptions(), function (oItem) {
|
||||
return oItem && sKeyId === oItem.id;
|
||||
}) : null
|
||||
;
|
||||
|
||||
if (oOption)
|
||||
{
|
||||
oKey = {
|
||||
'empty': !oOption.key,
|
||||
'selected': ko.observable(!!oOption.key),
|
||||
'users': oOption.key.users,
|
||||
'hash': oOption.key.id.substr(-8).toUpperCase(),
|
||||
'key': oOption.key
|
||||
};
|
||||
|
||||
this.signKey(oKey);
|
||||
}
|
||||
});
|
||||
|
||||
this.addCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
sKeyId = this.selectedPublicKey(),
|
||||
aKeys = this.encryptKeys(),
|
||||
oOption = sKeyId ? _.find(this.publicKeysOptions(), function (oItem) {
|
||||
return oItem && sKeyId === oItem.id;
|
||||
}) : null
|
||||
;
|
||||
|
||||
if (oOption)
|
||||
{
|
||||
aKeys.push({
|
||||
'empty': !oOption.key,
|
||||
'selected': ko.observable(!!oOption.key),
|
||||
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== oOption.key.id),
|
||||
'users': oOption.key.users,
|
||||
'hash': oOption.key.id.substr(-8).toUpperCase(),
|
||||
'key': oOption.key
|
||||
});
|
||||
|
||||
this.encryptKeys(aKeys);
|
||||
}
|
||||
});
|
||||
|
||||
this.updateCommand = Utils.createCommand(this, function () {
|
||||
_.each(this.encryptKeys(), function (oKey) {
|
||||
oKey.removable(!self.sign() || !self.signKey() || self.signKey().key.id !== oKey.key.id);
|
||||
});
|
||||
});
|
||||
|
||||
this.selectedPrivateKey.subscribe(function (sValue) {
|
||||
if (sValue)
|
||||
{
|
||||
this.selectCommand();
|
||||
this.updateCommand();
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.selectedPublicKey.subscribe(function (sValue) {
|
||||
if (sValue)
|
||||
{
|
||||
this.addCommand();
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
this.addOptionClass = function (oDomOption, oItem) {
|
||||
|
||||
self.defautOptionsAfterRender(oDomOption, oItem);
|
||||
|
||||
if (oItem && !Utils.isUnd(oItem.class) && oDomOption)
|
||||
{
|
||||
$(oDomOption).addClass(oItem.class);
|
||||
}
|
||||
};
|
||||
|
||||
this.deletePublickKey = _.bind(this.deletePublickKey, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/ComposeOpenPgp', 'PopupsComposeOpenPgpViewModel'], ComposeOpenPgpPopupView);
|
||||
_.extend(ComposeOpenPgpPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.deletePublickKey = function (oKey)
|
||||
{
|
||||
this.encryptKeys.remove(oKey);
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.notification('');
|
||||
|
||||
this.sign(false);
|
||||
this.encrypt(false);
|
||||
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
|
||||
this.signKey(null);
|
||||
this.encryptKeys([]);
|
||||
this.text('');
|
||||
|
||||
this.resultCallback = null;
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.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));
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onHideWithDelay = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if (this.sign())
|
||||
{
|
||||
this.password.focus(true);
|
||||
}, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buttonFocus(true);
|
||||
self.submitRequest(false);
|
||||
}
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onShow = function (fCallback, sText, oIdentity, sTo, sCc, sBcc)
|
||||
{
|
||||
this.clearPopup();
|
||||
return bResult;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest() && (this.sign() || this.encrypt());
|
||||
});
|
||||
|
||||
this.selectCommand = Utils.createCommand(this, function() {
|
||||
|
||||
var
|
||||
self = this,
|
||||
aRec = [],
|
||||
sEmail = '',
|
||||
aKeys = [],
|
||||
oEmail = new EmailModel()
|
||||
;
|
||||
sKeyId = this.selectedPrivateKey(),
|
||||
oKey = null,
|
||||
oOption = sKeyId ? _.find(this.privateKeysOptions(), function(oItem) {
|
||||
return oItem && sKeyId === oItem.id;
|
||||
}) : null;
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
|
||||
if ('' !== sTo)
|
||||
if (oOption)
|
||||
{
|
||||
aRec.push(sTo);
|
||||
}
|
||||
oKey = {
|
||||
'empty': !oOption.key,
|
||||
'selected': ko.observable(!!oOption.key),
|
||||
'users': oOption.key.users,
|
||||
'hash': oOption.key.id.substr(-8).toUpperCase(),
|
||||
'key': oOption.key
|
||||
};
|
||||
|
||||
if ('' !== sCc)
|
||||
this.signKey(oKey);
|
||||
}
|
||||
});
|
||||
|
||||
this.addCommand = Utils.createCommand(this, function() {
|
||||
|
||||
var
|
||||
sKeyId = this.selectedPublicKey(),
|
||||
aKeys = this.encryptKeys(),
|
||||
oOption = sKeyId ? _.find(this.publicKeysOptions(), function(oItem) {
|
||||
return oItem && sKeyId === oItem.id;
|
||||
}) : null;
|
||||
|
||||
if (oOption)
|
||||
{
|
||||
aRec.push(sCc);
|
||||
}
|
||||
aKeys.push({
|
||||
'empty': !oOption.key,
|
||||
'selected': ko.observable(!!oOption.key),
|
||||
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== oOption.key.id),
|
||||
'users': oOption.key.users,
|
||||
'hash': oOption.key.id.substr(-8).toUpperCase(),
|
||||
'key': oOption.key
|
||||
});
|
||||
|
||||
if ('' !== sBcc)
|
||||
this.encryptKeys(aKeys);
|
||||
}
|
||||
});
|
||||
|
||||
this.updateCommand = Utils.createCommand(this, function() {
|
||||
_.each(this.encryptKeys(), function(oKey) {
|
||||
oKey.removable(!self.sign() || !self.signKey() || self.signKey().key.id !== oKey.key.id);
|
||||
});
|
||||
});
|
||||
|
||||
this.selectedPrivateKey.subscribe(function(sValue) {
|
||||
if (sValue)
|
||||
{
|
||||
aRec.push(sBcc);
|
||||
this.selectCommand();
|
||||
this.updateCommand();
|
||||
}
|
||||
}, this);
|
||||
|
||||
aRec = aRec.join(', ').split(',');
|
||||
aRec = _.compact(_.map(aRec, function (sValue) {
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(Utils.trim(sValue));
|
||||
return '' === oEmail.email ? false : oEmail.email;
|
||||
}));
|
||||
|
||||
if (oIdentity && oIdentity.email())
|
||||
this.selectedPublicKey.subscribe(function(sValue) {
|
||||
if (sValue)
|
||||
{
|
||||
sEmail = oIdentity.email();
|
||||
aRec.unshift(sEmail);
|
||||
aKeys = PgpStore.findAllPrivateKeysByEmailNotNative(sEmail);
|
||||
if (aKeys && aKeys[0])
|
||||
{
|
||||
this.signKey({
|
||||
'users': aKeys[0].users || [sEmail],
|
||||
'hash': aKeys[0].id.substr(-8).toUpperCase(),
|
||||
'key': aKeys[0]
|
||||
});
|
||||
}
|
||||
this.addCommand();
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (this.signKey())
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
this.addOptionClass = function(oDomOption, oItem) {
|
||||
|
||||
self.defautOptionsAfterRender(oDomOption, oItem);
|
||||
|
||||
if (oItem && !Utils.isUnd(oItem.class) && oDomOption)
|
||||
{
|
||||
this.sign(true);
|
||||
$(oDomOption).addClass(oItem.class);
|
||||
}
|
||||
|
||||
if (aRec && 0 < aRec.length)
|
||||
{
|
||||
this.encryptKeys(_.uniq(_.compact(_.flatten(_.map(aRec, function (sRecEmail) {
|
||||
var keys = PgpStore.findAllPublicKeysByEmailNotNative(sRecEmail);
|
||||
return keys ? _.map(keys, function (oKey) {
|
||||
return {
|
||||
'empty': !oKey,
|
||||
'selected': ko.observable(!!oKey),
|
||||
'removable': ko.observable(!self.sign() || !self.signKey() || self.signKey().key.id !== oKey.id),
|
||||
'users': oKey ? (oKey.users || [sRecEmail]) : [sRecEmail],
|
||||
'hash': oKey ? oKey.id.substr(-8).toUpperCase() : '',
|
||||
'key': oKey
|
||||
};
|
||||
}) : [];
|
||||
}), true)), function (oEncryptKey) {
|
||||
return oEncryptKey.hash;
|
||||
}));
|
||||
|
||||
if (0 < this.encryptKeys().length)
|
||||
{
|
||||
this.encrypt(true);
|
||||
}
|
||||
}
|
||||
|
||||
this.text(sText);
|
||||
};
|
||||
|
||||
module.exports = ComposeOpenPgpPopupView;
|
||||
this.deletePublickKey = _.bind(this.deletePublickKey, this);
|
||||
|
||||
}());
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/ComposeOpenPgp', 'PopupsComposeOpenPgpViewModel'], ComposeOpenPgpPopupView);
|
||||
_.extend(ComposeOpenPgpPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.deletePublickKey = function(oKey)
|
||||
{
|
||||
this.encryptKeys.remove(oKey);
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.notification('');
|
||||
|
||||
this.sign(false);
|
||||
this.encrypt(false);
|
||||
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
|
||||
this.signKey(null);
|
||||
this.encryptKeys([]);
|
||||
this.text('');
|
||||
|
||||
this.resultCallback = null;
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.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;
|
||||
// no default
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}, this));
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onHideWithDelay = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (this.sign())
|
||||
{
|
||||
this.password.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buttonFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onShow = function(fCallback, sText, oIdentity, sTo, sCc, sBcc)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
var
|
||||
self = this,
|
||||
aRec = [],
|
||||
sEmail = '',
|
||||
aKeys = [],
|
||||
oEmail = new EmailModel();
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
|
||||
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;
|
||||
}));
|
||||
|
||||
if (oIdentity && oIdentity.email())
|
||||
{
|
||||
sEmail = oIdentity.email();
|
||||
aRec.unshift(sEmail);
|
||||
aKeys = PgpStore.findAllPrivateKeysByEmailNotNative(sEmail);
|
||||
if (aKeys && aKeys[0])
|
||||
{
|
||||
this.signKey({
|
||||
'users': aKeys[0].users || [sEmail],
|
||||
'hash': aKeys[0].id.substr(-8).toUpperCase(),
|
||||
'key': aKeys[0]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (this.signKey())
|
||||
{
|
||||
this.sign(true);
|
||||
}
|
||||
|
||||
if (aRec && 0 < aRec.length)
|
||||
{
|
||||
this.encryptKeys(_.uniq(_.compact(_.flatten(_.map(aRec, function(sRecEmail) {
|
||||
var keys = PgpStore.findAllPublicKeysByEmailNotNative(sRecEmail);
|
||||
return keys ? _.map(keys, function(oKey) {
|
||||
return {
|
||||
'empty': !oKey,
|
||||
'selected': ko.observable(!!oKey),
|
||||
'removable': ko.observable(!self.sign() || !self.signKey() || self.signKey().key.id !== oKey.id),
|
||||
'users': oKey ? (oKey.users || [sRecEmail]) : [sRecEmail],
|
||||
'hash': oKey ? oKey.id.substr(-8).toUpperCase() : '',
|
||||
'key': oKey
|
||||
};
|
||||
}) : [];
|
||||
}), true)), function(oEncryptKey) {
|
||||
return oEncryptKey.hash;
|
||||
}));
|
||||
|
||||
if (0 < this.encryptKeys().length)
|
||||
{
|
||||
this.encrypt(true);
|
||||
}
|
||||
}
|
||||
|
||||
this.text(sText);
|
||||
};
|
||||
|
||||
module.exports = ComposeOpenPgpPopupView;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,495 +1,486 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
CapaAdminStore = require('Stores/Admin/Capa'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
|
||||
CapaAdminStore = require('Stores/Admin/Capa'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomain');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.edit = ko.observable(false);
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.page = ko.observable('main');
|
||||
this.sieveSettings = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomain');
|
||||
this.testing = ko.observable(false);
|
||||
this.testingDone = ko.observable(false);
|
||||
this.testingImapError = ko.observable(false);
|
||||
this.testingSieveError = ko.observable(false);
|
||||
this.testingSmtpError = ko.observable(false);
|
||||
this.testingImapErrorDesc = ko.observable('');
|
||||
this.testingSieveErrorDesc = ko.observable('');
|
||||
this.testingSmtpErrorDesc = ko.observable('');
|
||||
|
||||
this.edit = ko.observable(false);
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.page = ko.observable('main');
|
||||
this.sieveSettings = ko.observable(false);
|
||||
|
||||
this.testing = ko.observable(false);
|
||||
this.testingDone = ko.observable(false);
|
||||
this.testingImapError = ko.observable(false);
|
||||
this.testingSieveError = ko.observable(false);
|
||||
this.testingSmtpError = ko.observable(false);
|
||||
this.testingImapErrorDesc = ko.observable('');
|
||||
this.testingSieveErrorDesc = ko.observable('');
|
||||
this.testingSmtpErrorDesc = ko.observable('');
|
||||
|
||||
this.testingImapError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingImapErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.testingSieveError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingSieveErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.testingSmtpError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.imapServerFocus = ko.observable(false);
|
||||
this.sieveServerFocus = 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.IMAP_DEFAULT_PORT);
|
||||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.useSieve = ko.observable(false);
|
||||
this.sieveAllowRaw = ko.observable(false);
|
||||
this.sieveServer = ko.observable('');
|
||||
this.sievePort = ko.observable('' + Consts.SIEVE_DEFAULT_PORT);
|
||||
this.sieveSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpServer = ko.observable('');
|
||||
this.smtpPort = ko.observable('' + Consts.SMTP_DEFAULT_PORT);
|
||||
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin = ko.observable(false);
|
||||
this.smtpAuth = ko.observable(true);
|
||||
this.smtpPhpMail = ko.observable(false);
|
||||
this.whiteList = ko.observable('');
|
||||
this.aliasName = ko.observable('');
|
||||
|
||||
this.enableSmartPorts = ko.observable(false);
|
||||
|
||||
this.allowSieve = ko.computed(function () {
|
||||
return CapaAdminStore.filters() && CapaAdminStore.sieve();
|
||||
}, this);
|
||||
|
||||
this.headerText = ko.computed(function () {
|
||||
|
||||
var
|
||||
sName = this.name(),
|
||||
sAliasName = this.aliasName(),
|
||||
sResult = ''
|
||||
;
|
||||
|
||||
if (this.edit())
|
||||
{
|
||||
sResult = Translator.i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', {'NAME': sName});
|
||||
if (sAliasName)
|
||||
{
|
||||
sResult += ' ← ' + sAliasName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = ('' === sName ? Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') :
|
||||
Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', {'NAME': sName}))
|
||||
;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
|
||||
}, this);
|
||||
|
||||
this.domainDesc = ko.computed(function () {
|
||||
var sName = this.name();
|
||||
return !this.edit() && sName ? Translator.i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', {'NAME': '*@' + sName}) : '';
|
||||
}, this);
|
||||
|
||||
this.domainIsComputed = ko.computed(function () {
|
||||
|
||||
var
|
||||
bPhpMail = this.smtpPhpMail(),
|
||||
bAllowSieve = this.allowSieve(),
|
||||
bUseSieve = this.useSieve()
|
||||
;
|
||||
|
||||
return '' !== this.name() &&
|
||||
'' !== this.imapServer() &&
|
||||
'' !== this.imapPort() &&
|
||||
(bAllowSieve && bUseSieve ? ('' !== this.sieveServer() && '' !== this.sievePort()) : true) &&
|
||||
(('' !== this.smtpServer() && '' !== this.smtpPort()) || bPhpMail);
|
||||
|
||||
}, 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.useSieve(),
|
||||
this.sieveAllowRaw(),
|
||||
this.sieveServer(),
|
||||
Utils.pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail(),
|
||||
|
||||
this.whiteList()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
this.testConnectionCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.page('main');
|
||||
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSieveError(false);
|
||||
this.testingSmtpError(false);
|
||||
this.testing(true);
|
||||
|
||||
Remote.testConnectionForDomain(
|
||||
_.bind(this.onTestConnectionResponse, this),
|
||||
this.name(),
|
||||
|
||||
this.imapServer(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveServer(),
|
||||
Utils.pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail()
|
||||
);
|
||||
}, this.canBeTested);
|
||||
|
||||
this.whiteListCommand = Utils.createCommand(this, function () {
|
||||
this.page('white-list');
|
||||
});
|
||||
|
||||
this.backCommand = Utils.createCommand(this, function () {
|
||||
this.page('main');
|
||||
});
|
||||
|
||||
this.sieveCommand = Utils.createCommand(this, function () {
|
||||
this.sieveSettings(!this.sieveSettings());
|
||||
this.clearTesting();
|
||||
});
|
||||
|
||||
this.page.subscribe(function () {
|
||||
this.sieveSettings(false);
|
||||
}, this);
|
||||
|
||||
// smart form improvements
|
||||
this.imapServerFocus.subscribe(function (bValue) {
|
||||
if (bValue && '' !== this.name() && '' === this.imapServer())
|
||||
{
|
||||
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.sieveServerFocus.subscribe(function (bValue) {
|
||||
if (bValue && '' !== this.imapServer() && '' === this.sieveServer())
|
||||
{
|
||||
this.sieveServer(this.imapServer());
|
||||
}
|
||||
}, 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) {
|
||||
if (this.enableSmartPorts())
|
||||
{
|
||||
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) {
|
||||
if (this.enableSmartPorts())
|
||||
{
|
||||
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(['View/Popup/Domain', 'PopupsDomainViewModel'], DomainPopupView);
|
||||
_.extend(DomainPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
DomainPopupView.prototype.onTestConnectionResponse = function (sResult, oData)
|
||||
{
|
||||
this.testing(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
this.testingImapError.subscribe(function(bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
var
|
||||
bImap = false,
|
||||
bSieve = false
|
||||
;
|
||||
this.testingImapErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.testingDone(true);
|
||||
this.testingImapError(true !== oData.Result.Imap);
|
||||
this.testingSieveError(true !== oData.Result.Sieve);
|
||||
this.testingSmtpError(true !== oData.Result.Smtp);
|
||||
this.testingSieveError.subscribe(function(bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingSieveErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (this.testingImapError() && oData.Result.Imap)
|
||||
{
|
||||
bImap = true;
|
||||
this.testingImapErrorDesc('');
|
||||
this.testingImapErrorDesc(oData.Result.Imap);
|
||||
}
|
||||
this.testingSmtpError.subscribe(function(bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (this.testingSieveError() && oData.Result.Sieve)
|
||||
{
|
||||
bSieve = true;
|
||||
this.testingSieveErrorDesc('');
|
||||
this.testingSieveErrorDesc(oData.Result.Sieve);
|
||||
}
|
||||
this.imapServerFocus = ko.observable(false);
|
||||
this.sieveServerFocus = ko.observable(false);
|
||||
this.smtpServerFocus = ko.observable(false);
|
||||
|
||||
if (this.testingSmtpError() && oData.Result.Smtp)
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
this.testingSmtpErrorDesc(oData.Result.Smtp);
|
||||
}
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
if (this.sieveSettings())
|
||||
this.imapServer = ko.observable('');
|
||||
this.imapPort = ko.observable('' + Consts.IMAP_DEFAULT_PORT);
|
||||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.useSieve = ko.observable(false);
|
||||
this.sieveAllowRaw = ko.observable(false);
|
||||
this.sieveServer = ko.observable('');
|
||||
this.sievePort = ko.observable('' + Consts.SIEVE_DEFAULT_PORT);
|
||||
this.sieveSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpServer = ko.observable('');
|
||||
this.smtpPort = ko.observable('' + Consts.SMTP_DEFAULT_PORT);
|
||||
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin = ko.observable(false);
|
||||
this.smtpAuth = ko.observable(true);
|
||||
this.smtpPhpMail = ko.observable(false);
|
||||
this.whiteList = ko.observable('');
|
||||
this.aliasName = ko.observable('');
|
||||
|
||||
this.enableSmartPorts = ko.observable(false);
|
||||
|
||||
this.allowSieve = ko.computed(function() {
|
||||
return CapaAdminStore.filters() && CapaAdminStore.sieve();
|
||||
}, this);
|
||||
|
||||
this.headerText = ko.computed(function() {
|
||||
|
||||
var
|
||||
sName = this.name(),
|
||||
sAliasName = this.aliasName(),
|
||||
sResult = '';
|
||||
|
||||
if (this.edit())
|
||||
{
|
||||
sResult = Translator.i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', {'NAME': sName});
|
||||
if (sAliasName)
|
||||
{
|
||||
if (!bSieve && bImap)
|
||||
{
|
||||
this.sieveSettings(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bSieve && !bImap)
|
||||
{
|
||||
this.sieveSettings(true);
|
||||
}
|
||||
sResult += ' ← ' + sAliasName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testingImapError(true);
|
||||
this.testingSieveError(true);
|
||||
this.testingSmtpError(true);
|
||||
this.sieveSettings(false);
|
||||
sResult = ('' === sName ? Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') :
|
||||
Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', {'NAME': sName}));
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onDomainCreateOrSaveResponse = function (sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
};
|
||||
return sResult;
|
||||
|
||||
}, this);
|
||||
|
||||
this.domainDesc = ko.computed(function() {
|
||||
var sName = this.name();
|
||||
return !this.edit() && sName ? Translator.i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', {'NAME': '*@' + sName}) : '';
|
||||
}, this);
|
||||
|
||||
this.domainIsComputed = ko.computed(function() {
|
||||
|
||||
var
|
||||
bPhpMail = this.smtpPhpMail(),
|
||||
bAllowSieve = this.allowSieve(),
|
||||
bUseSieve = this.useSieve();
|
||||
|
||||
return '' !== this.name() &&
|
||||
'' !== this.imapServer() &&
|
||||
'' !== this.imapPort() &&
|
||||
(bAllowSieve && bUseSieve ? ('' !== this.sieveServer() && '' !== this.sievePort()) : true) &&
|
||||
(('' !== this.smtpServer() && '' !== this.smtpPort()) || bPhpMail);
|
||||
|
||||
}, 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.useSieve(),
|
||||
this.sieveAllowRaw(),
|
||||
this.sieveServer(),
|
||||
Utils.pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail(),
|
||||
|
||||
this.whiteList()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
this.testConnectionCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.page('main');
|
||||
|
||||
DomainPopupView.prototype.clearTesting = function ()
|
||||
{
|
||||
this.testing(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSieveError(false);
|
||||
this.testingSmtpError(false);
|
||||
};
|
||||
this.testing(true);
|
||||
|
||||
DomainPopupView.prototype.onHide = function ()
|
||||
{
|
||||
Remote.testConnectionForDomain(
|
||||
_.bind(this.onTestConnectionResponse, this),
|
||||
this.name(),
|
||||
|
||||
this.imapServer(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveServer(),
|
||||
Utils.pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail()
|
||||
);
|
||||
}, this.canBeTested);
|
||||
|
||||
this.whiteListCommand = Utils.createCommand(this, function() {
|
||||
this.page('white-list');
|
||||
});
|
||||
|
||||
this.backCommand = Utils.createCommand(this, function() {
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
};
|
||||
|
||||
|
||||
DomainPopupView.prototype.onShow = function (oDomain)
|
||||
{
|
||||
this.saving(false);
|
||||
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
});
|
||||
|
||||
this.sieveCommand = Utils.createCommand(this, function() {
|
||||
this.sieveSettings(!this.sieveSettings());
|
||||
this.clearTesting();
|
||||
});
|
||||
|
||||
this.clearForm();
|
||||
if (oDomain)
|
||||
{
|
||||
this.enableSmartPorts(false);
|
||||
|
||||
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.useSieve(!!oDomain.UseSieve);
|
||||
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
|
||||
this.sieveServer(Utils.trim(oDomain.SieveHost));
|
||||
this.sievePort('' + Utils.pInt(oDomain.SievePort));
|
||||
this.sieveSecure(Utils.trim(oDomain.SieveSecure));
|
||||
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.smtpPhpMail(!!oDomain.OutUsePhpMail);
|
||||
this.whiteList(Utils.trim(oDomain.WhiteList));
|
||||
this.aliasName(Utils.trim(oDomain.AliasName));
|
||||
|
||||
this.enableSmartPorts(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if ('' === this.name() && !Globals.bMobile)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.clearForm = function ()
|
||||
{
|
||||
this.edit(false);
|
||||
|
||||
this.page('main');
|
||||
this.page.subscribe(function() {
|
||||
this.sieveSettings(false);
|
||||
}, this);
|
||||
|
||||
// smart form improvements
|
||||
this.imapServerFocus.subscribe(function(bValue) {
|
||||
if (bValue && '' !== this.name() && '' === this.imapServer())
|
||||
{
|
||||
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.sieveServerFocus.subscribe(function(bValue) {
|
||||
if (bValue && '' !== this.imapServer() && '' === this.sieveServer())
|
||||
{
|
||||
this.sieveServer(this.imapServer());
|
||||
}
|
||||
}, 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) {
|
||||
if (this.enableSmartPorts())
|
||||
{
|
||||
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;
|
||||
// no default
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.smtpSecure.subscribe(function(sValue) {
|
||||
if (this.enableSmartPorts())
|
||||
{
|
||||
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;
|
||||
// no default
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Domain', 'PopupsDomainViewModel'], DomainPopupView);
|
||||
_.extend(DomainPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
DomainPopupView.prototype.onTestConnectionResponse = function(sResult, oData)
|
||||
{
|
||||
this.testing(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
var
|
||||
bImap = false,
|
||||
bSieve = false;
|
||||
|
||||
this.testingDone(true);
|
||||
this.testingImapError(true !== oData.Result.Imap);
|
||||
this.testingSieveError(true !== oData.Result.Sieve);
|
||||
this.testingSmtpError(true !== oData.Result.Smtp);
|
||||
|
||||
if (this.testingImapError() && oData.Result.Imap)
|
||||
{
|
||||
bImap = true;
|
||||
this.testingImapErrorDesc('');
|
||||
this.testingImapErrorDesc(oData.Result.Imap);
|
||||
}
|
||||
|
||||
if (this.testingSieveError() && oData.Result.Sieve)
|
||||
{
|
||||
bSieve = true;
|
||||
this.testingSieveErrorDesc('');
|
||||
this.testingSieveErrorDesc(oData.Result.Sieve);
|
||||
}
|
||||
|
||||
if (this.testingSmtpError() && oData.Result.Smtp)
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
this.testingSmtpErrorDesc(oData.Result.Smtp);
|
||||
}
|
||||
|
||||
if (this.sieveSettings())
|
||||
{
|
||||
if (!bSieve && bImap)
|
||||
{
|
||||
this.sieveSettings(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bSieve && !bImap)
|
||||
{
|
||||
this.sieveSettings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testingImapError(true);
|
||||
this.testingSieveError(true);
|
||||
this.testingSmtpError(true);
|
||||
this.sieveSettings(false);
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onDomainCreateOrSaveResponse = function(sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.clearTesting = function()
|
||||
{
|
||||
this.testing(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSieveError(false);
|
||||
this.testingSmtpError(false);
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onHide = function()
|
||||
{
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
};
|
||||
|
||||
|
||||
DomainPopupView.prototype.onShow = function(oDomain)
|
||||
{
|
||||
this.saving(false);
|
||||
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
|
||||
this.clearTesting();
|
||||
|
||||
this.clearForm();
|
||||
if (oDomain)
|
||||
{
|
||||
this.enableSmartPorts(false);
|
||||
|
||||
this.savingError('');
|
||||
this.edit(true);
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
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.useSieve(!!oDomain.UseSieve);
|
||||
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
|
||||
this.sieveServer(Utils.trim(oDomain.SieveHost));
|
||||
this.sievePort('' + Utils.pInt(oDomain.SievePort));
|
||||
this.sieveSecure(Utils.trim(oDomain.SieveSecure));
|
||||
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.smtpPhpMail(!!oDomain.OutUsePhpMail);
|
||||
this.whiteList(Utils.trim(oDomain.WhiteList));
|
||||
this.aliasName(Utils.trim(oDomain.AliasName));
|
||||
|
||||
this.imapServer('');
|
||||
this.imapPort('' + Consts.IMAP_DEFAULT_PORT);
|
||||
this.imapSecure(Enums.ServerSecure.None);
|
||||
this.imapShortLogin(false);
|
||||
|
||||
this.useSieve(false);
|
||||
this.sieveAllowRaw(false);
|
||||
this.sieveServer('');
|
||||
this.sievePort('' + Consts.SIEVE_DEFAULT_PORT);
|
||||
this.sieveSecure(Enums.ServerSecure.None);
|
||||
|
||||
this.smtpServer('');
|
||||
this.smtpPort('' + Consts.SMTP_DEFAULT_PORT);
|
||||
this.smtpSecure(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin(false);
|
||||
this.smtpAuth(true);
|
||||
this.smtpPhpMail(false);
|
||||
|
||||
this.whiteList('');
|
||||
this.aliasName('');
|
||||
this.enableSmartPorts(true);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = DomainPopupView;
|
||||
DomainPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if ('' === this.name() && !Globals.bMobile)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
||||
DomainPopupView.prototype.clearForm = function()
|
||||
{
|
||||
this.edit(false);
|
||||
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
|
||||
this.enableSmartPorts(false);
|
||||
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.imapServer('');
|
||||
this.imapPort('' + Consts.IMAP_DEFAULT_PORT);
|
||||
this.imapSecure(Enums.ServerSecure.None);
|
||||
this.imapShortLogin(false);
|
||||
|
||||
this.useSieve(false);
|
||||
this.sieveAllowRaw(false);
|
||||
this.sieveServer('');
|
||||
this.sievePort('' + Consts.SIEVE_DEFAULT_PORT);
|
||||
this.sieveSecure(Enums.ServerSecure.None);
|
||||
|
||||
this.smtpServer('');
|
||||
this.smtpPort('' + Consts.SMTP_DEFAULT_PORT);
|
||||
this.smtpSecure(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin(false);
|
||||
this.smtpAuth(true);
|
||||
this.smtpPhpMail(false);
|
||||
|
||||
this.whiteList('');
|
||||
this.aliasName('');
|
||||
this.enableSmartPorts(true);
|
||||
};
|
||||
|
||||
module.exports = DomainPopupView;
|
||||
|
|
|
|||
|
|
@ -1,117 +1,110 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
DomainStore = require('Stores/Admin/Domain'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
|
||||
DomainStore = require('Stores/Admin/Domain'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainAliasPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomainAlias');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainAliasPopupView()
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.alias = ko.observable('');
|
||||
|
||||
this.domains = DomainStore.domainsWithoutAliases;
|
||||
|
||||
this.domainsOptions = ko.computed(function() {
|
||||
return _.map(this.domains(), function(item) {
|
||||
return {
|
||||
optValue: item.name,
|
||||
optText: item.name
|
||||
};
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.canBeSaved = ko.computed(function() {
|
||||
return !this.saving() && '' !== this.name() && '' !== this.alias();
|
||||
}, this);
|
||||
|
||||
this.createCommand = Utils.createCommand(this, function() {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(
|
||||
_.bind(this.onDomainAliasCreateOrSaveResponse, this),
|
||||
this.name(),
|
||||
this.alias()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/DomainAlias', 'PopupsDomainAliasViewModel'], DomainAliasPopupView);
|
||||
_.extend(DomainAliasPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
DomainAliasPopupView.prototype.onDomainAliasCreateOrSaveResponse = function(sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomainAlias');
|
||||
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.alias = ko.observable('');
|
||||
|
||||
this.domains = DomainStore.domainsWithoutAliases;
|
||||
|
||||
this.domainsOptions = ko.computed(function () {
|
||||
return _.map(this.domains(), function(item) {
|
||||
return {
|
||||
optValue: item.name,
|
||||
optText: item.name
|
||||
};
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.canBeSaved = ko.computed(function () {
|
||||
return !this.saving() && '' !== this.name() && '' !== this.alias();
|
||||
}, this);
|
||||
|
||||
this.createCommand = Utils.createCommand(this, function () {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(
|
||||
_.bind(this.onDomainAliasCreateOrSaveResponse, this),
|
||||
this.name(),
|
||||
this.alias()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/DomainAlias', 'PopupsDomainAliasViewModel'], DomainAliasPopupView);
|
||||
_.extend(DomainAliasPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
DomainAliasPopupView.prototype.onDomainAliasCreateOrSaveResponse = function (sResult, oData)
|
||||
else
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
};
|
||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShow = function ()
|
||||
DomainAliasPopupView.prototype.onShow = function()
|
||||
{
|
||||
this.clearForm();
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if ('' === this.name() && !Globals.bMobile)
|
||||
{
|
||||
this.clearForm();
|
||||
};
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if ('' === this.name() && !Globals.bMobile)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
DomainAliasPopupView.prototype.clearForm = function()
|
||||
{
|
||||
this.saving(false);
|
||||
this.savingError('');
|
||||
|
||||
DomainAliasPopupView.prototype.clearForm = function ()
|
||||
{
|
||||
this.saving(false);
|
||||
this.savingError('');
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
this.alias('');
|
||||
};
|
||||
|
||||
this.alias('');
|
||||
};
|
||||
|
||||
module.exports = DomainAliasPopupView;
|
||||
|
||||
}());
|
||||
module.exports = DomainAliasPopupView;
|
||||
|
|
|
|||
|
|
@ -1,210 +1,203 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
FilterStore = require('Stores/User/Filter'),
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
FilterStore = require('Stores/User/Filter'),
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FilterPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFilter');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.isNew = ko.observable(true);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FilterPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFilter');
|
||||
this.modules = FilterStore.modules;
|
||||
|
||||
this.isNew = ko.observable(true);
|
||||
this.fTrueCallback = null;
|
||||
this.filter = ko.observable(null);
|
||||
|
||||
this.modules = FilterStore.modules;
|
||||
this.allowMarkAsRead = ko.observable(false);
|
||||
|
||||
this.fTrueCallback = null;
|
||||
this.filter = ko.observable(null);
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
this.folderSelectList = FolderStore.folderMenuForFilters;
|
||||
this.selectedFolderValue = ko.observable('');
|
||||
|
||||
this.allowMarkAsRead = ko.observable(false);
|
||||
this.selectedFolderValue.subscribe(function() {
|
||||
if (this.filter())
|
||||
{
|
||||
this.filter().actionValue.error(false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
this.folderSelectList = FolderStore.folderMenuForFilters;
|
||||
this.selectedFolderValue = ko.observable('');
|
||||
this.saveFilter = Utils.createCommand(this, function() {
|
||||
|
||||
this.selectedFolderValue.subscribe(function() {
|
||||
if (this.filter())
|
||||
if (this.filter())
|
||||
{
|
||||
if (Enums.FiltersAction.MoveTo === this.filter().actionType())
|
||||
{
|
||||
this.filter().actionValue.error(false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.saveFilter = Utils.createCommand(this, function () {
|
||||
|
||||
if (this.filter())
|
||||
{
|
||||
if (Enums.FiltersAction.MoveTo === this.filter().actionType())
|
||||
{
|
||||
this.filter().actionValue(this.selectedFolderValue());
|
||||
}
|
||||
|
||||
if (!this.filter().verify())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.fTrueCallback)
|
||||
{
|
||||
this.fTrueCallback(this.filter());
|
||||
}
|
||||
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
Utils.delegateRun(this, 'closeCommand');
|
||||
}
|
||||
this.filter().actionValue(this.selectedFolderValue());
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
if (!this.filter().verify())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.actionTypeOptions = ko.observableArray([]);
|
||||
this.fieldOptions = ko.observableArray([]);
|
||||
this.typeOptions = ko.observableArray([]);
|
||||
this.typeOptionsSize = ko.observableArray([]);
|
||||
if (this.fTrueCallback)
|
||||
{
|
||||
this.fTrueCallback(this.filter());
|
||||
}
|
||||
|
||||
Translator.initOnStartOrLangChange(this.populateOptions, this);
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
Utils.delegateRun(this, 'closeCommand');
|
||||
}
|
||||
}
|
||||
|
||||
this.modules.subscribe(this.populateOptions, this);
|
||||
return true;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
this.actionTypeOptions = ko.observableArray([]);
|
||||
this.fieldOptions = ko.observableArray([]);
|
||||
this.typeOptions = ko.observableArray([]);
|
||||
this.typeOptionsSize = ko.observableArray([]);
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Filter', 'PopupsFilterViewModel'], FilterPopupView);
|
||||
_.extend(FilterPopupView.prototype, AbstractView.prototype);
|
||||
Translator.initOnStartOrLangChange(this.populateOptions, this);
|
||||
|
||||
FilterPopupView.prototype.populateOptions = function ()
|
||||
{
|
||||
this.actionTypeOptions([]);
|
||||
this.modules.subscribe(this.populateOptions, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Filter', 'PopupsFilterViewModel'], FilterPopupView);
|
||||
_.extend(FilterPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FilterPopupView.prototype.populateOptions = function()
|
||||
{
|
||||
this.actionTypeOptions([]);
|
||||
|
||||
// this.actionTypeOptions.push({'id': Enums.FiltersAction.None,
|
||||
// 'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_NONE')});
|
||||
|
||||
var oModules = this.modules();
|
||||
if (oModules)
|
||||
{
|
||||
if (oModules.markasread)
|
||||
{
|
||||
this.allowMarkAsRead(true);
|
||||
}
|
||||
|
||||
if (oModules.moveto)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.MoveTo,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_MOVE_TO')});
|
||||
}
|
||||
|
||||
if (oModules.redirect)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Forward,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_FORWARD_TO')});
|
||||
}
|
||||
|
||||
if (oModules.reject)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Reject,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_REJECT')});
|
||||
}
|
||||
|
||||
if (oModules.vacation)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Vacation,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_VACATION_MESSAGE')});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Discard,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_DISCARD')});
|
||||
|
||||
this.fieldOptions([
|
||||
{'id': Enums.FilterConditionField.From, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_FROM')},
|
||||
{'id': Enums.FilterConditionField.Recipient, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')},
|
||||
{'id': Enums.FilterConditionField.Subject, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')},
|
||||
{'id': Enums.FilterConditionField.Size, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SIZE')},
|
||||
{'id': Enums.FilterConditionField.Header, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_HEADER')}
|
||||
]);
|
||||
|
||||
this.typeOptions([
|
||||
{'id': Enums.FilterConditionType.Contains, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_CONTAINS')},
|
||||
{'id': Enums.FilterConditionType.NotContains, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_CONTAINS')},
|
||||
{'id': Enums.FilterConditionType.EqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')},
|
||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
|
||||
]);
|
||||
|
||||
if (oModules && oModules.regex)
|
||||
{
|
||||
this.typeOptions.push({'id': Enums.FilterConditionType.Regex, 'name': 'Regex'});
|
||||
}
|
||||
|
||||
this.typeOptionsSize([
|
||||
{'id': Enums.FilterConditionType.Over, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
|
||||
{'id': Enums.FilterConditionType.Under, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
FilterPopupView.prototype.removeCondition = function (oConditionToDelete)
|
||||
var oModules = this.modules();
|
||||
if (oModules)
|
||||
{
|
||||
if (this.filter())
|
||||
if (oModules.markasread)
|
||||
{
|
||||
this.filter().removeCondition(oConditionToDelete);
|
||||
this.allowMarkAsRead(true);
|
||||
}
|
||||
};
|
||||
|
||||
FilterPopupView.prototype.clearPopup = function ()
|
||||
if (oModules.moveto)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.MoveTo,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_MOVE_TO')});
|
||||
}
|
||||
|
||||
if (oModules.redirect)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Forward,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_FORWARD_TO')});
|
||||
}
|
||||
|
||||
if (oModules.reject)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Reject,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_REJECT')});
|
||||
}
|
||||
|
||||
if (oModules.vacation)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Vacation,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_VACATION_MESSAGE')});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Discard,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_DISCARD')});
|
||||
|
||||
this.fieldOptions([
|
||||
{'id': Enums.FilterConditionField.From, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_FROM')},
|
||||
{'id': Enums.FilterConditionField.Recipient, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')},
|
||||
{'id': Enums.FilterConditionField.Subject, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')},
|
||||
{'id': Enums.FilterConditionField.Size, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SIZE')},
|
||||
{'id': Enums.FilterConditionField.Header, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_HEADER')}
|
||||
]);
|
||||
|
||||
this.typeOptions([
|
||||
{'id': Enums.FilterConditionType.Contains, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_CONTAINS')},
|
||||
{'id': Enums.FilterConditionType.NotContains, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_CONTAINS')},
|
||||
{'id': Enums.FilterConditionType.EqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')},
|
||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
|
||||
]);
|
||||
|
||||
if (oModules && oModules.regex)
|
||||
{
|
||||
this.isNew(true);
|
||||
this.typeOptions.push({'id': Enums.FilterConditionType.Regex, 'name': 'Regex'});
|
||||
}
|
||||
|
||||
this.fTrueCallback = null;
|
||||
this.filter(null);
|
||||
};
|
||||
this.typeOptionsSize([
|
||||
{'id': Enums.FilterConditionType.Over, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
|
||||
{'id': Enums.FilterConditionType.Under, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
|
||||
]);
|
||||
};
|
||||
|
||||
FilterPopupView.prototype.onShow = function (oFilter, fTrueCallback, bEdit)
|
||||
|
||||
FilterPopupView.prototype.removeCondition = function(oConditionToDelete)
|
||||
{
|
||||
if (this.filter())
|
||||
{
|
||||
this.clearPopup();
|
||||
this.filter().removeCondition(oConditionToDelete);
|
||||
}
|
||||
};
|
||||
|
||||
this.fTrueCallback = fTrueCallback;
|
||||
this.filter(oFilter);
|
||||
FilterPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.isNew(true);
|
||||
|
||||
if (oFilter)
|
||||
{
|
||||
this.selectedFolderValue(oFilter.actionValue());
|
||||
}
|
||||
this.fTrueCallback = null;
|
||||
this.filter(null);
|
||||
};
|
||||
|
||||
this.isNew(!bEdit);
|
||||
FilterPopupView.prototype.onShow = function(oFilter, fTrueCallback, bEdit)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
if (!bEdit && oFilter)
|
||||
{
|
||||
oFilter.name.focused(true);
|
||||
}
|
||||
};
|
||||
this.fTrueCallback = fTrueCallback;
|
||||
this.filter(oFilter);
|
||||
|
||||
FilterPopupView.prototype.onShowWithDelay = function ()
|
||||
if (oFilter)
|
||||
{
|
||||
if (this.isNew() && this.filter() && !Globals.bMobile)
|
||||
{
|
||||
this.filter().name.focused(true);
|
||||
}
|
||||
};
|
||||
this.selectedFolderValue(oFilter.actionValue());
|
||||
}
|
||||
|
||||
module.exports = FilterPopupView;
|
||||
this.isNew(!bEdit);
|
||||
|
||||
}());
|
||||
if (!bEdit && oFilter)
|
||||
{
|
||||
oFilter.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
FilterPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (this.isNew() && this.filter() && !Globals.bMobile)
|
||||
{
|
||||
this.filter().name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FilterPopupView;
|
||||
|
|
|
|||
|
|
@ -1,127 +1,118 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Cache = require('Common/Cache'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
|
||||
Cache = require('Common/Cache'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderClearPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderClear');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.selectedFolder = ko.observable(null);
|
||||
this.clearingProcess = ko.observable(false);
|
||||
this.clearingError = ko.observable('');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderClearPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderClear');
|
||||
this.folderFullNameForClear = ko.computed(function() {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.printableFullName() : '';
|
||||
}, this);
|
||||
|
||||
this.selectedFolder = ko.observable(null);
|
||||
this.clearingProcess = ko.observable(false);
|
||||
this.clearingError = ko.observable('');
|
||||
this.folderNameForClear = ko.computed(function() {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.localName() : '';
|
||||
}, this);
|
||||
|
||||
this.folderFullNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.printableFullName() : '';
|
||||
}, this);
|
||||
this.dangerDescHtml = ko.computed(function() {
|
||||
return Translator.i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', {
|
||||
'FOLDER': this.folderNameForClear()
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.folderNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.localName() : '';
|
||||
}, this);
|
||||
this.clearCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.dangerDescHtml = ko.computed(function () {
|
||||
return Translator.i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', {
|
||||
'FOLDER': this.folderNameForClear()
|
||||
});
|
||||
}, this);
|
||||
var
|
||||
self = this,
|
||||
oFolderToClear = this.selectedFolder();
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
if (oFolderToClear)
|
||||
{
|
||||
MessageStore.message(null);
|
||||
MessageStore.messageList([]);
|
||||
|
||||
var
|
||||
self = this,
|
||||
oFolderToClear = this.selectedFolder()
|
||||
;
|
||||
this.clearingProcess(true);
|
||||
|
||||
if (oFolderToClear)
|
||||
{
|
||||
MessageStore.message(null);
|
||||
MessageStore.messageList([]);
|
||||
oFolderToClear.messageCountAll(0);
|
||||
oFolderToClear.messageCountUnread(0);
|
||||
|
||||
this.clearingProcess(true);
|
||||
Cache.setFolderHash(oFolderToClear.fullNameRaw, '');
|
||||
|
||||
oFolderToClear.messageCountAll(0);
|
||||
oFolderToClear.messageCountUnread(0);
|
||||
Remote.folderClear(function(sResult, oData) {
|
||||
|
||||
Cache.setFolderHash(oFolderToClear.fullNameRaw, '');
|
||||
|
||||
Remote.folderClear(function (sResult, oData) {
|
||||
|
||||
self.clearingProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
self.clearingProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
require('App/User').default.reloadMessageList(true);
|
||||
self.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
require('App/User').default.reloadMessageList(true);
|
||||
self.cancelCommand();
|
||||
self.clearingError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
self.clearingError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
self.clearingError(Translator.getNotification(Enums.Notification.MailServerError));
|
||||
}
|
||||
self.clearingError(Translator.getNotification(Enums.Notification.MailServerError));
|
||||
}
|
||||
}, oFolderToClear.fullNameRaw);
|
||||
}
|
||||
|
||||
}, function () {
|
||||
|
||||
var
|
||||
oFolder = this.selectedFolder(),
|
||||
bIsClearing = this.clearingProcess()
|
||||
;
|
||||
|
||||
return !bIsClearing && null !== oFolder;
|
||||
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/FolderClear', 'PopupsFolderClearViewModel'], FolderClearPopupView);
|
||||
_.extend(FolderClearPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderClearPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.clearingProcess(false);
|
||||
this.selectedFolder(null);
|
||||
};
|
||||
|
||||
FolderClearPopupView.prototype.onShow = function (oFolder)
|
||||
{
|
||||
this.clearPopup();
|
||||
if (oFolder)
|
||||
{
|
||||
this.selectedFolder(oFolder);
|
||||
}
|
||||
}, oFolderToClear.fullNameRaw);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderClearPopupView;
|
||||
}, function() {
|
||||
|
||||
}());
|
||||
var
|
||||
oFolder = this.selectedFolder(),
|
||||
bIsClearing = this.clearingProcess();
|
||||
|
||||
return !bIsClearing && null !== oFolder;
|
||||
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/FolderClear', 'PopupsFolderClearViewModel'], FolderClearPopupView);
|
||||
_.extend(FolderClearPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderClearPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.clearingProcess(false);
|
||||
this.selectedFolder(null);
|
||||
};
|
||||
|
||||
FolderClearPopupView.prototype.onShow = function(oFolder)
|
||||
{
|
||||
this.clearPopup();
|
||||
if (oFolder)
|
||||
{
|
||||
this.selectedFolder(oFolder);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderClearPopupView;
|
||||
|
|
|
|||
|
|
@ -1,120 +1,111 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Promises = require('Promises/User/Ajax'),
|
||||
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Promises = require('Promises/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderCreateView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderCreate');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.folderName = ko.observable('');
|
||||
this.folderName.focused = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderCreateView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderCreate');
|
||||
this.selectedParentValue = ko.observable(Consts.UNUSED_OPTION_VALUE);
|
||||
|
||||
this.folderName = ko.observable('');
|
||||
this.folderName.focused = ko.observable(false);
|
||||
this.parentFolderSelectList = ko.computed(function() {
|
||||
|
||||
this.selectedParentValue = ko.observable(Consts.UNUSED_OPTION_VALUE);
|
||||
var
|
||||
aTop = [],
|
||||
fDisableCallback = null,
|
||||
fVisibleCallback = null,
|
||||
aList = FolderStore.folderList(),
|
||||
fRenameCallback = function(oItem) {
|
||||
return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '';
|
||||
};
|
||||
|
||||
this.parentFolderSelectList = ko.computed(function () {
|
||||
aTop.push(['', '']);
|
||||
|
||||
var
|
||||
aTop = [],
|
||||
fDisableCallback = null,
|
||||
fVisibleCallback = null,
|
||||
aList = FolderStore.folderList(),
|
||||
fRenameCallback = function (oItem) {
|
||||
return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '';
|
||||
}
|
||||
;
|
||||
|
||||
aTop.push(['', '']);
|
||||
|
||||
if ('' !== FolderStore.namespace)
|
||||
{
|
||||
fDisableCallback = function (oItem)
|
||||
{
|
||||
return FolderStore.namespace !== oItem.fullNameRaw.substr(0, FolderStore.namespace.length);
|
||||
};
|
||||
}
|
||||
|
||||
return Utils.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback);
|
||||
|
||||
}, this);
|
||||
|
||||
// commands
|
||||
this.createFolder = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
sParentFolderName = this.selectedParentValue()
|
||||
;
|
||||
|
||||
if ('' === sParentFolderName && 1 < FolderStore.namespace.length)
|
||||
{
|
||||
sParentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1);
|
||||
}
|
||||
|
||||
require('App/User').default.foldersPromisesActionHelper(
|
||||
Promises.folderCreate(this.folderName(), sParentFolderName, FolderStore.foldersCreating),
|
||||
Enums.Notification.CantCreateFolder
|
||||
);
|
||||
|
||||
this.cancelCommand();
|
||||
|
||||
}, function () {
|
||||
return this.simpleFolderNameValidation(this.folderName());
|
||||
});
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/FolderCreate', 'PopupsFolderCreateViewModel'], FolderCreateView);
|
||||
_.extend(FolderCreateView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderCreateView.prototype.simpleFolderNameValidation = function (sName)
|
||||
{
|
||||
return (/^[^\\\/]+$/g).test(Utils.trim(sName));
|
||||
};
|
||||
|
||||
FolderCreateView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.folderName('');
|
||||
this.selectedParentValue('');
|
||||
this.folderName.focused(false);
|
||||
};
|
||||
|
||||
FolderCreateView.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
FolderCreateView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if (!Globals.bMobile)
|
||||
if ('' !== FolderStore.namespace)
|
||||
{
|
||||
this.folderName.focused(true);
|
||||
fDisableCallback = function(oItem)
|
||||
{
|
||||
return FolderStore.namespace !== oItem.fullNameRaw.substr(0, FolderStore.namespace.length);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderCreateView;
|
||||
return Utils.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback);
|
||||
|
||||
}());
|
||||
}, this);
|
||||
|
||||
// commands
|
||||
this.createFolder = Utils.createCommand(this, function() {
|
||||
|
||||
var
|
||||
sParentFolderName = this.selectedParentValue();
|
||||
|
||||
if ('' === sParentFolderName && 1 < FolderStore.namespace.length)
|
||||
{
|
||||
sParentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1);
|
||||
}
|
||||
|
||||
require('App/User').default.foldersPromisesActionHelper(
|
||||
Promises.folderCreate(this.folderName(), sParentFolderName, FolderStore.foldersCreating),
|
||||
Enums.Notification.CantCreateFolder
|
||||
);
|
||||
|
||||
this.cancelCommand();
|
||||
|
||||
}, function() {
|
||||
return this.simpleFolderNameValidation(this.folderName());
|
||||
});
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/FolderCreate', 'PopupsFolderCreateViewModel'], FolderCreateView);
|
||||
_.extend(FolderCreateView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderCreateView.prototype.simpleFolderNameValidation = function(sName)
|
||||
{
|
||||
return (/^[^\\\/]+$/g).test(Utils.trim(sName));
|
||||
};
|
||||
|
||||
FolderCreateView.prototype.clearPopup = function()
|
||||
{
|
||||
this.folderName('');
|
||||
this.selectedParentValue('');
|
||||
this.folderName.focused(false);
|
||||
};
|
||||
|
||||
FolderCreateView.prototype.onShow = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
FolderCreateView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (!Globals.bMobile)
|
||||
{
|
||||
this.folderName.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderCreateView;
|
||||
|
|
|
|||
|
|
@ -1,137 +1,130 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderSystemPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderSystem');
|
||||
|
||||
Translator.initOnStartOrLangChange(function() {
|
||||
this.sChooseOnText = Translator.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
|
||||
this.sUnuseText = Translator.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
|
||||
}, this);
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.folderSelectList = ko.computed(function() {
|
||||
return Utils.folderListOptionsBuilder([], FolderStore.folderList(), FolderStore.folderListSystemNames(), [
|
||||
['', this.sChooseOnText],
|
||||
[Consts.UNUSED_OPTION_VALUE, this.sUnuseText]
|
||||
], null, null, null, null, null, true);
|
||||
}, this);
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
fSaveSystemFolders = null,
|
||||
fCallback = null;
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
this.sentFolder = FolderStore.sentFolder;
|
||||
this.draftFolder = FolderStore.draftFolder;
|
||||
this.spamFolder = FolderStore.spamFolder;
|
||||
this.trashFolder = FolderStore.trashFolder;
|
||||
this.archiveFolder = FolderStore.archiveFolder;
|
||||
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
fSaveSystemFolders = _.debounce(function() {
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
Settings.settingsSet('SentFolder', FolderStore.sentFolder());
|
||||
Settings.settingsSet('DraftFolder', FolderStore.draftFolder());
|
||||
Settings.settingsSet('SpamFolder', FolderStore.spamFolder());
|
||||
Settings.settingsSet('TrashFolder', FolderStore.trashFolder());
|
||||
Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder());
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
Remote.saveSystemFolders(Utils.noop, {
|
||||
'SentFolder': FolderStore.sentFolder(),
|
||||
'DraftFolder': FolderStore.draftFolder(),
|
||||
'SpamFolder': FolderStore.spamFolder(),
|
||||
'TrashFolder': FolderStore.trashFolder(),
|
||||
'ArchiveFolder': FolderStore.archiveFolder(),
|
||||
'NullFolder': 'NullFolder'
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderSystemPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderSystem');
|
||||
}, 1000);
|
||||
|
||||
Translator.initOnStartOrLangChange(function () {
|
||||
this.sChooseOnText = Translator.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
|
||||
this.sUnuseText = Translator.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
|
||||
}, this);
|
||||
fCallback = function() {
|
||||
|
||||
this.notification = ko.observable('');
|
||||
Settings.settingsSet('SentFolder', FolderStore.sentFolder());
|
||||
Settings.settingsSet('DraftFolder', FolderStore.draftFolder());
|
||||
Settings.settingsSet('SpamFolder', FolderStore.spamFolder());
|
||||
Settings.settingsSet('TrashFolder', FolderStore.trashFolder());
|
||||
Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder());
|
||||
|
||||
this.folderSelectList = ko.computed(function () {
|
||||
return Utils.folderListOptionsBuilder([], FolderStore.folderList(), FolderStore.folderListSystemNames(), [
|
||||
['', this.sChooseOnText],
|
||||
[Consts.UNUSED_OPTION_VALUE, this.sUnuseText]
|
||||
], null, null, null, null, null, true);
|
||||
}, this);
|
||||
|
||||
var
|
||||
fSaveSystemFolders = null,
|
||||
fCallback = null
|
||||
;
|
||||
|
||||
this.sentFolder = FolderStore.sentFolder;
|
||||
this.draftFolder = FolderStore.draftFolder;
|
||||
this.spamFolder = FolderStore.spamFolder;
|
||||
this.trashFolder = FolderStore.trashFolder;
|
||||
this.archiveFolder = FolderStore.archiveFolder;
|
||||
|
||||
fSaveSystemFolders = _.debounce(function () {
|
||||
|
||||
Settings.settingsSet('SentFolder', FolderStore.sentFolder());
|
||||
Settings.settingsSet('DraftFolder', FolderStore.draftFolder());
|
||||
Settings.settingsSet('SpamFolder', FolderStore.spamFolder());
|
||||
Settings.settingsSet('TrashFolder', FolderStore.trashFolder());
|
||||
Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder());
|
||||
|
||||
Remote.saveSystemFolders(Utils.noop, {
|
||||
'SentFolder': FolderStore.sentFolder(),
|
||||
'DraftFolder': FolderStore.draftFolder(),
|
||||
'SpamFolder': FolderStore.spamFolder(),
|
||||
'TrashFolder': FolderStore.trashFolder(),
|
||||
'ArchiveFolder': FolderStore.archiveFolder(),
|
||||
'NullFolder': 'NullFolder'
|
||||
});
|
||||
|
||||
}, 1000);
|
||||
|
||||
fCallback = function () {
|
||||
|
||||
Settings.settingsSet('SentFolder', FolderStore.sentFolder());
|
||||
Settings.settingsSet('DraftFolder', FolderStore.draftFolder());
|
||||
Settings.settingsSet('SpamFolder', FolderStore.spamFolder());
|
||||
Settings.settingsSet('TrashFolder', FolderStore.trashFolder());
|
||||
Settings.settingsSet('ArchiveFolder', FolderStore.archiveFolder());
|
||||
|
||||
fSaveSystemFolders();
|
||||
};
|
||||
|
||||
FolderStore.sentFolder.subscribe(fCallback);
|
||||
FolderStore.draftFolder.subscribe(fCallback);
|
||||
FolderStore.spamFolder.subscribe(fCallback);
|
||||
FolderStore.trashFolder.subscribe(fCallback);
|
||||
FolderStore.archiveFolder.subscribe(fCallback);
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/FolderSystem', 'PopupsFolderSystemViewModel'], FolderSystemPopupView);
|
||||
_.extend(FolderSystemPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderSystemPopupView.prototype.sChooseOnText = '';
|
||||
FolderSystemPopupView.prototype.sUnuseText = '';
|
||||
|
||||
/**
|
||||
* @param {number=} iNotificationType = Enums.SetSystemFoldersNotification.None
|
||||
*/
|
||||
FolderSystemPopupView.prototype.onShow = function (iNotificationType)
|
||||
{
|
||||
var sNotification = '';
|
||||
|
||||
iNotificationType = Utils.isUnd(iNotificationType) ? Enums.SetSystemFoldersNotification.None : iNotificationType;
|
||||
|
||||
switch (iNotificationType)
|
||||
{
|
||||
case Enums.SetSystemFoldersNotification.Sent:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Draft:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Spam:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Trash:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Archive:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE');
|
||||
break;
|
||||
}
|
||||
|
||||
this.notification(sNotification);
|
||||
fSaveSystemFolders();
|
||||
};
|
||||
|
||||
module.exports = FolderSystemPopupView;
|
||||
FolderStore.sentFolder.subscribe(fCallback);
|
||||
FolderStore.draftFolder.subscribe(fCallback);
|
||||
FolderStore.spamFolder.subscribe(fCallback);
|
||||
FolderStore.trashFolder.subscribe(fCallback);
|
||||
FolderStore.archiveFolder.subscribe(fCallback);
|
||||
|
||||
}());
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/FolderSystem', 'PopupsFolderSystemViewModel'], FolderSystemPopupView);
|
||||
_.extend(FolderSystemPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderSystemPopupView.prototype.sChooseOnText = '';
|
||||
FolderSystemPopupView.prototype.sUnuseText = '';
|
||||
|
||||
/**
|
||||
* @param {number=} iNotificationType = Enums.SetSystemFoldersNotification.None
|
||||
*/
|
||||
FolderSystemPopupView.prototype.onShow = function(iNotificationType)
|
||||
{
|
||||
var sNotification = '';
|
||||
|
||||
iNotificationType = Utils.isUnd(iNotificationType) ? Enums.SetSystemFoldersNotification.None : iNotificationType;
|
||||
|
||||
switch (iNotificationType)
|
||||
{
|
||||
case Enums.SetSystemFoldersNotification.Sent:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Draft:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Spam:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Trash:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Archive:
|
||||
sNotification = Translator.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE');
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
|
||||
this.notification(sNotification);
|
||||
};
|
||||
|
||||
module.exports = FolderSystemPopupView;
|
||||
|
|
|
|||
|
|
@ -1,204 +1,197 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function IdentityPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsIdentity');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function IdentityPopupView()
|
||||
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.signature = ko.observable('');
|
||||
this.signatureInsertBefore = ko.observable(false);
|
||||
|
||||
this.showBcc = ko.observable(false);
|
||||
this.showReplyTo = ko.observable(false);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.bcc.subscribe(function(aValue) {
|
||||
if (false === self.showBcc() && 0 < aValue.length)
|
||||
{
|
||||
self.showBcc(true);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.replyTo.subscribe(function(aValue) {
|
||||
if (false === self.showReplyTo() && 0 < aValue.length)
|
||||
{
|
||||
self.showReplyTo(true);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.addOrEditIdentityCommand = Utils.createCommand(this, function() {
|
||||
|
||||
if (this.signature && this.signature.__fetchEditorValue)
|
||||
{
|
||||
this.signature.__fetchEditorValue();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.identityUpdate(_.bind(function(sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/User').default.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.id, this.email(), this.name(), this.replyTo(), this.bcc(),
|
||||
this.signature(), this.signatureInsertBefore());
|
||||
|
||||
return true;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Identity', 'PopupsIdentityViewModel'], IdentityPopupView);
|
||||
_.extend(IdentityPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
IdentityPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.id = '';
|
||||
this.edit(false);
|
||||
this.owner(false);
|
||||
|
||||
this.name('');
|
||||
this.email('');
|
||||
this.replyTo('');
|
||||
this.bcc('');
|
||||
this.signature('');
|
||||
this.signatureInsertBefore(false);
|
||||
|
||||
this.email.hasError(false);
|
||||
this.replyTo.hasError(false);
|
||||
this.bcc.hasError(false);
|
||||
|
||||
this.showBcc(false);
|
||||
this.showReplyTo(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?IdentityModel} oIdentity
|
||||
*/
|
||||
IdentityPopupView.prototype.onShow = function(oIdentity)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
if (oIdentity)
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsIdentity');
|
||||
this.edit(true);
|
||||
|
||||
var self = this;
|
||||
this.id = oIdentity.id() || '';
|
||||
this.name(oIdentity.name());
|
||||
this.email(oIdentity.email());
|
||||
this.replyTo(oIdentity.replyTo());
|
||||
this.bcc(oIdentity.bcc());
|
||||
this.signature(oIdentity.signature());
|
||||
this.signatureInsertBefore(oIdentity.signatureInsertBefore());
|
||||
|
||||
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.signature = ko.observable('');
|
||||
this.signatureInsertBefore = ko.observable(false);
|
||||
|
||||
this.showBcc = ko.observable(false);
|
||||
this.showReplyTo = ko.observable(false);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.bcc.subscribe(function (aValue) {
|
||||
if (false === self.showBcc() && 0 < aValue.length)
|
||||
{
|
||||
self.showBcc(true);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.replyTo.subscribe(function (aValue) {
|
||||
if (false === self.showReplyTo() && 0 < aValue.length)
|
||||
{
|
||||
self.showReplyTo(true);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.addOrEditIdentityCommand = Utils.createCommand(this, function () {
|
||||
|
||||
if (this.signature && this.signature.__fetchEditorValue)
|
||||
{
|
||||
this.signature.__fetchEditorValue();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.identityUpdate(_.bind(function (sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/User').default.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.id, this.email(), this.name(), this.replyTo(), this.bcc(),
|
||||
this.signature(), this.signatureInsertBefore());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
this.owner('' === this.id);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Identity', 'PopupsIdentityViewModel'], IdentityPopupView);
|
||||
_.extend(IdentityPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
IdentityPopupView.prototype.clearPopup = function ()
|
||||
else
|
||||
{
|
||||
this.id = '';
|
||||
this.edit(false);
|
||||
this.owner(false);
|
||||
this.id = Utils.fakeMd5();
|
||||
}
|
||||
};
|
||||
|
||||
this.name('');
|
||||
this.email('');
|
||||
this.replyTo('');
|
||||
this.bcc('');
|
||||
this.signature('');
|
||||
this.signatureInsertBefore(false);
|
||||
|
||||
this.email.hasError(false);
|
||||
this.replyTo.hasError(false);
|
||||
this.bcc.hasError(false);
|
||||
|
||||
this.showBcc(false);
|
||||
this.showReplyTo(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?IdentityModel} oIdentity
|
||||
*/
|
||||
IdentityPopupView.prototype.onShow = function (oIdentity)
|
||||
IdentityPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (!this.owner() && !Globals.bMobile)
|
||||
{
|
||||
this.clearPopup();
|
||||
this.email.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
if (oIdentity)
|
||||
{
|
||||
this.edit(true);
|
||||
IdentityPopupView.prototype.onHideWithDelay = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
this.id = oIdentity.id() || '';
|
||||
this.name(oIdentity.name());
|
||||
this.email(oIdentity.email());
|
||||
this.replyTo(oIdentity.replyTo());
|
||||
this.bcc(oIdentity.bcc());
|
||||
this.signature(oIdentity.signature());
|
||||
this.signatureInsertBefore(oIdentity.signatureInsertBefore());
|
||||
|
||||
this.owner(this.id === '');
|
||||
}
|
||||
else
|
||||
{
|
||||
this.id = Utils.fakeMd5();
|
||||
}
|
||||
};
|
||||
|
||||
IdentityPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if (!this.owner() && !Globals.bMobile)
|
||||
{
|
||||
this.email.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
IdentityPopupView.prototype.onHideWithDelay = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
module.exports = IdentityPopupView;
|
||||
|
||||
}());
|
||||
module.exports = IdentityPopupView;
|
||||
|
|
|
|||
|
|
@ -1,64 +1,56 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
key = require('key'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
key = require('key'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function KeyboardShortcutsHelpPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupKeyboardShortcutsHelp;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function KeyboardShortcutsHelpPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp');
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupKeyboardShortcutsHelp;
|
||||
kn.extendAsViewModel(['View/Popup/KeyboardShortcutsHelp', 'PopupsKeyboardShortcutsHelpViewModel'], KeyboardShortcutsHelpPopupView);
|
||||
_.extend(KeyboardShortcutsHelpPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
KeyboardShortcutsHelpPopupView.prototype.onBuild = function(oDom)
|
||||
{
|
||||
key('tab, shift+tab, left, right', Enums.KeyState.PopupKeyboardShortcutsHelp, _.throttle(_.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'));
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/KeyboardShortcutsHelp', 'PopupsKeyboardShortcutsHelpViewModel'], KeyboardShortcutsHelpPopupView);
|
||||
_.extend(KeyboardShortcutsHelpPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
KeyboardShortcutsHelpPopupView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
key('tab, shift+tab, left, right', Enums.KeyState.PopupKeyboardShortcutsHelp, _.throttle(_.bind(function (event, handler) {
|
||||
if (event && handler)
|
||||
if (!bNext && 0 < iIndex)
|
||||
{
|
||||
var
|
||||
$tabs = oDom.find('.nav.nav-tabs > li'),
|
||||
bNext = handler && ('tab' === handler.shortcut || 'right' === handler.shortcut),
|
||||
iIndex = $tabs.index($tabs.filter('.active'))
|
||||
;
|
||||
|
||||
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;
|
||||
iIndex -= 1;
|
||||
}
|
||||
else if (bNext && iIndex < $tabs.length - 1)
|
||||
{
|
||||
iIndex += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
iIndex = bNext ? 0 : $tabs.length - 1;
|
||||
}
|
||||
}, this), 100));
|
||||
};
|
||||
|
||||
module.exports = KeyboardShortcutsHelpPopupView;
|
||||
$tabs.eq(iIndex).find('a[data-toggle="tab"]').tab('show');
|
||||
return false;
|
||||
}
|
||||
}, this), 100));
|
||||
};
|
||||
|
||||
}());
|
||||
module.exports = KeyboardShortcutsHelpPopupView;
|
||||
|
|
|
|||
|
|
@ -1,95 +1,88 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LanguagesPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsLanguages');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LanguagesPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsLanguages');
|
||||
this.fLang = null;
|
||||
this.userLanguage = ko.observable('');
|
||||
|
||||
var self = this;
|
||||
this.langs = ko.observableArray([]);
|
||||
|
||||
this.fLang = null;
|
||||
this.userLanguage = ko.observable('');
|
||||
|
||||
this.langs = ko.observableArray([]);
|
||||
|
||||
this.languages = ko.computed(function () {
|
||||
var sUserLanguage = self.userLanguage();
|
||||
return _.map(self.langs(), function (sLanguage) {
|
||||
return {
|
||||
'key': sLanguage,
|
||||
'user': sLanguage === sUserLanguage,
|
||||
'selected': ko.observable(false),
|
||||
'fullName': Utils.convertLangName(sLanguage)
|
||||
};
|
||||
});
|
||||
this.languages = ko.computed(function() {
|
||||
var sUserLanguage = self.userLanguage();
|
||||
return _.map(self.langs(), function(sLanguage) {
|
||||
return {
|
||||
'key': sLanguage,
|
||||
'user': sLanguage === sUserLanguage,
|
||||
'selected': ko.observable(false),
|
||||
'fullName': Utils.convertLangName(sLanguage)
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
this.langs.subscribe(function () {
|
||||
this.setLanguageSelection();
|
||||
}, this);
|
||||
this.langs.subscribe(function() {
|
||||
this.setLanguageSelection();
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Languages', 'PopupsLanguagesViewModel'], LanguagesPopupView);
|
||||
_.extend(LanguagesPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
LanguagesPopupView.prototype.languageTooltipName = function(sLanguage)
|
||||
{
|
||||
var sResult = Utils.convertLangName(sLanguage, true);
|
||||
return Utils.convertLangName(sLanguage, false) === sResult ? '' : sResult;
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.setLanguageSelection = function()
|
||||
{
|
||||
var currentLang = this.fLang ? ko.unwrap(this.fLang) : '';
|
||||
_.each(this.languages(), function(item) {
|
||||
item.selected(item.key === currentLang);
|
||||
});
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.onBeforeShow = function()
|
||||
{
|
||||
this.fLang = null;
|
||||
this.userLanguage('');
|
||||
|
||||
this.langs([]);
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.onShow = function(fLanguage, aLangs, sUserLanguage)
|
||||
{
|
||||
this.fLang = fLanguage;
|
||||
this.userLanguage(sUserLanguage || '');
|
||||
|
||||
this.langs(aLangs);
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.changeLanguage = function(sLang)
|
||||
{
|
||||
if (this.fLang)
|
||||
{
|
||||
this.fLang(sLang);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Languages', 'PopupsLanguagesViewModel'], LanguagesPopupView);
|
||||
_.extend(LanguagesPopupView.prototype, AbstractView.prototype);
|
||||
this.cancelCommand();
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.languageTooltipName = function (sLanguage)
|
||||
{
|
||||
var sResult = Utils.convertLangName(sLanguage, true);
|
||||
return Utils.convertLangName(sLanguage, false) === sResult ? '' : sResult;
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.setLanguageSelection = function ()
|
||||
{
|
||||
var currentLang = this.fLang ? ko.unwrap(this.fLang) : '';
|
||||
_.each(this.languages(), function (item) {
|
||||
item.selected(item.key === currentLang);
|
||||
});
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.onBeforeShow = function ()
|
||||
{
|
||||
this.fLang = null;
|
||||
this.userLanguage('');
|
||||
|
||||
this.langs([]);
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.onShow = function (fLanguage, aLangs, sUserLanguage)
|
||||
{
|
||||
this.fLang = fLanguage;
|
||||
this.userLanguage(sUserLanguage || '');
|
||||
|
||||
this.langs(aLangs);
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.changeLanguage = function (sLang)
|
||||
{
|
||||
if (this.fLang)
|
||||
{
|
||||
this.fLang(sLang);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
};
|
||||
|
||||
module.exports = LanguagesPopupView;
|
||||
|
||||
}());
|
||||
module.exports = LanguagesPopupView;
|
||||
|
|
|
|||
|
|
@ -1,53 +1,47 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
$ = require('$'),
|
||||
|
||||
'use strict';
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
$ = require('$'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MessageOpenPgpPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsMessageOpenPgp');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.notification = ko.observable('');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MessageOpenPgpPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsMessageOpenPgp');
|
||||
this.selectedKey = ko.observable(null);
|
||||
this.privateKeys = ko.observableArray([]);
|
||||
|
||||
this.notification = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
|
||||
this.selectedKey = ko.observable(null);
|
||||
this.privateKeys = ko.observableArray([]);
|
||||
this.resultCallback = null;
|
||||
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
this.resultCallback = null;
|
||||
// commands
|
||||
this.doCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitRequest(true);
|
||||
|
||||
// commands
|
||||
this.doCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
_.delay(_.bind(function() {
|
||||
_.delay(_.bind(function() {
|
||||
|
||||
var
|
||||
oPrivateKeys = [],
|
||||
oPrivateKey = null
|
||||
;
|
||||
oPrivateKey = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -89,99 +83,95 @@ _.delay(_.bind(function() {
|
|||
this.cancelCommand();
|
||||
this.resultCallback(oPrivateKey);
|
||||
|
||||
}, this), 100);
|
||||
}, this), 100);
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
}, function() {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupMessageOpenPGP;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupMessageOpenPGP;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/MessageOpenPgp'], MessageOpenPgpPopupView);
|
||||
_.extend(MessageOpenPgpPopupView.prototype, AbstractView.prototype);
|
||||
kn.extendAsViewModel(['View/Popup/MessageOpenPgp'], MessageOpenPgpPopupView);
|
||||
_.extend(MessageOpenPgpPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
MessageOpenPgpPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.notification('');
|
||||
MessageOpenPgpPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.notification('');
|
||||
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
|
||||
this.selectedKey(false);
|
||||
this.submitRequest(false);
|
||||
this.selectedKey(false);
|
||||
this.submitRequest(false);
|
||||
|
||||
this.resultCallback = null;
|
||||
this.privateKeys([]);
|
||||
};
|
||||
this.resultCallback = null;
|
||||
this.privateKeys([]);
|
||||
};
|
||||
|
||||
MessageOpenPgpPopupView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
key('tab,shift+tab', Enums.KeyState.PopupMessageOpenPGP, _.bind(function () {
|
||||
MessageOpenPgpPopupView.prototype.onBuild = function(oDom)
|
||||
{
|
||||
key('tab,shift+tab', Enums.KeyState.PopupMessageOpenPGP, _.bind(function() {
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case this.password.focus():
|
||||
this.buttonFocus(true);
|
||||
break;
|
||||
case this.buttonFocus():
|
||||
this.password.focus(true);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}, this));
|
||||
|
||||
var self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.key-list__item', function () {
|
||||
|
||||
oDom.find('.key-list__item .key-list__item__radio')
|
||||
.addClass('icon-radio-unchecked')
|
||||
.removeClass('icon-radio-checked')
|
||||
;
|
||||
|
||||
$(this).find('.key-list__item__radio')
|
||||
.removeClass('icon-radio-unchecked')
|
||||
.addClass('icon-radio-checked')
|
||||
;
|
||||
|
||||
self.selectedKey(ko.dataFor(this));
|
||||
|
||||
self.password.focus(true);
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
MessageOpenPgpPopupView.prototype.onHideWithDelay = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
MessageOpenPgpPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
this.password.focus(true);
|
||||
// this.buttonFocus(true);
|
||||
};
|
||||
|
||||
MessageOpenPgpPopupView.prototype.onShow = function (fCallback, aPrivateKeys)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
this.privateKeys(aPrivateKeys);
|
||||
|
||||
if (this.viewModelDom)
|
||||
switch (true)
|
||||
{
|
||||
this.viewModelDom.find('.key-list__item').first().click();
|
||||
case this.password.focus():
|
||||
this.buttonFocus(true);
|
||||
break;
|
||||
case this.buttonFocus():
|
||||
this.password.focus(true);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = MessageOpenPgpPopupView;
|
||||
return false;
|
||||
|
||||
}());
|
||||
}, this));
|
||||
|
||||
var self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.key-list__item', function() {
|
||||
|
||||
oDom.find('.key-list__item .key-list__item__radio')
|
||||
.addClass('icon-radio-unchecked')
|
||||
.removeClass('icon-radio-checked');
|
||||
|
||||
$(this).find('.key-list__item__radio')
|
||||
.removeClass('icon-radio-unchecked')
|
||||
.addClass('icon-radio-checked');
|
||||
|
||||
self.selectedKey(ko.dataFor(this));
|
||||
|
||||
self.password.focus(true);
|
||||
});
|
||||
};
|
||||
|
||||
MessageOpenPgpPopupView.prototype.onHideWithDelay = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
MessageOpenPgpPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.password.focus(true);
|
||||
// this.buttonFocus(true);
|
||||
};
|
||||
|
||||
MessageOpenPgpPopupView.prototype.onShow = function(fCallback, aPrivateKeys)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
this.privateKeys(aPrivateKeys);
|
||||
|
||||
if (this.viewModelDom)
|
||||
{
|
||||
this.viewModelDom.find('.key-list__item').first().click();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = MessageOpenPgpPopupView;
|
||||
|
|
|
|||
|
|
@ -1,132 +1,124 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function NewOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsNewOpenPgpKey');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.email = ko.observable('');
|
||||
this.email.focus = ko.observable('');
|
||||
this.email.error = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function NewOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsNewOpenPgpKey');
|
||||
this.name = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.keyBitLength = ko.observable(2048);
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.email.focus = ko.observable('');
|
||||
this.email.error = ko.observable(false);
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.keyBitLength = ko.observable(2048);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.email.error(false);
|
||||
}, this);
|
||||
|
||||
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
oUserId = {},
|
||||
oOpenpgpKeyring = PgpStore.openpgpKeyring
|
||||
;
|
||||
|
||||
this.email.error('' === Utils.trim(this.email()));
|
||||
if (!oOpenpgpKeyring || this.email.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
oUserId.email = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
oUserId.name = this.name();
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
var mPromise = false;
|
||||
|
||||
try {
|
||||
|
||||
mPromise = PgpStore.openpgp.generateKey({
|
||||
userIds: [oUserId],
|
||||
numBits: Utils.pInt(self.keyBitLength()),
|
||||
passphrase: Utils.trim(self.password())
|
||||
});
|
||||
|
||||
mPromise.then(function (mKeyPair) {
|
||||
|
||||
self.submitRequest(false);
|
||||
|
||||
if (mKeyPair && mKeyPair.privateKeyArmored)
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored);
|
||||
oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored);
|
||||
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
|
||||
}).then(null, function() {
|
||||
self.submitRequest(false);
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
self.submitRequest(false);
|
||||
}
|
||||
|
||||
}, 100);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], NewOpenPgpKeyPopupView);
|
||||
_.extend(NewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.name('');
|
||||
this.password('');
|
||||
|
||||
this.email('');
|
||||
this.email.subscribe(function() {
|
||||
this.email.error(false);
|
||||
this.keyBitLength(2048);
|
||||
};
|
||||
}, this);
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function() {
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
this.email.focus(true);
|
||||
};
|
||||
var
|
||||
self = this,
|
||||
oUserId = {},
|
||||
oOpenpgpKeyring = PgpStore.openpgpKeyring;
|
||||
|
||||
module.exports = NewOpenPgpKeyPopupView;
|
||||
this.email.error('' === Utils.trim(this.email()));
|
||||
if (!oOpenpgpKeyring || this.email.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}());
|
||||
oUserId.email = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
oUserId.name = this.name();
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
_.delay(function() {
|
||||
|
||||
var mPromise = false;
|
||||
|
||||
try {
|
||||
|
||||
mPromise = PgpStore.openpgp.generateKey({
|
||||
userIds: [oUserId],
|
||||
numBits: Utils.pInt(self.keyBitLength()),
|
||||
passphrase: Utils.trim(self.password())
|
||||
});
|
||||
|
||||
mPromise.then(function(mKeyPair) {
|
||||
|
||||
self.submitRequest(false);
|
||||
|
||||
if (mKeyPair && mKeyPair.privateKeyArmored)
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored);
|
||||
oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored);
|
||||
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
|
||||
}).then(null, function() {
|
||||
self.submitRequest(false);
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
self.submitRequest(false);
|
||||
}
|
||||
|
||||
}, 100);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], NewOpenPgpKeyPopupView);
|
||||
_.extend(NewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.name('');
|
||||
this.password('');
|
||||
|
||||
this.email('');
|
||||
this.email.error(false);
|
||||
this.keyBitLength(2048);
|
||||
};
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.onShow = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
NewOpenPgpKeyPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.email.focus(true);
|
||||
};
|
||||
|
||||
module.exports = NewOpenPgpKeyPopupView;
|
||||
|
|
|
|||
|
|
@ -1,175 +1,167 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PluginPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsPlugin');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PluginPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsPlugin');
|
||||
this.onPluginSettingsUpdateResponse = _.bind(this.onPluginSettingsUpdateResponse, this);
|
||||
|
||||
var self = this;
|
||||
this.saveError = ko.observable('');
|
||||
|
||||
this.onPluginSettingsUpdateResponse = _.bind(this.onPluginSettingsUpdateResponse, this);
|
||||
this.name = ko.observable('');
|
||||
this.readme = ko.observable('');
|
||||
|
||||
this.saveError = ko.observable('');
|
||||
this.configures = ko.observableArray([]);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.readme = ko.observable('');
|
||||
this.hasReadme = ko.computed(function() {
|
||||
return '' !== this.readme();
|
||||
}, this);
|
||||
|
||||
this.configures = ko.observableArray([]);
|
||||
this.hasConfiguration = ko.computed(function() {
|
||||
return 0 < this.configures().length;
|
||||
}, this);
|
||||
|
||||
this.hasReadme = ko.computed(function () {
|
||||
return '' !== this.readme();
|
||||
}, this);
|
||||
|
||||
this.hasConfiguration = ko.computed(function () {
|
||||
return 0 < this.configures().length;
|
||||
}, this);
|
||||
|
||||
this.readmePopoverConf = {
|
||||
'placement': 'right',
|
||||
'trigger': 'hover',
|
||||
this.readmePopoverConf = {
|
||||
'placement': 'right',
|
||||
'trigger': 'hover',
|
||||
// 'trigger': 'click',
|
||||
'title': Translator.i18n('POPUPS_PLUGIN/TOOLTIP_ABOUT_TITLE'),
|
||||
'container': 'body',
|
||||
'html': true,
|
||||
'content': function () {
|
||||
return '<pre>' + self.readme() + '</pre>';
|
||||
'title': Translator.i18n('POPUPS_PLUGIN/TOOLTIP_ABOUT_TITLE'),
|
||||
'container': 'body',
|
||||
'html': true,
|
||||
'content': function() {
|
||||
return '<pre>' + self.readme() + '</pre>';
|
||||
// .replace(/[\r]/g, '').replace(/[\n]/g, '<br />').replace(/[\t]/g, ' ');
|
||||
}
|
||||
};
|
||||
|
||||
this.saveCommand = Utils.createCommand(this, function() {
|
||||
|
||||
var list = {};
|
||||
|
||||
list.Name = this.name();
|
||||
|
||||
_.each(this.configures(), function(oItem) {
|
||||
|
||||
var value = oItem.value();
|
||||
if (false === value || true === value)
|
||||
{
|
||||
value = value ? '1' : '0';
|
||||
}
|
||||
};
|
||||
|
||||
this.saveCommand = Utils.createCommand(this, function () {
|
||||
list['_' + oItem.Name] = value;
|
||||
|
||||
var list = {};
|
||||
}, this);
|
||||
|
||||
list.Name = this.name();
|
||||
this.saveError('');
|
||||
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list);
|
||||
|
||||
_.each(this.configures(), function (oItem) {
|
||||
}, this.hasConfiguration);
|
||||
|
||||
var value = oItem.value();
|
||||
if (false === value || true === value)
|
||||
{
|
||||
value = value ? '1' : '0';
|
||||
}
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.All;
|
||||
|
||||
list['_' + oItem.Name] = value;
|
||||
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
|
||||
|
||||
}, this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
this.saveError('');
|
||||
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list);
|
||||
kn.extendAsViewModel(['View/Popup/Plugin', 'PopupsPluginViewModel'], PluginPopupView);
|
||||
_.extend(PluginPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
}, this.hasConfiguration);
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.All;
|
||||
|
||||
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Plugin', 'PopupsPluginViewModel'], PluginPopupView);
|
||||
_.extend(PluginPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
PluginPopupView.prototype.onPluginSettingsUpdateResponse = function (sResult, oData)
|
||||
PluginPopupView.prototype.onPluginSettingsUpdateResponse = function(sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
this.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveError('');
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
this.cancelCommand();
|
||||
this.saveError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveError('');
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
this.saveError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveError(Translator.getNotification(Enums.Notification.CantSavePluginSettings));
|
||||
}
|
||||
this.saveError(Translator.getNotification(Enums.Notification.CantSavePluginSettings));
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
PluginPopupView.prototype.onShow = function (oPlugin)
|
||||
PluginPopupView.prototype.onShow = function(oPlugin)
|
||||
{
|
||||
this.name();
|
||||
this.readme();
|
||||
this.configures([]);
|
||||
|
||||
if (oPlugin)
|
||||
{
|
||||
this.name();
|
||||
this.readme();
|
||||
this.configures([]);
|
||||
this.name(oPlugin.Name);
|
||||
this.readme(oPlugin.Readme);
|
||||
|
||||
if (oPlugin)
|
||||
var aConfig = oPlugin.Config;
|
||||
if (Utils.isNonEmptyArray(aConfig))
|
||||
{
|
||||
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]),
|
||||
'placeholder': ko.observable(aItem[6]),
|
||||
'Name': aItem[1],
|
||||
'Type': aItem[2],
|
||||
'Label': aItem[3],
|
||||
'Default': aItem[4],
|
||||
'Desc': aItem[5]
|
||||
};
|
||||
}));
|
||||
}
|
||||
this.configures(_.map(aConfig, function(aItem) {
|
||||
return {
|
||||
'value': ko.observable(aItem[0]),
|
||||
'placeholder': ko.observable(aItem[6]),
|
||||
'Name': aItem[1],
|
||||
'Type': aItem[2],
|
||||
'Label': aItem[3],
|
||||
'Default': aItem[4],
|
||||
'Desc': aItem[5]
|
||||
};
|
||||
}));
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
PluginPopupView.prototype.tryToClosePopup = function ()
|
||||
PluginPopupView.prototype.tryToClosePopup = function()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
PopupsAskViewModel = require('View/Popup/Ask');
|
||||
|
||||
if (!kn.isPopupVisible(PopupsAskViewModel))
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
PopupsAskViewModel = require('View/Popup/Ask')
|
||||
;
|
||||
kn.showScreenPopup(PopupsAskViewModel, [Translator.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function() {
|
||||
if (self.modalVisibility())
|
||||
{
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
}]);
|
||||
}
|
||||
};
|
||||
|
||||
if (!kn.isPopupVisible(PopupsAskViewModel))
|
||||
PluginPopupView.prototype.onBuild = function()
|
||||
{
|
||||
key('esc', Enums.KeyState.All, _.bind(function() {
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
kn.showScreenPopup(PopupsAskViewModel, [Translator.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
|
||||
if (self.modalVisibility())
|
||||
{
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
}]);
|
||||
this.tryToClosePopup();
|
||||
}
|
||||
};
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
|
||||
PluginPopupView.prototype.onBuild = function ()
|
||||
{
|
||||
key('esc', Enums.KeyState.All, _.bind(function () {
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
this.tryToClosePopup();
|
||||
}
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
|
||||
module.exports = PluginPopupView;
|
||||
|
||||
}());
|
||||
module.exports = PluginPopupView;
|
||||
|
|
|
|||
|
|
@ -1,205 +1,198 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
HtmlEditor = require('Common/HtmlEditor'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
HtmlEditor = require('Common/HtmlEditor'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function TemplatePopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsTemplate');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.editor = null;
|
||||
this.signatureDom = ko.observable(null);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function TemplatePopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsTemplate');
|
||||
this.id = ko.observable('');
|
||||
|
||||
this.editor = null;
|
||||
this.signatureDom = ko.observable(null);
|
||||
this.name = ko.observable('');
|
||||
this.name.error = ko.observable(false);
|
||||
this.name.focus = ko.observable(false);
|
||||
|
||||
this.id = ko.observable('');
|
||||
this.body = ko.observable('');
|
||||
this.body.loading = ko.observable(false);
|
||||
this.body.error = ko.observable(false);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.name.error = ko.observable(false);
|
||||
this.name.focus = ko.observable(false);
|
||||
|
||||
this.body = ko.observable('');
|
||||
this.body.loading = ko.observable(false);
|
||||
this.body.error = ko.observable(false);
|
||||
|
||||
this.name.subscribe(function () {
|
||||
this.name.error(false);
|
||||
}, this);
|
||||
|
||||
this.body.subscribe(function () {
|
||||
this.body.error(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.addTemplateCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.populateBodyFromEditor();
|
||||
|
||||
this.name.error('' === Utils.trim(this.name()));
|
||||
this.body.error('' === Utils.trim(this.body()) ||
|
||||
':HTML:' === Utils.trim(this.body()));
|
||||
|
||||
if (this.name.error() || this.body.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.templateSetup(_.bind(function (sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/User').default.templates();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.id(), this.name(), this.body());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Template'], TemplatePopupView);
|
||||
_.extend(TemplatePopupView.prototype, AbstractView.prototype);
|
||||
|
||||
TemplatePopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.id('');
|
||||
|
||||
this.name('');
|
||||
this.name.subscribe(function() {
|
||||
this.name.error(false);
|
||||
}, this);
|
||||
|
||||
this.body('');
|
||||
this.body.loading(false);
|
||||
this.body.subscribe(function() {
|
||||
this.body.error(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
if (this.editor)
|
||||
this.addTemplateCommand = Utils.createCommand(this, function() {
|
||||
|
||||
this.populateBodyFromEditor();
|
||||
|
||||
this.name.error('' === Utils.trim(this.name()));
|
||||
this.body.error('' === Utils.trim(this.body()) ||
|
||||
':HTML:' === Utils.trim(this.body()));
|
||||
|
||||
if (this.name.error() || this.body.error())
|
||||
{
|
||||
this.editor.setPlain('', false);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
TemplatePopupView.prototype.populateBodyFromEditor = function ()
|
||||
{
|
||||
if (this.editor)
|
||||
{
|
||||
this.body(this.editor.getDataWithHtmlMark());
|
||||
}
|
||||
};
|
||||
this.submitRequest(true);
|
||||
|
||||
TemplatePopupView.prototype.editorSetBody = function (sBody)
|
||||
{
|
||||
if (!this.editor && this.signatureDom())
|
||||
{
|
||||
var self = this;
|
||||
this.editor = new HtmlEditor(self.signatureDom(), function () {
|
||||
self.populateBodyFromEditor();
|
||||
}, function () {
|
||||
self.editor.setHtmlOrPlain(sBody);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.editor.setHtmlOrPlain(sBody);
|
||||
}
|
||||
};
|
||||
Remote.templateSetup(_.bind(function(sResult, oData) {
|
||||
|
||||
TemplatePopupView.prototype.onShow = function (oTemplate)
|
||||
{
|
||||
var self = this;
|
||||
|
||||
this.clearPopup();
|
||||
|
||||
if (oTemplate && oTemplate.id)
|
||||
{
|
||||
this.id(oTemplate.id);
|
||||
this.name(oTemplate.name);
|
||||
this.body(oTemplate.body);
|
||||
|
||||
if (oTemplate.populated)
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
self.editorSetBody(this.body());
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/User').default.templates();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.body.loading(true);
|
||||
self.body.error(false);
|
||||
|
||||
Remote.templateGetById(function (sResult, oData) {
|
||||
|
||||
self.body.loading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
'Object/Template' === oData.Result['@Object'] && Utils.isNormal(oData.Result.Body))
|
||||
{
|
||||
oTemplate.body = oData.Result.Body;
|
||||
oTemplate.populated = true;
|
||||
|
||||
self.body(oTemplate.body);
|
||||
self.body.error(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.body('');
|
||||
self.body.error(true);
|
||||
}
|
||||
|
||||
self.editorSetBody(self.body());
|
||||
|
||||
}, this.id());
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.id(), this.name(), this.body());
|
||||
|
||||
return true;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Template'], TemplatePopupView);
|
||||
_.extend(TemplatePopupView.prototype, AbstractView.prototype);
|
||||
|
||||
TemplatePopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.id('');
|
||||
|
||||
this.name('');
|
||||
this.name.error(false);
|
||||
|
||||
this.body('');
|
||||
this.body.loading(false);
|
||||
this.body.error(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
|
||||
if (this.editor)
|
||||
{
|
||||
this.editor.setPlain('', false);
|
||||
}
|
||||
};
|
||||
|
||||
TemplatePopupView.prototype.populateBodyFromEditor = function()
|
||||
{
|
||||
if (this.editor)
|
||||
{
|
||||
this.body(this.editor.getDataWithHtmlMark());
|
||||
}
|
||||
};
|
||||
|
||||
TemplatePopupView.prototype.editorSetBody = function(sBody)
|
||||
{
|
||||
if (!this.editor && this.signatureDom())
|
||||
{
|
||||
var self = this;
|
||||
this.editor = new HtmlEditor(self.signatureDom(), function() {
|
||||
self.populateBodyFromEditor();
|
||||
}, function() {
|
||||
self.editor.setHtmlOrPlain(sBody);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.editor.setHtmlOrPlain(sBody);
|
||||
}
|
||||
};
|
||||
|
||||
TemplatePopupView.prototype.onShow = function(oTemplate)
|
||||
{
|
||||
var self = this;
|
||||
|
||||
this.clearPopup();
|
||||
|
||||
if (oTemplate && oTemplate.id)
|
||||
{
|
||||
this.id(oTemplate.id);
|
||||
this.name(oTemplate.name);
|
||||
this.body(oTemplate.body);
|
||||
|
||||
if (oTemplate.populated)
|
||||
{
|
||||
self.editorSetBody(this.body());
|
||||
}
|
||||
else
|
||||
{
|
||||
self.editorSetBody('');
|
||||
this.body.loading(true);
|
||||
self.body.error(false);
|
||||
|
||||
Remote.templateGetById(function(sResult, oData) {
|
||||
|
||||
self.body.loading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
'Object/Template' === oData.Result['@Object'] && Utils.isNormal(oData.Result.Body))
|
||||
{
|
||||
oTemplate.body = oData.Result.Body;
|
||||
oTemplate.populated = true;
|
||||
|
||||
self.body(oTemplate.body);
|
||||
self.body.error(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.body('');
|
||||
self.body.error(true);
|
||||
}
|
||||
|
||||
self.editorSetBody(self.body());
|
||||
|
||||
}, this.id());
|
||||
}
|
||||
};
|
||||
|
||||
TemplatePopupView.prototype.onShowWithDelay = function ()
|
||||
}
|
||||
else
|
||||
{
|
||||
this.name.focus(true);
|
||||
};
|
||||
self.editorSetBody('');
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = TemplatePopupView;
|
||||
TemplatePopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.name.focus(true);
|
||||
};
|
||||
|
||||
}());
|
||||
module.exports = TemplatePopupView;
|
||||
|
|
|
|||
|
|
@ -1,249 +1,242 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
qr = require('qr'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
qr = require('qr'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function TwoFactorConfigurationPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsTwoFactorConfiguration');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.lock = ko.observable(false);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function TwoFactorConfigurationPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsTwoFactorConfiguration');
|
||||
this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor);
|
||||
|
||||
this.lock = ko.observable(false);
|
||||
this.processing = ko.observable(false);
|
||||
this.clearing = ko.observable(false);
|
||||
this.secreting = ko.observable(false);
|
||||
|
||||
this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor);
|
||||
this.viewUser = ko.observable('');
|
||||
this.twoFactorStatus = ko.observable(false);
|
||||
|
||||
this.processing = ko.observable(false);
|
||||
this.clearing = ko.observable(false);
|
||||
this.secreting = ko.observable(false);
|
||||
this.twoFactorTested = ko.observable(false);
|
||||
|
||||
this.viewUser = ko.observable('');
|
||||
this.twoFactorStatus = ko.observable(false);
|
||||
this.viewSecret = ko.observable('');
|
||||
this.viewBackupCodes = ko.observable('');
|
||||
this.viewUrlTitle = ko.observable('');
|
||||
this.viewUrl = ko.observable('');
|
||||
|
||||
this.twoFactorTested = ko.observable(false);
|
||||
this.viewEnable_ = ko.observable(false);
|
||||
|
||||
this.viewSecret = ko.observable('');
|
||||
this.viewBackupCodes = ko.observable('');
|
||||
this.viewUrlTitle = ko.observable('');
|
||||
this.viewUrl = ko.observable('');
|
||||
this.viewEnable = ko.computed({
|
||||
'owner': this,
|
||||
'read': this.viewEnable_,
|
||||
'write': function(bValue) {
|
||||
|
||||
this.viewEnable_ = ko.observable(false);
|
||||
var self = this;
|
||||
|
||||
this.viewEnable = ko.computed({
|
||||
'owner': this,
|
||||
'read': this.viewEnable_,
|
||||
'write': function (bValue) {
|
||||
bValue = !!bValue;
|
||||
|
||||
var self = this;
|
||||
if (bValue && this.twoFactorTested())
|
||||
{
|
||||
this.viewEnable_(bValue);
|
||||
|
||||
bValue = !!bValue;
|
||||
|
||||
if (bValue && this.twoFactorTested())
|
||||
{
|
||||
this.viewEnable_(bValue);
|
||||
|
||||
Remote.enableTwoFactor(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
self.viewEnable_(false);
|
||||
}
|
||||
|
||||
}, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bValue)
|
||||
Remote.enableTwoFactor(function(sResult, oData) {
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
this.viewEnable_(bValue);
|
||||
self.viewEnable_(false);
|
||||
}
|
||||
|
||||
Remote.enableTwoFactor(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
self.viewEnable_(false);
|
||||
}
|
||||
|
||||
}, false);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
else
|
||||
{
|
||||
if (!bValue)
|
||||
{
|
||||
this.viewEnable_(bValue);
|
||||
}
|
||||
|
||||
this.viewTwoFactorEnableTooltip = ko.computed(function () {
|
||||
Translator.trigger();
|
||||
return this.twoFactorTested() || this.viewEnable_() ? '' :
|
||||
Translator.i18n('POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_TEST_BEFORE_DESC');
|
||||
}, this);
|
||||
Remote.enableTwoFactor(function(sResult, oData) {
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
self.viewEnable_(false);
|
||||
}
|
||||
|
||||
this.viewTwoFactorStatus = ko.computed(function () {
|
||||
Translator.trigger();
|
||||
return Translator.i18n(
|
||||
this.twoFactorStatus() ?
|
||||
'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_CONFIGURED_DESC' :
|
||||
'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC'
|
||||
);
|
||||
}, this);
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.twoFactorAllowedEnable = ko.computed(function () {
|
||||
return this.viewEnable() || this.twoFactorTested();
|
||||
}, this);
|
||||
this.viewTwoFactorEnableTooltip = ko.computed(function() {
|
||||
Translator.trigger();
|
||||
return this.twoFactorTested() || this.viewEnable_() ? '' :
|
||||
Translator.i18n('POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_TEST_BEFORE_DESC');
|
||||
}, this);
|
||||
|
||||
this.onResult = _.bind(this.onResult, this);
|
||||
this.onShowSecretResult = _.bind(this.onShowSecretResult, this);
|
||||
this.viewTwoFactorStatus = ko.computed(function() {
|
||||
Translator.trigger();
|
||||
return Translator.i18n(
|
||||
this.twoFactorStatus() ?
|
||||
'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_CONFIGURED_DESC' :
|
||||
'POPUPS_TWO_FACTOR_CFG/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC'
|
||||
);
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
this.twoFactorAllowedEnable = ko.computed(function() {
|
||||
return this.viewEnable() || this.twoFactorTested();
|
||||
}, this);
|
||||
|
||||
this.onResult = _.bind(this.onResult, this);
|
||||
this.onShowSecretResult = _.bind(this.onShowSecretResult, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/TwoFactorConfiguration', 'TwoFactorConfigurationPopupView'], TwoFactorConfigurationPopupView);
|
||||
_.extend(TwoFactorConfigurationPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.showSecret = function()
|
||||
{
|
||||
this.secreting(true);
|
||||
Remote.showTwoFactorSecret(this.onShowSecretResult);
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.hideSecret = function()
|
||||
{
|
||||
this.viewSecret('');
|
||||
this.viewBackupCodes('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.createTwoFactor = function()
|
||||
{
|
||||
this.processing(true);
|
||||
Remote.createTwoFactor(this.onResult);
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.logout = function()
|
||||
{
|
||||
require('App/User').default.logout();
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.testTwoFactor = function()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorTest'), [this.twoFactorTested]);
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.clearTwoFactor = function()
|
||||
{
|
||||
this.viewSecret('');
|
||||
this.viewBackupCodes('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
|
||||
this.twoFactorTested(false);
|
||||
|
||||
this.clearing(true);
|
||||
Remote.clearTwoFactor(this.onResult);
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.onShow = function(bLock)
|
||||
{
|
||||
this.lock(!!bLock);
|
||||
|
||||
this.viewSecret('');
|
||||
this.viewBackupCodes('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.onHide = function()
|
||||
{
|
||||
if (this.lock())
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/TwoFactorConfiguration', 'TwoFactorConfigurationPopupView'], TwoFactorConfigurationPopupView);
|
||||
_.extend(TwoFactorConfigurationPopupView.prototype, AbstractView.prototype);
|
||||
TwoFactorConfigurationPopupView.prototype.getQr = function()
|
||||
{
|
||||
return 'otpauth://totp/' + window.encodeURIComponent(this.viewUser()) +
|
||||
'?secret=' + window.encodeURIComponent(this.viewSecret()) +
|
||||
'&issuer=' + window.encodeURIComponent('');
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.onResult = function(sResult, oData)
|
||||
{
|
||||
this.processing(false);
|
||||
this.clearing(false);
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.showSecret = function ()
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
this.secreting(true);
|
||||
Remote.showTwoFactorSecret(this.onShowSecretResult);
|
||||
};
|
||||
this.viewUser(Utils.pString(oData.Result.User));
|
||||
this.viewEnable_(!!oData.Result.Enable);
|
||||
this.twoFactorStatus(!!oData.Result.IsSet);
|
||||
this.twoFactorTested(!!oData.Result.Tested);
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.hideSecret = function ()
|
||||
this.viewSecret(Utils.pString(oData.Result.Secret));
|
||||
this.viewBackupCodes(Utils.pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
|
||||
|
||||
this.viewUrlTitle(Utils.pString(oData.Result.UrlTitle));
|
||||
this.viewUrl(qr.toDataURL({level: 'M', size: 8, value: this.getQr()}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.viewSecret('');
|
||||
this.viewBackupCodes('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.createTwoFactor = function ()
|
||||
{
|
||||
this.processing(true);
|
||||
Remote.createTwoFactor(this.onResult);
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.logout = function ()
|
||||
{
|
||||
require('App/User').default.logout();
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.testTwoFactor = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorTest'), [this.twoFactorTested]);
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.clearTwoFactor = function ()
|
||||
{
|
||||
this.viewSecret('');
|
||||
this.viewBackupCodes('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
|
||||
this.viewUser('');
|
||||
this.viewEnable_(false);
|
||||
this.twoFactorStatus(false);
|
||||
this.twoFactorTested(false);
|
||||
|
||||
this.clearing(true);
|
||||
Remote.clearTwoFactor(this.onResult);
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.onShow = function (bLock)
|
||||
{
|
||||
this.lock(!!bLock);
|
||||
|
||||
this.viewSecret('');
|
||||
this.viewBackupCodes('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.onHide = function ()
|
||||
TwoFactorConfigurationPopupView.prototype.onShowSecretResult = function(sResult, oData)
|
||||
{
|
||||
this.secreting(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
if (this.lock())
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.getQr = function ()
|
||||
this.viewSecret(Utils.pString(oData.Result.Secret));
|
||||
this.viewUrlTitle(Utils.pString(oData.Result.UrlTitle));
|
||||
this.viewUrl(qr.toDataURL({level: 'M', size: 6, value: this.getQr()}));
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'otpauth://totp/' + window.encodeURIComponent(this.viewUser()) +
|
||||
'?secret=' + window.encodeURIComponent(this.viewSecret()) +
|
||||
'&issuer=' + window.encodeURIComponent('');
|
||||
};
|
||||
this.viewSecret('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.onResult = function (sResult, oData)
|
||||
TwoFactorConfigurationPopupView.prototype.onBuild = function()
|
||||
{
|
||||
if (this.capaTwoFactor)
|
||||
{
|
||||
this.processing(false);
|
||||
this.clearing(false);
|
||||
this.processing(true);
|
||||
Remote.getTwoFactor(this.onResult);
|
||||
}
|
||||
};
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
this.viewUser(Utils.pString(oData.Result.User));
|
||||
this.viewEnable_(!!oData.Result.Enable);
|
||||
this.twoFactorStatus(!!oData.Result.IsSet);
|
||||
this.twoFactorTested(!!oData.Result.Tested);
|
||||
|
||||
this.viewSecret(Utils.pString(oData.Result.Secret));
|
||||
this.viewBackupCodes(Utils.pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
|
||||
|
||||
this.viewUrlTitle(Utils.pString(oData.Result.UrlTitle));
|
||||
this.viewUrl(qr.toDataURL({level: 'M', size: 8, value: this.getQr()}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.viewUser('');
|
||||
this.viewEnable_(false);
|
||||
this.twoFactorStatus(false);
|
||||
this.twoFactorTested(false);
|
||||
|
||||
this.viewSecret('');
|
||||
this.viewBackupCodes('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.onShowSecretResult = function (sResult, oData)
|
||||
{
|
||||
this.secreting(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
this.viewSecret(Utils.pString(oData.Result.Secret));
|
||||
this.viewUrlTitle(Utils.pString(oData.Result.UrlTitle));
|
||||
this.viewUrl(qr.toDataURL({level: 'M', size: 6, value: this.getQr()}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.viewSecret('');
|
||||
this.viewUrlTitle('');
|
||||
this.viewUrl('');
|
||||
}
|
||||
};
|
||||
|
||||
TwoFactorConfigurationPopupView.prototype.onBuild = function ()
|
||||
{
|
||||
if (this.capaTwoFactor)
|
||||
{
|
||||
this.processing(true);
|
||||
Remote.getTwoFactor(this.onResult);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = TwoFactorConfigurationPopupView;
|
||||
|
||||
}());
|
||||
module.exports = TwoFactorConfigurationPopupView;
|
||||
|
|
|
|||
|
|
@ -1,91 +1,84 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function TwoFactorTestPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsTwoFactorTest');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function TwoFactorTestPopupView()
|
||||
this.code = ko.observable('');
|
||||
this.code.focused = ko.observable(false);
|
||||
this.code.status = ko.observable(null);
|
||||
|
||||
this.koTestedTrigger = null;
|
||||
|
||||
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);
|
||||
|
||||
if (self.koTestedTrigger && self.code.status())
|
||||
{
|
||||
self.koTestedTrigger(true);
|
||||
}
|
||||
|
||||
}, this.code());
|
||||
|
||||
}, function() {
|
||||
return '' !== this.code() && !this.testing();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/TwoFactorTest', 'PopupsTwoFactorTestViewModel'], TwoFactorTestPopupView);
|
||||
_.extend(TwoFactorTestPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
TwoFactorTestPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.code('');
|
||||
this.code.focused(false);
|
||||
this.code.status(null);
|
||||
this.testing(false);
|
||||
|
||||
this.koTestedTrigger = null;
|
||||
};
|
||||
|
||||
TwoFactorTestPopupView.prototype.onShow = function(koTestedTrigger)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.koTestedTrigger = koTestedTrigger;
|
||||
};
|
||||
|
||||
TwoFactorTestPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (!Globals.bMobile)
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsTwoFactorTest');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.code = ko.observable('');
|
||||
this.code.focused = ko.observable(false);
|
||||
this.code.status = ko.observable(null);
|
||||
|
||||
this.koTestedTrigger = null;
|
||||
|
||||
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);
|
||||
|
||||
if (self.koTestedTrigger && self.code.status())
|
||||
{
|
||||
self.koTestedTrigger(true);
|
||||
}
|
||||
|
||||
}, this.code());
|
||||
|
||||
}, function () {
|
||||
return '' !== this.code() && !this.testing();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
this.code.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/TwoFactorTest', 'PopupsTwoFactorTestViewModel'], TwoFactorTestPopupView);
|
||||
_.extend(TwoFactorTestPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
TwoFactorTestPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.code('');
|
||||
this.code.focused(false);
|
||||
this.code.status(null);
|
||||
this.testing(false);
|
||||
|
||||
this.koTestedTrigger = null;
|
||||
};
|
||||
|
||||
TwoFactorTestPopupView.prototype.onShow = function (koTestedTrigger)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.koTestedTrigger = koTestedTrigger;
|
||||
};
|
||||
|
||||
TwoFactorTestPopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if (!Globals.bMobile)
|
||||
{
|
||||
this.code.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = TwoFactorTestPopupView;
|
||||
|
||||
}());
|
||||
module.exports = TwoFactorTestPopupView;
|
||||
|
|
|
|||
|
|
@ -1,71 +1,64 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ViewOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsViewOpenPgpKey');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.key = ko.observable('');
|
||||
this.keyDom = ko.observable(null);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ViewOpenPgpKeyPopupView()
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupViewOpenPGP;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/ViewOpenPgpKey', 'PopupsViewOpenPgpKeyViewModel'], ViewOpenPgpKeyPopupView);
|
||||
_.extend(ViewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ViewOpenPgpKeyPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.key('');
|
||||
};
|
||||
|
||||
ViewOpenPgpKeyPopupView.prototype.selectKey = function()
|
||||
{
|
||||
var oEl = this.keyDom();
|
||||
if (oEl)
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsViewOpenPgpKey');
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.keyDom = ko.observable(null);
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupViewOpenPGP;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
Utils.selectElement(oEl);
|
||||
}
|
||||
};
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/ViewOpenPgpKey', 'PopupsViewOpenPgpKeyViewModel'], ViewOpenPgpKeyPopupView);
|
||||
_.extend(ViewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
ViewOpenPgpKeyPopupView.prototype.onShow = function(oOpenPgpKey)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
ViewOpenPgpKeyPopupView.prototype.clearPopup = function ()
|
||||
if (oOpenPgpKey)
|
||||
{
|
||||
this.key('');
|
||||
};
|
||||
this.key(oOpenPgpKey.armor);
|
||||
}
|
||||
};
|
||||
|
||||
ViewOpenPgpKeyPopupView.prototype.selectKey = function ()
|
||||
{
|
||||
var oEl = this.keyDom();
|
||||
if (oEl)
|
||||
{
|
||||
Utils.selectElement(oEl);
|
||||
}
|
||||
};
|
||||
ViewOpenPgpKeyPopupView.prototype.onBuild = function()
|
||||
{
|
||||
key('ctrl+a, command+a', Enums.KeyState.PopupViewOpenPGP, _.bind(function() {
|
||||
this.selectKey();
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
|
||||
ViewOpenPgpKeyPopupView.prototype.onShow = function (oOpenPgpKey)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
if (oOpenPgpKey)
|
||||
{
|
||||
this.key(oOpenPgpKey.armor);
|
||||
}
|
||||
};
|
||||
|
||||
ViewOpenPgpKeyPopupView.prototype.onBuild = function ()
|
||||
{
|
||||
key('ctrl+a, command+a', Enums.KeyState.PopupViewOpenPGP, _.bind(function () {
|
||||
this.selectKey();
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
|
||||
module.exports = ViewOpenPgpKeyPopupView;
|
||||
|
||||
}());
|
||||
module.exports = ViewOpenPgpKeyPopupView;
|
||||
|
|
|
|||
|
|
@ -1,62 +1,56 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Promises = require('Promises/User/Ajax'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Promises = require('Promises/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function WelcomePagePopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsWelcomePage');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.welcomePageURL = ko.observable('');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function WelcomePagePopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsWelcomePage');
|
||||
this.closeFocused = ko.observable(false);
|
||||
|
||||
this.welcomePageURL = ko.observable('');
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
this.closeFocused = ko.observable(false);
|
||||
kn.extendAsViewModel(['View/Popup/WelcomePage', 'WelcomePagePopupViewModel'], WelcomePagePopupView);
|
||||
_.extend(WelcomePagePopupView.prototype, AbstractView.prototype);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
WelcomePagePopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.welcomePageURL('');
|
||||
this.closeFocused(false);
|
||||
};
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/WelcomePage', 'WelcomePagePopupViewModel'], WelcomePagePopupView);
|
||||
_.extend(WelcomePagePopupView.prototype, AbstractView.prototype);
|
||||
/**
|
||||
* @param {string} sUrl
|
||||
* @returns {void}
|
||||
*/
|
||||
WelcomePagePopupView.prototype.onShow = function(sUrl)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
WelcomePagePopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.welcomePageURL('');
|
||||
this.closeFocused(false);
|
||||
};
|
||||
this.welcomePageURL(sUrl);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sUrl
|
||||
*/
|
||||
WelcomePagePopupView.prototype.onShow = function (sUrl)
|
||||
{
|
||||
this.clearPopup();
|
||||
WelcomePagePopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.closeFocused(true);
|
||||
};
|
||||
|
||||
this.welcomePageURL(sUrl);
|
||||
};
|
||||
WelcomePagePopupView.prototype.onHide = function()
|
||||
{
|
||||
Promises.welcomeClose();
|
||||
};
|
||||
|
||||
WelcomePagePopupView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
this.closeFocused(true);
|
||||
};
|
||||
|
||||
WelcomePagePopupView.prototype.onHide = function ()
|
||||
{
|
||||
Promises.welcomeClose();
|
||||
};
|
||||
|
||||
module.exports = WelcomePagePopupView;
|
||||
|
||||
}());
|
||||
module.exports = WelcomePagePopupView;
|
||||
|
|
|
|||
|
|
@ -1,34 +1,27 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AboutUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'About');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AboutUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'About');
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
kn.extendAsViewModel(['View/User/About', 'View/App/About', 'AboutViewModel'], AboutUserView);
|
||||
_.extend(AboutUserView.prototype, AbstractView.prototype);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/About', 'View/App/About', 'AboutViewModel'], AboutUserView);
|
||||
_.extend(AboutUserView.prototype, AbstractView.prototype);
|
||||
|
||||
module.exports = AboutUserView;
|
||||
|
||||
}());
|
||||
module.exports = AboutUserView;
|
||||
|
|
|
|||
|
|
@ -1,144 +1,137 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
Events = require('Common/Events'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
AppStore = require('Stores/User/App'),
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
Events = require('Common/Events'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
AppStore = require('Stores/User/App'),
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AbstractSystemDropDownUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'SystemDropDown');
|
||||
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.logoImg = Utils.trim(Settings.settingsGet('UserLogo'));
|
||||
this.logoTitle = Utils.trim(Settings.settingsGet('UserLogoTitle'));
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AbstractSystemDropDownUserView()
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
|
||||
this.allowSettings = !!Settings.capa(Enums.Capa.Settings);
|
||||
this.allowHelp = !!Settings.capa(Enums.Capa.Help);
|
||||
|
||||
this.currentAudio = AppStore.currentAudio;
|
||||
|
||||
this.accountEmail = AccountStore.email;
|
||||
|
||||
this.accounts = AccountStore.accounts;
|
||||
this.accountsUnreadCount = AccountStore.accountsUnreadCount;
|
||||
|
||||
this.accountMenuDropdownTrigger = ko.observable(false);
|
||||
this.capaAdditionalAccounts = ko.observable(Settings.capa(Enums.Capa.AdditionalAccounts));
|
||||
|
||||
this.accountClick = _.bind(this.accountClick, this);
|
||||
|
||||
this.accountClick = _.bind(this.accountClick, this);
|
||||
|
||||
Events.sub('audio.stop', function() {
|
||||
AppStore.currentAudio('');
|
||||
});
|
||||
|
||||
Events.sub('audio.start', function(sName) {
|
||||
AppStore.currentAudio(sName);
|
||||
});
|
||||
}
|
||||
|
||||
_.extend(AbstractSystemDropDownUserView.prototype, AbstractView.prototype);
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.stopPlay = function()
|
||||
{
|
||||
Events.pub('audio.api.stop');
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.accountClick = function(oAccount, oEvent)
|
||||
{
|
||||
if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'SystemDropDown');
|
||||
AccountStore.accounts.loading(true);
|
||||
|
||||
this.logoImg = Utils.trim(Settings.settingsGet('UserLogo'));
|
||||
this.logoTitle = Utils.trim(Settings.settingsGet('UserLogoTitle'));
|
||||
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
|
||||
this.allowSettings = !!Settings.capa(Enums.Capa.Settings);
|
||||
this.allowHelp = !!Settings.capa(Enums.Capa.Help);
|
||||
|
||||
this.currentAudio = AppStore.currentAudio;
|
||||
|
||||
this.accountEmail = AccountStore.email;
|
||||
|
||||
this.accounts = AccountStore.accounts;
|
||||
this.accountsUnreadCount = AccountStore.accountsUnreadCount;
|
||||
|
||||
this.accountMenuDropdownTrigger = ko.observable(false);
|
||||
this.capaAdditionalAccounts = ko.observable(Settings.capa(Enums.Capa.AdditionalAccounts));
|
||||
|
||||
this.accountClick = _.bind(this.accountClick, this);
|
||||
|
||||
this.accountClick = _.bind(this.accountClick, this);
|
||||
|
||||
Events.sub('audio.stop', function () {
|
||||
AppStore.currentAudio('');
|
||||
});
|
||||
|
||||
Events.sub('audio.start', function (sName) {
|
||||
AppStore.currentAudio(sName);
|
||||
});
|
||||
_.delay(function() {
|
||||
AccountStore.accounts.loading(false);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
_.extend(AbstractSystemDropDownUserView.prototype, AbstractView.prototype);
|
||||
return true;
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.stopPlay = function ()
|
||||
{
|
||||
Events.pub('audio.api.stop');
|
||||
};
|
||||
AbstractSystemDropDownUserView.prototype.emailTitle = function()
|
||||
{
|
||||
return AccountStore.email();
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.accountClick = function (oAccount, oEvent)
|
||||
AbstractSystemDropDownUserView.prototype.settingsClick = function()
|
||||
{
|
||||
if (Settings.capa(Enums.Capa.Settings))
|
||||
{
|
||||
if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
|
||||
require('Knoin/Knoin').setHash(Links.settings());
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.settingsHelp = function()
|
||||
{
|
||||
if (Settings.capa(Enums.Capa.Help))
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.addAccountClick = function()
|
||||
{
|
||||
if (this.capaAdditionalAccounts())
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.logoutClick = function()
|
||||
{
|
||||
require('App/User').default.logout();
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.onBuild = function()
|
||||
{
|
||||
var self = this;
|
||||
key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function() {
|
||||
if (self.viewModelVisibility())
|
||||
{
|
||||
AccountStore.accounts.loading(true);
|
||||
MessageStore.messageFullScreenMode(false);
|
||||
|
||||
_.delay(function () {
|
||||
AccountStore.accounts.loading(false);
|
||||
}, 1000);
|
||||
self.accountMenuDropdownTrigger(true);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.emailTitle = function ()
|
||||
{
|
||||
return AccountStore.email();
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.settingsClick = function ()
|
||||
{
|
||||
if (Settings.capa(Enums.Capa.Settings))
|
||||
{
|
||||
require('Knoin/Knoin').setHash(Links.settings());
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.settingsHelp = function ()
|
||||
{
|
||||
if (Settings.capa(Enums.Capa.Help))
|
||||
// shortcuts help
|
||||
key('shift+/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function() {
|
||||
if (self.viewModelVisibility())
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.addAccountClick = function ()
|
||||
{
|
||||
if (this.capaAdditionalAccounts())
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.logoutClick = function ()
|
||||
{
|
||||
require('App/User').default.logout();
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.onBuild = function ()
|
||||
{
|
||||
var self = this;
|
||||
key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
|
||||
if (self.viewModelVisibility())
|
||||
{
|
||||
MessageStore.messageFullScreenMode(false);
|
||||
|
||||
self.accountMenuDropdownTrigger(true);
|
||||
}
|
||||
});
|
||||
|
||||
// shortcuts help
|
||||
key('shift+/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
|
||||
if (self.viewModelVisibility())
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = AbstractSystemDropDownUserView;
|
||||
|
||||
}());
|
||||
module.exports = AbstractSystemDropDownUserView;
|
||||
|
|
|
|||
|
|
@ -1,520 +1,511 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
Plugins = require('Common/Plugins'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
LanguageStore = require('Stores/Language'),
|
||||
AppStore = require('Stores/User/App'),
|
||||
|
||||
Plugins = require('Common/Plugins'),
|
||||
Local = require('Storage/Client'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
LanguageStore = require('Stores/Language'),
|
||||
AppStore = require('Stores/User/App'),
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
|
||||
Local = require('Storage/Client'),
|
||||
Settings = require('Storage/Settings'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'Login');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.welcome = ko.observable(!!Settings.settingsGet('UseLoginWelcomePage'));
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'Login');
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.signMe = ko.observable(false);
|
||||
|
||||
this.welcome = ko.observable(!!Settings.settingsGet('UseLoginWelcomePage'));
|
||||
this.additionalCode = ko.observable('');
|
||||
this.additionalCode.error = ko.observable(false);
|
||||
this.additionalCode.errorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.additionalCode.focused = ko.observable(false);
|
||||
this.additionalCode.visibility = ko.observable(false);
|
||||
this.additionalCodeSignMe = ko.observable(false);
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.signMe = ko.observable(false);
|
||||
this.logoImg = Utils.trim(Settings.settingsGet('LoginLogo'));
|
||||
this.logoPowered = !!Settings.settingsGet('LoginPowered');
|
||||
this.loginDescription = Utils.trim(Settings.settingsGet('LoginDescription'));
|
||||
|
||||
this.additionalCode = ko.observable('');
|
||||
this.additionalCode.error = ko.observable(false);
|
||||
this.additionalCode.errorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.additionalCode.focused = ko.observable(false);
|
||||
this.additionalCode.visibility = ko.observable(false);
|
||||
this.additionalCodeSignMe = ko.observable(false);
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
|
||||
this.logoImg = Utils.trim(Settings.settingsGet('LoginLogo'));
|
||||
this.logoPowered = !!Settings.settingsGet('LoginPowered');
|
||||
this.loginDescription = Utils.trim(Settings.settingsGet('LoginDescription'));
|
||||
this.forgotPasswordLinkUrl = Settings.appSettingsGet('forgotPasswordLinkUrl');
|
||||
this.registrationLinkUrl = Settings.appSettingsGet('registrationLinkUrl');
|
||||
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.forgotPasswordLinkUrl = Settings.appSettingsGet('forgotPasswordLinkUrl');
|
||||
this.registrationLinkUrl = Settings.appSettingsGet('registrationLinkUrl');
|
||||
this.emailErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
this.formHidden = ko.observable(false);
|
||||
|
||||
this.emailErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.formError = ko.computed(function() {
|
||||
return this.emailErrorAnimation() || this.passwordErrorAnimation() ||
|
||||
(this.additionalCode.visibility() && this.additionalCode.errorAnimation());
|
||||
}, this);
|
||||
|
||||
this.formHidden = ko.observable(false);
|
||||
this.emailFocus = ko.observable(false);
|
||||
this.passwordFocus = ko.observable(false);
|
||||
this.submitFocus = ko.observable(false);
|
||||
|
||||
this.formError = ko.computed(function () {
|
||||
return this.emailErrorAnimation() || this.passwordErrorAnimation() ||
|
||||
(this.additionalCode.visibility() && this.additionalCode.errorAnimation());
|
||||
}, this);
|
||||
this.email.subscribe(function() {
|
||||
this.emailError(false);
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(false);
|
||||
}, this);
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
this.passwordFocus = ko.observable(false);
|
||||
this.submitFocus = ko.observable(false);
|
||||
this.password.subscribe(function() {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(false);
|
||||
}, this);
|
||||
this.additionalCode.subscribe(function() {
|
||||
this.additionalCode.error(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
this.additionalCode.visibility.subscribe(function() {
|
||||
this.additionalCode.error(false);
|
||||
}, this);
|
||||
|
||||
this.additionalCode.subscribe(function () {
|
||||
this.emailError.subscribe(function(bV) {
|
||||
this.emailErrorAnimation(!!bV);
|
||||
}, this);
|
||||
|
||||
this.passwordError.subscribe(function(bV) {
|
||||
this.passwordErrorAnimation(!!bV);
|
||||
}, this);
|
||||
|
||||
this.additionalCode.error.subscribe(function(bV) {
|
||||
this.additionalCode.errorAnimation(!!bV);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitErrorAddidional = ko.observable('');
|
||||
|
||||
this.submitError.subscribe(function(sValue) {
|
||||
if ('' === sValue)
|
||||
{
|
||||
this.submitErrorAddidional('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin;
|
||||
|
||||
this.langRequest = ko.observable(false);
|
||||
this.language = LanguageStore.language;
|
||||
this.languages = LanguageStore.languages;
|
||||
|
||||
this.bSendLanguage = false;
|
||||
|
||||
this.languageFullName = ko.computed(function() {
|
||||
return Utils.convertLangName(this.language());
|
||||
}, this);
|
||||
|
||||
this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
|
||||
|
||||
this.signMeType.subscribe(function(iValue) {
|
||||
this.signMe(Enums.LoginSignMeType.DefaultOn === iValue);
|
||||
}, this);
|
||||
|
||||
this.signMeVisibility = ko.computed(function() {
|
||||
return Enums.LoginSignMeType.Unused !== this.signMeType();
|
||||
}, this);
|
||||
|
||||
this.submitCommand = Utils.createCommand(this, function() {
|
||||
|
||||
Utils.triggerAutocompleteInputChange();
|
||||
|
||||
this.emailError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.additionalCode.visibility())
|
||||
{
|
||||
this.additionalCode.error(false);
|
||||
}, this);
|
||||
this.additionalCode.error('' === Utils.trim(this.additionalCode()));
|
||||
}
|
||||
|
||||
this.additionalCode.visibility.subscribe(function () {
|
||||
this.additionalCode.error(false);
|
||||
}, this);
|
||||
|
||||
this.emailError.subscribe(function (bV) {
|
||||
this.emailErrorAnimation(!!bV);
|
||||
}, this);
|
||||
|
||||
this.passwordError.subscribe(function (bV) {
|
||||
this.passwordErrorAnimation(!!bV);
|
||||
}, this);
|
||||
|
||||
this.additionalCode.error.subscribe(function (bV) {
|
||||
this.additionalCode.errorAnimation(!!bV);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitErrorAddidional = ko.observable('');
|
||||
|
||||
this.submitError.subscribe(function (sValue) {
|
||||
if ('' === sValue)
|
||||
if (this.emailError() || this.passwordError() ||
|
||||
(this.additionalCode.visibility() && this.additionalCode.error()))
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
this.submitErrorAddidional('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin;
|
||||
|
||||
this.langRequest = ko.observable(false);
|
||||
this.language = LanguageStore.language;
|
||||
this.languages = LanguageStore.languages;
|
||||
|
||||
this.bSendLanguage = false;
|
||||
|
||||
this.languageFullName = ko.computed(function () {
|
||||
return Utils.convertLangName(this.language());
|
||||
}, this);
|
||||
|
||||
this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
|
||||
|
||||
this.signMeType.subscribe(function (iValue) {
|
||||
this.signMe(Enums.LoginSignMeType.DefaultOn === iValue);
|
||||
}, this);
|
||||
|
||||
this.signMeVisibility = ko.computed(function () {
|
||||
return Enums.LoginSignMeType.Unused !== this.signMeType();
|
||||
}, this);
|
||||
|
||||
this.submitCommand = Utils.createCommand(this, function () {
|
||||
|
||||
Utils.triggerAutocompleteInputChange();
|
||||
|
||||
this.emailError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.additionalCode.visibility())
|
||||
{
|
||||
this.additionalCode.error(false);
|
||||
this.additionalCode.error('' === Utils.trim(this.additionalCode()));
|
||||
case this.emailError():
|
||||
this.emailFocus(true);
|
||||
break;
|
||||
case this.passwordError():
|
||||
this.passwordFocus(true);
|
||||
break;
|
||||
case this.additionalCode.visibility() && this.additionalCode.error():
|
||||
this.additionalCode.focused(true);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
|
||||
if (this.emailError() || this.passwordError() ||
|
||||
(this.additionalCode.visibility() && this.additionalCode.error()))
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
case this.emailError():
|
||||
this.emailFocus(true);
|
||||
break;
|
||||
case this.passwordError():
|
||||
this.passwordFocus(true);
|
||||
break;
|
||||
case this.additionalCode.visibility() && this.additionalCode.error():
|
||||
this.additionalCode.focused(true);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
var
|
||||
iPluginResultCode = 0,
|
||||
sPluginResultMessage = '',
|
||||
fSubmitResult = function(iResultCode, sResultMessage) {
|
||||
iPluginResultCode = iResultCode || 0;
|
||||
sPluginResultMessage = sResultMessage || '';
|
||||
};
|
||||
|
||||
var
|
||||
iPluginResultCode = 0,
|
||||
sPluginResultMessage = '',
|
||||
fSubmitResult = function (iResultCode, sResultMessage) {
|
||||
iPluginResultCode = iResultCode || 0;
|
||||
sPluginResultMessage = sResultMessage || '';
|
||||
}
|
||||
;
|
||||
Plugins.runHook('user-login-submit', [fSubmitResult]);
|
||||
if (0 < iPluginResultCode)
|
||||
{
|
||||
this.submitError(Translator.getNotification(iPluginResultCode));
|
||||
return false;
|
||||
}
|
||||
else if ('' !== sPluginResultMessage)
|
||||
{
|
||||
this.submitError(sPluginResultMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
Plugins.runHook('user-login-submit', [fSubmitResult]);
|
||||
if (0 < iPluginResultCode)
|
||||
{
|
||||
this.submitError(Translator.getNotification(iPluginResultCode));
|
||||
return false;
|
||||
}
|
||||
else if ('' !== sPluginResultMessage)
|
||||
{
|
||||
this.submitError(sPluginResultMessage);
|
||||
return false;
|
||||
}
|
||||
this.submitRequest(true);
|
||||
|
||||
this.submitRequest(true);
|
||||
var
|
||||
self = this,
|
||||
sPassword = this.password(),
|
||||
|
||||
var
|
||||
self = this,
|
||||
sPassword = this.password(),
|
||||
fLoginRequest = _.bind(function(sLoginPassword) {
|
||||
|
||||
fLoginRequest = _.bind(function (sLoginPassword) {
|
||||
Remote.login(_.bind(function(sResult, oData) {
|
||||
|
||||
Remote.login(_.bind(function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
if (oData.TwoFactorAuth)
|
||||
{
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(true);
|
||||
this.submitRequest(false);
|
||||
|
||||
_.delay(function() {
|
||||
self.additionalCode.focused(true);
|
||||
}, 100);
|
||||
}
|
||||
else if (oData.Admin)
|
||||
{
|
||||
require('App/User').default.redirectToAdminPanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
require('App/User').default.loginAndLogoutReload(false);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
if (oData.TwoFactorAuth)
|
||||
{
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(true);
|
||||
this.submitRequest(false);
|
||||
if (-1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.InvalidInputArgument]))
|
||||
{
|
||||
oData.ErrorCode = Enums.Notification.AuthError;
|
||||
}
|
||||
|
||||
this.submitError(Translator.getNotificationFromResponse(oData));
|
||||
|
||||
if ('' === this.submitError())
|
||||
{
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData.ErrorMessageAdditional)
|
||||
{
|
||||
this.submitErrorAddidional(oData.ErrorMessageAdditional);
|
||||
}
|
||||
}
|
||||
_.delay(function() {
|
||||
self.additionalCode.focused(true);
|
||||
}, 100);
|
||||
}
|
||||
else if (oData.Admin)
|
||||
{
|
||||
require('App/User').default.redirectToAdminPanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
require('App/User').default.loginAndLogoutReload(false);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
if (-1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.InvalidInputArgument]))
|
||||
{
|
||||
oData.ErrorCode = Enums.Notification.AuthError;
|
||||
}
|
||||
|
||||
this.submitError(Translator.getNotificationFromResponse(oData));
|
||||
|
||||
if ('' === this.submitError())
|
||||
{
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData.ErrorMessageAdditional)
|
||||
{
|
||||
this.submitErrorAddidional(oData.ErrorMessageAdditional);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.email(), '', sLoginPassword, !!this.signMe(),
|
||||
this.bSendLanguage ? this.language() : '',
|
||||
this.additionalCode.visibility() ? this.additionalCode() : '',
|
||||
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
|
||||
);
|
||||
}, this), this.email(), '', sLoginPassword, !!this.signMe(),
|
||||
this.bSendLanguage ? this.language() : '',
|
||||
this.additionalCode.visibility() ? this.additionalCode() : '',
|
||||
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
|
||||
);
|
||||
|
||||
Local.set(Enums.ClientSideKeyName.LastSignMe, this.signMe() ? '-1-' : '-0-');
|
||||
Local.set(Enums.ClientSideKeyName.LastSignMe, this.signMe() ? '-1-' : '-0-');
|
||||
|
||||
}, this)
|
||||
;
|
||||
}, this);
|
||||
|
||||
if (Settings.appSettingsGet('rsaPublicKey') && Utils.rsaEncode.supported)
|
||||
{
|
||||
fLoginRequest(Utils.rsaEncode(sPassword, Settings.appSettingsGet('rsaPublicKey')));
|
||||
}
|
||||
else
|
||||
{
|
||||
fLoginRequest(sPassword);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.facebookLoginEnabled = ko.observable(false);
|
||||
|
||||
this.facebookCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(Links.socialFacebook(), 'Facebook',
|
||||
'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.facebookLoginEnabled();
|
||||
});
|
||||
|
||||
this.googleLoginEnabled = ko.observable(false);
|
||||
this.googleFastLoginEnabled = ko.observable(false);
|
||||
|
||||
this.googleCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(Links.socialGoogle(), 'Google',
|
||||
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.googleLoginEnabled();
|
||||
});
|
||||
|
||||
this.googleFastCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(Links.socialGoogle(true), 'Google',
|
||||
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.googleFastLoginEnabled();
|
||||
});
|
||||
|
||||
this.twitterLoginEnabled = ko.observable(false);
|
||||
|
||||
this.twitterCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(Links.socialTwitter(), 'Twitter',
|
||||
'left=200,top=100,width=650,height=450,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);
|
||||
|
||||
if (Settings.settingsGet('AdditionalLoginError') && !this.submitError())
|
||||
if (Settings.appSettingsGet('rsaPublicKey') && Utils.rsaEncode.supported)
|
||||
{
|
||||
this.submitError(Settings.settingsGet('AdditionalLoginError'));
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/Login', 'View/App/Login', 'LoginViewModel'], LoginUserView);
|
||||
_.extend(LoginUserView.prototype, AbstractView.prototype);
|
||||
|
||||
LoginUserView.prototype.displayMainForm = function ()
|
||||
{
|
||||
this.welcome(false);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onShowWithDelay = function ()
|
||||
{
|
||||
if ('' !== this.email() && '' !== this.password())
|
||||
{
|
||||
this.submitFocus(true);
|
||||
}
|
||||
else if ('' === this.email())
|
||||
{
|
||||
this.emailFocus(true);
|
||||
}
|
||||
else if ('' === this.password())
|
||||
{
|
||||
this.passwordFocus(true);
|
||||
fLoginRequest(Utils.rsaEncode(sPassword, Settings.appSettingsGet('rsaPublicKey')));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.emailFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onHide = function ()
|
||||
{
|
||||
this.submitFocus(false);
|
||||
this.emailFocus(false);
|
||||
this.passwordFocus(false);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
sSignMeLocal = Local.get(Enums.ClientSideKeyName.LastSignMe),
|
||||
sSignMe = (Settings.settingsGet('SignMe') || 'unused').toLowerCase(),
|
||||
sJsHash = Settings.appSettingsGet('jsHash'),
|
||||
fSocial = function (iErrorCode) {
|
||||
iErrorCode = Utils.pInt(iErrorCode);
|
||||
if (0 === iErrorCode)
|
||||
{
|
||||
self.submitRequest(true);
|
||||
require('App/User').default.loginAndLogoutReload(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.submitError(Translator.getNotification(iErrorCode));
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
|
||||
this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
|
||||
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
|
||||
!!Settings.settingsGet('AllowGoogleSocialAuth'));
|
||||
this.googleFastLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
|
||||
!!Settings.settingsGet('AllowGoogleSocialAuthFast'));
|
||||
|
||||
switch (sSignMe)
|
||||
{
|
||||
case Enums.LoginSignMeTypeAsString.DefaultOff:
|
||||
case Enums.LoginSignMeTypeAsString.DefaultOn:
|
||||
|
||||
this.signMeType(Enums.LoginSignMeTypeAsString.DefaultOn === sSignMe ?
|
||||
Enums.LoginSignMeType.DefaultOn : Enums.LoginSignMeType.DefaultOff);
|
||||
|
||||
switch (sSignMeLocal)
|
||||
{
|
||||
case '-1-':
|
||||
this.signMeType(Enums.LoginSignMeType.DefaultOn);
|
||||
break;
|
||||
case '-0-':
|
||||
this.signMeType(Enums.LoginSignMeType.DefaultOff);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
case Enums.LoginSignMeTypeAsString.Unused:
|
||||
this.signMeType(Enums.LoginSignMeType.Unused);
|
||||
break;
|
||||
}
|
||||
|
||||
this.email(AppStore.devEmail);
|
||||
this.password(AppStore.devPassword);
|
||||
|
||||
if (this.googleLoginEnabled() || this.googleFastLoginEnabled())
|
||||
{
|
||||
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 () {
|
||||
|
||||
LanguageStore.language.subscribe(function (sValue) {
|
||||
|
||||
self.langRequest(true);
|
||||
|
||||
Translator.reload(false, sValue).then(function() {
|
||||
self.langRequest(false);
|
||||
self.bSendLanguage = true;
|
||||
}, function() {
|
||||
self.langRequest(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}, 50);
|
||||
|
||||
Utils.triggerAutocompleteInputChange(true);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.submitForm = function ()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
|
||||
LoginUserView.prototype.selectLanguage = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Languages'), [
|
||||
this.language, this.languages(), LanguageStore.userLanguage()
|
||||
]);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.selectLanguageOnTab = function (bShift)
|
||||
{
|
||||
if (!bShift)
|
||||
{
|
||||
var self = this;
|
||||
_.delay(function () {
|
||||
self.emailFocus(true);
|
||||
}, 5);
|
||||
|
||||
return false;
|
||||
fLoginRequest(sPassword);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = LoginUserView;
|
||||
}, function() {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
}());
|
||||
this.facebookLoginEnabled = ko.observable(false);
|
||||
|
||||
this.facebookCommand = Utils.createCommand(this, function() {
|
||||
|
||||
window.open(Links.socialFacebook(), 'Facebook',
|
||||
'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
|
||||
return true;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest() && this.facebookLoginEnabled();
|
||||
});
|
||||
|
||||
this.googleLoginEnabled = ko.observable(false);
|
||||
this.googleFastLoginEnabled = ko.observable(false);
|
||||
|
||||
this.googleCommand = Utils.createCommand(this, function() {
|
||||
|
||||
window.open(Links.socialGoogle(), 'Google',
|
||||
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
|
||||
return true;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest() && this.googleLoginEnabled();
|
||||
});
|
||||
|
||||
this.googleFastCommand = Utils.createCommand(this, function() {
|
||||
|
||||
window.open(Links.socialGoogle(true), 'Google',
|
||||
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
|
||||
return true;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest() && this.googleFastLoginEnabled();
|
||||
});
|
||||
|
||||
this.twitterLoginEnabled = ko.observable(false);
|
||||
|
||||
this.twitterCommand = Utils.createCommand(this, function() {
|
||||
|
||||
window.open(Links.socialTwitter(), 'Twitter',
|
||||
'left=200,top=100,width=650,height=450,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);
|
||||
|
||||
if (Settings.settingsGet('AdditionalLoginError') && !this.submitError())
|
||||
{
|
||||
this.submitError(Settings.settingsGet('AdditionalLoginError'));
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/Login', 'View/App/Login', 'LoginViewModel'], LoginUserView);
|
||||
_.extend(LoginUserView.prototype, AbstractView.prototype);
|
||||
|
||||
LoginUserView.prototype.displayMainForm = function()
|
||||
{
|
||||
this.welcome(false);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onShow = function()
|
||||
{
|
||||
kn.routeOff();
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if ('' !== this.email() && '' !== this.password())
|
||||
{
|
||||
this.submitFocus(true);
|
||||
}
|
||||
else if ('' === this.email())
|
||||
{
|
||||
this.emailFocus(true);
|
||||
}
|
||||
else if ('' === this.password())
|
||||
{
|
||||
this.passwordFocus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.emailFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onHide = function()
|
||||
{
|
||||
this.submitFocus(false);
|
||||
this.emailFocus(false);
|
||||
this.passwordFocus(false);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onBuild = function()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
sSignMeLocal = Local.get(Enums.ClientSideKeyName.LastSignMe),
|
||||
sSignMe = (Settings.settingsGet('SignMe') || 'unused').toLowerCase(),
|
||||
sJsHash = Settings.appSettingsGet('jsHash'),
|
||||
fSocial = function(iErrorCode) {
|
||||
iErrorCode = Utils.pInt(iErrorCode);
|
||||
if (0 === iErrorCode)
|
||||
{
|
||||
self.submitRequest(true);
|
||||
require('App/User').default.loginAndLogoutReload(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.submitError(Translator.getNotification(iErrorCode));
|
||||
}
|
||||
};
|
||||
|
||||
this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
|
||||
this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
|
||||
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
|
||||
!!Settings.settingsGet('AllowGoogleSocialAuth'));
|
||||
this.googleFastLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
|
||||
!!Settings.settingsGet('AllowGoogleSocialAuthFast'));
|
||||
|
||||
switch (sSignMe)
|
||||
{
|
||||
case Enums.LoginSignMeTypeAsString.DefaultOff:
|
||||
case Enums.LoginSignMeTypeAsString.DefaultOn:
|
||||
|
||||
this.signMeType(Enums.LoginSignMeTypeAsString.DefaultOn === sSignMe ?
|
||||
Enums.LoginSignMeType.DefaultOn : Enums.LoginSignMeType.DefaultOff);
|
||||
|
||||
switch (sSignMeLocal)
|
||||
{
|
||||
case '-1-':
|
||||
this.signMeType(Enums.LoginSignMeType.DefaultOn);
|
||||
break;
|
||||
case '-0-':
|
||||
this.signMeType(Enums.LoginSignMeType.DefaultOff);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
|
||||
break;
|
||||
case Enums.LoginSignMeTypeAsString.Unused:
|
||||
default:
|
||||
this.signMeType(Enums.LoginSignMeType.Unused);
|
||||
break;
|
||||
}
|
||||
|
||||
this.email(AppStore.devEmail);
|
||||
this.password(AppStore.devPassword);
|
||||
|
||||
if (this.googleLoginEnabled() || this.googleFastLoginEnabled())
|
||||
{
|
||||
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() {
|
||||
|
||||
LanguageStore.language.subscribe(function(sValue) {
|
||||
|
||||
self.langRequest(true);
|
||||
|
||||
Translator.reload(false, sValue).then(function() {
|
||||
self.langRequest(false);
|
||||
self.bSendLanguage = true;
|
||||
}, function() {
|
||||
self.langRequest(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}, 50);
|
||||
|
||||
Utils.triggerAutocompleteInputChange(true);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.submitForm = function()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
|
||||
LoginUserView.prototype.selectLanguage = function()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Languages'), [
|
||||
this.language, this.languages(), LanguageStore.userLanguage()
|
||||
]);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.selectLanguageOnTab = function(bShift)
|
||||
{
|
||||
if (!bShift)
|
||||
{
|
||||
var self = this;
|
||||
_.delay(function() {
|
||||
self.emailFocus(true);
|
||||
}, 5);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = LoginUserView;
|
||||
|
|
|
|||
|
|
@ -1,324 +1,310 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
'use strict';
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Cache = require('Common/Cache'),
|
||||
|
||||
AppStore = require('Stores/User/App'),
|
||||
SettingsStore = require('Stores/User/Settings'),
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderListMailBoxUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'MailFolderList');
|
||||
|
||||
this.oContentVisible = null;
|
||||
this.oContentScrollable = null;
|
||||
|
||||
this.composeInEdit = AppStore.composeInEdit;
|
||||
|
||||
this.messageList = MessageStore.messageList;
|
||||
this.folderList = FolderStore.folderList;
|
||||
this.folderListSystem = FolderStore.folderListSystem;
|
||||
this.foldersChanging = FolderStore.foldersChanging;
|
||||
|
||||
this.foldersListWithSingleInboxRootFolder = FolderStore.foldersListWithSingleInboxRootFolder;
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
this.iDropOverTimer = 0;
|
||||
|
||||
this.allowComposer = !!Settings.capa(Enums.Capa.Composer);
|
||||
this.allowContacts = !!AppStore.contactsIsAllowed();
|
||||
this.allowFolders = !!Settings.capa(Enums.Capa.Folders);
|
||||
|
||||
this.folderListFocused = ko.computed(function() {
|
||||
return Enums.Focused.FolderList === AppStore.focusedState();
|
||||
});
|
||||
|
||||
this.isInboxStarred = ko.computed(function() {
|
||||
return FolderStore.currentFolder() &&
|
||||
FolderStore.currentFolder().isInbox() &&
|
||||
-1 < Utils.trim(MessageStore.messageListSearch()).indexOf('is:flagged');
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/MailBox/FolderList', 'View/App/MailBox/FolderList', 'MailBoxFolderListViewModel'], FolderListMailBoxUserView);
|
||||
_.extend(FolderListMailBoxUserView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderListMailBoxUserView.prototype.onBuild = function(oDom)
|
||||
{
|
||||
this.oContentVisible = $('.b-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
self = this,
|
||||
bMobile = Settings.appSettingsGet('mobile'),
|
||||
fSelectFolder = function(oEvent, bStarred) {
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Links = require('Common/Links'),
|
||||
if (bMobile)
|
||||
{
|
||||
Globals.leftPanelDisabled(true);
|
||||
}
|
||||
|
||||
Cache = require('Common/Cache'),
|
||||
oEvent.preventDefault();
|
||||
|
||||
AppStore = require('Stores/User/App'),
|
||||
SettingsStore = require('Stores/User/Settings'),
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
if (bStarred)
|
||||
{
|
||||
oEvent.stopPropagation();
|
||||
}
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
var
|
||||
oFolder = ko.dataFor(this);
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderListMailBoxUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'MailFolderList');
|
||||
|
||||
this.oContentVisible = null;
|
||||
this.oContentScrollable = null;
|
||||
|
||||
this.composeInEdit = AppStore.composeInEdit;
|
||||
|
||||
this.messageList = MessageStore.messageList;
|
||||
this.folderList = FolderStore.folderList;
|
||||
this.folderListSystem = FolderStore.folderListSystem;
|
||||
this.foldersChanging = FolderStore.foldersChanging;
|
||||
|
||||
this.foldersListWithSingleInboxRootFolder = FolderStore.foldersListWithSingleInboxRootFolder;
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
this.iDropOverTimer = 0;
|
||||
|
||||
this.allowComposer = !!Settings.capa(Enums.Capa.Composer);
|
||||
this.allowContacts = !!AppStore.contactsIsAllowed();
|
||||
this.allowFolders = !!Settings.capa(Enums.Capa.Folders);
|
||||
|
||||
this.folderListFocused = ko.computed(function () {
|
||||
return Enums.Focused.FolderList === AppStore.focusedState();
|
||||
});
|
||||
|
||||
this.isInboxStarred = ko.computed(function () {
|
||||
return FolderStore.currentFolder() &&
|
||||
FolderStore.currentFolder().isInbox() &&
|
||||
-1 < Utils.trim(MessageStore.messageListSearch()).indexOf('is:flagged')
|
||||
;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/MailBox/FolderList', 'View/App/MailBox/FolderList', 'MailBoxFolderListViewModel'], FolderListMailBoxUserView);
|
||||
_.extend(FolderListMailBoxUserView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderListMailBoxUserView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
this.oContentVisible = $('.b-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
var
|
||||
self = this,
|
||||
bMobile = Settings.appSettingsGet('mobile'),
|
||||
fSelectFolder = function (oEvent, bStarred) {
|
||||
|
||||
if (bMobile)
|
||||
if (oFolder)
|
||||
{
|
||||
if (Enums.Layout.NoPreview === SettingsStore.layout())
|
||||
{
|
||||
Globals.leftPanelDisabled(true);
|
||||
MessageStore.message(null);
|
||||
}
|
||||
|
||||
oEvent.preventDefault();
|
||||
if (oFolder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
|
||||
{
|
||||
Cache.setFolderHash(oFolder.fullNameRaw, '');
|
||||
}
|
||||
|
||||
if (bStarred)
|
||||
{
|
||||
oEvent.stopPropagation();
|
||||
kn.setHash(Links.mailBox(oFolder.fullNameHash, 1, 'is:flagged'));
|
||||
}
|
||||
|
||||
var
|
||||
oFolder = ko.dataFor(this)
|
||||
;
|
||||
|
||||
if (oFolder)
|
||||
else
|
||||
{
|
||||
if (Enums.Layout.NoPreview === SettingsStore.layout())
|
||||
{
|
||||
MessageStore.message(null);
|
||||
}
|
||||
|
||||
if (oFolder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
|
||||
{
|
||||
Cache.setFolderHash(oFolder.fullNameRaw, '');
|
||||
}
|
||||
|
||||
if (bStarred)
|
||||
{
|
||||
kn.setHash(Links.mailBox(oFolder.fullNameHash, 1, 'is:flagged'));
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.setHash(Links.mailBox(oFolder.fullNameHash));
|
||||
}
|
||||
kn.setHash(Links.mailBox(oFolder.fullNameHash));
|
||||
}
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
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();
|
||||
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||
|
||||
oFolder.collapsed(!bCollapsed);
|
||||
oEvent.preventDefault();
|
||||
oEvent.stopPropagation();
|
||||
}
|
||||
})
|
||||
.on('click', '.b-folders .e-item .e-link.selectable .inbox-star-icon', function (oEvent) {
|
||||
fSelectFolder.call(this, oEvent, !self.isInboxStarred());
|
||||
})
|
||||
.on('click', '.b-folders .e-item .e-link.selectable', function (oEvent) {
|
||||
fSelectFolder.call(this, oEvent, false);
|
||||
})
|
||||
;
|
||||
|
||||
key('up, down', Enums.KeyState.FolderList, function (event, handler) {
|
||||
oDom
|
||||
.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function(oEvent) {
|
||||
|
||||
var
|
||||
iIndex = -1,
|
||||
iKeyCode = handler && 'up' === handler.shortcut ? 38 : 40,
|
||||
$items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom)
|
||||
;
|
||||
oFolder = ko.dataFor(this),
|
||||
bCollapsed = false;
|
||||
|
||||
if (event && $items.length)
|
||||
if (oFolder && oEvent)
|
||||
{
|
||||
iIndex = $items.index($items.filter('.focused'));
|
||||
if (-1 < iIndex)
|
||||
{
|
||||
$items.eq(iIndex).removeClass('focused');
|
||||
}
|
||||
bCollapsed = oFolder.collapsed();
|
||||
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||
|
||||
if (iKeyCode === 38 && iIndex > 0)
|
||||
{
|
||||
iIndex--;
|
||||
}
|
||||
else if (iKeyCode === 40 && iIndex < $items.length - 1)
|
||||
{
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
$items.eq(iIndex).addClass('focused');
|
||||
self.scrollToFocused();
|
||||
oFolder.collapsed(!bCollapsed);
|
||||
oEvent.preventDefault();
|
||||
oEvent.stopPropagation();
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
.on('click', '.b-folders .e-item .e-link.selectable .inbox-star-icon', function(oEvent) {
|
||||
fSelectFolder.call(this, oEvent, !self.isInboxStarred());
|
||||
})
|
||||
.on('click', '.b-folders .e-item .e-link.selectable', function(oEvent) {
|
||||
fSelectFolder.call(this, oEvent, false);
|
||||
});
|
||||
|
||||
key('enter', Enums.KeyState.FolderList, function () {
|
||||
var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
|
||||
if ($items.length && $items[0])
|
||||
{
|
||||
AppStore.focusedState(Enums.Focused.MessageList);
|
||||
$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();
|
||||
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||
oFolder.collapsed(!bCollapsed);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function () {
|
||||
AppStore.focusedState(Enums.Focused.MessageList);
|
||||
return false;
|
||||
});
|
||||
|
||||
AppStore.focusedState.subscribe(function (mValue) {
|
||||
$('.b-folders .e-item .e-link.focused', oDom).removeClass('focused');
|
||||
if (Enums.Focused.FolderList === mValue)
|
||||
{
|
||||
$('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.messagesDropOver = function (oFolder)
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
if (oFolder && oFolder.collapsed())
|
||||
{
|
||||
this.iDropOverTimer = window.setTimeout(function () {
|
||||
oFolder.collapsed(false);
|
||||
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, true);
|
||||
Utils.windowResize();
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.messagesDropOut = function ()
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.scrollToFocused = function ()
|
||||
{
|
||||
if (!this.oContentVisible || !this.oContentScrollable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
key('up, down', Enums.KeyState.FolderList, function(event, handler) {
|
||||
|
||||
var
|
||||
iOffset = 20,
|
||||
oFocused = $('.e-item .e-link.focused', this.oContentScrollable),
|
||||
oPos = oFocused.position(),
|
||||
iVisibleHeight = this.oContentVisible.height(),
|
||||
iFocusedHeight = oFocused.outerHeight()
|
||||
;
|
||||
iIndex = -1,
|
||||
iKeyCode = handler && 'up' === handler.shortcut ? 38 : 40,
|
||||
$items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom);
|
||||
|
||||
if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight))
|
||||
if (event && $items.length)
|
||||
{
|
||||
if (oPos.top < 0)
|
||||
iIndex = $items.index($items.filter('.focused'));
|
||||
if (-1 < iIndex)
|
||||
{
|
||||
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
|
||||
$items.eq(iIndex).removeClass('focused');
|
||||
}
|
||||
|
||||
return true;
|
||||
if (38 === iKeyCode && 0 < iIndex)
|
||||
{
|
||||
iIndex -= 1;
|
||||
}
|
||||
else if (40 === iKeyCode && iIndex < $items.length - 1)
|
||||
{
|
||||
iIndex += 1;
|
||||
}
|
||||
|
||||
$items.eq(iIndex).addClass('focused');
|
||||
self.scrollToFocused();
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {FolderModel} oToFolder
|
||||
* @param {{helper:jQuery}} oUi
|
||||
*/
|
||||
FolderListMailBoxUserView.prototype.messagesDrop = function (oToFolder, oUi)
|
||||
{
|
||||
if (oToFolder && oUi && oUi.helper)
|
||||
key('enter', Enums.KeyState.FolderList, function() {
|
||||
var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
|
||||
if ($items.length && $items[0])
|
||||
{
|
||||
var
|
||||
sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
|
||||
bCopy = Globals.$html.hasClass('rl-ctrl-key-pressed'),
|
||||
aUids = oUi.helper.data('rl-uids')
|
||||
;
|
||||
AppStore.focusedState(Enums.Focused.MessageList);
|
||||
$items.click();
|
||||
}
|
||||
|
||||
if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
|
||||
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)
|
||||
{
|
||||
require('App/User').default.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
|
||||
bCollapsed = oFolder.collapsed();
|
||||
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||
oFolder.collapsed(!bCollapsed);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.composeClick = function ()
|
||||
{
|
||||
if (Settings.capa(Enums.Capa.Composer))
|
||||
return false;
|
||||
});
|
||||
|
||||
key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function() {
|
||||
AppStore.focusedState(Enums.Focused.MessageList);
|
||||
return false;
|
||||
});
|
||||
|
||||
AppStore.focusedState.subscribe(function(mValue) {
|
||||
$('.b-folders .e-item .e-link.focused', oDom).removeClass('focused');
|
||||
if (Enums.Focused.FolderList === mValue)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
$('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.createFolder = function ()
|
||||
FolderListMailBoxUserView.prototype.messagesDropOver = function(oFolder)
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
if (oFolder && oFolder.collapsed())
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/FolderCreate'));
|
||||
};
|
||||
this.iDropOverTimer = window.setTimeout(function() {
|
||||
oFolder.collapsed(false);
|
||||
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, true);
|
||||
Utils.windowResize();
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.configureFolders = function ()
|
||||
{
|
||||
kn.setHash(Links.settings('folders'));
|
||||
};
|
||||
FolderListMailBoxUserView.prototype.messagesDropOut = function()
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.contactsClick = function ()
|
||||
FolderListMailBoxUserView.prototype.scrollToFocused = function()
|
||||
{
|
||||
if (!this.oContentVisible || !this.oContentScrollable)
|
||||
{
|
||||
if (this.allowContacts)
|
||||
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 && (0 > oPos.top || oPos.top + iFocusedHeight > iVisibleHeight))
|
||||
{
|
||||
if (0 > oPos.top)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Contacts'));
|
||||
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderListMailBoxUserView;
|
||||
return true;
|
||||
}
|
||||
|
||||
}());
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {FolderModel} oToFolder
|
||||
* @param {{helper:jQuery}} oUi
|
||||
* @returns {void}
|
||||
*/
|
||||
FolderListMailBoxUserView.prototype.messagesDrop = function(oToFolder, oUi)
|
||||
{
|
||||
if (oToFolder && oUi && oUi.helper)
|
||||
{
|
||||
var
|
||||
sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
|
||||
bCopy = Globals.$html.hasClass('rl-ctrl-key-pressed'),
|
||||
aUids = oUi.helper.data('rl-uids');
|
||||
|
||||
if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
|
||||
{
|
||||
require('App/User').default.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.composeClick = function()
|
||||
{
|
||||
if (Settings.capa(Enums.Capa.Composer))
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.createFolder = function()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/FolderCreate'));
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.configureFolders = function()
|
||||
{
|
||||
kn.setHash(Links.settings('folders'));
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.contactsClick = function()
|
||||
{
|
||||
if (this.allowContacts)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Contacts'));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderListMailBoxUserView;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,28 +1,21 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
'use strict';
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractSystemDropDownViewModel = require('View/User/AbstractSystemDropDown');
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownViewModel
|
||||
*/
|
||||
function SystemDropDownMailBoxUserView()
|
||||
{
|
||||
AbstractSystemDropDownViewModel.call(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractSystemDropDownViewModel = require('View/User/AbstractSystemDropDown')
|
||||
;
|
||||
kn.extendAsViewModel(['View/User/MailBox/SystemDropDown', 'View/App/MailBox/SystemDropDown', 'MailBoxSystemDropDownViewModel'], SystemDropDownMailBoxUserView);
|
||||
_.extend(SystemDropDownMailBoxUserView.prototype, AbstractSystemDropDownViewModel.prototype);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownViewModel
|
||||
*/
|
||||
function SystemDropDownMailBoxUserView()
|
||||
{
|
||||
AbstractSystemDropDownViewModel.call(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/MailBox/SystemDropDown', 'View/App/MailBox/SystemDropDown', 'MailBoxSystemDropDownViewModel'], SystemDropDownMailBoxUserView);
|
||||
_.extend(SystemDropDownMailBoxUserView.prototype, AbstractSystemDropDownViewModel.prototype);
|
||||
|
||||
module.exports = SystemDropDownMailBoxUserView;
|
||||
|
||||
}());
|
||||
module.exports = SystemDropDownMailBoxUserView;
|
||||
|
|
|
|||
|
|
@ -1,102 +1,91 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
key = require('key'),
|
||||
|
||||
'use strict';
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
key = require('key'),
|
||||
Cache = require('Common/Cache'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Links = require('Common/Links'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Cache = require('Common/Cache'),
|
||||
Settings = require('Storage/Settings'),
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} oScreen
|
||||
*/
|
||||
function MenuSettingsUserView(oScreen)
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'SettingsMenu');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
/**
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MenuSettingsUserView(oScreen)
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'SettingsMenu');
|
||||
this.mobile = Settings.appSettingsGet('mobile');
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
this.menu = oScreen.menu;
|
||||
|
||||
this.mobile = Settings.appSettingsGet('mobile');
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
kn.extendAsViewModel(['View/User/Settings/Menu', 'View/App/Settings/Menu', 'SettingsMenuViewModel'], MenuSettingsUserView);
|
||||
_.extend(MenuSettingsUserView.prototype, AbstractView.prototype);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/Settings/Menu', 'View/App/Settings/Menu', 'SettingsMenuViewModel'], MenuSettingsUserView);
|
||||
_.extend(MenuSettingsUserView.prototype, AbstractView.prototype);
|
||||
|
||||
MenuSettingsUserView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
MenuSettingsUserView.prototype.onBuild = function(oDom)
|
||||
{
|
||||
// var self = this;
|
||||
// key('esc', Enums.KeyState.Settings, function () {
|
||||
// key('esc', Enums.KeyState.Settings, function() {
|
||||
// self.backToMailBoxClick();
|
||||
// });
|
||||
|
||||
if (this.mobile)
|
||||
if (this.mobile)
|
||||
{
|
||||
oDom
|
||||
.on('click', '.b-settings-menu .e-item.selectable', function() {
|
||||
Globals.leftPanelDisabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
key('up, down', Enums.KeyState.Settings, _.throttle(function(event, handler) {
|
||||
|
||||
var
|
||||
sH = '',
|
||||
iIndex = -1,
|
||||
bUp = handler && 'up' === handler.shortcut,
|
||||
$items = $('.b-settings-menu .e-item', oDom);
|
||||
|
||||
if (event && $items.length)
|
||||
{
|
||||
oDom
|
||||
.on('click', '.b-settings-menu .e-item.selectable', function () {
|
||||
Globals.leftPanelDisabled(true);
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
key('up, down', Enums.KeyState.Settings, _.throttle(function (event, handler) {
|
||||
|
||||
var
|
||||
sH = '',
|
||||
iIndex = -1,
|
||||
bUp = handler && 'up' === handler.shortcut,
|
||||
$items = $('.b-settings-menu .e-item', oDom)
|
||||
;
|
||||
|
||||
if (event && $items.length)
|
||||
iIndex = $items.index($items.filter('.selected'));
|
||||
if (bUp && 0 < iIndex)
|
||||
{
|
||||
iIndex = $items.index($items.filter('.selected'));
|
||||
if (bUp && iIndex > 0)
|
||||
{
|
||||
iIndex--;
|
||||
}
|
||||
else if (!bUp && iIndex < $items.length - 1)
|
||||
{
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
sH = $items.eq(iIndex).attr('href');
|
||||
if (sH)
|
||||
{
|
||||
kn.setHash(sH, false, true);
|
||||
}
|
||||
iIndex -= 1;
|
||||
}
|
||||
else if (!bUp && iIndex < $items.length - 1)
|
||||
{
|
||||
iIndex += 1;
|
||||
}
|
||||
|
||||
}, 200));
|
||||
};
|
||||
sH = $items.eq(iIndex).attr('href');
|
||||
if (sH)
|
||||
{
|
||||
kn.setHash(sH, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
MenuSettingsUserView.prototype.link = function (sRoute)
|
||||
{
|
||||
return Links.settings(sRoute);
|
||||
};
|
||||
}, 200));
|
||||
};
|
||||
|
||||
MenuSettingsUserView.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(Links.inbox(Cache.getFolderInboxName()));
|
||||
};
|
||||
MenuSettingsUserView.prototype.link = function(sRoute)
|
||||
{
|
||||
return Links.settings(sRoute);
|
||||
};
|
||||
|
||||
module.exports = MenuSettingsUserView;
|
||||
MenuSettingsUserView.prototype.backToMailBoxClick = function()
|
||||
{
|
||||
kn.setHash(Links.inbox(Cache.getFolderInboxName()));
|
||||
};
|
||||
|
||||
}());
|
||||
module.exports = MenuSettingsUserView;
|
||||
|
|
|
|||
|
|
@ -1,76 +1,68 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
'use strict';
|
||||
Globals = require('Common/Globals'),
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'SettingsPane');
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
this.mobile = Settings.appSettingsGet('mobile');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsUserView()
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/Settings/Pane', 'View/App/Settings/Pane', 'SettingsPaneViewModel'], PaneSettingsUserView);
|
||||
_.extend(PaneSettingsUserView.prototype, AbstractView.prototype);
|
||||
|
||||
PaneSettingsUserView.prototype.onShow = function()
|
||||
{
|
||||
require('Stores/User/Message').message(null);
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.hideLeft = function(oItem, oEvent)
|
||||
{
|
||||
oEvent.preventDefault();
|
||||
oEvent.stopPropagation();
|
||||
|
||||
Globals.leftPanelDisabled(true);
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.showLeft = function(oItem, oEvent)
|
||||
{
|
||||
oEvent.preventDefault();
|
||||
oEvent.stopPropagation();
|
||||
|
||||
Globals.leftPanelDisabled(false);
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.onBuild = function(oDom)
|
||||
{
|
||||
if (this.mobile)
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'SettingsPane');
|
||||
|
||||
this.mobile = Settings.appSettingsGet('mobile');
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
oDom
|
||||
.on('click', function() {
|
||||
Globals.leftPanelDisabled(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
kn.extendAsViewModel(['View/User/Settings/Pane', 'View/App/Settings/Pane', 'SettingsPaneViewModel'], PaneSettingsUserView);
|
||||
_.extend(PaneSettingsUserView.prototype, AbstractView.prototype);
|
||||
PaneSettingsUserView.prototype.backToMailBoxClick = function()
|
||||
{
|
||||
kn.setHash(require('Common/Links').inbox(
|
||||
require('Common/Cache').getFolderInboxName()));
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.onShow = function ()
|
||||
{
|
||||
require('Stores/User/Message').message(null);
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.hideLeft = function (oItem, oEvent)
|
||||
{
|
||||
oEvent.preventDefault();
|
||||
oEvent.stopPropagation();
|
||||
|
||||
Globals.leftPanelDisabled(true);
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.showLeft = function (oItem, oEvent)
|
||||
{
|
||||
oEvent.preventDefault();
|
||||
oEvent.stopPropagation();
|
||||
|
||||
Globals.leftPanelDisabled(false);
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
if (this.mobile)
|
||||
{
|
||||
oDom
|
||||
.on('click', function () {
|
||||
Globals.leftPanelDisabled(true);
|
||||
})
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(require('Common/Links').inbox(
|
||||
require('Common/Cache').getFolderInboxName()));
|
||||
};
|
||||
|
||||
module.exports = PaneSettingsUserView;
|
||||
|
||||
}());
|
||||
module.exports = PaneSettingsUserView;
|
||||
|
|
|
|||
|
|
@ -1,28 +1,21 @@
|
|||
|
||||
(function () {
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
'use strict';
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractSystemDropDownUserView = require('View/User/AbstractSystemDropDown');
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownUserView
|
||||
*/
|
||||
function SystemDropDownSettingsUserView()
|
||||
{
|
||||
AbstractSystemDropDownUserView.call(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractSystemDropDownUserView = require('View/User/AbstractSystemDropDown')
|
||||
;
|
||||
kn.extendAsViewModel(['View/User/Settings/SystemDropDown', 'View/App/Settings/SystemDropDown', 'SettingsSystemDropDownViewModel'], SystemDropDownSettingsUserView);
|
||||
_.extend(SystemDropDownSettingsUserView.prototype, AbstractSystemDropDownUserView.prototype);
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownUserView
|
||||
*/
|
||||
function SystemDropDownSettingsUserView()
|
||||
{
|
||||
AbstractSystemDropDownUserView.call(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/Settings/SystemDropDown', 'View/App/Settings/SystemDropDown', 'SettingsSystemDropDownViewModel'], SystemDropDownSettingsUserView);
|
||||
_.extend(SystemDropDownSettingsUserView.prototype, AbstractSystemDropDownUserView.prototype);
|
||||
|
||||
module.exports = SystemDropDownSettingsUserView;
|
||||
|
||||
}());
|
||||
module.exports = SystemDropDownSettingsUserView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue