mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Code refactoring
Fixed owncloud password encoder/decoder (#291) Fixed ckeditor in ownCloud iframe (Closes #302) Release commit
This commit is contained in:
parent
7a374ebe03
commit
06274c6a7c
112 changed files with 2667 additions and 1862 deletions
121
dev/View/Admin/Login.js
Normal file
121
dev/View/Admin/Login.js
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Remote = require('Storage/Admin/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginAdminView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'AdminLogin');
|
||||
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.loginFocus = ko.observable(false);
|
||||
|
||||
this.login.subscribe(function () {
|
||||
this.loginError(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.submitCommand = Utils.createCommand(this, function () {
|
||||
|
||||
Utils.triggerAutocompleteInputChange();
|
||||
|
||||
this.loginError('' === Utils.trim(this.login()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.loginError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin(_.bind(function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').loginAndLogoutReload();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.login(), this.password());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Login', 'AdminLoginViewModel'], LoginAdminView);
|
||||
_.extend(LoginAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
LoginAdminView.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(_.bind(function () {
|
||||
this.loginFocus(true);
|
||||
}, this), 100);
|
||||
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.onHide = function ()
|
||||
{
|
||||
this.loginFocus(false);
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.onBuild = function ()
|
||||
{
|
||||
Utils.triggerAutocompleteInputChange(true);
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.submitForm = function ()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
|
||||
module.exports = LoginAdminView;
|
||||
|
||||
}());
|
||||
42
dev/View/Admin/Settings/Menu.js
Normal file
42
dev/View/Admin/Settings/Menu.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MenuSettingsAdminView(oScreen)
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'AdminMenu');
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Menu', 'AdminSettingsMenuViewModel'], MenuSettingsAdminView);
|
||||
_.extend(MenuSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
MenuSettingsAdminView.prototype.link = function (sRoute)
|
||||
{
|
||||
return '#/' + sRoute;
|
||||
};
|
||||
|
||||
module.exports = MenuSettingsAdminView;
|
||||
|
||||
}());
|
||||
46
dev/View/Admin/Settings/Pane.js
Normal file
46
dev/View/Admin/Settings/Pane.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/Admin/Data'),
|
||||
Remote = require('Storage/Admin/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsAdminView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'AdminPane');
|
||||
|
||||
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(Settings.settingsGet('Version'));
|
||||
|
||||
this.adminManLoadingVisibility = Data.adminManLoadingVisibility;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Pane', 'AdminSettingsPaneViewModel'], PaneSettingsAdminView);
|
||||
_.extend(PaneSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
PaneSettingsAdminView.prototype.logoutClick = function ()
|
||||
{
|
||||
Remote.adminLogout(function () {
|
||||
require('App/Admin').loginAndLogoutReload();
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = PaneSettingsAdminView;
|
||||
|
||||
}());
|
||||
34
dev/View/App/About.js
Normal file
34
dev/View/App/About.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AboutAppView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'About');
|
||||
|
||||
this.version = ko.observable(Settings.settingsGet('Version'));
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/About', 'AboutViewModel'], AboutAppView);
|
||||
_.extend(AboutAppView.prototype, AbstractView.prototype);
|
||||
|
||||
module.exports = AboutAppView;
|
||||
|
||||
}());
|
||||
120
dev/View/App/AbstractSystemDropDown.js
Normal file
120
dev/View/App/AbstractSystemDropDown.js
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/App/Data'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AbstractSystemDropDownAppView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'SystemDropDown');
|
||||
|
||||
this.accounts = Data.accounts;
|
||||
this.accountEmail = Data.accountEmail;
|
||||
this.accountsLoading = Data.accountsLoading;
|
||||
|
||||
this.accountMenuDropdownTrigger = ko.observable(false);
|
||||
|
||||
this.capaAdditionalAccounts = Settings.capa(Enums.Capa.AdditionalAccounts);
|
||||
|
||||
this.loading = ko.computed(function () {
|
||||
return this.accountsLoading();
|
||||
}, this);
|
||||
|
||||
this.accountClick = _.bind(this.accountClick, this);
|
||||
}
|
||||
|
||||
_.extend(AbstractSystemDropDownAppView.prototype, AbstractView.prototype);
|
||||
|
||||
AbstractSystemDropDownAppView.prototype.accountClick = function (oAccount, oEvent)
|
||||
{
|
||||
if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
|
||||
{
|
||||
var self = this;
|
||||
this.accountsLoading(true);
|
||||
_.delay(function () {
|
||||
self.accountsLoading(false);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
AbstractSystemDropDownAppView.prototype.emailTitle = function ()
|
||||
{
|
||||
return Data.accountEmail();
|
||||
};
|
||||
|
||||
AbstractSystemDropDownAppView.prototype.settingsClick = function ()
|
||||
{
|
||||
require('Knoin/Knoin').setHash(LinkBuilder.settings());
|
||||
};
|
||||
|
||||
AbstractSystemDropDownAppView.prototype.settingsHelp = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
||||
};
|
||||
|
||||
AbstractSystemDropDownAppView.prototype.addAccountClick = function ()
|
||||
{
|
||||
if (this.capaAdditionalAccounts)
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/AddAccount'));
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSystemDropDownAppView.prototype.logoutClick = function ()
|
||||
{
|
||||
Remote.logout(function () {
|
||||
if (window.__rlah_clear)
|
||||
{
|
||||
window.__rlah_clear();
|
||||
}
|
||||
|
||||
require('App/App').loginAndLogoutReload(true,
|
||||
Settings.settingsGet('ParentEmail') && 0 < Settings.settingsGet('ParentEmail').length);
|
||||
});
|
||||
};
|
||||
|
||||
AbstractSystemDropDownAppView.prototype.onBuild = function ()
|
||||
{
|
||||
var self = this;
|
||||
key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
|
||||
if (self.viewModelVisibility())
|
||||
{
|
||||
self.accountMenuDropdownTrigger(true);
|
||||
}
|
||||
});
|
||||
|
||||
// shortcuts help
|
||||
key('shift+/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
|
||||
if (self.viewModelVisibility())
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = AbstractSystemDropDownAppView;
|
||||
|
||||
}());
|
||||
368
dev/View/App/Login.js
Normal file
368
dev/View/App/Login.js
Normal file
|
|
@ -0,0 +1,368 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/App/Data'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginAppView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'Login');
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.signMe = ko.observable(false);
|
||||
|
||||
this.additionalCode = ko.observable('');
|
||||
this.additionalCode.error = ko.observable(false);
|
||||
this.additionalCode.focused = ko.observable(false);
|
||||
this.additionalCode.visibility = ko.observable(false);
|
||||
this.additionalCodeSignMe = ko.observable(false);
|
||||
|
||||
this.logoImg = Utils.trim(Settings.settingsGet('LoginLogo'));
|
||||
this.loginDescription = Utils.trim(Settings.settingsGet('LoginDescription'));
|
||||
this.logoCss = Utils.trim(Settings.settingsGet('LoginCss'));
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
this.submitFocus = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.additionalCode.subscribe(function () {
|
||||
this.additionalCode.error(false);
|
||||
}, this);
|
||||
|
||||
this.additionalCode.visibility.subscribe(function () {
|
||||
this.additionalCode.error(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin;
|
||||
|
||||
this.langRequest = ko.observable(false);
|
||||
this.mainLanguage = Data.mainLanguage;
|
||||
this.bSendLanguage = false;
|
||||
|
||||
this.mainLanguageFullName = ko.computed(function () {
|
||||
return Utils.convertLangName(this.mainLanguage());
|
||||
}, 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('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.additionalCode.visibility())
|
||||
{
|
||||
this.additionalCode.error('' === Utils.trim(this.additionalCode()));
|
||||
}
|
||||
|
||||
if (this.emailError() || this.passwordError() || this.additionalCode.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
var
|
||||
sPassword = this.password(),
|
||||
|
||||
fLoginRequest = _.bind(function (sPassword) {
|
||||
|
||||
Remote.login(_.bind(function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
if (oData.TwoFactorAuth)
|
||||
{
|
||||
this.additionalCode('');
|
||||
this.additionalCode.visibility(true);
|
||||
this.additionalCode.focused(true);
|
||||
|
||||
this.submitRequest(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
require('App/App').loginAndLogoutReload();
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
|
||||
if ('' === this.submitError())
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.email(), '', sPassword, !!this.signMe(),
|
||||
this.bSendLanguage ? this.mainLanguage() : '',
|
||||
this.additionalCode.visibility() ? this.additionalCode() : '',
|
||||
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
|
||||
);
|
||||
|
||||
}, this)
|
||||
;
|
||||
|
||||
if (!!Settings.settingsGet('UseRsaEncryption') && Utils.rsaEncode.supported)
|
||||
{
|
||||
Remote.getPublicKey(_.bind(function (sResult, oData) {
|
||||
|
||||
var bRequest = false;
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
Utils.isArray(oData.Result) && oData.Result[0] && oData.Result[1] && oData.Result[2])
|
||||
{
|
||||
var sEncryptedPassword = Utils.rsaEncode(sPassword, oData.Result[0], oData.Result[1], oData.Result[2]);
|
||||
if (sEncryptedPassword)
|
||||
{
|
||||
fLoginRequest(sEncryptedPassword);
|
||||
bRequest = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bRequest)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
fLoginRequest(sPassword);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.facebookLoginEnabled = ko.observable(false);
|
||||
|
||||
this.facebookCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(LinkBuilder.socialFacebook(), 'Facebook',
|
||||
'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.facebookLoginEnabled();
|
||||
});
|
||||
|
||||
this.googleLoginEnabled = ko.observable(false);
|
||||
|
||||
this.googleCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(LinkBuilder.socialGoogle(), 'Google',
|
||||
'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.googleLoginEnabled();
|
||||
});
|
||||
|
||||
this.twitterLoginEnabled = ko.observable(false);
|
||||
|
||||
this.twitterCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(LinkBuilder.socialTwitter(), 'Twitter',
|
||||
'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && this.twitterLoginEnabled();
|
||||
});
|
||||
|
||||
this.socialLoginEnabled = ko.computed(function () {
|
||||
|
||||
var
|
||||
bF = this.facebookLoginEnabled(),
|
||||
bG = this.googleLoginEnabled(),
|
||||
bT = this.twitterLoginEnabled()
|
||||
;
|
||||
|
||||
return bF || bG || bT;
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/Login', 'LoginViewModel'], LoginAppView);
|
||||
_.extend(LoginAppView.prototype, AbstractView.prototype);
|
||||
|
||||
LoginAppView.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(_.bind(function () {
|
||||
if ('' !== this.email() && '' !== this.password())
|
||||
{
|
||||
this.submitFocus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.emailFocus(true);
|
||||
}
|
||||
|
||||
if (Settings.settingsGet('UserLanguage'))
|
||||
{
|
||||
$.cookie('rllang', Data.language(), {'expires': 30});
|
||||
}
|
||||
|
||||
}, this), 100);
|
||||
};
|
||||
|
||||
LoginAppView.prototype.onHide = function ()
|
||||
{
|
||||
this.submitFocus(false);
|
||||
this.emailFocus(false);
|
||||
};
|
||||
|
||||
LoginAppView.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
sJsHash = Settings.settingsGet('JsHash'),
|
||||
fSocial = function (iErrorCode) {
|
||||
iErrorCode = Utils.pInt(iErrorCode);
|
||||
if (0 === iErrorCode)
|
||||
{
|
||||
self.submitRequest(true);
|
||||
require('App/App').loginAndLogoutReload();
|
||||
}
|
||||
else
|
||||
{
|
||||
self.submitError(Utils.getNotification(iErrorCode));
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
|
||||
this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
|
||||
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial'));
|
||||
|
||||
switch ((Settings.settingsGet('SignMe') || 'unused').toLowerCase())
|
||||
{
|
||||
case Enums.LoginSignMeTypeAsString.DefaultOff:
|
||||
this.signMeType(Enums.LoginSignMeType.DefaultOff);
|
||||
break;
|
||||
case Enums.LoginSignMeTypeAsString.DefaultOn:
|
||||
this.signMeType(Enums.LoginSignMeType.DefaultOn);
|
||||
break;
|
||||
default:
|
||||
case Enums.LoginSignMeTypeAsString.Unused:
|
||||
this.signMeType(Enums.LoginSignMeType.Unused);
|
||||
break;
|
||||
}
|
||||
|
||||
this.email(Data.devEmail);
|
||||
this.password(Data.devPassword);
|
||||
|
||||
if (this.googleLoginEnabled())
|
||||
{
|
||||
window['rl_' + sJsHash + '_google_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
if (this.facebookLoginEnabled())
|
||||
{
|
||||
window['rl_' + sJsHash + '_facebook_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
if (this.twitterLoginEnabled())
|
||||
{
|
||||
window['rl_' + sJsHash + '_twitter_login_service'] = fSocial;
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
Data.language.subscribe(function (sValue) {
|
||||
|
||||
self.langRequest(true);
|
||||
|
||||
Utils.reloadLanguage(sValue, function() {
|
||||
self.bSendLanguage = true;
|
||||
$.cookie('rllang', sValue, {'expires': 30});
|
||||
}, null, function() {
|
||||
self.langRequest(false);
|
||||
});
|
||||
|
||||
});
|
||||
}, 50);
|
||||
|
||||
Utils.triggerAutocompleteInputChange(true);
|
||||
};
|
||||
|
||||
LoginAppView.prototype.submitForm = function ()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
|
||||
LoginAppView.prototype.selectLanguage = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Languages'));
|
||||
};
|
||||
|
||||
module.exports = LoginAppView;
|
||||
|
||||
}());
|
||||
274
dev/View/App/MailBox/FolderList.js
Normal file
274
dev/View/App/MailBox/FolderList.js
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Cache = require('Storage/App/Cache'),
|
||||
Data = require('Storage/App/Data'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderListMailBoxAppView()
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'MailFolderList');
|
||||
|
||||
this.oContentVisible = null;
|
||||
this.oContentScrollable = null;
|
||||
|
||||
this.messageList = Data.messageList;
|
||||
this.folderList = Data.folderList;
|
||||
this.folderListSystem = Data.folderListSystem;
|
||||
this.foldersChanging = Data.foldersChanging;
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
this.iDropOverTimer = 0;
|
||||
|
||||
this.allowContacts = !!Settings.settingsGet('ContactsIsAllowed');
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/MailBox/FolderList', 'MailBoxFolderListViewModel'], FolderListMailBoxAppView);
|
||||
_.extend(FolderListMailBoxAppView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderListMailBoxAppView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
this.oContentVisible = $('.b-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
var self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function (oEvent) {
|
||||
|
||||
var
|
||||
oFolder = ko.dataFor(this),
|
||||
bCollapsed = false
|
||||
;
|
||||
|
||||
if (oFolder && oEvent)
|
||||
{
|
||||
bCollapsed = oFolder.collapsed();
|
||||
require('App/App').setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||
|
||||
oFolder.collapsed(!bCollapsed);
|
||||
oEvent.preventDefault();
|
||||
oEvent.stopPropagation();
|
||||
}
|
||||
})
|
||||
.on('click', '.b-folders .e-item .e-link.selectable', function (oEvent) {
|
||||
|
||||
oEvent.preventDefault();
|
||||
|
||||
var
|
||||
oFolder = ko.dataFor(this)
|
||||
;
|
||||
|
||||
if (oFolder)
|
||||
{
|
||||
if (Enums.Layout.NoPreview === Data.layout())
|
||||
{
|
||||
Data.message(null);
|
||||
}
|
||||
|
||||
if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw())
|
||||
{
|
||||
Cache.setFolderHash(oFolder.fullNameRaw, '');
|
||||
}
|
||||
|
||||
kn.setHash(LinkBuilder.mailBox(oFolder.fullNameHash));
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
key('up, down', Enums.KeyState.FolderList, function (event, handler) {
|
||||
|
||||
var
|
||||
iIndex = -1,
|
||||
iKeyCode = handler && 'up' === handler.shortcut ? 38 : 40,
|
||||
$items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom)
|
||||
;
|
||||
|
||||
if (event && $items.length)
|
||||
{
|
||||
iIndex = $items.index($items.filter('.focused'));
|
||||
if (-1 < iIndex)
|
||||
{
|
||||
$items.eq(iIndex).removeClass('focused');
|
||||
}
|
||||
|
||||
if (iKeyCode === 38 && iIndex > 0)
|
||||
{
|
||||
iIndex--;
|
||||
}
|
||||
else if (iKeyCode === 40 && iIndex < $items.length - 1)
|
||||
{
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
$items.eq(iIndex).addClass('focused');
|
||||
self.scrollToFocused();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
key('enter', Enums.KeyState.FolderList, function () {
|
||||
var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
|
||||
if ($items.length && $items[0])
|
||||
{
|
||||
self.folderList.focused(false);
|
||||
$items.click();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
key('space', Enums.KeyState.FolderList, function () {
|
||||
var bCollapsed = true, oFolder = null, $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
|
||||
if ($items.length && $items[0])
|
||||
{
|
||||
oFolder = ko.dataFor($items[0]);
|
||||
if (oFolder)
|
||||
{
|
||||
bCollapsed = oFolder.collapsed();
|
||||
require('App/App').setExpandedFolder(oFolder.fullNameHash, bCollapsed);
|
||||
oFolder.collapsed(!bCollapsed);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function () {
|
||||
self.folderList.focused(false);
|
||||
return false;
|
||||
});
|
||||
|
||||
self.folderList.focused.subscribe(function (bValue) {
|
||||
$('.b-folders .e-item .e-link.focused', oDom).removeClass('focused');
|
||||
if (bValue)
|
||||
{
|
||||
$('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
FolderListMailBoxAppView.prototype.messagesDropOver = function (oFolder)
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
if (oFolder && oFolder.collapsed())
|
||||
{
|
||||
this.iDropOverTimer = window.setTimeout(function () {
|
||||
oFolder.collapsed(false);
|
||||
require('App/App').setExpandedFolder(oFolder.fullNameHash, true);
|
||||
Utils.windowResize();
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxAppView.prototype.messagesDropOut = function ()
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
};
|
||||
|
||||
FolderListMailBoxAppView.prototype.scrollToFocused = function ()
|
||||
{
|
||||
if (!this.oContentVisible || !this.oContentScrollable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var
|
||||
iOffset = 20,
|
||||
oFocused = $('.e-item .e-link.focused', this.oContentScrollable),
|
||||
oPos = oFocused.position(),
|
||||
iVisibleHeight = this.oContentVisible.height(),
|
||||
iFocusedHeight = oFocused.outerHeight()
|
||||
;
|
||||
|
||||
if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight))
|
||||
{
|
||||
if (oPos.top < 0)
|
||||
{
|
||||
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {FolderModel} oToFolder
|
||||
* @param {{helper:jQuery}} oUi
|
||||
*/
|
||||
FolderListMailBoxAppView.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/App').moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxAppView.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
};
|
||||
|
||||
FolderListMailBoxAppView.prototype.createFolder = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/FolderCreate'));
|
||||
};
|
||||
|
||||
FolderListMailBoxAppView.prototype.configureFolders = function ()
|
||||
{
|
||||
kn.setHash(LinkBuilder.settings('folders'));
|
||||
};
|
||||
|
||||
FolderListMailBoxAppView.prototype.contactsClick = function ()
|
||||
{
|
||||
if (this.allowContacts)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Contacts'));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderListMailBoxAppView;
|
||||
|
||||
}());
|
||||
935
dev/View/App/MailBox/MessageList.js
Normal file
935
dev/View/App/MailBox/MessageList.js
Normal file
|
|
@ -0,0 +1,935 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
Jua = require('Jua'),
|
||||
ifvisible = require('ifvisible'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
Events = require('Common/Events'),
|
||||
Selector = require('Common/Selector'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Cache = require('Storage/App/Cache'),
|
||||
Data = require('Storage/App/Data'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MessageListMailBoxAppView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'MailMessageList');
|
||||
|
||||
this.sLastUid = null;
|
||||
this.bPrefetch = false;
|
||||
this.emptySubjectValue = '';
|
||||
|
||||
this.hideDangerousActions = !!Settings.settingsGet('HideDangerousActions');
|
||||
|
||||
this.popupVisibility = Globals.popupVisibility;
|
||||
|
||||
this.message = Data.message;
|
||||
this.messageList = Data.messageList;
|
||||
this.folderList = Data.folderList;
|
||||
this.currentMessage = Data.currentMessage;
|
||||
this.isMessageSelected = Data.isMessageSelected;
|
||||
this.messageListSearch = Data.messageListSearch;
|
||||
this.messageListError = Data.messageListError;
|
||||
this.folderMenuForMove = Data.folderMenuForMove;
|
||||
|
||||
this.useCheckboxesInList = Data.useCheckboxesInList;
|
||||
|
||||
this.mainMessageListSearch = Data.mainMessageListSearch;
|
||||
this.messageListEndFolder = Data.messageListEndFolder;
|
||||
|
||||
this.messageListChecked = Data.messageListChecked;
|
||||
this.messageListCheckedOrSelected = Data.messageListCheckedOrSelected;
|
||||
this.messageListCheckedOrSelectedUidsWithSubMails = Data.messageListCheckedOrSelectedUidsWithSubMails;
|
||||
this.messageListCompleteLoadingThrottle = Data.messageListCompleteLoadingThrottle;
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.emptySubjectValue = Utils.i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT');
|
||||
}, this);
|
||||
|
||||
this.userQuota = Data.userQuota;
|
||||
this.userUsageSize = Data.userUsageSize;
|
||||
this.userUsageProc = Data.userUsageProc;
|
||||
|
||||
this.moveDropdownTrigger = ko.observable(false);
|
||||
this.moreDropdownTrigger = ko.observable(false);
|
||||
|
||||
// append drag and drop
|
||||
this.dragOver = ko.observable(false).extend({'throttle': 1});
|
||||
this.dragOverEnter = ko.observable(false).extend({'throttle': 1});
|
||||
this.dragOverArea = ko.observable(null);
|
||||
this.dragOverBodyArea = ko.observable(null);
|
||||
|
||||
this.messageListItemTemplate = ko.computed(function () {
|
||||
return Enums.Layout.NoPreview !== Data.layout() ?
|
||||
'MailMessageListItem' : 'MailMessageListItemNoPreviewPane';
|
||||
});
|
||||
|
||||
this.messageListSearchDesc = ko.computed(function () {
|
||||
var sValue = Data.messageListEndSearch();
|
||||
return '' === sValue ? '' : Utils.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue});
|
||||
});
|
||||
|
||||
this.messageListPagenator = ko.computed(Utils.computedPagenatorHelper(Data.messageListPage, Data.messageListPageCount));
|
||||
|
||||
this.checkAll = ko.computed({
|
||||
'read': function () {
|
||||
return 0 < Data.messageListChecked().length;
|
||||
},
|
||||
|
||||
'write': function (bValue) {
|
||||
bValue = !!bValue;
|
||||
_.each(Data.messageList(), function (oMessage) {
|
||||
oMessage.checked(bValue);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.inputMessageListSearchFocus = ko.observable(false);
|
||||
|
||||
this.sLastSearchValue = '';
|
||||
this.inputProxyMessageListSearch = ko.computed({
|
||||
'read': this.mainMessageListSearch,
|
||||
'write': function (sValue) {
|
||||
this.sLastSearchValue = sValue;
|
||||
},
|
||||
'owner': this
|
||||
});
|
||||
|
||||
this.isIncompleteChecked = ko.computed(function () {
|
||||
var
|
||||
iM = Data.messageList().length,
|
||||
iC = Data.messageListChecked().length
|
||||
;
|
||||
return 0 < iM && 0 < iC && iM > iC;
|
||||
}, this);
|
||||
|
||||
this.hasMessages = ko.computed(function () {
|
||||
return 0 < this.messageList().length;
|
||||
}, this);
|
||||
|
||||
this.hasCheckedOrSelectedLines = ko.computed(function () {
|
||||
return 0 < this.messageListCheckedOrSelected().length;
|
||||
}, this);
|
||||
|
||||
this.isSpamFolder = ko.computed(function () {
|
||||
return Data.spamFolder() === this.messageListEndFolder() &&
|
||||
'' !== Data.spamFolder();
|
||||
}, this);
|
||||
|
||||
this.isSpamDisabled = ko.computed(function () {
|
||||
return Consts.Values.UnuseOptionValue === Data.spamFolder();
|
||||
}, this);
|
||||
|
||||
this.isTrashFolder = ko.computed(function () {
|
||||
return Data.trashFolder() === this.messageListEndFolder() &&
|
||||
'' !== Data.trashFolder();
|
||||
}, this);
|
||||
|
||||
this.isDraftFolder = ko.computed(function () {
|
||||
return Data.draftFolder() === this.messageListEndFolder() &&
|
||||
'' !== Data.draftFolder();
|
||||
}, this);
|
||||
|
||||
this.isSentFolder = ko.computed(function () {
|
||||
return Data.sentFolder() === this.messageListEndFolder() &&
|
||||
'' !== Data.sentFolder();
|
||||
}, this);
|
||||
|
||||
this.isArchiveFolder = ko.computed(function () {
|
||||
return Data.archiveFolder() === this.messageListEndFolder() &&
|
||||
'' !== Data.archiveFolder();
|
||||
}, this);
|
||||
|
||||
this.isArchiveDisabled = ko.computed(function () {
|
||||
return Consts.Values.UnuseOptionValue === Data.archiveFolder();
|
||||
}, this);
|
||||
|
||||
this.canBeMoved = this.hasCheckedOrSelectedLines;
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
kn.showScreenPopup(require('View/Popup/FolderClear'), [Data.currentFolder()]);
|
||||
});
|
||||
|
||||
this.multyForwardCommand = Utils.createCommand(this, function () {
|
||||
kn.showScreenPopup(require('View/Popup/Compose'), [
|
||||
Enums.ComposeType.ForwardAsAttachment, Data.messageListCheckedOrSelected()]);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), false);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.deleteCommand = Utils.createCommand(this, function () {
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.archiveCommand = Utils.createCommand(this, function () {
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.Archive,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.spamCommand = Utils.createCommand(this, function () {
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.Spam,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.notSpamCommand = Utils.createCommand(this, function () {
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.NotSpam,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.moveCommand = Utils.createCommand(this, Utils.emptyFunction, this.canBeMoved);
|
||||
|
||||
this.reloadCommand = Utils.createCommand(this, function () {
|
||||
if (!Data.messageListCompleteLoadingThrottle())
|
||||
{
|
||||
require('App/App').reloadMessageList(false, true);
|
||||
}
|
||||
});
|
||||
|
||||
this.quotaTooltip = _.bind(this.quotaTooltip, this);
|
||||
|
||||
this.selector = new Selector(this.messageList, this.currentMessage,
|
||||
'.messageListItem .actionHandle', '.messageListItem.selected', '.messageListItem .checkboxMessage',
|
||||
'.messageListItem.focused');
|
||||
|
||||
this.selector.on('onItemSelect', _.bind(function (oMessage) {
|
||||
if (oMessage)
|
||||
{
|
||||
Data.message(Data.staticMessageList.populateByMessageListItem(oMessage));
|
||||
this.populateMessageBody(Data.message());
|
||||
|
||||
if (Enums.Layout.NoPreview === Data.layout())
|
||||
{
|
||||
kn.setHash(LinkBuilder.messagePreview(), true);
|
||||
Data.message.focused(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.message(null);
|
||||
}
|
||||
}, this));
|
||||
|
||||
this.selector.on('onItemGetUid', function (oMessage) {
|
||||
return oMessage ? oMessage.generateUid() : '';
|
||||
});
|
||||
|
||||
Data.messageListEndHash.subscribe(function () {
|
||||
this.selector.scrollToTop();
|
||||
}, this);
|
||||
|
||||
Data.layout.subscribe(function (mValue) {
|
||||
this.selector.autoSelect(Enums.Layout.NoPreview !== mValue);
|
||||
}, this);
|
||||
|
||||
Data.layout.valueHasMutated();
|
||||
|
||||
Events
|
||||
.sub('mailbox.message-list.selector.go-down', function () {
|
||||
this.selector.goDown(true);
|
||||
}, this)
|
||||
.sub('mailbox.message-list.selector.go-up', function () {
|
||||
this.selector.goUp(true);
|
||||
}, this)
|
||||
;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/MailBox/MessageList', 'MailBoxMessageListViewModel'], MessageListMailBoxAppView);
|
||||
_.extend(MessageListMailBoxAppView.prototype, AbstractView.prototype);
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
MessageListMailBoxAppView.prototype.emptySubjectValue = '';
|
||||
|
||||
MessageListMailBoxAppView.prototype.searchEnterAction = function ()
|
||||
{
|
||||
this.mainMessageListSearch(this.sLastSearchValue);
|
||||
this.inputMessageListSearchFocus(false);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
MessageListMailBoxAppView.prototype.printableMessageCountForDeletion = function ()
|
||||
{
|
||||
var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
|
||||
return 1 < iCnt ? ' (' + (100 > iCnt ? iCnt : '99+') + ')' : '';
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.cancelSearch = function ()
|
||||
{
|
||||
this.mainMessageListSearch('');
|
||||
this.inputMessageListSearchFocus(false);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sToFolderFullNameRaw
|
||||
* @param {boolean} bCopy
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageListMailBoxAppView.prototype.moveSelectedMessagesToFolder = function (sToFolderFullNameRaw, bCopy)
|
||||
{
|
||||
if (this.canBeMoved())
|
||||
{
|
||||
require('App/App').moveMessagesToFolder(
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw, bCopy);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.dragAndDronHelper = function (oMessageListItem)
|
||||
{
|
||||
if (oMessageListItem)
|
||||
{
|
||||
oMessageListItem.checked(true);
|
||||
}
|
||||
|
||||
var
|
||||
oEl = Utils.draggeblePlace(),
|
||||
aUids = Data.messageListCheckedOrSelectedUidsWithSubMails()
|
||||
;
|
||||
|
||||
oEl.data('rl-folder', Data.currentFolderFullNameRaw());
|
||||
oEl.data('rl-uids', aUids);
|
||||
oEl.find('.text').text('' + aUids.length);
|
||||
|
||||
_.defer(function () {
|
||||
var aUids = Data.messageListCheckedOrSelectedUidsWithSubMails();
|
||||
|
||||
oEl.data('rl-uids', aUids);
|
||||
oEl.find('.text').text('' + aUids.length);
|
||||
});
|
||||
|
||||
return oEl;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sResult
|
||||
* @param {AjaxJsonDefaultResponse} oData
|
||||
* @param {boolean} bCached
|
||||
*/
|
||||
MessageListMailBoxAppView.prototype.onMessageResponse = function (sResult, oData, bCached)
|
||||
{
|
||||
Data.hideMessageBodies();
|
||||
Data.messageLoading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
Data.setMessage(oData, bCached);
|
||||
}
|
||||
else if (Enums.StorageResultType.Unload === sResult)
|
||||
{
|
||||
Data.message(null);
|
||||
Data.messageError('');
|
||||
}
|
||||
else if (Enums.StorageResultType.Abort !== sResult)
|
||||
{
|
||||
Data.message(null);
|
||||
Data.messageError((oData && oData.ErrorCode ?
|
||||
Utils.getNotification(oData.ErrorCode) :
|
||||
Utils.getNotification(Enums.Notification.UnknownError)));
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.populateMessageBody = function (oMessage)
|
||||
{
|
||||
if (oMessage)
|
||||
{
|
||||
if (Remote.message(this.onMessageResponse, oMessage.folderFullNameRaw, oMessage.uid))
|
||||
{
|
||||
Data.messageLoading(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.log('Error: Unknown message request: ' + oMessage.folderFullNameRaw + ' ~ ' + oMessage.uid + ' [e-101]');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFolderFullNameRaw
|
||||
* @param {number} iSetAction
|
||||
* @param {Array=} aMessages = null
|
||||
*/
|
||||
MessageListMailBoxAppView.prototype.setAction = function (sFolderFullNameRaw, iSetAction, aMessages)
|
||||
{
|
||||
var
|
||||
aUids = [],
|
||||
oFolder = null,
|
||||
iAlreadyUnread = 0
|
||||
;
|
||||
|
||||
if (Utils.isUnd(aMessages))
|
||||
{
|
||||
aMessages = Data.messageListChecked();
|
||||
}
|
||||
|
||||
aUids = _.map(aMessages, function (oMessage) {
|
||||
return oMessage.uid;
|
||||
});
|
||||
|
||||
if ('' !== sFolderFullNameRaw && 0 < aUids.length)
|
||||
{
|
||||
switch (iSetAction) {
|
||||
case Enums.MessageSetAction.SetSeen:
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oMessage.unseen())
|
||||
{
|
||||
iAlreadyUnread++;
|
||||
}
|
||||
|
||||
oMessage.unseen(false);
|
||||
Cache.storeMessageFlagsToCache(oMessage);
|
||||
});
|
||||
|
||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread);
|
||||
}
|
||||
|
||||
Remote.messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, true);
|
||||
break;
|
||||
case Enums.MessageSetAction.UnsetSeen:
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oMessage.unseen())
|
||||
{
|
||||
iAlreadyUnread++;
|
||||
}
|
||||
|
||||
oMessage.unseen(true);
|
||||
Cache.storeMessageFlagsToCache(oMessage);
|
||||
});
|
||||
|
||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread + aUids.length);
|
||||
}
|
||||
Remote.messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, false);
|
||||
break;
|
||||
case Enums.MessageSetAction.SetFlag:
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.flagged(true);
|
||||
Cache.storeMessageFlagsToCache(oMessage);
|
||||
});
|
||||
Remote.messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, true);
|
||||
break;
|
||||
case Enums.MessageSetAction.UnsetFlag:
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.flagged(false);
|
||||
Cache.storeMessageFlagsToCache(oMessage);
|
||||
});
|
||||
Remote.messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, false);
|
||||
break;
|
||||
}
|
||||
|
||||
require('App/App').reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFolderFullNameRaw
|
||||
* @param {number} iSetAction
|
||||
*/
|
||||
MessageListMailBoxAppView.prototype.setActionForAll = function (sFolderFullNameRaw, iSetAction)
|
||||
{
|
||||
var
|
||||
oFolder = null,
|
||||
aMessages = Data.messageList()
|
||||
;
|
||||
|
||||
if ('' !== sFolderFullNameRaw)
|
||||
{
|
||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
|
||||
if (oFolder)
|
||||
{
|
||||
switch (iSetAction) {
|
||||
case Enums.MessageSetAction.SetSeen:
|
||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.unseen(false);
|
||||
});
|
||||
|
||||
oFolder.messageCountUnread(0);
|
||||
Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
|
||||
}
|
||||
|
||||
Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, true);
|
||||
break;
|
||||
case Enums.MessageSetAction.UnsetSeen:
|
||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.unseen(true);
|
||||
});
|
||||
|
||||
oFolder.messageCountUnread(oFolder.messageCountAll());
|
||||
Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
|
||||
}
|
||||
Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, false);
|
||||
break;
|
||||
}
|
||||
|
||||
require('App/App').reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.listSetSeen = function ()
|
||||
{
|
||||
this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen, Data.messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.listSetAllSeen = function ()
|
||||
{
|
||||
this.setActionForAll(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen);
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.listUnsetSeen = function ()
|
||||
{
|
||||
this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetSeen, Data.messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.listSetFlags = function ()
|
||||
{
|
||||
this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetFlag, Data.messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.listUnsetFlags = function ()
|
||||
{
|
||||
this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetFlag, Data.messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.flagMessages = function (oCurrentMessage)
|
||||
{
|
||||
var
|
||||
aChecked = this.messageListCheckedOrSelected(),
|
||||
aCheckedUids = []
|
||||
;
|
||||
|
||||
if (oCurrentMessage)
|
||||
{
|
||||
if (0 < aChecked.length)
|
||||
{
|
||||
aCheckedUids = _.map(aChecked, function (oMessage) {
|
||||
return oMessage.uid;
|
||||
});
|
||||
}
|
||||
|
||||
if (0 < aCheckedUids.length && -1 < Utils.inArray(oCurrentMessage.uid, aCheckedUids))
|
||||
{
|
||||
this.setAction(oCurrentMessage.folderFullNameRaw, oCurrentMessage.flagged() ?
|
||||
Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setAction(oCurrentMessage.folderFullNameRaw, oCurrentMessage.flagged() ?
|
||||
Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oCurrentMessage]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.flagMessagesFast = function (bFlag)
|
||||
{
|
||||
var
|
||||
aChecked = this.messageListCheckedOrSelected(),
|
||||
aFlagged = []
|
||||
;
|
||||
|
||||
if (0 < aChecked.length)
|
||||
{
|
||||
aFlagged = _.filter(aChecked, function (oMessage) {
|
||||
return oMessage.flagged();
|
||||
});
|
||||
|
||||
if (Utils.isUnd(bFlag))
|
||||
{
|
||||
this.setAction(aChecked[0].folderFullNameRaw,
|
||||
aChecked.length === aFlagged.length ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setAction(aChecked[0].folderFullNameRaw,
|
||||
!bFlag ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.seenMessagesFast = function (bSeen)
|
||||
{
|
||||
var
|
||||
aChecked = this.messageListCheckedOrSelected(),
|
||||
aUnseen = []
|
||||
;
|
||||
|
||||
if (0 < aChecked.length)
|
||||
{
|
||||
aUnseen = _.filter(aChecked, function (oMessage) {
|
||||
return oMessage.unseen();
|
||||
});
|
||||
|
||||
if (Utils.isUnd(bSeen))
|
||||
{
|
||||
this.setAction(aChecked[0].folderFullNameRaw,
|
||||
0 < aUnseen.length ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setAction(aChecked[0].folderFullNameRaw,
|
||||
bSeen ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
var self = this;
|
||||
|
||||
this.oContentVisible = $('.b-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
this.oContentVisible.on('click', '.fullThreadHandle', function () {
|
||||
var
|
||||
aList = [],
|
||||
oMessage = ko.dataFor(this)
|
||||
;
|
||||
|
||||
if (oMessage && !oMessage.lastInCollapsedThreadLoading())
|
||||
{
|
||||
Data.messageListThreadFolder(oMessage.folderFullNameRaw);
|
||||
|
||||
aList = Data.messageListThreadUids();
|
||||
|
||||
if (oMessage.lastInCollapsedThread())
|
||||
{
|
||||
aList.push(0 < oMessage.parentUid() ? oMessage.parentUid() : oMessage.uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
aList = _.without(aList, 0 < oMessage.parentUid() ? oMessage.parentUid() : oMessage.uid);
|
||||
}
|
||||
|
||||
Data.messageListThreadUids(_.uniq(aList));
|
||||
|
||||
oMessage.lastInCollapsedThreadLoading(true);
|
||||
oMessage.lastInCollapsedThread(!oMessage.lastInCollapsedThread());
|
||||
|
||||
require('App/App').reloadMessageList();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
this.selector.init(this.oContentVisible, this.oContentScrollable, Enums.KeyState.MessageList);
|
||||
|
||||
oDom
|
||||
.on('click', '.messageList .b-message-list-wrapper', function () {
|
||||
if (self.message.focused())
|
||||
{
|
||||
self.message.focused(false);
|
||||
}
|
||||
})
|
||||
.on('click', '.e-pagenator .e-page', function () {
|
||||
var oPage = ko.dataFor(this);
|
||||
if (oPage)
|
||||
{
|
||||
kn.setHash(LinkBuilder.mailBox(
|
||||
Data.currentFolderFullNameHash(),
|
||||
oPage.value,
|
||||
Data.messageListSearch()
|
||||
));
|
||||
}
|
||||
})
|
||||
.on('click', '.messageList .checkboxCkeckAll', function () {
|
||||
self.checkAll(!self.checkAll());
|
||||
})
|
||||
.on('click', '.messageList .messageListItem .flagParent', function () {
|
||||
self.flagMessages(ko.dataFor(this));
|
||||
})
|
||||
;
|
||||
|
||||
this.initUploaderForAppend();
|
||||
this.initShortcuts();
|
||||
|
||||
if (!Globals.bMobileDevice && Settings.capa(Enums.Capa.Prefetch) && ifvisible)
|
||||
{
|
||||
ifvisible.setIdleDuration(10);
|
||||
|
||||
ifvisible.idle(function () {
|
||||
self.prefetchNextTick();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.initShortcuts = function ()
|
||||
{
|
||||
var self = this;
|
||||
|
||||
// disable print
|
||||
key('ctrl+p, command+p', Enums.KeyState.MessageList, function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
// archive (zip)
|
||||
key('z', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
self.archiveCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
// delete
|
||||
key('delete, shift+delete, shift+3', Enums.KeyState.MessageList, function (event, handler) {
|
||||
if (event)
|
||||
{
|
||||
if (0 < Data.messageListCheckedOrSelected().length)
|
||||
{
|
||||
if (handler && 'shift+delete' === handler.shortcut)
|
||||
{
|
||||
self.deleteWithoutMoveCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
self.deleteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// check mail
|
||||
key('ctrl+r, command+r', [Enums.KeyState.FolderList, Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
self.reloadCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
// check all
|
||||
key('ctrl+a, command+a', Enums.KeyState.MessageList, function () {
|
||||
self.checkAll(!(self.checkAll() && !self.isIncompleteChecked()));
|
||||
return false;
|
||||
});
|
||||
|
||||
// write/compose (open compose popup)
|
||||
key('w,c', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
return false;
|
||||
});
|
||||
|
||||
// important - star/flag messages
|
||||
key('i', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
self.flagMessagesFast();
|
||||
return false;
|
||||
});
|
||||
|
||||
// move
|
||||
key('m', Enums.KeyState.MessageList, function () {
|
||||
self.moveDropdownTrigger(true);
|
||||
return false;
|
||||
});
|
||||
|
||||
// read
|
||||
key('q', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
self.seenMessagesFast(true);
|
||||
return false;
|
||||
});
|
||||
|
||||
// unread
|
||||
key('u', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
self.seenMessagesFast(false);
|
||||
return false;
|
||||
});
|
||||
|
||||
key('shift+f', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
self.multyForwardCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
// search input focus
|
||||
key('/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
self.inputMessageListSearchFocus(true);
|
||||
return false;
|
||||
});
|
||||
|
||||
// cancel search
|
||||
key('esc', Enums.KeyState.MessageList, function () {
|
||||
if ('' !== self.messageListSearchDesc())
|
||||
{
|
||||
self.cancelSearch();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// change focused state
|
||||
key('tab, shift+tab, left, right', Enums.KeyState.MessageList, function (event, handler) {
|
||||
if (event && handler && ('shift+tab' === handler.shortcut || 'left' === handler.shortcut))
|
||||
{
|
||||
self.folderList.focused(true);
|
||||
}
|
||||
else if (self.message())
|
||||
{
|
||||
self.message.focused(true);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// TODO
|
||||
key('ctrl+left, command+left', Enums.KeyState.MessageView, function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
// TODO
|
||||
key('ctrl+right, command+right', Enums.KeyState.MessageView, function () {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.prefetchNextTick = function ()
|
||||
{
|
||||
if (!this.bPrefetch && !ifvisible.now() && this.viewModelVisibility())
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oMessage = _.find(this.messageList(), function (oMessage) {
|
||||
return oMessage &&
|
||||
!Cache.hasRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
|
||||
})
|
||||
;
|
||||
|
||||
if (oMessage)
|
||||
{
|
||||
this.bPrefetch = true;
|
||||
|
||||
Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
|
||||
|
||||
Remote.message(function (sResult, oData) {
|
||||
|
||||
var bNext = !!(Enums.StorageResultType.Success === sResult && oData && oData.Result);
|
||||
|
||||
_.delay(function () {
|
||||
self.bPrefetch = false;
|
||||
if (bNext)
|
||||
{
|
||||
self.prefetchNextTick();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
}, oMessage.folderFullNameRaw, oMessage.uid);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.advancedSearchClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/AdvancedSearch'));
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.quotaTooltip = function ()
|
||||
{
|
||||
return Utils.i18n('MESSAGE_LIST/QUOTA_SIZE', {
|
||||
'SIZE': Utils.friendlySize(this.userUsageSize()),
|
||||
'PROC': this.userUsageProc(),
|
||||
'LIMIT': Utils.friendlySize(this.userQuota())
|
||||
});
|
||||
};
|
||||
|
||||
MessageListMailBoxAppView.prototype.initUploaderForAppend = function ()
|
||||
{
|
||||
if (!Settings.settingsGet('AllowAppendMessage') || !this.dragOverArea())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var
|
||||
oJua = new Jua({
|
||||
'action': LinkBuilder.append(),
|
||||
'name': 'AppendFile',
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'disableFolderDragAndDrop': true,
|
||||
'hidden': {
|
||||
'Folder': function () {
|
||||
return Data.currentFolderFullNameRaw();
|
||||
}
|
||||
},
|
||||
'dragAndDropElement': this.dragOverArea(),
|
||||
'dragAndDropBodyElement': this.dragOverBodyArea()
|
||||
})
|
||||
;
|
||||
|
||||
oJua
|
||||
.on('onDragEnter', _.bind(function () {
|
||||
this.dragOverEnter(true);
|
||||
}, this))
|
||||
.on('onDragLeave', _.bind(function () {
|
||||
this.dragOverEnter(false);
|
||||
}, this))
|
||||
.on('onBodyDragEnter', _.bind(function () {
|
||||
this.dragOver(true);
|
||||
}, this))
|
||||
.on('onBodyDragLeave', _.bind(function () {
|
||||
this.dragOver(false);
|
||||
}, this))
|
||||
.on('onSelect', _.bind(function (sUid, oData) {
|
||||
if (sUid && oData && 'message/rfc822' === oData['Type'])
|
||||
{
|
||||
Data.messageListLoading(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}, this))
|
||||
.on('onComplete', _.bind(function () {
|
||||
require('App/App').reloadMessageList(true, true);
|
||||
}, this))
|
||||
;
|
||||
|
||||
return !!oJua;
|
||||
};
|
||||
|
||||
module.exports = MessageListMailBoxAppView;
|
||||
|
||||
}());
|
||||
722
dev/View/App/MailBox/MessageView.js
Normal file
722
dev/View/App/MailBox/MessageView.js
Normal file
|
|
@ -0,0 +1,722 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Events = require('Common/Events'),
|
||||
|
||||
Cache = require('Storage/App/Cache'),
|
||||
Data = require('Storage/App/Data'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MessageViewMailBoxAppView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'MailMessageView');
|
||||
|
||||
var
|
||||
self = this,
|
||||
sLastEmail = '',
|
||||
createCommandHelper = function (sType) {
|
||||
return Utils.createCommand(self, function () {
|
||||
this.replyOrforward(sType);
|
||||
}, self.canBeRepliedOrForwarded);
|
||||
}
|
||||
;
|
||||
|
||||
this.oMessageScrollerDom = null;
|
||||
|
||||
this.message = Data.message;
|
||||
this.currentMessage = Data.currentMessage;
|
||||
this.messageListChecked = Data.messageListChecked;
|
||||
this.hasCheckedMessages = Data.hasCheckedMessages;
|
||||
this.messageListCheckedOrSelectedUidsWithSubMails = Data.messageListCheckedOrSelectedUidsWithSubMails;
|
||||
this.messageLoading = Data.messageLoading;
|
||||
this.messageLoadingThrottle = Data.messageLoadingThrottle;
|
||||
this.messagesBodiesDom = Data.messagesBodiesDom;
|
||||
this.useThreads = Data.useThreads;
|
||||
this.replySameFolder = Data.replySameFolder;
|
||||
this.layout = Data.layout;
|
||||
this.usePreviewPane = Data.usePreviewPane;
|
||||
this.isMessageSelected = Data.isMessageSelected;
|
||||
this.messageActiveDom = Data.messageActiveDom;
|
||||
this.messageError = Data.messageError;
|
||||
|
||||
this.fullScreenMode = Data.messageFullScreenMode;
|
||||
|
||||
this.showFullInfo = ko.observable(false);
|
||||
this.moreDropdownTrigger = ko.observable(false);
|
||||
this.messageDomFocused = ko.observable(false).extend({'rateLimit': 0});
|
||||
|
||||
this.messageVisibility = ko.computed(function () {
|
||||
return !this.messageLoadingThrottle() && !!this.message();
|
||||
}, this);
|
||||
|
||||
this.message.subscribe(function (oMessage) {
|
||||
if (!oMessage)
|
||||
{
|
||||
this.currentMessage(null);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.canBeRepliedOrForwarded = this.messageVisibility;
|
||||
|
||||
// commands
|
||||
this.closeMessage = Utils.createCommand(this, function () {
|
||||
Data.message(null);
|
||||
});
|
||||
|
||||
this.replyCommand = createCommandHelper(Enums.ComposeType.Reply);
|
||||
this.replyAllCommand = createCommandHelper(Enums.ComposeType.ReplyAll);
|
||||
this.forwardCommand = createCommandHelper(Enums.ComposeType.Forward);
|
||||
this.forwardAsAttachmentCommand = createCommandHelper(Enums.ComposeType.ForwardAsAttachment);
|
||||
this.editAsNewCommand = createCommandHelper(Enums.ComposeType.EditAsNew);
|
||||
|
||||
this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility);
|
||||
|
||||
this.messageEditCommand = Utils.createCommand(this, function () {
|
||||
this.editMessage();
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.deleteCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||
this.message().folderFullNameRaw,
|
||||
[this.message().uid], true);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
[this.message().uid], false);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.archiveCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.Archive,
|
||||
this.message().folderFullNameRaw,
|
||||
[this.message().uid], true);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.spamCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.Spam,
|
||||
this.message().folderFullNameRaw,
|
||||
[this.message().uid], true);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.notSpamCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/App').deleteMessagesFromFolder(Enums.FolderType.NotSpam,
|
||||
this.message().folderFullNameRaw,
|
||||
[this.message().uid], true);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
// viewer
|
||||
this.viewHash = '';
|
||||
this.viewSubject = ko.observable('');
|
||||
this.viewFromShort = ko.observable('');
|
||||
this.viewToShort = ko.observable('');
|
||||
this.viewFrom = ko.observable('');
|
||||
this.viewTo = ko.observable('');
|
||||
this.viewCc = ko.observable('');
|
||||
this.viewBcc = ko.observable('');
|
||||
this.viewDate = ko.observable('');
|
||||
this.viewSize = ko.observable('');
|
||||
this.viewMoment = ko.observable('');
|
||||
this.viewLineAsCcc = ko.observable('');
|
||||
this.viewViewLink = ko.observable('');
|
||||
this.viewDownloadLink = ko.observable('');
|
||||
this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic);
|
||||
this.viewUserPicVisible = ko.observable(false);
|
||||
|
||||
this.viewPgpPassword = ko.observable('');
|
||||
this.viewPgpSignedVerifyStatus = ko.computed(function () {
|
||||
return this.message() ? this.message().pgpSignedVerifyStatus() : Enums.SignedVerifyStatus.None;
|
||||
}, this);
|
||||
|
||||
this.viewPgpSignedVerifyUser = ko.computed(function () {
|
||||
return this.message() ? this.message().pgpSignedVerifyUser() : '';
|
||||
}, this);
|
||||
|
||||
this.message.subscribe(function (oMessage) {
|
||||
|
||||
this.messageActiveDom(null);
|
||||
|
||||
this.viewPgpPassword('');
|
||||
|
||||
if (oMessage)
|
||||
{
|
||||
if (this.viewHash !== oMessage.hash)
|
||||
{
|
||||
this.scrollMessageToTop();
|
||||
}
|
||||
|
||||
this.viewHash = oMessage.hash;
|
||||
this.viewSubject(oMessage.subject());
|
||||
this.viewFromShort(oMessage.fromToLine(true, true));
|
||||
this.viewToShort(oMessage.toToLine(true, true));
|
||||
this.viewFrom(oMessage.fromToLine(false));
|
||||
this.viewTo(oMessage.toToLine(false));
|
||||
this.viewCc(oMessage.ccToLine(false));
|
||||
this.viewBcc(oMessage.bccToLine(false));
|
||||
this.viewDate(oMessage.fullFormatDateValue());
|
||||
this.viewSize(oMessage.friendlySize());
|
||||
this.viewMoment(oMessage.momentDate());
|
||||
this.viewLineAsCcc(oMessage.lineAsCcc());
|
||||
this.viewViewLink(oMessage.viewLink());
|
||||
this.viewDownloadLink(oMessage.downloadLink());
|
||||
|
||||
sLastEmail = oMessage.fromAsSingleEmail();
|
||||
Cache.getUserPic(sLastEmail, function (sPic, $sEmail) {
|
||||
if (sPic !== self.viewUserPic() && sLastEmail === $sEmail)
|
||||
{
|
||||
self.viewUserPicVisible(false);
|
||||
self.viewUserPic(Consts.DataImages.UserDotPic);
|
||||
if ('' !== sPic)
|
||||
{
|
||||
self.viewUserPicVisible(true);
|
||||
self.viewUserPic(sPic);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.viewHash = '';
|
||||
this.scrollMessageToTop();
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
||||
this.fullScreenMode.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
Globals.$html.addClass('rl-message-fullscreen');
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.$html.removeClass('rl-message-fullscreen');
|
||||
}
|
||||
|
||||
Utils.windowResize();
|
||||
});
|
||||
|
||||
this.messageLoadingThrottle.subscribe(function (bV) {
|
||||
if (bV)
|
||||
{
|
||||
Utils.windowResize();
|
||||
}
|
||||
});
|
||||
|
||||
this.goUpCommand = Utils.createCommand(this, function () {
|
||||
Events.pub('mailbox.message-list.selector.go-up');
|
||||
});
|
||||
|
||||
this.goDownCommand = Utils.createCommand(this, function () {
|
||||
Events.pub('mailbox.message-list.selector.go-down');
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/MailBox/MessageView', 'MailBoxMessageViewViewModel'], MessageViewMailBoxAppView);
|
||||
_.extend(MessageViewMailBoxAppView.prototype, AbstractView.prototype);
|
||||
|
||||
MessageViewMailBoxAppView.prototype.isPgpActionVisible = function ()
|
||||
{
|
||||
return Enums.SignedVerifyStatus.Success !== this.viewPgpSignedVerifyStatus();
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.isPgpStatusVerifyVisible = function ()
|
||||
{
|
||||
return Enums.SignedVerifyStatus.None !== this.viewPgpSignedVerifyStatus();
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.isPgpStatusVerifySuccess = function ()
|
||||
{
|
||||
return Enums.SignedVerifyStatus.Success === this.viewPgpSignedVerifyStatus();
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.pgpStatusVerifyMessage = function ()
|
||||
{
|
||||
var sResult = '';
|
||||
switch (this.viewPgpSignedVerifyStatus())
|
||||
{
|
||||
case Enums.SignedVerifyStatus.UnknownPublicKeys:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND');
|
||||
break;
|
||||
case Enums.SignedVerifyStatus.UnknownPrivateKey:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND');
|
||||
break;
|
||||
case Enums.SignedVerifyStatus.Unverified:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE');
|
||||
break;
|
||||
case Enums.SignedVerifyStatus.Error:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR');
|
||||
break;
|
||||
case Enums.SignedVerifyStatus.Success:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': this.viewPgpSignedVerifyUser()
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.fullScreen = function ()
|
||||
{
|
||||
this.fullScreenMode(true);
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.unFullScreen = function ()
|
||||
{
|
||||
this.fullScreenMode(false);
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.toggleFullScreen = function ()
|
||||
{
|
||||
Utils.removeSelection();
|
||||
|
||||
this.fullScreenMode(!this.fullScreenMode());
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sType
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.replyOrforward = function (sType)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'), [sType, Data.message()]);
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
var self = this;
|
||||
this.fullScreenMode.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
self.message.focused(true);
|
||||
}
|
||||
}, this);
|
||||
|
||||
$('.attachmentsPlace', oDom).magnificPopup({
|
||||
'delegate': '.magnificPopupImage:visible',
|
||||
'type': 'image',
|
||||
'gallery': {
|
||||
'enabled': true,
|
||||
'preload': [1, 1],
|
||||
'navigateByImgClick': true
|
||||
},
|
||||
'callbacks': {
|
||||
'open': function() {
|
||||
Globals.useKeyboardShortcuts(false);
|
||||
},
|
||||
'close': function() {
|
||||
Globals.useKeyboardShortcuts(true);
|
||||
}
|
||||
},
|
||||
'mainClass': 'mfp-fade',
|
||||
'removalDelay': 400
|
||||
});
|
||||
|
||||
oDom
|
||||
.on('click', 'a', function (oEvent) {
|
||||
// setup maito protocol
|
||||
return !(!!oEvent && 3 !== oEvent['which'] && Utils.mailToHelper($(this).attr('href'), require('View/Popup/Compose')));
|
||||
})
|
||||
.on('click', '.attachmentsPlace .attachmentPreview', function (oEvent) {
|
||||
if (oEvent && oEvent.stopPropagation)
|
||||
{
|
||||
oEvent.stopPropagation();
|
||||
}
|
||||
})
|
||||
.on('click', '.attachmentsPlace .attachmentItem', function () {
|
||||
|
||||
var
|
||||
oAttachment = ko.dataFor(this)
|
||||
;
|
||||
|
||||
if (oAttachment && oAttachment.download)
|
||||
{
|
||||
require('App/App').download(oAttachment.linkDownload());
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
this.message.focused.subscribe(function (bValue) {
|
||||
if (bValue && !Utils.inFocus()) {
|
||||
this.messageDomFocused(true);
|
||||
} else {
|
||||
this.messageDomFocused(false);
|
||||
this.scrollMessageToTop();
|
||||
this.scrollMessageToLeft();
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.messageDomFocused.subscribe(function (bValue) {
|
||||
if (!bValue && Enums.KeyState.MessageView === Globals.keyScope())
|
||||
{
|
||||
this.message.focused(false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
Globals.keyScope.subscribe(function (sValue) {
|
||||
if (Enums.KeyState.MessageView === sValue && this.message.focused())
|
||||
{
|
||||
this.messageDomFocused(true);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.oMessageScrollerDom = oDom.find('.messageItem .content');
|
||||
this.oMessageScrollerDom = this.oMessageScrollerDom && this.oMessageScrollerDom[0] ? this.oMessageScrollerDom : null;
|
||||
|
||||
this.initShortcuts();
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.escShortcuts = function ()
|
||||
{
|
||||
if (this.viewModelVisibility() && this.message())
|
||||
{
|
||||
if (this.fullScreenMode())
|
||||
{
|
||||
this.fullScreenMode(false);
|
||||
}
|
||||
else if (Enums.Layout.NoPreview === Data.layout())
|
||||
{
|
||||
this.message(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.message.focused(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.initShortcuts = function ()
|
||||
{
|
||||
var
|
||||
self = this
|
||||
;
|
||||
|
||||
// exit fullscreen, back
|
||||
key('esc', Enums.KeyState.MessageView, _.bind(this.escShortcuts, this));
|
||||
|
||||
// fullscreen
|
||||
key('enter', Enums.KeyState.MessageView, function () {
|
||||
self.toggleFullScreen();
|
||||
return false;
|
||||
});
|
||||
|
||||
key('enter', Enums.KeyState.MessageList, function () {
|
||||
if (Enums.Layout.NoPreview !== Data.layout() && self.message())
|
||||
{
|
||||
self.toggleFullScreen();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// TODO // more toggle
|
||||
// key('', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
// self.moreDropdownTrigger(true);
|
||||
// return false;
|
||||
// });
|
||||
|
||||
// reply
|
||||
key('r', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
if (Data.message())
|
||||
{
|
||||
self.replyCommand();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// replaAll
|
||||
key('a', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
if (Data.message())
|
||||
{
|
||||
self.replyAllCommand();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// forward
|
||||
key('f', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
if (Data.message())
|
||||
{
|
||||
self.forwardCommand();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// message information
|
||||
// key('i', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
// if (oData.message())
|
||||
// {
|
||||
// self.showFullInfo(!self.showFullInfo());
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
|
||||
// toggle message blockquotes
|
||||
key('b', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
|
||||
if (Data.message() && Data.message().body)
|
||||
{
|
||||
Data.message().body.find('.rlBlockquoteSwitcher').click();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
key('ctrl+left, command+left, ctrl+up, command+up', Enums.KeyState.MessageView, function () {
|
||||
self.goUpCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
key('ctrl+right, command+right, ctrl+down, command+down', Enums.KeyState.MessageView, function () {
|
||||
self.goDownCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
// print
|
||||
key('ctrl+p, command+p', Enums.KeyState.MessageView, function () {
|
||||
if (self.message())
|
||||
{
|
||||
self.message().printMessage();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// delete
|
||||
key('delete, shift+delete', Enums.KeyState.MessageView, function (event, handler) {
|
||||
if (event)
|
||||
{
|
||||
if (handler && 'shift+delete' === handler.shortcut)
|
||||
{
|
||||
self.deleteWithoutMoveCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
self.deleteCommand();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// change focused state
|
||||
key('tab, shift+tab, left', Enums.KeyState.MessageView, function (event, handler) {
|
||||
if (!self.fullScreenMode() && self.message() && Enums.Layout.NoPreview !== Data.layout())
|
||||
{
|
||||
if (event && handler && 'left' === handler.shortcut)
|
||||
{
|
||||
if (self.oMessageScrollerDom && 0 < self.oMessageScrollerDom.scrollLeft())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
self.message.focused(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.message.focused(false);
|
||||
}
|
||||
}
|
||||
else if (self.message() && Enums.Layout.NoPreview === Data.layout() && event && handler && 'left' === handler.shortcut)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.isDraftFolder = function ()
|
||||
{
|
||||
return Data.message() && Data.draftFolder() === Data.message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.isSentFolder = function ()
|
||||
{
|
||||
return Data.message() && Data.sentFolder() === Data.message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.isSpamFolder = function ()
|
||||
{
|
||||
return Data.message() && Data.spamFolder() === Data.message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.isSpamDisabled = function ()
|
||||
{
|
||||
return Data.message() && Data.spamFolder() === Consts.Values.UnuseOptionValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.isArchiveFolder = function ()
|
||||
{
|
||||
return Data.message() && Data.archiveFolder() === Data.message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.isArchiveDisabled = function ()
|
||||
{
|
||||
return Data.message() && Data.archiveFolder() === Consts.Values.UnuseOptionValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.isDraftOrSentFolder = function ()
|
||||
{
|
||||
return this.isDraftFolder() || this.isSentFolder();
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.editMessage = function ()
|
||||
{
|
||||
if (Data.message())
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'), [Enums.ComposeType.Draft, Data.message()]);
|
||||
}
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.scrollMessageToTop = function ()
|
||||
{
|
||||
if (this.oMessageScrollerDom)
|
||||
{
|
||||
this.oMessageScrollerDom.scrollTop(0);
|
||||
Utils.windowResize();
|
||||
}
|
||||
};
|
||||
|
||||
MessageViewMailBoxAppView.prototype.scrollMessageToLeft = function ()
|
||||
{
|
||||
if (this.oMessageScrollerDom)
|
||||
{
|
||||
this.oMessageScrollerDom.scrollLeft(0);
|
||||
Utils.windowResize();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.showImages = function (oMessage)
|
||||
{
|
||||
if (oMessage && oMessage.showExternalImages)
|
||||
{
|
||||
oMessage.showExternalImages(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.printableCheckedMessageCount = function ()
|
||||
{
|
||||
var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
|
||||
return 0 < iCnt ? (100 > iCnt ? iCnt : '99+') : '';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.verifyPgpSignedClearMessage = function (oMessage)
|
||||
{
|
||||
if (oMessage)
|
||||
{
|
||||
oMessage.verifyPgpSignedClearMessage();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.decryptPgpEncryptedMessage = function (oMessage)
|
||||
{
|
||||
if (oMessage)
|
||||
{
|
||||
oMessage.decryptPgpEncryptedMessage(this.viewPgpPassword());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MessageViewMailBoxAppView.prototype.readReceipt = function (oMessage)
|
||||
{
|
||||
if (oMessage && '' !== oMessage.readReceipt())
|
||||
{
|
||||
Remote.sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
|
||||
oMessage.readReceipt(),
|
||||
Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
|
||||
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': Data.accountEmail()}));
|
||||
|
||||
oMessage.isReadReceipt(true);
|
||||
|
||||
Cache.storeMessageFlagsToCache(oMessage);
|
||||
|
||||
require('App/App').reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = MessageViewMailBoxAppView;
|
||||
|
||||
}());
|
||||
28
dev/View/App/MailBox/SystemDropDown.js
Normal file
28
dev/View/App/MailBox/SystemDropDown.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractSystemDropDownViewModel = require('View/App/AbstractSystemDropDown')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownViewModel
|
||||
*/
|
||||
function SystemDropDownMailBoxAppView()
|
||||
{
|
||||
AbstractSystemDropDownViewModel.call(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/MailBox/SystemDropDown', 'MailBoxSystemDropDownViewModel'], SystemDropDownMailBoxAppView);
|
||||
_.extend(SystemDropDownMailBoxAppView.prototype, AbstractSystemDropDownViewModel.prototype);
|
||||
|
||||
module.exports = SystemDropDownMailBoxAppView;
|
||||
|
||||
}());
|
||||
48
dev/View/App/Settings/Menu.js
Normal file
48
dev/View/App/Settings/Menu.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MenuSettingsAppView(oScreen)
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'SettingsMenu');
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/Settings/Menu', 'SettingsMenuViewModel'], MenuSettingsAppView);
|
||||
_.extend(MenuSettingsAppView.prototype, AbstractView.prototype);
|
||||
|
||||
MenuSettingsAppView.prototype.link = function (sRoute)
|
||||
{
|
||||
return LinkBuilder.settings(sRoute);
|
||||
};
|
||||
|
||||
MenuSettingsAppView.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(LinkBuilder.inbox());
|
||||
};
|
||||
|
||||
module.exports = MenuSettingsAppView;
|
||||
|
||||
}());
|
||||
53
dev/View/App/Settings/Pane.js
Normal file
53
dev/View/App/Settings/Pane.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
key = require('key'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsAppView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'SettingsPane');
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/Settings/Pane', 'SettingsPaneViewModel'], PaneSettingsAppView);
|
||||
_.extend(PaneSettingsAppView.prototype, AbstractView.prototype);
|
||||
|
||||
PaneSettingsAppView.prototype.onBuild = function ()
|
||||
{
|
||||
var self = this;
|
||||
key('esc', Enums.KeyState.Settings, function () {
|
||||
self.backToMailBoxClick();
|
||||
});
|
||||
};
|
||||
|
||||
PaneSettingsAppView.prototype.onShow = function ()
|
||||
{
|
||||
Data.message(null);
|
||||
};
|
||||
|
||||
PaneSettingsAppView.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(LinkBuilder.inbox());
|
||||
};
|
||||
|
||||
module.exports = PaneSettingsAppView;
|
||||
|
||||
}());
|
||||
28
dev/View/App/Settings/SystemDropDown.js
Normal file
28
dev/View/App/Settings/SystemDropDown.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractSystemDropDownAppView = require('View/App/AbstractSystemDropDown')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownAppView
|
||||
*/
|
||||
function SystemDropDownSettingsAppView()
|
||||
{
|
||||
AbstractSystemDropDownAppView.call(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/App/Settings/SystemDropDown', 'SettingsSystemDropDownViewModel'], SystemDropDownSettingsAppView);
|
||||
_.extend(SystemDropDownSettingsAppView.prototype, AbstractSystemDropDownAppView.prototype);
|
||||
|
||||
module.exports = SystemDropDownSettingsAppView;
|
||||
|
||||
}());
|
||||
141
dev/View/Popup/Activate.js
Normal file
141
dev/View/Popup/Activate.js
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/Admin/Data'),
|
||||
Remote = require('Storage/Admin/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ActivatePopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsActivate');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
|
||||
this.licenseTrigger = Data.licenseTrigger;
|
||||
|
||||
this.activateProcess = ko.observable(false);
|
||||
this.activateText = ko.observable('');
|
||||
this.activateText.isError = ko.observable(false);
|
||||
|
||||
this.key.subscribe(function () {
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
}, this);
|
||||
|
||||
this.activationSuccessed.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.activateCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey())
|
||||
{
|
||||
Remote.licensingActivate(function (sResult, oData) {
|
||||
|
||||
self.activateProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
if (true === oData.Result)
|
||||
{
|
||||
self.activationSuccessed(true);
|
||||
self.activateText('Subscription Key Activated Successfully');
|
||||
self.activateText.isError(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(oData.Result);
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
self.activateText(Utils.getNotification(oData.ErrorCode));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
|
||||
}, this.domain(), this.key());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.activateProcess(false);
|
||||
this.activateText('Invalid Subscription Key');
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
|
||||
}, function () {
|
||||
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Activate', 'PopupsActivateViewModel'], ActivatePopupView);
|
||||
_.extend(ActivatePopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ActivatePopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.domain(Settings.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
this.key('');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
}
|
||||
};
|
||||
|
||||
ActivatePopupView.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
this.key.focus(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
ActivatePopupView.prototype.validateSubscriptionKey = function ()
|
||||
{
|
||||
var sValue = this.key();
|
||||
return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue));
|
||||
};
|
||||
|
||||
module.exports = ActivatePopupView;
|
||||
|
||||
}());
|
||||
116
dev/View/Popup/AddAccount.js
Normal file
116
dev/View/Popup/AddAccount.js
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AddAccountPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAddAccount');
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.emailError(false);
|
||||
}, this);
|
||||
|
||||
this.password.subscribe(function () {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
|
||||
this.addAccountCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.accountAdd(_.bind(function (sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AccountAdd' === oData.Action)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/App').accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.email(), '', this.password());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/AddAccount', 'PopupsAddAccountViewModel'], AddAccountPopupView);
|
||||
_.extend(AddAccountPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AddAccountPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.email('');
|
||||
this.password('');
|
||||
|
||||
this.emailError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
AddAccountPopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
AddAccountPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
this.emailFocus(true);
|
||||
};
|
||||
|
||||
module.exports = AddAccountPopupView;
|
||||
|
||||
}());
|
||||
110
dev/View/Popup/AddOpenPgpKey.js
Normal file
110
dev/View/Popup/AddOpenPgpKey.js
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AddOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAddOpenPgpKey');
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.key.error = ko.observable(false);
|
||||
this.key.focus = ko.observable(false);
|
||||
|
||||
this.key.subscribe(function () {
|
||||
this.key.error(false);
|
||||
}, this);
|
||||
|
||||
this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
iCount = 30,
|
||||
aMatch = null,
|
||||
sKey = Utils.trim(this.key()),
|
||||
oReg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi,
|
||||
oOpenpgpKeyring = Data.openpgpKeyring
|
||||
;
|
||||
|
||||
sKey = sKey.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g, '\n$1!-!N!-!$2')
|
||||
.replace(/[\n\r]+/g, '\n').replace(/!-!N!-!/g, '\n\n');
|
||||
|
||||
this.key.error('' === sKey);
|
||||
|
||||
if (!oOpenpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
aMatch = oReg.exec(sKey);
|
||||
if (!aMatch || 0 > iCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (aMatch[0] && aMatch[1] && aMatch[2] && aMatch[1] === aMatch[2])
|
||||
{
|
||||
if ('PRIVATE' === aMatch[1])
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(aMatch[0]);
|
||||
}
|
||||
else if ('PUBLIC' === aMatch[1])
|
||||
{
|
||||
oOpenpgpKeyring.publicKeys.importKey(aMatch[0]);
|
||||
}
|
||||
}
|
||||
|
||||
iCount--;
|
||||
}
|
||||
while (true);
|
||||
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
require('App/App').reloadOpenPgpKeys();
|
||||
Utils.delegateRun(this, 'cancelCommand');
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/AddOpenPgpKey', 'PopupsAddOpenPgpKeyViewModel'], AddOpenPgpKeyPopupView);
|
||||
_.extend(AddOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.key('');
|
||||
this.key.error(false);
|
||||
};
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
this.key.focus(true);
|
||||
};
|
||||
|
||||
module.exports = AddOpenPgpKeyPopupView;
|
||||
|
||||
}());
|
||||
158
dev/View/Popup/AdvancedSearch.js
Normal file
158
dev/View/Popup/AdvancedSearch.js
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
moment = require('moment'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
|
||||
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)
|
||||
{
|
||||
Data.mainMessageListSearch(sSearch);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/AdvancedSearch', 'PopupsAdvancedSearchViewModel'], AdvancedSearchPopupView);
|
||||
_.extend(AdvancedSearchPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AdvancedSearchPopupView.prototype.buildSearchStringValue = function (sValue)
|
||||
{
|
||||
if (-1 < sValue.indexOf(' '))
|
||||
{
|
||||
sValue = '"' + sValue + '"';
|
||||
}
|
||||
|
||||
return sValue;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
aResult.push('from:' + this.buildSearchStringValue(sFrom));
|
||||
}
|
||||
|
||||
if (sTo && '' !== sTo)
|
||||
{
|
||||
aResult.push('to:' + this.buildSearchStringValue(sTo));
|
||||
}
|
||||
|
||||
if (sSubject && '' !== sSubject)
|
||||
{
|
||||
aResult.push('subject:' + this.buildSearchStringValue(sSubject));
|
||||
}
|
||||
|
||||
if (this.hasAttachment())
|
||||
{
|
||||
aHas.push('attachment');
|
||||
}
|
||||
|
||||
if (this.unseen())
|
||||
{
|
||||
aIs.push('unseen');
|
||||
}
|
||||
|
||||
if (this.starred())
|
||||
{
|
||||
aIs.push('flagged');
|
||||
}
|
||||
|
||||
if (0 < aHas.length)
|
||||
{
|
||||
aResult.push('has:' + aHas.join(','));
|
||||
}
|
||||
|
||||
if (0 < aIs.length)
|
||||
{
|
||||
aResult.push('is:' + aIs.join(','));
|
||||
}
|
||||
|
||||
if (-1 < this.selectedDateValue())
|
||||
{
|
||||
aResult.push('date:' + moment().subtract('days', this.selectedDateValue()).format('YYYY.MM.DD') + '/');
|
||||
}
|
||||
|
||||
if (sText && '' !== sText)
|
||||
{
|
||||
aResult.push('text:' + this.buildSearchStringValue(sText));
|
||||
}
|
||||
|
||||
return Utils.trim(aResult.join(' '));
|
||||
};
|
||||
|
||||
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 ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
module.exports = AdvancedSearchPopupView;
|
||||
|
||||
}());
|
||||
131
dev/View/Popup/Ask.js
Normal file
131
dev/View/Popup/Ask.js
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AskPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAsk');
|
||||
|
||||
this.askDesc = ko.observable('');
|
||||
this.yesButton = ko.observable('');
|
||||
this.noButton = ko.observable('');
|
||||
|
||||
this.yesFocus = ko.observable(false);
|
||||
this.noFocus = ko.observable(false);
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Ask', 'PopupsAskViewModel'], AskPopupView);
|
||||
_.extend(AskPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AskPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.askDesc('');
|
||||
this.yesButton(Utils.i18n('POPUPS_ASK/BUTTON_YES'));
|
||||
this.noButton(Utils.i18n('POPUPS_ASK/BUTTON_NO'));
|
||||
|
||||
this.yesFocus(false);
|
||||
this.noFocus(false);
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
};
|
||||
|
||||
AskPopupView.prototype.yesClick = function ()
|
||||
{
|
||||
this.cancelCommand();
|
||||
|
||||
if (Utils.isFunc(this.fYesAction))
|
||||
{
|
||||
this.fYesAction.call(null);
|
||||
}
|
||||
};
|
||||
|
||||
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
|
||||
*/
|
||||
AskPopupView.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.fYesAction = fYesFunc || null;
|
||||
this.fNoAction = fNoFunc || null;
|
||||
|
||||
this.askDesc(sAskDesc || '');
|
||||
if (sYesButton)
|
||||
{
|
||||
this.yesButton(sYesButton);
|
||||
}
|
||||
|
||||
if (sYesButton)
|
||||
{
|
||||
this.yesButton(sNoButton);
|
||||
}
|
||||
};
|
||||
|
||||
AskPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
this.yesFocus(true);
|
||||
};
|
||||
|
||||
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));
|
||||
};
|
||||
|
||||
module.exports = AskPopupView;
|
||||
|
||||
}());
|
||||
1790
dev/View/Popup/Compose.js
Normal file
1790
dev/View/Popup/Compose.js
Normal file
File diff suppressed because it is too large
Load diff
264
dev/View/Popup/ComposeOpenPgp.js
Normal file
264
dev/View/Popup/ComposeOpenPgp.js
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
|
||||
EmailModel = require('Model/Email'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ComposeOpenPgpPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsComposeOpenPgp');
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.sign = ko.observable(true);
|
||||
this.encrypt = ko.observable(true);
|
||||
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
|
||||
this.from = ko.observable('');
|
||||
this.to = ko.observableArray([]);
|
||||
this.text = ko.observable('');
|
||||
|
||||
this.resultCallback = null;
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
// commands
|
||||
this.doCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
bResult = true,
|
||||
oPrivateKey = null,
|
||||
aPublicKeys = []
|
||||
;
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
if (bResult && this.sign() && '' === this.from())
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_FROM_EMAIL'));
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
if (bResult && this.sign())
|
||||
{
|
||||
oPrivateKey = Data.findPrivateKeyByEmail(this.from(), this.password());
|
||||
if (!oPrivateKey)
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.from()
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult && this.encrypt() && 0 === this.to().length)
|
||||
{
|
||||
this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_AT_LEAST_ONE_RECIPIENT'));
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
if (bResult && this.encrypt())
|
||||
{
|
||||
aPublicKeys = [];
|
||||
_.each(this.to(), function (sEmail) {
|
||||
var aKeys = Data.findPublicKeysByEmail(sEmail);
|
||||
if (0 === aKeys.length && bResult)
|
||||
{
|
||||
self.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
'EMAIL': sEmail
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
|
||||
aPublicKeys = aPublicKeys.concat(aKeys);
|
||||
});
|
||||
|
||||
if (bResult && (0 === aPublicKeys.length || this.to().length !== aPublicKeys.length))
|
||||
{
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
if (self.resultCallback && bResult)
|
||||
{
|
||||
try {
|
||||
|
||||
if (oPrivateKey && 0 === aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
Data.openpgp.signClearMessage([oPrivateKey], self.text())
|
||||
);
|
||||
}
|
||||
else if (oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
Data.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, self.text())
|
||||
);
|
||||
}
|
||||
else if (!oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
self.resultCallback(
|
||||
Data.openpgp.encryptMessage(aPublicKeys, self.text())
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
self.notification(Utils.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
self.cancelCommand();
|
||||
}
|
||||
|
||||
self.submitRequest(false);
|
||||
|
||||
}, 10);
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest() && (this.sign() || this.encrypt());
|
||||
});
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/ComposeOpenPgp', 'PopupsComposeOpenPgpViewModel'], ComposeOpenPgpPopupView);
|
||||
_.extend(ComposeOpenPgpPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
this.notification('');
|
||||
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
|
||||
this.from('');
|
||||
this.to([]);
|
||||
this.text('');
|
||||
|
||||
this.submitRequest(false);
|
||||
|
||||
this.resultCallback = null;
|
||||
};
|
||||
|
||||
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.onHide = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
if (this.sign())
|
||||
{
|
||||
this.password.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buttonFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
var
|
||||
oEmail = new EmailModel(),
|
||||
sResultFromEmail = '',
|
||||
aRec = []
|
||||
;
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(sFromEmail);
|
||||
if ('' !== oEmail.email)
|
||||
{
|
||||
sResultFromEmail = oEmail.email;
|
||||
}
|
||||
|
||||
if ('' !== sTo)
|
||||
{
|
||||
aRec.push(sTo);
|
||||
}
|
||||
|
||||
if ('' !== sCc)
|
||||
{
|
||||
aRec.push(sCc);
|
||||
}
|
||||
|
||||
if ('' !== sBcc)
|
||||
{
|
||||
aRec.push(sBcc);
|
||||
}
|
||||
|
||||
aRec = aRec.join(', ').split(',');
|
||||
aRec = _.compact(_.map(aRec, function (sValue) {
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(Utils.trim(sValue));
|
||||
return '' === oEmail.email ? false : oEmail.email;
|
||||
}));
|
||||
|
||||
this.from(sResultFromEmail);
|
||||
this.to(aRec);
|
||||
this.text(sText);
|
||||
};
|
||||
|
||||
module.exports = ComposeOpenPgpPopupView;
|
||||
|
||||
}());
|
||||
781
dev/View/Popup/Contacts.js
Normal file
781
dev/View/Popup/Contacts.js
Normal file
|
|
@ -0,0 +1,781 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Selector = require('Common/Selector'),
|
||||
LinkBuilder = require('Common/LinkBuilder'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
EmailModel = require('Model/Email'),
|
||||
ContactModel = require('Model/Contact'),
|
||||
ContactTagModel = require('Model/ContactTag'),
|
||||
ContactPropertyModel = require('Model/ContactProperty'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ContactsPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsContacts');
|
||||
|
||||
var
|
||||
self = this,
|
||||
fFastClearEmptyListHelper = function (aList) {
|
||||
if (aList && 0 < aList.length) {
|
||||
self.viewProperties.removeAll(aList);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
this.allowContactsSync = Data.allowContactsSync;
|
||||
this.enableContactsSync = Data.enableContactsSync;
|
||||
this.allowExport = !Globals.bMobileDevice;
|
||||
|
||||
this.search = ko.observable('');
|
||||
this.contactsCount = ko.observable(0);
|
||||
this.contacts = Data.contacts;
|
||||
this.contactTags = Data.contactTags;
|
||||
|
||||
this.currentContact = ko.observable(null);
|
||||
|
||||
this.importUploaderButton = ko.observable(null);
|
||||
|
||||
this.contactsPage = ko.observable(1);
|
||||
this.contactsPageCount = ko.computed(function () {
|
||||
var iPage = window.Math.ceil(this.contactsCount() / Consts.Defaults.ContactsPerPage);
|
||||
return 0 >= iPage ? 1 : iPage;
|
||||
}, this);
|
||||
|
||||
this.contactsPagenator = ko.computed(Utils.computedPagenatorHelper(this.contactsPage, this.contactsPageCount));
|
||||
|
||||
this.emptySelection = ko.observable(true);
|
||||
this.viewClearSearch = ko.observable(false);
|
||||
|
||||
this.viewID = ko.observable('');
|
||||
this.viewReadOnly = ko.observable(false);
|
||||
this.viewProperties = ko.observableArray([]);
|
||||
|
||||
this.viewTags = ko.observable('');
|
||||
this.viewTags.visibility = ko.observable(false);
|
||||
this.viewTags.focusTrigger = ko.observable(false);
|
||||
|
||||
this.viewTags.focusTrigger.subscribe(function (bValue) {
|
||||
if (!bValue && '' === this.viewTags())
|
||||
{
|
||||
this.viewTags.visibility(false);
|
||||
}
|
||||
else if (bValue)
|
||||
{
|
||||
this.viewTags.visibility(true);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) {
|
||||
return -1 < Utils.inArray(oProperty.type(), [
|
||||
Enums.ContactPropertyType.FirstName, Enums.ContactPropertyType.LastName
|
||||
]);
|
||||
});
|
||||
|
||||
this.viewPropertiesOther = this.viewProperties.filter(function(oProperty) {
|
||||
return -1 < Utils.inArray(oProperty.type(), [
|
||||
Enums.ContactPropertyType.Note
|
||||
]);
|
||||
});
|
||||
|
||||
this.viewPropertiesOther = ko.computed(function () {
|
||||
|
||||
var aList = _.filter(this.viewProperties(), function (oProperty) {
|
||||
return -1 < Utils.inArray(oProperty.type(), [
|
||||
Enums.ContactPropertyType.Nick
|
||||
]);
|
||||
});
|
||||
|
||||
return _.sortBy(aList, function (oProperty) {
|
||||
return oProperty.type();
|
||||
});
|
||||
|
||||
}, this);
|
||||
|
||||
this.viewPropertiesEmails = this.viewProperties.filter(function(oProperty) {
|
||||
return Enums.ContactPropertyType.Email === oProperty.type();
|
||||
});
|
||||
|
||||
this.viewPropertiesWeb = this.viewProperties.filter(function(oProperty) {
|
||||
return Enums.ContactPropertyType.Web === oProperty.type();
|
||||
});
|
||||
|
||||
this.viewHasNonEmptyRequaredProperties = ko.computed(function() {
|
||||
|
||||
var
|
||||
aNames = this.viewPropertiesNames(),
|
||||
aEmail = this.viewPropertiesEmails(),
|
||||
fHelper = function (oProperty) {
|
||||
return '' !== Utils.trim(oProperty.value());
|
||||
}
|
||||
;
|
||||
|
||||
return !!(_.find(aNames, fHelper) || _.find(aEmail, fHelper));
|
||||
}, this);
|
||||
|
||||
this.viewPropertiesPhones = this.viewProperties.filter(function(oProperty) {
|
||||
return Enums.ContactPropertyType.Phone === oProperty.type();
|
||||
});
|
||||
|
||||
this.viewPropertiesEmailsNonEmpty = this.viewPropertiesNames.filter(function(oProperty) {
|
||||
return '' !== Utils.trim(oProperty.value());
|
||||
});
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused = this.viewPropertiesEmails.filter(function(oProperty) {
|
||||
var bF = oProperty.focused();
|
||||
return '' === Utils.trim(oProperty.value()) && !bF;
|
||||
});
|
||||
|
||||
this.viewPropertiesPhonesEmptyAndOnFocused = this.viewPropertiesPhones.filter(function(oProperty) {
|
||||
var bF = oProperty.focused();
|
||||
return '' === Utils.trim(oProperty.value()) && !bF;
|
||||
});
|
||||
|
||||
this.viewPropertiesWebEmptyAndOnFocused = this.viewPropertiesWeb.filter(function(oProperty) {
|
||||
var bF = oProperty.focused();
|
||||
return '' === Utils.trim(oProperty.value()) && !bF;
|
||||
});
|
||||
|
||||
this.viewPropertiesOtherEmptyAndOnFocused = ko.computed(function () {
|
||||
return _.filter(this.viewPropertiesOther(), function (oProperty) {
|
||||
var bF = oProperty.focused();
|
||||
return '' === Utils.trim(oProperty.value()) && !bF;
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused.subscribe(function(aList) {
|
||||
fFastClearEmptyListHelper(aList);
|
||||
});
|
||||
|
||||
this.viewPropertiesPhonesEmptyAndOnFocused.subscribe(function(aList) {
|
||||
fFastClearEmptyListHelper(aList);
|
||||
});
|
||||
|
||||
this.viewPropertiesWebEmptyAndOnFocused.subscribe(function(aList) {
|
||||
fFastClearEmptyListHelper(aList);
|
||||
});
|
||||
|
||||
this.viewPropertiesOtherEmptyAndOnFocused.subscribe(function(aList) {
|
||||
fFastClearEmptyListHelper(aList);
|
||||
});
|
||||
|
||||
this.viewSaving = ko.observable(false);
|
||||
|
||||
this.useCheckboxesInList = Data.useCheckboxesInList;
|
||||
|
||||
this.search.subscribe(function () {
|
||||
this.reloadContactList();
|
||||
}, this);
|
||||
|
||||
this.contacts.subscribe(function () {
|
||||
Utils.windowResize();
|
||||
}, this);
|
||||
|
||||
this.viewProperties.subscribe(function () {
|
||||
Utils.windowResize();
|
||||
}, this);
|
||||
|
||||
this.contactsChecked = ko.computed(function () {
|
||||
return _.filter(this.contacts(), function (oItem) {
|
||||
return oItem.checked();
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.contactsCheckedOrSelected = ko.computed(function () {
|
||||
|
||||
var
|
||||
aChecked = this.contactsChecked(),
|
||||
oSelected = this.currentContact()
|
||||
;
|
||||
|
||||
return _.union(aChecked, oSelected ? [oSelected] : []);
|
||||
|
||||
}, this);
|
||||
|
||||
this.contactsCheckedOrSelectedUids = ko.computed(function () {
|
||||
return _.map(this.contactsCheckedOrSelected(), function (oContact) {
|
||||
return oContact.idContact;
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.selector = new Selector(this.contacts, this.currentContact,
|
||||
'.e-contact-item .actionHandle', '.e-contact-item.selected', '.e-contact-item .checkboxItem',
|
||||
'.e-contact-item.focused');
|
||||
|
||||
this.selector.on('onItemSelect', _.bind(function (oContact) {
|
||||
this.populateViewContact(oContact ? oContact : null);
|
||||
if (!oContact)
|
||||
{
|
||||
this.emptySelection(true);
|
||||
}
|
||||
}, this));
|
||||
|
||||
this.selector.on('onItemGetUid', function (oContact) {
|
||||
return oContact ? oContact.generateUid() : '';
|
||||
});
|
||||
|
||||
this.newCommand = Utils.createCommand(this, function () {
|
||||
this.populateViewContact(null);
|
||||
this.currentContact(null);
|
||||
});
|
||||
|
||||
this.deleteCommand = Utils.createCommand(this, function () {
|
||||
this.deleteSelectedContacts();
|
||||
this.emptySelection(true);
|
||||
}, function () {
|
||||
return 0 < this.contactsCheckedOrSelected().length;
|
||||
});
|
||||
|
||||
this.newMessageCommand = Utils.createCommand(this, function () {
|
||||
var aC = this.contactsCheckedOrSelected(), aE = [];
|
||||
if (Utils.isNonEmptyArray(aC))
|
||||
{
|
||||
aE = _.map(aC, function (oItem) {
|
||||
if (oItem)
|
||||
{
|
||||
var
|
||||
aData = oItem.getNameAndEmailHelper(),
|
||||
oEmail = aData ? new EmailModel(aData[0], aData[1]) : null
|
||||
;
|
||||
|
||||
if (oEmail && oEmail.validate())
|
||||
{
|
||||
return oEmail;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
aE = _.compact(aE);
|
||||
}
|
||||
|
||||
if (Utils.isNonEmptyArray(aE))
|
||||
{
|
||||
kn.hideScreenPopup(require('View/Popup/Contacts'));
|
||||
kn.showScreenPopup(require('View/Popup/Compose'), [Enums.ComposeType.Empty, null, aE]);
|
||||
}
|
||||
|
||||
}, function () {
|
||||
return 0 < this.contactsCheckedOrSelected().length;
|
||||
});
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
this.search('');
|
||||
});
|
||||
|
||||
this.saveCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.viewSaving(true);
|
||||
this.viewSaveTrigger(Enums.SaveSettingsStep.Animate);
|
||||
|
||||
var
|
||||
sRequestUid = Utils.fakeMd5(),
|
||||
aProperties = []
|
||||
;
|
||||
|
||||
_.each(this.viewProperties(), function (oItem) {
|
||||
if (oItem.type() && '' !== Utils.trim(oItem.value()))
|
||||
{
|
||||
aProperties.push([oItem.type(), oItem.value(), oItem.typeStr()]);
|
||||
}
|
||||
});
|
||||
|
||||
Remote.contactSave(function (sResult, oData) {
|
||||
|
||||
var bRes = false;
|
||||
self.viewSaving(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
oData.Result.RequestUid === sRequestUid && 0 < Utils.pInt(oData.Result.ResultID))
|
||||
{
|
||||
if ('' === self.viewID())
|
||||
{
|
||||
self.viewID(Utils.pInt(oData.Result.ResultID));
|
||||
}
|
||||
|
||||
self.reloadContactList();
|
||||
bRes = true;
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
self.viewSaveTrigger(bRes ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult);
|
||||
}, 300);
|
||||
|
||||
if (bRes)
|
||||
{
|
||||
self.watchDirty(false);
|
||||
|
||||
_.delay(function () {
|
||||
self.viewSaveTrigger(Enums.SaveSettingsStep.Idle);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
}, sRequestUid, this.viewID(), this.viewTags(), aProperties);
|
||||
|
||||
}, function () {
|
||||
var
|
||||
bV = this.viewHasNonEmptyRequaredProperties(),
|
||||
bReadOnly = this.viewReadOnly()
|
||||
;
|
||||
return !this.viewSaving() && bV && !bReadOnly;
|
||||
});
|
||||
|
||||
this.syncCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var self = this;
|
||||
require('App/App').contactsSync(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
window.alert(Utils.getNotification(
|
||||
oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.ContactsSyncError));
|
||||
}
|
||||
|
||||
self.reloadContactList(true);
|
||||
});
|
||||
|
||||
}, function () {
|
||||
return !this.contacts.syncing() && !this.contacts.importing();
|
||||
});
|
||||
|
||||
this.bDropPageAfterDelete = false;
|
||||
|
||||
this.watchDirty = ko.observable(false);
|
||||
this.watchHash = ko.observable(false);
|
||||
|
||||
this.viewHash = ko.computed(function () {
|
||||
return '' + self.viewTags() + '|' + _.map(self.viewProperties(), function (oItem) {
|
||||
return oItem.value();
|
||||
}).join('');
|
||||
});
|
||||
|
||||
// this.saveCommandDebounce = _.debounce(_.bind(this.saveCommand, this), 1000);
|
||||
|
||||
this.viewHash.subscribe(function () {
|
||||
if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty())
|
||||
{
|
||||
this.watchDirty(true);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.ContactList;
|
||||
|
||||
this.contactTagsSource = _.bind(this.contactTagsSource, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Contacts', 'PopupsContactsViewModel'], ContactsPopupView);
|
||||
_.extend(ContactsPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ContactsPopupView.prototype.contactTagsSource = function (oData, fResponse)
|
||||
{
|
||||
require('App/App').getContactTagsAutocomplete(oData.term, function (aData) {
|
||||
fResponse(_.map(aData, function (oTagItem) {
|
||||
return oTagItem.toLine(false);
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.getPropertyPlceholder = function (sType)
|
||||
{
|
||||
var sResult = '';
|
||||
switch (sType)
|
||||
{
|
||||
case Enums.ContactPropertyType.LastName:
|
||||
sResult = 'CONTACTS/PLACEHOLDER_ENTER_LAST_NAME';
|
||||
break;
|
||||
case Enums.ContactPropertyType.FirstName:
|
||||
sResult = 'CONTACTS/PLACEHOLDER_ENTER_FIRST_NAME';
|
||||
break;
|
||||
case Enums.ContactPropertyType.Nick:
|
||||
sResult = 'CONTACTS/PLACEHOLDER_ENTER_NICK_NAME';
|
||||
break;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewProperty = function (sType, sTypeStr)
|
||||
{
|
||||
this.viewProperties.push(new ContactPropertyModel(sType, sTypeStr || '', '', true, this.getPropertyPlceholder(sType)));
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewOrFocusProperty = function (sType, sTypeStr)
|
||||
{
|
||||
var oItem = _.find(this.viewProperties(), function (oItem) {
|
||||
return sType === oItem.type();
|
||||
});
|
||||
|
||||
if (oItem)
|
||||
{
|
||||
oItem.focused(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addNewProperty(sType, sTypeStr);
|
||||
}
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewTag = function ()
|
||||
{
|
||||
this.viewTags.visibility(true);
|
||||
this.viewTags.focusTrigger(true);
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewEmail = function ()
|
||||
{
|
||||
this.addNewProperty(Enums.ContactPropertyType.Email, 'Home');
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewPhone = function ()
|
||||
{
|
||||
this.addNewProperty(Enums.ContactPropertyType.Phone, 'Mobile');
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewWeb = function ()
|
||||
{
|
||||
this.addNewProperty(Enums.ContactPropertyType.Web);
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewNickname = function ()
|
||||
{
|
||||
this.addNewOrFocusProperty(Enums.ContactPropertyType.Nick);
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewNotes = function ()
|
||||
{
|
||||
this.addNewOrFocusProperty(Enums.ContactPropertyType.Note);
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.addNewBirthday = function ()
|
||||
{
|
||||
this.addNewOrFocusProperty(Enums.ContactPropertyType.Birthday);
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.exportVcf = function ()
|
||||
{
|
||||
require('App/App').download(LinkBuilder.exportContactsVcf());
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.exportCsv = function ()
|
||||
{
|
||||
require('App/App').download(LinkBuilder.exportContactsCsv());
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.initUploader = function ()
|
||||
{
|
||||
if (this.importUploaderButton())
|
||||
{
|
||||
var
|
||||
oJua = new Jua({
|
||||
'action': LinkBuilder.uploadContacts(),
|
||||
'name': 'uploader',
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'disableFolderDragAndDrop': true,
|
||||
'disableDragAndDrop': true,
|
||||
'disableMultiple': true,
|
||||
'disableDocumentDropPrevent': true,
|
||||
'clickElement': this.importUploaderButton()
|
||||
})
|
||||
;
|
||||
|
||||
if (oJua)
|
||||
{
|
||||
oJua
|
||||
.on('onStart', _.bind(function () {
|
||||
this.contacts.importing(true);
|
||||
}, this))
|
||||
.on('onComplete', _.bind(function (sId, bResult, oData) {
|
||||
|
||||
this.contacts.importing(false);
|
||||
this.reloadContactList();
|
||||
|
||||
if (!sId || !bResult || !oData || !oData.Result)
|
||||
{
|
||||
window.alert(Utils.i18n('CONTACTS/ERROR_IMPORT_FILE'));
|
||||
}
|
||||
|
||||
}, this))
|
||||
;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.removeCheckedOrSelectedContactsFromList = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oKoContacts = this.contacts,
|
||||
oCurrentContact = this.currentContact(),
|
||||
iCount = this.contacts().length,
|
||||
aContacts = this.contactsCheckedOrSelected()
|
||||
;
|
||||
|
||||
if (0 < aContacts.length)
|
||||
{
|
||||
_.each(aContacts, function (oContact) {
|
||||
|
||||
if (oCurrentContact && oCurrentContact.idContact === oContact.idContact)
|
||||
{
|
||||
oCurrentContact = null;
|
||||
self.currentContact(null);
|
||||
}
|
||||
|
||||
oContact.deleted(true);
|
||||
iCount--;
|
||||
});
|
||||
|
||||
if (iCount <= 0)
|
||||
{
|
||||
this.bDropPageAfterDelete = true;
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
_.each(aContacts, function (oContact) {
|
||||
oKoContacts.remove(oContact);
|
||||
});
|
||||
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.deleteSelectedContacts = function ()
|
||||
{
|
||||
if (0 < this.contactsCheckedOrSelected().length)
|
||||
{
|
||||
Remote.contactsDelete(
|
||||
_.bind(this.deleteResponse, this),
|
||||
this.contactsCheckedOrSelectedUids()
|
||||
);
|
||||
|
||||
this.removeCheckedOrSelectedContactsFromList();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sResult
|
||||
* @param {AjaxJsonDefaultResponse} oData
|
||||
*/
|
||||
ContactsPopupView.prototype.deleteResponse = function (sResult, oData)
|
||||
{
|
||||
if (500 < (Enums.StorageResultType.Success === sResult && oData && oData.Time ? Utils.pInt(oData.Time) : 0))
|
||||
{
|
||||
this.reloadContactList(this.bDropPageAfterDelete);
|
||||
}
|
||||
else
|
||||
{
|
||||
_.delay((function (self) {
|
||||
return function () {
|
||||
self.reloadContactList(self.bDropPageAfterDelete);
|
||||
};
|
||||
}(this)), 500);
|
||||
}
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.removeProperty = function (oProp)
|
||||
{
|
||||
this.viewProperties.remove(oProp);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?ContactModel} oContact
|
||||
*/
|
||||
ContactsPopupView.prototype.populateViewContact = function (oContact)
|
||||
{
|
||||
var
|
||||
sId = '',
|
||||
sLastName = '',
|
||||
sFirstName = '',
|
||||
aList = []
|
||||
;
|
||||
|
||||
this.watchHash(false);
|
||||
|
||||
this.emptySelection(false);
|
||||
this.viewReadOnly(false);
|
||||
this.viewTags('');
|
||||
|
||||
if (oContact)
|
||||
{
|
||||
sId = oContact.idContact;
|
||||
if (Utils.isNonEmptyArray(oContact.properties))
|
||||
{
|
||||
_.each(oContact.properties, function (aProperty) {
|
||||
if (aProperty && aProperty[0])
|
||||
{
|
||||
if (Enums.ContactPropertyType.LastName === aProperty[0])
|
||||
{
|
||||
sLastName = aProperty[1];
|
||||
}
|
||||
else if (Enums.ContactPropertyType.FirstName === aProperty[0])
|
||||
{
|
||||
sFirstName = aProperty[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
aList.push(new ContactPropertyModel(aProperty[0], aProperty[2] || '', aProperty[1]));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.viewTags(oContact.tags);
|
||||
|
||||
this.viewReadOnly(!!oContact.readOnly);
|
||||
}
|
||||
|
||||
this.viewTags.focusTrigger.valueHasMutated();
|
||||
this.viewTags.visibility('' !== this.viewTags());
|
||||
|
||||
aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.LastName, '', sLastName, false,
|
||||
this.getPropertyPlceholder(Enums.ContactPropertyType.LastName)));
|
||||
|
||||
aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.FirstName, '', sFirstName, !oContact,
|
||||
this.getPropertyPlceholder(Enums.ContactPropertyType.FirstName)));
|
||||
|
||||
this.viewID(sId);
|
||||
this.viewProperties([]);
|
||||
this.viewProperties(aList);
|
||||
|
||||
this.watchDirty(false);
|
||||
this.watchHash(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean=} bDropPagePosition = false
|
||||
*/
|
||||
ContactsPopupView.prototype.reloadContactList = function (bDropPagePosition)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage
|
||||
;
|
||||
|
||||
this.bDropPageAfterDelete = false;
|
||||
|
||||
if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition)
|
||||
{
|
||||
this.contactsPage(1);
|
||||
iOffset = 0;
|
||||
}
|
||||
|
||||
this.contacts.loading(true);
|
||||
Remote.contacts(function (sResult, oData) {
|
||||
var
|
||||
iCount = 0,
|
||||
aList = [],
|
||||
aTagsList = []
|
||||
;
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List)
|
||||
{
|
||||
if (Utils.isNonEmptyArray(oData.Result.List))
|
||||
{
|
||||
aList = _.map(oData.Result.List, function (oItem) {
|
||||
var oContact = new ContactModel();
|
||||
return oContact.parse(oItem) ? oContact : null;
|
||||
});
|
||||
|
||||
aList = _.compact(aList);
|
||||
|
||||
iCount = Utils.pInt(oData.Result.Count);
|
||||
iCount = 0 < iCount ? iCount : 0;
|
||||
}
|
||||
|
||||
if (Utils.isNonEmptyArray(oData.Result.Tags))
|
||||
{
|
||||
aTagsList = _.map(oData.Result.Tags, function (oItem) {
|
||||
var oContactTag = new ContactTagModel();
|
||||
return oContactTag.parse(oItem) ? oContactTag : null;
|
||||
});
|
||||
|
||||
aTagsList = _.compact(aTagsList);
|
||||
}
|
||||
}
|
||||
|
||||
self.contactsCount(iCount);
|
||||
|
||||
self.contacts(aList);
|
||||
self.contacts.loading(false);
|
||||
self.contactTags(aTagsList);
|
||||
|
||||
self.viewClearSearch('' !== self.search());
|
||||
|
||||
}, iOffset, Consts.Defaults.ContactsPerPage, this.search());
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
this.oContentVisible = $('.b-list-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
this.selector.init(this.oContentVisible, this.oContentScrollable, Enums.KeyState.ContactList);
|
||||
|
||||
var self = this;
|
||||
|
||||
key('delete', Enums.KeyState.ContactList, function () {
|
||||
self.deleteCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
oDom
|
||||
.on('click', '.e-pagenator .e-page', function () {
|
||||
var oPage = ko.dataFor(this);
|
||||
if (oPage)
|
||||
{
|
||||
self.contactsPage(Utils.pInt(oPage.value));
|
||||
self.reloadContactList();
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
this.initUploader();
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
this.reloadContactList(true);
|
||||
};
|
||||
|
||||
ContactsPopupView.prototype.onHide = function ()
|
||||
{
|
||||
kn.routeOn();
|
||||
this.currentContact(null);
|
||||
this.emptySelection(true);
|
||||
this.search('');
|
||||
this.contactsCount(0);
|
||||
this.contacts([]);
|
||||
};
|
||||
|
||||
module.exports = ContactsPopupView;
|
||||
|
||||
}());
|
||||
318
dev/View/Popup/Domain.js
Normal file
318
dev/View/Popup/Domain.js
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Remote = require('Storage/Admin/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomain');
|
||||
|
||||
this.edit = ko.observable(false);
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.whiteListPage = ko.observable(false);
|
||||
|
||||
this.testing = ko.observable(false);
|
||||
this.testingDone = ko.observable(false);
|
||||
this.testingImapError = ko.observable(false);
|
||||
this.testingSmtpError = ko.observable(false);
|
||||
this.testingImapErrorDesc = ko.observable('');
|
||||
this.testingSmtpErrorDesc = ko.observable('');
|
||||
|
||||
this.testingImapError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingImapErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.testingSmtpError.subscribe(function (bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.testingImapErrorDesc = ko.observable('');
|
||||
this.testingSmtpErrorDesc = ko.observable('');
|
||||
|
||||
this.imapServerFocus = ko.observable(false);
|
||||
this.smtpServerFocus = ko.observable(false);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.imapServer = ko.observable('');
|
||||
this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort);
|
||||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.smtpServer = ko.observable('');
|
||||
this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort);
|
||||
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin = ko.observable(false);
|
||||
this.smtpAuth = ko.observable(true);
|
||||
this.whiteList = ko.observable('');
|
||||
|
||||
this.headerText = ko.computed(function () {
|
||||
var sName = this.name();
|
||||
return this.edit() ? 'Edit Domain "' + sName + '"' :
|
||||
'Add Domain' + ('' === sName ? '' : ' "' + sName + '"');
|
||||
}, this);
|
||||
|
||||
this.domainIsComputed = ko.computed(function () {
|
||||
return '' !== this.name() &&
|
||||
'' !== this.imapServer() &&
|
||||
'' !== this.imapPort() &&
|
||||
'' !== this.smtpServer() &&
|
||||
'' !== this.smtpPort();
|
||||
}, this);
|
||||
|
||||
this.canBeTested = ko.computed(function () {
|
||||
return !this.testing() && this.domainIsComputed();
|
||||
}, this);
|
||||
|
||||
this.canBeSaved = ko.computed(function () {
|
||||
return !this.saving() && this.domainIsComputed();
|
||||
}, this);
|
||||
|
||||
this.createOrAddCommand = Utils.createCommand(this, function () {
|
||||
this.saving(true);
|
||||
Remote.createOrUpdateDomain(
|
||||
_.bind(this.onDomainCreateOrSaveResponse, this),
|
||||
!this.edit(),
|
||||
this.name(),
|
||||
this.imapServer(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.imapShortLogin(),
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
this.whiteList()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
this.testConnectionCommand = Utils.createCommand(this, function () {
|
||||
this.whiteListPage(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSmtpError(false);
|
||||
this.testing(true);
|
||||
Remote.testConnectionForDomain(
|
||||
_.bind(this.onTestConnectionResponse, this),
|
||||
this.name(),
|
||||
this.imapServer(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpAuth()
|
||||
);
|
||||
}, this.canBeTested);
|
||||
|
||||
this.whiteListCommand = Utils.createCommand(this, function () {
|
||||
this.whiteListPage(!this.whiteListPage());
|
||||
});
|
||||
|
||||
// smart form improvements
|
||||
this.imapServerFocus.subscribe(function (bValue) {
|
||||
if (bValue && '' !== this.name() && '' === this.imapServer())
|
||||
{
|
||||
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.smtpServerFocus.subscribe(function (bValue) {
|
||||
if (bValue && '' !== this.imapServer() && '' === this.smtpServer())
|
||||
{
|
||||
this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp'));
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.imapSecure.subscribe(function (sValue) {
|
||||
var iPort = Utils.pInt(this.imapPort());
|
||||
sValue = Utils.pString(sValue);
|
||||
switch (sValue)
|
||||
{
|
||||
case '0':
|
||||
if (993 === iPort)
|
||||
{
|
||||
this.imapPort('143');
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (143 === iPort)
|
||||
{
|
||||
this.imapPort('993');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.smtpSecure.subscribe(function (sValue) {
|
||||
var iPort = Utils.pInt(this.smtpPort());
|
||||
sValue = Utils.pString(sValue);
|
||||
switch (sValue)
|
||||
{
|
||||
case '0':
|
||||
if (465 === iPort || 587 === iPort)
|
||||
{
|
||||
this.smtpPort('25');
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (25 === iPort || 587 === iPort)
|
||||
{
|
||||
this.smtpPort('465');
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
if (25 === iPort || 465 === iPort)
|
||||
{
|
||||
this.smtpPort('587');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['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.testingDone(true);
|
||||
this.testingImapError(true !== oData.Result.Imap);
|
||||
this.testingSmtpError(true !== oData.Result.Smtp);
|
||||
|
||||
if (this.testingImapError() && oData.Result.Imap)
|
||||
{
|
||||
this.testingImapErrorDesc(oData.Result.Imap);
|
||||
}
|
||||
|
||||
if (this.testingSmtpError() && oData.Result.Smtp)
|
||||
{
|
||||
this.testingSmtpErrorDesc(oData.Result.Smtp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testingImapError(true);
|
||||
this.testingSmtpError(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onDomainCreateOrSaveResponse = function (sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError('Domain already exists');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError('Unknown error');
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onHide = function ()
|
||||
{
|
||||
this.whiteListPage(false);
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onShow = function (oDomain)
|
||||
{
|
||||
this.saving(false);
|
||||
this.whiteListPage(false);
|
||||
|
||||
this.testing(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSmtpError(false);
|
||||
|
||||
this.clearForm();
|
||||
if (oDomain)
|
||||
{
|
||||
this.edit(true);
|
||||
|
||||
this.name(Utils.trim(oDomain.Name));
|
||||
this.imapServer(Utils.trim(oDomain.IncHost));
|
||||
this.imapPort('' + Utils.pInt(oDomain.IncPort));
|
||||
this.imapSecure(Utils.trim(oDomain.IncSecure));
|
||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||
this.smtpServer(Utils.trim(oDomain.OutHost));
|
||||
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
|
||||
this.smtpSecure(Utils.trim(oDomain.OutSecure));
|
||||
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
||||
this.smtpAuth(!!oDomain.OutAuth);
|
||||
this.whiteList(Utils.trim(oDomain.WhiteList));
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
if ('' === this.name())
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.clearForm = function ()
|
||||
{
|
||||
this.edit(false);
|
||||
this.whiteListPage(false);
|
||||
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.imapServer('');
|
||||
this.imapPort('' + Consts.Values.ImapDefaulPort);
|
||||
this.imapSecure(Enums.ServerSecure.None);
|
||||
this.imapShortLogin(false);
|
||||
this.smtpServer('');
|
||||
this.smtpPort('' + Consts.Values.SmtpDefaulPort);
|
||||
this.smtpSecure(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin(false);
|
||||
this.smtpAuth(true);
|
||||
this.whiteList('');
|
||||
};
|
||||
|
||||
module.exports = DomainPopupView;
|
||||
|
||||
}());
|
||||
53
dev/View/Popup/Filter.js
Normal file
53
dev/View/Popup/Filter.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FilterPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFilter');
|
||||
|
||||
this.filter = ko.observable(null);
|
||||
|
||||
this.selectedFolderValue = ko.observable(Consts.Values.UnuseOptionValue);
|
||||
this.folderSelectList = Data.folderMenuForMove;
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Filter', 'PopupsFilterViewModel'], FilterPopupView);
|
||||
_.extend(FilterPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FilterPopupView.prototype.clearPopup = function ()
|
||||
{
|
||||
// TODO
|
||||
};
|
||||
|
||||
FilterPopupView.prototype.onShow = function (oFilter)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.filter(oFilter);
|
||||
};
|
||||
|
||||
module.exports = FilterPopupView;
|
||||
|
||||
}());
|
||||
124
dev/View/Popup/FolderClear.js
Normal file
124
dev/View/Popup/FolderClear.js
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
Cache = require('Storage/App/Cache'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderClearPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderClear');
|
||||
|
||||
this.selectedFolder = ko.observable(null);
|
||||
this.clearingProcess = ko.observable(false);
|
||||
this.clearingError = ko.observable('');
|
||||
|
||||
this.folderFullNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.printableFullName() : '';
|
||||
}, this);
|
||||
|
||||
this.folderNameForClear = ko.computed(function () {
|
||||
var oFolder = this.selectedFolder();
|
||||
return oFolder ? oFolder.localName() : '';
|
||||
}, this);
|
||||
|
||||
this.dangerDescHtml = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', {
|
||||
'FOLDER': this.folderNameForClear()
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.clearCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
oFolderToClear = this.selectedFolder()
|
||||
;
|
||||
|
||||
if (oFolderToClear)
|
||||
{
|
||||
Data.message(null);
|
||||
Data.messageList([]);
|
||||
|
||||
this.clearingProcess(true);
|
||||
|
||||
oFolderToClear.messageCountAll(0);
|
||||
oFolderToClear.messageCountUnread(0);
|
||||
|
||||
Cache.setFolderHash(oFolderToClear.fullNameRaw, '');
|
||||
|
||||
Remote.folderClear(function (sResult, oData) {
|
||||
|
||||
self.clearingProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
require('App/App').reloadMessageList(true);
|
||||
self.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
self.clearingError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
self.clearingError(Utils.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);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderClearPopupView;
|
||||
|
||||
}());
|
||||
132
dev/View/Popup/FolderCreate.js
Normal file
132
dev/View/Popup/FolderCreate.js
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderCreateView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderCreate');
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sNoParentText = Utils.i18n('POPUPS_CREATE_FOLDER/SELECT_NO_PARENT');
|
||||
}, this);
|
||||
|
||||
this.folderName = ko.observable('');
|
||||
this.folderName.focused = ko.observable(false);
|
||||
|
||||
this.selectedParentValue = ko.observable(Consts.Values.UnuseOptionValue);
|
||||
|
||||
this.parentFolderSelectList = ko.computed(function () {
|
||||
|
||||
var
|
||||
aTop = [],
|
||||
fDisableCallback = null,
|
||||
fVisibleCallback = null,
|
||||
aList = Data.folderList(),
|
||||
fRenameCallback = function (oItem) {
|
||||
return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : '';
|
||||
}
|
||||
;
|
||||
|
||||
aTop.push(['', this.sNoParentText]);
|
||||
|
||||
if ('' !== Data.namespace)
|
||||
{
|
||||
fDisableCallback = function (oItem)
|
||||
{
|
||||
return Data.namespace !== oItem.fullNameRaw.substr(0, Data.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 < Data.namespace.length)
|
||||
{
|
||||
sParentFolderName = Data.namespace.substr(0, Data.namespace.length - 1);
|
||||
}
|
||||
|
||||
Data.foldersCreating(true);
|
||||
Remote.folderCreate(function (sResult, oData) {
|
||||
|
||||
Data.foldersCreating(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
require('App/App').folders();
|
||||
}
|
||||
else
|
||||
{
|
||||
Data.foldersListError(
|
||||
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER'));
|
||||
}
|
||||
|
||||
}, this.folderName(), sParentFolderName);
|
||||
|
||||
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.sNoParentText = '';
|
||||
|
||||
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.onFocus = function ()
|
||||
{
|
||||
this.folderName.focused(true);
|
||||
};
|
||||
|
||||
module.exports = FolderCreateView;
|
||||
|
||||
}());
|
||||
136
dev/View/Popup/FolderSystem.js
Normal file
136
dev/View/Popup/FolderSystem.js
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/App/Data'),
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderSystemPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFolderSystem');
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.sChooseOnText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
|
||||
this.sUnuseText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
|
||||
}, this);
|
||||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.folderSelectList = ko.computed(function () {
|
||||
return Utils.folderListOptionsBuilder([], Data.folderList(), Data.folderListSystemNames(), [
|
||||
['', this.sChooseOnText],
|
||||
[Consts.Values.UnuseOptionValue, this.sUnuseText]
|
||||
]);
|
||||
}, this);
|
||||
|
||||
var
|
||||
self = this,
|
||||
fSaveSystemFolders = null,
|
||||
fCallback = null
|
||||
;
|
||||
|
||||
this.sentFolder = Data.sentFolder;
|
||||
this.draftFolder = Data.draftFolder;
|
||||
this.spamFolder = Data.spamFolder;
|
||||
this.trashFolder = Data.trashFolder;
|
||||
this.archiveFolder = Data.archiveFolder;
|
||||
|
||||
fSaveSystemFolders = _.debounce(function () {
|
||||
|
||||
Settings.settingsSet('SentFolder', self.sentFolder());
|
||||
Settings.settingsSet('DraftFolder', self.draftFolder());
|
||||
Settings.settingsSet('SpamFolder', self.spamFolder());
|
||||
Settings.settingsSet('TrashFolder', self.trashFolder());
|
||||
Settings.settingsSet('ArchiveFolder', self.archiveFolder());
|
||||
|
||||
Remote.saveSystemFolders(Utils.emptyFunction, {
|
||||
'SentFolder': self.sentFolder(),
|
||||
'DraftFolder': self.draftFolder(),
|
||||
'SpamFolder': self.spamFolder(),
|
||||
'TrashFolder': self.trashFolder(),
|
||||
'ArchiveFolder': self.archiveFolder(),
|
||||
'NullFolder': 'NullFolder'
|
||||
});
|
||||
|
||||
}, 1000);
|
||||
|
||||
fCallback = function () {
|
||||
|
||||
Settings.settingsSet('SentFolder', self.sentFolder());
|
||||
Settings.settingsSet('DraftFolder', self.draftFolder());
|
||||
Settings.settingsSet('SpamFolder', self.spamFolder());
|
||||
Settings.settingsSet('TrashFolder', self.trashFolder());
|
||||
Settings.settingsSet('ArchiveFolder', self.archiveFolder());
|
||||
|
||||
fSaveSystemFolders();
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fCallback);
|
||||
this.draftFolder.subscribe(fCallback);
|
||||
this.spamFolder.subscribe(fCallback);
|
||||
this.trashFolder.subscribe(fCallback);
|
||||
this.archiveFolder.subscribe(fCallback);
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
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 = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Draft:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Spam:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Trash:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH');
|
||||
break;
|
||||
case Enums.SetSystemFoldersNotification.Archive:
|
||||
sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE');
|
||||
break;
|
||||
}
|
||||
|
||||
this.notification(sNotification);
|
||||
};
|
||||
|
||||
module.exports = FolderSystemPopupView;
|
||||
|
||||
}());
|
||||
171
dev/View/Popup/Identity.js
Normal file
171
dev/View/Popup/Identity.js
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Remote = require('Storage/App/Remote'),
|
||||
Data = require('Storage/App/Data'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function IdentityPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsIdentity');
|
||||
|
||||
this.id = '';
|
||||
this.edit = ko.observable(false);
|
||||
this.owner = ko.observable(false);
|
||||
|
||||
this.email = ko.observable('').validateEmail();
|
||||
this.email.focused = ko.observable(false);
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
this.replyTo = ko.observable('').validateSimpleEmail();
|
||||
this.replyTo.focused = ko.observable(false);
|
||||
this.bcc = ko.observable('').validateSimpleEmail();
|
||||
this.bcc.focused = ko.observable(false);
|
||||
|
||||
// this.email.subscribe(function () {
|
||||
// this.email.hasError(false);
|
||||
// }, this);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.addOrEditIdentityCommand = Utils.createCommand(this, function () {
|
||||
|
||||
if (!this.email.hasError())
|
||||
{
|
||||
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/App').accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.id, this.email(), this.name(), this.replyTo(), this.bcc());
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.label = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'TITLE_UPDATE_IDENTITY': 'TITLE_ADD_IDENTITY'));
|
||||
}, this);
|
||||
|
||||
this.button = ko.computed(function () {
|
||||
return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'BUTTON_UPDATE_IDENTITY': 'BUTTON_ADD_IDENTITY'));
|
||||
}, this);
|
||||
|
||||
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.email.hasError(false);
|
||||
this.replyTo.hasError(false);
|
||||
this.bcc.hasError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?IdentityModel} oIdentity
|
||||
*/
|
||||
IdentityPopupView.prototype.onShow = function (oIdentity)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
if (oIdentity)
|
||||
{
|
||||
this.edit(true);
|
||||
|
||||
this.id = oIdentity.id;
|
||||
this.name(oIdentity.name());
|
||||
this.email(oIdentity.email());
|
||||
this.replyTo(oIdentity.replyTo());
|
||||
this.bcc(oIdentity.bcc());
|
||||
|
||||
this.owner(this.id === Data.accountEmail());
|
||||
}
|
||||
};
|
||||
|
||||
IdentityPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
if (!this.owner())
|
||||
{
|
||||
this.email.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = IdentityPopupView;
|
||||
|
||||
}());
|
||||
64
dev/View/Popup/KeyboardShortcutsHelp.js
Normal file
64
dev/View/Popup/KeyboardShortcutsHelp.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
key = require('key'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function KeyboardShortcutsHelpPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp');
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupKeyboardShortcutsHelp;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
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, _.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'))
|
||||
;
|
||||
|
||||
if (!bNext && iIndex > 0)
|
||||
{
|
||||
iIndex--;
|
||||
}
|
||||
else if (bNext && iIndex < $tabs.length - 1)
|
||||
{
|
||||
iIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iIndex = bNext ? 0 : $tabs.length - 1;
|
||||
}
|
||||
|
||||
$tabs.eq(iIndex).find('a[data-toggle="tab"]').tab('show');
|
||||
return false;
|
||||
}
|
||||
}, this));
|
||||
};
|
||||
|
||||
module.exports = KeyboardShortcutsHelpPopupView;
|
||||
|
||||
}());
|
||||
82
dev/View/Popup/Languages.js
Normal file
82
dev/View/Popup/Languages.js
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Globals = require('Common/Globals'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LanguagesPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsLanguages');
|
||||
|
||||
this.Data = Globals.__APP__.data(); // TODO
|
||||
|
||||
this.exp = ko.observable(false);
|
||||
|
||||
this.languages = ko.computed(function () {
|
||||
return _.map(this.Data.languages(), function (sLanguage) {
|
||||
return {
|
||||
'key': sLanguage,
|
||||
'selected': ko.observable(false),
|
||||
'fullName': Utils.convertLangName(sLanguage)
|
||||
};
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.Data.mainLanguage.subscribe(function () {
|
||||
this.resetMainLanguage();
|
||||
}, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Languages', 'PopupsLanguagesViewModel'], LanguagesPopupView);
|
||||
_.extend(LanguagesPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
LanguagesPopupView.prototype.languageEnName = function (sLanguage)
|
||||
{
|
||||
return Utils.convertLangName(sLanguage, true);
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.resetMainLanguage = function ()
|
||||
{
|
||||
var sCurrent = this.Data.mainLanguage();
|
||||
_.each(this.languages(), function (oItem) {
|
||||
oItem['selected'](oItem['key'] === sCurrent);
|
||||
});
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.exp(true);
|
||||
|
||||
this.resetMainLanguage();
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.onHide = function ()
|
||||
{
|
||||
this.exp(false);
|
||||
};
|
||||
|
||||
LanguagesPopupView.prototype.changeLanguage = function (sLang)
|
||||
{
|
||||
this.Data.mainLanguage(sLang);
|
||||
this.cancelCommand();
|
||||
};
|
||||
|
||||
module.exports = LanguagesPopupView;
|
||||
|
||||
}());
|
||||
115
dev/View/Popup/NewOpenPgpKey.js
Normal file
115
dev/View/Popup/NewOpenPgpKey.js
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Data = require('Storage/App/Data'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function NewOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsNewOpenPgpKey');
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.email.focus = ko.observable('');
|
||||
this.email.error = ko.observable(false);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.keyBitLength = ko.observable(2048);
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function () {
|
||||
this.email.error(false);
|
||||
}, this);
|
||||
|
||||
this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var
|
||||
self = this,
|
||||
sUserID = '',
|
||||
mKeyPair = null,
|
||||
oOpenpgpKeyring = Data.openpgpKeyring
|
||||
;
|
||||
|
||||
this.email.error('' === Utils.trim(this.email()));
|
||||
if (!oOpenpgpKeyring || this.email.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sUserID = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
sUserID = this.name() + ' <' + sUserID + '>';
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
_.delay(function () {
|
||||
// mKeyPair = Data.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password()));
|
||||
mKeyPair = Data.openpgp.generateKeyPair({
|
||||
'userId': sUserID,
|
||||
'numBits': Utils.pInt(self.keyBitLength()),
|
||||
'passphrase': Utils.trim(self.password())
|
||||
});
|
||||
|
||||
if (mKeyPair && mKeyPair.privateKeyArmored)
|
||||
{
|
||||
oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored);
|
||||
oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored);
|
||||
oOpenpgpKeyring.store();
|
||||
|
||||
require('App/App').reloadOpenPgpKeys();
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
|
||||
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.onFocus = function ()
|
||||
{
|
||||
this.email.focus(true);
|
||||
};
|
||||
|
||||
module.exports = NewOpenPgpKeyPopupView;
|
||||
|
||||
}());
|
||||
169
dev/View/Popup/Plugin.js
Normal file
169
dev/View/Popup/Plugin.js
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Remote = require('Storage/Admin/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PluginPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsPlugin');
|
||||
|
||||
var self = this;
|
||||
|
||||
this.onPluginSettingsUpdateResponse = _.bind(this.onPluginSettingsUpdateResponse, this);
|
||||
|
||||
this.saveError = ko.observable('');
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.readme = ko.observable('');
|
||||
|
||||
this.configures = ko.observableArray([]);
|
||||
|
||||
this.hasReadme = ko.computed(function () {
|
||||
return '' !== this.readme();
|
||||
}, this);
|
||||
|
||||
this.hasConfiguration = ko.computed(function () {
|
||||
return 0 < this.configures().length;
|
||||
}, this);
|
||||
|
||||
this.readmePopoverConf = {
|
||||
'placement': 'top',
|
||||
'trigger': 'hover',
|
||||
'title': 'About',
|
||||
'content': function () {
|
||||
return self.readme();
|
||||
}
|
||||
};
|
||||
|
||||
this.saveCommand = Utils.createCommand(this, function () {
|
||||
|
||||
var oList = {};
|
||||
|
||||
oList['Name'] = this.name();
|
||||
|
||||
_.each(this.configures(), function (oItem) {
|
||||
|
||||
var mValue = oItem.value();
|
||||
if (false === mValue || true === mValue)
|
||||
{
|
||||
mValue = mValue ? '1' : '0';
|
||||
}
|
||||
|
||||
oList['_' + oItem['Name']] = mValue;
|
||||
|
||||
}, this);
|
||||
|
||||
this.saveError('');
|
||||
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, oList);
|
||||
|
||||
}, this.hasConfiguration);
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.All;
|
||||
|
||||
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Plugin', 'PopupsPluginViewModel'], PluginPopupView);
|
||||
_.extend(PluginPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
PluginPopupView.prototype.onPluginSettingsUpdateResponse = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
this.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveError('');
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
this.saveError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveError(Utils.getNotification(Enums.Notification.CantSavePluginSettings));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PluginPopupView.prototype.onShow = function (oPlugin)
|
||||
{
|
||||
this.name();
|
||||
this.readme();
|
||||
this.configures([]);
|
||||
|
||||
if (oPlugin)
|
||||
{
|
||||
this.name(oPlugin['Name']);
|
||||
this.readme(oPlugin['Readme']);
|
||||
|
||||
var aConfig = oPlugin['Config'];
|
||||
if (Utils.isNonEmptyArray(aConfig))
|
||||
{
|
||||
this.configures(_.map(aConfig, function (aItem) {
|
||||
return {
|
||||
'value': ko.observable(aItem[0]),
|
||||
'Name': aItem[1],
|
||||
'Type': aItem[2],
|
||||
'Label': aItem[3],
|
||||
'Default': aItem[4],
|
||||
'Desc': aItem[5]
|
||||
};
|
||||
}));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PluginPopupView.prototype.tryToClosePopup = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
PopupsAskViewModel = require('View/Popup/Ask')
|
||||
;
|
||||
|
||||
if (!kn.isPopupVisible(PopupsAskViewModel))
|
||||
{
|
||||
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
|
||||
if (self.modalVisibility())
|
||||
{
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
}
|
||||
}]);
|
||||
}
|
||||
};
|
||||
|
||||
PluginPopupView.prototype.onBuild = function ()
|
||||
{
|
||||
key('esc', Enums.KeyState.All, _.bind(function () {
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
this.tryToClosePopup();
|
||||
}
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
|
||||
module.exports = PluginPopupView;
|
||||
|
||||
}());
|
||||
76
dev/View/Popup/TwoFactorTest.js
Normal file
76
dev/View/Popup/TwoFactorTest.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Remote = require('Storage/App/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function TwoFactorTestPopupView()
|
||||
{
|
||||
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.testing = ko.observable(false);
|
||||
|
||||
// commands
|
||||
this.testCode = Utils.createCommand(this, function () {
|
||||
|
||||
this.testing(true);
|
||||
Remote.testTwoFactor(function (sResult, oData) {
|
||||
|
||||
self.testing(false);
|
||||
self.code.status(Enums.StorageResultType.Success === sResult && oData && oData.Result ? true : false);
|
||||
|
||||
}, this.code());
|
||||
|
||||
}, function () {
|
||||
return '' !== this.code() && !this.testing();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['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);
|
||||
};
|
||||
|
||||
TwoFactorTestPopupView.prototype.onShow = function ()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
TwoFactorTestPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
this.code.focused(true);
|
||||
};
|
||||
|
||||
module.exports = TwoFactorTestPopupView;
|
||||
|
||||
}());
|
||||
59
dev/View/Popup/ViewOpenPgpKey.js
Normal file
59
dev/View/Popup/ViewOpenPgpKey.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ViewOpenPgpKeyPopupView()
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsViewOpenPgpKey');
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.keyDom = ko.observable(null);
|
||||
|
||||
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)
|
||||
{
|
||||
Utils.selectElement(oEl);
|
||||
}
|
||||
};
|
||||
|
||||
ViewOpenPgpKeyPopupView.prototype.onShow = function (oOpenPgpKey)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
if (oOpenPgpKey)
|
||||
{
|
||||
this.key(oOpenPgpKey.armor);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = ViewOpenPgpKeyPopupView;
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue