diff --git a/Gruntfile.js b/Gruntfile.js index 76a6fe407..3c6f7e5c1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -184,6 +184,7 @@ module.exports = function (grunt) { "dev/Knoin/Knoin.js", "dev/Models/EmailModel.js", + "dev/Models/ContactTagModel.js", "dev/ViewModels/PopupsDomainViewModel.js", "dev/ViewModels/PopupsPluginViewModel.js", @@ -264,6 +265,7 @@ module.exports = function (grunt) { "dev/Models/EmailModel.js", "dev/Models/ContactModel.js", "dev/Models/ContactPropertyModel.js", + "dev/Models/ContactTagModel.js", "dev/Models/AttachmentModel.js", "dev/Models/ComposeAttachmentModel.js", "dev/Models/MessageModel.js", @@ -459,10 +461,10 @@ module.exports = function (grunt) { require('wrench').rmdirSyncRecursive(releasesSrcPath); } }); - + // uglify grunt.registerTask('rlmin', ['uglify:min_app', 'uglify:min_admin']); - + // uglify (optional) grunt.registerTask('rl', ['uglify:rl']); grunt.registerTask('nano', ['uglify:nano']); diff --git a/dev/Boots/RainLoopApp.js b/dev/Boots/RainLoopApp.js index 87d5c57a8..1a731eb0c 100644 --- a/dev/Boots/RainLoopApp.js +++ b/dev/Boots/RainLoopApp.js @@ -12,7 +12,7 @@ function RainLoopApp() this.oRemote = null; this.oCache = null; this.oMoveCache = {}; - + this.quotaDebounce = _.debounce(this.quota, 1000 * 30); this.moveOrDeleteResponseHelper = _.bind(this.moveOrDeleteResponseHelper, this); @@ -189,11 +189,11 @@ RainLoopApp.prototype.contactsSync = function (fResultFunc) { return false; } - + oContacts.syncing(true); - + RL.remote().contactsSync(function (sResult, oData) { - + oContacts.syncing(false); if (fResultFunc) @@ -211,14 +211,14 @@ RainLoopApp.prototype.messagesMoveTrigger = function () self = this, sSpamFolder = RL.data().spamFolder() ; - + _.each(this.oMoveCache, function (oItem) { - + var bSpam = sSpamFolder === oItem['To'], bHam = !bSpam && sSpamFolder === oItem['From'] && 'INBOX' === oItem['To'] ; - + RL.remote().messagesMove(self.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'], bSpam ? 'SPAM' : (bHam ? 'HAM' : '')); }); @@ -272,7 +272,7 @@ RainLoopApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData) else { RL.cache().setFolderHash(RL.data().currentFolderFullNameRaw(), ''); - + if (oData && -1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage])) { @@ -345,14 +345,14 @@ RainLoopApp.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFol { kn.showScreenPopup(PopupsFolderSystemViewModel, [nSetSystemFoldersNotification]); } - else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType && + else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType && (sFromFolderFullNameRaw === oData.spamFolder() || sFromFolderFullNameRaw === oData.trashFolder()))) { kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () { self.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); oData.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); - + }]); } else if (oMoveFolder) @@ -469,7 +469,7 @@ RainLoopApp.prototype.reloadOpenPgpKeys = function () RainLoopApp.prototype.accountsAndIdentities = function () { var oRainLoopData = RL.data(); - + oRainLoopData.accountsLoading(true); oRainLoopData.identitiesLoading(true); @@ -477,14 +477,14 @@ RainLoopApp.prototype.accountsAndIdentities = function () oRainLoopData.accountsLoading(false); oRainLoopData.identitiesLoading(false); - + if (Enums.StorageResultType.Success === sResult && oData.Result) { - var + var sParentEmail = RL.settingsGet('ParentEmail'), sAccountEmail = oRainLoopData.accountEmail() ; - + sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail; if (Utils.isArray(oData.Result['Accounts'])) @@ -493,21 +493,21 @@ RainLoopApp.prototype.accountsAndIdentities = function () return new AccountModel(sValue, sValue !== sParentEmail); })); } - + if (Utils.isArray(oData.Result['Identities'])) { oRainLoopData.identities(_.map(oData.Result['Identities'], function (oIdentityData) { - - var + + var sId = Utils.pString(oIdentityData['Id']), sEmail = Utils.pString(oIdentityData['Email']), oIdentity = new IdentityModel(sId, sEmail, sId !== sAccountEmail) ; - + oIdentity.name(Utils.pString(oIdentityData['Name'])); oIdentity.replyTo(Utils.pString(oIdentityData['ReplyTo'])); oIdentity.bcc(Utils.pString(oIdentityData['Bcc'])); - + return oIdentity; })); } @@ -518,7 +518,7 @@ RainLoopApp.prototype.accountsAndIdentities = function () RainLoopApp.prototype.quota = function () { this.remote().quota(function (sResult, oData) { - if (Enums.StorageResultType.Success === sResult && oData && oData.Result && + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isArray(oData.Result) && 1 < oData.Result.length && Utils.isPosNumeric(oData.Result[0], true) && Utils.isPosNumeric(oData.Result[1], true)) { @@ -555,7 +555,7 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList) if (oFolder) { oFolder.interval = iUtc; - + if (oData.Result.Hash) { RL.cache().setFolderHash(oData.Result.Folder, oData.Result.Hash); @@ -652,7 +652,7 @@ RainLoopApp.prototype.folderInformationMultiply = function (bBoot) if (oData && oData.Result && oData.Result.List && Utils.isNonEmptyArray(oData.Result.List)) { _.each(oData.Result.List, function (oItem) { - + var aList = [], sHash = RL.cache().getFolderHash(oItem.Folder), @@ -936,7 +936,7 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa } } } - + if (oItem.subScribed() && 0 < oItem.subFolders().length) { aResult = aResult.concat(RL.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [], @@ -970,10 +970,21 @@ RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback) { fCallback([]); } - + }, sQuery); }; +/** + * @param {string} sQuery + * @param {Function} fCallback + */ +RainLoopApp.prototype.getContactsTagsAutocomplete = function (sQuery, fCallback) +{ + fCallback(_.filter(RL.data().contactTags(), function (oContactTag) { + return oContactTag && oContactTag.filterHelper(sQuery); + })); +}; + RainLoopApp.prototype.emailsPicsHashes = function () { RL.remote().emailsPicsHashes(function (sResult, oData) { @@ -1021,7 +1032,7 @@ RainLoopApp.prototype.bootstart = function () bFacebook = RL.settingsGet('AllowFacebookSocial'), bTwitter = RL.settingsGet('AllowTwitterSocial') ; - + if (!RL.settingsGet('ChangePasswordIsAllowed')) { Utils.removeSettingsViewModel(SettingsChangePasswordScreen); @@ -1036,7 +1047,7 @@ RainLoopApp.prototype.bootstart = function () { Utils.removeSettingsViewModel(SettingsAccounts); } - + if (RL.settingsGet('AllowIdentities')) { Utils.removeSettingsViewModel(SettingsIdentity); @@ -1045,7 +1056,7 @@ RainLoopApp.prototype.bootstart = function () { Utils.removeSettingsViewModel(SettingsIdentities); } - + if (!RL.settingsGet('OpenPGP')) { Utils.removeSettingsViewModel(SettingsOpenPGP); @@ -1060,12 +1071,12 @@ RainLoopApp.prototype.bootstart = function () { Utils.removeSettingsViewModel(SettingsSocialScreen); } - + if (!RL.settingsGet('AllowThemes')) { Utils.removeSettingsViewModel(SettingsThemes); } - + Utils.initOnStartOrLangChange(function () { $.extend(true, $.magnificPopup.defaults, { @@ -1113,9 +1124,9 @@ RainLoopApp.prototype.bootstart = function () { RL.data().openpgpKeyring = new window.openpgp.Keyring(); RL.data().allowOpenPGP(true); - + RL.pub('openpgp.init'); - + RL.reloadOpenPgpKeys(); } } @@ -1127,7 +1138,7 @@ RainLoopApp.prototype.bootstart = function () } kn.startScreens([MailBoxScreen, SettingsScreen]); - + if (bGoogle || bFacebook || bTwitter) { RL.socialUsers(true); @@ -1163,7 +1174,7 @@ RainLoopApp.prototype.bootstart = function () window.setInterval(function () { RL.contactsSync(); }, iContactsSyncInterval * 60000 + 5000); - + _.delay(function () { RL.contactsSync(); }, 5000); @@ -1223,7 +1234,7 @@ RainLoopApp.prototype.bootstart = function () Utils.initLayoutResizer('#rl-left', '#rl-right', Enums.ClientSideKeyName.FolderListSize); }); } - + }, this)); } else diff --git a/dev/Common/Knockout.js b/dev/Common/Knockout.js index bbe2f6211..c9e782ae0 100644 --- a/dev/Common/Knockout.js +++ b/dev/Common/Knockout.js @@ -74,7 +74,7 @@ ko.bindingHandlers.tooltip3 = { 'init': function (oElement) { var $oEl = $(oElement); - + $oEl.tooltip({ 'container': 'body', 'trigger': 'hover manual', @@ -93,7 +93,7 @@ ko.bindingHandlers.tooltip3 = { $document.click(function () { $oEl.tooltip('hide'); }); - + }, 'update': function (oElement, fValueAccessor) { var sValue = ko.utils.unwrapObservable(fValueAccessor()); @@ -124,7 +124,7 @@ ko.bindingHandlers.openDropdownTrigger = { $el.find('.dropdown-toggle').dropdown('toggle'); Utils.detectDropdownVisibility(); } - + fValueAccessor()(false); } } @@ -221,7 +221,7 @@ ko.bindingHandlers.clickOnTrue = { ko.bindingHandlers.modal = { 'init': function (oElement, fValueAccessor) { - + $(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({ 'keyboard': false, 'show': ko.utils.unwrapObservable(fValueAccessor()) @@ -536,11 +536,19 @@ ko.bindingHandlers.emailsTags = { 'init': function(oElement, fValueAccessor) { var $oEl = $(oElement), - fValue = fValueAccessor() + fValue = fValueAccessor(), + fFocusCallback = function (bValue) { + if (fValue && fValue.focusTrigger) + { + fValue.focusTrigger(bValue); + } + } ; $oEl.inputosaurus({ 'parseOnBlur': true, + 'allowDragAndDrop': true, + 'focusCallback': fFocusCallback, 'inputDelimiters': [',', ';'], 'autoCompleteSource': function (oData, fResponse) { RL.getAutocomplete(oData.term, function (aData) { @@ -551,12 +559,12 @@ ko.bindingHandlers.emailsTags = { }, 'parseHook': function (aInput) { return _.map(aInput, function (sInputValue) { - + var sValue = Utils.trim(sInputValue), oEmail = null ; - + if ('' !== sValue) { oEmail = new EmailModel(); @@ -586,8 +594,83 @@ ko.bindingHandlers.emailsTags = { if (fValue.focusTrigger) { - fValue.focusTrigger.subscribe(function () { - $oEl.inputosaurus('focus'); + fValue.focusTrigger.subscribe(function (bValue) { + if (bValue) + { + $oEl.inputosaurus('focus'); + } + }); + } + } +}; + +ko.bindingHandlers.contactTags = { + 'init': function(oElement, fValueAccessor) { + var + $oEl = $(oElement), + fValue = fValueAccessor(), + fFocusCallback = function (bValue) { + if (fValue && fValue.focusTrigger) + { + fValue.focusTrigger(bValue); + } + } + ; + + $oEl.inputosaurus({ + 'parseOnBlur': true, + 'allowDragAndDrop': false, + 'focusCallback': fFocusCallback, + 'inputDelimiters': [';'], + 'outputDelimiter': ';', + 'autoCompleteSource': function (oData, fResponse) { + RL.getContactsTagsAutocomplete(oData.term, function (aData) { + fResponse(_.map(aData, function (oTagItem) { + return oTagItem.toLine(false); + })); + }); + }, + 'parseHook': function (aInput) { + return _.map(aInput, function (sInputValue) { + + var + sValue = Utils.trim(sInputValue), + oTag = null + ; + + if ('' !== sValue) + { + oTag = new ContactTagModel(); + oTag.name(sValue); + return [oTag.toLine(false), oTag]; + } + + return [sValue, null]; + + }); + }, + 'change': _.bind(function (oEvent) { + $oEl.data('ContactsTagsValue', oEvent.target.value); + fValue(oEvent.target.value); + }, this) + }); + + fValue.subscribe(function (sValue) { + if ($oEl.data('ContactsTagsValue') !== sValue) + { + $oEl.val(sValue); + $oEl.data('ContactsTagsValue', sValue); + $oEl.inputosaurus('refresh'); + } + }); + + if (fValue.focusTrigger) + { + fValue.focusTrigger.subscribe(function (bValue) { + if (bValue) + { + $oEl.inputosaurus('focus'); + } }); } } @@ -737,7 +820,7 @@ ko.observable.fn.validateFunc = function (fFunc) this.subscribe(function (sValue) { this.hasFuncError(!fFunc(sValue)); }, this); - + this.valueHasMutated(); } diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index 373ca4ddd..ded9ecb1d 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -325,13 +325,13 @@ Utils.i18nToNode = function (oElement) { jqThis.html(Utils.i18n(sKey)); } - + sKey = jqThis.data('i18n-placeholder'); if (sKey) { jqThis.attr('placeholder', Utils.i18n(sKey)); } - + sKey = jqThis.data('i18n-title'); if (sKey) { @@ -469,7 +469,7 @@ Utils.fixLongSubject = function (sSubject) ; sSubject = Utils.trim(sSubject.replace(/[\s]+/, ' ')); - + do { oMatch = /^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/ig.exec(sSubject); @@ -598,9 +598,9 @@ Utils.initNotificationLanguage = function () NotificationI18N[Enums.Notification.CantSaveSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS'); NotificationI18N[Enums.Notification.CantSavePluginSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS'); - + NotificationI18N[Enums.Notification.DomainAlreadyExists] = Utils.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS'); - + NotificationI18N[Enums.Notification.CantInstallPackage] = Utils.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE'); NotificationI18N[Enums.Notification.CantDeletePackage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE'); NotificationI18N[Enums.Notification.InvalidPluginPackage] = Utils.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE'); @@ -613,7 +613,7 @@ Utils.initNotificationLanguage = function () NotificationI18N[Enums.Notification.DemoSendMessageError] = Utils.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR'); NotificationI18N[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS'); - + NotificationI18N[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR'); NotificationI18N[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR'); NotificationI18N[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR'); @@ -765,7 +765,7 @@ Utils.initDataConstructorBySettings = function (oData) oData.contactsAutosave = ko.observable(false); Globals.sAnimationType = Enums.InterfaceAnimation.Full; - + oData.allowThemes = ko.observable(true); oData.allowCustomLogin = ko.observable(false); oData.allowLanguagesOnSettings = ko.observable(true); @@ -775,7 +775,7 @@ Utils.initDataConstructorBySettings = function (oData) oData.useThreads = ko.observable(true); oData.replySameFolder = ko.observable(true); oData.useCheckboxesInList = ko.observable(true); - + oData.layout = ko.observable(Enums.Layout.SidePreview); oData.usePreviewPane = ko.computed(function () { return Enums.Layout.NoPreview !== oData.layout(); @@ -1058,7 +1058,7 @@ Utils.setExpandedFolder = function (sFullNameHash, bExpanded) { aExpandedList = []; } - + if (bExpanded) { aExpandedList.push(sFullNameHash); @@ -1075,7 +1075,7 @@ Utils.setExpandedFolder = function (sFullNameHash, bExpanded) Utils.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName) { var - iDisabledWidth = 65, + iDisabledWidth = 60, iMinWidth = 155, oLeft = $(sLeft), oRight = $(sRight), @@ -1153,7 +1153,7 @@ Utils.initBlockquoteSwitcher = function (oMessageTextBody) var $oList = $('blockquote:not(.rl-bq-switcher)', oMessageTextBody).filter(function () { return 0 === $(this).parent().closest('blockquote', oMessageTextBody).length; }); - + if ($oList && 0 < $oList.length) { $oList.each(function () { @@ -1563,7 +1563,7 @@ Utils.resizeAndCrop = function (sUrl, iValue, fCallback) oCtx.fillStyle = '#fff'; oCtx.fillRect(0, 0, iValue, iValue); oCtx.drawImage(this, aDiff[0] / 2, aDiff[1] / 2, this.width - aDiff[0], this.height - aDiff[1], 0, 0, iValue, iValue); - + fCallback(oCanvas.toDataURL('image/jpeg')); }; diff --git a/dev/Knoin/AbstractViewModel.js b/dev/Knoin/AbstractViewModel.js index 5288e32cd..2fa64c690 100644 --- a/dev/Knoin/AbstractViewModel.js +++ b/dev/Knoin/AbstractViewModel.js @@ -17,7 +17,7 @@ function KnoinAbstractViewModel(sPosition, sTemplate) this.viewModelName = ''; this.viewModelVisibility = ko.observable(false); this.modalVisibility = ko.observable(false).extend({'rateLimit': 0}); - + this.viewModelDom = null; } @@ -72,14 +72,21 @@ KnoinAbstractViewModel.prototype.restoreKeyScope = function () RL.data().keyScope(this.sCurrentKeyScope); }; -KnoinAbstractViewModel.prototype.registerPopupEscapeKey = function () +KnoinAbstractViewModel.prototype.registerPopupKeyDown = function () { var self = this; $window.on('keydown', function (oEvent) { - if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility && self.modalVisibility()) + if (oEvent && self.modalVisibility && self.modalVisibility()) { - Utils.delegateRun(self, 'cancelCommand'); - return false; + if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode) + { + Utils.delegateRun(self, 'cancelCommand'); + return false; + } + else if (Enums.EventKeyCode.Backspace === oEvent.keyCode && !Utils.inFocus()) + { + return false; + } } return true; diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 8fbff1348..3201af3bf 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -83,7 +83,7 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen) ViewModelClass.__builded = true; ViewModelClass.__vm = oViewModel; oViewModel.data = RL.data(); - + oViewModel.viewModelName = ViewModelClass.__name; if (oViewModelPlace && 1 === oViewModelPlace.length) @@ -126,19 +126,19 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen) self.viewModelDom.hide(); }, 300); } - + }, oViewModel); } - + Plugins.runHook('view-model-pre-build', [ViewModelClass.__name, oViewModel, oViewModelDom]); ko.applyBindings(oViewModel, oViewModelDom[0]); Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]); - if (oViewModel && 'Popups' === sPosition && !oViewModel.bDisabeCloseOnEsc) + if (oViewModel && 'Popups' === sPosition) { - oViewModel.registerPopupEscapeKey(); + oViewModel.registerPopupKeyDown(); } - + Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]); } else @@ -240,7 +240,7 @@ Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart) } _.defer(function () { - + // hide screen if (self.oCurrentScreen) { @@ -336,7 +336,7 @@ Knoin.prototype.startScreens = function (aScreensClasses) { oScreen.__started = true; oScreen.__start(); - + Plugins.runHook('screen-pre-start', [oScreen.screenName(), oScreen]); Utils.delegateRun(oScreen, 'onStart'); Plugins.runHook('screen-post-start', [oScreen.screenName(), oScreen]); diff --git a/dev/Models/ContactModel.js b/dev/Models/ContactModel.js index d48548fad..9ad3e73ca 100644 --- a/dev/Models/ContactModel.js +++ b/dev/Models/ContactModel.js @@ -8,6 +8,7 @@ function ContactModel() this.idContact = 0; this.display = ''; this.properties = []; + this.tags = ''; this.readOnly = false; this.focused = ko.observable(false); @@ -21,11 +22,11 @@ function ContactModel() */ ContactModel.prototype.getNameAndEmailHelper = function () { - var + var sName = '', sEmail = '' ; - + if (Utils.isNonEmptyArray(this.properties)) { _.each(this.properties, function (aProperty) { @@ -58,6 +59,7 @@ ContactModel.prototype.parse = function (oItem) this.idContact = Utils.pInt(oItem['IdContact']); this.display = Utils.pString(oItem['Display']); this.readOnly = !!oItem['ReadOnly']; + this.tags = ''; if (Utils.isNonEmptyArray(oItem['Properties'])) { @@ -69,6 +71,11 @@ ContactModel.prototype.parse = function (oItem) }, this); } + if (Utils.isNonEmptyArray(oItem['Tags'])) + { + this.tags = oItem['Tags'].join(';'); + } + bResult = true; } diff --git a/dev/Models/ContactTagModel.js b/dev/Models/ContactTagModel.js new file mode 100644 index 000000000..5141fecee --- /dev/null +++ b/dev/Models/ContactTagModel.js @@ -0,0 +1,45 @@ +/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ + +/** + * @constructor + */ +function ContactTagModel() +{ + this.idContactTag = 0; + this.name = ko.observable(''); + this.readOnly = false; +} + +ContactTagModel.prototype.parse = function (oItem) +{ + var bResult = false; + if (oItem && 'Object/Tag' === oItem['@Object']) + { + this.idContact = Utils.pInt(oItem['IdContactTag']); + this.name(Utils.pString(oItem['Name'])); + this.readOnly = !!oItem['ReadOnly']; + + bResult = true; + } + + return bResult; +}; + +/** + * @param {string} sSearch + * @return {boolean} + */ +ContactTagModel.prototype.filterHelper = function (sSearch) +{ + return this.name().toLowerCase().indexOf(sSearch.toLowerCase()) !== -1; +}; + +/** + * @param {boolean=} bEncodeHtml = false + * @return {string} + */ +ContactTagModel.prototype.toLine = function (bEncodeHtml) +{ + return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ? + Utils.encodeHtml(this.name()) : this.name(); +}; diff --git a/dev/Storages/WebMailAjaxRemote.js b/dev/Storages/WebMailAjaxRemote.js index 7376b798f..8b6181826 100644 --- a/dev/Storages/WebMailAjaxRemote.js +++ b/dev/Storages/WebMailAjaxRemote.js @@ -7,7 +7,7 @@ function WebMailAjaxRemoteStorage() { AbstractAjaxRemoteStorage.call(this); - + this.oRequests = {}; } @@ -686,11 +686,12 @@ WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, iOffset, iLim /** * @param {?Function} fCallback */ -WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, aProperties) +WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties) { this.defaultRequest(fCallback, 'ContactSave', { 'RequestUid': sRequestUid, 'Uid': Utils.trim(sUid), + 'Tags': Utils.trim(sTags), 'Properties': aProperties }); }; diff --git a/dev/Storages/WebMailData.js b/dev/Storages/WebMailData.js index 06f9ab508..8c78ad981 100644 --- a/dev/Storages/WebMailData.js +++ b/dev/Storages/WebMailData.js @@ -83,13 +83,14 @@ function WebMailDataStorage() this.identitiesLoading = ko.observable(false).extend({'throttle': 100}); // contacts + this.contactTags = ko.observableArray([]); this.contacts = ko.observableArray([]); this.contacts.loading = ko.observable(false).extend({'throttle': 200}); this.contacts.importing = ko.observable(false).extend({'throttle': 200}); this.contacts.syncing = ko.observable(false).extend({'throttle': 200}); this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200}); this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200}); - + this.allowContactsSync = ko.observable(false); this.enableContactsSync = ko.observable(false); this.contactsSyncUrl = ko.observable(''); @@ -229,11 +230,11 @@ function WebMailDataStorage() this.messageListEndFolder = ko.observable(''); this.messageListEndSearch = ko.observable(''); this.messageListEndPage = ko.observable(1); - + this.messageListEndHash = ko.computed(function () { return this.messageListEndFolder() + '|' + this.messageListEndSearch() + '|' + this.messageListEndPage(); }, this); - + this.messageListPageCount = ko.computed(function () { var iPage = Math.ceil(this.messageListCount() / this.messagesPerPage()); return 0 >= iPage ? 1 : iPage; @@ -266,7 +267,7 @@ function WebMailDataStorage() this.messageListCompleteLoading.subscribe(function (bValue) { this.messageListCompleteLoadingThrottle(bValue); }, this); - + this.messageList.subscribe(_.debounce(function (aList) { _.each(aList, function (oItem) { if (oItem.newForAnimation()) @@ -283,7 +284,7 @@ function WebMailDataStorage() this.messageLoadingThrottle = ko.observable(false).extend({'throttle': 50}); this.message.focused = ko.observable(false); - + this.message.subscribe(function (oMessage) { if (!oMessage) { @@ -313,7 +314,7 @@ function WebMailDataStorage() RL.data().keyScope(Enums.KeyState.MessageList); } }); - + this.folderList.focused.subscribe(function (bValue) { if (bValue) { @@ -324,11 +325,11 @@ function WebMailDataStorage() RL.data().keyScope(Enums.KeyState.MessageList); } }); - + this.messageLoading.subscribe(function (bValue) { this.messageLoadingThrottle(bValue); }, this); - + this.messageFullScreenMode = ko.observable(false); this.messageError = ko.observable(''); @@ -349,13 +350,13 @@ function WebMailDataStorage() }, this); this.currentMessage = ko.observable(null); - + this.messageListChecked = ko.computed(function () { return _.filter(this.messageList(), function (oItem) { return oItem.checked(); }); }, this).extend({'rateLimit': 0}); - + this.hasCheckedMessages = ko.computed(function () { return 0 < this.messageListChecked().length; }, this).extend({'rateLimit': 0}); @@ -442,7 +443,7 @@ WebMailDataStorage.prototype.purgeMessageBodyCache = function() oMessagesBodiesDom = null, iEnd = Globals.iMessageBodyCacheCount - Consts.Values.MessageBodyCacheLimit ; - + if (0 < iEnd) { oMessagesBodiesDom = this.messagesBodiesDom(); @@ -475,7 +476,7 @@ WebMailDataStorage.prototype.populateDataOnStart = function() this.accountIncLogin(RL.settingsGet('IncLogin')); this.accountOutLogin(RL.settingsGet('OutLogin')); this.projectHash(RL.settingsGet('ProjectHash')); - + this.displayName(RL.settingsGet('DisplayName')); this.replyTo(RL.settingsGet('ReplyTo')); this.signature(RL.settingsGet('Signature')); @@ -517,7 +518,7 @@ WebMailDataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUid { oNotification.show(); } - + window.setTimeout((function (oLocalNotifications) { return function () { if (oLocalNotifications.cancel) @@ -720,7 +721,7 @@ WebMailDataStorage.prototype.hideMessageBodies = function () WebMailDataStorage.prototype.getNextFolderNames = function (bBoot) { bBoot = Utils.isUnd(bBoot) ? false : !!bBoot; - + var aResult = [], iLimit = 10, @@ -756,10 +757,10 @@ WebMailDataStorage.prototype.getNextFolderNames = function (bBoot) { return 1; } - + return 0; }); - + _.find(aTimeouts, function (aItem) { var oFolder = RL.cache().getFolderFromCacheList(aItem[1]); if (oFolder) @@ -767,7 +768,7 @@ WebMailDataStorage.prototype.getNextFolderNames = function (bBoot) oFolder.interval = iUtc; aResult.push(aItem[1]); } - + return iLimit <= aResult.length; }); @@ -785,7 +786,7 @@ WebMailDataStorage.prototype.removeMessagesFromList = function ( { sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : ''; bCopy = Utils.isUnd(bCopy) ? false : !!bCopy; - + aUidForRemove = _.map(aUidForRemove, function (mValue) { return Utils.pInt(mValue); }); @@ -845,7 +846,7 @@ WebMailDataStorage.prototype.removeMessagesFromList = function ( else { oData.messageListIsNotCompleted(true); - + _.each(aMessages, function (oMessage) { if (oCurrentMessage && oCurrentMessage.hash === oMessage.hash) { @@ -916,7 +917,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) oBody = $('
').hide().addClass('rl-cache-class'); oBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount); - + if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html) { bIsHtml = true; @@ -926,7 +927,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) { bIsHtml = false; sPlain = oData.Result.Plain.toString(); - + if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && RL.data().allowOpenPGP() && Utils.isNormal(oData.Result.PlainRaw)) @@ -939,7 +940,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oMessage.plainRaw) && /-----BEGIN PGP SIGNATURE-----/.test(oMessage.plainRaw); } - + $proxyDiv.empty(); if (bPgpSigned && oMessage.isPgpSigned()) { @@ -951,7 +952,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) } else if (bPgpEncrypted && oMessage.isPgpEncrypted()) { - sPlain = + sPlain = $proxyDiv.append( $('').text(oMessage.plainRaw) ).html() @@ -1028,7 +1029,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) { RL.setMessageSeen(oMessage); } - + Utils.windowResize(); } }; @@ -1081,7 +1082,7 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached) if (oFolder && !bCached) { oFolder.interval = iUtc; - + RL.cache().setFolderHash(oData.Result.Folder, oData.Result.FolderHash); if (Utils.isNormal(oData.Result.MessageCount)) diff --git a/dev/Styles/Contacts.less b/dev/Styles/Contacts.less index 5d5fcb663..d7edba6c0 100644 --- a/dev/Styles/Contacts.less +++ b/dev/Styles/Contacts.less @@ -175,7 +175,7 @@ float: left; padding: 0 8px 0 6px; } - + .shareParent { display: none; float: right; @@ -224,7 +224,7 @@ } &.selected { - + background-color: #fff; z-index: 102; @@ -238,7 +238,7 @@ } } } - + .b-view-content-toolbar { background-color: #f5f5f5; padding: 7px; @@ -279,6 +279,27 @@ -webkit-overflow-scrolling: touch; } + .tags-property-container { + font-size: 18px; + width: 400px; + + .inputosaurus-container { + border-width: 1px; + border-color: transparent; + .box-shadow(none); + + &:hover { + .box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075)); + border-color: #ccc; + } + + &.inputosaurus-focused { + .box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075)); + border-color: #999; + } + } + } + .contactValueStatic, .contactValueLargeStatic, .contactValueTextAreaStatic { height: 20px; line-height: 20px; @@ -288,7 +309,7 @@ color: #555; display: none; } - + &.read-only { .contactValueStatic, .contactValueLargeStatic, .contactValueTextAreaStatic { display: inline-block; @@ -361,7 +382,7 @@ color: #ddd; } } - + .contactValueTextArea { width: 300px; } diff --git a/dev/Styles/Layout.less b/dev/Styles/Layout.less index 84b67d49c..e6e782734 100644 --- a/dev/Styles/Layout.less +++ b/dev/Styles/Layout.less @@ -175,9 +175,9 @@ html.ssm-state-tablet { } html.rl-left-panel-disabled { - + #rl-left { - width: 65px !important; + width: 60px !important; .show-on-panel-disabled { display: block; @@ -201,7 +201,7 @@ html.rl-left-panel-disabled { } #rl-right { - left: 65px !important; + left: 60px !important; } } diff --git a/dev/Styles/_InputosaurusFix.less b/dev/Styles/_InputosaurusFix.less index 84e578e51..3f25adc59 100644 --- a/dev/Styles/_InputosaurusFix.less +++ b/dev/Styles/_InputosaurusFix.less @@ -1,14 +1,21 @@ .inputosaurus-container { + width: 99%; line-height: 20px; padding: 2px; border: 1px solid #cccccc; border-radius: 3px; - + .box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075)); .transition(~"border linear .2s, box-shadow linear .2s"); + &.inputosaurus-focused { + background-color: #fff; + border: @rlInputBorderSize solid darken(@inputBorder, 20%); + .box-shadow(none); + } + li { max-width: 500px; background-color: #eee; diff --git a/dev/ViewModels/MailBoxMessageViewViewModel.js b/dev/ViewModels/MailBoxMessageViewViewModel.js index 7eeff2cd5..68411f6c6 100644 --- a/dev/ViewModels/MailBoxMessageViewViewModel.js +++ b/dev/ViewModels/MailBoxMessageViewViewModel.js @@ -67,9 +67,9 @@ function MailBoxMessageViewViewModel() this.forwardCommand = createCommandHelper(Enums.ComposeType.Forward); this.forwardAsAttachmentCommand = createCommandHelper(Enums.ComposeType.ForwardAsAttachment); this.editAsNewCommand = createCommandHelper(Enums.ComposeType.EditAsNew); - + this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility); - + this.messageEditCommand = Utils.createCommand(this, function () { this.editMessage(); }, this.messageVisibility); @@ -91,7 +91,7 @@ function MailBoxMessageViewViewModel() [this.message().uid], false); } }, this.messageVisibility); - + this.archiveCommand = Utils.createCommand(this, function () { if (this.message()) { @@ -100,7 +100,7 @@ function MailBoxMessageViewViewModel() [this.message().uid], true); } }, this.messageVisibility); - + this.spamCommand = Utils.createCommand(this, function () { if (this.message()) { @@ -120,6 +120,7 @@ function MailBoxMessageViewViewModel() }, this.messageVisibility); // viewer + this.viewHash = ''; this.viewSubject = ko.observable(''); this.viewFromShort = ko.observable(''); this.viewToShort = ko.observable(''); @@ -134,7 +135,7 @@ function MailBoxMessageViewViewModel() this.viewDownloadLink = ko.observable(''); this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic); this.viewUserPicVisible = ko.observable(false); - + this.viewPgpPassword = ko.observable(''); this.viewPgpSignedVerifyStatus = ko.computed(function () { return this.message() ? this.message().pgpSignedVerifyStatus() : Enums.SignedVerifyStatus.None; @@ -143,7 +144,7 @@ function MailBoxMessageViewViewModel() this.viewPgpSignedVerifyUser = ko.computed(function () { return this.message() ? this.message().pgpSignedVerifyUser() : ''; }, this); - + this.message.subscribe(function (oMessage) { this.messageActiveDom(null); @@ -152,6 +153,12 @@ function MailBoxMessageViewViewModel() if (oMessage) { + if (this.viewHash !== oMessage.hash) + { + this.scrollMessageToTop(); + } + + this.viewHash = oMessage.hash; this.viewSubject(oMessage.subject()); this.viewFromShort(oMessage.fromToLine(true, true)); this.viewToShort(oMessage.toToLine(true, true)); @@ -179,7 +186,12 @@ function MailBoxMessageViewViewModel() } }); } - + else + { + this.viewHash = ''; + this.scrollMessageToTop(); + } + }, this); this.fullScreenMode.subscribe(function (bValue) { @@ -202,14 +214,10 @@ function MailBoxMessageViewViewModel() } }); - this.messageActiveDom.subscribe(function () { - this.scrollMessageToTop(); - }, this); - this.goUpCommand = Utils.createCommand(this, function () { RL.pub('mailbox.message-list.selector.go-up'); }); - + this.goDownCommand = Utils.createCommand(this, function () { RL.pub('mailbox.message-list.selector.go-down'); }); @@ -274,7 +282,7 @@ MailBoxMessageViewViewModel.prototype.scrollToTop = function () // $('.messageItem', this.viewModelDom).animate({'scrollTop': 0}, 300); $('.messageItem', this.viewModelDom).scrollTop(0); } - + Utils.windowResize(); }; @@ -308,7 +316,7 @@ MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType) MailBoxMessageViewViewModel.prototype.onBuild = function (oDom) { - var + var self = this, oData = RL.data() ; @@ -319,7 +327,7 @@ MailBoxMessageViewViewModel.prototype.onBuild = function (oDom) self.message.focused(true); } }, this); - + $('.attachmentsPlace', oDom).magnificPopup({ 'delegate': '.magnificPopupImage:visible', 'type': 'image', @@ -513,7 +521,7 @@ MailBoxMessageViewViewModel.prototype.initShortcuts = function () { self.message().printMessage(); } - + return false; }); @@ -529,7 +537,7 @@ MailBoxMessageViewViewModel.prototype.initShortcuts = function () { self.deleteCommand(); } - + return false; } }); @@ -673,7 +681,7 @@ MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage) if (oMessage && '' !== oMessage.readReceipt()) { RL.remote().sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid, - oMessage.readReceipt(), + oMessage.readReceipt(), Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}), Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': RL.data().accountEmail()})); diff --git a/dev/ViewModels/PopupsContactsViewModel.js b/dev/ViewModels/PopupsContactsViewModel.js index a6a191d2f..163dbd5d1 100644 --- a/dev/ViewModels/PopupsContactsViewModel.js +++ b/dev/ViewModels/PopupsContactsViewModel.js @@ -24,7 +24,8 @@ function PopupsContactsViewModel() this.search = ko.observable(''); this.contactsCount = ko.observable(0); this.contacts = RL.data().contacts; - + this.contactTags = RL.data().contactTags; + this.currentContact = ko.observable(null); this.importUploaderButton = ko.observable(null); @@ -44,6 +45,21 @@ function PopupsContactsViewModel() this.viewReadOnly = ko.observable(false); this.viewProperties = ko.observableArray([]); + this.viewTags = ko.observable(''); + this.viewTags.visibility = ko.observable(false); + this.viewTags.focusTrigger = ko.observable(false); + + this.viewTags.focusTrigger.subscribe(function (bValue) { + if (!bValue && '' === this.viewTags()) + { + this.viewTags.visibility(false); + } + else if (bValue) + { + this.viewTags.visibility(true); + } + }, this); + this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) { @@ -57,7 +73,7 @@ function PopupsContactsViewModel() Enums.ContactPropertyType.Note ]); }); - + this.viewPropertiesOther = ko.computed(function () { var aList = _.filter(this.viewProperties(), function (oProperty) { @@ -71,7 +87,7 @@ function PopupsContactsViewModel() }); }, this); - + this.viewPropertiesEmails = this.viewProperties.filter(function(oProperty) { return Enums.ContactPropertyType.Email === oProperty.type(); }); @@ -81,7 +97,7 @@ function PopupsContactsViewModel() }); this.viewHasNonEmptyRequaredProperties = ko.computed(function() { - + var aNames = this.viewPropertiesNames(), aEmail = this.viewPropertiesEmails(), @@ -89,7 +105,7 @@ function PopupsContactsViewModel() return '' !== Utils.trim(oProperty.value()); } ; - + return !!(_.find(aNames, fHelper) || _.find(aEmail, fHelper)); }, this); @@ -198,7 +214,7 @@ function PopupsContactsViewModel() this.populateViewContact(null); this.currentContact(null); }); - + this.deleteCommand = Utils.createCommand(this, function () { this.deleteSelectedContacts(); this.emptySelection(true); @@ -213,7 +229,7 @@ function PopupsContactsViewModel() aE = _.map(aC, function (oItem) { if (oItem) { - var + var aData = oItem.getNameAndEmailHelper(), oEmail = aData ? new EmailModel(aData[0], aData[1]) : null ; @@ -235,7 +251,7 @@ function PopupsContactsViewModel() kn.hideScreenPopup(PopupsContactsViewModel); kn.showScreenPopup(PopupsComposeViewModel, [Enums.ComposeType.Empty, null, aE]); } - + }, function () { return 0 < this.contactsCheckedOrSelected().length; }); @@ -245,11 +261,11 @@ function PopupsContactsViewModel() }); this.saveCommand = Utils.createCommand(this, function () { - + this.viewSaving(true); this.viewSaveTrigger(Enums.SaveSettingsStep.Animate); - var + var sRequestUid = Utils.fakeMd5(), aProperties = [] ; @@ -265,7 +281,7 @@ function PopupsContactsViewModel() var bRes = false; self.viewSaving(false); - + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.RequestUid === sRequestUid && 0 < Utils.pInt(oData.Result.ResultID)) { @@ -290,11 +306,11 @@ function PopupsContactsViewModel() self.viewSaveTrigger(Enums.SaveSettingsStep.Idle); }, 1000); } - - }, sRequestUid, this.viewID(), aProperties); - + + }, sRequestUid, this.viewID(), this.viewTags(), aProperties); + }, function () { - var + var bV = this.viewHasNonEmptyRequaredProperties(), bReadOnly = this.viewReadOnly() ; @@ -313,7 +329,7 @@ function PopupsContactsViewModel() self.reloadContactList(true); }); - + }, function () { return !this.contacts.syncing() && !this.contacts.importing(); }); @@ -322,9 +338,9 @@ function PopupsContactsViewModel() this.watchDirty = ko.observable(false); this.watchHash = ko.observable(false); - + this.viewHash = ko.computed(function () { - return '' + _.map(self.viewProperties(), function (oItem) { + return '' + self.viewTags() + '|' + _.map(self.viewProperties(), function (oItem) { return oItem.value(); }).join(''); }); @@ -385,6 +401,12 @@ PopupsContactsViewModel.prototype.addNewOrFocusProperty = function (sType, sType } }; +PopupsContactsViewModel.prototype.addNewTag = function () +{ + this.viewTags.visibility(true); + this.viewTags.focusTrigger(true); +}; + PopupsContactsViewModel.prototype.addNewEmail = function () { this.addNewProperty(Enums.ContactPropertyType.Email, 'Home'); @@ -454,7 +476,7 @@ PopupsContactsViewModel.prototype.initUploader = function () this.contacts.importing(true); }, this)) .on('onComplete', _.bind(function (sId, bResult, oData) { - + this.contacts.importing(false); this.reloadContactList(); @@ -478,7 +500,7 @@ PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = func iCount = this.contacts().length, aContacts = this.contactsCheckedOrSelected() ; - + if (0 < aContacts.length) { _.each(aContacts, function (oContact) { @@ -499,11 +521,11 @@ PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = func } _.delay(function () { - + _.each(aContacts, function (oContact) { oKoContacts.remove(oContact); }); - + }, 500); } }; @@ -562,7 +584,8 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact) this.emptySelection(false); this.viewReadOnly(false); - + this.viewTags(''); + if (oContact) { sId = oContact.idContact; @@ -587,15 +610,20 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact) }); } + this.viewTags(oContact.tags); + this.viewReadOnly(!!oContact.readOnly); } + this.viewTags.focusTrigger.valueHasMutated(); + this.viewTags.visibility('' !== this.viewTags()); + aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.LastName, '', sLastName, false, this.getPropertyPlceholder(Enums.ContactPropertyType.LastName))); aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.FirstName, '', sFirstName, !oContact, this.getPropertyPlceholder(Enums.ContactPropertyType.FirstName))); - + this.viewID(sId); this.viewProperties([]); this.viewProperties(aList); @@ -613,7 +641,7 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio self = this, iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage ; - + this.bDropPageAfterDelete = false; if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition) @@ -626,9 +654,10 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio RL.remote().contacts(function (sResult, oData) { var iCount = 0, - aList = [] + aList = [], + aTagsList = [] ; - + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List) { if (Utils.isNonEmptyArray(oData.Result.List)) @@ -643,14 +672,26 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio iCount = Utils.pInt(oData.Result.Count); iCount = 0 < iCount ? iCount : 0; } + + if (Utils.isNonEmptyArray(oData.Result.Tags)) + { + aTagsList = _.map(oData.Result.Tags, function (oItem) { + var oContactTag = new ContactTagModel(); + return oContactTag.parse(oItem) ? oContactTag : null; + }); + + aTagsList = _.compact(aTagsList); + } } self.contactsCount(iCount); - + self.contacts(aList); - self.viewClearSearch('' !== self.search()); + self.contactTags(aTagsList); self.contacts.loading(false); + self.viewClearSearch('' !== self.search()); + }, iOffset, Consts.Defaults.ContactsPerPage, this.search()); }; diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 04f3b4fc6..053abdeae 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -142,13 +142,13 @@ class Actions /** * @param string $sSpecAuthToken - * + * * @return \RainLoop\Application */ public function SetSpecAuthToken($sSpecAuthToken) { $this->sSpecAuthToken = $sSpecAuthToken; - + return $this; } @@ -293,7 +293,7 @@ class Actions } } } - + /** * @return string */ @@ -361,7 +361,7 @@ class Actions /** * @param \RainLoop\Account $oAccount - * + * * @return void */ public function SetAuthToken($oAccount) @@ -372,12 +372,12 @@ class Actions $this->SetSpecAuthToken($sSpecAuthToken); \RainLoop\Utils::SetCookie(self::AUTH_SPEC_TOKEN_KEY, $sSpecAuthToken, 0, '/', null, null, true); - + if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken())) { \RainLoop\Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY, $oAccount->SignMeToken(), \time() + 60 * 60 * 24 * 30, '/', null, null, true); - + $this->StorageProvider()->Put(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'SignMe/UserToken/'.$oAccount->SignMeToken(), @@ -385,7 +385,7 @@ class Actions } } } - + /** * @return string */ @@ -456,7 +456,7 @@ class Actions return $this->oHttp; } - + /** * @return \RainLoop\Social */ @@ -582,7 +582,7 @@ class Actions return $this->oSuggestionsProvider; } - + /** * @param \RainLoop\Account $oAccount = null * @param bool $bForceEnable = false @@ -718,7 +718,7 @@ class Actions { $this->oCacher->SetDriver($oDriver); } - + $this->oCacher->SetCacheIndex($this->Config()->Get('cache', 'fast_cache_index', '')); } @@ -835,7 +835,7 @@ class Actions )), 0, '/', null, null, true); } } - + /** * @param string $sEmail * @param string $sLogin @@ -884,7 +884,7 @@ class Actions if ($oAccount instanceof \RainLoop\Account) { $this->Logger()->AddSecret($oAccount->Password()); - + $oAccount->SetParentEmail($aAccountHash[6]); $oResult = $oAccount; } @@ -917,7 +917,7 @@ class Actions return $oResult; } - + /** * @return \RainLoop\Account|bool */ @@ -936,7 +936,7 @@ class Actions return $oAccount; } - + /** * @param bool $bThrowExceptionOnFalse = true * @@ -1014,7 +1014,7 @@ class Actions if ($oAccount instanceof \RainLoop\Account) { $oAddressBookProvider = $this->AddressBookProvider($oAccount); - + $aResult['Auth'] = true; $aResult['Email'] = $oAccount->Email(); $aResult['IncLogin'] = $oAccount->IncLogin(); @@ -1043,7 +1043,7 @@ class Actions $aResult['ContactsSyncPassword'] = APP_DUMMY; } } - + if ($aResult['AccountSignMe']) { $sToken = \RainLoop\Utils::GetCookie(self::AUTH_MAILTO_TOKEN_KEY, null); @@ -1074,7 +1074,7 @@ class Actions { $aResult['AllowGoogleSocial'] = false; } - + $aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false); if ($aResult['AllowFacebookSocial'] && ( '' === \trim($oConfig->Get('social', 'fb_app_id', '')) || '' === \trim($oConfig->Get('social', 'fb_app_secret', '')))) @@ -1175,14 +1175,14 @@ class Actions $aResult['EnableTwoFactor'] = false; $aResult['ParentEmail'] = ''; $aResult['InterfaceAnimation'] = \RainLoop\Enumerations\InterfaceAnimation::NORMAL; - + if (!$bAdmin && $oSettings instanceof \RainLoop\Settings) { if ($oConfig->Get('webmail', 'allow_languages_on_settings', true)) { $sLanguage = $oSettings->GetConf('Language', $sLanguage); } - + if ($oConfig->Get('webmail', 'allow_themes', true)) { $sTheme = $oSettings->GetConf('Theme', $sTheme); @@ -1445,7 +1445,7 @@ class Actions $this->loginErrorDelay(); throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError, $oException); } - + return $oAccount; } @@ -1461,14 +1461,14 @@ class Actions $sPassword = $this->GetActionParam('Password', ''); $sLanguage = $this->GetActionParam('Language', ''); $bSignMe = '1' === (string) $this->GetActionParam('SignMe', '0'); - + $sAdditionalCode = $this->GetActionParam('AdditionalCode', ''); $bAdditionalCodeSignMe = '1' === (string) $this->GetActionParam('AdditionalCodeSignMe', '0'); $this->Logger()->AddSecret($sPassword); $oAccount = null; - + try { $oAccount = $this->LoginProcess($sEmail, $sLogin, $sPassword, @@ -1507,7 +1507,7 @@ class Actions /** * @param \RainLoop\Account $oAccount - * + * * @return array */ public function GetAccounts($oAccount) @@ -1573,7 +1573,7 @@ class Actions { $oItem = \RainLoop\Identity::NewInstance($aItem['Id'], $aItem['Email'], $aItem['Name'], $aItem['ReplyTo'], $aItem['Bcc']); - + $aIdentities[] = $oItem; } } @@ -1685,7 +1685,7 @@ class Actions $this->SetAccounts($oAccount, $aAccounts); return $this->TrueResponse(__FUNCTION__); } - + /** * @return array * @@ -1718,11 +1718,11 @@ class Actions $this->AuthProcess($oAccountToChange); } } - + $this->SetAccounts($oAccount, $aAccounts); return $this->TrueResponse(__FUNCTION__, array('Reload' => !!$oAccountToChange)); } - + return $this->FalseResponse(__FUNCTION__); } @@ -1737,7 +1737,7 @@ class Actions { return $this->FalseResponse(__FUNCTION__); } - + $oAccount = $this->getAccountFromToken(); $sId = \trim($this->GetActionParam('Id', '')); @@ -1797,7 +1797,7 @@ class Actions { return $this->FalseResponse(__FUNCTION__); } - + $oAccount = $this->getAccountFromToken(); $sId = \trim($this->GetActionParam('IdToDelete', '')); @@ -1818,7 +1818,7 @@ class Actions return $this->DefaultResponse(__FUNCTION__, $this->SetIdentities($oAccount, $aNew)); } - + /** * @return array * @@ -1856,7 +1856,7 @@ class Actions if ($oAccount && $oAccount->SignMe()) { \RainLoop\Utils::ClearCookie(\RainLoop\Actions::AUTH_SIGN_ME_TOKEN_KEY); - + $this->StorageProvider()->Clear(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'SignMe/UserToken/'.$oAccount->SignMeToken()); @@ -1871,7 +1871,7 @@ class Actions public function DoAppDelayStart() { $this->Plugins()->RunHook('service.app-delay-start-begin'); - + \RainLoop\Utils::UpdateConnectionToken(); $bMainCache = false; @@ -1880,7 +1880,7 @@ class Actions $iOneDay1 = 60 * 60 * 23; $iOneDay2 = 60 * 60 * 25; - + $sTimers = $this->StorageProvider()->Get(null, \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'Cache/Timers', ''); @@ -2084,7 +2084,7 @@ class Actions $this->setConfigFromParams($oConfig, 'AllowAdditionalAccounts', 'webmail', 'allow_additional_accounts', 'bool'); $this->setConfigFromParams($oConfig, 'AllowIdentities', 'webmail', 'allow_identities', 'bool'); - + $this->setConfigFromParams($oConfig, 'AllowGravatar', 'labs', 'allow_gravatar', 'bool'); $this->setConfigFromParams($oConfig, 'DetermineUserLanguage', 'login', 'determine_user_language', 'bool'); @@ -2222,7 +2222,7 @@ class Actions { $iCode = 0; $sContentType = ''; - + $sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain), 'RainLoop', $sContentType, $iCode, $this->Logger(), 10, $this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', '')); @@ -2501,7 +2501,7 @@ class Actions 'Smtp' => $bSmtpResult ? true : $sSmtpErrorDesc )); } - + /** * @param bool $bAdditionalOnly = false * @@ -2526,10 +2526,10 @@ class Actions { $sUrl = rtrim($sUrl, '\\/').'/'; } - + return $sUrl; } - + private function rainLoopUpdatable() { return @file_exists(APP_INDEX_ROOT_PATH.'index.php') && @@ -2593,7 +2593,7 @@ class Actions $sRepPath = $sRepo.$sRepoFile; $sRep = '' !== $sRepo ? $oHttp->GetUrlAsString($sRepPath, 'RainLoop', $sContentType, $iCode, $this->Logger(), 10, $this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', '')) : false; - + if (false !== $sRep) { $aRep = @\json_decode($sRep); @@ -2617,7 +2617,7 @@ class Actions } $bCoreAccess = $this->rainLoopCoreAccess(); - + $aResult = array(); if (\is_array($aRep)) { @@ -2673,7 +2673,7 @@ class Actions return $aResult; } - + private function getRepositoryData(&$bReal, &$bRainLoopUpdatable) { $bRainLoopUpdatable = $this->rainLoopUpdatable(); @@ -2778,14 +2778,14 @@ class Actions return $aResult; } - + /** * @return array */ public function DoAdminPackagesList() { $this->IsAdminLoggined(); - + $bReal = false; $bRainLoopUpdatable = false; $aList = $this->getRepositoryData($bReal, $bRainLoopUpdatable); @@ -2796,20 +2796,20 @@ class Actions 'List' => $aList )); } - + /** * @return array */ public function DoAdminPackageDelete() { $this->IsAdminLoggined(); - + $sId = $this->GetActionParam('Id', ''); - + $bReal = false; $bRainLoopUpdatable = false; $aList = $this->getRepositoryData($bReal, $bRainLoopUpdatable); - + $sResultId = ''; foreach ($aList as $oItem) { @@ -2819,7 +2819,7 @@ class Actions break; } } - + $bResult = false; if ('' !== $sResultId) { @@ -2829,29 +2829,29 @@ class Actions $this->pluginEnable($sResultId, false); } } - + return $this->DefaultResponse(__FUNCTION__, $bResult); } - + /** * @return array */ public function DoAdminPackageInstall() { $this->IsAdminLoggined(); - + $sType = $this->GetActionParam('Type', ''); $sId = $this->GetActionParam('Id', ''); $sFile = $this->GetActionParam('File', ''); $this->Logger()->Write('Start package install: '.$sFile.' ('.$sType.')', \MailSo\Log\Enumerations\Type::INFO, 'INSTALLER'); - + $sRealFile = ''; - + $bReal = false; $bRainLoopUpdatable = false; $aList = $this->getRepositoryData($bReal, $bRainLoopUpdatable); - + if (('plugin' !== $sType && $bRainLoopUpdatable) || 'plugin' === $sType) { foreach ($aList as $oItem) @@ -2881,7 +2881,7 @@ class Actions $oHttp = \MailSo\Base\Http::SingletonInstance(); $bResult = $oHttp->SaveUrlToFile($sUrl, $pDest, $sTmp, $sContentType, $iCode, $this->Logger(), 60, $this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', '')); - + if (!$bResult) { $this->Logger()->Write('Cannot save url to temp file: ', \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER'); @@ -2895,7 +2895,7 @@ class Actions $this->Logger()->Write('Cannot create temp file: '.$sTmp, \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER'); } } - + if ($bResult && '' !== $sTmp) { include_once APP_VERSION_ROOT_PATH.'app/libraries/pclzip/pclzip.lib.php'; @@ -2904,7 +2904,7 @@ class Actions if ('plugin' !== $sType) { $bResult = false; - + $sTmpFolder = APP_PRIVATE_DATA.\md5($sTmp); \mkdir($sTmpFolder); @@ -2970,7 +2970,7 @@ class Actions $this->Logger()->Write('Cannot remove previous plugin folder: '.$sId, \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER'); } } - + if ($bResult) { $bResult = 0 !== $oArchive->extract(PCLZIP_OPT_PATH, APP_PLUGINS_PATH); @@ -2980,27 +2980,27 @@ class Actions } } } - + @\unlink($sTmp); } return $this->DefaultResponse(__FUNCTION__, $bResult ? ('plugin' !== $sType ? array('Reload' => true) : true) : false); } - + /** * @return array */ public function DoAdminPluginList() { $this->IsAdminLoggined(); - + $aResult = array(); - + $sEnabledPlugins = $this->Config()->Get('plugins', 'enabled_list', ''); $aEnabledPlugins = \explode(',', \strtolower($sEnabledPlugins)); $aEnabledPlugins = \array_map('trim', $aEnabledPlugins); - + $aList = $this->Plugins()->InstalledPlugins(); foreach ($aList as $aItem) { @@ -3010,7 +3010,7 @@ class Actions 'Configured' => false ); } - + return $this->DefaultResponse(__FUNCTION__, $aResult); } @@ -3027,7 +3027,7 @@ class Actions } $oConfig = $this->Config(); - + $sEnabledPlugins = $oConfig->Get('plugins', 'enabled_list', ''); $aEnabledPlugins = \explode(',', \strtolower($sEnabledPlugins)); $aEnabledPlugins = \array_map('trim', $aEnabledPlugins); @@ -3061,10 +3061,10 @@ class Actions public function DoAdminPluginDisable() { $this->IsAdminLoggined(); - + $sName = (string) $this->GetActionParam('Name', ''); $bDisable = '1' === (string) $this->GetActionParam('Disabled', '1'); - + if (!$bDisable) { $oPlugin = $this->Plugins()->CreatePluginByName($sName); @@ -3081,17 +3081,17 @@ class Actions return $this->FalseResponse(__FUNCTION__, \RainLoop\Notifications::InvalidPluginPackage); } } - + return $this->DefaultResponse(__FUNCTION__, $this->pluginEnable($sName, !$bDisable)); } - + /** * @return array */ public function DoAdminPluginLoad() { $this->IsAdminLoggined(); - + $mResult = false; $sName = (string) $this->GetActionParam('Name', ''); @@ -3120,27 +3120,27 @@ class Actions { $aItem[0] = APP_DUMMY; } - + $mResult['Config'][] = $aItem; } } } } } - + return $this->DefaultResponse(__FUNCTION__, $mResult); } - + /** * @return array */ public function DoAdminPluginSettingsUpdate() { $this->IsAdminLoggined(); - + $mResult = false; $sName = (string) $this->GetActionParam('Name', ''); - + if (!empty($sName)) { $oPlugin = $this->Plugins()->CreatePluginByName($sName); @@ -3175,7 +3175,7 @@ class Actions $mResultValue = (string) $sValue; break; } - + if (null !== $mResultValue) { $oConfig->Set('plugin', $oItem->Name(), $mResultValue); @@ -3183,16 +3183,16 @@ class Actions } } } - + $mResult = $oConfig->Save(); } } - + if (!$mResult) { throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantSavePluginSettings); } - + return $this->DefaultResponse(__FUNCTION__, true); } @@ -3234,7 +3234,7 @@ class Actions $this->setSettingsFromParams($oSettings, 'MPP', 'int', function ($iValue) { return (int) (\in_array($iValue, array(10, 20, 30, 50, 100, 150, 200, 300)) ? $iValue : 20); }); - + $this->setSettingsFromParams($oSettings, 'Layout', 'int', function ($iValue) { return (int) (\in_array((int) $iValue, array(\RainLoop\Enumerations\Layout::NO_PREVIW, \RainLoop\Enumerations\Layout::SIDE_PREVIEW, \RainLoop\Enumerations\Layout::BOTTOM_PREVIEW)) ? @@ -3263,13 +3263,13 @@ class Actions $this->setSettingsFromParams($oSettings, 'EnableTwoFactor', 'bool'); $this->setSettingsFromParams($oSettings, 'CustomThemeImg', 'string'); - + if ('' === $oSettings->GetConf('CustomThemeImg', '')) { - $this->StorageProvider()->Clear($oAccount, + $this->StorageProvider()->Clear($oAccount, \RainLoop\Providers\Storage\Enumerations\StorageType::USER, 'CustomThemeBackground'); } - + return $this->DefaultResponse(__FUNCTION__, $this->SettingsProvider()->Save($oAccount, $oSettings)); } @@ -3402,7 +3402,7 @@ class Actions /** * @staticvar array $aCache * @param \RainLoop\Account $oAccount - * + * * @return array */ private function systemFoldersNames($oAccount) @@ -3411,7 +3411,7 @@ class Actions if (null === $aCache) { $aCache = array( - + 'Sent' => \MailSo\Imap\Enumerations\FolderType::SENT, 'Send' => \MailSo\Imap\Enumerations\FolderType::SENT, @@ -3443,7 +3443,7 @@ class Actions 'Bin' => \MailSo\Imap\Enumerations\FolderType::TRASH, 'Archive' => \MailSo\Imap\Enumerations\FolderType::ARCHIVE, - + 'All' => \MailSo\Imap\Enumerations\FolderType::ARCHIVE, 'All Mail' => \MailSo\Imap\Enumerations\FolderType::ARCHIVE, 'All Mails' => \MailSo\Imap\Enumerations\FolderType::ARCHIVE, @@ -3551,7 +3551,7 @@ class Actions if ($oFolderCollection instanceof \MailSo\Mail\FolderCollection) { $aSystemFolders = array(); - + $this->recFoldersTypes($oAccount, $oFolderCollection, $aSystemFolders); $oFolderCollection->SystemFolders = $aSystemFolders; @@ -3712,7 +3712,7 @@ class Actions return $this->TrueResponse(__FUNCTION__); } - + /** * @return array * @@ -3871,7 +3871,7 @@ class Actions { // sleep(5); // throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList); - + $sFolder = ''; $iOffset = 0; $iLimit = 20; @@ -3924,7 +3924,7 @@ class Actions if (0 < \strlen($sExpandedThreadUid)) { $aExpandedThreadUid = \explode(',', $sExpandedThreadUid); - + $aExpandedThreadUid = \array_map(function ($sValue) { $sValue = \trim($sValue); return is_numeric($sValue) ? (int) $sValue : 0; @@ -3934,7 +3934,7 @@ class Actions return 0 < $iValue; }); } - + $oMessageList = $this->MailClient()->MessageList( $sFolder, $iOffset, $iLimit, $sSearch, $sUidNext, ($this->Config()->Get('cache', 'enable', true) && $this->Config()->Get('cache', 'server_uids', false)) ? $this->Cacher() : null, @@ -3981,7 +3981,7 @@ class Actions $oMessage = \MailSo\Mime\Message::NewInstance(); $oMessage->RegenerateMessageId(); - + $oMessage->SetXMailer('RainLoop/'.APP_VERSION); $oSettings = $this->SettingsProvider()->Load($oAccount); @@ -3994,7 +3994,7 @@ class Actions { $sDisplayName = \trim($oSettings->GetConf('DisplayName', '')); $sReplyTo = \trim($oSettings->GetConf('ReplyTo', '')); - + $oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oAccount->Email(), $sDisplayName)); if (!empty($sReplyTo)) @@ -4013,7 +4013,7 @@ class Actions } $oMessage->SetSubject($sSubject); - + $oToEmails = \MailSo\Mime\EmailCollection::NewInstance($sTo); if ($oToEmails && $oToEmails->Count()) { @@ -4056,7 +4056,7 @@ class Actions $this->Plugins()->RunHook($bTextIsHtml ? 'filter.message-html' : 'filter.message-plain', array($oAccount, &$oMessage, &$sTextToAdd)); - + if ($bTextIsHtml && 0 < \strlen($sTextToAdd)) { $sTextConverted = \MailSo\Base\HtmlUtils::ConvertHtmlToPlain($sTextToAdd); @@ -4105,7 +4105,7 @@ class Actions { $sFileName = \preg_replace('/[^a-z0-9]+/i', '.', $aMatch[1]); $rResource = \MailSo\Base\ResourceRegistry::CreateMemoryResourceFromString($sRaw); - + $sRaw = ''; unset($sRaw); unset($aMatch); @@ -4212,7 +4212,7 @@ class Actions if (false !== $iMessageStreamSize) { $sMessageId = $oMessage->MessageId(); - + rewind($rMessageStream); $iNewUid = 0; @@ -4398,7 +4398,7 @@ class Actions if (false !== $iMessageStreamSize) { $this->smtpSendMessage($oAccount, $oMessage, $rMessageStream); - + if (is_array($aDraftInfo) && 3 === count($aDraftInfo)) { $sDraftInfoType = $aDraftInfo[0]; @@ -4521,7 +4521,7 @@ class Actions if (0 < \count($aArrayToFrec)) { $oSettings = $this->SettingsProvider()->Load($oAccount); - + $this->AddressBookProvider($oAccount)->IncFrec( $oAccount->ParentEmailHelper(), \array_values($aArrayToFrec), !!$oSettings->GetConf('ContactsAutosave', true)); } @@ -4621,7 +4621,7 @@ class Actions private function getContactsSyncData($oAccount) { $mResult = null; - + $sData = $this->StorageProvider()->Get($oAccount->ParentEmailHelper(), \RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG, 'contacts_sync' @@ -4650,7 +4650,7 @@ class Actions public function DoSaveContactsSyncData() { $oAccount = $this->getAccountFromToken(); - + $oAddressBookProvider = $this->AddressBookProvider($oAccount); if (!$oAddressBookProvider || !$oAddressBookProvider->IsActive()) { @@ -4678,7 +4678,7 @@ class Actions return $this->DefaultResponse(__FUNCTION__, $bResult); } - + /** * @return array */ @@ -4710,7 +4710,7 @@ class Actions private function getTwoFactorInfo($sEmail, $bRemoveSecret = false) { $mData = null; - + $aResult = array( 'User' => '', 'IsSet' => false, @@ -4772,7 +4772,7 @@ class Actions /** * @param string $sEmail * @param string $sCode - * + * * @return bool */ private function removeBackupCodeFromTwoFactorInfo($sEmail, $sCode) @@ -4795,7 +4795,7 @@ class Actions { $sBackupCodes = \preg_replace('/[^\d]+/', ' ', ' '.$mData['BackupCodes'].' '); $sBackupCodes = \str_replace(' '.$sCode.' ', '', $sBackupCodes); - + $mData['BackupCodes'] = \trim(\preg_replace('/[^\d]+/', ' ', $sBackupCodes)); return $this->StorageProvider()->Put(null, @@ -4820,7 +4820,7 @@ class Actions } $oAccount = $this->getAccountFromToken(); - + return $this->DefaultResponse(__FUNCTION__, $this->getTwoFactorInfo($oAccount->ParentEmailHelper(), true)); } @@ -4834,7 +4834,7 @@ class Actions { return $this->FalseResponse(__FUNCTION__); } - + $oAccount = $this->getAccountFromToken(); $sEmail = $oAccount->ParentEmailHelper(); @@ -4912,7 +4912,7 @@ class Actions )) ); } - + return $this->DefaultResponse(__FUNCTION__, $bResult); } @@ -4965,7 +4965,7 @@ class Actions public function DoContacts() { $oAccount = $this->getAccountFromToken(); - + $sSearch = \trim($this->GetActionParam('Search', '')); $iOffset = (int) $this->GetActionParam('Offset', 0); $iLimit = (int) $this->GetActionParam('Limit', 20); @@ -4973,11 +4973,17 @@ class Actions $iLimit = 0 > $iLimit ? 20 : $iLimit; $iResultCount = 0; - if ($this->AddressBookProvider($oAccount)->IsActive()) + $mResult = array(); + $aTags = array(); + + $oAbp = $this->AddressBookProvider($oAccount); + if ($oAbp->IsActive()) { $iResultCount = 0; - $mResult = $this->AddressBookProvider($oAccount)->GetContacts($oAccount->ParentEmailHelper(), + $mResult = $oAbp->GetContacts($oAccount->ParentEmailHelper(), $iOffset, $iLimit, $sSearch, $iResultCount); + + $aTags = $oAbp->GetContactTags($oAccount->ParentEmailHelper()); } return $this->DefaultResponse(__FUNCTION__, array( @@ -4985,10 +4991,30 @@ class Actions 'Limit' => $iLimit, 'Count' => $iResultCount, 'Search' => $sSearch, + 'List' => $mResult, + 'Tags' => $aTags + )); + } + + + /** + * @return array + */ + public function DoContactTags() + { + $oAccount = $this->getAccountFromToken(); + + $mResult = false; + if ($this->AddressBookProvider($oAccount)->IsActive()) + { + $mResult = $this->AddressBookProvider($oAccount)->GetContactTags($oAccount->ParentEmailHelper()); + } + + return $this->DefaultResponse(__FUNCTION__, array( 'List' => $mResult )); } - + /** * @return array */ @@ -5025,6 +5051,11 @@ class Actions if ($oAddressBookProvider && $oAddressBookProvider->IsActive() && 0 < \strlen($sRequestUid)) { $sUid = \trim($this->GetActionParam('Uid', '')); + $sTags = \trim($this->GetActionParam('Tags', '')); + $aTags = \explode(';', $sTags); + $aTags = \array_map('trim', $aTags); + $aTags = \array_unique($aTags); + $oContact = null; if (0 < \strlen($sUid)) { @@ -5039,7 +5070,8 @@ class Actions $oContact->IdContact = $sUid; } } - + + $oContact->Tags = $aTags; $oContact->Properties = array(); $aProperties = $this->GetActionParam('Properties', array()); if (\is_array($aProperties)) @@ -5084,9 +5116,9 @@ class Actions $iLimit = (int) $this->Config()->Get('contacts', 'suggestions_limit', 20); $aResult = array(); - + $this->Plugins()->RunHook('ajax.suggestions-input-parameters', array(&$sQuery, &$iLimit, $oAccount)); - + $iLimit = (int) $iLimit; if (5 > $iLimit) { @@ -5322,7 +5354,7 @@ class Actions { $this->MailClient()->MessageMove($sFromFolder, $sToFolder, $aFilteredUids, true, $this->Config()->Get('labs', 'use_imap_move', true)); - + $sHash = $this->MailClient()->FolderHash($sFromFolder); } catch (\Exception $oException) @@ -5521,7 +5553,7 @@ class Actions $oAccount = $this->getAccountFromToken(); return $this->DefaultResponse(__FUNCTION__, $this->Social()->GoogleDisconnect($oAccount)); } - + /** * @return array */ @@ -5676,7 +5708,7 @@ class Actions $iCount = 0; $aHeaders = null; $aData = array(); - + if ($oAccount && \is_resource($rFile)) { $oAddressBookProvider = $this->AddressBookProvider($oAccount); @@ -5755,7 +5787,7 @@ class Actions return $iCount; } - + /** * @return array */ @@ -5769,7 +5801,7 @@ class Actions $iError = UploadError::UNKNOWN; $iSizeLimit = ((int) $oConfig->Get('webmail', 'attachment_size_limit', 0)) * 1024 * 1024; - + if ($oAccount) { $oAddressBookProvider = $this->AddressBookProvider($oAccount); @@ -5842,7 +5874,7 @@ class Actions { $iClientError = UploadClientError::NORMAL; $sError = $this->getUploadErrorMessageByCode($iError, $iClientError); - + if (!empty($sError)) { return $this->FalseResponse(__FUNCTION__, $iClientError, $sError); @@ -5935,7 +5967,7 @@ class Actions header('Last-Modified: '.\gmdate('D, d M Y H:i:s', $iLast).' UTC', true); header('Expires: '.\gmdate('D, j M Y H:i:s', $iExpires).' UTC', true); header('Connection: close'); - + $bResult = true; } @@ -5962,7 +5994,7 @@ class Actions } } } - + /** * @param bool $bDownload * @@ -6051,7 +6083,7 @@ class Actions \header('Content-Transfer-Encoding: binary'); $this->oHttp->ServerNoCache(); - + return $this->AddressBookProvider($oAccount)->IsActive() ? $this->AddressBookProvider($oAccount)->Export($oAccount->ParentEmailHelper(), 'vcf') : false; } @@ -6086,8 +6118,8 @@ class Actions } $oAccount = $this->getAccountFromToken(); - - $sData = $this->StorageProvider()->Get($oAccount, + + $sData = $this->StorageProvider()->Get($oAccount, \RainLoop\Providers\Storage\Enumerations\StorageType::USER, 'contacts/'.$sRawKey); if ($sData) { @@ -6106,7 +6138,7 @@ class Actions return true; } } - + return false; } @@ -6278,14 +6310,14 @@ class Actions $sList[] = $sFile.'@custom'; } } - + @\closedir($rDirH); } } $sList = \array_unique($sList); \sort($sList); - + if ($bDefault) { \array_unshift($sList, 'Default'); @@ -6519,7 +6551,7 @@ class Actions $aAdditionalParams['ErrorCode'] = (int) $iErrorCode; $aAdditionalParams['ErrorMessage'] = null === $sErrorMessage ? '' : (string) $sErrorMessage; } - + $aResponseItem = $this->mainDefaultResponse($sActionName, $mResult, $aAdditionalParams); $this->Plugins()->RunHook('main.default-response', array($sActionName, &$aResponseItem)); @@ -6670,7 +6702,7 @@ class Actions */ private function hashFolderFullName($sFolderFullName) { - return \in_array(\strtolower($sFolderFullName), array('inbox', 'sent', 'send', 'drafts', + return \in_array(\strtolower($sFolderFullName), array('inbox', 'sent', 'send', 'drafts', 'spam', 'junk', 'bin', 'trash', 'archive', 'allmail')) ? \ucfirst(\strtolower($sFolderFullName)) : \md5($sFolderFullName); @@ -6749,7 +6781,7 @@ class Actions $bHook = true; $sClassName = \get_class($mResponse); $bHasSimpleJsonFunc = \method_exists($mResponse, 'ToSimpleJSON'); - + if ($bHasSimpleJsonFunc) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), $mResponse->ToSimpleJSON()); @@ -6823,7 +6855,7 @@ class Actions $sForwardedFlag = $this->Config()->Get('labs', 'imap_forwarded_flag', ''); $sReadReceiptFlag = $this->Config()->Get('labs', 'imap_read_receipt_flag', ''); - + $mResult['IsForwarded'] = 0 < \strlen($sForwardedFlag) && \in_array(\strtolower($sForwardedFlag), $aFlags); $mResult['IsReadReceipt'] = 0 < \strlen($sReadReceiptFlag) && \in_array(\strtolower($sReadReceiptFlag), $aFlags); @@ -6855,7 +6887,7 @@ class Actions $sPlain = ''; $sHtml = \trim($mResponse->Html()); $bRtl = false; - + if (0 === \strlen($sHtml)) { $sPlain = \trim($mResponse->Plain()); @@ -6933,9 +6965,19 @@ class Actions 'Display' => \MailSo\Base\Utils::Utf8Clear($mResponse->Display), 'ReadOnly' => $mResponse->ReadOnly, 'IdPropertyFromSearch' => $mResponse->IdPropertyFromSearch, + 'Tags' => $this->responseObject($mResponse->Tags, $sParent, $aParameters), 'Properties' => $this->responseObject($mResponse->Properties, $sParent, $aParameters) )); } + else if ('RainLoop\Providers\AddressBook\Classes\Tag' === $sClassName) + { + $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array( + /* @var $mResponse \RainLoop\Providers\AddressBook\Classes\Tag */ + 'IdContactTag' => $mResponse->IdContactTag, + 'Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->Name), + 'ReadOnly' => $mResponse->ReadOnly + )); + } else if ('RainLoop\Providers\AddressBook\Classes\Property' === $sClassName) { // Simple hack @@ -6959,7 +7001,7 @@ class Actions $mFoundedCIDs = isset($aParameters['FoundedCIDs']) && \is_array($aParameters['FoundedCIDs']) && 0 < \count($aParameters['FoundedCIDs']) ? $aParameters['FoundedCIDs'] : null; - + $mFoundedContentLocationUrls = isset($aParameters['FoundedContentLocationUrls']) && \is_array($aParameters['FoundedContentLocationUrls']) && 0 < \count($aParameters['FoundedContentLocationUrls']) ? @@ -7065,7 +7107,7 @@ class Actions { $aList = \array_slice($aList, 0, 100); } - + $mResult = $this->responseObject($aList, $sParent, $aParameters); $bHook = false; } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Common/PdoAbstract.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Common/PdoAbstract.php index 1e2738bf1..fbbd6ea4b 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Common/PdoAbstract.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Common/PdoAbstract.php @@ -23,7 +23,7 @@ abstract class PdoAbstract * @var string */ protected $sDbType; - + /** * @return bool */ @@ -67,7 +67,7 @@ abstract class PdoAbstract { return $this->oPDO; } - + if (!\class_exists('PDO')) { throw new \Exception('Class PDO does not exist'); @@ -100,7 +100,7 @@ abstract class PdoAbstract { throw $oException; } - + if ($oPdo) { $this->oPDO = $oPdo; @@ -127,7 +127,7 @@ abstract class PdoAbstract { $mName = \strtolower($sTabelName.'_'.$sColumnName.'_seq'); } - + return null === $mName ? $this->getPDO()->lastInsertId() : $this->getPDO()->lastInsertId($mName); } @@ -222,15 +222,15 @@ abstract class PdoAbstract $mResult->closeCursor(); } } - + /** - * @param string $sSql + * @param mixed $mData */ - protected function writeLog($sSql) + protected function writeLog($mData) { if ($this->oLogger) { - $this->oLogger->WriteMixed($sSql, \MailSo\Log\Enumerations\Type::INFO, 'SQL'); + $this->oLogger->WriteMixed($mData, \MailSo\Log\Enumerations\Type::INFO, 'SQL'); } } @@ -324,7 +324,7 @@ abstract class PdoAbstract } $this->writeLog($sQuery); - + $oStmt = $oPdo->prepare($sQuery); if ($oStmt->execute(array($sName))) { @@ -355,7 +355,7 @@ abstract class PdoAbstract /** * @param string $sName * @param int $iVersion - * + * * @return bool */ protected function setVersion($sName, $iVersion) @@ -371,7 +371,7 @@ abstract class PdoAbstract $sQuery = 'DELETE FROM rainloop_system WHERE sys_name = ? AND value_int <= ?;'; $this->writeLog($sQuery); - + $oStmt = $oPdo->prepare($sQuery); $bResult = !!$oStmt->execute(array($sName.'_version', $iVersion)); if ($bResult) @@ -507,7 +507,7 @@ rl_email text NOT NULL DEFAULT \'\' { $oPdo->rollBack(); } - + throw $oException; } } @@ -550,7 +550,7 @@ rl_email text NOT NULL DEFAULT \'\' { $oPdo = false; $bResult = false; - + foreach ($aData as $iVersion => $aQuery) { if (0 === \count($aQuery)) @@ -580,7 +580,7 @@ rl_email text NOT NULL DEFAULT \'\' if (false === $bExec) { $this->writeLog('Result: false'); - + $bResult = false; break; } @@ -605,7 +605,7 @@ rl_email text NOT NULL DEFAULT \'\' { $oPdo->rollBack(); } - + throw $oException; } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook.php index a088c8bba..dece0dc9f 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook.php @@ -85,7 +85,7 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider { return $this->IsActive() ? $this->oDriver->Export($sEmail, $sType) : false; } - + /** * @param string $sEmail * @param \RainLoop\Providers\AddressBook\Classes\Contact $oContact @@ -123,6 +123,16 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider $iOffset, $iLimit, $sSearch, $iResultCount) : array(); } + /** + * @param string $sEmail + * + * @return array + */ + public function GetContactTags($sEmail) + { + return $this->IsActive() ? $this->oDriver->GetContactTags($sEmail) : array(); + } + /** * @param string $sEmail * @param string $mID @@ -238,7 +248,7 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider $aMap = \array_change_key_case($aMap, CASE_LOWER); } - + $sCsvNameLower = \MailSo\Base\Utils::IsAscii($sCsvName) ? \preg_replace('/[\s\-]+/', '', \strtolower($sCsvName)) : ''; return !empty($sCsvNameLower) && isset($aMap[$sCsvNameLower]) ? $aMap[$sCsvNameLower] : PropertyType::UNKNOWN; } @@ -258,7 +268,7 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider foreach ($aCsvData as $aItem) { \MailSo\Base\Utils::ResetTimeLimit(); - + foreach ($aItem as $sItemName => $sItemValue) { $sItemName = \trim($sItemName); @@ -294,10 +304,10 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider unset($oContact); } - + return $iCount; } - + /** * @param string $sEmail * @param string $sVcfData @@ -336,14 +346,14 @@ class AddressBook extends \RainLoop\Providers\AbstractProvider if ($oVCard instanceof \Sabre\VObject\Component\VCard) { \MailSo\Base\Utils::ResetTimeLimit(); - + if (empty($oVCard->UID)) { $oVCard->UID = \Sabre\DAV\UUIDUtil::getUUID(); } $oContact->PopulateByVCard($oVCard->serialize()); - + if (0 < \count($oContact->Properties)) { if ($this->ContactSave($sEmail, $oContact)) diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php index ed0df1f7a..7691f903d 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Contact.php @@ -37,6 +37,11 @@ class Contact /** * @var array */ + public $Tags; + + /** + * @var bool + */ public $ReadOnly; /** @@ -58,15 +63,15 @@ class Contact { $this->IdContact = ''; $this->IdContactStr = ''; - $this->IdUser = 0; $this->Display = ''; $this->Changed = \time(); $this->Properties = array(); + $this->Tags = array(); $this->ReadOnly = false; $this->IdPropertyFromSearch = 0; $this->Etag = ''; } - + public function UpdateDependentValues() { $sLastName = ''; @@ -75,7 +80,7 @@ class Contact $sOther = ''; $oFullNameProperty = null; - + foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\AddressBook\Classes\Property */ &$oProperty) { if ($oProperty) @@ -133,7 +138,7 @@ class Contact } $this->Display = \trim($sDisplay); - + if ($oFullNameProperty) { $oFullNameProperty->Value = $this->Display; @@ -200,7 +205,7 @@ class Contact { $oVCard = new \Sabre\VObject\Component\VCard(); } - + $oVCard->VERSION = '3.0'; $oVCard->PRODID = '-//RainLoop//'.APP_VERSION.'//EN'; @@ -482,7 +487,7 @@ class Contact public function PopulateByVCard($sVCard, $sEtag = '') { $this->Properties = array(); - + if (!empty($sEtag)) { $this->Etag = $sEtag; diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Tag.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Tag.php new file mode 100644 index 000000000..d417e0963 --- /dev/null +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/Classes/Tag.php @@ -0,0 +1,33 @@ +Clear(); + } + + public function Clear() + { + $this->IdContactTag = ''; + $this->Name = ''; + $this->ReadOnly = false; + } +} diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php index 8ca30617b..0c35b35ef 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/AddressBook/PdoAddressBook.php @@ -17,7 +17,7 @@ class PdoAddressBook * @var string */ private $sDsnType; - + /** * @var string */ @@ -73,7 +73,7 @@ class PdoAddressBook ) ); } - + private function prepearDatabaseSyncData($iUserID) { $aResult = array(); @@ -122,7 +122,7 @@ class PdoAddressBook { $this->oLogger->WriteException($oException); } - + if (\is_array($aResponse)) { $mResult = array(); @@ -159,7 +159,7 @@ class PdoAddressBook private function davClientRequest($oClient, $sCmd, $sUrl, $mData = null) { \MailSo\Base\Utils::ResetTimeLimit(); - + $this->oLogger->Write($sCmd.' '.$sUrl.('PUT' === $sCmd && null !== $mData ? ' ('.\strlen($mData).')' : ''), \MailSo\Log\Enumerations\Type::INFO, 'DAV'); @@ -183,7 +183,7 @@ class PdoAddressBook { $this->oLogger->WriteException($oException); } - + return $oResponse; } @@ -199,13 +199,13 @@ class PdoAddressBook public function Sync($sEmail, $sUrl, $sUser, $sPassword, $sProxy = '') { $this->SyncDatabase(); - + $iUserID = $this->getUserId($sEmail); if (0 >= $iUserID) { return false; } - + $aUrl = \parse_url($sUrl); if (!\is_array($aUrl)) { @@ -233,6 +233,9 @@ class PdoAddressBook $oClient = new \Sabre\DAV\Client($aSettings); $oClient->setVerifyPeer(false); + $this->oLogger->AddSecret($sPassword); + $this->oLogger->Write('User: '.$aSettings['userName'].', Url: '.$sUrl, \MailSo\Log\Enumerations\Type::INFO, 'DAV'); + $aRemoteSyncData = $this->prepearRemoteSyncData($oClient, $sPath); if (false === $aRemoteSyncData) { @@ -276,7 +279,7 @@ class PdoAddressBook //+++new or newer (from db) foreach ($aDatabaseSyncData as $sKey => $aData) { - if (!$aData['deleted'] && + if (!$aData['deleted'] && (empty($aData['etag']) && !isset($aRemoteSyncData[$sKey])) // new || (!empty($aData['etag']) && isset($aRemoteSyncData[$sKey]) && // newer @@ -302,7 +305,7 @@ class PdoAddressBook $oResponse = $this->davClientRequest($oClient, 'PUT', $sPath.$oContact->CardDavNameUri(), $oContact->ToVCard($sExsistensBody)); - + if ($oResponse && isset($oResponse['headers'], $oResponse['headers']['etag'])) { $sEtag = \trim(\trim($oResponse['headers']['etag']), '"\''); @@ -314,7 +317,7 @@ class PdoAddressBook } } } - + unset($oContact); } } @@ -348,7 +351,7 @@ class PdoAddressBook { $oContact = new \RainLoop\Providers\AddressBook\Classes\Contact(); } - + $oContact->PopulateByVCard($sBody, !empty($oResponse['headers']['etag']) ? \trim(\trim($oResponse['headers']['etag']), '"\'') : ''); @@ -421,16 +424,16 @@ class PdoAddressBook { $this->SyncDatabase(); } - + $iUserID = $this->getUserId($sEmail); - + $iIdContact = 0 < \strlen($oContact->IdContact) && \is_numeric($oContact->IdContact) ? (int) $oContact->IdContact : 0; $bUpdate = 0 < $iIdContact; $oContact->UpdateDependentValues(); $oContact->Changed = \time(); - + try { if ($this->isTransactionSupported()) @@ -465,6 +468,14 @@ class PdoAddressBook ':id_contact' => array($iIdContact, \PDO::PARAM_INT) ) ); + + // clear previos tags + $this->prepareAndExecute( + 'DELETE FROM rainloop_ab_tags_contacts WHERE id_contact = :id_contact', + array( + ':id_contact' => array($iIdContact, \PDO::PARAM_INT) + ) + ); } else { @@ -517,6 +528,44 @@ class PdoAddressBook '(:id_contact, :id_user, :prop_type, :prop_type_str, :prop_value, :prop_value_custom, :prop_frec)'; $this->prepareAndExecute($sSql, $aParams, true); + + $aTags = array(); + $aContactTags = $this->GetContactTags($sEmail); + + $fFindFunc = function ($sName) use ($aContactTags) { + + $iResult = 0; + foreach ($aContactTags as $oItem) + { + if ($oItem && $oItem->Name === $sName) + { + $iResult = (int) $oItem->IdContactTag; + break; + } + } + + return $iResult; + }; + + foreach ($oContact->Tags as $sTagName) + { + $iTagID = $fFindFunc($sTagName); + if (0 >= $iTagID) + { + $iTagID = $this->CreateTag($sEmail, $sTagName, false); + } + + if (\is_int($iTagID) && 0 < $iTagID) + { + $aTags[] = array( + ':id_tag' => array($iTagID, \PDO::PARAM_INT), + ':id_contact' => array($iIdContact, \PDO::PARAM_INT) + ); + } + } + + $sSql = 'INSERT INTO rainloop_ab_tags_contacts (id_tag, id_contact) VALUES (:id_tag, :id_contact)'; + $this->prepareAndExecute($sSql, $aTags, true); } } catch (\Exception $oException) @@ -537,6 +586,64 @@ class PdoAddressBook return 0 < $iIdContact; } + /** + * @param string $sEmail + * @param string $sName + * @param bool $bSyncDb = true + * + * @return bool|int + */ + public function CreateTag($sEmail, $sName, $bSyncDb = true) + { + if ($bSyncDb) + { + $this->SyncDatabase(); + } + + $iUserID = $this->getUserId($sEmail); + + $mResult = false; + try + { + if ($this->isTransactionSupported()) + { + $this->beginTransaction(); + } + + $sSql = 'INSERT INTO rainloop_ab_tags '. + '(id_user, tag_name) VALUES (:id_user, :tag_name)'; + + $this->prepareAndExecute($sSql, + array( + ':id_user' => array($iUserID, \PDO::PARAM_INT), + ':tag_name' => array($sName, \PDO::PARAM_STR) + ) + ); + + $sLast = $this->lastInsertId('rainloop_ab_contacts', 'id_contact'); + if (\is_numeric($sLast) && 0 < (int) $sLast) + { + $mResult = (int) $sLast; + } + } + catch (\Exception $oException) + { + if ($this->isTransactionSupported()) + { + $this->rollBack(); + } + + throw $oException; + } + + if ($this->isTransactionSupported()) + { + $this->commit(); + } + + return $mResult; + } + /** * @param string $sEmail * @param array $aContactIds @@ -615,7 +722,7 @@ class PdoAddressBook * @param int $iLimit = 20 * @param string $sSearch = '' * @param int $iResultCount = 0 - * + * * @return array */ public function GetContacts($sEmail, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0) @@ -631,7 +738,7 @@ class PdoAddressBook $iCount = 0; $aSearchIds = array(); $aPropertyFromSearchIds = array(); - + if (0 < \strlen($sSearch)) { $sCustomSearch = $this->specialConvertSearchValueCustomPhone($sSearch); @@ -645,7 +752,7 @@ class PdoAddressBook PropertyType::EMAIl, PropertyType::FIRST_NAME, PropertyType::LAST_NAME, PropertyType::NICK_NAME, PropertyType::PHONE, PropertyType::WEB_PAGE )); - + $sSql = 'SELECT id_user, id_prop, id_contact FROM rainloop_ab_properties '. 'WHERE (id_user = :id_user) AND prop_type IN ('.$sSearchTypes.') AND (prop_value LIKE :search ESCAPE \'=\''. (0 < \strlen($sCustomSearch) ? ' OR (prop_type = '.PropertyType::PHONE.' AND prop_value_custom <> \'\' AND prop_value_custom LIKE :search_custom_phone)' : ''). @@ -686,7 +793,7 @@ class PdoAddressBook { $sSql = 'SELECT COUNT(DISTINCT id_contact) as contact_count FROM rainloop_ab_properties '. 'WHERE id_user = :id_user'; - + $aParams = array( ':id_user' => array($iUserID, \PDO::PARAM_INT) ); @@ -704,10 +811,11 @@ class PdoAddressBook $iResultCount = $iCount; + $aResult = array(); if (0 < $iCount) { $sSql = 'SELECT * FROM rainloop_ab_contacts WHERE deleted = 0 AND id_user = :id_user'; - + $aParams = array( ':id_user' => array($iUserID, \PDO::PARAM_INT) ); @@ -794,13 +902,136 @@ class PdoAddressBook $oItem->UpdateDependentValues(); } - return \array_values($aContacts); + $aResult = \array_values($aContacts); } } } } - return array(); + if (\is_array($aResult) && 0 < \count($aResult)) + { + $aIdContacts = array(); + $aIdTagsContacts = array(); + $aTags = $this->GetContactTags($sEmail); + + if (\is_array($aTags) && 0 < \count($aTags)) + { + foreach ($aResult as $oItem) + { + $aIdContacts[$oItem->IdContact] = true; + } + + if (0 < \count($aIdContacts)) + { + $sSql = 'SELECT id_tag, id_contact FROM rainloop_ab_tags_contacts WHERE id_contact IN ('.\implode(',', \array_keys($aIdContacts)).')'; + $oStmt = $this->prepareAndExecute($sSql); + + if ($oStmt) + { + $aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC); + if (\is_array($aFetch) && 0 < \count($aFetch)) + { + foreach ($aFetch as $aItem) + { + if ($aItem && isset($aItem['id_tag'], $aItem['id_contact'])) + { + $sID = (string) $aItem['id_contact']; + if (!isset($aIdTagsContacts[$sID])) + { + $aIdTagsContacts[$sID] = array(); + } + + $aIdTagsContacts[$sID][] = (string) $aItem['id_tag']; + } + } + } + + unset($aFetch); + } + + if (0 < \count($aIdTagsContacts)) + { + $fFindFunc = function ($sID) use ($aTags) { + + foreach ($aTags as $oItem) + { + if ($oItem && (string) $oItem->IdContactTag === $sID) + { + return\trim($oItem->Name); + } + } + + return ''; + }; + + foreach ($aResult as &$oItem) + { + $sID = $oItem ? (string) $oItem->IdContact : ''; + if (0 < \strlen($sID) && isset($aIdTagsContacts[$sID]) && \is_array($aIdTagsContacts[$sID])) + { + $aNames = array(); + foreach ($aIdTagsContacts[$sID] as $sSubID) + { + $sName = $fFindFunc($sSubID); + if (0 < \strlen($sName)) + { + $aNames[] = $sName; + } + } + + $oItem->Tags = $aNames; + } + } + } + } + } + } + + return $aResult; + } + + /** + * @param string $sEmail + * + * @return array + */ + public function GetContactTags($sEmail) + { + $this->SyncDatabase(); + + $iUserID = $this->getUserId($sEmail); + + $sSql = 'SELECT id_tag, id_user, tag_name FROM rainloop_ab_tags WHERE id_user = :id_user ORDER BY tag_name ASC'; + + $aParams = array( + ':id_user' => array($iUserID, \PDO::PARAM_INT) + ); + + $aResult = array(); + $oStmt = $this->prepareAndExecute($sSql, $aParams); + if ($oStmt) + { + $aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC); + if (\is_array($aFetch) && 0 < \count($aFetch)) + { + foreach ($aFetch as $aItem) + { + $iIdContactTag = $aItem && isset($aItem['id_tag']) ? (int) $aItem['id_tag'] : 0; + if (0 < $iIdContactTag) + { + $oContactTag = new \RainLoop\Providers\AddressBook\Classes\Tag(); + + $oContactTag->IdContactTag = (string) $iIdContactTag; + $oContactTag->Name = isset($aItem['tag_name']) ? (string) $aItem['tag_name'] : ''; + $oContactTag->ReadOnly = $iUserID !== (isset($aItem['id_user']) ? (int) $aItem['id_user'] : 0); + + $aResult[] = $oContactTag; + } + } + } + } + + return $aResult; } /** @@ -924,7 +1155,7 @@ class PdoAddressBook } $this->SyncDatabase(); - + $iUserID = $this->getUserId($sEmail); $sTypes = implode(',', array( @@ -933,7 +1164,7 @@ class PdoAddressBook $sSql = 'SELECT id_contact, id_prop, prop_type, prop_value FROM rainloop_ab_properties '. 'WHERE (id_user = :id_user) AND prop_type IN ('.$sTypes.') AND prop_value LIKE :search ESCAPE \'=\''; - + $aParams = array( ':id_user' => array($iUserID, \PDO::PARAM_INT), ':limit' => array($iLimit, \PDO::PARAM_INT), @@ -944,7 +1175,7 @@ class PdoAddressBook $sSql .= ' LIMIT :limit'; $aResult = array(); - + $oStmt = $this->prepareAndExecute($sSql, $aParams); if ($oStmt) { @@ -960,7 +1191,7 @@ class PdoAddressBook $iIdContact = $aItem && isset($aItem['id_contact']) ? (int) $aItem['id_contact'] : 0; $iIdProp = $aItem && isset($aItem['id_prop']) ? (int) $aItem['id_prop'] : 0; $iType = $aItem && isset($aItem['prop_type']) ? (int) $aItem['prop_type'] : 0; - + if (0 < $iIdContact && 0 < $iIdProp) { $aIdContacts[$iIdContact] = $iIdContact; @@ -985,7 +1216,7 @@ class PdoAddressBook if (0 < count($aIdContacts)) { $oStmt->closeCursor(); - + $sTypes = \implode(',', array( PropertyType::EMAIl, PropertyType::FIRST_NAME, PropertyType::LAST_NAME, PropertyType::NICK_NAME )); @@ -1042,10 +1273,10 @@ class PdoAddressBook { $bName = \in_array(PropertyType::FIRST_NAME, $aContactAllAccess[$iId]) || \in_array(PropertyType::LAST_NAME, $aContactAllAccess[$iId]); $bNick = \in_array(PropertyType::NICK_NAME, $aContactAllAccess[$iId]); - + $aNameItem = isset($aNames[$iId]) && \is_array($aNames[$iId]) ? $aNames[$iId] : array('', ''); $sNameItem = \trim($aNameItem[0].' '.$aNameItem[1]); - + $sNickItem = isset($aNicks[$iId]) ? $aNicks[$iId] : ''; foreach ($aItems as $sEmail) @@ -1054,7 +1285,7 @@ class PdoAddressBook { $aResult[] = array($sEmail, $sNameItem); } - + if ($bNick) { $aResult[] = array($sEmail, $sNickItem); @@ -1089,7 +1320,7 @@ class PdoAddressBook { $aResult = \array_slice($aResult, 0, $iLimit); } - + return $aResult; } } @@ -1121,7 +1352,7 @@ class PdoAddressBook $aEmailsObjects = \array_filter($aEmailsObjects, function ($oItem) { return !!$oItem; }); - + if (0 === \count($aEmailsObjects)) { throw new \InvalidArgumentException('Empty Emails argument'); @@ -1156,7 +1387,7 @@ class PdoAddressBook } } } - + $aEmailsToCreate = \array_filter($aEmailsObjects, function ($oItem) use ($aExists, &$aEmailsToUpdate) { if ($oItem) { @@ -1185,7 +1416,7 @@ class PdoAddressBook } } } - + unset($aEmails, $aEmailsObjects); if (0 < \count($aEmailsToCreate)) @@ -1225,7 +1456,7 @@ class PdoAddressBook $oContact->Properties[] = $oPropName; } - + if (0 < \strlen($sLast)) { $oPropName = new \RainLoop\Providers\AddressBook\Classes\Property(); @@ -1240,17 +1471,17 @@ class PdoAddressBook { $this->ContactSave($sEmail, $oContact); } - + $oContact->Clear(); } } - + $sSql = 'UPDATE rainloop_ab_properties SET prop_frec = prop_frec + 1 WHERE id_user = :id_user AND prop_type = :prop_type'; $aEmailsQuoted = \array_map(function ($mItem) use ($self) { return $self->quoteValue($mItem); }, $aEmailsToUpdate); - + if (1 === \count($aEmailsQuoted)) { $sSql .= ' AND prop_value = '.$aEmailsQuoted[0]; @@ -1259,7 +1490,7 @@ class PdoAddressBook { $sSql .= ' AND prop_value IN ('.\implode(',', $aEmailsQuoted).')'; } - + return !!$this->prepareAndExecute($sSql, array( ':id_user' => array($iUserID, \PDO::PARAM_INT), ':prop_type' => array(PropertyType::EMAIl, \PDO::PARAM_INT) @@ -1506,7 +1737,7 @@ SQLITEINITIAL; break; } - return false; + return $mCache; } /** diff --git a/rainloop/v/0.0.0/app/libraries/Sabre/DAV/Client.php b/rainloop/v/0.0.0/app/libraries/Sabre/DAV/Client.php index aa59f1bbd..0d771c8eb 100644 --- a/rainloop/v/0.0.0/app/libraries/Sabre/DAV/Client.php +++ b/rainloop/v/0.0.0/app/libraries/Sabre/DAV/Client.php @@ -315,7 +315,7 @@ class Client { // Return headers as part of the response CURLOPT_HEADER => true, CURLOPT_POSTFIELDS => $body, - CURLOPT_USERAGENT => 'RainLoop DAV Client', + CURLOPT_USERAGENT => 'RainLoop DAV Client', // TODO rainloop // Automatically follow redirects CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, @@ -323,9 +323,13 @@ class Client { if($this->verifyPeer !== null) { $curlSettings[CURLOPT_SSL_VERIFYPEER] = $this->verifyPeer; + // TODO rainloop + if (!$this->verifyPeer) { + $curlSettings[CURLOPT_SSL_VERIFYHOST] = 0; + } // --- } - if($this->trustedCertificates) { + if($this->trustedCertificates) { $curlSettings[CURLOPT_CAINFO] = $this->trustedCertificates; } @@ -459,6 +463,7 @@ class Client { // @codeCoverageIgnoreStart protected function curlRequest($url, $settings) { + // TODO rainloop $curl = curl_init($url); $sSafeMode = strtolower(trim(@ini_get('safe_mode'))); $bSafeMode = 'on' === $sSafeMode || '1' === $sSafeMode; diff --git a/rainloop/v/0.0.0/app/templates/Views/PopupsContacts.html b/rainloop/v/0.0.0/app/templates/Views/PopupsContacts.html index 1af2cf793..ef4d8c12b 100644 --- a/rainloop/v/0.0.0/app/templates/Views/PopupsContacts.html +++ b/rainloop/v/0.0.0/app/templates/Views/PopupsContacts.html @@ -1,11 +1,11 @@]*>/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,"")},V.plainToHtml=function(a){return a.toString().replace(/&/g,"&").replace(/>/g,">").replace(/")},V.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},V.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:V.isUnd(c)?a.toString():c.toString(),custom:V.isUnd(c)?!1:!0,title:V.isUnd(c)?"":a.toString(),value:a.toString()};(V.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}},V.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()}},V.disableKeyFilter=function(){a.key&&(key.filter=function(){return gb.data().useKeyboardShortcuts()})},V.restoreKeyFilter=function(){a.key&&(key.filter=function(a){if(gb.data().useKeyboardShortcuts()){var b=a.target||a.srcElement,c=b?b.tagName:"";return c=c.toUpperCase(),!("INPUT"===c||"SELECT"===c||"TEXTAREA"===c||b&&"DIV"===c&&"editorHtmlArea"===b.className&&b.contentEditable)}return!1})},V.detectDropdownVisibility=f.debounce(function(){Y.dropdownVisibility(!!f.find($,function(a){return a.hasClass("open")}))},50),X={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return X.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=X._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 X._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(!Y.bMobileDevice){var e=b(a),f=e.data("tooltip-class")||"",g=e.data("tooltip-placement")||"top";e.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:g,trigger:"hover",title:function(){return e.is(".disabled")||Y.dropdownVisibility()?"":''+V.i18n(c.utils.unwrapObservable(d()))+""}}).click(function(){e.tooltip("hide")}),Y.dropdownVisibility.subscribe(function(a){a&&e.tooltip("hide")})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a),e=d.data("tooltip-class")||"",f=d.data("tooltip-placement")||"top";d.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:f,title:function(){return d.is(".disabled")||Y.dropdownVisibility()?"":''+c()()+""}}).click(function(){d.tooltip("hide")}),Y.dropdownVisibility.subscribe(function(a){a&&d.tooltip("hide")})}},c.bindingHandlers.tooltip3={init:function(a){var c=b(a);c.tooltip({container:"body",trigger:"hover manual",title:function(){return c.data("tooltip3-data")||""}}),Y.dropdownVisibility.subscribe(function(a){a&&c.tooltip("hide")}),eb.click(function(){c.tooltip("hide")})},update:function(a,d){var e=c.utils.unwrapObservable(d());""===e?b(a).data("tooltip3-data","").tooltip("hide"):b(a).data("tooltip3-data",e).tooltip("show")}},c.bindingHandlers.registrateBootstrapDropdown={init:function(a){$.push(b(a))}},c.bindingHandlers.openDropdownTrigger={update:function(a,d){if(c.utils.unwrapObservable(d())){var e=b(a);e.hasClass("open")||(e.find(".dropdown-toggle").dropdown("toggle"),V.detectDropdownVisibility()),d()(!1)}}},c.bindingHandlers.dropdownCloser={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&&!V.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&&!V.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.clickOnTrue={update:function(a,d){c.utils.unwrapObservable(d())&&b(a).click()}},c.bindingHandlers.modal={init:function(a,d){b(a).toggleClass("fade",!Y.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("shown",function(){V.windowResize()}).find(".close").click(function(){d()(!1)})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){V.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),V.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=V.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=V.pInt(e[2]),g=db.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(!Y.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),V.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),V.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)},b(d).draggable(k).on("mousedown",function(){V.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!Y.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){Y.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){gb.getAutocomplete(a.term,function(a){b(f.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return f.map(a,function(a){var b=V.trim(a),c=null;return""!==b?(c=new o,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:f.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(V.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},V.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=V.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=V.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),V.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},g.prototype.root=function(){return this.sBase},g.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},g.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},g.prototype.uploadContacts=function(){return this.sServer+"/UploadContacts/"+this.sSpecSuffix+"/"},g.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},g.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},g.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},g.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},g.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},g.prototype.messagePreview=function(){return this.sBase+"mailbox/message-preview"},g.prototype.settings=function(a){var b=this.sBase+"settings";return V.isUnd(a)||""===a||(b+="/"+a),b},g.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},g.prototype.mailBox=function(a,b,c){b=V.isNormal(b)?V.pInt(b):1,c=V.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},g.prototype.phpInfo=function(){return this.sServer+"Info"},g.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},g.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},g.prototype.exportContactsVcf=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsVcf/"},g.prototype.exportContactsCsv=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsCsv/"},g.prototype.emptyContactPic=function(){return"rainloop/v/"+this.sVersion+"/static/css/images/empty-contact.png"},g.prototype.sound=function(a){return"rainloop/v/"+this.sVersion+"/static/sounds/"+a},g.prototype.themePreviewLink=function(a){var b="rainloop/v/"+this.sVersion+"/";return"@custom"===a.substr(-7)&&(a=V.trim(a.substring(0,a.length-7)),b=""),b+"themes/"+encodeURI(a)+"/images/preview.png"},g.prototype.notificationMailIcon=function(){return"rainloop/v/"+this.sVersion+"/static/css/images/icom-message-notification.png"},g.prototype.openPgpJs=function(){return"rainloop/v/"+this.sVersion+"/static/js/openpgp.min.js"},g.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},W.oViewModelsHooks={},W.oSimpleHooks={},W.regViewModelHook=function(a,b){b&&(b.__hookName=a) -},W.addHook=function(a,b){V.isFunc(b)&&(V.isArray(W.oSimpleHooks[a])||(W.oSimpleHooks[a]=[]),W.oSimpleHooks[a].push(b))},W.runHook=function(a,b){V.isArray(W.oSimpleHooks[a])&&(b=b||[],f.each(W.oSimpleHooks[a],function(a){a.apply(null,b)}))},W.mainSettingsGet=function(a){return gb?gb.settingsGet(a):null},W.remoteRequest=function(a,b,c,d,e,f){gb&&gb.remote().defaultRequest(a,b,c,d,e,f)},W.settingsGet=function(a,b){var c=W.mainSettingsGet("Plugins");return c=c&&V.isUnd(c[a])?null:c[a],c?V.isUnd(c[b])?null:c[b]:null},h.supported=function(){return!0},h.prototype.set=function(a,c){var d=b.cookie(S.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(S.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},h.prototype.get=function(a){var c=b.cookie(S.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!V.isUnd(d[a])?d[a]:null}catch(e){}return d},i.supported=function(){return!!a.localStorage},i.prototype.set=function(b,c){var d=a.localStorage[S.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[S.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},i.prototype.get=function(b){var c=a.localStorage[S.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!V.isUnd(d[b])?d[b]:null}catch(e){}return d},j.prototype.oDriver=null,j.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},j.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},k.prototype.bootstart=function(){},l.prototype.sPosition="",l.prototype.sTemplate="",l.prototype.viewModelName="",l.prototype.viewModelDom=null,l.prototype.viewModelTemplate=function(){return this.sTemplate},l.prototype.viewModelPosition=function(){return this.sPosition},l.prototype.cancelCommand=l.prototype.closeCommand=function(){},l.prototype.storeAndSetKeyScope=function(){this.sCurrentKeyScope=gb.data().keyScope(),gb.data().keyScope(this.sDefaultKeyScope)},l.prototype.restoreKeyScope=function(){gb.data().keyScope(this.sCurrentKeyScope)},l.prototype.registerPopupEscapeKey=function(){var a=this;db.on("keydown",function(b){return b&&T.EventKeyCode.Esc===b.keyCode&&a.modalVisibility&&a.modalVisibility()?(V.delegateRun(a,"cancelCommand"),!1):!0})},m.prototype.oCross=null,m.prototype.sScreenName="",m.prototype.aViewModels=[],m.prototype.viewModels=function(){return this.aViewModels},m.prototype.screenName=function(){return this.sScreenName},m.prototype.routes=function(){return null},m.prototype.__cross=function(){return this.oCross},m.prototype.__start=function(){var a=this.routes(),b=null,c=null;V.isNonEmptyArray(a)&&(c=f.bind(this.onRoute||V.emptyFunction,this),b=d.create(),f.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},n.constructorEnd=function(a){V.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},n.prototype.sDefaultScreenName="",n.prototype.oScreens={},n.prototype.oBoot=null,n.prototype.oCurrentScreen=null,n.prototype.hideLoading=function(){b("#rl-loading").hide()},n.prototype.routeOff=function(){e.changed.active=!1},n.prototype.routeOn=function(){e.changed.active=!0},n.prototype.setBoot=function(a){return V.isNormal(a)&&(this.oBoot=a),this},n.prototype.screen=function(a){return""===a||V.isUnd(this.oScreens[a])?null:this.oScreens[a]},n.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),g=e.viewModelPosition(),h=b("#rl-content #rl-"+g.toLowerCase()),i=null;a.__builded=!0,a.__vm=e,e.data=gb.data(),e.viewModelName=a.__name,h&&1===h.length?(i=b(" ").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),i.appendTo(h),e.viewModelDom=i,a.__dom=i,"Popups"===g&&(e.cancelCommand=e.closeCommand=V.createCommand(e,function(){_.hideScreenPopup(a)}),e.modalVisibility.subscribe(function(a){var b=this;a?(this.viewModelDom.show(),this.storeAndSetKeyScope(),gb.popupVisibilityNames.push(this.viewModelName),e.viewModelDom.css("z-index",3e3+gb.popupVisibilityNames().length+10),V.delegateRun(this,"onFocus",[],500)):(V.delegateRun(this,"onHide"),this.restoreKeyScope(),gb.popupVisibilityNames.remove(this.viewModelName),e.viewModelDom.css("z-index",2e3),f.delay(function(){b.viewModelDom.hide()},300))},e)),W.runHook("view-model-pre-build",[a.__name,e,i]),c.applyBindings(e,i[0]),V.delegateRun(e,"onBuild",[i]),e&&"Popups"===g&&!e.bDisabeCloseOnEsc&&e.registerPopupEscapeKey(),W.runHook("view-model-post-build",[a.__name,e,i])):V.log("Cannot find view model position: "+g)}return a?a.__vm:null},n.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},n.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__vm.modalVisibility(!1),W.runHook("view-model-on-hide",[a.__name,a.__vm]))},n.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__vm.modalVisibility(!0),V.delegateRun(a.__vm,"onShow",b||[]),W.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},n.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===V.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,V.isNonEmptyArray(d.viewModels())&&f.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),V.delegateRun(d,"onBuild")),f.defer(function(){c.oCurrentScreen&&(V.delegateRun(c.oCurrentScreen,"onHide"),V.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),V.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(V.delegateRun(c.oCurrentScreen,"onShow"),W.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),V.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),V.delegateRun(a.__vm,"onShow"),V.delegateRun(a.__vm,"onFocus",[],200),W.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},n.prototype.startScreens=function(a){b("#rl-content").css({visibility:"hidden"}),f.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),f.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),W.runHook("screen-pre-start",[a.screenName(),a]),V.delegateRun(a,"onStart"),W.runHook("screen-post-start",[a.screenName(),a]))},this);var c=d.create();c.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,f.bind(this.screenOnRoute,this)),e.initialized.add(c.parse,c),e.changed.add(c.parse,c),e.init(),b("#rl-content").css({visibility:"visible"}),f.delay(function(){cb.removeClass("rl-started-trigger").addClass("rl-started")},50)},n.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=V.isUnd(c)?!1:!!c,(V.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)},n.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},_=new n,o.newInstanceFromJson=function(a){var b=new o;return b.initByJson(a)?b:null},o.prototype.name="",o.prototype.email="",o.prototype.privateType=null,o.prototype.clear=function(){this.email="",this.name="",this.privateType=null},o.prototype.validate=function(){return""!==this.name||""!==this.email},o.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},o.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},o.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=T.EmailType.Facebook),null===this.privateType&&(this.privateType=T.EmailType.Default)),this.privateType},o.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},o.prototype.parse=function(a){this.clear(),a=V.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)},o.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=V.trim(a.Name),this.email=V.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},o.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=V.isUnd(b)?!1:!!b,c=V.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+V.encodeHtml(this.name)+"":c?V.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=V.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+V.encodeHtml(d)+""+V.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=V.encodeHtml(d))):b&&(d=''+V.encodeHtml(this.email)+""))),d},o.prototype.mailsoParse=function(a){if(a=V.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: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(h),e.data=gb.data(),e.viewModelDom=i,e.__rlSettingsData=g.__rlSettingsData,g.__dom=i,g.__builded=!0,g.__vm=e,c.applyBindings(e,i[0]),V.delegateRun(e,"onBuild",[i])):V.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&f.defer(function(){d.oCurrentSubScreen&&(V.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),V.delegateRun(d.oCurrentSubScreen,"onShow"),V.delegateRun(d.oCurrentSubScreen,"onFocus",[],200),f.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)),V.windowResize()})):_.setHash(gb.link().settings(),!1,!0)},N.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(V.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},N.prototype.onBuild=function(){f.each(Z.settings,function(a){a&&a.__rlSettingsData&&!f.find(Z["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!f.find(Z["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},N.prototype.routes=function(){var a=f.find(Z.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=V.isUnd(c.subname)?b:V.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},f.extend(O.prototype,m.prototype),O.prototype.onShow=function(){gb.setTitle("")},f.extend(P.prototype,N.prototype),P.prototype.onShow=function(){gb.setTitle("")},f.extend(Q.prototype,k.prototype),Q.prototype.oSettings=null,Q.prototype.oPlugins=null,Q.prototype.oLocal=null,Q.prototype.oLink=null,Q.prototype.oSubs={},Q.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):(Y.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},Q.prototype.link=function(){return null===this.oLink&&(this.oLink=new g),this.oLink},Q.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new j),this.oLocal},Q.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=V.isNormal(ab)?ab:{}),V.isUnd(this.oSettings[a])?null:this.oSettings[a]},Q.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=V.isNormal(ab)?ab:{}),this.oSettings[a]=b},Q.prototype.setTitle=function(b){b=(V.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=V.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=V.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=V.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},o.prototype.inputoTagLine=function(){return 0 (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 ').appendTo("body"),eb.on("error",function(a){hb&&a&&a.originalEvent&&a.originalEvent.message&&-1===W.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&hb.remote().jsError(W.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",db.attr("class"),W.microtime()-Z.now)}),fb.on("keydown",function(a){a&&a.ctrlKey&&db.addClass("rl-ctrl-key-pressed")}).on("keyup",function(a){a&&!a.ctrlKey&&db.removeClass("rl-ctrl-key-pressed")})}function S(){R.call(this),this.oData=null,this.oRemote=null,this.oCache=null}var T={},U={},V={},W={},X={},Y={},Z={},$={settings:[],"settings-removed":[],"settings-disabled":[]},_=[],ab=null,bb=a.rainloopAppData||{},cb=a.rainloopI18N||{},db=b("html"),eb=b(a),fb=b(a.document),gb=a.Notification&&a.Notification.requestPermission?a.Notification:null,hb=null;Z.now=(new Date).getTime(),Z.momentTrigger=c.observable(!0),Z.dropdownVisibility=c.observable(!1).extend({rateLimit:0}),Z.langChangeTrigger=c.observable(!0),Z.iAjaxErrorCount=0,Z.iTokenErrorCount=0,Z.iMessageBodyCacheCount=0,Z.bUnload=!1,Z.sUserAgent=(navigator.userAgent||"").toLowerCase(),Z.bIsiOSDevice=-1 /g,">").replace(/"/g,""").replace(/'/g,"'"):""},W.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=W.isUnd(b)?100:b;e.length>b;)d=e.substring(0,b),f=d.lastIndexOf(" "),g=d.lastIndexOf("\n"),-1!==g&&(f=g),-1===f&&(f=b),c+=d.substring(0,f)+"\n",e=e.substring(f+1);return c+e},W.timeOutAction=function(){var b={};return function(c,d,e){W.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),W.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),W.audio=function(){var b=!1;return function(c,d){if(!1===b)if(Z.bIsiOSDevice)b=null;else{var e=!1,f=!1,g=a.Audio?new a.Audio:null;g&&g.canPlayType&&g.play?(e=""!==g.canPlayType('audio/mpeg; codecs="mp3"'),e||(f=""!==g.canPlayType('audio/ogg; codecs="vorbis"')),e||f?(b=g,b.preload="none",b.loop=!1,b.autoplay=!1,b.muted=!1,b.src=e?c:d):b=null):b=null}return b}}(),W.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},W.i18n=function(a,b,c){var d="",e=W.isUnd(cb[a])?W.isUnd(c)?a:c:cb[a];if(!W.isUnd(b)&&!W.isNull(b))for(d in b)W.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},W.i18nToNode=function(a){f.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(W.i18n(c)):(c=a.data("i18n-html"),c&&a.html(W.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",W.i18n(c)),c=a.data("i18n-title"),c&&a.attr("title",W.i18n(c)))})})},W.i18nToDoc=function(){a.rainloopI18N&&(cb=a.rainloopI18N||{},W.i18nToNode(fb),Z.langChangeTrigger(!Z.langChangeTrigger())),a.rainloopI18N={}},W.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?Z.langChangeTrigger.subscribe(function(){a&&a.call(b),c.call(b)}):a&&Z.langChangeTrigger.subscribe(a,b)},W.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&a.contentEditable)},W.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},W.removeSelection=function(){if(a&&a.getSelection){var b=a.getSelection();b&&b.removeAllRanges&&b.removeAllRanges()}else document&&document.selection&&document.selection.empty&&document.selection.empty()},W.replySubjectAdd=function(b,c,d){var e=null,f=W.trim(c);return f=null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||W.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||W.isUnd(e[1])||W.isUnd(e[2])||W.isUnd(e[3])?b+": "+c:e[1]+(W.pInt(e[2])+1)+e[3]:b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),f=(W.isUnd(d)?!0:d)?W.fixLongSubject(f):f},W.fixLongSubject=function(a){var b=0,c=null;a=W.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||W.isUnd(c[0]))&&(c=null),c&&(b=0,b+=W.isUnd(c[2])?1:0+W.pInt(c[2]),b+=W.isUnd(c[4])?1:0+W.pInt(c[4]),a=a.replace(/^Re(\[[\d]+\]|):[\s]{0,3}Re(\[[\d]+\]|):/gi,"Re"+(b>0?"["+b+"]":"")+":"));while(c);return a=a.replace(/[\s]+/," ")},W.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},W.friendlySize=function(a){return a=W.pInt(a),a>=1073741824?W.roundNumber(a/1073741824,1)+"GB":a>=1048576?W.roundNumber(a/1048576,1)+"MB":a>=1024?W.roundNumber(a/1024,0)+"KB":a+"B"},W.log=function(b){a.console&&a.console.log&&a.console.log(b)},W.getNotification=function(a,b){return a=W.pInt(a),U.Notification.ClientViewError===a&&b?b:W.isUnd(V[a])?"":V[a]},W.initNotificationLanguage=function(){V[U.Notification.InvalidToken]=W.i18n("NOTIFICATIONS/INVALID_TOKEN"),V[U.Notification.AuthError]=W.i18n("NOTIFICATIONS/AUTH_ERROR"),V[U.Notification.AccessError]=W.i18n("NOTIFICATIONS/ACCESS_ERROR"),V[U.Notification.ConnectionError]=W.i18n("NOTIFICATIONS/CONNECTION_ERROR"),V[U.Notification.CaptchaError]=W.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),V[U.Notification.SocialFacebookLoginAccessDisable]=W.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),V[U.Notification.SocialTwitterLoginAccessDisable]=W.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),V[U.Notification.SocialGoogleLoginAccessDisable]=W.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),V[U.Notification.DomainNotAllowed]=W.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),V[U.Notification.AccountNotAllowed]=W.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),V[U.Notification.AccountTwoFactorAuthRequired]=W.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED"),V[U.Notification.AccountTwoFactorAuthError]=W.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR"),V[U.Notification.CouldNotSaveNewPassword]=W.i18n("NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD"),V[U.Notification.CurrentPasswordIncorrect]=W.i18n("NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT"),V[U.Notification.NewPasswordShort]=W.i18n("NOTIFICATIONS/NEW_PASSWORD_SHORT"),V[U.Notification.NewPasswordWeak]=W.i18n("NOTIFICATIONS/NEW_PASSWORD_WEAK"),V[U.Notification.NewPasswordForbidden]=W.i18n("NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT"),V[U.Notification.ContactsSyncError]=W.i18n("NOTIFICATIONS/CONTACTS_SYNC_ERROR"),V[U.Notification.CantGetMessageList]=W.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),V[U.Notification.CantGetMessage]=W.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),V[U.Notification.CantDeleteMessage]=W.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),V[U.Notification.CantMoveMessage]=W.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),V[U.Notification.CantCopyMessage]=W.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),V[U.Notification.CantSaveMessage]=W.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),V[U.Notification.CantSendMessage]=W.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),V[U.Notification.InvalidRecipients]=W.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),V[U.Notification.CantCreateFolder]=W.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),V[U.Notification.CantRenameFolder]=W.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),V[U.Notification.CantDeleteFolder]=W.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),V[U.Notification.CantDeleteNonEmptyFolder]=W.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),V[U.Notification.CantSubscribeFolder]=W.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),V[U.Notification.CantUnsubscribeFolder]=W.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),V[U.Notification.CantSaveSettings]=W.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),V[U.Notification.CantSavePluginSettings]=W.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),V[U.Notification.DomainAlreadyExists]=W.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),V[U.Notification.CantInstallPackage]=W.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),V[U.Notification.CantDeletePackage]=W.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),V[U.Notification.InvalidPluginPackage]=W.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),V[U.Notification.UnsupportedPluginPackage]=W.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),V[U.Notification.LicensingServerIsUnavailable]=W.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),V[U.Notification.LicensingExpired]=W.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),V[U.Notification.LicensingBanned]=W.i18n("NOTIFICATIONS/LICENSING_BANNED"),V[U.Notification.DemoSendMessageError]=W.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),V[U.Notification.AccountAlreadyExists]=W.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),V[U.Notification.MailServerError]=W.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),V[U.Notification.UnknownNotification]=W.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),V[U.Notification.UnknownError]=W.i18n("NOTIFICATIONS/UNKNOWN_ERROR") +},W.getUploadErrorDescByCode=function(a){var b="";switch(W.pInt(a)){case U.UploadErrorCode.FileIsTooBig:b=W.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case U.UploadErrorCode.FilePartiallyUploaded:b=W.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case U.UploadErrorCode.FileNoUploaded:b=W.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case U.UploadErrorCode.MissingTempFolder:b=W.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case U.UploadErrorCode.FileOnSaveingError:b=W.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case U.UploadErrorCode.FileType:b=W.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=W.i18n("UPLOAD/ERROR_UNKNOWN")}return b},W.delegateRun=function(a,b,c,d){a&&a[b]&&(d=W.pInt(d),0>=d?a[b].apply(a,W.isArray(c)?c:[]):f.delay(function(){a[b].apply(a,W.isArray(c)?c:[])},d))},W.killCtrlAandS=function(b){if(b=b||a.event,b&&b.ctrlKey&&!b.shiftKey&&!b.altKey){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(d===U.EventKeyCode.S)return void b.preventDefault();if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;d===U.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},W.createCommand=function(a,b,d){var e=b?function(){return e.canExecute&&e.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments)),!1}:function(){};return e.enabled=c.observable(!0),d=W.isUnd(d)?!0:d,e.canExecute=c.computed(W.isFunc(d)?function(){return e.enabled()&&d.call(a)}:function(){return e.enabled()&&!!d}),e},W.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(U.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(U.InterfaceAnimation.Full),b.contactsAutosave=c.observable(!1),Z.sAnimationType=U.InterfaceAnimation.Full,b.allowThemes=c.observable(!0),b.allowCustomLogin=c.observable(!1),b.allowLanguagesOnSettings=c.observable(!0),b.allowLanguagesOnLogin=c.observable(!0),b.desktopNotifications=c.observable(!1),b.useThreads=c.observable(!0),b.replySameFolder=c.observable(!0),b.useCheckboxesInList=c.observable(!0),b.layout=c.observable(U.Layout.SidePreview),b.usePreviewPane=c.computed(function(){return U.Layout.NoPreview!==b.layout()}),b.interfaceAnimation.subscribe(function(a){if(Z.bMobileDevice||a===U.InterfaceAnimation.None)db.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),Z.sAnimationType=U.InterfaceAnimation.None;else switch(a){case U.InterfaceAnimation.Full:db.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),Z.sAnimationType=a;break;case U.InterfaceAnimation.Normal:db.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),Z.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=U.DesktopNotifications.NotSupported;if(gb&&gb.permission)switch(gb.permission.toLowerCase()){case"granted":c=U.DesktopNotifications.Allowed;break;case"denied":c=U.DesktopNotifications.Denied;break;case"default":c=U.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&U.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();U.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):U.DesktopNotifications.NotAllowed===c?gb.requestPermission(function(){b.desktopNotifications.valueHasMutated(),U.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()?b.desktopNotifications()?b.desktopNotifications.valueHasMutated():b.desktopNotifications(!0):b.desktopNotifications()?b.desktopNotifications(!1):b.desktopNotifications.valueHasMutated()}):b.desktopNotifications(!1)}else b.desktopNotifications(!1)}}),b.language=c.observable(""),b.languages=c.observableArray([]),b.mainLanguage=c.computed({read:b.language,write:function(a){a!==b.language()?-1 =b.diff(c,"hours")?d:b.format("L")===c.format("L")?W.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?W.i18n("MESSAGE_LIST/YESTERDAY_AT",{TIME:c.format("LT")}):c.format(b.year()===c.year()?"D MMM.":"LL")},a)},W.isFolderExpanded=function(a){var b=hb.local().get(U.ClientSideKeyName.ExpandedFolders);return f.isArray(b)&&-1!==f.indexOf(b,a)},W.setExpandedFolder=function(a,b){var c=hb.local().get(U.ClientSideKeyName.ExpandedFolders);f.isArray(c)||(c=[]),b?(c.push(a),c=f.uniq(c)):c=f.without(c,a),hb.local().set(U.ClientSideKeyName.ExpandedFolders,c)},W.initLayoutResizer=function(a,c,d){var e=60,f=155,g=b(a),h=b(c),i=hb.local().get(d)||null,j=function(a){a&&(g.css({width:""+a+"px"}),h.css({left:""+a+"px"}))},k=function(a){if(a)g.resizable("disable"),j(e);else{g.resizable("enable");var b=W.pInt(hb.local().get(d))||f;j(b>f?b:f)}},l=function(a,b){b&&b.size&&b.size.width&&(hb.local().set(d,b.size.width),h.css({left:""+b.size.width+"px"}))};null!==i&&j(i>f?i:f),g.resizable({helper:"ui-resizable-helper",minWidth:f,maxWidth:350,handles:"e",stop:l}),hb.sub("left-panel.off",function(){k(!0)}),hb.sub("left-panel.on",function(){k(!1)})},W.initBlockquoteSwitcher=function(a){if(a){var c=b("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===b(this).parent().closest("blockquote",a).length});c&&0 100)&&(a.addClass("rl-bq-switcher hidden-bq"),b('').insertBefore(a).click(function(){a.toggleClass("hidden-bq"),W.windowResize()}).after("
").before("
"))})}},W.removeBlockquoteSwitcher=function(a){a&&(b(a).find("blockquote.rl-bq-switcher").each(function(){b(this).removeClass("rl-bq-switcher hidden-bq")}),b(a).find(".rlBlockquoteSwitcher").each(function(){b(this).remove()}))},W.toggleMessageBlockquote=function(a){a&&a.find(".rlBlockquoteSwitcher").click()},W.extendAsViewModel=function(a,b,c){b&&(c||(c=l),b.__name=a,X.regViewModelHook(a,b),f.extend(b.prototype,c.prototype))},W.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},$.settings.push(a)},W.removeSettingsViewModel=function(a){$["settings-removed"].push(a)},W.disableSettingsViewModel=function(a){$["settings-disabled"].push(a)},W.convertThemeName=function(a){return"@custom"===a.substr(-7)&&(a=W.trim(a.substring(0,a.length-7))),W.trim(a.replace(/[^a-zA-Z]+/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},W.quoteName=function(a){return a.replace(/["]/g,'\\"')},W.microtime=function(){return(new Date).getTime()},W.convertLangName=function(a,b){return W.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},W.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=W.isUnd(a)?32:W.pInt(a);b.length>>32-b}function c(a,b){var c,d,e,f,g;return e=2147483648&a,f=2147483648&b,c=1073741824&a,d=1073741824&b,g=(1073741823&a)+(1073741823&b),c&d?2147483648^g^e^f:c|d?1073741824&g?3221225472^g^e^f:1073741824^g^e^f:g^e^f}function d(a,b,c){return a&b|~a&c}function e(a,b,c){return a&c|b&~c}function f(a,b,c){return a^b^c}function g(a,b,c){return b^(a|~c)}function h(a,e,f,g,h,i,j){return a=c(a,c(c(d(e,f,g),h),j)),c(b(a,i),e)}function i(a,d,f,g,h,i,j){return a=c(a,c(c(e(d,f,g),h),j)),c(b(a,i),d)}function j(a,d,e,g,h,i,j){return a=c(a,c(c(f(d,e,g),h),j)),c(b(a,i),d)}function k(a,d,e,f,h,i,j){return a=c(a,c(c(g(d,e,f),h),j)),c(b(a,i),d)}function l(a){for(var b,c=a.length,d=c+8,e=(d-d%64)/64,f=16*(e+1),g=Array(f-1),h=0,i=0;c>i;)b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|a.charCodeAt(i)<>>29,g}function m(a){var b,c,d="",e="";for(c=0;3>=c;c++)b=a>>>8*c&255,e="0"+b.toString(16),d+=e.substr(e.length-2,2);return d}function n(a){a=a.replace(/rn/g,"n");for(var b="",c=0;c d?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var o,p,q,r,s,t,u,v,w,x=Array(),y=7,z=12,A=17,B=22,C=5,D=9,E=14,F=20,G=4,H=11,I=16,J=23,K=6,L=10,M=15,N=21;for(a=n(a),x=l(a),t=1732584193,u=4023233417,v=2562383102,w=271733878,o=0;o /g,">").replace(/")},W.draggeblePlace=function(){return b(' ').appendTo("#rl-hidden")},W.defautOptionsAfterRender=function(a,c){c&&!W.isUnd(c.disabled)&&a&&b(a).toggleClass("disabled",c.disabled).prop("disabled",c.disabled)},W.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+W.fakeMd5()+"__",j=b("#"+d);a[i]=function(){if(h&&h.document.body&&j&&j[0]){var d=b(h.document.body);b("#rl-content",d).html(j.html()),b("html",h.document).addClass("external "+b("html").attr("class")),W.i18nToNode(d),n.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.document.write(''+W.encodeHtml(e)+' '),h.document.close(),g=h.document.createElement("script"),g.type="text/javascript",g.innerHTML="if(window&&window.opener&&window.opener['"+i+"']){window.opener['"+i+"']();window.opener['"+i+"']=null}",h.document.getElementsByTagName("head")[0].appendChild(g)},W.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=W.isUnd(d)?1e3:W.pInt(d),function(e,g,h,i,j){b.call(c,g&&g.Result?U.SaveSettingsStep.TrueResult:U.SaveSettingsStep.FalseResult),a&&a.call(c,e,g,h,i,j),f.delay(function(){b.call(c,U.SaveSettingsStep.Idle)},d)}},W.settingsSaveHelperSimpleFunction=function(a,b){return W.settingsSaveHelperFunction(null,a,b,1e3)},W.htmlToPlain=function(a){var c="",d="> ",e=function(){if(arguments&&1\n",a.replace(/\n([> ]+)/gm,function(){return arguments&&1 ]*>(.|[\s\S\r\n]*)<\/div>/gim,f),a="\n"+b.trim(a)+"\n"),a}return""},g=function(){return arguments&&1 /g,">"):""},h=function(){if(arguments&&1 /gim,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,"\n").replace(/<\/tr>/gi,"\n").replace(/
]*>/gim,"\n_______________________________\n\n").replace(/]*>/gim,"").replace(/
]*>(.|[\s\S\r\n]*)<\/div>/gim,f).replace(/') ; /*jshint onevar: true*/ - + /** * @type {?} */ @@ -237,7 +237,7 @@ if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes) return oType && 'application/pdf' === oType.type; }); } - + Consts.Defaults = {}; Consts.Values = {}; Consts.DataImages = {}; @@ -355,7 +355,7 @@ Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA * @type {string} */ Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII='; - + /** * @enum {string} */ @@ -730,7 +730,7 @@ Enums.Notification = { 'UnknownNotification': 999, 'UnknownError': 999 }; - + Utils.trim = $.trim; Utils.inArray = $.inArray; Utils.isArray = _.isArray; @@ -1056,13 +1056,13 @@ Utils.i18nToNode = function (oElement) { jqThis.html(Utils.i18n(sKey)); } - + sKey = jqThis.data('i18n-placeholder'); if (sKey) { jqThis.attr('placeholder', Utils.i18n(sKey)); } - + sKey = jqThis.data('i18n-title'); if (sKey) { @@ -1200,7 +1200,7 @@ Utils.fixLongSubject = function (sSubject) ; sSubject = Utils.trim(sSubject.replace(/[\s]+/, ' ')); - + do { oMatch = /^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/ig.exec(sSubject); @@ -1329,9 +1329,9 @@ Utils.initNotificationLanguage = function () NotificationI18N[Enums.Notification.CantSaveSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS'); NotificationI18N[Enums.Notification.CantSavePluginSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS'); - + NotificationI18N[Enums.Notification.DomainAlreadyExists] = Utils.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS'); - + NotificationI18N[Enums.Notification.CantInstallPackage] = Utils.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE'); NotificationI18N[Enums.Notification.CantDeletePackage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE'); NotificationI18N[Enums.Notification.InvalidPluginPackage] = Utils.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE'); @@ -1344,7 +1344,7 @@ Utils.initNotificationLanguage = function () NotificationI18N[Enums.Notification.DemoSendMessageError] = Utils.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR'); NotificationI18N[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS'); - + NotificationI18N[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR'); NotificationI18N[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR'); NotificationI18N[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR'); @@ -1496,7 +1496,7 @@ Utils.initDataConstructorBySettings = function (oData) oData.contactsAutosave = ko.observable(false); Globals.sAnimationType = Enums.InterfaceAnimation.Full; - + oData.allowThemes = ko.observable(true); oData.allowCustomLogin = ko.observable(false); oData.allowLanguagesOnSettings = ko.observable(true); @@ -1506,7 +1506,7 @@ Utils.initDataConstructorBySettings = function (oData) oData.useThreads = ko.observable(true); oData.replySameFolder = ko.observable(true); oData.useCheckboxesInList = ko.observable(true); - + oData.layout = ko.observable(Enums.Layout.SidePreview); oData.usePreviewPane = ko.computed(function () { return Enums.Layout.NoPreview !== oData.layout(); @@ -1789,7 +1789,7 @@ Utils.setExpandedFolder = function (sFullNameHash, bExpanded) { aExpandedList = []; } - + if (bExpanded) { aExpandedList.push(sFullNameHash); @@ -1806,7 +1806,7 @@ Utils.setExpandedFolder = function (sFullNameHash, bExpanded) Utils.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName) { var - iDisabledWidth = 65, + iDisabledWidth = 60, iMinWidth = 155, oLeft = $(sLeft), oRight = $(sRight), @@ -1884,7 +1884,7 @@ Utils.initBlockquoteSwitcher = function (oMessageTextBody) var $oList = $('blockquote:not(.rl-bq-switcher)', oMessageTextBody).filter(function () { return 0 === $(this).parent().closest('blockquote', oMessageTextBody).length; }); - + if ($oList && 0 < $oList.length) { $oList.each(function () { @@ -2294,7 +2294,7 @@ Utils.resizeAndCrop = function (sUrl, iValue, fCallback) oCtx.fillStyle = '#fff'; oCtx.fillRect(0, 0, iValue, iValue); oCtx.drawImage(this, aDiff[0] / 2, aDiff[1] / 2, this.width - aDiff[0], this.height - aDiff[1], 0, 0, iValue, iValue); - + fCallback(oCanvas.toDataURL('image/jpeg')); }; @@ -2473,7 +2473,7 @@ Utils.detectDropdownVisibility = _.debounce(function () { Globals.dropdownVisibility(!!_.find(BootstrapDropdowns, function (oItem) { return oItem.hasClass('open'); })); -}, 50); +}, 50); // Base64 encode / decode // http://www.webtoolkit.info/ @@ -2636,7 +2636,7 @@ Base64 = { } }; -/*jslint bitwise: false*/ +/*jslint bitwise: false*/ ko.bindingHandlers.tooltip = { 'init': function (oElement, fValueAccessor) { if (!Globals.bMobileDevice) @@ -2711,7 +2711,7 @@ ko.bindingHandlers.tooltip3 = { 'init': function (oElement) { var $oEl = $(oElement); - + $oEl.tooltip({ 'container': 'body', 'trigger': 'hover manual', @@ -2730,7 +2730,7 @@ ko.bindingHandlers.tooltip3 = { $document.click(function () { $oEl.tooltip('hide'); }); - + }, 'update': function (oElement, fValueAccessor) { var sValue = ko.utils.unwrapObservable(fValueAccessor()); @@ -2761,7 +2761,7 @@ ko.bindingHandlers.openDropdownTrigger = { $el.find('.dropdown-toggle').dropdown('toggle'); Utils.detectDropdownVisibility(); } - + fValueAccessor()(false); } } @@ -2858,7 +2858,7 @@ ko.bindingHandlers.clickOnTrue = { ko.bindingHandlers.modal = { 'init': function (oElement, fValueAccessor) { - + $(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({ 'keyboard': false, 'show': ko.utils.unwrapObservable(fValueAccessor()) @@ -3173,11 +3173,19 @@ ko.bindingHandlers.emailsTags = { 'init': function(oElement, fValueAccessor) { var $oEl = $(oElement), - fValue = fValueAccessor() + fValue = fValueAccessor(), + fFocusCallback = function (bValue) { + if (fValue && fValue.focusTrigger) + { + fValue.focusTrigger(bValue); + } + } ; $oEl.inputosaurus({ 'parseOnBlur': true, + 'allowDragAndDrop': true, + 'focusCallback': fFocusCallback, 'inputDelimiters': [',', ';'], 'autoCompleteSource': function (oData, fResponse) { RL.getAutocomplete(oData.term, function (aData) { @@ -3188,12 +3196,12 @@ ko.bindingHandlers.emailsTags = { }, 'parseHook': function (aInput) { return _.map(aInput, function (sInputValue) { - + var sValue = Utils.trim(sInputValue), oEmail = null ; - + if ('' !== sValue) { oEmail = new EmailModel(); @@ -3223,8 +3231,83 @@ ko.bindingHandlers.emailsTags = { if (fValue.focusTrigger) { - fValue.focusTrigger.subscribe(function () { - $oEl.inputosaurus('focus'); + fValue.focusTrigger.subscribe(function (bValue) { + if (bValue) + { + $oEl.inputosaurus('focus'); + } + }); + } + } +}; + +ko.bindingHandlers.contactTags = { + 'init': function(oElement, fValueAccessor) { + var + $oEl = $(oElement), + fValue = fValueAccessor(), + fFocusCallback = function (bValue) { + if (fValue && fValue.focusTrigger) + { + fValue.focusTrigger(bValue); + } + } + ; + + $oEl.inputosaurus({ + 'parseOnBlur': true, + 'allowDragAndDrop': false, + 'focusCallback': fFocusCallback, + 'inputDelimiters': [';'], + 'outputDelimiter': ';', + 'autoCompleteSource': function (oData, fResponse) { + RL.getContactsTagsAutocomplete(oData.term, function (aData) { + fResponse(_.map(aData, function (oTagItem) { + return oTagItem.toLine(false); + })); + }); + }, + 'parseHook': function (aInput) { + return _.map(aInput, function (sInputValue) { + + var + sValue = Utils.trim(sInputValue), + oTag = null + ; + + if ('' !== sValue) + { + oTag = new ContactTagModel(); + oTag.name(sValue); + return [oTag.toLine(false), oTag]; + } + + return [sValue, null]; + + }); + }, + 'change': _.bind(function (oEvent) { + $oEl.data('ContactsTagsValue', oEvent.target.value); + fValue(oEvent.target.value); + }, this) + }); + + fValue.subscribe(function (sValue) { + if ($oEl.data('ContactsTagsValue') !== sValue) + { + $oEl.val(sValue); + $oEl.data('ContactsTagsValue', sValue); + $oEl.inputosaurus('refresh'); + } + }); + + if (fValue.focusTrigger) + { + fValue.focusTrigger.subscribe(function (bValue) { + if (bValue) + { + $oEl.inputosaurus('focus'); + } }); } } @@ -3374,14 +3457,14 @@ ko.observable.fn.validateFunc = function (fFunc) this.subscribe(function (sValue) { this.hasFuncError(!fFunc(sValue)); }, this); - + this.valueHasMutated(); } return this; }; - + /** * @constructor */ @@ -3693,7 +3776,7 @@ LinkBuilder.prototype.socialFacebook = function () { return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); }; - + /** * @type {Object} */ @@ -3787,7 +3870,7 @@ Plugins.settingsGet = function (sPluginSection, sName) }; - + function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady, fOnModeChange) { var self = this; @@ -4007,7 +4090,7 @@ NewHtmlEditorWrapper.prototype.clear = function (bFocus) this.setHtml('', bFocus); }; - + /** * @constructor * @param {koProperty} oKoList @@ -4716,7 +4799,7 @@ Selector.prototype.on = function (sEventName, fCallback) { this.oCallbacks[sEventName] = fCallback; }; - + /** * @constructor */ @@ -4790,7 +4873,7 @@ CookieDriver.prototype.get = function (sKey) return mResult; }; - + /** * @constructor */ @@ -4861,7 +4944,7 @@ LocalStorageDriver.prototype.get = function (sKey) return mResult; }; - + /** * @constructor */ @@ -4904,7 +4987,7 @@ LocalStorage.prototype.get = function (iKey) { return this.oDriver ? this.oDriver.get('p' + iKey) : null; }; - + /** * @constructor */ @@ -4917,7 +5000,7 @@ KnoinAbstractBoot.prototype.bootstart = function () { }; - + /** * @param {string=} sPosition = '' * @param {string=} sTemplate = '' @@ -4935,7 +5018,7 @@ function KnoinAbstractViewModel(sPosition, sTemplate) this.viewModelName = ''; this.viewModelVisibility = ko.observable(false); this.modalVisibility = ko.observable(false).extend({'rateLimit': 0}); - + this.viewModelDom = null; } @@ -4990,20 +5073,27 @@ KnoinAbstractViewModel.prototype.restoreKeyScope = function () RL.data().keyScope(this.sCurrentKeyScope); }; -KnoinAbstractViewModel.prototype.registerPopupEscapeKey = function () +KnoinAbstractViewModel.prototype.registerPopupKeyDown = function () { var self = this; $window.on('keydown', function (oEvent) { - if (oEvent && Enums.EventKeyCode.Esc === oEvent.keyCode && self.modalVisibility && self.modalVisibility()) + if (oEvent && self.modalVisibility && self.modalVisibility()) { - Utils.delegateRun(self, 'cancelCommand'); - return false; + if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode) + { + Utils.delegateRun(self, 'cancelCommand'); + return false; + } + else if (Enums.EventKeyCode.Backspace === oEvent.keyCode && !Utils.inFocus()) + { + return false; + } } return true; }); }; - + /** * @param {string} sScreenName * @param {?=} aViewModels = [] @@ -5079,7 +5169,7 @@ KnoinAbstractScreen.prototype.__start = function () this.oCross = oRoute; } }; - + /** * @constructor */ @@ -5163,7 +5253,7 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen) ViewModelClass.__builded = true; ViewModelClass.__vm = oViewModel; oViewModel.data = RL.data(); - + oViewModel.viewModelName = ViewModelClass.__name; if (oViewModelPlace && 1 === oViewModelPlace.length) @@ -5206,19 +5296,19 @@ Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen) self.viewModelDom.hide(); }, 300); } - + }, oViewModel); } - + Plugins.runHook('view-model-pre-build', [ViewModelClass.__name, oViewModel, oViewModelDom]); ko.applyBindings(oViewModel, oViewModelDom[0]); Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]); - if (oViewModel && 'Popups' === sPosition && !oViewModel.bDisabeCloseOnEsc) + if (oViewModel && 'Popups' === sPosition) { - oViewModel.registerPopupEscapeKey(); + oViewModel.registerPopupKeyDown(); } - + Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]); } else @@ -5320,7 +5410,7 @@ Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart) } _.defer(function () { - + // hide screen if (self.oCurrentScreen) { @@ -5416,7 +5506,7 @@ Knoin.prototype.startScreens = function (aScreensClasses) { oScreen.__started = true; oScreen.__start(); - + Plugins.runHook('screen-pre-start', [oScreen.screenName(), oScreen]); Utils.delegateRun(oScreen, 'onStart'); Plugins.runHook('screen-post-start', [oScreen.screenName(), oScreen]); @@ -5479,7 +5569,7 @@ Knoin.prototype.bootstart = function () }; kn = new Knoin(); - + /** * @param {string=} sEmail * @param {string=} sName @@ -5843,7 +5933,7 @@ EmailModel.prototype.inputoTagLine = function () { return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email; }; - + /** * @constructor */ @@ -5852,6 +5942,7 @@ function ContactModel() this.idContact = 0; this.display = ''; this.properties = []; + this.tags = ''; this.readOnly = false; this.focused = ko.observable(false); @@ -5865,11 +5956,11 @@ function ContactModel() */ ContactModel.prototype.getNameAndEmailHelper = function () { - var + var sName = '', sEmail = '' ; - + if (Utils.isNonEmptyArray(this.properties)) { _.each(this.properties, function (aProperty) { @@ -5902,6 +5993,7 @@ ContactModel.prototype.parse = function (oItem) this.idContact = Utils.pInt(oItem['IdContact']); this.display = Utils.pString(oItem['Display']); this.readOnly = !!oItem['ReadOnly']; + this.tags = ''; if (Utils.isNonEmptyArray(oItem['Properties'])) { @@ -5913,6 +6005,11 @@ ContactModel.prototype.parse = function (oItem) }, this); } + if (Utils.isNonEmptyArray(oItem['Tags'])) + { + this.tags = oItem['Tags'].join(';'); + } + bResult = true; } @@ -5960,7 +6057,7 @@ ContactModel.prototype.lineAsCcc = function () return aResult.join(' '); }; - + /** * @param {number=} iType = Enums.ContactPropertyType.Unknown * @param {string=} sTypeStr = '' @@ -5989,7 +6086,51 @@ function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder) }, this); } - + +/** + * @constructor + */ +function ContactTagModel() +{ + this.idContactTag = 0; + this.name = ko.observable(''); + this.readOnly = false; +} + +ContactTagModel.prototype.parse = function (oItem) +{ + var bResult = false; + if (oItem && 'Object/Tag' === oItem['@Object']) + { + this.idContact = Utils.pInt(oItem['IdContactTag']); + this.name(Utils.pString(oItem['Name'])); + this.readOnly = !!oItem['ReadOnly']; + + bResult = true; + } + + return bResult; +}; + +/** + * @param {string} sSearch + * @return {boolean} + */ +ContactTagModel.prototype.filterHelper = function (sSearch) +{ + return this.name().toLowerCase().indexOf(sSearch.toLowerCase()) !== -1; +}; + +/** + * @param {boolean=} bEncodeHtml = false + * @return {string} + */ +ContactTagModel.prototype.toLine = function (bEncodeHtml) +{ + return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ? + Utils.encodeHtml(this.name()) : this.name(); +}; + /** * @constructor */ @@ -6225,7 +6366,7 @@ AttachmentModel.prototype.iconClass = function () return sClass; }; - + /** * @constructor * @param {string} sId @@ -6286,7 +6427,7 @@ ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment) } return bResult; -}; +}; /** * @constructor */ @@ -7480,7 +7621,7 @@ MessageModel.prototype.flagHash = function () return [this.deleted(), this.unseen(), this.flagged(), this.answered(), this.forwarded(), this.isReadReceipt()].join(''); }; - + /** * @constructor */ @@ -7812,7 +7953,7 @@ FolderModel.prototype.printableFullName = function () { return this.fullName.split(this.delimiter).join(' / '); }; - + /** * @param {string} sEmail * @param {boolean=} bCanBeDelete = true @@ -7833,7 +7974,7 @@ AccountModel.prototype.email = ''; AccountModel.prototype.changeAccountLink = function () { return RL.link().change(this.email); -}; +}; /** * @param {string} sId * @param {string} sEmail @@ -7869,7 +8010,7 @@ IdentityModel.prototype.formattedNameForEmail = function () var sName = this.name(); return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>'; }; - + /** * @param {string} iIndex * @param {string} sGuID @@ -7900,7 +8041,7 @@ OpenPgpKeyModel.prototype.user = ''; OpenPgpKeyModel.prototype.email = ''; OpenPgpKeyModel.prototype.armor = ''; OpenPgpKeyModel.prototype.isPrivate = false; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -7996,7 +8137,7 @@ PopupsFolderClearViewModel.prototype.onShow = function (oFolder) this.selectedFolder(oFolder); } }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -8106,7 +8247,7 @@ PopupsFolderCreateViewModel.prototype.onFocus = function () { this.folderName.focused(true); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -8219,7 +8360,7 @@ PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType) this.notification(sNotification); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -9707,7 +9848,7 @@ PopupsComposeViewModel.prototype.triggerForResize = function () this.editorResizeThrottle(); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -9732,7 +9873,8 @@ function PopupsContactsViewModel() this.search = ko.observable(''); this.contactsCount = ko.observable(0); this.contacts = RL.data().contacts; - + this.contactTags = RL.data().contactTags; + this.currentContact = ko.observable(null); this.importUploaderButton = ko.observable(null); @@ -9752,6 +9894,21 @@ function PopupsContactsViewModel() this.viewReadOnly = ko.observable(false); this.viewProperties = ko.observableArray([]); + this.viewTags = ko.observable(''); + this.viewTags.visibility = ko.observable(false); + this.viewTags.focusTrigger = ko.observable(false); + + this.viewTags.focusTrigger.subscribe(function (bValue) { + if (!bValue && '' === this.viewTags()) + { + this.viewTags.visibility(false); + } + else if (bValue) + { + this.viewTags.visibility(true); + } + }, this); + this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) { @@ -9765,7 +9922,7 @@ function PopupsContactsViewModel() Enums.ContactPropertyType.Note ]); }); - + this.viewPropertiesOther = ko.computed(function () { var aList = _.filter(this.viewProperties(), function (oProperty) { @@ -9779,7 +9936,7 @@ function PopupsContactsViewModel() }); }, this); - + this.viewPropertiesEmails = this.viewProperties.filter(function(oProperty) { return Enums.ContactPropertyType.Email === oProperty.type(); }); @@ -9789,7 +9946,7 @@ function PopupsContactsViewModel() }); this.viewHasNonEmptyRequaredProperties = ko.computed(function() { - + var aNames = this.viewPropertiesNames(), aEmail = this.viewPropertiesEmails(), @@ -9797,7 +9954,7 @@ function PopupsContactsViewModel() return '' !== Utils.trim(oProperty.value()); } ; - + return !!(_.find(aNames, fHelper) || _.find(aEmail, fHelper)); }, this); @@ -9906,7 +10063,7 @@ function PopupsContactsViewModel() this.populateViewContact(null); this.currentContact(null); }); - + this.deleteCommand = Utils.createCommand(this, function () { this.deleteSelectedContacts(); this.emptySelection(true); @@ -9921,7 +10078,7 @@ function PopupsContactsViewModel() aE = _.map(aC, function (oItem) { if (oItem) { - var + var aData = oItem.getNameAndEmailHelper(), oEmail = aData ? new EmailModel(aData[0], aData[1]) : null ; @@ -9943,7 +10100,7 @@ function PopupsContactsViewModel() kn.hideScreenPopup(PopupsContactsViewModel); kn.showScreenPopup(PopupsComposeViewModel, [Enums.ComposeType.Empty, null, aE]); } - + }, function () { return 0 < this.contactsCheckedOrSelected().length; }); @@ -9953,11 +10110,11 @@ function PopupsContactsViewModel() }); this.saveCommand = Utils.createCommand(this, function () { - + this.viewSaving(true); this.viewSaveTrigger(Enums.SaveSettingsStep.Animate); - var + var sRequestUid = Utils.fakeMd5(), aProperties = [] ; @@ -9973,7 +10130,7 @@ function PopupsContactsViewModel() var bRes = false; self.viewSaving(false); - + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.RequestUid === sRequestUid && 0 < Utils.pInt(oData.Result.ResultID)) { @@ -9998,11 +10155,11 @@ function PopupsContactsViewModel() self.viewSaveTrigger(Enums.SaveSettingsStep.Idle); }, 1000); } - - }, sRequestUid, this.viewID(), aProperties); - + + }, sRequestUid, this.viewID(), this.viewTags(), aProperties); + }, function () { - var + var bV = this.viewHasNonEmptyRequaredProperties(), bReadOnly = this.viewReadOnly() ; @@ -10021,7 +10178,7 @@ function PopupsContactsViewModel() self.reloadContactList(true); }); - + }, function () { return !this.contacts.syncing() && !this.contacts.importing(); }); @@ -10030,9 +10187,9 @@ function PopupsContactsViewModel() this.watchDirty = ko.observable(false); this.watchHash = ko.observable(false); - + this.viewHash = ko.computed(function () { - return '' + _.map(self.viewProperties(), function (oItem) { + return '' + self.viewTags() + '|' + _.map(self.viewProperties(), function (oItem) { return oItem.value(); }).join(''); }); @@ -10093,6 +10250,12 @@ PopupsContactsViewModel.prototype.addNewOrFocusProperty = function (sType, sType } }; +PopupsContactsViewModel.prototype.addNewTag = function () +{ + this.viewTags.visibility(true); + this.viewTags.focusTrigger(true); +}; + PopupsContactsViewModel.prototype.addNewEmail = function () { this.addNewProperty(Enums.ContactPropertyType.Email, 'Home'); @@ -10162,7 +10325,7 @@ PopupsContactsViewModel.prototype.initUploader = function () this.contacts.importing(true); }, this)) .on('onComplete', _.bind(function (sId, bResult, oData) { - + this.contacts.importing(false); this.reloadContactList(); @@ -10186,7 +10349,7 @@ PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = func iCount = this.contacts().length, aContacts = this.contactsCheckedOrSelected() ; - + if (0 < aContacts.length) { _.each(aContacts, function (oContact) { @@ -10207,11 +10370,11 @@ PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = func } _.delay(function () { - + _.each(aContacts, function (oContact) { oKoContacts.remove(oContact); }); - + }, 500); } }; @@ -10270,7 +10433,8 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact) this.emptySelection(false); this.viewReadOnly(false); - + this.viewTags(''); + if (oContact) { sId = oContact.idContact; @@ -10295,15 +10459,20 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact) }); } + this.viewTags(oContact.tags); + this.viewReadOnly(!!oContact.readOnly); } + this.viewTags.focusTrigger.valueHasMutated(); + this.viewTags.visibility('' !== this.viewTags()); + aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.LastName, '', sLastName, false, this.getPropertyPlceholder(Enums.ContactPropertyType.LastName))); aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.FirstName, '', sFirstName, !oContact, this.getPropertyPlceholder(Enums.ContactPropertyType.FirstName))); - + this.viewID(sId); this.viewProperties([]); this.viewProperties(aList); @@ -10321,7 +10490,7 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio self = this, iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage ; - + this.bDropPageAfterDelete = false; if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition) @@ -10334,9 +10503,10 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio RL.remote().contacts(function (sResult, oData) { var iCount = 0, - aList = [] + aList = [], + aTagsList = [] ; - + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List) { if (Utils.isNonEmptyArray(oData.Result.List)) @@ -10351,14 +10521,26 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio iCount = Utils.pInt(oData.Result.Count); iCount = 0 < iCount ? iCount : 0; } + + if (Utils.isNonEmptyArray(oData.Result.Tags)) + { + aTagsList = _.map(oData.Result.Tags, function (oItem) { + var oContactTag = new ContactTagModel(); + return oContactTag.parse(oItem) ? oContactTag : null; + }); + + aTagsList = _.compact(aTagsList); + } } self.contactsCount(iCount); - + self.contacts(aList); - self.viewClearSearch('' !== self.search()); + self.contactTags(aTagsList); self.contacts.loading(false); + self.viewClearSearch('' !== self.search()); + }, iOffset, Consts.Defaults.ContactsPerPage, this.search()); }; @@ -10407,7 +10589,7 @@ PopupsContactsViewModel.prototype.onHide = function () oItem.checked(false); }); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -10543,7 +10725,7 @@ PopupsAdvancedSearchViewModel.prototype.onFocus = function () { this.fromFocus(true); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -10655,7 +10837,7 @@ PopupsAddAccountViewModel.prototype.onFocus = function () { this.emailFocus(true); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -10741,7 +10923,7 @@ PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function () { this.key.focus(true); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -10781,7 +10963,7 @@ PopupsViewOpenPgpKeyViewModel.prototype.onShow = function (oOpenPgpKey) this.key(oOpenPgpKey.armor); } }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -10869,7 +11051,7 @@ PopupsGenerateNewOpenPgpKeyViewModel.prototype.onFocus = function () { this.email.focus(true); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -11109,7 +11291,7 @@ PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFr this.to(aRec); this.text(sText); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -11257,7 +11439,7 @@ PopupsIdentityViewModel.prototype.onFocus = function () this.email.focused(true); } }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -11317,7 +11499,7 @@ PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang) RL.data().mainLanguage(sLang); this.cancelCommand(); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -11371,7 +11553,7 @@ PopupsTwoFactorTestViewModel.prototype.onFocus = function () { this.code.focused(true); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -11477,7 +11659,7 @@ PopupsAskViewModel.prototype.onBuild = function () }, this)); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -11522,7 +11704,7 @@ PopupsKeyboardShortcutsHelpViewModel.prototype.onBuild = function (oDom) } }, this)); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -11834,7 +12016,7 @@ LoginViewModel.prototype.selectLanguage = function () kn.showScreenPopup(PopupsLanguagesViewModel); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -11930,7 +12112,7 @@ AbstractSystemDropDownViewModel.prototype.onBuild = function () } }); }; - + /** * @constructor * @extends AbstractSystemDropDownViewModel @@ -11942,7 +12124,7 @@ function MailBoxSystemDropDownViewModel() } Utils.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel); - + /** * @constructor * @extends AbstractSystemDropDownViewModel @@ -11954,7 +12136,7 @@ function SettingsSystemDropDownViewModel() } Utils.extendAsViewModel('SettingsSystemDropDownViewModel', SettingsSystemDropDownViewModel, AbstractSystemDropDownViewModel); - + /** * @constructor * @extends KnoinAbstractViewModel @@ -12163,7 +12345,7 @@ MailBoxFolderListViewModel.prototype.contactsClick = function () kn.showScreenPopup(PopupsContactsViewModel); } }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -13066,7 +13248,7 @@ MailBoxMessageListViewModel.prototype.initUploaderForAppend = function () ; return !!oJua; -}; +}; /** * @constructor * @extends KnoinAbstractViewModel @@ -13134,9 +13316,9 @@ function MailBoxMessageViewViewModel() this.forwardCommand = createCommandHelper(Enums.ComposeType.Forward); this.forwardAsAttachmentCommand = createCommandHelper(Enums.ComposeType.ForwardAsAttachment); this.editAsNewCommand = createCommandHelper(Enums.ComposeType.EditAsNew); - + this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility); - + this.messageEditCommand = Utils.createCommand(this, function () { this.editMessage(); }, this.messageVisibility); @@ -13158,7 +13340,7 @@ function MailBoxMessageViewViewModel() [this.message().uid], false); } }, this.messageVisibility); - + this.archiveCommand = Utils.createCommand(this, function () { if (this.message()) { @@ -13167,7 +13349,7 @@ function MailBoxMessageViewViewModel() [this.message().uid], true); } }, this.messageVisibility); - + this.spamCommand = Utils.createCommand(this, function () { if (this.message()) { @@ -13187,6 +13369,7 @@ function MailBoxMessageViewViewModel() }, this.messageVisibility); // viewer + this.viewHash = ''; this.viewSubject = ko.observable(''); this.viewFromShort = ko.observable(''); this.viewToShort = ko.observable(''); @@ -13201,7 +13384,7 @@ function MailBoxMessageViewViewModel() this.viewDownloadLink = ko.observable(''); this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic); this.viewUserPicVisible = ko.observable(false); - + this.viewPgpPassword = ko.observable(''); this.viewPgpSignedVerifyStatus = ko.computed(function () { return this.message() ? this.message().pgpSignedVerifyStatus() : Enums.SignedVerifyStatus.None; @@ -13210,7 +13393,7 @@ function MailBoxMessageViewViewModel() this.viewPgpSignedVerifyUser = ko.computed(function () { return this.message() ? this.message().pgpSignedVerifyUser() : ''; }, this); - + this.message.subscribe(function (oMessage) { this.messageActiveDom(null); @@ -13219,6 +13402,12 @@ function MailBoxMessageViewViewModel() if (oMessage) { + if (this.viewHash !== oMessage.hash) + { + this.scrollMessageToTop(); + } + + this.viewHash = oMessage.hash; this.viewSubject(oMessage.subject()); this.viewFromShort(oMessage.fromToLine(true, true)); this.viewToShort(oMessage.toToLine(true, true)); @@ -13246,7 +13435,12 @@ function MailBoxMessageViewViewModel() } }); } - + else + { + this.viewHash = ''; + this.scrollMessageToTop(); + } + }, this); this.fullScreenMode.subscribe(function (bValue) { @@ -13269,14 +13463,10 @@ function MailBoxMessageViewViewModel() } }); - this.messageActiveDom.subscribe(function () { - this.scrollMessageToTop(); - }, this); - this.goUpCommand = Utils.createCommand(this, function () { RL.pub('mailbox.message-list.selector.go-up'); }); - + this.goDownCommand = Utils.createCommand(this, function () { RL.pub('mailbox.message-list.selector.go-down'); }); @@ -13341,7 +13531,7 @@ MailBoxMessageViewViewModel.prototype.scrollToTop = function () // $('.messageItem', this.viewModelDom).animate({'scrollTop': 0}, 300); $('.messageItem', this.viewModelDom).scrollTop(0); } - + Utils.windowResize(); }; @@ -13375,7 +13565,7 @@ MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType) MailBoxMessageViewViewModel.prototype.onBuild = function (oDom) { - var + var self = this, oData = RL.data() ; @@ -13386,7 +13576,7 @@ MailBoxMessageViewViewModel.prototype.onBuild = function (oDom) self.message.focused(true); } }, this); - + $('.attachmentsPlace', oDom).magnificPopup({ 'delegate': '.magnificPopupImage:visible', 'type': 'image', @@ -13580,7 +13770,7 @@ MailBoxMessageViewViewModel.prototype.initShortcuts = function () { self.message().printMessage(); } - + return false; }); @@ -13596,7 +13786,7 @@ MailBoxMessageViewViewModel.prototype.initShortcuts = function () { self.deleteCommand(); } - + return false; } }); @@ -13740,7 +13930,7 @@ MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage) if (oMessage && '' !== oMessage.readReceipt()) { RL.remote().sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid, - oMessage.readReceipt(), + oMessage.readReceipt(), Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}), Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': RL.data().accountEmail()})); @@ -13750,7 +13940,7 @@ MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage) RL.reloadFlagsCurrentMessageListAndMessageFromCache(); } }; - + /** * @param {?} oScreen * @@ -13779,7 +13969,7 @@ SettingsMenuViewModel.prototype.backToMailBoxClick = function () { kn.setHash(RL.link().inbox()); }; - + /** * @constructor * @extends KnoinAbstractViewModel @@ -13810,7 +14000,7 @@ SettingsPaneViewModel.prototype.backToMailBoxClick = function () { kn.setHash(RL.link().inbox()); }; - + /** * @constructor */ @@ -13970,7 +14160,7 @@ SettingsGeneral.prototype.selectLanguage = function () { kn.showScreenPopup(PopupsLanguagesViewModel); }; - + /** * @constructor */ @@ -14020,7 +14210,7 @@ SettingsContacts.prototype.onBuild = function () //{ // //}; - + /** * @constructor */ @@ -14101,7 +14291,7 @@ SettingsAccounts.prototype.deleteAccount = function (oAccountToRemove) } } }; - + /** * @constructor */ @@ -14189,7 +14379,7 @@ SettingsIdentity.prototype.onBuild = function () }, 50); }; - + /** * @constructor */ @@ -14347,7 +14537,7 @@ SettingsIdentities.prototype.onBuild = function (oDom) }); }, 50); -}; +}; /** * @constructor */ @@ -14497,7 +14687,7 @@ SettingsSecurity.prototype.onBuild = function () this.processing(true); RL.remote().getTwoFactor(this.onResult); }; - + /** * @constructor */ @@ -14564,7 +14754,7 @@ function SettingsSocialScreen() } Utils.addSettingsViewModel(SettingsSocialScreen, 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social'); - + /** * @constructor */ @@ -14669,7 +14859,7 @@ SettingsChangePasswordScreen.prototype.onChangePasswordResponse = function (sRes Utils.getNotification(Enums.Notification.CouldNotSaveNewPassword)); } }; - + /** * @constructor */ @@ -14864,7 +15054,7 @@ SettingsFolders.prototype.unSubscribeFolder = function (oFolder) oFolder.subScribed(false); }; - + /** * @constructor */ @@ -14978,7 +15168,7 @@ SettingsThemes.prototype.onBuild = function () }; })); }; - + /** * @constructor */ @@ -15046,7 +15236,7 @@ SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove) RL.reloadOpenPgpKeys(); } } -}; +}; /** * @constructor */ @@ -15176,7 +15366,7 @@ AbstractData.prototype.populateDataOnStart = function() this.contactsIsAllowed(!!RL.settingsGet('ContactsIsAllowed')); }; - + /** * @constructor * @extends AbstractData @@ -15260,13 +15450,14 @@ function WebMailDataStorage() this.identitiesLoading = ko.observable(false).extend({'throttle': 100}); // contacts + this.contactTags = ko.observableArray([]); this.contacts = ko.observableArray([]); this.contacts.loading = ko.observable(false).extend({'throttle': 200}); this.contacts.importing = ko.observable(false).extend({'throttle': 200}); this.contacts.syncing = ko.observable(false).extend({'throttle': 200}); this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200}); this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200}); - + this.allowContactsSync = ko.observable(false); this.enableContactsSync = ko.observable(false); this.contactsSyncUrl = ko.observable(''); @@ -15406,11 +15597,11 @@ function WebMailDataStorage() this.messageListEndFolder = ko.observable(''); this.messageListEndSearch = ko.observable(''); this.messageListEndPage = ko.observable(1); - + this.messageListEndHash = ko.computed(function () { return this.messageListEndFolder() + '|' + this.messageListEndSearch() + '|' + this.messageListEndPage(); }, this); - + this.messageListPageCount = ko.computed(function () { var iPage = Math.ceil(this.messageListCount() / this.messagesPerPage()); return 0 >= iPage ? 1 : iPage; @@ -15443,7 +15634,7 @@ function WebMailDataStorage() this.messageListCompleteLoading.subscribe(function (bValue) { this.messageListCompleteLoadingThrottle(bValue); }, this); - + this.messageList.subscribe(_.debounce(function (aList) { _.each(aList, function (oItem) { if (oItem.newForAnimation()) @@ -15460,7 +15651,7 @@ function WebMailDataStorage() this.messageLoadingThrottle = ko.observable(false).extend({'throttle': 50}); this.message.focused = ko.observable(false); - + this.message.subscribe(function (oMessage) { if (!oMessage) { @@ -15490,7 +15681,7 @@ function WebMailDataStorage() RL.data().keyScope(Enums.KeyState.MessageList); } }); - + this.folderList.focused.subscribe(function (bValue) { if (bValue) { @@ -15501,11 +15692,11 @@ function WebMailDataStorage() RL.data().keyScope(Enums.KeyState.MessageList); } }); - + this.messageLoading.subscribe(function (bValue) { this.messageLoadingThrottle(bValue); }, this); - + this.messageFullScreenMode = ko.observable(false); this.messageError = ko.observable(''); @@ -15526,13 +15717,13 @@ function WebMailDataStorage() }, this); this.currentMessage = ko.observable(null); - + this.messageListChecked = ko.computed(function () { return _.filter(this.messageList(), function (oItem) { return oItem.checked(); }); }, this).extend({'rateLimit': 0}); - + this.hasCheckedMessages = ko.computed(function () { return 0 < this.messageListChecked().length; }, this).extend({'rateLimit': 0}); @@ -15619,7 +15810,7 @@ WebMailDataStorage.prototype.purgeMessageBodyCache = function() oMessagesBodiesDom = null, iEnd = Globals.iMessageBodyCacheCount - Consts.Values.MessageBodyCacheLimit ; - + if (0 < iEnd) { oMessagesBodiesDom = this.messagesBodiesDom(); @@ -15652,7 +15843,7 @@ WebMailDataStorage.prototype.populateDataOnStart = function() this.accountIncLogin(RL.settingsGet('IncLogin')); this.accountOutLogin(RL.settingsGet('OutLogin')); this.projectHash(RL.settingsGet('ProjectHash')); - + this.displayName(RL.settingsGet('DisplayName')); this.replyTo(RL.settingsGet('ReplyTo')); this.signature(RL.settingsGet('Signature')); @@ -15694,7 +15885,7 @@ WebMailDataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUid { oNotification.show(); } - + window.setTimeout((function (oLocalNotifications) { return function () { if (oLocalNotifications.cancel) @@ -15897,7 +16088,7 @@ WebMailDataStorage.prototype.hideMessageBodies = function () WebMailDataStorage.prototype.getNextFolderNames = function (bBoot) { bBoot = Utils.isUnd(bBoot) ? false : !!bBoot; - + var aResult = [], iLimit = 10, @@ -15933,10 +16124,10 @@ WebMailDataStorage.prototype.getNextFolderNames = function (bBoot) { return 1; } - + return 0; }); - + _.find(aTimeouts, function (aItem) { var oFolder = RL.cache().getFolderFromCacheList(aItem[1]); if (oFolder) @@ -15944,7 +16135,7 @@ WebMailDataStorage.prototype.getNextFolderNames = function (bBoot) oFolder.interval = iUtc; aResult.push(aItem[1]); } - + return iLimit <= aResult.length; }); @@ -15962,7 +16153,7 @@ WebMailDataStorage.prototype.removeMessagesFromList = function ( { sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : ''; bCopy = Utils.isUnd(bCopy) ? false : !!bCopy; - + aUidForRemove = _.map(aUidForRemove, function (mValue) { return Utils.pInt(mValue); }); @@ -16022,7 +16213,7 @@ WebMailDataStorage.prototype.removeMessagesFromList = function ( else { oData.messageListIsNotCompleted(true); - + _.each(aMessages, function (oMessage) { if (oCurrentMessage && oCurrentMessage.hash === oMessage.hash) { @@ -16093,7 +16284,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) oBody = $('').hide().addClass('rl-cache-class'); oBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount); - + if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html) { bIsHtml = true; @@ -16103,7 +16294,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) { bIsHtml = false; sPlain = oData.Result.Plain.toString(); - + if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && RL.data().allowOpenPGP() && Utils.isNormal(oData.Result.PlainRaw)) @@ -16116,7 +16307,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oMessage.plainRaw) && /-----BEGIN PGP SIGNATURE-----/.test(oMessage.plainRaw); } - + $proxyDiv.empty(); if (bPgpSigned && oMessage.isPgpSigned()) { @@ -16128,7 +16319,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) } else if (bPgpEncrypted && oMessage.isPgpEncrypted()) { - sPlain = + sPlain = $proxyDiv.append( $('').text(oMessage.plainRaw) ).html() @@ -16205,7 +16396,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached) { RL.setMessageSeen(oMessage); } - + Utils.windowResize(); } }; @@ -16258,7 +16449,7 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached) if (oFolder && !bCached) { oFolder.interval = iUtc; - + RL.cache().setFolderHash(oData.Result.Folder, oData.Result.FolderHash); if (Utils.isNormal(oData.Result.MessageCount)) @@ -16429,7 +16620,7 @@ WebMailDataStorage.prototype.findSelfPrivateKey = function (sPassword) { return this.findPrivateKeyByEmail(this.accountEmail(), sPassword); }; - + /** * @constructor */ @@ -16703,7 +16894,7 @@ AbstractAjaxRemoteStorage.prototype.jsVersion = function (fCallback, sVersion) 'Version': sVersion }); }; - + /** * @constructor * @extends AbstractAjaxRemoteStorage @@ -16711,7 +16902,7 @@ AbstractAjaxRemoteStorage.prototype.jsVersion = function (fCallback, sVersion) function WebMailAjaxRemoteStorage() { AbstractAjaxRemoteStorage.call(this); - + this.oRequests = {}; } @@ -17390,11 +17581,12 @@ WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, iOffset, iLim /** * @param {?Function} fCallback */ -WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, aProperties) +WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties) { this.defaultRequest(fCallback, 'ContactSave', { 'RequestUid': sRequestUid, 'Uid': Utils.trim(sUid), + 'Tags': Utils.trim(sTags), 'Properties': aProperties }); }; @@ -17495,7 +17687,7 @@ WebMailAjaxRemoteStorage.prototype.socialUsers = function (fCallback) this.defaultRequest(fCallback, 'SocialUsers'); }; - + /** * @constructor */ @@ -17578,7 +17770,7 @@ AbstractCacheStorage.prototype.setEmailsPicsHashesData = function (oData) { this.oEmailsPicsHashes = oData; }; - + /** * @constructor * @extends AbstractCacheStorage @@ -17896,7 +18088,7 @@ WebMailCacheStorage.prototype.storeMessageFlagsToCacheByFolderAndUid = function this.setMessageFlagsToCache(sFolder, sUid, aFlags); } }; - + /** * @param {Array} aViewModels * @constructor @@ -18074,7 +18266,7 @@ AbstractSettings.prototype.routes = function () ['', oRules] ]; }; - + /** * @constructor * @extends KnoinAbstractScreen @@ -18089,7 +18281,7 @@ _.extend(LoginScreen.prototype, KnoinAbstractScreen.prototype); LoginScreen.prototype.onShow = function () { RL.setTitle(''); -}; +}; /** * @constructor * @extends KnoinAbstractScreen @@ -18260,7 +18452,7 @@ MailBoxScreen.prototype.routes = function () [/^([^\/]*)$/, {'normalize_': fNormS}] ]; }; - + /** * @constructor * @extends AbstractSettings @@ -18289,7 +18481,7 @@ SettingsScreen.prototype.onShow = function () RL.setTitle(this.sSettingsTitle); RL.data().keyScope(Enums.KeyState.Settings); }; - + /** * @constructor * @extends KnoinAbstractBoot @@ -18637,7 +18829,7 @@ AbstractApp.prototype.bootstart = function () ssm.ready(); }; - + /** * @constructor * @extends AbstractApp @@ -18650,7 +18842,7 @@ function RainLoopApp() this.oRemote = null; this.oCache = null; this.oMoveCache = {}; - + this.quotaDebounce = _.debounce(this.quota, 1000 * 30); this.moveOrDeleteResponseHelper = _.bind(this.moveOrDeleteResponseHelper, this); @@ -18827,11 +19019,11 @@ RainLoopApp.prototype.contactsSync = function (fResultFunc) { return false; } - + oContacts.syncing(true); - + RL.remote().contactsSync(function (sResult, oData) { - + oContacts.syncing(false); if (fResultFunc) @@ -18849,14 +19041,14 @@ RainLoopApp.prototype.messagesMoveTrigger = function () self = this, sSpamFolder = RL.data().spamFolder() ; - + _.each(this.oMoveCache, function (oItem) { - + var bSpam = sSpamFolder === oItem['To'], bHam = !bSpam && sSpamFolder === oItem['From'] && 'INBOX' === oItem['To'] ; - + RL.remote().messagesMove(self.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'], bSpam ? 'SPAM' : (bHam ? 'HAM' : '')); }); @@ -18910,7 +19102,7 @@ RainLoopApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData) else { RL.cache().setFolderHash(RL.data().currentFolderFullNameRaw(), ''); - + if (oData && -1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage])) { @@ -18983,14 +19175,14 @@ RainLoopApp.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFol { kn.showScreenPopup(PopupsFolderSystemViewModel, [nSetSystemFoldersNotification]); } - else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType && + else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType && (sFromFolderFullNameRaw === oData.spamFolder() || sFromFolderFullNameRaw === oData.trashFolder()))) { kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () { self.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); oData.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); - + }]); } else if (oMoveFolder) @@ -19107,7 +19299,7 @@ RainLoopApp.prototype.reloadOpenPgpKeys = function () RainLoopApp.prototype.accountsAndIdentities = function () { var oRainLoopData = RL.data(); - + oRainLoopData.accountsLoading(true); oRainLoopData.identitiesLoading(true); @@ -19115,14 +19307,14 @@ RainLoopApp.prototype.accountsAndIdentities = function () oRainLoopData.accountsLoading(false); oRainLoopData.identitiesLoading(false); - + if (Enums.StorageResultType.Success === sResult && oData.Result) { - var + var sParentEmail = RL.settingsGet('ParentEmail'), sAccountEmail = oRainLoopData.accountEmail() ; - + sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail; if (Utils.isArray(oData.Result['Accounts'])) @@ -19131,21 +19323,21 @@ RainLoopApp.prototype.accountsAndIdentities = function () return new AccountModel(sValue, sValue !== sParentEmail); })); } - + if (Utils.isArray(oData.Result['Identities'])) { oRainLoopData.identities(_.map(oData.Result['Identities'], function (oIdentityData) { - - var + + var sId = Utils.pString(oIdentityData['Id']), sEmail = Utils.pString(oIdentityData['Email']), oIdentity = new IdentityModel(sId, sEmail, sId !== sAccountEmail) ; - + oIdentity.name(Utils.pString(oIdentityData['Name'])); oIdentity.replyTo(Utils.pString(oIdentityData['ReplyTo'])); oIdentity.bcc(Utils.pString(oIdentityData['Bcc'])); - + return oIdentity; })); } @@ -19156,7 +19348,7 @@ RainLoopApp.prototype.accountsAndIdentities = function () RainLoopApp.prototype.quota = function () { this.remote().quota(function (sResult, oData) { - if (Enums.StorageResultType.Success === sResult && oData && oData.Result && + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isArray(oData.Result) && 1 < oData.Result.length && Utils.isPosNumeric(oData.Result[0], true) && Utils.isPosNumeric(oData.Result[1], true)) { @@ -19193,7 +19385,7 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList) if (oFolder) { oFolder.interval = iUtc; - + if (oData.Result.Hash) { RL.cache().setFolderHash(oData.Result.Folder, oData.Result.Hash); @@ -19290,7 +19482,7 @@ RainLoopApp.prototype.folderInformationMultiply = function (bBoot) if (oData && oData.Result && oData.Result.List && Utils.isNonEmptyArray(oData.Result.List)) { _.each(oData.Result.List, function (oItem) { - + var aList = [], sHash = RL.cache().getFolderHash(oItem.Folder), @@ -19574,7 +19766,7 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa } } } - + if (oItem.subScribed() && 0 < oItem.subFolders().length) { aResult = aResult.concat(RL.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [], @@ -19608,10 +19800,21 @@ RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback) { fCallback([]); } - + }, sQuery); }; +/** + * @param {string} sQuery + * @param {Function} fCallback + */ +RainLoopApp.prototype.getContactsTagsAutocomplete = function (sQuery, fCallback) +{ + fCallback(_.filter(RL.data().contactTags(), function (oContactTag) { + return oContactTag && oContactTag.filterHelper(sQuery); + })); +}; + RainLoopApp.prototype.emailsPicsHashes = function () { RL.remote().emailsPicsHashes(function (sResult, oData) { @@ -19659,7 +19862,7 @@ RainLoopApp.prototype.bootstart = function () bFacebook = RL.settingsGet('AllowFacebookSocial'), bTwitter = RL.settingsGet('AllowTwitterSocial') ; - + if (!RL.settingsGet('ChangePasswordIsAllowed')) { Utils.removeSettingsViewModel(SettingsChangePasswordScreen); @@ -19674,7 +19877,7 @@ RainLoopApp.prototype.bootstart = function () { Utils.removeSettingsViewModel(SettingsAccounts); } - + if (RL.settingsGet('AllowIdentities')) { Utils.removeSettingsViewModel(SettingsIdentity); @@ -19683,7 +19886,7 @@ RainLoopApp.prototype.bootstart = function () { Utils.removeSettingsViewModel(SettingsIdentities); } - + if (!RL.settingsGet('OpenPGP')) { Utils.removeSettingsViewModel(SettingsOpenPGP); @@ -19698,12 +19901,12 @@ RainLoopApp.prototype.bootstart = function () { Utils.removeSettingsViewModel(SettingsSocialScreen); } - + if (!RL.settingsGet('AllowThemes')) { Utils.removeSettingsViewModel(SettingsThemes); } - + Utils.initOnStartOrLangChange(function () { $.extend(true, $.magnificPopup.defaults, { @@ -19751,9 +19954,9 @@ RainLoopApp.prototype.bootstart = function () { RL.data().openpgpKeyring = new window.openpgp.Keyring(); RL.data().allowOpenPGP(true); - + RL.pub('openpgp.init'); - + RL.reloadOpenPgpKeys(); } } @@ -19765,7 +19968,7 @@ RainLoopApp.prototype.bootstart = function () } kn.startScreens([MailBoxScreen, SettingsScreen]); - + if (bGoogle || bFacebook || bTwitter) { RL.socialUsers(true); @@ -19801,7 +20004,7 @@ RainLoopApp.prototype.bootstart = function () window.setInterval(function () { RL.contactsSync(); }, iContactsSyncInterval * 60000 + 5000); - + _.delay(function () { RL.contactsSync(); }, 5000); @@ -19861,7 +20064,7 @@ RainLoopApp.prototype.bootstart = function () Utils.initLayoutResizer('#rl-left', '#rl-right', Enums.ClientSideKeyName.FolderListSize); }); } - + }, this)); } else @@ -19928,7 +20131,7 @@ RainLoopApp.prototype.bootstart = function () * @type {RainLoopApp} */ RL = new RainLoopApp(); - + $html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile'); $window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS); @@ -19979,9 +20182,9 @@ window['__RLBOOT'] = function (fCall) { window['__RLBOOT'] = null; }); }; - + if (window.SimplePace) { window.SimplePace.add(10); -} - +} + }(window, jQuery, ko, crossroads, hasher, moment, Jua, _, ifvisible, key)); \ No newline at end of file diff --git a/rainloop/v/0.0.0/static/js/app.min.js b/rainloop/v/0.0.0/static/js/app.min.js index 69533f4ed..b06601649 100644 --- a/rainloop/v/0.0.0/static/js/app.min.js +++ b/rainloop/v/0.0.0/static/js/app.min.js @@ -1,10 +1,10 @@ /*! RainLoop Webmail Main Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -!function(a,b,c,d,e,f,g,h,i,j){"use strict";function k(){this.sBase="#/",this.sVersion=Ob.settingsGet("Version"),this.sSpecSuffix=Ob.settingsGet("AuthAccountHash")||"0",this.sServer=(Ob.settingsGet("IndexFile")||"./")+"?"}function l(a,c,d,e){var f=this;f.editor=null,f.iBlurTimer=0,f.fOnBlur=c||null,f.fOnReady=d||null,f.fOnModeChange=e||null,f.$element=b(a),f.init()}function m(a,b,d,e,f,g){this.list=a,this.listChecked=c.computed(function(){return h.filter(this.list(),function(a){return a.checked()})},this).extend({rateLimit:0}),this.isListChecked=c.computed(function(){return 0]*>/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,"")},W.plainToHtml=function(a){return a.toString().replace(/&/g,"&").replace(/>/g,">").replace(/")},W.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},W.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:W.isUnd(c)?a.toString():c.toString(),custom:W.isUnd(c)?!1:!0,title:W.isUnd(c)?"":a.toString(),value:a.toString()};(W.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}},W.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()}},W.disableKeyFilter=function(){a.key&&(key.filter=function(){return hb.data().useKeyboardShortcuts()})},W.restoreKeyFilter=function(){a.key&&(key.filter=function(a){if(hb.data().useKeyboardShortcuts()){var b=a.target||a.srcElement,c=b?b.tagName:"";return c=c.toUpperCase(),!("INPUT"===c||"SELECT"===c||"TEXTAREA"===c||b&&"DIV"===c&&"editorHtmlArea"===b.className&&b.contentEditable)}return!1})},W.detectDropdownVisibility=f.debounce(function(){Z.dropdownVisibility(!!f.find(_,function(a){return a.hasClass("open")}))},50),Y={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return Y.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=Y._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 Y._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(!Z.bMobileDevice){var e=b(a),f=e.data("tooltip-class")||"",g=e.data("tooltip-placement")||"top";e.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:g,trigger:"hover",title:function(){return e.is(".disabled")||Z.dropdownVisibility()?"":''+W.i18n(c.utils.unwrapObservable(d()))+""}}).click(function(){e.tooltip("hide")}),Z.dropdownVisibility.subscribe(function(a){a&&e.tooltip("hide")})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a),e=d.data("tooltip-class")||"",f=d.data("tooltip-placement")||"top";d.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:f,title:function(){return d.is(".disabled")||Z.dropdownVisibility()?"":''+c()()+""}}).click(function(){d.tooltip("hide")}),Z.dropdownVisibility.subscribe(function(a){a&&d.tooltip("hide")})}},c.bindingHandlers.tooltip3={init:function(a){var c=b(a);c.tooltip({container:"body",trigger:"hover manual",title:function(){return c.data("tooltip3-data")||""}}),Z.dropdownVisibility.subscribe(function(a){a&&c.tooltip("hide")}),fb.click(function(){c.tooltip("hide")})},update:function(a,d){var e=c.utils.unwrapObservable(d());""===e?b(a).data("tooltip3-data","").tooltip("hide"):b(a).data("tooltip3-data",e).tooltip("show")}},c.bindingHandlers.registrateBootstrapDropdown={init:function(a){_.push(b(a))}},c.bindingHandlers.openDropdownTrigger={update:function(a,d){if(c.utils.unwrapObservable(d())){var e=b(a);e.hasClass("open")||(e.find(".dropdown-toggle").dropdown("toggle"),W.detectDropdownVisibility()),d()(!1)}}},c.bindingHandlers.dropdownCloser={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&&!W.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&&!W.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.clickOnTrue={update:function(a,d){c.utils.unwrapObservable(d())&&b(a).click()}},c.bindingHandlers.modal={init:function(a,d){b(a).toggleClass("fade",!Z.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("shown",function(){W.windowResize()}).find(".close").click(function(){d()(!1)})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){W.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),W.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=W.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=W.pInt(e[2]),g=eb.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(!Z.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),W.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),W.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)},b(d).draggable(k).on("mousedown",function(){W.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!Z.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){Z.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(),g=function(a){e&&e.focusTrigger&&e.focusTrigger(a)};d.inputosaurus({parseOnBlur:!0,allowDragAndDrop:!0,focusCallback:g,inputDelimiters:[",",";"],autoCompleteSource:function(a,b){hb.getAutocomplete(a.term,function(a){b(f.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return f.map(a,function(a){var b=W.trim(a),c=null;return""!==b?(c=new o,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:f.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(a){a&&d.inputosaurus("focus")})}},c.bindingHandlers.contactTags={init:function(a,c){var d=b(a),e=c(),g=function(a){e&&e.focusTrigger&&e.focusTrigger(a)};d.inputosaurus({parseOnBlur:!0,allowDragAndDrop:!1,focusCallback:g,inputDelimiters:[";"],outputDelimiter:";",autoCompleteSource:function(a,b){hb.getContactsTagsAutocomplete(a.term,function(a){b(f.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return f.map(a,function(a){var b=W.trim(a),c=null;return""!==b?(c=new p,c.name(b),[c.toLine(!1),c]):[b,null]})},change:f.bind(function(a){d.data("ContactsTagsValue",a.target.value),e(a.target.value)},this)}),e.subscribe(function(a){d.data("ContactsTagsValue")!==a&&(d.val(a),d.data("ContactsTagsValue",a),d.inputosaurus("refresh"))}),e.focusTrigger&&e.focusTrigger.subscribe(function(a){a&&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(W.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},W.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=W.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=W.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),W.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},g.prototype.root=function(){return this.sBase},g.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},g.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},g.prototype.uploadContacts=function(){return this.sServer+"/UploadContacts/"+this.sSpecSuffix+"/"},g.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},g.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},g.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},g.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},g.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},g.prototype.messagePreview=function(){return this.sBase+"mailbox/message-preview"},g.prototype.settings=function(a){var b=this.sBase+"settings";return W.isUnd(a)||""===a||(b+="/"+a),b},g.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},g.prototype.mailBox=function(a,b,c){b=W.isNormal(b)?W.pInt(b):1,c=W.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},g.prototype.phpInfo=function(){return this.sServer+"Info"},g.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},g.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},g.prototype.exportContactsVcf=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsVcf/"},g.prototype.exportContactsCsv=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsCsv/"},g.prototype.emptyContactPic=function(){return"rainloop/v/"+this.sVersion+"/static/css/images/empty-contact.png"},g.prototype.sound=function(a){return"rainloop/v/"+this.sVersion+"/static/sounds/"+a +},g.prototype.themePreviewLink=function(a){var b="rainloop/v/"+this.sVersion+"/";return"@custom"===a.substr(-7)&&(a=W.trim(a.substring(0,a.length-7)),b=""),b+"themes/"+encodeURI(a)+"/images/preview.png"},g.prototype.notificationMailIcon=function(){return"rainloop/v/"+this.sVersion+"/static/css/images/icom-message-notification.png"},g.prototype.openPgpJs=function(){return"rainloop/v/"+this.sVersion+"/static/js/openpgp.min.js"},g.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},X.oViewModelsHooks={},X.oSimpleHooks={},X.regViewModelHook=function(a,b){b&&(b.__hookName=a)},X.addHook=function(a,b){W.isFunc(b)&&(W.isArray(X.oSimpleHooks[a])||(X.oSimpleHooks[a]=[]),X.oSimpleHooks[a].push(b))},X.runHook=function(a,b){W.isArray(X.oSimpleHooks[a])&&(b=b||[],f.each(X.oSimpleHooks[a],function(a){a.apply(null,b)}))},X.mainSettingsGet=function(a){return hb?hb.settingsGet(a):null},X.remoteRequest=function(a,b,c,d,e,f){hb&&hb.remote().defaultRequest(a,b,c,d,e,f)},X.settingsGet=function(a,b){var c=X.mainSettingsGet("Plugins");return c=c&&W.isUnd(c[a])?null:c[a],c?W.isUnd(c[b])?null:c[b]:null},h.supported=function(){return!0},h.prototype.set=function(a,c){var d=b.cookie(T.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(T.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},h.prototype.get=function(a){var c=b.cookie(T.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!W.isUnd(d[a])?d[a]:null}catch(e){}return d},i.supported=function(){return!!a.localStorage},i.prototype.set=function(b,c){var d=a.localStorage[T.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[T.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},i.prototype.get=function(b){var c=a.localStorage[T.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!W.isUnd(d[b])?d[b]:null}catch(e){}return d},j.prototype.oDriver=null,j.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},j.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},k.prototype.bootstart=function(){},l.prototype.sPosition="",l.prototype.sTemplate="",l.prototype.viewModelName="",l.prototype.viewModelDom=null,l.prototype.viewModelTemplate=function(){return this.sTemplate},l.prototype.viewModelPosition=function(){return this.sPosition},l.prototype.cancelCommand=l.prototype.closeCommand=function(){},l.prototype.storeAndSetKeyScope=function(){this.sCurrentKeyScope=hb.data().keyScope(),hb.data().keyScope(this.sDefaultKeyScope)},l.prototype.restoreKeyScope=function(){hb.data().keyScope(this.sCurrentKeyScope)},l.prototype.registerPopupKeyDown=function(){var a=this;eb.on("keydown",function(b){if(b&&a.modalVisibility&&a.modalVisibility()){if(!this.bDisabeCloseOnEsc&&U.EventKeyCode.Esc===b.keyCode)return W.delegateRun(a,"cancelCommand"),!1;if(U.EventKeyCode.Backspace===b.keyCode&&!W.inFocus())return!1}return!0})},m.prototype.oCross=null,m.prototype.sScreenName="",m.prototype.aViewModels=[],m.prototype.viewModels=function(){return this.aViewModels},m.prototype.screenName=function(){return this.sScreenName},m.prototype.routes=function(){return null},m.prototype.__cross=function(){return this.oCross},m.prototype.__start=function(){var a=this.routes(),b=null,c=null;W.isNonEmptyArray(a)&&(c=f.bind(this.onRoute||W.emptyFunction,this),b=d.create(),f.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},n.constructorEnd=function(a){W.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},n.prototype.sDefaultScreenName="",n.prototype.oScreens={},n.prototype.oBoot=null,n.prototype.oCurrentScreen=null,n.prototype.hideLoading=function(){b("#rl-loading").hide()},n.prototype.routeOff=function(){e.changed.active=!1},n.prototype.routeOn=function(){e.changed.active=!0},n.prototype.setBoot=function(a){return W.isNormal(a)&&(this.oBoot=a),this},n.prototype.screen=function(a){return""===a||W.isUnd(this.oScreens[a])?null:this.oScreens[a]},n.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),g=e.viewModelPosition(),h=b("#rl-content #rl-"+g.toLowerCase()),i=null;a.__builded=!0,a.__vm=e,e.data=hb.data(),e.viewModelName=a.__name,h&&1===h.length?(i=b(" ").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),i.appendTo(h),e.viewModelDom=i,a.__dom=i,"Popups"===g&&(e.cancelCommand=e.closeCommand=W.createCommand(e,function(){ab.hideScreenPopup(a)}),e.modalVisibility.subscribe(function(a){var b=this;a?(this.viewModelDom.show(),this.storeAndSetKeyScope(),hb.popupVisibilityNames.push(this.viewModelName),e.viewModelDom.css("z-index",3e3+hb.popupVisibilityNames().length+10),W.delegateRun(this,"onFocus",[],500)):(W.delegateRun(this,"onHide"),this.restoreKeyScope(),hb.popupVisibilityNames.remove(this.viewModelName),e.viewModelDom.css("z-index",2e3),f.delay(function(){b.viewModelDom.hide()},300))},e)),X.runHook("view-model-pre-build",[a.__name,e,i]),c.applyBindings(e,i[0]),W.delegateRun(e,"onBuild",[i]),e&&"Popups"===g&&e.registerPopupKeyDown(),X.runHook("view-model-post-build",[a.__name,e,i])):W.log("Cannot find view model position: "+g)}return a?a.__vm:null},n.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},n.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__vm.modalVisibility(!1),X.runHook("view-model-on-hide",[a.__name,a.__vm]))},n.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__vm.modalVisibility(!0),W.delegateRun(a.__vm,"onShow",b||[]),X.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},n.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===W.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,W.isNonEmptyArray(d.viewModels())&&f.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),W.delegateRun(d,"onBuild")),f.defer(function(){c.oCurrentScreen&&(W.delegateRun(c.oCurrentScreen,"onHide"),W.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),W.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(W.delegateRun(c.oCurrentScreen,"onShow"),X.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),W.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),W.delegateRun(a.__vm,"onShow"),W.delegateRun(a.__vm,"onFocus",[],200),X.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},n.prototype.startScreens=function(a){b("#rl-content").css({visibility:"hidden"}),f.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),f.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),X.runHook("screen-pre-start",[a.screenName(),a]),W.delegateRun(a,"onStart"),X.runHook("screen-post-start",[a.screenName(),a]))},this);var c=d.create();c.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,f.bind(this.screenOnRoute,this)),e.initialized.add(c.parse,c),e.changed.add(c.parse,c),e.init(),b("#rl-content").css({visibility:"visible"}),f.delay(function(){db.removeClass("rl-started-trigger").addClass("rl-started")},50)},n.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=W.isUnd(c)?!1:!!c,(W.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)},n.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},ab=new n,o.newInstanceFromJson=function(a){var b=new o;return b.initByJson(a)?b:null},o.prototype.name="",o.prototype.email="",o.prototype.privateType=null,o.prototype.clear=function(){this.email="",this.name="",this.privateType=null},o.prototype.validate=function(){return""!==this.name||""!==this.email},o.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},o.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},o.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=U.EmailType.Facebook),null===this.privateType&&(this.privateType=U.EmailType.Default)),this.privateType},o.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},o.prototype.parse=function(a){this.clear(),a=W.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)},o.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=W.trim(a.Name),this.email=W.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},o.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=W.isUnd(b)?!1:!!b,c=W.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+W.encodeHtml(this.name)+"":c?W.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=W.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+W.encodeHtml(d)+""+W.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=W.encodeHtml(d))):b&&(d=''+W.encodeHtml(this.email)+""))),d},o.prototype.mailsoParse=function(a){if(a=W.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: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(h),e.data=hb.data(),e.viewModelDom=i,e.__rlSettingsData=g.__rlSettingsData,g.__dom=i,g.__builded=!0,g.__vm=e,c.applyBindings(e,i[0]),W.delegateRun(e,"onBuild",[i])):W.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&f.defer(function(){d.oCurrentSubScreen&&(W.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),W.delegateRun(d.oCurrentSubScreen,"onShow"),W.delegateRun(d.oCurrentSubScreen,"onFocus",[],200),f.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)),W.windowResize()})):ab.setHash(hb.link().settings(),!1,!0)},O.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(W.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},O.prototype.onBuild=function(){f.each($.settings,function(a){a&&a.__rlSettingsData&&!f.find($["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!f.find($["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},O.prototype.routes=function(){var a=f.find($.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=W.isUnd(c.subname)?b:W.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},f.extend(P.prototype,m.prototype),P.prototype.onShow=function(){hb.setTitle("")},f.extend(Q.prototype,O.prototype),Q.prototype.onShow=function(){hb.setTitle("")},f.extend(R.prototype,k.prototype),R.prototype.oSettings=null,R.prototype.oPlugins=null,R.prototype.oLocal=null,R.prototype.oLink=null,R.prototype.oSubs={},R.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):(Z.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},R.prototype.link=function(){return null===this.oLink&&(this.oLink=new g),this.oLink},R.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new j),this.oLocal},R.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=W.isNormal(bb)?bb:{}),W.isUnd(this.oSettings[a])?null:this.oSettings[a]},R.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=W.isNormal(bb)?bb:{}),this.oSettings[a]=b},R.prototype.setTitle=function(b){b=(W.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=W.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=W.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=W.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},o.prototype.inputoTagLine=function(){return 0 (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&&-1 b?b:a))},this),this.body=null,this.plainRaw="",this.isRtl=c.observable(!1),this.isHtml=c.observable(!1),this.hasImages=c.observable(!1),this.attachments=c.observableArray([]),this.isPgpSigned=c.observable(!1),this.isPgpEncrypted=c.observable(!1),this.pgpSignedVerifyStatus=c.observable(zb.SignedVerifyStatus.None),this.pgpSignedVerifyUser=c.observable(""),this.priority=c.observable(zb.MessagePriority.Normal),this.readReceipt=c.observable(""),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid=c.observable(0),this.threads=c.observableArray([]),this.threadsLen=c.observable(0),this.hasUnseenSubMessage=c.observable(!1),this.hasFlaggedSubMessage=c.observable(!1),this.lastInCollapsedThread=c.observable(!1),this.lastInCollapsedThreadLoading=c.observable(!1),this.threadsLenResult=c.computed(function(){var a=this.threadsLen();return 0===this.parentUid()&&a>0?a+1:""},this)}function A(){this.name=c.observable(""),this.fullName="",this.fullNameRaw="",this.fullNameHash="",this.delimiter="",this.namespace="",this.deep=0,this.interval=0,this.selectable=!1,this.existen=!0,this.type=c.observable(zb.FolderType.User),this.focused=c.observable(!1),this.selected=c.observable(!1),this.edited=c.observable(!1),this.collapsed=c.observable(!0),this.subScribed=c.observable(!0),this.subFolders=c.observableArray([]),this.deleteAccess=c.observable(!1),this.actionBlink=c.observable(!1).extend({falseTimeout:1e3}),this.nameForEdit=c.observable(""),this.name.subscribe(function(a){this.nameForEdit(a)},this),this.edited.subscribe(function(a){a&&this.nameForEdit(this.name())},this),this.privateMessageCountAll=c.observable(0),this.privateMessageCountUnread=c.observable(0),this.collapsedPrivate=c.observable(!0)}function B(a,b){this.email=a,this.deleteAccess=c.observable(!1),this.canBeDalete=c.observable(b)}function C(a,b,d){this.id=a,this.email=c.observable(b),this.name=c.observable(""),this.replyTo=c.observable(""),this.bcc=c.observable(""),this.deleteAccess=c.observable(!1),this.canBeDalete=c.observable(d)}function D(a,b,d,e,f,g,h){this.index=a,this.id=d,this.guid=b,this.user=e,this.email=f,this.armor=h,this.isPrivate=!!g,this.deleteAccess=c.observable(!1)}function E(){r.call(this,"Popups","PopupsFolderClear"),this.selectedFolder=c.observable(null),this.clearingProcess=c.observable(!1),this.clearingError=c.observable(""),this.folderFullNameForClear=c.computed(function(){var a=this.selectedFolder();return a?a.printableFullName():""},this),this.folderNameForClear=c.computed(function(){var a=this.selectedFolder();return a?a.localName():""},this),this.dangerDescHtml=c.computed(function(){return Bb.i18n("POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1",{FOLDER:this.folderNameForClear()})},this),this.clearCommand=Bb.createCommand(this,function(){var a=this,b=this.selectedFolder();b&&(Ob.data().message(null),Ob.data().messageList([]),this.clearingProcess(!0),Ob.cache().setFolderHash(b.fullNameRaw,""),Ob.remote().folderClear(function(b,c){a.clearingProcess(!1),zb.StorageResultType.Success===b&&c&&c.Result?(Ob.reloadMessageList(!0),a.cancelCommand()):c&&c.ErrorCode?a.clearingError(Bb.getNotification(c.ErrorCode)):a.clearingError(Bb.getNotification(zb.Notification.MailServerError))},b.fullNameRaw))},function(){var a=this.selectedFolder(),b=this.clearingProcess();return!b&&null!==a}),t.constructorEnd(this)}function F(){r.call(this,"Popups","PopupsFolderCreate"),Bb.initOnStartOrLangChange(function(){this.sNoParentText=Bb.i18n("POPUPS_CREATE_FOLDER/SELECT_NO_PARENT")},this),this.folderName=c.observable(""),this.folderName.focused=c.observable(!1),this.selectedParentValue=c.observable(yb.Values.UnuseOptionValue),this.parentFolderSelectList=c.computed(function(){var a=Ob.data(),b=[],c=null,d=null,e=a.folderList(),f=function(a){return a?a.isSystemFolder()?a.name()+" "+a.manageFolderSystemName():a.name():""};return b.push(["",this.sNoParentText]),""!==a.namespace&&(c=function(b){return a.namespace!==b.fullNameRaw.substr(0,a.namespace.length)}),Ob.folderListOptionsBuilder([],e,[],b,null,c,d,f)},this),this.createFolder=Bb.createCommand(this,function(){var a=Ob.data(),b=this.selectedParentValue();""===b&&1 =a?1:a},this),this.contactsPagenator=c.computed(Bb.computedPagenatorHelper(this.contactsPage,this.contactsPageCount)),this.emptySelection=c.observable(!0),this.viewClearSearch=c.observable(!1),this.viewID=c.observable(""),this.viewReadOnly=c.observable(!1),this.viewProperties=c.observableArray([]),this.viewSaveTrigger=c.observable(zb.SaveSettingsStep.Idle),this.viewPropertiesNames=this.viewProperties.filter(function(a){return-1 a)break;b[0]&&b[1]&&b[2]&&b[1]===b[2]&&("PRIVATE"===b[1]?e.privateKeys.importKey(b[0]):"PUBLIC"===b[1]&&e.publicKeys.importKey(b[0])),a--}return e.store(),Ob.reloadOpenPgpKeys(),Bb.delegateRun(this,"cancelCommand"),!0}),t.constructorEnd(this)}function M(){r.call(this,"Popups","PopupsViewOpenPgpKey"),this.key=c.observable(""),this.keyDom=c.observable(null),t.constructorEnd(this)}function N(){r.call(this,"Popups","PopupsGenerateNewOpenPgpKey"),this.email=c.observable(""),this.email.focus=c.observable(""),this.email.error=c.observable(!1),this.name=c.observable(""),this.password=c.observable(""),this.keyBitLength=c.observable(2048),this.submitRequest=c.observable(!1),this.email.subscribe(function(){this.email.error(!1)},this),this.generateOpenPgpKeyCommand=Bb.createCommand(this,function(){var b=this,c="",d=null,e=Ob.data().openpgpKeyring;return this.email.error(""===Bb.trim(this.email())),!e||this.email.error()?!1:(c=this.email(),""!==this.name()&&(c=this.name()+" <"+c+">"),this.submitRequest(!0),h.delay(function(){d=a.openpgp.generateKeyPair(1,Bb.pInt(b.keyBitLength()),c,Bb.trim(b.password())),d&&d.privateKeyArmored&&(e.privateKeys.importKey(d.privateKeyArmored),e.publicKeys.importKey(d.publicKeyArmored),e.store(),Ob.reloadOpenPgpKeys(),Bb.delegateRun(b,"cancelCommand")),b.submitRequest(!1)},100),!0)}),t.constructorEnd(this)}function O(){r.call(this,"Popups","PopupsComposeOpenPgp"),this.notification=c.observable(""),this.sign=c.observable(!0),this.encrypt=c.observable(!0),this.password=c.observable(""),this.password.focus=c.observable(!1),this.buttonFocus=c.observable(!1),this.from=c.observable(""),this.to=c.observableArray([]),this.text=c.observable(""),this.resultCallback=null,this.submitRequest=c.observable(!1),this.doCommand=Bb.createCommand(this,function(){var b=this,c=!0,d=Ob.data(),e=null,f=[];this.submitRequest(!0),c&&this.sign()&&""===this.from()&&(this.notification(Bb.i18n("PGP_NOTIFICATIONS/SPECIFY_FROM_EMAIL")),c=!1),c&&this.sign()&&(e=d.findPrivateKeyByEmail(this.from(),this.password()),e||(this.notification(Bb.i18n("PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR",{EMAIL:this.from()})),c=!1)),c&&this.encrypt()&&0===this.to().length&&(this.notification(Bb.i18n("PGP_NOTIFICATIONS/SPECIFY_AT_LEAST_ONE_RECIPIENT")),c=!1),c&&this.encrypt()&&(f=[],h.each(this.to(),function(a){var e=d.findPublicKeysByEmail(a);0===e.length&&c&&(b.notification(Bb.i18n("PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR",{EMAIL:a})),c=!1),f=f.concat(e)}),!c||0!==f.length&&this.to().length===f.length||(c=!1)),h.delay(function(){if(b.resultCallback&&c)try{e&&0===f.length?b.resultCallback(a.openpgp.signClearMessage([e],b.text())):e&&0 0&&b>0&&a>b},this),this.hasMessages=c.computed(function(){return 0 '),e.after(f),e.remove()),f&&f[0]&&(f.attr("data-href",g).attr("data-theme",a[0]),f&&f[0]&&f[0].styleSheet&&!Bb.isUnd(f[0].styleSheet.cssText)?f[0].styleSheet.cssText=a[1]:f.text(a[1])),d.themeTrigger(zb.SaveSettingsStep.TrueResult))}).always(function(){d.iTimer=a.setTimeout(function(){d.themeTrigger(zb.SaveSettingsStep.Idle)},1e3),d.oLastAjax=null})),Ob.remote().saveSettings(null,{Theme:c})},this)}function lb(){this.openpgpkeys=Ob.data().openpgpkeys,this.openpgpkeysPublic=Ob.data().openpgpkeysPublic,this.openpgpkeysPrivate=Ob.data().openpgpkeysPrivate,this.openPgpKeyForDeletion=c.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]})}function mb(){this.leftPanelDisabled=c.observable(!1),this.useKeyboardShortcuts=c.observable(!0),this.keyScopeReal=c.observable(zb.KeyState.All),this.keyScopeFake=c.observable(zb.KeyState.All),this.keyScope=c.computed({owner:this,read:function(){return this.keyScopeFake()},write:function(a){zb.KeyState.Menu!==a&&(zb.KeyState.Compose===a?Bb.disableKeyFilter():Bb.restoreKeyFilter(),this.keyScopeFake(a),Eb.dropdownVisibility()&&(a=zb.KeyState.Menu)),this.keyScopeReal(a)}}),this.keyScopeReal.subscribe(function(a){j.setScope(a)}),this.leftPanelDisabled.subscribe(function(a){Ob.pub("left-panel."+(a?"off":"on"))}),Eb.dropdownVisibility.subscribe(function(a){a?this.keyScope(zb.KeyState.Menu):zb.KeyState.Menu===j.getScope()&&this.keyScope(this.keyScopeFake())},this),Bb.initDataConstructorBySettings(this)}function nb(){mb.call(this);var d=function(a){return function(){var b=Ob.cache().getFolderFromCacheList(a());b&&b.type(zb.FolderType.User)}},e=function(a){return function(b){var c=Ob.cache().getFolderFromCacheList(b);c&&c.type(a)}};this.devEmail="",this.devLogin="",this.devPassword="",this.accountEmail=c.observable(""),this.accountIncLogin=c.observable(""),this.accountOutLogin=c.observable(""),this.projectHash=c.observable(""),this.threading=c.observable(!1),this.lastFoldersHash="",this.remoteSuggestions=!1,this.sentFolder=c.observable(""),this.draftFolder=c.observable(""),this.spamFolder=c.observable(""),this.trashFolder=c.observable(""),this.archiveFolder=c.observable(""),this.sentFolder.subscribe(d(this.sentFolder),this,"beforeChange"),this.draftFolder.subscribe(d(this.draftFolder),this,"beforeChange"),this.spamFolder.subscribe(d(this.spamFolder),this,"beforeChange"),this.trashFolder.subscribe(d(this.trashFolder),this,"beforeChange"),this.archiveFolder.subscribe(d(this.archiveFolder),this,"beforeChange"),this.sentFolder.subscribe(e(zb.FolderType.SentItems),this),this.draftFolder.subscribe(e(zb.FolderType.Draft),this),this.spamFolder.subscribe(e(zb.FolderType.Spam),this),this.trashFolder.subscribe(e(zb.FolderType.Trash),this),this.archiveFolder.subscribe(e(zb.FolderType.Archive),this),this.draftFolderNotEnabled=c.computed(function(){return""===this.draftFolder()||yb.Values.UnuseOptionValue===this.draftFolder()},this),this.displayName=c.observable(""),this.signature=c.observable(""),this.signatureToAll=c.observable(!1),this.replyTo=c.observable(""),this.enableTwoFactor=c.observable(!1),this.accounts=c.observableArray([]),this.accountsLoading=c.observable(!1).extend({throttle:100}),this.identities=c.observableArray([]),this.identitiesLoading=c.observable(!1).extend({throttle:100}),this.contacts=c.observableArray([]),this.contacts.loading=c.observable(!1).extend({throttle:200}),this.contacts.importing=c.observable(!1).extend({throttle:200}),this.contacts.syncing=c.observable(!1).extend({throttle:200}),this.contacts.exportingVcf=c.observable(!1).extend({throttle:200}),this.contacts.exportingCsv=c.observable(!1).extend({throttle:200}),this.allowContactsSync=c.observable(!1),this.enableContactsSync=c.observable(!1),this.contactsSyncUrl=c.observable(""),this.contactsSyncUser=c.observable(""),this.contactsSyncPass=c.observable(""),this.allowContactsSync=c.observable(!!Ob.settingsGet("ContactsSyncIsAllowed")),this.enableContactsSync=c.observable(!!Ob.settingsGet("EnableContactsSync")),this.contactsSyncUrl=c.observable(Ob.settingsGet("ContactsSyncUrl")),this.contactsSyncUser=c.observable(Ob.settingsGet("ContactsSyncUser")),this.contactsSyncPass=c.observable(Ob.settingsGet("ContactsSyncPassword")),this.namespace="",this.folderList=c.observableArray([]),this.folderList.focused=c.observable(!1),this.foldersListError=c.observable(""),this.foldersLoading=c.observable(!1),this.foldersCreating=c.observable(!1),this.foldersDeleting=c.observable(!1),this.foldersRenaming=c.observable(!1),this.foldersChanging=c.computed(function(){var a=this.foldersLoading(),b=this.foldersCreating(),c=this.foldersDeleting(),d=this.foldersRenaming();return a||b||c||d},this),this.foldersInboxUnreadCount=c.observable(0),this.currentFolder=c.observable(null).extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]}),this.currentFolderFullNameRaw=c.computed(function(){return this.currentFolder()?this.currentFolder().fullNameRaw:""},this),this.currentFolderFullName=c.computed(function(){return this.currentFolder()?this.currentFolder().fullName:""},this),this.currentFolderFullNameHash=c.computed(function(){return this.currentFolder()?this.currentFolder().fullNameHash:""},this),this.currentFolderName=c.computed(function(){return this.currentFolder()?this.currentFolder().name():""},this),this.folderListSystemNames=c.computed(function(){var a=["INBOX"],b=this.folderList(),c=this.sentFolder(),d=this.draftFolder(),e=this.spamFolder(),f=this.trashFolder(),g=this.archiveFolder();return Bb.isArray(b)&&0 =a?1:a},this),this.mainMessageListSearch=c.computed({read:this.messageListSearch,write:function(a){Hb.setHash(Ob.link().mailBox(this.currentFolderFullNameHash(),1,Bb.trim(a.toString())))},owner:this}),this.messageListError=c.observable(""),this.messageListLoading=c.observable(!1),this.messageListIsNotCompleted=c.observable(!1),this.messageListCompleteLoadingThrottle=c.observable(!1).extend({throttle:200}),this.messageListCompleteLoading=c.computed(function(){var a=this.messageListLoading(),b=this.messageListIsNotCompleted();return a||b},this),this.messageListCompleteLoading.subscribe(function(a){this.messageListCompleteLoadingThrottle(a)},this),this.messageList.subscribe(h.debounce(function(a){h.each(a,function(a){a.newForAnimation()&&a.newForAnimation(!1)})},500)),this.staticMessageList=new z,this.message=c.observable(null),this.messageLoading=c.observable(!1),this.messageLoadingThrottle=c.observable(!1).extend({throttle:50}),this.message.focused=c.observable(!1),this.message.subscribe(function(b){b?zb.Layout.NoPreview===this.layout()&&this.message.focused(!0):(this.message.focused(!1),this.hideMessageBodies(),zb.Layout.NoPreview===Ob.data().layout()&&-1 0?Math.ceil(b/a*100):0},this),this.allowOpenPGP=c.observable(!1),this.openpgpkeys=c.observableArray([]),this.openpgpKeyring=null,this.openpgpkeysPublic=this.openpgpkeys.filter(function(a){return!(!a||a.isPrivate)}),this.openpgpkeysPrivate=this.openpgpkeys.filter(function(a){return!(!a||!a.isPrivate)}),this.googleActions=c.observable(!1),this.googleLoggined=c.observable(!1),this.googleUserName=c.observable(""),this.facebookActions=c.observable(!1),this.facebookLoggined=c.observable(!1),this.facebookUserName=c.observable(""),this.twitterActions=c.observable(!1),this.twitterLoggined=c.observable(!1),this.twitterUserName=c.observable(""),this.customThemeType=c.observable(zb.CustomThemeType.Light),this.purgeMessageBodyCacheThrottle=h.throttle(this.purgeMessageBodyCache,3e4)}function ob(){this.oRequests={}}function pb(){ob.call(this),this.oRequests={}}function qb(){this.oEmailsPicsHashes={},this.oServices={},this.bAllowGravatar=!!Ob.settingsGet("AllowGravatar")}function rb(){qb.call(this),this.oFoldersCache={},this.oFoldersNamesCache={},this.oFolderHashCache={},this.oFolderUidNextCache={},this.oMessageListHashCache={},this.oMessageFlagsCache={},this.oNewMessage={},this.oRequestedMessage={}}function sb(a){s.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function tb(){s.call(this,"login",[U])}function ub(){s.call(this,"mailbox",[W,Y,Z,$]),this.oLastRoute={}}function vb(){sb.call(this,[X,_,ab]),Bb.initOnStartOrLangChange(function(){this.sSettingsTitle=Bb.i18n("TITLES/SETTINGS")},this,function(){Ob.setTitle(this.sSettingsTitle)})}function wb(){q.call(this),this.oSettings=null,this.oPlugins=null,this.oLocal=null,this.oLink=null,this.oSubs={},this.isLocalAutocomplete=!0,this.popupVisibilityNames=c.observableArray([]),this.popupVisibility=c.computed(function(){return 0 ').appendTo("body"),Lb.on("error",function(a){Ob&&a&&a.originalEvent&&a.originalEvent.message&&-1===Bb.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&Ob.remote().jsError(Bb.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",Kb.attr("class"),Bb.microtime()-Eb.now)}),Mb.on("keydown",function(a){a&&a.ctrlKey&&Kb.addClass("rl-ctrl-key-pressed")}).on("keyup",function(a){a&&!a.ctrlKey&&Kb.removeClass("rl-ctrl-key-pressed")})}function xb(){wb.call(this),this.oData=null,this.oRemote=null,this.oCache=null,this.oMoveCache={},this.quotaDebounce=h.debounce(this.quota,3e4),this.moveOrDeleteResponseHelper=h.bind(this.moveOrDeleteResponseHelper,this),this.messagesMoveTrigger=h.debounce(this.messagesMoveTrigger,500),a.setInterval(function(){Ob.pub("interval.30s")},3e4),a.setInterval(function(){Ob.pub("interval.1m")},6e4),a.setInterval(function(){Ob.pub("interval.2m")},12e4),a.setInterval(function(){Ob.pub("interval.3m")},18e4),a.setInterval(function(){Ob.pub("interval.5m")},3e5),a.setInterval(function(){Ob.pub("interval.10m")},6e5),a.setTimeout(function(){a.setInterval(function(){Ob.pub("interval.10m-after5m")},6e5)},3e5),b.wakeUp(function(){Ob.remote().jsVersion(function(b,c){zb.StorageResultType.Success===b&&c&&!c.Result&&(a.parent&&Ob.settingsGet("InIframe")?a.parent.location.reload():a.location.reload())},Ob.settingsGet("Version"))},{},36e5)}var yb={},zb={},Ab={},Bb={},Cb={},Db={},Eb={},Fb={settings:[],"settings-removed":[],"settings-disabled":[]},Gb=[],Hb=null,Ib=a.rainloopAppData||{},Jb=a.rainloopI18N||{},Kb=b("html"),Lb=b(a),Mb=b(a.document),Nb=a.Notification&&a.Notification.requestPermission?a.Notification:null,Ob=null,Pb=b("");Eb.now=(new Date).getTime(),Eb.momentTrigger=c.observable(!0),Eb.dropdownVisibility=c.observable(!1).extend({rateLimit:0}),Eb.langChangeTrigger=c.observable(!0),Eb.iAjaxErrorCount=0,Eb.iTokenErrorCount=0,Eb.iMessageBodyCacheCount=0,Eb.bUnload=!1,Eb.sUserAgent=(navigator.userAgent||"").toLowerCase(),Eb.bIsiOSDevice=-1 /g,">").replace(/"/g,""").replace(/'/g,"'"):""},Bb.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=Bb.isUnd(b)?100:b;e.length>b;)d=e.substring(0,b),f=d.lastIndexOf(" "),g=d.lastIndexOf("\n"),-1!==g&&(f=g),-1===f&&(f=b),c+=d.substring(0,f)+"\n",e=e.substring(f+1);return c+e},Bb.timeOutAction=function(){var b={};return function(c,d,e){Bb.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),Bb.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),Bb.audio=function(){var b=!1;return function(c,d){if(!1===b)if(Eb.bIsiOSDevice)b=null;else{var e=!1,f=!1,g=a.Audio?new a.Audio:null;g&&g.canPlayType&&g.play?(e=""!==g.canPlayType('audio/mpeg; codecs="mp3"'),e||(f=""!==g.canPlayType('audio/ogg; codecs="vorbis"')),e||f?(b=g,b.preload="none",b.loop=!1,b.autoplay=!1,b.muted=!1,b.src=e?c:d):b=null):b=null}return b}}(),Bb.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},Bb.i18n=function(a,b,c){var d="",e=Bb.isUnd(Jb[a])?Bb.isUnd(c)?a:c:Jb[a];if(!Bb.isUnd(b)&&!Bb.isNull(b))for(d in b)Bb.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},Bb.i18nToNode=function(a){h.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(Bb.i18n(c)):(c=a.data("i18n-html"),c&&a.html(Bb.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",Bb.i18n(c)),c=a.data("i18n-title"),c&&a.attr("title",Bb.i18n(c)))})})},Bb.i18nToDoc=function(){a.rainloopI18N&&(Jb=a.rainloopI18N||{},Bb.i18nToNode(Mb),Eb.langChangeTrigger(!Eb.langChangeTrigger())),a.rainloopI18N={}},Bb.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?Eb.langChangeTrigger.subscribe(function(){a&&a.call(b),c.call(b)}):a&&Eb.langChangeTrigger.subscribe(a,b)},Bb.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&a.contentEditable)},Bb.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},Bb.removeSelection=function(){if(a&&a.getSelection){var b=a.getSelection();b&&b.removeAllRanges&&b.removeAllRanges()}else document&&document.selection&&document.selection.empty&&document.selection.empty()},Bb.replySubjectAdd=function(b,c,d){var e=null,f=Bb.trim(c);return f=null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||Bb.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||Bb.isUnd(e[1])||Bb.isUnd(e[2])||Bb.isUnd(e[3])?b+": "+c:e[1]+(Bb.pInt(e[2])+1)+e[3]:b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),f=(Bb.isUnd(d)?!0:d)?Bb.fixLongSubject(f):f},Bb.fixLongSubject=function(a){var b=0,c=null;a=Bb.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||Bb.isUnd(c[0]))&&(c=null),c&&(b=0,b+=Bb.isUnd(c[2])?1:0+Bb.pInt(c[2]),b+=Bb.isUnd(c[4])?1:0+Bb.pInt(c[4]),a=a.replace(/^Re(\[[\d]+\]|):[\s]{0,3}Re(\[[\d]+\]|):/gi,"Re"+(b>0?"["+b+"]":"")+":"));while(c);return a=a.replace(/[\s]+/," ")},Bb.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},Bb.friendlySize=function(a){return a=Bb.pInt(a),a>=1073741824?Bb.roundNumber(a/1073741824,1)+"GB":a>=1048576?Bb.roundNumber(a/1048576,1)+"MB":a>=1024?Bb.roundNumber(a/1024,0)+"KB":a+"B"},Bb.log=function(b){a.console&&a.console.log&&a.console.log(b)},Bb.getNotification=function(a,b){return a=Bb.pInt(a),zb.Notification.ClientViewError===a&&b?b:Bb.isUnd(Ab[a])?"":Ab[a]},Bb.initNotificationLanguage=function(){Ab[zb.Notification.InvalidToken]=Bb.i18n("NOTIFICATIONS/INVALID_TOKEN"),Ab[zb.Notification.AuthError]=Bb.i18n("NOTIFICATIONS/AUTH_ERROR"),Ab[zb.Notification.AccessError]=Bb.i18n("NOTIFICATIONS/ACCESS_ERROR"),Ab[zb.Notification.ConnectionError]=Bb.i18n("NOTIFICATIONS/CONNECTION_ERROR"),Ab[zb.Notification.CaptchaError]=Bb.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),Ab[zb.Notification.SocialFacebookLoginAccessDisable]=Bb.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),Ab[zb.Notification.SocialTwitterLoginAccessDisable]=Bb.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),Ab[zb.Notification.SocialGoogleLoginAccessDisable]=Bb.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),Ab[zb.Notification.DomainNotAllowed]=Bb.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),Ab[zb.Notification.AccountNotAllowed]=Bb.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),Ab[zb.Notification.AccountTwoFactorAuthRequired]=Bb.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED"),Ab[zb.Notification.AccountTwoFactorAuthError]=Bb.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR"),Ab[zb.Notification.CouldNotSaveNewPassword]=Bb.i18n("NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD"),Ab[zb.Notification.CurrentPasswordIncorrect]=Bb.i18n("NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT"),Ab[zb.Notification.NewPasswordShort]=Bb.i18n("NOTIFICATIONS/NEW_PASSWORD_SHORT"),Ab[zb.Notification.NewPasswordWeak]=Bb.i18n("NOTIFICATIONS/NEW_PASSWORD_WEAK"),Ab[zb.Notification.NewPasswordForbidden]=Bb.i18n("NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT"),Ab[zb.Notification.ContactsSyncError]=Bb.i18n("NOTIFICATIONS/CONTACTS_SYNC_ERROR"),Ab[zb.Notification.CantGetMessageList]=Bb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),Ab[zb.Notification.CantGetMessage]=Bb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),Ab[zb.Notification.CantDeleteMessage]=Bb.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),Ab[zb.Notification.CantMoveMessage]=Bb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),Ab[zb.Notification.CantCopyMessage]=Bb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),Ab[zb.Notification.CantSaveMessage]=Bb.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),Ab[zb.Notification.CantSendMessage]=Bb.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),Ab[zb.Notification.InvalidRecipients]=Bb.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),Ab[zb.Notification.CantCreateFolder]=Bb.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),Ab[zb.Notification.CantRenameFolder]=Bb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),Ab[zb.Notification.CantDeleteFolder]=Bb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),Ab[zb.Notification.CantDeleteNonEmptyFolder]=Bb.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),Ab[zb.Notification.CantSubscribeFolder]=Bb.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),Ab[zb.Notification.CantUnsubscribeFolder]=Bb.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),Ab[zb.Notification.CantSaveSettings]=Bb.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),Ab[zb.Notification.CantSavePluginSettings]=Bb.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),Ab[zb.Notification.DomainAlreadyExists]=Bb.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),Ab[zb.Notification.CantInstallPackage]=Bb.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),Ab[zb.Notification.CantDeletePackage]=Bb.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),Ab[zb.Notification.InvalidPluginPackage]=Bb.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),Ab[zb.Notification.UnsupportedPluginPackage]=Bb.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),Ab[zb.Notification.LicensingServerIsUnavailable]=Bb.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),Ab[zb.Notification.LicensingExpired]=Bb.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),Ab[zb.Notification.LicensingBanned]=Bb.i18n("NOTIFICATIONS/LICENSING_BANNED"),Ab[zb.Notification.DemoSendMessageError]=Bb.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),Ab[zb.Notification.AccountAlreadyExists]=Bb.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),Ab[zb.Notification.MailServerError]=Bb.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),Ab[zb.Notification.UnknownNotification]=Bb.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),Ab[zb.Notification.UnknownError]=Bb.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},Bb.getUploadErrorDescByCode=function(a){var b="";switch(Bb.pInt(a)){case zb.UploadErrorCode.FileIsTooBig:b=Bb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case zb.UploadErrorCode.FilePartiallyUploaded:b=Bb.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case zb.UploadErrorCode.FileNoUploaded:b=Bb.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case zb.UploadErrorCode.MissingTempFolder:b=Bb.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case zb.UploadErrorCode.FileOnSaveingError:b=Bb.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case zb.UploadErrorCode.FileType:b=Bb.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=Bb.i18n("UPLOAD/ERROR_UNKNOWN")}return b},Bb.delegateRun=function(a,b,c,d){a&&a[b]&&(d=Bb.pInt(d),0>=d?a[b].apply(a,Bb.isArray(c)?c:[]):h.delay(function(){a[b].apply(a,Bb.isArray(c)?c:[])},d))},Bb.killCtrlAandS=function(b){if(b=b||a.event,b&&b.ctrlKey&&!b.shiftKey&&!b.altKey){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(d===zb.EventKeyCode.S)return b.preventDefault(),void 0;if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;d===zb.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},Bb.createCommand=function(a,b,d){var e=b?function(){return e.canExecute&&e.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments)),!1}:function(){};return e.enabled=c.observable(!0),d=Bb.isUnd(d)?!0:d,e.canExecute=Bb.isFunc(d)?c.computed(function(){return e.enabled()&&d.call(a)}):c.computed(function(){return e.enabled()&&!!d}),e},Bb.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(zb.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(zb.InterfaceAnimation.Full),b.contactsAutosave=c.observable(!1),Eb.sAnimationType=zb.InterfaceAnimation.Full,b.allowThemes=c.observable(!0),b.allowCustomLogin=c.observable(!1),b.allowLanguagesOnSettings=c.observable(!0),b.allowLanguagesOnLogin=c.observable(!0),b.desktopNotifications=c.observable(!1),b.useThreads=c.observable(!0),b.replySameFolder=c.observable(!0),b.useCheckboxesInList=c.observable(!0),b.layout=c.observable(zb.Layout.SidePreview),b.usePreviewPane=c.computed(function(){return zb.Layout.NoPreview!==b.layout()}),b.interfaceAnimation.subscribe(function(a){if(Eb.bMobileDevice||a===zb.InterfaceAnimation.None)Kb.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),Eb.sAnimationType=zb.InterfaceAnimation.None;else switch(a){case zb.InterfaceAnimation.Full:Kb.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),Eb.sAnimationType=a;break;case zb.InterfaceAnimation.Normal:Kb.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),Eb.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=zb.DesktopNotifications.NotSupported;if(Nb&&Nb.permission)switch(Nb.permission.toLowerCase()){case"granted":c=zb.DesktopNotifications.Allowed;break;case"denied":c=zb.DesktopNotifications.Denied;break;case"default":c=zb.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&zb.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();zb.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):zb.DesktopNotifications.NotAllowed===c?Nb.requestPermission(function(){b.desktopNotifications.valueHasMutated(),zb.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()?b.desktopNotifications()?b.desktopNotifications.valueHasMutated():b.desktopNotifications(!0):b.desktopNotifications()?b.desktopNotifications(!1):b.desktopNotifications.valueHasMutated()}):b.desktopNotifications(!1)}else b.desktopNotifications(!1)}}),b.language=c.observable(""),b.languages=c.observableArray([]),b.mainLanguage=c.computed({read:b.language,write:function(a){a!==b.language()?-1 =b.diff(c,"hours")?d:b.format("L")===c.format("L")?Bb.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?Bb.i18n("MESSAGE_LIST/YESTERDAY_AT",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},Bb.isFolderExpanded=function(a){var b=Ob.local().get(zb.ClientSideKeyName.ExpandedFolders);return h.isArray(b)&&-1!==h.indexOf(b,a)},Bb.setExpandedFolder=function(a,b){var c=Ob.local().get(zb.ClientSideKeyName.ExpandedFolders);h.isArray(c)||(c=[]),b?(c.push(a),c=h.uniq(c)):c=h.without(c,a),Ob.local().set(zb.ClientSideKeyName.ExpandedFolders,c)},Bb.initLayoutResizer=function(a,c,d){var e=65,f=155,g=b(a),h=b(c),i=Ob.local().get(d)||null,j=function(a){a&&(g.css({width:""+a+"px"}),h.css({left:""+a+"px"}))},k=function(a){if(a)g.resizable("disable"),j(e);else{g.resizable("enable");var b=Bb.pInt(Ob.local().get(d))||f;j(b>f?b:f)}},l=function(a,b){b&&b.size&&b.size.width&&(Ob.local().set(d,b.size.width),h.css({left:""+b.size.width+"px"}))};null!==i&&j(i>f?i:f),g.resizable({helper:"ui-resizable-helper",minWidth:f,maxWidth:350,handles:"e",stop:l}),Ob.sub("left-panel.off",function(){k(!0)}),Ob.sub("left-panel.on",function(){k(!1)})},Bb.initBlockquoteSwitcher=function(a){if(a){var c=b("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===b(this).parent().closest("blockquote",a).length});c&&0 100)&&(a.addClass("rl-bq-switcher hidden-bq"),b('').insertBefore(a).click(function(){a.toggleClass("hidden-bq"),Bb.windowResize()}).after("
").before("
"))})}},Bb.removeBlockquoteSwitcher=function(a){a&&(b(a).find("blockquote.rl-bq-switcher").each(function(){b(this).removeClass("rl-bq-switcher hidden-bq")}),b(a).find(".rlBlockquoteSwitcher").each(function(){b(this).remove()}))},Bb.toggleMessageBlockquote=function(a){a&&a.find(".rlBlockquoteSwitcher").click()},Bb.extendAsViewModel=function(a,b,c){b&&(c||(c=r),b.__name=a,Cb.regViewModelHook(a,b),h.extend(b.prototype,c.prototype))},Bb.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},Fb.settings.push(a)},Bb.removeSettingsViewModel=function(a){Fb["settings-removed"].push(a)},Bb.disableSettingsViewModel=function(a){Fb["settings-disabled"].push(a)},Bb.convertThemeName=function(a){return"@custom"===a.substr(-7)&&(a=Bb.trim(a.substring(0,a.length-7))),Bb.trim(a.replace(/[^a-zA-Z]+/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},Bb.quoteName=function(a){return a.replace(/["]/g,'\\"')},Bb.microtime=function(){return(new Date).getTime()},Bb.convertLangName=function(a,b){return Bb.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},Bb.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=Bb.isUnd(a)?32:Bb.pInt(a);b.length>>32-b}function c(a,b){var c,d,e,f,g;return e=2147483648&a,f=2147483648&b,c=1073741824&a,d=1073741824&b,g=(1073741823&a)+(1073741823&b),c&d?2147483648^g^e^f:c|d?1073741824&g?3221225472^g^e^f:1073741824^g^e^f:g^e^f}function d(a,b,c){return a&b|~a&c}function e(a,b,c){return a&c|b&~c}function f(a,b,c){return a^b^c}function g(a,b,c){return b^(a|~c)}function h(a,e,f,g,h,i,j){return a=c(a,c(c(d(e,f,g),h),j)),c(b(a,i),e)}function i(a,d,f,g,h,i,j){return a=c(a,c(c(e(d,f,g),h),j)),c(b(a,i),d) -}function j(a,d,e,g,h,i,j){return a=c(a,c(c(f(d,e,g),h),j)),c(b(a,i),d)}function k(a,d,e,f,h,i,j){return a=c(a,c(c(g(d,e,f),h),j)),c(b(a,i),d)}function l(a){for(var b,c=a.length,d=c+8,e=(d-d%64)/64,f=16*(e+1),g=Array(f-1),h=0,i=0;c>i;)b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|a.charCodeAt(i)<>>29,g}function m(a){var b,c,d="",e="";for(c=0;3>=c;c++)b=a>>>8*c&255,e="0"+b.toString(16),d+=e.substr(e.length-2,2);return d}function n(a){a=a.replace(/rn/g,"n");for(var b="",c=0;c d?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var o,p,q,r,s,t,u,v,w,x=Array(),y=7,z=12,A=17,B=22,C=5,D=9,E=14,F=20,G=4,H=11,I=16,J=23,K=6,L=10,M=15,N=21;for(a=n(a),x=l(a),t=1732584193,u=4023233417,v=2562383102,w=271733878,o=0;o /g,">").replace(/")},Bb.draggeblePlace=function(){return b(' ').appendTo("#rl-hidden")},Bb.defautOptionsAfterRender=function(a,c){c&&!Bb.isUnd(c.disabled)&&a&&b(a).toggleClass("disabled",c.disabled).prop("disabled",c.disabled)},Bb.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+Bb.fakeMd5()+"__",j=b("#"+d);a[i]=function(){if(h&&h.document.body&&j&&j[0]){var d=b(h.document.body);b("#rl-content",d).html(j.html()),b("html",h.document).addClass("external "+b("html").attr("class")),Bb.i18nToNode(d),t.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.document.write(''+Bb.encodeHtml(e)+' '),h.document.close(),g=h.document.createElement("script"),g.type="text/javascript",g.innerHTML="if(window&&window.opener&&window.opener['"+i+"']){window.opener['"+i+"']();window.opener['"+i+"']=null}",h.document.getElementsByTagName("head")[0].appendChild(g)},Bb.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=Bb.isUnd(d)?1e3:Bb.pInt(d),function(e,f,g,i,j){b.call(c,f&&f.Result?zb.SaveSettingsStep.TrueResult:zb.SaveSettingsStep.FalseResult),a&&a.call(c,e,f,g,i,j),h.delay(function(){b.call(c,zb.SaveSettingsStep.Idle)},d)}},Bb.settingsSaveHelperSimpleFunction=function(a,b){return Bb.settingsSaveHelperFunction(null,a,b,1e3)},Bb.htmlToPlain=function(a){var c="",d="> ",e=function(){if(arguments&&1\n",a.replace(/\n([> ]+)/gm,function(){return arguments&&1 ]*>(.|[\s\S\r\n]*)<\/div>/gim,f),a="\n"+b.trim(a)+"\n"),a}return""},g=function(){return arguments&&1 /g,">"):""},h=function(){if(arguments&&1 /gim,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,"\n").replace(/<\/tr>/gi,"\n").replace(/
]*>/gim,"\n_______________________________\n\n").replace(/]*>/gim,"").replace(/
]*>(.|[\s\S\r\n]*)<\/div>/gim,f).replace(/]*>/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,"")},Bb.plainToHtml=function(a){return a.toString().replace(/&/g,"&").replace(/>/g,">").replace(/")},Bb.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},Bb.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:Bb.isUnd(c)?a.toString():c.toString(),custom:Bb.isUnd(c)?!1:!0,title:Bb.isUnd(c)?"":a.toString(),value:a.toString()};(Bb.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}},Bb.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()}},Bb.disableKeyFilter=function(){a.key&&(j.filter=function(){return Ob.data().useKeyboardShortcuts()})},Bb.restoreKeyFilter=function(){a.key&&(j.filter=function(a){if(Ob.data().useKeyboardShortcuts()){var b=a.target||a.srcElement,c=b?b.tagName:"";return c=c.toUpperCase(),!("INPUT"===c||"SELECT"===c||"TEXTAREA"===c||b&&"DIV"===c&&"editorHtmlArea"===b.className&&b.contentEditable)}return!1})},Bb.detectDropdownVisibility=h.debounce(function(){Eb.dropdownVisibility(!!h.find(Gb,function(a){return a.hasClass("open")}))},50),Db={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return Db.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=Db._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 Db._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(!Eb.bMobileDevice){var e=b(a),f=e.data("tooltip-class")||"",g=e.data("tooltip-placement")||"top";e.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:g,trigger:"hover",title:function(){return e.is(".disabled")||Eb.dropdownVisibility()?"":''+Bb.i18n(c.utils.unwrapObservable(d()))+""}}).click(function(){e.tooltip("hide")}),Eb.dropdownVisibility.subscribe(function(a){a&&e.tooltip("hide")})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a),e=d.data("tooltip-class")||"",f=d.data("tooltip-placement")||"top";d.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:f,title:function(){return d.is(".disabled")||Eb.dropdownVisibility()?"":''+c()()+""}}).click(function(){d.tooltip("hide")}),Eb.dropdownVisibility.subscribe(function(a){a&&d.tooltip("hide")})}},c.bindingHandlers.tooltip3={init:function(a){var c=b(a);c.tooltip({container:"body",trigger:"hover manual",title:function(){return c.data("tooltip3-data")||""}}),Eb.dropdownVisibility.subscribe(function(a){a&&c.tooltip("hide")}),Mb.click(function(){c.tooltip("hide")})},update:function(a,d){var e=c.utils.unwrapObservable(d());""===e?b(a).data("tooltip3-data","").tooltip("hide"):b(a).data("tooltip3-data",e).tooltip("show")}},c.bindingHandlers.registrateBootstrapDropdown={init:function(a){Gb.push(b(a))}},c.bindingHandlers.openDropdownTrigger={update:function(a,d){if(c.utils.unwrapObservable(d())){var e=b(a);e.hasClass("open")||(e.find(".dropdown-toggle").dropdown("toggle"),Bb.detectDropdownVisibility()),d()(!1)}}},c.bindingHandlers.dropdownCloser={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&&!Bb.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&&!Bb.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.clickOnTrue={update:function(a,d){c.utils.unwrapObservable(d())&&b(a).click()}},c.bindingHandlers.modal={init:function(a,d){b(a).toggleClass("fade",!Eb.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("shown",function(){Bb.windowResize()}).find(".close").click(function(){d()(!1)})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){Bb.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),Bb.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=Bb.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=Bb.pInt(e[2]),g=Lb.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(!Eb.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),Bb.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),Bb.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)},b(d).draggable(k).on("mousedown",function(){Bb.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!Eb.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){Eb.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){Ob.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=Bb.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(Bb.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},Bb.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=Bb.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=Bb.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),Bb.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},k.prototype.root=function(){return this.sBase},k.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},k.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},k.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},k.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},k.prototype.uploadContacts=function(){return this.sServer+"/UploadContacts/"+this.sSpecSuffix+"/"},k.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},k.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},k.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},k.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},k.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},k.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},k.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},k.prototype.messagePreview=function(){return this.sBase+"mailbox/message-preview"},k.prototype.settings=function(a){var b=this.sBase+"settings";return Bb.isUnd(a)||""===a||(b+="/"+a),b},k.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},k.prototype.mailBox=function(a,b,c){b=Bb.isNormal(b)?Bb.pInt(b):1,c=Bb.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},k.prototype.phpInfo=function(){return this.sServer+"Info"},k.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},k.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},k.prototype.exportContactsVcf=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsVcf/"},k.prototype.exportContactsCsv=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsCsv/"},k.prototype.emptyContactPic=function(){return"rainloop/v/"+this.sVersion+"/static/css/images/empty-contact.png"},k.prototype.sound=function(a){return"rainloop/v/"+this.sVersion+"/static/sounds/"+a},k.prototype.themePreviewLink=function(a){var b="rainloop/v/"+this.sVersion+"/";return"@custom"===a.substr(-7)&&(a=Bb.trim(a.substring(0,a.length-7)),b=""),b+"themes/"+encodeURI(a)+"/images/preview.png"},k.prototype.notificationMailIcon=function(){return"rainloop/v/"+this.sVersion+"/static/css/images/icom-message-notification.png"},k.prototype.openPgpJs=function(){return"rainloop/v/"+this.sVersion+"/static/js/openpgp.min.js"},k.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},k.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},k.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},Cb.oViewModelsHooks={},Cb.oSimpleHooks={},Cb.regViewModelHook=function(a,b){b&&(b.__hookName=a)},Cb.addHook=function(a,b){Bb.isFunc(b)&&(Bb.isArray(Cb.oSimpleHooks[a])||(Cb.oSimpleHooks[a]=[]),Cb.oSimpleHooks[a].push(b))},Cb.runHook=function(a,b){Bb.isArray(Cb.oSimpleHooks[a])&&(b=b||[],h.each(Cb.oSimpleHooks[a],function(a){a.apply(null,b)}))},Cb.mainSettingsGet=function(a){return Ob?Ob.settingsGet(a):null},Cb.remoteRequest=function(a,b,c,d,e,f){Ob&&Ob.remote().defaultRequest(a,b,c,d,e,f)},Cb.settingsGet=function(a,b){var c=Cb.mainSettingsGet("Plugins");return c=c&&Bb.isUnd(c[a])?null:c[a],c?Bb.isUnd(c[b])?null:c[b]:null},l.prototype.blurTrigger=function(){if(this.fOnBlur){var b=this;a.clearTimeout(b.iBlurTimer),b.iBlurTimer=a.setTimeout(function(){b.fOnBlur()},200)}},l.prototype.focusTrigger=function(){this.fOnBlur&&a.clearTimeout(this.iBlurTimer)},l.prototype.isHtml=function(){return this.editor?"wysiwyg"===this.editor.mode:!1},l.prototype.checkDirty=function(){return this.editor?this.editor.checkDirty():!1},l.prototype.resetDirty=function(){this.editor&&this.editor.resetDirty()},l.prototype.getData=function(){return this.editor?"plain"===this.editor.mode&&this.editor.plugins.plain&&this.editor.__plain?this.editor.__plain.getRawData():this.editor.getData():""},l.prototype.modeToggle=function(a){this.editor&&(a?"plain"===this.editor.mode&&this.editor.setMode("wysiwyg"):"wysiwyg"===this.editor.mode&&this.editor.setMode("plain"))},l.prototype.setHtml=function(a,b){this.editor&&(this.modeToggle(!0),this.editor.setData(a),b&&this.focus())},l.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()}},l.prototype.init=function(){if(this.$element&&this.$element[0]){var b=this,c=Eb.oHtmlEditorDefaultConfig,d=Ob.settingsGet("Language"),e=!!Ob.settingsGet("AllowHtmlEditorSourceButton");e&&c.toolbarGroups&&!c.toolbarGroups.__SourceInited&&(c.toolbarGroups.__SourceInited=!0,c.toolbarGroups.push({name:"document",groups:["mode","document","doctools"]})),c.language=Eb.oHtmlEditorLangsMap[d]||"en",b.editor=a.CKEDITOR.appendTo(b.$element[0],c),b.editor.on("key",function(a){return a&&a.data&&9===a.data.keyCode?!1:void 0}),b.editor.on("blur",function(){b.blurTrigger()}),b.editor.on("mode",function(){b.blurTrigger(),b.fOnModeChange&&b.fOnModeChange("plain"!==b.editor.mode)}),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.__resizable=!0,b.resize()})}},l.prototype.focus=function(){this.editor&&this.editor.focus()},l.prototype.blur=function(){this.editor&&this.editor.focusManager.blur(!0)},l.prototype.resize=function(){this.editor&&this.__resizable&&this.editor.resize(this.$element.width(),this.$element.innerHeight())},l.prototype.clear=function(a){this.setHtml("",a)},m.prototype.itemSelected=function(a){this.isListChecked()?a||(this.oCallbacks.onItemSelect||this.emptyFunction)(a||null):a&&(this.oCallbacks.onItemSelect||this.emptyFunction)(a)},m.prototype.goDown=function(a){this.newSelectPosition(zb.EventKeyCode.Down,!1,a)},m.prototype.goUp=function(a){this.newSelectPosition(zb.EventKeyCode.Up,!1,a)},m.prototype.init=function(a,d,e){if(this.oContentVisible=a,this.oContentScrollable=d,e=e||"all",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.focusedItem(b),b.checked(!b.checked())))}),j("enter",e,function(){return f.focusedItem()&&!f.focusedItem().selected()?(f.actionClick(f.focusedItem()),!1):!0}),j("ctrl+up, command+up, ctrl+down, command+down",e,function(){return!1}),j("up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space",e,function(a,b){if(a&&b&&b.shortcut){var c=0;switch(b.shortcut){case"up":case"shift+up":c=zb.EventKeyCode.Up;break;case"down":case"shift+down":c=zb.EventKeyCode.Down;break;case"insert":c=zb.EventKeyCode.Insert;break;case"space":c=zb.EventKeyCode.Space;break;case"home":c=zb.EventKeyCode.Home;break;case"end":c=zb.EventKeyCode.End;break;case"pageup":c=zb.EventKeyCode.PageUp;break;case"pagedown":c=zb.EventKeyCode.PageDown}if(c>0)return f.newSelectPosition(c,j.shift),!1}})}},m.prototype.autoSelect=function(a){this.bAutoSelect=!!a},m.prototype.getItemUid=function(a){var b="",c=this.oCallbacks.onItemGetUid||null;return c&&a&&(b=c(a)),b.toString()},m.prototype.newSelectPosition=function(a,b,c){var d=0,e=10,f=!1,g=!1,i=null,j=this.list(),k=j?j.length:0,l=this.focusedItem();if(k>0)if(l){if(l)if(zb.EventKeyCode.Down===a||zb.EventKeyCode.Up===a||zb.EventKeyCode.Insert===a||zb.EventKeyCode.Space===a)h.each(j,function(b){if(!g)switch(a){case zb.EventKeyCode.Up:l===b?g=!0:i=b;break;case zb.EventKeyCode.Down:case zb.EventKeyCode.Insert:f?(i=b,g=!0):l===b&&(f=!0)}});else if(zb.EventKeyCode.Home===a||zb.EventKeyCode.End===a)zb.EventKeyCode.Home===a?i=j[0]:zb.EventKeyCode.End===a&&(i=j[j.length-1]);else if(zb.EventKeyCode.PageDown===a){for(;k>d;d++)if(l===j[d]){d+=e,d=d>k-1?k-1:d,i=j[d];break}}else if(zb.EventKeyCode.PageUp===a)for(d=k;d>=0;d--)if(l===j[d]){d-=e,d=0>d?0:d,i=j[d];break}}else zb.EventKeyCode.Down===a||zb.EventKeyCode.Insert===a||zb.EventKeyCode.Space===a||zb.EventKeyCode.Home===a||zb.EventKeyCode.PageUp===a?i=j[0]:(zb.EventKeyCode.Up===a||zb.EventKeyCode.End===a||zb.EventKeyCode.PageDown===a)&&(i=j[j.length-1]);i?(this.focusedItem(i),l&&(b?(zb.EventKeyCode.Up===a||zb.EventKeyCode.Down===a)&&l.checked(!l.checked()):(zb.EventKeyCode.Insert===a||zb.EventKeyCode.Space===a)&&l.checked(!l.checked())),!this.bAutoSelect&&!c||this.isListChecked()||zb.EventKeyCode.Space===a||this.selectedItem(i),this.scrollToFocused()):l&&(!b||zb.EventKeyCode.Up!==a&&zb.EventKeyCode.Down!==a?(zb.EventKeyCode.Insert===a||zb.EventKeyCode.Space===a)&&l.checked(!l.checked()):l.checked(!l.checked()),this.focusedItem(l))},m.prototype.scrollToFocused=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var a=20,c=b(this.sItemFocusedSelector,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},m.prototype.scrollToTop=function(a){return this.oContentVisible&&this.oContentScrollable?(a?this.oContentScrollable.scrollTop(0):this.oContentScrollable.stop().animate({scrollTop:0},200),!0):!1},m.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},m.prototype.actionClick=function(a,b){if(a){var c=!0,d=this.getItemUid(a);b&&(!b.shiftKey||b.ctrlKey||b.altKey?!b.ctrlKey||b.shiftKey||b.altKey||(c=!1,this.focusedItem(a),this.selectedItem()&&a!==this.selectedItem()&&this.selectedItem().checked(!0),a.checked(!a.checked())):(c=!1,""===this.sLastUid&&(this.sLastUid=d),a.checked(!a.checked()),this.eventClickFunction(a,b),this.focusedItem(a))),c&&(this.focusedItem(a),this.selectedItem(a))}},m.prototype.on=function(a,b){this.oCallbacks[a]=b},n.supported=function(){return!0},n.prototype.set=function(a,c){var d=b.cookie(yb.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(yb.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},n.prototype.get=function(a){var c=b.cookie(yb.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!Bb.isUnd(d[a])?d[a]:null}catch(e){}return d},o.supported=function(){return!!a.localStorage},o.prototype.set=function(b,c){var d=a.localStorage[yb.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[yb.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},o.prototype.get=function(b){var c=a.localStorage[yb.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!Bb.isUnd(d[b])?d[b]:null}catch(e){}return d},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.storeAndSetKeyScope=function(){this.sCurrentKeyScope=Ob.data().keyScope(),Ob.data().keyScope(this.sDefaultKeyScope) -},r.prototype.restoreKeyScope=function(){Ob.data().keyScope(this.sCurrentKeyScope)},r.prototype.registerPopupEscapeKey=function(){var a=this;Lb.on("keydown",function(b){return b&&zb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility&&a.modalVisibility()?(Bb.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;Bb.isNonEmptyArray(a)&&(c=h.bind(this.onRoute||Bb.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){Bb.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 Bb.isNormal(a)&&(this.oBoot=a),this},t.prototype.screen=function(a){return""===a||Bb.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()),i=null;a.__builded=!0,a.__vm=e,e.data=Ob.data(),e.viewModelName=a.__name,g&&1===g.length?(i=b(" ").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),i.appendTo(g),e.viewModelDom=i,a.__dom=i,"Popups"===f&&(e.cancelCommand=e.closeCommand=Bb.createCommand(e,function(){Hb.hideScreenPopup(a)}),e.modalVisibility.subscribe(function(a){var b=this;a?(this.viewModelDom.show(),this.storeAndSetKeyScope(),Ob.popupVisibilityNames.push(this.viewModelName),e.viewModelDom.css("z-index",3e3+Ob.popupVisibilityNames().length+10),Bb.delegateRun(this,"onFocus",[],500)):(Bb.delegateRun(this,"onHide"),this.restoreKeyScope(),Ob.popupVisibilityNames.remove(this.viewModelName),e.viewModelDom.css("z-index",2e3),h.delay(function(){b.viewModelDom.hide()},300))},e)),Cb.runHook("view-model-pre-build",[a.__name,e,i]),c.applyBindings(e,i[0]),Bb.delegateRun(e,"onBuild",[i]),e&&"Popups"===f&&!e.bDisabeCloseOnEsc&&e.registerPopupEscapeKey(),Cb.runHook("view-model-post-build",[a.__name,e,i])):Bb.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),Cb.runHook("view-model-on-hide",[a.__name,a.__vm]))},t.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__vm.modalVisibility(!0),Bb.delegateRun(a.__vm,"onShow",b||[]),Cb.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},t.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===Bb.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,Bb.isNonEmptyArray(d.viewModels())&&h.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),Bb.delegateRun(d,"onBuild")),h.defer(function(){c.oCurrentScreen&&(Bb.delegateRun(c.oCurrentScreen,"onHide"),Bb.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),Bb.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(Bb.delegateRun(c.oCurrentScreen,"onShow"),Cb.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),Bb.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),Bb.delegateRun(a.__vm,"onShow"),Bb.delegateRun(a.__vm,"onFocus",[],200),Cb.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(),Cb.runHook("screen-pre-start",[a.screenName(),a]),Bb.delegateRun(a,"onStart"),Cb.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(){Kb.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=Bb.isUnd(c)?!1:!!c,(Bb.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},Hb=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=zb.EmailType.Facebook),null===this.privateType&&(this.privateType=zb.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=Bb.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=Bb.trim(a.Name),this.email=Bb.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},u.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=Bb.isUnd(b)?!1:!!b,c=Bb.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+Bb.encodeHtml(this.name)+"":c?Bb.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=Bb.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+Bb.encodeHtml(d)+""+Bb.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=Bb.encodeHtml(d))):b&&(d=''+Bb.encodeHtml(this.email)+""))),d},u.prototype.mailsoParse=function(a){if(a=Bb.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=Ob.data(),e.viewModelDom=i,e.__rlSettingsData=f.__rlSettingsData,f.__dom=i,f.__builded=!0,f.__vm=e,c.applyBindings(e,i[0]),Bb.delegateRun(e,"onBuild",[i])):Bb.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&h.defer(function(){d.oCurrentSubScreen&&(Bb.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),Bb.delegateRun(d.oCurrentSubScreen,"onShow"),Bb.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)),Bb.windowResize()})):Hb.setHash(Ob.link().settings(),!1,!0)},sb.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(Bb.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},sb.prototype.onBuild=function(){h.each(Fb.settings,function(a){a&&a.__rlSettingsData&&!h.find(Fb["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(Fb["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},sb.prototype.routes=function(){var a=h.find(Fb.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=Bb.isUnd(c.subname)?b:Bb.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},h.extend(tb.prototype,s.prototype),tb.prototype.onShow=function(){Ob.setTitle("")},h.extend(ub.prototype,s.prototype),ub.prototype.oLastRoute={},ub.prototype.setNewTitle=function(){var a=Ob.data().accountEmail(),b=Ob.data().foldersInboxUnreadCount();Ob.setTitle((""===a?"":(b>0?"("+b+") ":" ")+a+" - ")+Bb.i18n("TITLES/MAILBOX"))},ub.prototype.onShow=function(){this.setNewTitle(),Ob.data().keyScope(zb.KeyState.MessageList)},ub.prototype.onRoute=function(a,b,c,d){if(Bb.isUnd(d)?1:!d){var e=Ob.data(),f=Ob.cache().getFolderFullNameRaw(a),g=Ob.cache().getFolderFromCacheList(f);g&&(e.currentFolder(g).messageListPage(b).messageListSearch(c),zb.Layout.NoPreview===e.layout()&&e.message()&&(e.message(null),e.messageFullScreenMode(!1)),Ob.reloadMessageList())}else zb.Layout.NoPreview!==Ob.data().layout()||Ob.data().message()||Ob.historyBack()},ub.prototype.onStart=function(){var a=Ob.data(),b=function(){Bb.windowResize()};(Ob.settingsGet("AllowAdditionalAccounts")||Ob.settingsGet("AllowIdentities"))&&Ob.accountsAndIdentities(),h.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&Ob.folderInformation("INBOX")},1e3),h.delay(function(){Ob.quota()},5e3),h.delay(function(){Ob.remote().appDelayStart(Bb.emptyFunction)},35e3),Kb.toggleClass("rl-no-preview-pane",zb.Layout.NoPreview===a.layout()),a.folderList.subscribe(b),a.messageList.subscribe(b),a.message.subscribe(b),a.layout.subscribe(function(a){Kb.toggleClass("rl-no-preview-pane",zb.Layout.NoPreview===a)}),a.foldersInboxUnreadCount.subscribe(function(){this.setNewTitle()},this)},ub.prototype.routes=function(){var a=function(){return["Inbox",1,"",!0]},b=function(a,b){return b[0]=Bb.pString(b[0]),b[1]=Bb.pInt(b[1]),b[1]=0>=b[1]?1:b[1],b[2]=Bb.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]=Bb.pString(b[0]),b[1]=Bb.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(vb.prototype,sb.prototype),vb.prototype.onShow=function(){Ob.setTitle(this.sSettingsTitle),Ob.data().keyScope(zb.KeyState.Settings)},h.extend(wb.prototype,q.prototype),wb.prototype.oSettings=null,wb.prototype.oPlugins=null,wb.prototype.oLocal=null,wb.prototype.oLink=null,wb.prototype.oSubs={},wb.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):(Eb.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},wb.prototype.link=function(){return null===this.oLink&&(this.oLink=new k),this.oLink},wb.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new p),this.oLocal},wb.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=Bb.isNormal(Ib)?Ib:{}),Bb.isUnd(this.oSettings[a])?null:this.oSettings[a]},wb.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=Bb.isNormal(Ib)?Ib:{}),this.oSettings[a]=b},wb.prototype.setTitle=function(b){b=(Bb.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=Bb.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=Bb.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=Bb.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(Bb.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++)Bb.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(zb.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.pgpSignedVerifyStatus(zb.SignedVerifyStatus.None),this.pgpSignedVerifyUser(""),this.priority(zb.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=Ob.data().sentFolder(),b=Ob.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(Bb.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(Bb.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(Bb.pInt(a.ParentThread)),this.threads(Bb.isArray(a.Threads)?a.Threads:[]),this.threadsLen(Bb.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0),b},z.prototype.initUpdateByMessageJson=function(a){var b=!1,c=zb.MessagePriority.Normal;return a&&"Object/Message"===a["@Object"]&&(c=Bb.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 Bb.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 Bb.isArray(this.from)&&this.from[0]?this.from[0].email:""},z.prototype.viewLink=function(){return Ob.link().messageViewLink(this.requestHash)},z.prototype.downloadLink=function(){return Ob.link().messageDownloadLink(this.requestHash)},z.prototype.replyEmails=function(a){var b=[],c=Bb.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=Bb.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(zb.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=Bb.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=Bb.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]}),Lb.resize()),Bb.windowResize(500))},z.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){this.body.data("rl-init-internal-images",!0),a=Bb.isUnd(a)?!1:a;var c=this;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=Bb.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]),Bb.windowResize(500)}},z.prototype.storeDataToDom=function(){this.body&&(this.body.data("rl-is-rtl",!!this.isRtl()),this.body.data("rl-is-html",!!this.isHtml()),this.body.data("rl-has-images",!!this.hasImages()),this.body.data("rl-plain-raw",this.plainRaw),Ob.data().allowOpenPGP()&&(this.body.data("rl-plain-pgp-signed",!!this.isPgpSigned()),this.body.data("rl-plain-pgp-encrypted",!!this.isPgpEncrypted()),this.body.data("rl-pgp-verify-status",this.pgpSignedVerifyStatus()),this.body.data("rl-pgp-verify-user",this.pgpSignedVerifyUser())))},z.prototype.storePgpVerifyDataToDom=function(){this.body&&Ob.data().allowOpenPGP()&&(this.body.data("rl-pgp-verify-status",this.pgpSignedVerifyStatus()),this.body.data("rl-pgp-verify-user",this.pgpSignedVerifyUser()))},z.prototype.fetchDataToDom=function(){this.body&&(this.isRtl(!!this.body.data("rl-is-rtl")),this.isHtml(!!this.body.data("rl-is-html")),this.hasImages(!!this.body.data("rl-has-images")),this.plainRaw=Bb.pString(this.body.data("rl-plain-raw")),Ob.data().allowOpenPGP()?(this.isPgpSigned(!!this.body.data("rl-plain-pgp-signed")),this.isPgpEncrypted(!!this.body.data("rl-plain-pgp-encrypted")),this.pgpSignedVerifyStatus(this.body.data("rl-pgp-verify-status")),this.pgpSignedVerifyUser(this.body.data("rl-pgp-verify-user"))):(this.isPgpSigned(!1),this.isPgpEncrypted(!1),this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.None),this.pgpSignedVerifyUser("")))},z.prototype.verifyPgpSignedClearMessage=function(){if(this.isPgpSigned()){var c=[],d=null,e=this.from&&this.from[0]&&this.from[0].email?this.from[0].email:"",f=Ob.data().findPublicKeysByEmail(e),g=null,i=null,j="";this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.Error),this.pgpSignedVerifyUser("");try{d=a.openpgp.cleartext.readArmored(this.plainRaw),d&&d.getText&&(this.pgpSignedVerifyStatus(f.length?zb.SignedVerifyStatus.Unverified:zb.SignedVerifyStatus.UnknownPublicKeys),c=d.verify(f),c&&0 ').text(j)).html(),Pb.empty(),this.replacePlaneTextBody(j)))))}catch(k){}this.storePgpVerifyDataToDom()}},z.prototype.decryptPgpEncryptedMessage=function(c){if(this.isPgpEncrypted()){var d=[],e=null,f=null,g=this.from&&this.from[0]&&this.from[0].email?this.from[0].email:"",i=Ob.data().findPublicKeysByEmail(g),j=Ob.data().findSelfPrivateKey(c),k=null,l=null,m="";this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.Error),this.pgpSignedVerifyUser(""),j||this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.UnknownPrivateKey);try{e=a.openpgp.message.readArmored(this.plainRaw),e&&j&&e.decrypt&&(this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.Unverified),f=e.decrypt(j),f&&(d=f.verify(i),d&&0 ').text(m)).html(),Pb.empty(),this.replacePlaneTextBody(m)))}catch(n){}this.storePgpVerifyDataToDom()}},z.prototype.replacePlaneTextBody=function(a){this.body&&this.body.html(a).addClass("b-text-part plain")},z.prototype.flagHash=function(){return[this.deleted(),this.unseen(),this.flagged(),this.answered(),this.forwarded(),this.isReadReceipt()].join("")},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()&&!a.isSystemFolder()})},this),this.canBeEdited=c.computed(function(){return zb.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 zb.FolderType.User!==this.type()},this),this.hidden=c.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return a&&!b||!this.selectable&&!b},this),this.selectableForFolderList=c.computed(function(){return!this.isSystemFolder()&&this.selectable},this),this.messageCountAll=c.computed({read:this.privateMessageCountAll,write:function(a){Bb.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this}),this.messageCountUnread=c.computed({read:this.privateMessageCountUnread,write:function(a){Bb.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(zb.FolderType.Inbox===c&&Ob.data().foldersInboxUnreadCount(b),a>0){if(zb.FolderType.Draft===c)return""+a;if(b>0&&zb.FolderType.Trash!==c&&zb.FolderType.Archive!==c&&zb.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(){Bb.timeOutAction("folder-list-folder-visibility-change",function(){Lb.trigger("folder-list-folder-visibility-change")},100)}),this.localName=c.computed(function(){Eb.langChangeTrigger();var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case zb.FolderType.Inbox:b=Bb.i18n("FOLDER_LIST/INBOX_NAME");break;case zb.FolderType.SentItems:b=Bb.i18n("FOLDER_LIST/SENT_NAME");break;case zb.FolderType.Draft:b=Bb.i18n("FOLDER_LIST/DRAFTS_NAME");break;case zb.FolderType.Spam:b=Bb.i18n("FOLDER_LIST/SPAM_NAME");break;case zb.FolderType.Trash:b=Bb.i18n("FOLDER_LIST/TRASH_NAME");break;case zb.FolderType.Archive:b=Bb.i18n("FOLDER_LIST/ARCHIVE_NAME")}return b},this),this.manageFolderSystemName=c.computed(function(){Eb.langChangeTrigger();var a="",b=this.type(),c=this.name();if(this.isSystemFolder())switch(b){case zb.FolderType.Inbox:a="("+Bb.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case zb.FolderType.SentItems:a="("+Bb.i18n("FOLDER_LIST/SENT_NAME")+")";break;case zb.FolderType.Draft:a="("+Bb.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case zb.FolderType.Spam:a="("+Bb.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case zb.FolderType.Trash:a="("+Bb.i18n("FOLDER_LIST/TRASH_NAME")+")";break;case zb.FolderType.Archive:a="("+Bb.i18n("FOLDER_LIST/ARCHIVE_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():'"'+Bb.quoteName(a)+'" <'+this.email()+">"},D.prototype.index=0,D.prototype.id="",D.prototype.guid="",D.prototype.user="",D.prototype.email="",D.prototype.armor="",D.prototype.isPrivate=!1,Bb.extendAsViewModel("PopupsFolderClearViewModel",E),E.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},E.prototype.onShow=function(a){this.clearPopup(),a&&this.selectedFolder(a)},Bb.extendAsViewModel("PopupsFolderCreateViewModel",F),F.prototype.sNoParentText="",F.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(Bb.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)},Bb.extendAsViewModel("PopupsFolderSystemViewModel",G),G.prototype.sChooseOnText="",G.prototype.sUnuseText="",G.prototype.onShow=function(a){var b="";switch(a=Bb.isUnd(a)?zb.SetSystemFoldersNotification.None:a){case zb.SetSystemFoldersNotification.Sent:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case zb.SetSystemFoldersNotification.Draft:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case zb.SetSystemFoldersNotification.Spam:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case zb.SetSystemFoldersNotification.Trash:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH");break;case zb.SetSystemFoldersNotification.Archive:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE")}this.notification(b)},Bb.extendAsViewModel("PopupsComposeViewModel",H),H.prototype.openOpenPgpPopup=function(){if(this.allowOpenPGP()&&this.oEditor&&!this.oEditor.isHtml()){var a=this;Hb.showScreenPopup(O,[function(b){a.editor(function(a){a.setPlain(b)})},this.oEditor.getData(),this.currentIdentityResultEmail(),this.to(),this.cc(),this.bcc()])}},H.prototype.reloadDraftFolder=function(){var a=Ob.data().draftFolder();""!==a&&(Ob.cache().setFolderHash(a,""),Ob.data().currentFolderFullNameRaw()===a?Ob.reloadMessageList(!0):Ob.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[Ob.data().accountEmail()]=Ob.data().accountEmail(),b)switch(a){case zb.ComposeType.Empty:d=Ob.data().accountEmail();break;case zb.ComposeType.Reply:case zb.ComposeType.ReplyAll:case zb.ComposeType.Forward:case zb.ComposeType.ForwardAsAttachment:h.find(h.union(b.to,b.cc,b.bcc),e);break;case zb.ComposeType.Draft:h.find(h.union(b.from,b.replyTo),e)}else d=Ob.data().accountEmail();return d},H.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)},H.prototype.formattedFrom=function(a){var b=Ob.data().displayName(),c=Ob.data().accountEmail();return""===b?c:(Bb.isUnd(a)?1:!a)?b+" ("+c+")":'"'+Bb.quoteName(b)+'" <'+c+">"},H.prototype.sendMessageResponse=function(b,c){var d=!1,e="";this.sending(!1),zb.StorageResultType.Success===b&&c&&c.Result&&(d=!0,this.modalVisibility()&&Bb.delegateRun(this,"closeCommand")),this.modalVisibility()&&!d&&(c&&zb.Notification.CantSaveMessage===c.ErrorCode?(this.sendSuccessButSaveError(!0),a.alert(Bb.trim(Bb.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(e=Bb.getNotification(c&&c.ErrorCode?c.ErrorCode:zb.Notification.CantSendMessage,c&&c.ErrorMessage?c.ErrorMessage:""),this.sendError(!0),a.alert(e||Bb.getNotification(zb.Notification.CantSendMessage)))),this.reloadDraftFolder()},H.prototype.saveMessageResponse=function(b,c){var d=!1,e=null;this.saving(!1),zb.StorageResultType.Success===b&&c&&c.Result&&c.Result.NewFolder&&c.Result.NewUid&&(this.bFromDraft&&(e=Ob.data().message(),e&&this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid&&Ob.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&&Bb.isNormal(c)&&(v=Bb.isArray(c)&&1===c.length?c[0]:Bb.isArray(c)?null:c),null!==q&&(p[q]=!0,this.currentIdentityID(this.findIdentityIdByMessage(w,v))),this.reset(),Bb.isNonEmptyArray(d)&&this.to(x(d)),""!==w&&v){switch(j=v.fullFormatDateValue(),k=v.subject(),u=v.aDraftInfo,l=b(v.body).clone(),Bb.removeBlockquoteSwitcher(l),m=l.html(),w){case zb.ComposeType.Empty:break;case zb.ComposeType.Reply:this.to(x(v.replyEmails(p))),this.subject(Bb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Bb.trim(this.sInReplyTo+" "+v.sReferences);break;case zb.ComposeType.ReplyAll:o=v.replyAllEmails(p),this.to(x(o[0])),this.cc(x(o[1])),this.subject(Bb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Bb.trim(this.sInReplyTo+" "+v.references());break;case zb.ComposeType.Forward:this.subject(Bb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Bb.trim(this.sInReplyTo+" "+v.sReferences);break;case zb.ComposeType.ForwardAsAttachment:this.subject(Bb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Bb.trim(this.sInReplyTo+" "+v.sReferences);break;case zb.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=Bb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences;break;case zb.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=Bb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences}switch(w){case zb.ComposeType.Reply:case zb.ComposeType.ReplyAll:f=v.fromToLine(!1,!0),n=Bb.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:j,EMAIL:f}),m="
"+n+":";break;case zb.ComposeType.Forward:f=v.fromToLine(!1,!0),g=v.toToLine(!1,!0),i=v.ccToLine(!1,!0),m=""+m+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+f+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+g+(0"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+i:"")+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+Bb.encodeHtml(j)+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+Bb.encodeHtml(k)+"
"+m;break;case zb.ComposeType.ForwardAsAttachment:m=""}s&&""!==r&&zb.ComposeType.EditAsNew!==w&&zb.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 zb.ComposeType.Empty===w?(m=this.convertSignature(r),this.editor(function(a){a.setHtml(m,!1),zb.EditorDefaultType.Html!==Ob.data().editorDefaultType()&&a.modeToggle(!1)})):Bb.isNonEmptyArray(c)&&h.each(c,function(a){e.addMessageAsAttachment(a)});t=this.getAttachmentsDownloadsForUpload(),Bb.isNonEmptyArray(t)&&Ob.remote().messageUploadAttachments(function(a,b){if(zb.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;Hb.showScreenPopup(S,[Bb.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&Bb.delegateRun(a,"closeCommand")}])},H.prototype.onBuild=function(){this.initUploader();var a=this,c=null;j("ctrl+q, command+q",zb.KeyState.Compose,function(){return a.identitiesDropdownTrigger(!0),!1}),j("ctrl+s, command+s",zb.KeyState.Compose,function(){return a.saveCommand(),!1}),j("ctrl+enter, command+enter",zb.KeyState.Compose,function(){return a.sendCommand(),!1}),j("esc",zb.KeyState.Compose,function(){return a.tryToClosePopup(),!1}),Lb.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",Ob.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=Bb.pInt(Ob.settingsGet("AttachmentLimit")),c=new g({action:Ob.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;Bb.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=Bb.isUnd(d.FileName)?"":d.FileName.toString(),g=Bb.isNormal(d.Size)?Bb.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(Bb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(b){var c=null;Bb.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=Bb.getUploadErrorDescByCode(f):g||(e=Bb.i18n("UPLOAD/ERROR_UNKNOWN")),h&&(""!==e&&00&&d>0&&f>d?(e.uploading(!1),e.error(Bb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(Ob.remote().composeUploadExternals(function(a,b){var c=!1;e.uploading(!1),zb.StorageResultType.Success===a&&b&&b.Result&&b.Result[e.id]&&(c=!0,e.tempName(b.Result[e.id])),c||e.error(Bb.getUploadErrorDescByCode(zb.UploadErrorCode.FileNoUploaded))},[a.link]),!0)},H.prototype.prepearMessageAttachments=function(a,b){if(a){var c=this,d=Bb.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(zb.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f>e;e++){switch(h=d[e],i=!1,b){case zb.ComposeType.Reply:case zb.ComposeType.ReplyAll:i=h.isLinked;break;case zb.ComposeType.Forward:case zb.ComposeType.Draft:case zb.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(Bb.getUploadErrorDescByCode(zb.UploadErrorCode.FileNoUploaded))},this)},H.prototype.isEmptyForm=function(a){a=Bb.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()},Bb.extendAsViewModel("PopupsContactsViewModel",I),I.prototype.getPropertyPlceholder=function(a){var b="";switch(a){case zb.ContactPropertyType.LastName:b="CONTACTS/PLACEHOLDER_ENTER_LAST_NAME";break;case zb.ContactPropertyType.FirstName:b="CONTACTS/PLACEHOLDER_ENTER_FIRST_NAME";break;case zb.ContactPropertyType.Nick:b="CONTACTS/PLACEHOLDER_ENTER_NICK_NAME"}return b},I.prototype.addNewProperty=function(a,b){this.viewProperties.push(new w(a,b||"","",!0,this.getPropertyPlceholder(a)))},I.prototype.addNewOrFocusProperty=function(a,b){var c=h.find(this.viewProperties(),function(b){return a===b.type()});c?c.focused(!0):this.addNewProperty(a,b)},I.prototype.addNewEmail=function(){this.addNewProperty(zb.ContactPropertyType.Email,"Home")},I.prototype.addNewPhone=function(){this.addNewProperty(zb.ContactPropertyType.Phone,"Mobile")},I.prototype.addNewWeb=function(){this.addNewProperty(zb.ContactPropertyType.Web)},I.prototype.addNewNickname=function(){this.addNewOrFocusProperty(zb.ContactPropertyType.Nick)},I.prototype.addNewNotes=function(){this.addNewOrFocusProperty(zb.ContactPropertyType.Note)},I.prototype.addNewBirthday=function(){this.addNewOrFocusProperty(zb.ContactPropertyType.Birthday)},I.prototype.exportVcf=function(){Ob.download(Ob.link().exportContactsVcf())},I.prototype.exportCsv=function(){Ob.download(Ob.link().exportContactsCsv())},I.prototype.initUploader=function(){if(this.importUploaderButton()){var b=new g({action:Ob.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(Bb.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)},c,yb.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,zb.KeyState.ContactList);var d=this;j("delete",zb.KeyState.ContactList,function(){return d.deleteCommand(),!1}),a.on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&(d.contactsPage(Bb.pInt(a.value)),d.reloadContactList())}),this.initUploader()},I.prototype.onShow=function(){Hb.routeOff(),this.reloadContactList(!0)},I.prototype.onHide=function(){Hb.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),h.each(this.contacts(),function(a){a.checked(!1)})},Bb.extendAsViewModel("PopupsAdvancedSearchViewModel",J),J.prototype.buildSearchStringValue=function(a){return-1 li"),e=c&&("tab"===c.shortcut||"right"===c.shortcut),f=d.index(d.filter(".active"));return!e&&f>0?f--:e&&f -1&&g.eq(e).removeClass("focused"),38===f&&e>0?e--:40===f&&e 1?" ("+(100>a?a:"99+")+")":""},Z.prototype.cancelSearch=function(){this.mainMessageListSearch(""),this.inputMessageListSearchFocus(!1)},Z.prototype.moveSelectedMessagesToFolder=function(a,b){return this.canBeMoved()&&Ob.moveMessagesToFolder(Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),a,b),!1},Z.prototype.dragAndDronHelper=function(a){a&&a.checked(!0);var b=Bb.draggeblePlace(),c=Ob.data().messageListCheckedOrSelectedUidsWithSubMails();return b.data("rl-folder",Ob.data().currentFolderFullNameRaw()),b.data("rl-uids",c),b.find(".text").text(""+c.length),h.defer(function(){var a=Ob.data().messageListCheckedOrSelectedUidsWithSubMails();b.data("rl-uids",a),b.find(".text").text(""+a.length)}),b},Z.prototype.onMessageResponse=function(a,b,c){var d=Ob.data();d.hideMessageBodies(),d.messageLoading(!1),zb.StorageResultType.Success===a&&b&&b.Result?d.setMessage(b,c):zb.StorageResultType.Unload===a?(d.message(null),d.messageError("")):zb.StorageResultType.Abort!==a&&(d.message(null),d.messageError(b&&b.ErrorCode?Bb.getNotification(b.ErrorCode):Bb.getNotification(zb.Notification.UnknownError)))},Z.prototype.populateMessageBody=function(a){a&&(Ob.remote().message(this.onMessageResponse,a.folderFullNameRaw,a.uid)?Ob.data().messageLoading(!0):Bb.log("Error: Unknown message request: "+a.folderFullNameRaw+" ~ "+a.uid+" [e-101]"))},Z.prototype.setAction=function(a,b,c){var d=[],e=null,f=Ob.cache(),g=0;if(Bb.isUnd(c)&&(c=Ob.data().messageListChecked()),d=h.map(c,function(a){return a.uid}),""!==a&&0 0?100>a?a:"99+":""},$.prototype.verifyPgpSignedClearMessage=function(a){a&&a.verifyPgpSignedClearMessage()},$.prototype.decryptPgpEncryptedMessage=function(a){a&&a.decryptPgpEncryptedMessage(this.viewPgpPassword())},$.prototype.readReceipt=function(a){a&&""!==a.readReceipt()&&(Ob.remote().sendReadReceiptMessage(Bb.emptyFunction,a.folderFullNameRaw,a.uid,a.readReceipt(),Bb.i18n("READ_RECEIPT/SUBJECT",{SUBJECT:a.subject()}),Bb.i18n("READ_RECEIPT/BODY",{"READ-RECEIPT":Ob.data().accountEmail()})),a.isReadReceipt(!0),Ob.cache().storeMessageFlagsToCache(a),Ob.reloadFlagsCurrentMessageListAndMessageFromCache())},Bb.extendAsViewModel("SettingsMenuViewModel",_),_.prototype.link=function(a){return Ob.link().settings(a)},_.prototype.backToMailBoxClick=function(){Hb.setHash(Ob.link().inbox())},Bb.extendAsViewModel("SettingsPaneViewModel",ab),ab.prototype.onBuild=function(){var a=this;j("esc",zb.KeyState.Settings,function(){a.backToMailBoxClick()})},ab.prototype.onShow=function(){Ob.data().message(null)},ab.prototype.backToMailBoxClick=function(){Hb.setHash(Ob.link().inbox())},Bb.addSettingsViewModel(bb,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0),bb.prototype.toggleLayout=function(){this.layout(zb.Layout.NoPreview===this.layout()?zb.Layout.SidePreview:zb.Layout.NoPreview)},bb.prototype.onBuild=function(){var a=this;h.delay(function(){var c=Ob.data(),d=Bb.settingsSaveHelperSimpleFunction(a.mppTrigger,a);c.language.subscribe(function(c){a.languageTrigger(zb.SaveSettingsStep.Animate),b.ajax({url:Ob.link().langLink(c),dataType:"script",cache:!0}).done(function(){Bb.i18nToDoc(),a.languageTrigger(zb.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(zb.SaveSettingsStep.FalseResult)}).always(function(){h.delay(function(){a.languageTrigger(zb.SaveSettingsStep.Idle)},1e3)}),Ob.remote().saveSettings(Bb.emptyFunction,{Language:c})}),c.editorDefaultType.subscribe(function(a){Ob.remote().saveSettings(Bb.emptyFunction,{EditorDefaultType:a})}),c.messagesPerPage.subscribe(function(a){Ob.remote().saveSettings(d,{MPP:a})}),c.showImages.subscribe(function(a){Ob.remote().saveSettings(Bb.emptyFunction,{ShowImages:a?"1":"0"})}),c.interfaceAnimation.subscribe(function(a){Ob.remote().saveSettings(Bb.emptyFunction,{InterfaceAnimation:a})}),c.useDesktopNotifications.subscribe(function(a){Bb.timeOutAction("SaveDesktopNotifications",function(){Ob.remote().saveSettings(Bb.emptyFunction,{DesktopNotifications:a?"1":"0"})},3e3)}),c.replySameFolder.subscribe(function(a){Bb.timeOutAction("SaveReplySameFolder",function(){Ob.remote().saveSettings(Bb.emptyFunction,{ReplySameFolder:a?"1":"0"})},3e3)}),c.useThreads.subscribe(function(a){c.messageList([]),Ob.remote().saveSettings(Bb.emptyFunction,{UseThreads:a?"1":"0"})}),c.layout.subscribe(function(a){c.messageList([]),Ob.remote().saveSettings(Bb.emptyFunction,{Layout:a})}),c.useCheckboxesInList.subscribe(function(a){Ob.remote().saveSettings(Bb.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)},bb.prototype.onShow=function(){Ob.data().desktopNotifications.valueHasMutated()},bb.prototype.selectLanguage=function(){Hb.showScreenPopup(Q)},Bb.addSettingsViewModel(cb,"SettingsContacts","SETTINGS_LABELS/LABEL_CONTACTS_NAME","contacts"),cb.prototype.onBuild=function(){Ob.data().contactsAutosave.subscribe(function(a){Ob.remote().saveSettings(Bb.emptyFunction,{ContactsAutosave:a?"1":"0"})})},Bb.addSettingsViewModel(db,"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts"),db.prototype.addNewAccount=function(){Hb.showScreenPopup(K)},db.prototype.deleteAccount=function(b){if(b&&b.deleteAccess()){this.accountForDeletion(null);var c=function(a){return b===a};b&&(this.accounts.remove(c),Ob.remote().accountDelete(function(b,c){zb.StorageResultType.Success===b&&c&&c.Result&&c.Reload?(Hb.routeOff(),Hb.setHash(Ob.link().root(),!0),Hb.routeOff(),h.defer(function(){a.location.reload()})):Ob.accountsAndIdentities()},b.email))}},Bb.addSettingsViewModel(eb,"SettingsIdentity","SETTINGS_LABELS/LABEL_IDENTITY_NAME","identity"),eb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Ob.data().signature();this.editor=new l(a.signatureDom(),function(){Ob.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)})}},eb.prototype.onBuild=function(){var a=this;h.delay(function(){var b=Ob.data(),c=Bb.settingsSaveHelperSimpleFunction(a.displayNameTrigger,a),d=Bb.settingsSaveHelperSimpleFunction(a.replyTrigger,a),e=Bb.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){Ob.remote().saveSettings(c,{DisplayName:a})}),b.replyTo.subscribe(function(a){Ob.remote().saveSettings(d,{ReplyTo:a})}),b.signature.subscribe(function(a){Ob.remote().saveSettings(e,{Signature:a})}),b.signatureToAll.subscribe(function(a){Ob.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},Bb.addSettingsViewModel(fb,"SettingsIdentities","SETTINGS_LABELS/LABEL_IDENTITIES_NAME","identities"),fb.prototype.addNewIdentity=function(){Hb.showScreenPopup(P)},fb.prototype.editIdentity=function(a){Hb.showScreenPopup(P,[a])},fb.prototype.deleteIdentity=function(a){if(a&&a.deleteAccess()){this.identityForDeletion(null);var b=function(b){return a===b};a&&(this.identities.remove(b),Ob.remote().identityDelete(function(){Ob.accountsAndIdentities()},a.id))}},fb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Ob.data().signature();this.editor=new l(a.signatureDom(),function(){Ob.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)})}},fb.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=Ob.data(),c=Bb.settingsSaveHelperSimpleFunction(b.displayNameTrigger,b),d=Bb.settingsSaveHelperSimpleFunction(b.replyTrigger,b),e=Bb.settingsSaveHelperSimpleFunction(b.signatureTrigger,b);a.displayName.subscribe(function(a){Ob.remote().saveSettings(c,{DisplayName:a})}),a.replyTo.subscribe(function(a){Ob.remote().saveSettings(d,{ReplyTo:a})}),a.signature.subscribe(function(a){Ob.remote().saveSettings(e,{Signature:a})}),a.signatureToAll.subscribe(function(a){Ob.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},Bb.addSettingsViewModel(gb,"SettingsSecurity","SETTINGS_LABELS/LABEL_SECURITY_NAME","security"),gb.prototype.showSecret=function(){this.secreting(!0),Ob.remote().showTwoFactorSecret(this.onSecretResult)},gb.prototype.hideSecret=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")},gb.prototype.createTwoFactor=function(){this.processing(!0),Ob.remote().createTwoFactor(this.onResult)},gb.prototype.enableTwoFactor=function(){this.processing(!0),Ob.remote().enableTwoFactor(this.onResult,this.viewEnable())},gb.prototype.testTwoFactor=function(){Hb.showScreenPopup(R)},gb.prototype.clearTwoFactor=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl(""),this.clearing(!0),Ob.remote().clearTwoFactor(this.onResult)},gb.prototype.onShow=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")},gb.prototype.onResult=function(a,b){if(this.processing(!1),this.clearing(!1),zb.StorageResultType.Success===a&&b&&b.Result?(this.viewUser(Bb.pString(b.Result.User)),this.viewEnable(!!b.Result.Enable),this.twoFactorStatus(!!b.Result.IsSet),this.viewSecret(Bb.pString(b.Result.Secret)),this.viewBackupCodes(Bb.pString(b.Result.BackupCodes).replace(/[\s]+/g," ")),this.viewUrl(Bb.pString(b.Result.Url))):(this.viewUser(""),this.viewEnable(!1),this.twoFactorStatus(!1),this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")),this.bFirst){this.bFirst=!1;var c=this;this.viewEnable.subscribe(function(a){this.viewEnable.subs&&Ob.remote().enableTwoFactor(function(a,b){zb.StorageResultType.Success===a&&b&&b.Result||(c.viewEnable.subs=!1,c.viewEnable(!1),c.viewEnable.subs=!0)},a)},this)}},gb.prototype.onSecretResult=function(a,b){this.secreting(!1),zb.StorageResultType.Success===a&&b&&b.Result?(this.viewSecret(Bb.pString(b.Result.Secret)),this.viewUrl(Bb.pString(b.Result.Url))):(this.viewSecret(""),this.viewUrl(""))},gb.prototype.onBuild=function(){this.processing(!0),Ob.remote().getTwoFactor(this.onResult)},Bb.addSettingsViewModel(hb,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social"),Bb.addSettingsViewModel(ib,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME","change-password"),ib.prototype.onHide=function(){this.changeProcess(!1),this.currentPassword(""),this.newPassword(""),this.newPassword2(""),this.errorDescription(""),this.passwordMismatch(!1),this.currentPassword.error(!1)},ib.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1),this.passwordMismatch(!1),this.errorDescription(""),this.currentPassword.error(!1),zb.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.newPassword2(""),this.passwordUpdateSuccess(!0),this.currentPassword.error(!1)):(b&&zb.Notification.CurrentPasswordIncorrect===b.ErrorCode&&this.currentPassword.error(!0),this.passwordUpdateError(!0),this.errorDescription(b&&b.ErrorCode?Bb.getNotification(b.ErrorCode):Bb.getNotification(zb.Notification.CouldNotSaveNewPassword)))},Bb.addSettingsViewModel(jb,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders"),jb.prototype.folderEditOnEnter=function(a){var b=a?Bb.trim(a.nameForEdit()):"";""!==b&&a.name()!==b&&(Ob.local().set(zb.ClientSideKeyName.FoldersLashHash,""),Ob.data().foldersRenaming(!0),Ob.remote().folderRename(function(a,b){Ob.data().foldersRenaming(!1),zb.StorageResultType.Success===a&&b&&b.Result||Ob.data().foldersListError(b&&b.ErrorCode?Bb.getNotification(b.ErrorCode):Bb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER")),Ob.folders()},a.fullNameRaw,b),Ob.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b)),a.edited(!1)},jb.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)},jb.prototype.onShow=function(){Ob.data().foldersListError("")},jb.prototype.createFolder=function(){Hb.showScreenPopup(F)},jb.prototype.systemFolder=function(){Hb.showScreenPopup(G)},jb.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&&(Ob.local().set(zb.ClientSideKeyName.FoldersLashHash,""),Ob.data().folderList.remove(b),Ob.data().foldersDeleting(!0),Ob.remote().folderDelete(function(a,b){Ob.data().foldersDeleting(!1),zb.StorageResultType.Success===a&&b&&b.Result||Ob.data().foldersListError(b&&b.ErrorCode?Bb.getNotification(b.ErrorCode):Bb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER")),Ob.folders()},a.fullNameRaw),Ob.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0 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)))},nb.prototype.populateDataOnStart=function(){mb.prototype.populateDataOnStart.call(this),this.accountEmail(Ob.settingsGet("Email")),this.accountIncLogin(Ob.settingsGet("IncLogin")),this.accountOutLogin(Ob.settingsGet("OutLogin")),this.projectHash(Ob.settingsGet("ProjectHash")),this.displayName(Ob.settingsGet("DisplayName")),this.replyTo(Ob.settingsGet("ReplyTo")),this.signature(Ob.settingsGet("Signature")),this.signatureToAll(!!Ob.settingsGet("SignatureToAll")),this.enableTwoFactor(!!Ob.settingsGet("EnableTwoFactor")),this.lastFoldersHash=Ob.local().get(zb.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!Ob.settingsGet("RemoteSuggestions"),this.devEmail=Ob.settingsGet("DevEmail"),this.devLogin=Ob.settingsGet("DevLogin"),this.devPassword=Ob.settingsGet("DevPassword") -},nb.prototype.initUidNextAndNewMessages=function(b,c,d){if("INBOX"===b&&Bb.isNormal(c)&&""!==c){if(Bb.isArray(d)&&0 3)i(Ob.link().notificationMailIcon(),Ob.data().accountEmail(),Bb.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:g}));else for(;g>f;f++)i(Ob.link().notificationMailIcon(),z.emailsToLine(z.initEmailsFromJson(d[f].From),!1),d[f].Subject)}Ob.cache().setFolderUidNext(b,c)}},nb.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=Ob.cache().getFolderFromCacheList(g),f||(f=A.newInstanceFromJson(e),f&&(Ob.cache().setFolderToCacheList(g,f),Ob.cache().setFolderFullNameRaw(f.fullNameHash,g))),f&&(f.collapsed(!Bb.isFolderExpanded(f.fullNameHash)),e.Extended&&(e.Extended.Hash&&Ob.cache().setFolderHash(f.fullNameRaw,e.Extended.Hash),Bb.isNormal(e.Extended.MessageCount)&&f.messageCountAll(e.Extended.MessageCount),Bb.isNormal(e.Extended.MessageUnseenCount)&&f.messageCountUnread(e.Extended.MessageUnseenCount)),h=e.SubFolders,h&&"Collection/FolderCollection"===h["@Object"]&&h["@Collection"]&&Bb.isArray(h["@Collection"])&&f.subFolders(this.folderResponseParseRec(a,h["@Collection"])),i.push(f)));return i},nb.prototype.setFolders=function(a){var b=[],c=!1,d=Ob.data(),e=function(a){return""===a||yb.Values.UnuseOptionValue===a||null!==Ob.cache().getFolderFromCacheList(a)?a:""};a&&a.Result&&"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&Bb.isArray(a.Result["@Collection"])&&(Bb.isUnd(a.Result.Namespace)||(d.namespace=a.Result.Namespace),this.threading(!!Ob.settingsGet("UseImapThread")&&a.Result.IsThreadsSupported&&!0),b=this.folderResponseParseRec(d.namespace,a.Result["@Collection"]),d.folderList(b),a.Result.SystemFolders&&""==""+Ob.settingsGet("SentFolder")+Ob.settingsGet("DraftFolder")+Ob.settingsGet("SpamFolder")+Ob.settingsGet("TrashFolder")+Ob.settingsGet("ArchiveFolder")+Ob.settingsGet("NullFolder")&&(Ob.settingsSet("SentFolder",a.Result.SystemFolders[2]||null),Ob.settingsSet("DraftFolder",a.Result.SystemFolders[3]||null),Ob.settingsSet("SpamFolder",a.Result.SystemFolders[4]||null),Ob.settingsSet("TrashFolder",a.Result.SystemFolders[5]||null),Ob.settingsSet("ArchiveFolder",a.Result.SystemFolders[12]||null),c=!0),d.sentFolder(e(Ob.settingsGet("SentFolder"))),d.draftFolder(e(Ob.settingsGet("DraftFolder"))),d.spamFolder(e(Ob.settingsGet("SpamFolder"))),d.trashFolder(e(Ob.settingsGet("TrashFolder"))),d.archiveFolder(e(Ob.settingsGet("ArchiveFolder"))),c&&Ob.remote().saveSystemFolders(Bb.emptyFunction,{SentFolder:d.sentFolder(),DraftFolder:d.draftFolder(),SpamFolder:d.spamFolder(),TrashFolder:d.trashFolder(),ArchiveFolder:d.archiveFolder(),NullFolder:"NullFolder"}),Ob.local().set(zb.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash))},nb.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()},nb.prototype.getNextFolderNames=function(a){a=Bb.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=Ob.cache().getFolderFromCacheList(a[1]);return e&&(e.interval=d,b.push(a[1])),c<=b.length}),h.uniq(b)},nb.prototype.removeMessagesFromList=function(a,b,c,d){c=Bb.isNormal(c)?c:"",d=Bb.isUnd(d)?!1:!!d,b=h.map(b,function(a){return Bb.pInt(a)});var e=0,f=Ob.data(),g=Ob.cache(),i=f.messageList(),j=Ob.cache().getFolderFromCacheList(a),k=""===c?null:g.getFolderFromCacheList(c||""),l=f.currentFolderFullNameRaw(),m=f.message(),n=l===a?h.filter(i,function(a){return a&&-1 0&&j.messageCountUnread(0<=j.messageCountUnread()-e?j.messageCountUnread()-e:0)),k&&(k.messageCountAll(k.messageCountAll()+b.length),e>0&&k.messageCountUnread(k.messageCountUnread()+e),k.actionBlink(!0)),0 ').hide().addClass("rl-cache-class"),g.data("rl-cache-count",++Eb.iMessageBodyCacheCount),Bb.isNormal(a.Result.Html)&&""!==a.Result.Html?(d=!0,g.html(a.Result.Html.toString()).addClass("b-text-part html")):Bb.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(d=!1,j=a.Result.Plain.toString(),(n.isPgpSigned()||n.isPgpEncrypted())&&Ob.data().allowOpenPGP()&&Bb.isNormal(a.Result.PlainRaw)&&(n.plainRaw=Bb.pString(a.Result.PlainRaw),l=/---BEGIN PGP MESSAGE---/.test(n.plainRaw),l||(k=/-----BEGIN PGP SIGNED MESSAGE-----/.test(n.plainRaw)&&/-----BEGIN PGP SIGNATURE-----/.test(n.plainRaw)),Pb.empty(),k&&n.isPgpSigned()?j=Pb.append(b('').text(n.plainRaw)).html():l&&n.isPgpEncrypted()&&(j=Pb.append(b('').text(n.plainRaw)).html()),Pb.empty(),n.isPgpSigned(k),n.isPgpEncrypted(l)),g.html(j).addClass("b-text-part plain")):d=!1,n.isHtml(!!d),n.hasImages(!!e),n.pgpSignedVerifyStatus(zb.SignedVerifyStatus.None),n.pgpSignedVerifyUser(""),a.Result.Rtl&&(n.isRtl(!0),g.addClass("rtl-text-part")),n.body=g,n.body&&m.append(n.body),n.storeDataToDom(),f&&n.showInternalImages(!0),n.hasImages()&&this.showImages()&&n.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()),this.messageActiveDom(n.body),this.hideMessageBodies(),n.body.show(),g&&Bb.initBlockquoteSwitcher(g)),Ob.cache().initMessageFlagsFromCache(n),n.unseen()&&Ob.setMessageSeen(n),Bb.windowResize())},nb.prototype.calculateMessageListHash=function(a){return h.map(a,function(a){return""+a.hash+"_"+a.threadsLen()+"_"+a.flagHash()}).join("|")},nb.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&Bb.isArray(a.Result["@Collection"])){var c=Ob.data(),d=Ob.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=Bb.pInt(a.Result.MessageResultCount),j=Bb.pInt(a.Result.Offset),Bb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),p=Ob.cache().getFolderFromCacheList(Bb.isNormal(a.Result.Folder)?a.Result.Folder:""),p&&!b&&(p.interval=l,Ob.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),Bb.isNormal(a.Result.MessageCount)&&p.messageCountAll(a.Result.MessageCount),Bb.isNormal(a.Result.MessageUnseenCount)&&(Bb.pInt(p.messageCountUnread())!==Bb.pInt(a.Result.MessageUnseenCount)&&(r=!0),p.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(p.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),r&&p&&Ob.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?Ob.cache().initMessageFlagsFromCache(o):Ob.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/"+Db.urlsafe_encode([b,c,Ob.data().projectHash(),Ob.data().threading()&&Ob.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},pb.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999e3)},pb.prototype.folderInformation=function(a,b,c){var d=!0,e=Ob.cache(),f=[];Bb.isArray(c)&&0 l;l++)q.push({id:e[l][0],name:e[l][1],system:!1,seporator:!1,disabled:!1});for(o=!0,l=0,m=b.length;m>l;l++)n=b[l],(h?h.call(null,n):!0)&&(o&&0 l;l++)n=c[l],(n.subScribed()||!n.existen)&&(h?h.call(null,n):!0)&&(zb.FolderType.User===n.type()||!j||0 =5?e:20,e=320>=e?e:320,a.setInterval(function(){Ob.contactsSync()},6e4*e+5e3),h.delay(function(){Ob.contactsSync()},5e3),h.delay(function(){Ob.folderInformationMultiply(!0)},500),h.delay(function(){Ob.emailsPicsHashes(),Ob.remote().servicesPics(function(a,b){zb.StorageResultType.Success===a&&b&&b.Result&&Ob.cache().setServicesData(b.Result)})},2e3),Cb.runHook("rl-start-user-screens"),Ob.pub("rl.bootstart-user-screens"),Ob.settingsGet("AccountSignMe")&&a.navigator.registerProtocolHandler&&h.delay(function(){try{a.navigator.registerProtocolHandler("mailto",a.location.protocol+"//"+a.location.host+a.location.pathname+"?mailto&to=%s",""+(Ob.settingsGet("Title")||"RainLoop"))}catch(b){}Ob.settingsGet("MailToEmail")&&Ob.mailToHelper(Ob.settingsGet("MailToEmail"))},500)):(Hb.startScreens([tb]),Cb.runHook("rl-start-login-screens"),Ob.pub("rl.bootstart-login-screens")),a.SimplePace&&a.SimplePace.set(100),Eb.bMobileDevice||h.defer(function(){Bb.initLayoutResizer("#rl-left","#rl-right",zb.ClientSideKeyName.FolderListSize)})},this))):(c=Bb.pString(Ob.settingsGet("CustomLoginLink")),c?(Hb.routeOff(),Hb.setHash(Ob.link().root(),!0),Hb.routeOff(),h.defer(function(){a.location.href=c})):(Hb.hideLoading(),Hb.startScreens([tb]),Cb.runHook("rl-start-login-screens"),Ob.pub("rl.bootstart-login-screens"),a.SimplePace&&a.SimplePace.set(100))),f&&(a["rl_"+d+"_google_service"]=function(){Ob.data().googleActions(!0),Ob.socialUsers()}),g&&(a["rl_"+d+"_facebook_service"]=function(){Ob.data().facebookActions(!0),Ob.socialUsers()}),i&&(a["rl_"+d+"_twitter_service"]=function(){Ob.data().twitterActions(!0),Ob.socialUsers()}),Ob.sub("interval.1m",function(){Eb.momentTrigger(!Eb.momentTrigger())}),Cb.runHook("rl-start-screens"),Ob.pub("rl.bootstart-end")},Ob=new xb,Kb.addClass(Eb.bMobileDevice?"mobile":"no-mobile"),Lb.keydown(Bb.killCtrlAandS).keyup(Bb.killCtrlAandS),Lb.unload(function(){Eb.bUnload=!0}),Kb.on("click.dropdown.data-api",function(){Bb.detectDropdownVisibility()}),a.rl=a.rl||{},a.rl.addHook=Cb.addHook,a.rl.settingsGet=Cb.mainSettingsGet,a.rl.remoteRequest=Cb.remoteRequest,a.rl.pluginSettingsGet=Cb.settingsGet,a.rl.addSettingsViewModel=Bb.addSettingsViewModel,a.rl.createCommand=Bb.createCommand,a.rl.EmailModel=u,a.rl.Enums=zb,a.__RLBOOT=function(c){b(function(){a.rainloopTEMPLATES&&a.rainloopTEMPLATES[0]?(b("#rl-templates").html(a.rainloopTEMPLATES[0]),h.delay(function(){a.rainloopAppData={},a.rainloopI18N={},a.rainloopTEMPLATES={},Hb.setBoot(Ob).bootstart(),Kb.removeClass("no-js rl-booted-trigger").addClass("rl-booted")},50)):c(!1),a.__RLBOOT=null})},a.SimplePace&&a.SimplePace.add(10)}(window,jQuery,ko,crossroads,hasher,moment,Jua,_,ifvisible,key); \ No newline at end of file +!function(a,b,c,d,e,f,g,h,i,j){"use strict";function k(){this.sBase="#/",this.sVersion=Pb.settingsGet("Version"),this.sSpecSuffix=Pb.settingsGet("AuthAccountHash")||"0",this.sServer=(Pb.settingsGet("IndexFile")||"./")+"?"}function l(a,c,d,e){var f=this;f.editor=null,f.iBlurTimer=0,f.fOnBlur=c||null,f.fOnReady=d||null,f.fOnModeChange=e||null,f.$element=b(a),f.init()}function m(a,b,d,e,f,g){this.list=a,this.listChecked=c.computed(function(){return h.filter(this.list(),function(a){return a.checked()})},this).extend({rateLimit:0}),this.isListChecked=c.computed(function(){return 0 0&&-1 b?b:a))},this),this.body=null,this.plainRaw="",this.isRtl=c.observable(!1),this.isHtml=c.observable(!1),this.hasImages=c.observable(!1),this.attachments=c.observableArray([]),this.isPgpSigned=c.observable(!1),this.isPgpEncrypted=c.observable(!1),this.pgpSignedVerifyStatus=c.observable(Ab.SignedVerifyStatus.None),this.pgpSignedVerifyUser=c.observable(""),this.priority=c.observable(Ab.MessagePriority.Normal),this.readReceipt=c.observable(""),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid=c.observable(0),this.threads=c.observableArray([]),this.threadsLen=c.observable(0),this.hasUnseenSubMessage=c.observable(!1),this.hasFlaggedSubMessage=c.observable(!1),this.lastInCollapsedThread=c.observable(!1),this.lastInCollapsedThreadLoading=c.observable(!1),this.threadsLenResult=c.computed(function(){var a=this.threadsLen();return 0===this.parentUid()&&a>0?a+1:""},this)}function B(){this.name=c.observable(""),this.fullName="",this.fullNameRaw="",this.fullNameHash="",this.delimiter="",this.namespace="",this.deep=0,this.interval=0,this.selectable=!1,this.existen=!0,this.type=c.observable(Ab.FolderType.User),this.focused=c.observable(!1),this.selected=c.observable(!1),this.edited=c.observable(!1),this.collapsed=c.observable(!0),this.subScribed=c.observable(!0),this.subFolders=c.observableArray([]),this.deleteAccess=c.observable(!1),this.actionBlink=c.observable(!1).extend({falseTimeout:1e3}),this.nameForEdit=c.observable(""),this.name.subscribe(function(a){this.nameForEdit(a)},this),this.edited.subscribe(function(a){a&&this.nameForEdit(this.name())},this),this.privateMessageCountAll=c.observable(0),this.privateMessageCountUnread=c.observable(0),this.collapsedPrivate=c.observable(!0)}function C(a,b){this.email=a,this.deleteAccess=c.observable(!1),this.canBeDalete=c.observable(b)}function D(a,b,d){this.id=a,this.email=c.observable(b),this.name=c.observable(""),this.replyTo=c.observable(""),this.bcc=c.observable(""),this.deleteAccess=c.observable(!1),this.canBeDalete=c.observable(d)}function E(a,b,d,e,f,g,h){this.index=a,this.id=d,this.guid=b,this.user=e,this.email=f,this.armor=h,this.isPrivate=!!g,this.deleteAccess=c.observable(!1)}function F(){r.call(this,"Popups","PopupsFolderClear"),this.selectedFolder=c.observable(null),this.clearingProcess=c.observable(!1),this.clearingError=c.observable(""),this.folderFullNameForClear=c.computed(function(){var a=this.selectedFolder();return a?a.printableFullName():""},this),this.folderNameForClear=c.computed(function(){var a=this.selectedFolder();return a?a.localName():""},this),this.dangerDescHtml=c.computed(function(){return Cb.i18n("POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1",{FOLDER:this.folderNameForClear()})},this),this.clearCommand=Cb.createCommand(this,function(){var a=this,b=this.selectedFolder();b&&(Pb.data().message(null),Pb.data().messageList([]),this.clearingProcess(!0),Pb.cache().setFolderHash(b.fullNameRaw,""),Pb.remote().folderClear(function(b,c){a.clearingProcess(!1),Ab.StorageResultType.Success===b&&c&&c.Result?(Pb.reloadMessageList(!0),a.cancelCommand()):a.clearingError(c&&c.ErrorCode?Cb.getNotification(c.ErrorCode):Cb.getNotification(Ab.Notification.MailServerError))},b.fullNameRaw))},function(){var a=this.selectedFolder(),b=this.clearingProcess();return!b&&null!==a}),t.constructorEnd(this)}function G(){r.call(this,"Popups","PopupsFolderCreate"),Cb.initOnStartOrLangChange(function(){this.sNoParentText=Cb.i18n("POPUPS_CREATE_FOLDER/SELECT_NO_PARENT")},this),this.folderName=c.observable(""),this.folderName.focused=c.observable(!1),this.selectedParentValue=c.observable(zb.Values.UnuseOptionValue),this.parentFolderSelectList=c.computed(function(){var a=Pb.data(),b=[],c=null,d=null,e=a.folderList(),f=function(a){return a?a.isSystemFolder()?a.name()+" "+a.manageFolderSystemName():a.name():""};return b.push(["",this.sNoParentText]),""!==a.namespace&&(c=function(b){return a.namespace!==b.fullNameRaw.substr(0,a.namespace.length)}),Pb.folderListOptionsBuilder([],e,[],b,null,c,d,f)},this),this.createFolder=Cb.createCommand(this,function(){var a=Pb.data(),b=this.selectedParentValue();""===b&&1 =a?1:a},this),this.contactsPagenator=c.computed(Cb.computedPagenatorHelper(this.contactsPage,this.contactsPageCount)),this.emptySelection=c.observable(!0),this.viewClearSearch=c.observable(!1),this.viewID=c.observable(""),this.viewReadOnly=c.observable(!1),this.viewProperties=c.observableArray([]),this.viewTags=c.observable(""),this.viewTags.visibility=c.observable(!1),this.viewTags.focusTrigger=c.observable(!1),this.viewTags.focusTrigger.subscribe(function(a){a||""!==this.viewTags()?a&&this.viewTags.visibility(!0):this.viewTags.visibility(!1)},this),this.viewSaveTrigger=c.observable(Ab.SaveSettingsStep.Idle),this.viewPropertiesNames=this.viewProperties.filter(function(a){return-1 a)break;b[0]&&b[1]&&b[2]&&b[1]===b[2]&&("PRIVATE"===b[1]?e.privateKeys.importKey(b[0]):"PUBLIC"===b[1]&&e.publicKeys.importKey(b[0])),a--}return e.store(),Pb.reloadOpenPgpKeys(),Cb.delegateRun(this,"cancelCommand"),!0}),t.constructorEnd(this)}function N(){r.call(this,"Popups","PopupsViewOpenPgpKey"),this.key=c.observable(""),this.keyDom=c.observable(null),t.constructorEnd(this)}function O(){r.call(this,"Popups","PopupsGenerateNewOpenPgpKey"),this.email=c.observable(""),this.email.focus=c.observable(""),this.email.error=c.observable(!1),this.name=c.observable(""),this.password=c.observable(""),this.keyBitLength=c.observable(2048),this.submitRequest=c.observable(!1),this.email.subscribe(function(){this.email.error(!1)},this),this.generateOpenPgpKeyCommand=Cb.createCommand(this,function(){var b=this,c="",d=null,e=Pb.data().openpgpKeyring;return this.email.error(""===Cb.trim(this.email())),!e||this.email.error()?!1:(c=this.email(),""!==this.name()&&(c=this.name()+" <"+c+">"),this.submitRequest(!0),h.delay(function(){d=a.openpgp.generateKeyPair(1,Cb.pInt(b.keyBitLength()),c,Cb.trim(b.password())),d&&d.privateKeyArmored&&(e.privateKeys.importKey(d.privateKeyArmored),e.publicKeys.importKey(d.publicKeyArmored),e.store(),Pb.reloadOpenPgpKeys(),Cb.delegateRun(b,"cancelCommand")),b.submitRequest(!1)},100),!0)}),t.constructorEnd(this)}function P(){r.call(this,"Popups","PopupsComposeOpenPgp"),this.notification=c.observable(""),this.sign=c.observable(!0),this.encrypt=c.observable(!0),this.password=c.observable(""),this.password.focus=c.observable(!1),this.buttonFocus=c.observable(!1),this.from=c.observable(""),this.to=c.observableArray([]),this.text=c.observable(""),this.resultCallback=null,this.submitRequest=c.observable(!1),this.doCommand=Cb.createCommand(this,function(){var b=this,c=!0,d=Pb.data(),e=null,f=[];this.submitRequest(!0),c&&this.sign()&&""===this.from()&&(this.notification(Cb.i18n("PGP_NOTIFICATIONS/SPECIFY_FROM_EMAIL")),c=!1),c&&this.sign()&&(e=d.findPrivateKeyByEmail(this.from(),this.password()),e||(this.notification(Cb.i18n("PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR",{EMAIL:this.from()})),c=!1)),c&&this.encrypt()&&0===this.to().length&&(this.notification(Cb.i18n("PGP_NOTIFICATIONS/SPECIFY_AT_LEAST_ONE_RECIPIENT")),c=!1),c&&this.encrypt()&&(f=[],h.each(this.to(),function(a){var e=d.findPublicKeysByEmail(a);0===e.length&&c&&(b.notification(Cb.i18n("PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR",{EMAIL:a})),c=!1),f=f.concat(e)}),!c||0!==f.length&&this.to().length===f.length||(c=!1)),h.delay(function(){if(b.resultCallback&&c)try{e&&0===f.length?b.resultCallback(a.openpgp.signClearMessage([e],b.text())):e&&0 0&&b>0&&a>b},this),this.hasMessages=c.computed(function(){return 0 '),e.after(f),e.remove()),f&&f[0]&&(f.attr("data-href",g).attr("data-theme",a[0]),f&&f[0]&&f[0].styleSheet&&!Cb.isUnd(f[0].styleSheet.cssText)?f[0].styleSheet.cssText=a[1]:f.text(a[1])),d.themeTrigger(Ab.SaveSettingsStep.TrueResult))}).always(function(){d.iTimer=a.setTimeout(function(){d.themeTrigger(Ab.SaveSettingsStep.Idle)},1e3),d.oLastAjax=null})),Pb.remote().saveSettings(null,{Theme:c})},this)}function mb(){this.openpgpkeys=Pb.data().openpgpkeys,this.openpgpkeysPublic=Pb.data().openpgpkeysPublic,this.openpgpkeysPrivate=Pb.data().openpgpkeysPrivate,this.openPgpKeyForDeletion=c.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]})}function nb(){this.leftPanelDisabled=c.observable(!1),this.useKeyboardShortcuts=c.observable(!0),this.keyScopeReal=c.observable(Ab.KeyState.All),this.keyScopeFake=c.observable(Ab.KeyState.All),this.keyScope=c.computed({owner:this,read:function(){return this.keyScopeFake()},write:function(a){Ab.KeyState.Menu!==a&&(Ab.KeyState.Compose===a?Cb.disableKeyFilter():Cb.restoreKeyFilter(),this.keyScopeFake(a),Fb.dropdownVisibility()&&(a=Ab.KeyState.Menu)),this.keyScopeReal(a)}}),this.keyScopeReal.subscribe(function(a){j.setScope(a)}),this.leftPanelDisabled.subscribe(function(a){Pb.pub("left-panel."+(a?"off":"on"))}),Fb.dropdownVisibility.subscribe(function(a){a?this.keyScope(Ab.KeyState.Menu):Ab.KeyState.Menu===j.getScope()&&this.keyScope(this.keyScopeFake())},this),Cb.initDataConstructorBySettings(this)}function ob(){nb.call(this);var d=function(a){return function(){var b=Pb.cache().getFolderFromCacheList(a());b&&b.type(Ab.FolderType.User)}},e=function(a){return function(b){var c=Pb.cache().getFolderFromCacheList(b);c&&c.type(a)}};this.devEmail="",this.devLogin="",this.devPassword="",this.accountEmail=c.observable(""),this.accountIncLogin=c.observable(""),this.accountOutLogin=c.observable(""),this.projectHash=c.observable(""),this.threading=c.observable(!1),this.lastFoldersHash="",this.remoteSuggestions=!1,this.sentFolder=c.observable(""),this.draftFolder=c.observable(""),this.spamFolder=c.observable(""),this.trashFolder=c.observable(""),this.archiveFolder=c.observable(""),this.sentFolder.subscribe(d(this.sentFolder),this,"beforeChange"),this.draftFolder.subscribe(d(this.draftFolder),this,"beforeChange"),this.spamFolder.subscribe(d(this.spamFolder),this,"beforeChange"),this.trashFolder.subscribe(d(this.trashFolder),this,"beforeChange"),this.archiveFolder.subscribe(d(this.archiveFolder),this,"beforeChange"),this.sentFolder.subscribe(e(Ab.FolderType.SentItems),this),this.draftFolder.subscribe(e(Ab.FolderType.Draft),this),this.spamFolder.subscribe(e(Ab.FolderType.Spam),this),this.trashFolder.subscribe(e(Ab.FolderType.Trash),this),this.archiveFolder.subscribe(e(Ab.FolderType.Archive),this),this.draftFolderNotEnabled=c.computed(function(){return""===this.draftFolder()||zb.Values.UnuseOptionValue===this.draftFolder()},this),this.displayName=c.observable(""),this.signature=c.observable(""),this.signatureToAll=c.observable(!1),this.replyTo=c.observable(""),this.enableTwoFactor=c.observable(!1),this.accounts=c.observableArray([]),this.accountsLoading=c.observable(!1).extend({throttle:100}),this.identities=c.observableArray([]),this.identitiesLoading=c.observable(!1).extend({throttle:100}),this.contactTags=c.observableArray([]),this.contacts=c.observableArray([]),this.contacts.loading=c.observable(!1).extend({throttle:200}),this.contacts.importing=c.observable(!1).extend({throttle:200}),this.contacts.syncing=c.observable(!1).extend({throttle:200}),this.contacts.exportingVcf=c.observable(!1).extend({throttle:200}),this.contacts.exportingCsv=c.observable(!1).extend({throttle:200}),this.allowContactsSync=c.observable(!1),this.enableContactsSync=c.observable(!1),this.contactsSyncUrl=c.observable(""),this.contactsSyncUser=c.observable(""),this.contactsSyncPass=c.observable(""),this.allowContactsSync=c.observable(!!Pb.settingsGet("ContactsSyncIsAllowed")),this.enableContactsSync=c.observable(!!Pb.settingsGet("EnableContactsSync")),this.contactsSyncUrl=c.observable(Pb.settingsGet("ContactsSyncUrl")),this.contactsSyncUser=c.observable(Pb.settingsGet("ContactsSyncUser")),this.contactsSyncPass=c.observable(Pb.settingsGet("ContactsSyncPassword")),this.namespace="",this.folderList=c.observableArray([]),this.folderList.focused=c.observable(!1),this.foldersListError=c.observable(""),this.foldersLoading=c.observable(!1),this.foldersCreating=c.observable(!1),this.foldersDeleting=c.observable(!1),this.foldersRenaming=c.observable(!1),this.foldersChanging=c.computed(function(){var a=this.foldersLoading(),b=this.foldersCreating(),c=this.foldersDeleting(),d=this.foldersRenaming();return a||b||c||d},this),this.foldersInboxUnreadCount=c.observable(0),this.currentFolder=c.observable(null).extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]}),this.currentFolderFullNameRaw=c.computed(function(){return this.currentFolder()?this.currentFolder().fullNameRaw:""},this),this.currentFolderFullName=c.computed(function(){return this.currentFolder()?this.currentFolder().fullName:""},this),this.currentFolderFullNameHash=c.computed(function(){return this.currentFolder()?this.currentFolder().fullNameHash:""},this),this.currentFolderName=c.computed(function(){return this.currentFolder()?this.currentFolder().name():""},this),this.folderListSystemNames=c.computed(function(){var a=["INBOX"],b=this.folderList(),c=this.sentFolder(),d=this.draftFolder(),e=this.spamFolder(),f=this.trashFolder(),g=this.archiveFolder(); +return Cb.isArray(b)&&0 =a?1:a},this),this.mainMessageListSearch=c.computed({read:this.messageListSearch,write:function(a){Ib.setHash(Pb.link().mailBox(this.currentFolderFullNameHash(),1,Cb.trim(a.toString())))},owner:this}),this.messageListError=c.observable(""),this.messageListLoading=c.observable(!1),this.messageListIsNotCompleted=c.observable(!1),this.messageListCompleteLoadingThrottle=c.observable(!1).extend({throttle:200}),this.messageListCompleteLoading=c.computed(function(){var a=this.messageListLoading(),b=this.messageListIsNotCompleted();return a||b},this),this.messageListCompleteLoading.subscribe(function(a){this.messageListCompleteLoadingThrottle(a)},this),this.messageList.subscribe(h.debounce(function(a){h.each(a,function(a){a.newForAnimation()&&a.newForAnimation(!1)})},500)),this.staticMessageList=new A,this.message=c.observable(null),this.messageLoading=c.observable(!1),this.messageLoadingThrottle=c.observable(!1).extend({throttle:50}),this.message.focused=c.observable(!1),this.message.subscribe(function(b){b?Ab.Layout.NoPreview===this.layout()&&this.message.focused(!0):(this.message.focused(!1),this.hideMessageBodies(),Ab.Layout.NoPreview===Pb.data().layout()&&-1 0?Math.ceil(b/a*100):0},this),this.allowOpenPGP=c.observable(!1),this.openpgpkeys=c.observableArray([]),this.openpgpKeyring=null,this.openpgpkeysPublic=this.openpgpkeys.filter(function(a){return!(!a||a.isPrivate)}),this.openpgpkeysPrivate=this.openpgpkeys.filter(function(a){return!(!a||!a.isPrivate)}),this.googleActions=c.observable(!1),this.googleLoggined=c.observable(!1),this.googleUserName=c.observable(""),this.facebookActions=c.observable(!1),this.facebookLoggined=c.observable(!1),this.facebookUserName=c.observable(""),this.twitterActions=c.observable(!1),this.twitterLoggined=c.observable(!1),this.twitterUserName=c.observable(""),this.customThemeType=c.observable(Ab.CustomThemeType.Light),this.purgeMessageBodyCacheThrottle=h.throttle(this.purgeMessageBodyCache,3e4)}function pb(){this.oRequests={}}function qb(){pb.call(this),this.oRequests={}}function rb(){this.oEmailsPicsHashes={},this.oServices={},this.bAllowGravatar=!!Pb.settingsGet("AllowGravatar")}function sb(){rb.call(this),this.oFoldersCache={},this.oFoldersNamesCache={},this.oFolderHashCache={},this.oFolderUidNextCache={},this.oMessageListHashCache={},this.oMessageFlagsCache={},this.oNewMessage={},this.oRequestedMessage={}}function tb(a){s.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function ub(){s.call(this,"login",[V])}function vb(){s.call(this,"mailbox",[X,Z,$,_]),this.oLastRoute={}}function wb(){tb.call(this,[Y,ab,bb]),Cb.initOnStartOrLangChange(function(){this.sSettingsTitle=Cb.i18n("TITLES/SETTINGS")},this,function(){Pb.setTitle(this.sSettingsTitle)})}function xb(){q.call(this),this.oSettings=null,this.oPlugins=null,this.oLocal=null,this.oLink=null,this.oSubs={},this.isLocalAutocomplete=!0,this.popupVisibilityNames=c.observableArray([]),this.popupVisibility=c.computed(function(){return 0 ').appendTo("body"),Mb.on("error",function(a){Pb&&a&&a.originalEvent&&a.originalEvent.message&&-1===Cb.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&Pb.remote().jsError(Cb.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",Lb.attr("class"),Cb.microtime()-Fb.now)}),Nb.on("keydown",function(a){a&&a.ctrlKey&&Lb.addClass("rl-ctrl-key-pressed")}).on("keyup",function(a){a&&!a.ctrlKey&&Lb.removeClass("rl-ctrl-key-pressed")})}function yb(){xb.call(this),this.oData=null,this.oRemote=null,this.oCache=null,this.oMoveCache={},this.quotaDebounce=h.debounce(this.quota,3e4),this.moveOrDeleteResponseHelper=h.bind(this.moveOrDeleteResponseHelper,this),this.messagesMoveTrigger=h.debounce(this.messagesMoveTrigger,500),a.setInterval(function(){Pb.pub("interval.30s")},3e4),a.setInterval(function(){Pb.pub("interval.1m")},6e4),a.setInterval(function(){Pb.pub("interval.2m")},12e4),a.setInterval(function(){Pb.pub("interval.3m")},18e4),a.setInterval(function(){Pb.pub("interval.5m")},3e5),a.setInterval(function(){Pb.pub("interval.10m")},6e5),a.setTimeout(function(){a.setInterval(function(){Pb.pub("interval.10m-after5m")},6e5)},3e5),b.wakeUp(function(){Pb.remote().jsVersion(function(b,c){Ab.StorageResultType.Success===b&&c&&!c.Result&&(a.parent&&Pb.settingsGet("InIframe")?a.parent.location.reload():a.location.reload())},Pb.settingsGet("Version"))},{},36e5)}var zb={},Ab={},Bb={},Cb={},Db={},Eb={},Fb={},Gb={settings:[],"settings-removed":[],"settings-disabled":[]},Hb=[],Ib=null,Jb=a.rainloopAppData||{},Kb=a.rainloopI18N||{},Lb=b("html"),Mb=b(a),Nb=b(a.document),Ob=a.Notification&&a.Notification.requestPermission?a.Notification:null,Pb=null,Qb=b("");Fb.now=(new Date).getTime(),Fb.momentTrigger=c.observable(!0),Fb.dropdownVisibility=c.observable(!1).extend({rateLimit:0}),Fb.langChangeTrigger=c.observable(!0),Fb.iAjaxErrorCount=0,Fb.iTokenErrorCount=0,Fb.iMessageBodyCacheCount=0,Fb.bUnload=!1,Fb.sUserAgent=(navigator.userAgent||"").toLowerCase(),Fb.bIsiOSDevice=-1 /g,">").replace(/"/g,""").replace(/'/g,"'"):""},Cb.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=Cb.isUnd(b)?100:b;e.length>b;)d=e.substring(0,b),f=d.lastIndexOf(" "),g=d.lastIndexOf("\n"),-1!==g&&(f=g),-1===f&&(f=b),c+=d.substring(0,f)+"\n",e=e.substring(f+1);return c+e},Cb.timeOutAction=function(){var b={};return function(c,d,e){Cb.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),Cb.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),Cb.audio=function(){var b=!1;return function(c,d){if(!1===b)if(Fb.bIsiOSDevice)b=null;else{var e=!1,f=!1,g=a.Audio?new a.Audio:null;g&&g.canPlayType&&g.play?(e=""!==g.canPlayType('audio/mpeg; codecs="mp3"'),e||(f=""!==g.canPlayType('audio/ogg; codecs="vorbis"')),e||f?(b=g,b.preload="none",b.loop=!1,b.autoplay=!1,b.muted=!1,b.src=e?c:d):b=null):b=null}return b}}(),Cb.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},Cb.i18n=function(a,b,c){var d="",e=Cb.isUnd(Kb[a])?Cb.isUnd(c)?a:c:Kb[a];if(!Cb.isUnd(b)&&!Cb.isNull(b))for(d in b)Cb.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},Cb.i18nToNode=function(a){h.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(Cb.i18n(c)):(c=a.data("i18n-html"),c&&a.html(Cb.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",Cb.i18n(c)),c=a.data("i18n-title"),c&&a.attr("title",Cb.i18n(c)))})})},Cb.i18nToDoc=function(){a.rainloopI18N&&(Kb=a.rainloopI18N||{},Cb.i18nToNode(Nb),Fb.langChangeTrigger(!Fb.langChangeTrigger())),a.rainloopI18N={}},Cb.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?Fb.langChangeTrigger.subscribe(function(){a&&a.call(b),c.call(b)}):a&&Fb.langChangeTrigger.subscribe(a,b)},Cb.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&a.contentEditable)},Cb.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},Cb.removeSelection=function(){if(a&&a.getSelection){var b=a.getSelection();b&&b.removeAllRanges&&b.removeAllRanges()}else document&&document.selection&&document.selection.empty&&document.selection.empty()},Cb.replySubjectAdd=function(b,c,d){var e=null,f=Cb.trim(c);return f=null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||Cb.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||Cb.isUnd(e[1])||Cb.isUnd(e[2])||Cb.isUnd(e[3])?b+": "+c:e[1]+(Cb.pInt(e[2])+1)+e[3]:b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),f=(Cb.isUnd(d)?!0:d)?Cb.fixLongSubject(f):f},Cb.fixLongSubject=function(a){var b=0,c=null;a=Cb.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||Cb.isUnd(c[0]))&&(c=null),c&&(b=0,b+=Cb.isUnd(c[2])?1:0+Cb.pInt(c[2]),b+=Cb.isUnd(c[4])?1:0+Cb.pInt(c[4]),a=a.replace(/^Re(\[[\d]+\]|):[\s]{0,3}Re(\[[\d]+\]|):/gi,"Re"+(b>0?"["+b+"]":"")+":"));while(c);return a=a.replace(/[\s]+/," ")},Cb.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},Cb.friendlySize=function(a){return a=Cb.pInt(a),a>=1073741824?Cb.roundNumber(a/1073741824,1)+"GB":a>=1048576?Cb.roundNumber(a/1048576,1)+"MB":a>=1024?Cb.roundNumber(a/1024,0)+"KB":a+"B"},Cb.log=function(b){a.console&&a.console.log&&a.console.log(b)},Cb.getNotification=function(a,b){return a=Cb.pInt(a),Ab.Notification.ClientViewError===a&&b?b:Cb.isUnd(Bb[a])?"":Bb[a]},Cb.initNotificationLanguage=function(){Bb[Ab.Notification.InvalidToken]=Cb.i18n("NOTIFICATIONS/INVALID_TOKEN"),Bb[Ab.Notification.AuthError]=Cb.i18n("NOTIFICATIONS/AUTH_ERROR"),Bb[Ab.Notification.AccessError]=Cb.i18n("NOTIFICATIONS/ACCESS_ERROR"),Bb[Ab.Notification.ConnectionError]=Cb.i18n("NOTIFICATIONS/CONNECTION_ERROR"),Bb[Ab.Notification.CaptchaError]=Cb.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),Bb[Ab.Notification.SocialFacebookLoginAccessDisable]=Cb.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),Bb[Ab.Notification.SocialTwitterLoginAccessDisable]=Cb.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),Bb[Ab.Notification.SocialGoogleLoginAccessDisable]=Cb.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),Bb[Ab.Notification.DomainNotAllowed]=Cb.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),Bb[Ab.Notification.AccountNotAllowed]=Cb.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),Bb[Ab.Notification.AccountTwoFactorAuthRequired]=Cb.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED"),Bb[Ab.Notification.AccountTwoFactorAuthError]=Cb.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR"),Bb[Ab.Notification.CouldNotSaveNewPassword]=Cb.i18n("NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD"),Bb[Ab.Notification.CurrentPasswordIncorrect]=Cb.i18n("NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT"),Bb[Ab.Notification.NewPasswordShort]=Cb.i18n("NOTIFICATIONS/NEW_PASSWORD_SHORT"),Bb[Ab.Notification.NewPasswordWeak]=Cb.i18n("NOTIFICATIONS/NEW_PASSWORD_WEAK"),Bb[Ab.Notification.NewPasswordForbidden]=Cb.i18n("NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT"),Bb[Ab.Notification.ContactsSyncError]=Cb.i18n("NOTIFICATIONS/CONTACTS_SYNC_ERROR"),Bb[Ab.Notification.CantGetMessageList]=Cb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),Bb[Ab.Notification.CantGetMessage]=Cb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),Bb[Ab.Notification.CantDeleteMessage]=Cb.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),Bb[Ab.Notification.CantMoveMessage]=Cb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),Bb[Ab.Notification.CantCopyMessage]=Cb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),Bb[Ab.Notification.CantSaveMessage]=Cb.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),Bb[Ab.Notification.CantSendMessage]=Cb.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),Bb[Ab.Notification.InvalidRecipients]=Cb.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),Bb[Ab.Notification.CantCreateFolder]=Cb.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),Bb[Ab.Notification.CantRenameFolder]=Cb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),Bb[Ab.Notification.CantDeleteFolder]=Cb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),Bb[Ab.Notification.CantDeleteNonEmptyFolder]=Cb.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),Bb[Ab.Notification.CantSubscribeFolder]=Cb.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),Bb[Ab.Notification.CantUnsubscribeFolder]=Cb.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),Bb[Ab.Notification.CantSaveSettings]=Cb.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),Bb[Ab.Notification.CantSavePluginSettings]=Cb.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),Bb[Ab.Notification.DomainAlreadyExists]=Cb.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),Bb[Ab.Notification.CantInstallPackage]=Cb.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),Bb[Ab.Notification.CantDeletePackage]=Cb.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),Bb[Ab.Notification.InvalidPluginPackage]=Cb.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),Bb[Ab.Notification.UnsupportedPluginPackage]=Cb.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),Bb[Ab.Notification.LicensingServerIsUnavailable]=Cb.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),Bb[Ab.Notification.LicensingExpired]=Cb.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),Bb[Ab.Notification.LicensingBanned]=Cb.i18n("NOTIFICATIONS/LICENSING_BANNED"),Bb[Ab.Notification.DemoSendMessageError]=Cb.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),Bb[Ab.Notification.AccountAlreadyExists]=Cb.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),Bb[Ab.Notification.MailServerError]=Cb.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),Bb[Ab.Notification.UnknownNotification]=Cb.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),Bb[Ab.Notification.UnknownError]=Cb.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},Cb.getUploadErrorDescByCode=function(a){var b="";switch(Cb.pInt(a)){case Ab.UploadErrorCode.FileIsTooBig:b=Cb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case Ab.UploadErrorCode.FilePartiallyUploaded:b=Cb.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case Ab.UploadErrorCode.FileNoUploaded:b=Cb.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case Ab.UploadErrorCode.MissingTempFolder:b=Cb.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case Ab.UploadErrorCode.FileOnSaveingError:b=Cb.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case Ab.UploadErrorCode.FileType:b=Cb.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=Cb.i18n("UPLOAD/ERROR_UNKNOWN")}return b},Cb.delegateRun=function(a,b,c,d){a&&a[b]&&(d=Cb.pInt(d),0>=d?a[b].apply(a,Cb.isArray(c)?c:[]):h.delay(function(){a[b].apply(a,Cb.isArray(c)?c:[])},d))},Cb.killCtrlAandS=function(b){if(b=b||a.event,b&&b.ctrlKey&&!b.shiftKey&&!b.altKey){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(d===Ab.EventKeyCode.S)return void b.preventDefault();if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;d===Ab.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},Cb.createCommand=function(a,b,d){var e=b?function(){return e.canExecute&&e.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments)),!1}:function(){};return e.enabled=c.observable(!0),d=Cb.isUnd(d)?!0:d,e.canExecute=c.computed(Cb.isFunc(d)?function(){return e.enabled()&&d.call(a)}:function(){return e.enabled()&&!!d}),e},Cb.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(Ab.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(Ab.InterfaceAnimation.Full),b.contactsAutosave=c.observable(!1),Fb.sAnimationType=Ab.InterfaceAnimation.Full,b.allowThemes=c.observable(!0),b.allowCustomLogin=c.observable(!1),b.allowLanguagesOnSettings=c.observable(!0),b.allowLanguagesOnLogin=c.observable(!0),b.desktopNotifications=c.observable(!1),b.useThreads=c.observable(!0),b.replySameFolder=c.observable(!0),b.useCheckboxesInList=c.observable(!0),b.layout=c.observable(Ab.Layout.SidePreview),b.usePreviewPane=c.computed(function(){return Ab.Layout.NoPreview!==b.layout()}),b.interfaceAnimation.subscribe(function(a){if(Fb.bMobileDevice||a===Ab.InterfaceAnimation.None)Lb.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),Fb.sAnimationType=Ab.InterfaceAnimation.None;else switch(a){case Ab.InterfaceAnimation.Full:Lb.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),Fb.sAnimationType=a;break;case Ab.InterfaceAnimation.Normal:Lb.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),Fb.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=Ab.DesktopNotifications.NotSupported;if(Ob&&Ob.permission)switch(Ob.permission.toLowerCase()){case"granted":c=Ab.DesktopNotifications.Allowed;break;case"denied":c=Ab.DesktopNotifications.Denied;break;case"default":c=Ab.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&Ab.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();Ab.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):Ab.DesktopNotifications.NotAllowed===c?Ob.requestPermission(function(){b.desktopNotifications.valueHasMutated(),Ab.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()?b.desktopNotifications()?b.desktopNotifications.valueHasMutated():b.desktopNotifications(!0):b.desktopNotifications()?b.desktopNotifications(!1):b.desktopNotifications.valueHasMutated()}):b.desktopNotifications(!1)}else b.desktopNotifications(!1)}}),b.language=c.observable(""),b.languages=c.observableArray([]),b.mainLanguage=c.computed({read:b.language,write:function(a){a!==b.language()?-1 =b.diff(c,"hours")?d:b.format("L")===c.format("L")?Cb.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?Cb.i18n("MESSAGE_LIST/YESTERDAY_AT",{TIME:c.format("LT")}):c.format(b.year()===c.year()?"D MMM.":"LL")},a)},Cb.isFolderExpanded=function(a){var b=Pb.local().get(Ab.ClientSideKeyName.ExpandedFolders);return h.isArray(b)&&-1!==h.indexOf(b,a)},Cb.setExpandedFolder=function(a,b){var c=Pb.local().get(Ab.ClientSideKeyName.ExpandedFolders);h.isArray(c)||(c=[]),b?(c.push(a),c=h.uniq(c)):c=h.without(c,a),Pb.local().set(Ab.ClientSideKeyName.ExpandedFolders,c)},Cb.initLayoutResizer=function(a,c,d){var e=60,f=155,g=b(a),h=b(c),i=Pb.local().get(d)||null,j=function(a){a&&(g.css({width:""+a+"px"}),h.css({left:""+a+"px"}))},k=function(a){if(a)g.resizable("disable"),j(e);else{g.resizable("enable");var b=Cb.pInt(Pb.local().get(d))||f;j(b>f?b:f)}},l=function(a,b){b&&b.size&&b.size.width&&(Pb.local().set(d,b.size.width),h.css({left:""+b.size.width+"px"}))};null!==i&&j(i>f?i:f),g.resizable({helper:"ui-resizable-helper",minWidth:f,maxWidth:350,handles:"e",stop:l}),Pb.sub("left-panel.off",function(){k(!0)}),Pb.sub("left-panel.on",function(){k(!1)})},Cb.initBlockquoteSwitcher=function(a){if(a){var c=b("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===b(this).parent().closest("blockquote",a).length});c&&0 100)&&(a.addClass("rl-bq-switcher hidden-bq"),b('').insertBefore(a).click(function(){a.toggleClass("hidden-bq"),Cb.windowResize()}).after("
").before("
"))})}},Cb.removeBlockquoteSwitcher=function(a){a&&(b(a).find("blockquote.rl-bq-switcher").each(function(){b(this).removeClass("rl-bq-switcher hidden-bq")}),b(a).find(".rlBlockquoteSwitcher").each(function(){b(this).remove()}))},Cb.toggleMessageBlockquote=function(a){a&&a.find(".rlBlockquoteSwitcher").click()},Cb.extendAsViewModel=function(a,b,c){b&&(c||(c=r),b.__name=a,Db.regViewModelHook(a,b),h.extend(b.prototype,c.prototype))},Cb.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},Gb.settings.push(a)},Cb.removeSettingsViewModel=function(a){Gb["settings-removed"].push(a)},Cb.disableSettingsViewModel=function(a){Gb["settings-disabled"].push(a)},Cb.convertThemeName=function(a){return"@custom"===a.substr(-7)&&(a=Cb.trim(a.substring(0,a.length-7))),Cb.trim(a.replace(/[^a-zA-Z]+/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},Cb.quoteName=function(a){return a.replace(/["]/g,'\\"')},Cb.microtime=function(){return(new Date).getTime()},Cb.convertLangName=function(a,b){return Cb.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},Cb.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=Cb.isUnd(a)?32:Cb.pInt(a);b.length>>32-b}function c(a,b){var c,d,e,f,g;return e=2147483648&a,f=2147483648&b,c=1073741824&a,d=1073741824&b,g=(1073741823&a)+(1073741823&b),c&d?2147483648^g^e^f:c|d?1073741824&g?3221225472^g^e^f:1073741824^g^e^f:g^e^f +}function d(a,b,c){return a&b|~a&c}function e(a,b,c){return a&c|b&~c}function f(a,b,c){return a^b^c}function g(a,b,c){return b^(a|~c)}function h(a,e,f,g,h,i,j){return a=c(a,c(c(d(e,f,g),h),j)),c(b(a,i),e)}function i(a,d,f,g,h,i,j){return a=c(a,c(c(e(d,f,g),h),j)),c(b(a,i),d)}function j(a,d,e,g,h,i,j){return a=c(a,c(c(f(d,e,g),h),j)),c(b(a,i),d)}function k(a,d,e,f,h,i,j){return a=c(a,c(c(g(d,e,f),h),j)),c(b(a,i),d)}function l(a){for(var b,c=a.length,d=c+8,e=(d-d%64)/64,f=16*(e+1),g=Array(f-1),h=0,i=0;c>i;)b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|a.charCodeAt(i)<>>29,g}function m(a){var b,c,d="",e="";for(c=0;3>=c;c++)b=a>>>8*c&255,e="0"+b.toString(16),d+=e.substr(e.length-2,2);return d}function n(a){a=a.replace(/rn/g,"n");for(var b="",c=0;c d?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var o,p,q,r,s,t,u,v,w,x=Array(),y=7,z=12,A=17,B=22,C=5,D=9,E=14,F=20,G=4,H=11,I=16,J=23,K=6,L=10,M=15,N=21;for(a=n(a),x=l(a),t=1732584193,u=4023233417,v=2562383102,w=271733878,o=0;o /g,">").replace(/")},Cb.draggeblePlace=function(){return b(' ').appendTo("#rl-hidden")},Cb.defautOptionsAfterRender=function(a,c){c&&!Cb.isUnd(c.disabled)&&a&&b(a).toggleClass("disabled",c.disabled).prop("disabled",c.disabled)},Cb.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+Cb.fakeMd5()+"__",j=b("#"+d);a[i]=function(){if(h&&h.document.body&&j&&j[0]){var d=b(h.document.body);b("#rl-content",d).html(j.html()),b("html",h.document).addClass("external "+b("html").attr("class")),Cb.i18nToNode(d),t.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.document.write(''+Cb.encodeHtml(e)+' '),h.document.close(),g=h.document.createElement("script"),g.type="text/javascript",g.innerHTML="if(window&&window.opener&&window.opener['"+i+"']){window.opener['"+i+"']();window.opener['"+i+"']=null}",h.document.getElementsByTagName("head")[0].appendChild(g)},Cb.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=Cb.isUnd(d)?1e3:Cb.pInt(d),function(e,f,g,i,j){b.call(c,f&&f.Result?Ab.SaveSettingsStep.TrueResult:Ab.SaveSettingsStep.FalseResult),a&&a.call(c,e,f,g,i,j),h.delay(function(){b.call(c,Ab.SaveSettingsStep.Idle)},d)}},Cb.settingsSaveHelperSimpleFunction=function(a,b){return Cb.settingsSaveHelperFunction(null,a,b,1e3)},Cb.htmlToPlain=function(a){var c="",d="> ",e=function(){if(arguments&&1\n",a.replace(/\n([> ]+)/gm,function(){return arguments&&1 ]*>(.|[\s\S\r\n]*)<\/div>/gim,f),a="\n"+b.trim(a)+"\n"),a}return""},g=function(){return arguments&&1 /g,">"):""},h=function(){if(arguments&&1 /gim,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,"\n").replace(/<\/tr>/gi,"\n").replace(/
]*>/gim,"\n_______________________________\n\n").replace(/]*>/gim,"").replace(/
]*>(.|[\s\S\r\n]*)<\/div>/gim,f).replace(/]*>/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,"")},Cb.plainToHtml=function(a){return a.toString().replace(/&/g,"&").replace(/>/g,">").replace(/")},Cb.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},Cb.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:Cb.isUnd(c)?a.toString():c.toString(),custom:Cb.isUnd(c)?!1:!0,title:Cb.isUnd(c)?"":a.toString(),value:a.toString()};(Cb.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}},Cb.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()}},Cb.disableKeyFilter=function(){a.key&&(j.filter=function(){return Pb.data().useKeyboardShortcuts()})},Cb.restoreKeyFilter=function(){a.key&&(j.filter=function(a){if(Pb.data().useKeyboardShortcuts()){var b=a.target||a.srcElement,c=b?b.tagName:"";return c=c.toUpperCase(),!("INPUT"===c||"SELECT"===c||"TEXTAREA"===c||b&&"DIV"===c&&"editorHtmlArea"===b.className&&b.contentEditable)}return!1})},Cb.detectDropdownVisibility=h.debounce(function(){Fb.dropdownVisibility(!!h.find(Hb,function(a){return a.hasClass("open")}))},50),Eb={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return Eb.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=Eb._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 Eb._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(!Fb.bMobileDevice){var e=b(a),f=e.data("tooltip-class")||"",g=e.data("tooltip-placement")||"top";e.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:g,trigger:"hover",title:function(){return e.is(".disabled")||Fb.dropdownVisibility()?"":''+Cb.i18n(c.utils.unwrapObservable(d()))+""}}).click(function(){e.tooltip("hide")}),Fb.dropdownVisibility.subscribe(function(a){a&&e.tooltip("hide")})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a),e=d.data("tooltip-class")||"",f=d.data("tooltip-placement")||"top";d.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:f,title:function(){return d.is(".disabled")||Fb.dropdownVisibility()?"":''+c()()+""}}).click(function(){d.tooltip("hide")}),Fb.dropdownVisibility.subscribe(function(a){a&&d.tooltip("hide")})}},c.bindingHandlers.tooltip3={init:function(a){var c=b(a);c.tooltip({container:"body",trigger:"hover manual",title:function(){return c.data("tooltip3-data")||""}}),Fb.dropdownVisibility.subscribe(function(a){a&&c.tooltip("hide")}),Nb.click(function(){c.tooltip("hide")})},update:function(a,d){var e=c.utils.unwrapObservable(d());""===e?b(a).data("tooltip3-data","").tooltip("hide"):b(a).data("tooltip3-data",e).tooltip("show")}},c.bindingHandlers.registrateBootstrapDropdown={init:function(a){Hb.push(b(a))}},c.bindingHandlers.openDropdownTrigger={update:function(a,d){if(c.utils.unwrapObservable(d())){var e=b(a);e.hasClass("open")||(e.find(".dropdown-toggle").dropdown("toggle"),Cb.detectDropdownVisibility()),d()(!1)}}},c.bindingHandlers.dropdownCloser={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&&!Cb.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&&!Cb.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.clickOnTrue={update:function(a,d){c.utils.unwrapObservable(d())&&b(a).click()}},c.bindingHandlers.modal={init:function(a,d){b(a).toggleClass("fade",!Fb.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("shown",function(){Cb.windowResize()}).find(".close").click(function(){d()(!1)})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){Cb.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),Cb.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=Cb.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=Cb.pInt(e[2]),g=Mb.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(!Fb.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),Cb.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),Cb.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)},b(d).draggable(k).on("mousedown",function(){Cb.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!Fb.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){Fb.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(),f=function(a){e&&e.focusTrigger&&e.focusTrigger(a)};d.inputosaurus({parseOnBlur:!0,allowDragAndDrop:!0,focusCallback:f,inputDelimiters:[",",";"],autoCompleteSource:function(a,b){Pb.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=Cb.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(a){a&&d.inputosaurus("focus")})}},c.bindingHandlers.contactTags={init:function(a,c){var d=b(a),e=c(),f=function(a){e&&e.focusTrigger&&e.focusTrigger(a)};d.inputosaurus({parseOnBlur:!0,allowDragAndDrop:!1,focusCallback:f,inputDelimiters:[";"],outputDelimiter:";",autoCompleteSource:function(a,b){Pb.getContactsTagsAutocomplete(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=Cb.trim(a),c=null;return""!==b?(c=new x,c.name(b),[c.toLine(!1),c]):[b,null]})},change:h.bind(function(a){d.data("ContactsTagsValue",a.target.value),e(a.target.value)},this)}),e.subscribe(function(a){d.data("ContactsTagsValue")!==a&&(d.val(a),d.data("ContactsTagsValue",a),d.inputosaurus("refresh"))}),e.focusTrigger&&e.focusTrigger.subscribe(function(a){a&&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(Cb.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},Cb.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=Cb.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=Cb.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),Cb.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},k.prototype.root=function(){return this.sBase},k.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},k.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},k.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},k.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},k.prototype.uploadContacts=function(){return this.sServer+"/UploadContacts/"+this.sSpecSuffix+"/"},k.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},k.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},k.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},k.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},k.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},k.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},k.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},k.prototype.messagePreview=function(){return this.sBase+"mailbox/message-preview"},k.prototype.settings=function(a){var b=this.sBase+"settings";return Cb.isUnd(a)||""===a||(b+="/"+a),b},k.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},k.prototype.mailBox=function(a,b,c){b=Cb.isNormal(b)?Cb.pInt(b):1,c=Cb.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},k.prototype.phpInfo=function(){return this.sServer+"Info"},k.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},k.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},k.prototype.exportContactsVcf=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsVcf/"},k.prototype.exportContactsCsv=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsCsv/"},k.prototype.emptyContactPic=function(){return"rainloop/v/"+this.sVersion+"/static/css/images/empty-contact.png"},k.prototype.sound=function(a){return"rainloop/v/"+this.sVersion+"/static/sounds/"+a},k.prototype.themePreviewLink=function(a){var b="rainloop/v/"+this.sVersion+"/";return"@custom"===a.substr(-7)&&(a=Cb.trim(a.substring(0,a.length-7)),b=""),b+"themes/"+encodeURI(a)+"/images/preview.png"},k.prototype.notificationMailIcon=function(){return"rainloop/v/"+this.sVersion+"/static/css/images/icom-message-notification.png"},k.prototype.openPgpJs=function(){return"rainloop/v/"+this.sVersion+"/static/js/openpgp.min.js"},k.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},k.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},k.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},Db.oViewModelsHooks={},Db.oSimpleHooks={},Db.regViewModelHook=function(a,b){b&&(b.__hookName=a)},Db.addHook=function(a,b){Cb.isFunc(b)&&(Cb.isArray(Db.oSimpleHooks[a])||(Db.oSimpleHooks[a]=[]),Db.oSimpleHooks[a].push(b))},Db.runHook=function(a,b){Cb.isArray(Db.oSimpleHooks[a])&&(b=b||[],h.each(Db.oSimpleHooks[a],function(a){a.apply(null,b)}))},Db.mainSettingsGet=function(a){return Pb?Pb.settingsGet(a):null},Db.remoteRequest=function(a,b,c,d,e,f){Pb&&Pb.remote().defaultRequest(a,b,c,d,e,f)},Db.settingsGet=function(a,b){var c=Db.mainSettingsGet("Plugins");return c=c&&Cb.isUnd(c[a])?null:c[a],c?Cb.isUnd(c[b])?null:c[b]:null},l.prototype.blurTrigger=function(){if(this.fOnBlur){var b=this;a.clearTimeout(b.iBlurTimer),b.iBlurTimer=a.setTimeout(function(){b.fOnBlur()},200)}},l.prototype.focusTrigger=function(){this.fOnBlur&&a.clearTimeout(this.iBlurTimer)},l.prototype.isHtml=function(){return this.editor?"wysiwyg"===this.editor.mode:!1},l.prototype.checkDirty=function(){return this.editor?this.editor.checkDirty():!1},l.prototype.resetDirty=function(){this.editor&&this.editor.resetDirty()},l.prototype.getData=function(){return this.editor?"plain"===this.editor.mode&&this.editor.plugins.plain&&this.editor.__plain?this.editor.__plain.getRawData():this.editor.getData():""},l.prototype.modeToggle=function(a){this.editor&&(a?"plain"===this.editor.mode&&this.editor.setMode("wysiwyg"):"wysiwyg"===this.editor.mode&&this.editor.setMode("plain"))},l.prototype.setHtml=function(a,b){this.editor&&(this.modeToggle(!0),this.editor.setData(a),b&&this.focus())},l.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()}},l.prototype.init=function(){if(this.$element&&this.$element[0]){var b=this,c=Fb.oHtmlEditorDefaultConfig,d=Pb.settingsGet("Language"),e=!!Pb.settingsGet("AllowHtmlEditorSourceButton");e&&c.toolbarGroups&&!c.toolbarGroups.__SourceInited&&(c.toolbarGroups.__SourceInited=!0,c.toolbarGroups.push({name:"document",groups:["mode","document","doctools"]})),c.language=Fb.oHtmlEditorLangsMap[d]||"en",b.editor=a.CKEDITOR.appendTo(b.$element[0],c),b.editor.on("key",function(a){return a&&a.data&&9===a.data.keyCode?!1:void 0}),b.editor.on("blur",function(){b.blurTrigger()}),b.editor.on("mode",function(){b.blurTrigger(),b.fOnModeChange&&b.fOnModeChange("plain"!==b.editor.mode)}),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.__resizable=!0,b.resize()})}},l.prototype.focus=function(){this.editor&&this.editor.focus()},l.prototype.blur=function(){this.editor&&this.editor.focusManager.blur(!0)},l.prototype.resize=function(){this.editor&&this.__resizable&&this.editor.resize(this.$element.width(),this.$element.innerHeight())},l.prototype.clear=function(a){this.setHtml("",a)},m.prototype.itemSelected=function(a){this.isListChecked()?a||(this.oCallbacks.onItemSelect||this.emptyFunction)(a||null):a&&(this.oCallbacks.onItemSelect||this.emptyFunction)(a)},m.prototype.goDown=function(a){this.newSelectPosition(Ab.EventKeyCode.Down,!1,a)},m.prototype.goUp=function(a){this.newSelectPosition(Ab.EventKeyCode.Up,!1,a)},m.prototype.init=function(a,d,e){if(this.oContentVisible=a,this.oContentScrollable=d,e=e||"all",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.focusedItem(b),b.checked(!b.checked())))}),j("enter",e,function(){return f.focusedItem()&&!f.focusedItem().selected()?(f.actionClick(f.focusedItem()),!1):!0}),j("ctrl+up, command+up, ctrl+down, command+down",e,function(){return!1}),j("up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space",e,function(a,b){if(a&&b&&b.shortcut){var c=0;switch(b.shortcut){case"up":case"shift+up":c=Ab.EventKeyCode.Up;break;case"down":case"shift+down":c=Ab.EventKeyCode.Down;break;case"insert":c=Ab.EventKeyCode.Insert;break;case"space":c=Ab.EventKeyCode.Space;break;case"home":c=Ab.EventKeyCode.Home;break;case"end":c=Ab.EventKeyCode.End;break;case"pageup":c=Ab.EventKeyCode.PageUp;break;case"pagedown":c=Ab.EventKeyCode.PageDown}if(c>0)return f.newSelectPosition(c,j.shift),!1}})}},m.prototype.autoSelect=function(a){this.bAutoSelect=!!a},m.prototype.getItemUid=function(a){var b="",c=this.oCallbacks.onItemGetUid||null;return c&&a&&(b=c(a)),b.toString()},m.prototype.newSelectPosition=function(a,b,c){var d=0,e=10,f=!1,g=!1,i=null,j=this.list(),k=j?j.length:0,l=this.focusedItem();if(k>0)if(l){if(l)if(Ab.EventKeyCode.Down===a||Ab.EventKeyCode.Up===a||Ab.EventKeyCode.Insert===a||Ab.EventKeyCode.Space===a)h.each(j,function(b){if(!g)switch(a){case Ab.EventKeyCode.Up:l===b?g=!0:i=b;break;case Ab.EventKeyCode.Down:case Ab.EventKeyCode.Insert:f?(i=b,g=!0):l===b&&(f=!0)}});else if(Ab.EventKeyCode.Home===a||Ab.EventKeyCode.End===a)Ab.EventKeyCode.Home===a?i=j[0]:Ab.EventKeyCode.End===a&&(i=j[j.length-1]);else if(Ab.EventKeyCode.PageDown===a){for(;k>d;d++)if(l===j[d]){d+=e,d=d>k-1?k-1:d,i=j[d];break}}else if(Ab.EventKeyCode.PageUp===a)for(d=k;d>=0;d--)if(l===j[d]){d-=e,d=0>d?0:d,i=j[d];break}}else Ab.EventKeyCode.Down===a||Ab.EventKeyCode.Insert===a||Ab.EventKeyCode.Space===a||Ab.EventKeyCode.Home===a||Ab.EventKeyCode.PageUp===a?i=j[0]:(Ab.EventKeyCode.Up===a||Ab.EventKeyCode.End===a||Ab.EventKeyCode.PageDown===a)&&(i=j[j.length-1]);i?(this.focusedItem(i),l&&(b?(Ab.EventKeyCode.Up===a||Ab.EventKeyCode.Down===a)&&l.checked(!l.checked()):(Ab.EventKeyCode.Insert===a||Ab.EventKeyCode.Space===a)&&l.checked(!l.checked())),!this.bAutoSelect&&!c||this.isListChecked()||Ab.EventKeyCode.Space===a||this.selectedItem(i),this.scrollToFocused()):l&&(!b||Ab.EventKeyCode.Up!==a&&Ab.EventKeyCode.Down!==a?(Ab.EventKeyCode.Insert===a||Ab.EventKeyCode.Space===a)&&l.checked(!l.checked()):l.checked(!l.checked()),this.focusedItem(l))},m.prototype.scrollToFocused=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var a=20,c=b(this.sItemFocusedSelector,this.oContentScrollable),d=c.position(),e=this.oContentVisible.height(),f=c.outerHeight();return d&&(d.top<0||d.top+f>e)?(this.oContentScrollable.scrollTop(d.top<0?this.oContentScrollable.scrollTop()+d.top-a:this.oContentScrollable.scrollTop()+d.top-e+f+a),!0):!1},m.prototype.scrollToTop=function(a){return this.oContentVisible&&this.oContentScrollable?(a?this.oContentScrollable.scrollTop(0):this.oContentScrollable.stop().animate({scrollTop:0},200),!0):!1},m.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},m.prototype.actionClick=function(a,b){if(a){var c=!0,d=this.getItemUid(a);b&&(!b.shiftKey||b.ctrlKey||b.altKey?!b.ctrlKey||b.shiftKey||b.altKey||(c=!1,this.focusedItem(a),this.selectedItem()&&a!==this.selectedItem()&&this.selectedItem().checked(!0),a.checked(!a.checked())):(c=!1,""===this.sLastUid&&(this.sLastUid=d),a.checked(!a.checked()),this.eventClickFunction(a,b),this.focusedItem(a))),c&&(this.focusedItem(a),this.selectedItem(a))}},m.prototype.on=function(a,b){this.oCallbacks[a]=b},n.supported=function(){return!0},n.prototype.set=function(a,c){var d=b.cookie(zb.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(zb.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e +},n.prototype.get=function(a){var c=b.cookie(zb.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!Cb.isUnd(d[a])?d[a]:null}catch(e){}return d},o.supported=function(){return!!a.localStorage},o.prototype.set=function(b,c){var d=a.localStorage[zb.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[zb.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},o.prototype.get=function(b){var c=a.localStorage[zb.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!Cb.isUnd(d[b])?d[b]:null}catch(e){}return d},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.storeAndSetKeyScope=function(){this.sCurrentKeyScope=Pb.data().keyScope(),Pb.data().keyScope(this.sDefaultKeyScope)},r.prototype.restoreKeyScope=function(){Pb.data().keyScope(this.sCurrentKeyScope)},r.prototype.registerPopupKeyDown=function(){var a=this;Mb.on("keydown",function(b){if(b&&a.modalVisibility&&a.modalVisibility()){if(!this.bDisabeCloseOnEsc&&Ab.EventKeyCode.Esc===b.keyCode)return Cb.delegateRun(a,"cancelCommand"),!1;if(Ab.EventKeyCode.Backspace===b.keyCode&&!Cb.inFocus())return!1}return!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;Cb.isNonEmptyArray(a)&&(c=h.bind(this.onRoute||Cb.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){Cb.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 Cb.isNormal(a)&&(this.oBoot=a),this},t.prototype.screen=function(a){return""===a||Cb.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()),i=null;a.__builded=!0,a.__vm=e,e.data=Pb.data(),e.viewModelName=a.__name,g&&1===g.length?(i=b(" ").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),i.appendTo(g),e.viewModelDom=i,a.__dom=i,"Popups"===f&&(e.cancelCommand=e.closeCommand=Cb.createCommand(e,function(){Ib.hideScreenPopup(a)}),e.modalVisibility.subscribe(function(a){var b=this;a?(this.viewModelDom.show(),this.storeAndSetKeyScope(),Pb.popupVisibilityNames.push(this.viewModelName),e.viewModelDom.css("z-index",3e3+Pb.popupVisibilityNames().length+10),Cb.delegateRun(this,"onFocus",[],500)):(Cb.delegateRun(this,"onHide"),this.restoreKeyScope(),Pb.popupVisibilityNames.remove(this.viewModelName),e.viewModelDom.css("z-index",2e3),h.delay(function(){b.viewModelDom.hide()},300))},e)),Db.runHook("view-model-pre-build",[a.__name,e,i]),c.applyBindings(e,i[0]),Cb.delegateRun(e,"onBuild",[i]),e&&"Popups"===f&&e.registerPopupKeyDown(),Db.runHook("view-model-post-build",[a.__name,e,i])):Cb.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),Db.runHook("view-model-on-hide",[a.__name,a.__vm]))},t.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__vm.modalVisibility(!0),Cb.delegateRun(a.__vm,"onShow",b||[]),Db.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},t.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===Cb.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,Cb.isNonEmptyArray(d.viewModels())&&h.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),Cb.delegateRun(d,"onBuild")),h.defer(function(){c.oCurrentScreen&&(Cb.delegateRun(c.oCurrentScreen,"onHide"),Cb.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),Cb.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(Cb.delegateRun(c.oCurrentScreen,"onShow"),Db.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),Cb.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),Cb.delegateRun(a.__vm,"onShow"),Cb.delegateRun(a.__vm,"onFocus",[],200),Db.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(),Db.runHook("screen-pre-start",[a.screenName(),a]),Cb.delegateRun(a,"onStart"),Db.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(){Lb.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=Cb.isUnd(c)?!1:!!c,(Cb.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},Ib=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=Ab.EmailType.Facebook),null===this.privateType&&(this.privateType=Ab.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=Cb.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=Cb.trim(a.Name),this.email=Cb.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},u.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=Cb.isUnd(b)?!1:!!b,c=Cb.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+Cb.encodeHtml(this.name)+"":c?Cb.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=Cb.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+Cb.encodeHtml(d)+""+Cb.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=Cb.encodeHtml(d))):b&&(d=''+Cb.encodeHtml(this.email)+""))),d},u.prototype.mailsoParse=function(a){if(a=Cb.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=Pb.data(),e.viewModelDom=i,e.__rlSettingsData=f.__rlSettingsData,f.__dom=i,f.__builded=!0,f.__vm=e,c.applyBindings(e,i[0]),Cb.delegateRun(e,"onBuild",[i])):Cb.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&h.defer(function(){d.oCurrentSubScreen&&(Cb.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),Cb.delegateRun(d.oCurrentSubScreen,"onShow"),Cb.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)),Cb.windowResize()})):Ib.setHash(Pb.link().settings(),!1,!0)},tb.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(Cb.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},tb.prototype.onBuild=function(){h.each(Gb.settings,function(a){a&&a.__rlSettingsData&&!h.find(Gb["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(Gb["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},tb.prototype.routes=function(){var a=h.find(Gb.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=Cb.isUnd(c.subname)?b:Cb.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},h.extend(ub.prototype,s.prototype),ub.prototype.onShow=function(){Pb.setTitle("")},h.extend(vb.prototype,s.prototype),vb.prototype.oLastRoute={},vb.prototype.setNewTitle=function(){var a=Pb.data().accountEmail(),b=Pb.data().foldersInboxUnreadCount();Pb.setTitle((""===a?"":(b>0?"("+b+") ":" ")+a+" - ")+Cb.i18n("TITLES/MAILBOX"))},vb.prototype.onShow=function(){this.setNewTitle(),Pb.data().keyScope(Ab.KeyState.MessageList)},vb.prototype.onRoute=function(a,b,c,d){if(Cb.isUnd(d)?1:!d){var e=Pb.data(),f=Pb.cache().getFolderFullNameRaw(a),g=Pb.cache().getFolderFromCacheList(f);g&&(e.currentFolder(g).messageListPage(b).messageListSearch(c),Ab.Layout.NoPreview===e.layout()&&e.message()&&(e.message(null),e.messageFullScreenMode(!1)),Pb.reloadMessageList())}else Ab.Layout.NoPreview!==Pb.data().layout()||Pb.data().message()||Pb.historyBack()},vb.prototype.onStart=function(){var a=Pb.data(),b=function(){Cb.windowResize()};(Pb.settingsGet("AllowAdditionalAccounts")||Pb.settingsGet("AllowIdentities"))&&Pb.accountsAndIdentities(),h.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&Pb.folderInformation("INBOX")},1e3),h.delay(function(){Pb.quota()},5e3),h.delay(function(){Pb.remote().appDelayStart(Cb.emptyFunction)},35e3),Lb.toggleClass("rl-no-preview-pane",Ab.Layout.NoPreview===a.layout()),a.folderList.subscribe(b),a.messageList.subscribe(b),a.message.subscribe(b),a.layout.subscribe(function(a){Lb.toggleClass("rl-no-preview-pane",Ab.Layout.NoPreview===a)}),a.foldersInboxUnreadCount.subscribe(function(){this.setNewTitle()},this)},vb.prototype.routes=function(){var a=function(){return["Inbox",1,"",!0]},b=function(a,b){return b[0]=Cb.pString(b[0]),b[1]=Cb.pInt(b[1]),b[1]=0>=b[1]?1:b[1],b[2]=Cb.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]=Cb.pString(b[0]),b[1]=Cb.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(wb.prototype,tb.prototype),wb.prototype.onShow=function(){Pb.setTitle(this.sSettingsTitle),Pb.data().keyScope(Ab.KeyState.Settings)},h.extend(xb.prototype,q.prototype),xb.prototype.oSettings=null,xb.prototype.oPlugins=null,xb.prototype.oLocal=null,xb.prototype.oLink=null,xb.prototype.oSubs={},xb.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):(Fb.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},xb.prototype.link=function(){return null===this.oLink&&(this.oLink=new k),this.oLink},xb.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new p),this.oLocal},xb.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=Cb.isNormal(Jb)?Jb:{}),Cb.isUnd(this.oSettings[a])?null:this.oSettings[a]},xb.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=Cb.isNormal(Jb)?Jb:{}),this.oSettings[a]=b},xb.prototype.setTitle=function(b){b=(Cb.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=Cb.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=Cb.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=Cb.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},y.prototype.isImage=function(){return-1 e;e++)d.push(a[e].toLine(b,c));return d.join(", ")},A.initEmailsFromJson=function(a){var b=0,c=0,d=null,e=[];if(Cb.isNonEmptyArray(a))for(b=0,c=a.length;c>b;b++)d=u.newInstanceFromJson(a[b]),d&&e.push(d);return e},A.replyHelper=function(a,b,c){if(a&&0 d;d++)Cb.isUnd(b[a[d].email])&&(b[a[d].email]=!0,c.push(a[d]))},A.prototype.clear=function(){this.folderFullNameRaw="",this.uid="",this.hash="",this.requestHash="",this.subject(""),this.size(0),this.dateTimeStampInUTC(0),this.priority(Ab.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.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.None),this.pgpSignedVerifyUser(""),this.priority(Ab.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)},A.prototype.computeSenderEmail=function(){var a=Pb.data().sentFolder(),b=Pb.data().draftFolder();this.senderEmailsString(this.folderFullNameRaw===a||this.folderFullNameRaw===b?this.toEmailsString():this.fromEmailString())},A.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(Cb.pInt(a.Size)),this.from=A.initEmailsFromJson(a.From),this.to=A.initEmailsFromJson(a.To),this.cc=A.initEmailsFromJson(a.Cc),this.bcc=A.initEmailsFromJson(a.Bcc),this.replyTo=A.initEmailsFromJson(a.ReplyTo),this.subject(a.Subject),this.dateTimeStampInUTC(Cb.pInt(a.DateTimeStampInUTC)),this.hasAttachments(!!a.HasAttachments),this.attachmentsMainType(a.AttachmentsMainType),this.fromEmailString(A.emailsToLine(this.from,!0)),this.toEmailsString(A.emailsToLine(this.to,!0)),this.parentUid(Cb.pInt(a.ParentThread)),this.threads(Cb.isArray(a.Threads)?a.Threads:[]),this.threadsLen(Cb.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0),b},A.prototype.initUpdateByMessageJson=function(a){var b=!1,c=Ab.MessagePriority.Normal;return a&&"Object/Message"===a["@Object"]&&(c=Cb.pInt(a.Priority),this.priority(-1 b;b++)d=y.newInstanceFromJson(a["@Collection"][b]),d&&(""!==d.cidWithOutTags&&0 +$/,""),b=h.find(c,function(b){return a===b.cidWithOutTags})),b||null},A.prototype.findAttachmentByContentLocation=function(a){var b=null,c=this.attachments();return Cb.isNonEmptyArray(c)&&(b=h.find(c,function(b){return a===b.contentLocation})),b||null},A.prototype.messageId=function(){return this.sMessageId},A.prototype.inReplyTo=function(){return this.sInReplyTo},A.prototype.references=function(){return this.sReferences},A.prototype.fromAsSingleEmail=function(){return Cb.isArray(this.from)&&this.from[0]?this.from[0].email:""},A.prototype.viewLink=function(){return Pb.link().messageViewLink(this.requestHash)},A.prototype.downloadLink=function(){return Pb.link().messageDownloadLink(this.requestHash)},A.prototype.replyEmails=function(a){var b=[],c=Cb.isUnd(a)?{}:a;return A.replyHelper(this.replyTo,c,b),0===b.length&&A.replyHelper(this.from,c,b),b},A.prototype.replyAllEmails=function(a){var b=[],c=[],d=Cb.isUnd(a)?{}:a;return A.replyHelper(this.replyTo,d,b),0===b.length&&A.replyHelper(this.from,d,b),A.replyHelper(this.to,d,b),A.replyHelper(this.cc,d,c),[b,c]},A.prototype.textBodyToString=function(){return this.body?this.body.html():""},A.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))})},A.prototype.printMessage=function(){this.viewPopupMessage(!0)},A.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid},A.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(Ab.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},A.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=Cb.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=Cb.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]}),Mb.resize()),Cb.windowResize(500))},A.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){this.body.data("rl-init-internal-images",!0),a=Cb.isUnd(a)?!1:a;var c=this;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=Cb.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]),Cb.windowResize(500)}},A.prototype.storeDataToDom=function(){this.body&&(this.body.data("rl-is-rtl",!!this.isRtl()),this.body.data("rl-is-html",!!this.isHtml()),this.body.data("rl-has-images",!!this.hasImages()),this.body.data("rl-plain-raw",this.plainRaw),Pb.data().allowOpenPGP()&&(this.body.data("rl-plain-pgp-signed",!!this.isPgpSigned()),this.body.data("rl-plain-pgp-encrypted",!!this.isPgpEncrypted()),this.body.data("rl-pgp-verify-status",this.pgpSignedVerifyStatus()),this.body.data("rl-pgp-verify-user",this.pgpSignedVerifyUser())))},A.prototype.storePgpVerifyDataToDom=function(){this.body&&Pb.data().allowOpenPGP()&&(this.body.data("rl-pgp-verify-status",this.pgpSignedVerifyStatus()),this.body.data("rl-pgp-verify-user",this.pgpSignedVerifyUser()))},A.prototype.fetchDataToDom=function(){this.body&&(this.isRtl(!!this.body.data("rl-is-rtl")),this.isHtml(!!this.body.data("rl-is-html")),this.hasImages(!!this.body.data("rl-has-images")),this.plainRaw=Cb.pString(this.body.data("rl-plain-raw")),Pb.data().allowOpenPGP()?(this.isPgpSigned(!!this.body.data("rl-plain-pgp-signed")),this.isPgpEncrypted(!!this.body.data("rl-plain-pgp-encrypted")),this.pgpSignedVerifyStatus(this.body.data("rl-pgp-verify-status")),this.pgpSignedVerifyUser(this.body.data("rl-pgp-verify-user"))):(this.isPgpSigned(!1),this.isPgpEncrypted(!1),this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.None),this.pgpSignedVerifyUser("")))},A.prototype.verifyPgpSignedClearMessage=function(){if(this.isPgpSigned()){var c=[],d=null,e=this.from&&this.from[0]&&this.from[0].email?this.from[0].email:"",f=Pb.data().findPublicKeysByEmail(e),g=null,i=null,j="";this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.Error),this.pgpSignedVerifyUser("");try{d=a.openpgp.cleartext.readArmored(this.plainRaw),d&&d.getText&&(this.pgpSignedVerifyStatus(f.length?Ab.SignedVerifyStatus.Unverified:Ab.SignedVerifyStatus.UnknownPublicKeys),c=d.verify(f),c&&0 ').text(j)).html(),Qb.empty(),this.replacePlaneTextBody(j)))))}catch(k){}this.storePgpVerifyDataToDom()}},A.prototype.decryptPgpEncryptedMessage=function(c){if(this.isPgpEncrypted()){var d=[],e=null,f=null,g=this.from&&this.from[0]&&this.from[0].email?this.from[0].email:"",i=Pb.data().findPublicKeysByEmail(g),j=Pb.data().findSelfPrivateKey(c),k=null,l=null,m="";this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.Error),this.pgpSignedVerifyUser(""),j||this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.UnknownPrivateKey);try{e=a.openpgp.message.readArmored(this.plainRaw),e&&j&&e.decrypt&&(this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.Unverified),f=e.decrypt(j),f&&(d=f.verify(i),d&&0 ').text(m)).html(),Qb.empty(),this.replacePlaneTextBody(m)))}catch(n){}this.storePgpVerifyDataToDom()}},A.prototype.replacePlaneTextBody=function(a){this.body&&this.body.html(a).addClass("b-text-part plain")},A.prototype.flagHash=function(){return[this.deleted(),this.unseen(),this.flagged(),this.answered(),this.forwarded(),this.isReadReceipt()].join("")},B.newInstanceFromJson=function(a){var b=new B;return b.initByJson(a)?b.initComputed():null},B.prototype.initComputed=function(){return this.hasSubScribedSubfolders=c.computed(function(){return!!h.find(this.subFolders(),function(a){return a.subScribed()&&!a.isSystemFolder()})},this),this.canBeEdited=c.computed(function(){return Ab.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 Ab.FolderType.User!==this.type()},this),this.hidden=c.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return a&&!b||!this.selectable&&!b},this),this.selectableForFolderList=c.computed(function(){return!this.isSystemFolder()&&this.selectable},this),this.messageCountAll=c.computed({read:this.privateMessageCountAll,write:function(a){Cb.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this}),this.messageCountUnread=c.computed({read:this.privateMessageCountUnread,write:function(a){Cb.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(Ab.FolderType.Inbox===c&&Pb.data().foldersInboxUnreadCount(b),a>0){if(Ab.FolderType.Draft===c)return""+a;if(b>0&&Ab.FolderType.Trash!==c&&Ab.FolderType.Archive!==c&&Ab.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(){Cb.timeOutAction("folder-list-folder-visibility-change",function(){Mb.trigger("folder-list-folder-visibility-change")},100)}),this.localName=c.computed(function(){Fb.langChangeTrigger(); +var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case Ab.FolderType.Inbox:b=Cb.i18n("FOLDER_LIST/INBOX_NAME");break;case Ab.FolderType.SentItems:b=Cb.i18n("FOLDER_LIST/SENT_NAME");break;case Ab.FolderType.Draft:b=Cb.i18n("FOLDER_LIST/DRAFTS_NAME");break;case Ab.FolderType.Spam:b=Cb.i18n("FOLDER_LIST/SPAM_NAME");break;case Ab.FolderType.Trash:b=Cb.i18n("FOLDER_LIST/TRASH_NAME");break;case Ab.FolderType.Archive:b=Cb.i18n("FOLDER_LIST/ARCHIVE_NAME")}return b},this),this.manageFolderSystemName=c.computed(function(){Fb.langChangeTrigger();var a="",b=this.type(),c=this.name();if(this.isSystemFolder())switch(b){case Ab.FolderType.Inbox:a="("+Cb.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case Ab.FolderType.SentItems:a="("+Cb.i18n("FOLDER_LIST/SENT_NAME")+")";break;case Ab.FolderType.Draft:a="("+Cb.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case Ab.FolderType.Spam:a="("+Cb.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case Ab.FolderType.Trash:a="("+Cb.i18n("FOLDER_LIST/TRASH_NAME")+")";break;case Ab.FolderType.Archive:a="("+Cb.i18n("FOLDER_LIST/ARCHIVE_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 "},D.prototype.formattedNameForCompose=function(){var a=this.name();return""===a?this.email():a+" ("+this.email()+")"},D.prototype.formattedNameForEmail=function(){var a=this.name();return""===a?this.email():'"'+Cb.quoteName(a)+'" <'+this.email()+">"},E.prototype.index=0,E.prototype.id="",E.prototype.guid="",E.prototype.user="",E.prototype.email="",E.prototype.armor="",E.prototype.isPrivate=!1,Cb.extendAsViewModel("PopupsFolderClearViewModel",F),F.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},F.prototype.onShow=function(a){this.clearPopup(),a&&this.selectedFolder(a)},Cb.extendAsViewModel("PopupsFolderCreateViewModel",G),G.prototype.sNoParentText="",G.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(Cb.trim(a))},G.prototype.clearPopup=function(){this.folderName(""),this.selectedParentValue(""),this.folderName.focused(!1)},G.prototype.onShow=function(){this.clearPopup()},G.prototype.onFocus=function(){this.folderName.focused(!0)},Cb.extendAsViewModel("PopupsFolderSystemViewModel",H),H.prototype.sChooseOnText="",H.prototype.sUnuseText="",H.prototype.onShow=function(a){var b="";switch(a=Cb.isUnd(a)?Ab.SetSystemFoldersNotification.None:a){case Ab.SetSystemFoldersNotification.Sent:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case Ab.SetSystemFoldersNotification.Draft:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case Ab.SetSystemFoldersNotification.Spam:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case Ab.SetSystemFoldersNotification.Trash:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH");break;case Ab.SetSystemFoldersNotification.Archive:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE")}this.notification(b)},Cb.extendAsViewModel("PopupsComposeViewModel",I),I.prototype.openOpenPgpPopup=function(){if(this.allowOpenPGP()&&this.oEditor&&!this.oEditor.isHtml()){var a=this;Ib.showScreenPopup(P,[function(b){a.editor(function(a){a.setPlain(b)})},this.oEditor.getData(),this.currentIdentityResultEmail(),this.to(),this.cc(),this.bcc()])}},I.prototype.reloadDraftFolder=function(){var a=Pb.data().draftFolder();""!==a&&(Pb.cache().setFolderHash(a,""),Pb.data().currentFolderFullNameRaw()===a?Pb.reloadMessageList(!0):Pb.folderInformation(a))},I.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[Pb.data().accountEmail()]=Pb.data().accountEmail(),b)switch(a){case Ab.ComposeType.Empty:d=Pb.data().accountEmail();break;case Ab.ComposeType.Reply:case Ab.ComposeType.ReplyAll:case Ab.ComposeType.Forward:case Ab.ComposeType.ForwardAsAttachment:h.find(h.union(b.to,b.cc,b.bcc),e);break;case Ab.ComposeType.Draft:h.find(h.union(b.from,b.replyTo),e)}else d=Pb.data().accountEmail();return d},I.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)},I.prototype.formattedFrom=function(a){var b=Pb.data().displayName(),c=Pb.data().accountEmail();return""===b?c:(Cb.isUnd(a)?1:!a)?b+" ("+c+")":'"'+Cb.quoteName(b)+'" <'+c+">"},I.prototype.sendMessageResponse=function(b,c){var d=!1,e="";this.sending(!1),Ab.StorageResultType.Success===b&&c&&c.Result&&(d=!0,this.modalVisibility()&&Cb.delegateRun(this,"closeCommand")),this.modalVisibility()&&!d&&(c&&Ab.Notification.CantSaveMessage===c.ErrorCode?(this.sendSuccessButSaveError(!0),a.alert(Cb.trim(Cb.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(e=Cb.getNotification(c&&c.ErrorCode?c.ErrorCode:Ab.Notification.CantSendMessage,c&&c.ErrorMessage?c.ErrorMessage:""),this.sendError(!0),a.alert(e||Cb.getNotification(Ab.Notification.CantSendMessage)))),this.reloadDraftFolder()},I.prototype.saveMessageResponse=function(b,c){var d=!1,e=null;this.saving(!1),Ab.StorageResultType.Success===b&&c&&c.Result&&c.Result.NewFolder&&c.Result.NewUid&&(this.bFromDraft&&(e=Pb.data().message(),e&&this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid&&Pb.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&&Cb.isNormal(c)&&(v=Cb.isArray(c)&&1===c.length?c[0]:Cb.isArray(c)?null:c),null!==q&&(p[q]=!0,this.currentIdentityID(this.findIdentityIdByMessage(w,v))),this.reset(),Cb.isNonEmptyArray(d)&&this.to(x(d)),""!==w&&v){switch(j=v.fullFormatDateValue(),k=v.subject(),u=v.aDraftInfo,l=b(v.body).clone(),Cb.removeBlockquoteSwitcher(l),m=l.html(),w){case Ab.ComposeType.Empty:break;case Ab.ComposeType.Reply:this.to(x(v.replyEmails(p))),this.subject(Cb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Cb.trim(this.sInReplyTo+" "+v.sReferences);break;case Ab.ComposeType.ReplyAll:o=v.replyAllEmails(p),this.to(x(o[0])),this.cc(x(o[1])),this.subject(Cb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Cb.trim(this.sInReplyTo+" "+v.references());break;case Ab.ComposeType.Forward:this.subject(Cb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Cb.trim(this.sInReplyTo+" "+v.sReferences);break;case Ab.ComposeType.ForwardAsAttachment:this.subject(Cb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Cb.trim(this.sInReplyTo+" "+v.sReferences);break;case Ab.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=Cb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences;break;case Ab.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=Cb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences}switch(w){case Ab.ComposeType.Reply:case Ab.ComposeType.ReplyAll:f=v.fromToLine(!1,!0),n=Cb.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:j,EMAIL:f}),m="
"+n+":";break;case Ab.ComposeType.Forward:f=v.fromToLine(!1,!0),g=v.toToLine(!1,!0),i=v.ccToLine(!1,!0),m=""+m+"
"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+f+"
"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+g+(0"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+i:"")+"
"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+Cb.encodeHtml(j)+"
"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+Cb.encodeHtml(k)+"
"+m;break;case Ab.ComposeType.ForwardAsAttachment:m=""}s&&""!==r&&Ab.ComposeType.EditAsNew!==w&&Ab.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 Ab.ComposeType.Empty===w?(m=this.convertSignature(r),this.editor(function(a){a.setHtml(m,!1),Ab.EditorDefaultType.Html!==Pb.data().editorDefaultType()&&a.modeToggle(!1)})):Cb.isNonEmptyArray(c)&&h.each(c,function(a){e.addMessageAsAttachment(a)});t=this.getAttachmentsDownloadsForUpload(),Cb.isNonEmptyArray(t)&&Pb.remote().messageUploadAttachments(function(a,b){if(Ab.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()},I.prototype.onFocus=function(){""===this.to()?this.to.focusTrigger(!this.to.focusTrigger()):this.oEditor&&this.oEditor.focus(),this.triggerForResize()},I.prototype.editorResize=function(){this.oEditor&&this.oEditor.resize()},I.prototype.tryToClosePopup=function(){var a=this;Ib.showScreenPopup(T,[Cb.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&Cb.delegateRun(a,"closeCommand")}])},I.prototype.onBuild=function(){this.initUploader();var a=this,c=null;j("ctrl+q, command+q",Ab.KeyState.Compose,function(){return a.identitiesDropdownTrigger(!0),!1}),j("ctrl+s, command+s",Ab.KeyState.Compose,function(){return a.saveCommand(),!1}),j("ctrl+enter, command+enter",Ab.KeyState.Compose,function(){return a.sendCommand(),!1}),j("esc",Ab.KeyState.Compose,function(){return a.tryToClosePopup(),!1}),Mb.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",Pb.settingsGet("DropboxApiKey")),document.body.appendChild(c))},I.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},I.prototype.initUploader=function(){if(this.composeUploaderButton()){var a={},b=Cb.pInt(Pb.settingsGet("AttachmentLimit")),c=new g({action:Pb.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;Cb.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=Cb.isUnd(d.FileName)?"":d.FileName.toString(),g=Cb.isNormal(d.Size)?Cb.pInt(d.Size):null,h=new z(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(Cb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(b){var c=null;Cb.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=Cb.getUploadErrorDescByCode(f):g||(e=Cb.i18n("UPLOAD/ERROR_UNKNOWN")),h&&(""!==e&&00&&d>0&&f>d?(e.uploading(!1),e.error(Cb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(Pb.remote().composeUploadExternals(function(a,b){var c=!1;e.uploading(!1),Ab.StorageResultType.Success===a&&b&&b.Result&&b.Result[e.id]&&(c=!0,e.tempName(b.Result[e.id])),c||e.error(Cb.getUploadErrorDescByCode(Ab.UploadErrorCode.FileNoUploaded))},[a.link]),!0)},I.prototype.prepearMessageAttachments=function(a,b){if(a){var c=this,d=Cb.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(Ab.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f>e;e++){switch(h=d[e],i=!1,b){case Ab.ComposeType.Reply:case Ab.ComposeType.ReplyAll:i=h.isLinked;break;case Ab.ComposeType.Forward:case Ab.ComposeType.Draft:case Ab.ComposeType.EditAsNew:i=!0}i=!0,i&&(g=new z(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))}}},I.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})},I.prototype.setMessageAttachmentFailedDowbloadText=function(){h.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(Cb.getUploadErrorDescByCode(Ab.UploadErrorCode.FileNoUploaded))},this)},I.prototype.isEmptyForm=function(a){a=Cb.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())},I.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)},I.prototype.getAttachmentsDownloadsForUpload=function(){return h.map(h.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})},I.prototype.triggerForResize=function(){this.resizer(!this.resizer()),this.editorResizeThrottle()},Cb.extendAsViewModel("PopupsContactsViewModel",J),J.prototype.getPropertyPlceholder=function(a){var b="";switch(a){case Ab.ContactPropertyType.LastName:b="CONTACTS/PLACEHOLDER_ENTER_LAST_NAME";break;case Ab.ContactPropertyType.FirstName:b="CONTACTS/PLACEHOLDER_ENTER_FIRST_NAME";break;case Ab.ContactPropertyType.Nick:b="CONTACTS/PLACEHOLDER_ENTER_NICK_NAME"}return b},J.prototype.addNewProperty=function(a,b){this.viewProperties.push(new w(a,b||"","",!0,this.getPropertyPlceholder(a)))},J.prototype.addNewOrFocusProperty=function(a,b){var c=h.find(this.viewProperties(),function(b){return a===b.type()});c?c.focused(!0):this.addNewProperty(a,b)},J.prototype.addNewTag=function(){this.viewTags.visibility(!0),this.viewTags.focusTrigger(!0)},J.prototype.addNewEmail=function(){this.addNewProperty(Ab.ContactPropertyType.Email,"Home")},J.prototype.addNewPhone=function(){this.addNewProperty(Ab.ContactPropertyType.Phone,"Mobile")},J.prototype.addNewWeb=function(){this.addNewProperty(Ab.ContactPropertyType.Web)},J.prototype.addNewNickname=function(){this.addNewOrFocusProperty(Ab.ContactPropertyType.Nick)},J.prototype.addNewNotes=function(){this.addNewOrFocusProperty(Ab.ContactPropertyType.Note)},J.prototype.addNewBirthday=function(){this.addNewOrFocusProperty(Ab.ContactPropertyType.Birthday)},J.prototype.exportVcf=function(){Pb.download(Pb.link().exportContactsVcf())},J.prototype.exportCsv=function(){Pb.download(Pb.link().exportContactsCsv())},J.prototype.initUploader=function(){if(this.importUploaderButton()){var b=new g({action:Pb.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(Cb.i18n("CONTACTS/ERROR_IMPORT_FILE"))},this))}},J.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))},J.prototype.deleteSelectedContacts=function(){0 0?d:0),Cb.isNonEmptyArray(c.Result.Tags)&&(f=h.map(c.Result.Tags,function(a){var b=new x;return b.parse(a)?b:null}),f=h.compact(f))),b.contactsCount(d),b.contacts(e),b.contactTags(f),b.contacts.loading(!1),b.viewClearSearch(""!==b.search())},c,zb.Defaults.ContactsPerPage,this.search())},J.prototype.onBuild=function(a){this.oContentVisible=b(".b-list-content",a),this.oContentScrollable=b(".content",this.oContentVisible),this.selector.init(this.oContentVisible,this.oContentScrollable,Ab.KeyState.ContactList);var d=this;j("delete",Ab.KeyState.ContactList,function(){return d.deleteCommand(),!1}),a.on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&(d.contactsPage(Cb.pInt(a.value)),d.reloadContactList())}),this.initUploader()},J.prototype.onShow=function(){Ib.routeOff(),this.reloadContactList(!0)},J.prototype.onHide=function(){Ib.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),h.each(this.contacts(),function(a){a.checked(!1)})},Cb.extendAsViewModel("PopupsAdvancedSearchViewModel",K),K.prototype.buildSearchStringValue=function(a){return-1 li"),e=c&&("tab"===c.shortcut||"right"===c.shortcut),f=d.index(d.filter(".active"));return!e&&f>0?f--:e&&f -1&&g.eq(e).removeClass("focused"),38===f&&e>0?e--:40===f&&e 1?" ("+(100>a?a:"99+")+")":""},$.prototype.cancelSearch=function(){this.mainMessageListSearch(""),this.inputMessageListSearchFocus(!1)},$.prototype.moveSelectedMessagesToFolder=function(a,b){return this.canBeMoved()&&Pb.moveMessagesToFolder(Pb.data().currentFolderFullNameRaw(),Pb.data().messageListCheckedOrSelectedUidsWithSubMails(),a,b),!1},$.prototype.dragAndDronHelper=function(a){a&&a.checked(!0);var b=Cb.draggeblePlace(),c=Pb.data().messageListCheckedOrSelectedUidsWithSubMails();return b.data("rl-folder",Pb.data().currentFolderFullNameRaw()),b.data("rl-uids",c),b.find(".text").text(""+c.length),h.defer(function(){var a=Pb.data().messageListCheckedOrSelectedUidsWithSubMails();b.data("rl-uids",a),b.find(".text").text(""+a.length)}),b},$.prototype.onMessageResponse=function(a,b,c){var d=Pb.data();d.hideMessageBodies(),d.messageLoading(!1),Ab.StorageResultType.Success===a&&b&&b.Result?d.setMessage(b,c):Ab.StorageResultType.Unload===a?(d.message(null),d.messageError("")):Ab.StorageResultType.Abort!==a&&(d.message(null),d.messageError(Cb.getNotification(b&&b.ErrorCode?b.ErrorCode:Ab.Notification.UnknownError)))},$.prototype.populateMessageBody=function(a){a&&(Pb.remote().message(this.onMessageResponse,a.folderFullNameRaw,a.uid)?Pb.data().messageLoading(!0):Cb.log("Error: Unknown message request: "+a.folderFullNameRaw+" ~ "+a.uid+" [e-101]"))},$.prototype.setAction=function(a,b,c){var d=[],e=null,f=Pb.cache(),g=0;if(Cb.isUnd(c)&&(c=Pb.data().messageListChecked()),d=h.map(c,function(a){return a.uid}),""!==a&&0 0?100>a?a:"99+":""},_.prototype.verifyPgpSignedClearMessage=function(a){a&&a.verifyPgpSignedClearMessage()},_.prototype.decryptPgpEncryptedMessage=function(a){a&&a.decryptPgpEncryptedMessage(this.viewPgpPassword())},_.prototype.readReceipt=function(a){a&&""!==a.readReceipt()&&(Pb.remote().sendReadReceiptMessage(Cb.emptyFunction,a.folderFullNameRaw,a.uid,a.readReceipt(),Cb.i18n("READ_RECEIPT/SUBJECT",{SUBJECT:a.subject()}),Cb.i18n("READ_RECEIPT/BODY",{"READ-RECEIPT":Pb.data().accountEmail()})),a.isReadReceipt(!0),Pb.cache().storeMessageFlagsToCache(a),Pb.reloadFlagsCurrentMessageListAndMessageFromCache())},Cb.extendAsViewModel("SettingsMenuViewModel",ab),ab.prototype.link=function(a){return Pb.link().settings(a)},ab.prototype.backToMailBoxClick=function(){Ib.setHash(Pb.link().inbox())},Cb.extendAsViewModel("SettingsPaneViewModel",bb),bb.prototype.onBuild=function(){var a=this;j("esc",Ab.KeyState.Settings,function(){a.backToMailBoxClick()})},bb.prototype.onShow=function(){Pb.data().message(null)},bb.prototype.backToMailBoxClick=function(){Ib.setHash(Pb.link().inbox())},Cb.addSettingsViewModel(cb,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0),cb.prototype.toggleLayout=function(){this.layout(Ab.Layout.NoPreview===this.layout()?Ab.Layout.SidePreview:Ab.Layout.NoPreview)},cb.prototype.onBuild=function(){var a=this;h.delay(function(){var c=Pb.data(),d=Cb.settingsSaveHelperSimpleFunction(a.mppTrigger,a);c.language.subscribe(function(c){a.languageTrigger(Ab.SaveSettingsStep.Animate),b.ajax({url:Pb.link().langLink(c),dataType:"script",cache:!0}).done(function(){Cb.i18nToDoc(),a.languageTrigger(Ab.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(Ab.SaveSettingsStep.FalseResult)}).always(function(){h.delay(function(){a.languageTrigger(Ab.SaveSettingsStep.Idle)},1e3)}),Pb.remote().saveSettings(Cb.emptyFunction,{Language:c})}),c.editorDefaultType.subscribe(function(a){Pb.remote().saveSettings(Cb.emptyFunction,{EditorDefaultType:a})}),c.messagesPerPage.subscribe(function(a){Pb.remote().saveSettings(d,{MPP:a})}),c.showImages.subscribe(function(a){Pb.remote().saveSettings(Cb.emptyFunction,{ShowImages:a?"1":"0"})}),c.interfaceAnimation.subscribe(function(a){Pb.remote().saveSettings(Cb.emptyFunction,{InterfaceAnimation:a})}),c.useDesktopNotifications.subscribe(function(a){Cb.timeOutAction("SaveDesktopNotifications",function(){Pb.remote().saveSettings(Cb.emptyFunction,{DesktopNotifications:a?"1":"0"})},3e3)}),c.replySameFolder.subscribe(function(a){Cb.timeOutAction("SaveReplySameFolder",function(){Pb.remote().saveSettings(Cb.emptyFunction,{ReplySameFolder:a?"1":"0"})},3e3)}),c.useThreads.subscribe(function(a){c.messageList([]),Pb.remote().saveSettings(Cb.emptyFunction,{UseThreads:a?"1":"0"})}),c.layout.subscribe(function(a){c.messageList([]),Pb.remote().saveSettings(Cb.emptyFunction,{Layout:a})}),c.useCheckboxesInList.subscribe(function(a){Pb.remote().saveSettings(Cb.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)},cb.prototype.onShow=function(){Pb.data().desktopNotifications.valueHasMutated()},cb.prototype.selectLanguage=function(){Ib.showScreenPopup(R)},Cb.addSettingsViewModel(db,"SettingsContacts","SETTINGS_LABELS/LABEL_CONTACTS_NAME","contacts"),db.prototype.onBuild=function(){Pb.data().contactsAutosave.subscribe(function(a){Pb.remote().saveSettings(Cb.emptyFunction,{ContactsAutosave:a?"1":"0"})})},Cb.addSettingsViewModel(eb,"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts"),eb.prototype.addNewAccount=function(){Ib.showScreenPopup(L)},eb.prototype.deleteAccount=function(b){if(b&&b.deleteAccess()){this.accountForDeletion(null);var c=function(a){return b===a};b&&(this.accounts.remove(c),Pb.remote().accountDelete(function(b,c){Ab.StorageResultType.Success===b&&c&&c.Result&&c.Reload?(Ib.routeOff(),Ib.setHash(Pb.link().root(),!0),Ib.routeOff(),h.defer(function(){a.location.reload()})):Pb.accountsAndIdentities()},b.email))}},Cb.addSettingsViewModel(fb,"SettingsIdentity","SETTINGS_LABELS/LABEL_IDENTITY_NAME","identity"),fb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Pb.data().signature();this.editor=new l(a.signatureDom(),function(){Pb.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)})}},fb.prototype.onBuild=function(){var a=this;h.delay(function(){var b=Pb.data(),c=Cb.settingsSaveHelperSimpleFunction(a.displayNameTrigger,a),d=Cb.settingsSaveHelperSimpleFunction(a.replyTrigger,a),e=Cb.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){Pb.remote().saveSettings(c,{DisplayName:a})}),b.replyTo.subscribe(function(a){Pb.remote().saveSettings(d,{ReplyTo:a})}),b.signature.subscribe(function(a){Pb.remote().saveSettings(e,{Signature:a})}),b.signatureToAll.subscribe(function(a){Pb.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},Cb.addSettingsViewModel(gb,"SettingsIdentities","SETTINGS_LABELS/LABEL_IDENTITIES_NAME","identities"),gb.prototype.addNewIdentity=function(){Ib.showScreenPopup(Q)},gb.prototype.editIdentity=function(a){Ib.showScreenPopup(Q,[a])},gb.prototype.deleteIdentity=function(a){if(a&&a.deleteAccess()){this.identityForDeletion(null);var b=function(b){return a===b};a&&(this.identities.remove(b),Pb.remote().identityDelete(function(){Pb.accountsAndIdentities()},a.id))}},gb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Pb.data().signature();this.editor=new l(a.signatureDom(),function(){Pb.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)})}},gb.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=Pb.data(),c=Cb.settingsSaveHelperSimpleFunction(b.displayNameTrigger,b),d=Cb.settingsSaveHelperSimpleFunction(b.replyTrigger,b),e=Cb.settingsSaveHelperSimpleFunction(b.signatureTrigger,b);a.displayName.subscribe(function(a){Pb.remote().saveSettings(c,{DisplayName:a})}),a.replyTo.subscribe(function(a){Pb.remote().saveSettings(d,{ReplyTo:a})}),a.signature.subscribe(function(a){Pb.remote().saveSettings(e,{Signature:a})}),a.signatureToAll.subscribe(function(a){Pb.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},Cb.addSettingsViewModel(hb,"SettingsSecurity","SETTINGS_LABELS/LABEL_SECURITY_NAME","security"),hb.prototype.showSecret=function(){this.secreting(!0),Pb.remote().showTwoFactorSecret(this.onSecretResult)},hb.prototype.hideSecret=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")},hb.prototype.createTwoFactor=function(){this.processing(!0),Pb.remote().createTwoFactor(this.onResult)},hb.prototype.enableTwoFactor=function(){this.processing(!0),Pb.remote().enableTwoFactor(this.onResult,this.viewEnable())},hb.prototype.testTwoFactor=function(){Ib.showScreenPopup(S)},hb.prototype.clearTwoFactor=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl(""),this.clearing(!0),Pb.remote().clearTwoFactor(this.onResult)},hb.prototype.onShow=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")},hb.prototype.onResult=function(a,b){if(this.processing(!1),this.clearing(!1),Ab.StorageResultType.Success===a&&b&&b.Result?(this.viewUser(Cb.pString(b.Result.User)),this.viewEnable(!!b.Result.Enable),this.twoFactorStatus(!!b.Result.IsSet),this.viewSecret(Cb.pString(b.Result.Secret)),this.viewBackupCodes(Cb.pString(b.Result.BackupCodes).replace(/[\s]+/g," ")),this.viewUrl(Cb.pString(b.Result.Url))):(this.viewUser(""),this.viewEnable(!1),this.twoFactorStatus(!1),this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")),this.bFirst){this.bFirst=!1;var c=this;this.viewEnable.subscribe(function(a){this.viewEnable.subs&&Pb.remote().enableTwoFactor(function(a,b){Ab.StorageResultType.Success===a&&b&&b.Result||(c.viewEnable.subs=!1,c.viewEnable(!1),c.viewEnable.subs=!0)},a)},this)}},hb.prototype.onSecretResult=function(a,b){this.secreting(!1),Ab.StorageResultType.Success===a&&b&&b.Result?(this.viewSecret(Cb.pString(b.Result.Secret)),this.viewUrl(Cb.pString(b.Result.Url))):(this.viewSecret(""),this.viewUrl(""))},hb.prototype.onBuild=function(){this.processing(!0),Pb.remote().getTwoFactor(this.onResult)},Cb.addSettingsViewModel(ib,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social"),Cb.addSettingsViewModel(jb,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME","change-password"),jb.prototype.onHide=function(){this.changeProcess(!1),this.currentPassword(""),this.newPassword(""),this.newPassword2(""),this.errorDescription(""),this.passwordMismatch(!1),this.currentPassword.error(!1)},jb.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1),this.passwordMismatch(!1),this.errorDescription(""),this.currentPassword.error(!1),Ab.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.newPassword2(""),this.passwordUpdateSuccess(!0),this.currentPassword.error(!1)):(b&&Ab.Notification.CurrentPasswordIncorrect===b.ErrorCode&&this.currentPassword.error(!0),this.passwordUpdateError(!0),this.errorDescription(Cb.getNotification(b&&b.ErrorCode?b.ErrorCode:Ab.Notification.CouldNotSaveNewPassword)))},Cb.addSettingsViewModel(kb,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders"),kb.prototype.folderEditOnEnter=function(a){var b=a?Cb.trim(a.nameForEdit()):"";""!==b&&a.name()!==b&&(Pb.local().set(Ab.ClientSideKeyName.FoldersLashHash,""),Pb.data().foldersRenaming(!0),Pb.remote().folderRename(function(a,b){Pb.data().foldersRenaming(!1),Ab.StorageResultType.Success===a&&b&&b.Result||Pb.data().foldersListError(b&&b.ErrorCode?Cb.getNotification(b.ErrorCode):Cb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER")),Pb.folders()},a.fullNameRaw,b),Pb.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b)),a.edited(!1)},kb.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)},kb.prototype.onShow=function(){Pb.data().foldersListError("")},kb.prototype.createFolder=function(){Ib.showScreenPopup(G)},kb.prototype.systemFolder=function(){Ib.showScreenPopup(H)},kb.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&&(Pb.local().set(Ab.ClientSideKeyName.FoldersLashHash,""),Pb.data().folderList.remove(b),Pb.data().foldersDeleting(!0),Pb.remote().folderDelete(function(a,b){Pb.data().foldersDeleting(!1),Ab.StorageResultType.Success===a&&b&&b.Result||Pb.data().foldersListError(b&&b.ErrorCode?Cb.getNotification(b.ErrorCode):Cb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER")),Pb.folders()},a.fullNameRaw),Pb.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0 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)))},ob.prototype.populateDataOnStart=function(){nb.prototype.populateDataOnStart.call(this),this.accountEmail(Pb.settingsGet("Email")),this.accountIncLogin(Pb.settingsGet("IncLogin")),this.accountOutLogin(Pb.settingsGet("OutLogin")),this.projectHash(Pb.settingsGet("ProjectHash")),this.displayName(Pb.settingsGet("DisplayName")),this.replyTo(Pb.settingsGet("ReplyTo")),this.signature(Pb.settingsGet("Signature")),this.signatureToAll(!!Pb.settingsGet("SignatureToAll")),this.enableTwoFactor(!!Pb.settingsGet("EnableTwoFactor")),this.lastFoldersHash=Pb.local().get(Ab.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!Pb.settingsGet("RemoteSuggestions"),this.devEmail=Pb.settingsGet("DevEmail"),this.devLogin=Pb.settingsGet("DevLogin"),this.devPassword=Pb.settingsGet("DevPassword")},ob.prototype.initUidNextAndNewMessages=function(b,c,d){if("INBOX"===b&&Cb.isNormal(c)&&""!==c){if(Cb.isArray(d)&&0 3)i(Pb.link().notificationMailIcon(),Pb.data().accountEmail(),Cb.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:g}));else for(;g>f;f++)i(Pb.link().notificationMailIcon(),A.emailsToLine(A.initEmailsFromJson(d[f].From),!1),d[f].Subject)}Pb.cache().setFolderUidNext(b,c)}},ob.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=Pb.cache().getFolderFromCacheList(g),f||(f=B.newInstanceFromJson(e),f&&(Pb.cache().setFolderToCacheList(g,f),Pb.cache().setFolderFullNameRaw(f.fullNameHash,g))),f&&(f.collapsed(!Cb.isFolderExpanded(f.fullNameHash)),e.Extended&&(e.Extended.Hash&&Pb.cache().setFolderHash(f.fullNameRaw,e.Extended.Hash),Cb.isNormal(e.Extended.MessageCount)&&f.messageCountAll(e.Extended.MessageCount),Cb.isNormal(e.Extended.MessageUnseenCount)&&f.messageCountUnread(e.Extended.MessageUnseenCount)),h=e.SubFolders,h&&"Collection/FolderCollection"===h["@Object"]&&h["@Collection"]&&Cb.isArray(h["@Collection"])&&f.subFolders(this.folderResponseParseRec(a,h["@Collection"])),i.push(f)));return i},ob.prototype.setFolders=function(a){var b=[],c=!1,d=Pb.data(),e=function(a){return""===a||zb.Values.UnuseOptionValue===a||null!==Pb.cache().getFolderFromCacheList(a)?a:""};a&&a.Result&&"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&Cb.isArray(a.Result["@Collection"])&&(Cb.isUnd(a.Result.Namespace)||(d.namespace=a.Result.Namespace),this.threading(!!Pb.settingsGet("UseImapThread")&&a.Result.IsThreadsSupported&&!0),b=this.folderResponseParseRec(d.namespace,a.Result["@Collection"]),d.folderList(b),a.Result.SystemFolders&&""==""+Pb.settingsGet("SentFolder")+Pb.settingsGet("DraftFolder")+Pb.settingsGet("SpamFolder")+Pb.settingsGet("TrashFolder")+Pb.settingsGet("ArchiveFolder")+Pb.settingsGet("NullFolder")&&(Pb.settingsSet("SentFolder",a.Result.SystemFolders[2]||null),Pb.settingsSet("DraftFolder",a.Result.SystemFolders[3]||null),Pb.settingsSet("SpamFolder",a.Result.SystemFolders[4]||null),Pb.settingsSet("TrashFolder",a.Result.SystemFolders[5]||null),Pb.settingsSet("ArchiveFolder",a.Result.SystemFolders[12]||null),c=!0),d.sentFolder(e(Pb.settingsGet("SentFolder"))),d.draftFolder(e(Pb.settingsGet("DraftFolder"))),d.spamFolder(e(Pb.settingsGet("SpamFolder"))),d.trashFolder(e(Pb.settingsGet("TrashFolder"))),d.archiveFolder(e(Pb.settingsGet("ArchiveFolder"))),c&&Pb.remote().saveSystemFolders(Cb.emptyFunction,{SentFolder:d.sentFolder(),DraftFolder:d.draftFolder(),SpamFolder:d.spamFolder(),TrashFolder:d.trashFolder(),ArchiveFolder:d.archiveFolder(),NullFolder:"NullFolder"}),Pb.local().set(Ab.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash))},ob.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()},ob.prototype.getNextFolderNames=function(a){a=Cb.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=Pb.cache().getFolderFromCacheList(a[1]);return e&&(e.interval=d,b.push(a[1])),c<=b.length}),h.uniq(b)},ob.prototype.removeMessagesFromList=function(a,b,c,d){c=Cb.isNormal(c)?c:"",d=Cb.isUnd(d)?!1:!!d,b=h.map(b,function(a){return Cb.pInt(a)});var e=0,f=Pb.data(),g=Pb.cache(),i=f.messageList(),j=Pb.cache().getFolderFromCacheList(a),k=""===c?null:g.getFolderFromCacheList(c||""),l=f.currentFolderFullNameRaw(),m=f.message(),n=l===a?h.filter(i,function(a){return a&&-1 0&&j.messageCountUnread(0<=j.messageCountUnread()-e?j.messageCountUnread()-e:0)),k&&(k.messageCountAll(k.messageCountAll()+b.length),e>0&&k.messageCountUnread(k.messageCountUnread()+e),k.actionBlink(!0)),0 ').hide().addClass("rl-cache-class"),g.data("rl-cache-count",++Fb.iMessageBodyCacheCount),Cb.isNormal(a.Result.Html)&&""!==a.Result.Html?(d=!0,g.html(a.Result.Html.toString()).addClass("b-text-part html")):Cb.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(d=!1,j=a.Result.Plain.toString(),(n.isPgpSigned()||n.isPgpEncrypted())&&Pb.data().allowOpenPGP()&&Cb.isNormal(a.Result.PlainRaw)&&(n.plainRaw=Cb.pString(a.Result.PlainRaw),l=/---BEGIN PGP MESSAGE---/.test(n.plainRaw),l||(k=/-----BEGIN PGP SIGNED MESSAGE-----/.test(n.plainRaw)&&/-----BEGIN PGP SIGNATURE-----/.test(n.plainRaw)),Qb.empty(),k&&n.isPgpSigned()?j=Qb.append(b('').text(n.plainRaw)).html():l&&n.isPgpEncrypted()&&(j=Qb.append(b('').text(n.plainRaw)).html()),Qb.empty(),n.isPgpSigned(k),n.isPgpEncrypted(l)),g.html(j).addClass("b-text-part plain")):d=!1,n.isHtml(!!d),n.hasImages(!!e),n.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.None),n.pgpSignedVerifyUser(""),a.Result.Rtl&&(n.isRtl(!0),g.addClass("rtl-text-part")),n.body=g,n.body&&m.append(n.body),n.storeDataToDom(),f&&n.showInternalImages(!0),n.hasImages()&&this.showImages()&&n.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()),this.messageActiveDom(n.body),this.hideMessageBodies(),n.body.show(),g&&Cb.initBlockquoteSwitcher(g)),Pb.cache().initMessageFlagsFromCache(n),n.unseen()&&Pb.setMessageSeen(n),Cb.windowResize())},ob.prototype.calculateMessageListHash=function(a){return h.map(a,function(a){return""+a.hash+"_"+a.threadsLen()+"_"+a.flagHash()}).join("|")},ob.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&Cb.isArray(a.Result["@Collection"])){var c=Pb.data(),d=Pb.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=Cb.pInt(a.Result.MessageResultCount),j=Cb.pInt(a.Result.Offset),Cb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),p=Pb.cache().getFolderFromCacheList(Cb.isNormal(a.Result.Folder)?a.Result.Folder:""),p&&!b&&(p.interval=l,Pb.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),Cb.isNormal(a.Result.MessageCount)&&p.messageCountAll(a.Result.MessageCount),Cb.isNormal(a.Result.MessageUnseenCount)&&(Cb.pInt(p.messageCountUnread())!==Cb.pInt(a.Result.MessageUnseenCount)&&(r=!0),p.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(p.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),r&&p&&Pb.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=A.newInstanceFromJson(n)),o&&(d.hasNewMessageAndRemoveFromCache(o.folderFullNameRaw,o.uid)&&5>=q&&(q++,o.newForAnimation(!0)),o.deleted(!1),b?Pb.cache().initMessageFlagsFromCache(o):Pb.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/"+Eb.urlsafe_encode([b,c,Pb.data().projectHash(),Pb.data().threading()&&Pb.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},qb.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999e3)},qb.prototype.folderInformation=function(a,b,c){var d=!0,e=Pb.cache(),f=[];Cb.isArray(c)&&0 l;l++)q.push({id:e[l][0],name:e[l][1],system:!1,seporator:!1,disabled:!1});for(o=!0,l=0,m=b.length;m>l;l++)n=b[l],(h?h.call(null,n):!0)&&(o&&0 l;l++)n=c[l],(n.subScribed()||!n.existen)&&(h?h.call(null,n):!0)&&(Ab.FolderType.User===n.type()||!j||0 =5?e:20,e=320>=e?e:320,a.setInterval(function(){Pb.contactsSync()},6e4*e+5e3),h.delay(function(){Pb.contactsSync()},5e3),h.delay(function(){Pb.folderInformationMultiply(!0)},500),h.delay(function(){Pb.emailsPicsHashes(),Pb.remote().servicesPics(function(a,b){Ab.StorageResultType.Success===a&&b&&b.Result&&Pb.cache().setServicesData(b.Result)})},2e3),Db.runHook("rl-start-user-screens"),Pb.pub("rl.bootstart-user-screens"),Pb.settingsGet("AccountSignMe")&&a.navigator.registerProtocolHandler&&h.delay(function(){try{a.navigator.registerProtocolHandler("mailto",a.location.protocol+"//"+a.location.host+a.location.pathname+"?mailto&to=%s",""+(Pb.settingsGet("Title")||"RainLoop"))}catch(b){}Pb.settingsGet("MailToEmail")&&Pb.mailToHelper(Pb.settingsGet("MailToEmail"))},500)):(Ib.startScreens([ub]),Db.runHook("rl-start-login-screens"),Pb.pub("rl.bootstart-login-screens")),a.SimplePace&&a.SimplePace.set(100),Fb.bMobileDevice||h.defer(function(){Cb.initLayoutResizer("#rl-left","#rl-right",Ab.ClientSideKeyName.FolderListSize)})},this))):(c=Cb.pString(Pb.settingsGet("CustomLoginLink")),c?(Ib.routeOff(),Ib.setHash(Pb.link().root(),!0),Ib.routeOff(),h.defer(function(){a.location.href=c})):(Ib.hideLoading(),Ib.startScreens([ub]),Db.runHook("rl-start-login-screens"),Pb.pub("rl.bootstart-login-screens"),a.SimplePace&&a.SimplePace.set(100))),f&&(a["rl_"+d+"_google_service"]=function(){Pb.data().googleActions(!0),Pb.socialUsers()}),g&&(a["rl_"+d+"_facebook_service"]=function(){Pb.data().facebookActions(!0),Pb.socialUsers()}),i&&(a["rl_"+d+"_twitter_service"]=function(){Pb.data().twitterActions(!0),Pb.socialUsers()}),Pb.sub("interval.1m",function(){Fb.momentTrigger(!Fb.momentTrigger())}),Db.runHook("rl-start-screens"),Pb.pub("rl.bootstart-end")},Pb=new yb,Lb.addClass(Fb.bMobileDevice?"mobile":"no-mobile"),Mb.keydown(Cb.killCtrlAandS).keyup(Cb.killCtrlAandS),Mb.unload(function(){Fb.bUnload=!0}),Lb.on("click.dropdown.data-api",function(){Cb.detectDropdownVisibility()}),a.rl=a.rl||{},a.rl.addHook=Db.addHook,a.rl.settingsGet=Db.mainSettingsGet,a.rl.remoteRequest=Db.remoteRequest,a.rl.pluginSettingsGet=Db.settingsGet,a.rl.addSettingsViewModel=Cb.addSettingsViewModel,a.rl.createCommand=Cb.createCommand,a.rl.EmailModel=u,a.rl.Enums=Ab,a.__RLBOOT=function(c){b(function(){a.rainloopTEMPLATES&&a.rainloopTEMPLATES[0]?(b("#rl-templates").html(a.rainloopTEMPLATES[0]),h.delay(function(){a.rainloopAppData={},a.rainloopI18N={},a.rainloopTEMPLATES={},Ib.setBoot(Pb).bootstart(),Lb.removeClass("no-js rl-booted-trigger").addClass("rl-booted")},50)):c(!1),a.__RLBOOT=null})},a.SimplePace&&a.SimplePace.add(10)}(window,jQuery,ko,crossroads,hasher,moment,Jua,_,ifvisible,key); \ No newline at end of file diff --git a/rainloop/v/0.0.0/static/js/libs.js b/rainloop/v/0.0.0/static/js/libs.js index 6515aced2..677717d51 100644 --- a/rainloop/v/0.0.0/static/js/libs.js +++ b/rainloop/v/0.0.0/static/js/libs.js @@ -1,60 +1,60 @@ /* Modernizr 2.6.2 (Custom Build) | MIT & BSD * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-svg-touch-shiv-cssclasses-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-fullscreen_api */ -;window.Modernizr=function(a,b,c){function C(a){j.cssText=a}function D(a,b){return C(n.join(a+";")+(b||""))}function E(a,b){return typeof a===b}function F(a,b){return!!~(""+a).indexOf(b)}function G(a,b){for(var d in a){var e=a[d];if(!F(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function H(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:E(f,"function")?f.bind(d||b):f}return!1}function I(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return E(b,"string")||E(b,"undefined")?G(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),H(e,b,c))}function J(){e.input=function(c){for(var d=0,e=c.length;d ',a,""].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=E(e[d],"function"),E(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),A={}.hasOwnProperty,B;!E(A,"undefined")&&!E(A.call,"undefined")?B=function(a,b){return A.call(a,b)}:B=function(a,b){return b in a&&E(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return I("flexWrap")},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!I("indexedDB",a)},s.hashchange=function(){return z("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return C("background-color:rgba(150,255,150,.5)"),F(j.backgroundColor,"rgba")},s.hsla=function(){return C("background-color:hsla(120,40%,100%,.5)"),F(j.backgroundColor,"rgba")||F(j.backgroundColor,"hsla")},s.multiplebgs=function(){return C("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return I("backgroundSize")},s.borderimage=function(){return I("borderImage")},s.borderradius=function(){return I("borderRadius")},s.boxshadow=function(){return I("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return D("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return I("animationName")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return C((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),F(j.backgroundImage,"gradient")},s.cssreflections=function(){return I("boxReflect")},s.csstransforms=function(){return!!I("transform")},s.csstransforms3d=function(){var a=!!I("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return I("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect};for(var K in s)B(s,K)&&(x=K.toLowerCase(),e[x]=s[K](),v.push((e[x]?"":"no-")+x));return e.input||J(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)B(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},C(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e ",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.hasEvent=z,e.testProp=function(a){return G([a])},e.testAllProps=I,e.testStyles=y,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),Modernizr.addTest("fullscreen",function(){for(var a=0;a ',a,""].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=E(e[d],"function"),E(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),A={}.hasOwnProperty,B;!E(A,"undefined")&&!E(A.call,"undefined")?B=function(a,b){return A.call(a,b)}:B=function(a,b){return b in a&&E(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return I("flexWrap")},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!I("indexedDB",a)},s.hashchange=function(){return z("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return C("background-color:rgba(150,255,150,.5)"),F(j.backgroundColor,"rgba")},s.hsla=function(){return C("background-color:hsla(120,40%,100%,.5)"),F(j.backgroundColor,"rgba")||F(j.backgroundColor,"hsla")},s.multiplebgs=function(){return C("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return I("backgroundSize")},s.borderimage=function(){return I("borderImage")},s.borderradius=function(){return I("borderRadius")},s.boxshadow=function(){return I("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return D("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return I("animationName")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return C((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),F(j.backgroundImage,"gradient")},s.cssreflections=function(){return I("boxReflect")},s.csstransforms=function(){return!!I("transform")},s.csstransforms3d=function(){var a=!!I("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return I("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect};for(var K in s)B(s,K)&&(x=K.toLowerCase(),e[x]=s[K](),v.push((e[x]?"":"no-")+x));return e.input||J(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)B(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},C(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e ",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.hasEvent=z,e.testProp=function(a){return G([a])},e.testAllProps=I,e.testStyles=y,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),Modernizr.addTest("fullscreen",function(){for(var a=0;a u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var E="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(E);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(E);return r},j.find=j.detect=function(n,t,r){var e;return O(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var O=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:O(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,function(n){return n[t]})},j.where=function(n,t,r){return j.isEmpty(t)?r?void 0:[]:j[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},j.findWhere=function(n,t){return j.where(n,t,!0)},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);if(!t&&j.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>e.computed&&(e={value:n,computed:a})}),e.value},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);if(!t&&j.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={},i=null==r?j.identity:k(r);return A(t,function(r,a){var o=i.call(e,r,a,t);n(u,o,r)}),u}};j.groupBy=F(function(n,t,r){(j.has(n,t)?n[t]:n[t]=[]).push(r)}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=null==r?j.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])=0})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:new Date,a=null,i=n.apply(e,u)};return function(){var l=new Date;o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u)):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o;return function(){i=this,u=arguments,a=new Date;var c=function(){var l=new Date-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u)))},l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u)),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=w||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var I={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};I.unescape=j.invert(I.escape);var T={escape:new RegExp("["+j.keys(I.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(I.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return I[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); - +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?(this._wrapped=n,void 0):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.5.2";var A=j.each=j.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var E="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(E);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(E);return r},j.find=j.detect=function(n,t,r){var e;return O(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var O=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:O(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,function(n){return n[t]})},j.where=function(n,t,r){return j.isEmpty(t)?r?void 0:[]:j[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},j.findWhere=function(n,t){return j.where(n,t,!0)},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);if(!t&&j.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>e.computed&&(e={value:n,computed:a})}),e.value},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);if(!t&&j.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={},i=null==r?j.identity:k(r);return A(t,function(r,a){var o=i.call(e,r,a,t);n(u,o,r)}),u}};j.groupBy=F(function(n,t,r){(j.has(n,t)?n[t]:n[t]=[]).push(r)}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=null==r?j.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])=0})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:new Date,a=null,i=n.apply(e,u)};return function(){var l=new Date;o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u)):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o;return function(){i=this,u=arguments,a=new Date;var c=function(){var l=new Date-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u)))},l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u)),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=w||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var I={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};I.unescape=j.invert(I.escape);var T={escape:new RegExp("["+j.keys(I.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(I.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return I[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); + /*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h; if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" a",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h
]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/\s*$/g,rb={option:[1,""],legend:[1,""],area:[1,""],param:[1,""],thead:[1," ","
"],tr:[2,"","
"],col:[2,""],td:[3,"
"," "],_default:k.htmlSerialize?[0,"",""]:[1,"X
"," ",""]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1>$2>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?"