snappymail/dev/ViewModels/MailBoxMessageViewViewModel.js

722 lines
18 KiB
JavaScript
Raw Normal View History

2014-09-05 06:49:03 +08:00
(function () {
2014-08-25 23:49:01 +08:00
'use strict';
2014-08-20 23:03:12 +08:00
var
_ = require('_'),
2014-08-25 23:49:01 +08:00
$ = require('$'),
ko = require('ko'),
key = require('key'),
2014-08-25 15:10:51 +08:00
2014-09-05 06:49:03 +08:00
Consts = require('Common/Consts'),
Enums = require('Common/Enums'),
Globals = require('Common/Globals'),
Utils = require('Common/Utils'),
Events = require('Common/Events'),
2014-08-21 23:08:34 +08:00
2014-08-27 23:59:44 +08:00
Cache = require('Storage:RainLoop:Cache'),
Data = require('Storage:RainLoop:Data'),
Remote = require('Storage:RainLoop:Remote'),
2014-08-22 23:08:56 +08:00
2014-08-27 23:59:44 +08:00
kn = require('App:Knoin'),
KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
;
2014-08-20 23:03:12 +08:00
/**
* @constructor
* @extends KnoinAbstractViewModel
*/
function MailBoxMessageViewViewModel()
{
KnoinAbstractViewModel.call(this, 'Right', 'MailMessageView');
var
self = this,
sLastEmail = '',
createCommandHelper = function (sType) {
return Utils.createCommand(self, function () {
this.replyOrforward(sType);
}, self.canBeRepliedOrForwarded);
}
;
this.oMessageScrollerDom = null;
2014-08-22 23:08:56 +08:00
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;
2014-08-20 23:03:12 +08:00
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);
2014-08-20 23:03:12 +08:00
this.canBeRepliedOrForwarded = this.messageVisibility;
2014-08-20 23:03:12 +08:00
// commands
this.closeMessage = Utils.createCommand(this, function () {
2014-08-22 23:08:56 +08:00
Data.message(null);
2014-08-20 23:03:12 +08:00
});
2014-08-20 23:03:12 +08:00
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);
2014-08-20 23:03:12 +08:00
this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility);
2014-03-20 00:18:28 +08:00
2014-08-20 23:03:12 +08:00
this.messageEditCommand = Utils.createCommand(this, function () {
this.editMessage();
}, this.messageVisibility);
2014-08-20 23:03:12 +08:00
this.deleteCommand = Utils.createCommand(this, function () {
if (this.message())
{
2014-08-27 23:59:44 +08:00
require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Trash,
2014-08-20 23:03:12 +08:00
this.message().folderFullNameRaw,
[this.message().uid], true);
}
}, this.messageVisibility);
2014-08-20 23:03:12 +08:00
this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
if (this.message())
{
2014-08-27 23:59:44 +08:00
require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Trash,
2014-08-22 23:08:56 +08:00
Data.currentFolderFullNameRaw(),
2014-08-20 23:03:12 +08:00
[this.message().uid], false);
}
}, this.messageVisibility);
2014-08-20 23:03:12 +08:00
this.archiveCommand = Utils.createCommand(this, function () {
if (this.message())
{
2014-08-27 23:59:44 +08:00
require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Archive,
2014-08-20 23:03:12 +08:00
this.message().folderFullNameRaw,
[this.message().uid], true);
}
}, this.messageVisibility);
2014-08-20 23:03:12 +08:00
this.spamCommand = Utils.createCommand(this, function () {
if (this.message())
{
2014-08-27 23:59:44 +08:00
require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Spam,
2014-08-20 23:03:12 +08:00
this.message().folderFullNameRaw,
[this.message().uid], true);
}
2014-08-20 23:03:12 +08:00
}, this.messageVisibility);
2014-08-20 23:03:12 +08:00
this.notSpamCommand = Utils.createCommand(this, function () {
if (this.message())
{
2014-08-27 23:59:44 +08:00
require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.NotSpam,
2014-08-20 23:03:12 +08:00
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('');
2014-08-20 23:03:12 +08:00
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)
{
2014-08-20 23:03:12 +08:00
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());
2014-08-20 23:03:12 +08:00
this.viewMoment(oMessage.momentDate());
this.viewLineAsCcc(oMessage.lineAsCcc());
this.viewViewLink(oMessage.viewLink());
this.viewDownloadLink(oMessage.downloadLink());
sLastEmail = oMessage.fromAsSingleEmail();
2014-08-21 23:08:34 +08:00
Cache.getUserPic(sLastEmail, function (sPic, $sEmail) {
2014-08-20 23:03:12 +08:00
if (sPic !== self.viewUserPic() && sLastEmail === $sEmail)
{
2014-08-20 23:03:12 +08:00
self.viewUserPicVisible(false);
self.viewUserPic(Consts.DataImages.UserDotPic);
if ('' !== sPic)
{
self.viewUserPicVisible(true);
self.viewUserPic(sPic);
}
}
2014-08-20 23:03:12 +08:00
});
}
else
{
this.viewHash = '';
this.scrollMessageToTop();
}
}, this);
this.fullScreenMode.subscribe(function (bValue) {
if (bValue)
{
2014-09-02 00:05:32 +08:00
Globals.$html.addClass('rl-message-fullscreen');
2014-08-20 23:03:12 +08:00
}
else
{
2014-09-02 00:05:32 +08:00
Globals.$html.removeClass('rl-message-fullscreen');
2014-08-20 23:03:12 +08:00
}
Utils.windowResize();
});
this.messageLoadingThrottle.subscribe(function (bV) {
if (bV)
{
Utils.windowResize();
}
});
this.goUpCommand = Utils.createCommand(this, function () {
2014-08-22 23:08:56 +08:00
Events.pub('mailbox.message-list.selector.go-up');
2014-08-20 23:03:12 +08:00
});
this.goDownCommand = Utils.createCommand(this, function () {
2014-08-22 23:08:56 +08:00
Events.pub('mailbox.message-list.selector.go-down');
2014-08-20 23:03:12 +08:00
});
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View:RainLoop:MailBoxMessageView', 'MailBoxMessageViewViewModel'], MailBoxMessageViewViewModel);
_.extend(MailBoxMessageViewViewModel.prototype, KnoinAbstractViewModel.prototype);
2014-08-20 23:03:12 +08:00
MailBoxMessageViewViewModel.prototype.isPgpActionVisible = function ()
{
return Enums.SignedVerifyStatus.Success !== this.viewPgpSignedVerifyStatus();
};
MailBoxMessageViewViewModel.prototype.isPgpStatusVerifyVisible = function ()
{
return Enums.SignedVerifyStatus.None !== this.viewPgpSignedVerifyStatus();
};
MailBoxMessageViewViewModel.prototype.isPgpStatusVerifySuccess = function ()
{
return Enums.SignedVerifyStatus.Success === this.viewPgpSignedVerifyStatus();
};
MailBoxMessageViewViewModel.prototype.pgpStatusVerifyMessage = function ()
{
var sResult = '';
switch (this.viewPgpSignedVerifyStatus())
{
2014-08-20 23:03:12 +08:00
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;
}
2014-08-20 23:03:12 +08:00
return sResult;
};
2014-08-20 23:03:12 +08:00
MailBoxMessageViewViewModel.prototype.fullScreen = function ()
{
this.fullScreenMode(true);
Utils.windowResize();
};
2014-08-20 23:03:12 +08:00
MailBoxMessageViewViewModel.prototype.unFullScreen = function ()
{
this.fullScreenMode(false);
Utils.windowResize();
};
2014-08-20 23:03:12 +08:00
MailBoxMessageViewViewModel.prototype.toggleFullScreen = function ()
{
Utils.removeSelection();
2013-12-13 07:23:47 +08:00
2014-08-20 23:03:12 +08:00
this.fullScreenMode(!this.fullScreenMode());
Utils.windowResize();
};
2014-08-20 23:03:12 +08:00
/**
* @param {string} sType
*/
MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType)
{
2014-08-27 23:59:44 +08:00
kn.showScreenPopup(require('View:Popup:Compose'), [sType, Data.message()]);
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
{
2014-08-27 23:59:44 +08:00
var self = this;
2014-08-20 23:03:12 +08:00
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() {
2014-08-22 23:08:56 +08:00
Globals.useKeyboardShortcuts(false);
2014-08-20 23:03:12 +08:00
},
'close': function() {
2014-08-22 23:08:56 +08:00
Globals.useKeyboardShortcuts(true);
2014-08-20 23:03:12 +08:00
}
},
'mainClass': 'mfp-fade',
'removalDelay': 400
});
2014-04-02 02:03:37 +08:00
2014-08-20 23:03:12 +08:00
oDom
.on('click', 'a', function (oEvent) {
// setup maito protocol
return !(!!oEvent && 3 !== oEvent['which'] && Utils.mailToHelper($(this).attr('href'), require('View:Popup:Compose')));
2014-08-20 23:03:12 +08:00
})
.on('click', '.attachmentsPlace .attachmentPreview', function (oEvent) {
if (oEvent && oEvent.stopPropagation)
{
oEvent.stopPropagation();
}
})
.on('click', '.attachmentsPlace .attachmentItem', function () {
2014-04-02 02:03:37 +08:00
2014-08-20 23:03:12 +08:00
var
oAttachment = ko.dataFor(this)
;
if (oAttachment && oAttachment.download)
{
2014-08-27 23:59:44 +08:00
require('App:RainLoop').download(oAttachment.linkDownload());
2014-08-20 23:03:12 +08:00
}
})
;
this.message.focused.subscribe(function (bValue) {
if (bValue && !Utils.inFocus()) {
this.messageDomFocused(true);
} else {
this.messageDomFocused(false);
this.scrollMessageToTop();
this.scrollMessageToLeft();
2014-08-20 23:03:12 +08:00
}
}, this);
2014-04-02 02:03:37 +08:00
2014-08-20 23:03:12 +08:00
this.messageDomFocused.subscribe(function (bValue) {
2014-08-22 23:08:56 +08:00
if (!bValue && Enums.KeyState.MessageView === Globals.keyScope())
2014-08-20 23:03:12 +08:00
{
this.message.focused(false);
}
}, this);
2014-04-02 02:03:37 +08:00
2014-08-22 23:08:56 +08:00
Globals.keyScope.subscribe(function (sValue) {
2014-08-20 23:03:12 +08:00
if (Enums.KeyState.MessageView === sValue && this.message.focused())
{
this.messageDomFocused(true);
}
}, this);
2014-08-20 23:03:12 +08:00
this.oMessageScrollerDom = oDom.find('.messageItem .content');
this.oMessageScrollerDom = this.oMessageScrollerDom && this.oMessageScrollerDom[0] ? this.oMessageScrollerDom : null;
this.initShortcuts();
};
2014-08-20 23:03:12 +08:00
/**
* @return {boolean}
*/
MailBoxMessageViewViewModel.prototype.escShortcuts = function ()
{
if (this.viewModelVisibility() && this.message())
{
2014-08-20 23:03:12 +08:00
if (this.fullScreenMode())
{
this.fullScreenMode(false);
}
2014-08-22 23:08:56 +08:00
else if (Enums.Layout.NoPreview === Data.layout())
2014-08-20 23:03:12 +08:00
{
this.message(null);
}
else
{
this.message.focused(false);
}
return false;
}
2014-08-20 23:03:12 +08:00
};
MailBoxMessageViewViewModel.prototype.initShortcuts = function ()
{
var
2014-08-22 23:08:56 +08:00
self = this
2014-08-20 23:03:12 +08:00
;
// 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 () {
2014-08-22 23:08:56 +08:00
if (Enums.Layout.NoPreview !== Data.layout() && self.message())
2014-08-20 23:03:12 +08:00
{
self.toggleFullScreen();
return false;
}
2014-08-20 23:03:12 +08:00
});
// 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 () {
2014-08-22 23:08:56 +08:00
if (Data.message())
{
2014-08-20 23:03:12 +08:00
self.replyCommand();
return false;
}
2014-08-20 23:03:12 +08:00
});
// replaAll
key('a', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
2014-08-22 23:08:56 +08:00
if (Data.message())
{
2014-08-20 23:03:12 +08:00
self.replyAllCommand();
return false;
}
2014-08-20 23:03:12 +08:00
});
2014-08-20 23:03:12 +08:00
// forward
key('f', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
2014-08-22 23:08:56 +08:00
if (Data.message())
2014-08-20 23:03:12 +08:00
{
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 () {
2014-08-22 23:08:56 +08:00
if (Data.message() && Data.message().body)
2014-08-20 23:03:12 +08:00
{
Data.message().body.find('.rlBlockquoteSwitcher').click();
2014-08-20 23:03:12 +08:00
return false;
}
});
2014-08-20 23:03:12 +08:00
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())
{
2014-08-20 23:03:12 +08:00
self.message().printMessage();
}
2014-08-20 23:03:12 +08:00
return false;
});
2014-08-20 23:03:12 +08:00
// delete
key('delete, shift+delete', Enums.KeyState.MessageView, function (event, handler) {
if (event)
{
if (handler && 'shift+delete' === handler.shortcut)
{
self.deleteWithoutMoveCommand();
}
else
{
self.deleteCommand();
}
2014-08-20 23:03:12 +08:00
return false;
}
});
2014-08-20 23:03:12 +08:00
// change focused state
key('tab, shift+tab, left', Enums.KeyState.MessageView, function (event, handler) {
2014-08-22 23:08:56 +08:00
if (!self.fullScreenMode() && self.message() && Enums.Layout.NoPreview !== Data.layout())
2014-08-20 23:03:12 +08:00
{
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;
2014-08-20 23:03:12 +08:00
}
2014-08-20 23:03:12 +08:00
return false;
});
};
2014-08-20 23:03:12 +08:00
/**
* @return {boolean}
*/
MailBoxMessageViewViewModel.prototype.isDraftFolder = function ()
{
2014-08-22 23:08:56 +08:00
return Data.message() && Data.draftFolder() === Data.message().folderFullNameRaw;
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @return {boolean}
*/
MailBoxMessageViewViewModel.prototype.isSentFolder = function ()
{
2014-08-22 23:08:56 +08:00
return Data.message() && Data.sentFolder() === Data.message().folderFullNameRaw;
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @return {boolean}
*/
MailBoxMessageViewViewModel.prototype.isSpamFolder = function ()
{
2014-08-22 23:08:56 +08:00
return Data.message() && Data.spamFolder() === Data.message().folderFullNameRaw;
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @return {boolean}
*/
MailBoxMessageViewViewModel.prototype.isSpamDisabled = function ()
{
2014-08-22 23:08:56 +08:00
return Data.message() && Data.spamFolder() === Consts.Values.UnuseOptionValue;
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @return {boolean}
*/
MailBoxMessageViewViewModel.prototype.isArchiveFolder = function ()
{
2014-08-22 23:08:56 +08:00
return Data.message() && Data.archiveFolder() === Data.message().folderFullNameRaw;
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @return {boolean}
*/
MailBoxMessageViewViewModel.prototype.isArchiveDisabled = function ()
{
2014-08-22 23:08:56 +08:00
return Data.message() && Data.archiveFolder() === Consts.Values.UnuseOptionValue;
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @return {boolean}
*/
MailBoxMessageViewViewModel.prototype.isDraftOrSentFolder = function ()
{
return this.isDraftFolder() || this.isSentFolder();
};
2014-08-20 23:03:12 +08:00
MailBoxMessageViewViewModel.prototype.composeClick = function ()
{
2014-08-27 23:59:44 +08:00
kn.showScreenPopup(require('View:Popup:Compose'));
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
MailBoxMessageViewViewModel.prototype.editMessage = function ()
{
2014-08-22 23:08:56 +08:00
if (Data.message())
{
2014-08-27 23:59:44 +08:00
kn.showScreenPopup(require('View:Popup:Compose'), [Enums.ComposeType.Draft, Data.message()]);
}
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
MailBoxMessageViewViewModel.prototype.scrollMessageToTop = function ()
{
if (this.oMessageScrollerDom)
{
2014-08-20 23:03:12 +08:00
this.oMessageScrollerDom.scrollTop(0);
Utils.windowResize();
}
};
MailBoxMessageViewViewModel.prototype.scrollMessageToLeft = function ()
{
if (this.oMessageScrollerDom)
{
this.oMessageScrollerDom.scrollLeft(0);
Utils.windowResize();
}
2014-08-20 23:03:12 +08:00
};
/**
* @param {MessageModel} oMessage
*/
MailBoxMessageViewViewModel.prototype.showImages = function (oMessage)
{
if (oMessage && oMessage.showExternalImages)
{
2014-08-20 23:03:12 +08:00
oMessage.showExternalImages(true);
}
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @returns {string}
*/
MailBoxMessageViewViewModel.prototype.printableCheckedMessageCount = function ()
{
var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
return 0 < iCnt ? (100 > iCnt ? iCnt : '99+') : '';
};
2014-08-20 23:03:12 +08:00
/**
* @param {MessageModel} oMessage
*/
MailBoxMessageViewViewModel.prototype.verifyPgpSignedClearMessage = function (oMessage)
{
if (oMessage)
{
2014-08-20 23:03:12 +08:00
oMessage.verifyPgpSignedClearMessage();
}
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @param {MessageModel} oMessage
*/
MailBoxMessageViewViewModel.prototype.decryptPgpEncryptedMessage = function (oMessage)
{
if (oMessage)
{
2014-08-20 23:03:12 +08:00
oMessage.decryptPgpEncryptedMessage(this.viewPgpPassword());
}
2014-08-20 23:03:12 +08:00
};
2014-08-20 23:03:12 +08:00
/**
* @param {MessageModel} oMessage
*/
MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage)
{
if (oMessage && '' !== oMessage.readReceipt())
{
2014-08-21 23:08:34 +08:00
Remote.sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
2014-08-20 23:03:12 +08:00
oMessage.readReceipt(),
Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
2014-08-22 23:08:56 +08:00
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': Data.accountEmail()}));
2014-08-20 23:03:12 +08:00
oMessage.isReadReceipt(true);
2014-08-21 23:08:34 +08:00
Cache.storeMessageFlagsToCache(oMessage);
2014-08-25 15:10:51 +08:00
2014-08-27 23:59:44 +08:00
require('App:RainLoop').reloadFlagsCurrentMessageListAndMessageFromCache();
2014-08-20 23:03:12 +08:00
}
};
2014-01-04 08:20:07 +08:00
2014-08-20 23:03:12 +08:00
module.exports = MailBoxMessageViewViewModel;
2014-01-04 08:20:07 +08:00
2014-09-05 06:49:03 +08:00
}());