mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Code refactoring
This commit is contained in:
parent
345e7c58af
commit
8cf8b94d39
103 changed files with 664 additions and 659 deletions
34
dev/View/User/About.js
Normal file
34
dev/View/User/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 AboutUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'About');
|
||||
|
||||
this.version = ko.observable(Settings.settingsGet('Version'));
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/About', 'View/App/About', 'AboutViewModel'], AboutUserView);
|
||||
_.extend(AboutUserView.prototype, AbstractView.prototype);
|
||||
|
||||
module.exports = AboutUserView;
|
||||
|
||||
}());
|
||||
114
dev/View/User/AbstractSystemDropDown.js
Normal file
114
dev/View/User/AbstractSystemDropDown.js
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/User/Data'),
|
||||
Remote = require('Storage/User/Remote'),
|
||||
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AbstractSystemDropDownUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'SystemDropDown');
|
||||
|
||||
this.accounts = Data.accounts;
|
||||
this.accountEmail = Data.accountEmail;
|
||||
this.accountsLoading = Data.accountsLoading;
|
||||
|
||||
this.accountMenuDropdownTrigger = ko.observable(false);
|
||||
|
||||
this.capaAdditionalAccounts = ko.observable(Settings.capa(Enums.Capa.AdditionalAccounts));
|
||||
|
||||
this.loading = ko.computed(function () {
|
||||
return this.accountsLoading();
|
||||
}, this);
|
||||
|
||||
this.accountClick = _.bind(this.accountClick, this);
|
||||
}
|
||||
|
||||
_.extend(AbstractSystemDropDownUserView.prototype, AbstractView.prototype);
|
||||
|
||||
AbstractSystemDropDownUserView.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;
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.emailTitle = function ()
|
||||
{
|
||||
return Data.accountEmail();
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.settingsClick = function ()
|
||||
{
|
||||
require('Knoin/Knoin').setHash(Links.settings());
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.settingsHelp = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.addAccountClick = function ()
|
||||
{
|
||||
if (this.capaAdditionalAccounts())
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/AddAccount'));
|
||||
}
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.prototype.logoutClick = function ()
|
||||
{
|
||||
Remote.logout(function () {
|
||||
require('App/User').loginAndLogoutReload(true,
|
||||
Settings.settingsGet('ParentEmail') && 0 < Settings.settingsGet('ParentEmail').length);
|
||||
});
|
||||
};
|
||||
|
||||
AbstractSystemDropDownUserView.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 = AbstractSystemDropDownUserView;
|
||||
|
||||
}());
|
||||
353
dev/View/User/Login.js
Normal file
353
dev/View/User/Login.js
Normal file
|
|
@ -0,0 +1,353 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/User/Data'),
|
||||
Remote = require('Storage/User/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginUserView()
|
||||
{
|
||||
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 if (oData.Admin)
|
||||
{
|
||||
require('App/User').redirectToAdminPanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
require('App/User').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 &&
|
||||
Settings.settingsGet('RsaPublicKey'))
|
||||
{
|
||||
fLoginRequest(Utils.rsaEncode(sPassword, Settings.settingsGet('RsaPublicKey')));
|
||||
}
|
||||
else
|
||||
{
|
||||
fLoginRequest(sPassword);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}, function () {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
|
||||
this.facebookLoginEnabled = ko.observable(false);
|
||||
|
||||
this.facebookCommand = Utils.createCommand(this, function () {
|
||||
|
||||
window.open(Links.socialFacebook(), 'Facebook',
|
||||
'left=200,top=100,width=650,height=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(Links.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(Links.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/User/Login', 'View/App/Login', 'LoginViewModel'], LoginUserView);
|
||||
_.extend(LoginUserView.prototype, AbstractView.prototype);
|
||||
|
||||
LoginUserView.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);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.onHide = function ()
|
||||
{
|
||||
this.submitFocus(false);
|
||||
this.emailFocus(false);
|
||||
};
|
||||
|
||||
LoginUserView.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/User').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);
|
||||
};
|
||||
|
||||
LoginUserView.prototype.submitForm = function ()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
|
||||
LoginUserView.prototype.selectLanguage = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Languages'));
|
||||
};
|
||||
|
||||
module.exports = LoginUserView;
|
||||
|
||||
}());
|
||||
274
dev/View/User/MailBox/FolderList.js
Normal file
274
dev/View/User/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'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
Data = require('Storage/User/Data'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FolderListMailBoxUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'MailFolderList');
|
||||
|
||||
this.oContentVisible = null;
|
||||
this.oContentScrollable = null;
|
||||
|
||||
this.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/User/MailBox/FolderList', 'View/App/MailBox/FolderList', 'MailBoxFolderListViewModel'], FolderListMailBoxUserView);
|
||||
_.extend(FolderListMailBoxUserView.prototype, AbstractView.prototype);
|
||||
|
||||
FolderListMailBoxUserView.prototype.onBuild = function (oDom)
|
||||
{
|
||||
this.oContentVisible = $('.b-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
var self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function (oEvent) {
|
||||
|
||||
var
|
||||
oFolder = ko.dataFor(this),
|
||||
bCollapsed = false
|
||||
;
|
||||
|
||||
if (oFolder && oEvent)
|
||||
{
|
||||
bCollapsed = oFolder.collapsed();
|
||||
require('App/User').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(Links.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/User').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');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.messagesDropOver = function (oFolder)
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
if (oFolder && oFolder.collapsed())
|
||||
{
|
||||
this.iDropOverTimer = window.setTimeout(function () {
|
||||
oFolder.collapsed(false);
|
||||
require('App/User').setExpandedFolder(oFolder.fullNameHash, true);
|
||||
Utils.windowResize();
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.messagesDropOut = function ()
|
||||
{
|
||||
window.clearTimeout(this.iDropOverTimer);
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.scrollToFocused = function ()
|
||||
{
|
||||
if (!this.oContentVisible || !this.oContentScrollable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
FolderListMailBoxUserView.prototype.messagesDrop = function (oToFolder, oUi)
|
||||
{
|
||||
if (oToFolder && oUi && oUi.helper)
|
||||
{
|
||||
var
|
||||
sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
|
||||
bCopy = Globals.$html.hasClass('rl-ctrl-key-pressed'),
|
||||
aUids = oUi.helper.data('rl-uids')
|
||||
;
|
||||
|
||||
if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
|
||||
{
|
||||
require('App/User').moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.createFolder = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/FolderCreate'));
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.configureFolders = function ()
|
||||
{
|
||||
kn.setHash(Links.settings('folders'));
|
||||
};
|
||||
|
||||
FolderListMailBoxUserView.prototype.contactsClick = function ()
|
||||
{
|
||||
if (this.allowContacts)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Contacts'));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FolderListMailBoxUserView;
|
||||
|
||||
}());
|
||||
935
dev/View/User/MailBox/MessageList.js
Normal file
935
dev/View/User/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'),
|
||||
Links = require('Common/Links'),
|
||||
Events = require('Common/Events'),
|
||||
Selector = require('Common/Selector'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
Data = require('Storage/User/Data'),
|
||||
Remote = require('Storage/User/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MessageListMailBoxUserView()
|
||||
{
|
||||
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/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), false);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.deleteCommand = Utils.createCommand(this, function () {
|
||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.archiveCommand = Utils.createCommand(this, function () {
|
||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Archive,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.spamCommand = Utils.createCommand(this, function () {
|
||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Spam,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
|
||||
}, this.canBeMoved);
|
||||
|
||||
this.notSpamCommand = Utils.createCommand(this, function () {
|
||||
require('App/User').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/User').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(Links.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/User/MailBox/MessageList', 'View/App/MailBox/MessageList', 'MailBoxMessageListViewModel'], MessageListMailBoxUserView);
|
||||
_.extend(MessageListMailBoxUserView.prototype, AbstractView.prototype);
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
MessageListMailBoxUserView.prototype.emptySubjectValue = '';
|
||||
|
||||
MessageListMailBoxUserView.prototype.searchEnterAction = function ()
|
||||
{
|
||||
this.mainMessageListSearch(this.sLastSearchValue);
|
||||
this.inputMessageListSearchFocus(false);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
MessageListMailBoxUserView.prototype.printableMessageCountForDeletion = function ()
|
||||
{
|
||||
var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
|
||||
return 1 < iCnt ? ' (' + (100 > iCnt ? iCnt : '99+') + ')' : '';
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.cancelSearch = function ()
|
||||
{
|
||||
this.mainMessageListSearch('');
|
||||
this.inputMessageListSearchFocus(false);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sToFolderFullNameRaw
|
||||
* @param {boolean} bCopy
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageListMailBoxUserView.prototype.moveSelectedMessagesToFolder = function (sToFolderFullNameRaw, bCopy)
|
||||
{
|
||||
if (this.canBeMoved())
|
||||
{
|
||||
require('App/User').moveMessagesToFolder(
|
||||
Data.currentFolderFullNameRaw(),
|
||||
Data.messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw, bCopy);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.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
|
||||
*/
|
||||
MessageListMailBoxUserView.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)));
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.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
|
||||
*/
|
||||
MessageListMailBoxUserView.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/User').reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sFolderFullNameRaw
|
||||
* @param {number} iSetAction
|
||||
*/
|
||||
MessageListMailBoxUserView.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/User').reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.listSetSeen = function ()
|
||||
{
|
||||
this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen, Data.messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.listSetAllSeen = function ()
|
||||
{
|
||||
this.setActionForAll(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen);
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.listUnsetSeen = function ()
|
||||
{
|
||||
this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetSeen, Data.messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.listSetFlags = function ()
|
||||
{
|
||||
this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetFlag, Data.messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.listUnsetFlags = function ()
|
||||
{
|
||||
this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetFlag, Data.messageListCheckedOrSelected());
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.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]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.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/User').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(Links.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 && ifvisible && Settings.capa(Enums.Capa.Prefetch))
|
||||
{
|
||||
ifvisible.setIdleDuration(10);
|
||||
|
||||
ifvisible.idle(function () {
|
||||
self.prefetchNextTick();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.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;
|
||||
});
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.prefetchNextTick = function ()
|
||||
{
|
||||
if (ifvisible && !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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.advancedSearchClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/AdvancedSearch'));
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.quotaTooltip = function ()
|
||||
{
|
||||
return Utils.i18n('MESSAGE_LIST/QUOTA_SIZE', {
|
||||
'SIZE': Utils.friendlySize(this.userUsageSize()),
|
||||
'PROC': this.userUsageProc(),
|
||||
'LIMIT': Utils.friendlySize(this.userQuota())
|
||||
});
|
||||
};
|
||||
|
||||
MessageListMailBoxUserView.prototype.initUploaderForAppend = function ()
|
||||
{
|
||||
if (!Settings.settingsGet('AllowAppendMessage') || !this.dragOverArea())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var
|
||||
oJua = new Jua({
|
||||
'action': Links.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/User').reloadMessageList(true, true);
|
||||
}, this))
|
||||
;
|
||||
|
||||
return !!oJua;
|
||||
};
|
||||
|
||||
module.exports = MessageListMailBoxUserView;
|
||||
|
||||
}());
|
||||
722
dev/View/User/MailBox/MessageView.js
Normal file
722
dev/View/User/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/User/Cache'),
|
||||
Data = require('Storage/User/Data'),
|
||||
Remote = require('Storage/User/Remote'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MessageViewMailBoxUserView()
|
||||
{
|
||||
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/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||
this.message().folderFullNameRaw,
|
||||
[this.message().uid], true);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Trash,
|
||||
Data.currentFolderFullNameRaw(),
|
||||
[this.message().uid], false);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.archiveCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Archive,
|
||||
this.message().folderFullNameRaw,
|
||||
[this.message().uid], true);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.spamCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/User').deleteMessagesFromFolder(Enums.FolderType.Spam,
|
||||
this.message().folderFullNameRaw,
|
||||
[this.message().uid], true);
|
||||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.notSpamCommand = Utils.createCommand(this, function () {
|
||||
if (this.message())
|
||||
{
|
||||
require('App/User').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/User/MailBox/MessageView', 'View/App/MailBox/MessageView', 'MailBoxMessageViewViewModel'], MessageViewMailBoxUserView);
|
||||
_.extend(MessageViewMailBoxUserView.prototype, AbstractView.prototype);
|
||||
|
||||
MessageViewMailBoxUserView.prototype.isPgpActionVisible = function ()
|
||||
{
|
||||
return Enums.SignedVerifyStatus.Success !== this.viewPgpSignedVerifyStatus();
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.isPgpStatusVerifyVisible = function ()
|
||||
{
|
||||
return Enums.SignedVerifyStatus.None !== this.viewPgpSignedVerifyStatus();
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.isPgpStatusVerifySuccess = function ()
|
||||
{
|
||||
return Enums.SignedVerifyStatus.Success === this.viewPgpSignedVerifyStatus();
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.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;
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.fullScreen = function ()
|
||||
{
|
||||
this.fullScreenMode(true);
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.unFullScreen = function ()
|
||||
{
|
||||
this.fullScreenMode(false);
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.toggleFullScreen = function ()
|
||||
{
|
||||
Utils.removeSelection();
|
||||
|
||||
this.fullScreenMode(!this.fullScreenMode());
|
||||
Utils.windowResize();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sType
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.replyOrforward = function (sType)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'), [sType, Data.message()]);
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.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/User').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}
|
||||
*/
|
||||
MessageViewMailBoxUserView.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;
|
||||
}
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.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}
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.isDraftFolder = function ()
|
||||
{
|
||||
return Data.message() && Data.draftFolder() === Data.message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.isSentFolder = function ()
|
||||
{
|
||||
return Data.message() && Data.sentFolder() === Data.message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.isSpamFolder = function ()
|
||||
{
|
||||
return Data.message() && Data.spamFolder() === Data.message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.isSpamDisabled = function ()
|
||||
{
|
||||
return Data.message() && Data.spamFolder() === Consts.Values.UnuseOptionValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.isArchiveFolder = function ()
|
||||
{
|
||||
return Data.message() && Data.archiveFolder() === Data.message().folderFullNameRaw;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.isArchiveDisabled = function ()
|
||||
{
|
||||
return Data.message() && Data.archiveFolder() === Consts.Values.UnuseOptionValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.isDraftOrSentFolder = function ()
|
||||
{
|
||||
return this.isDraftFolder() || this.isSentFolder();
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.composeClick = function ()
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'));
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.editMessage = function ()
|
||||
{
|
||||
if (Data.message())
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/Compose'), [Enums.ComposeType.Draft, Data.message()]);
|
||||
}
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.scrollMessageToTop = function ()
|
||||
{
|
||||
if (this.oMessageScrollerDom)
|
||||
{
|
||||
this.oMessageScrollerDom.scrollTop(0);
|
||||
Utils.windowResize();
|
||||
}
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.scrollMessageToLeft = function ()
|
||||
{
|
||||
if (this.oMessageScrollerDom)
|
||||
{
|
||||
this.oMessageScrollerDom.scrollLeft(0);
|
||||
Utils.windowResize();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.showImages = function (oMessage)
|
||||
{
|
||||
if (oMessage && oMessage.showExternalImages)
|
||||
{
|
||||
oMessage.showExternalImages(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.printableCheckedMessageCount = function ()
|
||||
{
|
||||
var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
|
||||
return 0 < iCnt ? (100 > iCnt ? iCnt : '99+') : '';
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.verifyPgpSignedClearMessage = function (oMessage)
|
||||
{
|
||||
if (oMessage)
|
||||
{
|
||||
oMessage.verifyPgpSignedClearMessage();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MessageViewMailBoxUserView.prototype.decryptPgpEncryptedMessage = function (oMessage)
|
||||
{
|
||||
if (oMessage)
|
||||
{
|
||||
oMessage.decryptPgpEncryptedMessage(this.viewPgpPassword());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {MessageModel} oMessage
|
||||
*/
|
||||
MessageViewMailBoxUserView.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/User').reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = MessageViewMailBoxUserView;
|
||||
|
||||
}());
|
||||
28
dev/View/User/MailBox/SystemDropDown.js
Normal file
28
dev/View/User/MailBox/SystemDropDown.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractSystemDropDownViewModel = require('View/User/AbstractSystemDropDown')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownViewModel
|
||||
*/
|
||||
function SystemDropDownMailBoxUserView()
|
||||
{
|
||||
AbstractSystemDropDownViewModel.call(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/MailBox/SystemDropDown', 'View/App/MailBox/SystemDropDown', 'MailBoxSystemDropDownViewModel'], SystemDropDownMailBoxUserView);
|
||||
_.extend(SystemDropDownMailBoxUserView.prototype, AbstractSystemDropDownViewModel.prototype);
|
||||
|
||||
module.exports = SystemDropDownMailBoxUserView;
|
||||
|
||||
}());
|
||||
50
dev/View/User/Settings/Menu.js
Normal file
50
dev/View/User/Settings/Menu.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Cache = require('Storage/User/Cache'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MenuSettingsUserView(oScreen)
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'SettingsMenu');
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/Settings/Menu', 'View/App/Settings/Menu', 'SettingsMenuViewModel'], MenuSettingsUserView);
|
||||
_.extend(MenuSettingsUserView.prototype, AbstractView.prototype);
|
||||
|
||||
MenuSettingsUserView.prototype.link = function (sRoute)
|
||||
{
|
||||
return Links.settings(sRoute);
|
||||
};
|
||||
|
||||
MenuSettingsUserView.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(Links.inbox(Cache.getFolderInboxName()));
|
||||
};
|
||||
|
||||
module.exports = MenuSettingsUserView;
|
||||
|
||||
}());
|
||||
54
dev/View/User/Settings/Pane.js
Normal file
54
dev/View/User/Settings/Pane.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
key = require('key'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Data = require('Storage/User/Data'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsUserView()
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'SettingsPane');
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/Settings/Pane', 'View/App/Settings/Pane', 'SettingsPaneViewModel'], PaneSettingsUserView);
|
||||
_.extend(PaneSettingsUserView.prototype, AbstractView.prototype);
|
||||
|
||||
PaneSettingsUserView.prototype.onBuild = function ()
|
||||
{
|
||||
var self = this;
|
||||
key('esc', Enums.KeyState.Settings, function () {
|
||||
self.backToMailBoxClick();
|
||||
});
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.onShow = function ()
|
||||
{
|
||||
Data.message(null);
|
||||
};
|
||||
|
||||
PaneSettingsUserView.prototype.backToMailBoxClick = function ()
|
||||
{
|
||||
kn.setHash(Links.inbox(Cache.getFolderInboxName()));
|
||||
};
|
||||
|
||||
module.exports = PaneSettingsUserView;
|
||||
|
||||
}());
|
||||
28
dev/View/User/Settings/SystemDropDown.js
Normal file
28
dev/View/User/Settings/SystemDropDown.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractSystemDropDownUserView = require('View/User/AbstractSystemDropDown')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractSystemDropDownUserView
|
||||
*/
|
||||
function SystemDropDownSettingsUserView()
|
||||
{
|
||||
AbstractSystemDropDownUserView.call(this);
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/User/Settings/SystemDropDown', 'View/App/Settings/SystemDropDown', 'SettingsSystemDropDownViewModel'], SystemDropDownSettingsUserView);
|
||||
_.extend(SystemDropDownSettingsUserView.prototype, AbstractSystemDropDownUserView.prototype);
|
||||
|
||||
module.exports = SystemDropDownSettingsUserView;
|
||||
|
||||
}());
|
||||
Loading…
Add table
Add a link
Reference in a new issue