diff --git a/dev/Boots/RainLoopApp.js b/dev/Boots/RainLoopApp.js index 58dd84a5b..fc9f9bced 100644 --- a/dev/Boots/RainLoopApp.js +++ b/dev/Boots/RainLoopApp.js @@ -13,6 +13,7 @@ function RainLoopApp() this.oCache = null; this.quotaDebounce = _.debounce(this.quota, 1000 * 30); + this.moveOrDeleteResponseHelper = _.bind(this.moveOrDeleteResponseHelper, this); window.setInterval(function () { RL.pub('interval.30s'); @@ -163,6 +164,137 @@ RainLoopApp.prototype.recacheInboxMessageList = function () RL.remote().messageList(Utils.emptyFunction, 'INBOX', 0, RL.data().messagesPerPage(), '', true); }; +RainLoopApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData) +{ + if (Enums.StorageResultType.Success === sResult && RL.data().currentFolder()) + { + if (oData && Utils.isArray(oData.Result) && 2 === oData.Result.length) + { + RL.cache().setFolderHash(oData.Result[0], oData.Result[1]); + } + else + { + RL.cache().setFolderHash(RL.data().currentFolderFullNameRaw(), ''); + + if (oData && -1 < Utils.inArray(oData.ErrorCode, + [Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage])) + { + window.alert(Utils.getNotification(oData.ErrorCode)); + } + } + + RL.reloadMessageList(0 === RL.data().messageList().length); + RL.quotaDebounce(); + } +}; + +/** + * @param {string} sFromFolderFullNameRaw + * @param {Array} aUidForRemove + */ +RainLoopApp.prototype.deleteMessagesFromFolderWithoutCheck = function (sFromFolderFullNameRaw, aUidForRemove) +{ + RL.remote().messagesDelete( + this.moveOrDeleteResponseHelper, + sFromFolderFullNameRaw, + aUidForRemove + ); + + RL.data().removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); +}; + +/** + * @param {number} iDeleteType + * @param {string} sFromFolderFullNameRaw + * @param {Array} aUidForRemove + * @param {boolean=} bUseFolder = true + */ +RainLoopApp.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFolderFullNameRaw, aUidForRemove, bUseFolder) +{ + var + self = this, + oData = RL.data(), + oCache = RL.cache(), + oTrashOrSpamFolder = oCache.getFolderFromCacheList( + Enums.FolderType.Spam === iDeleteType ? oData.spamFolder() : oData.trashFolder()) + ; + + bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder; + if (bUseFolder) + { + if ((Enums.FolderType.Spam === iDeleteType && Consts.Values.UnuseOptionValue === oData.spamFolder()) || + (Enums.FolderType.Trash === iDeleteType && Consts.Values.UnuseOptionValue === oData.trashFolder())) + { + bUseFolder = false; + } + } + + if (!oTrashOrSpamFolder && bUseFolder) + { + kn.showScreenPopup(PopupsFolderSystemViewModel, [ + Enums.FolderType.Spam === iDeleteType ? Enums.SetSystemFoldersNotification.Spam : Enums.SetSystemFoldersNotification.Trash]); + } + else if (!bUseFolder || (sFromFolderFullNameRaw === oData.spamFolder() || sFromFolderFullNameRaw === oData.trashFolder())) + { + kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () { + + RL.remote().messagesDelete( + self.moveOrDeleteResponseHelper, + sFromFolderFullNameRaw, + aUidForRemove + ); + + oData.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); + + }]); + } + else if (oTrashOrSpamFolder) + { + RL.remote().messagesMove( + this.moveOrDeleteResponseHelper, + sFromFolderFullNameRaw, + oTrashOrSpamFolder.fullNameRaw, + aUidForRemove + ); + + oData.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, oTrashOrSpamFolder.fullNameRaw); + } +}; + +/** + * @param {string} sFromFolderFullNameRaw + * @param {Array} aUidForMove + * @param {string} sToFolderFullNameRaw + * @param {boolean=} bCopy = false + */ +RainLoopApp.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForMove, sToFolderFullNameRaw, bCopy) +{ + if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForMove) && 0 < aUidForMove.length) + { + var + oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw), + oToFolder = RL.cache().getFolderFromCacheList(sToFolderFullNameRaw) + ; + + if (oFromFolder && oToFolder) + { + bCopy = Utils.isUnd(bCopy) ? false : !!bCopy; + + RL.remote()[bCopy ? 'messagesCopy' : 'messagesMove']( + this.moveOrDeleteResponseHelper, + oFromFolder.fullNameRaw, + oToFolder.fullNameRaw, + aUidForMove + ); + + RL.data().removeMessagesFromList(oFromFolder.fullNameRaw, aUidForMove, oToFolder.fullNameRaw, bCopy); + return true; + } + } + + return false; +}; + /** * @param {Function=} fCallback */ diff --git a/dev/Storages/WebMailData.js b/dev/Storages/WebMailData.js index 438657073..a0f2a1620 100644 --- a/dev/Storages/WebMailData.js +++ b/dev/Storages/WebMailData.js @@ -714,6 +714,107 @@ WebMailDataStorage.prototype.getNextFolderNames = function (bBoot) return _.uniq(aResult); }; +/** + * @param {Function} fCallback + * @param {string} sFromFolderFullNameRaw + * @param {Array} aUidForRemove + * @param {string=} sToFolderFullNameRaw = '' + * @param {bCopy=} bCopy = false + */ +WebMailDataStorage.prototype.removeMessagesFromList = function ( + sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy) +{ + sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : ''; + bCopy = Utils.isUnd(bCopy) ? false : !!bCopy; + + aUidForRemove = _.map(aUidForRemove, function (mValue) { + return Utils.pInt(mValue); + }); + + var + iUnseenCount = 0, + oData = RL.data(), + oCache = RL.cache(), + oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw), + oToFolder = '' === sToFolderFullNameRaw ? null : oCache.getFolderFromCacheList(sToFolderFullNameRaw || ''), + sCurrentFolderFullNameRaw = oData.currentFolderFullNameRaw(), + oCurrentMessage = oData.message(), + aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(oData.messageList(), function (oMessage) { + return oMessage && -1 < Utils.inArray(Utils.pInt(oMessage.uid), aUidForRemove); + }) : [] + ; + + _.each(aMessages, function (oMessage) { + if (oMessage && oMessage.unseen()) + { + iUnseenCount++; + } + }); + + if (oFromFolder && !bCopy) + { + oFromFolder.messageCountAll(0 <= oFromFolder.messageCountAll() - aUidForRemove.length ? + oFromFolder.messageCountAll() - aUidForRemove.length : 0); + + if (0 < iUnseenCount) + { + oFromFolder.messageCountUnread(0 <= oFromFolder.messageCountUnread() - iUnseenCount ? + oFromFolder.messageCountUnread() - iUnseenCount : 0); + } + } + + if (oToFolder) + { + oToFolder.messageCountAll(oToFolder.messageCountAll() + aUidForRemove.length); + if (0 < iUnseenCount) + { + oToFolder.messageCountUnread(oToFolder.messageCountUnread() + iUnseenCount); + } + + oToFolder.actionBlink(true); + } + + if (0 < aMessages.length) + { + if (bCopy) + { + _.each(aMessages, function (oMessage) { + oMessage.checked(false); + }); + } + else + { + oData.messageListIsNotCompleted(true); + + _.each(aMessages, function (oMessage) { + if (oCurrentMessage && oCurrentMessage.requestHash === oMessage.requestHash) + { + oCurrentMessage = null; + oData.message(null); + } + + oMessage.deleted(true); + }); + + _.delay(function () { + _.each(aMessages, function (oMessage) { + oData.messageList.remove(oMessage); + }); + }, 400); + } + } + + if ('' !== sFromFolderFullNameRaw) + { + oCache.setFolderHash(sFromFolderFullNameRaw, ''); + } + + if ('' !== sToFolderFullNameRaw) + { + oCache.setFolderHash(sToFolderFullNameRaw, ''); + } +}; + WebMailDataStorage.prototype.setMessage = function (oData, bCached) { var diff --git a/dev/ViewModels/MailBoxFolderListViewModel.js b/dev/ViewModels/MailBoxFolderListViewModel.js index 491afd177..3bb746504 100644 --- a/dev/ViewModels/MailBoxFolderListViewModel.js +++ b/dev/ViewModels/MailBoxFolderListViewModel.js @@ -99,10 +99,9 @@ MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi) aUids = oUi.helper.data('rl-uids') ; - if (MailBoxMessageListViewModel && MailBoxMessageListViewModel.__vm && Utils.isNormal(sFromFolderFullNameRaw) && Utils.isArray(aUids)) + if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids)) { - MailBoxMessageListViewModel.__vm.moveMessagesToFolder( - sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy); + RL.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy); } } }; diff --git a/dev/ViewModels/MailBoxMessageListViewModel.js b/dev/ViewModels/MailBoxMessageListViewModel.js index 7e7eadbc0..d16108741 100644 --- a/dev/ViewModels/MailBoxMessageListViewModel.js +++ b/dev/ViewModels/MailBoxMessageListViewModel.js @@ -131,15 +131,21 @@ function MailBoxMessageListViewModel() }, this.canBeMoved); this.deleteWithoutMoveCommand = Utils.createCommand(this, function () { - this.deleteSelectedMessageFromCurrentFolder(Enums.FolderType.Trash, false); + RL.deleteMessagesFromFolder(Enums.FolderType.Trash, + RL.data().currentFolderFullNameRaw(), + RL.data().messageListCheckedOrSelectedUidsWithSubMails(), false); }, this.canBeMoved); this.deleteCommand = Utils.createCommand(this, function () { - this.deleteSelectedMessageFromCurrentFolder(Enums.FolderType.Trash, true); + RL.deleteMessagesFromFolder(Enums.FolderType.Trash, + RL.data().currentFolderFullNameRaw(), + RL.data().messageListCheckedOrSelectedUidsWithSubMails(), true); }, this.canBeMoved); this.spamCommand = Utils.createCommand(this, function () { - this.deleteSelectedMessageFromCurrentFolder(Enums.FolderType.Spam, true); + RL.deleteMessagesFromFolder(Enums.FolderType.Spam, + RL.data().currentFolderFullNameRaw(), + RL.data().messageListCheckedOrSelectedUidsWithSubMails(), true); }, this.canBeMoved); this.moveCommand = Utils.createCommand(this, Utils.emptyFunction, this.canBeMoved); @@ -197,8 +203,6 @@ function MailBoxMessageListViewModel() }, this) ; - this.moveOrDeleteResponse = _.bind(this.moveOrDeleteResponse, this); - Knoin.constructorEnd(this); } @@ -221,165 +225,6 @@ MailBoxMessageListViewModel.prototype.cancelSearch = function () this.inputMessageListSearchFocus(false); }; -/** - * @param {string} sFromFolderFullNameRaw - * @param {Array} aUidForRemove - * @param {string=} sToFolderFullNameRaw - * @param {boolean=} bCopy = false - */ -MailBoxMessageListViewModel.prototype.removeMessagesFromList = function (sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy) -{ - sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : ''; - bCopy = Utils.isUnd(bCopy) ? false : !!bCopy; - - var - iUnseenCount = 0 , - oData = RL.data(), - oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw), - oToFolder = '' === sToFolderFullNameRaw ? null : RL.cache().getFolderFromCacheList(sToFolderFullNameRaw || ''), - sCurrentFolderFullNameRaw = oData.currentFolderFullNameRaw(), - oCurrentMessage = oData.message(), - aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(oData.messageList(), function (oMessage) { - return oMessage && -1 < Utils.inArray(oMessage.uid, aUidForRemove); - }) : [] - ; - - _.each(aMessages, function (oMessage) { - if (oMessage && oMessage.unseen()) - { - iUnseenCount++; - } - }); - - if (oFromFolder && !bCopy) - { - oFromFolder.messageCountAll(0 <= oFromFolder.messageCountAll() - aUidForRemove.length ? - oFromFolder.messageCountAll() - aUidForRemove.length : 0); - - if (0 < iUnseenCount) - { - oFromFolder.messageCountUnread(0 <= oFromFolder.messageCountUnread() - iUnseenCount ? - oFromFolder.messageCountUnread() - iUnseenCount : 0); - } - } - - if (oToFolder) - { - oToFolder.messageCountAll(oToFolder.messageCountAll() + aUidForRemove.length); - if (0 < iUnseenCount) - { - oToFolder.messageCountUnread(oToFolder.messageCountUnread() + iUnseenCount); - } - } - - if (0 < aMessages.length) - { - if (bCopy) - { - _.each(aMessages, function (oMessage) { - oMessage.checked(false); - }); - } - else - { - _.each(aMessages, function (oMessage) { - if (oCurrentMessage && oCurrentMessage.requestHash === oMessage.requestHash) - { - oCurrentMessage = null; - oData.message(null); - } - - oMessage.deleted(true); - }); - - _.delay(function () { - _.each(aMessages, function (oMessage) { - oData.messageList.remove(oMessage); - }); - }, 400); - - RL.data().messageListIsNotCompleted(true); - RL.cache().setFolderHash(sFromFolderFullNameRaw, ''); - } - - if (Utils.isNormal(sToFolderFullNameRaw)) - { - RL.cache().setFolderHash(sToFolderFullNameRaw || '', ''); - } - } -}; - -/** - * @param {string=} sToFolderFullNameRaw - */ -MailBoxMessageListViewModel.prototype.removeCheckedOrSelectedMessagesFromList = function (sToFolderFullNameRaw) -{ - this.removeMessagesFromList(RL.data().currentFolderFullNameRaw(), _.map(RL.data().messageListCheckedOrSelected(), function (oMessage) { - return oMessage.uid; - }), sToFolderFullNameRaw); -}; - -MailBoxMessageListViewModel.prototype.moveOrDeleteResponse = function (sResult, oData) -{ - if (Enums.StorageResultType.Success === sResult && RL.data().currentFolder()) - { - if (oData && Utils.isArray(oData.Result) && 2 === oData.Result.length) - { - RL.cache().setFolderHash(oData.Result[0], oData.Result[1]); - } - else - { - if (oData && -1 < Utils.inArray(oData.ErrorCode, - [Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage])) - { - window.alert(Utils.getNotification(oData.ErrorCode)); - } - - RL.cache().setFolderHash(RL.data().currentFolderFullNameRaw(), ''); - } - - RL.reloadMessageList(); - - RL.quotaDebounce(); - } -}; - -/** - * @param {string} sFromFolderFullNameRaw - * @param {Array} aUidForRemove - * @param {string} sToFolderFullNameRaw - * @param {boolean=} bCopy = false - */ -MailBoxMessageListViewModel.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy) -{ - if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForRemove) && 0 < aUidForRemove.length) - { - var - oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw), - oToFolder = RL.cache().getFolderFromCacheList(sToFolderFullNameRaw) - ; - - if (oFromFolder && oToFolder) - { - bCopy = Utils.isUnd(bCopy) ? false : !!bCopy; - - RL.remote()[bCopy ? 'messagesCopy' : 'messagesMove']( - this.moveOrDeleteResponse, - oFromFolder.fullNameRaw, - oToFolder.fullNameRaw, - aUidForRemove - ); - - oToFolder.actionBlink(true); - - this.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy); - return true; - } - } - - return false; -}; - /** * @param {string} sToFolderFullNameRaw * @return {boolean} @@ -388,74 +233,14 @@ MailBoxMessageListViewModel.prototype.moveSelectedMessagesToFolder = function (s { if (this.canBeMoved()) { - return this.moveMessagesToFolder(RL.data().currentFolderFullNameRaw(), + RL.moveMessagesToFolder( + RL.data().currentFolderFullNameRaw(), RL.data().messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw); } return false; }; -/** - * @param {number} iType - * @param {boolean=} bUseFolder = true - */ -MailBoxMessageListViewModel.prototype.deleteSelectedMessageFromCurrentFolder = function (iType, bUseFolder) -{ - if (this.canBeMoved()) - { - bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder; - if (bUseFolder) - { - if ((Enums.FolderType.Spam === iType && Consts.Values.UnuseOptionValue === RL.data().spamFolder()) || - (Enums.FolderType.Trash === iType && Consts.Values.UnuseOptionValue === RL.data().trashFolder())) - { - bUseFolder = false; - } - } - - var - self = this, - aUIds = null, - sCurrentFolderFullNameRaw = RL.data().currentFolderFullNameRaw(), - oTrashOrSpamFolder = RL.cache().getFolderFromCacheList( - Enums.FolderType.Spam === iType ? RL.data().spamFolder() : RL.data().trashFolder()) - ; - - if (!oTrashOrSpamFolder && bUseFolder) - { - kn.showScreenPopup(PopupsFolderSystemViewModel, [ - Enums.FolderType.Spam === iType ? Enums.SetSystemFoldersNotification.Spam : Enums.SetSystemFoldersNotification.Trash]); - } - else if (!bUseFolder || (oTrashOrSpamFolder && RL.data().currentFolderFullNameRaw() === oTrashOrSpamFolder.fullNameRaw)) - { - aUIds = RL.data().messageListCheckedOrSelectedUidsWithSubMails(); - - kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () { - - RL.remote().messagesDelete( - self.moveOrDeleteResponse, - sCurrentFolderFullNameRaw, - aUIds - ); - - self.removeCheckedOrSelectedMessagesFromList(); - }]); - } - else if (oTrashOrSpamFolder) - { - RL.remote().messagesMove( - this.moveOrDeleteResponse, - sCurrentFolderFullNameRaw, - oTrashOrSpamFolder.fullNameRaw, - RL.data().messageListCheckedOrSelectedUidsWithSubMails() - ); - - oTrashOrSpamFolder.actionBlink(true); - this.removeCheckedOrSelectedMessagesFromList(oTrashOrSpamFolder.fullNameRaw); - } - } -}; - MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageListItem, bCopy) { if (oMessageListItem) diff --git a/dev/ViewModels/MailBoxMessageViewViewModel.js b/dev/ViewModels/MailBoxMessageViewViewModel.js index 90183c7ee..ddd65780f 100644 --- a/dev/ViewModels/MailBoxMessageViewViewModel.js +++ b/dev/ViewModels/MailBoxMessageViewViewModel.js @@ -68,13 +68,25 @@ function MailBoxMessageViewViewModel() }, this.messageVisibility); this.deleteCommand = Utils.createCommand(this, function () { - // TODO - window.console.log(arguments); + + if (this.message()) + { + RL.deleteMessagesFromFolder(Enums.FolderType.Trash, + this.message().folderFullNameRaw, + [this.message().uid], true); + } + }, this.messageVisibility); this.spamCommand = Utils.createCommand(this, function () { - // TODO - window.console.log(arguments); + + if (this.message()) + { + RL.deleteMessagesFromFolder(Enums.FolderType.Spam, + this.message().folderFullNameRaw, + [this.message().uid], true); + } + }, this.messageVisibility); // viewer diff --git a/dev/ViewModels/PopupsComposeViewModel.js b/dev/ViewModels/PopupsComposeViewModel.js index f0910296b..8977e504a 100644 --- a/dev/ViewModels/PopupsComposeViewModel.js +++ b/dev/ViewModels/PopupsComposeViewModel.js @@ -14,7 +14,6 @@ function PopupsComposeViewModel() this.bFromDraft = false; this.sReferences = ''; - this.bReloadFolder = false; this.bAllowIdentities = RL.settingsGet('AllowIdentities'); this.bAllowCtrlS = !!RL.settingsGet('AllowCtrlSOnCompose'); @@ -177,38 +176,7 @@ function PopupsComposeViewModel() this.deleteCommand = Utils.createCommand(this, function () { - var - oMessage = null, - sDraftFolder = this.draftFolder(), - sDraftUid = this.draftUid() - ; - - if (this.bFromDraft) - { - oMessage = RL.data().message(); - if (oMessage && sDraftFolder === oMessage.folderFullNameRaw && sDraftUid === oMessage.uid) - { - RL.data().message(null); - } - } - - if (RL.data().currentFolderFullNameRaw() === this.draftFolder()) - { - _.each(RL.data().messageList(), function (oMessage) { - if (oMessage && sDraftFolder === oMessage.folderFullNameRaw && sDraftUid === oMessage.uid) - { - oMessage.deleted(true); - } - }); - } - - RL.data().messageListIsNotCompleted(true); - RL.remote().messagesDelete(function () { - RL.cache().setFolderHash(sDraftFolder, ''); - RL.reloadMessageList(); - }, this.draftFolder(), [this.draftUid()]); - - this.bReloadFolder = false; + RL.deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]); kn.hideScreenPopup(PopupsComposeViewModel); }, function () { @@ -247,7 +215,6 @@ function PopupsComposeViewModel() { this.sendError(false); this.sending(true); - this.bReloadFolder = true; if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length) { @@ -265,6 +232,7 @@ function PopupsComposeViewModel() RL.cache().setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], aFlagsCache); RL.reloadFlagsCurrentMessageListAndMessageFromCache(); + RL.cache().setFolderHash(this.aDraftInfo[2], ''); } } @@ -305,7 +273,6 @@ function PopupsComposeViewModel() { this.savedError(false); this.saving(true); - this.bReloadFolder = true; RL.cache().setFolderHash(RL.data().draftFolder(), ''); @@ -368,14 +335,6 @@ function PopupsComposeViewModel() return this.dropboxEnabled(); }); - this.modalVisibility.subscribe(function (bValue) { - if (!bValue && this.bReloadFolder) - { - this.bReloadFolder = false; - RL.reloadMessageList(); - } - }, this); - this.driveEnabled = ko.observable(false); this.driveCommand = Utils.createCommand(this, function () { @@ -396,6 +355,23 @@ function PopupsComposeViewModel() Utils.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel); +PopupsComposeViewModel.prototype.reloadDraftFolder = function () +{ + var sDraftFolder = RL.data().draftFolder(); + if ('' !== sDraftFolder) + { + RL.cache().setFolderHash(sDraftFolder, ''); + if (RL.data().currentFolderFullNameRaw() === sDraftFolder) + { + RL.reloadMessageList(true); + } + else + { + RL.folderInformation(sDraftFolder); + } + } +}; + PopupsComposeViewModel.prototype.findIdentityIdByMessage = function (sComposeType, oMessage) { var @@ -508,6 +484,8 @@ PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData) window.alert(sMessage || Utils.getNotification(Enums.Notification.CantSendMessage)); } } + + this.reloadDraftFolder(); }; PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData) @@ -560,6 +538,8 @@ PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData) this.savedError(true); this.savedOrSendingText(Utils.getNotification(Enums.Notification.CantSaveMessage)); } + + this.reloadDraftFolder(); }; PopupsComposeViewModel.prototype.onHide = function () @@ -1439,7 +1419,6 @@ PopupsComposeViewModel.prototype.reset = function () this.sInReplyTo = ''; this.bFromDraft = false; this.sReferences = ''; - this.bReloadFolder = false; this.sendError(false); this.sendSuccessButSaveError(false); diff --git a/rainloop/v/0.0.0/app/templates/Views/MailMessageList.html b/rainloop/v/0.0.0/app/templates/Views/MailMessageList.html index fe1b47371..3b6d8b2ab 100644 --- a/rainloop/v/0.0.0/app/templates/Views/MailMessageList.html +++ b/rainloop/v/0.0.0/app/templates/Views/MailMessageList.html @@ -26,7 +26,7 @@ - + diff --git a/rainloop/v/0.0.0/app/templates/Views/MailMessageView.html b/rainloop/v/0.0.0/app/templates/Views/MailMessageView.html index e4ce8f666..6d9863861 100644 --- a/rainloop/v/0.0.0/app/templates/Views/MailMessageView.html +++ b/rainloop/v/0.0.0/app/templates/Views/MailMessageView.html @@ -24,16 +24,16 @@ - - --> +
]*>/gim,"\n__bq__start__\n").replace(/<\/blockquote>/gim,"\n__bq__end__\n").replace(/]*>(.|[\s\S\r\n]*)<\/a>/gim,h).replace(/ /gi," ").replace(/<[^>]*>/gm,"").replace(/>/gi,">").replace(/</gi,"<").replace(/&/gi,"&").replace(/&\w{2,6};/gi,""),c.replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/__bq__start__(.|[\s\S\r\n]*)__bq__end__/gm,e).replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")},xb.plainToHtml=function(a){return a.toString().replace(/&/g,"&").replace(/>/g,">").replace(/")},xb.resizeAndCrop=function(b,c,d){var e=new a.Image;e.onload=function(){var a=[0,0],b=document.createElement("canvas"),e=b.getContext("2d");b.width=c,b.height=c,a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width],e.fillStyle="#fff",e.fillRect(0,0,c,c),e.drawImage(this,a[0]/2,a[1]/2,this.width-a[0],this.height-a[1],0,0,c,c),d(b.toDataURL("image/jpeg"))},e.src=b},xb.computedPagenatorHelper=function(a,b){return function(){var c=0,d=0,e=2,f=[],g=a(),h=b(),i=function(a,b,c){var d={current:a===g,name:xb.isUnd(c)?a.toString():c.toString(),custom:xb.isUnd(c)?!1:!0,title:xb.isUnd(c)?"":a.toString(),value:a.toString()};(xb.isUnd(b)?0:!b)?f.unshift(d):f.push(d)};if(h>1||h>0&&g>h){for(g>h?(i(h),c=h,d=h):((3>=g||g>=h-2)&&(e+=2),i(g),c=g,d=g);e>0;)if(c-=1,d+=1,c>0&&(i(c,!1),e--),h>=d)i(d,!0),e--;else if(0>=c)break;3===c?i(2,!1):c>3&&i(Math.round((c-1)/2),!1,"..."),h-2===d?i(h-1,!0):h-2>d&&i(Math.round((h+d)/2),!0,"..."),c>1&&i(1,!1),h>d&&i(h,!0)}return f}},xb.selectElement=function(b){if(a.getSelection){var c=a.getSelection();c.removeAllRanges();var d=document.createRange();d.selectNodeContents(b),c.addRange(d)}else if(document.selection){var e=document.body.createTextRange();e.moveToElementText(b),e.select()}},zb={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return zb.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=zb._utf8_encode(a);j>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+this._keyStr.charAt(e)+this._keyStr.charAt(f)+this._keyStr.charAt(g)+this._keyStr.charAt(h);return i},decode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");j >4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,i+=String.fromCharCode(b),64!==g&&(i+=String.fromCharCode(c)),64!==h&&(i+=String.fromCharCode(d));return zb._utf8_decode(i)},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0,d=a.length,e=0;d>c;c++)e=a.charCodeAt(c),128>e?b+=String.fromCharCode(e):e>127&&2048>e?(b+=String.fromCharCode(e>>6|192),b+=String.fromCharCode(63&e|128)):(b+=String.fromCharCode(e>>12|224),b+=String.fromCharCode(e>>6&63|128),b+=String.fromCharCode(63&e|128));return b},_utf8_decode:function(a){for(var b="",c=0,d=0,e=0,f=0;c d?(b+=String.fromCharCode(d),c++):d>191&&224>d?(e=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&e),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&e)<<6|63&f),c+=3);return b}},c.bindingHandlers.tooltip={init:function(a,d){if(!Ab.bMobileDevice){var e=b(a).data("tooltip-class")||"",f=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:f,trigger:"hover",title:function(){return''+xb.i18n(c.utils.unwrapObservable(d()))+""}})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a).data("tooltip-class")||"",e=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:e,title:function(){return''+c()()+""}})}},c.bindingHandlers.dropdown={init:function(a){b(a).closest(".dropdown").on("click",".e-item",function(){b(a).dropdown("toggle")})}},c.bindingHandlers.popover={init:function(a,d){b(a).popover(c.utils.unwrapObservable(d()))}},c.bindingHandlers.csstext={init:function(a,d){a&&a.styleSheet&&!xb.isUnd(a.styleSheet.cssText)?a.styleSheet.cssText=c.utils.unwrapObservable(d()):b(a).text(c.utils.unwrapObservable(d()))},update:function(a,d){a&&a.styleSheet&&!xb.isUnd(a.styleSheet.cssText)?a.styleSheet.cssText=c.utils.unwrapObservable(d()):b(a).text(c.utils.unwrapObservable(d()))}},c.bindingHandlers.resizecrop={init:function(a){b(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,c){c()(),b(a).resizecrop({width:"100",height:"100"})}},c.bindingHandlers.onEnter={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&13===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.onEsc={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&27===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.modal={init:function(a,d){b(a).toggleClass("fade",!Ab.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("hidden",function(){d()(!1)}).on("shown",function(){xb.windowResize()})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){xb.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),xb.i18nToNode(a)}},c.bindingHandlers.link={update:function(a,d){b(a).attr("href",c.utils.unwrapObservable(d()))}},c.bindingHandlers.title={update:function(a,d){b(a).attr("title",c.utils.unwrapObservable(d()))}},c.bindingHandlers.textF={init:function(a,d){b(a).text(c.utils.unwrapObservable(d()))}},c.bindingHandlers.initDom={init:function(a,b){b()(a)}},c.bindingHandlers.initResizeTrigger={init:function(a,d){var e=c.utils.unwrapObservable(d());b(a).css({height:e[1],"min-height":e[1]})},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=xb.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=xb.pInt(e[2]),g=Gb.height()-h,g>f&&(f=g),b(a).css({height:f,"min-height":f}))}},c.bindingHandlers.appendDom={update:function(a,d){b(a).hide().empty().append(c.utils.unwrapObservable(d())).show()}},c.bindingHandlers.draggable={init:function(d,e,f){if(!Ab.bMobileDevice){var g=100,h=3,i=f(),j=i&&i.droppableSelector?i.droppableSelector:"",k={distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},refreshPositions:!0,scroll:!0};j&&(k.drag=function(c){b(j).each(function(){var d=null,e=null,f=b(this),i=f.offset(),j=i.top+f.height();a.clearInterval(f.data("timerScroll")),f.data("timerScroll",!1),c.pageX>=i.left&&c.pageX<=i.left+f.width()&&(c.pageY>=j-g&&c.pageY<=j&&(d=function(){f.scrollTop(f.scrollTop()+h),xb.windowResize()},f.data("timerScroll",a.setInterval(d,10)),d()),c.pageY>=i.top&&c.pageY<=i.top+g&&(e=function(){f.scrollTop(f.scrollTop()-h),xb.windowResize()},f.data("timerScroll",a.setInterval(e,10)),e()))})},k.stop=function(){b(j).each(function(){a.clearInterval(b(this).data("timerScroll")),b(this).data("timerScroll",!1)})}),k.helper=function(a){return e()(a&&a.target?c.dataFor(a.target):null,!!a.shiftKey)},b(d).draggable(k).on("mousedown",function(){xb.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!Ab.bMobileDevice){var e=c(),f=d(),g=f&&f.droppableOver?f.droppableOver:null,h=f&&f.droppableOut?f.droppableOut:null,i={tolerance:"pointer",hoverClass:"droppableHover"};e&&(i.drop=function(a,b){e(a,b)},g&&(i.over=function(a,b){g(a,b)}),h&&(i.out=function(a,b){h(a,b)}),b(a).droppable(i))}}},c.bindingHandlers.nano={init:function(a){Ab.bDisableNanoScroll||b(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},c.bindingHandlers.saveTrigger={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text],input[type=email],input[type=password],select,textarea")?"input":"custom"),"custom"===c.data("save-trigger-type")?c.append(' ').addClass("settings-saved-trigger"):c.addClass("settings-saved-trigger-input")},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=b(a);if("custom"===f.data("save-trigger-type"))switch(e.toString()){case"1":f.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case"0":f.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case"-2":f.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:f.find(".animated").hide().end().find(".error,.success").removeClass("visible")}else switch(e.toString()){case"1":f.addClass("success").removeClass("error");break;case"0":f.addClass("error").removeClass("success");break;case"-2":break;default:f.removeClass("error success")}}},c.bindingHandlers.emailsTags={init:function(a,c){var d=b(a),e=c();d.inputosaurus({parseOnBlur:!0,inputDelimiters:[",",";"],autoCompleteSource:function(a,b){Jb.getAutocomplete(a.term,function(a){b(h.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return h.map(a,function(a){var b=xb.trim(a),c=null;return""!==b?(c=new u,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:h.bind(function(a){d.data("EmailsTagsValue",a.target.value),e(a.target.value)},this)}),e.subscribe(function(a){d.data("EmailsTagsValue")!==a&&(d.val(a),d.data("EmailsTagsValue",a),d.inputosaurus("refresh"))}),e.focusTrigger&&e.focusTrigger.subscribe(function(){d.inputosaurus("focus")})}},c.bindingHandlers.command={init:function(a,d,e,f){var g=b(a),h=d();if(!h||!h.enabled||!h.canExecute)throw new Error("You are not using command function");g.addClass("command"),c.bindingHandlers[g.is("form")?"submit":"click"].init.apply(f,arguments)},update:function(a,c){var d=!0,e=b(a),f=c();d=f.enabled(),e.toggleClass("command-not-enabled",!d),d&&(d=f.canExecute(),e.toggleClass("command-can-not-be-execute",!d)),e.toggleClass("command-disabled disable disabled",!d).toggleClass("no-disabled",!!d),(e.is("input")||e.is("button"))&&e.prop("disabled",!d)}},c.extenders.trimmer=function(a){var b=c.computed({read:a,write:function(b){a(xb.trim(b.toString()))},owner:this});return b(a()),b},c.extenders.reversible=function(a){var b=a();return a.commit=function(){b=a()},a.reverse=function(){a(b)},a.commitedValue=function(){return b},a},c.extenders.toggleSubscribe=function(a,b){return a.subscribe(b[1],b[0],"beforeChange"),a.subscribe(b[2],b[0]),a},c.extenders.falseTimeout=function(b,c){return b.iTimeout=0,b.subscribe(function(d){d&&(a.clearTimeout(b.iTimeout),b.iTimeout=a.setTimeout(function(){b(!1),b.iTimeout=0},xb.pInt(c)))}),b},c.observable.fn.validateNone=function(){return this.hasError=c.observable(!1),this},c.observable.fn.validateEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=xb.trim(a),this.hasError(""!==a&&!/^[^@\s]+@[^@\s]+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateSimpleEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=xb.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),xb.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},j.prototype.root=function(){return this.sBase},j.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},j.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},j.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},j.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},j.prototype.uploadContacts=function(){return this.sServer+"/UploadContacts/"+this.sSpecSuffix+"/"},j.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},j.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},j.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},j.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},j.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},j.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},j.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},j.prototype.messagePreview=function(){return this.sBase+"mailbox/message-preview"},j.prototype.settings=function(a){var b=this.sBase+"settings";return xb.isUnd(a)||""===a||(b+="/"+a),b },j.prototype.admin=function(a){var b=this.sBase;switch(a){case"AdminDomains":b+="domains";break;case"AdminSecurity":b+="security";break;case"AdminLicensing":b+="licensing"}return b},j.prototype.mailBox=function(a,b,c){b=xb.isNormal(b)?xb.pInt(b):1,c=xb.pString(c);var d=this.sBase+"mailbox/";return""!==a&&(d+=encodeURI(a)),b>1&&(d=d.replace(/[\/]+$/,""),d+="/p"+b),""!==c&&(d=d.replace(/[\/]+$/,""),d+="/"+encodeURI(c)),d},j.prototype.phpInfo=function(){return this.sServer+"Info"},j.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},j.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},j.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"},j.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a},j.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"},j.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"},j.prototype.openPgpJs=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/js/openpgp.js"},j.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},j.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},j.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},yb.oViewModelsHooks={},yb.oSimpleHooks={},yb.regViewModelHook=function(a,b){b&&(b.__hookName=a)},yb.addHook=function(a,b){xb.isFunc(b)&&(xb.isArray(yb.oSimpleHooks[a])||(yb.oSimpleHooks[a]=[]),yb.oSimpleHooks[a].push(b))},yb.runHook=function(a,b){xb.isArray(yb.oSimpleHooks[a])&&(b=b||[],h.each(yb.oSimpleHooks[a],function(a){a.apply(null,b)}))},yb.mainSettingsGet=function(a){return Jb?Jb.settingsGet(a):null},yb.remoteRequest=function(a,b,c,d,e,f){Jb&&Jb.remote().defaultRequest(a,b,c,d,e,f)},yb.settingsGet=function(a,b){var c=yb.mainSettingsGet("Plugins");return c=c&&xb.isUnd(c[a])?null:c[a],c?xb.isUnd(c[b])?null:c[b]:null},k.prototype.blurTrigger=function(){if(this.fOnBlur){var b=this;a.clearTimeout(b.iBlurTimer),b.iBlurTimer=a.setTimeout(function(){b.fOnBlur()},200)}},k.prototype.focusTrigger=function(){this.fOnBlur&&a.clearTimeout(this.iBlurTimer)},k.prototype.isHtml=function(){return this.editor?"wysiwyg"===this.editor.mode:!1},k.prototype.checkDirty=function(){return this.editor?this.editor.checkDirty():!1},k.prototype.resetDirty=function(){this.editor&&this.editor.resetDirty()},k.prototype.getData=function(){return this.editor?"plain"===this.editor.mode&&this.editor.plugins.plain&&this.editor.__plain?this.editor.__plain.getRawData():this.editor.getData():""},k.prototype.modeToggle=function(a){this.editor&&(a?"plain"===this.editor.mode&&this.editor.setMode("wysiwyg"):"wysiwyg"===this.editor.mode&&this.editor.setMode("plain"))},k.prototype.setHtml=function(a,b){this.editor&&(this.modeToggle(!0),this.editor.setData(a),b&&this.focus())},k.prototype.setPlain=function(a,b){if(this.editor){if(this.modeToggle(!1),"plain"===this.editor.mode&&this.editor.plugins.plain&&this.editor.__plain)return this.editor.__plain.setRawData(a);this.editor.setData(a),b&&this.focus()}},k.prototype.init=function(){if(this.$element&&this.$element[0]){var b=this,c=Ab.oHtmlEditorDefaultConfig,d=Jb.settingsGet("Language"),e=!!Jb.settingsGet("AllowHtmlEditorSourceButton");e&&c.toolbarGroups&&!c.toolbarGroups.__SourceInited&&(c.toolbarGroups.__SourceInited=!0,c.toolbarGroups.push({name:"document",groups:["mode","document","doctools"]})),c.language=Ab.oHtmlEditorLangsMap[d]||"en",b.editor=a.CKEDITOR.appendTo(b.$element[0],c),b.editor.on("blur",function(){b.blurTrigger()}),b.editor.on("mode",function(){b.blurTrigger()}),b.editor.on("focus",function(){b.focusTrigger()}),b.fOnReady&&b.editor.on("instanceReady",function(){b.editor.setKeystroke(a.CKEDITOR.CTRL+65,"selectAll"),b.fOnReady(),b.resize()})}},k.prototype.focus=function(){this.editor&&this.editor.focus()},k.prototype.blur=function(){this.editor&&this.editor.focusManager.blur(!0)},k.prototype.resize=function(){this.editor&&this.editor.resize(this.$element.width(),this.$element.innerHeight())},k.prototype.clear=function(a){this.setHtml("",a)},l.prototype.selectItemCallbacks=function(a){(this.oCallbacks.onItemSelect||this.emptyFunction)(a)},l.prototype.goDown=function(){this.newSelectPosition(vb.EventKeyCode.Down,!1)},l.prototype.goUp=function(){this.newSelectPosition(vb.EventKeyCode.Up,!1)},l.prototype.init=function(d,e){if(this.oContentVisible=d,this.oContentScrollable=e,this.oContentVisible&&this.oContentScrollable){var f=this;b(this.oContentVisible).on("selectstart",function(a){a&&a.preventDefault&&a.preventDefault()}).on("click",this.sItemSelector,function(a){f.actionClick(c.dataFor(this),a)}).on("click",this.sItemCheckedSelector,function(a){var b=c.dataFor(this);b&&(a&&a.shiftKey?f.actionClick(b,a):(f.sLastUid=f.getItemUid(b),b.selected()?(b.checked(!1),f.selectedItem(null)):b.checked(!b.checked())))}),b(a.document).on("keydown",function(a){var b=!0;return a&&f.bUseKeyboard&&!xb.inFocus()&&(-1 0)if(m){if(m)if(vb.EventKeyCode.Down===b||vb.EventKeyCode.Up===b||vb.EventKeyCode.Insert===b)h.each(k,function(a){if(!i)switch(b){case vb.EventKeyCode.Up:m===a?i=!0:j=a;break;case vb.EventKeyCode.Down:case vb.EventKeyCode.Insert:g?(j=a,i=!0):m===a&&(g=!0)}});else if(vb.EventKeyCode.Home===b||vb.EventKeyCode.End===b)vb.EventKeyCode.Home===b?j=k[0]:vb.EventKeyCode.End===b&&(j=k[k.length-1]);else if(vb.EventKeyCode.PageDown===b){for(;l>e;e++)if(m===k[e]){e+=f,e=e>l-1?l-1:e,j=k[e];break}}else if(vb.EventKeyCode.PageUp===b)for(e=l;e>=0;e--)if(m===k[e]){e-=f,e=0>e?0:e,j=k[e];break}}else vb.EventKeyCode.Down===b||vb.EventKeyCode.Insert===b||vb.EventKeyCode.Home===b||vb.EventKeyCode.PageUp===b?j=k[0]:(vb.EventKeyCode.Up===b||vb.EventKeyCode.End===b||vb.EventKeyCode.PageDown===b)&&(j=k[k.length-1]);j?(m&&(c?(vb.EventKeyCode.Up===b||vb.EventKeyCode.Down===b)&&m.checked(!m.checked()):vb.EventKeyCode.Insert===b&&m.checked(!m.checked())),this.throttleSelection=!0,this.selectedItem(j),this.throttleSelection=!0,0!==this.iSelectTimer?(a.clearTimeout(this.iSelectTimer),this.iSelectTimer=a.setTimeout(function(){d.iSelectTimer=0,d.actionClick(j)},1e3)):(this.iSelectTimer=a.setTimeout(function(){d.iSelectTimer=0},200),this.actionClick(j)),this.scrollToSelected()):m&&(!c||vb.EventKeyCode.Up!==b&&vb.EventKeyCode.Down!==b?vb.EventKeyCode.Insert===b&&m.checked(!m.checked()):m.checked(!m.checked()))},l.prototype.scrollToSelected=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var a=20,c=b(this.sItemSelectedSelector,this.oContentScrollable),d=c.position(),e=this.oContentVisible.height(),f=c.outerHeight();return d&&(d.top<0||d.top+f>e)?(d.top<0?this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+d.top-a):this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+d.top-e+f+a),!0):!1},l.prototype.eventClickFunction=function(a,b){var c=this.getItemUid(a),d=0,e=0,f=null,g="",h=!1,i=!1,j=[],k=!1;if(b&&b.shiftKey&&""!==c&&""!==this.sLastUid&&c!==this.sLastUid)for(j=this.list(),k=a.checked(),d=0,e=j.length;e>d;d++)f=j[d],g=this.getItemUid(f),h=!1,(g===this.sLastUid||g===c)&&(h=!0),h&&(i=!i),(i||h)&&f.checked(k);this.sLastUid=""===c?"":c},l.prototype.actionClick=function(a,b){if(a){var c=!0,d=this.getItemUid(a);b&&(b.shiftKey?(c=!1,""===this.sLastUid&&(this.sLastUid=d),a.checked(!a.checked()),this.eventClickFunction(a,b)):b.ctrlKey&&(c=!1,this.sLastUid=d,a.checked(!a.checked()))),c&&(this.selectedItem(a),this.sLastUid=d)}},l.prototype.on=function(a,b){this.oCallbacks[a]=b},m.supported=function(){return!0},m.prototype.set=function(a,c){var d=b.cookie(ub.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(ub.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},m.prototype.get=function(a){var c=b.cookie(ub.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!xb.isUnd(d[a])?d[a]:null}catch(e){}return d},n.supported=function(){return!!a.localStorage},n.prototype.set=function(b,c){var d=a.localStorage[ub.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[ub.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},n.prototype.get=function(b){var c=a.localStorage[ub.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!xb.isUnd(d[b])?d[b]:null}catch(e){}return d},o.prototype.item="armoredRainLoopKeys",o.prototype.load=function(){var b=0,c=0,d=[],e=JSON.parse(a.localStorage.getItem(this.item));if(e&&0 b;b++)d.push(a.openpgp.key.readArmored(e[b]).keys[0]);return d},o.prototype.store=function(b){for(var c=0,d=b.length,e=[];d>c;c++)e.push(b[c].armor());a.localStorage.setItem(this.item,JSON.stringify(e))},p.prototype.oDriver=null,p.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},p.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},q.prototype.bootstart=function(){},r.prototype.sPosition="",r.prototype.sTemplate="",r.prototype.viewModelName="",r.prototype.viewModelDom=null,r.prototype.viewModelTemplate=function(){return this.sTemplate},r.prototype.viewModelPosition=function(){return this.sPosition},r.prototype.cancelCommand=r.prototype.closeCommand=function(){},r.prototype.registerPopupEscapeKey=function(){var a=this;Gb.on("keydown",function(b){return b&&vb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()?(xb.delegateRun(a,"cancelCommand"),!1):!0})},s.prototype.oCross=null,s.prototype.sScreenName="",s.prototype.aViewModels=[],s.prototype.viewModels=function(){return this.aViewModels},s.prototype.screenName=function(){return this.sScreenName},s.prototype.routes=function(){return null},s.prototype.__cross=function(){return this.oCross},s.prototype.__start=function(){var a=this.routes(),b=null,c=null;xb.isNonEmptyArray(a)&&(c=h.bind(this.onRoute||xb.emptyFunction,this),b=d.create(),h.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},t.constructorEnd=function(a){xb.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},t.prototype.sDefaultScreenName="",t.prototype.oScreens={},t.prototype.oBoot=null,t.prototype.oCurrentScreen=null,t.prototype.hideLoading=function(){b("#rl-loading").hide()},t.prototype.routeOff=function(){e.changed.active=!1},t.prototype.routeOn=function(){e.changed.active=!0},t.prototype.setBoot=function(a){return xb.isNormal(a)&&(this.oBoot=a),this},t.prototype.screen=function(a){return""===a||xb.isUnd(this.oScreens[a])?null:this.oScreens[a]},t.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),f=e.viewModelPosition(),g=b("#rl-content #rl-"+f.toLowerCase()),h=null;a.__builded=!0,a.__vm=e,e.data=Jb.data(),e.viewModelName=a.__name,g&&1===g.length?(h=b(" ").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),h.appendTo(g),e.viewModelDom=h,a.__dom=h,"Popups"===f&&(e.cancelCommand=e.closeCommand=xb.createCommand(e,function(){Cb.hideScreenPopup(a)})),yb.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),xb.delegateRun(e,"onBuild",[h]),e&&"Popups"===f&&!e.bDisabeCloseOnEsc&&e.registerPopupEscapeKey(),yb.runHook("view-model-post-build",[a.__name,e,h])):xb.log("Cannot find view model position: "+f)}return a?a.__vm:null},t.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},t.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__vm.modalVisibility(!1),xb.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1),yb.runHook("view-model-on-hide",[a.__name,a.__vm]),h.delay(function(){a.__dom.hide()},300))},t.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),xb.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),yb.runHook("view-model-on-show",[a.__name,a.__vm,b||[]]),xb.delegateRun(a.__vm,"onFocus",[],500)))},t.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===xb.pString(a)&&(a=this.sDefaultScreenName),""!==a&&(d=this.screen(a),d||(d=this.screen(this.sDefaultScreenName),d&&(b=a+"/"+b,a=this.sDefaultScreenName)),d&&d.__started&&(d.__builded||(d.__builded=!0,xb.isNonEmptyArray(d.viewModels())&&h.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),xb.delegateRun(d,"onBuild")),h.defer(function(){c.oCurrentScreen&&(xb.delegateRun(c.oCurrentScreen,"onHide"),xb.isNonEmptyArray(c.oCurrentScreen.viewModels())&&h.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),xb.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(xb.delegateRun(c.oCurrentScreen,"onShow"),yb.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),xb.isNonEmptyArray(c.oCurrentScreen.viewModels())&&h.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),xb.delegateRun(a.__vm,"onShow"),xb.delegateRun(a.__vm,"onFocus",[],200),yb.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},t.prototype.startScreens=function(a){b("#rl-content").css({visibility:"hidden"}),h.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),h.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),yb.runHook("screen-pre-start",[a.screenName(),a]),xb.delegateRun(a,"onStart"),yb.runHook("screen-post-start",[a.screenName(),a]))},this);var c=d.create();c.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,h.bind(this.screenOnRoute,this)),e.initialized.add(c.parse,c),e.changed.add(c.parse,c),e.init(),b("#rl-content").css({visibility:"visible"}),h.delay(function(){Fb.removeClass("rl-started-trigger").addClass("rl-started")},50)},t.prototype.setHash=function(a,b,c){a="#"===a.substr(0,1)?a.substr(1):a,a="/"===a.substr(0,1)?a.substr(1):a,c=xb.isUnd(c)?!1:!!c,(xb.isUnd(b)?1:!b)?(e.changed.active=!0,e[c?"replaceHash":"setHash"](a),e.setHash(a)):(e.changed.active=!1,e[c?"replaceHash":"setHash"](a),e.changed.active=!0)},t.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},Cb=new t,u.newInstanceFromJson=function(a){var b=new u;return b.initByJson(a)?b:null},u.prototype.name="",u.prototype.email="",u.prototype.privateType=null,u.prototype.clear=function(){this.email="",this.name="",this.privateType=null},u.prototype.validate=function(){return""!==this.name||""!==this.email},u.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},u.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},u.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=vb.EmailType.Facebook),null===this.privateType&&(this.privateType=vb.EmailType.Default)),this.privateType},u.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},u.prototype.parse=function(a){this.clear(),a=xb.trim(a);var b=/(?:"([^"]+)")? ?(.*?@[^>,]+)>?,? ?/g,c=b.exec(a);c?(this.name=c[1]||"",this.email=c[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)},u.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=xb.trim(a.Name),this.email=xb.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},u.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=xb.isUnd(b)?!1:!!b,c=xb.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+xb.encodeHtml(this.name)+"":c?xb.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=xb.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+xb.encodeHtml(d)+""+xb.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=xb.encodeHtml(d))):b&&(d=''+xb.encodeHtml(this.email)+""))),d},u.prototype.mailsoParse=function(a){if(a=xb.trim(a),""===a)return!1;for(var b=function(a,b,c){a+="";var d=a.length;return 0>b&&(b+=d),d="undefined"==typeof c?d:0>c?c+d:c+b,b>=a.length||0>b||b>d?!1:a.slice(b,d)},c=function(a,b,c,d){return 0>c&&(c+=a.length),d=void 0!==d?d:a.length,0>d&&(d=d+a.length-c),a.slice(0,c)+b.substr(0,d)+b.slice(d)+a.slice(c+d)},d="",e="",f="",g=!1,h=!1,i=!1,j=null,k=0,l=0,m=0;m").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+f.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(g),e.data=Jb.data(),e.viewModelDom=i,e.__rlSettingsData=f.__rlSettingsData,f.__dom=i,f.__builded=!0,f.__vm=e,c.applyBindings(e,i[0]),xb.delegateRun(e,"onBuild",[i])):xb.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&h.defer(function(){d.oCurrentSubScreen&&(xb.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),xb.delegateRun(d.oCurrentSubScreen,"onShow"),xb.delegateRun(d.oCurrentSubScreen,"onFocus",[],200),h.each(d.menu(),function(a){a.selected(e&&e.__rlSettingsData&&a.route===e.__rlSettingsData.Route)}),b("#rl-content .b-settings .b-content .content").scrollTop(0)),xb.windowResize()})):Cb.setHash(Jb.link().settings(),!1,!0)},ob.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(xb.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},ob.prototype.onBuild=function(){h.each(Bb.settings,function(a){a&&a.__rlSettingsData&&!h.find(Bb["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!h.find(Bb["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},ob.prototype.routes=function(){var a=h.find(Bb.settings,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",c={subname:/^(.*)$/,normalize_:function(a,c){return c.subname=xb.isUnd(c.subname)?b:xb.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},h.extend(pb.prototype,s.prototype),pb.prototype.onShow=function(){Jb.setTitle("")},h.extend(qb.prototype,s.prototype),qb.prototype.oLastRoute={},qb.prototype.setNewTitle=function(){var a=Jb.data().accountEmail(),b=Jb.data().foldersInboxUnreadCount();Jb.setTitle((""===a?"":(b>0?"("+b+") ":" ")+a+" - ")+xb.i18n("TITLES/MAILBOX"))},qb.prototype.onShow=function(){this.setNewTitle()},qb.prototype.onRoute=function(a,b,c,d){if(xb.isUnd(d)?1:!d){var e=Jb.data(),f=Jb.cache().getFolderFullNameRaw(a),g=Jb.cache().getFolderFromCacheList(f);g&&(e.currentFolder(g).messageListPage(b).messageListSearch(c),vb.Layout.NoPreview===e.layout()&&e.message()&&(e.message(null),e.messageFullScreenMode(!1)),Jb.reloadMessageList())}else vb.Layout.NoPreview!==Jb.data().layout()||Jb.data().message()||Jb.historyBack()},qb.prototype.onStart=function(){var a=Jb.data(),b=function(){xb.windowResize()};(Jb.settingsGet("AllowAdditionalAccounts")||Jb.settingsGet("AllowIdentities"))&&Jb.accountsAndIdentities(),h.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&Jb.folderInformation("INBOX")},1e3),h.delay(function(){Jb.quota()},5e3),h.delay(function(){Jb.remote().appDelayStart(xb.emptyFunction)},35e3),Fb.toggleClass("rl-no-preview-pane",vb.Layout.NoPreview===a.layout()),a.folderList.subscribe(b),a.messageList.subscribe(b),a.message.subscribe(b),a.layout.subscribe(function(a){Fb.toggleClass("rl-no-preview-pane",vb.Layout.NoPreview===a)}),a.foldersInboxUnreadCount.subscribe(function(){this.setNewTitle()},this)},qb.prototype.routes=function(){var a=function(){return["Inbox",1,"",!0]},b=function(a,b){return b[0]=xb.pString(b[0]),b[1]=xb.pInt(b[1]),b[1]=0>=b[1]?1:b[1],b[2]=xb.pString(b[2]),""===a&&(b[0]="Inbox",b[1]=1),[decodeURI(b[0]),b[1],decodeURI(b[2]),!1]},c=function(a,b){return b[0]=xb.pString(b[0]),b[1]=xb.pString(b[1]),""===a&&(b[0]="Inbox"),[decodeURI(b[0]),1,decodeURI(b[1]),!1]};return[[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/,{normalize_:b}],[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/,{normalize_:b}],[/^([a-zA-Z0-9]+)\/(.+)\/?$/,{normalize_:c}],[/^message-preview$/,{normalize_:a}],[/^([^\/]*)$/,{normalize_:b}]]},h.extend(rb.prototype,ob.prototype),rb.prototype.onShow=function(){Jb.setTitle(this.sSettingsTitle)},h.extend(sb.prototype,q.prototype),sb.prototype.oSettings=null,sb.prototype.oPlugins=null,sb.prototype.oLocal=null,sb.prototype.oLink=null,sb.prototype.oSubs={},sb.prototype.download=function(b){var c=null,d=null,e=navigator.userAgent.toLowerCase();return e&&(e.indexOf("chrome")>-1||e.indexOf("chrome")>-1)&&(c=document.createElement("a"),c.href=b,document.createEvent&&(d=document.createEvent("MouseEvents"),d&&d.initEvent&&c.dispatchEvent))?(d.initEvent("click",!0,!0),c.dispatchEvent(d),!0):(Ab.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},sb.prototype.link=function(){return null===this.oLink&&(this.oLink=new j),this.oLink},sb.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new p),this.oLocal},sb.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=xb.isNormal(Db)?Db:{}),xb.isUnd(this.oSettings[a])?null:this.oSettings[a]},sb.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=xb.isNormal(Db)?Db:{}),this.oSettings[a]=b},sb.prototype.setTitle=function(b){b=(xb.isNormal(b)&&00&&0===d.length&&(d=b(a,0,m)),h=!0,k=m);break;case">":h&&(l=m,e=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,h=!1);break;case"(":g||h||i||(i=!0,k=m);break;case")":i&&(l=m,f=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,i=!1);break;case"\\":m++}m++}return 0===e.length&&(j=a.match(/[^@\s]+@\S+/i),j&&j[0]?e=j[0]:d=a),e.length>0&&0===d.length&&0===f.length&&(d=a.replace(e,"")),e=xb.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=xb.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=xb.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},u.prototype.inputoTagLine=function(){return 0 +$/,""),b=!0),b},x.prototype.isImage=function(){return-1 e;e++)d.push(a[e].toLine(b,c));return d.join(", ")},z.initEmailsFromJson=function(a){var b=0,c=0,d=null,e=[];if(xb.isNonEmptyArray(a))for(b=0,c=a.length;c>b;b++)d=u.newInstanceFromJson(a[b]),d&&e.push(d);return e},z.replyHelper=function(a,b,c){if(a&&0 d;d++)xb.isUnd(b[a[d].email])&&(b[a[d].email]=!0,c.push(a[d]))},z.prototype.clear=function(){this.folderFullNameRaw="",this.uid="",this.hash="",this.requestHash="",this.subject(""),this.size(0),this.dateTimeStampInUTC(0),this.priority(vb.MessagePriority.Normal),this.fromEmailString(""),this.toEmailsString(""),this.senderEmailsString(""),this.emails=[],this.from=[],this.to=[],this.cc=[],this.bcc=[],this.replyTo=[],this.newForAnimation(!1),this.deleted(!1),this.unseen(!1),this.flagged(!1),this.answered(!1),this.forwarded(!1),this.isReadReceipt(!1),this.selected(!1),this.checked(!1),this.hasAttachments(!1),this.attachmentsMainType(""),this.body=null,this.isRtl(!1),this.isHtml(!1),this.hasImages(!1),this.attachments([]),this.isPgpSigned(!1),this.isPgpEncrypted(!1),this.pgpSignature(""),this.priority(vb.MessagePriority.Normal),this.readReceipt(""),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid(0),this.threads([]),this.threadsLen(0),this.hasUnseenSubMessage(!1),this.hasFlaggedSubMessage(!1),this.lastInCollapsedThread(!1),this.lastInCollapsedThreadLoading(!1)},z.prototype.computeSenderEmail=function(){var a=Jb.data().sentFolder(),b=Jb.data().draftFolder();this.senderEmailsString(this.folderFullNameRaw===a||this.folderFullNameRaw===b?this.toEmailsString():this.fromEmailString())},z.prototype.initByJson=function(a){var b=!1;return a&&"Object/Message"===a["@Object"]&&(this.folderFullNameRaw=a.Folder,this.uid=a.Uid,this.hash=a.Hash,this.requestHash=a.RequestHash,this.size(xb.pInt(a.Size)),this.from=z.initEmailsFromJson(a.From),this.to=z.initEmailsFromJson(a.To),this.cc=z.initEmailsFromJson(a.Cc),this.bcc=z.initEmailsFromJson(a.Bcc),this.replyTo=z.initEmailsFromJson(a.ReplyTo),this.subject(a.Subject),this.dateTimeStampInUTC(xb.pInt(a.DateTimeStampInUTC)),this.hasAttachments(!!a.HasAttachments),this.attachmentsMainType(a.AttachmentsMainType),this.fromEmailString(z.emailsToLine(this.from,!0)),this.toEmailsString(z.emailsToLine(this.to,!0)),this.parentUid(xb.pInt(a.ParentThread)),this.threads(xb.isArray(a.Threads)?a.Threads:[]),this.threadsLen(xb.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0),b},z.prototype.initUpdateByMessageJson=function(a){var b=!1,c=vb.MessagePriority.Normal;return a&&"Object/Message"===a["@Object"]&&(c=xb.pInt(a.Priority),this.priority(-1 b;b++)d=x.newInstanceFromJson(a["@Collection"][b]),d&&(""!==d.cidWithOutTags&&0 +$/,""),b=h.find(c,function(b){return a===b.cidWithOutTags})),b||null},z.prototype.findAttachmentByContentLocation=function(a){var b=null,c=this.attachments();return xb.isNonEmptyArray(c)&&(b=h.find(c,function(b){return a===b.contentLocation})),b||null},z.prototype.messageId=function(){return this.sMessageId},z.prototype.inReplyTo=function(){return this.sInReplyTo},z.prototype.references=function(){return this.sReferences},z.prototype.fromAsSingleEmail=function(){return xb.isArray(this.from)&&this.from[0]?this.from[0].email:""},z.prototype.viewLink=function(){return Jb.link().messageViewLink(this.requestHash)},z.prototype.downloadLink=function(){return Jb.link().messageDownloadLink(this.requestHash)},z.prototype.replyEmails=function(a){var b=[],c=xb.isUnd(a)?{}:a;return z.replyHelper(this.replyTo,c,b),0===b.length&&z.replyHelper(this.from,c,b),b},z.prototype.replyAllEmails=function(a){var b=[],c=[],d=xb.isUnd(a)?{}:a;return z.replyHelper(this.replyTo,d,b),0===b.length&&z.replyHelper(this.from,d,b),z.replyHelper(this.to,d,b),z.replyHelper(this.cc,d,c),[b,c]},z.prototype.textBodyToString=function(){return this.body?this.body.html():""},z.prototype.attachmentsToStringLine=function(){var a=h.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0 =0&&e&&!f&&d.attr("src",e)}),c&&a.setTimeout(function(){d.print()},100))})},z.prototype.printMessage=function(){this.viewPopupMessage(!0)},z.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid},z.prototype.populateByMessageListItem=function(a){return this.folderFullNameRaw=a.folderFullNameRaw,this.uid=a.uid,this.hash=a.hash,this.requestHash=a.requestHash,this.subject(a.subject()),this.size(a.size()),this.dateTimeStampInUTC(a.dateTimeStampInUTC()),this.priority(a.priority()),this.fromEmailString(a.fromEmailString()),this.toEmailsString(a.toEmailsString()),this.emails=a.emails,this.from=a.from,this.to=a.to,this.cc=a.cc,this.bcc=a.bcc,this.replyTo=a.replyTo,this.unseen(a.unseen()),this.flagged(a.flagged()),this.answered(a.answered()),this.forwarded(a.forwarded()),this.isReadReceipt(a.isReadReceipt()),this.selected(a.selected()),this.checked(a.checked()),this.hasAttachments(a.hasAttachments()),this.attachmentsMainType(a.attachmentsMainType()),this.moment(a.moment()),this.body=null,this.priority(vb.MessagePriority.Normal),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid(a.parentUid()),this.threads(a.threads()),this.threadsLen(a.threadsLen()),this.computeSenderEmail(),this -},z.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=xb.isUnd(a)?!1:a,this.hasImages(!1),this.body.data("rl-has-images",!1),b("[data-x-src]",this.body).each(function(){a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",b(this).attr("data-x-src")).removeAttr("data-x-src"):b(this).attr("src",b(this).attr("data-x-src")).removeAttr("data-x-src")}),b("[data-x-style-url]",this.body).each(function(){var a=xb.trim(b(this).attr("style"));a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+b(this).attr("data-x-style-url")).removeAttr("data-x-style-url")}),a&&(b("img.lazy",this.body).addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b(".RL-MailMessageView .messageView .messageItem .content")[0]}),Gb.resize()),xb.windowResize(500))},z.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){a=xb.isUnd(a)?!1:a;var c=this;this.body.data("rl-init-internal-images",!0),b("[data-x-src-cid]",this.body).each(function(){var d=c.findAttachmentByCid(b(this).attr("data-x-src-cid"));d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-src-location]",this.body).each(function(){var d=c.findAttachmentByContentLocation(b(this).attr("data-x-src-location"));d||(d=c.findAttachmentByCid(b(this).attr("data-x-src-location"))),d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-style-cid]",this.body).each(function(){var a="",d="",e=c.findAttachmentByCid(b(this).attr("data-x-style-cid"));e&&e.linkPreview&&(d=b(this).attr("data-x-style-cid-name"),""!==d&&(a=xb.trim(b(this).attr("style")),a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+d+": url('"+e.linkPreview()+"')")))}),a&&!function(a,b){h.delay(function(){a.addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b})},300)}(b("img.lazy",c.body),b(".RL-MailMessageView .messageView .messageItem .content")[0]),xb.windowResize(500)}},A.newInstanceFromJson=function(a){var b=new A;return b.initByJson(a)?b.initComputed():null},A.prototype.initComputed=function(){return this.hasSubScribedSubfolders=c.computed(function(){return!!h.find(this.subFolders(),function(a){return a.subScribed()})},this),this.canBeEdited=c.computed(function(){return vb.FolderType.User===this.type()&&this.existen&&this.selectable},this),this.visible=c.computed(function(){var a=this.subScribed(),b=this.hasSubScribedSubfolders();return a||b&&(!this.existen||!this.selectable)},this),this.isSystemFolder=c.computed(function(){return vb.FolderType.User!==this.type()},this),this.hidden=c.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return this.isGmailFolder||a&&this.isNamespaceFolder||a&&!b},this),this.selectableForFolderList=c.computed(function(){return!this.isSystemFolder()&&this.selectable},this),this.messageCountAll=c.computed({read:this.privateMessageCountAll,write:function(a){xb.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this}),this.messageCountUnread=c.computed({read:this.privateMessageCountUnread,write:function(a){xb.isPosNumeric(a,!0)?this.privateMessageCountUnread(a):this.privateMessageCountUnread.valueHasMutated()},owner:this}),this.printableUnreadCount=c.computed(function(){var a=this.messageCountAll(),b=this.messageCountUnread(),c=this.type();if(vb.FolderType.Inbox===c&&Jb.data().foldersInboxUnreadCount(b),a>0){if(vb.FolderType.Draft===c)return""+a;if(b>0&&vb.FolderType.Trash!==c&&vb.FolderType.SentItems!==c)return""+b}return""},this),this.canBeDeleted=c.computed(function(){var a=this.isSystemFolder();return!a&&0===this.subFolders().length&&"INBOX"!==this.fullNameRaw},this),this.canBeSubScribed=c.computed(function(){return!this.isSystemFolder()&&this.selectable&&"INBOX"!==this.fullNameRaw},this),this.visible.subscribe(function(){xb.timeOutAction("folder-list-folder-visibility-change",function(){Gb.trigger("folder-list-folder-visibility-change")},100)}),this.localName=c.computed(function(){Ab.langChangeTrigger();var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case vb.FolderType.Inbox:b=xb.i18n("FOLDER_LIST/INBOX_NAME");break;case vb.FolderType.SentItems:b=xb.i18n("FOLDER_LIST/SENT_NAME");break;case vb.FolderType.Draft:b=xb.i18n("FOLDER_LIST/DRAFTS_NAME");break;case vb.FolderType.Spam:b=xb.i18n("FOLDER_LIST/SPAM_NAME");break;case vb.FolderType.Trash:b=xb.i18n("FOLDER_LIST/TRASH_NAME")}return b},this),this.manageFolderSystemName=c.computed(function(){Ab.langChangeTrigger();var a="",b=this.type(),c=this.name();if(this.isSystemFolder())switch(b){case vb.FolderType.Inbox:a="("+xb.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case vb.FolderType.SentItems:a="("+xb.i18n("FOLDER_LIST/SENT_NAME")+")";break;case vb.FolderType.Draft:a="("+xb.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case vb.FolderType.Spam:a="("+xb.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case vb.FolderType.Trash:a="("+xb.i18n("FOLDER_LIST/TRASH_NAME")+")"}return(""!==a&&"("+c+")"===a||"(inbox)"===a.toLowerCase())&&(a=""),a},this),this.collapsed=c.computed({read:function(){return!this.hidden()&&this.collapsedPrivate()},write:function(a){this.collapsedPrivate(a)},owner:this}),this.hasUnreadMessages=c.computed(function(){return 0 "},C.prototype.formattedNameForCompose=function(){var a=this.name();return""===a?this.email():a+" ("+this.email()+")"},C.prototype.formattedNameForEmail=function(){var a=this.name();return""===a?this.email():'"'+xb.quoteName(a)+'" <'+this.email()+">"},D.prototype.index=0,D.prototype.id="",D.prototype.user="",D.prototype.armor="",D.prototype.isPrivate=!1,xb.extendAsViewModel("PopupsFolderClearViewModel",E),E.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},E.prototype.onShow=function(a){this.clearPopup(),a&&this.selectedFolder(a)},xb.extendAsViewModel("PopupsFolderCreateViewModel",F),F.prototype.sNoParentText="",F.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(xb.trim(a))},F.prototype.clearPopup=function(){this.folderName(""),this.selectedParentValue(""),this.folderName.focused(!1)},F.prototype.onShow=function(){this.clearPopup()},F.prototype.onFocus=function(){this.folderName.focused(!0)},xb.extendAsViewModel("PopupsFolderSystemViewModel",G),G.prototype.sChooseOnText="",G.prototype.sUnuseText="",G.prototype.onShow=function(a){var b="";switch(a=xb.isUnd(a)?vb.SetSystemFoldersNotification.None:a){case vb.SetSystemFoldersNotification.Sent:b=xb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case vb.SetSystemFoldersNotification.Draft:b=xb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case vb.SetSystemFoldersNotification.Spam:b=xb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case vb.SetSystemFoldersNotification.Trash:b=xb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH")}this.notification(b)},xb.extendAsViewModel("PopupsComposeViewModel",H),H.prototype.findIdentityIdByMessage=function(a,b){var c={},d="",e=function(a){return a&&a.email&&c[a.email]?(d=c[a.email],!0):!1};if(this.bAllowIdentities&&h.each(this.identities(),function(a){c[a.email()]=a.id}),c[Jb.data().accountEmail()]=Jb.data().accountEmail(),b)switch(a){case vb.ComposeType.Empty:d=Jb.data().accountEmail();break;case vb.ComposeType.Reply:case vb.ComposeType.ReplyAll:case vb.ComposeType.Forward:case vb.ComposeType.ForwardAsAttachment:h.find(h.union(b.to,b.cc,b.bcc),e);break;case vb.ComposeType.Draft:h.find(h.union(b.from,b.replyTo),e)}else d=Jb.data().accountEmail();return d},H.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)},H.prototype.formattedFrom=function(a){var b=Jb.data().displayName(),c=Jb.data().accountEmail();return""===b?c:(xb.isUnd(a)?1:!a)?b+" ("+c+")":'"'+xb.quoteName(b)+'" <'+c+">"},H.prototype.sendMessageResponse=function(b,c){var d=!1,e="";this.sending(!1),vb.StorageResultType.Success===b&&c&&c.Result&&(d=!0,this.modalVisibility()&&xb.delegateRun(this,"closeCommand")),this.modalVisibility()&&!d&&(c&&vb.Notification.CantSaveMessage===c.ErrorCode?(this.sendSuccessButSaveError(!0),a.alert(xb.trim(xb.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(e=xb.getNotification(c&&c.ErrorCode?c.ErrorCode:vb.Notification.CantSendMessage,c&&c.ErrorMessage?c.ErrorMessage:""),this.sendError(!0),a.alert(e||xb.getNotification(vb.Notification.CantSendMessage))))},H.prototype.saveMessageResponse=function(b,c){var d=!1,e=null;this.saving(!1),vb.StorageResultType.Success===b&&c&&c.Result&&c.Result.NewFolder&&c.Result.NewUid&&(this.bFromDraft&&(e=Jb.data().message(),e&&this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid&&Jb.data().message(null)),this.draftFolder(c.Result.NewFolder),this.draftUid(c.Result.NewUid),this.modalVisibility()&&(this.savedTime(Math.round((new a.Date).getTime()/1e3)),this.savedOrSendingText(0 c;c++)e.push(a[c].toLine(!!b));return e.join(", ")};if(c=c||null,c&&xb.isNormal(c)&&(v=xb.isArray(c)&&1===c.length?c[0]:xb.isArray(c)?null:c),null!==q&&(p[q]=!0,this.currentIdentityID(this.findIdentityIdByMessage(w,v))),this.reset(),xb.isNonEmptyArray(d)&&this.to(x(d)),""!==w&&v){switch(j=v.fullFormatDateValue(),k=v.subject(),u=v.aDraftInfo,l=b(v.body).clone(),xb.removeBlockquoteSwitcher(l),m=l.html(),w){case vb.ComposeType.Empty:break;case vb.ComposeType.Reply:this.to(x(v.replyEmails(p))),this.subject(xb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=xb.trim(this.sInReplyTo+" "+v.sReferences);break;case vb.ComposeType.ReplyAll:o=v.replyAllEmails(p),this.to(x(o[0])),this.cc(x(o[1])),this.subject(xb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=xb.trim(this.sInReplyTo+" "+v.references());break;case vb.ComposeType.Forward:this.subject(xb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=xb.trim(this.sInReplyTo+" "+v.sReferences);break;case vb.ComposeType.ForwardAsAttachment:this.subject(xb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=xb.trim(this.sInReplyTo+" "+v.sReferences);break;case vb.ComposeType.Draft:this.to(x(v.to)),this.cc(x(v.cc)),this.bcc(x(v.bcc)),this.bFromDraft=!0,this.draftFolder(v.folderFullNameRaw),this.draftUid(v.uid),this.subject(k),this.prepearMessageAttachments(v,w),this.aDraftInfo=xb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences;break;case vb.ComposeType.EditAsNew:this.to(x(v.to)),this.cc(x(v.cc)),this.bcc(x(v.bcc)),this.subject(k),this.prepearMessageAttachments(v,w),this.aDraftInfo=xb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences}switch(w){case vb.ComposeType.Reply:case vb.ComposeType.ReplyAll:f=v.fromToLine(!1,!0),n=xb.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:j,EMAIL:f}),m="
"+n+":";break;case vb.ComposeType.Forward:f=v.fromToLine(!1,!0),g=v.toToLine(!1,!0),i=v.ccToLine(!1,!0),m=""+m+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+f+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+g+(0"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+i:"")+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+xb.encodeHtml(j)+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+xb.encodeHtml(k)+"
"+m;break;case vb.ComposeType.ForwardAsAttachment:m=""}s&&""!==r&&vb.ComposeType.EditAsNew!==w&&vb.ComposeType.Draft!==w&&(m=this.convertSignature(r,x(v.from,!0))+"
"+m),this.editor(function(a){a.setHtml(m,!1),v.isHtml()||a.modeToggle(!1)})}else vb.ComposeType.Empty===w?(m=this.convertSignature(r),this.editor(function(a){a.setHtml(m,!1),vb.EditorDefaultType.Html!==Jb.data().editorDefaultType()&&a.modeToggle(!1)})):xb.isNonEmptyArray(c)&&h.each(c,function(a){e.addMessageAsAttachment(a)});t=this.getAttachmentsDownloadsForUpload(),xb.isNonEmptyArray(t)&&Jb.remote().messageUploadAttachments(function(a,b){if(vb.StorageResultType.Success===a&&b&&b.Result){var c=null,d="";if(!e.viewModelVisibility())for(d in b.Result)b.Result.hasOwnProperty(d)&&(c=e.getAttachmentById(b.Result[d]),c&&c.tempName(d))}else e.setMessageAttachmentFailedDowbloadText()},t),this.triggerForResize()},H.prototype.onFocus=function(){""===this.to()?this.to.focusTrigger(!this.to.focusTrigger()):this.oEditor&&this.oEditor.focus(),this.triggerForResize()},H.prototype.editorResize=function(){this.oEditor&&this.oEditor.resize()},H.prototype.tryToClosePopup=function(){var a=this;Cb.showScreenPopup(Q,[xb.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&xb.delegateRun(a,"closeCommand")}])},H.prototype.onBuild=function(){this.initUploader();var a=this,c=null;Gb.on("keydown",function(b){var c=!0;return b&&a.modalVisibility()&&Jb.data().useKeyboardShortcuts()&&(a.bAllowCtrlS&&b.ctrlKey&&vb.EventKeyCode.S===b.keyCode?(a.saveCommand(),c=!1):b.ctrlKey&&vb.EventKeyCode.Enter===b.keyCode?(a.sendCommand(),c=!1):vb.EventKeyCode.Esc===b.keyCode&&(a.tryToClosePopup(),c=!1)),c}),Gb.on("resize",function(){a.triggerForResize()}),this.dropboxEnabled()&&(c=document.createElement("script"),c.type="text/javascript",c.src="https://www.dropbox.com/static/api/1/dropins.js",b(c).attr("id","dropboxjs").attr("data-app-key",Jb.settingsGet("DropboxApiKey")),document.body.appendChild(c))},H.prototype.getAttachmentById=function(a){for(var b=this.attachments(),c=0,d=b.length;d>c;c++)if(b[c]&&a===b[c].id)return b[c];return null},H.prototype.initUploader=function(){if(this.composeUploaderButton()){var a={},b=xb.pInt(Jb.settingsGet("AttachmentLimit")),c=new g({action:Jb.link().upload(),name:"uploader",queueSize:2,multipleSizeLimit:50,disableFolderDragAndDrop:!1,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace()});c?(c.on("onDragEnter",h.bind(function(){this.dragAndDropOver(!0)},this)).on("onDragLeave",h.bind(function(){this.dragAndDropOver(!1)},this)).on("onBodyDragEnter",h.bind(function(){this.dragAndDropVisible(!0)},this)).on("onBodyDragLeave",h.bind(function(){this.dragAndDropVisible(!1)},this)).on("onProgress",h.bind(function(b,c,d){var e=null;xb.isUnd(a[b])?(e=this.getAttachmentById(b),e&&(a[b]=e)):e=a[b],e&&e.progress(" - "+Math.floor(c/d*100)+"%")},this)).on("onSelect",h.bind(function(a,d){this.dragAndDropOver(!1);var e=this,f=xb.isUnd(d.FileName)?"":d.FileName.toString(),g=xb.isNormal(d.Size)?xb.pInt(d.Size):null,h=new y(a,f,g);return h.cancel=function(a){return function(){e.attachments.remove(function(b){return b&&b.id===a}),c&&c.cancel(a)}}(a),this.attachments.push(h),g>0&&b>0&&g>b?(h.error(xb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(b){var c=null;xb.isUnd(a[b])?(c=this.getAttachmentById(b),c&&(a[b]=c)):c=a[b],c&&(c.waiting(!1),c.uploading(!0))},this)).on("onComplete",h.bind(function(b,c,d){var e="",f=null,g=null,h=this.getAttachmentById(b);g=c&&d&&d.Result&&d.Result.Attachment?d.Result.Attachment:null,f=d&&d.Result&&d.Result.ErrorCode?d.Result.ErrorCode:null,null!==f?e=xb.getUploadErrorDescByCode(f):g||(e=xb.i18n("UPLOAD/ERROR_UNKNOWN")),h&&(""!==e&&00&&d>0&&f>d?(e.uploading(!1),e.error(xb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(Jb.remote().composeUploadExternals(function(a,b){var c=!1;e.uploading(!1),vb.StorageResultType.Success===a&&b&&b.Result&&b.Result[e.id]&&(c=!0,e.tempName(b.Result[e.id])),c||e.error(xb.getUploadErrorDescByCode(vb.UploadErrorCode.FileNoUploaded))},[a.link]),!0)},H.prototype.prepearMessageAttachments=function(a,b){if(a){var c=this,d=xb.isNonEmptyArray(a.attachments())?a.attachments():[],e=0,f=d.length,g=null,h=null,i=!1,j=function(a){return function(){c.attachments.remove(function(b){return b&&b.id===a})}};if(vb.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f>e;e++){switch(h=d[e],i=!1,b){case vb.ComposeType.Reply:case vb.ComposeType.ReplyAll:i=h.isLinked;break;case vb.ComposeType.Forward:case vb.ComposeType.Draft:case vb.ComposeType.EditAsNew:i=!0}i=!0,i&&(g=new y(h.download,h.fileName,h.estimatedSize,h.isInline,h.isLinked,h.cid,h.contentLocation),g.fromMessage=!0,g.cancel=j(h.download),g.waiting(!1).uploading(!0),this.attachments.push(g))}}},H.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})},H.prototype.setMessageAttachmentFailedDowbloadText=function(){h.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(xb.getUploadErrorDescByCode(vb.UploadErrorCode.FileNoUploaded))},this)},H.prototype.isEmptyForm=function(a){a=xb.isUnd(a)?!0:!!a;var b=a?0===this.attachments().length:0===this.attachmentsInReady().length;return 0===this.to().length&&0===this.cc().length&&0===this.bcc().length&&0===this.subject().length&&b&&(!this.oEditor||""===this.oEditor.getData())},H.prototype.reset=function(){this.to(""),this.cc(""),this.bcc(""),this.replyTo(""),this.subject(""),this.requestReadReceipt(!1),this.aDraftInfo=null,this.sInReplyTo="",this.bFromDraft=!1,this.sReferences="",this.bReloadFolder=!1,this.sendError(!1),this.sendSuccessButSaveError(!1),this.savedError(!1),this.savedTime(0),this.savedOrSendingText(""),this.emptyToError(!1),this.showCcAndBcc(!1),this.attachments([]),this.dragAndDropOver(!1),this.dragAndDropVisible(!1),this.draftFolder(""),this.draftUid(""),this.sending(!1),this.saving(!1),this.oEditor&&this.oEditor.clear(!1)},H.prototype.getAttachmentsDownloadsForUpload=function(){return h.map(h.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})},H.prototype.triggerForResize=function(){this.resizer(!this.resizer()),this.editorResizeThrottle()},xb.extendAsViewModel("PopupsContactsViewModel",I),I.prototype.setShareToNone=function(){this.viewScopeType(vb.ContactScopeType.Default)},I.prototype.setShareToAll=function(){this.viewScopeType(vb.ContactScopeType.ShareAll)},I.prototype.addNewProperty=function(a){var b=new w(a,"");b.focused(!0),this.viewProperties.push(b)},I.prototype.addNewEmail=function(){this.addNewProperty(vb.ContactPropertyType.EmailPersonal)},I.prototype.addNewPhone=function(){this.addNewProperty(vb.ContactPropertyType.MobilePersonal)},I.prototype.initUploader=function(){if(this.importUploaderButton()){var b=new g({action:Jb.link().uploadContacts(),name:"uploader",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,disableDragAndDrop:!0,disableMultiple:!0,disableDocumentDropPrevent:!0,clickElement:this.importUploaderButton()});b&&b.on("onStart",h.bind(function(){this.contacts.importing(!0)},this)).on("onComplete",h.bind(function(b,c,d){this.contacts.importing(!1),this.reloadContactList(),b&&c&&d&&d.Result||a.alert(xb.i18n("CONTACTS/ERROR_IMPORT_FILE"))},this))}},I.prototype.removeCheckedOrSelectedContactsFromList=function(){var a=this,b=this.contacts,c=this.currentContact(),d=this.contacts().length,e=this.contactsCheckedOrSelected();0 =d&&(this.bDropPageAfterDelete=!0),h.delay(function(){h.each(e,function(a){b.remove(a)})},500))},I.prototype.deleteSelectedContacts=function(){0 0?d:0),b.contactsCount(d),b.contacts(e),b.viewClearSearch(""!==b.search()),b.contacts.loading(!1),""!==b.viewID()&&!b.currentContact()&&b.contacts.setSelectedByUid&&b.contacts.setSelectedByUid(""+b.viewID())},c,ub.Defaults.ContactsPerPage,this.search())},I.prototype.onBuild=function(a){this.oContentVisible=b(".b-list-content",a),this.oContentScrollable=b(".content",this.oContentVisible),this.selector.init(this.oContentVisible,this.oContentScrollable);var d=this;c.computed(function(){var a=this.modalVisibility(),b=Jb.data().useKeyboardShortcuts();this.selector.useKeyboard(a&&b)},this).extend({notify:"always"}),a.on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&(d.contactsPage(xb.pInt(a.value)),d.reloadContactList())}),this.initUploader()},I.prototype.onShow=function(){Cb.routeOff(),this.reloadContactList(!0)},I.prototype.onHide=function(){Cb.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),h.each(this.contacts(),function(a){a.checked(!1)})},xb.extendAsViewModel("PopupsAdvancedSearchViewModel",J),J.prototype.buildSearchStringValue=function(a){return-1 0&&g.messageCountUnread(0<=g.messageCountUnread()-e?g.messageCountUnread()-e:0)),i&&(i.messageCountAll(i.messageCountAll()+b.length),e>0&&i.messageCountUnread(i.messageCountUnread()+e)),0 0&&vb.EventKeyCode.Esc===c&&d.viewModelVisibility()&&e.useKeyboardShortcuts()&&!xb.inFocus()&&e.message()&&(d.fullScreenMode(!1),vb.Layout.NoPreview===e.layout()&&Jb.historyBack(),b=!1),b}),b(".attachmentsPlace",a).magnificPopup({delegate:".magnificPopupImage:visible",type:"image",gallery:{enabled:!0,preload:[1,1],navigateByImgClick:!0},callbacks:{open:function(){e.useKeyboardShortcuts(!1)},close:function(){e.useKeyboardShortcuts(!0)}},mainClass:"mfp-fade",removalDelay:400}),a.on("mousedown","a",function(a){return!(a&&3!==a.which&&Jb.mailToHelper(b(this).attr("href")))}).on("click",".attachmentsPlace .attachmentPreview",function(a){a&&a.stopPropagation&&a.stopPropagation()}).on("click",".attachmentsPlace .attachmentItem",function(){var a=c.dataFor(this);a&&a.download&&Jb.download(a.linkDownload())}),this.oMessageScrollerDom=a.find(".messageItem .content"),this.oMessageScrollerDom=this.oMessageScrollerDom&&this.oMessageScrollerDom[0]?this.oMessageScrollerDom:null},X.prototype.isDraftFolder=function(){return Jb.data().message()&&Jb.data().draftFolder()===Jb.data().message().folderFullNameRaw},X.prototype.isSentFolder=function(){return Jb.data().message()&&Jb.data().sentFolder()===Jb.data().message().folderFullNameRaw},X.prototype.isDraftOrSentFolder=function(){return this.isDraftFolder()||this.isSentFolder()},X.prototype.composeClick=function(){Cb.showScreenPopup(H)},X.prototype.editMessage=function(){Jb.data().message()&&Cb.showScreenPopup(H,[vb.ComposeType.Draft,Jb.data().message()])},X.prototype.scrollMessageToTop=function(){this.oMessageScrollerDom&&this.oMessageScrollerDom.scrollTop(0)},X.prototype.showImages=function(a){a&&a.showExternalImages&&a.showExternalImages(!0)},X.prototype.readReceipt=function(a){a&&""!==a.readReceipt()&&(Jb.remote().sendReadReceiptMessage(xb.emptyFunction,a.folderFullNameRaw,a.uid,a.readReceipt(),xb.i18n("READ_RECEIPT/SUBJECT",{SUBJECT:a.subject()}),xb.i18n("READ_RECEIPT/BODY",{"READ-RECEIPT":a.readReceipt()})),a.isReadReceipt(!0),Jb.cache().storeMessageFlagsToCache(a),Jb.reloadFlagsCurrentMessageListAndMessageFromCache())},xb.extendAsViewModel("SettingsMenuViewModel",Y),Y.prototype.link=function(a){return Jb.link().settings(a)},Y.prototype.backToMailBoxClick=function(){Cb.setHash(Jb.link().inbox())},xb.extendAsViewModel("SettingsPaneViewModel",Z),Z.prototype.onShow=function(){Jb.data().message(null)},Z.prototype.backToMailBoxClick=function(){Cb.setHash(Jb.link().inbox())},xb.addSettingsViewModel($,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0),$.prototype.toggleLayout=function(){this.layout(vb.Layout.NoPreview===this.layout()?vb.Layout.SidePreview:vb.Layout.NoPreview)},$.prototype.onBuild=function(){var a=this;h.delay(function(){var c=Jb.data(),d=xb.settingsSaveHelperSimpleFunction(a.mppTrigger,a);c.language.subscribe(function(c){a.languageTrigger(vb.SaveSettingsStep.Animate),b.ajax({url:Jb.link().langLink(c),dataType:"script",cache:!0}).done(function(){xb.i18nToDoc(),a.languageTrigger(vb.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(vb.SaveSettingsStep.FalseResult)}).always(function(){h.delay(function(){a.languageTrigger(vb.SaveSettingsStep.Idle)},1e3)}),Jb.remote().saveSettings(xb.emptyFunction,{Language:c})}),c.editorDefaultType.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{EditorDefaultType:a})}),c.messagesPerPage.subscribe(function(a){Jb.remote().saveSettings(d,{MPP:a})}),c.showImages.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{ShowImages:a?"1":"0"})}),c.interfaceAnimation.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{InterfaceAnimation:a})}),c.useDesktopNotifications.subscribe(function(a){xb.timeOutAction("SaveDesktopNotifications",function(){Jb.remote().saveSettings(xb.emptyFunction,{DesktopNotifications:a?"1":"0"})},3e3)}),c.replySameFolder.subscribe(function(a){xb.timeOutAction("SaveReplySameFolder",function(){Jb.remote().saveSettings(xb.emptyFunction,{ReplySameFolder:a?"1":"0"})},3e3)}),c.useThreads.subscribe(function(a){c.messageList([]),Jb.remote().saveSettings(xb.emptyFunction,{UseThreads:a?"1":"0"})}),c.layout.subscribe(function(a){c.messageList([]),Jb.remote().saveSettings(xb.emptyFunction,{Layout:a})}),c.useCheckboxesInList.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)},$.prototype.onShow=function(){Jb.data().desktopNotifications.valueHasMutated()},$.prototype.selectLanguage=function(){Cb.showScreenPopup(P)},xb.addSettingsViewModel(_,"SettingsContacts","SETTINGS_LABELS/LABEL_CONTACTS_NAME","contacts"),_.prototype.toggleShowPassword=function(){this.showPassword(!this.showPassword())},_.prototype.onBuild=function(){Jb.data().contactsAutosave.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{ContactsAutosave:a?"1":"0"})})},_.prototype.onShow=function(){this.showPassword(!1)},xb.addSettingsViewModel(ab,"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts"),ab.prototype.addNewAccount=function(){Cb.showScreenPopup(K)},ab.prototype.deleteAccount=function(b){if(b&&b.deleteAccess()){this.accountForDeletion(null);var c=function(a){return b===a};b&&(this.accounts.remove(c),Jb.remote().accountDelete(function(b,c){vb.StorageResultType.Success===b&&c&&c.Result&&c.Reload?(Cb.routeOff(),Cb.setHash(Jb.link().root(),!0),Cb.routeOff(),h.defer(function(){a.location.reload()})):Jb.accountsAndIdentities()},b.email))}},xb.addSettingsViewModel(bb,"SettingsIdentity","SETTINGS_LABELS/LABEL_IDENTITY_NAME","identity"),bb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Jb.data().signature();this.editor=new k(a.signatureDom(),function(){Jb.data().signature((a.editor.isHtml()?":HTML:":"")+a.editor.getData())},function(){":HTML:"===b.substr(0,6)?a.editor.setHtml(b.substr(6),!1):a.editor.setPlain(b,!1)})}},bb.prototype.onBuild=function(){var a=this;h.delay(function(){var b=Jb.data(),c=xb.settingsSaveHelperSimpleFunction(a.displayNameTrigger,a),d=xb.settingsSaveHelperSimpleFunction(a.replyTrigger,a),e=xb.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){Jb.remote().saveSettings(c,{DisplayName:a})}),b.replyTo.subscribe(function(a){Jb.remote().saveSettings(d,{ReplyTo:a})}),b.signature.subscribe(function(a){Jb.remote().saveSettings(e,{Signature:a})}),b.signatureToAll.subscribe(function(a){Jb.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},xb.addSettingsViewModel(cb,"SettingsIdentities","SETTINGS_LABELS/LABEL_IDENTITIES_NAME","identities"),cb.prototype.addNewIdentity=function(){Cb.showScreenPopup(O)},cb.prototype.editIdentity=function(a){Cb.showScreenPopup(O,[a])},cb.prototype.deleteIdentity=function(a){if(a&&a.deleteAccess()){this.identityForDeletion(null);var b=function(b){return a===b};a&&(this.identities.remove(b),Jb.remote().identityDelete(function(){Jb.accountsAndIdentities()},a.id))}},cb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Jb.data().signature();this.editor=new k(a.signatureDom(),function(){Jb.data().signature((a.editor.isHtml()?":HTML:":"")+a.editor.getData())},function(){":HTML:"===b.substr(0,6)?a.editor.setHtml(b.substr(6),!1):a.editor.setPlain(b,!1)})}},cb.prototype.onBuild=function(a){var b=this;a.on("click",".identity-item .e-action",function(){var a=c.dataFor(this);a&&b.editIdentity(a)}),h.delay(function(){var a=Jb.data(),c=xb.settingsSaveHelperSimpleFunction(b.displayNameTrigger,b),d=xb.settingsSaveHelperSimpleFunction(b.replyTrigger,b),e=xb.settingsSaveHelperSimpleFunction(b.signatureTrigger,b);a.displayName.subscribe(function(a){Jb.remote().saveSettings(c,{DisplayName:a})}),a.replyTo.subscribe(function(a){Jb.remote().saveSettings(d,{ReplyTo:a})}),a.signature.subscribe(function(a){Jb.remote().saveSettings(e,{Signature:a})}),a.signatureToAll.subscribe(function(a){Jb.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},xb.addSettingsViewModel(db,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social"),xb.addSettingsViewModel(eb,"SettingsOpenPGP","SETTINGS_LABELS/LABEL_OPEN_PGP_NAME","openpgp"),eb.prototype.addOpenPgpKey=function(){Cb.showScreenPopup(L)},eb.prototype.generateOpenPgpKey=function(){Cb.showScreenPopup(N)},eb.prototype.viewOpenPgpKey=function(a){a&&Cb.showScreenPopup(M,[a])},eb.prototype.deleteOpenPgpKey=function(a){if(a&&a.deleteAccess()){this.openPgpKeyForDeletion(null);var b=Jb.data().openpgpKeyring,c=function(b){return a===b};a&&b&&(this.openpgpkeys.remove(c),b.removeKey(a.index),b.store(),Jb.reloadOpenPgpKeys())}},xb.addSettingsViewModel(fb,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME","change-password"),fb.prototype.onHide=function(){this.changeProcess(!1),this.currentPassword(""),this.newPassword("")},fb.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1),vb.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.passwordUpdateSuccess(!0)):this.passwordUpdateError(!0)},xb.addSettingsViewModel(gb,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders"),gb.prototype.folderEditOnEnter=function(a){var b=a?xb.trim(a.nameForEdit()):"";""!==b&&a.name()!==b&&(Jb.local().set(vb.ClientSideKeyName.FoldersLashHash,""),Jb.data().foldersRenaming(!0),Jb.remote().folderRename(function(a,b){Jb.data().foldersRenaming(!1),vb.StorageResultType.Success===a&&b&&b.Result||Jb.data().foldersListError(b&&b.ErrorCode?xb.getNotification(b.ErrorCode):xb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER")),Jb.folders()},a.fullNameRaw,b),Jb.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b)),a.edited(!1)},gb.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)},gb.prototype.onShow=function(){Jb.data().foldersListError("")},gb.prototype.createFolder=function(){Cb.showScreenPopup(F)},gb.prototype.systemFolder=function(){Cb.showScreenPopup(G)},gb.prototype.deleteFolder=function(a){if(a&&a.canBeDeleted()&&a.deleteAccess()&&0===a.privateMessageCountAll()){this.folderForDeletion(null);var b=function(c){return a===c?!0:(c.subFolders.remove(b),!1)};a&&(Jb.local().set(vb.ClientSideKeyName.FoldersLashHash,""),Jb.data().folderList.remove(b),Jb.data().foldersDeleting(!0),Jb.remote().folderDelete(function(a,b){Jb.data().foldersDeleting(!1),vb.StorageResultType.Success===a&&b&&b.Result||Jb.data().foldersListError(b&&b.ErrorCode?xb.getNotification(b.ErrorCode):xb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER")),Jb.folders()},a.fullNameRaw),Jb.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0 1048576?(a.alert(xb.i18n("SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(){this.customThemeUploaderProgress(!0)},this)).on("onComplete",h.bind(function(b,c,d){c&&d&&d.Result?this.customThemeImg(d.Result):a.alert(d&&d.ErrorCode?xb.getUploadErrorDescByCode(d.ErrorCode):xb.getUploadErrorDescByCode(vb.UploadErrorCode.Unknown)),this.customThemeUploaderProgress(!1)},this)),!!b}return!1},ib.prototype.populateDataOnStart=function(){var a=xb.pInt(Jb.settingsGet("Layout")),b=Jb.settingsGet("Languages"),c=Jb.settingsGet("Themes");xb.isArray(b)&&this.languages(b),xb.isArray(c)&&this.themes(c),this.mainLanguage(Jb.settingsGet("Language")),this.mainTheme(Jb.settingsGet("Theme")),this.allowCustomTheme(!!Jb.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!Jb.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!Jb.settingsGet("AllowIdentities")),this.determineUserLanguage(!!Jb.settingsGet("DetermineUserLanguage")),this.allowThemes(!!Jb.settingsGet("AllowThemes")),this.allowCustomLogin(!!Jb.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!Jb.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!Jb.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(Jb.settingsGet("EditorDefaultType")),this.showImages(!!Jb.settingsGet("ShowImages")),this.contactsAutosave(!!Jb.settingsGet("ContactsAutosave")),this.interfaceAnimation(Jb.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(Jb.settingsGet("MPP")),this.desktopNotifications(!!Jb.settingsGet("DesktopNotifications")),this.useThreads(!!Jb.settingsGet("UseThreads")),this.replySameFolder(!!Jb.settingsGet("ReplySameFolder")),this.useCheckboxesInList(!!Jb.settingsGet("UseCheckboxesInList")),this.layout(vb.Layout.SidePreview),-1 0&&(c=this.messagesBodiesDom(),c&&(c.find(".rl-cache-class").each(function(){var c=b(this);d>c.data("rl-cache-count")&&(c.addClass("rl-cache-purge"),a++)}),a>0&&h.delay(function(){c.find(".rl-cache-purge").remove()},300)))},jb.prototype.populateDataOnStart=function(){ib.prototype.populateDataOnStart.call(this),this.accountEmail(Jb.settingsGet("Email")),this.accountIncLogin(Jb.settingsGet("IncLogin")),this.accountOutLogin(Jb.settingsGet("OutLogin")),this.projectHash(Jb.settingsGet("ProjectHash")),this.displayName(Jb.settingsGet("DisplayName")),this.replyTo(Jb.settingsGet("ReplyTo")),this.signature(Jb.settingsGet("Signature")),this.signatureToAll(!!Jb.settingsGet("SignatureToAll")),this.lastFoldersHash=Jb.local().get(vb.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!Jb.settingsGet("RemoteSuggestions"),this.devEmail=Jb.settingsGet("DevEmail"),this.devLogin=Jb.settingsGet("DevLogin"),this.devPassword=Jb.settingsGet("DevPassword")},jb.prototype.initUidNextAndNewMessages=function(b,c,d){if("INBOX"===b&&xb.isNormal(c)&&""!==c){if(xb.isArray(d)&&0 3)i(Jb.link().notificationMailIcon(),Jb.data().accountEmail(),xb.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:g}));else for(;g>f;f++)i(Jb.link().notificationMailIcon(),z.emailsToLine(z.initEmailsFromJson(d[f].From),!1),d[f].Subject)}Jb.cache().setFolderUidNext(b,c)}},jb.prototype.folderResponseParseRec=function(a,b){var c=0,d=0,e=null,f=null,g="",h=[],i=[];for(c=0,d=b.length;d>c;c++)e=b[c],e&&(g=e.FullNameRaw,f=Jb.cache().getFolderFromCacheList(g),f||(f=A.newInstanceFromJson(e),f&&(Jb.cache().setFolderToCacheList(g,f),Jb.cache().setFolderFullNameRaw(f.fullNameHash,g),f.isGmailFolder=ub.Values.GmailFolderName.toLowerCase()===g.toLowerCase(),""!==a&&a===f.fullNameRaw+f.delimiter&&(f.isNamespaceFolder=!0),(f.isNamespaceFolder||f.isGmailFolder)&&(f.isUnpaddigFolder=!0))),f&&(f.collapsed(!xb.isFolderExpanded(f.fullNameHash)),e.Extended&&(e.Extended.Hash&&Jb.cache().setFolderHash(f.fullNameRaw,e.Extended.Hash),xb.isNormal(e.Extended.MessageCount)&&f.messageCountAll(e.Extended.MessageCount),xb.isNormal(e.Extended.MessageUnseenCount)&&f.messageCountUnread(e.Extended.MessageUnseenCount)),h=e.SubFolders,h&&"Collection/FolderCollection"===h["@Object"]&&h["@Collection"]&&xb.isArray(h["@Collection"])&&f.subFolders(this.folderResponseParseRec(a,h["@Collection"])),i.push(f)));return i},jb.prototype.setFolders=function(a){var b=[],c=!1,d=Jb.data(),e=function(a){return""===a||ub.Values.UnuseOptionValue===a||null!==Jb.cache().getFolderFromCacheList(a)?a:""};a&&a.Result&&"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&xb.isArray(a.Result["@Collection"])&&(xb.isUnd(a.Result.Namespace)||(d.namespace=a.Result.Namespace),this.threading(!!Jb.settingsGet("UseImapThread")&&a.Result.IsThreadsSupported&&!0),b=this.folderResponseParseRec(d.namespace,a.Result["@Collection"]),d.folderList(b),a.Result.SystemFolders&&""==""+Jb.settingsGet("SentFolder")+Jb.settingsGet("DraftFolder")+Jb.settingsGet("SpamFolder")+Jb.settingsGet("TrashFolder")+Jb.settingsGet("NullFolder")&&(Jb.settingsSet("SentFolder",a.Result.SystemFolders[2]||null),Jb.settingsSet("DraftFolder",a.Result.SystemFolders[3]||null),Jb.settingsSet("SpamFolder",a.Result.SystemFolders[4]||null),Jb.settingsSet("TrashFolder",a.Result.SystemFolders[5]||null),c=!0),d.sentFolder(e(Jb.settingsGet("SentFolder"))),d.draftFolder(e(Jb.settingsGet("DraftFolder"))),d.spamFolder(e(Jb.settingsGet("SpamFolder"))),d.trashFolder(e(Jb.settingsGet("TrashFolder"))),c&&Jb.remote().saveSystemFolders(xb.emptyFunction,{SentFolder:d.sentFolder(),DraftFolder:d.draftFolder(),SpamFolder:d.spamFolder(),TrashFolder:d.trashFolder(),NullFolder:"NullFolder"}),Jb.local().set(vb.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash)) -},jb.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()},jb.prototype.getNextFolderNames=function(a){a=xb.isUnd(a)?!1:!!a;var b=[],c=10,d=f().unix(),e=d-300,g=[],i=function(b){h.each(b,function(b){b&&"INBOX"!==b.fullNameRaw&&b.selectable&&b.existen&&e>b.interval&&(!a||b.subScribed())&&g.push([b.interval,b.fullNameRaw]),b&&0 b[0]?1:0}),h.find(g,function(a){var e=Jb.cache().getFolderFromCacheList(a[1]);return e&&(e.interval=d,b.push(a[1])),c<=b.length}),h.uniq(b)},jb.prototype.setMessage=function(c,d){var e=!1,f=!1,g=!1,h=null,i=null,j="",k="",l=!1,m=!1,n=null,o=this.messagesBodiesDom(),p=this.message();if(c&&p&&c.Result&&"Object/Message"===c.Result["@Object"]&&p.folderFullNameRaw===c.Result.Folder&&p.uid===c.Result.Uid){if(this.messageError(""),p.initUpdateByMessageJson(c.Result),Jb.cache().addRequestedMessage(p.folderFullNameRaw,p.uid),d||p.initFlagsByJson(c.Result),o=o&&o[0]?o:null){if(j="rl-mgs-"+p.hash.replace(/[^a-zA-Z0-9]/g,""),i=o.find("#"+j),i&&i[0])p.body=i,p.body&&(p.body.data("rl-cache-count",++Ab.iMessageBodyCacheCount),p.isRtl(!!p.body.data("rl-is-rtl")),p.isHtml(!!p.body.data("rl-is-html")),p.hasImages(!!p.body.data("rl-has-images")),p.plainRaw=xb.pString(p.body.data("rl-plain-raw")));else{if(f=!!c.Result.HasExternals,g=!!c.Result.HasInternals,h=b('').hide().addClass("rl-cache-class"),h.data("rl-cache-count",++Ab.iMessageBodyCacheCount),xb.isNormal(c.Result.Html)&&""!==c.Result.Html)e=!0,h.html(c.Result.Html.toString()).addClass("b-text-part html");else if(xb.isNormal(c.Result.Plain)&&""!==c.Result.Plain){if(e=!1,k=c.Result.Plain.toString(),Ab.bAllowOpenPGP&&(p.isPgpSigned()||p.isPgpEncrypted())&&xb.isNormal(c.Result.PlainRaw)){if(m=/---BEGIN PGP MESSAGE---/.test(c.Result.PlainRaw),m||(l=/-----BEGIN PGP SIGNED MESSAGE-----/.test(c.Result.PlainRaw)&&/-----BEGIN PGP SIGNATURE-----/.test(c.Result.PlainRaw)),l&&p.isPgpSigned()&&p.pgpSignature()){k=' '+c.Result.PlainRaw+"";try{n=a.openpgp.cleartext.readArmored(c.Result.PlainRaw)}catch(q){}n&&n.getText?k=n.getText():l=!1}else if(m&&p.isPgpEncrypted()){try{n=a.openpgp.message.readArmored(c.Result.PlainRaw)}catch(q){}k=''+c.Result.PlainRaw+""}(l||m)&&(h.data("rl-plain-raw",c.Result.PlainRaw),h.data("rl-plain-pgp-encrypted",m),h.data("rl-plain-pgp-signed",l))}h.html(k).addClass("b-text-part plain")}else e=!1;c.Result.Rtl&&(h.data("rl-is-rtl",!0),h.addClass("rtl-text-part")),p.body=h,p.body&&(o.append(p.body),p.body.data("rl-is-html",e),p.body.data("rl-has-images",f),p.isRtl(!!p.body.data("rl-is-rtl")),p.isHtml(!!p.body.data("rl-is-html")),p.hasImages(!!p.body.data("rl-has-images")),p.plainRaw=xb.pString(p.body.data("rl-plain-raw"))),g&&p.showInternalImages(!0),p.hasImages()&&this.showImages()&&p.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()}Ab.bAllowOpenPGP&&p.body?(p.isPgpSigned(!!p.body.data("rl-plain-pgp-signed")),p.isPgpEncrypted(!!p.body.data("rl-plain-pgp-encrypted"))):(p.isPgpSigned(!1),p.isPgpEncrypted(!1)),this.messageActiveDom(p.body),this.hideMessageBodies(),p.body.show(),h&&xb.initBlockquoteSwitcher(h)}Jb.cache().initMessageFlagsFromCache(p),p.unseen()&&Jb.setMessageSeen(p),xb.windowResize()}},jb.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&xb.isArray(a.Result["@Collection"])){var c=Jb.data(),d=Jb.cache(),e=null,g=0,h=0,i=0,j=0,k=[],l=f().unix(),m=c.staticMessageList,n=null,o=null,p=null,q=0,r=!1;for(i=xb.pInt(a.Result.MessageResultCount),j=xb.pInt(a.Result.Offset),xb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),p=Jb.cache().getFolderFromCacheList(xb.isNormal(a.Result.Folder)?a.Result.Folder:""),p&&!b&&(p.interval=l,Jb.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),xb.isNormal(a.Result.MessageCount)&&p.messageCountAll(a.Result.MessageCount),xb.isNormal(a.Result.MessageUnseenCount)&&(xb.pInt(p.messageCountUnread())!==xb.pInt(a.Result.MessageUnseenCount)&&(r=!0),p.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(p.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),r&&p&&Jb.cache().clearMessageFlagsFromCacheByFolder(p.fullNameRaw),g=0,h=a.Result["@Collection"].length;h>g;g++)n=a.Result["@Collection"][g],n&&"Object/Message"===n["@Object"]&&(o=m[g],o&&o.initByJson(n)||(o=z.newInstanceFromJson(n)),o&&(d.hasNewMessageAndRemoveFromCache(o.folderFullNameRaw,o.uid)&&5>=q&&(q++,o.newForAnimation(!0)),o.deleted(!1),b?Jb.cache().initMessageFlagsFromCache(o):Jb.cache().storeMessageFlagsToCache(o),o.lastInCollapsedThread(e&&-1(new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="abort"),i.oRequests[n]=null),i.defaultResponse(c,n,e,b,f,d)}),n&&0 0?(this.defaultRequest(a,"Message",{},null,"Message/"+zb.urlsafe_encode([b,c,Jb.data().projectHash(),Jb.data().threading()&&Jb.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},lb.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999e3)},lb.prototype.folderInformation=function(a,b,c){var d=!0,e=Jb.cache(),f=[];xb.isArray(c)&&0 l;l++)p.push({id:e[l][0],name:e[l][1],disable:!1});for(l=0,m=b.length;m>l;l++)n=b[l],(h?h.call(null,n):!0)&&p.push({id:n.fullNameRaw,system:!0,name:i?i.call(null,n):n.name(),disable:!n.selectable||-1 l;l++)n=c[l],n.isGmailFolder||!n.subScribed()&&n.existen||(h?h.call(null,n):!0)&&(vb.FolderType.User===n.type()||!j||!n.isNamespaceFolder&&0 0){if(vb.FolderType.Draft===c)return""+a;if(b>0&&vb.FolderType.Trash!==c&&vb.FolderType.SentItems!==c)return""+b}return""},this),this.canBeDeleted=c.computed(function(){var a=this.isSystemFolder();return!a&&0===this.subFolders().length&&"INBOX"!==this.fullNameRaw},this),this.canBeSubScribed=c.computed(function(){return!this.isSystemFolder()&&this.selectable&&"INBOX"!==this.fullNameRaw},this),this.visible.subscribe(function(){xb.timeOutAction("folder-list-folder-visibility-change",function(){Gb.trigger("folder-list-folder-visibility-change")},100)}),this.localName=c.computed(function(){Ab.langChangeTrigger();var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case vb.FolderType.Inbox:b=xb.i18n("FOLDER_LIST/INBOX_NAME");break;case vb.FolderType.SentItems:b=xb.i18n("FOLDER_LIST/SENT_NAME");break;case vb.FolderType.Draft:b=xb.i18n("FOLDER_LIST/DRAFTS_NAME");break;case vb.FolderType.Spam:b=xb.i18n("FOLDER_LIST/SPAM_NAME");break;case vb.FolderType.Trash:b=xb.i18n("FOLDER_LIST/TRASH_NAME")}return b},this),this.manageFolderSystemName=c.computed(function(){Ab.langChangeTrigger();var a="",b=this.type(),c=this.name();if(this.isSystemFolder())switch(b){case vb.FolderType.Inbox:a="("+xb.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case vb.FolderType.SentItems:a="("+xb.i18n("FOLDER_LIST/SENT_NAME")+")";break;case vb.FolderType.Draft:a="("+xb.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case vb.FolderType.Spam:a="("+xb.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case vb.FolderType.Trash:a="("+xb.i18n("FOLDER_LIST/TRASH_NAME")+")"}return(""!==a&&"("+c+")"===a||"(inbox)"===a.toLowerCase())&&(a=""),a},this),this.collapsed=c.computed({read:function(){return!this.hidden()&&this.collapsedPrivate()},write:function(a){this.collapsedPrivate(a)},owner:this}),this.hasUnreadMessages=c.computed(function(){return 0 "},C.prototype.formattedNameForCompose=function(){var a=this.name();return""===a?this.email():a+" ("+this.email()+")"},C.prototype.formattedNameForEmail=function(){var a=this.name();return""===a?this.email():'"'+xb.quoteName(a)+'" <'+this.email()+">"},D.prototype.index=0,D.prototype.id="",D.prototype.user="",D.prototype.armor="",D.prototype.isPrivate=!1,xb.extendAsViewModel("PopupsFolderClearViewModel",E),E.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},E.prototype.onShow=function(a){this.clearPopup(),a&&this.selectedFolder(a)},xb.extendAsViewModel("PopupsFolderCreateViewModel",F),F.prototype.sNoParentText="",F.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(xb.trim(a))},F.prototype.clearPopup=function(){this.folderName(""),this.selectedParentValue(""),this.folderName.focused(!1)},F.prototype.onShow=function(){this.clearPopup()},F.prototype.onFocus=function(){this.folderName.focused(!0)},xb.extendAsViewModel("PopupsFolderSystemViewModel",G),G.prototype.sChooseOnText="",G.prototype.sUnuseText="",G.prototype.onShow=function(a){var b="";switch(a=xb.isUnd(a)?vb.SetSystemFoldersNotification.None:a){case vb.SetSystemFoldersNotification.Sent:b=xb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case vb.SetSystemFoldersNotification.Draft:b=xb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case vb.SetSystemFoldersNotification.Spam:b=xb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case vb.SetSystemFoldersNotification.Trash:b=xb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH")}this.notification(b)},xb.extendAsViewModel("PopupsComposeViewModel",H),H.prototype.reloadDraftFolder=function(){var a=Jb.data().draftFolder();""!==a&&(Jb.cache().setFolderHash(a,""),Jb.data().currentFolderFullNameRaw()===a?Jb.reloadMessageList(!0):Jb.folderInformation(a))},H.prototype.findIdentityIdByMessage=function(a,b){var c={},d="",e=function(a){return a&&a.email&&c[a.email]?(d=c[a.email],!0):!1};if(this.bAllowIdentities&&h.each(this.identities(),function(a){c[a.email()]=a.id}),c[Jb.data().accountEmail()]=Jb.data().accountEmail(),b)switch(a){case vb.ComposeType.Empty:d=Jb.data().accountEmail();break;case vb.ComposeType.Reply:case vb.ComposeType.ReplyAll:case vb.ComposeType.Forward:case vb.ComposeType.ForwardAsAttachment:h.find(h.union(b.to,b.cc,b.bcc),e);break;case vb.ComposeType.Draft:h.find(h.union(b.from,b.replyTo),e)}else d=Jb.data().accountEmail();return d},H.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)},H.prototype.formattedFrom=function(a){var b=Jb.data().displayName(),c=Jb.data().accountEmail();return""===b?c:(xb.isUnd(a)?1:!a)?b+" ("+c+")":'"'+xb.quoteName(b)+'" <'+c+">"},H.prototype.sendMessageResponse=function(b,c){var d=!1,e="";this.sending(!1),vb.StorageResultType.Success===b&&c&&c.Result&&(d=!0,this.modalVisibility()&&xb.delegateRun(this,"closeCommand")),this.modalVisibility()&&!d&&(c&&vb.Notification.CantSaveMessage===c.ErrorCode?(this.sendSuccessButSaveError(!0),a.alert(xb.trim(xb.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(e=xb.getNotification(c&&c.ErrorCode?c.ErrorCode:vb.Notification.CantSendMessage,c&&c.ErrorMessage?c.ErrorMessage:""),this.sendError(!0),a.alert(e||xb.getNotification(vb.Notification.CantSendMessage)))),this.reloadDraftFolder()},H.prototype.saveMessageResponse=function(b,c){var d=!1,e=null;this.saving(!1),vb.StorageResultType.Success===b&&c&&c.Result&&c.Result.NewFolder&&c.Result.NewUid&&(this.bFromDraft&&(e=Jb.data().message(),e&&this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid&&Jb.data().message(null)),this.draftFolder(c.Result.NewFolder),this.draftUid(c.Result.NewUid),this.modalVisibility()&&(this.savedTime(Math.round((new a.Date).getTime()/1e3)),this.savedOrSendingText(0 c;c++)e.push(a[c].toLine(!!b));return e.join(", ")};if(c=c||null,c&&xb.isNormal(c)&&(v=xb.isArray(c)&&1===c.length?c[0]:xb.isArray(c)?null:c),null!==q&&(p[q]=!0,this.currentIdentityID(this.findIdentityIdByMessage(w,v))),this.reset(),xb.isNonEmptyArray(d)&&this.to(x(d)),""!==w&&v){switch(j=v.fullFormatDateValue(),k=v.subject(),u=v.aDraftInfo,l=b(v.body).clone(),xb.removeBlockquoteSwitcher(l),m=l.html(),w){case vb.ComposeType.Empty:break;case vb.ComposeType.Reply:this.to(x(v.replyEmails(p))),this.subject(xb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=xb.trim(this.sInReplyTo+" "+v.sReferences);break;case vb.ComposeType.ReplyAll:o=v.replyAllEmails(p),this.to(x(o[0])),this.cc(x(o[1])),this.subject(xb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=xb.trim(this.sInReplyTo+" "+v.references());break;case vb.ComposeType.Forward:this.subject(xb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=xb.trim(this.sInReplyTo+" "+v.sReferences);break;case vb.ComposeType.ForwardAsAttachment:this.subject(xb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=xb.trim(this.sInReplyTo+" "+v.sReferences);break;case vb.ComposeType.Draft:this.to(x(v.to)),this.cc(x(v.cc)),this.bcc(x(v.bcc)),this.bFromDraft=!0,this.draftFolder(v.folderFullNameRaw),this.draftUid(v.uid),this.subject(k),this.prepearMessageAttachments(v,w),this.aDraftInfo=xb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences;break;case vb.ComposeType.EditAsNew:this.to(x(v.to)),this.cc(x(v.cc)),this.bcc(x(v.bcc)),this.subject(k),this.prepearMessageAttachments(v,w),this.aDraftInfo=xb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences}switch(w){case vb.ComposeType.Reply:case vb.ComposeType.ReplyAll:f=v.fromToLine(!1,!0),n=xb.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:j,EMAIL:f}),m="
"+n+":";break;case vb.ComposeType.Forward:f=v.fromToLine(!1,!0),g=v.toToLine(!1,!0),i=v.ccToLine(!1,!0),m=""+m+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+f+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+g+(0"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+i:"")+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+xb.encodeHtml(j)+"
"+xb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+xb.encodeHtml(k)+"
"+m;break;case vb.ComposeType.ForwardAsAttachment:m=""}s&&""!==r&&vb.ComposeType.EditAsNew!==w&&vb.ComposeType.Draft!==w&&(m=this.convertSignature(r,x(v.from,!0))+"
"+m),this.editor(function(a){a.setHtml(m,!1),v.isHtml()||a.modeToggle(!1)})}else vb.ComposeType.Empty===w?(m=this.convertSignature(r),this.editor(function(a){a.setHtml(m,!1),vb.EditorDefaultType.Html!==Jb.data().editorDefaultType()&&a.modeToggle(!1)})):xb.isNonEmptyArray(c)&&h.each(c,function(a){e.addMessageAsAttachment(a)});t=this.getAttachmentsDownloadsForUpload(),xb.isNonEmptyArray(t)&&Jb.remote().messageUploadAttachments(function(a,b){if(vb.StorageResultType.Success===a&&b&&b.Result){var c=null,d="";if(!e.viewModelVisibility())for(d in b.Result)b.Result.hasOwnProperty(d)&&(c=e.getAttachmentById(b.Result[d]),c&&c.tempName(d))}else e.setMessageAttachmentFailedDowbloadText()},t),this.triggerForResize()},H.prototype.onFocus=function(){""===this.to()?this.to.focusTrigger(!this.to.focusTrigger()):this.oEditor&&this.oEditor.focus(),this.triggerForResize()},H.prototype.editorResize=function(){this.oEditor&&this.oEditor.resize()},H.prototype.tryToClosePopup=function(){var a=this;Cb.showScreenPopup(Q,[xb.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&xb.delegateRun(a,"closeCommand")}])},H.prototype.onBuild=function(){this.initUploader();var a=this,c=null;Gb.on("keydown",function(b){var c=!0;return b&&a.modalVisibility()&&Jb.data().useKeyboardShortcuts()&&(a.bAllowCtrlS&&b.ctrlKey&&vb.EventKeyCode.S===b.keyCode?(a.saveCommand(),c=!1):b.ctrlKey&&vb.EventKeyCode.Enter===b.keyCode?(a.sendCommand(),c=!1):vb.EventKeyCode.Esc===b.keyCode&&(a.tryToClosePopup(),c=!1)),c}),Gb.on("resize",function(){a.triggerForResize()}),this.dropboxEnabled()&&(c=document.createElement("script"),c.type="text/javascript",c.src="https://www.dropbox.com/static/api/1/dropins.js",b(c).attr("id","dropboxjs").attr("data-app-key",Jb.settingsGet("DropboxApiKey")),document.body.appendChild(c))},H.prototype.getAttachmentById=function(a){for(var b=this.attachments(),c=0,d=b.length;d>c;c++)if(b[c]&&a===b[c].id)return b[c];return null},H.prototype.initUploader=function(){if(this.composeUploaderButton()){var a={},b=xb.pInt(Jb.settingsGet("AttachmentLimit")),c=new g({action:Jb.link().upload(),name:"uploader",queueSize:2,multipleSizeLimit:50,disableFolderDragAndDrop:!1,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace()});c?(c.on("onDragEnter",h.bind(function(){this.dragAndDropOver(!0)},this)).on("onDragLeave",h.bind(function(){this.dragAndDropOver(!1)},this)).on("onBodyDragEnter",h.bind(function(){this.dragAndDropVisible(!0)},this)).on("onBodyDragLeave",h.bind(function(){this.dragAndDropVisible(!1)},this)).on("onProgress",h.bind(function(b,c,d){var e=null;xb.isUnd(a[b])?(e=this.getAttachmentById(b),e&&(a[b]=e)):e=a[b],e&&e.progress(" - "+Math.floor(c/d*100)+"%")},this)).on("onSelect",h.bind(function(a,d){this.dragAndDropOver(!1);var e=this,f=xb.isUnd(d.FileName)?"":d.FileName.toString(),g=xb.isNormal(d.Size)?xb.pInt(d.Size):null,h=new y(a,f,g);return h.cancel=function(a){return function(){e.attachments.remove(function(b){return b&&b.id===a}),c&&c.cancel(a)}}(a),this.attachments.push(h),g>0&&b>0&&g>b?(h.error(xb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(b){var c=null;xb.isUnd(a[b])?(c=this.getAttachmentById(b),c&&(a[b]=c)):c=a[b],c&&(c.waiting(!1),c.uploading(!0))},this)).on("onComplete",h.bind(function(b,c,d){var e="",f=null,g=null,h=this.getAttachmentById(b);g=c&&d&&d.Result&&d.Result.Attachment?d.Result.Attachment:null,f=d&&d.Result&&d.Result.ErrorCode?d.Result.ErrorCode:null,null!==f?e=xb.getUploadErrorDescByCode(f):g||(e=xb.i18n("UPLOAD/ERROR_UNKNOWN")),h&&(""!==e&&00&&d>0&&f>d?(e.uploading(!1),e.error(xb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(Jb.remote().composeUploadExternals(function(a,b){var c=!1;e.uploading(!1),vb.StorageResultType.Success===a&&b&&b.Result&&b.Result[e.id]&&(c=!0,e.tempName(b.Result[e.id])),c||e.error(xb.getUploadErrorDescByCode(vb.UploadErrorCode.FileNoUploaded))},[a.link]),!0)},H.prototype.prepearMessageAttachments=function(a,b){if(a){var c=this,d=xb.isNonEmptyArray(a.attachments())?a.attachments():[],e=0,f=d.length,g=null,h=null,i=!1,j=function(a){return function(){c.attachments.remove(function(b){return b&&b.id===a})}};if(vb.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f>e;e++){switch(h=d[e],i=!1,b){case vb.ComposeType.Reply:case vb.ComposeType.ReplyAll:i=h.isLinked;break;case vb.ComposeType.Forward:case vb.ComposeType.Draft:case vb.ComposeType.EditAsNew:i=!0}i=!0,i&&(g=new y(h.download,h.fileName,h.estimatedSize,h.isInline,h.isLinked,h.cid,h.contentLocation),g.fromMessage=!0,g.cancel=j(h.download),g.waiting(!1).uploading(!0),this.attachments.push(g))}}},H.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})},H.prototype.setMessageAttachmentFailedDowbloadText=function(){h.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(xb.getUploadErrorDescByCode(vb.UploadErrorCode.FileNoUploaded))},this)},H.prototype.isEmptyForm=function(a){a=xb.isUnd(a)?!0:!!a;var b=a?0===this.attachments().length:0===this.attachmentsInReady().length;return 0===this.to().length&&0===this.cc().length&&0===this.bcc().length&&0===this.subject().length&&b&&(!this.oEditor||""===this.oEditor.getData())},H.prototype.reset=function(){this.to(""),this.cc(""),this.bcc(""),this.replyTo(""),this.subject(""),this.requestReadReceipt(!1),this.aDraftInfo=null,this.sInReplyTo="",this.bFromDraft=!1,this.sReferences="",this.sendError(!1),this.sendSuccessButSaveError(!1),this.savedError(!1),this.savedTime(0),this.savedOrSendingText(""),this.emptyToError(!1),this.showCcAndBcc(!1),this.attachments([]),this.dragAndDropOver(!1),this.dragAndDropVisible(!1),this.draftFolder(""),this.draftUid(""),this.sending(!1),this.saving(!1),this.oEditor&&this.oEditor.clear(!1)},H.prototype.getAttachmentsDownloadsForUpload=function(){return h.map(h.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})},H.prototype.triggerForResize=function(){this.resizer(!this.resizer()),this.editorResizeThrottle()},xb.extendAsViewModel("PopupsContactsViewModel",I),I.prototype.setShareToNone=function(){this.viewScopeType(vb.ContactScopeType.Default)},I.prototype.setShareToAll=function(){this.viewScopeType(vb.ContactScopeType.ShareAll)},I.prototype.addNewProperty=function(a){var b=new w(a,"");b.focused(!0),this.viewProperties.push(b)},I.prototype.addNewEmail=function(){this.addNewProperty(vb.ContactPropertyType.EmailPersonal)},I.prototype.addNewPhone=function(){this.addNewProperty(vb.ContactPropertyType.MobilePersonal)},I.prototype.initUploader=function(){if(this.importUploaderButton()){var b=new g({action:Jb.link().uploadContacts(),name:"uploader",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,disableDragAndDrop:!0,disableMultiple:!0,disableDocumentDropPrevent:!0,clickElement:this.importUploaderButton()});b&&b.on("onStart",h.bind(function(){this.contacts.importing(!0)},this)).on("onComplete",h.bind(function(b,c,d){this.contacts.importing(!1),this.reloadContactList(),b&&c&&d&&d.Result||a.alert(xb.i18n("CONTACTS/ERROR_IMPORT_FILE"))},this))}},I.prototype.removeCheckedOrSelectedContactsFromList=function(){var a=this,b=this.contacts,c=this.currentContact(),d=this.contacts().length,e=this.contactsCheckedOrSelected();0 =d&&(this.bDropPageAfterDelete=!0),h.delay(function(){h.each(e,function(a){b.remove(a)})},500))},I.prototype.deleteSelectedContacts=function(){0 0?d:0),b.contactsCount(d),b.contacts(e),b.viewClearSearch(""!==b.search()),b.contacts.loading(!1),""!==b.viewID()&&!b.currentContact()&&b.contacts.setSelectedByUid&&b.contacts.setSelectedByUid(""+b.viewID())},c,ub.Defaults.ContactsPerPage,this.search())},I.prototype.onBuild=function(a){this.oContentVisible=b(".b-list-content",a),this.oContentScrollable=b(".content",this.oContentVisible),this.selector.init(this.oContentVisible,this.oContentScrollable);var d=this;c.computed(function(){var a=this.modalVisibility(),b=Jb.data().useKeyboardShortcuts();this.selector.useKeyboard(a&&b)},this).extend({notify:"always"}),a.on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&(d.contactsPage(xb.pInt(a.value)),d.reloadContactList())}),this.initUploader()},I.prototype.onShow=function(){Cb.routeOff(),this.reloadContactList(!0)},I.prototype.onHide=function(){Cb.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),h.each(this.contacts(),function(a){a.checked(!1)})},xb.extendAsViewModel("PopupsAdvancedSearchViewModel",J),J.prototype.buildSearchStringValue=function(a){return-1 0&&vb.EventKeyCode.Esc===c&&d.viewModelVisibility()&&e.useKeyboardShortcuts()&&!xb.inFocus()&&e.message()&&(d.fullScreenMode(!1),vb.Layout.NoPreview===e.layout()&&Jb.historyBack(),b=!1),b}),b(".attachmentsPlace",a).magnificPopup({delegate:".magnificPopupImage:visible",type:"image",gallery:{enabled:!0,preload:[1,1],navigateByImgClick:!0},callbacks:{open:function(){e.useKeyboardShortcuts(!1)},close:function(){e.useKeyboardShortcuts(!0)}},mainClass:"mfp-fade",removalDelay:400}),a.on("mousedown","a",function(a){return!(a&&3!==a.which&&Jb.mailToHelper(b(this).attr("href")))}).on("click",".attachmentsPlace .attachmentPreview",function(a){a&&a.stopPropagation&&a.stopPropagation()}).on("click",".attachmentsPlace .attachmentItem",function(){var a=c.dataFor(this);a&&a.download&&Jb.download(a.linkDownload())}),this.oMessageScrollerDom=a.find(".messageItem .content"),this.oMessageScrollerDom=this.oMessageScrollerDom&&this.oMessageScrollerDom[0]?this.oMessageScrollerDom:null},X.prototype.isDraftFolder=function(){return Jb.data().message()&&Jb.data().draftFolder()===Jb.data().message().folderFullNameRaw},X.prototype.isSentFolder=function(){return Jb.data().message()&&Jb.data().sentFolder()===Jb.data().message().folderFullNameRaw},X.prototype.isDraftOrSentFolder=function(){return this.isDraftFolder()||this.isSentFolder()},X.prototype.composeClick=function(){Cb.showScreenPopup(H)},X.prototype.editMessage=function(){Jb.data().message()&&Cb.showScreenPopup(H,[vb.ComposeType.Draft,Jb.data().message()])},X.prototype.scrollMessageToTop=function(){this.oMessageScrollerDom&&this.oMessageScrollerDom.scrollTop(0)},X.prototype.showImages=function(a){a&&a.showExternalImages&&a.showExternalImages(!0)},X.prototype.readReceipt=function(a){a&&""!==a.readReceipt()&&(Jb.remote().sendReadReceiptMessage(xb.emptyFunction,a.folderFullNameRaw,a.uid,a.readReceipt(),xb.i18n("READ_RECEIPT/SUBJECT",{SUBJECT:a.subject()}),xb.i18n("READ_RECEIPT/BODY",{"READ-RECEIPT":a.readReceipt()})),a.isReadReceipt(!0),Jb.cache().storeMessageFlagsToCache(a),Jb.reloadFlagsCurrentMessageListAndMessageFromCache())},xb.extendAsViewModel("SettingsMenuViewModel",Y),Y.prototype.link=function(a){return Jb.link().settings(a)},Y.prototype.backToMailBoxClick=function(){Cb.setHash(Jb.link().inbox())},xb.extendAsViewModel("SettingsPaneViewModel",Z),Z.prototype.onShow=function(){Jb.data().message(null)},Z.prototype.backToMailBoxClick=function(){Cb.setHash(Jb.link().inbox())},xb.addSettingsViewModel($,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0),$.prototype.toggleLayout=function(){this.layout(vb.Layout.NoPreview===this.layout()?vb.Layout.SidePreview:vb.Layout.NoPreview)},$.prototype.onBuild=function(){var a=this;h.delay(function(){var c=Jb.data(),d=xb.settingsSaveHelperSimpleFunction(a.mppTrigger,a);c.language.subscribe(function(c){a.languageTrigger(vb.SaveSettingsStep.Animate),b.ajax({url:Jb.link().langLink(c),dataType:"script",cache:!0}).done(function(){xb.i18nToDoc(),a.languageTrigger(vb.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(vb.SaveSettingsStep.FalseResult)}).always(function(){h.delay(function(){a.languageTrigger(vb.SaveSettingsStep.Idle)},1e3)}),Jb.remote().saveSettings(xb.emptyFunction,{Language:c})}),c.editorDefaultType.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{EditorDefaultType:a})}),c.messagesPerPage.subscribe(function(a){Jb.remote().saveSettings(d,{MPP:a})}),c.showImages.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{ShowImages:a?"1":"0"})}),c.interfaceAnimation.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{InterfaceAnimation:a})}),c.useDesktopNotifications.subscribe(function(a){xb.timeOutAction("SaveDesktopNotifications",function(){Jb.remote().saveSettings(xb.emptyFunction,{DesktopNotifications:a?"1":"0"})},3e3)}),c.replySameFolder.subscribe(function(a){xb.timeOutAction("SaveReplySameFolder",function(){Jb.remote().saveSettings(xb.emptyFunction,{ReplySameFolder:a?"1":"0"})},3e3)}),c.useThreads.subscribe(function(a){c.messageList([]),Jb.remote().saveSettings(xb.emptyFunction,{UseThreads:a?"1":"0"})}),c.layout.subscribe(function(a){c.messageList([]),Jb.remote().saveSettings(xb.emptyFunction,{Layout:a})}),c.useCheckboxesInList.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)},$.prototype.onShow=function(){Jb.data().desktopNotifications.valueHasMutated()},$.prototype.selectLanguage=function(){Cb.showScreenPopup(P)},xb.addSettingsViewModel(_,"SettingsContacts","SETTINGS_LABELS/LABEL_CONTACTS_NAME","contacts"),_.prototype.toggleShowPassword=function(){this.showPassword(!this.showPassword())},_.prototype.onBuild=function(){Jb.data().contactsAutosave.subscribe(function(a){Jb.remote().saveSettings(xb.emptyFunction,{ContactsAutosave:a?"1":"0"})})},_.prototype.onShow=function(){this.showPassword(!1)},xb.addSettingsViewModel(ab,"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts"),ab.prototype.addNewAccount=function(){Cb.showScreenPopup(K)},ab.prototype.deleteAccount=function(b){if(b&&b.deleteAccess()){this.accountForDeletion(null);var c=function(a){return b===a};b&&(this.accounts.remove(c),Jb.remote().accountDelete(function(b,c){vb.StorageResultType.Success===b&&c&&c.Result&&c.Reload?(Cb.routeOff(),Cb.setHash(Jb.link().root(),!0),Cb.routeOff(),h.defer(function(){a.location.reload()})):Jb.accountsAndIdentities()},b.email))}},xb.addSettingsViewModel(bb,"SettingsIdentity","SETTINGS_LABELS/LABEL_IDENTITY_NAME","identity"),bb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Jb.data().signature();this.editor=new k(a.signatureDom(),function(){Jb.data().signature((a.editor.isHtml()?":HTML:":"")+a.editor.getData())},function(){":HTML:"===b.substr(0,6)?a.editor.setHtml(b.substr(6),!1):a.editor.setPlain(b,!1)})}},bb.prototype.onBuild=function(){var a=this;h.delay(function(){var b=Jb.data(),c=xb.settingsSaveHelperSimpleFunction(a.displayNameTrigger,a),d=xb.settingsSaveHelperSimpleFunction(a.replyTrigger,a),e=xb.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){Jb.remote().saveSettings(c,{DisplayName:a})}),b.replyTo.subscribe(function(a){Jb.remote().saveSettings(d,{ReplyTo:a})}),b.signature.subscribe(function(a){Jb.remote().saveSettings(e,{Signature:a})}),b.signatureToAll.subscribe(function(a){Jb.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},xb.addSettingsViewModel(cb,"SettingsIdentities","SETTINGS_LABELS/LABEL_IDENTITIES_NAME","identities"),cb.prototype.addNewIdentity=function(){Cb.showScreenPopup(O)},cb.prototype.editIdentity=function(a){Cb.showScreenPopup(O,[a])},cb.prototype.deleteIdentity=function(a){if(a&&a.deleteAccess()){this.identityForDeletion(null);var b=function(b){return a===b};a&&(this.identities.remove(b),Jb.remote().identityDelete(function(){Jb.accountsAndIdentities()},a.id))}},cb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Jb.data().signature();this.editor=new k(a.signatureDom(),function(){Jb.data().signature((a.editor.isHtml()?":HTML:":"")+a.editor.getData())},function(){":HTML:"===b.substr(0,6)?a.editor.setHtml(b.substr(6),!1):a.editor.setPlain(b,!1)})}},cb.prototype.onBuild=function(a){var b=this;a.on("click",".identity-item .e-action",function(){var a=c.dataFor(this);a&&b.editIdentity(a)}),h.delay(function(){var a=Jb.data(),c=xb.settingsSaveHelperSimpleFunction(b.displayNameTrigger,b),d=xb.settingsSaveHelperSimpleFunction(b.replyTrigger,b),e=xb.settingsSaveHelperSimpleFunction(b.signatureTrigger,b);a.displayName.subscribe(function(a){Jb.remote().saveSettings(c,{DisplayName:a})}),a.replyTo.subscribe(function(a){Jb.remote().saveSettings(d,{ReplyTo:a})}),a.signature.subscribe(function(a){Jb.remote().saveSettings(e,{Signature:a})}),a.signatureToAll.subscribe(function(a){Jb.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},xb.addSettingsViewModel(db,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social"),xb.addSettingsViewModel(eb,"SettingsOpenPGP","SETTINGS_LABELS/LABEL_OPEN_PGP_NAME","openpgp"),eb.prototype.addOpenPgpKey=function(){Cb.showScreenPopup(L)},eb.prototype.generateOpenPgpKey=function(){Cb.showScreenPopup(N)},eb.prototype.viewOpenPgpKey=function(a){a&&Cb.showScreenPopup(M,[a])},eb.prototype.deleteOpenPgpKey=function(a){if(a&&a.deleteAccess()){this.openPgpKeyForDeletion(null);var b=Jb.data().openpgpKeyring,c=function(b){return a===b};a&&b&&(this.openpgpkeys.remove(c),b.removeKey(a.index),b.store(),Jb.reloadOpenPgpKeys())}},xb.addSettingsViewModel(fb,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME","change-password"),fb.prototype.onHide=function(){this.changeProcess(!1),this.currentPassword(""),this.newPassword("")},fb.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1),vb.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.passwordUpdateSuccess(!0)):this.passwordUpdateError(!0)},xb.addSettingsViewModel(gb,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders"),gb.prototype.folderEditOnEnter=function(a){var b=a?xb.trim(a.nameForEdit()):"";""!==b&&a.name()!==b&&(Jb.local().set(vb.ClientSideKeyName.FoldersLashHash,""),Jb.data().foldersRenaming(!0),Jb.remote().folderRename(function(a,b){Jb.data().foldersRenaming(!1),vb.StorageResultType.Success===a&&b&&b.Result||Jb.data().foldersListError(b&&b.ErrorCode?xb.getNotification(b.ErrorCode):xb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER")),Jb.folders()},a.fullNameRaw,b),Jb.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b)),a.edited(!1)},gb.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)},gb.prototype.onShow=function(){Jb.data().foldersListError("")},gb.prototype.createFolder=function(){Cb.showScreenPopup(F)},gb.prototype.systemFolder=function(){Cb.showScreenPopup(G)},gb.prototype.deleteFolder=function(a){if(a&&a.canBeDeleted()&&a.deleteAccess()&&0===a.privateMessageCountAll()){this.folderForDeletion(null);var b=function(c){return a===c?!0:(c.subFolders.remove(b),!1)};a&&(Jb.local().set(vb.ClientSideKeyName.FoldersLashHash,""),Jb.data().folderList.remove(b),Jb.data().foldersDeleting(!0),Jb.remote().folderDelete(function(a,b){Jb.data().foldersDeleting(!1),vb.StorageResultType.Success===a&&b&&b.Result||Jb.data().foldersListError(b&&b.ErrorCode?xb.getNotification(b.ErrorCode):xb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER")),Jb.folders()},a.fullNameRaw),Jb.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0 1048576?(a.alert(xb.i18n("SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(){this.customThemeUploaderProgress(!0)},this)).on("onComplete",h.bind(function(b,c,d){c&&d&&d.Result?this.customThemeImg(d.Result):a.alert(d&&d.ErrorCode?xb.getUploadErrorDescByCode(d.ErrorCode):xb.getUploadErrorDescByCode(vb.UploadErrorCode.Unknown)),this.customThemeUploaderProgress(!1)},this)),!!b}return!1},ib.prototype.populateDataOnStart=function(){var a=xb.pInt(Jb.settingsGet("Layout")),b=Jb.settingsGet("Languages"),c=Jb.settingsGet("Themes");xb.isArray(b)&&this.languages(b),xb.isArray(c)&&this.themes(c),this.mainLanguage(Jb.settingsGet("Language")),this.mainTheme(Jb.settingsGet("Theme")),this.allowCustomTheme(!!Jb.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!Jb.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!Jb.settingsGet("AllowIdentities")),this.determineUserLanguage(!!Jb.settingsGet("DetermineUserLanguage")),this.allowThemes(!!Jb.settingsGet("AllowThemes")),this.allowCustomLogin(!!Jb.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!Jb.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!Jb.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(Jb.settingsGet("EditorDefaultType")),this.showImages(!!Jb.settingsGet("ShowImages")),this.contactsAutosave(!!Jb.settingsGet("ContactsAutosave")),this.interfaceAnimation(Jb.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(Jb.settingsGet("MPP")),this.desktopNotifications(!!Jb.settingsGet("DesktopNotifications")),this.useThreads(!!Jb.settingsGet("UseThreads")),this.replySameFolder(!!Jb.settingsGet("ReplySameFolder")),this.useCheckboxesInList(!!Jb.settingsGet("UseCheckboxesInList")),this.layout(vb.Layout.SidePreview),-1 0&&(c=this.messagesBodiesDom(),c&&(c.find(".rl-cache-class").each(function(){var c=b(this);d>c.data("rl-cache-count")&&(c.addClass("rl-cache-purge"),a++)}),a>0&&h.delay(function(){c.find(".rl-cache-purge").remove()},300)))},jb.prototype.populateDataOnStart=function(){ib.prototype.populateDataOnStart.call(this),this.accountEmail(Jb.settingsGet("Email")),this.accountIncLogin(Jb.settingsGet("IncLogin")),this.accountOutLogin(Jb.settingsGet("OutLogin")),this.projectHash(Jb.settingsGet("ProjectHash")),this.displayName(Jb.settingsGet("DisplayName")),this.replyTo(Jb.settingsGet("ReplyTo")),this.signature(Jb.settingsGet("Signature")),this.signatureToAll(!!Jb.settingsGet("SignatureToAll")),this.lastFoldersHash=Jb.local().get(vb.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!Jb.settingsGet("RemoteSuggestions"),this.devEmail=Jb.settingsGet("DevEmail"),this.devLogin=Jb.settingsGet("DevLogin"),this.devPassword=Jb.settingsGet("DevPassword")},jb.prototype.initUidNextAndNewMessages=function(b,c,d){if("INBOX"===b&&xb.isNormal(c)&&""!==c){if(xb.isArray(d)&&0 3)i(Jb.link().notificationMailIcon(),Jb.data().accountEmail(),xb.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:g}));else for(;g>f;f++)i(Jb.link().notificationMailIcon(),z.emailsToLine(z.initEmailsFromJson(d[f].From),!1),d[f].Subject)}Jb.cache().setFolderUidNext(b,c)}},jb.prototype.folderResponseParseRec=function(a,b){var c=0,d=0,e=null,f=null,g="",h=[],i=[];for(c=0,d=b.length;d>c;c++)e=b[c],e&&(g=e.FullNameRaw,f=Jb.cache().getFolderFromCacheList(g),f||(f=A.newInstanceFromJson(e),f&&(Jb.cache().setFolderToCacheList(g,f),Jb.cache().setFolderFullNameRaw(f.fullNameHash,g),f.isGmailFolder=ub.Values.GmailFolderName.toLowerCase()===g.toLowerCase(),""!==a&&a===f.fullNameRaw+f.delimiter&&(f.isNamespaceFolder=!0),(f.isNamespaceFolder||f.isGmailFolder)&&(f.isUnpaddigFolder=!0))),f&&(f.collapsed(!xb.isFolderExpanded(f.fullNameHash)),e.Extended&&(e.Extended.Hash&&Jb.cache().setFolderHash(f.fullNameRaw,e.Extended.Hash),xb.isNormal(e.Extended.MessageCount)&&f.messageCountAll(e.Extended.MessageCount),xb.isNormal(e.Extended.MessageUnseenCount)&&f.messageCountUnread(e.Extended.MessageUnseenCount)),h=e.SubFolders,h&&"Collection/FolderCollection"===h["@Object"]&&h["@Collection"]&&xb.isArray(h["@Collection"])&&f.subFolders(this.folderResponseParseRec(a,h["@Collection"])),i.push(f)));return i},jb.prototype.setFolders=function(a){var b=[],c=!1,d=Jb.data(),e=function(a){return""===a||ub.Values.UnuseOptionValue===a||null!==Jb.cache().getFolderFromCacheList(a)?a:""};a&&a.Result&&"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&xb.isArray(a.Result["@Collection"])&&(xb.isUnd(a.Result.Namespace)||(d.namespace=a.Result.Namespace),this.threading(!!Jb.settingsGet("UseImapThread")&&a.Result.IsThreadsSupported&&!0),b=this.folderResponseParseRec(d.namespace,a.Result["@Collection"]),d.folderList(b),a.Result.SystemFolders&&""==""+Jb.settingsGet("SentFolder")+Jb.settingsGet("DraftFolder")+Jb.settingsGet("SpamFolder")+Jb.settingsGet("TrashFolder")+Jb.settingsGet("NullFolder")&&(Jb.settingsSet("SentFolder",a.Result.SystemFolders[2]||null),Jb.settingsSet("DraftFolder",a.Result.SystemFolders[3]||null),Jb.settingsSet("SpamFolder",a.Result.SystemFolders[4]||null),Jb.settingsSet("TrashFolder",a.Result.SystemFolders[5]||null),c=!0),d.sentFolder(e(Jb.settingsGet("SentFolder"))),d.draftFolder(e(Jb.settingsGet("DraftFolder"))),d.spamFolder(e(Jb.settingsGet("SpamFolder"))),d.trashFolder(e(Jb.settingsGet("TrashFolder"))),c&&Jb.remote().saveSystemFolders(xb.emptyFunction,{SentFolder:d.sentFolder(),DraftFolder:d.draftFolder(),SpamFolder:d.spamFolder(),TrashFolder:d.trashFolder(),NullFolder:"NullFolder"}),Jb.local().set(vb.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash))},jb.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()},jb.prototype.getNextFolderNames=function(a){a=xb.isUnd(a)?!1:!!a;var b=[],c=10,d=f().unix(),e=d-300,g=[],i=function(b){h.each(b,function(b){b&&"INBOX"!==b.fullNameRaw&&b.selectable&&b.existen&&e>b.interval&&(!a||b.subScribed())&&g.push([b.interval,b.fullNameRaw]),b&&0 b[0]?1:0}),h.find(g,function(a){var e=Jb.cache().getFolderFromCacheList(a[1]);return e&&(e.interval=d,b.push(a[1])),c<=b.length}),h.uniq(b)},jb.prototype.removeMessagesFromList=function(a,b,c,d){c=xb.isNormal(c)?c:"",d=xb.isUnd(d)?!1:!!d,b=h.map(b,function(a){return xb.pInt(a)});var e=0,f=Jb.data(),g=Jb.cache(),i=Jb.cache().getFolderFromCacheList(a),j=""===c?null:g.getFolderFromCacheList(c||""),k=f.currentFolderFullNameRaw(),l=f.message(),m=k===a?h.filter(f.messageList(),function(a){return a&&-1 0&&i.messageCountUnread(0<=i.messageCountUnread()-e?i.messageCountUnread()-e:0)),j&&(j.messageCountAll(j.messageCountAll()+b.length),e>0&&j.messageCountUnread(j.messageCountUnread()+e),j.actionBlink(!0)),0 ').hide().addClass("rl-cache-class"),h.data("rl-cache-count",++Ab.iMessageBodyCacheCount),xb.isNormal(c.Result.Html)&&""!==c.Result.Html)e=!0,h.html(c.Result.Html.toString()).addClass("b-text-part html");else if(xb.isNormal(c.Result.Plain)&&""!==c.Result.Plain){if(e=!1,k=c.Result.Plain.toString(),Ab.bAllowOpenPGP&&(p.isPgpSigned()||p.isPgpEncrypted())&&xb.isNormal(c.Result.PlainRaw)){if(m=/---BEGIN PGP MESSAGE---/.test(c.Result.PlainRaw),m||(l=/-----BEGIN PGP SIGNED MESSAGE-----/.test(c.Result.PlainRaw)&&/-----BEGIN PGP SIGNATURE-----/.test(c.Result.PlainRaw)),l&&p.isPgpSigned()&&p.pgpSignature()){k=' '+c.Result.PlainRaw+"";try{n=a.openpgp.cleartext.readArmored(c.Result.PlainRaw)}catch(q){}n&&n.getText?k=n.getText():l=!1}else if(m&&p.isPgpEncrypted()){try{n=a.openpgp.message.readArmored(c.Result.PlainRaw)}catch(q){}k=''+c.Result.PlainRaw+""}(l||m)&&(h.data("rl-plain-raw",c.Result.PlainRaw),h.data("rl-plain-pgp-encrypted",m),h.data("rl-plain-pgp-signed",l))}h.html(k).addClass("b-text-part plain")}else e=!1;c.Result.Rtl&&(h.data("rl-is-rtl",!0),h.addClass("rtl-text-part")),p.body=h,p.body&&(o.append(p.body),p.body.data("rl-is-html",e),p.body.data("rl-has-images",f),p.isRtl(!!p.body.data("rl-is-rtl")),p.isHtml(!!p.body.data("rl-is-html")),p.hasImages(!!p.body.data("rl-has-images")),p.plainRaw=xb.pString(p.body.data("rl-plain-raw"))),g&&p.showInternalImages(!0),p.hasImages()&&this.showImages()&&p.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()}Ab.bAllowOpenPGP&&p.body?(p.isPgpSigned(!!p.body.data("rl-plain-pgp-signed")),p.isPgpEncrypted(!!p.body.data("rl-plain-pgp-encrypted"))):(p.isPgpSigned(!1),p.isPgpEncrypted(!1)),this.messageActiveDom(p.body),this.hideMessageBodies(),p.body.show(),h&&xb.initBlockquoteSwitcher(h)}Jb.cache().initMessageFlagsFromCache(p),p.unseen()&&Jb.setMessageSeen(p),xb.windowResize()}},jb.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&xb.isArray(a.Result["@Collection"])){var c=Jb.data(),d=Jb.cache(),e=null,g=0,h=0,i=0,j=0,k=[],l=f().unix(),m=c.staticMessageList,n=null,o=null,p=null,q=0,r=!1;for(i=xb.pInt(a.Result.MessageResultCount),j=xb.pInt(a.Result.Offset),xb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),p=Jb.cache().getFolderFromCacheList(xb.isNormal(a.Result.Folder)?a.Result.Folder:""),p&&!b&&(p.interval=l,Jb.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),xb.isNormal(a.Result.MessageCount)&&p.messageCountAll(a.Result.MessageCount),xb.isNormal(a.Result.MessageUnseenCount)&&(xb.pInt(p.messageCountUnread())!==xb.pInt(a.Result.MessageUnseenCount)&&(r=!0),p.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(p.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),r&&p&&Jb.cache().clearMessageFlagsFromCacheByFolder(p.fullNameRaw),g=0,h=a.Result["@Collection"].length;h>g;g++)n=a.Result["@Collection"][g],n&&"Object/Message"===n["@Object"]&&(o=m[g],o&&o.initByJson(n)||(o=z.newInstanceFromJson(n)),o&&(d.hasNewMessageAndRemoveFromCache(o.folderFullNameRaw,o.uid)&&5>=q&&(q++,o.newForAnimation(!0)),o.deleted(!1),b?Jb.cache().initMessageFlagsFromCache(o):Jb.cache().storeMessageFlagsToCache(o),o.lastInCollapsedThread(e&&-1(new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="abort"),i.oRequests[n]=null),i.defaultResponse(c,n,e,b,f,d)}),n&&0 0?(this.defaultRequest(a,"Message",{},null,"Message/"+zb.urlsafe_encode([b,c,Jb.data().projectHash(),Jb.data().threading()&&Jb.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},lb.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999e3)},lb.prototype.folderInformation=function(a,b,c){var d=!0,e=Jb.cache(),f=[];xb.isArray(c)&&0