diff --git a/dev/Apps/AbstractApp.js b/dev/Apps/AbstractApp.js index a79777d8b..8525e9886 100644 --- a/dev/Apps/AbstractApp.js +++ b/dev/Apps/AbstractApp.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,10 +8,10 @@ _ = require('_'), $ = require('$'), - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - Events = require('Events'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), + Events = require('Common/Events'), Settings = require('Storage:Settings'), @@ -74,11 +74,6 @@ return null; }; - AbstractApp.prototype.setupSettings = function () - { - return true; - }; - /** * @param {string} sLink * @return {boolean} @@ -270,4 +265,4 @@ module.exports = AbstractApp; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Apps/AdminApp.js b/dev/Apps/AdminApp.js index b1e6c7db1..cab11dce3 100644 --- a/dev/Apps/AdminApp.js +++ b/dev/Apps/AdminApp.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,9 +8,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings'), Data = require('Storage:Admin:Data'), @@ -44,47 +44,6 @@ return Data; }; - AdminApp.prototype.setupSettings = function () - { - kn.addSettingsViewModel(require('Settings:Admin:General'), - 'AdminSettingsGeneral', 'General', 'general', true); - - kn.addSettingsViewModel(require('Settings:Admin:Login'), - 'AdminSettingsLogin', 'Login', 'login'); - - if (Settings.capa(Enums.Capa.Prem)) - { - kn.addSettingsViewModel(require('Settings:Admin:Branding'), - 'AdminSettingsBranding', 'Branding', 'branding'); - } - - kn.addSettingsViewModel(require('Settings:Admin:Contacts'), - 'AdminSettingsContacts', 'Contacts', 'contacts'); - - kn.addSettingsViewModel(require('Settings:Admin:Domains'), - 'AdminSettingsDomains', 'Domains', 'domains'); - - kn.addSettingsViewModel(require('Settings:Admin:Security'), - 'AdminSettingsSecurity', 'Security', 'security'); - - kn.addSettingsViewModel(require('Settings:Admin:Social'), - 'AdminSettingsSocial', 'Social', 'social'); - - kn.addSettingsViewModel(require('Settings:Admin:Plugins'), - 'AdminSettingsPlugins', 'Plugins', 'plugins'); - - kn.addSettingsViewModel(require('Settings:Admin:Packages'), - 'AdminSettingsPackages', 'Packages', 'packages'); - - kn.addSettingsViewModel(require('Settings:Admin:Licensing'), - 'AdminSettingsLicensing', 'Licensing', 'licensing'); - - kn.addSettingsViewModel(require('Settings:Admin:About'), - 'AdminSettingsAbout', 'About', 'about'); - - return true; - }; - AdminApp.prototype.reloadDomainList = function () { Data.domainsLoading(true); @@ -311,4 +270,4 @@ module.exports = new AdminApp(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Apps/RainLoopApp.js b/dev/Apps/RainLoopApp.js index 21e2f3ece..b94a981d8 100644 --- a/dev/Apps/RainLoopApp.js +++ b/dev/Apps/RainLoopApp.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -9,13 +9,13 @@ $ = require('$'), moment = require('moment'), - Enums = require('Enums'), - Globals = require('Globals'), - Consts = require('Consts'), - Plugins = require('Plugins'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - Events = require('Events'), + Enums = require('Common/Enums'), + Globals = require('Common/Globals'), + Consts = require('Common/Consts'), + Plugins = require('Common/Plugins'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), + Events = require('Common/Events'), kn = require('App:Knoin'), @@ -114,78 +114,6 @@ return Data; }; - RainLoopApp.prototype.setupSettings = function () - { - kn.addSettingsViewModel(require('Settings:RainLoop:General'), - 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true); - - if (Settings.settingsGet('ContactsIsAllowed')) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Contacts'), - 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts'); - } - - if (Settings.capa(Enums.Capa.AdditionalAccounts)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Accounts'), - 'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts'); - } - - if (Settings.capa(Enums.Capa.AdditionalIdentities)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Identities'), - 'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities'); - } - else - { - kn.addSettingsViewModel(require('Settings:RainLoop:Identity'), - 'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity'); - } - - if (Settings.capa(Enums.Capa.Filters)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Filters'), - 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters'); - } - - if (Settings.capa(Enums.Capa.TwoFactor)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Security'), - 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security'); - } - - if (Settings.settingsGet('AllowGoogleSocial') || - Settings.settingsGet('AllowFacebookSocial') || - Settings.settingsGet('AllowTwitterSocial')) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Social'), - 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social'); - } - - if (Settings.settingsGet('ChangePasswordIsAllowed')) - { - kn.addSettingsViewModel(require('Settings:RainLoop:ChangePassword'), - 'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password'); - } - - kn.addSettingsViewModel(require('Settings:RainLoop:Folders'), - 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders'); - - if (Settings.capa(Enums.Capa.Themes)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Themes'), - 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes'); - } - - if (Settings.capa(Enums.Capa.OpenPGP)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:OpenPGP'), - 'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp'); - } - - return true; - }; - RainLoopApp.prototype.reloadFlagsCurrentMessageListAndMessageFromCache = function () { _.each(Data.messageList(), function (oMessage) { @@ -1372,107 +1300,112 @@ this.folders(_.bind(function (bValue) { - kn.hideLoading(); - if (bValue) { - if (window.$LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP)) - { - window.$LAB.script(window.openpgp ? '' : LinkBuilder.openPgpJs()).wait(function () { - if (window.openpgp) + require.ensure([], function () { + + kn.hideLoading(); + + if (window.$LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP)) + { + window.$LAB.script(window.openpgp ? '' : LinkBuilder.openPgpJs()).wait(function () { + if (window.openpgp) + { + Data.openpgpKeyring = new window.openpgp.Keyring(); + Data.capaOpenPGP(true); + + Events.pub('openpgp.init'); + + self.reloadOpenPgpKeys(); + } + }); + } + else + { + Data.capaOpenPGP(false); + } + + kn.startScreens([ + require('Screen:RainLoop:MailBox'), + require('Screen:RainLoop:Settings'), + require('Screen:RainLoop:About') + ]); + + if (bGoogle || bFacebook || bTwitter) + { + self.socialUsers(true); + } + + Events.sub('interval.2m', function () { + self.folderInformation('INBOX'); + }); + + Events.sub('interval.2m', function () { + var sF = Data.currentFolderFullNameRaw(); + if ('INBOX' !== sF) { - Data.openpgpKeyring = new window.openpgp.Keyring(); - Data.capaOpenPGP(true); - - Events.pub('openpgp.init'); - - self.reloadOpenPgpKeys(); + self.folderInformation(sF); } }); - } - else - { - Data.capaOpenPGP(false); - } - kn.startScreens([ - require('Screen:RainLoop:MailBox'), - require('Screen:RainLoop:Settings'), - require('Screen:RainLoop:About') - ]); + Events.sub('interval.3m', function () { + self.folderInformationMultiply(); + }); - if (bGoogle || bFacebook || bTwitter) - { - self.socialUsers(true); - } + Events.sub('interval.5m', function () { + self.quota(); + }); - Events.sub('interval.2m', function () { - self.folderInformation('INBOX'); - }); + Events.sub('interval.10m', function () { + self.folders(); + }); - Events.sub('interval.2m', function () { - var sF = Data.currentFolderFullNameRaw(); - if ('INBOX' !== sF) + iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20; + iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320; + + window.setInterval(function () { + self.contactsSync(); + }, iContactsSyncInterval * 60000 + 5000); + + _.delay(function () { + self.contactsSync(); + }, 5000); + + _.delay(function () { + self.folderInformationMultiply(true); + }, 500); + + Plugins.runHook('rl-start-user-screens'); + Events.pub('rl.bootstart-user-screens'); + + if (!!Settings.settingsGet('AccountSignMe') && window.navigator.registerProtocolHandler) { - self.folderInformation(sF); + _.delay(function () { + try { + window.navigator.registerProtocolHandler('mailto', + window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', + '' + (Settings.settingsGet('Title') || 'RainLoop')); + } catch(e) {} + + if (Settings.settingsGet('MailToEmail')) + { + Utils.mailToHelper(Settings.settingsGet('MailToEmail'), require('View:Popup:Compose')); + } + }, 500); + } + + if (!Globals.bMobileDevice) + { + _.defer(function () { + self.initLayoutResizer('#rl-left', '#rl-right', Enums.ClientSideKeyName.FolderListSize); + }); } }); - - Events.sub('interval.3m', function () { - self.folderInformationMultiply(); - }); - - Events.sub('interval.5m', function () { - self.quota(); - }); - - Events.sub('interval.10m', function () { - self.folders(); - }); - - iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20; - iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320; - - window.setInterval(function () { - self.contactsSync(); - }, iContactsSyncInterval * 60000 + 5000); - - _.delay(function () { - self.contactsSync(); - }, 5000); - - _.delay(function () { - self.folderInformationMultiply(true); - }, 500); - - Plugins.runHook('rl-start-user-screens'); - Events.pub('rl.bootstart-user-screens'); - - if (!!Settings.settingsGet('AccountSignMe') && window.navigator.registerProtocolHandler) - { - _.delay(function () { - try { - window.navigator.registerProtocolHandler('mailto', - window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', - '' + (Settings.settingsGet('Title') || 'RainLoop')); - } catch(e) {} - - if (Settings.settingsGet('MailToEmail')) - { - Utils.mailToHelper(Settings.settingsGet('MailToEmail'), require('View:Popup:Compose')); - } - }, 500); - } - - if (!Globals.bMobileDevice) - { - _.defer(function () { - self.initLayoutResizer('#rl-left', '#rl-right', Enums.ClientSideKeyName.FolderListSize); - }); - } } else { + kn.hideLoading(); + self.bootstartLoginScreen(); } @@ -1527,4 +1460,4 @@ module.exports = new RainLoopApp(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Boot.js b/dev/Boot.js index 4938bc995..7859b25d7 100644 --- a/dev/Boot.js +++ b/dev/Boot.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -10,18 +10,16 @@ _ = require('_'), $ = require('$'), - Globals = require('Globals'), - Plugins = require('Plugins'), - Utils = require('Utils'), - Enums = require('Enums'), + Globals = require('Common/Globals'), + Plugins = require('Common/Plugins'), + Utils = require('Common/Utils'), + Enums = require('Common/Enums'), EmailModel = require('Model:Email') ; Globals.__APP = App; - App.setupSettings(); - Plugins.__boot = App; Plugins.__remote = App.remote(); Plugins.__data = App.data(); @@ -76,4 +74,4 @@ }; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/Base64.js b/dev/Common/Base64.js index 37758e523..2f0d355a1 100644 --- a/dev/Common/Base64.js +++ b/dev/Common/Base64.js @@ -1,7 +1,7 @@ // Base64 encode / decode // http://www.webtoolkit.info/ -(function (module) { +(function () { 'use strict'; @@ -168,4 +168,4 @@ module.exports = Base64; /*jslint bitwise: false*/ -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/Consts.js b/dev/Common/Consts.js index c46d1ce8b..f5536279e 100644 --- a/dev/Common/Consts.js +++ b/dev/Common/Consts.js @@ -1,5 +1,5 @@ -(function (module) { +(function () { 'use strict'; diff --git a/dev/Common/Enums.js b/dev/Common/Enums.js index f26c03bb6..ed0b73545 100644 --- a/dev/Common/Enums.js +++ b/dev/Common/Enums.js @@ -1,5 +1,5 @@ -(function (module) { +(function () { 'use strict'; @@ -427,4 +427,4 @@ module.exports = Enums; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/Events.js b/dev/Common/Events.js index 09ba23f46..b8198fb1f 100644 --- a/dev/Common/Events.js +++ b/dev/Common/Events.js @@ -1,13 +1,13 @@ -(function (module, require) { +(function () { 'use strict'; var _ = require('_'), - Utils = require('Utils'), - Plugins = require('Plugins') + Utils = require('Common/Utils'), + Plugins = require('Common/Plugins') ; /** @@ -62,4 +62,4 @@ module.exports = new Events(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/Globals.js b/dev/Common/Globals.js index d16aa9c7e..7f4e4f65e 100644 --- a/dev/Common/Globals.js +++ b/dev/Common/Globals.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -12,7 +12,7 @@ ko = require('ko'), key = require('key'), - Enums = require('Enums') + Enums = require('Common/Enums') ; Globals.$win = $(window); @@ -284,4 +284,4 @@ module.exports = Globals; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/HtmlEditor.js b/dev/Common/HtmlEditor.js index 8c223c149..b099bb6c7 100644 --- a/dev/Common/HtmlEditor.js +++ b/dev/Common/HtmlEditor.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,7 +7,7 @@ window = require('window'), _ = require('_'), - Globals = require('Globals'), + Globals = require('Common/Globals'), Settings = require('Storage:Settings') ; @@ -272,4 +272,4 @@ module.exports = HtmlEditor; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/LinkBuilder.js b/dev/Common/LinkBuilder.js index d76cd7971..428a660da 100644 --- a/dev/Common/LinkBuilder.js +++ b/dev/Common/LinkBuilder.js @@ -1,11 +1,10 @@ -(function (module, require) { +(function () { 'use strict'; var - window = require('window'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -95,7 +94,7 @@ */ LinkBuilder.prototype.change = function (sEmail) { - return this.sServer + '/Change/' + this.sSpecSuffix + '/' + window.encodeURIComponent(sEmail) + '/'; + return this.sServer + '/Change/' + this.sSpecSuffix + '/' + Utils.encodeURIComponent(sEmail) + '/'; }; /** @@ -131,7 +130,7 @@ */ LinkBuilder.prototype.avatarLink = function (sEmail) { - return this.sServer + '/Raw/0/Avatar/' + window.encodeURIComponent(sEmail) + '/'; + return this.sServer + '/Raw/0/Avatar/' + Utils.encodeURIComponent(sEmail) + '/'; }; /** @@ -304,7 +303,7 @@ */ LinkBuilder.prototype.openPgpJs = function () { - return this.sStaticPrefix + 'js/openpgp.min.js'; + return this.sStaticPrefix + 'js/min/openpgp.js'; }; /** @@ -333,4 +332,4 @@ module.exports = new LinkBuilder(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/Plugins.js b/dev/Common/Plugins.js index 8c56833d4..da37b5223 100644 --- a/dev/Common/Plugins.js +++ b/dev/Common/Plugins.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var _ = require('_'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -110,4 +110,4 @@ module.exports = new Plugins(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/Selector.js b/dev/Common/Selector.js index 1f1090232..98e7ff875 100644 --- a/dev/Common/Selector.js +++ b/dev/Common/Selector.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -9,8 +9,8 @@ ko = require('ko'), key = require('key'), - Enums = require('Enums'), - Utils = require('Utils') + Enums = require('Common/Enums'), + Utils = require('Common/Utils') ; /** @@ -726,4 +726,4 @@ module.exports = Selector; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index 290ed4679..702b94cc4 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -11,11 +11,11 @@ $ = require('$'), ko = require('ko'), - Enums = require('Enums'), - Consts = require('Consts'), - Globals = require('Globals') + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + Globals = require('Common/Globals') ; - + Utils.trim = $.trim; Utils.inArray = $.inArray; Utils.isArray = _.isArray; @@ -80,6 +80,15 @@ return Utils.isNormal(mValue) ? '' + mValue : ''; }; + /** + * @param {string} sComponent + * @return {string} + */ + Utils.encodeURIComponent = function (sComponent) + { + return window.encodeURIComponent(sComponent); + }; + /** * @param {*} aValue * @return {boolean} @@ -1929,4 +1938,4 @@ module.exports = Utils; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/External/JSON.js b/dev/External/JSON.js deleted file mode 100644 index 4a1798c8d..000000000 --- a/dev/External/JSON.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = JSON; \ No newline at end of file diff --git a/dev/External/Jua.js b/dev/External/Jua.js deleted file mode 100644 index 3b736d2d6..000000000 --- a/dev/External/Jua.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = Jua; \ No newline at end of file diff --git a/dev/External/crossroads.js b/dev/External/crossroads.js deleted file mode 100644 index 7c51abb2f..000000000 --- a/dev/External/crossroads.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = crossroads; \ No newline at end of file diff --git a/dev/External/hasher.js b/dev/External/hasher.js deleted file mode 100644 index d090af6a8..000000000 --- a/dev/External/hasher.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = hasher; \ No newline at end of file diff --git a/dev/External/ifvisible.js b/dev/External/ifvisible.js deleted file mode 100644 index c65bee98d..000000000 --- a/dev/External/ifvisible.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = ifvisible; \ No newline at end of file diff --git a/dev/External/jquery.js b/dev/External/jquery.js deleted file mode 100644 index b27a8d9ec..000000000 --- a/dev/External/jquery.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = $; \ No newline at end of file diff --git a/dev/External/key.js b/dev/External/key.js deleted file mode 100644 index 8477df378..000000000 --- a/dev/External/key.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = key; \ No newline at end of file diff --git a/dev/External/ko.js b/dev/External/ko.js index b88740728..fd2cbc7e6 100644 --- a/dev/External/ko.js +++ b/dev/External/ko.js @@ -13,8 +13,8 @@ 'init': function (oElement, fValueAccessor) { var - Globals = require('Globals'), - Utils = require('Utils') + Globals = require('Common/Globals'), + Utils = require('Common/Utils') ; if (!Globals.bMobileDevice) @@ -52,7 +52,7 @@ ko.bindingHandlers.tooltip2 = { 'init': function (oElement, fValueAccessor) { var - Globals = require('Globals'), + Globals = require('Common/Globals'), $oEl = $(oElement), sClass = $oEl.data('tooltip-class') || '', sPlacement = $oEl.data('tooltip-placement') || 'top' @@ -85,7 +85,7 @@ var $oEl = $(oElement), - Globals = require('Globals') + Globals = require('Common/Globals') ; $oEl.tooltip({ @@ -119,7 +119,7 @@ ko.bindingHandlers.registrateBootstrapDropdown = { 'init': function (oElement) { - var Globals = require('Globals'); + var Globals = require('Common/Globals'); Globals.aBootstrapDropdowns.push($(oElement)); } }; @@ -130,7 +130,7 @@ { var $el = $(oElement), - Utils = require('Utils') + Utils = require('Common/Utils') ; if (!$el.hasClass('open')) @@ -160,7 +160,7 @@ ko.bindingHandlers.csstext = { 'init': function (oElement, fValueAccessor) { - var Utils = require('Utils'); + var Utils = require('Common/Utils'); if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText)) { oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor()); @@ -171,7 +171,7 @@ } }, 'update': function (oElement, fValueAccessor) { - var Utils = require('Utils'); + var Utils = require('Common/Utils'); if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText)) { oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor()); @@ -239,8 +239,8 @@ 'init': function (oElement, fValueAccessor) { var - Globals = require('Globals'), - Utils = require('Utils') + Globals = require('Common/Globals'), + Utils = require('Common/Utils') ; $(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({ @@ -262,14 +262,14 @@ ko.bindingHandlers.i18nInit = { 'init': function (oElement) { - var Utils = require('Utils'); + var Utils = require('Common/Utils'); Utils.i18nToNode(oElement); } }; ko.bindingHandlers.i18nUpdate = { 'update': function (oElement, fValueAccessor) { - var Utils = require('Utils'); + var Utils = require('Common/Utils'); ko.utils.unwrapObservable(fValueAccessor()); Utils.i18nToNode(oElement); } @@ -310,8 +310,8 @@ 'update': function (oElement, fValueAccessor) { var - Utils = require('Utils'), - Globals = require('Globals'), + Utils = require('Common/Utils'), + Globals = require('Common/Globals'), aValues = ko.utils.unwrapObservable(fValueAccessor()), iValue = Utils.pInt(aValues[1]), iSize = 0, @@ -345,8 +345,8 @@ ko.bindingHandlers.draggable = { 'init': function (oElement, fValueAccessor, fAllBindingsAccessor) { var - Globals = require('Globals'), - Utils = require('Utils') + Globals = require('Common/Globals'), + Utils = require('Common/Utils') ; if (!Globals.bMobileDevice) { @@ -428,7 +428,7 @@ ko.bindingHandlers.droppable = { 'init': function (oElement, fValueAccessor, fAllBindingsAccessor) { - var Globals = require('Globals'); + var Globals = require('Common/Globals'); if (!Globals.bMobileDevice) { var @@ -470,7 +470,7 @@ ko.bindingHandlers.nano = { 'init': function (oElement) { - var Globals = require('Globals'); + var Globals = require('Common/Globals'); if (!Globals.bDisableNanoScroll) { $(oElement) @@ -567,7 +567,7 @@ 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { var - Utils = require('Utils'), + Utils = require('Common/Utils'), EmailModel = require('Model:Email'), $oEl = $(oElement), @@ -641,7 +641,7 @@ 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { var - Utils = require('Utils'), + Utils = require('Common/Utils'), ContactTagModel = require('Model:ContactTag'), $oEl = $(oElement), @@ -756,7 +756,7 @@ ko.extenders.trimmer = function (oTarget) { var - Utils = require('Utils'), + Utils = require('Common/Utils'), oResult = ko.computed({ 'read': oTarget, 'write': function (sNewValue) { @@ -773,7 +773,7 @@ ko.extenders.posInterer = function (oTarget, iDefault) { var - Utils = require('Utils'), + Utils = require('Common/Utils'), oResult = ko.computed({ 'read': oTarget, 'write': function (sNewValue) { @@ -829,7 +829,7 @@ ko.extenders.falseTimeout = function (oTarget, iOption) { - var Utils = require('Utils'); + var Utils = require('Common/Utils'); oTarget.iTimeout = 0; oTarget.subscribe(function (bValue) { @@ -854,7 +854,7 @@ ko.observable.fn.validateEmail = function () { - var Utils = require('Utils'); + var Utils = require('Common/Utils'); this.hasError = ko.observable(false); @@ -869,7 +869,7 @@ ko.observable.fn.validateSimpleEmail = function () { - var Utils = require('Utils'); + var Utils = require('Common/Utils'); this.hasError = ko.observable(false); @@ -884,7 +884,7 @@ ko.observable.fn.validateFunc = function (fFunc) { - var Utils = require('Utils'); + var Utils = require('Common/Utils'); this.hasFuncError = ko.observable(false); diff --git a/dev/External/moment.js b/dev/External/moment.js deleted file mode 100644 index 6f58042c2..000000000 --- a/dev/External/moment.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = moment; \ No newline at end of file diff --git a/dev/External/ssm.js b/dev/External/ssm.js deleted file mode 100644 index eb6bc0227..000000000 --- a/dev/External/ssm.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = ssm; \ No newline at end of file diff --git a/dev/External/underscore.js b/dev/External/underscore.js deleted file mode 100644 index e055bcc62..000000000 --- a/dev/External/underscore.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = _; \ No newline at end of file diff --git a/dev/External/window.js b/dev/External/window.js deleted file mode 100644 index 1150c0e0f..000000000 --- a/dev/External/window.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = window; \ No newline at end of file diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 3dcd88082..ea089f220 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -10,9 +10,9 @@ hasher = require('hasher'), crossroads = require('crossroads'), - Globals = require('Globals'), - Plugins = require('Plugins'), - Utils = require('Utils') + Globals = require('Common/Globals'), + Plugins = require('Common/Plugins'), + Utils = require('Common/Utils') ; /** @@ -458,4 +458,4 @@ module.exports = new Knoin(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Knoin/KnoinAbstractBoot.js b/dev/Knoin/KnoinAbstractBoot.js index 08a39ff17..cda1e7ef1 100644 --- a/dev/Knoin/KnoinAbstractBoot.js +++ b/dev/Knoin/KnoinAbstractBoot.js @@ -1,5 +1,5 @@ -(function (module) { +(function () { 'use strict'; @@ -18,4 +18,4 @@ module.exports = KnoinAbstractBoot; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Knoin/KnoinAbstractScreen.js b/dev/Knoin/KnoinAbstractScreen.js index 060762b07..f4e6ef515 100644 --- a/dev/Knoin/KnoinAbstractScreen.js +++ b/dev/Knoin/KnoinAbstractScreen.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,7 +7,7 @@ _ = require('_'), crossroads = require('crossroads'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -88,4 +88,4 @@ module.exports = KnoinAbstractScreen; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Knoin/KnoinAbstractViewModel.js b/dev/Knoin/KnoinAbstractViewModel.js index c2067a132..e06e4ca23 100644 --- a/dev/Knoin/KnoinAbstractViewModel.js +++ b/dev/Knoin/KnoinAbstractViewModel.js @@ -1,14 +1,14 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - Globals = require('Globals') + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + Globals = require('Common/Globals') ; /** @@ -127,4 +127,4 @@ module.exports = KnoinAbstractViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/AccountModel.js b/dev/Models/AccountModel.js index d1fb95fc9..9f7aba2f4 100644 --- a/dev/Models/AccountModel.js +++ b/dev/Models/AccountModel.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -33,9 +33,9 @@ */ AccountModel.prototype.changeAccountLink = function () { - return require('LinkBuilder').change(this.email); + return require('Common/LinkBuilder').change(this.email); }; module.exports = AccountModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/AttachmentModel.js b/dev/Models/AttachmentModel.js index 3859c5546..adf42549d 100644 --- a/dev/Models/AttachmentModel.js +++ b/dev/Models/AttachmentModel.js @@ -1,14 +1,14 @@ -(function (module, require) { +(function () { 'use strict'; var window = require('window'), - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder') + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder') ; /** @@ -249,4 +249,4 @@ module.exports = AttachmentModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/ComposeAttachmentModel.js b/dev/Models/ComposeAttachmentModel.js index 0365f083c..346f67413 100644 --- a/dev/Models/ComposeAttachmentModel.js +++ b/dev/Models/ComposeAttachmentModel.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -73,4 +73,4 @@ module.exports = ComposeAttachmentModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/ContactModel.js b/dev/Models/ContactModel.js index 660aa7d66..bf79f5ac3 100644 --- a/dev/Models/ContactModel.js +++ b/dev/Models/ContactModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,9 +7,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder') + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder') ; /** @@ -138,4 +138,4 @@ module.exports = ContactModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/ContactPropertyModel.js b/dev/Models/ContactPropertyModel.js index 283704310..d7f55ed19 100644 --- a/dev/Models/ContactPropertyModel.js +++ b/dev/Models/ContactPropertyModel.js @@ -1,13 +1,13 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils') + Enums = require('Common/Enums'), + Utils = require('Common/Utils') ; /** @@ -39,4 +39,4 @@ module.exports = ContactPropertyModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/ContactTagModel.js b/dev/Models/ContactTagModel.js index 94ecc3189..0531b1b78 100644 --- a/dev/Models/ContactTagModel.js +++ b/dev/Models/ContactTagModel.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -55,4 +55,4 @@ module.exports = ContactTagModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/EmailModel.js b/dev/Models/EmailModel.js index 457012836..bb26edb39 100644 --- a/dev/Models/EmailModel.js +++ b/dev/Models/EmailModel.js @@ -1,10 +1,10 @@ -(function (module, require) { +(function () { 'use strict'; var - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -345,4 +345,4 @@ module.exports = EmailModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/FilterConditionModel.js b/dev/Models/FilterConditionModel.js index 8b67f4b7e..7bde5f94a 100644 --- a/dev/Models/FilterConditionModel.js +++ b/dev/Models/FilterConditionModel.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Enums = require('Enums') + Enums = require('Common/Enums') ; /** @@ -59,4 +59,4 @@ module.exports = FilterConditionModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/FilterModel.js b/dev/Models/FilterModel.js index 9d236ab01..54f0a26b0 100644 --- a/dev/Models/FilterModel.js +++ b/dev/Models/FilterModel.js @@ -1,13 +1,13 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), FilterConditionModel = require('Model:FilterCondition') ; @@ -91,4 +91,4 @@ module.exports = FilterModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/FolderModel.js b/dev/Models/FolderModel.js index 5913aca71..f5794ffa7 100644 --- a/dev/Models/FolderModel.js +++ b/dev/Models/FolderModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,10 +7,10 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - Events = require('Events') + Enums = require('Common/Enums'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + Events = require('Common/Events') ; /** @@ -350,4 +350,4 @@ module.exports = FolderModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/IdentityModel.js b/dev/Models/IdentityModel.js index e248f5f31..0a8f512a1 100644 --- a/dev/Models/IdentityModel.js +++ b/dev/Models/IdentityModel.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -47,4 +47,4 @@ module.exports = IdentityModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/MessageModel.js b/dev/Models/MessageModel.js index 5c4c1ef11..33a380f90 100644 --- a/dev/Models/MessageModel.js +++ b/dev/Models/MessageModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -10,10 +10,10 @@ ko = require('ko'), moment = require('moment'), - Enums = require('Enums'), - Utils = require('Utils'), - Globals = require('Globals'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + Globals = require('Common/Globals'), + LinkBuilder = require('Common/LinkBuilder'), EmailModel = require('Model:Email'), AttachmentModel = require('Model:Attachment') @@ -1291,4 +1291,4 @@ module.exports = MessageModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Models/OpenPgpKeyModel.js b/dev/Models/OpenPgpKeyModel.js index 1d5b54919..d2b0abfc2 100644 --- a/dev/Models/OpenPgpKeyModel.js +++ b/dev/Models/OpenPgpKeyModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -40,4 +40,4 @@ module.exports = OpenPgpKeyModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Screens/AboutScreen.js b/dev/Screens/AboutScreen.js index 3464768c3..daa60d213 100644 --- a/dev/Screens/AboutScreen.js +++ b/dev/Screens/AboutScreen.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -29,4 +29,4 @@ module.exports = AboutScreen; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Screens/AbstractSettingsScreen.js b/dev/Screens/AbstractSettingsScreen.js index 4da910aa5..ee99b7af7 100644 --- a/dev/Screens/AbstractSettingsScreen.js +++ b/dev/Screens/AbstractSettingsScreen.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,9 +8,9 @@ $ = require('$'), ko = require('ko'), - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), kn = require('App:Knoin'), KnoinAbstractScreen = require('Knoin:AbstractScreen') @@ -29,10 +29,23 @@ this.oCurrentSubScreen = null; this.oViewModelPlace = null; + + this.setupSettings(); } _.extend(AbstractSettingsScreen.prototype, KnoinAbstractScreen.prototype); + /** + * @param {Function=} fCallback + */ + AbstractSettingsScreen.prototype.setupSettings = function (fCallback) + { + if (fCallback) + { + fCallback(); + } + }; + AbstractSettingsScreen.prototype.onRoute = function (sSubName) { var @@ -196,4 +209,4 @@ module.exports = AbstractSettingsScreen; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Screens/AdminLoginScreen.js b/dev/Screens/AdminLoginScreen.js index cabd9502c..da90a2001 100644 --- a/dev/Screens/AdminLoginScreen.js +++ b/dev/Screens/AdminLoginScreen.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -29,4 +29,4 @@ module.exports = AdminLoginScreen; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Screens/AdminSettingsScreen.js b/dev/Screens/AdminSettingsScreen.js index 751220820..c653f99f0 100644 --- a/dev/Screens/AdminSettingsScreen.js +++ b/dev/Screens/AdminSettingsScreen.js @@ -1,11 +1,13 @@ -(function (module, require) { +(function () { 'use strict'; var _ = require('_'), + kn = require('App:Knoin'), + AbstractSettings = require('Screen:AbstractSettings') ; @@ -23,6 +25,50 @@ _.extend(AdminSettingsScreen.prototype, AbstractSettings.prototype); + /** + * @param {Function=} fCallback + */ + AdminSettingsScreen.prototype.setupSettings = function (fCallback) + { + kn.addSettingsViewModel(require('Settings:Admin:General'), + 'AdminSettingsGeneral', 'General', 'general', true); + + kn.addSettingsViewModel(require('Settings:Admin:Login'), + 'AdminSettingsLogin', 'Login', 'login'); + + kn.addSettingsViewModel(require('Settings:Admin:Branding'), + 'AdminSettingsBranding', 'Branding', 'branding'); + + kn.addSettingsViewModel(require('Settings:Admin:Contacts'), + 'AdminSettingsContacts', 'Contacts', 'contacts'); + + kn.addSettingsViewModel(require('Settings:Admin:Domains'), + 'AdminSettingsDomains', 'Domains', 'domains'); + + kn.addSettingsViewModel(require('Settings:Admin:Security'), + 'AdminSettingsSecurity', 'Security', 'security'); + + kn.addSettingsViewModel(require('Settings:Admin:Social'), + 'AdminSettingsSocial', 'Social', 'social'); + + kn.addSettingsViewModel(require('Settings:Admin:Plugins'), + 'AdminSettingsPlugins', 'Plugins', 'plugins'); + + kn.addSettingsViewModel(require('Settings:Admin:Packages'), + 'AdminSettingsPackages', 'Packages', 'packages'); + + kn.addSettingsViewModel(require('Settings:Admin:Licensing'), + 'AdminSettingsLicensing', 'Licensing', 'licensing'); + + kn.addSettingsViewModel(require('Settings:Admin:About'), + 'AdminSettingsAbout', 'About', 'about'); + + if (fCallback) + { + fCallback(); + } + }; + AdminSettingsScreen.prototype.onShow = function () { require('App:Admin').setTitle(''); @@ -30,4 +76,4 @@ module.exports = AdminSettingsScreen; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Screens/LoginScreen.js b/dev/Screens/LoginScreen.js index 5a61daea2..f809ebf45 100644 --- a/dev/Screens/LoginScreen.js +++ b/dev/Screens/LoginScreen.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -29,4 +29,4 @@ module.exports = LoginScreen; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Screens/MailBoxScreen.js b/dev/Screens/MailBoxScreen.js index c6391634b..15bb8c041 100644 --- a/dev/Screens/MailBoxScreen.js +++ b/dev/Screens/MailBoxScreen.js @@ -1,15 +1,15 @@ -(function (module, require) { +(function () { 'use strict'; var _ = require('_'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - Events = require('Events'), + Enums = require('Common/Enums'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + Events = require('Common/Events'), KnoinAbstractScreen = require('Knoin:AbstractScreen'), @@ -193,4 +193,4 @@ module.exports = MailBoxScreen; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Screens/SettingsScreen.js b/dev/Screens/SettingsScreen.js index d3c6ddd64..20dbec296 100644 --- a/dev/Screens/SettingsScreen.js +++ b/dev/Screens/SettingsScreen.js @@ -1,14 +1,18 @@ -(function (module, require) { +(function () { 'use strict'; var _ = require('_'), - Enums = require('Enums'), - Utils = require('Utils'), - Globals = require('Globals'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + Globals = require('Common/Globals'), + + Settings = require('Storage:Settings'), + + kn = require('App:Knoin'), AbstractSettingsScreen = require('Screen:AbstractSettings') ; @@ -34,6 +38,84 @@ _.extend(SettingsScreen.prototype, AbstractSettingsScreen.prototype); + /** + * @param {Function=} fCallback + */ + SettingsScreen.prototype.setupSettings = function (fCallback) + { + kn.addSettingsViewModel(require('Settings:RainLoop:General'), + 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true); + + if (Settings.settingsGet('ContactsIsAllowed')) + { + kn.addSettingsViewModel(require('Settings:RainLoop:Contacts'), + 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts'); + } + + if (Settings.capa(Enums.Capa.AdditionalAccounts)) + { + kn.addSettingsViewModel(require('Settings:RainLoop:Accounts'), + 'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts'); + } + + if (Settings.capa(Enums.Capa.AdditionalIdentities)) + { + kn.addSettingsViewModel(require('Settings:RainLoop:Identities'), + 'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities'); + } + else + { + kn.addSettingsViewModel(require('Settings:RainLoop:Identity'), + 'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity'); + } + + if (Settings.capa(Enums.Capa.Filters)) + { + kn.addSettingsViewModel(require('Settings:RainLoop:Filters'), + 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters'); + } + + if (Settings.capa(Enums.Capa.TwoFactor)) + { + kn.addSettingsViewModel(require('Settings:RainLoop:Security'), + 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security'); + } + + if (Settings.settingsGet('AllowGoogleSocial') || + Settings.settingsGet('AllowFacebookSocial') || + Settings.settingsGet('AllowTwitterSocial')) + { + kn.addSettingsViewModel(require('Settings:RainLoop:Social'), + 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social'); + } + + if (Settings.settingsGet('ChangePasswordIsAllowed')) + { + kn.addSettingsViewModel(require('Settings:RainLoop:ChangePassword'), + 'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password'); + } + + kn.addSettingsViewModel(require('Settings:RainLoop:Folders'), + 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders'); + + if (Settings.capa(Enums.Capa.Themes)) + { + kn.addSettingsViewModel(require('Settings:RainLoop:Themes'), + 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes'); + } + + if (Settings.capa(Enums.Capa.OpenPGP)) + { + kn.addSettingsViewModel(require('Settings:RainLoop:OpenPGP'), + 'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp'); + } + + if (fCallback) + { + fCallback(); + } + }; + SettingsScreen.prototype.onShow = function () { this.setSettingsTitle(); @@ -47,4 +129,4 @@ module.exports = SettingsScreen; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsAbout.js b/dev/Settings/Admin/AdminSettingsAbout.js index 5fb3b61bd..92e3253c7 100644 --- a/dev/Settings/Admin/AdminSettingsAbout.js +++ b/dev/Settings/Admin/AdminSettingsAbout.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -85,4 +85,4 @@ module.exports = AdminSettingsAbout; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsBranding.js b/dev/Settings/Admin/AdminSettingsBranding.js index 2986c7ed7..8f9c6c9e7 100644 --- a/dev/Settings/Admin/AdminSettingsBranding.js +++ b/dev/Settings/Admin/AdminSettingsBranding.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,7 +7,7 @@ _ = require('_'), ko = require('ko'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -16,7 +16,7 @@ function AdminSettingsBranding() { var - Enums = require('Enums'), + Enums = require('Common/Enums'), Settings = require('Storage:Settings') ; @@ -88,4 +88,4 @@ module.exports = AdminSettingsBranding; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsContacts.js b/dev/Settings/Admin/AdminSettingsContacts.js index 9c5673108..d0c25e2c8 100644 --- a/dev/Settings/Admin/AdminSettingsContacts.js +++ b/dev/Settings/Admin/AdminSettingsContacts.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Settings = require('Storage:Settings') ; @@ -239,4 +239,4 @@ module.exports = AdminSettingsContacts; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsDomains.js b/dev/Settings/Admin/AdminSettingsDomains.js index 9f0b83bb8..b14fa0330 100644 --- a/dev/Settings/Admin/AdminSettingsDomains.js +++ b/dev/Settings/Admin/AdminSettingsDomains.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,7 +8,7 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), + Enums = require('Common/Enums'), PopupsDomainViewModel = require('View:Popup:Domain'), @@ -103,4 +103,4 @@ module.exports = AdminSettingsDomains; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsGeneral.js b/dev/Settings/Admin/AdminSettingsGeneral.js index 6f68d79f4..b287f371e 100644 --- a/dev/Settings/Admin/AdminSettingsGeneral.js +++ b/dev/Settings/Admin/AdminSettingsGeneral.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,9 +7,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings'), Data = require('Storage:Admin:Data') @@ -142,4 +142,4 @@ module.exports = AdminSettingsGeneral; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsLicensing.js b/dev/Settings/Admin/AdminSettingsLicensing.js index 3cb89caa4..c17781c78 100644 --- a/dev/Settings/Admin/AdminSettingsLicensing.js +++ b/dev/Settings/Admin/AdminSettingsLicensing.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -67,4 +67,4 @@ module.exports = AdminSettingsLicensing; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsLogin.js b/dev/Settings/Admin/AdminSettingsLogin.js index 45e6545d6..801b7694e 100644 --- a/dev/Settings/Admin/AdminSettingsLogin.js +++ b/dev/Settings/Admin/AdminSettingsLogin.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Settings = require('Storage:Settings'), Data = require('Storage:Admin:Data') @@ -68,4 +68,4 @@ module.exports = AdminSettingsLogin; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsPackages.js b/dev/Settings/Admin/AdminSettingsPackages.js index 1b066f57b..22a60fc15 100644 --- a/dev/Settings/Admin/AdminSettingsPackages.js +++ b/dev/Settings/Admin/AdminSettingsPackages.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ window = require('window'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Data = require('Storage:Admin:Data'), Remote = require('Storage:Admin:Remote') @@ -110,4 +110,4 @@ module.exports = AdminSettingsPackages; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsPlugins.js b/dev/Settings/Admin/AdminSettingsPlugins.js index 1c00a8507..8471c21d7 100644 --- a/dev/Settings/Admin/AdminSettingsPlugins.js +++ b/dev/Settings/Admin/AdminSettingsPlugins.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Settings = require('Storage:Settings'), Data = require('Storage:Admin:Data'), @@ -110,4 +110,4 @@ module.exports = AdminSettingsPlugins; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/Admin/AdminSettingsSecurity.js b/dev/Settings/Admin/AdminSettingsSecurity.js index d4af8eb03..1e882f306 100644 --- a/dev/Settings/Admin/AdminSettingsSecurity.js +++ b/dev/Settings/Admin/AdminSettingsSecurity.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,9 +7,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings'), Data = require('Storage:Admin:Data'), @@ -133,4 +133,4 @@ module.exports = AdminSettingsSecurity; -}(module, require)); +}()); diff --git a/dev/Settings/Admin/AdminSettingsSocial.js b/dev/Settings/Admin/AdminSettingsSocial.js index 304a87c70..7924727df 100644 --- a/dev/Settings/Admin/AdminSettingsSocial.js +++ b/dev/Settings/Admin/AdminSettingsSocial.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils') + Enums = require('Common/Enums'), + Utils = require('Common/Utils') ; /** @@ -150,4 +150,4 @@ module.exports = AdminSettingsSocial; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsAccounts.js b/dev/Settings/App/SettingsAccounts.js index 3903814e7..50ff86c05 100644 --- a/dev/Settings/App/SettingsAccounts.js +++ b/dev/Settings/App/SettingsAccounts.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,9 +8,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Data = require('Storage:RainLoop:Data'), Remote = require('Storage:RainLoop:Remote') @@ -96,4 +96,4 @@ module.exports = SettingsAccounts; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsChangePassword.js b/dev/Settings/App/SettingsChangePassword.js index 742657bfc..c11c67353 100644 --- a/dev/Settings/App/SettingsChangePassword.js +++ b/dev/Settings/App/SettingsChangePassword.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Remote = require('Storage:RainLoop:Remote') ; @@ -118,4 +118,4 @@ module.exports = SettingsChangePassword; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsContacts.js b/dev/Settings/App/SettingsContacts.js index 535682357..d0993a438 100644 --- a/dev/Settings/App/SettingsContacts.js +++ b/dev/Settings/App/SettingsContacts.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Utils = require('Utils'), + Utils = require('Common/Utils'), Remote = require('Storage:RainLoop:Remote'), Data = require('Storage:RainLoop:Data') @@ -55,4 +55,4 @@ module.exports = SettingsContacts; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsFilters.js b/dev/Settings/App/SettingsFilters.js index c8eeed848..244d3666c 100644 --- a/dev/Settings/App/SettingsFilters.js +++ b/dev/Settings/App/SettingsFilters.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -39,4 +39,4 @@ module.exports = SettingsFilters; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsFolders.js b/dev/Settings/App/SettingsFolders.js index e47fa1caf..d505428ec 100644 --- a/dev/Settings/App/SettingsFolders.js +++ b/dev/Settings/App/SettingsFolders.js @@ -1,13 +1,13 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Settings = require('Storage:Settings'), Data = require('Storage:RainLoop:Data'), @@ -211,4 +211,4 @@ module.exports = SettingsFolders; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsGeneral.js b/dev/Settings/App/SettingsGeneral.js index 9aea8ffea..74a6b7ca7 100644 --- a/dev/Settings/App/SettingsGeneral.js +++ b/dev/Settings/App/SettingsGeneral.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,11 +8,11 @@ $ = require('$'), ko = require('ko'), - Enums = require('Enums'), - Consts = require('Consts'), - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Data = require('Storage:RainLoop:Data'), Remote = require('Storage:RainLoop:Remote') @@ -175,4 +175,4 @@ module.exports = SettingsGeneral; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsIdentities.js b/dev/Settings/App/SettingsIdentities.js index 8a824d2bd..d3b1f9edf 100644 --- a/dev/Settings/App/SettingsIdentities.js +++ b/dev/Settings/App/SettingsIdentities.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,9 +7,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - HtmlEditor = require('HtmlEditor'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + HtmlEditor = require('Common/HtmlEditor'), Data = require('Storage:RainLoop:Data'), Remote = require('Storage:RainLoop:Remote') @@ -230,4 +230,4 @@ module.exports = SettingsIdentities; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsIdentity.js b/dev/Settings/App/SettingsIdentity.js index 47c3f29c2..8c0e1e64e 100644 --- a/dev/Settings/App/SettingsIdentity.js +++ b/dev/Settings/App/SettingsIdentity.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,9 +7,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - HtmlEditor = require('HtmlEditor'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + HtmlEditor = require('Common/HtmlEditor'), Data = require('Storage:RainLoop:Data'), Remote = require('Storage:RainLoop:Remote') @@ -100,4 +100,4 @@ module.exports = SettingsIdentity; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsOpenPGP.js b/dev/Settings/App/SettingsOpenPGP.js index 8d0e85a7a..3ca65d6ed 100644 --- a/dev/Settings/App/SettingsOpenPGP.js +++ b/dev/Settings/App/SettingsOpenPGP.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -80,4 +80,4 @@ module.exports = SettingsOpenPGP; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsSecurity.js b/dev/Settings/App/SettingsSecurity.js index 119050493..18f576e8f 100644 --- a/dev/Settings/App/SettingsSecurity.js +++ b/dev/Settings/App/SettingsSecurity.js @@ -1,14 +1,14 @@ -(function (module, require) { +(function () { 'use strict'; var ko = require('ko'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), Remote = require('Storage:RainLoop:Remote') ; @@ -163,4 +163,4 @@ module.exports = SettingsSecurity; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsSocial.js b/dev/Settings/App/SettingsSocial.js index 34ca6018d..1f753d2a5 100644 --- a/dev/Settings/App/SettingsSocial.js +++ b/dev/Settings/App/SettingsSocial.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -9,7 +9,7 @@ function SettingsSocial() { var - Utils = require('Utils'), + Utils = require('Common/Utils'), Data = require('Storage:RainLoop:Data') ; @@ -73,4 +73,4 @@ module.exports = SettingsSocial; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Settings/App/SettingsThemes.js b/dev/Settings/App/SettingsThemes.js index 8cb5dc07d..bb10a685a 100644 --- a/dev/Settings/App/SettingsThemes.js +++ b/dev/Settings/App/SettingsThemes.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -9,9 +9,9 @@ $ = require('$'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Data = require('Storage:RainLoop:Data'), Remote = require('Storage:RainLoop:Remote') @@ -129,4 +129,4 @@ module.exports = SettingsThemes; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/AbstractData.js b/dev/Storages/AbstractData.js index 8ed4fd3f6..84b2021a9 100644 --- a/dev/Storages/AbstractData.js +++ b/dev/Storages/AbstractData.js @@ -1,12 +1,12 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; var - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Settings = require('Storage:Settings') ; @@ -90,4 +90,4 @@ module.exports = AbstractData; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/AbstractRemoteStorage.js b/dev/Storages/AbstractRemoteStorage.js index 87d6b0662..356ba6d33 100644 --- a/dev/Storages/AbstractRemoteStorage.js +++ b/dev/Storages/AbstractRemoteStorage.js @@ -1,6 +1,6 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; @@ -9,12 +9,12 @@ _ = require('_'), $ = require('$'), - Consts = require('Consts'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - Plugins = require('Plugins'), - LinkBuilder = require('LinkBuilder'), + Consts = require('Common/Consts'), + Enums = require('Common/Enums'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + Plugins = require('Common/Plugins'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings') ; @@ -309,4 +309,4 @@ module.exports = AbstractRemoteStorage; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/AdminDataStorage.js b/dev/Storages/AdminDataStorage.js index f5687482d..eb3d4602d 100644 --- a/dev/Storages/AdminDataStorage.js +++ b/dev/Storages/AdminDataStorage.js @@ -1,6 +1,6 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; @@ -65,4 +65,4 @@ module.exports = new AdminDataStorage(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/AdminRemoteStorage.js b/dev/Storages/AdminRemoteStorage.js index e912a05ed..7851551a9 100644 --- a/dev/Storages/AdminRemoteStorage.js +++ b/dev/Storages/AdminRemoteStorage.js @@ -1,6 +1,6 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; @@ -273,4 +273,4 @@ module.exports = new AdminRemoteStorage(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/CacheStorage.js b/dev/Storages/CacheStorage.js index 3f040850d..0f52a618f 100644 --- a/dev/Storages/CacheStorage.js +++ b/dev/Storages/CacheStorage.js @@ -1,15 +1,15 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; var _ = require('_'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings') ; @@ -346,4 +346,4 @@ module.exports = new CacheStorage(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/DataStorage.js b/dev/Storages/DataStorage.js index 1696c5485..8e5947c78 100644 --- a/dev/Storages/DataStorage.js +++ b/dev/Storages/DataStorage.js @@ -1,6 +1,6 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; @@ -11,11 +11,11 @@ ko = require('ko'), moment = require('moment'), - Consts = require('Consts'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Consts = require('Common/Consts'), + Enums = require('Common/Enums'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings'), Cache = require('Storage:RainLoop:Cache'), @@ -1061,4 +1061,4 @@ module.exports = new DataStorage(); -}(module, require)); +}()); diff --git a/dev/Storages/LocalStorage.js b/dev/Storages/LocalStorage.js index a6b55584d..8ac649ba4 100644 --- a/dev/Storages/LocalStorage.js +++ b/dev/Storages/LocalStorage.js @@ -1,6 +1,6 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; @@ -52,4 +52,4 @@ module.exports = new LocalStorage(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/LocalStorages/CookieDriver.js b/dev/Storages/LocalStorages/CookieDriver.js index 2d2dbc251..5f544245b 100644 --- a/dev/Storages/LocalStorages/CookieDriver.js +++ b/dev/Storages/LocalStorages/CookieDriver.js @@ -1,6 +1,6 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; @@ -8,8 +8,8 @@ $ = require('$'), JSON = require('JSON'), - Consts = require('Consts'), - Utils = require('Utils') + Consts = require('Common/Consts'), + Utils = require('Common/Utils') ; /** @@ -97,4 +97,4 @@ module.exports = CookieDriver; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/LocalStorages/LocalStorageDriver.js b/dev/Storages/LocalStorages/LocalStorageDriver.js index e72aaf6d1..d91217ce3 100644 --- a/dev/Storages/LocalStorages/LocalStorageDriver.js +++ b/dev/Storages/LocalStorages/LocalStorageDriver.js @@ -1,6 +1,6 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; @@ -8,8 +8,8 @@ window = require('window'), JSON = require('JSON'), - Consts = require('Consts'), - Utils = require('Utils') + Consts = require('Common/Consts'), + Utils = require('Common/Utils') ; /** @@ -95,4 +95,4 @@ module.exports = LocalStorageDriver; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/RemoteStorage.js b/dev/Storages/RemoteStorage.js index aeff1053d..d8b587667 100644 --- a/dev/Storages/RemoteStorage.js +++ b/dev/Storages/RemoteStorage.js @@ -1,16 +1,16 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { - +(function () { + 'use strict'; var _ = require('_'), - Utils = require('Utils'), - Consts = require('Consts'), - Globals = require('Globals'), - Base64 = require('Base64'), + Utils = require('Common/Utils'), + Consts = require('Common/Consts'), + Globals = require('Common/Globals'), + Base64 = require('Common/Base64'), Settings = require('Storage:Settings'), Cache = require('Storage:RainLoop:Cache'), @@ -811,4 +811,4 @@ module.exports = new RemoteStorage(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/Storages/SettingsStorage.js b/dev/Storages/SettingsStorage.js index 4f224de9b..9497d3657 100644 --- a/dev/Storages/SettingsStorage.js +++ b/dev/Storages/SettingsStorage.js @@ -1,13 +1,13 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function (module, require) { +(function () { 'use strict'; var window = require('window'), - Utils = require('Utils') + Utils = require('Common/Utils') ; /** @@ -52,4 +52,4 @@ module.exports = new SettingsStorage(); -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/AboutViewModel.js b/dev/ViewModels/AboutViewModel.js index 8d2d57d7d..52eea8a1a 100644 --- a/dev/ViewModels/AboutViewModel.js +++ b/dev/ViewModels/AboutViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -31,4 +31,4 @@ module.exports = AboutViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/AbstractSystemDropDownViewModel.js b/dev/ViewModels/AbstractSystemDropDownViewModel.js index 41a48c352..9bc69a438 100644 --- a/dev/ViewModels/AbstractSystemDropDownViewModel.js +++ b/dev/ViewModels/AbstractSystemDropDownViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -9,9 +9,9 @@ ko = require('ko'), key = require('key'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings'), Data = require('Storage:RainLoop:Data'), @@ -117,4 +117,4 @@ module.exports = AbstractSystemDropDownViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/AdminLoginViewModel.js b/dev/ViewModels/AdminLoginViewModel.js index 174a72449..9d4791a29 100644 --- a/dev/ViewModels/AdminLoginViewModel.js +++ b/dev/ViewModels/AdminLoginViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Remote = require('Storage:Admin:Remote'), @@ -118,4 +118,4 @@ module.exports = AdminLoginViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/AdminSettingsMenuViewModel.js b/dev/ViewModels/AdminSettingsMenuViewModel.js index 8a3435d27..59a4ba430 100644 --- a/dev/ViewModels/AdminSettingsMenuViewModel.js +++ b/dev/ViewModels/AdminSettingsMenuViewModel.js @@ -1,12 +1,12 @@ -(function (module, require) { +(function () { 'use strict'; var _ = require('_'), - Globals = require('Globals'), + Globals = require('Common/Globals'), kn = require('App:Knoin'), KnoinAbstractViewModel = require('Knoin:AbstractViewModel') @@ -39,4 +39,4 @@ module.exports = AdminSettingsMenuViewModel; -}(module, require)); +}()); diff --git a/dev/ViewModels/AdminSettingsPaneViewModel.js b/dev/ViewModels/AdminSettingsPaneViewModel.js index 0c7cbb9fb..7dc933a61 100644 --- a/dev/ViewModels/AdminSettingsPaneViewModel.js +++ b/dev/ViewModels/AdminSettingsPaneViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -43,4 +43,4 @@ module.exports = AdminSettingsPaneViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/LoginViewModel.js b/dev/ViewModels/LoginViewModel.js index 707481e5f..b9330a60d 100644 --- a/dev/ViewModels/LoginViewModel.js +++ b/dev/ViewModels/LoginViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -9,9 +9,9 @@ $ = require('$'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings'), Data = require('Storage:RainLoop:Data'), @@ -367,4 +367,4 @@ module.exports = LoginViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/MailBoxFolderListViewModel.js b/dev/ViewModels/MailBoxFolderListViewModel.js index 8e04428f3..215587556 100644 --- a/dev/ViewModels/MailBoxFolderListViewModel.js +++ b/dev/ViewModels/MailBoxFolderListViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -10,10 +10,10 @@ ko = require('ko'), key = require('key'), - Utils = require('Utils'), - Enums = require('Enums'), - Globals = require('Globals'), - LinkBuilder = require('LinkBuilder'), + Utils = require('Common/Utils'), + Enums = require('Common/Enums'), + Globals = require('Common/Globals'), + LinkBuilder = require('Common/LinkBuilder'), Settings = require('Storage:Settings'), Cache = require('Storage:RainLoop:Cache'), @@ -271,4 +271,4 @@ module.exports = MailBoxFolderListViewModel; -}(module, require)); +}()); diff --git a/dev/ViewModels/MailBoxMessageListViewModel.js b/dev/ViewModels/MailBoxMessageListViewModel.js index 1c5c318bc..53d974f9c 100644 --- a/dev/ViewModels/MailBoxMessageListViewModel.js +++ b/dev/ViewModels/MailBoxMessageListViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -11,13 +11,13 @@ Jua = require('Jua'), ifvisible = require('ifvisible'), - Enums = require('Enums'), - Consts = require('Consts'), - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - Events = require('Events'), - Selector = require('Selector'), + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + LinkBuilder = require('Common/LinkBuilder'), + Events = require('Common/Events'), + Selector = require('Common/Selector'), Settings = require('Storage:Settings'), Cache = require('Storage:RainLoop:Cache'), @@ -932,4 +932,4 @@ module.exports = MailBoxMessageListViewModel; -}(module, require)); +}()); diff --git a/dev/ViewModels/MailBoxMessageViewViewModel.js b/dev/ViewModels/MailBoxMessageViewViewModel.js index 6d70588ef..c91d7ade2 100644 --- a/dev/ViewModels/MailBoxMessageViewViewModel.js +++ b/dev/ViewModels/MailBoxMessageViewViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -9,11 +9,11 @@ ko = require('ko'), key = require('key'), - Consts = require('Consts'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - Events = require('Events'), + Consts = require('Common/Consts'), + Enums = require('Common/Enums'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + Events = require('Common/Events'), Cache = require('Storage:RainLoop:Cache'), Data = require('Storage:RainLoop:Data'), @@ -719,4 +719,4 @@ module.exports = MailBoxMessageViewViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/MailBoxSystemDropDownViewModel.js b/dev/ViewModels/MailBoxSystemDropDownViewModel.js index ab3d09de0..09d715b7e 100644 --- a/dev/ViewModels/MailBoxSystemDropDownViewModel.js +++ b/dev/ViewModels/MailBoxSystemDropDownViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -25,4 +25,4 @@ module.exports = MailBoxSystemDropDownViewModel; -}(module, require)); +}()); diff --git a/dev/ViewModels/Popups/PopupsActivateViewModel.js b/dev/ViewModels/Popups/PopupsActivateViewModel.js index 76d24d69c..6c9f3afb7 100644 --- a/dev/ViewModels/Popups/PopupsActivateViewModel.js +++ b/dev/ViewModels/Popups/PopupsActivateViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Settings = require('Storage:Settings'), Data = require('Storage:Admin:Data'), @@ -138,4 +138,4 @@ module.exports = PopupsActivateViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsAddAccountViewModel.js b/dev/ViewModels/Popups/PopupsAddAccountViewModel.js index 930ef39e3..94c035783 100644 --- a/dev/ViewModels/Popups/PopupsAddAccountViewModel.js +++ b/dev/ViewModels/Popups/PopupsAddAccountViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Remote = require('Storage:RainLoop:Remote'), @@ -113,4 +113,4 @@ module.exports = PopupsAddAccountViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js b/dev/ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js index 4f7b87760..d8ef0344a 100644 --- a/dev/ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js +++ b/dev/ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,7 +7,7 @@ _ = require('_'), ko = require('ko'), - Utils = require('Utils'), + Utils = require('Common/Utils'), Data = require('Storage:RainLoop:Data'), @@ -107,4 +107,4 @@ module.exports = PopupsAddOpenPgpKeyViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsAdvancedSearchViewModel.js b/dev/ViewModels/Popups/PopupsAdvancedSearchViewModel.js index fcac81fdf..df6aabdcb 100644 --- a/dev/ViewModels/Popups/PopupsAdvancedSearchViewModel.js +++ b/dev/ViewModels/Popups/PopupsAdvancedSearchViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,7 +8,7 @@ ko = require('ko'), moment = require('moment'), - Utils = require('Utils'), + Utils = require('Common/Utils'), Data = require('Storage:RainLoop:Data'), @@ -155,4 +155,4 @@ module.exports = PopupsAdvancedSearchViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsAskViewModel.js b/dev/ViewModels/Popups/PopupsAskViewModel.js index 1a6134522..166bb48af 100644 --- a/dev/ViewModels/Popups/PopupsAskViewModel.js +++ b/dev/ViewModels/Popups/PopupsAskViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,8 +8,8 @@ ko = require('ko'), key = require('key'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), kn = require('App:Knoin'), KnoinAbstractViewModel = require('Knoin:AbstractViewModel') @@ -128,4 +128,4 @@ module.exports = PopupsAskViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsComposeOpenPgpViewModel.js b/dev/ViewModels/Popups/PopupsComposeOpenPgpViewModel.js index 4b3bdc3aa..2e7d531f9 100644 --- a/dev/ViewModels/Popups/PopupsComposeOpenPgpViewModel.js +++ b/dev/ViewModels/Popups/PopupsComposeOpenPgpViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -9,8 +9,8 @@ ko = require('ko'), key = require('key'), - Utils = require('Utils'), - Enums = require('Enums'), + Utils = require('Common/Utils'), + Enums = require('Common/Enums'), Data = require('Storage:RainLoop:Data'), @@ -262,4 +262,4 @@ module.exports = PopupsComposeOpenPgpViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsComposeViewModel.js b/dev/ViewModels/Popups/PopupsComposeViewModel.js index f8e8d5c29..df419f739 100644 --- a/dev/ViewModels/Popups/PopupsComposeViewModel.js +++ b/dev/ViewModels/Popups/PopupsComposeViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -12,13 +12,13 @@ JSON = require('JSON'), Jua = require('Jua'), - Enums = require('Enums'), - Consts = require('Consts'), - Utils = require('Utils'), - Globals = require('Globals'), - Events = require('Events'), - LinkBuilder = require('LinkBuilder'), - HtmlEditor = require('HtmlEditor'), + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + Utils = require('Common/Utils'), + Globals = require('Common/Globals'), + Events = require('Common/Events'), + LinkBuilder = require('Common/LinkBuilder'), + HtmlEditor = require('Common/HtmlEditor'), Settings = require('Storage:Settings'), Data = require('Storage:RainLoop:Data'), @@ -1787,4 +1787,4 @@ module.exports = PopupsComposeViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsContactsViewModel.js b/dev/ViewModels/Popups/PopupsContactsViewModel.js index 415fd0c09..1af7befeb 100644 --- a/dev/ViewModels/Popups/PopupsContactsViewModel.js +++ b/dev/ViewModels/Popups/PopupsContactsViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -10,12 +10,12 @@ ko = require('ko'), key = require('key'), - Enums = require('Enums'), - Consts = require('Consts'), - Globals = require('Globals'), - Utils = require('Utils'), - Selector = require('Selector'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + Globals = require('Common/Globals'), + Utils = require('Common/Utils'), + Selector = require('Common/Selector'), + LinkBuilder = require('Common/LinkBuilder'), Data = require('Storage:RainLoop:Data'), Remote = require('Storage:RainLoop:Remote'), @@ -778,4 +778,4 @@ module.exports = PopupsContactsViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsDomainViewModel.js b/dev/ViewModels/Popups/PopupsDomainViewModel.js index 89bfae193..19713affb 100644 --- a/dev/ViewModels/Popups/PopupsDomainViewModel.js +++ b/dev/ViewModels/Popups/PopupsDomainViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,9 +7,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Consts = require('Consts'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + Utils = require('Common/Utils'), Remote = require('Storage:Admin:Remote'), @@ -315,4 +315,4 @@ module.exports = PopupsDomainViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsFilterViewModel.js b/dev/ViewModels/Popups/PopupsFilterViewModel.js index 63921bcd7..999ecac69 100644 --- a/dev/ViewModels/Popups/PopupsFilterViewModel.js +++ b/dev/ViewModels/Popups/PopupsFilterViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Consts = require('Consts'), - Utils = require('Utils'), + Consts = require('Common/Consts'), + Utils = require('Common/Utils'), Data = require('Storage:RainLoop:Data'), @@ -50,4 +50,4 @@ module.exports = PopupsFilterViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsFolderClearViewModel.js b/dev/ViewModels/Popups/PopupsFolderClearViewModel.js index 94dda63a3..449dffb9d 100644 --- a/dev/ViewModels/Popups/PopupsFolderClearViewModel.js +++ b/dev/ViewModels/Popups/PopupsFolderClearViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Data = require('Storage:RainLoop:Data'), Cache = require('Storage:RainLoop:Cache'), @@ -121,4 +121,4 @@ module.exports = PopupsFolderClearViewModel; -}(module, require)); +}()); diff --git a/dev/ViewModels/Popups/PopupsFolderCreateViewModel.js b/dev/ViewModels/Popups/PopupsFolderCreateViewModel.js index 41278d32d..a2bfec538 100644 --- a/dev/ViewModels/Popups/PopupsFolderCreateViewModel.js +++ b/dev/ViewModels/Popups/PopupsFolderCreateViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,9 +7,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Consts = require('Consts'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + Utils = require('Common/Utils'), Data = require('Storage:RainLoop:Data'), Remote = require('Storage:RainLoop:Remote'), @@ -129,4 +129,4 @@ module.exports = PopupsFolderCreateViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsFolderSystemViewModel.js b/dev/ViewModels/Popups/PopupsFolderSystemViewModel.js index 2189386ae..9c8dca18f 100644 --- a/dev/ViewModels/Popups/PopupsFolderSystemViewModel.js +++ b/dev/ViewModels/Popups/PopupsFolderSystemViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,9 +7,9 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Consts = require('Consts'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Consts = require('Common/Consts'), + Utils = require('Common/Utils'), Settings = require('Storage:Settings'), Data = require('Storage:RainLoop:Data'), @@ -133,4 +133,4 @@ module.exports = PopupsFolderSystemViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsIdentityViewModel.js b/dev/ViewModels/Popups/PopupsIdentityViewModel.js index 9bf754f4e..6e3f823fc 100644 --- a/dev/ViewModels/Popups/PopupsIdentityViewModel.js +++ b/dev/ViewModels/Popups/PopupsIdentityViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Remote = require('Storage:RainLoop:Remote'), Data = require('Storage:RainLoop:Data'), @@ -168,4 +168,4 @@ module.exports = PopupsIdentityViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsKeyboardShortcutsHelpViewModel.js b/dev/ViewModels/Popups/PopupsKeyboardShortcutsHelpViewModel.js index 18d34adb5..f28200b11 100644 --- a/dev/ViewModels/Popups/PopupsKeyboardShortcutsHelpViewModel.js +++ b/dev/ViewModels/Popups/PopupsKeyboardShortcutsHelpViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,7 +7,7 @@ _ = require('_'), key = require('key'), - Enums = require('Enums'), + Enums = require('Common/Enums'), kn = require('App:Knoin'), KnoinAbstractViewModel = require('Knoin:AbstractViewModel') @@ -61,4 +61,4 @@ module.exports = PopupsKeyboardShortcutsHelpViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsLanguagesViewModel.js b/dev/ViewModels/Popups/PopupsLanguagesViewModel.js index 435757623..48543f7a9 100644 --- a/dev/ViewModels/Popups/PopupsLanguagesViewModel.js +++ b/dev/ViewModels/Popups/PopupsLanguagesViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Utils = require('Utils'), - Globals = require('Globals'), + Utils = require('Common/Utils'), + Globals = require('Common/Globals'), kn = require('App:Knoin'), KnoinAbstractViewModel = require('Knoin:AbstractViewModel') @@ -79,4 +79,4 @@ module.exports = PopupsLanguagesViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsNewOpenPgpKeyViewModel.js b/dev/ViewModels/Popups/PopupsNewOpenPgpKeyViewModel.js index 9332340d8..1c46ba562 100644 --- a/dev/ViewModels/Popups/PopupsNewOpenPgpKeyViewModel.js +++ b/dev/ViewModels/Popups/PopupsNewOpenPgpKeyViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,7 +8,7 @@ _ = require('_'), ko = require('ko'), - Utils = require('Utils'), + Utils = require('Common/Utils'), Data = require('Storage:RainLoop:Data'), @@ -113,4 +113,4 @@ module.exports = PopupsNewOpenPgpKeyViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsPluginViewModel.js b/dev/ViewModels/Popups/PopupsPluginViewModel.js index 150ae09b2..24c181b0d 100644 --- a/dev/ViewModels/Popups/PopupsPluginViewModel.js +++ b/dev/ViewModels/Popups/PopupsPluginViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -8,8 +8,8 @@ ko = require('ko'), key = require('key'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Remote = require('Storage:Admin:Remote'), @@ -166,4 +166,4 @@ module.exports = PopupsPluginViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsTwoFactorTestViewModel.js b/dev/ViewModels/Popups/PopupsTwoFactorTestViewModel.js index 3b23f7f73..cd6edf5f7 100644 --- a/dev/ViewModels/Popups/PopupsTwoFactorTestViewModel.js +++ b/dev/ViewModels/Popups/PopupsTwoFactorTestViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), ko = require('ko'), - Enums = require('Enums'), - Utils = require('Utils'), + Enums = require('Common/Enums'), + Utils = require('Common/Utils'), Remote = require('Storage:RainLoop:Remote'), @@ -73,4 +73,4 @@ module.exports = PopupsTwoFactorTestViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js b/dev/ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js index 3e3079d24..f97330e25 100644 --- a/dev/ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js +++ b/dev/ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,7 +7,7 @@ _ = require('_'), ko = require('ko'), - Utils = require('Utils'), + Utils = require('Common/Utils'), kn = require('App:Knoin'), KnoinAbstractViewModel = require('Knoin:AbstractViewModel') @@ -56,4 +56,4 @@ module.exports = PopupsViewOpenPgpKeyViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/SettingsMenuViewModel.js b/dev/ViewModels/SettingsMenuViewModel.js index f756d1cc2..eeb4b6f90 100644 --- a/dev/ViewModels/SettingsMenuViewModel.js +++ b/dev/ViewModels/SettingsMenuViewModel.js @@ -1,13 +1,13 @@ -(function (module, require) { +(function () { 'use strict'; var _ = require('_'), - Globals = require('Globals'), - LinkBuilder = require('LinkBuilder'), + Globals = require('Common/Globals'), + LinkBuilder = require('Common/LinkBuilder'), kn = require('App:Knoin'), KnoinAbstractViewModel = require('Knoin:AbstractViewModel') @@ -45,4 +45,4 @@ module.exports = SettingsMenuViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/SettingsPaneViewModel.js b/dev/ViewModels/SettingsPaneViewModel.js index 86ca294e5..b48720613 100644 --- a/dev/ViewModels/SettingsPaneViewModel.js +++ b/dev/ViewModels/SettingsPaneViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -7,8 +7,8 @@ _ = require('_'), key = require('key'), - Enums = require('Enums'), - LinkBuilder = require('LinkBuilder'), + Enums = require('Common/Enums'), + LinkBuilder = require('Common/LinkBuilder'), Data = require('Storage:RainLoop:Data'), @@ -50,4 +50,4 @@ module.exports = SettingsPaneViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/dev/ViewModels/SettingsSystemDropDownViewModel.js b/dev/ViewModels/SettingsSystemDropDownViewModel.js index 3a79515c4..7c8adf4c4 100644 --- a/dev/ViewModels/SettingsSystemDropDownViewModel.js +++ b/dev/ViewModels/SettingsSystemDropDownViewModel.js @@ -1,5 +1,5 @@ -(function (module, require) { +(function () { 'use strict'; @@ -25,4 +25,4 @@ module.exports = SettingsSystemDropDownViewModel; -}(module, require)); \ No newline at end of file +}()); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 3547da056..9acef14a2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,8 +20,7 @@ var }, uglify: { mangle: true, - compress: true, - preserveComments: 'some' + compress: true } }, @@ -32,6 +31,7 @@ var header = require('gulp-header'), footer = require('gulp-footer'), rename = require('gulp-rename'), + replace = require('gulp-replace'), uglify = require('gulp-uglify'), gutil = require('gulp-util') ; @@ -69,6 +69,7 @@ function renameFileWothMd5Hash(sFile) cfg.paths.globjs = 'dev/**/*.js'; cfg.paths.staticJS = 'rainloop/v/' + cfg.devVersion + '/static/js/'; +cfg.paths.staticMinJS = 'rainloop/v/' + cfg.devVersion + '/static/js/min/'; cfg.paths.staticCSS = 'rainloop/v/' + cfg.devVersion + '/static/css/'; cfg.paths.less = { @@ -111,13 +112,13 @@ cfg.paths.js = { ] }, openpgp: { - name: 'openpgp.min.js', + name: 'openpgp.js', src: [ 'vendors/openpgp/openpgp-0.7.2.min.js' ] }, encrypt: { - name: '_encrypt.min.js', + name: 'bundle.js', header: '(function (window) {', footer: '}(window));', dest: 'vendors/jsbn/', @@ -126,7 +127,7 @@ cfg.paths.js = { 'vendors/jsbn/prng4.js', 'vendors/jsbn/rng.js', 'vendors/jsbn/rsa.js', - 'vendors/jsbn/_fix.js' + 'vendors/jsbn/fix.js' ] }, libs: { @@ -153,13 +154,16 @@ cfg.paths.js = { 'vendors/knockout-projections/knockout-projections-1.0.0.min.js', 'vendors/ssm/ssm.min.js', 'vendors/jua/jua.min.js', - 'vendors/jsbn/_encrypt.min.js', + 'vendors/jsbn/bundle.js', 'vendors/keymaster/keymaster.js', 'vendors/ifvisible/ifvisible.min.js', 'vendors/jquery-magnific-popup/jquery.magnific-popup.min.js', 'vendors/bootstrap/js/bootstrap.min.js' ] }, + common: { + name: 'common.js' + }, app: { name: 'app.js' }, @@ -211,7 +215,7 @@ gulp.task('css:main:min', ['css:main'], function() { gulp.task('js:boot', function() { return gulp.src(cfg.paths.js.boot.src) .pipe(concat(cfg.paths.js.boot.name)) - .pipe(gulp.dest(cfg.paths.staticJS)); + .pipe(gulp.dest(cfg.paths.staticMinJS)); }); gulp.task('js:encrypt', function() { @@ -220,65 +224,69 @@ gulp.task('js:encrypt', function() { .pipe(header(cfg.paths.js.encrypt.header || '')) .pipe(footer(cfg.paths.js.encrypt.footer || '')) .pipe(uglify(cfg.uglify)) - .pipe(gulp.dest(cfg.paths.js.encrypt.dest || cfg.paths.staticJS)) + .pipe(gulp.dest(cfg.paths.js.encrypt.dest)) .on('error', gutil.log); }); gulp.task('js:openpgp', function() { return gulp.src(cfg.paths.js.openpgp.src) .pipe(rename(cfg.paths.js.openpgp.name)) - .pipe(gulp.dest(cfg.paths.staticJS)); + .pipe(gulp.dest(cfg.paths.staticMinJS)); }); -gulp.task('js:libs', function() { +gulp.task('js:libs', ['js:encrypt'], function() { return gulp.src(cfg.paths.js.libs.src) .pipe(concat(cfg.paths.js.libs.name, {separator: '\n\n'})) - .pipe(gulp.dest(cfg.paths.staticJS)); + .pipe(gulp.dest(cfg.paths.staticMinJS)); }); -gulp.task('js:app', function() { - +gulp.task('js:webpack:clear', function() { + return gulp.src([cfg.paths.staticJS + '*.chunk.js', cfg.paths.staticMinJS + '*.chunk.js'], {read: false}) + .pipe(require('gulp-rimraf')()); +}); +gulp.task('js:webpack', ['js:webpack:clear'], function(callback) { var - browserify = require('browserify'), -// exorcist = require('exorcist'), - source = require('vinyl-source-stream'), - buffer = require('vinyl-buffer') + webpack = require('webpack'), + webpackCfg = require('./webpack.config.js') ; - return browserify({ - 'basedir': './dev/', - 'entries': './RainLoop.js', - 'detectGlobals': false, - 'debug': false - }) - .bundle() -// .pipe(exorcist(cfg.paths.staticJS + cfg.paths.js.app.name + '.map')) - .pipe(source(cfg.paths.js.app.name)) - .pipe(buffer()) + if (webpackCfg && webpackCfg.output) + { + webpackCfg.output.publicPath = cfg.paths.staticJS; + } + + webpack(webpackCfg, function(err, stats) { + if (err) { + throw new gutil.PluginError('webpack', err); + } + gutil.log('[webpack]', stats.toString({})); + callback(); + }); +}); + +gulp.task('js:app', ['js:webpack'], function() { + return gulp.src(cfg.paths.staticJS + cfg.paths.js.app.name) .pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n')) .pipe(gulp.dest(cfg.paths.staticJS)) .on('error', gutil.log); }); -gulp.task('js:admin', function() { +gulp.task('js:admin', ['js:webpack'], function() { + return gulp.src(cfg.paths.staticJS + cfg.paths.js.admin.name) + .pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n')) + .pipe(gulp.dest(cfg.paths.staticJS)) + .on('error', gutil.log); +}); - var - browserify = require('browserify'), -// exorcist = require('exorcist'), - source = require('vinyl-source-stream'), - buffer = require('vinyl-buffer') - ; +gulp.task('js:common', ['js:webpack'], function() { + return gulp.src(cfg.paths.staticJS + cfg.paths.js.common.name) + .pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n')) + .pipe(gulp.dest(cfg.paths.staticJS)) + .on('error', gutil.log); +}); - return browserify({ - 'basedir': './dev/', - 'entries': './Admin.js', - 'detectGlobals': false, - 'debug': false - }) - .bundle() -// .pipe(exorcist(cfg.paths.staticJS + cfg.paths.js.admin.name + '.map')) - .pipe(source(cfg.paths.js.admin.name)) - .pipe(buffer()) +gulp.task('js:chunks', ['js:webpack'], function() { + return gulp.src(cfg.paths.staticJS + '*.chunk.js') .pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n')) .pipe(gulp.dest(cfg.paths.staticJS)) .on('error', gutil.log); @@ -288,18 +296,37 @@ gulp.task('js:admin', function() { gulp.task('js:app:min', ['js:app'], function() { return gulp.src(cfg.paths.staticJS + cfg.paths.js.app.name) .pipe(uglify(cfg.uglify)) - .pipe(rename({suffix: '.min'})) +// .pipe(rename({suffix: '.min'})) .pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n')) - .pipe(gulp.dest(cfg.paths.staticJS)) + .pipe(gulp.dest(cfg.paths.staticMinJS)) .on('error', gutil.log); }); gulp.task('js:admin:min', ['js:admin'], function() { return gulp.src(cfg.paths.staticJS + cfg.paths.js.admin.name) .pipe(uglify(cfg.uglify)) - .pipe(rename({suffix: '.min'})) +// .pipe(rename({suffix: '.min'})) .pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n')) - .pipe(gulp.dest(cfg.paths.staticJS)) + .pipe(gulp.dest(cfg.paths.staticMinJS)) + .on('error', gutil.log); +}); + +gulp.task('js:common:min', ['js:common'], function() { + return gulp.src(cfg.paths.staticJS + cfg.paths.js.common.name) + .pipe(uglify(cfg.uglify)) +// .pipe(rename({suffix: '.min'})) + .pipe(replace(/rainloop\/v\/([^\/]+)\/static\/js\//g, 'rainloop/v/$1/static/js/min/')) + .pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n')) + .pipe(gulp.dest(cfg.paths.staticMinJS)) + .on('error', gutil.log); +}); + +gulp.task('js:chunks:min', ['js:chunks'], function() { + return gulp.src(cfg.paths.staticJS + '*.chunk.js') + .pipe(uglify(cfg.uglify)) +// .pipe(rename({suffix: '.min'})) + .pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n')) + .pipe(gulp.dest(cfg.paths.staticMinJS)) .on('error', gutil.log); }); @@ -462,8 +489,8 @@ gulp.task('rainloop:owncloud:clean', ['rainloop:owncloud:copy', 'rainloop:ownclo }); // MAIN -gulp.task('default', [ 'js:libs', 'js:boot', 'js:encrypt', 'js:openpgp', 'js:lint', 'js:app:min', 'js:admin:min', 'css:main:min']); -gulp.task('fast', ['js:app', 'js:admin', 'css:main']); +gulp.task('default', [ 'js:libs', 'js:boot', 'js:encrypt', 'js:openpgp', 'js:lint', 'js:app:min', 'js:admin:min', 'js:common:min', 'js:chunks:min', 'css:main:min']); +gulp.task('fast', ['js:app', 'js:admin', 'js:common', 'js:chunks', 'css:main']); gulp.task('rainloop', ['rainloop:copy', 'rainloop:setup', 'rainloop:zip', 'rainloop:md5', 'rainloop:clean']); gulp.task('rainloop+', ['rainloop', 'package-inc-release']); diff --git a/package.json b/package.json index f7a3b7ecd..e88dc6e28 100644 --- a/package.json +++ b/package.json @@ -40,152 +40,12 @@ "engines": { "node": ">= 0.10.0" }, - "browser": { - "window": "./dev/External/window.js", - "JSON": "./dev/External/JSON.js", - "$": "./dev/External/jquery.js", - "jquery": "./dev/External/jquery.js", - "_": "./dev/External/underscore.js", - "underscore": "./dev/External/underscore.js", - "ko": "./dev/External/ko.js", - "key": "./dev/External/key.js", - "moment": "./dev/External/moment.js", - "crossroads": "./dev/External/crossroads.js", - "hasher": "./dev/External/hasher.js", - "ifvisible": "./dev/External/ifvisible.js", - "ssm": "./dev/External/ssm.js", - "Jua": "./dev/External/Jua.js", - - "Base64": "./dev/Common/Base64.js", - "Consts": "./dev/Common/Consts.js", - "Globals": "./dev/Common/Globals.js", - "Plugins": "./dev/Common/Plugins.js", - "Enums": "./dev/Common/Enums.js", - "Utils": "./dev/Common/Utils.js", - "Events": "./dev/Common/Events.js", - "Selector": "./dev/Common/Selector.js", - "LinkBuilder": "./dev/Common/LinkBuilder.js", - "HtmlEditor": "./dev/Common/HtmlEditor.js", - - "Knoin:AbstractBoot": "./dev/Knoin/KnoinAbstractBoot.js", - "Knoin:AbstractScreen": "./dev/Knoin/KnoinAbstractScreen.js", - "Knoin:AbstractViewModel": "./dev/Knoin/KnoinAbstractViewModel.js", - - "App:Boot": "./dev/Boot.js", - "App:Knoin": "./dev/Knoin/Knoin.js", - "App:Abstract": "./dev/Apps/AbstractApp.js", - "App:RainLoop": "./dev/Apps/RainLoopApp.js", - "App:Admin": "./dev/Apps/AdminApp.js", - - "Model:Account": "./dev/Models/AccountModel.js", - "Model:Attachment": "./dev/Models/AttachmentModel.js", - "Model:ComposeAttachment": "./dev/Models/ComposeAttachmentModel.js", - "Model:Contact": "./dev/Models/ContactModel.js", - "Model:ContactProperty": "./dev/Models/ContactPropertyModel.js", - "Model:ContactTag": "./dev/Models/ContactTagModel.js", - "Model:Email": "./dev/Models/EmailModel.js", - "Model:Filter": "./dev/Models/FilterModel.js", - "Model:FilterCondition": "./dev/Models/FilterConditionModel.js", - "Model:Folder": "./dev/Models/FolderModel.js", - "Model:Identity": "./dev/Models/IdentityModel.js", - "Model:Message": "./dev/Models/MessageModel.js", - "Model:OpenPgpKey": "./dev/Models/OpenPgpKeyModel.js", - - "Storage:LocalStorage": "./dev/Storages/LocalStorage.js", - "Storage:LocalStorage:Cookie": "./dev/Storages/LocalStorages/CookieDriver.js", - "Storage:LocalStorage:LocalStorage": "./dev/Storages/LocalStorages/LocalStorageDriver.js", - - "Storage:Settings": "./dev/Storages/SettingsStorage.js", - - "Storage:Abstract:Remote": "./dev/Storages/AbstractRemoteStorage.js", - "Storage:Abstract:Data": "./dev/Storages/AbstractData.js", - - "Storage:RainLoop:Cache": "./dev/Storages/CacheStorage.js", - "Storage:RainLoop:Remote": "./dev/Storages/RemoteStorage.js", - "Storage:RainLoop:Data": "./dev/Storages/DataStorage.js", - - "Storage:Admin:Remote": "./dev/Storages/AdminRemoteStorage.js", - "Storage:Admin:Data": "./dev/Storages/AdminDataStorage.js", - - "Screen:AbstractSettings": "./dev/Screens/AbstractSettingsScreen.js", - "Screen:RainLoop:Login": "./dev/Screens/LoginScreen.js", - "Screen:RainLoop:About": "./dev/Screens/AboutScreen.js", - "Screen:RainLoop:MailBox": "./dev/Screens/MailBoxScreen.js", - "Screen:RainLoop:Settings": "./dev/Screens/SettingsScreen.js", - "Screen:Admin:Login": "./dev/Screens/AdminLoginScreen.js", - "Screen:Admin:Settings": "./dev/Screens/AdminSettingsScreen.js", - - "Settings:RainLoop:General": "./dev/Settings/App/SettingsGeneral.js", - "Settings:RainLoop:ChangePassword": "./dev/Settings/App/SettingsChangePassword.js", - "Settings:RainLoop:Accounts": "./dev/Settings/App/SettingsAccounts.js", - "Settings:RainLoop:Contacts": "./dev/Settings/App/SettingsContacts.js", - "Settings:RainLoop:Filters": "./dev/Settings/App/SettingsFilters.js", - "Settings:RainLoop:Folders": "./dev/Settings/App/SettingsFolders.js", - "Settings:RainLoop:Identity": "./dev/Settings/App/SettingsIdentity.js", - "Settings:RainLoop:Identities": "./dev/Settings/App/SettingsIdentities.js", - "Settings:RainLoop:OpenPGP": "./dev/Settings/App/SettingsOpenPGP.js", - "Settings:RainLoop:Security": "./dev/Settings/App/SettingsSecurity.js", - "Settings:RainLoop:Social": "./dev/Settings/App/SettingsSocial.js", - "Settings:RainLoop:Themes": "./dev/Settings/App/SettingsThemes.js", - - "Settings:Admin:General": "./dev/Settings/Admin/AdminSettingsGeneral.js", - "Settings:Admin:Login": "./dev/Settings/Admin/AdminSettingsLogin.js", - "Settings:Admin:Branding": "./dev/Settings/Admin/AdminSettingsBranding.js", - "Settings:Admin:Contacts": "./dev/Settings/Admin/AdminSettingsContacts.js", - "Settings:Admin:Domains": "./dev/Settings/Admin/AdminSettingsDomains.js", - "Settings:Admin:Social": "./dev/Settings/Admin/AdminSettingsSocial.js", - "Settings:Admin:Security": "./dev/Settings/Admin/AdminSettingsSecurity.js", - "Settings:Admin:Plugins": "./dev/Settings/Admin/AdminSettingsPlugins.js", - "Settings:Admin:Packages": "./dev/Settings/Admin/AdminSettingsPackages.js", - "Settings:Admin:Licensing": "./dev/Settings/Admin/AdminSettingsLicensing.js", - "Settings:Admin:About": "./dev/Settings/Admin/AdminSettingsAbout.js", - - "View:Admin:Login": "./dev/ViewModels/AdminLoginViewModel.js", - "View:Admin:SettingsMenu": "./dev/ViewModels/AdminSettingsMenuViewModel.js", - "View:Admin:SettingsPane": "./dev/ViewModels/AdminSettingsPaneViewModel.js", - - "View:RainLoop:AbstractSystemDropDown": "./dev/ViewModels/AbstractSystemDropDownViewModel.js", - "View:RainLoop:MailBoxSystemDropDown": "./dev/ViewModels/MailBoxSystemDropDownViewModel.js", - "View:RainLoop:SettingsSystemDropDown": "./dev/ViewModels/SettingsSystemDropDownViewModel.js", - "View:RainLoop:SettingsMenu": "./dev/ViewModels/SettingsMenuViewModel.js", - "View:RainLoop:SettingsPane": "./dev/ViewModels/SettingsPaneViewModel.js", - "View:RainLoop:MailBoxMessageView": "./dev/ViewModels/MailBoxMessageViewViewModel.js", - "View:RainLoop:MailBoxMessageList": "./dev/ViewModels/MailBoxMessageListViewModel.js", - "View:RainLoop:MailBoxFolderList": "./dev/ViewModels/MailBoxFolderListViewModel.js", - "View:RainLoop:Login": "./dev/ViewModels/LoginViewModel.js", - "View:RainLoop:About": "./dev/ViewModels/AboutViewModel.js", - - "View:Popup:Activate": "./dev/ViewModels/Popups/PopupsActivateViewModel.js", - "View:Popup:AddAccount": "./dev/ViewModels/Popups/PopupsAddAccountViewModel.js", - "View:Popup:AddOpenPgpKey": "./dev/ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js", - "View:Popup:AdvancedSearch": "./dev/ViewModels/Popups/PopupsAdvancedSearchViewModel.js", - "View:Popup:Ask": "./dev/ViewModels/Popups/PopupsAskViewModel.js", - "View:Popup:ComposeOpenPgp": "./dev/ViewModels/Popups/PopupsComposeOpenPgpViewModel.js", - "View:Popup:Compose": "./dev/ViewModels/Popups/PopupsComposeViewModel.js", - "View:Popup:Contacts": "./dev/ViewModels/Popups/PopupsContactsViewModel.js", - "View:Popup:Domain": "./dev/ViewModels/Popups/PopupsDomainViewModel.js", - "View:Popup:Filter": "./dev/ViewModels/Popups/PopupsFilterViewModel.js", - "View:Popup:FolderClear": "./dev/ViewModels/Popups/PopupsFolderClearViewModel.js", - "View:Popup:FolderCreate": "./dev/ViewModels/Popups/PopupsFolderCreateViewModel.js", - "View:Popup:FolderSystem": "./dev/ViewModels/Popups/PopupsFolderSystemViewModel.js", - "View:Popup:Identity": "./dev/ViewModels/Popups/PopupsIdentityViewModel.js", - "View:Popup:KeyboardShortcutsHelp": "./dev/ViewModels/Popups/PopupsKeyboardShortcutsHelpViewModel.js", - "View:Popup:Languages": "./dev/ViewModels/Popups/PopupsLanguagesViewModel.js", - "View:Popup:NewOpenPgpKey": "./dev/ViewModels/Popups/PopupsNewOpenPgpKeyViewModel.js", - "View:Popup:Plugin": "./dev/ViewModels/Popups/PopupsPluginViewModel.js", - "View:Popup:TwoFactorTest": "./dev/ViewModels/Popups/PopupsTwoFactorTestViewModel.js", - "View:Popup:ViewOpenPgpKey": "./dev/ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js" - }, "devDependencies": { - "crypto": "*", "node-fs": "*", "jshint-summary": "*", - "browserify": "*", - "exorcist": "*", - "vinyl-source-stream": "*", - "vinyl-buffer": "*", + "webpack": "*", "gulp": "*", "gulp-util": "*", @@ -195,6 +55,7 @@ "gulp-less": "*", "gulp-zip": "*", "gulp-rename": "*", + "gulp-replace": "*", "gulp-header": "*", "gulp-footer": "*", "gulp-minify-css": "*", diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php index 092436335..edc7a6f56 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php @@ -200,11 +200,12 @@ class Service 'FaviconPngLink' => $sStaticPrefix.'favicon.png', 'AppleTouchLink' => $sStaticPrefix.'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix.'css/app'.($bAppCssDebug ? '' : '.min').'.css', - 'BootJsLink' => $sStaticPrefix.'js/boot.js', - 'LibJsLink' => $sStaticPrefix.'js/libs.js', + 'BootJsLink' => $sStaticPrefix.'js/min/boot.js', + 'LibJsLink' => $sStaticPrefix.'js/min/libs.js', 'EditorJsLink' => $sStaticPrefix.'ckeditor/ckeditor.js', - 'OpenPgpJsLink' => $sStaticPrefix.'js/openpgp.min.js', - 'AppJsLink' => $sStaticPrefix.'js/'.($bAdmin ? 'admin' : 'app').($bAppJsDebug ? '' : '.min').'.js' + 'OpenPgpJsLink' => $sStaticPrefix.'js/min/openpgp.min.js', + 'CommonJsLink' => $sStaticPrefix.'js/'.($bAppJsDebug ? '' : 'min/').'common.js', + 'AppJsLink' => $sStaticPrefix.'js/'.($bAppJsDebug ? '' : 'min/').($bAdmin ? 'admin' : 'app').'.js' ); $aTemplateParameters = array( @@ -217,6 +218,7 @@ class Service '{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'], '{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'], '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], + '{{BaseCommonMainScriptLink}}' => $aData['CommonJsLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], '{{BaseAppLoadingDescription}}' => \htmlspecialchars($aData['LoadingDescription'], ENT_QUOTES|ENT_IGNORE, 'UTF-8'), '{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr' diff --git a/rainloop/v/0.0.0/app/templates/Index.html b/rainloop/v/0.0.0/app/templates/Index.html index cb5187b58..bf39dc35a 100644 --- a/rainloop/v/0.0.0/app/templates/Index.html +++ b/rainloop/v/0.0.0/app/templates/Index.html @@ -82,9 +82,13 @@ .wait(function () { __simplePace(30); }) + .script('{{BaseCommonMainScriptLink}}') + .wait(function () { + __simplePace(5); + }) .script('{{BaseAppMainScriptLink}}') .wait(function () { - __simplePace(20); + __simplePace(15); }) .script(function () { return window.rainloopAppData['PluginsLink'] || null; diff --git a/rainloop/v/0.0.0/static/css/app.css b/rainloop/v/0.0.0/static/css/app.css index 5fee38042..6bf1bc69f 100644 --- a/rainloop/v/0.0.0/static/css/app.css +++ b/rainloop/v/0.0.0/static/css/app.css @@ -637,7 +637,7 @@ filter: Alpha(Opacity=30); } - + /*! normalize.css 2012-03-11T12:53 UTC - http://github.com/necolas/normalize.css */ /* ============================================================================= @@ -1150,7 +1150,7 @@ table { border-spacing: 0; border-collapse: collapse; } - + @charset "UTF-8"; @font-face { @@ -1522,7 +1522,7 @@ table { .icon-resize-out:before { content: "\e06d"; } - + /** initial setup **/ .nano { /* @@ -1638,7 +1638,7 @@ table { .nano > .pane2.active > .slider2 { background-color: rgba(0, 0, 0, 0.4); } - + /* Magnific Popup CSS */ .mfp-bg { position: fixed; @@ -2094,7 +2094,7 @@ img.mfp-img { padding-top: 0; } - + /* overlay at start */ .mfp-fade.mfp-bg { @@ -2135,7 +2135,7 @@ img.mfp-img { -ms-transform: translateX(50px); transform: translateX(50px); } - + .simple-pace { pointer-events: none; @@ -2210,7 +2210,7 @@ img.mfp-img { transform: translate(-32px, 0); transform: translate(-32px, 0); } -} +} .inputosaurus-container { display: inline-block; margin: 0 5px 0 0; @@ -2275,7 +2275,7 @@ img.mfp-img { .inputosaurus-input-hidden { display: none; } - + .flag-wrapper { display: inline-block; width: 24px; @@ -2401,7 +2401,7 @@ img.mfp-img { .flag.flag-zh-cn, .flag.flag-zh-hk { background-position: -208px -22px; -} +} /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ .clearfix { *zoom: 1; diff --git a/rainloop/v/0.0.0/static/js/701a517c70faed82fff3.chunk.js b/rainloop/v/0.0.0/static/js/701a517c70faed82fff3.chunk.js new file mode 100644 index 000000000..ac61aeac3 --- /dev/null +++ b/rainloop/v/0.0.0/static/js/701a517c70faed82fff3.chunk.js @@ -0,0 +1,10194 @@ +/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ +webpackJsonp([0],Array(21).concat([ +/* 21 */ +/*!*********************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsComposeViewModel.js ***! + \*********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + moment = __webpack_require__(/*! moment */ 25), + JSON = __webpack_require__(/*! JSON */ 33), + Jua = __webpack_require__(/*! Jua */ 47), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Consts = __webpack_require__(/*! Common/Consts */ 17), + Utils = __webpack_require__(/*! Common/Utils */ 1), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Events = __webpack_require__(/*! Common/Events */ 22), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + HtmlEditor = __webpack_require__(/*! Common/HtmlEditor */ 28), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + ComposeAttachmentModel = __webpack_require__(/*! Model:ComposeAttachment */ 53), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsComposeViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsCompose'); + + this.oEditor = null; + this.aDraftInfo = null; + this.sInReplyTo = ''; + this.bFromDraft = false; + this.bSkipNext = false; + this.sReferences = ''; + + this.bCapaAdditionalIdentities = Settings.capa(Enums.Capa.AdditionalIdentities); + + var + self = this, + fCcAndBccCheckHelper = function (aValue) { + if (false === self.showCcAndBcc() && 0 < aValue.length) + { + self.showCcAndBcc(true); + } + } + ; + + this.capaOpenPGP = Data.capaOpenPGP; + + this.resizer = ko.observable(false).extend({'throttle': 50}); + + this.identitiesDropdownTrigger = ko.observable(false); + + this.to = ko.observable(''); + this.to.focusTrigger = ko.observable(false); + this.cc = ko.observable(''); + this.bcc = ko.observable(''); + + this.replyTo = ko.observable(''); + this.subject = ko.observable(''); + this.isHtml = ko.observable(false); + + this.requestReadReceipt = ko.observable(false); + + this.sendError = ko.observable(false); + this.sendSuccessButSaveError = ko.observable(false); + this.savedError = ko.observable(false); + + this.savedTime = ko.observable(0); + this.savedOrSendingText = ko.observable(''); + + this.emptyToError = ko.observable(false); + this.attachmentsInProcessError = ko.observable(false); + this.showCcAndBcc = ko.observable(false); + + this.cc.subscribe(fCcAndBccCheckHelper, this); + this.bcc.subscribe(fCcAndBccCheckHelper, this); + + this.draftFolder = ko.observable(''); + this.draftUid = ko.observable(''); + this.sending = ko.observable(false); + this.saving = ko.observable(false); + this.attachments = ko.observableArray([]); + + this.attachmentsInProcess = this.attachments.filter(function (oItem) { + return oItem && '' === oItem.tempName(); + }); + + this.attachmentsInReady = this.attachments.filter(function (oItem) { + return oItem && '' !== oItem.tempName(); + }); + + this.attachments.subscribe(function () { + this.triggerForResize(); + }, this); + + this.isDraftFolderMessage = ko.computed(function () { + return '' !== this.draftFolder() && '' !== this.draftUid(); + }, this); + + this.composeUploaderButton = ko.observable(null); + this.composeUploaderDropPlace = ko.observable(null); + this.dragAndDropEnabled = ko.observable(false); + this.dragAndDropOver = ko.observable(false).extend({'throttle': 1}); + this.dragAndDropVisible = ko.observable(false).extend({'throttle': 1}); + this.attacheMultipleAllowed = ko.observable(false); + this.addAttachmentEnabled = ko.observable(false); + + this.composeEditorArea = ko.observable(null); + + this.identities = Data.identities; + this.defaultIdentityID = Data.defaultIdentityID; + this.currentIdentityID = ko.observable(''); + + this.currentIdentityString = ko.observable(''); + this.currentIdentityResultEmail = ko.observable(''); + + this.identitiesOptions = ko.computed(function () { + + var aList = [{ + 'optValue': Data.accountEmail(), + 'optText': this.formattedFrom(false) + }]; + + _.each(Data.identities(), function (oItem) { + aList.push({ + 'optValue': oItem.id, + 'optText': oItem.formattedNameForCompose() + }); + }); + + return aList; + + }, this); + + ko.computed(function () { + + var + sResult = '', + sResultEmail = '', + oItem = null, + aList = this.identities(), + sID = this.currentIdentityID() + ; + + if (this.bCapaAdditionalIdentities && sID && sID !== Data.accountEmail()) + { + oItem = _.find(aList, function (oItem) { + return oItem && sID === oItem['id']; + }); + + sResult = oItem ? oItem.formattedNameForCompose() : ''; + sResultEmail = oItem ? oItem.formattedNameForEmail() : ''; + + if ('' === sResult && aList[0]) + { + this.currentIdentityID(aList[0]['id']); + return ''; + } + } + + if ('' === sResult) + { + sResult = this.formattedFrom(false); + sResultEmail = this.formattedFrom(true); + } + + this.currentIdentityString(sResult); + this.currentIdentityResultEmail(sResultEmail); + + return sResult; + + }, this); + + this.to.subscribe(function (sValue) { + if (this.emptyToError() && 0 < sValue.length) + { + this.emptyToError(false); + } + }, this); + + this.attachmentsInProcess.subscribe(function (aValue) { + if (this.attachmentsInProcessError() && Utils.isArray(aValue) && 0 === aValue.length) + { + this.attachmentsInProcessError(false); + } + }, this); + + this.editorResizeThrottle = _.throttle(_.bind(this.editorResize, this), 100); + + this.resizer.subscribe(function () { + this.editorResizeThrottle(); + }, this); + + this.canBeSendedOrSaved = ko.computed(function () { + return !this.sending() && !this.saving(); + }, this); + + this.deleteCommand = Utils.createCommand(this, function () { + + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]); + kn.hideScreenPopup(PopupsComposeViewModel); + + }, function () { + return this.isDraftFolderMessage(); + }); + + this.sendMessageResponse = _.bind(this.sendMessageResponse, this); + this.saveMessageResponse = _.bind(this.saveMessageResponse, this); + + this.sendCommand = Utils.createCommand(this, function () { + var + sTo = Utils.trim(this.to()), + sSentFolder = Data.sentFolder(), + aFlagsCache = [] + ; + + if (0 < this.attachmentsInProcess().length) + { + this.attachmentsInProcessError(true); + } + else if (0 === sTo.length) + { + this.emptyToError(true); + } + else + { + if (Data.replySameFolder()) + { + if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && Utils.isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length) + { + sSentFolder = this.aDraftInfo[2]; + } + } + + if ('' === sSentFolder) + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:FolderSystem */ 27), [Enums.SetSystemFoldersNotification.Sent]); + } + else + { + this.sendError(false); + this.sending(true); + + if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length) + { + aFlagsCache = Cache.getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]); + if (aFlagsCache) + { + if ('forward' === this.aDraftInfo[0]) + { + aFlagsCache[3] = true; + } + else + { + aFlagsCache[2] = true; + } + + Cache.setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], aFlagsCache); + __webpack_require__(/*! App:RainLoop */ 4).reloadFlagsCurrentMessageListAndMessageFromCache(); + Cache.setFolderHash(this.aDraftInfo[2], ''); + } + } + + sSentFolder = Consts.Values.UnuseOptionValue === sSentFolder ? '' : sSentFolder; + + Cache.setFolderHash(this.draftFolder(), ''); + Cache.setFolderHash(sSentFolder, ''); + + Remote.sendMessage( + this.sendMessageResponse, + this.draftFolder(), + this.draftUid(), + sSentFolder, + this.currentIdentityResultEmail(), + sTo, + this.cc(), + this.bcc(), + this.subject(), + this.oEditor ? this.oEditor.isHtml() : false, + this.oEditor ? this.oEditor.getData(true) : '', + this.prepearAttachmentsForSendOrSave(), + this.aDraftInfo, + this.sInReplyTo, + this.sReferences, + this.requestReadReceipt() + ); + } + } + }, this.canBeSendedOrSaved); + + this.saveCommand = Utils.createCommand(this, function () { + + if (Data.draftFolderNotEnabled()) + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:FolderSystem */ 27), [Enums.SetSystemFoldersNotification.Draft]); + } + else + { + this.savedError(false); + this.saving(true); + + this.bSkipNext = true; + + Cache.setFolderHash(Data.draftFolder(), ''); + + Remote.saveMessage( + this.saveMessageResponse, + this.draftFolder(), + this.draftUid(), + Data.draftFolder(), + this.currentIdentityResultEmail(), + this.to(), + this.cc(), + this.bcc(), + this.subject(), + this.oEditor ? this.oEditor.isHtml() : false, + this.oEditor ? this.oEditor.getData(true) : '', + this.prepearAttachmentsForSendOrSave(), + this.aDraftInfo, + this.sInReplyTo, + this.sReferences + ); + } + + }, this.canBeSendedOrSaved); + + Events.sub('interval.1m', function () { + if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) && + !this.bSkipNext && !this.saving() && !this.sending() && !this.savedError()) + { + this.bSkipNext = false; + this.saveCommand(); + } + }, this); + + this.showCcAndBcc.subscribe(function () { + this.triggerForResize(); + }, this); + + this.dropboxEnabled = ko.observable(!!Settings.settingsGet('DropboxApiKey')); + + this.dropboxCommand = Utils.createCommand(this, function () { + + if (window.Dropbox) + { + window.Dropbox.choose({ + //'iframe': true, + 'success': function(aFiles) { + + if (aFiles && aFiles[0] && aFiles[0]['link']) + { + self.addDropboxAttachment(aFiles[0]); + } + }, + 'linkType': "direct", + 'multiselect': false + }); + } + + return true; + + }, function () { + return this.dropboxEnabled(); + }); + + this.driveEnabled = ko.observable(Globals.bXMLHttpRequestSupported && + !!Settings.settingsGet('GoogleClientID') && !!Settings.settingsGet('GoogleApiKey')); + + this.driveVisible = ko.observable(false); + + this.driveCommand = Utils.createCommand(this, function () { + + this.driveOpenPopup(); + return true; + + }, function () { + return this.driveEnabled(); + }); + + this.driveCallback = _.bind(this.driveCallback, this); + + this.bDisabeCloseOnEsc = true; + this.sDefaultKeyScope = Enums.KeyState.Compose; + + this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200); + + this.emailsSource = _.bind(this.emailsSource, this); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:Compose', 'PopupsComposeViewModel'], PopupsComposeViewModel); + _.extend(PopupsComposeViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsComposeViewModel.prototype.emailsSource = function (oData, fResponse) + { + __webpack_require__(/*! App:RainLoop */ 4).getAutocomplete(oData.term, function (aData) { + fResponse(_.map(aData, function (oEmailItem) { + return oEmailItem.toLine(false); + })); + }); + }; + + PopupsComposeViewModel.prototype.openOpenPgpPopup = function () + { + if (this.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml()) + { + var self = this; + kn.showScreenPopup(__webpack_require__(/*! View:Popup:ComposeOpenPgp */ 104), [ + function (sResult) { + self.editor(function (oEditor) { + oEditor.setPlain(sResult); + }); + }, + this.oEditor.getData(), + this.currentIdentityResultEmail(), + this.to(), + this.cc(), + this.bcc() + ]); + } + }; + + PopupsComposeViewModel.prototype.reloadDraftFolder = function () + { + var + sDraftFolder = Data.draftFolder() + ; + + if ('' !== sDraftFolder) + { + Cache.setFolderHash(sDraftFolder, ''); + if (Data.currentFolderFullNameRaw() === sDraftFolder) + { + __webpack_require__(/*! App:RainLoop */ 4).reloadMessageList(true); + } + else + { + __webpack_require__(/*! App:RainLoop */ 4).folderInformation(sDraftFolder); + } + } + }; + + PopupsComposeViewModel.prototype.findIdentityIdByMessage = function (sComposeType, oMessage) + { + var + oIDs = {}, + sResult = '', + fFindHelper = function (oItem) { + if (oItem && oItem.email && oIDs[oItem.email]) + { + sResult = oIDs[oItem.email]; + return true; + } + + return false; + } + ; + + if (this.bCapaAdditionalIdentities) + { + _.each(this.identities(), function (oItem) { + oIDs[oItem.email()] = oItem['id']; + }); + } + + oIDs[Data.accountEmail()] = Data.accountEmail(); + + if (oMessage) + { + switch (sComposeType) + { + case Enums.ComposeType.Empty: + break; + case Enums.ComposeType.Reply: + case Enums.ComposeType.ReplyAll: + case Enums.ComposeType.Forward: + case Enums.ComposeType.ForwardAsAttachment: + _.find(_.union(oMessage.to, oMessage.cc, oMessage.bcc, oMessage.deliveredTo), fFindHelper); + break; + case Enums.ComposeType.Draft: + _.find(_.union(oMessage.from, oMessage.replyTo), fFindHelper); + break; + } + } + + if ('' === sResult) + { + sResult = this.defaultIdentityID(); + } + + if ('' === sResult) + { + sResult = Data.accountEmail(); + } + + return sResult; + }; + + PopupsComposeViewModel.prototype.selectIdentity = function (oIdentity) + { + if (oIdentity) + { + this.currentIdentityID(oIdentity.optValue); + } + }; + + /** + * + * @param {boolean=} bHeaderResult = false + * @returns {string} + */ + PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult) + { + var + sDisplayName = Data.displayName(), + sEmail = Data.accountEmail() + ; + + return '' === sDisplayName ? sEmail : + ((Utils.isUnd(bHeaderResult) ? false : !!bHeaderResult) ? + '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>' : + sDisplayName + ' (' + sEmail + ')') + ; + }; + + PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData) + { + var + bResult = false, + sMessage = '' + ; + + this.sending(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + bResult = true; + if (this.modalVisibility()) + { + Utils.delegateRun(this, 'closeCommand'); + } + } + + if (this.modalVisibility() && !bResult) + { + if (oData && Enums.Notification.CantSaveMessage === oData.ErrorCode) + { + this.sendSuccessButSaveError(true); + window.alert(Utils.trim(Utils.i18n('COMPOSE/SAVED_ERROR_ON_SEND'))); + } + else + { + sMessage = Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage, + oData && oData.ErrorMessage ? oData.ErrorMessage : ''); + + this.sendError(true); + window.alert(sMessage || Utils.getNotification(Enums.Notification.CantSendMessage)); + } + } + + this.reloadDraftFolder(); + }; + + PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData) + { + var + bResult = false, + oMessage = null + ; + + this.saving(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + if (oData.Result.NewFolder && oData.Result.NewUid) + { + if (this.bFromDraft) + { + oMessage = Data.message(); + if (oMessage && this.draftFolder() === oMessage.folderFullNameRaw && this.draftUid() === oMessage.uid) + { + Data.message(null); + } + } + + this.draftFolder(oData.Result.NewFolder); + this.draftUid(oData.Result.NewUid); + + if (this.modalVisibility()) + { + this.savedTime(window.Math.round((new window.Date()).getTime() / 1000)); + + this.savedOrSendingText( + 0 < this.savedTime() ? Utils.i18n('COMPOSE/SAVED_TIME', { + 'TIME': moment.unix(this.savedTime() - 1).format('LT') + }) : '' + ); + + bResult = true; + + if (this.bFromDraft) + { + Cache.setFolderHash(this.draftFolder(), ''); + } + } + } + } + + if (!this.modalVisibility() && !bResult) + { + this.savedError(true); + this.savedOrSendingText(Utils.getNotification(Enums.Notification.CantSaveMessage)); + } + + this.reloadDraftFolder(); + }; + + PopupsComposeViewModel.prototype.onHide = function () + { + this.reset(); + kn.routeOn(); + }; + + /** + * @param {string} sSignature + * @param {string=} sFrom + * @param {string=} sData + * @param {string=} sComposeType + * @return {string} + */ + PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom, sData, sComposeType) + { + var bHtml = false, bData = false; + if ('' !== sSignature) + { + if (':HTML:' === sSignature.substr(0, 6)) + { + bHtml = true; + sSignature = sSignature.substr(6); + } + + sSignature = sSignature.replace(/[\r]/g, ''); + + sFrom = Utils.pString(sFrom); + if ('' !== sFrom) + { + sSignature = sSignature.replace(/{{FROM}}/g, sFrom); + } + + sSignature = sSignature.replace(/[\s]{1,2}{{FROM}}/g, '{{FROM}}'); + + sSignature = sSignature.replace(/{{FROM}}/g, ''); + sSignature = sSignature.replace(/{{DATE}}/g, moment().format('llll')); + + if (sData && Enums.ComposeType.Empty === sComposeType && + -1 < sSignature.indexOf('{{DATA}}')) + { + bData = true; + sSignature = sSignature.replace('{{DATA}}', sData); + } + + sSignature = sSignature.replace(/{{DATA}}/g, ''); + + if (!bHtml) + { + sSignature = Utils.convertPlainTextToHtml(sSignature); + } + } + + if (sData && !bData) + { + switch (sComposeType) + { + case Enums.ComposeType.Empty: + sSignature = sData + '
' + sSignature; + break; + default: + sSignature = sSignature + '
' + sData; + break; + } + } + + return sSignature; + }; + + PopupsComposeViewModel.prototype.editor = function (fOnInit) + { + if (fOnInit) + { + var self = this; + if (!this.oEditor && this.composeEditorArea()) + { + _.delay(function () { + self.oEditor = new HtmlEditor(self.composeEditorArea(), null, function () { + fOnInit(self.oEditor); + }, function (bHtml) { + self.isHtml(!!bHtml); + }); + }, 300); + } + else if (this.oEditor) + { + fOnInit(this.oEditor); + } + } + }; + + /** + * @param {string=} sType = Enums.ComposeType.Empty + * @param {?MessageModel|Array=} oMessageOrArray = null + * @param {Array=} aToEmails = null + * @param {string=} sCustomSubject = null + * @param {string=} sCustomPlainText = null + */ + PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToEmails, sCustomSubject, sCustomPlainText) + { + kn.routeOff(); + + var + self = this, + sFrom = '', + sTo = '', + sCc = '', + sDate = '', + sSubject = '', + oText = null, + sText = '', + sReplyTitle = '', + aResplyAllParts = [], + oExcludeEmail = {}, + mEmail = Data.accountEmail(), + sSignature = Data.signature(), + bSignatureToAll = Data.signatureToAll(), + aDownloads = [], + aDraftInfo = null, + oMessage = null, + sComposeType = sType || Enums.ComposeType.Empty, + fEmailArrayToStringLineHelper = function (aList, bFriendly) { + + var + iIndex = 0, + iLen = aList.length, + aResult = [] + ; + + for (; iIndex < iLen; iIndex++) + { + aResult.push(aList[iIndex].toLine(!!bFriendly)); + } + + return aResult.join(', '); + } + ; + + oMessageOrArray = oMessageOrArray || null; + if (oMessageOrArray && Utils.isNormal(oMessageOrArray)) + { + oMessage = Utils.isArray(oMessageOrArray) && 1 === oMessageOrArray.length ? oMessageOrArray[0] : + (!Utils.isArray(oMessageOrArray) ? oMessageOrArray : null); + } + + if (null !== mEmail) + { + oExcludeEmail[mEmail] = true; + } + + this.currentIdentityID(this.findIdentityIdByMessage(sComposeType, oMessage)); + this.reset(); + + if (Utils.isNonEmptyArray(aToEmails)) + { + this.to(fEmailArrayToStringLineHelper(aToEmails)); + } + + if ('' !== sComposeType && oMessage) + { + sDate = oMessage.fullFormatDateValue(); + sSubject = oMessage.subject(); + aDraftInfo = oMessage.aDraftInfo; + + oText = $(oMessage.body).clone(); + if (oText) + { + oText.find('blockquote.rl-bq-switcher').each(function () { + $(this).removeClass('rl-bq-switcher hidden-bq'); + }); + oText.find('.rlBlockquoteSwitcher').each(function () { + $(this).remove(); + }); + } + + oText.find('[data-html-editor-font-wrapper]').removeAttr('data-html-editor-font-wrapper'); + sText = oText.html(); + + switch (sComposeType) + { + case Enums.ComposeType.Empty: + break; + + case Enums.ComposeType.Reply: + this.to(fEmailArrayToStringLineHelper(oMessage.replyEmails(oExcludeEmail))); + this.subject(Utils.replySubjectAdd('Re', sSubject)); + this.prepearMessageAttachments(oMessage, sComposeType); + this.aDraftInfo = ['reply', oMessage.uid, oMessage.folderFullNameRaw]; + this.sInReplyTo = oMessage.sMessageId; + this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences); + break; + + case Enums.ComposeType.ReplyAll: + aResplyAllParts = oMessage.replyAllEmails(oExcludeEmail); + this.to(fEmailArrayToStringLineHelper(aResplyAllParts[0])); + this.cc(fEmailArrayToStringLineHelper(aResplyAllParts[1])); + this.subject(Utils.replySubjectAdd('Re', sSubject)); + this.prepearMessageAttachments(oMessage, sComposeType); + this.aDraftInfo = ['reply', oMessage.uid, oMessage.folderFullNameRaw]; + this.sInReplyTo = oMessage.sMessageId; + this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.references()); + break; + + case Enums.ComposeType.Forward: + this.subject(Utils.replySubjectAdd('Fwd', sSubject)); + this.prepearMessageAttachments(oMessage, sComposeType); + this.aDraftInfo = ['forward', oMessage.uid, oMessage.folderFullNameRaw]; + this.sInReplyTo = oMessage.sMessageId; + this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences); + break; + + case Enums.ComposeType.ForwardAsAttachment: + this.subject(Utils.replySubjectAdd('Fwd', sSubject)); + this.prepearMessageAttachments(oMessage, sComposeType); + this.aDraftInfo = ['forward', oMessage.uid, oMessage.folderFullNameRaw]; + this.sInReplyTo = oMessage.sMessageId; + this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences); + break; + + case Enums.ComposeType.Draft: + this.to(fEmailArrayToStringLineHelper(oMessage.to)); + this.cc(fEmailArrayToStringLineHelper(oMessage.cc)); + this.bcc(fEmailArrayToStringLineHelper(oMessage.bcc)); + + this.bFromDraft = true; + + this.draftFolder(oMessage.folderFullNameRaw); + this.draftUid(oMessage.uid); + + this.subject(sSubject); + this.prepearMessageAttachments(oMessage, sComposeType); + + this.aDraftInfo = Utils.isNonEmptyArray(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null; + this.sInReplyTo = oMessage.sInReplyTo; + this.sReferences = oMessage.sReferences; + break; + + case Enums.ComposeType.EditAsNew: + this.to(fEmailArrayToStringLineHelper(oMessage.to)); + this.cc(fEmailArrayToStringLineHelper(oMessage.cc)); + this.bcc(fEmailArrayToStringLineHelper(oMessage.bcc)); + + this.subject(sSubject); + this.prepearMessageAttachments(oMessage, sComposeType); + + this.aDraftInfo = Utils.isNonEmptyArray(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null; + this.sInReplyTo = oMessage.sInReplyTo; + this.sReferences = oMessage.sReferences; + break; + } + + switch (sComposeType) + { + case Enums.ComposeType.Reply: + case Enums.ComposeType.ReplyAll: + sFrom = oMessage.fromToLine(false, true); + sReplyTitle = Utils.i18n('COMPOSE/REPLY_MESSAGE_TITLE', { + 'DATETIME': sDate, + 'EMAIL': sFrom + }); + + sText = '

' + sReplyTitle + ':' + + '

' + sText + '

'; + + break; + + case Enums.ComposeType.Forward: + sFrom = oMessage.fromToLine(false, true); + sTo = oMessage.toToLine(false, true); + sCc = oMessage.ccToLine(false, true); + sText = '


' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_TITLE') + + '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_FROM') + ': ' + sFrom + + '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_TO') + ': ' + sTo + + (0 < sCc.length ? '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_CC') + ': ' + sCc : '') + + '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_SENT') + ': ' + Utils.encodeHtml(sDate) + + '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT') + ': ' + Utils.encodeHtml(sSubject) + + '

' + sText; + break; + case Enums.ComposeType.ForwardAsAttachment: + sText = ''; + break; + } + + if (bSignatureToAll && '' !== sSignature && + Enums.ComposeType.EditAsNew !== sComposeType && Enums.ComposeType.Draft !== sComposeType) + { + sText = this.convertSignature(sSignature, fEmailArrayToStringLineHelper(oMessage.from, true), sText, sComposeType); + } + + this.editor(function (oEditor) { + oEditor.setHtml(sText, false); + if (!oMessage.isHtml()) + { + oEditor.modeToggle(false); + } + }); + } + else if (Enums.ComposeType.Empty === sComposeType) + { + this.subject(Utils.isNormal(sCustomSubject) ? '' + sCustomSubject : ''); + + sText = Utils.isNormal(sCustomPlainText) ? '' + sCustomPlainText : ''; + if (bSignatureToAll && '' !== sSignature) + { + sText = this.convertSignature(sSignature, '', + Utils.convertPlainTextToHtml(sText), sComposeType); + } + + this.editor(function (oEditor) { + oEditor.setHtml(sText, false); + if (Enums.EditorDefaultType.Html !== Data.editorDefaultType()) + { + oEditor.modeToggle(false); + } + }); + } + else if (Utils.isNonEmptyArray(oMessageOrArray)) + { + _.each(oMessageOrArray, function (oMessage) { + self.addMessageAsAttachment(oMessage); + }); + } + + aDownloads = this.getAttachmentsDownloadsForUpload(); + if (Utils.isNonEmptyArray(aDownloads)) + { + Remote.messageUploadAttachments(function (sResult, oData) { + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + var + oAttachment = null, + sTempName = '' + ; + + if (!self.viewModelVisibility()) + { + for (sTempName in oData.Result) + { + if (oData.Result.hasOwnProperty(sTempName)) + { + oAttachment = self.getAttachmentById(oData.Result[sTempName]); + if (oAttachment) + { + oAttachment.tempName(sTempName); + } + } + } + } + } + else + { + self.setMessageAttachmentFailedDowbloadText(); + } + + }, aDownloads); + } + + this.triggerForResize(); + }; + + PopupsComposeViewModel.prototype.onFocus = function () + { + if ('' === this.to()) + { + this.to.focusTrigger(!this.to.focusTrigger()); + } + else if (this.oEditor) + { + this.oEditor.focus(); + } + + this.triggerForResize(); + }; + + PopupsComposeViewModel.prototype.editorResize = function () + { + if (this.oEditor) + { + this.oEditor.resize(); + } + }; + + PopupsComposeViewModel.prototype.tryToClosePopup = function () + { + var + self = this, + PopupsAskViewModel = __webpack_require__(/*! View:Popup:Ask */ 31) + ; + + if (!kn.isPopupVisible(PopupsAskViewModel)) + { + kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () { + if (self.modalVisibility()) + { + Utils.delegateRun(self, 'closeCommand'); + } + }]); + } + }; + + PopupsComposeViewModel.prototype.onBuild = function () + { + this.initUploader(); + + var + self = this, + oScript = null + ; + + key('ctrl+q, command+q', Enums.KeyState.Compose, function () { + self.identitiesDropdownTrigger(true); + return false; + }); + + key('ctrl+s, command+s', Enums.KeyState.Compose, function () { + self.saveCommand(); + return false; + }); + + key('ctrl+enter, command+enter', Enums.KeyState.Compose, function () { + self.sendCommand(); + return false; + }); + + key('esc', Enums.KeyState.Compose, function () { + if (self.modalVisibility()) + { + self.tryToClosePopup(); + } + return false; + }); + + Globals.$win.on('resize', function () { + self.triggerForResize(); + }); + + if (this.dropboxEnabled()) + { + oScript = window.document.createElement('script'); + oScript.type = 'text/javascript'; + oScript.src = 'https://www.dropbox.com/static/api/1/dropins.js'; + $(oScript).attr('id', 'dropboxjs').attr('data-app-key', Settings.settingsGet('DropboxApiKey')); + + window.document.body.appendChild(oScript); + } + + if (this.driveEnabled()) + { + $.getScript('https://apis.google.com/js/api.js', function () { + if (window.gapi) + { + self.driveVisible(true); + } + }); + } + }; + + PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData) + { + if (oData && window.XMLHttpRequest && window.google && + oData[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED && + oData[window.google.picker.Response.DOCUMENTS] && oData[window.google.picker.Response.DOCUMENTS][0] && + oData[window.google.picker.Response.DOCUMENTS][0]['id']) + { + var + self = this, + oRequest = new window.XMLHttpRequest() + ; + + oRequest.open('GET', 'https://www.googleapis.com/drive/v2/files/' + oData[window.google.picker.Response.DOCUMENTS][0]['id']); + oRequest.setRequestHeader('Authorization', 'Bearer ' + sAccessToken); + oRequest.addEventListener('load', function() { + if (oRequest && oRequest.responseText) + { + var oItem = JSON.parse(oRequest.responseText), fExport = function (oItem, sMimeType, sExt) { + if (oItem && oItem['exportLinks']) + { + if (oItem['exportLinks'][sMimeType]) + { + oItem['downloadUrl'] = oItem['exportLinks'][sMimeType]; + oItem['title'] = oItem['title'] + '.' + sExt; + oItem['mimeType'] = sMimeType; + } + else if (oItem['exportLinks']['application/pdf']) + { + oItem['downloadUrl'] = oItem['exportLinks']['application/pdf']; + oItem['title'] = oItem['title'] + '.pdf'; + oItem['mimeType'] = 'application/pdf'; + } + } + }; + + if (oItem && !oItem['downloadUrl'] && oItem['mimeType'] && oItem['exportLinks']) + { + switch (oItem['mimeType'].toString().toLowerCase()) + { + case 'application/vnd.google-apps.document': + fExport(oItem, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'docx'); + break; + case 'application/vnd.google-apps.spreadsheet': + fExport(oItem, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsx'); + break; + case 'application/vnd.google-apps.drawing': + fExport(oItem, 'image/png', 'png'); + break; + case 'application/vnd.google-apps.presentation': + fExport(oItem, 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pptx'); + break; + default: + fExport(oItem, 'application/pdf', 'pdf'); + break; + } + } + + if (oItem && oItem['downloadUrl']) + { + self.addDriveAttachment(oItem, sAccessToken); + } + } + }); + + oRequest.send(); + } + }; + + PopupsComposeViewModel.prototype.driveCreatePiker = function (oOauthToken) + { + if (window.gapi && oOauthToken && oOauthToken.access_token) + { + var self = this; + + window.gapi.load('picker', {'callback': function () { + + if (window.google && window.google.picker) + { + var drivePicker = new window.google.picker.PickerBuilder() + .addView( + new window.google.picker.DocsView() + .setIncludeFolders(true) + ) + .setAppId(Settings.settingsGet('GoogleClientID')) + .setOAuthToken(oOauthToken.access_token) + .setCallback(_.bind(self.driveCallback, self, oOauthToken.access_token)) + .enableFeature(window.google.picker.Feature.NAV_HIDDEN) + .build() + ; + + drivePicker.setVisible(true); + } + }}); + } + }; + + PopupsComposeViewModel.prototype.driveOpenPopup = function () + { + if (window.gapi) + { + var self = this; + + window.gapi.load('auth', {'callback': function () { + + var oAuthToken = window.gapi.auth.getToken(); + if (!oAuthToken) + { + window.gapi.auth.authorize({ + 'client_id': Settings.settingsGet('GoogleClientID'), + 'scope': 'https://www.googleapis.com/auth/drive.readonly', + 'immediate': true + }, function (oAuthResult) { + if (oAuthResult && !oAuthResult.error) + { + var oAuthToken = window.gapi.auth.getToken(); + if (oAuthToken) + { + self.driveCreatePiker(oAuthToken); + } + } + else + { + window.gapi.auth.authorize({ + 'client_id': Settings.settingsGet('GoogleClientID'), + 'scope': 'https://www.googleapis.com/auth/drive.readonly', + 'immediate': false + }, function (oAuthResult) { + if (oAuthResult && !oAuthResult.error) + { + var oAuthToken = window.gapi.auth.getToken(); + if (oAuthToken) + { + self.driveCreatePiker(oAuthToken); + } + } + }); + } + }); + } + else + { + self.driveCreatePiker(oAuthToken); + } + }}); + } + }; + + /** + * @param {string} sId + * @return {?Object} + */ + PopupsComposeViewModel.prototype.getAttachmentById = function (sId) + { + var + aAttachments = this.attachments(), + iIndex = 0, + iLen = aAttachments.length + ; + + for (; iIndex < iLen; iIndex++) + { + if (aAttachments[iIndex] && sId === aAttachments[iIndex].id) + { + return aAttachments[iIndex]; + } + } + + return null; + }; + + PopupsComposeViewModel.prototype.initUploader = function () + { + if (this.composeUploaderButton()) + { + var + oUploadCache = {}, + iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')), + oJua = new Jua({ + 'action': LinkBuilder.upload(), + 'name': 'uploader', + 'queueSize': 2, + 'multipleSizeLimit': 50, + 'disableFolderDragAndDrop': false, + 'clickElement': this.composeUploaderButton(), + 'dragAndDropElement': this.composeUploaderDropPlace() + }) + ; + + if (oJua) + { + oJua + // .on('onLimitReached', function (iLimit) { + // alert(iLimit); + // }) + .on('onDragEnter', _.bind(function () { + this.dragAndDropOver(true); + }, this)) + .on('onDragLeave', _.bind(function () { + this.dragAndDropOver(false); + }, this)) + .on('onBodyDragEnter', _.bind(function () { + this.dragAndDropVisible(true); + }, this)) + .on('onBodyDragLeave', _.bind(function () { + this.dragAndDropVisible(false); + }, this)) + .on('onProgress', _.bind(function (sId, iLoaded, iTotal) { + var oItem = null; + if (Utils.isUnd(oUploadCache[sId])) + { + oItem = this.getAttachmentById(sId); + if (oItem) + { + oUploadCache[sId] = oItem; + } + } + else + { + oItem = oUploadCache[sId]; + } + + if (oItem) + { + oItem.progress(' - ' + window.Math.floor(iLoaded / iTotal * 100) + '%'); + } + + }, this)) + .on('onSelect', _.bind(function (sId, oData) { + + this.dragAndDropOver(false); + + var + that = this, + sFileName = Utils.isUnd(oData.FileName) ? '' : oData.FileName.toString(), + mSize = Utils.isNormal(oData.Size) ? Utils.pInt(oData.Size) : null, + oAttachment = new ComposeAttachmentModel(sId, sFileName, mSize) + ; + + oAttachment.cancel = (function (sId) { + + return function () { + that.attachments.remove(function (oItem) { + return oItem && oItem.id === sId; + }); + + if (oJua) + { + oJua.cancel(sId); + } + }; + + }(sId)); + + this.attachments.push(oAttachment); + + if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize) + { + oAttachment.error(Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG')); + return false; + } + + return true; + + }, this)) + .on('onStart', _.bind(function (sId) { + + var + oItem = null + ; + + if (Utils.isUnd(oUploadCache[sId])) + { + oItem = this.getAttachmentById(sId); + if (oItem) + { + oUploadCache[sId] = oItem; + } + } + else + { + oItem = oUploadCache[sId]; + } + + if (oItem) + { + oItem.waiting(false); + oItem.uploading(true); + } + + }, this)) + .on('onComplete', _.bind(function (sId, bResult, oData) { + + var + sError = '', + mErrorCode = null, + oAttachmentJson = null, + oAttachment = this.getAttachmentById(sId) + ; + + oAttachmentJson = bResult && oData && oData.Result && oData.Result.Attachment ? oData.Result.Attachment : null; + mErrorCode = oData && oData.Result && oData.Result.ErrorCode ? oData.Result.ErrorCode : null; + + if (null !== mErrorCode) + { + sError = Utils.getUploadErrorDescByCode(mErrorCode); + } + else if (!oAttachmentJson) + { + sError = Utils.i18n('UPLOAD/ERROR_UNKNOWN'); + } + + if (oAttachment) + { + if ('' !== sError && 0 < sError.length) + { + oAttachment + .waiting(false) + .uploading(false) + .error(sError) + ; + } + else if (oAttachmentJson) + { + oAttachment + .waiting(false) + .uploading(false) + ; + + oAttachment.initByUploadJson(oAttachmentJson); + } + + if (Utils.isUnd(oUploadCache[sId])) + { + delete (oUploadCache[sId]); + } + } + + }, this)) + ; + + this + .addAttachmentEnabled(true) + .dragAndDropEnabled(oJua.isDragAndDropSupported()) + ; + } + else + { + this + .addAttachmentEnabled(false) + .dragAndDropEnabled(false) + ; + } + } + }; + + /** + * @return {Object} + */ + PopupsComposeViewModel.prototype.prepearAttachmentsForSendOrSave = function () + { + var oResult = {}; + _.each(this.attachmentsInReady(), function (oItem) { + if (oItem && '' !== oItem.tempName() && oItem.enabled()) + { + oResult[oItem.tempName()] = [ + oItem.fileName(), + oItem.isInline ? '1' : '0', + oItem.CID, + oItem.contentLocation + ]; + } + }); + + return oResult; + }; + + /** + * @param {MessageModel} oMessage + */ + PopupsComposeViewModel.prototype.addMessageAsAttachment = function (oMessage) + { + if (oMessage) + { + var + self = this, + oAttachment = null, + sTemp = oMessage.subject(), + fCancelFunc = function (sId) { + return function () { + self.attachments.remove(function (oItem) { + return oItem && oItem.id === sId; + }); + }; + } + ; + + sTemp = '.eml' === sTemp.substr(-4).toLowerCase() ? sTemp : sTemp + '.eml'; + oAttachment = new ComposeAttachmentModel( + oMessage.requestHash, sTemp, oMessage.size() + ); + + oAttachment.fromMessage = true; + oAttachment.cancel = fCancelFunc(oMessage.requestHash); + oAttachment.waiting(false).uploading(true); + + this.attachments.push(oAttachment); + } + }; + + /** + * @param {Object} oDropboxFile + * @return {boolean} + */ + PopupsComposeViewModel.prototype.addDropboxAttachment = function (oDropboxFile) + { + var + self = this, + oAttachment = null, + fCancelFunc = function (sId) { + return function () { + self.attachments.remove(function (oItem) { + return oItem && oItem.id === sId; + }); + }; + }, + iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')), + mSize = oDropboxFile['bytes'] + ; + + oAttachment = new ComposeAttachmentModel( + oDropboxFile['link'], oDropboxFile['name'], mSize + ); + + oAttachment.fromMessage = false; + oAttachment.cancel = fCancelFunc(oDropboxFile['link']); + oAttachment.waiting(false).uploading(true); + + this.attachments.push(oAttachment); + + if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize) + { + oAttachment.uploading(false); + oAttachment.error(Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG')); + return false; + } + + Remote.composeUploadExternals(function (sResult, oData) { + + var bResult = false; + oAttachment.uploading(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + if (oData.Result[oAttachment.id]) + { + bResult = true; + oAttachment.tempName(oData.Result[oAttachment.id]); + } + } + + if (!bResult) + { + oAttachment.error(Utils.getUploadErrorDescByCode(Enums.UploadErrorCode.FileNoUploaded)); + } + + }, [oDropboxFile['link']]); + + return true; + }; + + /** + * @param {Object} oDriveFile + * @param {string} sAccessToken + * @return {boolean} + */ + PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAccessToken) + { + var + self = this, + fCancelFunc = function (sId) { + return function () { + self.attachments.remove(function (oItem) { + return oItem && oItem.id === sId; + }); + }; + }, + iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')), + oAttachment = null, + mSize = oDriveFile['fileSize'] ? Utils.pInt(oDriveFile['fileSize']) : 0 + ; + + oAttachment = new ComposeAttachmentModel( + oDriveFile['downloadUrl'], oDriveFile['title'], mSize + ); + + oAttachment.fromMessage = false; + oAttachment.cancel = fCancelFunc(oDriveFile['downloadUrl']); + oAttachment.waiting(false).uploading(true); + + this.attachments.push(oAttachment); + + if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize) + { + oAttachment.uploading(false); + oAttachment.error(Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG')); + return false; + } + + Remote.composeUploadDrive(function (sResult, oData) { + + var bResult = false; + oAttachment.uploading(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + if (oData.Result[oAttachment.id]) + { + bResult = true; + oAttachment.tempName(oData.Result[oAttachment.id][0]); + oAttachment.size(Utils.pInt(oData.Result[oAttachment.id][1])); + } + } + + if (!bResult) + { + oAttachment.error(Utils.getUploadErrorDescByCode(Enums.UploadErrorCode.FileNoUploaded)); + } + + }, oDriveFile['downloadUrl'], sAccessToken); + + return true; + }; + + /** + * @param {MessageModel} oMessage + * @param {string} sType + */ + PopupsComposeViewModel.prototype.prepearMessageAttachments = function (oMessage, sType) + { + if (oMessage) + { + var + self = this, + aAttachments = Utils.isNonEmptyArray(oMessage.attachments()) ? oMessage.attachments() : [], + iIndex = 0, + iLen = aAttachments.length, + oAttachment = null, + oItem = null, + bAdd = false, + fCancelFunc = function (sId) { + return function () { + self.attachments.remove(function (oItem) { + return oItem && oItem.id === sId; + }); + }; + } + ; + + if (Enums.ComposeType.ForwardAsAttachment === sType) + { + this.addMessageAsAttachment(oMessage); + } + else + { + for (; iIndex < iLen; iIndex++) + { + oItem = aAttachments[iIndex]; + + bAdd = false; + switch (sType) { + case Enums.ComposeType.Reply: + case Enums.ComposeType.ReplyAll: + bAdd = oItem.isLinked; + break; + + case Enums.ComposeType.Forward: + case Enums.ComposeType.Draft: + case Enums.ComposeType.EditAsNew: + bAdd = true; + break; + } + + if (bAdd) + { + oAttachment = new ComposeAttachmentModel( + oItem.download, oItem.fileName, oItem.estimatedSize, + oItem.isInline, oItem.isLinked, oItem.cid, oItem.contentLocation + ); + + oAttachment.fromMessage = true; + oAttachment.cancel = fCancelFunc(oItem.download); + oAttachment.waiting(false).uploading(true); + + this.attachments.push(oAttachment); + } + } + } + } + }; + + PopupsComposeViewModel.prototype.removeLinkedAttachments = function () + { + this.attachments.remove(function (oItem) { + return oItem && oItem.isLinked; + }); + }; + + PopupsComposeViewModel.prototype.setMessageAttachmentFailedDowbloadText = function () + { + _.each(this.attachments(), function(oAttachment) { + if (oAttachment && oAttachment.fromMessage) + { + oAttachment + .waiting(false) + .uploading(false) + .error(Utils.getUploadErrorDescByCode(Enums.UploadErrorCode.FileNoUploaded)) + ; + } + }, this); + }; + + /** + * @param {boolean=} bIncludeAttachmentInProgress = true + * @return {boolean} + */ + PopupsComposeViewModel.prototype.isEmptyForm = function (bIncludeAttachmentInProgress) + { + bIncludeAttachmentInProgress = Utils.isUnd(bIncludeAttachmentInProgress) ? true : !!bIncludeAttachmentInProgress; + var bAttach = bIncludeAttachmentInProgress ? + 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 && + bAttach && + (!this.oEditor || '' === this.oEditor.getData()) + ; + }; + + PopupsComposeViewModel.prototype.reset = function () + { + this.to(''); + this.cc(''); + this.bcc(''); + this.replyTo(''); + this.subject(''); + + this.requestReadReceipt(false); + + this.aDraftInfo = null; + this.sInReplyTo = ''; + this.bFromDraft = false; + this.sReferences = ''; + + this.sendError(false); + this.sendSuccessButSaveError(false); + this.savedError(false); + this.savedTime(0); + this.savedOrSendingText(''); + this.emptyToError(false); + this.attachmentsInProcessError(false); + this.showCcAndBcc(false); + + this.attachments([]); + this.dragAndDropOver(false); + this.dragAndDropVisible(false); + + this.draftFolder(''); + this.draftUid(''); + + this.sending(false); + this.saving(false); + + if (this.oEditor) + { + this.oEditor.clear(false); + } + }; + + /** + * @return {Array} + */ + PopupsComposeViewModel.prototype.getAttachmentsDownloadsForUpload = function () + { + return _.map(_.filter(this.attachments(), function (oItem) { + return oItem && '' === oItem.tempName(); + }), function (oItem) { + return oItem.id; + }); + }; + + PopupsComposeViewModel.prototype.triggerForResize = function () + { + this.resizer(!this.resizer()); + this.editorResizeThrottle(); + }; + + module.exports = PopupsComposeViewModel; + + }()); + +/***/ }, +/* 22 */, +/* 23 */, +/* 24 */, +/* 25 */, +/* 26 */, +/* 27 */, +/* 28 */ +/*!**********************************!*\ + !*** ./dev/Common/HtmlEditor.js ***! + \**********************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + + Globals = __webpack_require__(/*! Common/Globals */ 7), + Settings = __webpack_require__(/*! Storage:Settings */ 10) + ; + + /** + * @constructor + * @param {Object} oElement + * @param {Function=} fOnBlur + * @param {Function=} fOnReady + * @param {Function=} fOnModeChange + */ + function HtmlEditor(oElement, fOnBlur, fOnReady, fOnModeChange) + { + this.editor = null; + this.iBlurTimer = 0; + this.fOnBlur = fOnBlur || null; + this.fOnReady = fOnReady || null; + this.fOnModeChange = fOnModeChange || null; + + this.$element = $(oElement); + + this.resize = _.throttle(_.bind(this.resize, this), 100); + + this.init(); + } + + HtmlEditor.prototype.blurTrigger = function () + { + if (this.fOnBlur) + { + var self = this; + window.clearTimeout(this.iBlurTimer); + this.iBlurTimer = window.setTimeout(function () { + self.fOnBlur(); + }, 200); + } + }; + + HtmlEditor.prototype.focusTrigger = function () + { + if (this.fOnBlur) + { + window.clearTimeout(this.iBlurTimer); + } + }; + + /** + * @return {boolean} + */ + HtmlEditor.prototype.isHtml = function () + { + return this.editor ? 'wysiwyg' === this.editor.mode : false; + }; + + /** + * @return {boolean} + */ + HtmlEditor.prototype.checkDirty = function () + { + return this.editor ? this.editor.checkDirty() : false; + }; + + HtmlEditor.prototype.resetDirty = function () + { + if (this.editor) + { + this.editor.resetDirty(); + } + }; + + /** + * @return {string} + */ + HtmlEditor.prototype.getData = function (bWrapIsHtml) + { + if (this.editor) + { + if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain) + { + return this.editor.__plain.getRawData(); + } + + return bWrapIsHtml ? + '
' + + this.editor.getData() + '
' : this.editor.getData(); + } + + return ''; + }; + + HtmlEditor.prototype.modeToggle = function (bPlain) + { + if (this.editor) + { + if (bPlain) + { + if ('plain' === this.editor.mode) + { + this.editor.setMode('wysiwyg'); + } + } + else + { + if ('wysiwyg' === this.editor.mode) + { + this.editor.setMode('plain'); + } + } + + this.resize(); + } + }; + + HtmlEditor.prototype.setHtml = function (sHtml, bFocus) + { + if (this.editor) + { + this.modeToggle(true); + this.editor.setData(sHtml); + + if (bFocus) + { + this.focus(); + } + } + }; + + HtmlEditor.prototype.setPlain = function (sPlain, bFocus) + { + if (this.editor) + { + this.modeToggle(false); + if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain) + { + return this.editor.__plain.setRawData(sPlain); + } + else + { + this.editor.setData(sPlain); + } + + if (bFocus) + { + this.focus(); + } + } + }; + + HtmlEditor.prototype.init = function () + { + if (this.$element && this.$element[0]) + { + var + self = this, + fInit = function () { + + var + oConfig = Globals.oHtmlEditorDefaultConfig, + sLanguage = Settings.settingsGet('Language'), + bSource = !!Settings.settingsGet('AllowHtmlEditorSourceButton') + ; + + if (bSource && oConfig.toolbarGroups && !oConfig.toolbarGroups.__SourceInited) + { + oConfig.toolbarGroups.__SourceInited = true; + oConfig.toolbarGroups.push({name: 'document', groups: ['mode', 'document', 'doctools']}); + } + + oConfig.enterMode = window.CKEDITOR.ENTER_BR; + oConfig.shiftEnterMode = window.CKEDITOR.ENTER_BR; + + oConfig.language = Globals.oHtmlEditorLangsMap[sLanguage] || 'en'; + if (window.CKEDITOR.env) + { + window.CKEDITOR.env.isCompatible = true; + } + + self.editor = window.CKEDITOR.appendTo(self.$element[0], oConfig); + + self.editor.on('key', function(oEvent) { + if (oEvent && oEvent.data && 9 /* Tab */ === oEvent.data.keyCode) + { + return false; + } + }); + + self.editor.on('blur', function() { + self.blurTrigger(); + }); + + self.editor.on('mode', function() { + + self.blurTrigger(); + + if (self.fOnModeChange) + { + self.fOnModeChange('plain' !== self.editor.mode); + } + }); + + self.editor.on('focus', function() { + self.focusTrigger(); + }); + + if (self.fOnReady) + { + self.editor.on('instanceReady', function () { + + self.editor.setKeystroke(window.CKEDITOR.CTRL + 65 /* A */, 'selectAll'); + + self.fOnReady(); + self.__resizable = true; + self.resize(); + }); + } + } + ; + + if (window.CKEDITOR) + { + fInit(); + } + else + { + window.__initEditor = fInit; + } + } + }; + + HtmlEditor.prototype.focus = function () + { + if (this.editor) + { + this.editor.focus(); + } + }; + + HtmlEditor.prototype.blur = function () + { + if (this.editor) + { + this.editor.focusManager.blur(true); + } + }; + + HtmlEditor.prototype.resize = function () + { + if (this.editor && this.__resizable) + { + try + { + this.editor.resize(this.$element.width(), this.$element.innerHeight()); + } + catch (e) {} + } + }; + + HtmlEditor.prototype.clear = function (bFocus) + { + this.setHtml('', bFocus); + }; + + + module.exports = HtmlEditor; + + }()); + +/***/ }, +/* 29 */ +/*!***********************************************!*\ + !*** ./dev/Screens/AbstractSettingsScreen.js ***! + \***********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractScreen = __webpack_require__(/*! Knoin:AbstractScreen */ 24) + ; + + /** + * @constructor + * @param {Array} aViewModels + * @extends KnoinAbstractScreen + */ + function AbstractSettingsScreen(aViewModels) + { + KnoinAbstractScreen.call(this, 'settings', aViewModels); + + this.menu = ko.observableArray([]); + + this.oCurrentSubScreen = null; + this.oViewModelPlace = null; + + this.setupSettings(); + } + + _.extend(AbstractSettingsScreen.prototype, KnoinAbstractScreen.prototype); + + /** + * @param {Function=} fCallback + */ + AbstractSettingsScreen.prototype.setupSettings = function (fCallback) + { + if (fCallback) + { + fCallback(); + } + }; + + AbstractSettingsScreen.prototype.onRoute = function (sSubName) + { + var + self = this, + oSettingsScreen = null, + RoutedSettingsViewModel = null, + oViewModelPlace = null, + oViewModelDom = null + ; + + RoutedSettingsViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) { + return SettingsViewModel && SettingsViewModel.__rlSettingsData && + sSubName === SettingsViewModel.__rlSettingsData.Route; + }); + + if (RoutedSettingsViewModel) + { + if (_.find(Globals.aViewModels['settings-removed'], function (DisabledSettingsViewModel) { + return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel; + })) + { + RoutedSettingsViewModel = null; + } + + if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { + return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel; + })) + { + RoutedSettingsViewModel = null; + } + } + + if (RoutedSettingsViewModel) + { + if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm) + { + oSettingsScreen = RoutedSettingsViewModel.__vm; + } + else + { + oViewModelPlace = this.oViewModelPlace; + if (oViewModelPlace && 1 === oViewModelPlace.length) + { + oSettingsScreen = new RoutedSettingsViewModel(); + + oViewModelDom = $('
').addClass('rl-settings-view-model').hide(); + oViewModelDom.appendTo(oViewModelPlace); + + oSettingsScreen.viewModelDom = oViewModelDom; + + oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData; + + RoutedSettingsViewModel.__dom = oViewModelDom; + RoutedSettingsViewModel.__builded = true; + RoutedSettingsViewModel.__vm = oSettingsScreen; + + ko.applyBindingAccessorsToNode(oViewModelDom[0], { + 'i18nInit': true, + 'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; } + }, oSettingsScreen); + + Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]); + } + else + { + Utils.log('Cannot find sub settings view model position: SettingsSubScreen'); + } + } + + if (oSettingsScreen) + { + _.defer(function () { + // hide + if (self.oCurrentSubScreen) + { + Utils.delegateRun(self.oCurrentSubScreen, 'onHide'); + self.oCurrentSubScreen.viewModelDom.hide(); + } + // -- + + self.oCurrentSubScreen = oSettingsScreen; + + // show + if (self.oCurrentSubScreen) + { + self.oCurrentSubScreen.viewModelDom.show(); + Utils.delegateRun(self.oCurrentSubScreen, 'onShow'); + Utils.delegateRun(self.oCurrentSubScreen, 'onFocus', [], 200); + + _.each(self.menu(), function (oItem) { + oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route); + }); + + $('#rl-content .b-settings .b-content .content').scrollTop(0); + } + // -- + + Utils.windowResize(); + }); + } + } + else + { + kn.setHash(LinkBuilder.settings(), false, true); + } + }; + + AbstractSettingsScreen.prototype.onHide = function () + { + if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom) + { + Utils.delegateRun(this.oCurrentSubScreen, 'onHide'); + this.oCurrentSubScreen.viewModelDom.hide(); + } + }; + + AbstractSettingsScreen.prototype.onBuild = function () + { + _.each(Globals.aViewModels['settings'], function (SettingsViewModel) { + if (SettingsViewModel && SettingsViewModel.__rlSettingsData && + !_.find(Globals.aViewModels['settings-removed'], function (RemoveSettingsViewModel) { + return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel; + })) + { + this.menu.push({ + 'route': SettingsViewModel.__rlSettingsData.Route, + 'label': SettingsViewModel.__rlSettingsData.Label, + 'selected': ko.observable(false), + 'disabled': !!_.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { + return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel; + }) + }); + } + }, this); + + this.oViewModelPlace = $('#rl-content #rl-settings-subscreen'); + }; + + AbstractSettingsScreen.prototype.routes = function () + { + var + DefaultViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) { + return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData['IsDefault']; + }), + sDefaultRoute = DefaultViewModel ? DefaultViewModel.__rlSettingsData['Route'] : 'general', + oRules = { + 'subname': /^(.*)$/, + 'normalize_': function (oRequest, oVals) { + oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname); + return [oVals.subname]; + } + } + ; + + return [ + ['{subname}/', oRules], + ['{subname}', oRules], + ['', oRules] + ]; + }; + + module.exports = AbstractSettingsScreen; + + }()); + +/***/ }, +/* 30 */, +/* 31 */, +/* 32 */, +/* 33 */, +/* 34 */, +/* 35 */, +/* 36 */ +/*!********************************!*\ + !*** ./dev/Common/Selector.js ***! + \********************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + * @param {koProperty} oKoList + * @param {koProperty} oKoSelectedItem + * @param {string} sItemSelector + * @param {string} sItemSelectedSelector + * @param {string} sItemCheckedSelector + * @param {string} sItemFocusedSelector + */ + function Selector(oKoList, oKoSelectedItem, + sItemSelector, sItemSelectedSelector, sItemCheckedSelector, sItemFocusedSelector) + { + this.list = oKoList; + + this.listChecked = ko.computed(function () { + return _.filter(this.list(), function (oItem) { + return oItem.checked(); + }); + }, this).extend({'rateLimit': 0}); + + this.isListChecked = ko.computed(function () { + return 0 < this.listChecked().length; + }, this); + + this.focusedItem = ko.observable(null); + this.selectedItem = oKoSelectedItem; + this.selectedItemUseCallback = true; + + this.itemSelectedThrottle = _.debounce(_.bind(this.itemSelected, this), 300); + + this.listChecked.subscribe(function (aItems) { + if (0 < aItems.length) + { + if (null === this.selectedItem()) + { + this.selectedItem.valueHasMutated(); + } + else + { + this.selectedItem(null); + } + } + else if (this.bAutoSelect && this.focusedItem()) + { + this.selectedItem(this.focusedItem()); + } + }, this); + + this.selectedItem.subscribe(function (oItem) { + + if (oItem) + { + if (this.isListChecked()) + { + _.each(this.listChecked(), function (oSubItem) { + oSubItem.checked(false); + }); + } + + if (this.selectedItemUseCallback) + { + this.itemSelectedThrottle(oItem); + } + } + else if (this.selectedItemUseCallback) + { + this.itemSelected(null); + } + + }, this); + + this.selectedItem.extend({'toggleSubscribe': [null, + function (oPrev) { + if (oPrev) + { + oPrev.selected(false); + } + }, function (oNext) { + if (oNext) + { + oNext.selected(true); + } + } + ]}); + + this.focusedItem.extend({'toggleSubscribe': [null, + function (oPrev) { + if (oPrev) + { + oPrev.focused(false); + } + }, function (oNext) { + if (oNext) + { + oNext.focused(true); + } + } + ]}); + + this.oContentVisible = null; + this.oContentScrollable = null; + + this.sItemSelector = sItemSelector; + this.sItemSelectedSelector = sItemSelectedSelector; + this.sItemCheckedSelector = sItemCheckedSelector; + this.sItemFocusedSelector = sItemFocusedSelector; + + this.sLastUid = ''; + this.bAutoSelect = true; + this.oCallbacks = {}; + + this.emptyFunction = function () {}; + + this.focusedItem.subscribe(function (oItem) { + if (oItem) + { + this.sLastUid = this.getItemUid(oItem); + } + }, this); + + var + aCache = [], + aCheckedCache = [], + mFocused = null, + mSelected = null + ; + + this.list.subscribe(function (aItems) { + + var self = this; + if (Utils.isArray(aItems)) + { + _.each(aItems, function (oItem) { + if (oItem) + { + var sUid = self.getItemUid(oItem); + + aCache.push(sUid); + if (oItem.checked()) + { + aCheckedCache.push(sUid); + } + if (null === mFocused && oItem.focused()) + { + mFocused = sUid; + } + if (null === mSelected && oItem.selected()) + { + mSelected = sUid; + } + } + }); + } + }, this, 'beforeChange'); + + this.list.subscribe(function (aItems) { + + var + self = this, + oTemp = null, + bGetNext = false, + aUids = [], + mNextFocused = mFocused, + bChecked = false, + bSelected = false, + iLen = 0 + ; + + this.selectedItemUseCallback = false; + + this.focusedItem(null); + this.selectedItem(null); + + if (Utils.isArray(aItems)) + { + iLen = aCheckedCache.length; + + _.each(aItems, function (oItem) { + + var sUid = self.getItemUid(oItem); + aUids.push(sUid); + + if (null !== mFocused && mFocused === sUid) + { + self.focusedItem(oItem); + mFocused = null; + } + + if (0 < iLen && -1 < Utils.inArray(sUid, aCheckedCache)) + { + bChecked = true; + oItem.checked(true); + iLen--; + } + + if (!bChecked && null !== mSelected && mSelected === sUid) + { + bSelected = true; + self.selectedItem(oItem); + mSelected = null; + } + }); + + this.selectedItemUseCallback = true; + + if (!bChecked && !bSelected && this.bAutoSelect) + { + if (self.focusedItem()) + { + self.selectedItem(self.focusedItem()); + } + else if (0 < aItems.length) + { + if (null !== mNextFocused) + { + bGetNext = false; + mNextFocused = _.find(aCache, function (sUid) { + if (bGetNext && -1 < Utils.inArray(sUid, aUids)) + { + return sUid; + } + else if (mNextFocused === sUid) + { + bGetNext = true; + } + return false; + }); + + if (mNextFocused) + { + oTemp = _.find(aItems, function (oItem) { + return mNextFocused === self.getItemUid(oItem); + }); + } + } + + self.selectedItem(oTemp || null); + self.focusedItem(self.selectedItem()); + } + } + } + + aCache = []; + aCheckedCache = []; + mFocused = null; + mSelected = null; + + }, this); + } + + Selector.prototype.itemSelected = function (oItem) + { + if (this.isListChecked()) + { + if (!oItem) + { + (this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem || null); + } + } + else + { + if (oItem) + { + (this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem); + } + } + }; + + Selector.prototype.goDown = function (bForceSelect) + { + this.newSelectPosition(Enums.EventKeyCode.Down, false, bForceSelect); + }; + + Selector.prototype.goUp = function (bForceSelect) + { + this.newSelectPosition(Enums.EventKeyCode.Up, false, bForceSelect); + }; + + Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeyScope) + { + this.oContentVisible = oContentVisible; + this.oContentScrollable = oContentScrollable; + + sKeyScope = sKeyScope || 'all'; + + if (this.oContentVisible && this.oContentScrollable) + { + var + self = this + ; + + $(this.oContentVisible) + .on('selectstart', function (oEvent) { + if (oEvent && oEvent.preventDefault) + { + oEvent.preventDefault(); + } + }) + .on('click', this.sItemSelector, function (oEvent) { + self.actionClick(ko.dataFor(this), oEvent); + }) + .on('click', this.sItemCheckedSelector, function (oEvent) { + var oItem = ko.dataFor(this); + if (oItem) + { + if (oEvent && oEvent.shiftKey) + { + self.actionClick(oItem, oEvent); + } + else + { + self.focusedItem(oItem); + oItem.checked(!oItem.checked()); + } + } + }) + ; + + key('enter', sKeyScope, function () { + if (self.focusedItem() && !self.focusedItem().selected()) + { + self.actionClick(self.focusedItem()); + return false; + } + + return true; + }); + + key('ctrl+up, command+up, ctrl+down, command+down', sKeyScope, function () { + return false; + }); + + key('up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space', sKeyScope, function (event, handler) { + if (event && handler && handler.shortcut) + { + // TODO + var iKey = 0; + switch (handler.shortcut) + { + case 'up': + case 'shift+up': + iKey = Enums.EventKeyCode.Up; + break; + case 'down': + case 'shift+down': + iKey = Enums.EventKeyCode.Down; + break; + case 'insert': + iKey = Enums.EventKeyCode.Insert; + break; + case 'space': + iKey = Enums.EventKeyCode.Space; + break; + case 'home': + iKey = Enums.EventKeyCode.Home; + break; + case 'end': + iKey = Enums.EventKeyCode.End; + break; + case 'pageup': + iKey = Enums.EventKeyCode.PageUp; + break; + case 'pagedown': + iKey = Enums.EventKeyCode.PageDown; + break; + } + + if (0 < iKey) + { + self.newSelectPosition(iKey, key.shift); + return false; + } + } + }); + } + }; + + Selector.prototype.autoSelect = function (bValue) + { + this.bAutoSelect = !!bValue; + }; + + /** + * @param {Object} oItem + * @returns {string} + */ + Selector.prototype.getItemUid = function (oItem) + { + var + sUid = '', + fGetItemUidCallback = this.oCallbacks['onItemGetUid'] || null + ; + + if (fGetItemUidCallback && oItem) + { + sUid = fGetItemUidCallback(oItem); + } + + return sUid.toString(); + }; + + /** + * @param {number} iEventKeyCode + * @param {boolean} bShiftKey + * @param {boolean=} bForceSelect = false + */ + Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForceSelect) + { + var + iIndex = 0, + iPageStep = 10, + bNext = false, + bStop = false, + oResult = null, + aList = this.list(), + iListLen = aList ? aList.length : 0, + oFocused = this.focusedItem() + ; + + if (0 < iListLen) + { + if (!oFocused) + { + if (Enums.EventKeyCode.Down === iEventKeyCode || Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode || Enums.EventKeyCode.Home === iEventKeyCode || Enums.EventKeyCode.PageUp === iEventKeyCode) + { + oResult = aList[0]; + } + else if (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.End === iEventKeyCode || Enums.EventKeyCode.PageDown === iEventKeyCode) + { + oResult = aList[aList.length - 1]; + } + } + else if (oFocused) + { + if (Enums.EventKeyCode.Down === iEventKeyCode || Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode) + { + _.each(aList, function (oItem) { + if (!bStop) + { + switch (iEventKeyCode) { + case Enums.EventKeyCode.Up: + if (oFocused === oItem) + { + bStop = true; + } + else + { + oResult = oItem; + } + break; + case Enums.EventKeyCode.Down: + case Enums.EventKeyCode.Insert: + if (bNext) + { + oResult = oItem; + bStop = true; + } + else if (oFocused === oItem) + { + bNext = true; + } + break; + } + } + }); + } + else if (Enums.EventKeyCode.Home === iEventKeyCode || Enums.EventKeyCode.End === iEventKeyCode) + { + if (Enums.EventKeyCode.Home === iEventKeyCode) + { + oResult = aList[0]; + } + else if (Enums.EventKeyCode.End === iEventKeyCode) + { + oResult = aList[aList.length - 1]; + } + } + else if (Enums.EventKeyCode.PageDown === iEventKeyCode) + { + for (; iIndex < iListLen; iIndex++) + { + if (oFocused === aList[iIndex]) + { + iIndex += iPageStep; + iIndex = iListLen - 1 < iIndex ? iListLen - 1 : iIndex; + oResult = aList[iIndex]; + break; + } + } + } + else if (Enums.EventKeyCode.PageUp === iEventKeyCode) + { + for (iIndex = iListLen; iIndex >= 0; iIndex--) + { + if (oFocused === aList[iIndex]) + { + iIndex -= iPageStep; + iIndex = 0 > iIndex ? 0 : iIndex; + oResult = aList[iIndex]; + break; + } + } + } + } + } + + if (oResult) + { + this.focusedItem(oResult); + + if (oFocused) + { + if (bShiftKey) + { + if (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.Down === iEventKeyCode) + { + oFocused.checked(!oFocused.checked()); + } + } + else if (Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode) + { + oFocused.checked(!oFocused.checked()); + } + } + + if ((this.bAutoSelect || !!bForceSelect) && + !this.isListChecked() && Enums.EventKeyCode.Space !== iEventKeyCode) + { + this.selectedItem(oResult); + } + + this.scrollToFocused(); + } + else if (oFocused) + { + if (bShiftKey && (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.Down === iEventKeyCode)) + { + oFocused.checked(!oFocused.checked()); + } + else if (Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode) + { + oFocused.checked(!oFocused.checked()); + } + + this.focusedItem(oFocused); + } + }; + + /** + * @return {boolean} + */ + Selector.prototype.scrollToFocused = function () + { + if (!this.oContentVisible || !this.oContentScrollable) + { + return false; + } + + var + iOffset = 20, + oFocused = $(this.sItemFocusedSelector, this.oContentScrollable), + oPos = oFocused.position(), + iVisibleHeight = this.oContentVisible.height(), + iFocusedHeight = oFocused.outerHeight() + ; + + if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight)) + { + if (oPos.top < 0) + { + this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset); + } + else + { + this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset); + } + + return true; + } + + return false; + }; + + /** + * @param {boolean=} bFast = false + * @return {boolean} + */ + Selector.prototype.scrollToTop = function (bFast) + { + if (!this.oContentVisible || !this.oContentScrollable) + { + return false; + } + + if (bFast) + { + this.oContentScrollable.scrollTop(0); + } + else + { + this.oContentScrollable.stop().animate({'scrollTop': 0}, 200); + } + + return true; + }; + + Selector.prototype.eventClickFunction = function (oItem, oEvent) + { + var + sUid = this.getItemUid(oItem), + iIndex = 0, + iLength = 0, + oListItem = null, + sLineUid = '', + bChangeRange = false, + bIsInRange = false, + aList = [], + bChecked = false + ; + + if (oEvent && oEvent.shiftKey) + { + if ('' !== sUid && '' !== this.sLastUid && sUid !== this.sLastUid) + { + aList = this.list(); + bChecked = oItem.checked(); + + for (iIndex = 0, iLength = aList.length; iIndex < iLength; iIndex++) + { + oListItem = aList[iIndex]; + sLineUid = this.getItemUid(oListItem); + + bChangeRange = false; + if (sLineUid === this.sLastUid || sLineUid === sUid) + { + bChangeRange = true; + } + + if (bChangeRange) + { + bIsInRange = !bIsInRange; + } + + if (bIsInRange || bChangeRange) + { + oListItem.checked(bChecked); + } + } + } + } + + this.sLastUid = '' === sUid ? '' : sUid; + }; + + /** + * @param {Object} oItem + * @param {Object=} oEvent + */ + Selector.prototype.actionClick = function (oItem, oEvent) + { + if (oItem) + { + var + bClick = true, + sUid = this.getItemUid(oItem) + ; + + if (oEvent) + { + if (oEvent.shiftKey && !oEvent.ctrlKey && !oEvent.altKey) + { + bClick = false; + if ('' === this.sLastUid) + { + this.sLastUid = sUid; + } + + oItem.checked(!oItem.checked()); + this.eventClickFunction(oItem, oEvent); + + this.focusedItem(oItem); + } + else if (oEvent.ctrlKey && !oEvent.shiftKey && !oEvent.altKey) + { + bClick = false; + this.focusedItem(oItem); + + if (this.selectedItem() && oItem !== this.selectedItem()) + { + this.selectedItem().checked(true); + } + + oItem.checked(!oItem.checked()); + } + } + + if (bClick) + { + this.focusedItem(oItem); + this.selectedItem(oItem); + + this.scrollToFocused(); + } + } + }; + + Selector.prototype.on = function (sEventName, fCallback) + { + this.oCallbacks[sEventName] = fCallback; + }; + + module.exports = Selector; + + }()); + +/***/ }, +/* 37 */, +/* 38 */, +/* 39 */, +/* 40 */, +/* 41 */ +/*!***********************************************************!*\ + !*** ./dev/ViewModels/AbstractSystemDropDownViewModel.js ***! + \***********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function AbstractSystemDropDownViewModel() + { + KnoinAbstractViewModel.call(this, 'Right', 'SystemDropDown'); + + this.accounts = Data.accounts; + this.accountEmail = Data.accountEmail; + this.accountsLoading = Data.accountsLoading; + + this.accountMenuDropdownTrigger = ko.observable(false); + + this.capaAdditionalAccounts = Settings.capa(Enums.Capa.AdditionalAccounts); + + this.loading = ko.computed(function () { + return this.accountsLoading(); + }, this); + + this.accountClick = _.bind(this.accountClick, this); + } + + _.extend(AbstractSystemDropDownViewModel.prototype, KnoinAbstractViewModel.prototype); + + AbstractSystemDropDownViewModel.prototype.accountClick = function (oAccount, oEvent) + { + if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which) + { + var self = this; + this.accountsLoading(true); + _.delay(function () { + self.accountsLoading(false); + }, 1000); + } + + return true; + }; + + AbstractSystemDropDownViewModel.prototype.emailTitle = function () + { + return Data.accountEmail(); + }; + + AbstractSystemDropDownViewModel.prototype.settingsClick = function () + { + __webpack_require__(/*! App:Knoin */ 5).setHash(LinkBuilder.settings()); + }; + + AbstractSystemDropDownViewModel.prototype.settingsHelp = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:KeyboardShortcutsHelp */ 46)); + }; + + AbstractSystemDropDownViewModel.prototype.addAccountClick = function () + { + if (this.capaAdditionalAccounts) + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:AddAccount */ 42)); + } + }; + + AbstractSystemDropDownViewModel.prototype.logoutClick = function () + { + Remote.logout(function () { + if (window.__rlah_clear) + { + window.__rlah_clear(); + } + + __webpack_require__(/*! App:RainLoop */ 4).loginAndLogoutReload(true, + Settings.settingsGet('ParentEmail') && 0 < Settings.settingsGet('ParentEmail').length); + }); + }; + + AbstractSystemDropDownViewModel.prototype.onBuild = function () + { + var self = this; + key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () { + if (self.viewModelVisibility()) + { + self.accountMenuDropdownTrigger(true); + } + }); + + // shortcuts help + key('shift+/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () { + if (self.viewModelVisibility()) + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:KeyboardShortcutsHelp */ 46)); + return false; + } + }); + }; + + module.exports = AbstractSystemDropDownViewModel; + + }()); + +/***/ }, +/* 42 */ +/*!************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsAddAccountViewModel.js ***! + \************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsAddAccountViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddAccount'); + + this.email = ko.observable(''); + this.password = ko.observable(''); + + this.emailError = ko.observable(false); + this.passwordError = ko.observable(false); + + this.email.subscribe(function () { + this.emailError(false); + }, this); + + this.password.subscribe(function () { + this.passwordError(false); + }, this); + + this.submitRequest = ko.observable(false); + this.submitError = ko.observable(''); + + this.emailFocus = ko.observable(false); + + this.addAccountCommand = Utils.createCommand(this, function () { + + this.emailError('' === Utils.trim(this.email())); + this.passwordError('' === Utils.trim(this.password())); + + if (this.emailError() || this.passwordError()) + { + return false; + } + + this.submitRequest(true); + + Remote.accountAdd(_.bind(function (sResult, oData) { + + this.submitRequest(false); + if (Enums.StorageResultType.Success === sResult && oData && 'AccountAdd' === oData.Action) + { + if (oData.Result) + { + __webpack_require__(/*! App:RainLoop */ 4).accountsAndIdentities(); + this.cancelCommand(); + } + else if (oData.ErrorCode) + { + this.submitError(Utils.getNotification(oData.ErrorCode)); + } + } + else + { + this.submitError(Utils.getNotification(Enums.Notification.UnknownError)); + } + + }, this), this.email(), '', this.password()); + + return true; + + }, function () { + return !this.submitRequest(); + }); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:AddAccount', 'PopupsAddAccountViewModel'], PopupsAddAccountViewModel); + _.extend(PopupsAddAccountViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsAddAccountViewModel.prototype.clearPopup = function () + { + this.email(''); + this.password(''); + + this.emailError(false); + this.passwordError(false); + + this.submitRequest(false); + this.submitError(''); + }; + + PopupsAddAccountViewModel.prototype.onShow = function () + { + this.clearPopup(); + }; + + PopupsAddAccountViewModel.prototype.onFocus = function () + { + this.emailFocus(true); + }; + + module.exports = PopupsAddAccountViewModel; + + }()); + +/***/ }, +/* 43 */ +/*!**********************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsContactsViewModel.js ***! + \**********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Consts = __webpack_require__(/*! Common/Consts */ 17), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + Selector = __webpack_require__(/*! Common/Selector */ 36), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + EmailModel = __webpack_require__(/*! Model:Email */ 23), + ContactModel = __webpack_require__(/*! Model:Contact */ 54), + ContactTagModel = __webpack_require__(/*! Model:ContactTag */ 37), + ContactPropertyModel = __webpack_require__(/*! Model:ContactProperty */ 55), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsContactsViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsContacts'); + + var + self = this, + fFastClearEmptyListHelper = function (aList) { + if (aList && 0 < aList.length) { + self.viewProperties.removeAll(aList); + } + } + ; + + this.allowContactsSync = Data.allowContactsSync; + this.enableContactsSync = Data.enableContactsSync; + this.allowExport = !Globals.bMobileDevice; + + this.search = ko.observable(''); + this.contactsCount = ko.observable(0); + this.contacts = Data.contacts; + this.contactTags = Data.contactTags; + + this.currentContact = ko.observable(null); + + this.importUploaderButton = ko.observable(null); + + this.contactsPage = ko.observable(1); + this.contactsPageCount = ko.computed(function () { + var iPage = window.Math.ceil(this.contactsCount() / Consts.Defaults.ContactsPerPage); + return 0 >= iPage ? 1 : iPage; + }, this); + + this.contactsPagenator = ko.computed(Utils.computedPagenatorHelper(this.contactsPage, this.contactsPageCount)); + + this.emptySelection = ko.observable(true); + this.viewClearSearch = ko.observable(false); + + this.viewID = ko.observable(''); + this.viewReadOnly = ko.observable(false); + this.viewProperties = ko.observableArray([]); + + this.viewTags = ko.observable(''); + this.viewTags.visibility = ko.observable(false); + this.viewTags.focusTrigger = ko.observable(false); + + this.viewTags.focusTrigger.subscribe(function (bValue) { + if (!bValue && '' === this.viewTags()) + { + this.viewTags.visibility(false); + } + else if (bValue) + { + this.viewTags.visibility(true); + } + }, this); + + this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + + this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) { + return -1 < Utils.inArray(oProperty.type(), [ + Enums.ContactPropertyType.FirstName, Enums.ContactPropertyType.LastName + ]); + }); + + this.viewPropertiesOther = this.viewProperties.filter(function(oProperty) { + return -1 < Utils.inArray(oProperty.type(), [ + Enums.ContactPropertyType.Note + ]); + }); + + this.viewPropertiesOther = ko.computed(function () { + + var aList = _.filter(this.viewProperties(), function (oProperty) { + return -1 < Utils.inArray(oProperty.type(), [ + Enums.ContactPropertyType.Nick + ]); + }); + + return _.sortBy(aList, function (oProperty) { + return oProperty.type(); + }); + + }, this); + + this.viewPropertiesEmails = this.viewProperties.filter(function(oProperty) { + return Enums.ContactPropertyType.Email === oProperty.type(); + }); + + this.viewPropertiesWeb = this.viewProperties.filter(function(oProperty) { + return Enums.ContactPropertyType.Web === oProperty.type(); + }); + + this.viewHasNonEmptyRequaredProperties = ko.computed(function() { + + var + aNames = this.viewPropertiesNames(), + aEmail = this.viewPropertiesEmails(), + fHelper = function (oProperty) { + return '' !== Utils.trim(oProperty.value()); + } + ; + + return !!(_.find(aNames, fHelper) || _.find(aEmail, fHelper)); + }, this); + + this.viewPropertiesPhones = this.viewProperties.filter(function(oProperty) { + return Enums.ContactPropertyType.Phone === oProperty.type(); + }); + + this.viewPropertiesEmailsNonEmpty = this.viewPropertiesNames.filter(function(oProperty) { + return '' !== Utils.trim(oProperty.value()); + }); + + this.viewPropertiesEmailsEmptyAndOnFocused = this.viewPropertiesEmails.filter(function(oProperty) { + var bF = oProperty.focused(); + return '' === Utils.trim(oProperty.value()) && !bF; + }); + + this.viewPropertiesPhonesEmptyAndOnFocused = this.viewPropertiesPhones.filter(function(oProperty) { + var bF = oProperty.focused(); + return '' === Utils.trim(oProperty.value()) && !bF; + }); + + this.viewPropertiesWebEmptyAndOnFocused = this.viewPropertiesWeb.filter(function(oProperty) { + var bF = oProperty.focused(); + return '' === Utils.trim(oProperty.value()) && !bF; + }); + + this.viewPropertiesOtherEmptyAndOnFocused = ko.computed(function () { + return _.filter(this.viewPropertiesOther(), function (oProperty) { + var bF = oProperty.focused(); + return '' === Utils.trim(oProperty.value()) && !bF; + }); + }, this); + + this.viewPropertiesEmailsEmptyAndOnFocused.subscribe(function(aList) { + fFastClearEmptyListHelper(aList); + }); + + this.viewPropertiesPhonesEmptyAndOnFocused.subscribe(function(aList) { + fFastClearEmptyListHelper(aList); + }); + + this.viewPropertiesWebEmptyAndOnFocused.subscribe(function(aList) { + fFastClearEmptyListHelper(aList); + }); + + this.viewPropertiesOtherEmptyAndOnFocused.subscribe(function(aList) { + fFastClearEmptyListHelper(aList); + }); + + this.viewSaving = ko.observable(false); + + this.useCheckboxesInList = Data.useCheckboxesInList; + + this.search.subscribe(function () { + this.reloadContactList(); + }, this); + + this.contacts.subscribe(function () { + Utils.windowResize(); + }, this); + + this.viewProperties.subscribe(function () { + Utils.windowResize(); + }, this); + + this.contactsChecked = ko.computed(function () { + return _.filter(this.contacts(), function (oItem) { + return oItem.checked(); + }); + }, this); + + this.contactsCheckedOrSelected = ko.computed(function () { + + var + aChecked = this.contactsChecked(), + oSelected = this.currentContact() + ; + + return _.union(aChecked, oSelected ? [oSelected] : []); + + }, this); + + this.contactsCheckedOrSelectedUids = ko.computed(function () { + return _.map(this.contactsCheckedOrSelected(), function (oContact) { + return oContact.idContact; + }); + }, this); + + this.selector = new Selector(this.contacts, this.currentContact, + '.e-contact-item .actionHandle', '.e-contact-item.selected', '.e-contact-item .checkboxItem', + '.e-contact-item.focused'); + + this.selector.on('onItemSelect', _.bind(function (oContact) { + this.populateViewContact(oContact ? oContact : null); + if (!oContact) + { + this.emptySelection(true); + } + }, this)); + + this.selector.on('onItemGetUid', function (oContact) { + return oContact ? oContact.generateUid() : ''; + }); + + this.newCommand = Utils.createCommand(this, function () { + this.populateViewContact(null); + this.currentContact(null); + }); + + this.deleteCommand = Utils.createCommand(this, function () { + this.deleteSelectedContacts(); + this.emptySelection(true); + }, function () { + return 0 < this.contactsCheckedOrSelected().length; + }); + + this.newMessageCommand = Utils.createCommand(this, function () { + var aC = this.contactsCheckedOrSelected(), aE = []; + if (Utils.isNonEmptyArray(aC)) + { + aE = _.map(aC, function (oItem) { + if (oItem) + { + var + aData = oItem.getNameAndEmailHelper(), + oEmail = aData ? new EmailModel(aData[0], aData[1]) : null + ; + + if (oEmail && oEmail.validate()) + { + return oEmail; + } + } + + return null; + }); + + aE = _.compact(aE); + } + + if (Utils.isNonEmptyArray(aE)) + { + kn.hideScreenPopup(__webpack_require__(/*! View:Popup:Contacts */ 43)); + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Compose */ 21), [Enums.ComposeType.Empty, null, aE]); + } + + }, function () { + return 0 < this.contactsCheckedOrSelected().length; + }); + + this.clearCommand = Utils.createCommand(this, function () { + this.search(''); + }); + + this.saveCommand = Utils.createCommand(this, function () { + + this.viewSaving(true); + this.viewSaveTrigger(Enums.SaveSettingsStep.Animate); + + var + sRequestUid = Utils.fakeMd5(), + aProperties = [] + ; + + _.each(this.viewProperties(), function (oItem) { + if (oItem.type() && '' !== Utils.trim(oItem.value())) + { + aProperties.push([oItem.type(), oItem.value(), oItem.typeStr()]); + } + }); + + Remote.contactSave(function (sResult, oData) { + + var bRes = false; + self.viewSaving(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && + oData.Result.RequestUid === sRequestUid && 0 < Utils.pInt(oData.Result.ResultID)) + { + if ('' === self.viewID()) + { + self.viewID(Utils.pInt(oData.Result.ResultID)); + } + + self.reloadContactList(); + bRes = true; + } + + _.delay(function () { + self.viewSaveTrigger(bRes ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult); + }, 300); + + if (bRes) + { + self.watchDirty(false); + + _.delay(function () { + self.viewSaveTrigger(Enums.SaveSettingsStep.Idle); + }, 1000); + } + + }, sRequestUid, this.viewID(), this.viewTags(), aProperties); + + }, function () { + var + bV = this.viewHasNonEmptyRequaredProperties(), + bReadOnly = this.viewReadOnly() + ; + return !this.viewSaving() && bV && !bReadOnly; + }); + + this.syncCommand = Utils.createCommand(this, function () { + + var self = this; + __webpack_require__(/*! App:RainLoop */ 4).contactsSync(function (sResult, oData) { + if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) + { + window.alert(Utils.getNotification( + oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.ContactsSyncError)); + } + + self.reloadContactList(true); + }); + + }, function () { + return !this.contacts.syncing() && !this.contacts.importing(); + }); + + this.bDropPageAfterDelete = false; + + this.watchDirty = ko.observable(false); + this.watchHash = ko.observable(false); + + this.viewHash = ko.computed(function () { + return '' + self.viewTags() + '|' + _.map(self.viewProperties(), function (oItem) { + return oItem.value(); + }).join(''); + }); + + // this.saveCommandDebounce = _.debounce(_.bind(this.saveCommand, this), 1000); + + this.viewHash.subscribe(function () { + if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty()) + { + this.watchDirty(true); + } + }, this); + + this.sDefaultKeyScope = Enums.KeyState.ContactList; + + this.contactTagsSource = _.bind(this.contactTagsSource, this); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:Contacts', 'PopupsContactsViewModel'], PopupsContactsViewModel); + _.extend(PopupsContactsViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsContactsViewModel.prototype.contactTagsSource = function (oData, fResponse) + { + __webpack_require__(/*! App:RainLoop */ 4).getContactTagsAutocomplete(oData.term, function (aData) { + fResponse(_.map(aData, function (oTagItem) { + return oTagItem.toLine(false); + })); + }); + }; + + PopupsContactsViewModel.prototype.getPropertyPlceholder = function (sType) + { + var sResult = ''; + switch (sType) + { + case Enums.ContactPropertyType.LastName: + sResult = 'CONTACTS/PLACEHOLDER_ENTER_LAST_NAME'; + break; + case Enums.ContactPropertyType.FirstName: + sResult = 'CONTACTS/PLACEHOLDER_ENTER_FIRST_NAME'; + break; + case Enums.ContactPropertyType.Nick: + sResult = 'CONTACTS/PLACEHOLDER_ENTER_NICK_NAME'; + break; + } + + return sResult; + }; + + PopupsContactsViewModel.prototype.addNewProperty = function (sType, sTypeStr) + { + this.viewProperties.push(new ContactPropertyModel(sType, sTypeStr || '', '', true, this.getPropertyPlceholder(sType))); + }; + + PopupsContactsViewModel.prototype.addNewOrFocusProperty = function (sType, sTypeStr) + { + var oItem = _.find(this.viewProperties(), function (oItem) { + return sType === oItem.type(); + }); + + if (oItem) + { + oItem.focused(true); + } + else + { + this.addNewProperty(sType, sTypeStr); + } + }; + + PopupsContactsViewModel.prototype.addNewTag = function () + { + this.viewTags.visibility(true); + this.viewTags.focusTrigger(true); + }; + + PopupsContactsViewModel.prototype.addNewEmail = function () + { + this.addNewProperty(Enums.ContactPropertyType.Email, 'Home'); + }; + + PopupsContactsViewModel.prototype.addNewPhone = function () + { + this.addNewProperty(Enums.ContactPropertyType.Phone, 'Mobile'); + }; + + PopupsContactsViewModel.prototype.addNewWeb = function () + { + this.addNewProperty(Enums.ContactPropertyType.Web); + }; + + PopupsContactsViewModel.prototype.addNewNickname = function () + { + this.addNewOrFocusProperty(Enums.ContactPropertyType.Nick); + }; + + PopupsContactsViewModel.prototype.addNewNotes = function () + { + this.addNewOrFocusProperty(Enums.ContactPropertyType.Note); + }; + + PopupsContactsViewModel.prototype.addNewBirthday = function () + { + this.addNewOrFocusProperty(Enums.ContactPropertyType.Birthday); + }; + + PopupsContactsViewModel.prototype.exportVcf = function () + { + __webpack_require__(/*! App:RainLoop */ 4).download(LinkBuilder.exportContactsVcf()); + }; + + PopupsContactsViewModel.prototype.exportCsv = function () + { + __webpack_require__(/*! App:RainLoop */ 4).download(LinkBuilder.exportContactsCsv()); + }; + + PopupsContactsViewModel.prototype.initUploader = function () + { + if (this.importUploaderButton()) + { + var + oJua = new Jua({ + 'action': LinkBuilder.uploadContacts(), + 'name': 'uploader', + 'queueSize': 1, + 'multipleSizeLimit': 1, + 'disableFolderDragAndDrop': true, + 'disableDragAndDrop': true, + 'disableMultiple': true, + 'disableDocumentDropPrevent': true, + 'clickElement': this.importUploaderButton() + }) + ; + + if (oJua) + { + oJua + .on('onStart', _.bind(function () { + this.contacts.importing(true); + }, this)) + .on('onComplete', _.bind(function (sId, bResult, oData) { + + this.contacts.importing(false); + this.reloadContactList(); + + if (!sId || !bResult || !oData || !oData.Result) + { + window.alert(Utils.i18n('CONTACTS/ERROR_IMPORT_FILE')); + } + + }, this)) + ; + } + } + }; + + PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = function () + { + var + self = this, + oKoContacts = this.contacts, + oCurrentContact = this.currentContact(), + iCount = this.contacts().length, + aContacts = this.contactsCheckedOrSelected() + ; + + if (0 < aContacts.length) + { + _.each(aContacts, function (oContact) { + + if (oCurrentContact && oCurrentContact.idContact === oContact.idContact) + { + oCurrentContact = null; + self.currentContact(null); + } + + oContact.deleted(true); + iCount--; + }); + + if (iCount <= 0) + { + this.bDropPageAfterDelete = true; + } + + _.delay(function () { + + _.each(aContacts, function (oContact) { + oKoContacts.remove(oContact); + }); + + }, 500); + } + }; + + PopupsContactsViewModel.prototype.deleteSelectedContacts = function () + { + if (0 < this.contactsCheckedOrSelected().length) + { + Remote.contactsDelete( + _.bind(this.deleteResponse, this), + this.contactsCheckedOrSelectedUids() + ); + + this.removeCheckedOrSelectedContactsFromList(); + } + }; + + /** + * @param {string} sResult + * @param {AjaxJsonDefaultResponse} oData + */ + PopupsContactsViewModel.prototype.deleteResponse = function (sResult, oData) + { + if (500 < (Enums.StorageResultType.Success === sResult && oData && oData.Time ? Utils.pInt(oData.Time) : 0)) + { + this.reloadContactList(this.bDropPageAfterDelete); + } + else + { + _.delay((function (self) { + return function () { + self.reloadContactList(self.bDropPageAfterDelete); + }; + }(this)), 500); + } + }; + + PopupsContactsViewModel.prototype.removeProperty = function (oProp) + { + this.viewProperties.remove(oProp); + }; + + /** + * @param {?ContactModel} oContact + */ + PopupsContactsViewModel.prototype.populateViewContact = function (oContact) + { + var + sId = '', + sLastName = '', + sFirstName = '', + aList = [] + ; + + this.watchHash(false); + + this.emptySelection(false); + this.viewReadOnly(false); + this.viewTags(''); + + if (oContact) + { + sId = oContact.idContact; + if (Utils.isNonEmptyArray(oContact.properties)) + { + _.each(oContact.properties, function (aProperty) { + if (aProperty && aProperty[0]) + { + if (Enums.ContactPropertyType.LastName === aProperty[0]) + { + sLastName = aProperty[1]; + } + else if (Enums.ContactPropertyType.FirstName === aProperty[0]) + { + sFirstName = aProperty[1]; + } + else + { + aList.push(new ContactPropertyModel(aProperty[0], aProperty[2] || '', aProperty[1])); + } + } + }); + } + + this.viewTags(oContact.tags); + + this.viewReadOnly(!!oContact.readOnly); + } + + this.viewTags.focusTrigger.valueHasMutated(); + this.viewTags.visibility('' !== this.viewTags()); + + aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.LastName, '', sLastName, false, + this.getPropertyPlceholder(Enums.ContactPropertyType.LastName))); + + aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.FirstName, '', sFirstName, !oContact, + this.getPropertyPlceholder(Enums.ContactPropertyType.FirstName))); + + this.viewID(sId); + this.viewProperties([]); + this.viewProperties(aList); + + this.watchDirty(false); + this.watchHash(true); + }; + + /** + * @param {boolean=} bDropPagePosition = false + */ + PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePosition) + { + var + self = this, + iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage + ; + + this.bDropPageAfterDelete = false; + + if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition) + { + this.contactsPage(1); + iOffset = 0; + } + + this.contacts.loading(true); + Remote.contacts(function (sResult, oData) { + var + iCount = 0, + aList = [], + aTagsList = [] + ; + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List) + { + if (Utils.isNonEmptyArray(oData.Result.List)) + { + aList = _.map(oData.Result.List, function (oItem) { + var oContact = new ContactModel(); + return oContact.parse(oItem) ? oContact : null; + }); + + aList = _.compact(aList); + + iCount = Utils.pInt(oData.Result.Count); + iCount = 0 < iCount ? iCount : 0; + } + + if (Utils.isNonEmptyArray(oData.Result.Tags)) + { + aTagsList = _.map(oData.Result.Tags, function (oItem) { + var oContactTag = new ContactTagModel(); + return oContactTag.parse(oItem) ? oContactTag : null; + }); + + aTagsList = _.compact(aTagsList); + } + } + + self.contactsCount(iCount); + + self.contacts(aList); + self.contacts.loading(false); + self.contactTags(aTagsList); + + self.viewClearSearch('' !== self.search()); + + }, iOffset, Consts.Defaults.ContactsPerPage, this.search()); + }; + + PopupsContactsViewModel.prototype.onBuild = function (oDom) + { + this.oContentVisible = $('.b-list-content', oDom); + this.oContentScrollable = $('.content', this.oContentVisible); + + this.selector.init(this.oContentVisible, this.oContentScrollable, Enums.KeyState.ContactList); + + var self = this; + + key('delete', Enums.KeyState.ContactList, function () { + self.deleteCommand(); + return false; + }); + + oDom + .on('click', '.e-pagenator .e-page', function () { + var oPage = ko.dataFor(this); + if (oPage) + { + self.contactsPage(Utils.pInt(oPage.value)); + self.reloadContactList(); + } + }) + ; + + this.initUploader(); + }; + + PopupsContactsViewModel.prototype.onShow = function () + { + kn.routeOff(); + this.reloadContactList(true); + }; + + PopupsContactsViewModel.prototype.onHide = function () + { + kn.routeOn(); + this.currentContact(null); + this.emptySelection(true); + this.search(''); + this.contactsCount(0); + this.contacts([]); + }; + + module.exports = PopupsContactsViewModel; + + }()); + +/***/ }, +/* 44 */ +/*!**************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsFolderCreateViewModel.js ***! + \**************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Consts = __webpack_require__(/*! Common/Consts */ 17), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsFolderCreateViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderCreate'); + + Utils.initOnStartOrLangChange(function () { + this.sNoParentText = Utils.i18n('POPUPS_CREATE_FOLDER/SELECT_NO_PARENT'); + }, this); + + this.folderName = ko.observable(''); + this.folderName.focused = ko.observable(false); + + this.selectedParentValue = ko.observable(Consts.Values.UnuseOptionValue); + + this.parentFolderSelectList = ko.computed(function () { + + var + aTop = [], + fDisableCallback = null, + fVisibleCallback = null, + aList = Data.folderList(), + fRenameCallback = function (oItem) { + return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : ''; + } + ; + + aTop.push(['', this.sNoParentText]); + + if ('' !== Data.namespace) + { + fDisableCallback = function (oItem) + { + return Data.namespace !== oItem.fullNameRaw.substr(0, Data.namespace.length); + }; + } + + return Utils.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback); + + }, this); + + // commands + this.createFolder = Utils.createCommand(this, function () { + + var + sParentFolderName = this.selectedParentValue() + ; + + if ('' === sParentFolderName && 1 < Data.namespace.length) + { + sParentFolderName = Data.namespace.substr(0, Data.namespace.length - 1); + } + + Data.foldersCreating(true); + Remote.folderCreate(function (sResult, oData) { + + Data.foldersCreating(false); + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + __webpack_require__(/*! App:RainLoop */ 4).folders(); + } + else + { + Data.foldersListError( + oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER')); + } + + }, this.folderName(), sParentFolderName); + + this.cancelCommand(); + + }, function () { + return this.simpleFolderNameValidation(this.folderName()); + }); + + this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:FolderCreate', 'PopupsFolderCreateViewModel'], PopupsFolderCreateViewModel); + _.extend(PopupsFolderCreateViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsFolderCreateViewModel.prototype.sNoParentText = ''; + + PopupsFolderCreateViewModel.prototype.simpleFolderNameValidation = function (sName) + { + return (/^[^\\\/]+$/g).test(Utils.trim(sName)); + }; + + PopupsFolderCreateViewModel.prototype.clearPopup = function () + { + this.folderName(''); + this.selectedParentValue(''); + this.folderName.focused(false); + }; + + PopupsFolderCreateViewModel.prototype.onShow = function () + { + this.clearPopup(); + }; + + PopupsFolderCreateViewModel.prototype.onFocus = function () + { + this.folderName.focused(true); + }; + + module.exports = PopupsFolderCreateViewModel; + + }()); + +/***/ }, +/* 45 */ +/*!**********************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsIdentityViewModel.js ***! + \**********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsIdentityViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsIdentity'); + + this.id = ''; + this.edit = ko.observable(false); + this.owner = ko.observable(false); + + this.email = ko.observable('').validateEmail(); + this.email.focused = ko.observable(false); + this.name = ko.observable(''); + this.name.focused = ko.observable(false); + this.replyTo = ko.observable('').validateSimpleEmail(); + this.replyTo.focused = ko.observable(false); + this.bcc = ko.observable('').validateSimpleEmail(); + this.bcc.focused = ko.observable(false); + + // this.email.subscribe(function () { + // this.email.hasError(false); + // }, this); + + this.submitRequest = ko.observable(false); + this.submitError = ko.observable(''); + + this.addOrEditIdentityCommand = Utils.createCommand(this, function () { + + if (!this.email.hasError()) + { + this.email.hasError('' === Utils.trim(this.email())); + } + + if (this.email.hasError()) + { + if (!this.owner()) + { + this.email.focused(true); + } + + return false; + } + + if (this.replyTo.hasError()) + { + this.replyTo.focused(true); + return false; + } + + if (this.bcc.hasError()) + { + this.bcc.focused(true); + return false; + } + + this.submitRequest(true); + + Remote.identityUpdate(_.bind(function (sResult, oData) { + + this.submitRequest(false); + if (Enums.StorageResultType.Success === sResult && oData) + { + if (oData.Result) + { + __webpack_require__(/*! App:RainLoop */ 4).accountsAndIdentities(); + this.cancelCommand(); + } + else if (oData.ErrorCode) + { + this.submitError(Utils.getNotification(oData.ErrorCode)); + } + } + else + { + this.submitError(Utils.getNotification(Enums.Notification.UnknownError)); + } + + }, this), this.id, this.email(), this.name(), this.replyTo(), this.bcc()); + + return true; + + }, function () { + return !this.submitRequest(); + }); + + this.label = ko.computed(function () { + return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'TITLE_UPDATE_IDENTITY': 'TITLE_ADD_IDENTITY')); + }, this); + + this.button = ko.computed(function () { + return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'BUTTON_UPDATE_IDENTITY': 'BUTTON_ADD_IDENTITY')); + }, this); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:Identity', 'PopupsIdentityViewModel'], PopupsIdentityViewModel); + _.extend(PopupsIdentityViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsIdentityViewModel.prototype.clearPopup = function () + { + this.id = ''; + this.edit(false); + this.owner(false); + + this.name(''); + this.email(''); + this.replyTo(''); + this.bcc(''); + + this.email.hasError(false); + this.replyTo.hasError(false); + this.bcc.hasError(false); + + this.submitRequest(false); + this.submitError(''); + }; + + /** + * @param {?IdentityModel} oIdentity + */ + PopupsIdentityViewModel.prototype.onShow = function (oIdentity) + { + this.clearPopup(); + + if (oIdentity) + { + this.edit(true); + + this.id = oIdentity.id; + this.name(oIdentity.name()); + this.email(oIdentity.email()); + this.replyTo(oIdentity.replyTo()); + this.bcc(oIdentity.bcc()); + + this.owner(this.id === Data.accountEmail()); + } + }; + + PopupsIdentityViewModel.prototype.onFocus = function () + { + if (!this.owner()) + { + this.email.focused(true); + } + }; + + module.exports = PopupsIdentityViewModel; + + }()); + +/***/ }, +/* 46 */ +/*!***********************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsKeyboardShortcutsHelpViewModel.js ***! + \***********************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + key = __webpack_require__(/*! key */ 19), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsKeyboardShortcutsHelpViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp'); + + this.sDefaultKeyScope = Enums.KeyState.PopupKeyboardShortcutsHelp; + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:KeyboardShortcutsHelp', 'PopupsKeyboardShortcutsHelpViewModel'], PopupsKeyboardShortcutsHelpViewModel); + _.extend(PopupsKeyboardShortcutsHelpViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsKeyboardShortcutsHelpViewModel.prototype.onBuild = function (oDom) + { + key('tab, shift+tab, left, right', Enums.KeyState.PopupKeyboardShortcutsHelp, _.bind(function (event, handler) { + if (event && handler) + { + var + $tabs = oDom.find('.nav.nav-tabs > li'), + bNext = handler && ('tab' === handler.shortcut || 'right' === handler.shortcut), + iIndex = $tabs.index($tabs.filter('.active')) + ; + + if (!bNext && iIndex > 0) + { + iIndex--; + } + else if (bNext && iIndex < $tabs.length - 1) + { + iIndex++; + } + else + { + iIndex = bNext ? 0 : $tabs.length - 1; + } + + $tabs.eq(iIndex).find('a[data-toggle="tab"]').tab('show'); + return false; + } + }, this)); + }; + + module.exports = PopupsKeyboardShortcutsHelpViewModel; + + }()); + +/***/ }, +/* 47 */ +/*!**********************!*\ + !*** external "Jua" ***! + \**********************/ +/***/ function(module, exports, __webpack_require__) { + + module.exports = Jua; + +/***/ }, +/* 48 */, +/* 49 */, +/* 50 */, +/* 51 */, +/* 52 */, +/* 53 */ +/*!**********************************************!*\ + !*** ./dev/Models/ComposeAttachmentModel.js ***! + \**********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + * @param {string} sId + * @param {string} sFileName + * @param {?number=} nSize + * @param {boolean=} bInline + * @param {boolean=} bLinked + * @param {string=} sCID + * @param {string=} sContentLocation + */ + function ComposeAttachmentModel(sId, sFileName, nSize, bInline, bLinked, sCID, sContentLocation) + { + this.id = sId; + this.isInline = Utils.isUnd(bInline) ? false : !!bInline; + this.isLinked = Utils.isUnd(bLinked) ? false : !!bLinked; + this.CID = Utils.isUnd(sCID) ? '' : sCID; + this.contentLocation = Utils.isUnd(sContentLocation) ? '' : sContentLocation; + this.fromMessage = false; + + this.fileName = ko.observable(sFileName); + this.size = ko.observable(Utils.isUnd(nSize) ? null : nSize); + this.tempName = ko.observable(''); + + this.progress = ko.observable(''); + this.error = ko.observable(''); + this.waiting = ko.observable(true); + this.uploading = ko.observable(false); + this.enabled = ko.observable(true); + + this.friendlySize = ko.computed(function () { + var mSize = this.size(); + return null === mSize ? '' : Utils.friendlySize(this.size()); + }, this); + } + + ComposeAttachmentModel.prototype.id = ''; + ComposeAttachmentModel.prototype.isInline = false; + ComposeAttachmentModel.prototype.isLinked = false; + ComposeAttachmentModel.prototype.CID = ''; + ComposeAttachmentModel.prototype.contentLocation = ''; + ComposeAttachmentModel.prototype.fromMessage = false; + ComposeAttachmentModel.prototype.cancel = Utils.emptyFunction; + + /** + * @param {AjaxJsonComposeAttachment} oJsonAttachment + */ + ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment) + { + var bResult = false; + if (oJsonAttachment) + { + this.fileName(oJsonAttachment.Name); + this.size(Utils.isUnd(oJsonAttachment.Size) ? 0 : Utils.pInt(oJsonAttachment.Size)); + this.tempName(Utils.isUnd(oJsonAttachment.TempName) ? '' : oJsonAttachment.TempName); + this.isInline = false; + + bResult = true; + } + + return bResult; + }; + + module.exports = ComposeAttachmentModel; + + }()); + +/***/ }, +/* 54 */ +/*!************************************!*\ + !*** ./dev/Models/ContactModel.js ***! + \************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11) + ; + + /** + * @constructor + */ + function ContactModel() + { + this.idContact = 0; + this.display = ''; + this.properties = []; + this.tags = ''; + this.readOnly = false; + + this.focused = ko.observable(false); + this.selected = ko.observable(false); + this.checked = ko.observable(false); + this.deleted = ko.observable(false); + } + + /** + * @return {Array|null} + */ + ContactModel.prototype.getNameAndEmailHelper = function () + { + var + sName = '', + sEmail = '' + ; + + if (Utils.isNonEmptyArray(this.properties)) + { + _.each(this.properties, function (aProperty) { + if (aProperty) + { + if (Enums.ContactPropertyType.FirstName === aProperty[0]) + { + sName = Utils.trim(aProperty[1] + ' ' + sName); + } + else if (Enums.ContactPropertyType.LastName === aProperty[0]) + { + sName = Utils.trim(sName + ' ' + aProperty[1]); + } + else if ('' === sEmail && Enums.ContactPropertyType.Email === aProperty[0]) + { + sEmail = aProperty[1]; + } + } + }, this); + } + + return '' === sEmail ? null : [sEmail, sName]; + }; + + ContactModel.prototype.parse = function (oItem) + { + var bResult = false; + if (oItem && 'Object/Contact' === oItem['@Object']) + { + this.idContact = Utils.pInt(oItem['IdContact']); + this.display = Utils.pString(oItem['Display']); + this.readOnly = !!oItem['ReadOnly']; + this.tags = ''; + + if (Utils.isNonEmptyArray(oItem['Properties'])) + { + _.each(oItem['Properties'], function (oProperty) { + if (oProperty && oProperty['Type'] && Utils.isNormal(oProperty['Value']) && Utils.isNormal(oProperty['TypeStr'])) + { + this.properties.push([Utils.pInt(oProperty['Type']), Utils.pString(oProperty['Value']), Utils.pString(oProperty['TypeStr'])]); + } + }, this); + } + + if (Utils.isNonEmptyArray(oItem['Tags'])) + { + this.tags = oItem['Tags'].join(','); + } + + bResult = true; + } + + return bResult; + }; + + /** + * @return {string} + */ + ContactModel.prototype.srcAttr = function () + { + return LinkBuilder.emptyContactPic(); + }; + + /** + * @return {string} + */ + ContactModel.prototype.generateUid = function () + { + return '' + this.idContact; + }; + + /** + * @return string + */ + ContactModel.prototype.lineAsCcc = function () + { + var aResult = []; + if (this.deleted()) + { + aResult.push('deleted'); + } + if (this.selected()) + { + aResult.push('selected'); + } + if (this.checked()) + { + aResult.push('checked'); + } + if (this.focused()) + { + aResult.push('focused'); + } + + return aResult.join(' '); + }; + + module.exports = ContactModel; + + }()); + +/***/ }, +/* 55 */ +/*!********************************************!*\ + !*** ./dev/Models/ContactPropertyModel.js ***! + \********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + * @param {number=} iType = Enums.ContactPropertyType.Unknown + * @param {string=} sTypeStr = '' + * @param {string=} sValue = '' + * @param {boolean=} bFocused = false + * @param {string=} sPlaceholder = '' + */ + function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder) + { + this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType); + this.typeStr = ko.observable(Utils.isUnd(sTypeStr) ? '' : sTypeStr); + this.focused = ko.observable(Utils.isUnd(bFocused) ? false : !!bFocused); + this.value = ko.observable(Utils.pString(sValue)); + + this.placeholder = ko.observable(sPlaceholder || ''); + + this.placeholderValue = ko.computed(function () { + var sPlaceholder = this.placeholder(); + return sPlaceholder ? Utils.i18n(sPlaceholder) : ''; + }, this); + + this.largeValue = ko.computed(function () { + return Enums.ContactPropertyType.Note === this.type(); + }, this); + } + + module.exports = ContactPropertyModel; + + }()); + +/***/ }, +/* 56 */ +/*!********************************************!*\ + !*** ./dev/Models/FilterConditionModel.js ***! + \********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6) + ; + + /** + * @param {*} oKoList + * @constructor + */ + function FilterConditionModel(oKoList) + { + this.parentList = oKoList; + + this.field = ko.observable(Enums.FilterConditionField.From); + + this.fieldOptions = [ // TODO i18n + {'id': Enums.FilterConditionField.From, 'name': 'From'}, + {'id': Enums.FilterConditionField.Recipient, 'name': 'Recipient (To or CC)'}, + {'id': Enums.FilterConditionField.To, 'name': 'To'}, + {'id': Enums.FilterConditionField.Subject, 'name': 'Subject'} + ]; + + this.type = ko.observable(Enums.FilterConditionType.EqualTo); + + this.typeOptions = [ // TODO i18n + {'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To'}, + {'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To'}, + {'id': Enums.FilterConditionType.Contains, 'name': 'Contains'}, + {'id': Enums.FilterConditionType.NotContains, 'name': 'Not Contains'} + ]; + + this.value = ko.observable(''); + + this.template = ko.computed(function () { + + var sTemplate = ''; + switch (this.type()) + { + default: + sTemplate = 'SettingsFiltersConditionDefault'; + break; + } + + return sTemplate; + + }, this); + } + + FilterConditionModel.prototype.removeSelf = function () + { + this.parentList.remove(this); + }; + + module.exports = FilterConditionModel; + + }()); + +/***/ }, +/* 57 */ +/*!***********************************!*\ + !*** ./dev/Models/FilterModel.js ***! + \***********************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + FilterConditionModel = __webpack_require__(/*! Model:FilterCondition */ 56) + ; + + /** + * @constructor + */ + function FilterModel() + { + this.isNew = ko.observable(true); + this.enabled = ko.observable(true); + + this.name = ko.observable(''); + + this.conditionsType = ko.observable(Enums.FilterRulesType.And); + + this.conditions = ko.observableArray([]); + + this.conditions.subscribe(function () { + Utils.windowResize(); + }); + + // Actions + this.actionMarkAsRead = ko.observable(false); + this.actionSkipOtherFilters = ko.observable(true); + this.actionValue = ko.observable(''); + + this.actionType = ko.observable(Enums.FiltersAction.Move); + this.actionTypeOptions = [ // TODO i18n + {'id': Enums.FiltersAction.None, 'name': 'Action - None'}, + {'id': Enums.FiltersAction.Move, 'name': 'Action - Move to'}, + // {'id': Enums.FiltersAction.Forward, 'name': 'Action - Forward to'}, + {'id': Enums.FiltersAction.Discard, 'name': 'Action - Discard'} + ]; + + this.actionMarkAsReadVisiblity = ko.computed(function () { + return -1 < Utils.inArray(this.actionType(), [ + Enums.FiltersAction.None, Enums.FiltersAction.Forward, Enums.FiltersAction.Move + ]); + }, this); + + this.actionTemplate = ko.computed(function () { + + var sTemplate = ''; + switch (this.actionType()) + { + default: + case Enums.FiltersAction.Move: + sTemplate = 'SettingsFiltersActionValueAsFolders'; + break; + case Enums.FiltersAction.Forward: + sTemplate = 'SettingsFiltersActionWithValue'; + break; + case Enums.FiltersAction.None: + case Enums.FiltersAction.Discard: + sTemplate = 'SettingsFiltersActionNoValue'; + break; + } + + return sTemplate; + + }, this); + } + + FilterModel.prototype.addCondition = function () + { + this.conditions.push(new FilterConditionModel(this.conditions)); + }; + + FilterModel.prototype.parse = function (oItem) + { + var bResult = false; + if (oItem && 'Object/Filter' === oItem['@Object']) + { + this.name(Utils.pString(oItem['Name'])); + + bResult = true; + } + + return bResult; + }; + + module.exports = FilterModel; + + }()); + +/***/ }, +/* 58 */, +/* 59 */, +/* 60 */, +/* 61 */ +/*!************************************!*\ + !*** ./dev/Screens/AboutScreen.js ***! + \************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + KnoinAbstractScreen = __webpack_require__(/*! Knoin:AbstractScreen */ 24) + ; + + /** + * @constructor + * @extends KnoinAbstractScreen + */ + function AboutScreen() + { + KnoinAbstractScreen.call(this, 'about', [ + __webpack_require__(/*! View:RainLoop:About */ 92) + ]); + } + + _.extend(AboutScreen.prototype, KnoinAbstractScreen.prototype); + + AboutScreen.prototype.onShow = function () + { + __webpack_require__(/*! App:RainLoop */ 4).setTitle('RainLoop'); + }; + + module.exports = AboutScreen; + + }()); + +/***/ }, +/* 62 */, +/* 63 */, +/* 64 */, +/* 65 */ +/*!**************************************!*\ + !*** ./dev/Screens/MailBoxScreen.js ***! + \**************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + Events = __webpack_require__(/*! Common/Events */ 22), + + KnoinAbstractScreen = __webpack_require__(/*! Knoin:AbstractScreen */ 24), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13) + ; + + /** + * @constructor + * @extends KnoinAbstractScreen + */ + function MailBoxScreen() + { + KnoinAbstractScreen.call(this, 'mailbox', [ + __webpack_require__(/*! View:RainLoop:MailBoxSystemDropDown */ 100), + __webpack_require__(/*! View:RainLoop:MailBoxFolderList */ 97), + __webpack_require__(/*! View:RainLoop:MailBoxMessageList */ 98), + __webpack_require__(/*! View:RainLoop:MailBoxMessageView */ 99) + ]); + + this.oLastRoute = {}; + } + + _.extend(MailBoxScreen.prototype, KnoinAbstractScreen.prototype); + + /** + * @type {Object} + */ + MailBoxScreen.prototype.oLastRoute = {}; + + MailBoxScreen.prototype.setNewTitle = function () + { + var + sEmail = Data.accountEmail(), + nFoldersInboxUnreadCount = Data.foldersInboxUnreadCount() + ; + + __webpack_require__(/*! App:RainLoop */ 4).setTitle(('' === sEmail ? '' : + (0 < nFoldersInboxUnreadCount ? '(' + nFoldersInboxUnreadCount + ') ' : ' ') + sEmail + ' - ') + Utils.i18n('TITLES/MAILBOX')); + }; + + MailBoxScreen.prototype.onShow = function () + { + this.setNewTitle(); + Globals.keyScope(Enums.KeyState.MessageList); + }; + + /** + * @param {string} sFolderHash + * @param {number} iPage + * @param {string} sSearch + * @param {boolean=} bPreview = false + */ + MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPreview) + { + if (Utils.isUnd(bPreview) ? false : !!bPreview) + { + if (Enums.Layout.NoPreview === Data.layout() && !Data.message()) + { + __webpack_require__(/*! App:RainLoop */ 4).historyBack(); + } + } + else + { + var + sFolderFullNameRaw = Cache.getFolderFullNameRaw(sFolderHash), + oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw) + ; + + if (oFolder) + { + Data + .currentFolder(oFolder) + .messageListPage(iPage) + .messageListSearch(sSearch) + ; + + if (Enums.Layout.NoPreview === Data.layout() && Data.message()) + { + Data.message(null); + } + + __webpack_require__(/*! App:RainLoop */ 4).reloadMessageList(); + } + } + }; + + MailBoxScreen.prototype.onStart = function () + { + var + fResizeFunction = function () { + Utils.windowResize(); + } + ; + + if (Settings.capa(Enums.Capa.AdditionalAccounts) || Settings.capa(Enums.Capa.AdditionalIdentities)) + { + __webpack_require__(/*! App:RainLoop */ 4).accountsAndIdentities(); + } + + _.delay(function () { + if ('INBOX' !== Data.currentFolderFullNameRaw()) + { + __webpack_require__(/*! App:RainLoop */ 4).folderInformation('INBOX'); + } + }, 1000); + + _.delay(function () { + __webpack_require__(/*! App:RainLoop */ 4).quota(); + }, 5000); + + _.delay(function () { + Remote.appDelayStart(Utils.emptyFunction); + }, 35000); + + Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === Data.layout()); + + Data.folderList.subscribe(fResizeFunction); + Data.messageList.subscribe(fResizeFunction); + Data.message.subscribe(fResizeFunction); + + Data.layout.subscribe(function (nValue) { + Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue); + }); + + Events.sub('mailbox.inbox-unread-count', function (nCount) { + Data.foldersInboxUnreadCount(nCount); + }); + + Data.foldersInboxUnreadCount.subscribe(function () { + this.setNewTitle(); + }, this); + }; + + /** + * @return {Array} + */ + MailBoxScreen.prototype.routes = function () + { + var + fNormP = function () { + return ['Inbox', 1, '', true]; + }, + fNormS = function (oRequest, oVals) { + oVals[0] = Utils.pString(oVals[0]); + oVals[1] = Utils.pInt(oVals[1]); + oVals[1] = 0 >= oVals[1] ? 1 : oVals[1]; + oVals[2] = Utils.pString(oVals[2]); + + if ('' === oRequest) + { + oVals[0] = 'Inbox'; + oVals[1] = 1; + } + + return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2]), false]; + }, + fNormD = function (oRequest, oVals) { + oVals[0] = Utils.pString(oVals[0]); + oVals[1] = Utils.pString(oVals[1]); + + if ('' === oRequest) + { + oVals[0] = 'Inbox'; + } + + return [decodeURI(oVals[0]), 1, decodeURI(oVals[1]), false]; + } + ; + + return [ + [/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}], + [/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}], + [/^([a-zA-Z0-9]+)\/(.+)\/?$/, {'normalize_': fNormD}], + [/^message-preview$/, {'normalize_': fNormP}], + [/^([^\/]*)$/, {'normalize_': fNormS}] + ]; + }; + + module.exports = MailBoxScreen; + + }()); + +/***/ }, +/* 66 */ +/*!***************************************!*\ + !*** ./dev/Screens/SettingsScreen.js ***! + \***************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + Globals = __webpack_require__(/*! Common/Globals */ 7), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + + kn = __webpack_require__(/*! App:Knoin */ 5), + + AbstractSettingsScreen = __webpack_require__(/*! Screen:AbstractSettings */ 29) + ; + + /** + * @constructor + * @extends AbstractSettingsScreen + */ + function SettingsScreen() + { + AbstractSettingsScreen.call(this, [ + __webpack_require__(/*! View:RainLoop:SettingsSystemDropDown */ 114), + __webpack_require__(/*! View:RainLoop:SettingsMenu */ 112), + __webpack_require__(/*! View:RainLoop:SettingsPane */ 113) + ]); + + Utils.initOnStartOrLangChange(function () { + this.sSettingsTitle = Utils.i18n('TITLES/SETTINGS'); + }, this, function () { + this.setSettingsTitle(); + }); + } + + _.extend(SettingsScreen.prototype, AbstractSettingsScreen.prototype); + + /** + * @param {Function=} fCallback + */ + SettingsScreen.prototype.setupSettings = function (fCallback) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:General */ 83), + 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true); + + if (Settings.settingsGet('ContactsIsAllowed')) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Contacts */ 80), + 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts'); + } + + if (Settings.capa(Enums.Capa.AdditionalAccounts)) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Accounts */ 78), + 'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts'); + } + + if (Settings.capa(Enums.Capa.AdditionalIdentities)) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Identities */ 84), + 'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities'); + } + else + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Identity */ 85), + 'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity'); + } + + if (Settings.capa(Enums.Capa.Filters)) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Filters */ 81), + 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters'); + } + + if (Settings.capa(Enums.Capa.TwoFactor)) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Security */ 87), + 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security'); + } + + if (Settings.settingsGet('AllowGoogleSocial') || + Settings.settingsGet('AllowFacebookSocial') || + Settings.settingsGet('AllowTwitterSocial')) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Social */ 88), + 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social'); + } + + if (Settings.settingsGet('ChangePasswordIsAllowed')) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:ChangePassword */ 79), + 'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password'); + } + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Folders */ 82), + 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders'); + + if (Settings.capa(Enums.Capa.Themes)) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:Themes */ 89), + 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes'); + } + + if (Settings.capa(Enums.Capa.OpenPGP)) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:RainLoop:OpenPGP */ 86), + 'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp'); + } + + if (fCallback) + { + fCallback(); + } + }; + + SettingsScreen.prototype.onShow = function () + { + this.setSettingsTitle(); + Globals.keyScope(Enums.KeyState.Settings); + }; + + SettingsScreen.prototype.setSettingsTitle = function () + { + __webpack_require__(/*! App:RainLoop */ 4).setTitle(this.sSettingsTitle); + }; + + module.exports = SettingsScreen; + + }()); + +/***/ }, +/* 67 */, +/* 68 */, +/* 69 */, +/* 70 */, +/* 71 */, +/* 72 */, +/* 73 */, +/* 74 */, +/* 75 */, +/* 76 */, +/* 77 */, +/* 78 */ +/*!**********************************************!*\ + !*** ./dev/Settings/App/SettingsAccounts.js ***! + \**********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13) + ; + + /** + * @constructor + */ + function SettingsAccounts() + { + this.accounts = Data.accounts; + + this.processText = ko.computed(function () { + return Data.accountsLoading() ? Utils.i18n('SETTINGS_ACCOUNTS/LOADING_PROCESS') : ''; + }, this); + + this.visibility = ko.computed(function () { + return '' === this.processText() ? 'hidden' : 'visible'; + }, this); + + this.accountForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, + function (oPrev) { + if (oPrev) + { + oPrev.deleteAccess(false); + } + }, function (oNext) { + if (oNext) + { + oNext.deleteAccess(true); + } + } + ]}); + } + + SettingsAccounts.prototype.addNewAccount = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:AddAccount */ 42)); + }; + + /** + * @param {AccountModel} oAccountToRemove + */ + SettingsAccounts.prototype.deleteAccount = function (oAccountToRemove) + { + if (oAccountToRemove && oAccountToRemove.deleteAccess()) + { + this.accountForDeletion(null); + + var + kn = __webpack_require__(/*! App:Knoin */ 5), + fRemoveAccount = function (oAccount) { + return oAccountToRemove === oAccount; + } + ; + + if (oAccountToRemove) + { + this.accounts.remove(fRemoveAccount); + + Remote.accountDelete(function (sResult, oData) { + + if (Enums.StorageResultType.Success === sResult && oData && + oData.Result && oData.Reload) + { + kn.routeOff(); + kn.setHash(LinkBuilder.root(), true); + kn.routeOff(); + + _.defer(function () { + window.location.reload(); + }); + } + else + { + __webpack_require__(/*! App:RainLoop */ 4).accountsAndIdentities(); + } + + }, oAccountToRemove.email); + } + } + }; + + module.exports = SettingsAccounts; + + }()); + +/***/ }, +/* 79 */ +/*!****************************************************!*\ + !*** ./dev/Settings/App/SettingsChangePassword.js ***! + \****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13) + ; + + /** + * @constructor + */ + function SettingsChangePassword() + { + this.changeProcess = ko.observable(false); + + this.errorDescription = ko.observable(''); + this.passwordMismatch = ko.observable(false); + this.passwordUpdateError = ko.observable(false); + this.passwordUpdateSuccess = ko.observable(false); + + this.currentPassword = ko.observable(''); + this.currentPassword.error = ko.observable(false); + this.newPassword = ko.observable(''); + this.newPassword2 = ko.observable(''); + + this.currentPassword.subscribe(function () { + this.passwordUpdateError(false); + this.passwordUpdateSuccess(false); + this.currentPassword.error(false); + }, this); + + this.newPassword.subscribe(function () { + this.passwordUpdateError(false); + this.passwordUpdateSuccess(false); + this.passwordMismatch(false); + }, this); + + this.newPassword2.subscribe(function () { + this.passwordUpdateError(false); + this.passwordUpdateSuccess(false); + this.passwordMismatch(false); + }, this); + + this.saveNewPasswordCommand = Utils.createCommand(this, function () { + + if (this.newPassword() !== this.newPassword2()) + { + this.passwordMismatch(true); + this.errorDescription(Utils.i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH')); + } + else + { + this.changeProcess(true); + + this.passwordUpdateError(false); + this.passwordUpdateSuccess(false); + this.currentPassword.error(false); + this.passwordMismatch(false); + this.errorDescription(''); + + Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword()); + } + + }, function () { + return !this.changeProcess() && '' !== this.currentPassword() && + '' !== this.newPassword() && '' !== this.newPassword2(); + }); + + this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this); + } + + SettingsChangePassword.prototype.onHide = function () + { + this.changeProcess(false); + this.currentPassword(''); + this.newPassword(''); + this.newPassword2(''); + this.errorDescription(''); + this.passwordMismatch(false); + this.currentPassword.error(false); + }; + + SettingsChangePassword.prototype.onChangePasswordResponse = function (sResult, oData) + { + this.changeProcess(false); + this.passwordMismatch(false); + this.errorDescription(''); + this.currentPassword.error(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + this.currentPassword(''); + this.newPassword(''); + this.newPassword2(''); + + this.passwordUpdateSuccess(true); + this.currentPassword.error(false); + } + else + { + if (oData && Enums.Notification.CurrentPasswordIncorrect === oData.ErrorCode) + { + this.currentPassword.error(true); + } + + this.passwordUpdateError(true); + this.errorDescription(oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : + Utils.getNotification(Enums.Notification.CouldNotSaveNewPassword)); + } + }; + + module.exports = SettingsChangePassword; + + }()); + +/***/ }, +/* 80 */ +/*!**********************************************!*\ + !*** ./dev/Settings/App/SettingsContacts.js ***! + \**********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8) + ; + + /** + * @constructor + */ + function SettingsContacts() + { + this.contactsAutosave = Data.contactsAutosave; + + this.allowContactsSync = Data.allowContactsSync; + this.enableContactsSync = Data.enableContactsSync; + this.contactsSyncUrl = Data.contactsSyncUrl; + this.contactsSyncUser = Data.contactsSyncUser; + this.contactsSyncPass = Data.contactsSyncPass; + + this.saveTrigger = ko.computed(function () { + return [ + this.enableContactsSync() ? '1' : '0', + this.contactsSyncUrl(), + this.contactsSyncUser(), + this.contactsSyncPass() + ].join('|'); + }, this).extend({'throttle': 500}); + + this.saveTrigger.subscribe(function () { + Remote.saveContactsSyncData(null, + this.enableContactsSync(), + this.contactsSyncUrl(), + this.contactsSyncUser(), + this.contactsSyncPass() + ); + }, this); + } + + SettingsContacts.prototype.onBuild = function () + { + Data.contactsAutosave.subscribe(function (bValue) { + Remote.saveSettings(Utils.emptyFunction, { + 'ContactsAutosave': bValue ? '1' : '0' + }); + }); + }; + + module.exports = SettingsContacts; + + }()); + +/***/ }, +/* 81 */ +/*!*********************************************!*\ + !*** ./dev/Settings/App/SettingsFilters.js ***! + \*********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + */ + function SettingsFilters() + { + this.filters = ko.observableArray([]); + this.filters.loading = ko.observable(false); + + this.filters.subscribe(function () { + Utils.windowResize(); + }); + } + + SettingsFilters.prototype.deleteFilter = function (oFilter) + { + this.filters.remove(oFilter); + }; + + SettingsFilters.prototype.addFilter = function () + { + var + FilterModel = __webpack_require__(/*! Model:Filter */ 57) + ; + + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup( + __webpack_require__(/*! View:Popup:Filter */ 106), [new FilterModel()]); + }; + + module.exports = SettingsFilters; + + }()); + +/***/ }, +/* 82 */ +/*!*********************************************!*\ + !*** ./dev/Settings/App/SettingsFolders.js ***! + \*********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + LocalStorage = __webpack_require__(/*! Storage:LocalStorage */ 30) + ; + + /** + * @constructor + */ + function SettingsFolders() + { + this.foldersListError = Data.foldersListError; + this.folderList = Data.folderList; + + this.processText = ko.computed(function () { + + var + bLoading = Data.foldersLoading(), + bCreating = Data.foldersCreating(), + bDeleting = Data.foldersDeleting(), + bRenaming = Data.foldersRenaming() + ; + + if (bCreating) + { + return Utils.i18n('SETTINGS_FOLDERS/CREATING_PROCESS'); + } + else if (bDeleting) + { + return Utils.i18n('SETTINGS_FOLDERS/DELETING_PROCESS'); + } + else if (bRenaming) + { + return Utils.i18n('SETTINGS_FOLDERS/RENAMING_PROCESS'); + } + else if (bLoading) + { + return Utils.i18n('SETTINGS_FOLDERS/LOADING_PROCESS'); + } + + return ''; + + }, this); + + this.visibility = ko.computed(function () { + return '' === this.processText() ? 'hidden' : 'visible'; + }, this); + + this.folderForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, + function (oPrev) { + if (oPrev) + { + oPrev.deleteAccess(false); + } + }, function (oNext) { + if (oNext) + { + oNext.deleteAccess(true); + } + } + ]}); + + this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this, + function (oPrev) { + if (oPrev) + { + oPrev.edited(false); + } + }, function (oNext) { + if (oNext && oNext.canBeEdited()) + { + oNext.edited(true); + } + } + ]}); + + this.useImapSubscribe = !!Settings.settingsGet('UseImapSubscribe'); + } + + SettingsFolders.prototype.folderEditOnEnter = function (oFolder) + { + var + sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '' + ; + + if ('' !== sEditName && oFolder.name() !== sEditName) + { + LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, ''); + + Data.foldersRenaming(true); + Remote.folderRename(function (sResult, oData) { + + Data.foldersRenaming(false); + if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) + { + Data.foldersListError( + oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER')); + } + + __webpack_require__(/*! App:RainLoop */ 4).folders(); + + }, oFolder.fullNameRaw, sEditName); + + Cache.removeFolderFromCacheList(oFolder.fullNameRaw); + + oFolder.name(sEditName); + } + + oFolder.edited(false); + }; + + SettingsFolders.prototype.folderEditOnEsc = function (oFolder) + { + if (oFolder) + { + oFolder.edited(false); + } + }; + + SettingsFolders.prototype.onShow = function () + { + Data.foldersListError(''); + }; + + SettingsFolders.prototype.createFolder = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:FolderCreate */ 44)); + }; + + SettingsFolders.prototype.systemFolder = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:FolderSystem */ 27)); + }; + + SettingsFolders.prototype.deleteFolder = function (oFolderToRemove) + { + if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() && + 0 === oFolderToRemove.privateMessageCountAll()) + { + this.folderForDeletion(null); + + var + fRemoveFolder = function (oFolder) { + + if (oFolderToRemove === oFolder) + { + return true; + } + + oFolder.subFolders.remove(fRemoveFolder); + return false; + } + ; + + if (oFolderToRemove) + { + LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, ''); + + Data.folderList.remove(fRemoveFolder); + + Data.foldersDeleting(true); + Remote.folderDelete(function (sResult, oData) { + + Data.foldersDeleting(false); + if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) + { + Data.foldersListError( + oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER')); + } + + __webpack_require__(/*! App:RainLoop */ 4).folders(); + + }, oFolderToRemove.fullNameRaw); + + Cache.removeFolderFromCacheList(oFolderToRemove.fullNameRaw); + } + } + else if (0 < oFolderToRemove.privateMessageCountAll()) + { + Data.foldersListError(Utils.getNotification(Enums.Notification.CantDeleteNonEmptyFolder)); + } + }; + + SettingsFolders.prototype.subscribeFolder = function (oFolder) + { + LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, ''); + Remote.folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, true); + + oFolder.subScribed(true); + }; + + SettingsFolders.prototype.unSubscribeFolder = function (oFolder) + { + LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, ''); + Remote.folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, false); + + oFolder.subScribed(false); + }; + + module.exports = SettingsFolders; + + }()); + +/***/ }, +/* 83 */ +/*!*********************************************!*\ + !*** ./dev/Settings/App/SettingsGeneral.js ***! + \*********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Consts = __webpack_require__(/*! Common/Consts */ 17), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13) + ; + + /** + * @constructor + */ + function SettingsGeneral() + { + this.mainLanguage = Data.mainLanguage; + this.mainMessagesPerPage = Data.mainMessagesPerPage; + this.mainMessagesPerPageArray = Consts.Defaults.MessagesPerPageArray; + this.editorDefaultType = Data.editorDefaultType; + this.showImages = Data.showImages; + this.interfaceAnimation = Data.interfaceAnimation; + this.useDesktopNotifications = Data.useDesktopNotifications; + this.threading = Data.threading; + this.useThreads = Data.useThreads; + this.replySameFolder = Data.replySameFolder; + this.layout = Data.layout; + this.usePreviewPane = Data.usePreviewPane; + this.useCheckboxesInList = Data.useCheckboxesInList; + this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings; + + this.isDesktopNotificationsSupported = ko.computed(function () { + return Enums.DesktopNotifications.NotSupported !== Data.desktopNotificationsPermisions(); + }); + + this.isDesktopNotificationsDenied = ko.computed(function () { + return Enums.DesktopNotifications.NotSupported === Data.desktopNotificationsPermisions() || + Enums.DesktopNotifications.Denied === Data.desktopNotificationsPermisions(); + }); + + this.mainLanguageFullName = ko.computed(function () { + return Utils.convertLangName(this.mainLanguage()); + }, this); + + this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100}); + this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + + this.isAnimationSupported = Globals.bAnimationSupported; + } + + SettingsGeneral.prototype.toggleLayout = function () + { + this.layout(Enums.Layout.NoPreview === this.layout() ? Enums.Layout.SidePreview : Enums.Layout.NoPreview); + }; + + SettingsGeneral.prototype.onBuild = function () + { + var self = this; + + _.delay(function () { + + var + f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self) + ; + + Data.language.subscribe(function (sValue) { + + self.languageTrigger(Enums.SaveSettingsStep.Animate); + + $.ajax({ + 'url': LinkBuilder.langLink(sValue), + 'dataType': 'script', + 'cache': true + }).done(function() { + Utils.i18nReload(); + self.languageTrigger(Enums.SaveSettingsStep.TrueResult); + }).fail(function() { + self.languageTrigger(Enums.SaveSettingsStep.FalseResult); + }).always(function() { + _.delay(function () { + self.languageTrigger(Enums.SaveSettingsStep.Idle); + }, 1000); + }); + + Remote.saveSettings(Utils.emptyFunction, { + 'Language': sValue + }); + }); + + Data.editorDefaultType.subscribe(function (sValue) { + Remote.saveSettings(Utils.emptyFunction, { + 'EditorDefaultType': sValue + }); + }); + + Data.messagesPerPage.subscribe(function (iValue) { + Remote.saveSettings(f1, { + 'MPP': iValue + }); + }); + + Data.showImages.subscribe(function (bValue) { + Remote.saveSettings(Utils.emptyFunction, { + 'ShowImages': bValue ? '1' : '0' + }); + }); + + Data.interfaceAnimation.subscribe(function (sValue) { + Remote.saveSettings(Utils.emptyFunction, { + 'InterfaceAnimation': sValue + }); + }); + + Data.useDesktopNotifications.subscribe(function (bValue) { + Utils.timeOutAction('SaveDesktopNotifications', function () { + Remote.saveSettings(Utils.emptyFunction, { + 'DesktopNotifications': bValue ? '1' : '0' + }); + }, 3000); + }); + + Data.replySameFolder.subscribe(function (bValue) { + Utils.timeOutAction('SaveReplySameFolder', function () { + Remote.saveSettings(Utils.emptyFunction, { + 'ReplySameFolder': bValue ? '1' : '0' + }); + }, 3000); + }); + + Data.useThreads.subscribe(function (bValue) { + + Data.messageList([]); + + Remote.saveSettings(Utils.emptyFunction, { + 'UseThreads': bValue ? '1' : '0' + }); + }); + + Data.layout.subscribe(function (nValue) { + + Data.messageList([]); + + Remote.saveSettings(Utils.emptyFunction, { + 'Layout': nValue + }); + }); + + Data.useCheckboxesInList.subscribe(function (bValue) { + Remote.saveSettings(Utils.emptyFunction, { + 'UseCheckboxesInList': bValue ? '1' : '0' + }); + }); + + }, 50); + }; + + SettingsGeneral.prototype.onShow = function () + { + Data.desktopNotifications.valueHasMutated(); + }; + + SettingsGeneral.prototype.selectLanguage = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:Languages */ 32)); + }; + + module.exports = SettingsGeneral; + + }()); + +/***/ }, +/* 84 */ +/*!************************************************!*\ + !*** ./dev/Settings/App/SettingsIdentities.js ***! + \************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + HtmlEditor = __webpack_require__(/*! Common/HtmlEditor */ 28), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13) + ; + + /** + * @constructor + */ + function SettingsIdentities() + { + this.editor = null; + this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; + + this.accountEmail = Data.accountEmail; + this.displayName = Data.displayName; + this.signature = Data.signature; + this.signatureToAll = Data.signatureToAll; + this.replyTo = Data.replyTo; + + this.signatureDom = ko.observable(null); + + this.defaultIdentityIDTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + + this.identities = Data.identities; + this.defaultIdentityID = Data.defaultIdentityID; + + this.identitiesOptions = ko.computed(function () { + + var + aList = this.identities(), + aResult = [] + ; + + if (0 < aList.length) + { + aResult.push({ + 'id': this.accountEmail.peek(), + 'name': this.formattedAccountIdentity(), + 'seporator': false + }); + + aResult.push({ + 'id': '---', + 'name': '---', + 'seporator': true, + 'disabled': true + }); + + _.each(aList, function (oItem) { + aResult.push({ + 'id': oItem.id, + 'name': oItem.formattedNameForEmail(), + 'seporator': false + }); + }); + } + + return aResult; + }, this); + + this.processText = ko.computed(function () { + return Data.identitiesLoading() ? Utils.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : ''; + }, this); + + this.visibility = ko.computed(function () { + return '' === this.processText() ? 'hidden' : 'visible'; + }, this); + + this.identityForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, + function (oPrev) { + if (oPrev) + { + oPrev.deleteAccess(false); + } + }, function (oNext) { + if (oNext) + { + oNext.deleteAccess(true); + } + } + ]}); + } + + /** + * + * @return {string} + */ + SettingsIdentities.prototype.formattedAccountIdentity = function () + { + var + sDisplayName = this.displayName.peek(), + sEmail = this.accountEmail.peek() + ; + + return '' === sDisplayName ? sEmail : '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>'; + }; + + SettingsIdentities.prototype.addNewIdentity = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:Identity */ 45)); + }; + + SettingsIdentities.prototype.editIdentity = function (oIdentity) + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:Identity */ 45), [oIdentity]); + }; + + /** + * @param {IdentityModel} oIdentityToRemove + */ + SettingsIdentities.prototype.deleteIdentity = function (oIdentityToRemove) + { + if (oIdentityToRemove && oIdentityToRemove.deleteAccess()) + { + this.identityForDeletion(null); + + var + fRemoveFolder = function (oIdentity) { + return oIdentityToRemove === oIdentity; + } + ; + + if (oIdentityToRemove) + { + this.identities.remove(fRemoveFolder); + + Remote.identityDelete(function () { + __webpack_require__(/*! App:RainLoop */ 4).accountsAndIdentities(); + }, oIdentityToRemove.id); + } + } + }; + + SettingsIdentities.prototype.onFocus = function () + { + if (!this.editor && this.signatureDom()) + { + var + self = this, + sSignature = Data.signature() + ; + + this.editor = new HtmlEditor(self.signatureDom(), function () { + Data.signature( + (self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData() + ); + }, function () { + if (':HTML:' === sSignature.substr(0, 6)) + { + self.editor.setHtml(sSignature.substr(6), false); + } + else + { + self.editor.setPlain(sSignature, false); + } + }); + } + }; + + SettingsIdentities.prototype.onBuild = function (oDom) + { + var self = this; + + oDom + .on('click', '.identity-item .e-action', function () { + var oIdentityItem = ko.dataFor(this); + if (oIdentityItem) + { + self.editIdentity(oIdentityItem); + } + }) + ; + + _.delay(function () { + + var + f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self), + f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self), + f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self), + f4 = Utils.settingsSaveHelperSimpleFunction(self.defaultIdentityIDTrigger, self) + ; + + Data.defaultIdentityID.subscribe(function (sValue) { + Remote.saveSettings(f4, { + 'DefaultIdentityID': sValue + }); + }); + + Data.displayName.subscribe(function (sValue) { + Remote.saveSettings(f1, { + 'DisplayName': sValue + }); + }); + + Data.replyTo.subscribe(function (sValue) { + Remote.saveSettings(f2, { + 'ReplyTo': sValue + }); + }); + + Data.signature.subscribe(function (sValue) { + Remote.saveSettings(f3, { + 'Signature': sValue + }); + }); + + Data.signatureToAll.subscribe(function (bValue) { + Remote.saveSettings(null, { + 'SignatureToAll': bValue ? '1' : '0' + }); + }); + + }, 50); + }; + + module.exports = SettingsIdentities; + + }()); + +/***/ }, +/* 85 */ +/*!**********************************************!*\ + !*** ./dev/Settings/App/SettingsIdentity.js ***! + \**********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + HtmlEditor = __webpack_require__(/*! Common/HtmlEditor */ 28), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13) + ; + + /** + * @constructor + */ + function SettingsIdentity() + { + this.editor = null; + + this.displayName = Data.displayName; + this.signature = Data.signature; + this.signatureToAll = Data.signatureToAll; + this.replyTo = Data.replyTo; + + this.signatureDom = ko.observable(null); + + this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + } + + SettingsIdentity.prototype.onFocus = function () + { + if (!this.editor && this.signatureDom()) + { + var + self = this, + sSignature = Data.signature() + ; + + this.editor = new HtmlEditor(self.signatureDom(), function () { + Data.signature( + (self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData() + ); + }, function () { + if (':HTML:' === sSignature.substr(0, 6)) + { + self.editor.setHtml(sSignature.substr(6), false); + } + else + { + self.editor.setPlain(sSignature, false); + } + }); + } + }; + + SettingsIdentity.prototype.onBuild = function () + { + var self = this; + _.delay(function () { + + var + f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self), + f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self), + f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self) + ; + + Data.displayName.subscribe(function (sValue) { + Remote.saveSettings(f1, { + 'DisplayName': sValue + }); + }); + + Data.replyTo.subscribe(function (sValue) { + Remote.saveSettings(f2, { + 'ReplyTo': sValue + }); + }); + + Data.signature.subscribe(function (sValue) { + Remote.saveSettings(f3, { + 'Signature': sValue + }); + }); + + Data.signatureToAll.subscribe(function (bValue) { + Remote.saveSettings(null, { + 'SignatureToAll': bValue ? '1' : '0' + }); + }); + + }, 50); + }; + + module.exports = SettingsIdentity; + + }()); + +/***/ }, +/* 86 */ +/*!*********************************************!*\ + !*** ./dev/Settings/App/SettingsOpenPGP.js ***! + \*********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + kn = __webpack_require__(/*! App:Knoin */ 5), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8) + ; + + /** + * @constructor + */ + function SettingsOpenPGP() + { + this.openpgpkeys = Data.openpgpkeys; + this.openpgpkeysPublic = Data.openpgpkeysPublic; + this.openpgpkeysPrivate = Data.openpgpkeysPrivate; + + this.openPgpKeyForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, + function (oPrev) { + if (oPrev) + { + oPrev.deleteAccess(false); + } + }, function (oNext) { + if (oNext) + { + oNext.deleteAccess(true); + } + } + ]}); + } + + SettingsOpenPGP.prototype.addOpenPgpKey = function () + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:AddOpenPgpKey */ 102)); + }; + + SettingsOpenPGP.prototype.generateOpenPgpKey = function () + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:NewOpenPgpKey */ 108)); + }; + + SettingsOpenPGP.prototype.viewOpenPgpKey = function (oOpenPgpKey) + { + if (oOpenPgpKey) + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:ViewOpenPgpKey */ 111), [oOpenPgpKey]); + } + }; + + /** + * @param {OpenPgpKeyModel} oOpenPgpKeyToRemove + */ + SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove) + { + if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess()) + { + this.openPgpKeyForDeletion(null); + + if (oOpenPgpKeyToRemove && Data.openpgpKeyring) + { + this.openpgpkeys.remove(function (oOpenPgpKey) { + return oOpenPgpKeyToRemove === oOpenPgpKey; + }); + + Data.openpgpKeyring[oOpenPgpKeyToRemove.isPrivate ? 'privateKeys' : 'publicKeys'] + .removeForId(oOpenPgpKeyToRemove.guid); + + Data.openpgpKeyring.store(); + + __webpack_require__(/*! App:RainLoop */ 4).reloadOpenPgpKeys(); + } + } + }; + + module.exports = SettingsOpenPGP; + + }()); + +/***/ }, +/* 87 */ +/*!**********************************************!*\ + !*** ./dev/Settings/App/SettingsSecurity.js ***! + \**********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13) + ; + + /** + * @constructor + */ + function SettingsSecurity() + { + this.processing = ko.observable(false); + this.clearing = ko.observable(false); + this.secreting = ko.observable(false); + + this.viewUser = ko.observable(''); + this.viewEnable = ko.observable(false); + this.viewEnable.subs = true; + this.twoFactorStatus = ko.observable(false); + + this.viewSecret = ko.observable(''); + this.viewBackupCodes = ko.observable(''); + this.viewUrl = ko.observable(''); + + this.bFirst = true; + + this.viewTwoFactorStatus = ko.computed(function () { + Globals.langChangeTrigger(); + return Utils.i18n( + this.twoFactorStatus() ? + 'SETTINGS_SECURITY/TWO_FACTOR_SECRET_CONFIGURED_DESC' : + 'SETTINGS_SECURITY/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC' + ); + }, this); + + this.onResult = _.bind(this.onResult, this); + this.onSecretResult = _.bind(this.onSecretResult, this); + } + + SettingsSecurity.prototype.showSecret = function () + { + this.secreting(true); + Remote.showTwoFactorSecret(this.onSecretResult); + }; + + SettingsSecurity.prototype.hideSecret = function () + { + this.viewSecret(''); + this.viewBackupCodes(''); + this.viewUrl(''); + }; + + SettingsSecurity.prototype.createTwoFactor = function () + { + this.processing(true); + Remote.createTwoFactor(this.onResult); + }; + + SettingsSecurity.prototype.enableTwoFactor = function () + { + this.processing(true); + Remote.enableTwoFactor(this.onResult, this.viewEnable()); + }; + + SettingsSecurity.prototype.testTwoFactor = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:TwoFactorTest */ 110)); + }; + + SettingsSecurity.prototype.clearTwoFactor = function () + { + this.viewSecret(''); + this.viewBackupCodes(''); + this.viewUrl(''); + + this.clearing(true); + Remote.clearTwoFactor(this.onResult); + }; + + SettingsSecurity.prototype.onShow = function () + { + this.viewSecret(''); + this.viewBackupCodes(''); + this.viewUrl(''); + }; + + SettingsSecurity.prototype.onResult = function (sResult, oData) + { + this.processing(false); + this.clearing(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + this.viewUser(Utils.pString(oData.Result.User)); + this.viewEnable(!!oData.Result.Enable); + this.twoFactorStatus(!!oData.Result.IsSet); + + this.viewSecret(Utils.pString(oData.Result.Secret)); + this.viewBackupCodes(Utils.pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' ')); + this.viewUrl(Utils.pString(oData.Result.Url)); + } + else + { + this.viewUser(''); + this.viewEnable(false); + this.twoFactorStatus(false); + + this.viewSecret(''); + this.viewBackupCodes(''); + this.viewUrl(''); + } + + if (this.bFirst) + { + this.bFirst = false; + var self = this; + this.viewEnable.subscribe(function (bValue) { + if (this.viewEnable.subs) + { + Remote.enableTwoFactor(function (sResult, oData) { + if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) + { + self.viewEnable.subs = false; + self.viewEnable(false); + self.viewEnable.subs = true; + } + }, bValue); + } + }, this); + } + }; + + SettingsSecurity.prototype.onSecretResult = function (sResult, oData) + { + this.secreting(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + this.viewSecret(Utils.pString(oData.Result.Secret)); + this.viewUrl(Utils.pString(oData.Result.Url)); + } + else + { + this.viewSecret(''); + this.viewUrl(''); + } + }; + + SettingsSecurity.prototype.onBuild = function () + { + this.processing(true); + Remote.getTwoFactor(this.onResult); + }; + + module.exports = SettingsSecurity; + + }()); + +/***/ }, +/* 88 */ +/*!********************************************!*\ + !*** ./dev/Settings/App/SettingsSocial.js ***! + \********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + /** + * @constructor + */ + function SettingsSocial() + { + var + Utils = __webpack_require__(/*! Common/Utils */ 1), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8) + ; + + this.googleEnable = Data.googleEnable; + + this.googleActions = Data.googleActions; + this.googleLoggined = Data.googleLoggined; + this.googleUserName = Data.googleUserName; + + this.facebookEnable = Data.facebookEnable; + + this.facebookActions = Data.facebookActions; + this.facebookLoggined = Data.facebookLoggined; + this.facebookUserName = Data.facebookUserName; + + this.twitterEnable = Data.twitterEnable; + + this.twitterActions = Data.twitterActions; + this.twitterLoggined = Data.twitterLoggined; + this.twitterUserName = Data.twitterUserName; + + this.connectGoogle = Utils.createCommand(this, function () { + if (!this.googleLoggined()) + { + __webpack_require__(/*! App:RainLoop */ 4).googleConnect(); + } + }, function () { + return !this.googleLoggined() && !this.googleActions(); + }); + + this.disconnectGoogle = Utils.createCommand(this, function () { + __webpack_require__(/*! App:RainLoop */ 4).googleDisconnect(); + }); + + this.connectFacebook = Utils.createCommand(this, function () { + if (!this.facebookLoggined()) + { + __webpack_require__(/*! App:RainLoop */ 4).facebookConnect(); + } + }, function () { + return !this.facebookLoggined() && !this.facebookActions(); + }); + + this.disconnectFacebook = Utils.createCommand(this, function () { + __webpack_require__(/*! App:RainLoop */ 4).facebookDisconnect(); + }); + + this.connectTwitter = Utils.createCommand(this, function () { + if (!this.twitterLoggined()) + { + __webpack_require__(/*! App:RainLoop */ 4).twitterConnect(); + } + }, function () { + return !this.twitterLoggined() && !this.twitterActions(); + }); + + this.disconnectTwitter = Utils.createCommand(this, function () { + __webpack_require__(/*! App:RainLoop */ 4).twitterDisconnect(); + }); + } + + module.exports = SettingsSocial; + + }()); + +/***/ }, +/* 89 */ +/*!********************************************!*\ + !*** ./dev/Settings/App/SettingsThemes.js ***! + \********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13) + ; + + /** + * @constructor + */ + function SettingsThemes() + { + var self = this; + + this.mainTheme = Data.mainTheme; + this.themesObjects = ko.observableArray([]); + + this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100}); + + this.oLastAjax = null; + this.iTimer = 0; + + Data.theme.subscribe(function (sValue) { + + _.each(this.themesObjects(), function (oTheme) { + oTheme.selected(sValue === oTheme.name); + }); + + var + oThemeLink = $('#rlThemeLink'), + oThemeStyle = $('#rlThemeStyle'), + sUrl = oThemeLink.attr('href') + ; + + if (!sUrl) + { + sUrl = oThemeStyle.attr('data-href'); + } + + if (sUrl) + { + sUrl = sUrl.toString().replace(/\/-\/[^\/]+\/\-\//, '/-/' + sValue + '/-/'); + sUrl = sUrl.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/0/User/'); + + if ('Json/' !== sUrl.substring(sUrl.length - 5, sUrl.length)) + { + sUrl += 'Json/'; + } + + window.clearTimeout(self.iTimer); + self.themeTrigger(Enums.SaveSettingsStep.Animate); + + if (this.oLastAjax && this.oLastAjax.abort) + { + this.oLastAjax.abort(); + } + + this.oLastAjax = $.ajax({ + 'url': sUrl, + 'dataType': 'json' + }).done(function(aData) { + + if (aData && Utils.isArray(aData) && 2 === aData.length) + { + if (oThemeLink && oThemeLink[0] && (!oThemeStyle || !oThemeStyle[0])) + { + oThemeStyle = $(''); + oThemeLink.after(oThemeStyle); + oThemeLink.remove(); + } + + if (oThemeStyle && oThemeStyle[0]) + { + oThemeStyle.attr('data-href', sUrl).attr('data-theme', aData[0]); + if (oThemeStyle && oThemeStyle[0] && oThemeStyle[0].styleSheet && !Utils.isUnd(oThemeStyle[0].styleSheet.cssText)) + { + oThemeStyle[0].styleSheet.cssText = aData[1]; + } + else + { + oThemeStyle.text(aData[1]); + } + } + + self.themeTrigger(Enums.SaveSettingsStep.TrueResult); + } + + }).always(function() { + + self.iTimer = window.setTimeout(function () { + self.themeTrigger(Enums.SaveSettingsStep.Idle); + }, 1000); + + self.oLastAjax = null; + }); + } + + Remote.saveSettings(null, { + 'Theme': sValue + }); + + }, this); + } + + SettingsThemes.prototype.onBuild = function () + { + var sCurrentTheme = Data.theme(); + this.themesObjects(_.map(Data.themes(), function (sTheme) { + return { + 'name': sTheme, + 'nameDisplay': Utils.convertThemeName(sTheme), + 'selected': ko.observable(sTheme === sCurrentTheme), + 'themePreviewSrc': LinkBuilder.themePreviewLink(sTheme) + }; + })); + }; + + module.exports = SettingsThemes; + + }()); + +/***/ }, +/* 90 */, +/* 91 */, +/* 92 */ +/*!******************************************!*\ + !*** ./dev/ViewModels/AboutViewModel.js ***! + \******************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + kn = __webpack_require__(/*! App:Knoin */ 5), + Settings = __webpack_require__(/*! Storage:Settings */ 10), + + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function AboutViewModel() + { + KnoinAbstractViewModel.call(this, 'Center', 'About'); + + this.version = ko.observable(Settings.settingsGet('Version')); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:About', 'AboutViewModel'], AboutViewModel); + _.extend(AboutViewModel.prototype, KnoinAbstractViewModel.prototype); + + module.exports = AboutViewModel; + + }()); + +/***/ }, +/* 93 */, +/* 94 */, +/* 95 */, +/* 96 */, +/* 97 */ +/*!******************************************************!*\ + !*** ./dev/ViewModels/MailBoxFolderListViewModel.js ***! + \******************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + Enums = __webpack_require__(/*! Common/Enums */ 6), + Globals = __webpack_require__(/*! Common/Globals */ 7), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function MailBoxFolderListViewModel() + { + KnoinAbstractViewModel.call(this, 'Left', 'MailFolderList'); + + this.oContentVisible = null; + this.oContentScrollable = null; + + this.messageList = Data.messageList; + this.folderList = Data.folderList; + this.folderListSystem = Data.folderListSystem; + this.foldersChanging = Data.foldersChanging; + + this.leftPanelDisabled = Globals.leftPanelDisabled; + + this.iDropOverTimer = 0; + + this.allowContacts = !!Settings.settingsGet('ContactsIsAllowed'); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:MailBoxFolderList', 'MailBoxFolderListViewModel'], MailBoxFolderListViewModel); + _.extend(MailBoxFolderListViewModel.prototype, KnoinAbstractViewModel.prototype); + + MailBoxFolderListViewModel.prototype.onBuild = function (oDom) + { + this.oContentVisible = $('.b-content', oDom); + this.oContentScrollable = $('.content', this.oContentVisible); + + var self = this; + + oDom + .on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function (oEvent) { + + var + oFolder = ko.dataFor(this), + bCollapsed = false + ; + + if (oFolder && oEvent) + { + bCollapsed = oFolder.collapsed(); + __webpack_require__(/*! App:RainLoop */ 4).setExpandedFolder(oFolder.fullNameHash, bCollapsed); + + oFolder.collapsed(!bCollapsed); + oEvent.preventDefault(); + oEvent.stopPropagation(); + } + }) + .on('click', '.b-folders .e-item .e-link.selectable', function (oEvent) { + + oEvent.preventDefault(); + + var + oFolder = ko.dataFor(this) + ; + + if (oFolder) + { + if (Enums.Layout.NoPreview === Data.layout()) + { + Data.message(null); + } + + if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw()) + { + Cache.setFolderHash(oFolder.fullNameRaw, ''); + } + + kn.setHash(LinkBuilder.mailBox(oFolder.fullNameHash)); + } + }) + ; + + key('up, down', Enums.KeyState.FolderList, function (event, handler) { + + var + iIndex = -1, + iKeyCode = handler && 'up' === handler.shortcut ? 38 : 40, + $items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom) + ; + + if (event && $items.length) + { + iIndex = $items.index($items.filter('.focused')); + if (-1 < iIndex) + { + $items.eq(iIndex).removeClass('focused'); + } + + if (iKeyCode === 38 && iIndex > 0) + { + iIndex--; + } + else if (iKeyCode === 40 && iIndex < $items.length - 1) + { + iIndex++; + } + + $items.eq(iIndex).addClass('focused'); + self.scrollToFocused(); + } + + return false; + }); + + key('enter', Enums.KeyState.FolderList, function () { + var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom); + if ($items.length && $items[0]) + { + self.folderList.focused(false); + $items.click(); + } + + return false; + }); + + key('space', Enums.KeyState.FolderList, function () { + var bCollapsed = true, oFolder = null, $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom); + if ($items.length && $items[0]) + { + oFolder = ko.dataFor($items[0]); + if (oFolder) + { + bCollapsed = oFolder.collapsed(); + __webpack_require__(/*! App:RainLoop */ 4).setExpandedFolder(oFolder.fullNameHash, bCollapsed); + oFolder.collapsed(!bCollapsed); + } + } + + return false; + }); + + key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function () { + self.folderList.focused(false); + return false; + }); + + self.folderList.focused.subscribe(function (bValue) { + $('.b-folders .e-item .e-link.focused', oDom).removeClass('focused'); + if (bValue) + { + $('.b-folders .e-item .e-link.selected', oDom).addClass('focused'); + } + }); + }; + + MailBoxFolderListViewModel.prototype.messagesDropOver = function (oFolder) + { + window.clearTimeout(this.iDropOverTimer); + if (oFolder && oFolder.collapsed()) + { + this.iDropOverTimer = window.setTimeout(function () { + oFolder.collapsed(false); + __webpack_require__(/*! App:RainLoop */ 4).setExpandedFolder(oFolder.fullNameHash, true); + Utils.windowResize(); + }, 500); + } + }; + + MailBoxFolderListViewModel.prototype.messagesDropOut = function () + { + window.clearTimeout(this.iDropOverTimer); + }; + + MailBoxFolderListViewModel.prototype.scrollToFocused = function () + { + if (!this.oContentVisible || !this.oContentScrollable) + { + return false; + } + + var + iOffset = 20, + oFocused = $('.e-item .e-link.focused', this.oContentScrollable), + oPos = oFocused.position(), + iVisibleHeight = this.oContentVisible.height(), + iFocusedHeight = oFocused.outerHeight() + ; + + if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight)) + { + if (oPos.top < 0) + { + this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset); + } + else + { + this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset); + } + + return true; + } + + return false; + }; + + /** + * + * @param {FolderModel} oToFolder + * @param {{helper:jQuery}} oUi + */ + MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi) + { + if (oToFolder && oUi && oUi.helper) + { + var + sFromFolderFullNameRaw = oUi.helper.data('rl-folder'), + bCopy = Globals.$html.hasClass('rl-ctrl-key-pressed'), + aUids = oUi.helper.data('rl-uids') + ; + + if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids)) + { + __webpack_require__(/*! App:RainLoop */ 4).moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy); + } + } + }; + + MailBoxFolderListViewModel.prototype.composeClick = function () + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Compose */ 21)); + }; + + MailBoxFolderListViewModel.prototype.createFolder = function () + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:FolderCreate */ 44)); + }; + + MailBoxFolderListViewModel.prototype.configureFolders = function () + { + kn.setHash(LinkBuilder.settings('folders')); + }; + + MailBoxFolderListViewModel.prototype.contactsClick = function () + { + if (this.allowContacts) + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Contacts */ 43)); + } + }; + + module.exports = MailBoxFolderListViewModel; + + }()); + + +/***/ }, +/* 98 */ +/*!*******************************************************!*\ + !*** ./dev/ViewModels/MailBoxMessageListViewModel.js ***! + \*******************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + Jua = __webpack_require__(/*! Jua */ 47), + ifvisible = __webpack_require__(/*! ifvisible */ 116), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Consts = __webpack_require__(/*! Common/Consts */ 17), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + Events = __webpack_require__(/*! Common/Events */ 22), + Selector = __webpack_require__(/*! Common/Selector */ 36), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function MailBoxMessageListViewModel() + { + KnoinAbstractViewModel.call(this, 'Right', 'MailMessageList'); + + this.sLastUid = null; + this.bPrefetch = false; + this.emptySubjectValue = ''; + + this.hideDangerousActions = !!Settings.settingsGet('HideDangerousActions'); + + this.popupVisibility = Globals.popupVisibility; + + this.message = Data.message; + this.messageList = Data.messageList; + this.folderList = Data.folderList; + this.currentMessage = Data.currentMessage; + this.isMessageSelected = Data.isMessageSelected; + this.messageListSearch = Data.messageListSearch; + this.messageListError = Data.messageListError; + this.folderMenuForMove = Data.folderMenuForMove; + + this.useCheckboxesInList = Data.useCheckboxesInList; + + this.mainMessageListSearch = Data.mainMessageListSearch; + this.messageListEndFolder = Data.messageListEndFolder; + + this.messageListChecked = Data.messageListChecked; + this.messageListCheckedOrSelected = Data.messageListCheckedOrSelected; + this.messageListCheckedOrSelectedUidsWithSubMails = Data.messageListCheckedOrSelectedUidsWithSubMails; + this.messageListCompleteLoadingThrottle = Data.messageListCompleteLoadingThrottle; + + Utils.initOnStartOrLangChange(function () { + this.emptySubjectValue = Utils.i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT'); + }, this); + + this.userQuota = Data.userQuota; + this.userUsageSize = Data.userUsageSize; + this.userUsageProc = Data.userUsageProc; + + this.moveDropdownTrigger = ko.observable(false); + this.moreDropdownTrigger = ko.observable(false); + + // append drag and drop + this.dragOver = ko.observable(false).extend({'throttle': 1}); + this.dragOverEnter = ko.observable(false).extend({'throttle': 1}); + this.dragOverArea = ko.observable(null); + this.dragOverBodyArea = ko.observable(null); + + this.messageListItemTemplate = ko.computed(function () { + return Enums.Layout.NoPreview !== Data.layout() ? + 'MailMessageListItem' : 'MailMessageListItemNoPreviewPane'; + }); + + this.messageListSearchDesc = ko.computed(function () { + var sValue = Data.messageListEndSearch(); + return '' === sValue ? '' : Utils.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue}); + }); + + this.messageListPagenator = ko.computed(Utils.computedPagenatorHelper(Data.messageListPage, Data.messageListPageCount)); + + this.checkAll = ko.computed({ + 'read': function () { + return 0 < Data.messageListChecked().length; + }, + + 'write': function (bValue) { + bValue = !!bValue; + _.each(Data.messageList(), function (oMessage) { + oMessage.checked(bValue); + }); + } + }); + + this.inputMessageListSearchFocus = ko.observable(false); + + this.sLastSearchValue = ''; + this.inputProxyMessageListSearch = ko.computed({ + 'read': this.mainMessageListSearch, + 'write': function (sValue) { + this.sLastSearchValue = sValue; + }, + 'owner': this + }); + + this.isIncompleteChecked = ko.computed(function () { + var + iM = Data.messageList().length, + iC = Data.messageListChecked().length + ; + return 0 < iM && 0 < iC && iM > iC; + }, this); + + this.hasMessages = ko.computed(function () { + return 0 < this.messageList().length; + }, this); + + this.hasCheckedOrSelectedLines = ko.computed(function () { + return 0 < this.messageListCheckedOrSelected().length; + }, this); + + this.isSpamFolder = ko.computed(function () { + return Data.spamFolder() === this.messageListEndFolder() && + '' !== Data.spamFolder(); + }, this); + + this.isSpamDisabled = ko.computed(function () { + return Consts.Values.UnuseOptionValue === Data.spamFolder(); + }, this); + + this.isTrashFolder = ko.computed(function () { + return Data.trashFolder() === this.messageListEndFolder() && + '' !== Data.trashFolder(); + }, this); + + this.isDraftFolder = ko.computed(function () { + return Data.draftFolder() === this.messageListEndFolder() && + '' !== Data.draftFolder(); + }, this); + + this.isSentFolder = ko.computed(function () { + return Data.sentFolder() === this.messageListEndFolder() && + '' !== Data.sentFolder(); + }, this); + + this.isArchiveFolder = ko.computed(function () { + return Data.archiveFolder() === this.messageListEndFolder() && + '' !== Data.archiveFolder(); + }, this); + + this.isArchiveDisabled = ko.computed(function () { + return Consts.Values.UnuseOptionValue === Data.archiveFolder(); + }, this); + + this.canBeMoved = this.hasCheckedOrSelectedLines; + + this.clearCommand = Utils.createCommand(this, function () { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:FolderClear */ 107), [Data.currentFolder()]); + }); + + this.multyForwardCommand = Utils.createCommand(this, function () { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Compose */ 21), [ + Enums.ComposeType.ForwardAsAttachment, Data.messageListCheckedOrSelected()]); + }, this.canBeMoved); + + this.deleteWithoutMoveCommand = Utils.createCommand(this, function () { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.Trash, + Data.currentFolderFullNameRaw(), + Data.messageListCheckedOrSelectedUidsWithSubMails(), false); + }, this.canBeMoved); + + this.deleteCommand = Utils.createCommand(this, function () { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.Trash, + Data.currentFolderFullNameRaw(), + Data.messageListCheckedOrSelectedUidsWithSubMails(), true); + }, this.canBeMoved); + + this.archiveCommand = Utils.createCommand(this, function () { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.Archive, + Data.currentFolderFullNameRaw(), + Data.messageListCheckedOrSelectedUidsWithSubMails(), true); + }, this.canBeMoved); + + this.spamCommand = Utils.createCommand(this, function () { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.Spam, + Data.currentFolderFullNameRaw(), + Data.messageListCheckedOrSelectedUidsWithSubMails(), true); + }, this.canBeMoved); + + this.notSpamCommand = Utils.createCommand(this, function () { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.NotSpam, + Data.currentFolderFullNameRaw(), + Data.messageListCheckedOrSelectedUidsWithSubMails(), true); + }, this.canBeMoved); + + this.moveCommand = Utils.createCommand(this, Utils.emptyFunction, this.canBeMoved); + + this.reloadCommand = Utils.createCommand(this, function () { + if (!Data.messageListCompleteLoadingThrottle()) + { + __webpack_require__(/*! App:RainLoop */ 4).reloadMessageList(false, true); + } + }); + + this.quotaTooltip = _.bind(this.quotaTooltip, this); + + this.selector = new Selector(this.messageList, this.currentMessage, + '.messageListItem .actionHandle', '.messageListItem.selected', '.messageListItem .checkboxMessage', + '.messageListItem.focused'); + + this.selector.on('onItemSelect', _.bind(function (oMessage) { + if (oMessage) + { + Data.message(Data.staticMessageList.populateByMessageListItem(oMessage)); + this.populateMessageBody(Data.message()); + + if (Enums.Layout.NoPreview === Data.layout()) + { + kn.setHash(LinkBuilder.messagePreview(), true); + Data.message.focused(true); + } + } + else + { + Data.message(null); + } + }, this)); + + this.selector.on('onItemGetUid', function (oMessage) { + return oMessage ? oMessage.generateUid() : ''; + }); + + Data.messageListEndHash.subscribe(function () { + this.selector.scrollToTop(); + }, this); + + Data.layout.subscribe(function (mValue) { + this.selector.autoSelect(Enums.Layout.NoPreview !== mValue); + }, this); + + Data.layout.valueHasMutated(); + + Events + .sub('mailbox.message-list.selector.go-down', function () { + this.selector.goDown(true); + }, this) + .sub('mailbox.message-list.selector.go-up', function () { + this.selector.goUp(true); + }, this) + ; + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:MailBoxMessageList', 'MailBoxMessageListViewModel'], MailBoxMessageListViewModel); + _.extend(MailBoxMessageListViewModel.prototype, KnoinAbstractViewModel.prototype); + + /** + * @type {string} + */ + MailBoxMessageListViewModel.prototype.emptySubjectValue = ''; + + MailBoxMessageListViewModel.prototype.searchEnterAction = function () + { + this.mainMessageListSearch(this.sLastSearchValue); + this.inputMessageListSearchFocus(false); + }; + + /** + * @returns {string} + */ + MailBoxMessageListViewModel.prototype.printableMessageCountForDeletion = function () + { + var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length; + return 1 < iCnt ? ' (' + (100 > iCnt ? iCnt : '99+') + ')' : ''; + }; + + MailBoxMessageListViewModel.prototype.cancelSearch = function () + { + this.mainMessageListSearch(''); + this.inputMessageListSearchFocus(false); + }; + + /** + * @param {string} sToFolderFullNameRaw + * @param {boolean} bCopy + * @return {boolean} + */ + MailBoxMessageListViewModel.prototype.moveSelectedMessagesToFolder = function (sToFolderFullNameRaw, bCopy) + { + if (this.canBeMoved()) + { + __webpack_require__(/*! App:RainLoop */ 4).moveMessagesToFolder( + Data.currentFolderFullNameRaw(), + Data.messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw, bCopy); + } + + return false; + }; + + MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageListItem) + { + if (oMessageListItem) + { + oMessageListItem.checked(true); + } + + var + oEl = Utils.draggeblePlace(), + aUids = Data.messageListCheckedOrSelectedUidsWithSubMails() + ; + + oEl.data('rl-folder', Data.currentFolderFullNameRaw()); + oEl.data('rl-uids', aUids); + oEl.find('.text').text('' + aUids.length); + + _.defer(function () { + var aUids = Data.messageListCheckedOrSelectedUidsWithSubMails(); + + oEl.data('rl-uids', aUids); + oEl.find('.text').text('' + aUids.length); + }); + + return oEl; + }; + + /** + * @param {string} sResult + * @param {AjaxJsonDefaultResponse} oData + * @param {boolean} bCached + */ + MailBoxMessageListViewModel.prototype.onMessageResponse = function (sResult, oData, bCached) + { + Data.hideMessageBodies(); + Data.messageLoading(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + Data.setMessage(oData, bCached); + } + else if (Enums.StorageResultType.Unload === sResult) + { + Data.message(null); + Data.messageError(''); + } + else if (Enums.StorageResultType.Abort !== sResult) + { + Data.message(null); + Data.messageError((oData && oData.ErrorCode ? + Utils.getNotification(oData.ErrorCode) : + Utils.getNotification(Enums.Notification.UnknownError))); + } + }; + + MailBoxMessageListViewModel.prototype.populateMessageBody = function (oMessage) + { + if (oMessage) + { + if (Remote.message(this.onMessageResponse, oMessage.folderFullNameRaw, oMessage.uid)) + { + Data.messageLoading(true); + } + else + { + Utils.log('Error: Unknown message request: ' + oMessage.folderFullNameRaw + ' ~ ' + oMessage.uid + ' [e-101]'); + } + } + }; + + /** + * @param {string} sFolderFullNameRaw + * @param {number} iSetAction + * @param {Array=} aMessages = null + */ + MailBoxMessageListViewModel.prototype.setAction = function (sFolderFullNameRaw, iSetAction, aMessages) + { + var + aUids = [], + oFolder = null, + iAlreadyUnread = 0 + ; + + if (Utils.isUnd(aMessages)) + { + aMessages = Data.messageListChecked(); + } + + aUids = _.map(aMessages, function (oMessage) { + return oMessage.uid; + }); + + if ('' !== sFolderFullNameRaw && 0 < aUids.length) + { + switch (iSetAction) { + case Enums.MessageSetAction.SetSeen: + _.each(aMessages, function (oMessage) { + if (oMessage.unseen()) + { + iAlreadyUnread++; + } + + oMessage.unseen(false); + Cache.storeMessageFlagsToCache(oMessage); + }); + + oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); + if (oFolder) + { + oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread); + } + + Remote.messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, true); + break; + case Enums.MessageSetAction.UnsetSeen: + _.each(aMessages, function (oMessage) { + if (oMessage.unseen()) + { + iAlreadyUnread++; + } + + oMessage.unseen(true); + Cache.storeMessageFlagsToCache(oMessage); + }); + + oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); + if (oFolder) + { + oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread + aUids.length); + } + Remote.messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, false); + break; + case Enums.MessageSetAction.SetFlag: + _.each(aMessages, function (oMessage) { + oMessage.flagged(true); + Cache.storeMessageFlagsToCache(oMessage); + }); + Remote.messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, true); + break; + case Enums.MessageSetAction.UnsetFlag: + _.each(aMessages, function (oMessage) { + oMessage.flagged(false); + Cache.storeMessageFlagsToCache(oMessage); + }); + Remote.messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, false); + break; + } + + __webpack_require__(/*! App:RainLoop */ 4).reloadFlagsCurrentMessageListAndMessageFromCache(); + } + }; + + /** + * @param {string} sFolderFullNameRaw + * @param {number} iSetAction + */ + MailBoxMessageListViewModel.prototype.setActionForAll = function (sFolderFullNameRaw, iSetAction) + { + var + oFolder = null, + aMessages = Data.messageList() + ; + + if ('' !== sFolderFullNameRaw) + { + oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); + + if (oFolder) + { + switch (iSetAction) { + case Enums.MessageSetAction.SetSeen: + oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); + if (oFolder) + { + _.each(aMessages, function (oMessage) { + oMessage.unseen(false); + }); + + oFolder.messageCountUnread(0); + Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw); + } + + Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, true); + break; + case Enums.MessageSetAction.UnsetSeen: + oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); + if (oFolder) + { + _.each(aMessages, function (oMessage) { + oMessage.unseen(true); + }); + + oFolder.messageCountUnread(oFolder.messageCountAll()); + Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw); + } + Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, false); + break; + } + + __webpack_require__(/*! App:RainLoop */ 4).reloadFlagsCurrentMessageListAndMessageFromCache(); + } + } + }; + + MailBoxMessageListViewModel.prototype.listSetSeen = function () + { + this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen, Data.messageListCheckedOrSelected()); + }; + + MailBoxMessageListViewModel.prototype.listSetAllSeen = function () + { + this.setActionForAll(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen); + }; + + MailBoxMessageListViewModel.prototype.listUnsetSeen = function () + { + this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetSeen, Data.messageListCheckedOrSelected()); + }; + + MailBoxMessageListViewModel.prototype.listSetFlags = function () + { + this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetFlag, Data.messageListCheckedOrSelected()); + }; + + MailBoxMessageListViewModel.prototype.listUnsetFlags = function () + { + this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetFlag, Data.messageListCheckedOrSelected()); + }; + + MailBoxMessageListViewModel.prototype.flagMessages = function (oCurrentMessage) + { + var + aChecked = this.messageListCheckedOrSelected(), + aCheckedUids = [] + ; + + if (oCurrentMessage) + { + if (0 < aChecked.length) + { + aCheckedUids = _.map(aChecked, function (oMessage) { + return oMessage.uid; + }); + } + + if (0 < aCheckedUids.length && -1 < Utils.inArray(oCurrentMessage.uid, aCheckedUids)) + { + this.setAction(oCurrentMessage.folderFullNameRaw, oCurrentMessage.flagged() ? + Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked); + } + else + { + this.setAction(oCurrentMessage.folderFullNameRaw, oCurrentMessage.flagged() ? + Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oCurrentMessage]); + } + } + }; + + MailBoxMessageListViewModel.prototype.flagMessagesFast = function (bFlag) + { + var + aChecked = this.messageListCheckedOrSelected(), + aFlagged = [] + ; + + if (0 < aChecked.length) + { + aFlagged = _.filter(aChecked, function (oMessage) { + return oMessage.flagged(); + }); + + if (Utils.isUnd(bFlag)) + { + this.setAction(aChecked[0].folderFullNameRaw, + aChecked.length === aFlagged.length ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked); + } + else + { + this.setAction(aChecked[0].folderFullNameRaw, + !bFlag ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked); + } + } + }; + + MailBoxMessageListViewModel.prototype.seenMessagesFast = function (bSeen) + { + var + aChecked = this.messageListCheckedOrSelected(), + aUnseen = [] + ; + + if (0 < aChecked.length) + { + aUnseen = _.filter(aChecked, function (oMessage) { + return oMessage.unseen(); + }); + + if (Utils.isUnd(bSeen)) + { + this.setAction(aChecked[0].folderFullNameRaw, + 0 < aUnseen.length ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked); + } + else + { + this.setAction(aChecked[0].folderFullNameRaw, + bSeen ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked); + } + } + }; + + MailBoxMessageListViewModel.prototype.onBuild = function (oDom) + { + var self = this; + + this.oContentVisible = $('.b-content', oDom); + this.oContentScrollable = $('.content', this.oContentVisible); + + this.oContentVisible.on('click', '.fullThreadHandle', function () { + var + aList = [], + oMessage = ko.dataFor(this) + ; + + if (oMessage && !oMessage.lastInCollapsedThreadLoading()) + { + Data.messageListThreadFolder(oMessage.folderFullNameRaw); + + aList = Data.messageListThreadUids(); + + if (oMessage.lastInCollapsedThread()) + { + aList.push(0 < oMessage.parentUid() ? oMessage.parentUid() : oMessage.uid); + } + else + { + aList = _.without(aList, 0 < oMessage.parentUid() ? oMessage.parentUid() : oMessage.uid); + } + + Data.messageListThreadUids(_.uniq(aList)); + + oMessage.lastInCollapsedThreadLoading(true); + oMessage.lastInCollapsedThread(!oMessage.lastInCollapsedThread()); + + __webpack_require__(/*! App:RainLoop */ 4).reloadMessageList(); + } + + return false; + }); + + this.selector.init(this.oContentVisible, this.oContentScrollable, Enums.KeyState.MessageList); + + oDom + .on('click', '.messageList .b-message-list-wrapper', function () { + if (self.message.focused()) + { + self.message.focused(false); + } + }) + .on('click', '.e-pagenator .e-page', function () { + var oPage = ko.dataFor(this); + if (oPage) + { + kn.setHash(LinkBuilder.mailBox( + Data.currentFolderFullNameHash(), + oPage.value, + Data.messageListSearch() + )); + } + }) + .on('click', '.messageList .checkboxCkeckAll', function () { + self.checkAll(!self.checkAll()); + }) + .on('click', '.messageList .messageListItem .flagParent', function () { + self.flagMessages(ko.dataFor(this)); + }) + ; + + this.initUploaderForAppend(); + this.initShortcuts(); + + if (!Globals.bMobileDevice && Settings.capa(Enums.Capa.Prefetch) && ifvisible) + { + ifvisible.setIdleDuration(10); + + ifvisible.idle(function () { + self.prefetchNextTick(); + }); + } + }; + + MailBoxMessageListViewModel.prototype.initShortcuts = function () + { + var self = this; + + // disable print + key('ctrl+p, command+p', Enums.KeyState.MessageList, function () { + return false; + }); + + // archive (zip) + key('z', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + self.archiveCommand(); + return false; + }); + + // delete + key('delete, shift+delete, shift+3', Enums.KeyState.MessageList, function (event, handler) { + if (event) + { + if (0 < Data.messageListCheckedOrSelected().length) + { + if (handler && 'shift+delete' === handler.shortcut) + { + self.deleteWithoutMoveCommand(); + } + else + { + self.deleteCommand(); + } + } + + return false; + } + }); + + // check mail + key('ctrl+r, command+r', [Enums.KeyState.FolderList, Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + self.reloadCommand(); + return false; + }); + + // check all + key('ctrl+a, command+a', Enums.KeyState.MessageList, function () { + self.checkAll(!(self.checkAll() && !self.isIncompleteChecked())); + return false; + }); + + // write/compose (open compose popup) + key('w,c', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Compose */ 21)); + return false; + }); + + // important - star/flag messages + key('i', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + self.flagMessagesFast(); + return false; + }); + + // move + key('m', Enums.KeyState.MessageList, function () { + self.moveDropdownTrigger(true); + return false; + }); + + // read + key('q', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + self.seenMessagesFast(true); + return false; + }); + + // unread + key('u', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + self.seenMessagesFast(false); + return false; + }); + + key('shift+f', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + self.multyForwardCommand(); + return false; + }); + + // search input focus + key('/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + self.inputMessageListSearchFocus(true); + return false; + }); + + // cancel search + key('esc', Enums.KeyState.MessageList, function () { + if ('' !== self.messageListSearchDesc()) + { + self.cancelSearch(); + return false; + } + }); + + // change focused state + key('tab, shift+tab, left, right', Enums.KeyState.MessageList, function (event, handler) { + if (event && handler && ('shift+tab' === handler.shortcut || 'left' === handler.shortcut)) + { + self.folderList.focused(true); + } + else if (self.message()) + { + self.message.focused(true); + } + + return false; + }); + + // TODO + key('ctrl+left, command+left', Enums.KeyState.MessageView, function () { + return false; + }); + + // TODO + key('ctrl+right, command+right', Enums.KeyState.MessageView, function () { + return false; + }); + }; + + MailBoxMessageListViewModel.prototype.prefetchNextTick = function () + { + if (!this.bPrefetch && !ifvisible.now() && this.viewModelVisibility()) + { + var + self = this, + oMessage = _.find(this.messageList(), function (oMessage) { + return oMessage && + !Cache.hasRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid); + }) + ; + + if (oMessage) + { + this.bPrefetch = true; + + Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid); + + Remote.message(function (sResult, oData) { + + var bNext = !!(Enums.StorageResultType.Success === sResult && oData && oData.Result); + + _.delay(function () { + self.bPrefetch = false; + if (bNext) + { + self.prefetchNextTick(); + } + }, 1000); + + }, oMessage.folderFullNameRaw, oMessage.uid); + } + } + }; + + MailBoxMessageListViewModel.prototype.composeClick = function () + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Compose */ 21)); + }; + + MailBoxMessageListViewModel.prototype.advancedSearchClick = function () + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:AdvancedSearch */ 103)); + }; + + MailBoxMessageListViewModel.prototype.quotaTooltip = function () + { + return Utils.i18n('MESSAGE_LIST/QUOTA_SIZE', { + 'SIZE': Utils.friendlySize(this.userUsageSize()), + 'PROC': this.userUsageProc(), + 'LIMIT': Utils.friendlySize(this.userQuota()) + }); + }; + + MailBoxMessageListViewModel.prototype.initUploaderForAppend = function () + { + if (!Settings.settingsGet('AllowAppendMessage') || !this.dragOverArea()) + { + return false; + } + + var + oJua = new Jua({ + 'action': LinkBuilder.append(), + 'name': 'AppendFile', + 'queueSize': 1, + 'multipleSizeLimit': 1, + 'disableFolderDragAndDrop': true, + 'hidden': { + 'Folder': function () { + return Data.currentFolderFullNameRaw(); + } + }, + 'dragAndDropElement': this.dragOverArea(), + 'dragAndDropBodyElement': this.dragOverBodyArea() + }) + ; + + oJua + .on('onDragEnter', _.bind(function () { + this.dragOverEnter(true); + }, this)) + .on('onDragLeave', _.bind(function () { + this.dragOverEnter(false); + }, this)) + .on('onBodyDragEnter', _.bind(function () { + this.dragOver(true); + }, this)) + .on('onBodyDragLeave', _.bind(function () { + this.dragOver(false); + }, this)) + .on('onSelect', _.bind(function (sUid, oData) { + if (sUid && oData && 'message/rfc822' === oData['Type']) + { + Data.messageListLoading(true); + return true; + } + + return false; + }, this)) + .on('onComplete', _.bind(function () { + __webpack_require__(/*! App:RainLoop */ 4).reloadMessageList(true, true); + }, this)) + ; + + return !!oJua; + }; + + module.exports = MailBoxMessageListViewModel; + + }()); + + +/***/ }, +/* 99 */ +/*!*******************************************************!*\ + !*** ./dev/ViewModels/MailBoxMessageViewViewModel.js ***! + \*******************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Consts = __webpack_require__(/*! Common/Consts */ 17), + Enums = __webpack_require__(/*! Common/Enums */ 6), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + Events = __webpack_require__(/*! Common/Events */ 22), + + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function MailBoxMessageViewViewModel() + { + KnoinAbstractViewModel.call(this, 'Right', 'MailMessageView'); + + var + self = this, + sLastEmail = '', + createCommandHelper = function (sType) { + return Utils.createCommand(self, function () { + this.replyOrforward(sType); + }, self.canBeRepliedOrForwarded); + } + ; + + this.oMessageScrollerDom = null; + + this.message = Data.message; + this.currentMessage = Data.currentMessage; + this.messageListChecked = Data.messageListChecked; + this.hasCheckedMessages = Data.hasCheckedMessages; + this.messageListCheckedOrSelectedUidsWithSubMails = Data.messageListCheckedOrSelectedUidsWithSubMails; + this.messageLoading = Data.messageLoading; + this.messageLoadingThrottle = Data.messageLoadingThrottle; + this.messagesBodiesDom = Data.messagesBodiesDom; + this.useThreads = Data.useThreads; + this.replySameFolder = Data.replySameFolder; + this.layout = Data.layout; + this.usePreviewPane = Data.usePreviewPane; + this.isMessageSelected = Data.isMessageSelected; + this.messageActiveDom = Data.messageActiveDom; + this.messageError = Data.messageError; + + this.fullScreenMode = Data.messageFullScreenMode; + + this.showFullInfo = ko.observable(false); + this.moreDropdownTrigger = ko.observable(false); + this.messageDomFocused = ko.observable(false).extend({'rateLimit': 0}); + + this.messageVisibility = ko.computed(function () { + return !this.messageLoadingThrottle() && !!this.message(); + }, this); + + this.message.subscribe(function (oMessage) { + if (!oMessage) + { + this.currentMessage(null); + } + }, this); + + this.canBeRepliedOrForwarded = this.messageVisibility; + + // commands + this.closeMessage = Utils.createCommand(this, function () { + Data.message(null); + }); + + this.replyCommand = createCommandHelper(Enums.ComposeType.Reply); + this.replyAllCommand = createCommandHelper(Enums.ComposeType.ReplyAll); + this.forwardCommand = createCommandHelper(Enums.ComposeType.Forward); + this.forwardAsAttachmentCommand = createCommandHelper(Enums.ComposeType.ForwardAsAttachment); + this.editAsNewCommand = createCommandHelper(Enums.ComposeType.EditAsNew); + + this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility); + + this.messageEditCommand = Utils.createCommand(this, function () { + this.editMessage(); + }, this.messageVisibility); + + this.deleteCommand = Utils.createCommand(this, function () { + if (this.message()) + { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.Trash, + this.message().folderFullNameRaw, + [this.message().uid], true); + } + }, this.messageVisibility); + + this.deleteWithoutMoveCommand = Utils.createCommand(this, function () { + if (this.message()) + { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.Trash, + Data.currentFolderFullNameRaw(), + [this.message().uid], false); + } + }, this.messageVisibility); + + this.archiveCommand = Utils.createCommand(this, function () { + if (this.message()) + { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.Archive, + this.message().folderFullNameRaw, + [this.message().uid], true); + } + }, this.messageVisibility); + + this.spamCommand = Utils.createCommand(this, function () { + if (this.message()) + { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.Spam, + this.message().folderFullNameRaw, + [this.message().uid], true); + } + }, this.messageVisibility); + + this.notSpamCommand = Utils.createCommand(this, function () { + if (this.message()) + { + __webpack_require__(/*! App:RainLoop */ 4).deleteMessagesFromFolder(Enums.FolderType.NotSpam, + this.message().folderFullNameRaw, + [this.message().uid], true); + } + }, this.messageVisibility); + + // viewer + this.viewHash = ''; + this.viewSubject = ko.observable(''); + this.viewFromShort = ko.observable(''); + this.viewToShort = ko.observable(''); + this.viewFrom = ko.observable(''); + this.viewTo = ko.observable(''); + this.viewCc = ko.observable(''); + this.viewBcc = ko.observable(''); + this.viewDate = ko.observable(''); + this.viewSize = ko.observable(''); + this.viewMoment = ko.observable(''); + this.viewLineAsCcc = ko.observable(''); + this.viewViewLink = ko.observable(''); + this.viewDownloadLink = ko.observable(''); + this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic); + this.viewUserPicVisible = ko.observable(false); + + this.viewPgpPassword = ko.observable(''); + this.viewPgpSignedVerifyStatus = ko.computed(function () { + return this.message() ? this.message().pgpSignedVerifyStatus() : Enums.SignedVerifyStatus.None; + }, this); + + this.viewPgpSignedVerifyUser = ko.computed(function () { + return this.message() ? this.message().pgpSignedVerifyUser() : ''; + }, this); + + this.message.subscribe(function (oMessage) { + + this.messageActiveDom(null); + + this.viewPgpPassword(''); + + if (oMessage) + { + if (this.viewHash !== oMessage.hash) + { + this.scrollMessageToTop(); + } + + this.viewHash = oMessage.hash; + this.viewSubject(oMessage.subject()); + this.viewFromShort(oMessage.fromToLine(true, true)); + this.viewToShort(oMessage.toToLine(true, true)); + this.viewFrom(oMessage.fromToLine(false)); + this.viewTo(oMessage.toToLine(false)); + this.viewCc(oMessage.ccToLine(false)); + this.viewBcc(oMessage.bccToLine(false)); + this.viewDate(oMessage.fullFormatDateValue()); + this.viewSize(oMessage.friendlySize()); + this.viewMoment(oMessage.momentDate()); + this.viewLineAsCcc(oMessage.lineAsCcc()); + this.viewViewLink(oMessage.viewLink()); + this.viewDownloadLink(oMessage.downloadLink()); + + sLastEmail = oMessage.fromAsSingleEmail(); + Cache.getUserPic(sLastEmail, function (sPic, $sEmail) { + if (sPic !== self.viewUserPic() && sLastEmail === $sEmail) + { + self.viewUserPicVisible(false); + self.viewUserPic(Consts.DataImages.UserDotPic); + if ('' !== sPic) + { + self.viewUserPicVisible(true); + self.viewUserPic(sPic); + } + } + }); + } + else + { + this.viewHash = ''; + this.scrollMessageToTop(); + } + + }, this); + + this.fullScreenMode.subscribe(function (bValue) { + if (bValue) + { + Globals.$html.addClass('rl-message-fullscreen'); + } + else + { + Globals.$html.removeClass('rl-message-fullscreen'); + } + + Utils.windowResize(); + }); + + this.messageLoadingThrottle.subscribe(function (bV) { + if (bV) + { + Utils.windowResize(); + } + }); + + this.goUpCommand = Utils.createCommand(this, function () { + Events.pub('mailbox.message-list.selector.go-up'); + }); + + this.goDownCommand = Utils.createCommand(this, function () { + Events.pub('mailbox.message-list.selector.go-down'); + }); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:MailBoxMessageView', 'MailBoxMessageViewViewModel'], MailBoxMessageViewViewModel); + _.extend(MailBoxMessageViewViewModel.prototype, KnoinAbstractViewModel.prototype); + + MailBoxMessageViewViewModel.prototype.isPgpActionVisible = function () + { + return Enums.SignedVerifyStatus.Success !== this.viewPgpSignedVerifyStatus(); + }; + + MailBoxMessageViewViewModel.prototype.isPgpStatusVerifyVisible = function () + { + return Enums.SignedVerifyStatus.None !== this.viewPgpSignedVerifyStatus(); + }; + + MailBoxMessageViewViewModel.prototype.isPgpStatusVerifySuccess = function () + { + return Enums.SignedVerifyStatus.Success === this.viewPgpSignedVerifyStatus(); + }; + + MailBoxMessageViewViewModel.prototype.pgpStatusVerifyMessage = function () + { + var sResult = ''; + switch (this.viewPgpSignedVerifyStatus()) + { + case Enums.SignedVerifyStatus.UnknownPublicKeys: + sResult = Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND'); + break; + case Enums.SignedVerifyStatus.UnknownPrivateKey: + sResult = Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'); + break; + case Enums.SignedVerifyStatus.Unverified: + sResult = Utils.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE'); + break; + case Enums.SignedVerifyStatus.Error: + sResult = Utils.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'); + break; + case Enums.SignedVerifyStatus.Success: + sResult = Utils.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', { + 'USER': this.viewPgpSignedVerifyUser() + }); + break; + } + + return sResult; + }; + + MailBoxMessageViewViewModel.prototype.fullScreen = function () + { + this.fullScreenMode(true); + Utils.windowResize(); + }; + + MailBoxMessageViewViewModel.prototype.unFullScreen = function () + { + this.fullScreenMode(false); + Utils.windowResize(); + }; + + MailBoxMessageViewViewModel.prototype.toggleFullScreen = function () + { + Utils.removeSelection(); + + this.fullScreenMode(!this.fullScreenMode()); + Utils.windowResize(); + }; + + /** + * @param {string} sType + */ + MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType) + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Compose */ 21), [sType, Data.message()]); + }; + + MailBoxMessageViewViewModel.prototype.onBuild = function (oDom) + { + var self = this; + this.fullScreenMode.subscribe(function (bValue) { + if (bValue) + { + self.message.focused(true); + } + }, this); + + $('.attachmentsPlace', oDom).magnificPopup({ + 'delegate': '.magnificPopupImage:visible', + 'type': 'image', + 'gallery': { + 'enabled': true, + 'preload': [1, 1], + 'navigateByImgClick': true + }, + 'callbacks': { + 'open': function() { + Globals.useKeyboardShortcuts(false); + }, + 'close': function() { + Globals.useKeyboardShortcuts(true); + } + }, + 'mainClass': 'mfp-fade', + 'removalDelay': 400 + }); + + oDom + .on('click', 'a', function (oEvent) { + // setup maito protocol + return !(!!oEvent && 3 !== oEvent['which'] && Utils.mailToHelper($(this).attr('href'), __webpack_require__(/*! View:Popup:Compose */ 21))); + }) + .on('click', '.attachmentsPlace .attachmentPreview', function (oEvent) { + if (oEvent && oEvent.stopPropagation) + { + oEvent.stopPropagation(); + } + }) + .on('click', '.attachmentsPlace .attachmentItem', function () { + + var + oAttachment = ko.dataFor(this) + ; + + if (oAttachment && oAttachment.download) + { + __webpack_require__(/*! App:RainLoop */ 4).download(oAttachment.linkDownload()); + } + }) + ; + + this.message.focused.subscribe(function (bValue) { + if (bValue && !Utils.inFocus()) { + this.messageDomFocused(true); + } else { + this.messageDomFocused(false); + this.scrollMessageToTop(); + this.scrollMessageToLeft(); + } + }, this); + + this.messageDomFocused.subscribe(function (bValue) { + if (!bValue && Enums.KeyState.MessageView === Globals.keyScope()) + { + this.message.focused(false); + } + }, this); + + Globals.keyScope.subscribe(function (sValue) { + if (Enums.KeyState.MessageView === sValue && this.message.focused()) + { + this.messageDomFocused(true); + } + }, this); + + this.oMessageScrollerDom = oDom.find('.messageItem .content'); + this.oMessageScrollerDom = this.oMessageScrollerDom && this.oMessageScrollerDom[0] ? this.oMessageScrollerDom : null; + + this.initShortcuts(); + }; + + /** + * @return {boolean} + */ + MailBoxMessageViewViewModel.prototype.escShortcuts = function () + { + if (this.viewModelVisibility() && this.message()) + { + if (this.fullScreenMode()) + { + this.fullScreenMode(false); + } + else if (Enums.Layout.NoPreview === Data.layout()) + { + this.message(null); + } + else + { + this.message.focused(false); + } + + return false; + } + }; + + MailBoxMessageViewViewModel.prototype.initShortcuts = function () + { + var + self = this + ; + + // exit fullscreen, back + key('esc', Enums.KeyState.MessageView, _.bind(this.escShortcuts, this)); + + // fullscreen + key('enter', Enums.KeyState.MessageView, function () { + self.toggleFullScreen(); + return false; + }); + + key('enter', Enums.KeyState.MessageList, function () { + if (Enums.Layout.NoPreview !== Data.layout() && self.message()) + { + self.toggleFullScreen(); + return false; + } + }); + + // TODO // more toggle + // key('', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + // self.moreDropdownTrigger(true); + // return false; + // }); + + // reply + key('r', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + if (Data.message()) + { + self.replyCommand(); + return false; + } + }); + + // replaAll + key('a', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + if (Data.message()) + { + self.replyAllCommand(); + return false; + } + }); + + // forward + key('f', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + if (Data.message()) + { + self.forwardCommand(); + return false; + } + }); + + // message information + // key('i', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + // if (oData.message()) + // { + // self.showFullInfo(!self.showFullInfo()); + // return false; + // } + // }); + + // toggle message blockquotes + key('b', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () { + if (Data.message() && Data.message().body) + { + Data.message().body.find('.rlBlockquoteSwitcher').click(); + return false; + } + }); + + key('ctrl+left, command+left, ctrl+up, command+up', Enums.KeyState.MessageView, function () { + self.goUpCommand(); + return false; + }); + + key('ctrl+right, command+right, ctrl+down, command+down', Enums.KeyState.MessageView, function () { + self.goDownCommand(); + return false; + }); + + // print + key('ctrl+p, command+p', Enums.KeyState.MessageView, function () { + if (self.message()) + { + self.message().printMessage(); + } + + return false; + }); + + // delete + key('delete, shift+delete', Enums.KeyState.MessageView, function (event, handler) { + if (event) + { + if (handler && 'shift+delete' === handler.shortcut) + { + self.deleteWithoutMoveCommand(); + } + else + { + self.deleteCommand(); + } + + return false; + } + }); + + // change focused state + key('tab, shift+tab, left', Enums.KeyState.MessageView, function (event, handler) { + if (!self.fullScreenMode() && self.message() && Enums.Layout.NoPreview !== Data.layout()) + { + if (event && handler && 'left' === handler.shortcut) + { + if (self.oMessageScrollerDom && 0 < self.oMessageScrollerDom.scrollLeft()) + { + return true; + } + + self.message.focused(false); + } + else + { + self.message.focused(false); + } + } + else if (self.message() && Enums.Layout.NoPreview === Data.layout() && event && handler && 'left' === handler.shortcut) + { + return true; + } + + return false; + }); + }; + + /** + * @return {boolean} + */ + MailBoxMessageViewViewModel.prototype.isDraftFolder = function () + { + return Data.message() && Data.draftFolder() === Data.message().folderFullNameRaw; + }; + + /** + * @return {boolean} + */ + MailBoxMessageViewViewModel.prototype.isSentFolder = function () + { + return Data.message() && Data.sentFolder() === Data.message().folderFullNameRaw; + }; + + /** + * @return {boolean} + */ + MailBoxMessageViewViewModel.prototype.isSpamFolder = function () + { + return Data.message() && Data.spamFolder() === Data.message().folderFullNameRaw; + }; + + /** + * @return {boolean} + */ + MailBoxMessageViewViewModel.prototype.isSpamDisabled = function () + { + return Data.message() && Data.spamFolder() === Consts.Values.UnuseOptionValue; + }; + + /** + * @return {boolean} + */ + MailBoxMessageViewViewModel.prototype.isArchiveFolder = function () + { + return Data.message() && Data.archiveFolder() === Data.message().folderFullNameRaw; + }; + + /** + * @return {boolean} + */ + MailBoxMessageViewViewModel.prototype.isArchiveDisabled = function () + { + return Data.message() && Data.archiveFolder() === Consts.Values.UnuseOptionValue; + }; + + /** + * @return {boolean} + */ + MailBoxMessageViewViewModel.prototype.isDraftOrSentFolder = function () + { + return this.isDraftFolder() || this.isSentFolder(); + }; + + MailBoxMessageViewViewModel.prototype.composeClick = function () + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Compose */ 21)); + }; + + MailBoxMessageViewViewModel.prototype.editMessage = function () + { + if (Data.message()) + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Compose */ 21), [Enums.ComposeType.Draft, Data.message()]); + } + }; + + MailBoxMessageViewViewModel.prototype.scrollMessageToTop = function () + { + if (this.oMessageScrollerDom) + { + this.oMessageScrollerDom.scrollTop(0); + Utils.windowResize(); + } + }; + + MailBoxMessageViewViewModel.prototype.scrollMessageToLeft = function () + { + if (this.oMessageScrollerDom) + { + this.oMessageScrollerDom.scrollLeft(0); + Utils.windowResize(); + } + }; + + /** + * @param {MessageModel} oMessage + */ + MailBoxMessageViewViewModel.prototype.showImages = function (oMessage) + { + if (oMessage && oMessage.showExternalImages) + { + oMessage.showExternalImages(true); + } + }; + + /** + * @returns {string} + */ + MailBoxMessageViewViewModel.prototype.printableCheckedMessageCount = function () + { + var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length; + return 0 < iCnt ? (100 > iCnt ? iCnt : '99+') : ''; + }; + + + /** + * @param {MessageModel} oMessage + */ + MailBoxMessageViewViewModel.prototype.verifyPgpSignedClearMessage = function (oMessage) + { + if (oMessage) + { + oMessage.verifyPgpSignedClearMessage(); + } + }; + + /** + * @param {MessageModel} oMessage + */ + MailBoxMessageViewViewModel.prototype.decryptPgpEncryptedMessage = function (oMessage) + { + if (oMessage) + { + oMessage.decryptPgpEncryptedMessage(this.viewPgpPassword()); + } + }; + + /** + * @param {MessageModel} oMessage + */ + MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage) + { + if (oMessage && '' !== oMessage.readReceipt()) + { + Remote.sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid, + oMessage.readReceipt(), + Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}), + Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': Data.accountEmail()})); + + oMessage.isReadReceipt(true); + + Cache.storeMessageFlagsToCache(oMessage); + + __webpack_require__(/*! App:RainLoop */ 4).reloadFlagsCurrentMessageListAndMessageFromCache(); + } + }; + + module.exports = MailBoxMessageViewViewModel; + + }()); + +/***/ }, +/* 100 */ +/*!**********************************************************!*\ + !*** ./dev/ViewModels/MailBoxSystemDropDownViewModel.js ***! + \**********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + kn = __webpack_require__(/*! App:Knoin */ 5), + AbstractSystemDropDownViewModel = __webpack_require__(/*! View:RainLoop:AbstractSystemDropDown */ 41) + ; + + /** + * @constructor + * @extends AbstractSystemDropDownViewModel + */ + function MailBoxSystemDropDownViewModel() + { + AbstractSystemDropDownViewModel.call(this); + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:MailBoxSystemDropDown', 'MailBoxSystemDropDownViewModel'], MailBoxSystemDropDownViewModel); + _.extend(MailBoxSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype); + + module.exports = MailBoxSystemDropDownViewModel; + + }()); + + +/***/ }, +/* 101 */, +/* 102 */ +/*!***************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js ***! + \***************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsAddOpenPgpKeyViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey'); + + this.key = ko.observable(''); + this.key.error = ko.observable(false); + this.key.focus = ko.observable(false); + + this.key.subscribe(function () { + this.key.error(false); + }, this); + + this.addOpenPgpKeyCommand = Utils.createCommand(this, function () { + + var + iCount = 30, + aMatch = null, + sKey = Utils.trim(this.key()), + oReg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi, + oOpenpgpKeyring = Data.openpgpKeyring + ; + + sKey = sKey.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g, '\n$1!-!N!-!$2') + .replace(/[\n\r]+/g, '\n').replace(/!-!N!-!/g, '\n\n'); + + this.key.error('' === sKey); + + if (!oOpenpgpKeyring || this.key.error()) + { + return false; + } + + do + { + aMatch = oReg.exec(sKey); + if (!aMatch || 0 > iCount) + { + break; + } + + if (aMatch[0] && aMatch[1] && aMatch[2] && aMatch[1] === aMatch[2]) + { + if ('PRIVATE' === aMatch[1]) + { + oOpenpgpKeyring.privateKeys.importKey(aMatch[0]); + } + else if ('PUBLIC' === aMatch[1]) + { + oOpenpgpKeyring.publicKeys.importKey(aMatch[0]); + } + } + + iCount--; + } + while (true); + + oOpenpgpKeyring.store(); + + __webpack_require__(/*! App:RainLoop */ 4).reloadOpenPgpKeys(); + Utils.delegateRun(this, 'cancelCommand'); + + return true; + }); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:AddOpenPgpKey', 'PopupsAddOpenPgpKeyViewModel'], PopupsAddOpenPgpKeyViewModel); + _.extend(PopupsAddOpenPgpKeyViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function () + { + this.key(''); + this.key.error(false); + }; + + PopupsAddOpenPgpKeyViewModel.prototype.onShow = function () + { + this.clearPopup(); + }; + + PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function () + { + this.key.focus(true); + }; + + module.exports = PopupsAddOpenPgpKeyViewModel; + + }()); + +/***/ }, +/* 103 */ +/*!****************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsAdvancedSearchViewModel.js ***! + \****************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + moment = __webpack_require__(/*! moment */ 25), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsAdvancedSearchViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAdvancedSearch'); + + this.fromFocus = ko.observable(false); + + this.from = ko.observable(''); + this.to = ko.observable(''); + this.subject = ko.observable(''); + this.text = ko.observable(''); + this.selectedDateValue = ko.observable(-1); + + this.hasAttachment = ko.observable(false); + this.starred = ko.observable(false); + this.unseen = ko.observable(false); + + this.searchCommand = Utils.createCommand(this, function () { + + var sSearch = this.buildSearchString(); + if ('' !== sSearch) + { + Data.mainMessageListSearch(sSearch); + } + + this.cancelCommand(); + }); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:AdvancedSearch', 'PopupsAdvancedSearchViewModel'], PopupsAdvancedSearchViewModel); + _.extend(PopupsAdvancedSearchViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsAdvancedSearchViewModel.prototype.buildSearchStringValue = function (sValue) + { + if (-1 < sValue.indexOf(' ')) + { + sValue = '"' + sValue + '"'; + } + + return sValue; + }; + + PopupsAdvancedSearchViewModel.prototype.buildSearchString = function () + { + var + aResult = [], + sFrom = Utils.trim(this.from()), + sTo = Utils.trim(this.to()), + sSubject = Utils.trim(this.subject()), + sText = Utils.trim(this.text()), + aIs = [], + aHas = [] + ; + + if (sFrom && '' !== sFrom) + { + aResult.push('from:' + this.buildSearchStringValue(sFrom)); + } + + if (sTo && '' !== sTo) + { + aResult.push('to:' + this.buildSearchStringValue(sTo)); + } + + if (sSubject && '' !== sSubject) + { + aResult.push('subject:' + this.buildSearchStringValue(sSubject)); + } + + if (this.hasAttachment()) + { + aHas.push('attachment'); + } + + if (this.unseen()) + { + aIs.push('unseen'); + } + + if (this.starred()) + { + aIs.push('flagged'); + } + + if (0 < aHas.length) + { + aResult.push('has:' + aHas.join(',')); + } + + if (0 < aIs.length) + { + aResult.push('is:' + aIs.join(',')); + } + + if (-1 < this.selectedDateValue()) + { + aResult.push('date:' + moment().subtract('days', this.selectedDateValue()).format('YYYY.MM.DD') + '/'); + } + + if (sText && '' !== sText) + { + aResult.push('text:' + this.buildSearchStringValue(sText)); + } + + return Utils.trim(aResult.join(' ')); + }; + + PopupsAdvancedSearchViewModel.prototype.clearPopup = function () + { + this.from(''); + this.to(''); + this.subject(''); + this.text(''); + + this.selectedDateValue(-1); + this.hasAttachment(false); + this.starred(false); + this.unseen(false); + + this.fromFocus(true); + }; + + PopupsAdvancedSearchViewModel.prototype.onShow = function () + { + this.clearPopup(); + }; + + PopupsAdvancedSearchViewModel.prototype.onFocus = function () + { + this.fromFocus(true); + }; + + module.exports = PopupsAdvancedSearchViewModel; + + }()); + +/***/ }, +/* 104 */ +/*!****************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsComposeOpenPgpViewModel.js ***! + \****************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + Enums = __webpack_require__(/*! Common/Enums */ 6), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + + EmailModel = __webpack_require__(/*! Model:Email */ 23), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsComposeOpenPgpViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsComposeOpenPgp'); + + this.notification = ko.observable(''); + + this.sign = ko.observable(true); + this.encrypt = ko.observable(true); + + this.password = ko.observable(''); + this.password.focus = ko.observable(false); + this.buttonFocus = ko.observable(false); + + this.from = ko.observable(''); + this.to = ko.observableArray([]); + this.text = ko.observable(''); + + this.resultCallback = null; + + this.submitRequest = ko.observable(false); + + // commands + this.doCommand = Utils.createCommand(this, function () { + + var + self = this, + bResult = true, + oPrivateKey = null, + aPublicKeys = [] + ; + + this.submitRequest(true); + + if (bResult && this.sign() && '' === this.from()) + { + this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_FROM_EMAIL')); + bResult = false; + } + + if (bResult && this.sign()) + { + oPrivateKey = Data.findPrivateKeyByEmail(this.from(), this.password()); + if (!oPrivateKey) + { + this.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', { + 'EMAIL': this.from() + })); + + bResult = false; + } + } + + if (bResult && this.encrypt() && 0 === this.to().length) + { + this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_AT_LEAST_ONE_RECIPIENT')); + bResult = false; + } + + if (bResult && this.encrypt()) + { + aPublicKeys = []; + _.each(this.to(), function (sEmail) { + var aKeys = Data.findPublicKeysByEmail(sEmail); + if (0 === aKeys.length && bResult) + { + self.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', { + 'EMAIL': sEmail + })); + + bResult = false; + } + + aPublicKeys = aPublicKeys.concat(aKeys); + }); + + if (bResult && (0 === aPublicKeys.length || this.to().length !== aPublicKeys.length)) + { + bResult = false; + } + } + + _.delay(function () { + + if (self.resultCallback && bResult) + { + try { + + if (oPrivateKey && 0 === aPublicKeys.length) + { + self.resultCallback( + window.openpgp.signClearMessage([oPrivateKey], self.text()) + ); + } + else if (oPrivateKey && 0 < aPublicKeys.length) + { + self.resultCallback( + window.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, self.text()) + ); + } + else if (!oPrivateKey && 0 < aPublicKeys.length) + { + self.resultCallback( + window.openpgp.encryptMessage(aPublicKeys, self.text()) + ); + } + } + catch (e) + { + self.notification(Utils.i18n('PGP_NOTIFICATIONS/PGP_ERROR', { + 'ERROR': '' + e + })); + + bResult = false; + } + } + + if (bResult) + { + self.cancelCommand(); + } + + self.submitRequest(false); + + }, 10); + + }, function () { + return !this.submitRequest() && (this.sign() || this.encrypt()); + }); + + this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP; + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:ComposeOpenPgp', 'PopupsComposeOpenPgpViewModel'], PopupsComposeOpenPgpViewModel); + _.extend(PopupsComposeOpenPgpViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsComposeOpenPgpViewModel.prototype.clearPopup = function () + { + this.notification(''); + + this.password(''); + this.password.focus(false); + this.buttonFocus(false); + + this.from(''); + this.to([]); + this.text(''); + + this.submitRequest(false); + + this.resultCallback = null; + }; + + PopupsComposeOpenPgpViewModel.prototype.onBuild = function () + { + key('tab,shift+tab', Enums.KeyState.PopupComposeOpenPGP, _.bind(function () { + + switch (true) + { + case this.password.focus(): + this.buttonFocus(true); + break; + case this.buttonFocus(): + this.password.focus(true); + break; + } + + return false; + + }, this)); + }; + + PopupsComposeOpenPgpViewModel.prototype.onHide = function () + { + this.clearPopup(); + }; + + PopupsComposeOpenPgpViewModel.prototype.onFocus = function () + { + if (this.sign()) + { + this.password.focus(true); + } + else + { + this.buttonFocus(true); + } + }; + + PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc) + { + this.clearPopup(); + + var + oEmail = new EmailModel(), + sResultFromEmail = '', + aRec = [] + ; + + this.resultCallback = fCallback; + + oEmail.clear(); + oEmail.mailsoParse(sFromEmail); + if ('' !== oEmail.email) + { + sResultFromEmail = oEmail.email; + } + + if ('' !== sTo) + { + aRec.push(sTo); + } + + if ('' !== sCc) + { + aRec.push(sCc); + } + + if ('' !== sBcc) + { + aRec.push(sBcc); + } + + aRec = aRec.join(', ').split(','); + aRec = _.compact(_.map(aRec, function (sValue) { + oEmail.clear(); + oEmail.mailsoParse(Utils.trim(sValue)); + return '' === oEmail.email ? false : oEmail.email; + })); + + this.from(sResultFromEmail); + this.to(aRec); + this.text(sText); + }; + + module.exports = PopupsComposeOpenPgpViewModel; + + }()); + +/***/ }, +/* 105 */, +/* 106 */ +/*!********************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsFilterViewModel.js ***! + \********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Consts = __webpack_require__(/*! Common/Consts */ 17), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsFilterViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFilter'); + + this.filter = ko.observable(null); + + this.selectedFolderValue = ko.observable(Consts.Values.UnuseOptionValue); + this.folderSelectList = Data.folderMenuForMove; + this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:Filter', 'PopupsFilterViewModel'], PopupsFilterViewModel); + _.extend(PopupsFilterViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsFilterViewModel.prototype.clearPopup = function () + { + // TODO + }; + + PopupsFilterViewModel.prototype.onShow = function (oFilter) + { + this.clearPopup(); + + this.filter(oFilter); + }; + + module.exports = PopupsFilterViewModel; + + }()); + +/***/ }, +/* 107 */ +/*!*************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsFolderClearViewModel.js ***! + \*************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsFolderClearViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderClear'); + + this.selectedFolder = ko.observable(null); + this.clearingProcess = ko.observable(false); + this.clearingError = ko.observable(''); + + this.folderFullNameForClear = ko.computed(function () { + var oFolder = this.selectedFolder(); + return oFolder ? oFolder.printableFullName() : ''; + }, this); + + this.folderNameForClear = ko.computed(function () { + var oFolder = this.selectedFolder(); + return oFolder ? oFolder.localName() : ''; + }, this); + + this.dangerDescHtml = ko.computed(function () { + return Utils.i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { + 'FOLDER': this.folderNameForClear() + }); + }, this); + + this.clearCommand = Utils.createCommand(this, function () { + + var + self = this, + oFolderToClear = this.selectedFolder() + ; + + if (oFolderToClear) + { + Data.message(null); + Data.messageList([]); + + this.clearingProcess(true); + + oFolderToClear.messageCountAll(0); + oFolderToClear.messageCountUnread(0); + + Cache.setFolderHash(oFolderToClear.fullNameRaw, ''); + + Remote.folderClear(function (sResult, oData) { + + self.clearingProcess(false); + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + __webpack_require__(/*! App:RainLoop */ 4).reloadMessageList(true); + self.cancelCommand(); + } + else + { + if (oData && oData.ErrorCode) + { + self.clearingError(Utils.getNotification(oData.ErrorCode)); + } + else + { + self.clearingError(Utils.getNotification(Enums.Notification.MailServerError)); + } + } + }, oFolderToClear.fullNameRaw); + } + + }, function () { + + var + oFolder = this.selectedFolder(), + bIsClearing = this.clearingProcess() + ; + + return !bIsClearing && null !== oFolder; + + }); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:FolderClear', 'PopupsFolderClearViewModel'], PopupsFolderClearViewModel); + _.extend(PopupsFolderClearViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsFolderClearViewModel.prototype.clearPopup = function () + { + this.clearingProcess(false); + this.selectedFolder(null); + }; + + PopupsFolderClearViewModel.prototype.onShow = function (oFolder) + { + this.clearPopup(); + if (oFolder) + { + this.selectedFolder(oFolder); + } + }; + + module.exports = PopupsFolderClearViewModel; + + }()); + + +/***/ }, +/* 108 */ +/*!***************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsNewOpenPgpKeyViewModel.js ***! + \***************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsNewOpenPgpKeyViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsNewOpenPgpKey'); + + this.email = ko.observable(''); + this.email.focus = ko.observable(''); + this.email.error = ko.observable(false); + + this.name = ko.observable(''); + this.password = ko.observable(''); + this.keyBitLength = ko.observable(2048); + + this.submitRequest = ko.observable(false); + + this.email.subscribe(function () { + this.email.error(false); + }, this); + + this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () { + + var + self = this, + sUserID = '', + mKeyPair = null, + oOpenpgpKeyring = Data.openpgpKeyring + ; + + this.email.error('' === Utils.trim(this.email())); + if (!oOpenpgpKeyring || this.email.error()) + { + return false; + } + + sUserID = this.email(); + if ('' !== this.name()) + { + sUserID = this.name() + ' <' + sUserID + '>'; + } + + this.submitRequest(true); + + _.delay(function () { + // mKeyPair = window.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password())); + mKeyPair = window.openpgp.generateKeyPair({ + 'userId': sUserID, + 'numBits': Utils.pInt(self.keyBitLength()), + 'passphrase': Utils.trim(self.password()) + }); + + if (mKeyPair && mKeyPair.privateKeyArmored) + { + oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored); + oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored); + oOpenpgpKeyring.store(); + + __webpack_require__(/*! App:RainLoop */ 4).reloadOpenPgpKeys(); + Utils.delegateRun(self, 'cancelCommand'); + } + + self.submitRequest(false); + }, 100); + + return true; + }); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], PopupsNewOpenPgpKeyViewModel); + _.extend(PopupsNewOpenPgpKeyViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsNewOpenPgpKeyViewModel.prototype.clearPopup = function () + { + this.name(''); + this.password(''); + + this.email(''); + this.email.error(false); + this.keyBitLength(2048); + }; + + PopupsNewOpenPgpKeyViewModel.prototype.onShow = function () + { + this.clearPopup(); + }; + + PopupsNewOpenPgpKeyViewModel.prototype.onFocus = function () + { + this.email.focus(true); + }; + + module.exports = PopupsNewOpenPgpKeyViewModel; + + }()); + +/***/ }, +/* 109 */, +/* 110 */ +/*!***************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsTwoFactorTestViewModel.js ***! + \***************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsTwoFactorTestViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsTwoFactorTest'); + + var self = this; + + this.code = ko.observable(''); + this.code.focused = ko.observable(false); + this.code.status = ko.observable(null); + + this.testing = ko.observable(false); + + // commands + this.testCode = Utils.createCommand(this, function () { + + this.testing(true); + Remote.testTwoFactor(function (sResult, oData) { + + self.testing(false); + self.code.status(Enums.StorageResultType.Success === sResult && oData && oData.Result ? true : false); + + }, this.code()); + + }, function () { + return '' !== this.code() && !this.testing(); + }); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:TwoFactorTest', 'PopupsTwoFactorTestViewModel'], PopupsTwoFactorTestViewModel); + _.extend(PopupsTwoFactorTestViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsTwoFactorTestViewModel.prototype.clearPopup = function () + { + this.code(''); + this.code.focused(false); + this.code.status(null); + this.testing(false); + }; + + PopupsTwoFactorTestViewModel.prototype.onShow = function () + { + this.clearPopup(); + }; + + PopupsTwoFactorTestViewModel.prototype.onFocus = function () + { + this.code.focused(true); + }; + + module.exports = PopupsTwoFactorTestViewModel; + + }()); + +/***/ }, +/* 111 */ +/*!****************************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js ***! + \****************************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsViewOpenPgpKeyViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsViewOpenPgpKey'); + + this.key = ko.observable(''); + this.keyDom = ko.observable(null); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:ViewOpenPgpKey', 'PopupsViewOpenPgpKeyViewModel'], PopupsViewOpenPgpKeyViewModel); + _.extend(PopupsViewOpenPgpKeyViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsViewOpenPgpKeyViewModel.prototype.clearPopup = function () + { + this.key(''); + }; + + PopupsViewOpenPgpKeyViewModel.prototype.selectKey = function () + { + var oEl = this.keyDom(); + if (oEl) + { + Utils.selectElement(oEl); + } + }; + + PopupsViewOpenPgpKeyViewModel.prototype.onShow = function (oOpenPgpKey) + { + this.clearPopup(); + + if (oOpenPgpKey) + { + this.key(oOpenPgpKey.armor); + } + }; + + module.exports = PopupsViewOpenPgpKeyViewModel; + + }()); + +/***/ }, +/* 112 */ +/*!*************************************************!*\ + !*** ./dev/ViewModels/SettingsMenuViewModel.js ***! + \*************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + Globals = __webpack_require__(/*! Common/Globals */ 7), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @param {?} oScreen + * + * @constructor + * @extends KnoinAbstractViewModel + */ + function SettingsMenuViewModel(oScreen) + { + KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu'); + + this.leftPanelDisabled = Globals.leftPanelDisabled; + + this.menu = oScreen.menu; + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:SettingsMenu', 'SettingsMenuViewModel'], SettingsMenuViewModel); + _.extend(SettingsMenuViewModel.prototype, KnoinAbstractViewModel.prototype); + + SettingsMenuViewModel.prototype.link = function (sRoute) + { + return LinkBuilder.settings(sRoute); + }; + + SettingsMenuViewModel.prototype.backToMailBoxClick = function () + { + kn.setHash(LinkBuilder.inbox()); + }; + + module.exports = SettingsMenuViewModel; + + }()); + +/***/ }, +/* 113 */ +/*!*************************************************!*\ + !*** ./dev/ViewModels/SettingsPaneViewModel.js ***! + \*************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + key = __webpack_require__(/*! key */ 19), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function SettingsPaneViewModel() + { + KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane'); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:SettingsPane', 'SettingsPaneViewModel'], SettingsPaneViewModel); + _.extend(SettingsPaneViewModel.prototype, KnoinAbstractViewModel.prototype); + + SettingsPaneViewModel.prototype.onBuild = function () + { + var self = this; + key('esc', Enums.KeyState.Settings, function () { + self.backToMailBoxClick(); + }); + }; + + SettingsPaneViewModel.prototype.onShow = function () + { + Data.message(null); + }; + + SettingsPaneViewModel.prototype.backToMailBoxClick = function () + { + kn.setHash(LinkBuilder.inbox()); + }; + + module.exports = SettingsPaneViewModel; + + }()); + +/***/ }, +/* 114 */ +/*!***********************************************************!*\ + !*** ./dev/ViewModels/SettingsSystemDropDownViewModel.js ***! + \***********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + kn = __webpack_require__(/*! App:Knoin */ 5), + AbstractSystemDropDownViewModel = __webpack_require__(/*! View:RainLoop:AbstractSystemDropDown */ 41) + ; + + /** + * @constructor + * @extends AbstractSystemDropDownViewModel + */ + function SettingsSystemDropDownViewModel() + { + AbstractSystemDropDownViewModel.call(this); + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:SettingsSystemDropDown', 'SettingsSystemDropDownViewModel'], SettingsSystemDropDownViewModel); + _.extend(SettingsSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype); + + module.exports = SettingsSystemDropDownViewModel; + + }()); + +/***/ }, +/* 115 */, +/* 116 */ +/*!****************************!*\ + !*** external "ifvisible" ***! + \****************************/ +/***/ function(module, exports, __webpack_require__) { + + module.exports = ifvisible; + +/***/ } +])); \ No newline at end of file diff --git a/rainloop/v/0.0.0/static/js/admin.js b/rainloop/v/0.0.0/static/js/admin.js index bc83e244c..4146898df 100644 --- a/rainloop/v/0.0.0/static/js/admin.js +++ b/rainloop/v/0.0.0/static/js/admin.js @@ -1,9487 +1,3331 @@ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o').appendTo('body'); - - Globals.$win.on('error', function (oEvent) { - if (oEvent && oEvent.originalEvent && oEvent.originalEvent.message && - -1 === Utils.inArray(oEvent.originalEvent.message, [ - 'Script error.', 'Uncaught Error: Error calling method on NPObject.' - ])) - { - Remote.jsError( - Utils.emptyFunction, - oEvent.originalEvent.message, - oEvent.originalEvent.filename, - oEvent.originalEvent.lineno, - window.location && window.location.toString ? window.location.toString() : '', - Globals.$html.attr('class'), - Utils.microtime() - Globals.now - ); - } - }); - - Globals.$doc.on('keydown', function (oEvent) { - if (oEvent && oEvent.ctrlKey) - { - Globals.$html.addClass('rl-ctrl-key-pressed'); - } - }).on('keyup', function (oEvent) { - if (oEvent && !oEvent.ctrlKey) - { - Globals.$html.removeClass('rl-ctrl-key-pressed'); - } - }); - } - - _.extend(AbstractApp.prototype, KnoinAbstractBoot.prototype); - - AbstractApp.prototype.remote = function () - { - return null; - }; - - AbstractApp.prototype.data = function () - { - return null; - }; - - AbstractApp.prototype.setupSettings = function () - { - return true; - }; - - /** - * @param {string} sLink - * @return {boolean} - */ - AbstractApp.prototype.download = function (sLink) - { var - oE = null, - oLink = null, - sUserAgent = window.navigator.userAgent.toLowerCase() + _ = __webpack_require__(/*! _ */ 2), + + AbstractRemoteStorage = __webpack_require__(/*! Storage:Abstract:Remote */ 40) ; - if (sUserAgent && (sUserAgent.indexOf('chrome') > -1 || sUserAgent.indexOf('chrome') > -1)) + /** + * @constructor + * @extends AbstractRemoteStorage + */ + function AdminRemoteStorage() { - oLink = window.document.createElement('a'); - oLink['href'] = sLink; + AbstractRemoteStorage.call(this); - if (window.document['createEvent']) - { - oE = window.document['createEvent']('MouseEvents'); - if (oE && oE['initEvent'] && oLink['dispatchEvent']) - { - oE['initEvent']('click', true, true); - oLink['dispatchEvent'](oE); - return true; - } - } + this.oRequests = {}; } - if (Globals.bMobileDevice) + _.extend(AdminRemoteStorage.prototype, AbstractRemoteStorage.prototype); + + /** + * @param {?Function} fCallback + * @param {string} sLogin + * @param {string} sPassword + */ + AdminRemoteStorage.prototype.adminLogin = function (fCallback, sLogin, sPassword) { - window.open(sLink, '_self'); - window.focus(); - } - else + this.defaultRequest(fCallback, 'AdminLogin', { + 'Login': sLogin, + 'Password': sPassword + }); + }; + + /** + * @param {?Function} fCallback + */ + AdminRemoteStorage.prototype.adminLogout = function (fCallback) { - this.iframe.attr('src', sLink); - // window.document.location.href = sLink; - } + this.defaultRequest(fCallback, 'AdminLogout'); + }; - return true; - }; + /** + * @param {?Function} fCallback + * @param {?} oData + */ + AdminRemoteStorage.prototype.saveAdminConfig = function (fCallback, oData) + { + this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData); + }; - /** - * @param {string} sTitle - */ - AbstractApp.prototype.setTitle = function (sTitle) - { - sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') + - Settings.settingsGet('Title') || ''; + /** + * @param {?Function} fCallback + */ + AdminRemoteStorage.prototype.domainList = function (fCallback) + { + this.defaultRequest(fCallback, 'AdminDomainList'); + }; - window.document.title = '_'; - window.document.title = sTitle; - }; + /** + * @param {?Function} fCallback + */ + AdminRemoteStorage.prototype.pluginList = function (fCallback) + { + this.defaultRequest(fCallback, 'AdminPluginList'); + }; + + /** + * @param {?Function} fCallback + */ + AdminRemoteStorage.prototype.packagesList = function (fCallback) + { + this.defaultRequest(fCallback, 'AdminPackagesList'); + }; + + /** + * @param {?Function} fCallback + */ + AdminRemoteStorage.prototype.coreData = function (fCallback) + { + this.defaultRequest(fCallback, 'AdminCoreData'); + }; + + /** + * @param {?Function} fCallback + */ + AdminRemoteStorage.prototype.updateCoreData = function (fCallback) + { + this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000); + }; + + /** + * @param {?Function} fCallback + * @param {Object} oPackage + */ + AdminRemoteStorage.prototype.packageInstall = function (fCallback, oPackage) + { + this.defaultRequest(fCallback, 'AdminPackageInstall', { + 'Id': oPackage.id, + 'Type': oPackage.type, + 'File': oPackage.file + }, 60000); + }; + + /** + * @param {?Function} fCallback + * @param {Object} oPackage + */ + AdminRemoteStorage.prototype.packageDelete = function (fCallback, oPackage) + { + this.defaultRequest(fCallback, 'AdminPackageDelete', { + 'Id': oPackage.id + }); + }; + + /** + * @param {?Function} fCallback + * @param {string} sName + */ + AdminRemoteStorage.prototype.domain = function (fCallback, sName) + { + this.defaultRequest(fCallback, 'AdminDomainLoad', { + 'Name': sName + }); + }; + + /** + * @param {?Function} fCallback + * @param {string} sName + */ + AdminRemoteStorage.prototype.plugin = function (fCallback, sName) + { + this.defaultRequest(fCallback, 'AdminPluginLoad', { + 'Name': sName + }); + }; + + /** + * @param {?Function} fCallback + * @param {string} sName + */ + AdminRemoteStorage.prototype.domainDelete = function (fCallback, sName) + { + this.defaultRequest(fCallback, 'AdminDomainDelete', { + 'Name': sName + }); + }; + + /** + * @param {?Function} fCallback + * @param {string} sName + * @param {boolean} bDisabled + */ + AdminRemoteStorage.prototype.domainDisable = function (fCallback, sName, bDisabled) + { + return this.defaultRequest(fCallback, 'AdminDomainDisable', { + 'Name': sName, + 'Disabled': !!bDisabled ? '1' : '0' + }); + }; + + /** + * @param {?Function} fCallback + * @param {Object} oConfig + */ + AdminRemoteStorage.prototype.pluginSettingsUpdate = function (fCallback, oConfig) + { + return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig); + }; + + /** + * @param {?Function} fCallback + * @param {boolean} bForce + */ + AdminRemoteStorage.prototype.licensing = function (fCallback, bForce) + { + return this.defaultRequest(fCallback, 'AdminLicensing', { + 'Force' : bForce ? '1' : '0' + }); + }; + + /** + * @param {?Function} fCallback + * @param {string} sDomain + * @param {string} sKey + */ + AdminRemoteStorage.prototype.licensingActivate = function (fCallback, sDomain, sKey) + { + return this.defaultRequest(fCallback, 'AdminLicensingActivate', { + 'Domain' : sDomain, + 'Key' : sKey + }); + }; + + /** + * @param {?Function} fCallback + * @param {string} sName + * @param {boolean} bDisabled + */ + AdminRemoteStorage.prototype.pluginDisable = function (fCallback, sName, bDisabled) + { + return this.defaultRequest(fCallback, 'AdminPluginDisable', { + 'Name': sName, + 'Disabled': !!bDisabled ? '1' : '0' + }); + }; + + AdminRemoteStorage.prototype.createOrUpdateDomain = function (fCallback, + bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncShortLogin, + sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, sWhiteList) + { + this.defaultRequest(fCallback, 'AdminDomainSave', { + 'Create': bCreate ? '1' : '0', + 'Name': sName, + 'IncHost': sIncHost, + 'IncPort': iIncPort, + 'IncSecure': sIncSecure, + 'IncShortLogin': bIncShortLogin ? '1' : '0', + 'OutHost': sOutHost, + 'OutPort': iOutPort, + 'OutSecure': sOutSecure, + 'OutShortLogin': bOutShortLogin ? '1' : '0', + 'OutAuth': bOutAuth ? '1' : '0', + 'WhiteList': sWhiteList + }); + }; + + AdminRemoteStorage.prototype.testConnectionForDomain = function (fCallback, sName, + sIncHost, iIncPort, sIncSecure, + sOutHost, iOutPort, sOutSecure, bOutAuth) + { + this.defaultRequest(fCallback, 'AdminDomainTest', { + 'Name': sName, + 'IncHost': sIncHost, + 'IncPort': iIncPort, + 'IncSecure': sIncSecure, + 'OutHost': sOutHost, + 'OutPort': iOutPort, + 'OutSecure': sOutSecure, + 'OutAuth': bOutAuth ? '1' : '0' + }); + }; + + /** + * @param {?Function} fCallback + * @param {?} oData + */ + AdminRemoteStorage.prototype.testContacts = function (fCallback, oData) + { + this.defaultRequest(fCallback, 'AdminContactsTest', oData); + }; + + /** + * @param {?Function} fCallback + * @param {?} oData + */ + AdminRemoteStorage.prototype.saveNewAdminPassword = function (fCallback, oData) + { + this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData); + }; + + /** + * @param {?Function} fCallback + */ + AdminRemoteStorage.prototype.adminPing = function (fCallback) + { + this.defaultRequest(fCallback, 'AdminPing'); + }; + + module.exports = new AdminRemoteStorage(); + + }()); + +/***/ }, + +/***/ 16: +/*!******************************!*\ + !*** ./dev/Apps/AdminApp.js ***! + \******************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; - /** - * @param {boolean=} bLogout = false - * @param {boolean=} bClose = false - */ - AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose) - { var - kn = require('App:Knoin'), - sCustomLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')), - bInIframe = !!Settings.settingsGet('InIframe') + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18), + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15), + + AdminSettingsScreen = __webpack_require__(/*! Screen:Admin:Settings */ 63), + AdminLoginScreen = __webpack_require__(/*! Screen:Admin:Login */ 62), + + kn = __webpack_require__(/*! App:Knoin */ 5), + AbstractApp = __webpack_require__(/*! App:Abstract */ 34) ; - bLogout = Utils.isUnd(bLogout) ? false : !!bLogout; - bClose = Utils.isUnd(bClose) ? false : !!bClose; - - if (bLogout && bClose && window.close) + /** + * @constructor + * @extends AbstractApp + */ + function AdminApp() { - window.close(); + AbstractApp.call(this, Remote); } - if (bLogout && '' !== sCustomLogoutLink && window.location.href !== sCustomLogoutLink) + _.extend(AdminApp.prototype, AbstractApp.prototype); + + AdminApp.prototype.remote = function () { - _.delay(function () { - if (bInIframe && window.parent) - { - window.parent.location.href = sCustomLogoutLink; - } - else - { - window.location.href = sCustomLogoutLink; - } - }, 100); - } - else + return Remote; + }; + + AdminApp.prototype.data = function () { - kn.routeOff(); - kn.setHash(LinkBuilder.root(), true); - kn.routeOff(); + return Data; + }; - _.delay(function () { - if (bInIframe && window.parent) - { - window.parent.location.reload(); - } - else - { - window.location.reload(); - } - }, 100); - } - }; - - AbstractApp.prototype.historyBack = function () - { - window.history.back(); - }; - - AbstractApp.prototype.bootstart = function () - { - Events.pub('rl.bootstart'); - - var ssm = require('ssm'); - - Utils.initOnStartOrLangChange(function () { - Utils.initNotificationLanguage(); - }, null); - - _.delay(function () { - Utils.windowResize(); - }, 1000); - - ssm.addState({ - 'id': 'mobile', - 'maxWidth': 767, - 'onEnter': function() { - Globals.$html.addClass('ssm-state-mobile'); - Events.pub('ssm.mobile-enter'); - }, - 'onLeave': function() { - Globals.$html.removeClass('ssm-state-mobile'); - Events.pub('ssm.mobile-leave'); - } - }); - - ssm.addState({ - 'id': 'tablet', - 'minWidth': 768, - 'maxWidth': 999, - 'onEnter': function() { - Globals.$html.addClass('ssm-state-tablet'); - }, - 'onLeave': function() { - Globals.$html.removeClass('ssm-state-tablet'); - } - }); - - ssm.addState({ - 'id': 'desktop', - 'minWidth': 1000, - 'maxWidth': 1400, - 'onEnter': function() { - Globals.$html.addClass('ssm-state-desktop'); - }, - 'onLeave': function() { - Globals.$html.removeClass('ssm-state-desktop'); - } - }); - - ssm.addState({ - 'id': 'desktop-large', - 'minWidth': 1400, - 'onEnter': function() { - Globals.$html.addClass('ssm-state-desktop-large'); - }, - 'onLeave': function() { - Globals.$html.removeClass('ssm-state-desktop-large'); - } - }); - - Events.sub('ssm.mobile-enter', function () { - Globals.leftPanelDisabled(true); - }); - - Events.sub('ssm.mobile-leave', function () { - Globals.leftPanelDisabled(false); - }); - - Globals.leftPanelDisabled.subscribe(function (bValue) { - Globals.$html.toggleClass('rl-left-panel-disabled', bValue); - }); - - ssm.ready(); - }; - - module.exports = AbstractApp; - -}(module, require)); -},{"$":14,"App:Knoin":21,"Events":7,"Globals":8,"Knoin:AbstractBoot":22,"LinkBuilder":9,"Storage:Settings":45,"Utils":11,"_":19,"ssm":18,"window":20}],3:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data'), - Remote = require('Storage:Admin:Remote'), - - AdminSettingsScreen = require('Screen:Admin:Settings'), - AdminLoginScreen = require('Screen:Admin:Login'), - - kn = require('App:Knoin'), - AbstractApp = require('App:Abstract') - ; - - /** - * @constructor - * @extends AbstractApp - */ - function AdminApp() - { - AbstractApp.call(this, Remote); - } - - _.extend(AdminApp.prototype, AbstractApp.prototype); - - AdminApp.prototype.remote = function () - { - return Remote; - }; - - AdminApp.prototype.data = function () - { - return Data; - }; - - AdminApp.prototype.setupSettings = function () - { - kn.addSettingsViewModel(require('Settings:Admin:General'), - 'AdminSettingsGeneral', 'General', 'general', true); - - kn.addSettingsViewModel(require('Settings:Admin:Login'), - 'AdminSettingsLogin', 'Login', 'login'); - - if (Settings.capa(Enums.Capa.Prem)) + AdminApp.prototype.reloadDomainList = function () { - kn.addSettingsViewModel(require('Settings:Admin:Branding'), - 'AdminSettingsBranding', 'Branding', 'branding'); - } + Data.domainsLoading(true); - kn.addSettingsViewModel(require('Settings:Admin:Contacts'), - 'AdminSettingsContacts', 'Contacts', 'contacts'); - - kn.addSettingsViewModel(require('Settings:Admin:Domains'), - 'AdminSettingsDomains', 'Domains', 'domains'); - - kn.addSettingsViewModel(require('Settings:Admin:Security'), - 'AdminSettingsSecurity', 'Security', 'security'); - - kn.addSettingsViewModel(require('Settings:Admin:Social'), - 'AdminSettingsSocial', 'Social', 'social'); - - kn.addSettingsViewModel(require('Settings:Admin:Plugins'), - 'AdminSettingsPlugins', 'Plugins', 'plugins'); - - kn.addSettingsViewModel(require('Settings:Admin:Packages'), - 'AdminSettingsPackages', 'Packages', 'packages'); - - kn.addSettingsViewModel(require('Settings:Admin:Licensing'), - 'AdminSettingsLicensing', 'Licensing', 'licensing'); - - kn.addSettingsViewModel(require('Settings:Admin:About'), - 'AdminSettingsAbout', 'About', 'about'); - - return true; - }; - - AdminApp.prototype.reloadDomainList = function () - { - Data.domainsLoading(true); - - Remote.domainList(function (sResult, oData) { - Data.domainsLoading(false); - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - var aList = _.map(oData.Result, function (bEnabled, sName) { - return { - 'name': sName, - 'disabled': ko.observable(!bEnabled), - 'deleteAccess': ko.observable(false) - }; - }, this); - - Data.domains(aList); - } - }); - }; - - AdminApp.prototype.reloadPluginList = function () - { - Data.pluginsLoading(true); - Remote.pluginList(function (sResult, oData) { - - Data.pluginsLoading(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - var aList = _.map(oData.Result, function (oItem) { - return { - 'name': oItem['Name'], - 'disabled': ko.observable(!oItem['Enabled']), - 'configured': ko.observable(!!oItem['Configured']) - }; - }, this); - - Data.plugins(aList); - } - }); - }; - - AdminApp.prototype.reloadPackagesList = function () - { - Data.packagesLoading(true); - Data.packagesReal(true); - - Remote.packagesList(function (sResult, oData) { - - Data.packagesLoading(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - Data.packagesReal(!!oData.Result.Real); - Data.packagesMainUpdatable(!!oData.Result.MainUpdatable); - - var - aList = [], - aLoading = {} - ; - - _.each(Data.packages(), function (oItem) { - if (oItem && oItem['loading']()) - { - aLoading[oItem['file']] = oItem; - } - }); - - if (Utils.isArray(oData.Result.List)) + Remote.domainList(function (sResult, oData) { + Data.domainsLoading(false); + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { - aList = _.compact(_.map(oData.Result.List, function (oItem) { - if (oItem) + var aList = _.map(oData.Result, function (bEnabled, sName) { + return { + 'name': sName, + 'disabled': ko.observable(!bEnabled), + 'deleteAccess': ko.observable(false) + }; + }, this); + + Data.domains(aList); + } + }); + }; + + AdminApp.prototype.reloadPluginList = function () + { + Data.pluginsLoading(true); + Remote.pluginList(function (sResult, oData) { + + Data.pluginsLoading(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + var aList = _.map(oData.Result, function (oItem) { + return { + 'name': oItem['Name'], + 'disabled': ko.observable(!oItem['Enabled']), + 'configured': ko.observable(!!oItem['Configured']) + }; + }, this); + + Data.plugins(aList); + } + }); + }; + + AdminApp.prototype.reloadPackagesList = function () + { + Data.packagesLoading(true); + Data.packagesReal(true); + + Remote.packagesList(function (sResult, oData) { + + Data.packagesLoading(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + Data.packagesReal(!!oData.Result.Real); + Data.packagesMainUpdatable(!!oData.Result.MainUpdatable); + + var + aList = [], + aLoading = {} + ; + + _.each(Data.packages(), function (oItem) { + if (oItem && oItem['loading']()) { - oItem['loading'] = ko.observable(!Utils.isUnd(aLoading[oItem['file']])); - return 'core' === oItem['type'] && !oItem['canBeInstalled'] ? null : oItem; + aLoading[oItem['file']] = oItem; } - return null; - })); + }); + + if (Utils.isArray(oData.Result.List)) + { + aList = _.compact(_.map(oData.Result.List, function (oItem) { + if (oItem) + { + oItem['loading'] = ko.observable(!Utils.isUnd(aLoading[oItem['file']])); + return 'core' === oItem['type'] && !oItem['canBeInstalled'] ? null : oItem; + } + return null; + })); + } + + Data.packages(aList); } + else + { + Data.packagesReal(false); + } + }); + }; - Data.packages(aList); - } - else - { - Data.packagesReal(false); - } - }); - }; + AdminApp.prototype.updateCoreData = function () + { + Data.coreUpdating(true); + Remote.updateCoreData(function (sResult, oData) { - AdminApp.prototype.updateCoreData = function () - { - Data.coreUpdating(true); - Remote.updateCoreData(function (sResult, oData) { - - Data.coreUpdating(false); - Data.coreRemoteVersion(''); - Data.coreRemoteRelease(''); - Data.coreVersionCompare(-2); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - Data.coreReal(true); - window.location.reload(); - } - else - { - Data.coreReal(false); - } - }); - - }; - - AdminApp.prototype.reloadCoreData = function () - { - Data.coreChecking(true); - Data.coreReal(true); - - Remote.coreData(function (sResult, oData) { - - Data.coreChecking(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - Data.coreReal(!!oData.Result.Real); - Data.coreUpdatable(!!oData.Result.Updatable); - Data.coreAccess(!!oData.Result.Access); - Data.coreRemoteVersion(oData.Result.RemoteVersion || ''); - Data.coreRemoteRelease(oData.Result.RemoteRelease || ''); - Data.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare)); - } - else - { - Data.coreReal(false); + Data.coreUpdating(false); Data.coreRemoteVersion(''); Data.coreRemoteRelease(''); Data.coreVersionCompare(-2); - } - }); - }; - /** - * - * @param {boolean=} bForce = false - */ - AdminApp.prototype.reloadLicensing = function (bForce) - { - bForce = Utils.isUnd(bForce) ? false : !!bForce; - - Data.licensingProcess(true); - Data.licenseError(''); - - Remote.licensing(function (sResult, oData) { - Data.licensingProcess(false); - if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired'])) - { - Data.licenseValid(true); - Data.licenseExpired(Utils.pInt(oData.Result['Expired'])); - Data.licenseError(''); - - Data.licensing(true); - } - else - { - if (oData && oData.ErrorCode && -1 < Utils.inArray(Utils.pInt(oData.ErrorCode), [ - Enums.Notification.LicensingServerIsUnavailable, - Enums.Notification.LicensingExpired - ])) + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { - Data.licenseError(Utils.getNotification(Utils.pInt(oData.ErrorCode))); + Data.coreReal(true); + window.location.reload(); + } + else + { + Data.coreReal(false); + } + }); + + }; + + AdminApp.prototype.reloadCoreData = function () + { + Data.coreChecking(true); + Data.coreReal(true); + + Remote.coreData(function (sResult, oData) { + + Data.coreChecking(false); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + Data.coreReal(!!oData.Result.Real); + Data.coreUpdatable(!!oData.Result.Updatable); + Data.coreAccess(!!oData.Result.Access); + Data.coreRemoteVersion(oData.Result.RemoteVersion || ''); + Data.coreRemoteRelease(oData.Result.RemoteRelease || ''); + Data.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare)); + } + else + { + Data.coreReal(false); + Data.coreRemoteVersion(''); + Data.coreRemoteRelease(''); + Data.coreVersionCompare(-2); + } + }); + }; + + /** + * + * @param {boolean=} bForce = false + */ + AdminApp.prototype.reloadLicensing = function (bForce) + { + bForce = Utils.isUnd(bForce) ? false : !!bForce; + + Data.licensingProcess(true); + Data.licenseError(''); + + Remote.licensing(function (sResult, oData) { + Data.licensingProcess(false); + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired'])) + { + Data.licenseValid(true); + Data.licenseExpired(Utils.pInt(oData.Result['Expired'])); + Data.licenseError(''); + Data.licensing(true); } else { - if (Enums.StorageResultType.Abort === sResult) + if (oData && oData.ErrorCode && -1 < Utils.inArray(Utils.pInt(oData.ErrorCode), [ + Enums.Notification.LicensingServerIsUnavailable, + Enums.Notification.LicensingExpired + ])) { - Data.licenseError(Utils.getNotification(Enums.Notification.LicensingServerIsUnavailable)); + Data.licenseError(Utils.getNotification(Utils.pInt(oData.ErrorCode))); Data.licensing(true); } else { - Data.licensing(false); - } - } - } - }, bForce); - }; - - AdminApp.prototype.bootstart = function () - { - AbstractApp.prototype.bootstart.call(this); - - Data.populateDataOnStart(); - - kn.hideLoading(); - - if (!Settings.settingsGet('AllowAdminPanel')) - { - kn.routeOff(); - kn.setHash(LinkBuilder.root(), true); - kn.routeOff(); - - _.defer(function () { - window.location.href = '/'; - }); - } - else - { - if (!!Settings.settingsGet('Auth')) - { - kn.startScreens([AdminSettingsScreen]); - } - else - { - kn.startScreens([AdminLoginScreen]); - } - } - - if (window.SimplePace) - { - window.SimplePace.set(100); - } - }; - - module.exports = new AdminApp(); - -}(module, require)); -},{"App:Abstract":2,"App:Knoin":21,"Enums":6,"LinkBuilder":9,"Screen:Admin:Login":28,"Screen:Admin:Settings":29,"Settings:Admin:About":30,"Settings:Admin:Branding":31,"Settings:Admin:Contacts":32,"Settings:Admin:Domains":33,"Settings:Admin:General":34,"Settings:Admin:Licensing":35,"Settings:Admin:Login":36,"Settings:Admin:Packages":37,"Settings:Admin:Plugins":38,"Settings:Admin:Security":39,"Settings:Admin:Social":40,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Storage:Settings":45,"Utils":11,"_":19,"ko":16,"window":20}],4:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - module.exports = function (App) { - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - - Globals = require('Globals'), - Plugins = require('Plugins'), - Utils = require('Utils'), - Enums = require('Enums'), - - EmailModel = require('Model:Email') - ; - - Globals.__APP = App; - - App.setupSettings(); - - Plugins.__boot = App; - Plugins.__remote = App.remote(); - Plugins.__data = App.data(); - - Globals.$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile'); - - Globals.$win.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS); - - Globals.$win.unload(function () { - Globals.bUnload = true; - }); - - Globals.$html.on('click.dropdown.data-api', function () { - Utils.detectDropdownVisibility(); - }); - - // export - window['rl'] = window['rl'] || {}; - window['rl']['addHook'] = _.bind(Plugins.addHook, Plugins); - window['rl']['settingsGet'] = _.bind(Plugins.mainSettingsGet, Plugins); - window['rl']['remoteRequest'] = _.bind(Plugins.remoteRequest, Plugins); - window['rl']['pluginSettingsGet'] = _.bind(Plugins.settingsGet, Plugins); - window['rl']['createCommand'] = Utils.createCommand; - - window['rl']['EmailModel'] = EmailModel; - window['rl']['Enums'] = Enums; - - window['__APP_BOOT'] = function (fCall) { - - // boot - $(function () { - - if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0]) - { - $('#rl-templates').html(window['rainloopTEMPLATES'][0]); - - _.delay(function () { - - App.bootstart(); - Globals.$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted'); - - }, 10); - } - else - { - fCall(false); - } - - window['__APP_BOOT'] = null; - }); - }; - - }; - -}(module, require)); -},{"$":14,"Enums":6,"Globals":8,"Model:Email":26,"Plugins":10,"Utils":11,"_":19,"window":20}],5:[function(require,module,exports){ - -(function (module) { - - 'use strict'; - - var Consts = {}; - - Consts.Values = {}; - Consts.DataImages = {}; - Consts.Defaults = {}; - - /** - * @const - * @type {number} - */ - Consts.Defaults.MessagesPerPage = 20; - - /** - * @const - * @type {number} - */ - Consts.Defaults.ContactsPerPage = 50; - - /** - * @const - * @type {Array} - */ - Consts.Defaults.MessagesPerPageArray = [10, 20, 30, 50, 100/*, 150, 200, 300*/]; - - /** - * @const - * @type {number} - */ - Consts.Defaults.DefaultAjaxTimeout = 30000; - - /** - * @const - * @type {number} - */ - Consts.Defaults.SearchAjaxTimeout = 300000; - - /** - * @const - * @type {number} - */ - Consts.Defaults.SendMessageAjaxTimeout = 300000; - - /** - * @const - * @type {number} - */ - Consts.Defaults.SaveMessageAjaxTimeout = 200000; - - /** - * @const - * @type {number} - */ - Consts.Defaults.ContactsSyncAjaxTimeout = 200000; - - /** - * @const - * @type {string} - */ - Consts.Values.UnuseOptionValue = '__UNUSE__'; - - /** - * @const - * @type {string} - */ - Consts.Values.ClientSideStorageIndexName = 'rlcsc'; - - /** - * @const - * @type {number} - */ - Consts.Values.ImapDefaulPort = 143; - - /** - * @const - * @type {number} - */ - Consts.Values.ImapDefaulSecurePort = 993; - - /** - * @const - * @type {number} - */ - Consts.Values.SmtpDefaulPort = 25; - - /** - * @const - * @type {number} - */ - Consts.Values.SmtpDefaulSecurePort = 465; - - /** - * @const - * @type {number} - */ - Consts.Values.MessageBodyCacheLimit = 15; - - /** - * @const - * @type {number} - */ - Consts.Values.AjaxErrorLimit = 7; - - /** - * @const - * @type {number} - */ - Consts.Values.TokenErrorLimit = 10; - - /** - * @const - * @type {string} - */ - Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII='; - - /** - * @const - * @type {string} - */ - Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII='; - - module.exports = Consts; - -}(module)); -},{}],6:[function(require,module,exports){ - -(function (module) { - - 'use strict'; - - var Enums = {}; - - /** - * @enum {string} - */ - Enums.StorageResultType = { - 'Success': 'success', - 'Abort': 'abort', - 'Error': 'error', - 'Unload': 'unload' - }; - - /** - * @enum {number} - */ - Enums.State = { - 'Empty': 10, - 'Login': 20, - 'Auth': 30 - }; - - /** - * @enum {number} - */ - Enums.StateType = { - 'Webmail': 0, - 'Admin': 1 - }; - - /** - * @enum {string} - */ - Enums.Capa = { - 'Prem': 'PREM', - 'TwoFactor': 'TWO_FACTOR', - 'OpenPGP': 'OPEN_PGP', - 'Prefetch': 'PREFETCH', - 'Gravatar': 'GRAVATAR', - 'Themes': 'THEMES', - 'Filters': 'FILTERS', - 'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS', - 'AdditionalIdentities': 'ADDITIONAL_IDENTITIES' - }; - - /** - * @enum {string} - */ - Enums.KeyState = { - 'All': 'all', - 'None': 'none', - 'ContactList': 'contact-list', - 'MessageList': 'message-list', - 'FolderList': 'folder-list', - 'MessageView': 'message-view', - 'Compose': 'compose', - 'Settings': 'settings', - 'Menu': 'menu', - 'PopupComposeOpenPGP': 'compose-open-pgp', - 'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help', - 'PopupAsk': 'popup-ask' - }; - - /** - * @enum {number} - */ - Enums.FolderType = { - 'Inbox': 10, - 'SentItems': 11, - 'Draft': 12, - 'Trash': 13, - 'Spam': 14, - 'Archive': 15, - 'NotSpam': 80, - 'User': 99 - }; - - /** - * @enum {string} - */ - Enums.LoginSignMeTypeAsString = { - 'DefaultOff': 'defaultoff', - 'DefaultOn': 'defaulton', - 'Unused': 'unused' - }; - - /** - * @enum {number} - */ - Enums.LoginSignMeType = { - 'DefaultOff': 0, - 'DefaultOn': 1, - 'Unused': 2 - }; - - /** - * @enum {string} - */ - Enums.ComposeType = { - 'Empty': 'empty', - 'Reply': 'reply', - 'ReplyAll': 'replyall', - 'Forward': 'forward', - 'ForwardAsAttachment': 'forward-as-attachment', - 'Draft': 'draft', - 'EditAsNew': 'editasnew' - }; - - /** - * @enum {number} - */ - Enums.UploadErrorCode = { - 'Normal': 0, - 'FileIsTooBig': 1, - 'FilePartiallyUploaded': 2, - 'FileNoUploaded': 3, - 'MissingTempFolder': 4, - 'FileOnSaveingError': 5, - 'FileType': 98, - 'Unknown': 99 - }; - - /** - * @enum {number} - */ - Enums.SetSystemFoldersNotification = { - 'None': 0, - 'Sent': 1, - 'Draft': 2, - 'Spam': 3, - 'Trash': 4, - 'Archive': 5 - }; - - /** - * @enum {number} - */ - Enums.ClientSideKeyName = { - 'FoldersLashHash': 0, - 'MessagesInboxLastHash': 1, - 'MailBoxListSize': 2, - 'ExpandedFolders': 3, - 'FolderListSize': 4 - }; - - /** - * @enum {number} - */ - Enums.EventKeyCode = { - 'Backspace': 8, - 'Tab': 9, - 'Enter': 13, - 'Esc': 27, - 'PageUp': 33, - 'PageDown': 34, - 'Left': 37, - 'Right': 39, - 'Up': 38, - 'Down': 40, - 'End': 35, - 'Home': 36, - 'Space': 32, - 'Insert': 45, - 'Delete': 46, - 'A': 65, - 'S': 83 - }; - - /** - * @enum {number} - */ - Enums.MessageSetAction = { - 'SetSeen': 0, - 'UnsetSeen': 1, - 'SetFlag': 2, - 'UnsetFlag': 3 - }; - - /** - * @enum {number} - */ - Enums.MessageSelectAction = { - 'All': 0, - 'None': 1, - 'Invert': 2, - 'Unseen': 3, - 'Seen': 4, - 'Flagged': 5, - 'Unflagged': 6 - }; - - /** - * @enum {number} - */ - Enums.DesktopNotifications = { - 'Allowed': 0, - 'NotAllowed': 1, - 'Denied': 2, - 'NotSupported': 9 - }; - - /** - * @enum {number} - */ - Enums.MessagePriority = { - 'Low': 5, - 'Normal': 3, - 'High': 1 - }; - - /** - * @enum {string} - */ - Enums.EditorDefaultType = { - 'Html': 'Html', - 'Plain': 'Plain' - }; - - /** - * @enum {string} - */ - Enums.CustomThemeType = { - 'Light': 'Light', - 'Dark': 'Dark' - }; - - /** - * @enum {number} - */ - Enums.ServerSecure = { - 'None': 0, - 'SSL': 1, - 'TLS': 2 - }; - - /** - * @enum {number} - */ - Enums.SearchDateType = { - 'All': -1, - 'Days3': 3, - 'Days7': 7, - 'Month': 30 - }; - - /** - * @enum {number} - */ - Enums.SaveSettingsStep = { - 'Animate': -2, - 'Idle': -1, - 'TrueResult': 1, - 'FalseResult': 0 - }; - - /** - * @enum {string} - */ - Enums.InterfaceAnimation = { - 'None': 'None', - 'Normal': 'Normal', - 'Full': 'Full' - }; - - /** - * @enum {number} - */ - Enums.Layout = { - 'NoPreview': 0, - 'SidePreview': 1, - 'BottomPreview': 2 - }; - - /** - * @enum {string} - */ - Enums.FilterConditionField = { - 'From': 'From', - 'To': 'To', - 'Recipient': 'Recipient', - 'Subject': 'Subject' - }; - - /** - * @enum {string} - */ - Enums.FilterConditionType = { - 'Contains': 'Contains', - 'NotContains': 'NotContains', - 'EqualTo': 'EqualTo', - 'NotEqualTo': 'NotEqualTo' - }; - - /** - * @enum {string} - */ - Enums.FiltersAction = { - 'None': 'None', - 'Move': 'Move', - 'Discard': 'Discard', - 'Forward': 'Forward' - }; - - /** - * @enum {string} - */ - Enums.FilterRulesType = { - 'And': 'And', - 'Or': 'Or' - }; - - /** - * @enum {number} - */ - Enums.SignedVerifyStatus = { - 'UnknownPublicKeys': -4, - 'UnknownPrivateKey': -3, - 'Unverified': -2, - 'Error': -1, - 'None': 0, - 'Success': 1 - }; - - /** - * @enum {number} - */ - Enums.ContactPropertyType = { - - 'Unknown': 0, - - 'FullName': 10, - - 'FirstName': 15, - 'LastName': 16, - 'MiddleName': 16, - 'Nick': 18, - - 'NamePrefix': 20, - 'NameSuffix': 21, - - 'Email': 30, - 'Phone': 31, - 'Web': 32, - - 'Birthday': 40, - - 'Facebook': 90, - 'Skype': 91, - 'GitHub': 92, - - 'Note': 110, - - 'Custom': 250 - }; - - /** - * @enum {number} - */ - Enums.Notification = { - 'InvalidToken': 101, - 'AuthError': 102, - 'AccessError': 103, - 'ConnectionError': 104, - 'CaptchaError': 105, - 'SocialFacebookLoginAccessDisable': 106, - 'SocialTwitterLoginAccessDisable': 107, - 'SocialGoogleLoginAccessDisable': 108, - 'DomainNotAllowed': 109, - 'AccountNotAllowed': 110, - - 'AccountTwoFactorAuthRequired': 120, - 'AccountTwoFactorAuthError': 121, - - 'CouldNotSaveNewPassword': 130, - 'CurrentPasswordIncorrect': 131, - 'NewPasswordShort': 132, - 'NewPasswordWeak': 133, - 'NewPasswordForbidden': 134, - - 'ContactsSyncError': 140, - - 'CantGetMessageList': 201, - 'CantGetMessage': 202, - 'CantDeleteMessage': 203, - 'CantMoveMessage': 204, - 'CantCopyMessage': 205, - - 'CantSaveMessage': 301, - 'CantSendMessage': 302, - 'InvalidRecipients': 303, - - 'CantCreateFolder': 400, - 'CantRenameFolder': 401, - 'CantDeleteFolder': 402, - 'CantSubscribeFolder': 403, - 'CantUnsubscribeFolder': 404, - 'CantDeleteNonEmptyFolder': 405, - - 'CantSaveSettings': 501, - 'CantSavePluginSettings': 502, - - 'DomainAlreadyExists': 601, - - 'CantInstallPackage': 701, - 'CantDeletePackage': 702, - 'InvalidPluginPackage': 703, - 'UnsupportedPluginPackage': 704, - - 'LicensingServerIsUnavailable': 710, - 'LicensingExpired': 711, - 'LicensingBanned': 712, - - 'DemoSendMessageError': 750, - - 'AccountAlreadyExists': 801, - - 'MailServerError': 901, - 'ClientViewError': 902, - 'InvalidInputArgument': 903, - 'UnknownNotification': 999, - 'UnknownError': 999 - }; - - module.exports = Enums; - -}(module, require)); -},{}],7:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - Utils = require('Utils'), - Plugins = require('Plugins') - ; - - /** - * @constructor - */ - function Events() - { - this.oSubs = {}; - } - - Events.prototype.oSubs = {}; - - /** - * @param {string} sName - * @param {Function} fFunc - * @param {Object=} oContext - * @return {Events} - */ - Events.prototype.sub = function (sName, fFunc, oContext) - { - if (Utils.isUnd(this.oSubs[sName])) - { - this.oSubs[sName] = []; - } - - this.oSubs[sName].push([fFunc, oContext]); - - return this; - }; - - /** - * @param {string} sName - * @param {Array=} aArgs - * @return {Events} - */ - Events.prototype.pub = function (sName, aArgs) - { - Plugins.runHook('rl-pub', [sName, aArgs]); - - if (!Utils.isUnd(this.oSubs[sName])) - { - _.each(this.oSubs[sName], function (aItem) { - if (aItem[0]) - { - aItem[0].apply(aItem[1] || null, aArgs || []); - } - }); - } - - return this; - }; - - module.exports = new Events(); - -}(module, require)); -},{"Plugins":10,"Utils":11,"_":19}],8:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - Globals = {}, - - window = require('window'), - _ = require('_'), - $ = require('$'), - ko = require('ko'), - key = require('key'), - - Enums = require('Enums') - ; - - Globals.$win = $(window); - Globals.$doc = $(window.document); - Globals.$html = $('html'); - Globals.$div = $('
'); - - /** - * @type {?} - */ - Globals.now = (new window.Date()).getTime(); - - /** - * @type {?} - */ - Globals.momentTrigger = ko.observable(true); - - /** - * @type {?} - */ - Globals.dropdownVisibility = ko.observable(false).extend({'rateLimit': 0}); - - /** - * @type {?} - */ - Globals.tooltipTrigger = ko.observable(false).extend({'rateLimit': 0}); - - /** - * @type {?} - */ - Globals.langChangeTrigger = ko.observable(true); - - /** - * @type {boolean} - */ - Globals.useKeyboardShortcuts = ko.observable(true); - - /** - * @type {number} - */ - Globals.iAjaxErrorCount = 0; - - /** - * @type {number} - */ - Globals.iTokenErrorCount = 0; - - /** - * @type {number} - */ - Globals.iMessageBodyCacheCount = 0; - - /** - * @type {boolean} - */ - Globals.bUnload = false; - - /** - * @type {string} - */ - Globals.sUserAgent = (window.navigator.userAgent || '').toLowerCase(); - - /** - * @type {boolean} - */ - Globals.bIsiOSDevice = -1 < Globals.sUserAgent.indexOf('iphone') || -1 < Globals.sUserAgent.indexOf('ipod') || -1 < Globals.sUserAgent.indexOf('ipad'); - - /** - * @type {boolean} - */ - Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android'); - - /** - * @type {boolean} - */ - Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice; - - /** - * @type {boolean} - */ - Globals.bDisableNanoScroll = Globals.bMobileDevice; - - /** - * @type {boolean} - */ - Globals.bAllowPdfPreview = !Globals.bMobileDevice; - - /** - * @type {boolean} - */ - Globals.bAnimationSupported = !Globals.bMobileDevice && Globals.$html.hasClass('csstransitions'); - - /** - * @type {boolean} - */ - Globals.bXMLHttpRequestSupported = !!window.XMLHttpRequest; - - /** - * @type {string} - */ - Globals.sAnimationType = ''; - - /** - * @type {*} - */ - Globals.__APP = null; - - /** - * @type {Object} - */ - Globals.oHtmlEditorDefaultConfig = { - 'title': false, - 'stylesSet': false, - 'customConfig': '', - 'contentsCss': '', - 'toolbarGroups': [ - {name: 'spec'}, - {name: 'styles'}, - {name: 'basicstyles', groups: ['basicstyles', 'cleanup']}, - {name: 'colors'}, - {name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align']}, - {name: 'links'}, - {name: 'insert'}, - {name: 'others'} - // {name: 'document', groups: ['mode', 'document', 'doctools']} - ], - - 'removePlugins': 'contextmenu', //blockquote - 'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll', - 'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced', - - 'extraPlugins': 'plain', - - 'allowedContent': true, - 'autoParagraph': false, - - 'font_defaultLabel': 'Arial', - 'fontSize_defaultLabel': '13', - 'fontSize_sizes': '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px' - }; - - /** - * @type {Object} - */ - Globals.oHtmlEditorLangsMap = { - 'de': 'de', - 'es': 'es', - 'fr': 'fr', - 'hu': 'hu', - 'is': 'is', - 'it': 'it', - 'ja': 'ja', - 'ja-jp': 'ja', - 'ko': 'ko', - 'ko-kr': 'ko', - 'lv': 'lv', - 'nl': 'nl', - 'no': 'no', - 'pl': 'pl', - 'pt': 'pt', - 'pt-pt': 'pt', - 'pt-br': 'pt-br', - 'ro': 'ro', - 'ru': 'ru', - 'sk': 'sk', - 'tr': 'tr', - 'ua': 'ru', - 'zh': 'zh', - 'zh-cn': 'zh-cn' - }; - - if (Globals.bAllowPdfPreview && window.navigator && window.navigator.mimeTypes) - { - Globals.bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function (oType) { - return oType && 'application/pdf' === oType.type; - }); - } - - Globals.oI18N = window['rainloopI18N'] || {}; - - Globals.oNotificationI18N = {}; - - Globals.aBootstrapDropdowns = []; - - Globals.aViewModels = { - 'settings': [], - 'settings-removed': [], - 'settings-disabled': [] - }; - - Globals.leftPanelDisabled = ko.observable(false); - - // popups - Globals.popupVisibilityNames = ko.observableArray([]); - - Globals.popupVisibility = ko.computed(function () { - return 0 < Globals.popupVisibilityNames().length; - }, this); - - // keys - Globals.keyScopeReal = ko.observable(Enums.KeyState.All); - Globals.keyScopeFake = ko.observable(Enums.KeyState.All); - - Globals.keyScope = ko.computed({ - 'owner': this, - 'read': function () { - return Globals.keyScopeFake(); - }, - 'write': function (sValue) { - - if (Enums.KeyState.Menu !== sValue) - { - if (Enums.KeyState.Compose === sValue) - { - // disableKeyFilter - key.filter = function () { - return Globals.useKeyboardShortcuts(); - }; - } - else - { - // restoreKeyFilter - key.filter = function (event) { - - if (Globals.useKeyboardShortcuts()) + if (Enums.StorageResultType.Abort === sResult) { - var - oElement = event.target || event.srcElement, - sTagName = oElement ? oElement.tagName : '' - ; - - sTagName = sTagName.toUpperCase(); - return !(sTagName === 'INPUT' || sTagName === 'SELECT' || sTagName === 'TEXTAREA' || - (oElement && sTagName === 'DIV' && 'editorHtmlArea' === oElement.className && oElement.contentEditable) - ); - } - - return false; - }; - } - - Globals.keyScopeFake(sValue); - if (Globals.dropdownVisibility()) - { - sValue = Enums.KeyState.Menu; - } - } - - Globals.keyScopeReal(sValue); - } - }); - - Globals.keyScopeReal.subscribe(function (sValue) { -// window.console.log(sValue); - key.setScope(sValue); - }); - - Globals.dropdownVisibility.subscribe(function (bValue) { - if (bValue) - { - Globals.tooltipTrigger(!Globals.tooltipTrigger()); - Globals.keyScope(Enums.KeyState.Menu); - } - else if (Enums.KeyState.Menu === key.getScope()) - { - Globals.keyScope(Globals.keyScopeFake()); - } - }); - - module.exports = Globals; - -}(module, require)); -},{"$":14,"Enums":6,"_":19,"key":15,"ko":16,"window":20}],9:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - Utils = require('Utils') - ; - - /** - * @constructor - */ - function LinkBuilder() - { - var Settings = require('Storage:Settings'); - - this.sBase = '#/'; - this.sServer = './?'; - this.sVersion = Settings.settingsGet('Version'); - this.sSpecSuffix = Settings.settingsGet('AuthAccountHash') || '0'; - this.sStaticPrefix = Settings.settingsGet('StaticPrefix') || 'rainloop/v/' + this.sVersion + '/static/'; - } - - /** - * @return {string} - */ - LinkBuilder.prototype.root = function () - { - return this.sBase; - }; - - /** - * @param {string} sDownload - * @return {string} - */ - LinkBuilder.prototype.attachmentDownload = function (sDownload) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sDownload; - }; - - /** - * @param {string} sDownload - * @return {string} - */ - LinkBuilder.prototype.attachmentPreview = function (sDownload) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/View/' + sDownload; - }; - - /** - * @param {string} sDownload - * @return {string} - */ - LinkBuilder.prototype.attachmentPreviewAsPlain = function (sDownload) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sDownload; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.upload = function () - { - return this.sServer + '/Upload/' + this.sSpecSuffix + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.uploadContacts = function () - { - return this.sServer + '/UploadContacts/' + this.sSpecSuffix + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.uploadBackground = function () - { - return this.sServer + '/UploadBackground/' + this.sSpecSuffix + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.append = function () - { - return this.sServer + '/Append/' + this.sSpecSuffix + '/'; - }; - - /** - * @param {string} sEmail - * @return {string} - */ - LinkBuilder.prototype.change = function (sEmail) - { - return this.sServer + '/Change/' + this.sSpecSuffix + '/' + window.encodeURIComponent(sEmail) + '/'; - }; - - /** - * @param {string=} sAdd - * @return {string} - */ - LinkBuilder.prototype.ajax = function (sAdd) - { - return this.sServer + '/Ajax/' + this.sSpecSuffix + '/' + sAdd; - }; - - /** - * @param {string} sRequestHash - * @return {string} - */ - LinkBuilder.prototype.messageViewLink = function (sRequestHash) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sRequestHash; - }; - - /** - * @param {string} sRequestHash - * @return {string} - */ - LinkBuilder.prototype.messageDownloadLink = function (sRequestHash) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sRequestHash; - }; - - /** - * @param {string} sEmail - * @return {string} - */ - LinkBuilder.prototype.avatarLink = function (sEmail) - { - return this.sServer + '/Raw/0/Avatar/' + window.encodeURIComponent(sEmail) + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.inbox = function () - { - return this.sBase + 'mailbox/Inbox'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.messagePreview = function () - { - return this.sBase + 'mailbox/message-preview'; - }; - - /** - * @param {string=} sScreenName - * @return {string} - */ - LinkBuilder.prototype.settings = function (sScreenName) - { - var sResult = this.sBase + 'settings'; - if (!Utils.isUnd(sScreenName) && '' !== sScreenName) - { - sResult += '/' + sScreenName; - } - - return sResult; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.about = function () - { - return this.sBase + 'about'; - }; - - /** - * @param {string} sScreenName - * @return {string} - */ - LinkBuilder.prototype.admin = function (sScreenName) - { - var sResult = this.sBase; - switch (sScreenName) { - case 'AdminDomains': - sResult += 'domains'; - break; - case 'AdminSecurity': - sResult += 'security'; - break; - case 'AdminLicensing': - sResult += 'licensing'; - break; - } - - return sResult; - }; - - /** - * @param {string} sFolder - * @param {number=} iPage = 1 - * @param {string=} sSearch = '' - * @return {string} - */ - LinkBuilder.prototype.mailBox = function (sFolder, iPage, sSearch) - { - iPage = Utils.isNormal(iPage) ? Utils.pInt(iPage) : 1; - sSearch = Utils.pString(sSearch); - - var sResult = this.sBase + 'mailbox/'; - if ('' !== sFolder) - { - sResult += encodeURI(sFolder); - } - if (1 < iPage) - { - sResult = sResult.replace(/[\/]+$/, ''); - sResult += '/p' + iPage; - } - if ('' !== sSearch) - { - sResult = sResult.replace(/[\/]+$/, ''); - sResult += '/' + encodeURI(sSearch); - } - - return sResult; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.phpInfo = function () - { - return this.sServer + 'Info'; - }; - - /** - * @param {string} sLang - * @return {string} - */ - LinkBuilder.prototype.langLink = function (sLang) - { - return this.sServer + '/Lang/0/' + encodeURI(sLang) + '/' + this.sVersion + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.exportContactsVcf = function () - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsVcf/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.exportContactsCsv = function () - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsCsv/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.emptyContactPic = function () - { - return this.sStaticPrefix + 'css/images/empty-contact.png'; - }; - - /** - * @param {string} sFileName - * @return {string} - */ - LinkBuilder.prototype.sound = function (sFileName) - { - return this.sStaticPrefix + 'sounds/' + sFileName; - }; - - /** - * @param {string} sTheme - * @return {string} - */ - LinkBuilder.prototype.themePreviewLink = function (sTheme) - { - var sPrefix = 'rainloop/v/' + this.sVersion + '/'; - if ('@custom' === sTheme.substr(-7)) - { - sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7)); - sPrefix = ''; - } - - return sPrefix + 'themes/' + encodeURI(sTheme) + '/images/preview.png'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.notificationMailIcon = function () - { - return this.sStaticPrefix + 'css/images/icom-message-notification.png'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.openPgpJs = function () - { - return this.sStaticPrefix + 'js/openpgp.min.js'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.socialGoogle = function () - { - return this.sServer + 'SocialGoogle' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.socialTwitter = function () - { - return this.sServer + 'SocialTwitter' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.socialFacebook = function () - { - return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); - }; - - module.exports = new LinkBuilder(); - -}(module, require)); -},{"Storage:Settings":45,"Utils":11,"window":20}],10:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - Utils = require('Utils') - ; - - /** - * @constructor - */ - function Plugins() - { - this.__boot = null; - this.__data = null; - this.__remote = null; - - this.oSettings = require('Storage:Settings'); - - this.oViewModelsHooks = {}; - this.oSimpleHooks = {}; - } - - Plugins.prototype.__boot = null; - Plugins.prototype.__data = null; - Plugins.prototype.__remote = null; - - /** - * @type {Object} - */ - Plugins.prototype.oViewModelsHooks = {}; - - /** - * @type {Object} - */ - Plugins.prototype.oSimpleHooks = {}; - - /** - * @param {string} sName - * @param {Function} fCallback - */ - Plugins.prototype.addHook = function (sName, fCallback) - { - if (Utils.isFunc(fCallback)) - { - if (!Utils.isArray(this.oSimpleHooks[sName])) - { - this.oSimpleHooks[sName] = []; - } - - this.oSimpleHooks[sName].push(fCallback); - } - }; - - /** - * @param {string} sName - * @param {Array=} aArguments - */ - Plugins.prototype.runHook = function (sName, aArguments) - { - if (Utils.isArray(this.oSimpleHooks[sName])) - { - aArguments = aArguments || []; - - _.each(this.oSimpleHooks[sName], function (fCallback) { - fCallback.apply(null, aArguments); - }); - } - }; - - /** - * @param {string} sName - * @return {?} - */ - Plugins.prototype.mainSettingsGet = function (sName) - { - return this.oSettings.settingsGet(sName); - }; - - /** - * @param {Function} fCallback - * @param {string} sAction - * @param {Object=} oParameters - * @param {?number=} iTimeout - * @param {string=} sGetAdd = '' - * @param {Array=} aAbortActions = [] - */ - Plugins.prototype.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) - { - if (this.__remote) - { - this.__remote.defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions); - } - }; - - /** - * @param {string} sPluginSection - * @param {string} sName - * @return {?} - */ - Plugins.prototype.settingsGet = function (sPluginSection, sName) - { - var oPlugin = this.oSettings.settingsGet('Plugins'); - oPlugin = oPlugin && !Utils.isUnd(oPlugin[sPluginSection]) ? oPlugin[sPluginSection] : null; - return oPlugin ? (Utils.isUnd(oPlugin[sName]) ? null : oPlugin[sName]) : null; - }; - - module.exports = new Plugins(); - -}(module, require)); -},{"Storage:Settings":45,"Utils":11,"_":19}],11:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - Utils = {}, - - window = require('window'), - _ = require('_'), - $ = require('$'), - ko = require('ko'), - - Enums = require('Enums'), - Consts = require('Consts'), - Globals = require('Globals') - ; - - Utils.trim = $.trim; - Utils.inArray = $.inArray; - Utils.isArray = _.isArray; - Utils.isFunc = _.isFunction; - Utils.isUnd = _.isUndefined; - Utils.isNull = _.isNull; - Utils.emptyFunction = function () {}; - - /** - * @param {*} oValue - * @return {boolean} - */ - Utils.isNormal = function (oValue) - { - return !Utils.isUnd(oValue) && !Utils.isNull(oValue); - }; - - Utils.windowResize = _.debounce(function (iTimeout) { - if (Utils.isUnd(iTimeout)) - { - Globals.$win.resize(); - } - else - { - window.setTimeout(function () { - Globals.$win.resize(); - }, iTimeout); - } - }, 50); - - /** - * @param {(string|number)} mValue - * @param {boolean=} bIncludeZero - * @return {boolean} - */ - Utils.isPosNumeric = function (mValue, bIncludeZero) - { - return Utils.isNormal(mValue) ? - ((Utils.isUnd(bIncludeZero) ? true : !!bIncludeZero) ? - (/^[0-9]*$/).test(mValue.toString()) : - (/^[1-9]+[0-9]*$/).test(mValue.toString())) : - false; - }; - - /** - * @param {*} iValue - * @param {number=} iDefault = 0 - * @return {number} - */ - Utils.pInt = function (iValue, iDefault) - { - var iResult = Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : (iDefault || 0); - return window.isNaN(iResult) ? (iDefault || 0) : iResult; - }; - - /** - * @param {*} mValue - * @return {string} - */ - Utils.pString = function (mValue) - { - return Utils.isNormal(mValue) ? '' + mValue : ''; - }; - - /** - * @param {*} aValue - * @return {boolean} - */ - Utils.isNonEmptyArray = function (aValue) - { - return Utils.isArray(aValue) && 0 < aValue.length; - }; - - /** - * @return {*|null} - */ - Utils.notificationClass = function () - { - return window.Notification && window.Notification.requestPermission ? window.Notification : null; - }; - - /** - * @param {string} sQueryString - * @return {Object} - */ - Utils.simpleQueryParser = function (sQueryString) - { - var - oParams = {}, - aQueries = [], - aTemp = [], - iIndex = 0, - iLen = 0 - ; - - aQueries = sQueryString.split('&'); - for (iIndex = 0, iLen = aQueries.length; iIndex < iLen; iIndex++) - { - aTemp = aQueries[iIndex].split('='); - oParams[window.decodeURIComponent(aTemp[0])] = window.decodeURIComponent(aTemp[1]); - } - - return oParams; - }; - - /** - * @param {string} sMailToUrl - * @param {Function} PopupComposeVoreModel - * @returns {boolean} - */ - Utils.mailToHelper = function (sMailToUrl, PopupComposeVoreModel) - { - if (sMailToUrl && 'mailto:' === sMailToUrl.toString().substr(0, 7).toLowerCase()) - { - sMailToUrl = sMailToUrl.toString().substr(7); - - var - oParams = {}, - oEmailModel = null, - sEmail = sMailToUrl.replace(/\?.+$/, ''), - sQueryString = sMailToUrl.replace(/^[^\?]*\?/, ''), - EmailModel = require('Model:Email') - ; - - oEmailModel = new EmailModel(); - oEmailModel.parse(window.decodeURIComponent(sEmail)); - - if (oEmailModel && oEmailModel.email) - { - oParams = Utils.simpleQueryParser(sQueryString); - - require('App:Knoin').showScreenPopup(PopupComposeVoreModel, [Enums.ComposeType.Empty, null, [oEmailModel], - Utils.isUnd(oParams.subject) ? null : Utils.pString(oParams.subject), - Utils.isUnd(oParams.body) ? null : Utils.plainToHtml(Utils.pString(oParams.body)) - ]); - } - - return true; - } - - return false; - }; - - /** - * @param {string} sValue - * @param {string} sHash - * @param {string} sKey - * @param {string} sLongKey - * @return {string|boolean} - */ - Utils.rsaEncode = function (sValue, sHash, sKey, sLongKey) - { - if (window.crypto && window.crypto.getRandomValues && window.RSAKey && sHash && sKey && sLongKey) - { - var oRsa = new window.RSAKey(); - oRsa.setPublic(sLongKey, sKey); - - sValue = oRsa.encrypt(Utils.fakeMd5() + ':' + sValue + ':' + Utils.fakeMd5()); - if (false !== sValue) - { - return 'rsa:' + sHash + ':' + sValue; - } - } - - return false; - }; - - Utils.rsaEncode.supported = !!(window.crypto && window.crypto.getRandomValues && window.RSAKey); - - /** - * @param {string} sPath - * @param {*=} oObject - * @param {Object=} oObjectToExportTo - */ - Utils.exportPath = function (sPath, oObject, oObjectToExportTo) - { - var - sPart = null, - aParts = sPath.split('.'), - oCur = oObjectToExportTo || window - ; - - for (; aParts.length && (sPart = aParts.shift());) - { - if (!aParts.length && !Utils.isUnd(oObject)) - { - oCur[sPart] = oObject; - } - else if (oCur[sPart]) - { - oCur = oCur[sPart]; - } - else - { - oCur = oCur[sPart] = {}; - } - } - }; - - /** - * @param {Object} oObject - * @param {string} sName - * @param {*} mValue - */ - Utils.pImport = function (oObject, sName, mValue) - { - oObject[sName] = mValue; - }; - - /** - * @param {Object} oObject - * @param {string} sName - * @param {*} mDefault - * @return {*} - */ - Utils.pExport = function (oObject, sName, mDefault) - { - return Utils.isUnd(oObject[sName]) ? mDefault : oObject[sName]; - }; - - /** - * @param {string} sText - * @return {string} - */ - Utils.encodeHtml = function (sText) - { - return Utils.isNormal(sText) ? sText.toString() - .replace(/&/g, '&').replace(//g, '>') - .replace(/"/g, '"').replace(/'/g, ''') : ''; - }; - - /** - * @param {string} sText - * @param {number=} iLen - * @return {string} - */ - Utils.splitPlainText = function (sText, iLen) - { - var - sPrefix = '', - sSubText = '', - sResult = sText, - iSpacePos = 0, - iNewLinePos = 0 - ; - - iLen = Utils.isUnd(iLen) ? 100 : iLen; - - while (sResult.length > iLen) - { - sSubText = sResult.substring(0, iLen); - iSpacePos = sSubText.lastIndexOf(' '); - iNewLinePos = sSubText.lastIndexOf('\n'); - - if (-1 !== iNewLinePos) - { - iSpacePos = iNewLinePos; - } - - if (-1 === iSpacePos) - { - iSpacePos = iLen; - } - - sPrefix += sSubText.substring(0, iSpacePos) + '\n'; - sResult = sResult.substring(iSpacePos + 1); - } - - return sPrefix + sResult; - }; - - Utils.timeOutAction = (function () { - - var - oTimeOuts = {} - ; - - return function (sAction, fFunction, iTimeOut) - { - if (Utils.isUnd(oTimeOuts[sAction])) - { - oTimeOuts[sAction] = 0; - } - - window.clearTimeout(oTimeOuts[sAction]); - oTimeOuts[sAction] = window.setTimeout(fFunction, iTimeOut); - }; - }()); - - Utils.timeOutActionSecond = (function () { - - var - oTimeOuts = {} - ; - - return function (sAction, fFunction, iTimeOut) - { - if (!oTimeOuts[sAction]) - { - oTimeOuts[sAction] = window.setTimeout(function () { - fFunction(); - oTimeOuts[sAction] = 0; - }, iTimeOut); - } - }; - }()); - - Utils.audio = (function () { - - var - oAudio = false - ; - - return function (sMp3File, sOggFile) { - - if (false === oAudio) - { - if (Globals.bIsiOSDevice) - { - oAudio = null; - } - else - { - var - bCanPlayMp3 = false, - bCanPlayOgg = false, - oAudioLocal = window.Audio ? new window.Audio() : null - ; - - if (oAudioLocal && oAudioLocal.canPlayType && oAudioLocal.play) - { - bCanPlayMp3 = '' !== oAudioLocal.canPlayType('audio/mpeg; codecs="mp3"'); - if (!bCanPlayMp3) - { - bCanPlayOgg = '' !== oAudioLocal.canPlayType('audio/ogg; codecs="vorbis"'); - } - - if (bCanPlayMp3 || bCanPlayOgg) - { - oAudio = oAudioLocal; - oAudio.preload = 'none'; - oAudio.loop = false; - oAudio.autoplay = false; - oAudio.muted = false; - oAudio.src = bCanPlayMp3 ? sMp3File : sOggFile; + Data.licenseError(Utils.getNotification(Enums.Notification.LicensingServerIsUnavailable)); + Data.licensing(true); } else { - oAudio = null; + Data.licensing(false); } } - else - { - oAudio = null; - } + } + }, bForce); + }; + + AdminApp.prototype.bootstart = function () + { + AbstractApp.prototype.bootstart.call(this); + + Data.populateDataOnStart(); + + kn.hideLoading(); + + if (!Settings.settingsGet('AllowAdminPanel')) + { + kn.routeOff(); + kn.setHash(LinkBuilder.root(), true); + kn.routeOff(); + + _.defer(function () { + window.location.href = '/'; + }); + } + else + { + if (!!Settings.settingsGet('Auth')) + { + kn.startScreens([AdminSettingsScreen]); + } + else + { + kn.startScreens([AdminLoginScreen]); } } - return oAudio; + if (window.SimplePace) + { + window.SimplePace.set(100); + } }; + + module.exports = new AdminApp(); + }()); - /** - * @param {(Object|null|undefined)} oObject - * @param {string} sProp - * @return {boolean} - */ - Utils.hos = function (oObject, sProp) - { - return oObject && window.Object && window.Object.hasOwnProperty ? window.Object.hasOwnProperty.call(oObject, sProp) : false; - }; +/***/ }, - /** - * @param {string} sKey - * @param {Object=} oValueList - * @param {string=} sDefaulValue - * @return {string} - */ - Utils.i18n = function (sKey, oValueList, sDefaulValue) - { - var - sValueName = '', - sResult = Utils.isUnd(Globals.oI18N[sKey]) ? (Utils.isUnd(sDefaulValue) ? sKey : sDefaulValue) : Globals.oI18N[sKey] - ; +/***/ 18: +/*!******************************************!*\ + !*** ./dev/Storages/AdminDataStorage.js ***! + \******************************************/ +/***/ function(module, exports, __webpack_require__) { - if (!Utils.isUnd(oValueList) && !Utils.isNull(oValueList)) - { - for (sValueName in oValueList) - { - if (Utils.hos(oValueList, sValueName)) - { - sResult = sResult.replace('%' + sValueName + '%', oValueList[sValueName]); - } - } - } + /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - return sResult; - }; + (function () { - /** - * @param {Object} oElement - */ - Utils.i18nToNode = function (oElement) - { - _.defer(function () { - $('.i18n', oElement).each(function () { - var - jqThis = $(this), - sKey = '' - ; - - sKey = jqThis.data('i18n-text'); - if (sKey) - { - jqThis.text(Utils.i18n(sKey)); - } - else - { - sKey = jqThis.data('i18n-html'); - if (sKey) - { - 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) - { - jqThis.attr('title', Utils.i18n(sKey)); - } - } - }); - }); - }; - - Utils.i18nReload = function () - { - if (window['rainloopI18N']) - { - Globals.oI18N = window['rainloopI18N'] || {}; - - Utils.i18nToNode(Globals.$doc); - - Globals.langChangeTrigger(!Globals.langChangeTrigger()); - } - - window['rainloopI18N'] = null; - }; - - /** - * @param {Function} fCallback - * @param {Object} oScope - * @param {Function=} fLangCallback - */ - Utils.initOnStartOrLangChange = function (fCallback, oScope, fLangCallback) - { - if (fCallback) - { - fCallback.call(oScope); - } - - if (fLangCallback) - { - Globals.langChangeTrigger.subscribe(function () { - if (fCallback) - { - fCallback.call(oScope); - } - - fLangCallback.call(oScope); - }); - } - else if (fCallback) - { - Globals.langChangeTrigger.subscribe(fCallback, oScope); - } - }; - - /** - * @return {boolean} - */ - Utils.inFocus = function () - { - if (window.document.activeElement) - { - if (Utils.isUnd(window.document.activeElement.__inFocusCache)) - { - window.document.activeElement.__inFocusCache = $(window.document.activeElement).is('input,textarea,iframe,.cke_editable'); - } - - return !!window.document.activeElement.__inFocusCache; - } - - return false; - }; - - Utils.removeInFocus = function () - { - if (window.document && window.document.activeElement && window.document.activeElement.blur) - { - var oA = $(window.document.activeElement); - if (oA.is('input,textarea')) - { - window.document.activeElement.blur(); - } - } - }; - - Utils.removeSelection = function () - { - if (window && window.getSelection) - { - var oSel = window.getSelection(); - if (oSel && oSel.removeAllRanges) - { - oSel.removeAllRanges(); - } - } - else if (window.document && window.document.selection && window.document.selection.empty) - { - window.document.selection.empty(); - } - }; - - /** - * @param {string} sPrefix - * @param {string} sSubject - * @return {string} - */ - Utils.replySubjectAdd = function (sPrefix, sSubject) - { - sPrefix = Utils.trim(sPrefix.toUpperCase()); - sSubject = Utils.trim(sSubject.replace(/[\s]+/g, ' ')); + 'use strict'; var - bDrop = false, - aSubject = [], - bRe = 'RE' === sPrefix, - bFwd = 'FWD' === sPrefix, - bPrefixIsRe = !bFwd + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + AbstractData = __webpack_require__(/*! Storage:Abstract:Data */ 39) ; - if ('' !== sSubject) + /** + * @constructor + * @extends AbstractData + */ + function AdminDataStorage() { - _.each(sSubject.split(':'), function (sPart) { - var sTrimmedPart = Utils.trim(sPart); - if (!bDrop && (/^(RE|FWD)$/i.test(sTrimmedPart) || /^(RE|FWD)[\[\(][\d]+[\]\)]$/i.test(sTrimmedPart))) - { - if (!bRe) - { - bRe = !!(/^RE/i.test(sTrimmedPart)); - } - - if (!bFwd) - { - bFwd = !!(/^FWD/i.test(sTrimmedPart)); - } - } - else - { - aSubject.push(sPart); - bDrop = true; - } - }); - } - - if (bPrefixIsRe) - { - bRe = false; - } - else - { - bFwd = false; - } - - return Utils.trim( - (bPrefixIsRe ? 'Re: ' : 'Fwd: ') + - (bRe ? 'Re: ' : '') + - (bFwd ? 'Fwd: ' : '') + - Utils.trim(aSubject.join(':')) - ); - }; - - /** - * @param {number} iNum - * @param {number} iDec - * @return {number} - */ - Utils.roundNumber = function (iNum, iDec) - { - return window.Math.round(iNum * window.Math.pow(10, iDec)) / window.Math.pow(10, iDec); - }; - - /** - * @param {(number|string)} iSizeInBytes - * @return {string} - */ - Utils.friendlySize = function (iSizeInBytes) - { - iSizeInBytes = Utils.pInt(iSizeInBytes); - - if (iSizeInBytes >= 1073741824) - { - return Utils.roundNumber(iSizeInBytes / 1073741824, 1) + 'GB'; - } - else if (iSizeInBytes >= 1048576) - { - return Utils.roundNumber(iSizeInBytes / 1048576, 1) + 'MB'; - } - else if (iSizeInBytes >= 1024) - { - return Utils.roundNumber(iSizeInBytes / 1024, 0) + 'KB'; - } - - return iSizeInBytes + 'B'; - }; - - /** - * @param {string} sDesc - */ - Utils.log = function (sDesc) - { - if (window.console && window.console.log) - { - window.console.log(sDesc); - } - }; - - /** - * @param {number} iCode - * @param {*=} mMessage = '' - * @return {string} - */ - Utils.getNotification = function (iCode, mMessage) - { - iCode = Utils.pInt(iCode); - if (Enums.Notification.ClientViewError === iCode && mMessage) - { - return mMessage; - } - - return Utils.isUnd(Globals.oNotificationI18N[iCode]) ? '' : Globals.oNotificationI18N[iCode]; - }; - - Utils.initNotificationLanguage = function () - { - var oN = Globals.oNotificationI18N || {}; - oN[Enums.Notification.InvalidToken] = Utils.i18n('NOTIFICATIONS/INVALID_TOKEN'); - oN[Enums.Notification.AuthError] = Utils.i18n('NOTIFICATIONS/AUTH_ERROR'); - oN[Enums.Notification.AccessError] = Utils.i18n('NOTIFICATIONS/ACCESS_ERROR'); - oN[Enums.Notification.ConnectionError] = Utils.i18n('NOTIFICATIONS/CONNECTION_ERROR'); - oN[Enums.Notification.CaptchaError] = Utils.i18n('NOTIFICATIONS/CAPTCHA_ERROR'); - oN[Enums.Notification.SocialFacebookLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE'); - oN[Enums.Notification.SocialTwitterLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE'); - oN[Enums.Notification.SocialGoogleLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE'); - oN[Enums.Notification.DomainNotAllowed] = Utils.i18n('NOTIFICATIONS/DOMAIN_NOT_ALLOWED'); - oN[Enums.Notification.AccountNotAllowed] = Utils.i18n('NOTIFICATIONS/ACCOUNT_NOT_ALLOWED'); - - oN[Enums.Notification.AccountTwoFactorAuthRequired] = Utils.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED'); - oN[Enums.Notification.AccountTwoFactorAuthError] = Utils.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR'); - - oN[Enums.Notification.CouldNotSaveNewPassword] = Utils.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD'); - oN[Enums.Notification.CurrentPasswordIncorrect] = Utils.i18n('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT'); - oN[Enums.Notification.NewPasswordShort] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_SHORT'); - oN[Enums.Notification.NewPasswordWeak] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_WEAK'); - oN[Enums.Notification.NewPasswordForbidden] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT'); - - oN[Enums.Notification.ContactsSyncError] = Utils.i18n('NOTIFICATIONS/CONTACTS_SYNC_ERROR'); - - oN[Enums.Notification.CantGetMessageList] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST'); - oN[Enums.Notification.CantGetMessage] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE'); - oN[Enums.Notification.CantDeleteMessage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_MESSAGE'); - oN[Enums.Notification.CantMoveMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE'); - oN[Enums.Notification.CantCopyMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE'); - - oN[Enums.Notification.CantSaveMessage] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_MESSAGE'); - oN[Enums.Notification.CantSendMessage] = Utils.i18n('NOTIFICATIONS/CANT_SEND_MESSAGE'); - oN[Enums.Notification.InvalidRecipients] = Utils.i18n('NOTIFICATIONS/INVALID_RECIPIENTS'); - - oN[Enums.Notification.CantCreateFolder] = Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER'); - oN[Enums.Notification.CantRenameFolder] = Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'); - oN[Enums.Notification.CantDeleteFolder] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'); - oN[Enums.Notification.CantDeleteNonEmptyFolder] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER'); - oN[Enums.Notification.CantSubscribeFolder] = Utils.i18n('NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER'); - oN[Enums.Notification.CantUnsubscribeFolder] = Utils.i18n('NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER'); - - oN[Enums.Notification.CantSaveSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS'); - oN[Enums.Notification.CantSavePluginSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS'); - - oN[Enums.Notification.DomainAlreadyExists] = Utils.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS'); - - oN[Enums.Notification.CantInstallPackage] = Utils.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE'); - oN[Enums.Notification.CantDeletePackage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE'); - oN[Enums.Notification.InvalidPluginPackage] = Utils.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE'); - oN[Enums.Notification.UnsupportedPluginPackage] = Utils.i18n('NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE'); - - oN[Enums.Notification.LicensingServerIsUnavailable] = Utils.i18n('NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE'); - oN[Enums.Notification.LicensingExpired] = Utils.i18n('NOTIFICATIONS/LICENSING_EXPIRED'); - oN[Enums.Notification.LicensingBanned] = Utils.i18n('NOTIFICATIONS/LICENSING_BANNED'); - - oN[Enums.Notification.DemoSendMessageError] = Utils.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR'); - - oN[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS'); - - oN[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR'); - oN[Enums.Notification.InvalidInputArgument] = Utils.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT'); - oN[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR'); - oN[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR'); - }; - - /** - * @param {*} mCode - * @return {string} - */ - Utils.getUploadErrorDescByCode = function (mCode) - { - var sResult = ''; - switch (Utils.pInt(mCode)) { - case Enums.UploadErrorCode.FileIsTooBig: - sResult = Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG'); - break; - case Enums.UploadErrorCode.FilePartiallyUploaded: - sResult = Utils.i18n('UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED'); - break; - case Enums.UploadErrorCode.FileNoUploaded: - sResult = Utils.i18n('UPLOAD/ERROR_NO_FILE_UPLOADED'); - break; - case Enums.UploadErrorCode.MissingTempFolder: - sResult = Utils.i18n('UPLOAD/ERROR_MISSING_TEMP_FOLDER'); - break; - case Enums.UploadErrorCode.FileOnSaveingError: - sResult = Utils.i18n('UPLOAD/ERROR_ON_SAVING_FILE'); - break; - case Enums.UploadErrorCode.FileType: - sResult = Utils.i18n('UPLOAD/ERROR_FILE_TYPE'); - break; - default: - sResult = Utils.i18n('UPLOAD/ERROR_UNKNOWN'); - break; - } - - return sResult; - }; - - /** - * @param {?} oObject - * @param {string} sMethodName - * @param {Array=} aParameters - * @param {number=} nDelay - */ - Utils.delegateRun = function (oObject, sMethodName, aParameters, nDelay) - { - if (oObject && oObject[sMethodName]) - { - nDelay = Utils.pInt(nDelay); - if (0 >= nDelay) - { - oObject[sMethodName].apply(oObject, Utils.isArray(aParameters) ? aParameters : []); - } - else - { - _.delay(function () { - oObject[sMethodName].apply(oObject, Utils.isArray(aParameters) ? aParameters : []); - }, nDelay); - } - } - }; - - /** - * @param {?} oEvent - */ - Utils.killCtrlAandS = function (oEvent) - { - oEvent = oEvent || window.event; - if (oEvent && oEvent.ctrlKey && !oEvent.shiftKey && !oEvent.altKey) - { - var - oSender = oEvent.target || oEvent.srcElement, - iKey = oEvent.keyCode || oEvent.which - ; - - if (iKey === Enums.EventKeyCode.S) - { - oEvent.preventDefault(); - return; - } - - if (oSender && oSender.tagName && oSender.tagName.match(/INPUT|TEXTAREA/i)) - { - return; - } - - if (iKey === Enums.EventKeyCode.A) - { - if (window.getSelection) - { - window.getSelection().removeAllRanges(); - } - else if (window.document.selection && window.document.selection.clear) - { - window.document.selection.clear(); - } - - oEvent.preventDefault(); - } - } - }; - - /** - * @param {(Object|null|undefined)} oContext - * @param {Function} fExecute - * @param {(Function|boolean|null)=} fCanExecute - * @return {Function} - */ - Utils.createCommand = function (oContext, fExecute, fCanExecute) - { - var - fResult = fExecute ? function () { - - if (fResult && fResult.canExecute && fResult.canExecute()) - { - fExecute.apply(oContext, Array.prototype.slice.call(arguments)); - } - - return false; - - } : function () {} - ; - - fResult.enabled = ko.observable(true); - - fCanExecute = Utils.isUnd(fCanExecute) ? true : fCanExecute; - if (Utils.isFunc(fCanExecute)) - { - fResult.canExecute = ko.computed(function () { - return fResult.enabled() && fCanExecute.call(oContext); - }); - } - else - { - fResult.canExecute = ko.computed(function () { - return fResult.enabled() && !!fCanExecute; - }); - } - - return fResult; - }; - - /** - * @param {Object} oData - */ - Utils.initDataConstructorBySettings = function (oData) - { - oData.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html); - oData.showImages = ko.observable(false); - oData.interfaceAnimation = ko.observable(Enums.InterfaceAnimation.Full); - oData.contactsAutosave = ko.observable(false); - - Globals.sAnimationType = Enums.InterfaceAnimation.Full; - - oData.capaThemes = ko.observable(false); - oData.allowLanguagesOnSettings = ko.observable(true); - oData.allowLanguagesOnLogin = ko.observable(true); - - oData.useLocalProxyForExternalImages = ko.observable(false); - - oData.desktopNotifications = ko.observable(false); - 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(); - }); - - oData.interfaceAnimation.subscribe(function (sValue) { - if (Globals.bMobileDevice || sValue === Enums.InterfaceAnimation.None) - { - Globals.$html.removeClass('rl-anim rl-anim-full').addClass('no-rl-anim'); - - Globals.sAnimationType = Enums.InterfaceAnimation.None; - } - else - { - switch (sValue) - { - case Enums.InterfaceAnimation.Full: - Globals.$html.removeClass('no-rl-anim').addClass('rl-anim rl-anim-full'); - Globals.sAnimationType = sValue; - break; - case Enums.InterfaceAnimation.Normal: - Globals.$html.removeClass('no-rl-anim rl-anim-full').addClass('rl-anim'); - Globals.sAnimationType = sValue; - break; - } - } - }); - - oData.interfaceAnimation.valueHasMutated(); - - oData.desktopNotificationsPermisions = ko.computed(function () { - - oData.desktopNotifications(); - - var - NotificationClass = Utils.notificationClass(), - iResult = Enums.DesktopNotifications.NotSupported - ; - - if (NotificationClass && NotificationClass.permission) - { - switch (NotificationClass.permission.toLowerCase()) - { - case 'granted': - iResult = Enums.DesktopNotifications.Allowed; - break; - case 'denied': - iResult = Enums.DesktopNotifications.Denied; - break; - case 'default': - iResult = Enums.DesktopNotifications.NotAllowed; - break; - } - } - else if (window.webkitNotifications && window.webkitNotifications.checkPermission) - { - iResult = window.webkitNotifications.checkPermission(); - } - - return iResult; - }); - - oData.useDesktopNotifications = ko.computed({ - 'read': function () { - return oData.desktopNotifications() && - Enums.DesktopNotifications.Allowed === oData.desktopNotificationsPermisions(); - }, - 'write': function (bValue) { - if (bValue) - { - var - NotificationClass = Utils.notificationClass(), - iPermission = oData.desktopNotificationsPermisions() - ; - - if (NotificationClass && Enums.DesktopNotifications.Allowed === iPermission) - { - oData.desktopNotifications(true); - } - else if (NotificationClass && Enums.DesktopNotifications.NotAllowed === iPermission) - { - NotificationClass.requestPermission(function () { - oData.desktopNotifications.valueHasMutated(); - if (Enums.DesktopNotifications.Allowed === oData.desktopNotificationsPermisions()) - { - if (oData.desktopNotifications()) - { - oData.desktopNotifications.valueHasMutated(); - } - else - { - oData.desktopNotifications(true); - } - } - else - { - if (oData.desktopNotifications()) - { - oData.desktopNotifications(false); - } - else - { - oData.desktopNotifications.valueHasMutated(); - } - } - }); - } - else - { - oData.desktopNotifications(false); - } - } - else - { - oData.desktopNotifications(false); - } - } - }); - - oData.language = ko.observable(''); - oData.languages = ko.observableArray([]); - - oData.mainLanguage = ko.computed({ - 'read': oData.language, - 'write': function (sValue) { - if (sValue !== oData.language()) - { - if (-1 < Utils.inArray(sValue, oData.languages())) - { - oData.language(sValue); - } - else if (0 < oData.languages().length) - { - oData.language(oData.languages()[0]); - } - } - else - { - oData.language.valueHasMutated(); - } - } - }); - - oData.theme = ko.observable(''); - oData.themes = ko.observableArray([]); - - oData.mainTheme = ko.computed({ - 'read': oData.theme, - 'write': function (sValue) { - if (sValue !== oData.theme()) - { - var aThemes = oData.themes(); - if (-1 < Utils.inArray(sValue, aThemes)) - { - oData.theme(sValue); - } - else if (0 < aThemes.length) - { - oData.theme(aThemes[0]); - } - } - else - { - oData.theme.valueHasMutated(); - } - } - }); - - oData.capaAdditionalAccounts = ko.observable(false); - oData.capaAdditionalIdentities = ko.observable(false); - oData.capaGravatar = ko.observable(false); - oData.determineUserLanguage = ko.observable(false); - oData.determineUserDomain = ko.observable(false); - - oData.messagesPerPage = ko.observable(Consts.Defaults.MessagesPerPage);//.extend({'throttle': 200}); - - oData.mainMessagesPerPage = oData.messagesPerPage; - oData.mainMessagesPerPage = ko.computed({ - 'read': oData.messagesPerPage, - 'write': function (iValue) { - if (-1 < Utils.inArray(Utils.pInt(iValue), Consts.Defaults.MessagesPerPageArray)) - { - if (iValue !== oData.messagesPerPage()) - { - oData.messagesPerPage(iValue); - } - } - else - { - oData.messagesPerPage.valueHasMutated(); - } - } - }); - - oData.facebookSupported = ko.observable(false); - oData.facebookEnable = ko.observable(false); - oData.facebookAppID = ko.observable(''); - oData.facebookAppSecret = ko.observable(''); - - oData.twitterEnable = ko.observable(false); - oData.twitterConsumerKey = ko.observable(''); - oData.twitterConsumerSecret = ko.observable(''); - - oData.googleEnable = ko.observable(false); - oData.googleClientID = ko.observable(''); - oData.googleClientSecret = ko.observable(''); - oData.googleApiKey = ko.observable(''); - - oData.dropboxEnable = ko.observable(false); - oData.dropboxApiKey = ko.observable(''); - - oData.contactsIsAllowed = ko.observable(false); - }; - - /** - * @param {{moment:Function}} oObject - */ - Utils.createMomentDate = function (oObject) - { - if (Utils.isUnd(oObject.moment)) - { - oObject.moment = ko.observable(moment()); - } - - return ko.computed(function () { - Globals.momentTrigger(); - var oMoment = this.moment(); - return 1970 === oMoment.year() ? '' : oMoment.fromNow(); - }, oObject); - }; - - /** - * @param {{moment:Function, momentDate:Function}} oObject - */ - Utils.createMomentShortDate = function (oObject) - { - return ko.computed(function () { - - var - sResult = '', - oMomentNow = moment(), - oMoment = this.moment(), - sMomentDate = this.momentDate() - ; - - if (1970 === oMoment.year()) - { - sResult = ''; - } - else if (4 >= oMomentNow.diff(oMoment, 'hours')) - { - sResult = sMomentDate; - } - else if (oMomentNow.format('L') === oMoment.format('L')) - { - sResult = Utils.i18n('MESSAGE_LIST/TODAY_AT', { - 'TIME': oMoment.format('LT') - }); - } - else if (oMomentNow.clone().subtract('days', 1).format('L') === oMoment.format('L')) - { - sResult = Utils.i18n('MESSAGE_LIST/YESTERDAY_AT', { - 'TIME': oMoment.format('LT') - }); - } - else if (oMomentNow.year() === oMoment.year()) - { - sResult = oMoment.format('D MMM.'); - } - else - { - sResult = oMoment.format('LL'); - } - - return sResult; - - }, oObject); - }; - - /** - * @param {string} sTheme - * @return {string} - */ - Utils.convertThemeName = function (sTheme) - { - if ('@custom' === sTheme.substr(-7)) - { - sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7)); - } - - return Utils.trim(sTheme.replace(/[^a-zA-Z0-9]+/g, ' ').replace(/([A-Z])/g, ' $1').replace(/[\s]+/g, ' ')); - }; - - /** - * @param {string} sName - * @return {string} - */ - Utils.quoteName = function (sName) - { - return sName.replace(/["]/g, '\\"'); - }; - - /** - * @return {number} - */ - Utils.microtime = function () - { - return (new Date()).getTime(); - }; - - /** - * - * @param {string} sLanguage - * @param {boolean=} bEng = false - * @return {string} - */ - Utils.convertLangName = function (sLanguage, bEng) - { - return Utils.i18n('LANGS_NAMES' + (true === bEng ? '_EN' : '') + '/LANG_' + - sLanguage.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_'), null, sLanguage); - }; - - /** - * @param {number=} iLen - * @return {string} - */ - Utils.fakeMd5 = function(iLen) - { - var - sResult = '', - sLine = '0123456789abcdefghijklmnopqrstuvwxyz' - ; - - iLen = Utils.isUnd(iLen) ? 32 : Utils.pInt(iLen); - - while (sResult.length < iLen) - { - sResult += sLine.substr(window.Math.round(window.Math.random() * sLine.length), 1); - } - - return sResult; - }; - - /** - * @param {string} sPlain - * @return {string} - */ - Utils.convertPlainTextToHtml = function (sPlain) - { - return sPlain.toString() - .replace(/&/g, '&').replace(/>/g, '>').replace(/'); - }; - - Utils.draggeblePlace = function () - { - return $('
 
').appendTo('#rl-hidden'); - }; - - Utils.defautOptionsAfterRender = function (oDomOption, oItem) - { - if (oItem && !Utils.isUnd(oItem.disabled) && oDomOption) - { - $(oDomOption) - .toggleClass('disabled', oItem.disabled) - .prop('disabled', oItem.disabled) - ; - } - }; - - /** - * @param {Object} oViewModel - * @param {string} sTemplateID - * @param {string} sTitle - * @param {Function=} fCallback - */ - Utils.windowPopupKnockout = function (oViewModel, sTemplateID, sTitle, fCallback) - { - var - oScript = null, - oWin = window.open(''), - sFunc = '__OpenerApplyBindingsUid' + Utils.fakeMd5() + '__', - oTemplate = $('#' + sTemplateID) - ; - - window[sFunc] = function () { - - if (oWin && oWin.document.body && oTemplate && oTemplate[0]) - { - var oBody = $(oWin.document.body); - - $('#rl-content', oBody).html(oTemplate.html()); - $('html', oWin.document).addClass('external ' + $('html').attr('class')); - - Utils.i18nToNode(oBody); - - if (oViewModel && $('#rl-content', oBody)[0]) - { - ko.applyBindings(oViewModel, $('#rl-content', oBody)[0]); - } - - window[sFunc] = null; - - fCallback(oWin); - } - }; - - oWin.document.open(); - oWin.document.write('' + -'' + -'' + -'' + -'' + -'' + -'' + Utils.encodeHtml(sTitle) + '' + -'
'); - oWin.document.close(); - - oScript = oWin.document.createElement('script'); - oScript.type = 'text/javascript'; - oScript.innerHTML = 'if(window&&window.opener&&window.opener[\'' + sFunc + '\']){window.opener[\'' + sFunc + '\']();window.opener[\'' + sFunc + '\']=null}'; - oWin.document.getElementsByTagName('head')[0].appendChild(oScript); - }; - - /** - * @param {Function} fCallback - * @param {?} koTrigger - * @param {?} oContext = null - * @param {number=} iTimer = 1000 - * @return {Function} - */ - Utils.settingsSaveHelperFunction = function (fCallback, koTrigger, oContext, iTimer) - { - oContext = oContext || null; - iTimer = Utils.isUnd(iTimer) ? 1000 : Utils.pInt(iTimer); - - return function (sType, mData, bCached, sRequestAction, oRequestParameters) { - koTrigger.call(oContext, mData && mData['Result'] ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult); - if (fCallback) - { - fCallback.call(oContext, sType, mData, bCached, sRequestAction, oRequestParameters); - } - _.delay(function () { - koTrigger.call(oContext, Enums.SaveSettingsStep.Idle); - }, iTimer); - }; - }; - - Utils.settingsSaveHelperSimpleFunction = function (koTrigger, oContext) - { - return Utils.settingsSaveHelperFunction(null, koTrigger, oContext, 1000); - }; - - /** - * @param {string} sHtml - * @return {string} - */ - Utils.htmlToPlain = function (sHtml) - { - var - iPos = 0, - iP1 = 0, - iP2 = 0, - iP3 = 0, - iLimit = 0, - - sText = '', - - splitPlainText = function (sText) - { - var - iLen = 100, - sPrefix = '', - sSubText = '', - sResult = sText, - iSpacePos = 0, - iNewLinePos = 0 - ; - - while (sResult.length > iLen) - { - sSubText = sResult.substring(0, iLen); - iSpacePos = sSubText.lastIndexOf(' '); - iNewLinePos = sSubText.lastIndexOf('\n'); - - if (-1 !== iNewLinePos) - { - iSpacePos = iNewLinePos; - } - - if (-1 === iSpacePos) - { - iSpacePos = iLen; - } - - sPrefix += sSubText.substring(0, iSpacePos) + '\n'; - sResult = sResult.substring(iSpacePos + 1); - } - - return sPrefix + sResult; - }, - - convertBlockquote = function (sText) { - sText = splitPlainText($.trim(sText)); - sText = '> ' + sText.replace(/\n/gm, '\n> '); - return sText.replace(/(^|\n)([> ]+)/gm, function () { - return (arguments && 2 < arguments.length) ? arguments[1] + $.trim(arguments[2].replace(/[\s]/g, '')) + ' ' : ''; - }); - }, - - convertDivs = function () { - if (arguments && 1 < arguments.length) - { - var sText = $.trim(arguments[1]); - if (0 < sText.length) - { - sText = sText.replace(/]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs); - sText = '\n' + $.trim(sText) + '\n'; - } - - return sText; - } - - return ''; - }, - - convertPre = function () { - return (arguments && 1 < arguments.length) ? arguments[1].toString().replace(/[\n]/gm, '
') : ''; - }, - - fixAttibuteValue = function () { - return (arguments && 1 < arguments.length) ? - '' + arguments[1] + arguments[2].replace(//g, '>') : ''; - }, - - convertLinks = function () { - return (arguments && 1 < arguments.length) ? $.trim(arguments[1]) : ''; - } - ; - - sText = sHtml - .replace(/]*>([\s\S\r\n]*)<\/pre>/gmi, convertPre) - .replace(/[\s]+/gm, ' ') - .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) - .replace(/]*>/gmi, '\n') - .replace(/<\/h[\d]>/gi, '\n') - .replace(/<\/p>/gi, '\n\n') - .replace(/<\/li>/gi, '\n') - .replace(/<\/td>/gi, '\n') - .replace(/<\/tr>/gi, '\n') - .replace(/]*>/gmi, '\n_______________________________\n\n') - .replace(/]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs) - .replace(/]*>/gmi, '\n__bq__start__\n') - .replace(/<\/blockquote>/gmi, '\n__bq__end__\n') - .replace(/]*>([\s\S\r\n]*?)<\/a>/gmi, convertLinks) - .replace(/<\/div>/gi, '\n') - .replace(/ /gi, ' ') - .replace(/"/gi, '"') - .replace(/<[^>]*>/gm, '') - ; - - sText = Globals.$div.html(sText).text(); - - sText = sText - .replace(/\n[ \t]+/gm, '\n') - .replace(/[\n]{3,}/gm, '\n\n') - .replace(/>/gi, '>') - .replace(/</gi, '<') - .replace(/&/gi, '&') - ; - - iPos = 0; - iLimit = 100; - - while (0 < iLimit) - { - iLimit--; - iP1 = sText.indexOf('__bq__start__', iPos); - if (-1 < iP1) - { - iP2 = sText.indexOf('__bq__start__', iP1 + 5); - iP3 = sText.indexOf('__bq__end__', iP1 + 5); - - if ((-1 === iP2 || iP3 < iP2) && iP1 < iP3) - { - sText = sText.substring(0, iP1) + - convertBlockquote(sText.substring(iP1 + 13, iP3)) + - sText.substring(iP3 + 11); - - iPos = 0; - } - else if (-1 < iP2 && iP2 < iP3) - { - iPos = iP2 - 1; - } - else - { - iPos = 0; - } - } - else - { - break; - } - } - - sText = sText - .replace(/__bq__start__/gm, '') - .replace(/__bq__end__/gm, '') - ; - - return sText; - }; - - /** - * @param {string} sPlain - * @param {boolean} bLinkify = false - * @return {string} - */ - Utils.plainToHtml = function (sPlain, bLinkify) - { - sPlain = sPlain.toString().replace(/\r/g, ''); - - var - bIn = false, - bDo = true, - bStart = true, - aNextText = [], - sLine = '', - iIndex = 0, - aText = sPlain.split("\n") - ; - - do - { - bDo = false; - aNextText = []; - for (iIndex = 0; iIndex < aText.length; iIndex++) - { - sLine = aText[iIndex]; - bStart = '>' === sLine.substr(0, 1); - if (bStart && !bIn) - { - bDo = true; - bIn = true; - aNextText.push('~~~blockquote~~~'); - aNextText.push(sLine.substr(1)); - } - else if (!bStart && bIn) - { - bIn = false; - aNextText.push('~~~/blockquote~~~'); - aNextText.push(sLine); - } - else if (bStart && bIn) - { - aNextText.push(sLine.substr(1)); - } - else - { - aNextText.push(sLine); - } - } - - if (bIn) - { - bIn = false; - aNextText.push('~~~/blockquote~~~'); - } - - aText = aNextText; - } - while (bDo); - - sPlain = aText.join("\n"); - - sPlain = sPlain - .replace(/&/g, '&') - .replace(/>/g, '>').replace(/') - .replace(/[\s]*~~~\/blockquote~~~/g, '') - .replace(/[\-_~]{10,}/g, '
') - .replace(/\n/g, '
'); - - return bLinkify ? Utils.linkify(sPlain) : sPlain; - }; - - window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain; - window.rainloop_Utils_plainToHtml = Utils.plainToHtml; - - /** - * @param {string} sHtml - * @return {string} - */ - Utils.linkify = function (sHtml) - { - if ($.fn && $.fn.linkify) - { - sHtml = Globals.$div.html(sHtml.replace(/&/ig, 'amp_amp_12345_amp_amp')) - .linkify() - .find('.linkified').removeClass('linkified').end() - .html() - .replace(/amp_amp_12345_amp_amp/g, '&') - ; - } - - return sHtml; - }; - - /** - * @param {string} sUrl - * @param {number} iValue - * @param {Function} fCallback - */ - Utils.resizeAndCrop = function (sUrl, iValue, fCallback) - { - var oTempImg = new window.Image(); - oTempImg.onload = function() { - - var - aDiff = [0, 0], - oCanvas = window.document.createElement('canvas'), - oCtx = oCanvas.getContext('2d') - ; - - oCanvas.width = iValue; - oCanvas.height = iValue; - - if (this.width > this.height) - { - aDiff = [this.width - this.height, 0]; - } - else - { - aDiff = [0, this.height - this.width]; - } - - 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')); - }; - - oTempImg.src = sUrl; - }; - - /** - * @param {Array} aSystem - * @param {Array} aList - * @param {Array=} aDisabled - * @param {Array=} aHeaderLines - * @param {?number=} iUnDeep - * @param {Function=} fDisableCallback - * @param {Function=} fVisibleCallback - * @param {Function=} fRenameCallback - * @param {boolean=} bSystem - * @param {boolean=} bBuildUnvisible - * @return {Array} - */ - Utils.folderListOptionsBuilder = function (aSystem, aList, aDisabled, aHeaderLines, iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible) - { - var - /** - * @type {?FolderModel} - */ - oItem = null, - bSep = false, - iIndex = 0, - iLen = 0, - sDeepPrefix = '\u00A0\u00A0\u00A0', - aResult = [] - ; - - bSystem = !Utils.isNormal(bSystem) ? 0 < aSystem.length : bSystem; - bBuildUnvisible = Utils.isUnd(bBuildUnvisible) ? false : !!bBuildUnvisible; - iUnDeep = !Utils.isNormal(iUnDeep) ? 0 : iUnDeep; - fDisableCallback = Utils.isNormal(fDisableCallback) ? fDisableCallback : null; - fVisibleCallback = Utils.isNormal(fVisibleCallback) ? fVisibleCallback : null; - fRenameCallback = Utils.isNormal(fRenameCallback) ? fRenameCallback : null; - - if (!Utils.isArray(aDisabled)) - { - aDisabled = []; - } - - if (!Utils.isArray(aHeaderLines)) - { - aHeaderLines = []; - } - - for (iIndex = 0, iLen = aHeaderLines.length; iIndex < iLen; iIndex++) - { - aResult.push({ - 'id': aHeaderLines[iIndex][0], - 'name': aHeaderLines[iIndex][1], - 'system': false, - 'seporator': false, - 'disabled': false - }); - } - - bSep = true; - for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++) - { - oItem = aSystem[iIndex]; - if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true) - { - if (bSep && 0 < aResult.length) - { - aResult.push({ - 'id': '---', - 'name': '---', - 'system': false, - 'seporator': true, - 'disabled': true - }); - } - - bSep = false; - aResult.push({ - 'id': oItem.fullNameRaw, - 'name': fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name(), - 'system': true, - 'seporator': false, - 'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) || - (fDisableCallback ? fDisableCallback.call(null, oItem) : false) - }); - } - } - - bSep = true; - for (iIndex = 0, iLen = aList.length; iIndex < iLen; iIndex++) - { - oItem = aList[iIndex]; - if (oItem.subScribed() || !oItem.existen) - { - if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true) - { - if (Enums.FolderType.User === oItem.type() || !bSystem || 0 < oItem.subFolders().length) - { - if (bSep && 0 < aResult.length) - { - aResult.push({ - 'id': '---', - 'name': '---', - 'system': false, - 'seporator': true, - 'disabled': true - }); - } - - bSep = false; - aResult.push({ - 'id': oItem.fullNameRaw, - 'name': (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) + - (fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name()), - 'system': false, - 'seporator': false, - 'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) || - (fDisableCallback ? fDisableCallback.call(null, oItem) : false) - }); - } - } - } - - if (oItem.subScribed() && 0 < oItem.subFolders().length) - { - aResult = aResult.concat(Utils.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [], - iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible)); - } - } - - return aResult; - }; - - Utils.computedPagenatorHelper = function (koCurrentPage, koPageCount) - { - return function() { - - var - iPrev = 0, - iNext = 0, - iLimit = 2, - aResult = [], - iCurrentPage = koCurrentPage(), - iPageCount = koPageCount(), - - /** - * @param {number} iIndex - * @param {boolean=} bPush = true - * @param {string=} sCustomName = '' - */ - fAdd = function (iIndex, bPush, sCustomName) { - - var oData = { - 'current': iIndex === iCurrentPage, - 'name': Utils.isUnd(sCustomName) ? iIndex.toString() : sCustomName.toString(), - 'custom': Utils.isUnd(sCustomName) ? false : true, - 'title': Utils.isUnd(sCustomName) ? '' : iIndex.toString(), - 'value': iIndex.toString() - }; - - if (Utils.isUnd(bPush) ? true : !!bPush) - { - aResult.push(oData); - } - else - { - aResult.unshift(oData); - } - } - ; - - if (1 < iPageCount || (0 < iPageCount && iPageCount < iCurrentPage)) - // if (0 < iPageCount && 0 < iCurrentPage) - { - if (iPageCount < iCurrentPage) - { - fAdd(iPageCount); - iPrev = iPageCount; - iNext = iPageCount; - } - else - { - if (3 >= iCurrentPage || iPageCount - 2 <= iCurrentPage) - { - iLimit += 2; - } - - fAdd(iCurrentPage); - iPrev = iCurrentPage; - iNext = iCurrentPage; - } - - while (0 < iLimit) { - - iPrev -= 1; - iNext += 1; - - if (0 < iPrev) - { - fAdd(iPrev, false); - iLimit--; - } - - if (iPageCount >= iNext) - { - fAdd(iNext, true); - iLimit--; - } - else if (0 >= iPrev) - { - break; - } - } - - if (3 === iPrev) - { - fAdd(2, false); - } - else if (3 < iPrev) - { - fAdd(window.Math.round((iPrev - 1) / 2), false, '...'); - } - - if (iPageCount - 2 === iNext) - { - fAdd(iPageCount - 1, true); - } - else if (iPageCount - 2 > iNext) - { - fAdd(window.Math.round((iPageCount + iNext) / 2), true, '...'); - } - - // first and last - if (1 < iPrev) - { - fAdd(1, false); - } - - if (iPageCount > iNext) - { - fAdd(iPageCount, true); - } - } - - return aResult; - }; - }; - - Utils.selectElement = function (element) - { - var sel, range; - if (window.getSelection) - { - sel = window.getSelection(); - sel.removeAllRanges(); - range = window.document.createRange(); - range.selectNodeContents(element); - sel.addRange(range); - } - else if (window.document.selection) - { - range = window.document.body.createTextRange(); - range.moveToElementText(element); - range.select(); - } - }; - - Utils.detectDropdownVisibility = _.debounce(function () { - Globals.dropdownVisibility(!!_.find(Globals.aBootstrapDropdowns, function (oItem) { - return oItem.hasClass('open'); - })); - }, 50); - - /** - * @param {boolean=} bDelay = false - */ - Utils.triggerAutocompleteInputChange = function (bDelay) { - - var fFunc = function () { - $('.checkAutocomplete').trigger('change'); - }; - - if (Utils.isUnd(bDelay) ? false : !!bDelay) - { - _.delay(fFunc, 100); - } - else - { - fFunc(); - } - }; - - module.exports = Utils; - -}(module, require)); -},{"$":14,"App:Knoin":21,"Consts":5,"Enums":6,"Globals":8,"Model:Email":26,"_":19,"ko":16,"window":20}],12:[function(require,module,exports){ -module.exports = crossroads; -},{}],13:[function(require,module,exports){ -module.exports = hasher; -},{}],14:[function(require,module,exports){ -module.exports = $; -},{}],15:[function(require,module,exports){ -module.exports = key; -},{}],16:[function(require,module,exports){ - -(function (module, ko) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$') - ; - - ko.bindingHandlers.tooltip = { - 'init': function (oElement, fValueAccessor) { - - var - Globals = require('Globals'), - Utils = require('Utils') - ; - - if (!Globals.bMobileDevice) - { - var - $oEl = $(oElement), - sClass = $oEl.data('tooltip-class') || '', - sPlacement = $oEl.data('tooltip-placement') || 'top' - ; - - $oEl.tooltip({ - 'delay': { - 'show': 500, - 'hide': 100 - }, - 'html': true, - 'container': 'body', - 'placement': sPlacement, - 'trigger': 'hover', - 'title': function () { - return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' : '' + - Utils.i18n(ko.utils.unwrapObservable(fValueAccessor())) + ''; - } - }).click(function () { - $oEl.tooltip('hide'); - }); - - Globals.tooltipTrigger.subscribe(function () { - $oEl.tooltip('hide'); - }); - } - } - }; - - ko.bindingHandlers.tooltip2 = { - 'init': function (oElement, fValueAccessor) { - var - Globals = require('Globals'), - $oEl = $(oElement), - sClass = $oEl.data('tooltip-class') || '', - sPlacement = $oEl.data('tooltip-placement') || 'top' - ; - - $oEl.tooltip({ - 'delay': { - 'show': 500, - 'hide': 100 - }, - 'html': true, - 'container': 'body', - 'placement': sPlacement, - 'title': function () { - return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' : - '' + fValueAccessor()() + ''; - } - }).click(function () { - $oEl.tooltip('hide'); - }); - - Globals.tooltipTrigger.subscribe(function () { - $oEl.tooltip('hide'); - }); - } - }; - - ko.bindingHandlers.tooltip3 = { - 'init': function (oElement) { - - var - $oEl = $(oElement), - Globals = require('Globals') - ; - - $oEl.tooltip({ - 'container': 'body', - 'trigger': 'hover manual', - 'title': function () { - return $oEl.data('tooltip3-data') || ''; - } - }); - - $(window.document).click(function () { - $oEl.tooltip('hide'); - }); - - Globals.tooltipTrigger.subscribe(function () { - $oEl.tooltip('hide'); - }); - }, - 'update': function (oElement, fValueAccessor) { - var sValue = ko.utils.unwrapObservable(fValueAccessor()); - if ('' === sValue) - { - $(oElement).data('tooltip3-data', '').tooltip('hide'); - } - else - { - $(oElement).data('tooltip3-data', sValue).tooltip('show'); - } - } - }; - - ko.bindingHandlers.registrateBootstrapDropdown = { - 'init': function (oElement) { - var Globals = require('Globals'); - Globals.aBootstrapDropdowns.push($(oElement)); - } - }; - - ko.bindingHandlers.openDropdownTrigger = { - 'update': function (oElement, fValueAccessor) { - if (ko.utils.unwrapObservable(fValueAccessor())) - { - var - $el = $(oElement), - Utils = require('Utils') - ; - - if (!$el.hasClass('open')) - { - $el.find('.dropdown-toggle').dropdown('toggle'); - Utils.detectDropdownVisibility(); - } - - fValueAccessor()(false); - } - } - }; - - ko.bindingHandlers.dropdownCloser = { - 'init': function (oElement) { - $(oElement).closest('.dropdown').on('click', '.e-item', function () { - $(oElement).dropdown('toggle'); - }); - } - }; - - ko.bindingHandlers.popover = { - 'init': function (oElement, fValueAccessor) { - $(oElement).popover(ko.utils.unwrapObservable(fValueAccessor())); - } - }; - - ko.bindingHandlers.csstext = { - 'init': function (oElement, fValueAccessor) { - var Utils = require('Utils'); - if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText)) - { - oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor()); - } - else - { - $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); - } - }, - 'update': function (oElement, fValueAccessor) { - var Utils = require('Utils'); - if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText)) - { - oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor()); - } - else - { - $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); - } - } - }; - - ko.bindingHandlers.resizecrop = { - 'init': function (oElement) { - $(oElement).addClass('resizecrop').resizecrop({ - 'width': '100', - 'height': '100', - 'wrapperCSS': { - 'border-radius': '10px' - } - }); - }, - 'update': function (oElement, fValueAccessor) { - fValueAccessor()(); - $(oElement).resizecrop({ - 'width': '100', - 'height': '100' - }); - } - }; - - ko.bindingHandlers.onEnter = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { - $(oElement).on('keypress', function (oEvent) { - if (oEvent && 13 === window.parseInt(oEvent.keyCode, 10)) - { - $(oElement).trigger('change'); - fValueAccessor().call(oViewModel); - } - }); - } - }; - - ko.bindingHandlers.onEsc = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { - $(oElement).on('keypress', function (oEvent) { - if (oEvent && 27 === window.parseInt(oEvent.keyCode, 10)) - { - $(oElement).trigger('change'); - fValueAccessor().call(oViewModel); - } - }); - } - }; - - ko.bindingHandlers.clickOnTrue = { - 'update': function (oElement, fValueAccessor) { - if (ko.utils.unwrapObservable(fValueAccessor())) - { - $(oElement).click(); - } - } - }; - - ko.bindingHandlers.modal = { - 'init': function (oElement, fValueAccessor) { - - var - Globals = require('Globals'), - Utils = require('Utils') - ; - - $(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({ - 'keyboard': false, - 'show': ko.utils.unwrapObservable(fValueAccessor()) - }) - .on('shown', function () { - Utils.windowResize(); - }) - .find('.close').click(function () { - fValueAccessor()(false); - }); - - }, - 'update': function (oElement, fValueAccessor) { - $(oElement).modal(ko.utils.unwrapObservable(fValueAccessor()) ? 'show' : 'hide'); - } - }; - - ko.bindingHandlers.i18nInit = { - 'init': function (oElement) { - var Utils = require('Utils'); - Utils.i18nToNode(oElement); - } - }; - - ko.bindingHandlers.i18nUpdate = { - 'update': function (oElement, fValueAccessor) { - var Utils = require('Utils'); - ko.utils.unwrapObservable(fValueAccessor()); - Utils.i18nToNode(oElement); - } - }; - - ko.bindingHandlers.link = { - 'update': function (oElement, fValueAccessor) { - $(oElement).attr('href', ko.utils.unwrapObservable(fValueAccessor())); - } - }; - - ko.bindingHandlers.title = { - 'update': function (oElement, fValueAccessor) { - $(oElement).attr('title', ko.utils.unwrapObservable(fValueAccessor())); - } - }; - - ko.bindingHandlers.textF = { - 'init': function (oElement, fValueAccessor) { - $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); - } - }; - - ko.bindingHandlers.initDom = { - 'init': function (oElement, fValueAccessor) { - fValueAccessor()(oElement); - } - }; - - ko.bindingHandlers.initResizeTrigger = { - 'init': function (oElement, fValueAccessor) { - var aValues = ko.utils.unwrapObservable(fValueAccessor()); - $(oElement).css({ - 'height': aValues[1], - 'min-height': aValues[1] - }); - }, - 'update': function (oElement, fValueAccessor) { - - var - Utils = require('Utils'), - Globals = require('Globals'), - aValues = ko.utils.unwrapObservable(fValueAccessor()), - iValue = Utils.pInt(aValues[1]), - iSize = 0, - iOffset = $(oElement).offset().top - ; - - if (0 < iOffset) - { - iOffset += Utils.pInt(aValues[2]); - iSize = Globals.$win.height() - iOffset; - - if (iValue < iSize) - { - iValue = iSize; - } - - $(oElement).css({ - 'height': iValue, - 'min-height': iValue - }); - } - } - }; - - ko.bindingHandlers.appendDom = { - 'update': function (oElement, fValueAccessor) { - $(oElement).hide().empty().append(ko.utils.unwrapObservable(fValueAccessor())).show(); - } - }; - - ko.bindingHandlers.draggable = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor) { - var - Globals = require('Globals'), - Utils = require('Utils') - ; - if (!Globals.bMobileDevice) - { - var - iTriggerZone = 100, - iScrollSpeed = 3, - fAllValueFunc = fAllBindingsAccessor(), - sDroppableSelector = fAllValueFunc && fAllValueFunc['droppableSelector'] ? fAllValueFunc['droppableSelector'] : '', - oConf = { - 'distance': 20, - 'handle': '.dragHandle', - 'cursorAt': {'top': 22, 'left': 3}, - 'refreshPositions': true, - 'scroll': true - } - ; - - if (sDroppableSelector) - { - oConf['drag'] = function (oEvent) { - - $(sDroppableSelector).each(function () { - var - moveUp = null, - moveDown = null, - $this = $(this), - oOffset = $this.offset(), - bottomPos = oOffset.top + $this.height() - ; - - window.clearInterval($this.data('timerScroll')); - $this.data('timerScroll', false); - - if (oEvent.pageX >= oOffset.left && oEvent.pageX <= oOffset.left + $this.width()) - { - if (oEvent.pageY >= bottomPos - iTriggerZone && oEvent.pageY <= bottomPos) - { - moveUp = function() { - $this.scrollTop($this.scrollTop() + iScrollSpeed); - Utils.windowResize(); - }; - - $this.data('timerScroll', window.setInterval(moveUp, 10)); - moveUp(); - } - - if (oEvent.pageY >= oOffset.top && oEvent.pageY <= oOffset.top + iTriggerZone) - { - moveDown = function() { - $this.scrollTop($this.scrollTop() - iScrollSpeed); - Utils.windowResize(); - }; - - $this.data('timerScroll', window.setInterval(moveDown, 10)); - moveDown(); - } - } - }); - }; - - oConf['stop'] = function() { - $(sDroppableSelector).each(function () { - window.clearInterval($(this).data('timerScroll')); - $(this).data('timerScroll', false); - }); - }; - } - - oConf['helper'] = function (oEvent) { - return fValueAccessor()(oEvent && oEvent.target ? ko.dataFor(oEvent.target) : null); - }; - - $(oElement).draggable(oConf).on('mousedown', function () { - Utils.removeInFocus(); - }); - } - } - }; - - ko.bindingHandlers.droppable = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor) { - var Globals = require('Globals'); - if (!Globals.bMobileDevice) - { - var - fValueFunc = fValueAccessor(), - fAllValueFunc = fAllBindingsAccessor(), - fOverCallback = fAllValueFunc && fAllValueFunc['droppableOver'] ? fAllValueFunc['droppableOver'] : null, - fOutCallback = fAllValueFunc && fAllValueFunc['droppableOut'] ? fAllValueFunc['droppableOut'] : null, - oConf = { - 'tolerance': 'pointer', - 'hoverClass': 'droppableHover' - } - ; - - if (fValueFunc) - { - oConf['drop'] = function (oEvent, oUi) { - fValueFunc(oEvent, oUi); - }; - - if (fOverCallback) - { - oConf['over'] = function (oEvent, oUi) { - fOverCallback(oEvent, oUi); - }; - } - - if (fOutCallback) - { - oConf['out'] = function (oEvent, oUi) { - fOutCallback(oEvent, oUi); - }; - } - - $(oElement).droppable(oConf); - } - } - } - }; - - ko.bindingHandlers.nano = { - 'init': function (oElement) { - var Globals = require('Globals'); - if (!Globals.bDisableNanoScroll) - { - $(oElement) - .addClass('nano') - .nanoScroller({ - 'iOSNativeScrolling': false, - 'preventPageScrolling': true - }) - ; - } - } - }; - - ko.bindingHandlers.saveTrigger = { - 'init': function (oElement) { - - var $oEl = $(oElement); - - $oEl.data('save-trigger-type', $oEl.is('input[type=text],input[type=email],input[type=password],select,textarea') ? 'input' : 'custom'); - - if ('custom' === $oEl.data('save-trigger-type')) - { - $oEl.append( - '  ' - ).addClass('settings-saved-trigger'); - } - else - { - $oEl.addClass('settings-saved-trigger-input'); - } - }, - 'update': function (oElement, fValueAccessor) { - var - mValue = ko.utils.unwrapObservable(fValueAccessor()), - $oEl = $(oElement) - ; - - if ('custom' === $oEl.data('save-trigger-type')) - { - switch (mValue.toString()) - { - case '1': - $oEl - .find('.animated,.error').hide().removeClass('visible') - .end() - .find('.success').show().addClass('visible') - ; - break; - case '0': - $oEl - .find('.animated,.success').hide().removeClass('visible') - .end() - .find('.error').show().addClass('visible') - ; - break; - case '-2': - $oEl - .find('.error,.success').hide().removeClass('visible') - .end() - .find('.animated').show().addClass('visible') - ; - break; - default: - $oEl - .find('.animated').hide() - .end() - .find('.error,.success').removeClass('visible') - ; - break; - } - } - else - { - switch (mValue.toString()) - { - case '1': - $oEl.addClass('success').removeClass('error'); - break; - case '0': - $oEl.addClass('error').removeClass('success'); - break; - case '-2': - // $oEl; - break; - default: - $oEl.removeClass('error success'); - break; - } - } - } - }; - - ko.bindingHandlers.emailsTags = { - 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { - - var - Utils = require('Utils'), - EmailModel = require('Model:Email'), - - $oEl = $(oElement), - fValue = fValueAccessor(), - fAllBindings = fAllBindingsAccessor(), - fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null, - fFocusCallback = function (bValue) { - if (fValue && fValue.focusTrigger) - { - fValue.focusTrigger(bValue); - } - } - ; - - $oEl.inputosaurus({ - 'parseOnBlur': true, - 'allowDragAndDrop': true, - 'focusCallback': fFocusCallback, - 'inputDelimiters': [',', ';'], - 'autoCompleteSource': fAutoCompleteSource, - 'parseHook': function (aInput) { - return _.map(aInput, function (sInputValue) { - - var - sValue = Utils.trim(sInputValue), - oEmail = null - ; - - if ('' !== sValue) - { - oEmail = new EmailModel(); - oEmail.mailsoParse(sValue); - oEmail.clearDuplicateName(); - return [oEmail.toLine(false), oEmail]; - } - - return [sValue, null]; - - }); - }, - 'change': _.bind(function (oEvent) { - $oEl.data('EmailsTagsValue', oEvent.target.value); - fValue(oEvent.target.value); - }, this) - }); - }, - 'update': function (oElement, fValueAccessor, fAllBindingsAccessor) { - - var - $oEl = $(oElement), - fAllValueFunc = fAllBindingsAccessor(), - fEmailsTagsFilter = fAllValueFunc['emailsTagsFilter'] || null, - sValue = ko.utils.unwrapObservable(fValueAccessor()) - ; - - if ($oEl.data('EmailsTagsValue') !== sValue) - { - $oEl.val(sValue); - $oEl.data('EmailsTagsValue', sValue); - $oEl.inputosaurus('refresh'); - } - - if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter)) - { - $oEl.inputosaurus('focus'); - } - } - }; - - ko.bindingHandlers.contactTags = { - 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { - - var - Utils = require('Utils'), - ContactTagModel = require('Model:ContactTag'), - - $oEl = $(oElement), - fValue = fValueAccessor(), - fAllBindings = fAllBindingsAccessor(), - fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null, - fFocusCallback = function (bValue) { - if (fValue && fValue.focusTrigger) - { - fValue.focusTrigger(bValue); - } - } - ; - - $oEl.inputosaurus({ - 'parseOnBlur': true, - 'allowDragAndDrop': false, - 'focusCallback': fFocusCallback, - 'inputDelimiters': [',', ';'], - 'outputDelimiter': ',', - 'autoCompleteSource': fAutoCompleteSource, - '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('ContactTagsValue', oEvent.target.value); - fValue(oEvent.target.value); - }, this) - }); - }, - 'update': function (oElement, fValueAccessor, fAllBindingsAccessor) { - - var - $oEl = $(oElement), - fAllValueFunc = fAllBindingsAccessor(), - fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null, - sValue = ko.utils.unwrapObservable(fValueAccessor()) - ; - - if ($oEl.data('ContactTagsValue') !== sValue) - { - $oEl.val(sValue); - $oEl.data('ContactTagsValue', sValue); - $oEl.inputosaurus('refresh'); - } - - if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter)) - { - $oEl.inputosaurus('focus'); - } - } - }; - - ko.bindingHandlers.command = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { - var - jqElement = $(oElement), - oCommand = fValueAccessor() - ; - - if (!oCommand || !oCommand.enabled || !oCommand.canExecute) - { - throw new Error('You are not using command function'); - } - - jqElement.addClass('command'); - ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click'].init.apply(oViewModel, arguments); - }, - - 'update': function (oElement, fValueAccessor) { - - var - bResult = true, - jqElement = $(oElement), - oCommand = fValueAccessor() - ; - - bResult = oCommand.enabled(); - jqElement.toggleClass('command-not-enabled', !bResult); - - if (bResult) - { - bResult = oCommand.canExecute(); - jqElement.toggleClass('command-can-not-be-execute', !bResult); - } - - jqElement.toggleClass('command-disabled disable disabled', !bResult).toggleClass('no-disabled', !!bResult); - - if (jqElement.is('input') || jqElement.is('button')) - { - jqElement.prop('disabled', !bResult); - } - } - }; - - ko.extenders.trimmer = function (oTarget) - { - var - Utils = require('Utils'), - oResult = ko.computed({ - 'read': oTarget, - 'write': function (sNewValue) { - oTarget(Utils.trim(sNewValue.toString())); - }, - 'owner': this - }) - ; - - oResult(oTarget()); - return oResult; - }; - - ko.extenders.posInterer = function (oTarget, iDefault) - { - var - Utils = require('Utils'), - oResult = ko.computed({ - 'read': oTarget, - 'write': function (sNewValue) { - var iNew = Utils.pInt(sNewValue.toString(), iDefault); - if (0 >= iNew) - { - iNew = iDefault; - } - - if (iNew === oTarget() && '' + iNew !== '' + sNewValue) - { - oTarget(iNew + 1); - } - - oTarget(iNew); - } - }) - ; - - oResult(oTarget()); - return oResult; - }; - - ko.extenders.reversible = function (oTarget) - { - var mValue = oTarget(); - - oTarget.commit = function () - { - mValue = oTarget(); - }; - - oTarget.reverse = function () - { - oTarget(mValue); - }; - - oTarget.commitedValue = function () - { - return mValue; - }; - - return oTarget; - }; - - ko.extenders.toggleSubscribe = function (oTarget, oOptions) - { - oTarget.subscribe(oOptions[1], oOptions[0], 'beforeChange'); - oTarget.subscribe(oOptions[2], oOptions[0]); - - return oTarget; - }; - - ko.extenders.falseTimeout = function (oTarget, iOption) - { - var Utils = require('Utils'); - - oTarget.iTimeout = 0; - oTarget.subscribe(function (bValue) { - if (bValue) - { - window.clearTimeout(oTarget.iTimeout); - oTarget.iTimeout = window.setTimeout(function () { - oTarget(false); - oTarget.iTimeout = 0; - }, Utils.pInt(iOption)); - } - }); - - return oTarget; - }; - - ko.observable.fn.validateNone = function () - { - this.hasError = ko.observable(false); - return this; - }; - - ko.observable.fn.validateEmail = function () - { - var Utils = require('Utils'); - - this.hasError = ko.observable(false); - - this.subscribe(function (sValue) { - sValue = Utils.trim(sValue); - this.hasError('' !== sValue && !(/^[^@\s]+@[^@\s]+$/.test(sValue))); - }, this); - - this.valueHasMutated(); - return this; - }; - - ko.observable.fn.validateSimpleEmail = function () - { - var Utils = require('Utils'); - - this.hasError = ko.observable(false); - - this.subscribe(function (sValue) { - sValue = Utils.trim(sValue); - this.hasError('' !== sValue && !(/^.+@.+$/.test(sValue))); - }, this); - - this.valueHasMutated(); - return this; - }; - - ko.observable.fn.validateFunc = function (fFunc) - { - var Utils = require('Utils'); - - this.hasFuncError = ko.observable(false); - - if (Utils.isFunc(fFunc)) - { - this.subscribe(function (sValue) { - this.hasFuncError(!fFunc(sValue)); + AbstractData.call(this); + + this.domainsLoading = ko.observable(false).extend({'throttle': 100}); + this.domains = ko.observableArray([]); + + this.pluginsLoading = ko.observable(false).extend({'throttle': 100}); + this.plugins = ko.observableArray([]); + + this.packagesReal = ko.observable(true); + this.packagesMainUpdatable = ko.observable(true); + this.packagesLoading = ko.observable(false).extend({'throttle': 100}); + this.packages = ko.observableArray([]); + + this.coreReal = ko.observable(true); + this.coreUpdatable = ko.observable(true); + this.coreAccess = ko.observable(true); + this.coreChecking = ko.observable(false).extend({'throttle': 100}); + this.coreUpdating = ko.observable(false).extend({'throttle': 100}); + this.coreRemoteVersion = ko.observable(''); + this.coreRemoteRelease = ko.observable(''); + this.coreVersionCompare = ko.observable(-2); + + this.licensing = ko.observable(false); + this.licensingProcess = ko.observable(false); + this.licenseValid = ko.observable(false); + this.licenseExpired = ko.observable(0); + this.licenseError = ko.observable(''); + + this.licenseTrigger = ko.observable(false); + + this.adminManLoading = ko.computed(function () { + return '000' !== [this.domainsLoading() ? '1' : '0', this.pluginsLoading() ? '1' : '0', this.packagesLoading() ? '1' : '0'].join(''); }, this); - this.valueHasMutated(); + this.adminManLoadingVisibility = ko.computed(function () { + return this.adminManLoading() ? 'visible' : 'hidden'; + }, this).extend({'rateLimit': 300}); } - return this; - }; + _.extend(AdminDataStorage.prototype, AbstractData.prototype); - module.exports = ko; - -}(module, ko)); - -},{"$":14,"Globals":8,"Model:ContactTag":25,"Model:Email":26,"Utils":11,"_":19,"window":20}],17:[function(require,module,exports){ -module.exports = moment; -},{}],18:[function(require,module,exports){ -module.exports = ssm; -},{}],19:[function(require,module,exports){ -module.exports = _; -},{}],20:[function(require,module,exports){ -module.exports = window; -},{}],21:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - $ = require('$'), - ko = require('ko'), - hasher = require('hasher'), - crossroads = require('crossroads'), - - Globals = require('Globals'), - Plugins = require('Plugins'), - Utils = require('Utils') - ; - - /** - * @constructor - */ - function Knoin() - { - this.oScreens = {}; - this.sDefaultScreenName = ''; - this.oCurrentScreen = null; - } - - Knoin.prototype.oScreens = {}; - Knoin.prototype.sDefaultScreenName = ''; - Knoin.prototype.oCurrentScreen = null; - - Knoin.prototype.hideLoading = function () - { - $('#rl-loading').hide(); - }; - - /** - * @param {Object} thisObject - */ - Knoin.prototype.constructorEnd = function (thisObject) - { - if (Utils.isFunc(thisObject['__constructor_end'])) + AdminDataStorage.prototype.populateDataOnStart = function() { - thisObject['__constructor_end'].call(thisObject); - } - }; - - /** - * @param {string|Array} mName - * @param {Function} ViewModelClass - */ - Knoin.prototype.extendAsViewModel = function (mName, ViewModelClass) - { - if (ViewModelClass) - { - if (Utils.isArray(mName)) - { - ViewModelClass.__names = mName; - } - else - { - ViewModelClass.__names = [mName]; - } - - ViewModelClass.__name = ViewModelClass.__names[0]; - } - }; - - /** - * @param {Function} SettingsViewModelClass - * @param {string} sLabelName - * @param {string} sTemplate - * @param {string} sRoute - * @param {boolean=} bDefault - */ - Knoin.prototype.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute, bDefault) - { - SettingsViewModelClass.__rlSettingsData = { - 'Label': sLabelName, - 'Template': sTemplate, - 'Route': sRoute, - 'IsDefault': !!bDefault + AbstractData.prototype.populateDataOnStart.call(this); }; - Globals.aViewModels['settings'].push(SettingsViewModelClass); - }; + module.exports = new AdminDataStorage(); - /** - * @param {Function} SettingsViewModelClass - */ - Knoin.prototype.removeSettingsViewModel = function (SettingsViewModelClass) - { - Globals.aViewModels['settings-removed'].push(SettingsViewModelClass); - }; + }()); - /** - * @param {Function} SettingsViewModelClass - */ - Knoin.prototype.disableSettingsViewModel = function (SettingsViewModelClass) - { - Globals.aViewModels['settings-disabled'].push(SettingsViewModelClass); - }; +/***/ }, - Knoin.prototype.routeOff = function () - { - hasher.changed.active = false; - }; +/***/ 29: +/*!***********************************************!*\ + !*** ./dev/Screens/AbstractSettingsScreen.js ***! + \***********************************************/ +/***/ function(module, exports, __webpack_require__) { - Knoin.prototype.routeOn = function () - { - hasher.changed.active = true; - }; + + (function () { - /** - * @param {string} sScreenName - * @return {?Object} - */ - Knoin.prototype.screen = function (sScreenName) - { - return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null; - }; + 'use strict'; - /** - * @param {Function} ViewModelClass - * @param {Object=} oScreen - */ - Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen) - { - if (ViewModelClass && !ViewModelClass.__builded) + var + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractScreen = __webpack_require__(/*! Knoin:AbstractScreen */ 24) + ; + + /** + * @constructor + * @param {Array} aViewModels + * @extends KnoinAbstractScreen + */ + function AbstractSettingsScreen(aViewModels) + { + KnoinAbstractScreen.call(this, 'settings', aViewModels); + + this.menu = ko.observableArray([]); + + this.oCurrentSubScreen = null; + this.oViewModelPlace = null; + + this.setupSettings(); + } + + _.extend(AbstractSettingsScreen.prototype, KnoinAbstractScreen.prototype); + + /** + * @param {Function=} fCallback + */ + AbstractSettingsScreen.prototype.setupSettings = function (fCallback) + { + if (fCallback) + { + fCallback(); + } + }; + + AbstractSettingsScreen.prototype.onRoute = function (sSubName) { var - kn = this, - oViewModel = new ViewModelClass(oScreen), - sPosition = oViewModel.viewModelPosition(), - oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()), + self = this, + oSettingsScreen = null, + RoutedSettingsViewModel = null, + oViewModelPlace = null, oViewModelDom = null ; - ViewModelClass.__builded = true; - ViewModelClass.__vm = oViewModel; - - oViewModel.viewModelName = ViewModelClass.__name; - oViewModel.viewModelNames = ViewModelClass.__names; - - if (oViewModelPlace && 1 === oViewModelPlace.length) - { - oViewModelDom = $('
').addClass('rl-view-model').addClass('RL-' + oViewModel.viewModelTemplate()).hide(); - oViewModelDom.appendTo(oViewModelPlace); - - oViewModel.viewModelDom = oViewModelDom; - ViewModelClass.__dom = oViewModelDom; - - if ('Popups' === sPosition) - { - oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, function () { - kn.hideScreenPopup(ViewModelClass); - }); - - oViewModel.modalVisibility.subscribe(function (bValue) { - - var self = this; - if (bValue) - { - this.viewModelDom.show(); - this.storeAndSetKeyScope(); - - Globals.popupVisibilityNames.push(this.viewModelName); - oViewModel.viewModelDom.css('z-index', 3000 + Globals.popupVisibilityNames().length + 10); - - Utils.delegateRun(this, 'onFocus', [], 500); - } - else - { - Utils.delegateRun(this, 'onHide'); - this.restoreKeyScope(); - - _.each(this.viewModelNames, function (sName) { - Plugins.runHook('view-model-on-hide', [sName, self]); - }); - - Globals.popupVisibilityNames.remove(this.viewModelName); - oViewModel.viewModelDom.css('z-index', 2000); - - Globals.tooltipTrigger(!Globals.tooltipTrigger()); - - _.delay(function () { - self.viewModelDom.hide(); - }, 300); - } - - }, oViewModel); - } - - _.each(ViewModelClass.__names, function (sName) { - Plugins.runHook('view-model-pre-build', [sName, oViewModel, oViewModelDom]); - }); - - ko.applyBindingAccessorsToNode(oViewModelDom[0], { - 'i18nInit': true, - 'template': function () { return {'name': oViewModel.viewModelTemplate()};} - }, oViewModel); - - Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]); - if (oViewModel && 'Popups' === sPosition) - { - oViewModel.registerPopupKeyDown(); - } - - _.each(ViewModelClass.__names, function (sName) { - Plugins.runHook('view-model-post-build', [sName, oViewModel, oViewModelDom]); - }); - } - else - { - Utils.log('Cannot find view model position: ' + sPosition); - } - } - - return ViewModelClass ? ViewModelClass.__vm : null; - }; - - /** - * @param {Function} ViewModelClassToHide - */ - Knoin.prototype.hideScreenPopup = function (ViewModelClassToHide) - { - if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) - { - ViewModelClassToHide.__vm.modalVisibility(false); - } - }; - - /** - * @param {Function} ViewModelClassToShow - * @param {Array=} aParameters - */ - Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters) - { - if (ViewModelClassToShow) - { - this.buildViewModel(ViewModelClassToShow); - - if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom) - { - ViewModelClassToShow.__vm.modalVisibility(true); - Utils.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []); - - _.each(ViewModelClassToShow.__names, function (sName) { - Plugins.runHook('view-model-on-show', [sName, ViewModelClassToShow.__vm, aParameters || []]); - }); - } - } - }; - - /** - * @param {Function} ViewModelClassToShow - * @return {boolean} - */ - Knoin.prototype.isPopupVisible = function (ViewModelClassToShow) - { - return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false; - }; - - /** - * @param {string} sScreenName - * @param {string} sSubPart - */ - Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart) - { - var - self = this, - oScreen = null, - oCross = null - ; - - if ('' === Utils.pString(sScreenName)) - { - sScreenName = this.sDefaultScreenName; - } - - if ('' !== sScreenName) - { - oScreen = this.screen(sScreenName); - if (!oScreen) - { - oScreen = this.screen(this.sDefaultScreenName); - if (oScreen) - { - sSubPart = sScreenName + '/' + sSubPart; - sScreenName = this.sDefaultScreenName; - } - } - - if (oScreen && oScreen.__started) - { - if (!oScreen.__builded) - { - oScreen.__builded = true; - - if (Utils.isNonEmptyArray(oScreen.viewModels())) - { - _.each(oScreen.viewModels(), function (ViewModelClass) { - this.buildViewModel(ViewModelClass, oScreen); - }, this); - } - - Utils.delegateRun(oScreen, 'onBuild'); - } - - _.defer(function () { - - // hide screen - if (self.oCurrentScreen) - { - Utils.delegateRun(self.oCurrentScreen, 'onHide'); - - if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels())) - { - _.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) { - - if (ViewModelClass.__vm && ViewModelClass.__dom && - 'Popups' !== ViewModelClass.__vm.viewModelPosition()) - { - ViewModelClass.__dom.hide(); - ViewModelClass.__vm.viewModelVisibility(false); - Utils.delegateRun(ViewModelClass.__vm, 'onHide'); - } - - }); - } - } - // -- - - self.oCurrentScreen = oScreen; - - // show screen - if (self.oCurrentScreen) - { - Utils.delegateRun(self.oCurrentScreen, 'onShow'); - - Plugins.runHook('screen-on-show', [self.oCurrentScreen.screenName(), self.oCurrentScreen]); - - if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels())) - { - _.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) { - - if (ViewModelClass.__vm && ViewModelClass.__dom && - 'Popups' !== ViewModelClass.__vm.viewModelPosition()) - { - ViewModelClass.__dom.show(); - ViewModelClass.__vm.viewModelVisibility(true); - - Utils.delegateRun(ViewModelClass.__vm, 'onShow'); - Utils.delegateRun(ViewModelClass.__vm, 'onFocus', [], 200); - - _.each(ViewModelClass.__names, function (sName) { - Plugins.runHook('view-model-on-show', [sName, ViewModelClass.__vm]); - }); - } - - }, self); - } - } - // -- - - oCross = oScreen.__cross ? oScreen.__cross() : null; - if (oCross) - { - oCross.parse(sSubPart); - } - }); - } - } - }; - - /** - * @param {Array} aScreensClasses - */ - Knoin.prototype.startScreens = function (aScreensClasses) - { - $('#rl-content').css({ - 'visibility': 'hidden' - }); - - _.each(aScreensClasses, function (CScreen) { - - var - oScreen = new CScreen(), - sScreenName = oScreen ? oScreen.screenName() : '' - ; - - if (oScreen && '' !== sScreenName) - { - if ('' === this.sDefaultScreenName) - { - this.sDefaultScreenName = sScreenName; - } - - this.oScreens[sScreenName] = oScreen; - } - - }, this); - - - _.each(this.oScreens, function (oScreen) { - if (oScreen && !oScreen.__started && oScreen.__start) - { - 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]); - } - }, this); - - var oCross = crossroads.create(); - oCross.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/, _.bind(this.screenOnRoute, this)); - - hasher.initialized.add(oCross.parse, oCross); - hasher.changed.add(oCross.parse, oCross); - hasher.init(); - - $('#rl-content').css({ - 'visibility': 'visible' - }); - - _.delay(function () { - Globals.$html.removeClass('rl-started-trigger').addClass('rl-started'); - }, 50); - }; - - /** - * @param {string} sHash - * @param {boolean=} bSilence = false - * @param {boolean=} bReplace = false - */ - Knoin.prototype.setHash = function (sHash, bSilence, bReplace) - { - sHash = '#' === sHash.substr(0, 1) ? sHash.substr(1) : sHash; - sHash = '/' === sHash.substr(0, 1) ? sHash.substr(1) : sHash; - - bReplace = Utils.isUnd(bReplace) ? false : !!bReplace; - - if (Utils.isUnd(bSilence) ? false : !!bSilence) - { - hasher.changed.active = false; - hasher[bReplace ? 'replaceHash' : 'setHash'](sHash); - hasher.changed.active = true; - } - else - { - hasher.changed.active = true; - hasher[bReplace ? 'replaceHash' : 'setHash'](sHash); - hasher.setHash(sHash); - } - }; - - module.exports = new Knoin(); - -}(module, require)); -},{"$":14,"Globals":8,"Plugins":10,"Utils":11,"_":19,"crossroads":12,"hasher":13,"ko":16}],22:[function(require,module,exports){ - -(function (module) { - - 'use strict'; - - /** - * @constructor - */ - function KnoinAbstractBoot() - { - - } - - KnoinAbstractBoot.prototype.bootstart = function () - { - - }; - - module.exports = KnoinAbstractBoot; - -}(module, require)); -},{}],23:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - crossroads = require('crossroads'), - - Utils = require('Utils') - ; - - /** - * @param {string} sScreenName - * @param {?=} aViewModels = [] - * @constructor - */ - function KnoinAbstractScreen(sScreenName, aViewModels) - { - this.sScreenName = sScreenName; - this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : []; - } - - /** - * @type {Array} - */ - KnoinAbstractScreen.prototype.oCross = null; - - /** - * @type {string} - */ - KnoinAbstractScreen.prototype.sScreenName = ''; - - /** - * @type {Array} - */ - KnoinAbstractScreen.prototype.aViewModels = []; - - /** - * @return {Array} - */ - KnoinAbstractScreen.prototype.viewModels = function () - { - return this.aViewModels; - }; - - /** - * @return {string} - */ - KnoinAbstractScreen.prototype.screenName = function () - { - return this.sScreenName; - }; - - KnoinAbstractScreen.prototype.routes = function () - { - return null; - }; - - /** - * @return {?Object} - */ - KnoinAbstractScreen.prototype.__cross = function () - { - return this.oCross; - }; - - KnoinAbstractScreen.prototype.__start = function () - { - var - aRoutes = this.routes(), - oRoute = null, - fMatcher = null - ; - - if (Utils.isNonEmptyArray(aRoutes)) - { - fMatcher = _.bind(this.onRoute || Utils.emptyFunction, this); - oRoute = crossroads.create(); - - _.each(aRoutes, function (aItem) { - oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1]; + RoutedSettingsViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) { + return SettingsViewModel && SettingsViewModel.__rlSettingsData && + sSubName === SettingsViewModel.__rlSettingsData.Route; }); - this.oCross = oRoute; - } - }; - - module.exports = KnoinAbstractScreen; - -}(module, require)); -},{"Utils":11,"_":19,"crossroads":12}],24:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - Globals = require('Globals') - ; - - /** - * @constructor - * @param {string=} sPosition = '' - * @param {string=} sTemplate = '' - */ - function KnoinAbstractViewModel(sPosition, sTemplate) - { - this.bDisabeCloseOnEsc = false; - this.sPosition = Utils.pString(sPosition); - this.sTemplate = Utils.pString(sTemplate); - - this.sDefaultKeyScope = Enums.KeyState.None; - this.sCurrentKeyScope = this.sDefaultKeyScope; - - this.viewModelVisibility = ko.observable(false); - this.modalVisibility = ko.observable(false).extend({'rateLimit': 0}); - - this.viewModelName = ''; - this.viewModelNames = []; - this.viewModelDom = null; - } - - /** - * @type {boolean} - */ - KnoinAbstractViewModel.prototype.bDisabeCloseOnEsc = false; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.sPosition = ''; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.sTemplate = ''; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.sDefaultKeyScope = Enums.KeyState.None; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.sCurrentKeyScope = Enums.KeyState.None; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.viewModelName = ''; - - /** - * @type {Array} - */ - KnoinAbstractViewModel.prototype.viewModelNames = []; - - /** - * @type {?} - */ - KnoinAbstractViewModel.prototype.viewModelDom = null; - - /** - * @return {string} - */ - KnoinAbstractViewModel.prototype.viewModelTemplate = function () - { - return this.sTemplate; - }; - - /** - * @return {string} - */ - KnoinAbstractViewModel.prototype.viewModelPosition = function () - { - return this.sPosition; - }; - - KnoinAbstractViewModel.prototype.cancelCommand = function () {}; - KnoinAbstractViewModel.prototype.closeCommand = function () {}; - - KnoinAbstractViewModel.prototype.storeAndSetKeyScope = function () - { - this.sCurrentKeyScope = Globals.keyScope(); - Globals.keyScope(this.sDefaultKeyScope); - }; - - KnoinAbstractViewModel.prototype.restoreKeyScope = function () - { - Globals.keyScope(this.sCurrentKeyScope); - }; - - KnoinAbstractViewModel.prototype.registerPopupKeyDown = function () - { - var self = this; - - Globals.$win.on('keydown', function (oEvent) { - if (oEvent && self.modalVisibility && self.modalVisibility()) + if (RoutedSettingsViewModel) { - if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode) + if (_.find(Globals.aViewModels['settings-removed'], function (DisabledSettingsViewModel) { + return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel; + })) { - Utils.delegateRun(self, 'cancelCommand'); - return false; + RoutedSettingsViewModel = null; } - else if (Enums.EventKeyCode.Backspace === oEvent.keyCode && !Utils.inFocus()) + + if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { + return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel; + })) { - return false; + RoutedSettingsViewModel = null; } } - return true; - }); - }; - - module.exports = KnoinAbstractViewModel; - -}(module, require)); -},{"Enums":6,"Globals":8,"Utils":11,"ko":16}],25:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Utils = require('Utils') - ; - - /** - * @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(); - }; - - module.exports = ContactTagModel; - -}(module, require)); -},{"Utils":11,"ko":16}],26:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - Utils = require('Utils') - ; - - /** - * @param {string=} sEmail - * @param {string=} sName - * - * @constructor - */ - function EmailModel(sEmail, sName) - { - this.email = sEmail || ''; - this.name = sName || ''; - - this.clearDuplicateName(); - } - - /** - * @static - * @param {AjaxJsonEmail} oJsonEmail - * @return {?EmailModel} - */ - EmailModel.newInstanceFromJson = function (oJsonEmail) - { - var oEmailModel = new EmailModel(); - return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null; - }; - - /** - * @type {string} - */ - EmailModel.prototype.name = ''; - - /** - * @type {string} - */ - EmailModel.prototype.email = ''; - - EmailModel.prototype.clear = function () - { - this.email = ''; - this.name = ''; - }; - - /** - * @returns {boolean} - */ - EmailModel.prototype.validate = function () - { - return '' !== this.name || '' !== this.email; - }; - - /** - * @param {boolean} bWithoutName = false - * @return {string} - */ - EmailModel.prototype.hash = function (bWithoutName) - { - return '#' + (bWithoutName ? '' : this.name) + '#' + this.email + '#'; - }; - - EmailModel.prototype.clearDuplicateName = function () - { - if (this.name === this.email) - { - this.name = ''; - } - }; - - /** - * @param {string} sQuery - * @return {boolean} - */ - EmailModel.prototype.search = function (sQuery) - { - return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(sQuery.toLowerCase()); - }; - - /** - * @param {string} sString - */ - EmailModel.prototype.parse = function (sString) - { - this.clear(); - - sString = Utils.trim(sString); - - var - mRegex = /(?:"([^"]+)")? ?,]+)>?,? ?/g, - mMatch = mRegex.exec(sString) - ; - - if (mMatch) - { - this.name = mMatch[1] || ''; - this.email = mMatch[2] || ''; - - this.clearDuplicateName(); - } - else if ((/^[^@]+@[^@]+$/).test(sString)) - { - this.name = ''; - this.email = sString; - } - }; - - /** - * @param {AjaxJsonEmail} oJsonEmail - * @return {boolean} - */ - EmailModel.prototype.initByJson = function (oJsonEmail) - { - var bResult = false; - if (oJsonEmail && 'Object/Email' === oJsonEmail['@Object']) - { - this.name = Utils.trim(oJsonEmail.Name); - this.email = Utils.trim(oJsonEmail.Email); - - bResult = '' !== this.email; - this.clearDuplicateName(); - } - - return bResult; - }; - - /** - * @param {boolean} bFriendlyView - * @param {boolean=} bWrapWithLink = false - * @param {boolean=} bEncodeHtml = false - * @return {string} - */ - EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtml) - { - var sResult = ''; - if ('' !== this.email) - { - bWrapWithLink = Utils.isUnd(bWrapWithLink) ? false : !!bWrapWithLink; - bEncodeHtml = Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml; - - if (bFriendlyView && '' !== this.name) + if (RoutedSettingsViewModel) { - sResult = bWrapWithLink ? '
') + - '" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.name) + '' : - (bEncodeHtml ? Utils.encodeHtml(this.name) : this.name); - } - else - { - sResult = this.email; - if ('' !== this.name) + if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm) { - if (bWrapWithLink) + oSettingsScreen = RoutedSettingsViewModel.__vm; + } + else + { + oViewModelPlace = this.oViewModelPlace; + if (oViewModelPlace && 1 === oViewModelPlace.length) { - sResult = Utils.encodeHtml('"' + this.name + '" <') + - '') + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(sResult) + '' + Utils.encodeHtml('>'); + oSettingsScreen = new RoutedSettingsViewModel(); + + oViewModelDom = $('
').addClass('rl-settings-view-model').hide(); + oViewModelDom.appendTo(oViewModelPlace); + + oSettingsScreen.viewModelDom = oViewModelDom; + + oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData; + + RoutedSettingsViewModel.__dom = oViewModelDom; + RoutedSettingsViewModel.__builded = true; + RoutedSettingsViewModel.__vm = oSettingsScreen; + + ko.applyBindingAccessorsToNode(oViewModelDom[0], { + 'i18nInit': true, + 'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; } + }, oSettingsScreen); + + Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]); } else { - sResult = '"' + this.name + '" <' + sResult + '>'; - if (bEncodeHtml) + Utils.log('Cannot find sub settings view model position: SettingsSubScreen'); + } + } + + if (oSettingsScreen) + { + _.defer(function () { + // hide + if (self.oCurrentSubScreen) { - sResult = Utils.encodeHtml(sResult); + Utils.delegateRun(self.oCurrentSubScreen, 'onHide'); + self.oCurrentSubScreen.viewModelDom.hide(); } - } - } - else if (bWrapWithLink) - { - sResult = '' + Utils.encodeHtml(this.email) + ''; - } - } - } + // -- - return sResult; - }; + self.oCurrentSubScreen = oSettingsScreen; - /** - * @param {string} $sEmailAddress - * @return {boolean} - */ - EmailModel.prototype.mailsoParse = function ($sEmailAddress) - { - $sEmailAddress = Utils.trim($sEmailAddress); - if ('' === $sEmailAddress) - { - return false; - } - - var - substr = function (str, start, len) { - str += ''; - var end = str.length; - - if (start < 0) { - start += end; - } - - end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start); - - return start >= str.length || start < 0 || start > end ? false : str.slice(start, end); - }, - - substr_replace = function (str, replace, start, length) { - if (start < 0) { - start = start + str.length; - } - length = length !== undefined ? length : str.length; - if (length < 0) { - length = length + str.length - start; - } - return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length); - }, - - $sName = '', - $sEmail = '', - $sComment = '', - - $bInName = false, - $bInAddress = false, - $bInComment = false, - - $aRegs = null, - - $iStartIndex = 0, - $iEndIndex = 0, - $iCurrentIndex = 0 - ; - - while ($iCurrentIndex < $sEmailAddress.length) - { - switch ($sEmailAddress.substr($iCurrentIndex, 1)) - { - case '"': - if ((!$bInName) && (!$bInAddress) && (!$bInComment)) - { - $bInName = true; - $iStartIndex = $iCurrentIndex; - } - else if ((!$bInAddress) && (!$bInComment)) - { - $iEndIndex = $iCurrentIndex; - $sName = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); - $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); - $iEndIndex = 0; - $iCurrentIndex = 0; - $iStartIndex = 0; - $bInName = false; - } - break; - case '<': - if ((!$bInName) && (!$bInAddress) && (!$bInComment)) - { - if ($iCurrentIndex > 0 && $sName.length === 0) + // show + if (self.oCurrentSubScreen) { - $sName = substr($sEmailAddress, 0, $iCurrentIndex); + self.oCurrentSubScreen.viewModelDom.show(); + Utils.delegateRun(self.oCurrentSubScreen, 'onShow'); + Utils.delegateRun(self.oCurrentSubScreen, 'onFocus', [], 200); + + _.each(self.menu(), function (oItem) { + oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route); + }); + + $('#rl-content .b-settings .b-content .content').scrollTop(0); } + // -- - $bInAddress = true; - $iStartIndex = $iCurrentIndex; - } - break; - case '>': - if ($bInAddress) - { - $iEndIndex = $iCurrentIndex; - $sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); - $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); - $iEndIndex = 0; - $iCurrentIndex = 0; - $iStartIndex = 0; - $bInAddress = false; - } - break; - case '(': - if ((!$bInName) && (!$bInAddress) && (!$bInComment)) - { - $bInComment = true; - $iStartIndex = $iCurrentIndex; - } - break; - case ')': - if ($bInComment) - { - $iEndIndex = $iCurrentIndex; - $sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); - $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); - $iEndIndex = 0; - $iCurrentIndex = 0; - $iStartIndex = 0; - $bInComment = false; - } - break; - case '\\': - $iCurrentIndex++; - break; - } - - $iCurrentIndex++; - } - - if ($sEmail.length === 0) - { - $aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i); - if ($aRegs && $aRegs[0]) - { - $sEmail = $aRegs[0]; + Utils.windowResize(); + }); + } } else { - $sName = $sEmailAddress; - } - } - - if ($sEmail.length > 0 && $sName.length === 0 && $sComment.length === 0) - { - $sName = $sEmailAddress.replace($sEmail, ''); - } - - $sEmail = Utils.trim($sEmail).replace(/^[<]+/, '').replace(/[>]+$/, ''); - $sName = Utils.trim($sName).replace(/^["']+/, '').replace(/["']+$/, ''); - $sComment = Utils.trim($sComment).replace(/^[(]+/, '').replace(/[)]+$/, ''); - - // Remove backslash - $sName = $sName.replace(/\\\\(.)/g, '$1'); - $sComment = $sComment.replace(/\\\\(.)/g, '$1'); - - this.name = $sName; - this.email = $sEmail; - - this.clearDuplicateName(); - return true; - }; - - /** - * @return {string} - */ - EmailModel.prototype.inputoTagLine = function () - { - return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email; - }; - - module.exports = EmailModel; - -}(module, require)); -},{"Utils":11}],27:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - $ = require('$'), - ko = require('ko'), - - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - kn = require('App:Knoin'), - KnoinAbstractScreen = require('Knoin:AbstractScreen') - ; - - /** - * @constructor - * @param {Array} aViewModels - * @extends KnoinAbstractScreen - */ - function AbstractSettingsScreen(aViewModels) - { - KnoinAbstractScreen.call(this, 'settings', aViewModels); - - this.menu = ko.observableArray([]); - - this.oCurrentSubScreen = null; - this.oViewModelPlace = null; - } - - _.extend(AbstractSettingsScreen.prototype, KnoinAbstractScreen.prototype); - - AbstractSettingsScreen.prototype.onRoute = function (sSubName) - { - var - self = this, - oSettingsScreen = null, - RoutedSettingsViewModel = null, - oViewModelPlace = null, - oViewModelDom = null - ; - - RoutedSettingsViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) { - return SettingsViewModel && SettingsViewModel.__rlSettingsData && - sSubName === SettingsViewModel.__rlSettingsData.Route; - }); - - if (RoutedSettingsViewModel) - { - if (_.find(Globals.aViewModels['settings-removed'], function (DisabledSettingsViewModel) { - return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel; - })) - { - RoutedSettingsViewModel = null; - } - - if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { - return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel; - })) - { - RoutedSettingsViewModel = null; - } - } - - if (RoutedSettingsViewModel) - { - if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm) - { - oSettingsScreen = RoutedSettingsViewModel.__vm; - } - else - { - oViewModelPlace = this.oViewModelPlace; - if (oViewModelPlace && 1 === oViewModelPlace.length) - { - oSettingsScreen = new RoutedSettingsViewModel(); - - oViewModelDom = $('
').addClass('rl-settings-view-model').hide(); - oViewModelDom.appendTo(oViewModelPlace); - - oSettingsScreen.viewModelDom = oViewModelDom; - - oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData; - - RoutedSettingsViewModel.__dom = oViewModelDom; - RoutedSettingsViewModel.__builded = true; - RoutedSettingsViewModel.__vm = oSettingsScreen; - - ko.applyBindingAccessorsToNode(oViewModelDom[0], { - 'i18nInit': true, - 'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; } - }, oSettingsScreen); - - Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]); - } - else - { - Utils.log('Cannot find sub settings view model position: SettingsSubScreen'); - } - } - - if (oSettingsScreen) - { - _.defer(function () { - // hide - if (self.oCurrentSubScreen) - { - Utils.delegateRun(self.oCurrentSubScreen, 'onHide'); - self.oCurrentSubScreen.viewModelDom.hide(); - } - // -- - - self.oCurrentSubScreen = oSettingsScreen; - - // show - if (self.oCurrentSubScreen) - { - self.oCurrentSubScreen.viewModelDom.show(); - Utils.delegateRun(self.oCurrentSubScreen, 'onShow'); - Utils.delegateRun(self.oCurrentSubScreen, 'onFocus', [], 200); - - _.each(self.menu(), function (oItem) { - oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route); - }); - - $('#rl-content .b-settings .b-content .content').scrollTop(0); - } - // -- - - Utils.windowResize(); - }); - } - } - else - { - kn.setHash(LinkBuilder.settings(), false, true); - } - }; - - AbstractSettingsScreen.prototype.onHide = function () - { - if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom) - { - Utils.delegateRun(this.oCurrentSubScreen, 'onHide'); - this.oCurrentSubScreen.viewModelDom.hide(); - } - }; - - AbstractSettingsScreen.prototype.onBuild = function () - { - _.each(Globals.aViewModels['settings'], function (SettingsViewModel) { - if (SettingsViewModel && SettingsViewModel.__rlSettingsData && - !_.find(Globals.aViewModels['settings-removed'], function (RemoveSettingsViewModel) { - return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel; - })) - { - this.menu.push({ - 'route': SettingsViewModel.__rlSettingsData.Route, - 'label': SettingsViewModel.__rlSettingsData.Label, - 'selected': ko.observable(false), - 'disabled': !!_.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { - return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel; - }) - }); - } - }, this); - - this.oViewModelPlace = $('#rl-content #rl-settings-subscreen'); - }; - - AbstractSettingsScreen.prototype.routes = function () - { - var - DefaultViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) { - return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData['IsDefault']; - }), - sDefaultRoute = DefaultViewModel ? DefaultViewModel.__rlSettingsData['Route'] : 'general', - oRules = { - 'subname': /^(.*)$/, - 'normalize_': function (oRequest, oVals) { - oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname); - return [oVals.subname]; - } - } - ; - - return [ - ['{subname}/', oRules], - ['{subname}', oRules], - ['', oRules] - ]; - }; - - module.exports = AbstractSettingsScreen; - -}(module, require)); -},{"$":14,"App:Knoin":21,"Globals":8,"Knoin:AbstractScreen":23,"LinkBuilder":9,"Utils":11,"_":19,"ko":16}],28:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - KnoinAbstractScreen = require('Knoin:AbstractScreen') - ; - - /** - * @constructor - * @extends KnoinAbstractScreen - */ - function AdminLoginScreen() - { - KnoinAbstractScreen.call(this, 'login', [ - require('View:Admin:Login') - ]); - } - - _.extend(AdminLoginScreen.prototype, KnoinAbstractScreen.prototype); - - AdminLoginScreen.prototype.onShow = function () - { - require('App:Admin').setTitle(''); - }; - - module.exports = AdminLoginScreen; - -}(module, require)); -},{"App:Admin":3,"Knoin:AbstractScreen":23,"View:Admin:Login":46,"_":19}],29:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - AbstractSettings = require('Screen:AbstractSettings') - ; - - /** - * @constructor - * @extends AbstractSettings - */ - function AdminSettingsScreen() - { - AbstractSettings.call(this, [ - require('View:Admin:SettingsMenu'), - require('View:Admin:SettingsPane') - ]); - } - - _.extend(AdminSettingsScreen.prototype, AbstractSettings.prototype); - - AdminSettingsScreen.prototype.onShow = function () - { - require('App:Admin').setTitle(''); - }; - - module.exports = AdminSettingsScreen; - -}(module, require)); -},{"App:Admin":3,"Screen:AbstractSettings":27,"View:Admin:SettingsMenu":47,"View:Admin:SettingsPane":48,"_":19}],30:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko') - ; - - /** - * @constructor - */ - function AdminSettingsAbout() - { - var - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data') - ; - - this.version = ko.observable(Settings.settingsGet('Version')); - this.access = ko.observable(!!Settings.settingsGet('CoreAccess')); - this.errorDesc = ko.observable(''); - - this.coreReal = Data.coreReal; - this.coreUpdatable = Data.coreUpdatable; - this.coreAccess = Data.coreAccess; - this.coreChecking = Data.coreChecking; - this.coreUpdating = Data.coreUpdating; - this.coreRemoteVersion = Data.coreRemoteVersion; - this.coreRemoteRelease = Data.coreRemoteRelease; - this.coreVersionCompare = Data.coreVersionCompare; - - this.statusType = ko.computed(function () { - - var - sType = '', - iVersionCompare = this.coreVersionCompare(), - bChecking = this.coreChecking(), - bUpdating = this.coreUpdating(), - bReal = this.coreReal() - ; - - if (bChecking) - { - sType = 'checking'; - } - else if (bUpdating) - { - sType = 'updating'; - } - else if (bReal && 0 === iVersionCompare) - { - sType = 'up-to-date'; - } - else if (bReal && -1 === iVersionCompare) - { - sType = 'available'; - } - else if (!bReal) - { - sType = 'error'; - this.errorDesc('Cannot access the repository at the moment.'); - } - - return sType; - - }, this); - } - - AdminSettingsAbout.prototype.onBuild = function () - { - if (this.access()) - { - require('App:Admin').reloadCoreData(); - } - }; - - AdminSettingsAbout.prototype.updateCoreData = function () - { - if (!this.coreUpdating()) - { - require('App:Admin').updateCoreData(); - } - }; - - module.exports = AdminSettingsAbout; - -}(module, require)); -},{"App:Admin":3,"Storage:Admin:Data":43,"Storage:Settings":45,"ko":16}],31:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Utils = require('Utils') - ; - - /** - * @constructor - */ - function AdminSettingsBranding() - { - var - Enums = require('Enums'), - Settings = require('Storage:Settings') - ; - - this.title = ko.observable(Settings.settingsGet('Title')); - this.title.trigger = ko.observable(Enums.SaveSettingsStep.Idle); - - this.loadingDesc = ko.observable(Settings.settingsGet('LoadingDescription')); - this.loadingDesc.trigger = ko.observable(Enums.SaveSettingsStep.Idle); - - this.loginLogo = ko.observable(Settings.settingsGet('LoginLogo')); - this.loginLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle); - - this.loginDescription = ko.observable(Settings.settingsGet('LoginDescription')); - this.loginDescription.trigger = ko.observable(Enums.SaveSettingsStep.Idle); - - this.loginCss = ko.observable(Settings.settingsGet('LoginCss')); - this.loginCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle); - } - - AdminSettingsBranding.prototype.onBuild = function () - { - var - self = this, - Remote = require('Storage:Admin:Remote') - ; - - _.delay(function () { - - var - f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self), - f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self), - f3 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self), - f4 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self), - f5 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self) - ; - - self.title.subscribe(function (sValue) { - Remote.saveAdminConfig(f1, { - 'Title': Utils.trim(sValue) - }); - }); - - self.loadingDesc.subscribe(function (sValue) { - Remote.saveAdminConfig(f2, { - 'LoadingDescription': Utils.trim(sValue) - }); - }); - - self.loginLogo.subscribe(function (sValue) { - Remote.saveAdminConfig(f3, { - 'LoginLogo': Utils.trim(sValue) - }); - }); - - self.loginDescription.subscribe(function (sValue) { - Remote.saveAdminConfig(f4, { - 'LoginDescription': Utils.trim(sValue) - }); - }); - - self.loginCss.subscribe(function (sValue) { - Remote.saveAdminConfig(f5, { - 'LoginCss': Utils.trim(sValue) - }); - }); - - }, 50); - }; - - module.exports = AdminSettingsBranding; - -}(module, require)); -},{"Enums":6,"Storage:Admin:Remote":44,"Storage:Settings":45,"Utils":11,"_":19,"ko":16}],32:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Settings = require('Storage:Settings') - ; - - /** - * @constructor - */ - function AdminSettingsContacts() - { - var - Remote = require('Storage:Admin:Remote') - ; - - this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; - this.enableContacts = ko.observable(!!Settings.settingsGet('ContactsEnable')); - this.contactsSharing = ko.observable(!!Settings.settingsGet('ContactsSharing')); - this.contactsSync = ko.observable(!!Settings.settingsGet('ContactsSync')); - - var - aTypes = ['sqlite', 'mysql', 'pgsql'], - aSupportedTypes = [], - getTypeName = function(sName) { - switch (sName) - { - case 'sqlite': - sName = 'SQLite'; - break; - case 'mysql': - sName = 'MySQL'; - break; - case 'pgsql': - sName = 'PostgreSQL'; - break; - } - - return sName; - } - ; - - if (!!Settings.settingsGet('SQLiteIsSupported')) - { - aSupportedTypes.push('sqlite'); - } - if (!!Settings.settingsGet('MySqlIsSupported')) - { - aSupportedTypes.push('mysql'); - } - if (!!Settings.settingsGet('PostgreSqlIsSupported')) - { - aSupportedTypes.push('pgsql'); - } - - this.contactsSupported = 0 < aSupportedTypes.length; - - this.contactsTypes = ko.observableArray([]); - this.contactsTypesOptions = this.contactsTypes.map(function (sValue) { - var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes); - return { - 'id': sValue, - 'name': getTypeName(sValue) + (bDisabled ? ' (not supported)' : ''), - 'disabled': bDisabled - }; - }); - - this.contactsTypes(aTypes); - this.contactsType = ko.observable(''); - - this.mainContactsType = ko.computed({ - 'owner': this, - 'read': this.contactsType, - 'write': function (sValue) { - if (sValue !== this.contactsType()) - { - if (-1 < Utils.inArray(sValue, aSupportedTypes)) - { - this.contactsType(sValue); - } - else if (0 < aSupportedTypes.length) - { - this.contactsType(''); - } - } - else - { - this.contactsType.valueHasMutated(); - } - } - }); - - this.contactsType.subscribe(function () { - this.testContactsSuccess(false); - this.testContactsError(false); - this.testContactsErrorMessage(''); - }, this); - - this.pdoDsn = ko.observable(Settings.settingsGet('ContactsPdoDsn')); - this.pdoUser = ko.observable(Settings.settingsGet('ContactsPdoUser')); - this.pdoPassword = ko.observable(Settings.settingsGet('ContactsPdoPassword')); - - this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - - this.testing = ko.observable(false); - this.testContactsSuccess = ko.observable(false); - this.testContactsError = ko.observable(false); - this.testContactsErrorMessage = ko.observable(''); - - this.testContactsCommand = Utils.createCommand(this, function () { - - this.testContactsSuccess(false); - this.testContactsError(false); - this.testContactsErrorMessage(''); - this.testing(true); - - Remote.testContacts(this.onTestContactsResponse, { - 'ContactsPdoType': this.contactsType(), - 'ContactsPdoDsn': this.pdoDsn(), - 'ContactsPdoUser': this.pdoUser(), - 'ContactsPdoPassword': this.pdoPassword() - }); - - }, function () { - return '' !== this.pdoDsn() && '' !== this.pdoUser(); - }); - - this.contactsType(Settings.settingsGet('ContactsPdoType')); - - this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this); - } - - AdminSettingsContacts.prototype.onTestContactsResponse = function (sResult, oData) - { - this.testContactsSuccess(false); - this.testContactsError(false); - this.testContactsErrorMessage(''); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Result) - { - this.testContactsSuccess(true); - } - else - { - this.testContactsError(true); - if (oData && oData.Result) - { - this.testContactsErrorMessage(oData.Result.Message || ''); - } - else - { - this.testContactsErrorMessage(''); - } - } - - this.testing(false); - }; - - AdminSettingsContacts.prototype.onShow = function () - { - this.testContactsSuccess(false); - this.testContactsError(false); - this.testContactsErrorMessage(''); - }; - - AdminSettingsContacts.prototype.onBuild = function () - { - var - self = this, - Remote = require('Storage:Admin:Remote') - ; - - _.delay(function () { - - var - f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self), - f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self), - f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self), - f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self) - ; - - self.enableContacts.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'ContactsEnable': bValue ? '1' : '0' - }); - }); - - self.contactsSharing.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'ContactsSharing': bValue ? '1' : '0' - }); - }); - - self.contactsSync.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'ContactsSync': bValue ? '1' : '0' - }); - }); - - self.contactsType.subscribe(function (sValue) { - Remote.saveAdminConfig(f5, { - 'ContactsPdoType': sValue - }); - }); - - self.pdoDsn.subscribe(function (sValue) { - Remote.saveAdminConfig(f1, { - 'ContactsPdoDsn': Utils.trim(sValue) - }); - }); - - self.pdoUser.subscribe(function (sValue) { - Remote.saveAdminConfig(f3, { - 'ContactsPdoUser': Utils.trim(sValue) - }); - }); - - self.pdoPassword.subscribe(function (sValue) { - Remote.saveAdminConfig(f4, { - 'ContactsPdoPassword': Utils.trim(sValue) - }); - }); - - self.contactsType(Settings.settingsGet('ContactsPdoType')); - - }, 50); - }; - - module.exports = AdminSettingsContacts; - -}(module, require)); -},{"Enums":6,"Storage:Admin:Remote":44,"Storage:Settings":45,"Utils":11,"_":19,"ko":16}],33:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - - PopupsDomainViewModel = require('View:Popup:Domain'), - - Data = require('Storage:Admin:Data'), - Remote = require('Storage:Admin:Remote') - ; - - /** - * @constructor - */ - function AdminSettingsDomains() - { - this.domains = Data.domains; - this.domainsLoading = Data.domainsLoading; - - this.iDomainForDeletionTimeout = 0; - - this.visibility = ko.computed(function () { - return Data.domainsLoading() ? 'visible' : 'hidden'; - }, this); - - this.domainForDeletion = ko.observable(null).extend({'toggleSubscribe': [this, - function (oPrev) { - if (oPrev) - { - oPrev.deleteAccess(false); - } - }, function (oNext) { - if (oNext) - { - oNext.deleteAccess(true); - this.startDomainForDeletionTimeout(); - } - } - ]}); - } - - AdminSettingsDomains.prototype.startDomainForDeletionTimeout = function () - { - var self = this; - window.clearInterval(this.iDomainForDeletionTimeout); - this.iDomainForDeletionTimeout = window.setTimeout(function () { - self.domainForDeletion(null); - }, 1000 * 3); - }; - - AdminSettingsDomains.prototype.createDomain = function () - { - require('App:Knoin').showScreenPopup(PopupsDomainViewModel); - }; - - AdminSettingsDomains.prototype.deleteDomain = function (oDomain) - { - this.domains.remove(oDomain); - Remote.domainDelete(_.bind(this.onDomainListChangeRequest, this), oDomain.name); - }; - - AdminSettingsDomains.prototype.disableDomain = function (oDomain) - { - oDomain.disabled(!oDomain.disabled()); - Remote.domainDisable(_.bind(this.onDomainListChangeRequest, this), oDomain.name, oDomain.disabled()); - }; - - AdminSettingsDomains.prototype.onBuild = function (oDom) - { - var self = this; - oDom - .on('click', '.b-admin-domains-list-table .e-item .e-action', function () { - var oDomainItem = ko.dataFor(this); - if (oDomainItem) - { - Remote.domain(_.bind(self.onDomainLoadRequest, self), oDomainItem.name); - } - }) - ; - - require('App:Admin').reloadDomainList(); - }; - - AdminSettingsDomains.prototype.onDomainLoadRequest = function (sResult, oData) - { - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - require('App:Knoin').showScreenPopup(PopupsDomainViewModel, [oData.Result]); - } - }; - - AdminSettingsDomains.prototype.onDomainListChangeRequest = function () - { - require('App:Admin').reloadDomainList(); - }; - - module.exports = AdminSettingsDomains; - -}(module, require)); -},{"App:Admin":3,"App:Knoin":21,"Enums":6,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"View:Popup:Domain":51,"_":19,"ko":16,"window":20}],34:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data') - ; - - /** - * @constructor - */ - function AdminSettingsGeneral() - { - this.mainLanguage = Data.mainLanguage; - this.mainTheme = Data.mainTheme; - - this.language = Data.language; - this.theme = Data.theme; - - this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings; - this.capaThemes = Data.capaThemes; - this.capaGravatar = Data.capaGravatar; - this.capaAdditionalAccounts = Data.capaAdditionalAccounts; - this.capaAdditionalIdentities = Data.capaAdditionalIdentities; - - this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25}); - this.uploadData = Settings.settingsGet('PhpUploadSizes'); - this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ? - [ - this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '', - this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : '' - ].join('') - : ''; - - this.themesOptions = ko.computed(function () { - return _.map(Data.themes(), function (sTheme) { - return { - 'optValue': sTheme, - 'optText': Utils.convertThemeName(sTheme) - }; - }); - }); - - this.mainLanguageFullName = ko.computed(function () { - return Utils.convertLangName(this.mainLanguage()); - }, this); - - this.weakPassword = !!Settings.settingsGet('WeakPassword'); - - this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - } - - AdminSettingsGeneral.prototype.onBuild = function () - { - var - self = this, - Remote = require('Storage:Admin:Remote') - ; - - _.delay(function () { - - var - f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self), - f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self), - f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self) - ; - - self.mainAttachmentLimit.subscribe(function (sValue) { - Remote.saveAdminConfig(f1, { - 'AttachmentLimit': Utils.pInt(sValue) - }); - }); - - self.language.subscribe(function (sValue) { - Remote.saveAdminConfig(f2, { - 'Language': Utils.trim(sValue) - }); - }); - - self.theme.subscribe(function (sValue) { - Remote.saveAdminConfig(f3, { - 'Theme': Utils.trim(sValue) - }); - }); - - self.capaAdditionalAccounts.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'CapaAdditionalAccounts': bValue ? '1' : '0' - }); - }); - - self.capaAdditionalIdentities.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'CapaAdditionalIdentities': bValue ? '1' : '0' - }); - }); - - self.capaGravatar.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'CapaGravatar': bValue ? '1' : '0' - }); - }); - - self.capaThemes.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'CapaThemes': bValue ? '1' : '0' - }); - }); - - self.allowLanguagesOnSettings.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'AllowLanguagesOnSettings': bValue ? '1' : '0' - }); - }); - - }, 50); - }; - - AdminSettingsGeneral.prototype.selectLanguage = function () - { - require('App:Knoin').showScreenPopup(require('View:Popup:Languages')); - }; - - /** - * @return {string} - */ - AdminSettingsGeneral.prototype.phpInfoLink = function () - { - return LinkBuilder.phpInfo(); - }; - - module.exports = AdminSettingsGeneral; - -}(module, require)); -},{"App:Knoin":21,"Enums":6,"LinkBuilder":9,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Storage:Settings":45,"Utils":11,"View:Popup:Languages":52,"_":19,"ko":16}],35:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - moment = require('moment'), - - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data') - ; - - /** - * @constructor - */ - function AdminSettingsLicensing() - { - this.licensing = Data.licensing; - this.licensingProcess = Data.licensingProcess; - this.licenseValid = Data.licenseValid; - this.licenseExpired = Data.licenseExpired; - this.licenseError = Data.licenseError; - this.licenseTrigger = Data.licenseTrigger; - - this.adminDomain = ko.observable(''); - this.subscriptionEnabled = ko.observable(!!Settings.settingsGet('SubscriptionEnabled')); - - this.licenseTrigger.subscribe(function () { - if (this.subscriptionEnabled()) - { - require('App:Admin').reloadLicensing(true); - } - }, this); - } - - AdminSettingsLicensing.prototype.onBuild = function () - { - if (this.subscriptionEnabled()) - { - require('App:Admin').reloadLicensing(false); - } - }; - - AdminSettingsLicensing.prototype.onShow = function () - { - this.adminDomain(Settings.settingsGet('AdminDomain')); - }; - - AdminSettingsLicensing.prototype.showActivationForm = function () - { - require('App:Knoin').showScreenPopup(require('View:Popup:Activate')); - }; - - /** - * @returns {string} - */ - AdminSettingsLicensing.prototype.licenseExpiredMomentValue = function () - { - var - iTime = this.licenseExpired(), - oDate = moment.unix(iTime) - ; - - return iTime && 1898625600 === iTime ? 'Never' : (oDate.format('LL') + ' (' + oDate.from(moment()) + ')'); - }; - - module.exports = AdminSettingsLicensing; - -}(module, require)); -},{"App:Admin":3,"App:Knoin":21,"Storage:Admin:Data":43,"Storage:Settings":45,"View:Popup:Activate":49,"ko":16,"moment":17}],36:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data') - ; - - /** - * @constructor - */ - function AdminSettingsLogin() - { - this.determineUserLanguage = Data.determineUserLanguage; - this.determineUserDomain = Data.determineUserDomain; - - this.defaultDomain = ko.observable(Settings.settingsGet('LoginDefaultDomain')); - - this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin; - this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - } - - AdminSettingsLogin.prototype.onBuild = function () - { - var - self = this, - Remote = require('Storage:Admin:Remote') - ; - - _.delay(function () { - - var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self); - - self.determineUserLanguage.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'DetermineUserLanguage': bValue ? '1' : '0' - }); - }); - - self.determineUserDomain.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'DetermineUserDomain': bValue ? '1' : '0' - }); - }); - - self.allowLanguagesOnLogin.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'AllowLanguagesOnLogin': bValue ? '1' : '0' - }); - }); - - self.defaultDomain.subscribe(function (sValue) { - Remote.saveAdminConfig(f1, { - 'LoginDefaultDomain': Utils.trim(sValue) - }); - }); - - }, 50); - }; - - module.exports = AdminSettingsLogin; - -}(module, require)); -},{"Enums":6,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Storage:Settings":45,"Utils":11,"_":19,"ko":16}],37:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Data = require('Storage:Admin:Data'), - Remote = require('Storage:Admin:Remote') - ; - - /** - * @constructor - */ - function AdminSettingsPackages() - { - this.packagesError = ko.observable(''); - - this.packages = Data.packages; - this.packagesLoading = Data.packagesLoading; - this.packagesReal = Data.packagesReal; - this.packagesMainUpdatable = Data.packagesMainUpdatable; - - this.packagesCurrent = this.packages.filter(function (oItem) { - return oItem && '' !== oItem['installed'] && !oItem['compare']; - }); - - this.packagesAvailableForUpdate = this.packages.filter(function (oItem) { - return oItem && '' !== oItem['installed'] && !!oItem['compare']; - }); - - this.packagesAvailableForInstallation = this.packages.filter(function (oItem) { - return oItem && '' === oItem['installed']; - }); - - this.visibility = ko.computed(function () { - return Data.packagesLoading() ? 'visible' : 'hidden'; - }, this); - } - - AdminSettingsPackages.prototype.onShow = function () - { - this.packagesError(''); - }; - - AdminSettingsPackages.prototype.onBuild = function () - { - require('App:Admin').reloadPackagesList(); - }; - - AdminSettingsPackages.prototype.requestHelper = function (oPackage, bInstall) - { - var self = this; - return function (sResult, oData) { - - if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) - { - if (oData && oData.ErrorCode) - { - self.packagesError(Utils.getNotification(oData.ErrorCode)); - } - else - { - self.packagesError(Utils.getNotification( - bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage)); - } - } - - _.each(Data.packages(), function (oItem) { - if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file']) - { - oPackage['loading'](false); - oItem['loading'](false); - } - }); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result['Reload']) - { - window.location.reload(); - } - else - { - require('App:Admin').reloadPackagesList(); + kn.setHash(LinkBuilder.settings(), false, true); } }; - }; - AdminSettingsPackages.prototype.deletePackage = function (oPackage) - { - if (oPackage) + AbstractSettingsScreen.prototype.onHide = function () { - oPackage['loading'](true); - Remote.packageDelete(this.requestHelper(oPackage, false), oPackage); - } - }; + if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom) + { + Utils.delegateRun(this.oCurrentSubScreen, 'onHide'); + this.oCurrentSubScreen.viewModelDom.hide(); + } + }; - AdminSettingsPackages.prototype.installPackage = function (oPackage) - { - if (oPackage) + AbstractSettingsScreen.prototype.onBuild = function () { - oPackage['loading'](true); - Remote.packageInstall(this.requestHelper(oPackage, true), oPackage); - } - }; - - module.exports = AdminSettingsPackages; - -}(module, require)); -},{"App:Admin":3,"Enums":6,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Utils":11,"ko":16,"window":20}],38:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data'), - Remote = require('Storage:Admin:Remote') - ; - - /** - * @constructor - */ - function AdminSettingsPlugins() - { - this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins')); - - this.pluginsError = ko.observable(''); - - this.plugins = Data.plugins; - this.pluginsLoading = Data.pluginsLoading; - - this.visibility = ko.computed(function () { - return Data.pluginsLoading() ? 'visible' : 'hidden'; - }, this); - - this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this); - this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this); - } - - AdminSettingsPlugins.prototype.disablePlugin = function (oPlugin) - { - oPlugin.disabled(!oPlugin.disabled()); - Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled()); - }; - - AdminSettingsPlugins.prototype.configurePlugin = function (oPlugin) - { - Remote.plugin(this.onPluginLoadRequest, oPlugin.name); - }; - - AdminSettingsPlugins.prototype.onBuild = function (oDom) - { - var self = this; - - oDom - .on('click', '.e-item .configure-plugin-action', function () { - var oPlugin = ko.dataFor(this); - if (oPlugin) + _.each(Globals.aViewModels['settings'], function (SettingsViewModel) { + if (SettingsViewModel && SettingsViewModel.__rlSettingsData && + !_.find(Globals.aViewModels['settings-removed'], function (RemoveSettingsViewModel) { + return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel; + })) { - self.configurePlugin(oPlugin); + this.menu.push({ + 'route': SettingsViewModel.__rlSettingsData.Route, + 'label': SettingsViewModel.__rlSettingsData.Label, + 'selected': ko.observable(false), + 'disabled': !!_.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { + return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel; + }) + }); } - }) - .on('click', '.e-item .disabled-plugin', function () { - var oPlugin = ko.dataFor(this); - if (oPlugin) - { - self.disablePlugin(oPlugin); + }, this); + + this.oViewModelPlace = $('#rl-content #rl-settings-subscreen'); + }; + + AbstractSettingsScreen.prototype.routes = function () + { + var + DefaultViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) { + return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData['IsDefault']; + }), + sDefaultRoute = DefaultViewModel ? DefaultViewModel.__rlSettingsData['Route'] : 'general', + oRules = { + 'subname': /^(.*)$/, + 'normalize_': function (oRequest, oVals) { + oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname); + return [oVals.subname]; + } } - }) + ; + + return [ + ['{subname}/', oRules], + ['{subname}', oRules], + ['', oRules] + ]; + }; + + module.exports = AbstractSettingsScreen; + + }()); + +/***/ }, + +/***/ 62: +/*!*****************************************!*\ + !*** ./dev/Screens/AdminLoginScreen.js ***! + \*****************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + KnoinAbstractScreen = __webpack_require__(/*! Knoin:AbstractScreen */ 24) ; - this.enabledPlugins.subscribe(function (bValue) { - Remote.saveAdminConfig(Utils.emptyFunction, { - 'EnabledPlugins': bValue ? '1' : '0' - }); - }); - }; - - AdminSettingsPlugins.prototype.onShow = function () - { - this.pluginsError(''); - require('App:Admin').reloadPluginList(); - }; - - AdminSettingsPlugins.prototype.onPluginLoadRequest = function (sResult, oData) - { - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + /** + * @constructor + * @extends KnoinAbstractScreen + */ + function AdminLoginScreen() { - require('App:Knoin').showScreenPopup(require('View:Popup:Plugin'), [oData.Result]); + KnoinAbstractScreen.call(this, 'login', [ + __webpack_require__(/*! View:Admin:Login */ 93) + ]); } - }; - AdminSettingsPlugins.prototype.onPluginDisableRequest = function (sResult, oData) - { - if (Enums.StorageResultType.Success === sResult && oData) + _.extend(AdminLoginScreen.prototype, KnoinAbstractScreen.prototype); + + AdminLoginScreen.prototype.onShow = function () { - if (!oData.Result && oData.ErrorCode) + __webpack_require__(/*! App:Admin */ 16).setTitle(''); + }; + + module.exports = AdminLoginScreen; + + }()); + +/***/ }, + +/***/ 63: +/*!********************************************!*\ + !*** ./dev/Screens/AdminSettingsScreen.js ***! + \********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + kn = __webpack_require__(/*! App:Knoin */ 5), + + AbstractSettings = __webpack_require__(/*! Screen:AbstractSettings */ 29) + ; + + /** + * @constructor + * @extends AbstractSettings + */ + function AdminSettingsScreen() + { + AbstractSettings.call(this, [ + __webpack_require__(/*! View:Admin:SettingsMenu */ 94), + __webpack_require__(/*! View:Admin:SettingsPane */ 95) + ]); + } + + _.extend(AdminSettingsScreen.prototype, AbstractSettings.prototype); + + /** + * @param {Function=} fCallback + */ + AdminSettingsScreen.prototype.setupSettings = function (fCallback) + { + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:General */ 71), + 'AdminSettingsGeneral', 'General', 'general', true); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Login */ 73), + 'AdminSettingsLogin', 'Login', 'login'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Branding */ 68), + 'AdminSettingsBranding', 'Branding', 'branding'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Contacts */ 69), + 'AdminSettingsContacts', 'Contacts', 'contacts'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Domains */ 70), + 'AdminSettingsDomains', 'Domains', 'domains'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Security */ 76), + 'AdminSettingsSecurity', 'Security', 'security'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Social */ 77), + 'AdminSettingsSocial', 'Social', 'social'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Plugins */ 75), + 'AdminSettingsPlugins', 'Plugins', 'plugins'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Packages */ 74), + 'AdminSettingsPackages', 'Packages', 'packages'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:Licensing */ 72), + 'AdminSettingsLicensing', 'Licensing', 'licensing'); + + kn.addSettingsViewModel(__webpack_require__(/*! Settings:Admin:About */ 67), + 'AdminSettingsAbout', 'About', 'about'); + + if (fCallback) { - if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage) + fCallback(); + } + }; + + AdminSettingsScreen.prototype.onShow = function () + { + __webpack_require__(/*! App:Admin */ 16).setTitle(''); + }; + + module.exports = AdminSettingsScreen; + + }()); + +/***/ }, + +/***/ 67: +/*!**************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsAbout.js ***! + \**************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3) + ; + + /** + * @constructor + */ + function AdminSettingsAbout() + { + var + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18) + ; + + this.version = ko.observable(Settings.settingsGet('Version')); + this.access = ko.observable(!!Settings.settingsGet('CoreAccess')); + this.errorDesc = ko.observable(''); + + this.coreReal = Data.coreReal; + this.coreUpdatable = Data.coreUpdatable; + this.coreAccess = Data.coreAccess; + this.coreChecking = Data.coreChecking; + this.coreUpdating = Data.coreUpdating; + this.coreRemoteVersion = Data.coreRemoteVersion; + this.coreRemoteRelease = Data.coreRemoteRelease; + this.coreVersionCompare = Data.coreVersionCompare; + + this.statusType = ko.computed(function () { + + var + sType = '', + iVersionCompare = this.coreVersionCompare(), + bChecking = this.coreChecking(), + bUpdating = this.coreUpdating(), + bReal = this.coreReal() + ; + + if (bChecking) { - this.pluginsError(oData.ErrorMessage); + sType = 'checking'; + } + else if (bUpdating) + { + sType = 'updating'; + } + else if (bReal && 0 === iVersionCompare) + { + sType = 'up-to-date'; + } + else if (bReal && -1 === iVersionCompare) + { + sType = 'available'; + } + else if (!bReal) + { + sType = 'error'; + this.errorDesc('Cannot access the repository at the moment.'); + } + + return sType; + + }, this); + } + + AdminSettingsAbout.prototype.onBuild = function () + { + if (this.access()) + { + __webpack_require__(/*! App:Admin */ 16).reloadCoreData(); + } + }; + + AdminSettingsAbout.prototype.updateCoreData = function () + { + if (!this.coreUpdating()) + { + __webpack_require__(/*! App:Admin */ 16).updateCoreData(); + } + }; + + module.exports = AdminSettingsAbout; + + }()); + +/***/ }, + +/***/ 68: +/*!*****************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsBranding.js ***! + \*****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + */ + function AdminSettingsBranding() + { + var + Enums = __webpack_require__(/*! Common/Enums */ 6), + Settings = __webpack_require__(/*! Storage:Settings */ 10) + ; + + this.title = ko.observable(Settings.settingsGet('Title')); + this.title.trigger = ko.observable(Enums.SaveSettingsStep.Idle); + + this.loadingDesc = ko.observable(Settings.settingsGet('LoadingDescription')); + this.loadingDesc.trigger = ko.observable(Enums.SaveSettingsStep.Idle); + + this.loginLogo = ko.observable(Settings.settingsGet('LoginLogo')); + this.loginLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle); + + this.loginDescription = ko.observable(Settings.settingsGet('LoginDescription')); + this.loginDescription.trigger = ko.observable(Enums.SaveSettingsStep.Idle); + + this.loginCss = ko.observable(Settings.settingsGet('LoginCss')); + this.loginCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle); + } + + AdminSettingsBranding.prototype.onBuild = function () + { + var + self = this, + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + _.delay(function () { + + var + f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self), + f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self), + f3 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self), + f4 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self), + f5 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self) + ; + + self.title.subscribe(function (sValue) { + Remote.saveAdminConfig(f1, { + 'Title': Utils.trim(sValue) + }); + }); + + self.loadingDesc.subscribe(function (sValue) { + Remote.saveAdminConfig(f2, { + 'LoadingDescription': Utils.trim(sValue) + }); + }); + + self.loginLogo.subscribe(function (sValue) { + Remote.saveAdminConfig(f3, { + 'LoginLogo': Utils.trim(sValue) + }); + }); + + self.loginDescription.subscribe(function (sValue) { + Remote.saveAdminConfig(f4, { + 'LoginDescription': Utils.trim(sValue) + }); + }); + + self.loginCss.subscribe(function (sValue) { + Remote.saveAdminConfig(f5, { + 'LoginCss': Utils.trim(sValue) + }); + }); + + }, 50); + }; + + module.exports = AdminSettingsBranding; + + }()); + +/***/ }, + +/***/ 69: +/*!*****************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsContacts.js ***! + \*****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Settings = __webpack_require__(/*! Storage:Settings */ 10) + ; + + /** + * @constructor + */ + function AdminSettingsContacts() + { + var + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; + this.enableContacts = ko.observable(!!Settings.settingsGet('ContactsEnable')); + this.contactsSharing = ko.observable(!!Settings.settingsGet('ContactsSharing')); + this.contactsSync = ko.observable(!!Settings.settingsGet('ContactsSync')); + + var + aTypes = ['sqlite', 'mysql', 'pgsql'], + aSupportedTypes = [], + getTypeName = function(sName) { + switch (sName) + { + case 'sqlite': + sName = 'SQLite'; + break; + case 'mysql': + sName = 'MySQL'; + break; + case 'pgsql': + sName = 'PostgreSQL'; + break; + } + + return sName; + } + ; + + if (!!Settings.settingsGet('SQLiteIsSupported')) + { + aSupportedTypes.push('sqlite'); + } + if (!!Settings.settingsGet('MySqlIsSupported')) + { + aSupportedTypes.push('mysql'); + } + if (!!Settings.settingsGet('PostgreSqlIsSupported')) + { + aSupportedTypes.push('pgsql'); + } + + this.contactsSupported = 0 < aSupportedTypes.length; + + this.contactsTypes = ko.observableArray([]); + this.contactsTypesOptions = this.contactsTypes.map(function (sValue) { + var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes); + return { + 'id': sValue, + 'name': getTypeName(sValue) + (bDisabled ? ' (not supported)' : ''), + 'disabled': bDisabled + }; + }); + + this.contactsTypes(aTypes); + this.contactsType = ko.observable(''); + + this.mainContactsType = ko.computed({ + 'owner': this, + 'read': this.contactsType, + 'write': function (sValue) { + if (sValue !== this.contactsType()) + { + if (-1 < Utils.inArray(sValue, aSupportedTypes)) + { + this.contactsType(sValue); + } + else if (0 < aSupportedTypes.length) + { + this.contactsType(''); + } + } + else + { + this.contactsType.valueHasMutated(); + } + } + }); + + this.contactsType.subscribe(function () { + this.testContactsSuccess(false); + this.testContactsError(false); + this.testContactsErrorMessage(''); + }, this); + + this.pdoDsn = ko.observable(Settings.settingsGet('ContactsPdoDsn')); + this.pdoUser = ko.observable(Settings.settingsGet('ContactsPdoUser')); + this.pdoPassword = ko.observable(Settings.settingsGet('ContactsPdoPassword')); + + this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + + this.testing = ko.observable(false); + this.testContactsSuccess = ko.observable(false); + this.testContactsError = ko.observable(false); + this.testContactsErrorMessage = ko.observable(''); + + this.testContactsCommand = Utils.createCommand(this, function () { + + this.testContactsSuccess(false); + this.testContactsError(false); + this.testContactsErrorMessage(''); + this.testing(true); + + Remote.testContacts(this.onTestContactsResponse, { + 'ContactsPdoType': this.contactsType(), + 'ContactsPdoDsn': this.pdoDsn(), + 'ContactsPdoUser': this.pdoUser(), + 'ContactsPdoPassword': this.pdoPassword() + }); + + }, function () { + return '' !== this.pdoDsn() && '' !== this.pdoUser(); + }); + + this.contactsType(Settings.settingsGet('ContactsPdoType')); + + this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this); + } + + AdminSettingsContacts.prototype.onTestContactsResponse = function (sResult, oData) + { + this.testContactsSuccess(false); + this.testContactsError(false); + this.testContactsErrorMessage(''); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Result) + { + this.testContactsSuccess(true); + } + else + { + this.testContactsError(true); + if (oData && oData.Result) + { + this.testContactsErrorMessage(oData.Result.Message || ''); } else { - this.pluginsError(Utils.getNotification(oData.ErrorCode)); + this.testContactsErrorMessage(''); } } + + this.testing(false); + }; + + AdminSettingsContacts.prototype.onShow = function () + { + this.testContactsSuccess(false); + this.testContactsError(false); + this.testContactsErrorMessage(''); + }; + + AdminSettingsContacts.prototype.onBuild = function () + { + var + self = this, + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + _.delay(function () { + + var + f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self), + f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self), + f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self), + f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self) + ; + + self.enableContacts.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'ContactsEnable': bValue ? '1' : '0' + }); + }); + + self.contactsSharing.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'ContactsSharing': bValue ? '1' : '0' + }); + }); + + self.contactsSync.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'ContactsSync': bValue ? '1' : '0' + }); + }); + + self.contactsType.subscribe(function (sValue) { + Remote.saveAdminConfig(f5, { + 'ContactsPdoType': sValue + }); + }); + + self.pdoDsn.subscribe(function (sValue) { + Remote.saveAdminConfig(f1, { + 'ContactsPdoDsn': Utils.trim(sValue) + }); + }); + + self.pdoUser.subscribe(function (sValue) { + Remote.saveAdminConfig(f3, { + 'ContactsPdoUser': Utils.trim(sValue) + }); + }); + + self.pdoPassword.subscribe(function (sValue) { + Remote.saveAdminConfig(f4, { + 'ContactsPdoPassword': Utils.trim(sValue) + }); + }); + + self.contactsType(Settings.settingsGet('ContactsPdoType')); + + }, 50); + }; + + module.exports = AdminSettingsContacts; + + }()); + +/***/ }, + +/***/ 70: +/*!****************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsDomains.js ***! + \****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + + PopupsDomainViewModel = __webpack_require__(/*! View:Popup:Domain */ 105), + + Data = __webpack_require__(/*! Storage:Admin:Data */ 18), + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + /** + * @constructor + */ + function AdminSettingsDomains() + { + this.domains = Data.domains; + this.domainsLoading = Data.domainsLoading; + + this.iDomainForDeletionTimeout = 0; + + this.visibility = ko.computed(function () { + return Data.domainsLoading() ? 'visible' : 'hidden'; + }, this); + + this.domainForDeletion = ko.observable(null).extend({'toggleSubscribe': [this, + function (oPrev) { + if (oPrev) + { + oPrev.deleteAccess(false); + } + }, function (oNext) { + if (oNext) + { + oNext.deleteAccess(true); + this.startDomainForDeletionTimeout(); + } + } + ]}); } - require('App:Admin').reloadPluginList(); - }; + AdminSettingsDomains.prototype.startDomainForDeletionTimeout = function () + { + var self = this; + window.clearInterval(this.iDomainForDeletionTimeout); + this.iDomainForDeletionTimeout = window.setTimeout(function () { + self.domainForDeletion(null); + }, 1000 * 3); + }; - module.exports = AdminSettingsPlugins; + AdminSettingsDomains.prototype.createDomain = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(PopupsDomainViewModel); + }; -}(module, require)); -},{"App:Admin":3,"App:Knoin":21,"Enums":6,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Storage:Settings":45,"Utils":11,"View:Popup:Plugin":53,"_":19,"ko":16}],39:[function(require,module,exports){ + AdminSettingsDomains.prototype.deleteDomain = function (oDomain) + { + this.domains.remove(oDomain); + Remote.domainDelete(_.bind(this.onDomainListChangeRequest, this), oDomain.name); + }; -(function (module, require) { + AdminSettingsDomains.prototype.disableDomain = function (oDomain) + { + oDomain.disabled(!oDomain.disabled()); + Remote.domainDisable(_.bind(this.onDomainListChangeRequest, this), oDomain.name, oDomain.disabled()); + }; - 'use strict'; + AdminSettingsDomains.prototype.onBuild = function (oDom) + { + var self = this; + oDom + .on('click', '.b-admin-domains-list-table .e-item .e-action', function () { + var oDomainItem = ko.dataFor(this); + if (oDomainItem) + { + Remote.domain(_.bind(self.onDomainLoadRequest, self), oDomainItem.name); + } + }) + ; - var - _ = require('_'), - ko = require('ko'), + __webpack_require__(/*! App:Admin */ 16).reloadDomainList(); + }; - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data'), - Remote = require('Storage:Admin:Remote') - ; - - /** - * @constructor - */ - function AdminSettingsSecurity() - { - this.useLocalProxyForExternalImages = Data.useLocalProxyForExternalImages; - - this.capaOpenPGP = ko.observable(Settings.capa(Enums.Capa.OpenPGP)); - this.capaTwoFactorAuth = ko.observable(Settings.capa(Enums.Capa.TwoFactor)); - - this.adminLogin = ko.observable(Settings.settingsGet('AdminLogin')); - this.adminPassword = ko.observable(''); - this.adminPasswordNew = ko.observable(''); - this.adminPasswordNew2 = ko.observable(''); - this.adminPasswordNewError = ko.observable(false); - - this.adminPasswordUpdateError = ko.observable(false); - this.adminPasswordUpdateSuccess = ko.observable(false); - - this.adminPassword.subscribe(function () { - this.adminPasswordUpdateError(false); - this.adminPasswordUpdateSuccess(false); - }, this); - - this.adminPasswordNew.subscribe(function () { - this.adminPasswordUpdateError(false); - this.adminPasswordUpdateSuccess(false); - this.adminPasswordNewError(false); - }, this); - - this.adminPasswordNew2.subscribe(function () { - this.adminPasswordUpdateError(false); - this.adminPasswordUpdateSuccess(false); - this.adminPasswordNewError(false); - }, this); - - this.saveNewAdminPasswordCommand = Utils.createCommand(this, function () { - - if (this.adminPasswordNew() !== this.adminPasswordNew2()) + AdminSettingsDomains.prototype.onDomainLoadRequest = function (sResult, oData) + { + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { - this.adminPasswordNewError(true); - return false; + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(PopupsDomainViewModel, [oData.Result]); } + }; - this.adminPasswordUpdateError(false); - this.adminPasswordUpdateSuccess(false); + AdminSettingsDomains.prototype.onDomainListChangeRequest = function () + { + __webpack_require__(/*! App:Admin */ 16).reloadDomainList(); + }; - Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, { - 'Password': this.adminPassword(), - 'NewPassword': this.adminPasswordNew() + module.exports = AdminSettingsDomains; + + }()); + +/***/ }, + +/***/ 71: +/*!****************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsGeneral.js ***! + \****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18) + ; + + /** + * @constructor + */ + function AdminSettingsGeneral() + { + this.mainLanguage = Data.mainLanguage; + this.mainTheme = Data.mainTheme; + + this.language = Data.language; + this.theme = Data.theme; + + this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings; + this.capaThemes = Data.capaThemes; + this.capaGravatar = Data.capaGravatar; + this.capaAdditionalAccounts = Data.capaAdditionalAccounts; + this.capaAdditionalIdentities = Data.capaAdditionalIdentities; + + this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25}); + this.uploadData = Settings.settingsGet('PhpUploadSizes'); + this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ? + [ + this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '', + this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : '' + ].join('') + : ''; + + this.themesOptions = ko.computed(function () { + return _.map(Data.themes(), function (sTheme) { + return { + 'optValue': sTheme, + 'optText': Utils.convertThemeName(sTheme) + }; + }); }); - }, function () { - return '' !== this.adminPassword() && '' !== this.adminPasswordNew() && '' !== this.adminPasswordNew2(); - }); + this.mainLanguageFullName = ko.computed(function () { + return Utils.convertLangName(this.mainLanguage()); + }, this); - this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this); - } + this.weakPassword = !!Settings.settingsGet('WeakPassword'); - AdminSettingsSecurity.prototype.onNewAdminPasswordResponse = function (sResult, oData) - { - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + } + + AdminSettingsGeneral.prototype.onBuild = function () + { + var + self = this, + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + _.delay(function () { + + var + f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self), + f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self), + f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self) + ; + + self.mainAttachmentLimit.subscribe(function (sValue) { + Remote.saveAdminConfig(f1, { + 'AttachmentLimit': Utils.pInt(sValue) + }); + }); + + self.language.subscribe(function (sValue) { + Remote.saveAdminConfig(f2, { + 'Language': Utils.trim(sValue) + }); + }); + + self.theme.subscribe(function (sValue) { + Remote.saveAdminConfig(f3, { + 'Theme': Utils.trim(sValue) + }); + }); + + self.capaAdditionalAccounts.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'CapaAdditionalAccounts': bValue ? '1' : '0' + }); + }); + + self.capaAdditionalIdentities.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'CapaAdditionalIdentities': bValue ? '1' : '0' + }); + }); + + self.capaGravatar.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'CapaGravatar': bValue ? '1' : '0' + }); + }); + + self.capaThemes.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'CapaThemes': bValue ? '1' : '0' + }); + }); + + self.allowLanguagesOnSettings.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'AllowLanguagesOnSettings': bValue ? '1' : '0' + }); + }); + + }, 50); + }; + + AdminSettingsGeneral.prototype.selectLanguage = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:Languages */ 32)); + }; + + /** + * @return {string} + */ + AdminSettingsGeneral.prototype.phpInfoLink = function () + { + return LinkBuilder.phpInfo(); + }; + + module.exports = AdminSettingsGeneral; + + }()); + +/***/ }, + +/***/ 72: +/*!******************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsLicensing.js ***! + \******************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + moment = __webpack_require__(/*! moment */ 25), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18) + ; + + /** + * @constructor + */ + function AdminSettingsLicensing() + { + this.licensing = Data.licensing; + this.licensingProcess = Data.licensingProcess; + this.licenseValid = Data.licenseValid; + this.licenseExpired = Data.licenseExpired; + this.licenseError = Data.licenseError; + this.licenseTrigger = Data.licenseTrigger; + + this.adminDomain = ko.observable(''); + this.subscriptionEnabled = ko.observable(!!Settings.settingsGet('SubscriptionEnabled')); + + this.licenseTrigger.subscribe(function () { + if (this.subscriptionEnabled()) + { + __webpack_require__(/*! App:Admin */ 16).reloadLicensing(true); + } + }, this); + } + + AdminSettingsLicensing.prototype.onBuild = function () + { + if (this.subscriptionEnabled()) + { + __webpack_require__(/*! App:Admin */ 16).reloadLicensing(false); + } + }; + + AdminSettingsLicensing.prototype.onShow = function () + { + this.adminDomain(Settings.settingsGet('AdminDomain')); + }; + + AdminSettingsLicensing.prototype.showActivationForm = function () + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:Activate */ 101)); + }; + + /** + * @returns {string} + */ + AdminSettingsLicensing.prototype.licenseExpiredMomentValue = function () + { + var + iTime = this.licenseExpired(), + oDate = moment.unix(iTime) + ; + + return iTime && 1898625600 === iTime ? 'Never' : (oDate.format('LL') + ' (' + oDate.from(moment()) + ')'); + }; + + module.exports = AdminSettingsLicensing; + + }()); + +/***/ }, + +/***/ 73: +/*!**************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsLogin.js ***! + \**************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18) + ; + + /** + * @constructor + */ + function AdminSettingsLogin() + { + this.determineUserLanguage = Data.determineUserLanguage; + this.determineUserDomain = Data.determineUserDomain; + + this.defaultDomain = ko.observable(Settings.settingsGet('LoginDefaultDomain')); + + this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin; + this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + } + + AdminSettingsLogin.prototype.onBuild = function () + { + var + self = this, + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + _.delay(function () { + + var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self); + + self.determineUserLanguage.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'DetermineUserLanguage': bValue ? '1' : '0' + }); + }); + + self.determineUserDomain.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'DetermineUserDomain': bValue ? '1' : '0' + }); + }); + + self.allowLanguagesOnLogin.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'AllowLanguagesOnLogin': bValue ? '1' : '0' + }); + }); + + self.defaultDomain.subscribe(function (sValue) { + Remote.saveAdminConfig(f1, { + 'LoginDefaultDomain': Utils.trim(sValue) + }); + }); + + }, 50); + }; + + module.exports = AdminSettingsLogin; + + }()); + +/***/ }, + +/***/ 74: +/*!*****************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsPackages.js ***! + \*****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Data = __webpack_require__(/*! Storage:Admin:Data */ 18), + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + /** + * @constructor + */ + function AdminSettingsPackages() + { + this.packagesError = ko.observable(''); + + this.packages = Data.packages; + this.packagesLoading = Data.packagesLoading; + this.packagesReal = Data.packagesReal; + this.packagesMainUpdatable = Data.packagesMainUpdatable; + + this.packagesCurrent = this.packages.filter(function (oItem) { + return oItem && '' !== oItem['installed'] && !oItem['compare']; + }); + + this.packagesAvailableForUpdate = this.packages.filter(function (oItem) { + return oItem && '' !== oItem['installed'] && !!oItem['compare']; + }); + + this.packagesAvailableForInstallation = this.packages.filter(function (oItem) { + return oItem && '' === oItem['installed']; + }); + + this.visibility = ko.computed(function () { + return Data.packagesLoading() ? 'visible' : 'hidden'; + }, this); + } + + AdminSettingsPackages.prototype.onShow = function () + { + this.packagesError(''); + }; + + AdminSettingsPackages.prototype.onBuild = function () + { + __webpack_require__(/*! App:Admin */ 16).reloadPackagesList(); + }; + + AdminSettingsPackages.prototype.requestHelper = function (oPackage, bInstall) + { + var self = this; + return function (sResult, oData) { + + if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) + { + if (oData && oData.ErrorCode) + { + self.packagesError(Utils.getNotification(oData.ErrorCode)); + } + else + { + self.packagesError(Utils.getNotification( + bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage)); + } + } + + _.each(Data.packages(), function (oItem) { + if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file']) + { + oPackage['loading'](false); + oItem['loading'](false); + } + }); + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result['Reload']) + { + window.location.reload(); + } + else + { + __webpack_require__(/*! App:Admin */ 16).reloadPackagesList(); + } + }; + }; + + AdminSettingsPackages.prototype.deletePackage = function (oPackage) + { + if (oPackage) + { + oPackage['loading'](true); + Remote.packageDelete(this.requestHelper(oPackage, false), oPackage); + } + }; + + AdminSettingsPackages.prototype.installPackage = function (oPackage) + { + if (oPackage) + { + oPackage['loading'](true); + Remote.packageInstall(this.requestHelper(oPackage, true), oPackage); + } + }; + + module.exports = AdminSettingsPackages; + + }()); + +/***/ }, + +/***/ 75: +/*!****************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsPlugins.js ***! + \****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18), + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + /** + * @constructor + */ + function AdminSettingsPlugins() + { + this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins')); + + this.pluginsError = ko.observable(''); + + this.plugins = Data.plugins; + this.pluginsLoading = Data.pluginsLoading; + + this.visibility = ko.computed(function () { + return Data.pluginsLoading() ? 'visible' : 'hidden'; + }, this); + + this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this); + this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this); + } + + AdminSettingsPlugins.prototype.disablePlugin = function (oPlugin) + { + oPlugin.disabled(!oPlugin.disabled()); + Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled()); + }; + + AdminSettingsPlugins.prototype.configurePlugin = function (oPlugin) + { + Remote.plugin(this.onPluginLoadRequest, oPlugin.name); + }; + + AdminSettingsPlugins.prototype.onBuild = function (oDom) + { + var self = this; + + oDom + .on('click', '.e-item .configure-plugin-action', function () { + var oPlugin = ko.dataFor(this); + if (oPlugin) + { + self.configurePlugin(oPlugin); + } + }) + .on('click', '.e-item .disabled-plugin', function () { + var oPlugin = ko.dataFor(this); + if (oPlugin) + { + self.disablePlugin(oPlugin); + } + }) + ; + + this.enabledPlugins.subscribe(function (bValue) { + Remote.saveAdminConfig(Utils.emptyFunction, { + 'EnabledPlugins': bValue ? '1' : '0' + }); + }); + }; + + AdminSettingsPlugins.prototype.onShow = function () + { + this.pluginsError(''); + __webpack_require__(/*! App:Admin */ 16).reloadPluginList(); + }; + + AdminSettingsPlugins.prototype.onPluginLoadRequest = function (sResult, oData) + { + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(__webpack_require__(/*! View:Popup:Plugin */ 109), [oData.Result]); + } + }; + + AdminSettingsPlugins.prototype.onPluginDisableRequest = function (sResult, oData) + { + if (Enums.StorageResultType.Success === sResult && oData) + { + if (!oData.Result && oData.ErrorCode) + { + if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage) + { + this.pluginsError(oData.ErrorMessage); + } + else + { + this.pluginsError(Utils.getNotification(oData.ErrorCode)); + } + } + } + + __webpack_require__(/*! App:Admin */ 16).reloadPluginList(); + }; + + module.exports = AdminSettingsPlugins; + + }()); + +/***/ }, + +/***/ 76: +/*!*****************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsSecurity.js ***! + \*****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18), + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + /** + * @constructor + */ + function AdminSettingsSecurity() + { + this.useLocalProxyForExternalImages = Data.useLocalProxyForExternalImages; + + this.capaOpenPGP = ko.observable(Settings.capa(Enums.Capa.OpenPGP)); + this.capaTwoFactorAuth = ko.observable(Settings.capa(Enums.Capa.TwoFactor)); + + this.adminLogin = ko.observable(Settings.settingsGet('AdminLogin')); + this.adminPassword = ko.observable(''); + this.adminPasswordNew = ko.observable(''); + this.adminPasswordNew2 = ko.observable(''); + this.adminPasswordNewError = ko.observable(false); + + this.adminPasswordUpdateError = ko.observable(false); + this.adminPasswordUpdateSuccess = ko.observable(false); + + this.adminPassword.subscribe(function () { + this.adminPasswordUpdateError(false); + this.adminPasswordUpdateSuccess(false); + }, this); + + this.adminPasswordNew.subscribe(function () { + this.adminPasswordUpdateError(false); + this.adminPasswordUpdateSuccess(false); + this.adminPasswordNewError(false); + }, this); + + this.adminPasswordNew2.subscribe(function () { + this.adminPasswordUpdateError(false); + this.adminPasswordUpdateSuccess(false); + this.adminPasswordNewError(false); + }, this); + + this.saveNewAdminPasswordCommand = Utils.createCommand(this, function () { + + if (this.adminPasswordNew() !== this.adminPasswordNew2()) + { + this.adminPasswordNewError(true); + return false; + } + + this.adminPasswordUpdateError(false); + this.adminPasswordUpdateSuccess(false); + + Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, { + 'Password': this.adminPassword(), + 'NewPassword': this.adminPasswordNew() + }); + + }, function () { + return '' !== this.adminPassword() && '' !== this.adminPasswordNew() && '' !== this.adminPasswordNew2(); + }); + + this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this); + } + + AdminSettingsSecurity.prototype.onNewAdminPasswordResponse = function (sResult, oData) + { + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + this.adminPassword(''); + this.adminPasswordNew(''); + this.adminPasswordNew2(''); + + this.adminPasswordUpdateSuccess(true); + } + else + { + this.adminPasswordUpdateError(true); + } + }; + + AdminSettingsSecurity.prototype.onBuild = function () + { + var + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) + ; + + this.capaOpenPGP.subscribe(function (bValue) { + Remote.saveAdminConfig(Utils.emptyFunction, { + 'CapaOpenPGP': bValue ? '1' : '0' + }); + }); + + this.capaTwoFactorAuth.subscribe(function (bValue) { + Remote.saveAdminConfig(Utils.emptyFunction, { + 'CapaTwoFactorAuth': bValue ? '1' : '0' + }); + }); + + this.useLocalProxyForExternalImages.subscribe(function (bValue) { + Remote.saveAdminConfig(null, { + 'UseLocalProxyForExternalImages': bValue ? '1' : '0' + }); + }); + }; + + AdminSettingsSecurity.prototype.onHide = function () { this.adminPassword(''); this.adminPasswordNew(''); this.adminPasswordNew2(''); + }; - this.adminPasswordUpdateSuccess(true); - } - else + /** + * @return {string} + */ + AdminSettingsSecurity.prototype.phpInfoLink = function () { - this.adminPasswordUpdateError(true); + return LinkBuilder.phpInfo(); + }; + + module.exports = AdminSettingsSecurity; + + }()); + + +/***/ }, + +/***/ 77: +/*!***************************************************!*\ + !*** ./dev/Settings/Admin/AdminSettingsSocial.js ***! + \***************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + */ + function AdminSettingsSocial() + { + var Data = __webpack_require__(/*! Storage:Admin:Data */ 18); + + this.googleEnable = Data.googleEnable; + this.googleClientID = Data.googleClientID; + this.googleApiKey = Data.googleApiKey; + this.googleClientSecret = Data.googleClientSecret; + this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); + this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); + this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle); + + this.facebookSupported = Data.facebookSupported; + this.facebookEnable = Data.facebookEnable; + this.facebookAppID = Data.facebookAppID; + this.facebookAppSecret = Data.facebookAppSecret; + this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); + this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); + + this.twitterEnable = Data.twitterEnable; + this.twitterConsumerKey = Data.twitterConsumerKey; + this.twitterConsumerSecret = Data.twitterConsumerSecret; + this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); + this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); + + this.dropboxEnable = Data.dropboxEnable; + this.dropboxApiKey = Data.dropboxApiKey; + this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); } - }; - - AdminSettingsSecurity.prototype.onBuild = function () - { - var - Remote = require('Storage:Admin:Remote') - ; - - this.capaOpenPGP.subscribe(function (bValue) { - Remote.saveAdminConfig(Utils.emptyFunction, { - 'CapaOpenPGP': bValue ? '1' : '0' - }); - }); - - this.capaTwoFactorAuth.subscribe(function (bValue) { - Remote.saveAdminConfig(Utils.emptyFunction, { - 'CapaTwoFactorAuth': bValue ? '1' : '0' - }); - }); - - this.useLocalProxyForExternalImages.subscribe(function (bValue) { - Remote.saveAdminConfig(null, { - 'UseLocalProxyForExternalImages': bValue ? '1' : '0' - }); - }); - }; - - AdminSettingsSecurity.prototype.onHide = function () - { - this.adminPassword(''); - this.adminPasswordNew(''); - this.adminPasswordNew2(''); - }; - - /** - * @return {string} - */ - AdminSettingsSecurity.prototype.phpInfoLink = function () - { - return LinkBuilder.phpInfo(); - }; - - module.exports = AdminSettingsSecurity; - -}(module, require)); - -},{"Enums":6,"LinkBuilder":9,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Storage:Settings":45,"Utils":11,"_":19,"ko":16}],40:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils') - ; - - /** - * @constructor - */ - function AdminSettingsSocial() - { - var Data = require('Storage:Admin:Data'); - - this.googleEnable = Data.googleEnable; - this.googleClientID = Data.googleClientID; - this.googleApiKey = Data.googleApiKey; - this.googleClientSecret = Data.googleClientSecret; - this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); - this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); - this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle); - - this.facebookSupported = Data.facebookSupported; - this.facebookEnable = Data.facebookEnable; - this.facebookAppID = Data.facebookAppID; - this.facebookAppSecret = Data.facebookAppSecret; - this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); - this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); - - this.twitterEnable = Data.twitterEnable; - this.twitterConsumerKey = Data.twitterConsumerKey; - this.twitterConsumerSecret = Data.twitterConsumerSecret; - this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); - this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); - - this.dropboxEnable = Data.dropboxEnable; - this.dropboxApiKey = Data.dropboxApiKey; - this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); - } - - AdminSettingsSocial.prototype.onBuild = function () - { - var - self = this, - Remote = require('Storage:Admin:Remote') - ; - - _.delay(function () { + AdminSettingsSocial.prototype.onBuild = function () + { var - f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self), - f2 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger2, self), - f3 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger1, self), - f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self), - f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self), - f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self), - f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self), - f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self) + self = this, + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15) ; - self.facebookEnable.subscribe(function (bValue) { - if (self.facebookSupported()) - { + _.delay(function () { + + var + f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self), + f2 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger2, self), + f3 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger1, self), + f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self), + f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self), + f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self), + f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self), + f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self) + ; + + self.facebookEnable.subscribe(function (bValue) { + if (self.facebookSupported()) + { + Remote.saveAdminConfig(Utils.emptyFunction, { + 'FacebookEnable': bValue ? '1' : '0' + }); + } + }); + + self.facebookAppID.subscribe(function (sValue) { + if (self.facebookSupported()) + { + Remote.saveAdminConfig(f1, { + 'FacebookAppID': Utils.trim(sValue) + }); + } + }); + + self.facebookAppSecret.subscribe(function (sValue) { + if (self.facebookSupported()) + { + Remote.saveAdminConfig(f2, { + 'FacebookAppSecret': Utils.trim(sValue) + }); + } + }); + + self.twitterEnable.subscribe(function (bValue) { Remote.saveAdminConfig(Utils.emptyFunction, { - 'FacebookEnable': bValue ? '1' : '0' + 'TwitterEnable': bValue ? '1' : '0' }); - } - }); + }); - self.facebookAppID.subscribe(function (sValue) { - if (self.facebookSupported()) - { - Remote.saveAdminConfig(f1, { - 'FacebookAppID': Utils.trim(sValue) + self.twitterConsumerKey.subscribe(function (sValue) { + Remote.saveAdminConfig(f3, { + 'TwitterConsumerKey': Utils.trim(sValue) }); - } - }); + }); - self.facebookAppSecret.subscribe(function (sValue) { - if (self.facebookSupported()) - { - Remote.saveAdminConfig(f2, { - 'FacebookAppSecret': Utils.trim(sValue) + self.twitterConsumerSecret.subscribe(function (sValue) { + Remote.saveAdminConfig(f4, { + 'TwitterConsumerSecret': Utils.trim(sValue) }); - } - }); - - self.twitterEnable.subscribe(function (bValue) { - Remote.saveAdminConfig(Utils.emptyFunction, { - 'TwitterEnable': bValue ? '1' : '0' }); - }); - self.twitterConsumerKey.subscribe(function (sValue) { - Remote.saveAdminConfig(f3, { - 'TwitterConsumerKey': Utils.trim(sValue) + self.googleEnable.subscribe(function (bValue) { + Remote.saveAdminConfig(Utils.emptyFunction, { + 'GoogleEnable': bValue ? '1' : '0' + }); }); - }); - self.twitterConsumerSecret.subscribe(function (sValue) { - Remote.saveAdminConfig(f4, { - 'TwitterConsumerSecret': Utils.trim(sValue) + self.googleClientID.subscribe(function (sValue) { + Remote.saveAdminConfig(f5, { + 'GoogleClientID': Utils.trim(sValue) + }); }); - }); - self.googleEnable.subscribe(function (bValue) { - Remote.saveAdminConfig(Utils.emptyFunction, { - 'GoogleEnable': bValue ? '1' : '0' + self.googleClientSecret.subscribe(function (sValue) { + Remote.saveAdminConfig(f6, { + 'GoogleClientSecret': Utils.trim(sValue) + }); }); - }); - self.googleClientID.subscribe(function (sValue) { - Remote.saveAdminConfig(f5, { - 'GoogleClientID': Utils.trim(sValue) + self.googleApiKey.subscribe(function (sValue) { + Remote.saveAdminConfig(f7, { + 'GoogleApiKey': Utils.trim(sValue) + }); }); - }); - self.googleClientSecret.subscribe(function (sValue) { - Remote.saveAdminConfig(f6, { - 'GoogleClientSecret': Utils.trim(sValue) + self.dropboxEnable.subscribe(function (bValue) { + Remote.saveAdminConfig(Utils.emptyFunction, { + 'DropboxEnable': bValue ? '1' : '0' + }); }); - }); - self.googleApiKey.subscribe(function (sValue) { - Remote.saveAdminConfig(f7, { - 'GoogleApiKey': Utils.trim(sValue) + self.dropboxApiKey.subscribe(function (sValue) { + Remote.saveAdminConfig(f8, { + 'DropboxApiKey': Utils.trim(sValue) + }); }); - }); - self.dropboxEnable.subscribe(function (bValue) { - Remote.saveAdminConfig(Utils.emptyFunction, { - 'DropboxEnable': bValue ? '1' : '0' - }); - }); + }, 50); + }; - self.dropboxApiKey.subscribe(function (sValue) { - Remote.saveAdminConfig(f8, { - 'DropboxApiKey': Utils.trim(sValue) - }); - }); + module.exports = AdminSettingsSocial; - }, 50); - }; + }()); - module.exports = AdminSettingsSocial; +/***/ }, -}(module, require)); -},{"Enums":6,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Utils":11,"_":19,"ko":16}],41:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ +/***/ 93: +/*!***********************************************!*\ + !*** ./dev/ViewModels/AdminLoginViewModel.js ***! + \***********************************************/ +/***/ function(module, exports, __webpack_require__) { -(function (module, require) { + + (function () { - 'use strict'; + 'use strict'; - var - Enums = require('Enums'), - Utils = require('Utils'), - - Settings = require('Storage:Settings') - ; - - /** - * @constructor - */ - function AbstractData() - { - Utils.initDataConstructorBySettings(this); - } - - AbstractData.prototype.populateDataOnStart = function() - { var - mLayout = Utils.pInt(Settings.settingsGet('Layout')), - aLanguages = Settings.settingsGet('Languages'), - aThemes = Settings.settingsGet('Themes') + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) ; - if (Utils.isArray(aLanguages)) + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function AdminLoginViewModel() { - this.languages(aLanguages); - } + KnoinAbstractViewModel.call(this, 'Center', 'AdminLogin'); - if (Utils.isArray(aThemes)) - { - this.themes(aThemes); - } + this.login = ko.observable(''); + this.password = ko.observable(''); - this.mainLanguage(Settings.settingsGet('Language')); - this.mainTheme(Settings.settingsGet('Theme')); + this.loginError = ko.observable(false); + this.passwordError = ko.observable(false); - this.capaAdditionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts)); - this.capaAdditionalIdentities(Settings.capa(Enums.Capa.AdditionalIdentities)); - this.capaGravatar(Settings.capa(Enums.Capa.Gravatar)); - this.determineUserLanguage(!!Settings.settingsGet('DetermineUserLanguage')); - this.determineUserDomain(!!Settings.settingsGet('DetermineUserDomain')); + this.loginFocus = ko.observable(false); - this.capaThemes(Settings.capa(Enums.Capa.Themes)); - this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin')); - this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings')); - this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages')); + this.login.subscribe(function () { + this.loginError(false); + }, this); - this.editorDefaultType(Settings.settingsGet('EditorDefaultType')); - this.showImages(!!Settings.settingsGet('ShowImages')); - this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave')); - this.interfaceAnimation(Settings.settingsGet('InterfaceAnimation')); + this.password.subscribe(function () { + this.passwordError(false); + }, this); - this.mainMessagesPerPage(Settings.settingsGet('MPP')); + this.submitRequest = ko.observable(false); + this.submitError = ko.observable(''); - this.desktopNotifications(!!Settings.settingsGet('DesktopNotifications')); - this.useThreads(!!Settings.settingsGet('UseThreads')); - this.replySameFolder(!!Settings.settingsGet('ReplySameFolder')); - this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList')); + this.submitCommand = Utils.createCommand(this, function () { - this.layout(Enums.Layout.SidePreview); - if (-1 < Utils.inArray(mLayout, [Enums.Layout.NoPreview, Enums.Layout.SidePreview, Enums.Layout.BottomPreview])) - { - this.layout(mLayout); - } - this.facebookSupported(!!Settings.settingsGet('SupportedFacebookSocial')); - this.facebookEnable(!!Settings.settingsGet('AllowFacebookSocial')); - this.facebookAppID(Settings.settingsGet('FacebookAppID')); - this.facebookAppSecret(Settings.settingsGet('FacebookAppSecret')); + Utils.triggerAutocompleteInputChange(); - this.twitterEnable(!!Settings.settingsGet('AllowTwitterSocial')); - this.twitterConsumerKey(Settings.settingsGet('TwitterConsumerKey')); - this.twitterConsumerSecret(Settings.settingsGet('TwitterConsumerSecret')); + this.loginError('' === Utils.trim(this.login())); + this.passwordError('' === Utils.trim(this.password())); - this.googleEnable(!!Settings.settingsGet('AllowGoogleSocial')); - this.googleClientID(Settings.settingsGet('GoogleClientID')); - this.googleClientSecret(Settings.settingsGet('GoogleClientSecret')); - this.googleApiKey(Settings.settingsGet('GoogleApiKey')); - - this.dropboxEnable(!!Settings.settingsGet('AllowDropboxSocial')); - this.dropboxApiKey(Settings.settingsGet('DropboxApiKey')); - - this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed')); - }; - - module.exports = AbstractData; - -}(module, require)); -},{"Enums":6,"Storage:Settings":45,"Utils":11}],42:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - - Consts = require('Consts'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - Plugins = require('Plugins'), - LinkBuilder = require('LinkBuilder'), - - Settings = require('Storage:Settings') - ; - - /** - * @constructor - */ - function AbstractRemoteStorage() - { - this.oRequests = {}; - } - - AbstractRemoteStorage.prototype.oRequests = {}; - - /** - * @param {?Function} fCallback - * @param {string} sRequestAction - * @param {string} sType - * @param {?AjaxJsonDefaultResponse} oData - * @param {boolean} bCached - * @param {*=} oRequestParameters - */ - AbstractRemoteStorage.prototype.defaultResponse = function (fCallback, sRequestAction, sType, oData, bCached, oRequestParameters) - { - var - fCall = function () { - if (Enums.StorageResultType.Success !== sType && Globals.bUnload) - { - sType = Enums.StorageResultType.Unload; - } - - if (Enums.StorageResultType.Success === sType && oData && !oData.Result) - { - if (oData && -1 < Utils.inArray(oData.ErrorCode, [ - Enums.Notification.AuthError, Enums.Notification.AccessError, - Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed, - Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError - ])) - { - Globals.iAjaxErrorCount++; - } - - if (oData && Enums.Notification.InvalidToken === oData.ErrorCode) - { - Globals.iTokenErrorCount++; - } - - if (Consts.Values.TokenErrorLimit < Globals.iTokenErrorCount) - { - if (Globals.__APP) - { - Globals.__APP.loginAndLogoutReload(true); - } - } - - if (oData.Logout || Consts.Values.AjaxErrorLimit < Globals.iAjaxErrorCount) - { - if (window.__rlah_clear) - { - window.__rlah_clear(); - } - - if (Globals.__APP) - { - Globals.__APP.loginAndLogoutReload(true); - } - } - } - else if (Enums.StorageResultType.Success === sType && oData && oData.Result) - { - Globals.iAjaxErrorCount = 0; - Globals.iTokenErrorCount = 0; - } - - if (fCallback) - { - Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]); - - fCallback( - sType, - Enums.StorageResultType.Success === sType ? oData : null, - bCached, - sRequestAction, - oRequestParameters - ); - } - } - ; - - switch (sType) - { - case 'success': - sType = Enums.StorageResultType.Success; - break; - case 'abort': - sType = Enums.StorageResultType.Abort; - break; - default: - sType = Enums.StorageResultType.Error; - break; - } - - if (Enums.StorageResultType.Error === sType) - { - _.delay(fCall, 300); - } - else - { - fCall(); - } - }; - - /** - * @param {?Function} fResultCallback - * @param {Object} oParameters - * @param {?number=} iTimeOut = 20000 - * @param {string=} sGetAdd = '' - * @param {Array=} aAbortActions = [] - * @return {jQuery.jqXHR} - */ - AbstractRemoteStorage.prototype.ajaxRequest = function (fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions) - { - var - self = this, - bPost = '' === sGetAdd, - oHeaders = {}, - iStart = (new window.Date()).getTime(), - oDefAjax = null, - sAction = '' - ; - - oParameters = oParameters || {}; - iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000; - sGetAdd = Utils.isUnd(sGetAdd) ? '' : Utils.pString(sGetAdd); - aAbortActions = Utils.isArray(aAbortActions) ? aAbortActions : []; - - sAction = oParameters.Action || ''; - - if (sAction && 0 < aAbortActions.length) - { - _.each(aAbortActions, function (sActionToAbort) { - if (self.oRequests[sActionToAbort]) - { - self.oRequests[sActionToAbort].__aborted = true; - if (self.oRequests[sActionToAbort].abort) - { - self.oRequests[sActionToAbort].abort(); - } - self.oRequests[sActionToAbort] = null; - } - }); - } - - if (bPost) - { - oParameters['XToken'] = Settings.settingsGet('Token'); - } - - oDefAjax = $.ajax({ - 'type': bPost ? 'POST' : 'GET', - 'url': LinkBuilder.ajax(sGetAdd), - 'async': true, - 'dataType': 'json', - 'data': bPost ? oParameters : {}, - 'headers': oHeaders, - 'timeout': iTimeOut, - 'global': true - }); - - oDefAjax.always(function (oData, sType) { - - var bCached = false; - if (oData && oData['Time']) - { - bCached = Utils.pInt(oData['Time']) > (new window.Date()).getTime() - iStart; - } - - if (sAction && self.oRequests[sAction]) - { - if (self.oRequests[sAction].__aborted) - { - sType = 'abort'; - } - - self.oRequests[sAction] = null; - } - - self.defaultResponse(fResultCallback, sAction, sType, oData, bCached, oParameters); - }); - - if (sAction && 0 < aAbortActions.length && -1 < Utils.inArray(sAction, aAbortActions)) - { - if (this.oRequests[sAction]) - { - this.oRequests[sAction].__aborted = true; - if (this.oRequests[sAction].abort) - { - this.oRequests[sAction].abort(); - } - this.oRequests[sAction] = null; - } - - this.oRequests[sAction] = oDefAjax; - } - - return oDefAjax; - }; - - /** - * @param {?Function} fCallback - * @param {string} sAction - * @param {Object=} oParameters - * @param {?number=} iTimeout - * @param {string=} sGetAdd = '' - * @param {Array=} aAbortActions = [] - */ - AbstractRemoteStorage.prototype.defaultRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) - { - oParameters = oParameters || {}; - oParameters.Action = sAction; - - sGetAdd = Utils.pString(sGetAdd); - - Plugins.runHook('ajax-default-request', [sAction, oParameters, sGetAdd]); - - this.ajaxRequest(fCallback, oParameters, - Utils.isUnd(iTimeout) ? Consts.Defaults.DefaultAjaxTimeout : Utils.pInt(iTimeout), sGetAdd, aAbortActions); - }; - - /** - * @param {?Function} fCallback - */ - AbstractRemoteStorage.prototype.noop = function (fCallback) - { - this.defaultRequest(fCallback, 'Noop'); - }; - - /** - * @param {?Function} fCallback - * @param {string} sMessage - * @param {string} sFileName - * @param {number} iLineNo - * @param {string} sLocation - * @param {string} sHtmlCapa - * @param {number} iTime - */ - AbstractRemoteStorage.prototype.jsError = function (fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime) - { - this.defaultRequest(fCallback, 'JsError', { - 'Message': sMessage, - 'FileName': sFileName, - 'LineNo': iLineNo, - 'Location': sLocation, - 'HtmlCapa': sHtmlCapa, - 'TimeOnPage': iTime - }); - }; - - /** - * @param {?Function} fCallback - * @param {string} sType - * @param {Array=} mData = null - * @param {boolean=} bIsError = false - */ - AbstractRemoteStorage.prototype.jsInfo = function (fCallback, sType, mData, bIsError) - { - this.defaultRequest(fCallback, 'JsInfo', { - 'Type': sType, - 'Data': mData, - 'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0' - }); - }; - - /** - * @param {?Function} fCallback - */ - AbstractRemoteStorage.prototype.getPublicKey = function (fCallback) - { - this.defaultRequest(fCallback, 'GetPublicKey'); - }; - - /** - * @param {?Function} fCallback - * @param {string} sVersion - */ - AbstractRemoteStorage.prototype.jsVersion = function (fCallback, sVersion) - { - this.defaultRequest(fCallback, 'Version', { - 'Version': sVersion - }); - }; - - module.exports = AbstractRemoteStorage; - -}(module, require)); -},{"$":14,"Consts":5,"Enums":6,"Globals":8,"LinkBuilder":9,"Plugins":10,"Storage:Settings":45,"Utils":11,"_":19,"window":20}],43:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - AbstractData = require('Storage:Abstract:Data') - ; - - /** - * @constructor - * @extends AbstractData - */ - function AdminDataStorage() - { - AbstractData.call(this); - - this.domainsLoading = ko.observable(false).extend({'throttle': 100}); - this.domains = ko.observableArray([]); - - this.pluginsLoading = ko.observable(false).extend({'throttle': 100}); - this.plugins = ko.observableArray([]); - - this.packagesReal = ko.observable(true); - this.packagesMainUpdatable = ko.observable(true); - this.packagesLoading = ko.observable(false).extend({'throttle': 100}); - this.packages = ko.observableArray([]); - - this.coreReal = ko.observable(true); - this.coreUpdatable = ko.observable(true); - this.coreAccess = ko.observable(true); - this.coreChecking = ko.observable(false).extend({'throttle': 100}); - this.coreUpdating = ko.observable(false).extend({'throttle': 100}); - this.coreRemoteVersion = ko.observable(''); - this.coreRemoteRelease = ko.observable(''); - this.coreVersionCompare = ko.observable(-2); - - this.licensing = ko.observable(false); - this.licensingProcess = ko.observable(false); - this.licenseValid = ko.observable(false); - this.licenseExpired = ko.observable(0); - this.licenseError = ko.observable(''); - - this.licenseTrigger = ko.observable(false); - - this.adminManLoading = ko.computed(function () { - return '000' !== [this.domainsLoading() ? '1' : '0', this.pluginsLoading() ? '1' : '0', this.packagesLoading() ? '1' : '0'].join(''); - }, this); - - this.adminManLoadingVisibility = ko.computed(function () { - return this.adminManLoading() ? 'visible' : 'hidden'; - }, this).extend({'rateLimit': 300}); - } - - _.extend(AdminDataStorage.prototype, AbstractData.prototype); - - AdminDataStorage.prototype.populateDataOnStart = function() - { - AbstractData.prototype.populateDataOnStart.call(this); - }; - - module.exports = new AdminDataStorage(); - -}(module, require)); -},{"Storage:Abstract:Data":41,"_":19,"ko":16}],44:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - AbstractRemoteStorage = require('Storage:Abstract:Remote') - ; - - /** - * @constructor - * @extends AbstractRemoteStorage - */ - function AdminRemoteStorage() - { - AbstractRemoteStorage.call(this); - - this.oRequests = {}; - } - - _.extend(AdminRemoteStorage.prototype, AbstractRemoteStorage.prototype); - - /** - * @param {?Function} fCallback - * @param {string} sLogin - * @param {string} sPassword - */ - AdminRemoteStorage.prototype.adminLogin = function (fCallback, sLogin, sPassword) - { - this.defaultRequest(fCallback, 'AdminLogin', { - 'Login': sLogin, - 'Password': sPassword - }); - }; - - /** - * @param {?Function} fCallback - */ - AdminRemoteStorage.prototype.adminLogout = function (fCallback) - { - this.defaultRequest(fCallback, 'AdminLogout'); - }; - - /** - * @param {?Function} fCallback - * @param {?} oData - */ - AdminRemoteStorage.prototype.saveAdminConfig = function (fCallback, oData) - { - this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData); - }; - - /** - * @param {?Function} fCallback - */ - AdminRemoteStorage.prototype.domainList = function (fCallback) - { - this.defaultRequest(fCallback, 'AdminDomainList'); - }; - - /** - * @param {?Function} fCallback - */ - AdminRemoteStorage.prototype.pluginList = function (fCallback) - { - this.defaultRequest(fCallback, 'AdminPluginList'); - }; - - /** - * @param {?Function} fCallback - */ - AdminRemoteStorage.prototype.packagesList = function (fCallback) - { - this.defaultRequest(fCallback, 'AdminPackagesList'); - }; - - /** - * @param {?Function} fCallback - */ - AdminRemoteStorage.prototype.coreData = function (fCallback) - { - this.defaultRequest(fCallback, 'AdminCoreData'); - }; - - /** - * @param {?Function} fCallback - */ - AdminRemoteStorage.prototype.updateCoreData = function (fCallback) - { - this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000); - }; - - /** - * @param {?Function} fCallback - * @param {Object} oPackage - */ - AdminRemoteStorage.prototype.packageInstall = function (fCallback, oPackage) - { - this.defaultRequest(fCallback, 'AdminPackageInstall', { - 'Id': oPackage.id, - 'Type': oPackage.type, - 'File': oPackage.file - }, 60000); - }; - - /** - * @param {?Function} fCallback - * @param {Object} oPackage - */ - AdminRemoteStorage.prototype.packageDelete = function (fCallback, oPackage) - { - this.defaultRequest(fCallback, 'AdminPackageDelete', { - 'Id': oPackage.id - }); - }; - - /** - * @param {?Function} fCallback - * @param {string} sName - */ - AdminRemoteStorage.prototype.domain = function (fCallback, sName) - { - this.defaultRequest(fCallback, 'AdminDomainLoad', { - 'Name': sName - }); - }; - - /** - * @param {?Function} fCallback - * @param {string} sName - */ - AdminRemoteStorage.prototype.plugin = function (fCallback, sName) - { - this.defaultRequest(fCallback, 'AdminPluginLoad', { - 'Name': sName - }); - }; - - /** - * @param {?Function} fCallback - * @param {string} sName - */ - AdminRemoteStorage.prototype.domainDelete = function (fCallback, sName) - { - this.defaultRequest(fCallback, 'AdminDomainDelete', { - 'Name': sName - }); - }; - - /** - * @param {?Function} fCallback - * @param {string} sName - * @param {boolean} bDisabled - */ - AdminRemoteStorage.prototype.domainDisable = function (fCallback, sName, bDisabled) - { - return this.defaultRequest(fCallback, 'AdminDomainDisable', { - 'Name': sName, - 'Disabled': !!bDisabled ? '1' : '0' - }); - }; - - /** - * @param {?Function} fCallback - * @param {Object} oConfig - */ - AdminRemoteStorage.prototype.pluginSettingsUpdate = function (fCallback, oConfig) - { - return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig); - }; - - /** - * @param {?Function} fCallback - * @param {boolean} bForce - */ - AdminRemoteStorage.prototype.licensing = function (fCallback, bForce) - { - return this.defaultRequest(fCallback, 'AdminLicensing', { - 'Force' : bForce ? '1' : '0' - }); - }; - - /** - * @param {?Function} fCallback - * @param {string} sDomain - * @param {string} sKey - */ - AdminRemoteStorage.prototype.licensingActivate = function (fCallback, sDomain, sKey) - { - return this.defaultRequest(fCallback, 'AdminLicensingActivate', { - 'Domain' : sDomain, - 'Key' : sKey - }); - }; - - /** - * @param {?Function} fCallback - * @param {string} sName - * @param {boolean} bDisabled - */ - AdminRemoteStorage.prototype.pluginDisable = function (fCallback, sName, bDisabled) - { - return this.defaultRequest(fCallback, 'AdminPluginDisable', { - 'Name': sName, - 'Disabled': !!bDisabled ? '1' : '0' - }); - }; - - AdminRemoteStorage.prototype.createOrUpdateDomain = function (fCallback, - bCreate, sName, sIncHost, iIncPort, sIncSecure, bIncShortLogin, - sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, sWhiteList) - { - this.defaultRequest(fCallback, 'AdminDomainSave', { - 'Create': bCreate ? '1' : '0', - 'Name': sName, - 'IncHost': sIncHost, - 'IncPort': iIncPort, - 'IncSecure': sIncSecure, - 'IncShortLogin': bIncShortLogin ? '1' : '0', - 'OutHost': sOutHost, - 'OutPort': iOutPort, - 'OutSecure': sOutSecure, - 'OutShortLogin': bOutShortLogin ? '1' : '0', - 'OutAuth': bOutAuth ? '1' : '0', - 'WhiteList': sWhiteList - }); - }; - - AdminRemoteStorage.prototype.testConnectionForDomain = function (fCallback, sName, - sIncHost, iIncPort, sIncSecure, - sOutHost, iOutPort, sOutSecure, bOutAuth) - { - this.defaultRequest(fCallback, 'AdminDomainTest', { - 'Name': sName, - 'IncHost': sIncHost, - 'IncPort': iIncPort, - 'IncSecure': sIncSecure, - 'OutHost': sOutHost, - 'OutPort': iOutPort, - 'OutSecure': sOutSecure, - 'OutAuth': bOutAuth ? '1' : '0' - }); - }; - - /** - * @param {?Function} fCallback - * @param {?} oData - */ - AdminRemoteStorage.prototype.testContacts = function (fCallback, oData) - { - this.defaultRequest(fCallback, 'AdminContactsTest', oData); - }; - - /** - * @param {?Function} fCallback - * @param {?} oData - */ - AdminRemoteStorage.prototype.saveNewAdminPassword = function (fCallback, oData) - { - this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData); - }; - - /** - * @param {?Function} fCallback - */ - AdminRemoteStorage.prototype.adminPing = function (fCallback) - { - this.defaultRequest(fCallback, 'AdminPing'); - }; - - module.exports = new AdminRemoteStorage(); - -}(module, require)); -},{"Storage:Abstract:Remote":42,"_":19}],45:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - - Utils = require('Utils') - ; - - /** - * @constructor - */ - function SettingsStorage() - { - this.oSettings = window['rainloopAppData'] || {}; - this.oSettings = Utils.isNormal(this.oSettings) ? this.oSettings : {}; - } - - SettingsStorage.prototype.oSettings = null; - - /** - * @param {string} sName - * @return {?} - */ - SettingsStorage.prototype.settingsGet = function (sName) - { - return Utils.isUnd(this.oSettings[sName]) ? null : this.oSettings[sName]; - }; - - /** - * @param {string} sName - * @param {?} mValue - */ - SettingsStorage.prototype.settingsSet = function (sName, mValue) - { - this.oSettings[sName] = mValue; - }; - - /** - * @param {string} sName - * @return {boolean} - */ - SettingsStorage.prototype.capa = function (sName) - { - var mCapa = this.settingsGet('Capa'); - return Utils.isArray(mCapa) && Utils.isNormal(sName) && -1 < Utils.inArray(sName, mCapa); - }; - - - module.exports = new SettingsStorage(); - -}(module, require)); -},{"Utils":11,"window":20}],46:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Remote = require('Storage:Admin:Remote'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function AdminLoginViewModel() - { - KnoinAbstractViewModel.call(this, 'Center', 'AdminLogin'); - - this.login = ko.observable(''); - this.password = ko.observable(''); - - this.loginError = ko.observable(false); - this.passwordError = ko.observable(false); - - this.loginFocus = ko.observable(false); - - this.login.subscribe(function () { - this.loginError(false); - }, this); - - this.password.subscribe(function () { - this.passwordError(false); - }, this); - - this.submitRequest = ko.observable(false); - this.submitError = ko.observable(''); - - this.submitCommand = Utils.createCommand(this, function () { - - Utils.triggerAutocompleteInputChange(); - - this.loginError('' === Utils.trim(this.login())); - this.passwordError('' === Utils.trim(this.password())); - - if (this.loginError() || this.passwordError()) - { - return false; - } - - this.submitRequest(true); - - Remote.adminLogin(_.bind(function (sResult, oData) { - - if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action) + if (this.loginError() || this.passwordError()) { - if (oData.Result) - { - require('App:Admin').loginAndLogoutReload(); - } - else if (oData.ErrorCode) - { - this.submitRequest(false); - this.submitError(Utils.getNotification(oData.ErrorCode)); - } - } - else - { - this.submitRequest(false); - this.submitError(Utils.getNotification(Enums.Notification.UnknownError)); + return false; } - }, this), this.login(), this.password()); + this.submitRequest(true); - return true; + Remote.adminLogin(_.bind(function (sResult, oData) { - }, function () { - return !this.submitRequest(); - }); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Admin:Login', 'AdminLoginViewModel'], AdminLoginViewModel); - _.extend(AdminLoginViewModel.prototype, KnoinAbstractViewModel.prototype); - - AdminLoginViewModel.prototype.onShow = function () - { - kn.routeOff(); - - _.delay(_.bind(function () { - this.loginFocus(true); - }, this), 100); - - }; - - AdminLoginViewModel.prototype.onHide = function () - { - this.loginFocus(false); - }; - - AdminLoginViewModel.prototype.onBuild = function () - { - Utils.triggerAutocompleteInputChange(true); - }; - - AdminLoginViewModel.prototype.submitForm = function () - { - this.submitCommand(); - }; - - module.exports = AdminLoginViewModel; - -}(module, require)); -},{"App:Admin":3,"App:Knoin":21,"Enums":6,"Knoin:AbstractViewModel":24,"Storage:Admin:Remote":44,"Utils":11,"_":19,"ko":16}],47:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - Globals = require('Globals'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @param {?} oScreen - * - * @constructor - * @extends KnoinAbstractViewModel - */ - function AdminSettingsMenuViewModel(oScreen) - { - KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu'); - - this.leftPanelDisabled = Globals.leftPanelDisabled; - - this.menu = oScreen.menu; - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Admin:SettingsMenu', 'AdminSettingsMenuViewModel'], AdminSettingsMenuViewModel); - _.extend(AdminSettingsMenuViewModel.prototype, KnoinAbstractViewModel.prototype); - - AdminSettingsMenuViewModel.prototype.link = function (sRoute) - { - return '#/' + sRoute; - }; - - module.exports = AdminSettingsMenuViewModel; - -}(module, require)); - -},{"App:Knoin":21,"Globals":8,"Knoin:AbstractViewModel":24,"_":19}],48:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data'), - Remote = require('Storage:Admin:Remote'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function AdminSettingsPaneViewModel() - { - KnoinAbstractViewModel.call(this, 'Right', 'AdminPane'); - - this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain')); - this.version = ko.observable(Settings.settingsGet('Version')); - - this.adminManLoadingVisibility = Data.adminManLoadingVisibility; - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Admin:SettingsPane', 'AdminSettingsPaneViewModel'], AdminSettingsPaneViewModel); - _.extend(AdminSettingsPaneViewModel.prototype, KnoinAbstractViewModel.prototype); - - AdminSettingsPaneViewModel.prototype.logoutClick = function () - { - Remote.adminLogout(function () { - require('App:Admin').loginAndLogoutReload(); - }); - }; - - module.exports = AdminSettingsPaneViewModel; - -}(module, require)); -},{"App:Admin":3,"App:Knoin":21,"Knoin:AbstractViewModel":24,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Storage:Settings":45,"_":19,"ko":16}],49:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Settings = require('Storage:Settings'), - Data = require('Storage:Admin:Data'), - Remote = require('Storage:Admin:Remote'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsActivateViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsActivate'); - - var self = this; - - this.domain = ko.observable(''); - this.key = ko.observable(''); - this.key.focus = ko.observable(false); - this.activationSuccessed = ko.observable(false); - - this.licenseTrigger = Data.licenseTrigger; - - this.activateProcess = ko.observable(false); - this.activateText = ko.observable(''); - this.activateText.isError = ko.observable(false); - - this.key.subscribe(function () { - this.activateText(''); - this.activateText.isError(false); - }, this); - - this.activationSuccessed.subscribe(function (bValue) { - if (bValue) - { - this.licenseTrigger(!this.licenseTrigger()); - } - }, this); - - this.activateCommand = Utils.createCommand(this, function () { - - this.activateProcess(true); - if (this.validateSubscriptionKey()) - { - Remote.licensingActivate(function (sResult, oData) { - - self.activateProcess(false); - if (Enums.StorageResultType.Success === sResult && oData.Result) + if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action) { - if (true === oData.Result) + if (oData.Result) { - self.activationSuccessed(true); - self.activateText('Subscription Key Activated Successfully'); - self.activateText.isError(false); + __webpack_require__(/*! App:Admin */ 16).loginAndLogoutReload(); } - else + else if (oData.ErrorCode) { - self.activateText(oData.Result); - self.activateText.isError(true); - self.key.focus(true); + this.submitRequest(false); + this.submitError(Utils.getNotification(oData.ErrorCode)); } } - else if (oData.ErrorCode) - { - self.activateText(Utils.getNotification(oData.ErrorCode)); - self.activateText.isError(true); - self.key.focus(true); - } else { - self.activateText(Utils.getNotification(Enums.Notification.UnknownError)); - self.activateText.isError(true); - self.key.focus(true); + this.submitRequest(false); + this.submitError(Utils.getNotification(Enums.Notification.UnknownError)); } - }, this.domain(), this.key()); - } - else - { - this.activateProcess(false); - this.activateText('Invalid Subscription Key'); - this.activateText.isError(true); - this.key.focus(true); - } + }, this), this.login(), this.password()); - }, function () { - return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed(); - }); + return true; - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:Activate', 'PopupsActivateViewModel'], PopupsActivateViewModel); - _.extend(PopupsActivateViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsActivateViewModel.prototype.onShow = function () - { - this.domain(Settings.settingsGet('AdminDomain')); - if (!this.activateProcess()) - { - this.key(''); - this.activateText(''); - this.activateText.isError(false); - this.activationSuccessed(false); - } - }; - - PopupsActivateViewModel.prototype.onFocus = function () - { - if (!this.activateProcess()) - { - this.key.focus(true); - } - }; - - /** - * @returns {boolean} - */ - PopupsActivateViewModel.prototype.validateSubscriptionKey = function () - { - var sValue = this.key(); - return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue)); - }; - - module.exports = PopupsActivateViewModel; - -}(module, require)); -},{"App:Knoin":21,"Enums":6,"Knoin:AbstractViewModel":24,"Storage:Admin:Data":43,"Storage:Admin:Remote":44,"Storage:Settings":45,"Utils":11,"_":19,"ko":16}],50:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - key = require('key'), - - Enums = require('Enums'), - Utils = require('Utils'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsAskViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAsk'); - - this.askDesc = ko.observable(''); - this.yesButton = ko.observable(''); - this.noButton = ko.observable(''); - - this.yesFocus = ko.observable(false); - this.noFocus = ko.observable(false); - - this.fYesAction = null; - this.fNoAction = null; - - this.bDisabeCloseOnEsc = true; - this.sDefaultKeyScope = Enums.KeyState.PopupAsk; - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:Ask', 'PopupsAskViewModel'], PopupsAskViewModel); - _.extend(PopupsAskViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsAskViewModel.prototype.clearPopup = function () - { - this.askDesc(''); - this.yesButton(Utils.i18n('POPUPS_ASK/BUTTON_YES')); - this.noButton(Utils.i18n('POPUPS_ASK/BUTTON_NO')); - - this.yesFocus(false); - this.noFocus(false); - - this.fYesAction = null; - this.fNoAction = null; - }; - - PopupsAskViewModel.prototype.yesClick = function () - { - this.cancelCommand(); - - if (Utils.isFunc(this.fYesAction)) - { - this.fYesAction.call(null); - } - }; - - PopupsAskViewModel.prototype.noClick = function () - { - this.cancelCommand(); - - if (Utils.isFunc(this.fNoAction)) - { - this.fNoAction.call(null); - } - }; - - /** - * @param {string} sAskDesc - * @param {Function=} fYesFunc - * @param {Function=} fNoFunc - * @param {string=} sYesButton - * @param {string=} sNoButton - */ - PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton) - { - this.clearPopup(); - - this.fYesAction = fYesFunc || null; - this.fNoAction = fNoFunc || null; - - this.askDesc(sAskDesc || ''); - if (sYesButton) - { - this.yesButton(sYesButton); - } - - if (sYesButton) - { - this.yesButton(sNoButton); - } - }; - - PopupsAskViewModel.prototype.onFocus = function () - { - this.yesFocus(true); - }; - - PopupsAskViewModel.prototype.onBuild = function () - { - key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function () { - if (this.yesFocus()) - { - this.noFocus(true); - } - else - { - this.yesFocus(true); - } - return false; - }, this)); - - key('esc', Enums.KeyState.PopupAsk, _.bind(function () { - this.noClick(); - return false; - }, this)); - }; - - module.exports = PopupsAskViewModel; - -}(module, require)); -},{"App:Knoin":21,"Enums":6,"Knoin:AbstractViewModel":24,"Utils":11,"_":19,"key":15,"ko":16}],51:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Consts = require('Consts'), - Utils = require('Utils'), - - Remote = require('Storage:Admin:Remote'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsDomainViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsDomain'); - - this.edit = ko.observable(false); - this.saving = ko.observable(false); - this.savingError = ko.observable(''); - this.whiteListPage = ko.observable(false); - - this.testing = ko.observable(false); - this.testingDone = ko.observable(false); - this.testingImapError = ko.observable(false); - this.testingSmtpError = ko.observable(false); - this.testingImapErrorDesc = ko.observable(''); - this.testingSmtpErrorDesc = ko.observable(''); - - this.testingImapError.subscribe(function (bValue) { - if (!bValue) - { - this.testingImapErrorDesc(''); - } - }, this); - - this.testingSmtpError.subscribe(function (bValue) { - if (!bValue) - { - this.testingSmtpErrorDesc(''); - } - }, this); - - this.testingImapErrorDesc = ko.observable(''); - this.testingSmtpErrorDesc = ko.observable(''); - - this.imapServerFocus = ko.observable(false); - this.smtpServerFocus = ko.observable(false); - - this.name = ko.observable(''); - this.name.focused = ko.observable(false); - - this.imapServer = ko.observable(''); - this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort); - this.imapSecure = ko.observable(Enums.ServerSecure.None); - this.imapShortLogin = ko.observable(false); - this.smtpServer = ko.observable(''); - this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort); - this.smtpSecure = ko.observable(Enums.ServerSecure.None); - this.smtpShortLogin = ko.observable(false); - this.smtpAuth = ko.observable(true); - this.whiteList = ko.observable(''); - - this.headerText = ko.computed(function () { - var sName = this.name(); - return this.edit() ? 'Edit Domain "' + sName + '"' : - 'Add Domain' + ('' === sName ? '' : ' "' + sName + '"'); - }, this); - - this.domainIsComputed = ko.computed(function () { - return '' !== this.name() && - '' !== this.imapServer() && - '' !== this.imapPort() && - '' !== this.smtpServer() && - '' !== this.smtpPort(); - }, this); - - this.canBeTested = ko.computed(function () { - return !this.testing() && this.domainIsComputed(); - }, this); - - this.canBeSaved = ko.computed(function () { - return !this.saving() && this.domainIsComputed(); - }, this); - - this.createOrAddCommand = Utils.createCommand(this, function () { - this.saving(true); - Remote.createOrUpdateDomain( - _.bind(this.onDomainCreateOrSaveResponse, this), - !this.edit(), - this.name(), - this.imapServer(), - Utils.pInt(this.imapPort()), - this.imapSecure(), - this.imapShortLogin(), - this.smtpServer(), - Utils.pInt(this.smtpPort()), - this.smtpSecure(), - this.smtpShortLogin(), - this.smtpAuth(), - this.whiteList() - ); - }, this.canBeSaved); - - this.testConnectionCommand = Utils.createCommand(this, function () { - this.whiteListPage(false); - this.testingDone(false); - this.testingImapError(false); - this.testingSmtpError(false); - this.testing(true); - Remote.testConnectionForDomain( - _.bind(this.onTestConnectionResponse, this), - this.name(), - this.imapServer(), - Utils.pInt(this.imapPort()), - this.imapSecure(), - this.smtpServer(), - Utils.pInt(this.smtpPort()), - this.smtpSecure(), - this.smtpAuth() - ); - }, this.canBeTested); - - this.whiteListCommand = Utils.createCommand(this, function () { - this.whiteListPage(!this.whiteListPage()); - }); - - // smart form improvements - this.imapServerFocus.subscribe(function (bValue) { - if (bValue && '' !== this.name() && '' === this.imapServer()) - { - this.imapServer(this.name().replace(/[.]?[*][.]?/g, '')); - } - }, this); - - this.smtpServerFocus.subscribe(function (bValue) { - if (bValue && '' !== this.imapServer() && '' === this.smtpServer()) - { - this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp')); - } - }, this); - - this.imapSecure.subscribe(function (sValue) { - var iPort = Utils.pInt(this.imapPort()); - sValue = Utils.pString(sValue); - switch (sValue) - { - case '0': - if (993 === iPort) - { - this.imapPort('143'); - } - break; - case '1': - if (143 === iPort) - { - this.imapPort('993'); - } - break; - } - }, this); - - this.smtpSecure.subscribe(function (sValue) { - var iPort = Utils.pInt(this.smtpPort()); - sValue = Utils.pString(sValue); - switch (sValue) - { - case '0': - if (465 === iPort || 587 === iPort) - { - this.smtpPort('25'); - } - break; - case '1': - if (25 === iPort || 587 === iPort) - { - this.smtpPort('465'); - } - break; - case '2': - if (25 === iPort || 465 === iPort) - { - this.smtpPort('587'); - } - break; - } - }, this); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:Domain', 'PopupsDomainViewModel'], PopupsDomainViewModel); - _.extend(PopupsDomainViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsDomainViewModel.prototype.onTestConnectionResponse = function (sResult, oData) - { - this.testing(false); - if (Enums.StorageResultType.Success === sResult && oData.Result) - { - this.testingDone(true); - this.testingImapError(true !== oData.Result.Imap); - this.testingSmtpError(true !== oData.Result.Smtp); - - if (this.testingImapError() && oData.Result.Imap) - { - this.testingImapErrorDesc(oData.Result.Imap); - } - - if (this.testingSmtpError() && oData.Result.Smtp) - { - this.testingSmtpErrorDesc(oData.Result.Smtp); - } - } - else - { - this.testingImapError(true); - this.testingSmtpError(true); - } - }; - - PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult, oData) - { - this.saving(false); - if (Enums.StorageResultType.Success === sResult && oData) - { - if (oData.Result) - { - require('App:Admin').reloadDomainList(); - this.closeCommand(); - } - else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode) - { - this.savingError('Domain already exists'); - } - } - else - { - this.savingError('Unknown error'); - } - }; - - PopupsDomainViewModel.prototype.onHide = function () - { - this.whiteListPage(false); - }; - - PopupsDomainViewModel.prototype.onShow = function (oDomain) - { - this.saving(false); - this.whiteListPage(false); - - this.testing(false); - this.testingDone(false); - this.testingImapError(false); - this.testingSmtpError(false); - - this.clearForm(); - if (oDomain) - { - this.edit(true); - - this.name(Utils.trim(oDomain.Name)); - this.imapServer(Utils.trim(oDomain.IncHost)); - this.imapPort('' + Utils.pInt(oDomain.IncPort)); - this.imapSecure(Utils.trim(oDomain.IncSecure)); - this.imapShortLogin(!!oDomain.IncShortLogin); - this.smtpServer(Utils.trim(oDomain.OutHost)); - this.smtpPort('' + Utils.pInt(oDomain.OutPort)); - this.smtpSecure(Utils.trim(oDomain.OutSecure)); - this.smtpShortLogin(!!oDomain.OutShortLogin); - this.smtpAuth(!!oDomain.OutAuth); - this.whiteList(Utils.trim(oDomain.WhiteList)); - } - }; - - PopupsDomainViewModel.prototype.onFocus = function () - { - if ('' === this.name()) - { - this.name.focused(true); - } - }; - - PopupsDomainViewModel.prototype.clearForm = function () - { - this.edit(false); - this.whiteListPage(false); - - this.savingError(''); - - this.name(''); - this.name.focused(false); - - this.imapServer(''); - this.imapPort('' + Consts.Values.ImapDefaulPort); - this.imapSecure(Enums.ServerSecure.None); - this.imapShortLogin(false); - this.smtpServer(''); - this.smtpPort('' + Consts.Values.SmtpDefaulPort); - this.smtpSecure(Enums.ServerSecure.None); - this.smtpShortLogin(false); - this.smtpAuth(true); - this.whiteList(''); - }; - - module.exports = PopupsDomainViewModel; - -}(module, require)); -},{"App:Admin":3,"App:Knoin":21,"Consts":5,"Enums":6,"Knoin:AbstractViewModel":24,"Storage:Admin:Remote":44,"Utils":11,"_":19,"ko":16}],52:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Utils = require('Utils'), - Globals = require('Globals'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsLanguagesViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsLanguages'); - - this.Data = Globals.__APP.data(); // TODO - - this.exp = ko.observable(false); - - this.languages = ko.computed(function () { - return _.map(this.Data.languages(), function (sLanguage) { - return { - 'key': sLanguage, - 'selected': ko.observable(false), - 'fullName': Utils.convertLangName(sLanguage) - }; + }, function () { + return !this.submitRequest(); }); - }, this); - this.Data.mainLanguage.subscribe(function () { - this.resetMainLanguage(); - }, this); + kn.constructorEnd(this); + } - kn.constructorEnd(this); - } + kn.extendAsViewModel(['View:Admin:Login', 'AdminLoginViewModel'], AdminLoginViewModel); + _.extend(AdminLoginViewModel.prototype, KnoinAbstractViewModel.prototype); - kn.extendAsViewModel(['View:Popup:Languages', 'PopupsLanguagesViewModel'], PopupsLanguagesViewModel); - _.extend(PopupsLanguagesViewModel.prototype, KnoinAbstractViewModel.prototype); + AdminLoginViewModel.prototype.onShow = function () + { + kn.routeOff(); - PopupsLanguagesViewModel.prototype.languageEnName = function (sLanguage) - { - return Utils.convertLangName(sLanguage, true); - }; + _.delay(_.bind(function () { + this.loginFocus(true); + }, this), 100); - PopupsLanguagesViewModel.prototype.resetMainLanguage = function () - { - var sCurrent = this.Data.mainLanguage(); - _.each(this.languages(), function (oItem) { - oItem['selected'](oItem['key'] === sCurrent); - }); - }; + }; - PopupsLanguagesViewModel.prototype.onShow = function () - { - this.exp(true); + AdminLoginViewModel.prototype.onHide = function () + { + this.loginFocus(false); + }; - this.resetMainLanguage(); - }; + AdminLoginViewModel.prototype.onBuild = function () + { + Utils.triggerAutocompleteInputChange(true); + }; - PopupsLanguagesViewModel.prototype.onHide = function () - { - this.exp(false); - }; + AdminLoginViewModel.prototype.submitForm = function () + { + this.submitCommand(); + }; - PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang) - { - this.Data.mainLanguage(sLang); - this.cancelCommand(); - }; + module.exports = AdminLoginViewModel; - module.exports = PopupsLanguagesViewModel; + }()); -}(module, require)); -},{"App:Knoin":21,"Globals":8,"Knoin:AbstractViewModel":24,"Utils":11,"_":19,"ko":16}],53:[function(require,module,exports){ +/***/ }, -(function (module, require) { +/***/ 94: +/*!******************************************************!*\ + !*** ./dev/ViewModels/AdminSettingsMenuViewModel.js ***! + \******************************************************/ +/***/ function(module, exports, __webpack_require__) { - 'use strict'; + + (function () { - var - _ = require('_'), - ko = require('ko'), - key = require('key'), + 'use strict'; - Enums = require('Enums'), - Utils = require('Utils'), + var + _ = __webpack_require__(/*! _ */ 2), + + Globals = __webpack_require__(/*! Common/Globals */ 7), - Remote = require('Storage:Admin:Remote'), + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; + /** + * @param {?} oScreen + * + * @constructor + * @extends KnoinAbstractViewModel + */ + function AdminSettingsMenuViewModel(oScreen) + { + KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu'); - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsPluginViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsPlugin'); + this.leftPanelDisabled = Globals.leftPanelDisabled; - var self = this; + this.menu = oScreen.menu; - this.onPluginSettingsUpdateResponse = _.bind(this.onPluginSettingsUpdateResponse, this); + kn.constructorEnd(this); + } - this.saveError = ko.observable(''); + kn.extendAsViewModel(['View:Admin:SettingsMenu', 'AdminSettingsMenuViewModel'], AdminSettingsMenuViewModel); + _.extend(AdminSettingsMenuViewModel.prototype, KnoinAbstractViewModel.prototype); - this.name = ko.observable(''); - this.readme = ko.observable(''); + AdminSettingsMenuViewModel.prototype.link = function (sRoute) + { + return '#/' + sRoute; + }; - this.configures = ko.observableArray([]); + module.exports = AdminSettingsMenuViewModel; - this.hasReadme = ko.computed(function () { - return '' !== this.readme(); - }, this); + }()); - this.hasConfiguration = ko.computed(function () { - return 0 < this.configures().length; - }, this); - this.readmePopoverConf = { - 'placement': 'top', - 'trigger': 'hover', - 'title': 'About', - 'content': function () { - return self.readme(); +/***/ }, + +/***/ 95: +/*!******************************************************!*\ + !*** ./dev/ViewModels/AdminSettingsPaneViewModel.js ***! + \******************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18), + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function AdminSettingsPaneViewModel() + { + KnoinAbstractViewModel.call(this, 'Right', 'AdminPane'); + + this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain')); + this.version = ko.observable(Settings.settingsGet('Version')); + + this.adminManLoadingVisibility = Data.adminManLoadingVisibility; + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Admin:SettingsPane', 'AdminSettingsPaneViewModel'], AdminSettingsPaneViewModel); + _.extend(AdminSettingsPaneViewModel.prototype, KnoinAbstractViewModel.prototype); + + AdminSettingsPaneViewModel.prototype.logoutClick = function () + { + Remote.adminLogout(function () { + __webpack_require__(/*! App:Admin */ 16).loginAndLogoutReload(); + }); + }; + + module.exports = AdminSettingsPaneViewModel; + + }()); + +/***/ }, + +/***/ 101: +/*!**********************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsActivateViewModel.js ***! + \**********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:Admin:Data */ 18), + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsActivateViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsActivate'); + + var self = this; + + this.domain = ko.observable(''); + this.key = ko.observable(''); + this.key.focus = ko.observable(false); + this.activationSuccessed = ko.observable(false); + + this.licenseTrigger = Data.licenseTrigger; + + this.activateProcess = ko.observable(false); + this.activateText = ko.observable(''); + this.activateText.isError = ko.observable(false); + + this.key.subscribe(function () { + this.activateText(''); + this.activateText.isError(false); + }, this); + + this.activationSuccessed.subscribe(function (bValue) { + if (bValue) + { + this.licenseTrigger(!this.licenseTrigger()); + } + }, this); + + this.activateCommand = Utils.createCommand(this, function () { + + this.activateProcess(true); + if (this.validateSubscriptionKey()) + { + Remote.licensingActivate(function (sResult, oData) { + + self.activateProcess(false); + if (Enums.StorageResultType.Success === sResult && oData.Result) + { + if (true === oData.Result) + { + self.activationSuccessed(true); + self.activateText('Subscription Key Activated Successfully'); + self.activateText.isError(false); + } + else + { + self.activateText(oData.Result); + self.activateText.isError(true); + self.key.focus(true); + } + } + else if (oData.ErrorCode) + { + self.activateText(Utils.getNotification(oData.ErrorCode)); + self.activateText.isError(true); + self.key.focus(true); + } + else + { + self.activateText(Utils.getNotification(Enums.Notification.UnknownError)); + self.activateText.isError(true); + self.key.focus(true); + } + + }, this.domain(), this.key()); + } + else + { + this.activateProcess(false); + this.activateText('Invalid Subscription Key'); + this.activateText.isError(true); + this.key.focus(true); + } + + }, function () { + return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed(); + }); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:Activate', 'PopupsActivateViewModel'], PopupsActivateViewModel); + _.extend(PopupsActivateViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsActivateViewModel.prototype.onShow = function () + { + this.domain(Settings.settingsGet('AdminDomain')); + if (!this.activateProcess()) + { + this.key(''); + this.activateText(''); + this.activateText.isError(false); + this.activationSuccessed(false); } }; - this.saveCommand = Utils.createCommand(this, function () { + PopupsActivateViewModel.prototype.onFocus = function () + { + if (!this.activateProcess()) + { + this.key.focus(true); + } + }; - var oList = {}; + /** + * @returns {boolean} + */ + PopupsActivateViewModel.prototype.validateSubscriptionKey = function () + { + var sValue = this.key(); + return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue)); + }; - oList['Name'] = this.name(); + module.exports = PopupsActivateViewModel; - _.each(this.configures(), function (oItem) { + }()); - var mValue = oItem.value(); - if (false === mValue || true === mValue) +/***/ }, + +/***/ 105: +/*!********************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsDomainViewModel.js ***! + \********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Consts = __webpack_require__(/*! Common/Consts */ 17), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsDomainViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsDomain'); + + this.edit = ko.observable(false); + this.saving = ko.observable(false); + this.savingError = ko.observable(''); + this.whiteListPage = ko.observable(false); + + this.testing = ko.observable(false); + this.testingDone = ko.observable(false); + this.testingImapError = ko.observable(false); + this.testingSmtpError = ko.observable(false); + this.testingImapErrorDesc = ko.observable(''); + this.testingSmtpErrorDesc = ko.observable(''); + + this.testingImapError.subscribe(function (bValue) { + if (!bValue) { - mValue = mValue ? '1' : '0'; + this.testingImapErrorDesc(''); } - - oList['_' + oItem['Name']] = mValue; - }, this); - this.saveError(''); - Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, oList); + this.testingSmtpError.subscribe(function (bValue) { + if (!bValue) + { + this.testingSmtpErrorDesc(''); + } + }, this); - }, this.hasConfiguration); + this.testingImapErrorDesc = ko.observable(''); + this.testingSmtpErrorDesc = ko.observable(''); - this.bDisabeCloseOnEsc = true; - this.sDefaultKeyScope = Enums.KeyState.All; + this.imapServerFocus = ko.observable(false); + this.smtpServerFocus = ko.observable(false); - this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200); + this.name = ko.observable(''); + this.name.focused = ko.observable(false); - kn.constructorEnd(this); - } + this.imapServer = ko.observable(''); + this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort); + this.imapSecure = ko.observable(Enums.ServerSecure.None); + this.imapShortLogin = ko.observable(false); + this.smtpServer = ko.observable(''); + this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort); + this.smtpSecure = ko.observable(Enums.ServerSecure.None); + this.smtpShortLogin = ko.observable(false); + this.smtpAuth = ko.observable(true); + this.whiteList = ko.observable(''); - kn.extendAsViewModel(['View:Popup:Plugin', 'PopupsPluginViewModel'], PopupsPluginViewModel); - _.extend(PopupsPluginViewModel.prototype, KnoinAbstractViewModel.prototype); + this.headerText = ko.computed(function () { + var sName = this.name(); + return this.edit() ? 'Edit Domain "' + sName + '"' : + 'Add Domain' + ('' === sName ? '' : ' "' + sName + '"'); + }, this); - PopupsPluginViewModel.prototype.onPluginSettingsUpdateResponse = function (sResult, oData) - { - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - this.cancelCommand(); + this.domainIsComputed = ko.computed(function () { + return '' !== this.name() && + '' !== this.imapServer() && + '' !== this.imapPort() && + '' !== this.smtpServer() && + '' !== this.smtpPort(); + }, this); + + this.canBeTested = ko.computed(function () { + return !this.testing() && this.domainIsComputed(); + }, this); + + this.canBeSaved = ko.computed(function () { + return !this.saving() && this.domainIsComputed(); + }, this); + + this.createOrAddCommand = Utils.createCommand(this, function () { + this.saving(true); + Remote.createOrUpdateDomain( + _.bind(this.onDomainCreateOrSaveResponse, this), + !this.edit(), + this.name(), + this.imapServer(), + Utils.pInt(this.imapPort()), + this.imapSecure(), + this.imapShortLogin(), + this.smtpServer(), + Utils.pInt(this.smtpPort()), + this.smtpSecure(), + this.smtpShortLogin(), + this.smtpAuth(), + this.whiteList() + ); + }, this.canBeSaved); + + this.testConnectionCommand = Utils.createCommand(this, function () { + this.whiteListPage(false); + this.testingDone(false); + this.testingImapError(false); + this.testingSmtpError(false); + this.testing(true); + Remote.testConnectionForDomain( + _.bind(this.onTestConnectionResponse, this), + this.name(), + this.imapServer(), + Utils.pInt(this.imapPort()), + this.imapSecure(), + this.smtpServer(), + Utils.pInt(this.smtpPort()), + this.smtpSecure(), + this.smtpAuth() + ); + }, this.canBeTested); + + this.whiteListCommand = Utils.createCommand(this, function () { + this.whiteListPage(!this.whiteListPage()); + }); + + // smart form improvements + this.imapServerFocus.subscribe(function (bValue) { + if (bValue && '' !== this.name() && '' === this.imapServer()) + { + this.imapServer(this.name().replace(/[.]?[*][.]?/g, '')); + } + }, this); + + this.smtpServerFocus.subscribe(function (bValue) { + if (bValue && '' !== this.imapServer() && '' === this.smtpServer()) + { + this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp')); + } + }, this); + + this.imapSecure.subscribe(function (sValue) { + var iPort = Utils.pInt(this.imapPort()); + sValue = Utils.pString(sValue); + switch (sValue) + { + case '0': + if (993 === iPort) + { + this.imapPort('143'); + } + break; + case '1': + if (143 === iPort) + { + this.imapPort('993'); + } + break; + } + }, this); + + this.smtpSecure.subscribe(function (sValue) { + var iPort = Utils.pInt(this.smtpPort()); + sValue = Utils.pString(sValue); + switch (sValue) + { + case '0': + if (465 === iPort || 587 === iPort) + { + this.smtpPort('25'); + } + break; + case '1': + if (25 === iPort || 587 === iPort) + { + this.smtpPort('465'); + } + break; + case '2': + if (25 === iPort || 465 === iPort) + { + this.smtpPort('587'); + } + break; + } + }, this); + + kn.constructorEnd(this); } - else + + kn.extendAsViewModel(['View:Popup:Domain', 'PopupsDomainViewModel'], PopupsDomainViewModel); + _.extend(PopupsDomainViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsDomainViewModel.prototype.onTestConnectionResponse = function (sResult, oData) { - this.saveError(''); - if (oData && oData.ErrorCode) + this.testing(false); + if (Enums.StorageResultType.Success === sResult && oData.Result) { - this.saveError(Utils.getNotification(oData.ErrorCode)); + this.testingDone(true); + this.testingImapError(true !== oData.Result.Imap); + this.testingSmtpError(true !== oData.Result.Smtp); + + if (this.testingImapError() && oData.Result.Imap) + { + this.testingImapErrorDesc(oData.Result.Imap); + } + + if (this.testingSmtpError() && oData.Result.Smtp) + { + this.testingSmtpErrorDesc(oData.Result.Smtp); + } } else { - this.saveError(Utils.getNotification(Enums.Notification.CantSavePluginSettings)); + this.testingImapError(true); + this.testingSmtpError(true); } - } - }; + }; - PopupsPluginViewModel.prototype.onShow = function (oPlugin) - { - this.name(); - this.readme(); - this.configures([]); - - if (oPlugin) + PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult, oData) { - this.name(oPlugin['Name']); - this.readme(oPlugin['Readme']); - - var aConfig = oPlugin['Config']; - if (Utils.isNonEmptyArray(aConfig)) + this.saving(false); + if (Enums.StorageResultType.Success === sResult && oData) { - this.configures(_.map(aConfig, function (aItem) { - return { - 'value': ko.observable(aItem[0]), - 'Name': aItem[1], - 'Type': aItem[2], - 'Label': aItem[3], - 'Default': aItem[4], - 'Desc': aItem[5] - }; - })); + if (oData.Result) + { + __webpack_require__(/*! App:Admin */ 16).reloadDomainList(); + this.closeCommand(); + } + else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode) + { + this.savingError('Domain already exists'); + } } - } - }; + else + { + this.savingError('Unknown error'); + } + }; + + PopupsDomainViewModel.prototype.onHide = function () + { + this.whiteListPage(false); + }; + + PopupsDomainViewModel.prototype.onShow = function (oDomain) + { + this.saving(false); + this.whiteListPage(false); + + this.testing(false); + this.testingDone(false); + this.testingImapError(false); + this.testingSmtpError(false); + + this.clearForm(); + if (oDomain) + { + this.edit(true); + + this.name(Utils.trim(oDomain.Name)); + this.imapServer(Utils.trim(oDomain.IncHost)); + this.imapPort('' + Utils.pInt(oDomain.IncPort)); + this.imapSecure(Utils.trim(oDomain.IncSecure)); + this.imapShortLogin(!!oDomain.IncShortLogin); + this.smtpServer(Utils.trim(oDomain.OutHost)); + this.smtpPort('' + Utils.pInt(oDomain.OutPort)); + this.smtpSecure(Utils.trim(oDomain.OutSecure)); + this.smtpShortLogin(!!oDomain.OutShortLogin); + this.smtpAuth(!!oDomain.OutAuth); + this.whiteList(Utils.trim(oDomain.WhiteList)); + } + }; + + PopupsDomainViewModel.prototype.onFocus = function () + { + if ('' === this.name()) + { + this.name.focused(true); + } + }; + + PopupsDomainViewModel.prototype.clearForm = function () + { + this.edit(false); + this.whiteListPage(false); + + this.savingError(''); + + this.name(''); + this.name.focused(false); + + this.imapServer(''); + this.imapPort('' + Consts.Values.ImapDefaulPort); + this.imapSecure(Enums.ServerSecure.None); + this.imapShortLogin(false); + this.smtpServer(''); + this.smtpPort('' + Consts.Values.SmtpDefaulPort); + this.smtpSecure(Enums.ServerSecure.None); + this.smtpShortLogin(false); + this.smtpAuth(true); + this.whiteList(''); + }; + + module.exports = PopupsDomainViewModel; + + }()); + +/***/ }, + +/***/ 109: +/*!********************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsPluginViewModel.js ***! + \********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; - PopupsPluginViewModel.prototype.tryToClosePopup = function () - { var - self = this, - PopupsAskViewModel = require('View:Popup:Ask') + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + Remote = __webpack_require__(/*! Storage:Admin:Remote */ 15), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) ; - if (!kn.isPopupVisible(PopupsAskViewModel)) + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsPluginViewModel() { - kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () { - if (self.modalVisibility()) - { - Utils.delegateRun(self, 'cancelCommand'); + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsPlugin'); + + var self = this; + + this.onPluginSettingsUpdateResponse = _.bind(this.onPluginSettingsUpdateResponse, this); + + this.saveError = ko.observable(''); + + this.name = ko.observable(''); + this.readme = ko.observable(''); + + this.configures = ko.observableArray([]); + + this.hasReadme = ko.computed(function () { + return '' !== this.readme(); + }, this); + + this.hasConfiguration = ko.computed(function () { + return 0 < this.configures().length; + }, this); + + this.readmePopoverConf = { + 'placement': 'top', + 'trigger': 'hover', + 'title': 'About', + 'content': function () { + return self.readme(); } - }]); + }; + + this.saveCommand = Utils.createCommand(this, function () { + + var oList = {}; + + oList['Name'] = this.name(); + + _.each(this.configures(), function (oItem) { + + var mValue = oItem.value(); + if (false === mValue || true === mValue) + { + mValue = mValue ? '1' : '0'; + } + + oList['_' + oItem['Name']] = mValue; + + }, this); + + this.saveError(''); + Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, oList); + + }, this.hasConfiguration); + + this.bDisabeCloseOnEsc = true; + this.sDefaultKeyScope = Enums.KeyState.All; + + this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200); + + kn.constructorEnd(this); } - }; - PopupsPluginViewModel.prototype.onBuild = function () - { - key('esc', Enums.KeyState.All, _.bind(function () { - if (this.modalVisibility()) + kn.extendAsViewModel(['View:Popup:Plugin', 'PopupsPluginViewModel'], PopupsPluginViewModel); + _.extend(PopupsPluginViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsPluginViewModel.prototype.onPluginSettingsUpdateResponse = function (sResult, oData) + { + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { - this.tryToClosePopup(); + this.cancelCommand(); } - return false; - }, this)); - }; + else + { + this.saveError(''); + if (oData && oData.ErrorCode) + { + this.saveError(Utils.getNotification(oData.ErrorCode)); + } + else + { + this.saveError(Utils.getNotification(Enums.Notification.CantSavePluginSettings)); + } + } + }; - module.exports = PopupsPluginViewModel; + PopupsPluginViewModel.prototype.onShow = function (oPlugin) + { + this.name(); + this.readme(); + this.configures([]); -}(module, require)); -},{"App:Knoin":21,"Enums":6,"Knoin:AbstractViewModel":24,"Storage:Admin:Remote":44,"Utils":11,"View:Popup:Ask":50,"_":19,"key":15,"ko":16}]},{},[1]); + if (oPlugin) + { + this.name(oPlugin['Name']); + this.readme(oPlugin['Readme']); + + var aConfig = oPlugin['Config']; + if (Utils.isNonEmptyArray(aConfig)) + { + this.configures(_.map(aConfig, function (aItem) { + return { + 'value': ko.observable(aItem[0]), + 'Name': aItem[1], + 'Type': aItem[2], + 'Label': aItem[3], + 'Default': aItem[4], + 'Desc': aItem[5] + }; + })); + } + } + }; + + PopupsPluginViewModel.prototype.tryToClosePopup = function () + { + var + self = this, + PopupsAskViewModel = __webpack_require__(/*! View:Popup:Ask */ 31) + ; + + if (!kn.isPopupVisible(PopupsAskViewModel)) + { + kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () { + if (self.modalVisibility()) + { + Utils.delegateRun(self, 'cancelCommand'); + } + }]); + } + }; + + PopupsPluginViewModel.prototype.onBuild = function () + { + key('esc', Enums.KeyState.All, _.bind(function () { + if (this.modalVisibility()) + { + this.tryToClosePopup(); + } + return false; + }, this)); + }; + + module.exports = PopupsPluginViewModel; + + }()); + +/***/ } + +}); \ No newline at end of file diff --git a/rainloop/v/0.0.0/static/js/admin.min.js b/rainloop/v/0.0.0/static/js/admin.min.js deleted file mode 100644 index 4c146cc67..000000000 --- a/rainloop/v/0.0.0/static/js/admin.min.js +++ /dev/null @@ -1,5 +0,0 @@ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -!function e(t,i,n){function o(a,r){if(!i[a]){if(!t[a]){var l="function"==typeof require&&require;if(!r&&l)return l(a,!0);if(s)return s(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=i[a]={exports:{}};t[a][0].call(u.exports,function(e){var i=t[a][1][e];return o(i?i:e)},u,u.exports,e,t,i,n)}return i[a].exports}for(var s="function"==typeof require&&require,a=0;a').appendTo("body"),a.$win.on("error",function(t){t&&t.originalEvent&&t.originalEvent.message&&-1===r.inArray(t.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&e.jsError(r.emptyFunction,t.originalEvent.message,t.originalEvent.filename,t.originalEvent.lineno,n.location&&n.location.toString?n.location.toString():"",a.$html.attr("class"),r.microtime()-a.now)}),a.$doc.on("keydown",function(e){e&&e.ctrlKey&&a.$html.addClass("rl-ctrl-key-pressed")}).on("keyup",function(e){e&&!e.ctrlKey&&a.$html.removeClass("rl-ctrl-key-pressed")})}var n=t("window"),o=t("_"),s=t("$"),a=t("Globals"),r=t("Utils"),l=t("LinkBuilder"),c=t("Events"),u=t("Storage:Settings"),p=t("Knoin:AbstractBoot");o.extend(i.prototype,p.prototype),i.prototype.remote=function(){return null},i.prototype.data=function(){return null},i.prototype.setupSettings=function(){return!0},i.prototype.download=function(e){var t=null,i=null,o=n.navigator.userAgent.toLowerCase();return o&&(o.indexOf("chrome")>-1||o.indexOf("chrome")>-1)&&(i=n.document.createElement("a"),i.href=e,n.document.createEvent&&(t=n.document.createEvent("MouseEvents"),t&&t.initEvent&&i.dispatchEvent))?(t.initEvent("click",!0,!0),i.dispatchEvent(t),!0):(a.bMobileDevice?(n.open(e,"_self"),n.focus()):this.iframe.attr("src",e),!0)},i.prototype.setTitle=function(e){e=(r.isNormal(e)&&0"),i.now=(new n.Date).getTime(),i.momentTrigger=a.observable(!0),i.dropdownVisibility=a.observable(!1).extend({rateLimit:0}),i.tooltipTrigger=a.observable(!1).extend({rateLimit:0}),i.langChangeTrigger=a.observable(!0),i.useKeyboardShortcuts=a.observable(!0),i.iAjaxErrorCount=0,i.iTokenErrorCount=0,i.iMessageBodyCacheCount=0,i.bUnload=!1,i.sUserAgent=(n.navigator.userAgent||"").toLowerCase(),i.bIsiOSDevice=-11&&(n=n.replace(/[\/]+$/,""),n+="/p"+t),""!==i&&(n=n.replace(/[\/]+$/,""),n+="/"+encodeURI(i)),n},i.prototype.phpInfo=function(){return this.sServer+"Info"},i.prototype.langLink=function(e){return this.sServer+"/Lang/0/"+encodeURI(e)+"/"+this.sVersion+"/"},i.prototype.exportContactsVcf=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsVcf/"},i.prototype.exportContactsCsv=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsCsv/"},i.prototype.emptyContactPic=function(){return this.sStaticPrefix+"css/images/empty-contact.png"},i.prototype.sound=function(e){return this.sStaticPrefix+"sounds/"+e},i.prototype.themePreviewLink=function(e){var t="rainloop/v/"+this.sVersion+"/";return"@custom"===e.substr(-7)&&(e=o.trim(e.substring(0,e.length-7)),t=""),t+"themes/"+encodeURI(e)+"/images/preview.png"},i.prototype.notificationMailIcon=function(){return this.sStaticPrefix+"css/images/icom-message-notification.png"},i.prototype.openPgpJs=function(){return this.sStaticPrefix+"js/openpgp.min.js"},i.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},i.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},i.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},e.exports=new i}(t,e)},{"Storage:Settings":45,Utils:11,window:20}],10:[function(e,t){!function(e,t){"use strict";function i(){this.__boot=null,this.__data=null,this.__remote=null,this.oSettings=t("Storage:Settings"),this.oViewModelsHooks={},this.oSimpleHooks={}}var n=t("_"),o=t("Utils");i.prototype.__boot=null,i.prototype.__data=null,i.prototype.__remote=null,i.prototype.oViewModelsHooks={},i.prototype.oSimpleHooks={},i.prototype.addHook=function(e,t){o.isFunc(t)&&(o.isArray(this.oSimpleHooks[e])||(this.oSimpleHooks[e]=[]),this.oSimpleHooks[e].push(t))},i.prototype.runHook=function(e,t){o.isArray(this.oSimpleHooks[e])&&(t=t||[],n.each(this.oSimpleHooks[e],function(e){e.apply(null,t)}))},i.prototype.mainSettingsGet=function(e){return this.oSettings.settingsGet(e)},i.prototype.remoteRequest=function(e,t,i,n,o,s){this.__remote&&this.__remote.defaultRequest(e,t,i,n,o,s)},i.prototype.settingsGet=function(e,t){var i=this.oSettings.settingsGet("Plugins");return i=i&&!o.isUnd(i[e])?i[e]:null,i?o.isUnd(i[t])?null:i[t]:null},e.exports=new i}(t,e)},{"Storage:Settings":45,Utils:11,_:19}],11:[function(e,t){!function(e,t){"use strict";var i={},n=t("window"),o=t("_"),s=t("$"),a=t("ko"),r=t("Enums"),l=t("Consts"),c=t("Globals");i.trim=s.trim,i.inArray=s.inArray,i.isArray=o.isArray,i.isFunc=o.isFunction,i.isUnd=o.isUndefined,i.isNull=o.isNull,i.emptyFunction=function(){},i.isNormal=function(e){return!i.isUnd(e)&&!i.isNull(e)},i.windowResize=o.debounce(function(e){i.isUnd(e)?c.$win.resize():n.setTimeout(function(){c.$win.resize()},e)},50),i.isPosNumeric=function(e,t){return i.isNormal(e)?(i.isUnd(t)?0:!t)?/^[1-9]+[0-9]*$/.test(e.toString()):/^[0-9]*$/.test(e.toString()):!1},i.pInt=function(e,t){var o=i.isNormal(e)&&""!==e?n.parseInt(e,10):t||0;return n.isNaN(o)?t||0:o},i.pString=function(e){return i.isNormal(e)?""+e:""},i.isNonEmptyArray=function(e){return i.isArray(e)&&0s;s++)o=i[s].split("="),t[n.decodeURIComponent(o[0])]=n.decodeURIComponent(o[1]);return t},i.mailToHelper=function(e,o){if(e&&"mailto:"===e.toString().substr(0,7).toLowerCase()){e=e.toString().substr(7);var s={},a=null,l=e.replace(/\?.+$/,""),c=e.replace(/^[^\?]*\?/,""),u=t("Model:Email");return a=new u,a.parse(n.decodeURIComponent(l)),a&&a.email&&(s=i.simpleQueryParser(c),t("App:Knoin").showScreenPopup(o,[r.ComposeType.Empty,null,[a],i.isUnd(s.subject)?null:i.pString(s.subject),i.isUnd(s.body)?null:i.plainToHtml(i.pString(s.body))])),!0}return!1},i.rsaEncode=function(e,t,o,s){if(n.crypto&&n.crypto.getRandomValues&&n.RSAKey&&t&&o&&s){var a=new n.RSAKey;if(a.setPublic(s,o),e=a.encrypt(i.fakeMd5()+":"+e+":"+i.fakeMd5()),!1!==e)return"rsa:"+t+":"+e}return!1},i.rsaEncode.supported=!!(n.crypto&&n.crypto.getRandomValues&&n.RSAKey),i.exportPath=function(e,t,o){for(var s=null,a=e.split("."),r=o||n;a.length&&(s=a.shift());)a.length||i.isUnd(t)?r=r[s]?r[s]:r[s]={}:r[s]=t},i.pImport=function(e,t,i){e[t]=i},i.pExport=function(e,t,n){return i.isUnd(e[t])?n:e[t]},i.encodeHtml=function(e){return i.isNormal(e)?e.toString().replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):""},i.splitPlainText=function(e,t){var n="",o="",s=e,a=0,r=0;for(t=i.isUnd(t)?100:t;s.length>t;)o=s.substring(0,t),a=o.lastIndexOf(" "),r=o.lastIndexOf("\n"),-1!==r&&(a=r),-1===a&&(a=t),n+=o.substring(0,a)+"\n",s=s.substring(a+1);return n+s},i.timeOutAction=function(){var e={};return function(t,o,s){i.isUnd(e[t])&&(e[t]=0),n.clearTimeout(e[t]),e[t]=n.setTimeout(o,s)}}(),i.timeOutActionSecond=function(){var e={};return function(t,i,o){e[t]||(e[t]=n.setTimeout(function(){i(),e[t]=0},o))}}(),i.audio=function(){var e=!1;return function(t,i){if(!1===e)if(c.bIsiOSDevice)e=null;else{var o=!1,s=!1,a=n.Audio?new n.Audio:null;a&&a.canPlayType&&a.play?(o=""!==a.canPlayType('audio/mpeg; codecs="mp3"'),o||(s=""!==a.canPlayType('audio/ogg; codecs="vorbis"')),o||s?(e=a,e.preload="none",e.loop=!1,e.autoplay=!1,e.muted=!1,e.src=o?t:i):e=null):e=null}return e}}(),i.hos=function(e,t){return e&&n.Object&&n.Object.hasOwnProperty?n.Object.hasOwnProperty.call(e,t):!1},i.i18n=function(e,t,n){var o="",s=i.isUnd(c.oI18N[e])?i.isUnd(n)?e:n:c.oI18N[e];if(!i.isUnd(t)&&!i.isNull(t))for(o in t)i.hos(t,o)&&(s=s.replace("%"+o+"%",t[o]));return s},i.i18nToNode=function(e){o.defer(function(){s(".i18n",e).each(function(){var e=s(this),t="";t=e.data("i18n-text"),t?e.text(i.i18n(t)):(t=e.data("i18n-html"),t&&e.html(i.i18n(t)),t=e.data("i18n-placeholder"),t&&e.attr("placeholder",i.i18n(t)),t=e.data("i18n-title"),t&&e.attr("title",i.i18n(t)))})})},i.i18nReload=function(){n.rainloopI18N&&(c.oI18N=n.rainloopI18N||{},i.i18nToNode(c.$doc),c.langChangeTrigger(!c.langChangeTrigger())),n.rainloopI18N=null},i.initOnStartOrLangChange=function(e,t,i){e&&e.call(t),i?c.langChangeTrigger.subscribe(function(){e&&e.call(t),i.call(t)}):e&&c.langChangeTrigger.subscribe(e,t)},i.inFocus=function(){return n.document.activeElement?(i.isUnd(n.document.activeElement.__inFocusCache)&&(n.document.activeElement.__inFocusCache=s(n.document.activeElement).is("input,textarea,iframe,.cke_editable")),!!n.document.activeElement.__inFocusCache):!1},i.removeInFocus=function(){if(n.document&&n.document.activeElement&&n.document.activeElement.blur){var e=s(n.document.activeElement);e.is("input,textarea")&&n.document.activeElement.blur()}},i.removeSelection=function(){if(n&&n.getSelection){var e=n.getSelection();e&&e.removeAllRanges&&e.removeAllRanges()}else n.document&&n.document.selection&&n.document.selection.empty&&n.document.selection.empty()},i.replySubjectAdd=function(e,t){e=i.trim(e.toUpperCase()),t=i.trim(t.replace(/[\s]+/g," "));var n=!1,s=[],a="RE"===e,r="FWD"===e,l=!r;return""!==t&&o.each(t.split(":"),function(e){var t=i.trim(e);n||!/^(RE|FWD)$/i.test(t)&&!/^(RE|FWD)[\[\(][\d]+[\]\)]$/i.test(t)?(s.push(e),n=!0):(a||(a=!!/^RE/i.test(t)),r||(r=!!/^FWD/i.test(t)))}),l?a=!1:r=!1,i.trim((l?"Re: ":"Fwd: ")+(a?"Re: ":"")+(r?"Fwd: ":"")+i.trim(s.join(":")))},i.roundNumber=function(e,t){return n.Math.round(e*n.Math.pow(10,t))/n.Math.pow(10,t)},i.friendlySize=function(e){return e=i.pInt(e),e>=1073741824?i.roundNumber(e/1073741824,1)+"GB":e>=1048576?i.roundNumber(e/1048576,1)+"MB":e>=1024?i.roundNumber(e/1024,0)+"KB":e+"B"},i.log=function(e){n.console&&n.console.log&&n.console.log(e)},i.getNotification=function(e,t){return e=i.pInt(e),r.Notification.ClientViewError===e&&t?t:i.isUnd(c.oNotificationI18N[e])?"":c.oNotificationI18N[e]},i.initNotificationLanguage=function(){var e=c.oNotificationI18N||{};e[r.Notification.InvalidToken]=i.i18n("NOTIFICATIONS/INVALID_TOKEN"),e[r.Notification.AuthError]=i.i18n("NOTIFICATIONS/AUTH_ERROR"),e[r.Notification.AccessError]=i.i18n("NOTIFICATIONS/ACCESS_ERROR"),e[r.Notification.ConnectionError]=i.i18n("NOTIFICATIONS/CONNECTION_ERROR"),e[r.Notification.CaptchaError]=i.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),e[r.Notification.SocialFacebookLoginAccessDisable]=i.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),e[r.Notification.SocialTwitterLoginAccessDisable]=i.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),e[r.Notification.SocialGoogleLoginAccessDisable]=i.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),e[r.Notification.DomainNotAllowed]=i.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),e[r.Notification.AccountNotAllowed]=i.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),e[r.Notification.AccountTwoFactorAuthRequired]=i.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED"),e[r.Notification.AccountTwoFactorAuthError]=i.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR"),e[r.Notification.CouldNotSaveNewPassword]=i.i18n("NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD"),e[r.Notification.CurrentPasswordIncorrect]=i.i18n("NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT"),e[r.Notification.NewPasswordShort]=i.i18n("NOTIFICATIONS/NEW_PASSWORD_SHORT"),e[r.Notification.NewPasswordWeak]=i.i18n("NOTIFICATIONS/NEW_PASSWORD_WEAK"),e[r.Notification.NewPasswordForbidden]=i.i18n("NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT"),e[r.Notification.ContactsSyncError]=i.i18n("NOTIFICATIONS/CONTACTS_SYNC_ERROR"),e[r.Notification.CantGetMessageList]=i.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),e[r.Notification.CantGetMessage]=i.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),e[r.Notification.CantDeleteMessage]=i.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),e[r.Notification.CantMoveMessage]=i.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),e[r.Notification.CantCopyMessage]=i.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),e[r.Notification.CantSaveMessage]=i.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),e[r.Notification.CantSendMessage]=i.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),e[r.Notification.InvalidRecipients]=i.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),e[r.Notification.CantCreateFolder]=i.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),e[r.Notification.CantRenameFolder]=i.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),e[r.Notification.CantDeleteFolder]=i.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),e[r.Notification.CantDeleteNonEmptyFolder]=i.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),e[r.Notification.CantSubscribeFolder]=i.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),e[r.Notification.CantUnsubscribeFolder]=i.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),e[r.Notification.CantSaveSettings]=i.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),e[r.Notification.CantSavePluginSettings]=i.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),e[r.Notification.DomainAlreadyExists]=i.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),e[r.Notification.CantInstallPackage]=i.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),e[r.Notification.CantDeletePackage]=i.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),e[r.Notification.InvalidPluginPackage]=i.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),e[r.Notification.UnsupportedPluginPackage]=i.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),e[r.Notification.LicensingServerIsUnavailable]=i.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),e[r.Notification.LicensingExpired]=i.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),e[r.Notification.LicensingBanned]=i.i18n("NOTIFICATIONS/LICENSING_BANNED"),e[r.Notification.DemoSendMessageError]=i.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),e[r.Notification.AccountAlreadyExists]=i.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),e[r.Notification.MailServerError]=i.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),e[r.Notification.InvalidInputArgument]=i.i18n("NOTIFICATIONS/INVALID_INPUT_ARGUMENT"),e[r.Notification.UnknownNotification]=i.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),e[r.Notification.UnknownError]=i.i18n("NOTIFICATIONS/UNKNOWN_ERROR") -},i.getUploadErrorDescByCode=function(e){var t="";switch(i.pInt(e)){case r.UploadErrorCode.FileIsTooBig:t=i.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case r.UploadErrorCode.FilePartiallyUploaded:t=i.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case r.UploadErrorCode.FileNoUploaded:t=i.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case r.UploadErrorCode.MissingTempFolder:t=i.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case r.UploadErrorCode.FileOnSaveingError:t=i.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case r.UploadErrorCode.FileType:t=i.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:t=i.i18n("UPLOAD/ERROR_UNKNOWN")}return t},i.delegateRun=function(e,t,n,s){e&&e[t]&&(s=i.pInt(s),0>=s?e[t].apply(e,i.isArray(n)?n:[]):o.delay(function(){e[t].apply(e,i.isArray(n)?n:[])},s))},i.killCtrlAandS=function(e){if(e=e||n.event,e&&e.ctrlKey&&!e.shiftKey&&!e.altKey){var t=e.target||e.srcElement,i=e.keyCode||e.which;if(i===r.EventKeyCode.S)return void e.preventDefault();if(t&&t.tagName&&t.tagName.match(/INPUT|TEXTAREA/i))return;i===r.EventKeyCode.A&&(n.getSelection?n.getSelection().removeAllRanges():n.document.selection&&n.document.selection.clear&&n.document.selection.clear(),e.preventDefault())}},i.createCommand=function(e,t,n){var o=t?function(){return o&&o.canExecute&&o.canExecute()&&t.apply(e,Array.prototype.slice.call(arguments)),!1}:function(){};return o.enabled=a.observable(!0),n=i.isUnd(n)?!0:n,o.canExecute=a.computed(i.isFunc(n)?function(){return o.enabled()&&n.call(e)}:function(){return o.enabled()&&!!n}),o},i.initDataConstructorBySettings=function(e){e.editorDefaultType=a.observable(r.EditorDefaultType.Html),e.showImages=a.observable(!1),e.interfaceAnimation=a.observable(r.InterfaceAnimation.Full),e.contactsAutosave=a.observable(!1),c.sAnimationType=r.InterfaceAnimation.Full,e.capaThemes=a.observable(!1),e.allowLanguagesOnSettings=a.observable(!0),e.allowLanguagesOnLogin=a.observable(!0),e.useLocalProxyForExternalImages=a.observable(!1),e.desktopNotifications=a.observable(!1),e.useThreads=a.observable(!0),e.replySameFolder=a.observable(!0),e.useCheckboxesInList=a.observable(!0),e.layout=a.observable(r.Layout.SidePreview),e.usePreviewPane=a.computed(function(){return r.Layout.NoPreview!==e.layout()}),e.interfaceAnimation.subscribe(function(e){if(c.bMobileDevice||e===r.InterfaceAnimation.None)c.$html.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),c.sAnimationType=r.InterfaceAnimation.None;else switch(e){case r.InterfaceAnimation.Full:c.$html.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),c.sAnimationType=e;break;case r.InterfaceAnimation.Normal:c.$html.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),c.sAnimationType=e}}),e.interfaceAnimation.valueHasMutated(),e.desktopNotificationsPermisions=a.computed(function(){e.desktopNotifications();var t=i.notificationClass(),o=r.DesktopNotifications.NotSupported;if(t&&t.permission)switch(t.permission.toLowerCase()){case"granted":o=r.DesktopNotifications.Allowed;break;case"denied":o=r.DesktopNotifications.Denied;break;case"default":o=r.DesktopNotifications.NotAllowed}else n.webkitNotifications&&n.webkitNotifications.checkPermission&&(o=n.webkitNotifications.checkPermission());return o}),e.useDesktopNotifications=a.computed({read:function(){return e.desktopNotifications()&&r.DesktopNotifications.Allowed===e.desktopNotificationsPermisions()},write:function(t){if(t){var n=i.notificationClass(),o=e.desktopNotificationsPermisions();n&&r.DesktopNotifications.Allowed===o?e.desktopNotifications(!0):n&&r.DesktopNotifications.NotAllowed===o?n.requestPermission(function(){e.desktopNotifications.valueHasMutated(),r.DesktopNotifications.Allowed===e.desktopNotificationsPermisions()?e.desktopNotifications()?e.desktopNotifications.valueHasMutated():e.desktopNotifications(!0):e.desktopNotifications()?e.desktopNotifications(!1):e.desktopNotifications.valueHasMutated()}):e.desktopNotifications(!1)}else e.desktopNotifications(!1)}}),e.language=a.observable(""),e.languages=a.observableArray([]),e.mainLanguage=a.computed({read:e.language,write:function(t){t!==e.language()?-1=t.diff(n,"hours")?o:t.format("L")===n.format("L")?i.i18n("MESSAGE_LIST/TODAY_AT",{TIME:n.format("LT")}):t.clone().subtract("days",1).format("L")===n.format("L")?i.i18n("MESSAGE_LIST/YESTERDAY_AT",{TIME:n.format("LT")}):n.format(t.year()===n.year()?"D MMM.":"LL")},e)},i.convertThemeName=function(e){return"@custom"===e.substr(-7)&&(e=i.trim(e.substring(0,e.length-7))),i.trim(e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},i.quoteName=function(e){return e.replace(/["]/g,'\\"')},i.microtime=function(){return(new Date).getTime()},i.convertLangName=function(e,t){return i.i18n("LANGS_NAMES"+(!0===t?"_EN":"")+"/LANG_"+e.toUpperCase().replace(/[^a-zA-Z0-9]+/g,"_"),null,e)},i.fakeMd5=function(e){var t="",o="0123456789abcdefghijklmnopqrstuvwxyz";for(e=i.isUnd(e)?32:i.pInt(e);t.length/g,">").replace(/")},i.draggeblePlace=function(){return s('
 
').appendTo("#rl-hidden")},i.defautOptionsAfterRender=function(e,t){t&&!i.isUnd(t.disabled)&&e&&s(e).toggleClass("disabled",t.disabled).prop("disabled",t.disabled)},i.windowPopupKnockout=function(e,t,o,r){var l=null,c=n.open(""),u="__OpenerApplyBindingsUid"+i.fakeMd5()+"__",p=s("#"+t);n[u]=function(){if(c&&c.document.body&&p&&p[0]){var t=s(c.document.body);s("#rl-content",t).html(p.html()),s("html",c.document).addClass("external "+s("html").attr("class")),i.i18nToNode(t),e&&s("#rl-content",t)[0]&&a.applyBindings(e,s("#rl-content",t)[0]),n[u]=null,r(c)}},c.document.open(),c.document.write(''+i.encodeHtml(o)+'
'),c.document.close(),l=c.document.createElement("script"),l.type="text/javascript",l.innerHTML="if(window&&window.opener&&window.opener['"+u+"']){window.opener['"+u+"']();window.opener['"+u+"']=null}",c.document.getElementsByTagName("head")[0].appendChild(l)},i.settingsSaveHelperFunction=function(e,t,n,s){return n=n||null,s=i.isUnd(s)?1e3:i.pInt(s),function(i,a,l,c,u){t.call(n,a&&a.Result?r.SaveSettingsStep.TrueResult:r.SaveSettingsStep.FalseResult),e&&e.call(n,i,a,l,c,u),o.delay(function(){t.call(n,r.SaveSettingsStep.Idle)},s)}},i.settingsSaveHelperSimpleFunction=function(e,t){return i.settingsSaveHelperFunction(null,e,t,1e3)},i.htmlToPlain=function(e){var t=0,i=0,n=0,o=0,a=0,r="",l=function(e){for(var t=100,i="",n="",o=e,s=0,a=0;o.length>t;)n=o.substring(0,t),s=n.lastIndexOf(" "),a=n.lastIndexOf("\n"),-1!==a&&(s=a),-1===s&&(s=t),i+=n.substring(0,s)+"\n",o=o.substring(s+1);return i+o},u=function(e){return e=l(s.trim(e)),e="> "+e.replace(/\n/gm,"\n> "),e.replace(/(^|\n)([> ]+)/gm,function(){return arguments&&2]*>([\s\S\r\n]*)<\/div>/gim,p),e="\n"+s.trim(e)+"\n"),e}return""},d=function(){return arguments&&1"):""},g=function(){return arguments&&1/g,">"):""},m=function(){return arguments&&1]*>([\s\S\r\n]*)<\/pre>/gim,d).replace(/[\s]+/gm," ").replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gim,g).replace(/]*>/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(/]*>([\s\S\r\n]*)<\/div>/gim,p).replace(/]*>/gim,"\n__bq__start__\n").replace(/<\/blockquote>/gim,"\n__bq__end__\n").replace(/]*>([\s\S\r\n]*?)<\/a>/gim,m).replace(/<\/div>/gi,"\n").replace(/ /gi," ").replace(/"/gi,'"').replace(/<[^>]*>/gm,""),r=c.$div.html(r).text(),r=r.replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/>/gi,">").replace(/</gi,"<").replace(/&/gi,"&"),t=0,a=100;a>0&&(a--,i=r.indexOf("__bq__start__",t),i>-1);)n=r.indexOf("__bq__start__",i+5),o=r.indexOf("__bq__end__",i+5),(-1===n||n>o)&&o>i?(r=r.substring(0,i)+u(r.substring(i+13,o))+r.substring(o+11),t=0):t=n>-1&&o>n?n-1:0;return r=r.replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")},i.plainToHtml=function(e,t){e=e.toString().replace(/\r/g,"");var n=!1,o=!0,s=!0,a=[],r="",l=0,c=e.split("\n");do{for(o=!1,a=[],l=0;l"===r.substr(0,1),s&&!n?(o=!0,n=!0,a.push("~~~blockquote~~~"),a.push(r.substr(1))):!s&&n?(n=!1,a.push("~~~/blockquote~~~"),a.push(r)):a.push(s&&n?r.substr(1):r);n&&(n=!1,a.push("~~~/blockquote~~~")),c=a}while(o);return e=c.join("\n"),e=e.replace(/&/g,"&").replace(/>/g,">").replace(/").replace(/[\s]*~~~\/blockquote~~~/g,"").replace(/[\-_~]{10,}/g,"
").replace(/\n/g,"
"),t?i.linkify(e):e},n.rainloop_Utils_htmlToPlain=i.htmlToPlain,n.rainloop_Utils_plainToHtml=i.plainToHtml,i.linkify=function(e){return s.fn&&s.fn.linkify&&(e=c.$div.html(e.replace(/&/gi,"amp_amp_12345_amp_amp")).linkify().find(".linkified").removeClass("linkified").end().html().replace(/amp_amp_12345_amp_amp/g,"&")),e},i.resizeAndCrop=function(e,t,i){var o=new n.Image;o.onload=function(){var e=[0,0],o=n.document.createElement("canvas"),s=o.getContext("2d");o.width=t,o.height=t,e=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width],s.fillStyle="#fff",s.fillRect(0,0,t,t),s.drawImage(this,e[0]/2,e[1]/2,this.width-e[0],this.height-e[1],0,0,t,t),i(o.toDataURL("image/jpeg"))},o.src=e},i.folderListOptionsBuilder=function(e,t,o,s,a,l,c,u,p,d){var g=null,m=!1,h=0,f=0,b="   ",S=[];for(p=i.isNormal(p)?p:0h;h++)S.push({id:s[h][0],name:s[h][1],system:!1,seporator:!1,disabled:!1});for(m=!0,h=0,f=e.length;f>h;h++)g=e[h],(c?c.call(null,g):!0)&&(m&&0h;h++)g=t[h],(g.subScribed()||!g.existen)&&(c?c.call(null,g):!0)&&(r.FolderType.User===g.type()||!p||01||c>0&&l>c){for(l>c?(u(c),o=c,s=c):((3>=l||l>=c-2)&&(a+=2),u(l),o=l,s=l);a>0;)if(o-=1,s+=1,o>0&&(u(o,!1),a--),c>=s)u(s,!0),a--;else if(0>=o)break;3===o?u(2,!1):o>3&&u(n.Math.round((o-1)/2),!1,"..."),c-2===s?u(c-1,!0):c-2>s&&u(n.Math.round((c+s)/2),!0,"..."),o>1&&u(1,!1),c>s&&u(c,!0)}return r}},i.selectElement=function(e){var t,i;n.getSelection?(t=n.getSelection(),t.removeAllRanges(),i=n.document.createRange(),i.selectNodeContents(e),t.addRange(i)):n.document.selection&&(i=n.document.body.createTextRange(),i.moveToElementText(e),i.select())},i.detectDropdownVisibility=o.debounce(function(){c.dropdownVisibility(!!o.find(c.aBootstrapDropdowns,function(e){return e.hasClass("open")}))},50),i.triggerAutocompleteInputChange=function(e){var t=function(){s(".checkAutocomplete").trigger("change")};(i.isUnd(e)?1:!e)?t():o.delay(t,100)},e.exports=i}(t,e)},{$:14,"App:Knoin":21,Consts:5,Enums:6,Globals:8,"Model:Email":26,_:19,ko:16,window:20}],12:[function(e,t){t.exports=crossroads},{}],13:[function(e,t){t.exports=hasher},{}],14:[function(e,t){t.exports=$},{}],15:[function(e,t){t.exports=key},{}],16:[function(e,t){!function(t,i){"use strict";var n=e("window"),o=e("_"),s=e("$");i.bindingHandlers.tooltip={init:function(t,n){var o=e("Globals"),a=e("Utils");if(!o.bMobileDevice){var r=s(t),l=r.data("tooltip-class")||"",c=r.data("tooltip-placement")||"top";r.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:c,trigger:"hover",title:function(){return r.is(".disabled")||o.dropdownVisibility()?"":''+a.i18n(i.utils.unwrapObservable(n()))+""}}).click(function(){r.tooltip("hide")}),o.tooltipTrigger.subscribe(function(){r.tooltip("hide")})}}},i.bindingHandlers.tooltip2={init:function(t,i){var n=e("Globals"),o=s(t),a=o.data("tooltip-class")||"",r=o.data("tooltip-placement")||"top";o.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:r,title:function(){return o.is(".disabled")||n.dropdownVisibility()?"":''+i()()+""}}).click(function(){o.tooltip("hide")}),n.tooltipTrigger.subscribe(function(){o.tooltip("hide")})}},i.bindingHandlers.tooltip3={init:function(t){var i=s(t),o=e("Globals");i.tooltip({container:"body",trigger:"hover manual",title:function(){return i.data("tooltip3-data")||""}}),s(n.document).click(function(){i.tooltip("hide")}),o.tooltipTrigger.subscribe(function(){i.tooltip("hide")})},update:function(e,t){var n=i.utils.unwrapObservable(t());""===n?s(e).data("tooltip3-data","").tooltip("hide"):s(e).data("tooltip3-data",n).tooltip("show")}},i.bindingHandlers.registrateBootstrapDropdown={init:function(t){var i=e("Globals");i.aBootstrapDropdowns.push(s(t))}},i.bindingHandlers.openDropdownTrigger={update:function(t,n){if(i.utils.unwrapObservable(n())){var o=s(t),a=e("Utils");o.hasClass("open")||(o.find(".dropdown-toggle").dropdown("toggle"),a.detectDropdownVisibility()),n()(!1)}}},i.bindingHandlers.dropdownCloser={init:function(e){s(e).closest(".dropdown").on("click",".e-item",function(){s(e).dropdown("toggle")})}},i.bindingHandlers.popover={init:function(e,t){s(e).popover(i.utils.unwrapObservable(t()))}},i.bindingHandlers.csstext={init:function(t,n){var o=e("Utils");t&&t.styleSheet&&!o.isUnd(t.styleSheet.cssText)?t.styleSheet.cssText=i.utils.unwrapObservable(n()):s(t).text(i.utils.unwrapObservable(n()))},update:function(t,n){var o=e("Utils");t&&t.styleSheet&&!o.isUnd(t.styleSheet.cssText)?t.styleSheet.cssText=i.utils.unwrapObservable(n()):s(t).text(i.utils.unwrapObservable(n()))}},i.bindingHandlers.resizecrop={init:function(e){s(e).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(e,t){t()(),s(e).resizecrop({width:"100",height:"100"})}},i.bindingHandlers.onEnter={init:function(e,t,i,o){s(e).on("keypress",function(i){i&&13===n.parseInt(i.keyCode,10)&&(s(e).trigger("change"),t().call(o))})}},i.bindingHandlers.onEsc={init:function(e,t,i,o){s(e).on("keypress",function(i){i&&27===n.parseInt(i.keyCode,10)&&(s(e).trigger("change"),t().call(o))})}},i.bindingHandlers.clickOnTrue={update:function(e,t){i.utils.unwrapObservable(t())&&s(e).click()}},i.bindingHandlers.modal={init:function(t,n){var o=e("Globals"),a=e("Utils");s(t).toggleClass("fade",!o.bMobileDevice).modal({keyboard:!1,show:i.utils.unwrapObservable(n())}).on("shown",function(){a.windowResize()}).find(".close").click(function(){n()(!1)})},update:function(e,t){s(e).modal(i.utils.unwrapObservable(t())?"show":"hide")}},i.bindingHandlers.i18nInit={init:function(t){var i=e("Utils");i.i18nToNode(t)}},i.bindingHandlers.i18nUpdate={update:function(t,n){var o=e("Utils");i.utils.unwrapObservable(n()),o.i18nToNode(t)}},i.bindingHandlers.link={update:function(e,t){s(e).attr("href",i.utils.unwrapObservable(t()))}},i.bindingHandlers.title={update:function(e,t){s(e).attr("title",i.utils.unwrapObservable(t()))}},i.bindingHandlers.textF={init:function(e,t){s(e).text(i.utils.unwrapObservable(t()))}},i.bindingHandlers.initDom={init:function(e,t){t()(e)}},i.bindingHandlers.initResizeTrigger={init:function(e,t){var n=i.utils.unwrapObservable(t());s(e).css({height:n[1],"min-height":n[1]})},update:function(t,n){var o=e("Utils"),a=e("Globals"),r=i.utils.unwrapObservable(n()),l=o.pInt(r[1]),c=0,u=s(t).offset().top;u>0&&(u+=o.pInt(r[2]),c=a.$win.height()-u,c>l&&(l=c),s(t).css({height:l,"min-height":l}))}},i.bindingHandlers.appendDom={update:function(e,t){s(e).hide().empty().append(i.utils.unwrapObservable(t())).show()}},i.bindingHandlers.draggable={init:function(t,o,a){var r=e("Globals"),l=e("Utils");if(!r.bMobileDevice){var c=100,u=3,p=a(),d=p&&p.droppableSelector?p.droppableSelector:"",g={distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},refreshPositions:!0,scroll:!0};d&&(g.drag=function(e){s(d).each(function(){var t=null,i=null,o=s(this),a=o.offset(),r=a.top+o.height();n.clearInterval(o.data("timerScroll")),o.data("timerScroll",!1),e.pageX>=a.left&&e.pageX<=a.left+o.width()&&(e.pageY>=r-c&&e.pageY<=r&&(t=function(){o.scrollTop(o.scrollTop()+u),l.windowResize()},o.data("timerScroll",n.setInterval(t,10)),t()),e.pageY>=a.top&&e.pageY<=a.top+c&&(i=function(){o.scrollTop(o.scrollTop()-u),l.windowResize()},o.data("timerScroll",n.setInterval(i,10)),i()))})},g.stop=function(){s(d).each(function(){n.clearInterval(s(this).data("timerScroll")),s(this).data("timerScroll",!1)})}),g.helper=function(e){return o()(e&&e.target?i.dataFor(e.target):null)},s(t).draggable(g).on("mousedown",function(){l.removeInFocus()})}}},i.bindingHandlers.droppable={init:function(t,i,n){var o=e("Globals");if(!o.bMobileDevice){var a=i(),r=n(),l=r&&r.droppableOver?r.droppableOver:null,c=r&&r.droppableOut?r.droppableOut:null,u={tolerance:"pointer",hoverClass:"droppableHover"};a&&(u.drop=function(e,t){a(e,t)},l&&(u.over=function(e,t){l(e,t)}),c&&(u.out=function(e,t){c(e,t)}),s(t).droppable(u))}}},i.bindingHandlers.nano={init:function(t){var i=e("Globals");i.bDisableNanoScroll||s(t).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},i.bindingHandlers.saveTrigger={init:function(e){var t=s(e);t.data("save-trigger-type",t.is("input[type=text],input[type=email],input[type=password],select,textarea")?"input":"custom"),"custom"===t.data("save-trigger-type")?t.append('  ').addClass("settings-saved-trigger"):t.addClass("settings-saved-trigger-input")},update:function(e,t){var n=i.utils.unwrapObservable(t()),o=s(e);if("custom"===o.data("save-trigger-type"))switch(n.toString()){case"1":o.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case"0":o.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case"-2":o.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:o.find(".animated").hide().end().find(".error,.success").removeClass("visible")}else switch(n.toString()){case"1":o.addClass("success").removeClass("error");break;case"0":o.addClass("error").removeClass("success");break;case"-2":break;default:o.removeClass("error success")}}},i.bindingHandlers.emailsTags={init:function(t,i,n){var a=e("Utils"),r=e("Model:Email"),l=s(t),c=i(),u=n(),p=u.autoCompleteSource||null,d=function(e){c&&c.focusTrigger&&c.focusTrigger(e)};l.inputosaurus({parseOnBlur:!0,allowDragAndDrop:!0,focusCallback:d,inputDelimiters:[",",";"],autoCompleteSource:p,parseHook:function(e){return o.map(e,function(e){var t=a.trim(e),i=null;return""!==t?(i=new r,i.mailsoParse(t),i.clearDuplicateName(),[i.toLine(!1),i]):[t,null]})},change:o.bind(function(e){l.data("EmailsTagsValue",e.target.value),c(e.target.value)},this)})},update:function(e,t,n){var o=s(e),a=n(),r=a.emailsTagsFilter||null,l=i.utils.unwrapObservable(t());o.data("EmailsTagsValue")!==l&&(o.val(l),o.data("EmailsTagsValue",l),o.inputosaurus("refresh")),r&&i.utils.unwrapObservable(r)&&o.inputosaurus("focus")}},i.bindingHandlers.contactTags={init:function(t,i,n){var a=e("Utils"),r=e("Model:ContactTag"),l=s(t),c=i(),u=n(),p=u.autoCompleteSource||null,d=function(e){c&&c.focusTrigger&&c.focusTrigger(e)};l.inputosaurus({parseOnBlur:!0,allowDragAndDrop:!1,focusCallback:d,inputDelimiters:[",",";"],outputDelimiter:",",autoCompleteSource:p,parseHook:function(e){return o.map(e,function(e){var t=a.trim(e),i=null;return""!==t?(i=new r,i.name(t),[i.toLine(!1),i]):[t,null]})},change:o.bind(function(e){l.data("ContactTagsValue",e.target.value),c(e.target.value)},this)})},update:function(e,t,n){var o=s(e),a=n(),r=a.contactTagsFilter||null,l=i.utils.unwrapObservable(t());o.data("ContactTagsValue")!==l&&(o.val(l),o.data("ContactTagsValue",l),o.inputosaurus("refresh")),r&&i.utils.unwrapObservable(r)&&o.inputosaurus("focus")}},i.bindingHandlers.command={init:function(e,t,n,o){var a=s(e),r=t();if(!r||!r.enabled||!r.canExecute)throw new Error("You are not using command function");a.addClass("command"),i.bindingHandlers[a.is("form")?"submit":"click"].init.apply(o,arguments)},update:function(e,t){var i=!0,n=s(e),o=t();i=o.enabled(),n.toggleClass("command-not-enabled",!i),i&&(i=o.canExecute(),n.toggleClass("command-can-not-be-execute",!i)),n.toggleClass("command-disabled disable disabled",!i).toggleClass("no-disabled",!!i),(n.is("input")||n.is("button"))&&n.prop("disabled",!i)}},i.extenders.trimmer=function(t){var n=e("Utils"),o=i.computed({read:t,write:function(e){t(n.trim(e.toString()))},owner:this});return o(t()),o},i.extenders.posInterer=function(t,n){var o=e("Utils"),s=i.computed({read:t,write:function(e){var i=o.pInt(e.toString(),n);0>=i&&(i=n),i===t()&&""+i!=""+e&&t(i+1),t(i)}});return s(t()),s},i.extenders.reversible=function(e){var t=e();return e.commit=function(){t=e()},e.reverse=function(){e(t)},e.commitedValue=function(){return t},e},i.extenders.toggleSubscribe=function(e,t){return e.subscribe(t[1],t[0],"beforeChange"),e.subscribe(t[2],t[0]),e},i.extenders.falseTimeout=function(t,i){var o=e("Utils");return t.iTimeout=0,t.subscribe(function(e){e&&(n.clearTimeout(t.iTimeout),t.iTimeout=n.setTimeout(function(){t(!1),t.iTimeout=0},o.pInt(i)))}),t},i.observable.fn.validateNone=function(){return this.hasError=i.observable(!1),this},i.observable.fn.validateEmail=function(){var t=e("Utils");return this.hasError=i.observable(!1),this.subscribe(function(e){e=t.trim(e),this.hasError(""!==e&&!/^[^@\s]+@[^@\s]+$/.test(e))},this),this.valueHasMutated(),this},i.observable.fn.validateSimpleEmail=function(){var t=e("Utils");return this.hasError=i.observable(!1),this.subscribe(function(e){e=t.trim(e),this.hasError(""!==e&&!/^.+@.+$/.test(e))},this),this.valueHasMutated(),this},i.observable.fn.validateFunc=function(t){var n=e("Utils");return this.hasFuncError=i.observable(!1),n.isFunc(t)&&(this.subscribe(function(e){this.hasFuncError(!t(e))},this),this.valueHasMutated()),this},t.exports=i}(t,ko)},{$:14,Globals:8,"Model:ContactTag":25,"Model:Email":26,Utils:11,_:19,window:20}],17:[function(e,t){t.exports=moment},{}],18:[function(e,t){t.exports=ssm},{}],19:[function(e,t){t.exports=_},{}],20:[function(e,t){t.exports=window},{}],21:[function(e,t){!function(e,t){"use strict";function i(){this.oScreens={},this.sDefaultScreenName="",this.oCurrentScreen=null}var n=t("_"),o=t("$"),s=t("ko"),a=t("hasher"),r=t("crossroads"),l=t("Globals"),c=t("Plugins"),u=t("Utils");i.prototype.oScreens={},i.prototype.sDefaultScreenName="",i.prototype.oCurrentScreen=null,i.prototype.hideLoading=function(){o("#rl-loading").hide()},i.prototype.constructorEnd=function(e){u.isFunc(e.__constructor_end)&&e.__constructor_end.call(e)},i.prototype.extendAsViewModel=function(e,t){t&&(t.__names=u.isArray(e)?e:[e],t.__name=t.__names[0])},i.prototype.addSettingsViewModel=function(e,t,i,n,o){e.__rlSettingsData={Label:i,Template:t,Route:n,IsDefault:!!o},l.aViewModels.settings.push(e)},i.prototype.removeSettingsViewModel=function(e){l.aViewModels["settings-removed"].push(e)},i.prototype.disableSettingsViewModel=function(e){l.aViewModels["settings-disabled"].push(e)},i.prototype.routeOff=function(){a.changed.active=!1},i.prototype.routeOn=function(){a.changed.active=!0},i.prototype.screen=function(e){return""===e||u.isUnd(this.oScreens[e])?null:this.oScreens[e]},i.prototype.buildViewModel=function(e,t){if(e&&!e.__builded){var i=this,a=new e(t),r=a.viewModelPosition(),p=o("#rl-content #rl-"+r.toLowerCase()),d=null;e.__builded=!0,e.__vm=a,a.viewModelName=e.__name,a.viewModelNames=e.__names,p&&1===p.length?(d=o("
").addClass("rl-view-model").addClass("RL-"+a.viewModelTemplate()).hide(),d.appendTo(p),a.viewModelDom=d,e.__dom=d,"Popups"===r&&(a.cancelCommand=a.closeCommand=u.createCommand(a,function(){i.hideScreenPopup(e)}),a.modalVisibility.subscribe(function(e){var t=this;e?(this.viewModelDom.show(),this.storeAndSetKeyScope(),l.popupVisibilityNames.push(this.viewModelName),a.viewModelDom.css("z-index",3e3+l.popupVisibilityNames().length+10),u.delegateRun(this,"onFocus",[],500)):(u.delegateRun(this,"onHide"),this.restoreKeyScope(),n.each(this.viewModelNames,function(e){c.runHook("view-model-on-hide",[e,t])}),l.popupVisibilityNames.remove(this.viewModelName),a.viewModelDom.css("z-index",2e3),l.tooltipTrigger(!l.tooltipTrigger()),n.delay(function(){t.viewModelDom.hide()},300))},a)),n.each(e.__names,function(e){c.runHook("view-model-pre-build",[e,a,d])}),s.applyBindingAccessorsToNode(d[0],{i18nInit:!0,template:function(){return{name:a.viewModelTemplate()}}},a),u.delegateRun(a,"onBuild",[d]),a&&"Popups"===r&&a.registerPopupKeyDown(),n.each(e.__names,function(e){c.runHook("view-model-post-build",[e,a,d])})):u.log("Cannot find view model position: "+r)}return e?e.__vm:null},i.prototype.hideScreenPopup=function(e){e&&e.__vm&&e.__dom&&e.__vm.modalVisibility(!1)},i.prototype.showScreenPopup=function(e,t){e&&(this.buildViewModel(e),e.__vm&&e.__dom&&(e.__vm.modalVisibility(!0),u.delegateRun(e.__vm,"onShow",t||[]),n.each(e.__names,function(i){c.runHook("view-model-on-show",[i,e.__vm,t||[]])})))},i.prototype.isPopupVisible=function(e){return e&&e.__vm?e.__vm.modalVisibility():!1},i.prototype.screenOnRoute=function(e,t){var i=this,o=null,s=null;""===u.pString(e)&&(e=this.sDefaultScreenName),""!==e&&(o=this.screen(e),o||(o=this.screen(this.sDefaultScreenName),o&&(t=e+"/"+t,e=this.sDefaultScreenName)),o&&o.__started&&(o.__builded||(o.__builded=!0,u.isNonEmptyArray(o.viewModels())&&n.each(o.viewModels(),function(e){this.buildViewModel(e,o)},this),u.delegateRun(o,"onBuild")),n.defer(function(){i.oCurrentScreen&&(u.delegateRun(i.oCurrentScreen,"onHide"),u.isNonEmptyArray(i.oCurrentScreen.viewModels())&&n.each(i.oCurrentScreen.viewModels(),function(e){e.__vm&&e.__dom&&"Popups"!==e.__vm.viewModelPosition()&&(e.__dom.hide(),e.__vm.viewModelVisibility(!1),u.delegateRun(e.__vm,"onHide"))})),i.oCurrentScreen=o,i.oCurrentScreen&&(u.delegateRun(i.oCurrentScreen,"onShow"),c.runHook("screen-on-show",[i.oCurrentScreen.screenName(),i.oCurrentScreen]),u.isNonEmptyArray(i.oCurrentScreen.viewModels())&&n.each(i.oCurrentScreen.viewModels(),function(e){e.__vm&&e.__dom&&"Popups"!==e.__vm.viewModelPosition()&&(e.__dom.show(),e.__vm.viewModelVisibility(!0),u.delegateRun(e.__vm,"onShow"),u.delegateRun(e.__vm,"onFocus",[],200),n.each(e.__names,function(t){c.runHook("view-model-on-show",[t,e.__vm])}))},i)),s=o.__cross?o.__cross():null,s&&s.parse(t)})))},i.prototype.startScreens=function(e){o("#rl-content").css({visibility:"hidden"}),n.each(e,function(e){var t=new e,i=t?t.screenName():"";t&&""!==i&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=i),this.oScreens[i]=t)},this),n.each(this.oScreens,function(e){e&&!e.__started&&e.__start&&(e.__started=!0,e.__start(),c.runHook("screen-pre-start",[e.screenName(),e]),u.delegateRun(e,"onStart"),c.runHook("screen-post-start",[e.screenName(),e]))},this);var t=r.create();t.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,n.bind(this.screenOnRoute,this)),a.initialized.add(t.parse,t),a.changed.add(t.parse,t),a.init(),o("#rl-content").css({visibility:"visible"}),n.delay(function(){l.$html.removeClass("rl-started-trigger").addClass("rl-started")},50)},i.prototype.setHash=function(e,t,i){e="#"===e.substr(0,1)?e.substr(1):e,e="/"===e.substr(0,1)?e.substr(1):e,i=u.isUnd(i)?!1:!!i,(u.isUnd(t)?1:!t)?(a.changed.active=!0,a[i?"replaceHash":"setHash"](e),a.setHash(e)):(a.changed.active=!1,a[i?"replaceHash":"setHash"](e),a.changed.active=!0)},e.exports=new i}(t,e)},{$:14,Globals:8,Plugins:10,Utils:11,_:19,crossroads:12,hasher:13,ko:16}],22:[function(e,t){!function(e){"use strict";function t(){}t.prototype.bootstart=function(){},e.exports=t}(t,e)},{}],23:[function(e,t){!function(e,t){"use strict";function i(e,t){this.sScreenName=e,this.aViewModels=s.isArray(t)?t:[]}var n=t("_"),o=t("crossroads"),s=t("Utils");i.prototype.oCross=null,i.prototype.sScreenName="",i.prototype.aViewModels=[],i.prototype.viewModels=function(){return this.aViewModels},i.prototype.screenName=function(){return this.sScreenName},i.prototype.routes=function(){return null},i.prototype.__cross=function(){return this.oCross},i.prototype.__start=function(){var e=this.routes(),t=null,i=null;s.isNonEmptyArray(e)&&(i=n.bind(this.onRoute||s.emptyFunction,this),t=o.create(),n.each(e,function(e){t.addRoute(e[0],i).rules=e[1]}),this.oCross=t)},e.exports=i}(t,e)},{Utils:11,_:19,crossroads:12}],24:[function(e,t){!function(e,t){"use strict"; -function i(e,t){this.bDisabeCloseOnEsc=!1,this.sPosition=s.pString(e),this.sTemplate=s.pString(t),this.sDefaultKeyScope=o.KeyState.None,this.sCurrentKeyScope=this.sDefaultKeyScope,this.viewModelVisibility=n.observable(!1),this.modalVisibility=n.observable(!1).extend({rateLimit:0}),this.viewModelName="",this.viewModelNames=[],this.viewModelDom=null}var n=t("ko"),o=t("Enums"),s=t("Utils"),a=t("Globals");i.prototype.bDisabeCloseOnEsc=!1,i.prototype.sPosition="",i.prototype.sTemplate="",i.prototype.sDefaultKeyScope=o.KeyState.None,i.prototype.sCurrentKeyScope=o.KeyState.None,i.prototype.viewModelName="",i.prototype.viewModelNames=[],i.prototype.viewModelDom=null,i.prototype.viewModelTemplate=function(){return this.sTemplate},i.prototype.viewModelPosition=function(){return this.sPosition},i.prototype.cancelCommand=function(){},i.prototype.closeCommand=function(){},i.prototype.storeAndSetKeyScope=function(){this.sCurrentKeyScope=a.keyScope(),a.keyScope(this.sDefaultKeyScope)},i.prototype.restoreKeyScope=function(){a.keyScope(this.sCurrentKeyScope)},i.prototype.registerPopupKeyDown=function(){var e=this;a.$win.on("keydown",function(t){if(t&&e.modalVisibility&&e.modalVisibility()){if(!this.bDisabeCloseOnEsc&&o.EventKeyCode.Esc===t.keyCode)return s.delegateRun(e,"cancelCommand"),!1;if(o.EventKeyCode.Backspace===t.keyCode&&!s.inFocus())return!1}return!0})},e.exports=i}(t,e)},{Enums:6,Globals:8,Utils:11,ko:16}],25:[function(e,t){!function(e,t){"use strict";function i(){this.idContactTag=0,this.name=n.observable(""),this.readOnly=!1}var n=t("ko"),o=t("Utils");i.prototype.parse=function(e){var t=!1;return e&&"Object/Tag"===e["@Object"]&&(this.idContact=o.pInt(e.IdContactTag),this.name(o.pString(e.Name)),this.readOnly=!!e.ReadOnly,t=!0),t},i.prototype.filterHelper=function(e){return-1!==this.name().toLowerCase().indexOf(e.toLowerCase())},i.prototype.toLine=function(e){return(o.isUnd(e)?1:!e)?this.name():o.encodeHtml(this.name())},e.exports=i}(t,e)},{Utils:11,ko:16}],26:[function(e,t){!function(e,t){"use strict";function i(e,t){this.email=e||"",this.name=t||"",this.clearDuplicateName()}var n=t("Utils");i.newInstanceFromJson=function(e){var t=new i;return t.initByJson(e)?t:null},i.prototype.name="",i.prototype.email="",i.prototype.clear=function(){this.email="",this.name=""},i.prototype.validate=function(){return""!==this.name||""!==this.email},i.prototype.hash=function(e){return"#"+(e?"":this.name)+"#"+this.email+"#"},i.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},i.prototype.search=function(e){return-1<(this.name+" "+this.email).toLowerCase().indexOf(e.toLowerCase())},i.prototype.parse=function(e){this.clear(),e=n.trim(e);var t=/(?:"([^"]+)")? ?,]+)>?,? ?/g,i=t.exec(e);i?(this.name=i[1]||"",this.email=i[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(e)&&(this.name="",this.email=e)},i.prototype.initByJson=function(e){var t=!1;return e&&"Object/Email"===e["@Object"]&&(this.name=n.trim(e.Name),this.email=n.trim(e.Email),t=""!==this.email,this.clearDuplicateName()),t},i.prototype.toLine=function(e,t,i){var o="";return""!==this.email&&(t=n.isUnd(t)?!1:!!t,i=n.isUnd(i)?!1:!!i,e&&""!==this.name?o=t?'
")+'" target="_blank" tabindex="-1">'+n.encodeHtml(this.name)+"":i?n.encodeHtml(this.name):this.name:(o=this.email,""!==this.name?t?o=n.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+n.encodeHtml(o)+""+n.encodeHtml(">"):(o='"'+this.name+'" <'+o+">",i&&(o=n.encodeHtml(o))):t&&(o=''+n.encodeHtml(this.email)+""))),o},i.prototype.mailsoParse=function(e){if(e=n.trim(e),""===e)return!1;for(var t=function(e,t,i){e+="";var n=e.length;return 0>t&&(t+=n),n="undefined"==typeof i?n:0>i?i+n:i+t,t>=e.length||0>t||t>n?!1:e.slice(t,n)},i=function(e,t,i,n){return 0>i&&(i+=e.length),n=void 0!==n?n:e.length,0>n&&(n=n+e.length-i),e.slice(0,i)+t.substr(0,n)+t.slice(n)+e.slice(i+n)},o="",s="",a="",r=!1,l=!1,c=!1,u=null,p=0,d=0,g=0;g0&&0===o.length&&(o=t(e,0,g)),l=!0,p=g);break;case">":l&&(d=g,s=t(e,p+1,d-p-1),e=i(e,"",p,d-p+1),d=0,g=0,p=0,l=!1);break;case"(":r||l||c||(c=!0,p=g);break;case")":c&&(d=g,a=t(e,p+1,d-p-1),e=i(e,"",p,d-p+1),d=0,g=0,p=0,c=!1);break;case"\\":g++}g++}return 0===s.length&&(u=e.match(/[^@\s]+@\S+/i),u&&u[0]?s=u[0]:o=e),s.length>0&&0===o.length&&0===a.length&&(o=e.replace(s,"")),s=n.trim(s).replace(/^[<]+/,"").replace(/[>]+$/,""),o=n.trim(o).replace(/^["']+/,"").replace(/["']+$/,""),a=n.trim(a).replace(/^[(]+/,"").replace(/[)]+$/,""),o=o.replace(/\\\\(.)/g,"$1"),a=a.replace(/\\\\(.)/g,"$1"),this.name=o,this.email=s,this.clearDuplicateName(),!0},i.prototype.inputoTagLine=function(){return 0").addClass("rl-settings-view-model").hide(),d.appendTo(p),i.viewModelDom=d,i.__rlSettingsData=u.__rlSettingsData,u.__dom=d,u.__builded=!0,u.__vm=i,s.applyBindingAccessorsToNode(d[0],{i18nInit:!0,template:function(){return{name:u.__rlSettingsData.Template}}},i),r.delegateRun(i,"onBuild",[d])):r.log("Cannot find sub settings view model position: SettingsSubScreen")),i&&n.defer(function(){t.oCurrentSubScreen&&(r.delegateRun(t.oCurrentSubScreen,"onHide"),t.oCurrentSubScreen.viewModelDom.hide()),t.oCurrentSubScreen=i,t.oCurrentSubScreen&&(t.oCurrentSubScreen.viewModelDom.show(),r.delegateRun(t.oCurrentSubScreen,"onShow"),r.delegateRun(t.oCurrentSubScreen,"onFocus",[],200),n.each(t.menu(),function(e){e.selected(i&&i.__rlSettingsData&&e.route===i.__rlSettingsData.Route)}),o("#rl-content .b-settings .b-content .content").scrollTop(0)),r.windowResize()})):c.setHash(l.settings(),!1,!0)},i.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(r.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},i.prototype.onBuild=function(){n.each(a.aViewModels.settings,function(e){e&&e.__rlSettingsData&&!n.find(a.aViewModels["settings-removed"],function(t){return t&&t===e})&&this.menu.push({route:e.__rlSettingsData.Route,label:e.__rlSettingsData.Label,selected:s.observable(!1),disabled:!!n.find(a.aViewModels["settings-disabled"],function(t){return t&&t===e})})},this),this.oViewModelPlace=o("#rl-content #rl-settings-subscreen")},i.prototype.routes=function(){var e=n.find(a.aViewModels.settings,function(e){return e&&e.__rlSettingsData&&e.__rlSettingsData.IsDefault}),t=e?e.__rlSettingsData.Route:"general",i={subname:/^(.*)$/,normalize_:function(e,i){return i.subname=r.isUnd(i.subname)?t:r.pString(i.subname),[i.subname]}};return[["{subname}/",i],["{subname}",i],["",i]]},e.exports=i}(t,e)},{$:14,"App:Knoin":21,Globals:8,"Knoin:AbstractScreen":23,LinkBuilder:9,Utils:11,_:19,ko:16}],28:[function(e,t){!function(e,t){"use strict";function i(){o.call(this,"login",[t("View:Admin:Login")])}var n=t("_"),o=t("Knoin:AbstractScreen");n.extend(i.prototype,o.prototype),i.prototype.onShow=function(){t("App:Admin").setTitle("")},e.exports=i}(t,e)},{"App:Admin":3,"Knoin:AbstractScreen":23,"View:Admin:Login":46,_:19}],29:[function(e,t){!function(e,t){"use strict";function i(){o.call(this,[t("View:Admin:SettingsMenu"),t("View:Admin:SettingsPane")])}var n=t("_"),o=t("Screen:AbstractSettings");n.extend(i.prototype,o.prototype),i.prototype.onShow=function(){t("App:Admin").setTitle("")},e.exports=i}(t,e)},{"App:Admin":3,"Screen:AbstractSettings":27,"View:Admin:SettingsMenu":47,"View:Admin:SettingsPane":48,_:19}],30:[function(e,t){!function(e,t){"use strict";function i(){var e=t("Storage:Settings"),i=t("Storage:Admin:Data");this.version=n.observable(e.settingsGet("Version")),this.access=n.observable(!!e.settingsGet("CoreAccess")),this.errorDesc=n.observable(""),this.coreReal=i.coreReal,this.coreUpdatable=i.coreUpdatable,this.coreAccess=i.coreAccess,this.coreChecking=i.coreChecking,this.coreUpdating=i.coreUpdating,this.coreRemoteVersion=i.coreRemoteVersion,this.coreRemoteRelease=i.coreRemoteRelease,this.coreVersionCompare=i.coreVersionCompare,this.statusType=n.computed(function(){var e="",t=this.coreVersionCompare(),i=this.coreChecking(),n=this.coreUpdating(),o=this.coreReal();return i?e="checking":n?e="updating":o&&0===t?e="up-to-date":o&&-1===t?e="available":o||(e="error",this.errorDesc("Cannot access the repository at the moment.")),e},this)}var n=t("ko");i.prototype.onBuild=function(){this.access()&&t("App:Admin").reloadCoreData()},i.prototype.updateCoreData=function(){this.coreUpdating()||t("App:Admin").updateCoreData()},e.exports=i}(t,e)},{"App:Admin":3,"Storage:Admin:Data":43,"Storage:Settings":45,ko:16}],31:[function(e,t){!function(e,t){"use strict";function i(){var e=t("Enums"),i=t("Storage:Settings");this.title=o.observable(i.settingsGet("Title")),this.title.trigger=o.observable(e.SaveSettingsStep.Idle),this.loadingDesc=o.observable(i.settingsGet("LoadingDescription")),this.loadingDesc.trigger=o.observable(e.SaveSettingsStep.Idle),this.loginLogo=o.observable(i.settingsGet("LoginLogo")),this.loginLogo.trigger=o.observable(e.SaveSettingsStep.Idle),this.loginDescription=o.observable(i.settingsGet("LoginDescription")),this.loginDescription.trigger=o.observable(e.SaveSettingsStep.Idle),this.loginCss=o.observable(i.settingsGet("LoginCss")),this.loginCss.trigger=o.observable(e.SaveSettingsStep.Idle)}var n=t("_"),o=t("ko"),s=t("Utils");i.prototype.onBuild=function(){var e=this,i=t("Storage:Admin:Remote");n.delay(function(){var t=s.settingsSaveHelperSimpleFunction(e.title.trigger,e),n=s.settingsSaveHelperSimpleFunction(e.loadingDesc.trigger,e),o=s.settingsSaveHelperSimpleFunction(e.loginLogo.trigger,e),a=s.settingsSaveHelperSimpleFunction(e.loginDescription.trigger,e),r=s.settingsSaveHelperSimpleFunction(e.loginCss.trigger,e);e.title.subscribe(function(e){i.saveAdminConfig(t,{Title:s.trim(e)})}),e.loadingDesc.subscribe(function(e){i.saveAdminConfig(n,{LoadingDescription:s.trim(e)})}),e.loginLogo.subscribe(function(e){i.saveAdminConfig(o,{LoginLogo:s.trim(e)})}),e.loginDescription.subscribe(function(e){i.saveAdminConfig(a,{LoginDescription:s.trim(e)})}),e.loginCss.subscribe(function(e){i.saveAdminConfig(r,{LoginCss:s.trim(e)})})},50)},e.exports=i}(t,e)},{Enums:6,"Storage:Admin:Remote":44,"Storage:Settings":45,Utils:11,_:19,ko:16}],32:[function(e,t){!function(e,t){"use strict";function i(){var e=t("Storage:Admin:Remote");this.defautOptionsAfterRender=a.defautOptionsAfterRender,this.enableContacts=o.observable(!!r.settingsGet("ContactsEnable")),this.contactsSharing=o.observable(!!r.settingsGet("ContactsSharing")),this.contactsSync=o.observable(!!r.settingsGet("ContactsSync"));var i=["sqlite","mysql","pgsql"],l=[],c=function(e){switch(e){case"sqlite":e="SQLite";break;case"mysql":e="MySQL";break;case"pgsql":e="PostgreSQL"}return e};r.settingsGet("SQLiteIsSupported")&&l.push("sqlite"),r.settingsGet("MySqlIsSupported")&&l.push("mysql"),r.settingsGet("PostgreSqlIsSupported")&&l.push("pgsql"),this.contactsSupported=0(new n.Date).getTime()-m),f&&l.oRequests[f]&&(l.oRequests[f].__aborted&&(o="abort"),l.oRequests[f]=null),l.defaultResponse(e,f,o,i,s,t)}),f&&0').appendTo('body'); - - Globals.$win.on('error', function (oEvent) { - if (oEvent && oEvent.originalEvent && oEvent.originalEvent.message && - -1 === Utils.inArray(oEvent.originalEvent.message, [ - 'Script error.', 'Uncaught Error: Error calling method on NPObject.' - ])) - { - Remote.jsError( - Utils.emptyFunction, - oEvent.originalEvent.message, - oEvent.originalEvent.filename, - oEvent.originalEvent.lineno, - window.location && window.location.toString ? window.location.toString() : '', - Globals.$html.attr('class'), - Utils.microtime() - Globals.now - ); - } - }); - - Globals.$doc.on('keydown', function (oEvent) { - if (oEvent && oEvent.ctrlKey) - { - Globals.$html.addClass('rl-ctrl-key-pressed'); - } - }).on('keyup', function (oEvent) { - if (oEvent && !oEvent.ctrlKey) - { - Globals.$html.removeClass('rl-ctrl-key-pressed'); - } - }); - } - - _.extend(AbstractApp.prototype, KnoinAbstractBoot.prototype); - - AbstractApp.prototype.remote = function () - { - return null; - }; - - AbstractApp.prototype.data = function () - { - return null; - }; - - AbstractApp.prototype.setupSettings = function () - { - return true; - }; - - /** - * @param {string} sLink - * @return {boolean} - */ - AbstractApp.prototype.download = function (sLink) - { var - oE = null, - oLink = null, - sUserAgent = window.navigator.userAgent.toLowerCase() + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + moment = __webpack_require__(/*! moment */ 25), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Consts = __webpack_require__(/*! Common/Consts */ 17), + Plugins = __webpack_require__(/*! Common/Plugins */ 26), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + Events = __webpack_require__(/*! Common/Events */ 22), + + kn = __webpack_require__(/*! App:Knoin */ 5), + + Local = __webpack_require__(/*! Storage:LocalStorage */ 30), + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13), + + EmailModel = __webpack_require__(/*! Model:Email */ 23), + FolderModel = __webpack_require__(/*! Model:Folder */ 58), + MessageModel = __webpack_require__(/*! Model:Message */ 38), + AccountModel = __webpack_require__(/*! Model:Account */ 51), + IdentityModel = __webpack_require__(/*! Model:Identity */ 59), + OpenPgpKeyModel = __webpack_require__(/*! Model:OpenPgpKey */ 60), + + AbstractApp = __webpack_require__(/*! App:Abstract */ 34) ; - if (sUserAgent && (sUserAgent.indexOf('chrome') > -1 || sUserAgent.indexOf('chrome') > -1)) + /** + * @constructor + * @extends AbstractApp + */ + function RainLoopApp() { - oLink = window.document.createElement('a'); - oLink['href'] = sLink; + AbstractApp.call(this, Remote); - if (window.document['createEvent']) - { - oE = window.document['createEvent']('MouseEvents'); - if (oE && oE['initEvent'] && oLink['dispatchEvent']) - { - oE['initEvent']('click', true, true); - oLink['dispatchEvent'](oE); - return true; - } - } - } + this.oMoveCache = {}; - if (Globals.bMobileDevice) - { - window.open(sLink, '_self'); - window.focus(); - } - else - { - this.iframe.attr('src', sLink); - // window.document.location.href = sLink; - } + this.quotaDebounce = _.debounce(this.quota, 1000 * 30); + this.moveOrDeleteResponseHelper = _.bind(this.moveOrDeleteResponseHelper, this); - return true; - }; + this.messagesMoveTrigger = _.debounce(this.messagesMoveTrigger, 500); - /** - * @param {string} sTitle - */ - AbstractApp.prototype.setTitle = function (sTitle) - { - sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') + - Settings.settingsGet('Title') || ''; - - window.document.title = '_'; - window.document.title = sTitle; - }; - - /** - * @param {boolean=} bLogout = false - * @param {boolean=} bClose = false - */ - AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose) - { - var - kn = require('App:Knoin'), - sCustomLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')), - bInIframe = !!Settings.settingsGet('InIframe') - ; - - bLogout = Utils.isUnd(bLogout) ? false : !!bLogout; - bClose = Utils.isUnd(bClose) ? false : !!bClose; - - if (bLogout && bClose && window.close) - { - window.close(); - } - - if (bLogout && '' !== sCustomLogoutLink && window.location.href !== sCustomLogoutLink) - { - _.delay(function () { - if (bInIframe && window.parent) - { - window.parent.location.href = sCustomLogoutLink; - } - else - { - window.location.href = sCustomLogoutLink; - } - }, 100); - } - else - { - kn.routeOff(); - kn.setHash(LinkBuilder.root(), true); - kn.routeOff(); - - _.delay(function () { - if (bInIframe && window.parent) - { - window.parent.location.reload(); - } - else - { - window.location.reload(); - } - }, 100); - } - }; - - AbstractApp.prototype.historyBack = function () - { - window.history.back(); - }; - - AbstractApp.prototype.bootstart = function () - { - Events.pub('rl.bootstart'); - - var ssm = require('ssm'); - - Utils.initOnStartOrLangChange(function () { - Utils.initNotificationLanguage(); - }, null); - - _.delay(function () { - Utils.windowResize(); - }, 1000); - - ssm.addState({ - 'id': 'mobile', - 'maxWidth': 767, - 'onEnter': function() { - Globals.$html.addClass('ssm-state-mobile'); - Events.pub('ssm.mobile-enter'); - }, - 'onLeave': function() { - Globals.$html.removeClass('ssm-state-mobile'); - Events.pub('ssm.mobile-leave'); - } - }); - - ssm.addState({ - 'id': 'tablet', - 'minWidth': 768, - 'maxWidth': 999, - 'onEnter': function() { - Globals.$html.addClass('ssm-state-tablet'); - }, - 'onLeave': function() { - Globals.$html.removeClass('ssm-state-tablet'); - } - }); - - ssm.addState({ - 'id': 'desktop', - 'minWidth': 1000, - 'maxWidth': 1400, - 'onEnter': function() { - Globals.$html.addClass('ssm-state-desktop'); - }, - 'onLeave': function() { - Globals.$html.removeClass('ssm-state-desktop'); - } - }); - - ssm.addState({ - 'id': 'desktop-large', - 'minWidth': 1400, - 'onEnter': function() { - Globals.$html.addClass('ssm-state-desktop-large'); - }, - 'onLeave': function() { - Globals.$html.removeClass('ssm-state-desktop-large'); - } - }); - - Events.sub('ssm.mobile-enter', function () { - Globals.leftPanelDisabled(true); - }); - - Events.sub('ssm.mobile-leave', function () { - Globals.leftPanelDisabled(false); - }); - - Globals.leftPanelDisabled.subscribe(function (bValue) { - Globals.$html.toggleClass('rl-left-panel-disabled', bValue); - }); - - ssm.ready(); - }; - - module.exports = AbstractApp; - -}(module, require)); -},{"$":20,"App:Knoin":27,"Events":8,"Globals":9,"Knoin:AbstractBoot":28,"LinkBuilder":11,"Storage:Settings":69,"Utils":14,"_":25,"ssm":24,"window":26}],3:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - moment = require('moment'), - - Enums = require('Enums'), - Globals = require('Globals'), - Consts = require('Consts'), - Plugins = require('Plugins'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - Events = require('Events'), - - kn = require('App:Knoin'), - - Local = require('Storage:LocalStorage'), - Settings = require('Storage:Settings'), - Data = require('Storage:RainLoop:Data'), - Cache = require('Storage:RainLoop:Cache'), - Remote = require('Storage:RainLoop:Remote'), - - EmailModel = require('Model:Email'), - FolderModel = require('Model:Folder'), - MessageModel = require('Model:Message'), - AccountModel = require('Model:Account'), - IdentityModel = require('Model:Identity'), - OpenPgpKeyModel = require('Model:OpenPgpKey'), - - AbstractApp = require('App:Abstract') - ; - - /** - * @constructor - * @extends AbstractApp - */ - function RainLoopApp() - { - AbstractApp.call(this, Remote); - - this.oMoveCache = {}; - - this.quotaDebounce = _.debounce(this.quota, 1000 * 30); - this.moveOrDeleteResponseHelper = _.bind(this.moveOrDeleteResponseHelper, this); - - this.messagesMoveTrigger = _.debounce(this.messagesMoveTrigger, 500); - - window.setInterval(function () { - Events.pub('interval.30s'); - }, 30000); - - window.setInterval(function () { - Events.pub('interval.1m'); - }, 60000); - - window.setInterval(function () { - Events.pub('interval.2m'); - }, 60000 * 2); - - window.setInterval(function () { - Events.pub('interval.3m'); - }, 60000 * 3); - - window.setInterval(function () { - Events.pub('interval.5m'); - }, 60000 * 5); - - window.setInterval(function () { - Events.pub('interval.10m'); - }, 60000 * 10); - - window.setTimeout(function () { window.setInterval(function () { - Events.pub('interval.10m-after5m'); + Events.pub('interval.30s'); + }, 30000); + + window.setInterval(function () { + Events.pub('interval.1m'); + }, 60000); + + window.setInterval(function () { + Events.pub('interval.2m'); + }, 60000 * 2); + + window.setInterval(function () { + Events.pub('interval.3m'); + }, 60000 * 3); + + window.setInterval(function () { + Events.pub('interval.5m'); + }, 60000 * 5); + + window.setInterval(function () { + Events.pub('interval.10m'); }, 60000 * 10); - }, 60000 * 5); - $.wakeUp(function () { + window.setTimeout(function () { + window.setInterval(function () { + Events.pub('interval.10m-after5m'); + }, 60000 * 10); + }, 60000 * 5); - Remote.jsVersion(function (sResult, oData) { - if (Enums.StorageResultType.Success === sResult && oData && !oData.Result) - { - if (window.parent && !!Settings.settingsGet('InIframe')) + $.wakeUp(function () { + + Remote.jsVersion(function (sResult, oData) { + if (Enums.StorageResultType.Success === sResult && oData && !oData.Result) { - window.parent.location.reload(); + if (window.parent && !!Settings.settingsGet('InIframe')) + { + window.parent.location.reload(); + } + else + { + window.location.reload(); + } } - else - { - window.location.reload(); - } - } - }, Settings.settingsGet('Version')); + }, Settings.settingsGet('Version')); - }, {}, 60 * 60 * 1000); + }, {}, 60 * 60 * 1000); - this.socialUsers = _.bind(this.socialUsers, this); - } - - _.extend(RainLoopApp.prototype, AbstractApp.prototype); - - RainLoopApp.prototype.remote = function () - { - return Remote; - }; - - RainLoopApp.prototype.data = function () - { - return Data; - }; - - RainLoopApp.prototype.setupSettings = function () - { - kn.addSettingsViewModel(require('Settings:RainLoop:General'), - 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true); - - if (Settings.settingsGet('ContactsIsAllowed')) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Contacts'), - 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts'); + this.socialUsers = _.bind(this.socialUsers, this); } - if (Settings.capa(Enums.Capa.AdditionalAccounts)) + _.extend(RainLoopApp.prototype, AbstractApp.prototype); + + RainLoopApp.prototype.remote = function () { - kn.addSettingsViewModel(require('Settings:RainLoop:Accounts'), - 'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts'); - } + return Remote; + }; - if (Settings.capa(Enums.Capa.AdditionalIdentities)) + RainLoopApp.prototype.data = function () { - kn.addSettingsViewModel(require('Settings:RainLoop:Identities'), - 'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities'); - } - else + return Data; + }; + + RainLoopApp.prototype.reloadFlagsCurrentMessageListAndMessageFromCache = function () { - kn.addSettingsViewModel(require('Settings:RainLoop:Identity'), - 'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity'); - } + _.each(Data.messageList(), function (oMessage) { + Cache.initMessageFlagsFromCache(oMessage); + }); - if (Settings.capa(Enums.Capa.Filters)) + Cache.initMessageFlagsFromCache(Data.message()); + }; + + /** + * @param {boolean=} bDropPagePosition = false + * @param {boolean=} bDropCurrenFolderCache = false + */ + RainLoopApp.prototype.reloadMessageList = function (bDropPagePosition, bDropCurrenFolderCache) { - kn.addSettingsViewModel(require('Settings:RainLoop:Filters'), - 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters'); - } - - if (Settings.capa(Enums.Capa.TwoFactor)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Security'), - 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security'); - } - - if (Settings.settingsGet('AllowGoogleSocial') || - Settings.settingsGet('AllowFacebookSocial') || - Settings.settingsGet('AllowTwitterSocial')) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Social'), - 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social'); - } - - if (Settings.settingsGet('ChangePasswordIsAllowed')) - { - kn.addSettingsViewModel(require('Settings:RainLoop:ChangePassword'), - 'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password'); - } - - kn.addSettingsViewModel(require('Settings:RainLoop:Folders'), - 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders'); - - if (Settings.capa(Enums.Capa.Themes)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:Themes'), - 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes'); - } - - if (Settings.capa(Enums.Capa.OpenPGP)) - { - kn.addSettingsViewModel(require('Settings:RainLoop:OpenPGP'), - 'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp'); - } - - return true; - }; - - RainLoopApp.prototype.reloadFlagsCurrentMessageListAndMessageFromCache = function () - { - _.each(Data.messageList(), function (oMessage) { - Cache.initMessageFlagsFromCache(oMessage); - }); - - Cache.initMessageFlagsFromCache(Data.message()); - }; - - /** - * @param {boolean=} bDropPagePosition = false - * @param {boolean=} bDropCurrenFolderCache = false - */ - RainLoopApp.prototype.reloadMessageList = function (bDropPagePosition, bDropCurrenFolderCache) - { - var - self = this, - iOffset = (Data.messageListPage() - 1) * Data.messagesPerPage() - ; - - if (Utils.isUnd(bDropCurrenFolderCache) ? false : !!bDropCurrenFolderCache) - { - Cache.setFolderHash(Data.currentFolderFullNameRaw(), ''); - } - - if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition) - { - Data.messageListPage(1); - iOffset = 0; - } - - Data.messageListLoading(true); - Remote.messageList(function (sResult, oData, bCached) { - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - Data.messageListError(''); - Data.messageListLoading(false); - self.setMessageList(oData, bCached); - } - else if (Enums.StorageResultType.Unload === sResult) - { - Data.messageListError(''); - Data.messageListLoading(false); - } - else if (Enums.StorageResultType.Abort !== sResult) - { - Data.messageList([]); - Data.messageListLoading(false); - Data.messageListError(oData && oData.ErrorCode ? - Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST') - ); - } - - }, Data.currentFolderFullNameRaw(), iOffset, Data.messagesPerPage(), Data.messageListSearch()); - }; - - RainLoopApp.prototype.recacheInboxMessageList = function () - { - Remote.messageList(Utils.emptyFunction, 'INBOX', 0, Data.messagesPerPage(), '', true); - }; - - RainLoopApp.prototype.reloadMessageListHelper = function (bEmptyList) - { - this.reloadMessageList(bEmptyList); - }; - - /** - * @param {Function} fResultFunc - * @returns {boolean} - */ - RainLoopApp.prototype.contactsSync = function (fResultFunc) - { - var oContacts = Data.contacts; - if (oContacts.importing() || oContacts.syncing() || !Data.enableContactsSync() || !Data.allowContactsSync()) - { - return false; - } - - oContacts.syncing(true); - - Remote.contactsSync(function (sResult, oData) { - - oContacts.syncing(false); - - if (fResultFunc) - { - fResultFunc(sResult, oData); - } - }); - - return true; - }; - - RainLoopApp.prototype.messagesMoveTrigger = function () - { - var - self = this, - sSpamFolder = Data.spamFolder() - ; - - _.each(this.oMoveCache, function (oItem) { - var - bSpam = sSpamFolder === oItem['To'], - bHam = !bSpam && sSpamFolder === oItem['From'] && 'INBOX' === oItem['To'] + self = this, + iOffset = (Data.messageListPage() - 1) * Data.messagesPerPage() ; - Remote.messagesMove(self.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'], - bSpam ? 'SPAM' : (bHam ? 'HAM' : '')); - }); - - this.oMoveCache = {}; - }; - - RainLoopApp.prototype.messagesMoveHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForMove) - { - var sH = '$$' + sFromFolderFullNameRaw + '$$' + sToFolderFullNameRaw + '$$'; - if (!this.oMoveCache[sH]) - { - this.oMoveCache[sH] = { - 'From': sFromFolderFullNameRaw, - 'To': sToFolderFullNameRaw, - 'Uid': [] - }; - } - - this.oMoveCache[sH]['Uid'] = _.union(this.oMoveCache[sH]['Uid'], aUidForMove); - this.messagesMoveTrigger(); - }; - - RainLoopApp.prototype.messagesCopyHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForCopy) - { - Remote.messagesCopy( - this.moveOrDeleteResponseHelper, - sFromFolderFullNameRaw, - sToFolderFullNameRaw, - aUidForCopy - ); - }; - - RainLoopApp.prototype.messagesDeleteHelper = function (sFromFolderFullNameRaw, aUidForRemove) - { - Remote.messagesDelete( - this.moveOrDeleteResponseHelper, - sFromFolderFullNameRaw, - aUidForRemove - ); - }; - - RainLoopApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData) - { - if (Enums.StorageResultType.Success === sResult && Data.currentFolder()) - { - if (oData && Utils.isArray(oData.Result) && 2 === oData.Result.length) - { - Cache.setFolderHash(oData.Result[0], oData.Result[1]); - } - else + if (Utils.isUnd(bDropCurrenFolderCache) ? false : !!bDropCurrenFolderCache) { Cache.setFolderHash(Data.currentFolderFullNameRaw(), ''); - - if (oData && -1 < Utils.inArray(oData.ErrorCode, - [Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage])) - { - window.alert(Utils.getNotification(oData.ErrorCode)); - } } - this.reloadMessageListHelper(0 === Data.messageList().length); - this.quotaDebounce(); - } - }; - - /** - * @param {string} sFromFolderFullNameRaw - * @param {Array} aUidForRemove - */ - RainLoopApp.prototype.deleteMessagesFromFolderWithoutCheck = function (sFromFolderFullNameRaw, aUidForRemove) - { - this.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); - Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); - }; - - /** - * @param {number} iDeleteType - * @param {string} sFromFolderFullNameRaw - * @param {Array} aUidForRemove - * @param {boolean=} bUseFolder = true - */ - RainLoopApp.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFolderFullNameRaw, aUidForRemove, bUseFolder) - { - var - self = this, - oMoveFolder = null, - nSetSystemFoldersNotification = null - ; - - switch (iDeleteType) - { - case Enums.FolderType.Spam: - oMoveFolder = Cache.getFolderFromCacheList(Data.spamFolder()); - nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Spam; - break; - case Enums.FolderType.NotSpam: - oMoveFolder = Cache.getFolderFromCacheList('INBOX'); - break; - case Enums.FolderType.Trash: - oMoveFolder = Cache.getFolderFromCacheList(Data.trashFolder()); - nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Trash; - break; - case Enums.FolderType.Archive: - oMoveFolder = Cache.getFolderFromCacheList(Data.archiveFolder()); - nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Archive; - break; - } - - bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder; - if (bUseFolder) - { - if ((Enums.FolderType.Spam === iDeleteType && Consts.Values.UnuseOptionValue === Data.spamFolder()) || - (Enums.FolderType.Trash === iDeleteType && Consts.Values.UnuseOptionValue === Data.trashFolder()) || - (Enums.FolderType.Archive === iDeleteType && Consts.Values.UnuseOptionValue === Data.archiveFolder())) + if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition) { - bUseFolder = false; + Data.messageListPage(1); + iOffset = 0; } - } - if (!oMoveFolder && bUseFolder) + Data.messageListLoading(true); + Remote.messageList(function (sResult, oData, bCached) { + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + { + Data.messageListError(''); + Data.messageListLoading(false); + self.setMessageList(oData, bCached); + } + else if (Enums.StorageResultType.Unload === sResult) + { + Data.messageListError(''); + Data.messageListLoading(false); + } + else if (Enums.StorageResultType.Abort !== sResult) + { + Data.messageList([]); + Data.messageListLoading(false); + Data.messageListError(oData && oData.ErrorCode ? + Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST') + ); + } + + }, Data.currentFolderFullNameRaw(), iOffset, Data.messagesPerPage(), Data.messageListSearch()); + }; + + RainLoopApp.prototype.recacheInboxMessageList = function () { - kn.showScreenPopup(require('View:Popup:FolderSystem'), [nSetSystemFoldersNotification]); - } - else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType && - (sFromFolderFullNameRaw === Data.spamFolder() || sFromFolderFullNameRaw === Data.trashFolder()))) + Remote.messageList(Utils.emptyFunction, 'INBOX', 0, Data.messagesPerPage(), '', true); + }; + + RainLoopApp.prototype.reloadMessageListHelper = function (bEmptyList) { - kn.showScreenPopup(require('View:Popup:Ask'), [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () { + this.reloadMessageList(bEmptyList); + }; - self.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); - Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); - - }]); - } - else if (oMoveFolder) + /** + * @param {Function} fResultFunc + * @returns {boolean} + */ + RainLoopApp.prototype.contactsSync = function (fResultFunc) { - this.messagesMoveHelper(sFromFolderFullNameRaw, oMoveFolder.fullNameRaw, aUidForRemove); - Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, oMoveFolder.fullNameRaw); - } - }; - - /** - * @param {string} sFromFolderFullNameRaw - * @param {Array} aUidForMove - * @param {string} sToFolderFullNameRaw - * @param {boolean=} bCopy = false - */ - RainLoopApp.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForMove, sToFolderFullNameRaw, bCopy) - { - if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForMove) && 0 < aUidForMove.length) - { - var - oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw), - oToFolder = Cache.getFolderFromCacheList(sToFolderFullNameRaw) - ; - - if (oFromFolder && oToFolder) + var oContacts = Data.contacts; + if (oContacts.importing() || oContacts.syncing() || !Data.enableContactsSync() || !Data.allowContactsSync()) { - if (Utils.isUnd(bCopy) ? false : !!bCopy) - { - this.messagesCopyHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove); - } - else - { - this.messagesMoveHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove); - } - - Data.removeMessagesFromList(oFromFolder.fullNameRaw, aUidForMove, oToFolder.fullNameRaw, bCopy); - return true; + return false; } - } - return false; - }; + oContacts.syncing(true); - /** - * @param {Function=} fCallback - */ - RainLoopApp.prototype.folders = function (fCallback) - { - Data.foldersLoading(true); - Remote.folders(_.bind(function (sResult, oData) { + Remote.contactsSync(function (sResult, oData) { - Data.foldersLoading(false); - if (Enums.StorageResultType.Success === sResult) - { - this.setFolders(oData); - if (fCallback) + oContacts.syncing(false); + + if (fResultFunc) { - fCallback(true); - } - } - else - { - if (fCallback) - { - fCallback(false); - } - } - }, this)); - }; - - RainLoopApp.prototype.reloadOpenPgpKeys = function () - { - if (Data.capaOpenPGP()) - { - var - aKeys = [], - oEmail = new EmailModel(), - oOpenpgpKeyring = Data.openpgpKeyring, - oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : [] - ; - - _.each(oOpenpgpKeys, function (oItem, iIndex) { - if (oItem && oItem.primaryKey) - { - var - - oPrimaryUser = oItem.getPrimaryUser(), - sUser = (oPrimaryUser && oPrimaryUser.user) ? oPrimaryUser.user.userId.userid - : (oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '') - ; - - oEmail.clear(); - oEmail.mailsoParse(sUser); - - if (oEmail.validate()) - { - aKeys.push(new OpenPgpKeyModel( - iIndex, - oItem.primaryKey.getFingerprint(), - oItem.primaryKey.getKeyId().toHex().toLowerCase(), - sUser, - oEmail.email, - oItem.isPrivate(), - oItem.armor()) - ); - } + fResultFunc(sResult, oData); } }); - Data.openpgpkeys(aKeys); - } - }; + return true; + }; - RainLoopApp.prototype.accountsAndIdentities = function () - { - Data.accountsLoading(true); - Data.identitiesLoading(true); + RainLoopApp.prototype.messagesMoveTrigger = function () + { + var + self = this, + sSpamFolder = Data.spamFolder() + ; - Remote.accountsAndIdentities(function (sResult, oData) { + _.each(this.oMoveCache, function (oItem) { - Data.accountsLoading(false); - Data.identitiesLoading(false); - - if (Enums.StorageResultType.Success === sResult && oData.Result) - { var - sParentEmail = Settings.settingsGet('ParentEmail'), - sAccountEmail = Data.accountEmail() + bSpam = sSpamFolder === oItem['To'], + bHam = !bSpam && sSpamFolder === oItem['From'] && 'INBOX' === oItem['To'] ; - sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail; + Remote.messagesMove(self.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'], + bSpam ? 'SPAM' : (bHam ? 'HAM' : '')); + }); - if (Utils.isArray(oData.Result['Accounts'])) - { - Data.accounts(_.map(oData.Result['Accounts'], function (sValue) { - return new AccountModel(sValue, sValue !== sParentEmail); - })); - } + this.oMoveCache = {}; + }; - if (Utils.isArray(oData.Result['Identities'])) - { - Data.identities(_.map(oData.Result['Identities'], function (oIdentityData) { - - 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; - })); - } - } - }); - }; - - RainLoopApp.prototype.quota = function () - { - Remote.quota(function (sResult, oData) { - 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)) - { - Data.userQuota(Utils.pInt(oData.Result[1]) * 1024); - Data.userUsageSize(Utils.pInt(oData.Result[0]) * 1024); - } - }); - }; - - /** - * @param {string} sFolder - * @param {Array=} aList = [] - */ - RainLoopApp.prototype.folderInformation = function (sFolder, aList) - { - if ('' !== Utils.trim(sFolder)) + RainLoopApp.prototype.messagesMoveHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForMove) { - var self = this; - Remote.folderInformation(function (sResult, oData) { - if (Enums.StorageResultType.Success === sResult) + var sH = '$$' + sFromFolderFullNameRaw + '$$' + sToFolderFullNameRaw + '$$'; + if (!this.oMoveCache[sH]) + { + this.oMoveCache[sH] = { + 'From': sFromFolderFullNameRaw, + 'To': sToFolderFullNameRaw, + 'Uid': [] + }; + } + + this.oMoveCache[sH]['Uid'] = _.union(this.oMoveCache[sH]['Uid'], aUidForMove); + this.messagesMoveTrigger(); + }; + + RainLoopApp.prototype.messagesCopyHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForCopy) + { + Remote.messagesCopy( + this.moveOrDeleteResponseHelper, + sFromFolderFullNameRaw, + sToFolderFullNameRaw, + aUidForCopy + ); + }; + + RainLoopApp.prototype.messagesDeleteHelper = function (sFromFolderFullNameRaw, aUidForRemove) + { + Remote.messagesDelete( + this.moveOrDeleteResponseHelper, + sFromFolderFullNameRaw, + aUidForRemove + ); + }; + + RainLoopApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData) + { + if (Enums.StorageResultType.Success === sResult && Data.currentFolder()) + { + if (oData && Utils.isArray(oData.Result) && 2 === oData.Result.length) { - if (oData && oData.Result && oData.Result.Hash && oData.Result.Folder) + Cache.setFolderHash(oData.Result[0], oData.Result[1]); + } + else + { + Cache.setFolderHash(Data.currentFolderFullNameRaw(), ''); + + if (oData && -1 < Utils.inArray(oData.ErrorCode, + [Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage])) { - var - iUtc = moment().unix(), - sHash = Cache.getFolderHash(oData.Result.Folder), - oFolder = Cache.getFolderFromCacheList(oData.Result.Folder), - bCheck = false, - sUid = '', - aList = [], - bUnreadCountChange = false, - oFlags = null - ; - - if (oFolder) - { - oFolder.interval = iUtc; - - if (oData.Result.Hash) - { - Cache.setFolderHash(oData.Result.Folder, oData.Result.Hash); - } - - if (Utils.isNormal(oData.Result.MessageCount)) - { - oFolder.messageCountAll(oData.Result.MessageCount); - } - - if (Utils.isNormal(oData.Result.MessageUnseenCount)) - { - if (Utils.pInt(oFolder.messageCountUnread()) !== Utils.pInt(oData.Result.MessageUnseenCount)) - { - bUnreadCountChange = true; - } - - oFolder.messageCountUnread(oData.Result.MessageUnseenCount); - } - - if (bUnreadCountChange) - { - Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw); - } - - if (oData.Result.Flags) - { - for (sUid in oData.Result.Flags) - { - if (oData.Result.Flags.hasOwnProperty(sUid)) - { - bCheck = true; - oFlags = oData.Result.Flags[sUid]; - Cache.storeMessageFlagsToCacheByFolderAndUid(oFolder.fullNameRaw, sUid.toString(), [ - !oFlags['IsSeen'], !!oFlags['IsFlagged'], !!oFlags['IsAnswered'], !!oFlags['IsForwarded'], !!oFlags['IsReadReceipt'] - ]); - } - } - - if (bCheck) - { - self.reloadFlagsCurrentMessageListAndMessageFromCache(); - } - } - - Data.initUidNextAndNewMessages(oFolder.fullNameRaw, oData.Result.UidNext, oData.Result.NewMessages); - - if (oData.Result.Hash !== sHash || '' === sHash) - { - if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw()) - { - self.reloadMessageList(); - } - else if ('INBOX' === oFolder.fullNameRaw) - { - self.recacheInboxMessageList(); - } - } - else if (bUnreadCountChange) - { - if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw()) - { - aList = Data.messageList(); - if (Utils.isNonEmptyArray(aList)) - { - self.folderInformation(oFolder.fullNameRaw, aList); - } - } - } - } + window.alert(Utils.getNotification(oData.ErrorCode)); } } - }, sFolder, aList); - } - }; - /** - * @param {boolean=} bBoot = false - */ - RainLoopApp.prototype.folderInformationMultiply = function (bBoot) - { - bBoot = Utils.isUnd(bBoot) ? false : !!bBoot; + this.reloadMessageListHelper(0 === Data.messageList().length); + this.quotaDebounce(); + } + }; - var - self = this, - iUtc = moment().unix(), - aFolders = Data.getNextFolderNames(bBoot) - ; - - if (Utils.isNonEmptyArray(aFolders)) + /** + * @param {string} sFromFolderFullNameRaw + * @param {Array} aUidForRemove + */ + RainLoopApp.prototype.deleteMessagesFromFolderWithoutCheck = function (sFromFolderFullNameRaw, aUidForRemove) { - Remote.folderInformationMultiply(function (sResult, oData) { + this.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); + Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); + }; + + /** + * @param {number} iDeleteType + * @param {string} sFromFolderFullNameRaw + * @param {Array} aUidForRemove + * @param {boolean=} bUseFolder = true + */ + RainLoopApp.prototype.deleteMessagesFromFolder = function (iDeleteType, sFromFolderFullNameRaw, aUidForRemove, bUseFolder) + { + var + self = this, + oMoveFolder = null, + nSetSystemFoldersNotification = null + ; + + switch (iDeleteType) + { + case Enums.FolderType.Spam: + oMoveFolder = Cache.getFolderFromCacheList(Data.spamFolder()); + nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Spam; + break; + case Enums.FolderType.NotSpam: + oMoveFolder = Cache.getFolderFromCacheList('INBOX'); + break; + case Enums.FolderType.Trash: + oMoveFolder = Cache.getFolderFromCacheList(Data.trashFolder()); + nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Trash; + break; + case Enums.FolderType.Archive: + oMoveFolder = Cache.getFolderFromCacheList(Data.archiveFolder()); + nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Archive; + break; + } + + bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder; + if (bUseFolder) + { + if ((Enums.FolderType.Spam === iDeleteType && Consts.Values.UnuseOptionValue === Data.spamFolder()) || + (Enums.FolderType.Trash === iDeleteType && Consts.Values.UnuseOptionValue === Data.trashFolder()) || + (Enums.FolderType.Archive === iDeleteType && Consts.Values.UnuseOptionValue === Data.archiveFolder())) + { + bUseFolder = false; + } + } + + if (!oMoveFolder && bUseFolder) + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:FolderSystem */ 27), [nSetSystemFoldersNotification]); + } + else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType && + (sFromFolderFullNameRaw === Data.spamFolder() || sFromFolderFullNameRaw === Data.trashFolder()))) + { + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Ask */ 31), [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () { + + self.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); + Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); + + }]); + } + else if (oMoveFolder) + { + this.messagesMoveHelper(sFromFolderFullNameRaw, oMoveFolder.fullNameRaw, aUidForRemove); + Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, oMoveFolder.fullNameRaw); + } + }; + + /** + * @param {string} sFromFolderFullNameRaw + * @param {Array} aUidForMove + * @param {string} sToFolderFullNameRaw + * @param {boolean=} bCopy = false + */ + RainLoopApp.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForMove, sToFolderFullNameRaw, bCopy) + { + if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForMove) && 0 < aUidForMove.length) + { + var + oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw), + oToFolder = Cache.getFolderFromCacheList(sToFolderFullNameRaw) + ; + + if (oFromFolder && oToFolder) + { + if (Utils.isUnd(bCopy) ? false : !!bCopy) + { + this.messagesCopyHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove); + } + else + { + this.messagesMoveHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove); + } + + Data.removeMessagesFromList(oFromFolder.fullNameRaw, aUidForMove, oToFolder.fullNameRaw, bCopy); + return true; + } + } + + return false; + }; + + /** + * @param {Function=} fCallback + */ + RainLoopApp.prototype.folders = function (fCallback) + { + Data.foldersLoading(true); + Remote.folders(_.bind(function (sResult, oData) { + + Data.foldersLoading(false); if (Enums.StorageResultType.Success === sResult) { - if (oData && oData.Result && oData.Result.List && Utils.isNonEmptyArray(oData.Result.List)) + this.setFolders(oData); + if (fCallback) { - _.each(oData.Result.List, function (oItem) { + fCallback(true); + } + } + else + { + if (fCallback) + { + fCallback(false); + } + } + }, this)); + }; + + RainLoopApp.prototype.reloadOpenPgpKeys = function () + { + if (Data.capaOpenPGP()) + { + var + aKeys = [], + oEmail = new EmailModel(), + oOpenpgpKeyring = Data.openpgpKeyring, + oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : [] + ; + + _.each(oOpenpgpKeys, function (oItem, iIndex) { + if (oItem && oItem.primaryKey) + { + var + + oPrimaryUser = oItem.getPrimaryUser(), + sUser = (oPrimaryUser && oPrimaryUser.user) ? oPrimaryUser.user.userId.userid + : (oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '') + ; + + oEmail.clear(); + oEmail.mailsoParse(sUser); + + if (oEmail.validate()) + { + aKeys.push(new OpenPgpKeyModel( + iIndex, + oItem.primaryKey.getFingerprint(), + oItem.primaryKey.getKeyId().toHex().toLowerCase(), + sUser, + oEmail.email, + oItem.isPrivate(), + oItem.armor()) + ); + } + } + }); + + Data.openpgpkeys(aKeys); + } + }; + + RainLoopApp.prototype.accountsAndIdentities = function () + { + Data.accountsLoading(true); + Data.identitiesLoading(true); + + Remote.accountsAndIdentities(function (sResult, oData) { + + Data.accountsLoading(false); + Data.identitiesLoading(false); + + if (Enums.StorageResultType.Success === sResult && oData.Result) + { + var + sParentEmail = Settings.settingsGet('ParentEmail'), + sAccountEmail = Data.accountEmail() + ; + + sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail; + + if (Utils.isArray(oData.Result['Accounts'])) + { + Data.accounts(_.map(oData.Result['Accounts'], function (sValue) { + return new AccountModel(sValue, sValue !== sParentEmail); + })); + } + + if (Utils.isArray(oData.Result['Identities'])) + { + Data.identities(_.map(oData.Result['Identities'], function (oIdentityData) { 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; + })); + } + } + }); + }; + + RainLoopApp.prototype.quota = function () + { + Remote.quota(function (sResult, oData) { + 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)) + { + Data.userQuota(Utils.pInt(oData.Result[1]) * 1024); + Data.userUsageSize(Utils.pInt(oData.Result[0]) * 1024); + } + }); + }; + + /** + * @param {string} sFolder + * @param {Array=} aList = [] + */ + RainLoopApp.prototype.folderInformation = function (sFolder, aList) + { + if ('' !== Utils.trim(sFolder)) + { + var self = this; + Remote.folderInformation(function (sResult, oData) { + if (Enums.StorageResultType.Success === sResult) + { + if (oData && oData.Result && oData.Result.Hash && oData.Result.Folder) + { + var + iUtc = moment().unix(), + sHash = Cache.getFolderHash(oData.Result.Folder), + oFolder = Cache.getFolderFromCacheList(oData.Result.Folder), + bCheck = false, + sUid = '', aList = [], - sHash = Cache.getFolderHash(oItem.Folder), - oFolder = Cache.getFolderFromCacheList(oItem.Folder), - bUnreadCountChange = false + bUnreadCountChange = false, + oFlags = null ; if (oFolder) { oFolder.interval = iUtc; - if (oItem.Hash) + if (oData.Result.Hash) { - Cache.setFolderHash(oItem.Folder, oItem.Hash); + Cache.setFolderHash(oData.Result.Folder, oData.Result.Hash); } - if (Utils.isNormal(oItem.MessageCount)) + if (Utils.isNormal(oData.Result.MessageCount)) { - oFolder.messageCountAll(oItem.MessageCount); + oFolder.messageCountAll(oData.Result.MessageCount); } - if (Utils.isNormal(oItem.MessageUnseenCount)) + if (Utils.isNormal(oData.Result.MessageUnseenCount)) { - if (Utils.pInt(oFolder.messageCountUnread()) !== Utils.pInt(oItem.MessageUnseenCount)) + if (Utils.pInt(oFolder.messageCountUnread()) !== Utils.pInt(oData.Result.MessageUnseenCount)) { bUnreadCountChange = true; } - oFolder.messageCountUnread(oItem.MessageUnseenCount); + oFolder.messageCountUnread(oData.Result.MessageUnseenCount); } if (bUnreadCountChange) @@ -1043,12 +603,38 @@ Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw); } - if (oItem.Hash !== sHash || '' === sHash) + if (oData.Result.Flags) + { + for (sUid in oData.Result.Flags) + { + if (oData.Result.Flags.hasOwnProperty(sUid)) + { + bCheck = true; + oFlags = oData.Result.Flags[sUid]; + Cache.storeMessageFlagsToCacheByFolderAndUid(oFolder.fullNameRaw, sUid.toString(), [ + !oFlags['IsSeen'], !!oFlags['IsFlagged'], !!oFlags['IsAnswered'], !!oFlags['IsForwarded'], !!oFlags['IsReadReceipt'] + ]); + } + } + + if (bCheck) + { + self.reloadFlagsCurrentMessageListAndMessageFromCache(); + } + } + + Data.initUidNextAndNewMessages(oFolder.fullNameRaw, oData.Result.UidNext, oData.Result.NewMessages); + + if (oData.Result.Hash !== sHash || '' === sHash) { if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw()) { self.reloadMessageList(); } + else if ('INBOX' === oFolder.fullNameRaw) + { + self.recacheInboxMessageList(); + } } else if (bUnreadCountChange) { @@ -1062,9711 +648,4489 @@ } } } - }); - - if (bBoot) - { - self.folderInformationMultiply(true); } } - } - }, aFolders); - } - }; + }, sFolder, aList); + } + }; - RainLoopApp.prototype.setMessageSeen = function (oMessage) - { - if (oMessage.unseen()) + /** + * @param {boolean=} bBoot = false + */ + RainLoopApp.prototype.folderInformationMultiply = function (bBoot) { - oMessage.unseen(false); + bBoot = Utils.isUnd(bBoot) ? false : !!bBoot; - var oFolder = Cache.getFolderFromCacheList(oMessage.folderFullNameRaw); - if (oFolder) - { - oFolder.messageCountUnread(0 <= oFolder.messageCountUnread() - 1 ? - oFolder.messageCountUnread() - 1 : 0); - } - - Cache.storeMessageFlagsToCache(oMessage); - this.reloadFlagsCurrentMessageListAndMessageFromCache(); - } - - Remote.messageSetSeen(Utils.emptyFunction, oMessage.folderFullNameRaw, [oMessage.uid], true); - }; - - RainLoopApp.prototype.googleConnect = function () - { - window.open(LinkBuilder.socialGoogle(), 'Google', 'left=200,top=100,width=650,height=600,menubar=no,status=no,resizable=yes,scrollbars=yes'); - }; - - RainLoopApp.prototype.twitterConnect = function () - { - window.open(LinkBuilder.socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=350,menubar=no,status=no,resizable=yes,scrollbars=yes'); - }; - - RainLoopApp.prototype.facebookConnect = function () - { - window.open(LinkBuilder.socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); - }; - - /** - * @param {boolean=} bFireAllActions - */ - RainLoopApp.prototype.socialUsers = function (bFireAllActions) - { - if (bFireAllActions) - { - Data.googleActions(true); - Data.facebookActions(true); - Data.twitterActions(true); - } - - Remote.socialUsers(function (sResult, oData) { - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - Data.googleUserName(oData.Result['Google'] || ''); - Data.facebookUserName(oData.Result['Facebook'] || ''); - Data.twitterUserName(oData.Result['Twitter'] || ''); - } - else - { - Data.googleUserName(''); - Data.facebookUserName(''); - Data.twitterUserName(''); - } - - Data.googleLoggined('' !== Data.googleUserName()); - Data.facebookLoggined('' !== Data.facebookUserName()); - Data.twitterLoggined('' !== Data.twitterUserName()); - - Data.googleActions(false); - Data.facebookActions(false); - Data.twitterActions(false); - }); - }; - - RainLoopApp.prototype.googleDisconnect = function () - { - Data.googleActions(true); - Remote.googleDisconnect(this.socialUsers); - }; - - RainLoopApp.prototype.facebookDisconnect = function () - { - Data.facebookActions(true); - Remote.facebookDisconnect(this.socialUsers); - }; - - RainLoopApp.prototype.twitterDisconnect = function () - { - Data.twitterActions(true); - Remote.twitterDisconnect(this.socialUsers); - }; - - /** - * @param {string} sQuery - * @param {Function} fCallback - */ - RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback) - { - var - aData = [] - ; - - Remote.suggestions(function (sResult, oData) { - if (Enums.StorageResultType.Success === sResult && oData && Utils.isArray(oData.Result)) - { - aData = _.map(oData.Result, function (aItem) { - return aItem && aItem[0] ? new EmailModel(aItem[0], aItem[1]) : null; - }); - - fCallback(_.compact(aData)); - } - else if (Enums.StorageResultType.Abort !== sResult) - { - fCallback([]); - } - - }, sQuery); - }; - - /** - * @param {string} sQuery - * @param {Function} fCallback - */ - RainLoopApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback) - { - fCallback(_.filter(Data.contactTags(), function (oContactTag) { - return oContactTag && oContactTag.filterHelper(sQuery); - })); - }; - - RainLoopApp.prototype.setMessageList = function (oData, bCached) - { - if (oData && oData.Result && 'Collection/MessageCollection' === oData.Result['@Object'] && - oData.Result['@Collection'] && Utils.isArray(oData.Result['@Collection'])) - { var - mLastCollapsedThreadUids = null, - iIndex = 0, - iLen = 0, - iCount = 0, - iOffset = 0, - aList = [], + self = this, iUtc = moment().unix(), - aStaticList = Data.staticMessageList, - oJsonMessage = null, - oMessage = null, - oFolder = null, - iNewCount = 0, - bUnreadCountChange = false + aFolders = Data.getNextFolderNames(bBoot) ; - iCount = Utils.pInt(oData.Result.MessageResultCount); - iOffset = Utils.pInt(oData.Result.Offset); - - if (Utils.isNonEmptyArray(oData.Result.LastCollapsedThreadUids)) + if (Utils.isNonEmptyArray(aFolders)) { - mLastCollapsedThreadUids = oData.Result.LastCollapsedThreadUids; - } - - oFolder = Cache.getFolderFromCacheList( - Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : ''); - - if (oFolder && !bCached) - { - oFolder.interval = iUtc; - - Cache.setFolderHash(oData.Result.Folder, oData.Result.FolderHash); - - if (Utils.isNormal(oData.Result.MessageCount)) - { - oFolder.messageCountAll(oData.Result.MessageCount); - } - - if (Utils.isNormal(oData.Result.MessageUnseenCount)) - { - if (Utils.pInt(oFolder.messageCountUnread()) !== Utils.pInt(oData.Result.MessageUnseenCount)) + Remote.folderInformationMultiply(function (sResult, oData) { + if (Enums.StorageResultType.Success === sResult) { - bUnreadCountChange = true; - } - - oFolder.messageCountUnread(oData.Result.MessageUnseenCount); - } - - Data.initUidNextAndNewMessages(oFolder.fullNameRaw, oData.Result.UidNext, oData.Result.NewMessages); - } - - if (bUnreadCountChange && oFolder) - { - Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw); - } - - for (iIndex = 0, iLen = oData.Result['@Collection'].length; iIndex < iLen; iIndex++) - { - oJsonMessage = oData.Result['@Collection'][iIndex]; - if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) - { - oMessage = aStaticList[iIndex]; - if (!oMessage || !oMessage.initByJson(oJsonMessage)) - { - oMessage = MessageModel.newInstanceFromJson(oJsonMessage); - } - - if (oMessage) - { - if (Cache.hasNewMessageAndRemoveFromCache(oMessage.folderFullNameRaw, oMessage.uid) && 5 >= iNewCount) + if (oData && oData.Result && oData.Result.List && Utils.isNonEmptyArray(oData.Result.List)) { - iNewCount++; - oMessage.newForAnimation(true); - } + _.each(oData.Result.List, function (oItem) { - oMessage.deleted(false); + var + aList = [], + sHash = Cache.getFolderHash(oItem.Folder), + oFolder = Cache.getFolderFromCacheList(oItem.Folder), + bUnreadCountChange = false + ; - if (bCached) - { - Cache.initMessageFlagsFromCache(oMessage); - } - else - { - Cache.storeMessageFlagsToCache(oMessage); - } + if (oFolder) + { + oFolder.interval = iUtc; - oMessage.lastInCollapsedThread(mLastCollapsedThreadUids && -1 < Utils.inArray(Utils.pInt(oMessage.uid), mLastCollapsedThreadUids) ? true : false); + if (oItem.Hash) + { + Cache.setFolderHash(oItem.Folder, oItem.Hash); + } - aList.push(oMessage); - } - } - } + if (Utils.isNormal(oItem.MessageCount)) + { + oFolder.messageCountAll(oItem.MessageCount); + } - Data.messageListCount(iCount); - Data.messageListSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : ''); - Data.messageListPage(window.Math.ceil((iOffset / Data.messagesPerPage()) + 1)); - Data.messageListEndFolder(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : ''); - Data.messageListEndSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : ''); - Data.messageListEndPage(Data.messageListPage()); + if (Utils.isNormal(oItem.MessageUnseenCount)) + { + if (Utils.pInt(oFolder.messageCountUnread()) !== Utils.pInt(oItem.MessageUnseenCount)) + { + bUnreadCountChange = true; + } - Data.messageList(aList); - Data.messageListIsNotCompleted(false); + oFolder.messageCountUnread(oItem.MessageUnseenCount); + } - if (aStaticList.length < aList.length) - { - Data.staticMessageList = aList; - } + if (bUnreadCountChange) + { + Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw); + } - Cache.clearNewMessageCache(); + if (oItem.Hash !== sHash || '' === sHash) + { + if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw()) + { + self.reloadMessageList(); + } + } + else if (bUnreadCountChange) + { + if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw()) + { + aList = Data.messageList(); + if (Utils.isNonEmptyArray(aList)) + { + self.folderInformation(oFolder.fullNameRaw, aList); + } + } + } + } + }); - if (oFolder && (bCached || bUnreadCountChange || Data.useThreads())) - { - this.folderInformation(oFolder.fullNameRaw, aList); - } - } - else - { - Data.messageListCount(0); - Data.messageList([]); - Data.messageListError(Utils.getNotification( - oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantGetMessageList - )); - } - }; - - /** - * @param {string} sNamespace - * @param {Array} aFolders - * @return {Array} - */ - RainLoopApp.prototype.folderResponseParseRec = function (sNamespace, aFolders) - { - var - self = this, - iIndex = 0, - iLen = 0, - oFolder = null, - oCacheFolder = null, - sFolderFullNameRaw = '', - aSubFolders = [], - aList = [] - ; - - for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++) - { - oFolder = aFolders[iIndex]; - if (oFolder) - { - sFolderFullNameRaw = oFolder.FullNameRaw; - - oCacheFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); - if (!oCacheFolder) - { - oCacheFolder = FolderModel.newInstanceFromJson(oFolder); - if (oCacheFolder) - { - Cache.setFolderToCacheList(sFolderFullNameRaw, oCacheFolder); - Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw); - } - } - - if (oCacheFolder) - { - oCacheFolder.collapsed(!self.isFolderExpanded(oCacheFolder.fullNameHash)); - - if (oFolder.Extended) - { - if (oFolder.Extended.Hash) - { - Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash); - } - - if (Utils.isNormal(oFolder.Extended.MessageCount)) - { - oCacheFolder.messageCountAll(oFolder.Extended.MessageCount); - } - - if (Utils.isNormal(oFolder.Extended.MessageUnseenCount)) - { - oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount); + if (bBoot) + { + self.folderInformationMultiply(true); + } } } - - aSubFolders = oFolder['SubFolders']; - if (aSubFolders && 'Collection/FolderCollection' === aSubFolders['@Object'] && - aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection'])) - { - oCacheFolder.subFolders( - this.folderResponseParseRec(sNamespace, aSubFolders['@Collection'])); - } - - aList.push(oCacheFolder); - } + }, aFolders); } - } + }; - return aList; - }; - - /** - * @param {*} oData - */ - RainLoopApp.prototype.setFolders = function (oData) - { - var - aList = [], - bUpdate = false, - fNormalizeFolder = function (sFolderFullNameRaw) { - return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw || - null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : ''; - } - ; - - if (oData && oData.Result && 'Collection/FolderCollection' === oData.Result['@Object'] && - oData.Result['@Collection'] && Utils.isArray(oData.Result['@Collection'])) + RainLoopApp.prototype.setMessageSeen = function (oMessage) { - if (!Utils.isUnd(oData.Result.Namespace)) + if (oMessage.unseen()) { - Data.namespace = oData.Result.Namespace; - } + oMessage.unseen(false); - Data.threading(!!Settings.settingsGet('UseImapThread') && oData.Result.IsThreadsSupported && true); - - aList = this.folderResponseParseRec(Data.namespace, oData.Result['@Collection']); - Data.folderList(aList); - - if (oData.Result['SystemFolders'] && - '' === '' + Settings.settingsGet('SentFolder') + Settings.settingsGet('DraftFolder') + - Settings.settingsGet('SpamFolder') + Settings.settingsGet('TrashFolder') + Settings.settingsGet('ArchiveFolder') + - Settings.settingsGet('NullFolder')) - { - // TODO Magic Numbers - Settings.settingsSet('SentFolder', oData.Result['SystemFolders'][2] || null); - Settings.settingsSet('DraftFolder', oData.Result['SystemFolders'][3] || null); - Settings.settingsSet('SpamFolder', oData.Result['SystemFolders'][4] || null); - Settings.settingsSet('TrashFolder', oData.Result['SystemFolders'][5] || null); - Settings.settingsSet('ArchiveFolder', oData.Result['SystemFolders'][12] || null); - - bUpdate = true; - } - - Data.sentFolder(fNormalizeFolder(Settings.settingsGet('SentFolder'))); - Data.draftFolder(fNormalizeFolder(Settings.settingsGet('DraftFolder'))); - Data.spamFolder(fNormalizeFolder(Settings.settingsGet('SpamFolder'))); - Data.trashFolder(fNormalizeFolder(Settings.settingsGet('TrashFolder'))); - Data.archiveFolder(fNormalizeFolder(Settings.settingsGet('ArchiveFolder'))); - - if (bUpdate) - { - Remote.saveSystemFolders(Utils.emptyFunction, { - 'SentFolder': Data.sentFolder(), - 'DraftFolder': Data.draftFolder(), - 'SpamFolder': Data.spamFolder(), - 'TrashFolder': Data.trashFolder(), - 'ArchiveFolder': Data.archiveFolder(), - 'NullFolder': 'NullFolder' - }); - } - - Local.set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash); - } - }; - - /** - * @param {string} sFullNameHash - * @return {boolean} - */ - RainLoopApp.prototype.isFolderExpanded = function (sFullNameHash) - { - var aExpandedList = Local.get(Enums.ClientSideKeyName.ExpandedFolders); - return Utils.isArray(aExpandedList) && -1 !== _.indexOf(aExpandedList, sFullNameHash); - }; - - /** - * @param {string} sFullNameHash - * @param {boolean} bExpanded - */ - RainLoopApp.prototype.setExpandedFolder = function (sFullNameHash, bExpanded) - { - var aExpandedList = Local.get(Enums.ClientSideKeyName.ExpandedFolders); - if (!Utils.isArray(aExpandedList)) - { - aExpandedList = []; - } - - if (bExpanded) - { - aExpandedList.push(sFullNameHash); - aExpandedList = _.uniq(aExpandedList); - } - else - { - aExpandedList = _.without(aExpandedList, sFullNameHash); - } - - Local.set(Enums.ClientSideKeyName.ExpandedFolders, aExpandedList); - }; - - RainLoopApp.prototype.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName) - { - var - iDisabledWidth = 60, - iMinWidth = 155, - oLeft = $(sLeft), - oRight = $(sRight), - - mLeftWidth = Local.get(sClientSideKeyName) || null, - - fSetWidth = function (iWidth) { - if (iWidth) + var oFolder = Cache.getFolderFromCacheList(oMessage.folderFullNameRaw); + if (oFolder) { - oLeft.css({ - 'width': '' + iWidth + 'px' - }); - - oRight.css({ - 'left': '' + iWidth + 'px' - }); + oFolder.messageCountUnread(0 <= oFolder.messageCountUnread() - 1 ? + oFolder.messageCountUnread() - 1 : 0); } - }, - fDisable = function (bDisable) { - if (bDisable) + Cache.storeMessageFlagsToCache(oMessage); + this.reloadFlagsCurrentMessageListAndMessageFromCache(); + } + + Remote.messageSetSeen(Utils.emptyFunction, oMessage.folderFullNameRaw, [oMessage.uid], true); + }; + + RainLoopApp.prototype.googleConnect = function () + { + window.open(LinkBuilder.socialGoogle(), 'Google', 'left=200,top=100,width=650,height=600,menubar=no,status=no,resizable=yes,scrollbars=yes'); + }; + + RainLoopApp.prototype.twitterConnect = function () + { + window.open(LinkBuilder.socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=350,menubar=no,status=no,resizable=yes,scrollbars=yes'); + }; + + RainLoopApp.prototype.facebookConnect = function () + { + window.open(LinkBuilder.socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); + }; + + /** + * @param {boolean=} bFireAllActions + */ + RainLoopApp.prototype.socialUsers = function (bFireAllActions) + { + if (bFireAllActions) + { + Data.googleActions(true); + Data.facebookActions(true); + Data.twitterActions(true); + } + + Remote.socialUsers(function (sResult, oData) { + + if (Enums.StorageResultType.Success === sResult && oData && oData.Result) { - oLeft.resizable('disable'); - fSetWidth(iDisabledWidth); + Data.googleUserName(oData.Result['Google'] || ''); + Data.facebookUserName(oData.Result['Facebook'] || ''); + Data.twitterUserName(oData.Result['Twitter'] || ''); } else { - oLeft.resizable('enable'); - var iWidth = Utils.pInt(Local.get(sClientSideKeyName)) || iMinWidth; - fSetWidth(iWidth > iMinWidth ? iWidth : iMinWidth); + Data.googleUserName(''); + Data.facebookUserName(''); + Data.twitterUserName(''); } - }, - fResizeFunction = function (oEvent, oObject) { - if (oObject && oObject.size && oObject.size.width) + Data.googleLoggined('' !== Data.googleUserName()); + Data.facebookLoggined('' !== Data.facebookUserName()); + Data.twitterLoggined('' !== Data.twitterUserName()); + + Data.googleActions(false); + Data.facebookActions(false); + Data.twitterActions(false); + }); + }; + + RainLoopApp.prototype.googleDisconnect = function () + { + Data.googleActions(true); + Remote.googleDisconnect(this.socialUsers); + }; + + RainLoopApp.prototype.facebookDisconnect = function () + { + Data.facebookActions(true); + Remote.facebookDisconnect(this.socialUsers); + }; + + RainLoopApp.prototype.twitterDisconnect = function () + { + Data.twitterActions(true); + Remote.twitterDisconnect(this.socialUsers); + }; + + /** + * @param {string} sQuery + * @param {Function} fCallback + */ + RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback) + { + var + aData = [] + ; + + Remote.suggestions(function (sResult, oData) { + if (Enums.StorageResultType.Success === sResult && oData && Utils.isArray(oData.Result)) { - Local.set(sClientSideKeyName, oObject.size.width); - - oRight.css({ - 'left': '' + oObject.size.width + 'px' + aData = _.map(oData.Result, function (aItem) { + return aItem && aItem[0] ? new EmailModel(aItem[0], aItem[1]) : null; }); + + fCallback(_.compact(aData)); + } + else if (Enums.StorageResultType.Abort !== sResult) + { + fCallback([]); + } + + }, sQuery); + }; + + /** + * @param {string} sQuery + * @param {Function} fCallback + */ + RainLoopApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback) + { + fCallback(_.filter(Data.contactTags(), function (oContactTag) { + return oContactTag && oContactTag.filterHelper(sQuery); + })); + }; + + RainLoopApp.prototype.setMessageList = function (oData, bCached) + { + if (oData && oData.Result && 'Collection/MessageCollection' === oData.Result['@Object'] && + oData.Result['@Collection'] && Utils.isArray(oData.Result['@Collection'])) + { + var + mLastCollapsedThreadUids = null, + iIndex = 0, + iLen = 0, + iCount = 0, + iOffset = 0, + aList = [], + iUtc = moment().unix(), + aStaticList = Data.staticMessageList, + oJsonMessage = null, + oMessage = null, + oFolder = null, + iNewCount = 0, + bUnreadCountChange = false + ; + + iCount = Utils.pInt(oData.Result.MessageResultCount); + iOffset = Utils.pInt(oData.Result.Offset); + + if (Utils.isNonEmptyArray(oData.Result.LastCollapsedThreadUids)) + { + mLastCollapsedThreadUids = oData.Result.LastCollapsedThreadUids; + } + + oFolder = Cache.getFolderFromCacheList( + Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : ''); + + if (oFolder && !bCached) + { + oFolder.interval = iUtc; + + Cache.setFolderHash(oData.Result.Folder, oData.Result.FolderHash); + + if (Utils.isNormal(oData.Result.MessageCount)) + { + oFolder.messageCountAll(oData.Result.MessageCount); + } + + if (Utils.isNormal(oData.Result.MessageUnseenCount)) + { + if (Utils.pInt(oFolder.messageCountUnread()) !== Utils.pInt(oData.Result.MessageUnseenCount)) + { + bUnreadCountChange = true; + } + + oFolder.messageCountUnread(oData.Result.MessageUnseenCount); + } + + Data.initUidNextAndNewMessages(oFolder.fullNameRaw, oData.Result.UidNext, oData.Result.NewMessages); + } + + if (bUnreadCountChange && oFolder) + { + Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw); + } + + for (iIndex = 0, iLen = oData.Result['@Collection'].length; iIndex < iLen; iIndex++) + { + oJsonMessage = oData.Result['@Collection'][iIndex]; + if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) + { + oMessage = aStaticList[iIndex]; + if (!oMessage || !oMessage.initByJson(oJsonMessage)) + { + oMessage = MessageModel.newInstanceFromJson(oJsonMessage); + } + + if (oMessage) + { + if (Cache.hasNewMessageAndRemoveFromCache(oMessage.folderFullNameRaw, oMessage.uid) && 5 >= iNewCount) + { + iNewCount++; + oMessage.newForAnimation(true); + } + + oMessage.deleted(false); + + if (bCached) + { + Cache.initMessageFlagsFromCache(oMessage); + } + else + { + Cache.storeMessageFlagsToCache(oMessage); + } + + oMessage.lastInCollapsedThread(mLastCollapsedThreadUids && -1 < Utils.inArray(Utils.pInt(oMessage.uid), mLastCollapsedThreadUids) ? true : false); + + aList.push(oMessage); + } + } + } + + Data.messageListCount(iCount); + Data.messageListSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : ''); + Data.messageListPage(window.Math.ceil((iOffset / Data.messagesPerPage()) + 1)); + Data.messageListEndFolder(Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : ''); + Data.messageListEndSearch(Utils.isNormal(oData.Result.Search) ? oData.Result.Search : ''); + Data.messageListEndPage(Data.messageListPage()); + + Data.messageList(aList); + Data.messageListIsNotCompleted(false); + + if (aStaticList.length < aList.length) + { + Data.staticMessageList = aList; + } + + Cache.clearNewMessageCache(); + + if (oFolder && (bCached || bUnreadCountChange || Data.useThreads())) + { + this.folderInformation(oFolder.fullNameRaw, aList); } } - ; + else + { + Data.messageListCount(0); + Data.messageList([]); + Data.messageListError(Utils.getNotification( + oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantGetMessageList + )); + } + }; - if (null !== mLeftWidth) + /** + * @param {string} sNamespace + * @param {Array} aFolders + * @return {Array} + */ + RainLoopApp.prototype.folderResponseParseRec = function (sNamespace, aFolders) { - fSetWidth(mLeftWidth > iMinWidth ? mLeftWidth : iMinWidth); - } + var + self = this, + iIndex = 0, + iLen = 0, + oFolder = null, + oCacheFolder = null, + sFolderFullNameRaw = '', + aSubFolders = [], + aList = [] + ; - oLeft.resizable({ - 'helper': 'ui-resizable-helper', - 'minWidth': iMinWidth, - 'maxWidth': 350, - 'handles': 'e', - 'stop': fResizeFunction - }); + for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++) + { + oFolder = aFolders[iIndex]; + if (oFolder) + { + sFolderFullNameRaw = oFolder.FullNameRaw; - Events.sub('left-panel.off', function () { - fDisable(true); - }); + oCacheFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); + if (!oCacheFolder) + { + oCacheFolder = FolderModel.newInstanceFromJson(oFolder); + if (oCacheFolder) + { + Cache.setFolderToCacheList(sFolderFullNameRaw, oCacheFolder); + Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw); + } + } - Events.sub('left-panel.on', function () { - fDisable(false); - }); - }; + if (oCacheFolder) + { + oCacheFolder.collapsed(!self.isFolderExpanded(oCacheFolder.fullNameHash)); - RainLoopApp.prototype.bootstartLoginScreen = function () - { - var sCustomLoginLink = Utils.pString(Settings.settingsGet('CustomLoginLink')); - if (!sCustomLoginLink) - { - kn.hideLoading(); + if (oFolder.Extended) + { + if (oFolder.Extended.Hash) + { + Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash); + } - kn.startScreens([ - require('Screen:RainLoop:Login') - ]); + if (Utils.isNormal(oFolder.Extended.MessageCount)) + { + oCacheFolder.messageCountAll(oFolder.Extended.MessageCount); + } - Plugins.runHook('rl-start-login-screens'); - Events.pub('rl.bootstart-login-screens'); - } - else - { - kn.routeOff(); - kn.setHash(LinkBuilder.root(), true); - kn.routeOff(); + if (Utils.isNormal(oFolder.Extended.MessageUnseenCount)) + { + oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount); + } + } - _.defer(function () { - window.location.href = sCustomLoginLink; - }); - } - }; + aSubFolders = oFolder['SubFolders']; + if (aSubFolders && 'Collection/FolderCollection' === aSubFolders['@Object'] && + aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection'])) + { + oCacheFolder.subFolders( + this.folderResponseParseRec(sNamespace, aSubFolders['@Collection'])); + } - RainLoopApp.prototype.bootstart = function () - { - AbstractApp.prototype.bootstart.call(this); - - Data.populateDataOnStart(); - - var - self = this, - sJsHash = Settings.settingsGet('JsHash'), - iContactsSyncInterval = Utils.pInt(Settings.settingsGet('ContactsSyncInterval')), - bGoogle = Settings.settingsGet('AllowGoogleSocial'), - bFacebook = Settings.settingsGet('AllowFacebookSocial'), - bTwitter = Settings.settingsGet('AllowTwitterSocial') - ; - - Utils.initOnStartOrLangChange(function () { - - $.extend(true, $.magnificPopup.defaults, { - 'tClose': Utils.i18n('MAGNIFIC_POPUP/CLOSE'), - 'tLoading': Utils.i18n('MAGNIFIC_POPUP/LOADING'), - 'gallery': { - 'tPrev': Utils.i18n('MAGNIFIC_POPUP/GALLERY_PREV'), - 'tNext': Utils.i18n('MAGNIFIC_POPUP/GALLERY_NEXT'), - 'tCounter': Utils.i18n('MAGNIFIC_POPUP/GALLERY_COUNTER') - }, - 'image': { - 'tError': Utils.i18n('MAGNIFIC_POPUP/IMAGE_ERROR') - }, - 'ajax': { - 'tError': Utils.i18n('MAGNIFIC_POPUP/AJAX_ERROR') + aList.push(oCacheFolder); + } } + } + + return aList; + }; + + /** + * @param {*} oData + */ + RainLoopApp.prototype.setFolders = function (oData) + { + var + aList = [], + bUpdate = false, + fNormalizeFolder = function (sFolderFullNameRaw) { + return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw || + null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : ''; + } + ; + + if (oData && oData.Result && 'Collection/FolderCollection' === oData.Result['@Object'] && + oData.Result['@Collection'] && Utils.isArray(oData.Result['@Collection'])) + { + if (!Utils.isUnd(oData.Result.Namespace)) + { + Data.namespace = oData.Result.Namespace; + } + + Data.threading(!!Settings.settingsGet('UseImapThread') && oData.Result.IsThreadsSupported && true); + + aList = this.folderResponseParseRec(Data.namespace, oData.Result['@Collection']); + Data.folderList(aList); + + if (oData.Result['SystemFolders'] && + '' === '' + Settings.settingsGet('SentFolder') + Settings.settingsGet('DraftFolder') + + Settings.settingsGet('SpamFolder') + Settings.settingsGet('TrashFolder') + Settings.settingsGet('ArchiveFolder') + + Settings.settingsGet('NullFolder')) + { + // TODO Magic Numbers + Settings.settingsSet('SentFolder', oData.Result['SystemFolders'][2] || null); + Settings.settingsSet('DraftFolder', oData.Result['SystemFolders'][3] || null); + Settings.settingsSet('SpamFolder', oData.Result['SystemFolders'][4] || null); + Settings.settingsSet('TrashFolder', oData.Result['SystemFolders'][5] || null); + Settings.settingsSet('ArchiveFolder', oData.Result['SystemFolders'][12] || null); + + bUpdate = true; + } + + Data.sentFolder(fNormalizeFolder(Settings.settingsGet('SentFolder'))); + Data.draftFolder(fNormalizeFolder(Settings.settingsGet('DraftFolder'))); + Data.spamFolder(fNormalizeFolder(Settings.settingsGet('SpamFolder'))); + Data.trashFolder(fNormalizeFolder(Settings.settingsGet('TrashFolder'))); + Data.archiveFolder(fNormalizeFolder(Settings.settingsGet('ArchiveFolder'))); + + if (bUpdate) + { + Remote.saveSystemFolders(Utils.emptyFunction, { + 'SentFolder': Data.sentFolder(), + 'DraftFolder': Data.draftFolder(), + 'SpamFolder': Data.spamFolder(), + 'TrashFolder': Data.trashFolder(), + 'ArchiveFolder': Data.archiveFolder(), + 'NullFolder': 'NullFolder' + }); + } + + Local.set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash); + } + }; + + /** + * @param {string} sFullNameHash + * @return {boolean} + */ + RainLoopApp.prototype.isFolderExpanded = function (sFullNameHash) + { + var aExpandedList = Local.get(Enums.ClientSideKeyName.ExpandedFolders); + return Utils.isArray(aExpandedList) && -1 !== _.indexOf(aExpandedList, sFullNameHash); + }; + + /** + * @param {string} sFullNameHash + * @param {boolean} bExpanded + */ + RainLoopApp.prototype.setExpandedFolder = function (sFullNameHash, bExpanded) + { + var aExpandedList = Local.get(Enums.ClientSideKeyName.ExpandedFolders); + if (!Utils.isArray(aExpandedList)) + { + aExpandedList = []; + } + + if (bExpanded) + { + aExpandedList.push(sFullNameHash); + aExpandedList = _.uniq(aExpandedList); + } + else + { + aExpandedList = _.without(aExpandedList, sFullNameHash); + } + + Local.set(Enums.ClientSideKeyName.ExpandedFolders, aExpandedList); + }; + + RainLoopApp.prototype.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName) + { + var + iDisabledWidth = 60, + iMinWidth = 155, + oLeft = $(sLeft), + oRight = $(sRight), + + mLeftWidth = Local.get(sClientSideKeyName) || null, + + fSetWidth = function (iWidth) { + if (iWidth) + { + oLeft.css({ + 'width': '' + iWidth + 'px' + }); + + oRight.css({ + 'left': '' + iWidth + 'px' + }); + } + }, + + fDisable = function (bDisable) { + if (bDisable) + { + oLeft.resizable('disable'); + fSetWidth(iDisabledWidth); + } + else + { + oLeft.resizable('enable'); + var iWidth = Utils.pInt(Local.get(sClientSideKeyName)) || iMinWidth; + fSetWidth(iWidth > iMinWidth ? iWidth : iMinWidth); + } + }, + + fResizeFunction = function (oEvent, oObject) { + if (oObject && oObject.size && oObject.size.width) + { + Local.set(sClientSideKeyName, oObject.size.width); + + oRight.css({ + 'left': '' + oObject.size.width + 'px' + }); + } + } + ; + + if (null !== mLeftWidth) + { + fSetWidth(mLeftWidth > iMinWidth ? mLeftWidth : iMinWidth); + } + + oLeft.resizable({ + 'helper': 'ui-resizable-helper', + 'minWidth': iMinWidth, + 'maxWidth': 350, + 'handles': 'e', + 'stop': fResizeFunction }); - }, this); + Events.sub('left-panel.off', function () { + fDisable(true); + }); - if (window.SimplePace) + Events.sub('left-panel.on', function () { + fDisable(false); + }); + }; + + RainLoopApp.prototype.bootstartLoginScreen = function () { - window.SimplePace.set(70); - window.SimplePace.sleep(); - } - - Globals.leftPanelDisabled.subscribe(function (bValue) { - Events.pub('left-panel.' + (bValue ? 'off' : 'on')); - }); - - if (!!Settings.settingsGet('Auth')) - { - this.setTitle(Utils.i18n('TITLES/LOADING')); - - this.folders(_.bind(function (bValue) { - + var sCustomLoginLink = Utils.pString(Settings.settingsGet('CustomLoginLink')); + if (!sCustomLoginLink) + { kn.hideLoading(); - if (bValue) - { - if (window.$LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP)) + kn.startScreens([ + __webpack_require__(/*! Screen:RainLoop:Login */ 64) + ]); + + Plugins.runHook('rl-start-login-screens'); + Events.pub('rl.bootstart-login-screens'); + } + else + { + kn.routeOff(); + kn.setHash(LinkBuilder.root(), true); + kn.routeOff(); + + _.defer(function () { + window.location.href = sCustomLoginLink; + }); + } + }; + + RainLoopApp.prototype.bootstart = function () + { + AbstractApp.prototype.bootstart.call(this); + + Data.populateDataOnStart(); + + var + self = this, + sJsHash = Settings.settingsGet('JsHash'), + iContactsSyncInterval = Utils.pInt(Settings.settingsGet('ContactsSyncInterval')), + bGoogle = Settings.settingsGet('AllowGoogleSocial'), + bFacebook = Settings.settingsGet('AllowFacebookSocial'), + bTwitter = Settings.settingsGet('AllowTwitterSocial') + ; + + Utils.initOnStartOrLangChange(function () { + + $.extend(true, $.magnificPopup.defaults, { + 'tClose': Utils.i18n('MAGNIFIC_POPUP/CLOSE'), + 'tLoading': Utils.i18n('MAGNIFIC_POPUP/LOADING'), + 'gallery': { + 'tPrev': Utils.i18n('MAGNIFIC_POPUP/GALLERY_PREV'), + 'tNext': Utils.i18n('MAGNIFIC_POPUP/GALLERY_NEXT'), + 'tCounter': Utils.i18n('MAGNIFIC_POPUP/GALLERY_COUNTER') + }, + 'image': { + 'tError': Utils.i18n('MAGNIFIC_POPUP/IMAGE_ERROR') + }, + 'ajax': { + 'tError': Utils.i18n('MAGNIFIC_POPUP/AJAX_ERROR') + } + }); + + }, this); + + if (window.SimplePace) + { + window.SimplePace.set(70); + window.SimplePace.sleep(); + } + + Globals.leftPanelDisabled.subscribe(function (bValue) { + Events.pub('left-panel.' + (bValue ? 'off' : 'on')); + }); + + if (!!Settings.settingsGet('Auth')) + { + this.setTitle(Utils.i18n('TITLES/LOADING')); + + this.folders(_.bind(function (bValue) { + + if (bValue) { - window.$LAB.script(window.openpgp ? '' : LinkBuilder.openPgpJs()).wait(function () { - if (window.openpgp) + __webpack_require__.e/*nsure*/(0, function () { + + kn.hideLoading(); + + if (window.$LAB && window.crypto && window.crypto.getRandomValues && Settings.capa(Enums.Capa.OpenPGP)) { - Data.openpgpKeyring = new window.openpgp.Keyring(); - Data.capaOpenPGP(true); + window.$LAB.script(window.openpgp ? '' : LinkBuilder.openPgpJs()).wait(function () { + if (window.openpgp) + { + Data.openpgpKeyring = new window.openpgp.Keyring(); + Data.capaOpenPGP(true); - Events.pub('openpgp.init'); + Events.pub('openpgp.init'); - self.reloadOpenPgpKeys(); + self.reloadOpenPgpKeys(); + } + }); + } + else + { + Data.capaOpenPGP(false); + } + + kn.startScreens([ + __webpack_require__(/*! Screen:RainLoop:MailBox */ 65), + __webpack_require__(/*! Screen:RainLoop:Settings */ 66), + __webpack_require__(/*! Screen:RainLoop:About */ 61) + ]); + + if (bGoogle || bFacebook || bTwitter) + { + self.socialUsers(true); + } + + Events.sub('interval.2m', function () { + self.folderInformation('INBOX'); + }); + + Events.sub('interval.2m', function () { + var sF = Data.currentFolderFullNameRaw(); + if ('INBOX' !== sF) + { + self.folderInformation(sF); + } + }); + + Events.sub('interval.3m', function () { + self.folderInformationMultiply(); + }); + + Events.sub('interval.5m', function () { + self.quota(); + }); + + Events.sub('interval.10m', function () { + self.folders(); + }); + + iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20; + iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320; + + window.setInterval(function () { + self.contactsSync(); + }, iContactsSyncInterval * 60000 + 5000); + + _.delay(function () { + self.contactsSync(); + }, 5000); + + _.delay(function () { + self.folderInformationMultiply(true); + }, 500); + + Plugins.runHook('rl-start-user-screens'); + Events.pub('rl.bootstart-user-screens'); + + if (!!Settings.settingsGet('AccountSignMe') && window.navigator.registerProtocolHandler) + { + _.delay(function () { + try { + window.navigator.registerProtocolHandler('mailto', + window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', + '' + (Settings.settingsGet('Title') || 'RainLoop')); + } catch(e) {} + + if (Settings.settingsGet('MailToEmail')) + { + Utils.mailToHelper(Settings.settingsGet('MailToEmail'), __webpack_require__(/*! View:Popup:Compose */ 21)); + } + }, 500); + } + + if (!Globals.bMobileDevice) + { + _.defer(function () { + self.initLayoutResizer('#rl-left', '#rl-right', Enums.ClientSideKeyName.FolderListSize); + }); } }); } else { - Data.capaOpenPGP(false); + kn.hideLoading(); + + self.bootstartLoginScreen(); } - kn.startScreens([ - require('Screen:RainLoop:MailBox'), - require('Screen:RainLoop:Settings'), - require('Screen:RainLoop:About') - ]); - - if (bGoogle || bFacebook || bTwitter) + if (window.SimplePace) { - self.socialUsers(true); + window.SimplePace.set(100); } - Events.sub('interval.2m', function () { - self.folderInformation('INBOX'); - }); - - Events.sub('interval.2m', function () { - var sF = Data.currentFolderFullNameRaw(); - if ('INBOX' !== sF) - { - self.folderInformation(sF); - } - }); - - Events.sub('interval.3m', function () { - self.folderInformationMultiply(); - }); - - Events.sub('interval.5m', function () { - self.quota(); - }); - - Events.sub('interval.10m', function () { - self.folders(); - }); - - iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20; - iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320; - - window.setInterval(function () { - self.contactsSync(); - }, iContactsSyncInterval * 60000 + 5000); - - _.delay(function () { - self.contactsSync(); - }, 5000); - - _.delay(function () { - self.folderInformationMultiply(true); - }, 500); - - Plugins.runHook('rl-start-user-screens'); - Events.pub('rl.bootstart-user-screens'); - - if (!!Settings.settingsGet('AccountSignMe') && window.navigator.registerProtocolHandler) - { - _.delay(function () { - try { - window.navigator.registerProtocolHandler('mailto', - window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', - '' + (Settings.settingsGet('Title') || 'RainLoop')); - } catch(e) {} - - if (Settings.settingsGet('MailToEmail')) - { - Utils.mailToHelper(Settings.settingsGet('MailToEmail'), require('View:Popup:Compose')); - } - }, 500); - } - - if (!Globals.bMobileDevice) - { - _.defer(function () { - self.initLayoutResizer('#rl-left', '#rl-right', Enums.ClientSideKeyName.FolderListSize); - }); - } - } - else - { - self.bootstartLoginScreen(); - } + }, this)); + } + else + { + this.bootstartLoginScreen(); if (window.SimplePace) { window.SimplePace.set(100); } - - }, this)); - } - else - { - this.bootstartLoginScreen(); - - if (window.SimplePace) - { - window.SimplePace.set(100); } - } - if (bGoogle) - { - window['rl_' + sJsHash + '_google_service'] = function () { - Data.googleActions(true); - self.socialUsers(); - }; - } + if (bGoogle) + { + window['rl_' + sJsHash + '_google_service'] = function () { + Data.googleActions(true); + self.socialUsers(); + }; + } - if (bFacebook) - { - window['rl_' + sJsHash + '_facebook_service'] = function () { - Data.facebookActions(true); - self.socialUsers(); - }; - } + if (bFacebook) + { + window['rl_' + sJsHash + '_facebook_service'] = function () { + Data.facebookActions(true); + self.socialUsers(); + }; + } - if (bTwitter) - { - window['rl_' + sJsHash + '_twitter_service'] = function () { - Data.twitterActions(true); - self.socialUsers(); - }; - } + if (bTwitter) + { + window['rl_' + sJsHash + '_twitter_service'] = function () { + Data.twitterActions(true); + self.socialUsers(); + }; + } - Events.sub('interval.1m', function () { - Globals.momentTrigger(!Globals.momentTrigger()); - }); - - Plugins.runHook('rl-start-screens'); - Events.pub('rl.bootstart-end'); - }; - - module.exports = new RainLoopApp(); - -}(module, require)); -},{"$":20,"App:Abstract":2,"App:Knoin":27,"Consts":6,"Enums":7,"Events":8,"Globals":9,"LinkBuilder":11,"Model:Account":31,"Model:Email":37,"Model:Folder":40,"Model:Identity":41,"Model:Message":42,"Model:OpenPgpKey":43,"Plugins":12,"Screen:RainLoop:About":44,"Screen:RainLoop:Login":46,"Screen:RainLoop:MailBox":47,"Screen:RainLoop:Settings":48,"Settings:RainLoop:Accounts":49,"Settings:RainLoop:ChangePassword":50,"Settings:RainLoop:Contacts":51,"Settings:RainLoop:Filters":52,"Settings:RainLoop:Folders":53,"Settings:RainLoop:General":54,"Settings:RainLoop:Identities":55,"Settings:RainLoop:Identity":56,"Settings:RainLoop:OpenPGP":57,"Settings:RainLoop:Security":58,"Settings:RainLoop:Social":59,"Settings:RainLoop:Themes":60,"Storage:LocalStorage":65,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,"Utils":14,"View:Popup:Ask":80,"View:Popup:Compose":82,"View:Popup:FolderSystem":87,"_":25,"moment":23,"window":26}],4:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - module.exports = function (App) { - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - - Globals = require('Globals'), - Plugins = require('Plugins'), - Utils = require('Utils'), - Enums = require('Enums'), - - EmailModel = require('Model:Email') - ; - - Globals.__APP = App; - - App.setupSettings(); - - Plugins.__boot = App; - Plugins.__remote = App.remote(); - Plugins.__data = App.data(); - - Globals.$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile'); - - Globals.$win.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS); - - Globals.$win.unload(function () { - Globals.bUnload = true; - }); - - Globals.$html.on('click.dropdown.data-api', function () { - Utils.detectDropdownVisibility(); - }); - - // export - window['rl'] = window['rl'] || {}; - window['rl']['addHook'] = _.bind(Plugins.addHook, Plugins); - window['rl']['settingsGet'] = _.bind(Plugins.mainSettingsGet, Plugins); - window['rl']['remoteRequest'] = _.bind(Plugins.remoteRequest, Plugins); - window['rl']['pluginSettingsGet'] = _.bind(Plugins.settingsGet, Plugins); - window['rl']['createCommand'] = Utils.createCommand; - - window['rl']['EmailModel'] = EmailModel; - window['rl']['Enums'] = Enums; - - window['__APP_BOOT'] = function (fCall) { - - // boot - $(function () { - - if (window['rainloopTEMPLATES'] && window['rainloopTEMPLATES'][0]) - { - $('#rl-templates').html(window['rainloopTEMPLATES'][0]); - - _.delay(function () { - - App.bootstart(); - Globals.$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted'); - - }, 10); - } - else - { - fCall(false); - } - - window['__APP_BOOT'] = null; + Events.sub('interval.1m', function () { + Globals.momentTrigger(!Globals.momentTrigger()); }); + + Plugins.runHook('rl-start-screens'); + Events.pub('rl.bootstart-end'); }; - }; + module.exports = new RainLoopApp(); -}(module, require)); -},{"$":20,"Enums":7,"Globals":9,"Model:Email":37,"Plugins":12,"Utils":14,"_":25,"window":26}],5:[function(require,module,exports){ -// Base64 encode / decode -// http://www.webtoolkit.info/ + }()); -(function (module) { +/***/ }, - 'use strict'; +/***/ 8: +/*!*************************************!*\ + !*** ./dev/Storages/DataStorage.js ***! + \*************************************/ +/***/ function(module, exports, __webpack_require__) { - /*jslint bitwise: true*/ - var Base64 = { + /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - // private property - _keyStr : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', + (function () { - // public method for urlsafe encoding - urlsafe_encode : function (input) { - return Base64.encode(input).replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.'); - }, - - // public method for encoding - encode : function (input) { - var - output = '', - chr1, chr2, chr3, enc1, enc2, enc3, enc4, - i = 0 - ; - - input = Base64._utf8_encode(input); - - while (i < input.length) - { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) - { - enc3 = enc4 = 64; - } - else if (isNaN(chr3)) - { - enc4 = 64; - } - - output = output + - this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + - this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); - } - - return output; - }, - - // public method for decoding - decode : function (input) { - var - output = '', - chr1, chr2, chr3, enc1, enc2, enc3, enc4, - i = 0 - ; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ''); - - while (i < input.length) - { - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 !== 64) - { - output = output + String.fromCharCode(chr2); - } - - if (enc4 !== 64) - { - output = output + String.fromCharCode(chr3); - } - } - - return Base64._utf8_decode(output); - }, - - // private method for UTF-8 encoding - _utf8_encode : function (string) { - - string = string.replace(/\r\n/g, "\n"); - - var - utftext = '', - n = 0, - l = string.length, - c = 0 - ; - - for (; n < l; n++) { - - c = string.charCodeAt(n); - - if (c < 128) - { - utftext += String.fromCharCode(c); - } - else if ((c > 127) && (c < 2048)) - { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else - { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - } - - return utftext; - }, - - // private method for UTF-8 decoding - _utf8_decode : function (utftext) { - var - string = '', - i = 0, - c = 0, - c2 = 0, - c3 = 0 - ; - - while ( i < utftext.length ) - { - c = utftext.charCodeAt(i); - - if (c < 128) - { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) - { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else - { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - } - - return string; - } - }; - - module.exports = Base64; - /*jslint bitwise: false*/ - -}(module, require)); -},{}],6:[function(require,module,exports){ - -(function (module) { - - 'use strict'; - - var Consts = {}; - - Consts.Values = {}; - Consts.DataImages = {}; - Consts.Defaults = {}; - - /** - * @const - * @type {number} - */ - Consts.Defaults.MessagesPerPage = 20; - - /** - * @const - * @type {number} - */ - Consts.Defaults.ContactsPerPage = 50; - - /** - * @const - * @type {Array} - */ - Consts.Defaults.MessagesPerPageArray = [10, 20, 30, 50, 100/*, 150, 200, 300*/]; - - /** - * @const - * @type {number} - */ - Consts.Defaults.DefaultAjaxTimeout = 30000; - - /** - * @const - * @type {number} - */ - Consts.Defaults.SearchAjaxTimeout = 300000; - - /** - * @const - * @type {number} - */ - Consts.Defaults.SendMessageAjaxTimeout = 300000; - - /** - * @const - * @type {number} - */ - Consts.Defaults.SaveMessageAjaxTimeout = 200000; - - /** - * @const - * @type {number} - */ - Consts.Defaults.ContactsSyncAjaxTimeout = 200000; - - /** - * @const - * @type {string} - */ - Consts.Values.UnuseOptionValue = '__UNUSE__'; - - /** - * @const - * @type {string} - */ - Consts.Values.ClientSideStorageIndexName = 'rlcsc'; - - /** - * @const - * @type {number} - */ - Consts.Values.ImapDefaulPort = 143; - - /** - * @const - * @type {number} - */ - Consts.Values.ImapDefaulSecurePort = 993; - - /** - * @const - * @type {number} - */ - Consts.Values.SmtpDefaulPort = 25; - - /** - * @const - * @type {number} - */ - Consts.Values.SmtpDefaulSecurePort = 465; - - /** - * @const - * @type {number} - */ - Consts.Values.MessageBodyCacheLimit = 15; - - /** - * @const - * @type {number} - */ - Consts.Values.AjaxErrorLimit = 7; - - /** - * @const - * @type {number} - */ - Consts.Values.TokenErrorLimit = 10; - - /** - * @const - * @type {string} - */ - Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII='; - - /** - * @const - * @type {string} - */ - Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII='; - - module.exports = Consts; - -}(module)); -},{}],7:[function(require,module,exports){ - -(function (module) { - - 'use strict'; - - var Enums = {}; - - /** - * @enum {string} - */ - Enums.StorageResultType = { - 'Success': 'success', - 'Abort': 'abort', - 'Error': 'error', - 'Unload': 'unload' - }; - - /** - * @enum {number} - */ - Enums.State = { - 'Empty': 10, - 'Login': 20, - 'Auth': 30 - }; - - /** - * @enum {number} - */ - Enums.StateType = { - 'Webmail': 0, - 'Admin': 1 - }; - - /** - * @enum {string} - */ - Enums.Capa = { - 'Prem': 'PREM', - 'TwoFactor': 'TWO_FACTOR', - 'OpenPGP': 'OPEN_PGP', - 'Prefetch': 'PREFETCH', - 'Gravatar': 'GRAVATAR', - 'Themes': 'THEMES', - 'Filters': 'FILTERS', - 'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS', - 'AdditionalIdentities': 'ADDITIONAL_IDENTITIES' - }; - - /** - * @enum {string} - */ - Enums.KeyState = { - 'All': 'all', - 'None': 'none', - 'ContactList': 'contact-list', - 'MessageList': 'message-list', - 'FolderList': 'folder-list', - 'MessageView': 'message-view', - 'Compose': 'compose', - 'Settings': 'settings', - 'Menu': 'menu', - 'PopupComposeOpenPGP': 'compose-open-pgp', - 'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help', - 'PopupAsk': 'popup-ask' - }; - - /** - * @enum {number} - */ - Enums.FolderType = { - 'Inbox': 10, - 'SentItems': 11, - 'Draft': 12, - 'Trash': 13, - 'Spam': 14, - 'Archive': 15, - 'NotSpam': 80, - 'User': 99 - }; - - /** - * @enum {string} - */ - Enums.LoginSignMeTypeAsString = { - 'DefaultOff': 'defaultoff', - 'DefaultOn': 'defaulton', - 'Unused': 'unused' - }; - - /** - * @enum {number} - */ - Enums.LoginSignMeType = { - 'DefaultOff': 0, - 'DefaultOn': 1, - 'Unused': 2 - }; - - /** - * @enum {string} - */ - Enums.ComposeType = { - 'Empty': 'empty', - 'Reply': 'reply', - 'ReplyAll': 'replyall', - 'Forward': 'forward', - 'ForwardAsAttachment': 'forward-as-attachment', - 'Draft': 'draft', - 'EditAsNew': 'editasnew' - }; - - /** - * @enum {number} - */ - Enums.UploadErrorCode = { - 'Normal': 0, - 'FileIsTooBig': 1, - 'FilePartiallyUploaded': 2, - 'FileNoUploaded': 3, - 'MissingTempFolder': 4, - 'FileOnSaveingError': 5, - 'FileType': 98, - 'Unknown': 99 - }; - - /** - * @enum {number} - */ - Enums.SetSystemFoldersNotification = { - 'None': 0, - 'Sent': 1, - 'Draft': 2, - 'Spam': 3, - 'Trash': 4, - 'Archive': 5 - }; - - /** - * @enum {number} - */ - Enums.ClientSideKeyName = { - 'FoldersLashHash': 0, - 'MessagesInboxLastHash': 1, - 'MailBoxListSize': 2, - 'ExpandedFolders': 3, - 'FolderListSize': 4 - }; - - /** - * @enum {number} - */ - Enums.EventKeyCode = { - 'Backspace': 8, - 'Tab': 9, - 'Enter': 13, - 'Esc': 27, - 'PageUp': 33, - 'PageDown': 34, - 'Left': 37, - 'Right': 39, - 'Up': 38, - 'Down': 40, - 'End': 35, - 'Home': 36, - 'Space': 32, - 'Insert': 45, - 'Delete': 46, - 'A': 65, - 'S': 83 - }; - - /** - * @enum {number} - */ - Enums.MessageSetAction = { - 'SetSeen': 0, - 'UnsetSeen': 1, - 'SetFlag': 2, - 'UnsetFlag': 3 - }; - - /** - * @enum {number} - */ - Enums.MessageSelectAction = { - 'All': 0, - 'None': 1, - 'Invert': 2, - 'Unseen': 3, - 'Seen': 4, - 'Flagged': 5, - 'Unflagged': 6 - }; - - /** - * @enum {number} - */ - Enums.DesktopNotifications = { - 'Allowed': 0, - 'NotAllowed': 1, - 'Denied': 2, - 'NotSupported': 9 - }; - - /** - * @enum {number} - */ - Enums.MessagePriority = { - 'Low': 5, - 'Normal': 3, - 'High': 1 - }; - - /** - * @enum {string} - */ - Enums.EditorDefaultType = { - 'Html': 'Html', - 'Plain': 'Plain' - }; - - /** - * @enum {string} - */ - Enums.CustomThemeType = { - 'Light': 'Light', - 'Dark': 'Dark' - }; - - /** - * @enum {number} - */ - Enums.ServerSecure = { - 'None': 0, - 'SSL': 1, - 'TLS': 2 - }; - - /** - * @enum {number} - */ - Enums.SearchDateType = { - 'All': -1, - 'Days3': 3, - 'Days7': 7, - 'Month': 30 - }; - - /** - * @enum {number} - */ - Enums.SaveSettingsStep = { - 'Animate': -2, - 'Idle': -1, - 'TrueResult': 1, - 'FalseResult': 0 - }; - - /** - * @enum {string} - */ - Enums.InterfaceAnimation = { - 'None': 'None', - 'Normal': 'Normal', - 'Full': 'Full' - }; - - /** - * @enum {number} - */ - Enums.Layout = { - 'NoPreview': 0, - 'SidePreview': 1, - 'BottomPreview': 2 - }; - - /** - * @enum {string} - */ - Enums.FilterConditionField = { - 'From': 'From', - 'To': 'To', - 'Recipient': 'Recipient', - 'Subject': 'Subject' - }; - - /** - * @enum {string} - */ - Enums.FilterConditionType = { - 'Contains': 'Contains', - 'NotContains': 'NotContains', - 'EqualTo': 'EqualTo', - 'NotEqualTo': 'NotEqualTo' - }; - - /** - * @enum {string} - */ - Enums.FiltersAction = { - 'None': 'None', - 'Move': 'Move', - 'Discard': 'Discard', - 'Forward': 'Forward' - }; - - /** - * @enum {string} - */ - Enums.FilterRulesType = { - 'And': 'And', - 'Or': 'Or' - }; - - /** - * @enum {number} - */ - Enums.SignedVerifyStatus = { - 'UnknownPublicKeys': -4, - 'UnknownPrivateKey': -3, - 'Unverified': -2, - 'Error': -1, - 'None': 0, - 'Success': 1 - }; - - /** - * @enum {number} - */ - Enums.ContactPropertyType = { - - 'Unknown': 0, - - 'FullName': 10, - - 'FirstName': 15, - 'LastName': 16, - 'MiddleName': 16, - 'Nick': 18, - - 'NamePrefix': 20, - 'NameSuffix': 21, - - 'Email': 30, - 'Phone': 31, - 'Web': 32, - - 'Birthday': 40, - - 'Facebook': 90, - 'Skype': 91, - 'GitHub': 92, - - 'Note': 110, - - 'Custom': 250 - }; - - /** - * @enum {number} - */ - Enums.Notification = { - 'InvalidToken': 101, - 'AuthError': 102, - 'AccessError': 103, - 'ConnectionError': 104, - 'CaptchaError': 105, - 'SocialFacebookLoginAccessDisable': 106, - 'SocialTwitterLoginAccessDisable': 107, - 'SocialGoogleLoginAccessDisable': 108, - 'DomainNotAllowed': 109, - 'AccountNotAllowed': 110, - - 'AccountTwoFactorAuthRequired': 120, - 'AccountTwoFactorAuthError': 121, - - 'CouldNotSaveNewPassword': 130, - 'CurrentPasswordIncorrect': 131, - 'NewPasswordShort': 132, - 'NewPasswordWeak': 133, - 'NewPasswordForbidden': 134, - - 'ContactsSyncError': 140, - - 'CantGetMessageList': 201, - 'CantGetMessage': 202, - 'CantDeleteMessage': 203, - 'CantMoveMessage': 204, - 'CantCopyMessage': 205, - - 'CantSaveMessage': 301, - 'CantSendMessage': 302, - 'InvalidRecipients': 303, - - 'CantCreateFolder': 400, - 'CantRenameFolder': 401, - 'CantDeleteFolder': 402, - 'CantSubscribeFolder': 403, - 'CantUnsubscribeFolder': 404, - 'CantDeleteNonEmptyFolder': 405, - - 'CantSaveSettings': 501, - 'CantSavePluginSettings': 502, - - 'DomainAlreadyExists': 601, - - 'CantInstallPackage': 701, - 'CantDeletePackage': 702, - 'InvalidPluginPackage': 703, - 'UnsupportedPluginPackage': 704, - - 'LicensingServerIsUnavailable': 710, - 'LicensingExpired': 711, - 'LicensingBanned': 712, - - 'DemoSendMessageError': 750, - - 'AccountAlreadyExists': 801, - - 'MailServerError': 901, - 'ClientViewError': 902, - 'InvalidInputArgument': 903, - 'UnknownNotification': 999, - 'UnknownError': 999 - }; - - module.exports = Enums; - -}(module, require)); -},{}],8:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - Utils = require('Utils'), - Plugins = require('Plugins') - ; - - /** - * @constructor - */ - function Events() - { - this.oSubs = {}; - } - - Events.prototype.oSubs = {}; - - /** - * @param {string} sName - * @param {Function} fFunc - * @param {Object=} oContext - * @return {Events} - */ - Events.prototype.sub = function (sName, fFunc, oContext) - { - if (Utils.isUnd(this.oSubs[sName])) - { - this.oSubs[sName] = []; - } - - this.oSubs[sName].push([fFunc, oContext]); - - return this; - }; - - /** - * @param {string} sName - * @param {Array=} aArgs - * @return {Events} - */ - Events.prototype.pub = function (sName, aArgs) - { - Plugins.runHook('rl-pub', [sName, aArgs]); - - if (!Utils.isUnd(this.oSubs[sName])) - { - _.each(this.oSubs[sName], function (aItem) { - if (aItem[0]) - { - aItem[0].apply(aItem[1] || null, aArgs || []); - } - }); - } - - return this; - }; - - module.exports = new Events(); - -}(module, require)); -},{"Plugins":12,"Utils":14,"_":25}],9:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - Globals = {}, - - window = require('window'), - _ = require('_'), - $ = require('$'), - ko = require('ko'), - key = require('key'), - - Enums = require('Enums') - ; - - Globals.$win = $(window); - Globals.$doc = $(window.document); - Globals.$html = $('html'); - Globals.$div = $('
'); - - /** - * @type {?} - */ - Globals.now = (new window.Date()).getTime(); - - /** - * @type {?} - */ - Globals.momentTrigger = ko.observable(true); - - /** - * @type {?} - */ - Globals.dropdownVisibility = ko.observable(false).extend({'rateLimit': 0}); - - /** - * @type {?} - */ - Globals.tooltipTrigger = ko.observable(false).extend({'rateLimit': 0}); - - /** - * @type {?} - */ - Globals.langChangeTrigger = ko.observable(true); - - /** - * @type {boolean} - */ - Globals.useKeyboardShortcuts = ko.observable(true); - - /** - * @type {number} - */ - Globals.iAjaxErrorCount = 0; - - /** - * @type {number} - */ - Globals.iTokenErrorCount = 0; - - /** - * @type {number} - */ - Globals.iMessageBodyCacheCount = 0; - - /** - * @type {boolean} - */ - Globals.bUnload = false; - - /** - * @type {string} - */ - Globals.sUserAgent = (window.navigator.userAgent || '').toLowerCase(); - - /** - * @type {boolean} - */ - Globals.bIsiOSDevice = -1 < Globals.sUserAgent.indexOf('iphone') || -1 < Globals.sUserAgent.indexOf('ipod') || -1 < Globals.sUserAgent.indexOf('ipad'); - - /** - * @type {boolean} - */ - Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android'); - - /** - * @type {boolean} - */ - Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice; - - /** - * @type {boolean} - */ - Globals.bDisableNanoScroll = Globals.bMobileDevice; - - /** - * @type {boolean} - */ - Globals.bAllowPdfPreview = !Globals.bMobileDevice; - - /** - * @type {boolean} - */ - Globals.bAnimationSupported = !Globals.bMobileDevice && Globals.$html.hasClass('csstransitions'); - - /** - * @type {boolean} - */ - Globals.bXMLHttpRequestSupported = !!window.XMLHttpRequest; - - /** - * @type {string} - */ - Globals.sAnimationType = ''; - - /** - * @type {*} - */ - Globals.__APP = null; - - /** - * @type {Object} - */ - Globals.oHtmlEditorDefaultConfig = { - 'title': false, - 'stylesSet': false, - 'customConfig': '', - 'contentsCss': '', - 'toolbarGroups': [ - {name: 'spec'}, - {name: 'styles'}, - {name: 'basicstyles', groups: ['basicstyles', 'cleanup']}, - {name: 'colors'}, - {name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align']}, - {name: 'links'}, - {name: 'insert'}, - {name: 'others'} - // {name: 'document', groups: ['mode', 'document', 'doctools']} - ], - - 'removePlugins': 'contextmenu', //blockquote - 'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll', - 'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced', - - 'extraPlugins': 'plain', - - 'allowedContent': true, - 'autoParagraph': false, - - 'font_defaultLabel': 'Arial', - 'fontSize_defaultLabel': '13', - 'fontSize_sizes': '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px' - }; - - /** - * @type {Object} - */ - Globals.oHtmlEditorLangsMap = { - 'de': 'de', - 'es': 'es', - 'fr': 'fr', - 'hu': 'hu', - 'is': 'is', - 'it': 'it', - 'ja': 'ja', - 'ja-jp': 'ja', - 'ko': 'ko', - 'ko-kr': 'ko', - 'lv': 'lv', - 'nl': 'nl', - 'no': 'no', - 'pl': 'pl', - 'pt': 'pt', - 'pt-pt': 'pt', - 'pt-br': 'pt-br', - 'ro': 'ro', - 'ru': 'ru', - 'sk': 'sk', - 'tr': 'tr', - 'ua': 'ru', - 'zh': 'zh', - 'zh-cn': 'zh-cn' - }; - - if (Globals.bAllowPdfPreview && window.navigator && window.navigator.mimeTypes) - { - Globals.bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function (oType) { - return oType && 'application/pdf' === oType.type; - }); - } - - Globals.oI18N = window['rainloopI18N'] || {}; - - Globals.oNotificationI18N = {}; - - Globals.aBootstrapDropdowns = []; - - Globals.aViewModels = { - 'settings': [], - 'settings-removed': [], - 'settings-disabled': [] - }; - - Globals.leftPanelDisabled = ko.observable(false); - - // popups - Globals.popupVisibilityNames = ko.observableArray([]); - - Globals.popupVisibility = ko.computed(function () { - return 0 < Globals.popupVisibilityNames().length; - }, this); - - // keys - Globals.keyScopeReal = ko.observable(Enums.KeyState.All); - Globals.keyScopeFake = ko.observable(Enums.KeyState.All); - - Globals.keyScope = ko.computed({ - 'owner': this, - 'read': function () { - return Globals.keyScopeFake(); - }, - 'write': function (sValue) { - - if (Enums.KeyState.Menu !== sValue) - { - if (Enums.KeyState.Compose === sValue) - { - // disableKeyFilter - key.filter = function () { - return Globals.useKeyboardShortcuts(); - }; - } - else - { - // restoreKeyFilter - key.filter = function (event) { - - if (Globals.useKeyboardShortcuts()) - { - var - oElement = event.target || event.srcElement, - sTagName = oElement ? oElement.tagName : '' - ; - - sTagName = sTagName.toUpperCase(); - return !(sTagName === 'INPUT' || sTagName === 'SELECT' || sTagName === 'TEXTAREA' || - (oElement && sTagName === 'DIV' && 'editorHtmlArea' === oElement.className && oElement.contentEditable) - ); - } - - return false; - }; - } - - Globals.keyScopeFake(sValue); - if (Globals.dropdownVisibility()) - { - sValue = Enums.KeyState.Menu; - } - } - - Globals.keyScopeReal(sValue); - } - }); - - Globals.keyScopeReal.subscribe(function (sValue) { -// window.console.log(sValue); - key.setScope(sValue); - }); - - Globals.dropdownVisibility.subscribe(function (bValue) { - if (bValue) - { - Globals.tooltipTrigger(!Globals.tooltipTrigger()); - Globals.keyScope(Enums.KeyState.Menu); - } - else if (Enums.KeyState.Menu === key.getScope()) - { - Globals.keyScope(Globals.keyScopeFake()); - } - }); - - module.exports = Globals; - -}(module, require)); -},{"$":20,"Enums":7,"_":25,"key":21,"ko":22,"window":26}],10:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - - Globals = require('Globals'), - Settings = require('Storage:Settings') - ; - - /** - * @constructor - * @param {Object} oElement - * @param {Function=} fOnBlur - * @param {Function=} fOnReady - * @param {Function=} fOnModeChange - */ - function HtmlEditor(oElement, fOnBlur, fOnReady, fOnModeChange) - { - this.editor = null; - this.iBlurTimer = 0; - this.fOnBlur = fOnBlur || null; - this.fOnReady = fOnReady || null; - this.fOnModeChange = fOnModeChange || null; - - this.$element = $(oElement); - - this.resize = _.throttle(_.bind(this.resize, this), 100); - - this.init(); - } - - HtmlEditor.prototype.blurTrigger = function () - { - if (this.fOnBlur) - { - var self = this; - window.clearTimeout(this.iBlurTimer); - this.iBlurTimer = window.setTimeout(function () { - self.fOnBlur(); - }, 200); - } - }; - - HtmlEditor.prototype.focusTrigger = function () - { - if (this.fOnBlur) - { - window.clearTimeout(this.iBlurTimer); - } - }; - - /** - * @return {boolean} - */ - HtmlEditor.prototype.isHtml = function () - { - return this.editor ? 'wysiwyg' === this.editor.mode : false; - }; - - /** - * @return {boolean} - */ - HtmlEditor.prototype.checkDirty = function () - { - return this.editor ? this.editor.checkDirty() : false; - }; - - HtmlEditor.prototype.resetDirty = function () - { - if (this.editor) - { - this.editor.resetDirty(); - } - }; - - /** - * @return {string} - */ - HtmlEditor.prototype.getData = function (bWrapIsHtml) - { - if (this.editor) - { - if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain) - { - return this.editor.__plain.getRawData(); - } - - return bWrapIsHtml ? - '
' + - this.editor.getData() + '
' : this.editor.getData(); - } - - return ''; - }; - - HtmlEditor.prototype.modeToggle = function (bPlain) - { - if (this.editor) - { - if (bPlain) - { - if ('plain' === this.editor.mode) - { - this.editor.setMode('wysiwyg'); - } - } - else - { - if ('wysiwyg' === this.editor.mode) - { - this.editor.setMode('plain'); - } - } - - this.resize(); - } - }; - - HtmlEditor.prototype.setHtml = function (sHtml, bFocus) - { - if (this.editor) - { - this.modeToggle(true); - this.editor.setData(sHtml); - - if (bFocus) - { - this.focus(); - } - } - }; - - HtmlEditor.prototype.setPlain = function (sPlain, bFocus) - { - if (this.editor) - { - this.modeToggle(false); - if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain) - { - return this.editor.__plain.setRawData(sPlain); - } - else - { - this.editor.setData(sPlain); - } - - if (bFocus) - { - this.focus(); - } - } - }; - - HtmlEditor.prototype.init = function () - { - if (this.$element && this.$element[0]) - { - var - self = this, - fInit = function () { - - var - oConfig = Globals.oHtmlEditorDefaultConfig, - sLanguage = Settings.settingsGet('Language'), - bSource = !!Settings.settingsGet('AllowHtmlEditorSourceButton') - ; - - if (bSource && oConfig.toolbarGroups && !oConfig.toolbarGroups.__SourceInited) - { - oConfig.toolbarGroups.__SourceInited = true; - oConfig.toolbarGroups.push({name: 'document', groups: ['mode', 'document', 'doctools']}); - } - - oConfig.enterMode = window.CKEDITOR.ENTER_BR; - oConfig.shiftEnterMode = window.CKEDITOR.ENTER_BR; - - oConfig.language = Globals.oHtmlEditorLangsMap[sLanguage] || 'en'; - if (window.CKEDITOR.env) - { - window.CKEDITOR.env.isCompatible = true; - } - - self.editor = window.CKEDITOR.appendTo(self.$element[0], oConfig); - - self.editor.on('key', function(oEvent) { - if (oEvent && oEvent.data && 9 /* Tab */ === oEvent.data.keyCode) - { - return false; - } - }); - - self.editor.on('blur', function() { - self.blurTrigger(); - }); - - self.editor.on('mode', function() { - - self.blurTrigger(); - - if (self.fOnModeChange) - { - self.fOnModeChange('plain' !== self.editor.mode); - } - }); - - self.editor.on('focus', function() { - self.focusTrigger(); - }); - - if (self.fOnReady) - { - self.editor.on('instanceReady', function () { - - self.editor.setKeystroke(window.CKEDITOR.CTRL + 65 /* A */, 'selectAll'); - - self.fOnReady(); - self.__resizable = true; - self.resize(); - }); - } - } - ; - - if (window.CKEDITOR) - { - fInit(); - } - else - { - window.__initEditor = fInit; - } - } - }; - - HtmlEditor.prototype.focus = function () - { - if (this.editor) - { - this.editor.focus(); - } - }; - - HtmlEditor.prototype.blur = function () - { - if (this.editor) - { - this.editor.focusManager.blur(true); - } - }; - - HtmlEditor.prototype.resize = function () - { - if (this.editor && this.__resizable) - { - try - { - this.editor.resize(this.$element.width(), this.$element.innerHeight()); - } - catch (e) {} - } - }; - - HtmlEditor.prototype.clear = function (bFocus) - { - this.setHtml('', bFocus); - }; - - - module.exports = HtmlEditor; - -}(module, require)); -},{"Globals":9,"Storage:Settings":69,"_":25,"window":26}],11:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - Utils = require('Utils') - ; - - /** - * @constructor - */ - function LinkBuilder() - { - var Settings = require('Storage:Settings'); - - this.sBase = '#/'; - this.sServer = './?'; - this.sVersion = Settings.settingsGet('Version'); - this.sSpecSuffix = Settings.settingsGet('AuthAccountHash') || '0'; - this.sStaticPrefix = Settings.settingsGet('StaticPrefix') || 'rainloop/v/' + this.sVersion + '/static/'; - } - - /** - * @return {string} - */ - LinkBuilder.prototype.root = function () - { - return this.sBase; - }; - - /** - * @param {string} sDownload - * @return {string} - */ - LinkBuilder.prototype.attachmentDownload = function (sDownload) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sDownload; - }; - - /** - * @param {string} sDownload - * @return {string} - */ - LinkBuilder.prototype.attachmentPreview = function (sDownload) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/View/' + sDownload; - }; - - /** - * @param {string} sDownload - * @return {string} - */ - LinkBuilder.prototype.attachmentPreviewAsPlain = function (sDownload) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sDownload; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.upload = function () - { - return this.sServer + '/Upload/' + this.sSpecSuffix + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.uploadContacts = function () - { - return this.sServer + '/UploadContacts/' + this.sSpecSuffix + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.uploadBackground = function () - { - return this.sServer + '/UploadBackground/' + this.sSpecSuffix + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.append = function () - { - return this.sServer + '/Append/' + this.sSpecSuffix + '/'; - }; - - /** - * @param {string} sEmail - * @return {string} - */ - LinkBuilder.prototype.change = function (sEmail) - { - return this.sServer + '/Change/' + this.sSpecSuffix + '/' + window.encodeURIComponent(sEmail) + '/'; - }; - - /** - * @param {string=} sAdd - * @return {string} - */ - LinkBuilder.prototype.ajax = function (sAdd) - { - return this.sServer + '/Ajax/' + this.sSpecSuffix + '/' + sAdd; - }; - - /** - * @param {string} sRequestHash - * @return {string} - */ - LinkBuilder.prototype.messageViewLink = function (sRequestHash) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sRequestHash; - }; - - /** - * @param {string} sRequestHash - * @return {string} - */ - LinkBuilder.prototype.messageDownloadLink = function (sRequestHash) - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sRequestHash; - }; - - /** - * @param {string} sEmail - * @return {string} - */ - LinkBuilder.prototype.avatarLink = function (sEmail) - { - return this.sServer + '/Raw/0/Avatar/' + window.encodeURIComponent(sEmail) + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.inbox = function () - { - return this.sBase + 'mailbox/Inbox'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.messagePreview = function () - { - return this.sBase + 'mailbox/message-preview'; - }; - - /** - * @param {string=} sScreenName - * @return {string} - */ - LinkBuilder.prototype.settings = function (sScreenName) - { - var sResult = this.sBase + 'settings'; - if (!Utils.isUnd(sScreenName) && '' !== sScreenName) - { - sResult += '/' + sScreenName; - } - - return sResult; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.about = function () - { - return this.sBase + 'about'; - }; - - /** - * @param {string} sScreenName - * @return {string} - */ - LinkBuilder.prototype.admin = function (sScreenName) - { - var sResult = this.sBase; - switch (sScreenName) { - case 'AdminDomains': - sResult += 'domains'; - break; - case 'AdminSecurity': - sResult += 'security'; - break; - case 'AdminLicensing': - sResult += 'licensing'; - break; - } - - return sResult; - }; - - /** - * @param {string} sFolder - * @param {number=} iPage = 1 - * @param {string=} sSearch = '' - * @return {string} - */ - LinkBuilder.prototype.mailBox = function (sFolder, iPage, sSearch) - { - iPage = Utils.isNormal(iPage) ? Utils.pInt(iPage) : 1; - sSearch = Utils.pString(sSearch); - - var sResult = this.sBase + 'mailbox/'; - if ('' !== sFolder) - { - sResult += encodeURI(sFolder); - } - if (1 < iPage) - { - sResult = sResult.replace(/[\/]+$/, ''); - sResult += '/p' + iPage; - } - if ('' !== sSearch) - { - sResult = sResult.replace(/[\/]+$/, ''); - sResult += '/' + encodeURI(sSearch); - } - - return sResult; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.phpInfo = function () - { - return this.sServer + 'Info'; - }; - - /** - * @param {string} sLang - * @return {string} - */ - LinkBuilder.prototype.langLink = function (sLang) - { - return this.sServer + '/Lang/0/' + encodeURI(sLang) + '/' + this.sVersion + '/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.exportContactsVcf = function () - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsVcf/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.exportContactsCsv = function () - { - return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsCsv/'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.emptyContactPic = function () - { - return this.sStaticPrefix + 'css/images/empty-contact.png'; - }; - - /** - * @param {string} sFileName - * @return {string} - */ - LinkBuilder.prototype.sound = function (sFileName) - { - return this.sStaticPrefix + 'sounds/' + sFileName; - }; - - /** - * @param {string} sTheme - * @return {string} - */ - LinkBuilder.prototype.themePreviewLink = function (sTheme) - { - var sPrefix = 'rainloop/v/' + this.sVersion + '/'; - if ('@custom' === sTheme.substr(-7)) - { - sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7)); - sPrefix = ''; - } - - return sPrefix + 'themes/' + encodeURI(sTheme) + '/images/preview.png'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.notificationMailIcon = function () - { - return this.sStaticPrefix + 'css/images/icom-message-notification.png'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.openPgpJs = function () - { - return this.sStaticPrefix + 'js/openpgp.min.js'; - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.socialGoogle = function () - { - return this.sServer + 'SocialGoogle' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.socialTwitter = function () - { - return this.sServer + 'SocialTwitter' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); - }; - - /** - * @return {string} - */ - LinkBuilder.prototype.socialFacebook = function () - { - return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); - }; - - module.exports = new LinkBuilder(); - -}(module, require)); -},{"Storage:Settings":69,"Utils":14,"window":26}],12:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - Utils = require('Utils') - ; - - /** - * @constructor - */ - function Plugins() - { - this.__boot = null; - this.__data = null; - this.__remote = null; - - this.oSettings = require('Storage:Settings'); - - this.oViewModelsHooks = {}; - this.oSimpleHooks = {}; - } - - Plugins.prototype.__boot = null; - Plugins.prototype.__data = null; - Plugins.prototype.__remote = null; - - /** - * @type {Object} - */ - Plugins.prototype.oViewModelsHooks = {}; - - /** - * @type {Object} - */ - Plugins.prototype.oSimpleHooks = {}; - - /** - * @param {string} sName - * @param {Function} fCallback - */ - Plugins.prototype.addHook = function (sName, fCallback) - { - if (Utils.isFunc(fCallback)) - { - if (!Utils.isArray(this.oSimpleHooks[sName])) - { - this.oSimpleHooks[sName] = []; - } - - this.oSimpleHooks[sName].push(fCallback); - } - }; - - /** - * @param {string} sName - * @param {Array=} aArguments - */ - Plugins.prototype.runHook = function (sName, aArguments) - { - if (Utils.isArray(this.oSimpleHooks[sName])) - { - aArguments = aArguments || []; - - _.each(this.oSimpleHooks[sName], function (fCallback) { - fCallback.apply(null, aArguments); - }); - } - }; - - /** - * @param {string} sName - * @return {?} - */ - Plugins.prototype.mainSettingsGet = function (sName) - { - return this.oSettings.settingsGet(sName); - }; - - /** - * @param {Function} fCallback - * @param {string} sAction - * @param {Object=} oParameters - * @param {?number=} iTimeout - * @param {string=} sGetAdd = '' - * @param {Array=} aAbortActions = [] - */ - Plugins.prototype.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) - { - if (this.__remote) - { - this.__remote.defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions); - } - }; - - /** - * @param {string} sPluginSection - * @param {string} sName - * @return {?} - */ - Plugins.prototype.settingsGet = function (sPluginSection, sName) - { - var oPlugin = this.oSettings.settingsGet('Plugins'); - oPlugin = oPlugin && !Utils.isUnd(oPlugin[sPluginSection]) ? oPlugin[sPluginSection] : null; - return oPlugin ? (Utils.isUnd(oPlugin[sName]) ? null : oPlugin[sName]) : null; - }; - - module.exports = new Plugins(); - -}(module, require)); -},{"Storage:Settings":69,"Utils":14,"_":25}],13:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - $ = require('$'), - ko = require('ko'), - key = require('key'), - - Enums = require('Enums'), - Utils = require('Utils') - ; - - /** - * @constructor - * @param {koProperty} oKoList - * @param {koProperty} oKoSelectedItem - * @param {string} sItemSelector - * @param {string} sItemSelectedSelector - * @param {string} sItemCheckedSelector - * @param {string} sItemFocusedSelector - */ - function Selector(oKoList, oKoSelectedItem, - sItemSelector, sItemSelectedSelector, sItemCheckedSelector, sItemFocusedSelector) - { - this.list = oKoList; - - this.listChecked = ko.computed(function () { - return _.filter(this.list(), function (oItem) { - return oItem.checked(); - }); - }, this).extend({'rateLimit': 0}); - - this.isListChecked = ko.computed(function () { - return 0 < this.listChecked().length; - }, this); - - this.focusedItem = ko.observable(null); - this.selectedItem = oKoSelectedItem; - this.selectedItemUseCallback = true; - - this.itemSelectedThrottle = _.debounce(_.bind(this.itemSelected, this), 300); - - this.listChecked.subscribe(function (aItems) { - if (0 < aItems.length) - { - if (null === this.selectedItem()) - { - this.selectedItem.valueHasMutated(); - } - else - { - this.selectedItem(null); - } - } - else if (this.bAutoSelect && this.focusedItem()) - { - this.selectedItem(this.focusedItem()); - } - }, this); - - this.selectedItem.subscribe(function (oItem) { - - if (oItem) - { - if (this.isListChecked()) - { - _.each(this.listChecked(), function (oSubItem) { - oSubItem.checked(false); - }); - } - - if (this.selectedItemUseCallback) - { - this.itemSelectedThrottle(oItem); - } - } - else if (this.selectedItemUseCallback) - { - this.itemSelected(null); - } - - }, this); - - this.selectedItem.extend({'toggleSubscribe': [null, - function (oPrev) { - if (oPrev) - { - oPrev.selected(false); - } - }, function (oNext) { - if (oNext) - { - oNext.selected(true); - } - } - ]}); - - this.focusedItem.extend({'toggleSubscribe': [null, - function (oPrev) { - if (oPrev) - { - oPrev.focused(false); - } - }, function (oNext) { - if (oNext) - { - oNext.focused(true); - } - } - ]}); - - this.oContentVisible = null; - this.oContentScrollable = null; - - this.sItemSelector = sItemSelector; - this.sItemSelectedSelector = sItemSelectedSelector; - this.sItemCheckedSelector = sItemCheckedSelector; - this.sItemFocusedSelector = sItemFocusedSelector; - - this.sLastUid = ''; - this.bAutoSelect = true; - this.oCallbacks = {}; - - this.emptyFunction = function () {}; - - this.focusedItem.subscribe(function (oItem) { - if (oItem) - { - this.sLastUid = this.getItemUid(oItem); - } - }, this); + 'use strict'; var - aCache = [], - aCheckedCache = [], - mFocused = null, - mSelected = null + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + moment = __webpack_require__(/*! moment */ 25), + + Consts = __webpack_require__(/*! Common/Consts */ 17), + Enums = __webpack_require__(/*! Common/Enums */ 6), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20), + + kn = __webpack_require__(/*! App:Knoin */ 5), + + MessageModel = __webpack_require__(/*! Model:Message */ 38), + + LocalStorage = __webpack_require__(/*! Storage:LocalStorage */ 30), + AbstractData = __webpack_require__(/*! Storage:Abstract:Data */ 39) ; - this.list.subscribe(function (aItems) { + /** + * @constructor + * @extends AbstractData + */ + function DataStorage() + { + AbstractData.call(this); - var self = this; - if (Utils.isArray(aItems)) - { - _.each(aItems, function (oItem) { - if (oItem) + var + fRemoveSystemFolderType = function (observable) { + return function () { + var oFolder = Cache.getFolderFromCacheList(observable()); + if (oFolder) + { + oFolder.type(Enums.FolderType.User); + } + }; + }, + fSetSystemFolderType = function (iType) { + return function (sValue) { + var oFolder = Cache.getFolderFromCacheList(sValue); + if (oFolder) + { + oFolder.type(iType); + } + }; + } + ; + + this.devEmail = ''; + this.devPassword = ''; + + this.accountEmail = ko.observable(''); + this.accountIncLogin = ko.observable(''); + this.accountOutLogin = ko.observable(''); + this.projectHash = ko.observable(''); + this.threading = ko.observable(false); + + this.lastFoldersHash = ''; + this.remoteSuggestions = false; + + // system folders + this.sentFolder = ko.observable(''); + this.draftFolder = ko.observable(''); + this.spamFolder = ko.observable(''); + this.trashFolder = ko.observable(''); + this.archiveFolder = ko.observable(''); + + this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange'); + this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange'); + this.spamFolder.subscribe(fRemoveSystemFolderType(this.spamFolder), this, 'beforeChange'); + this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange'); + this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange'); + + this.sentFolder.subscribe(fSetSystemFolderType(Enums.FolderType.SentItems), this); + this.draftFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Draft), this); + this.spamFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Spam), this); + this.trashFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Trash), this); + this.archiveFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Archive), this); + + this.draftFolderNotEnabled = ko.computed(function () { + return '' === this.draftFolder() || Consts.Values.UnuseOptionValue === this.draftFolder(); + }, this); + + // personal + this.displayName = ko.observable(''); + this.signature = ko.observable(''); + this.signatureToAll = ko.observable(false); + this.replyTo = ko.observable(''); + + // security + this.enableTwoFactor = ko.observable(false); + + // accounts + this.accounts = ko.observableArray([]); + this.accountsLoading = ko.observable(false).extend({'throttle': 100}); + + // identities + this.defaultIdentityID = ko.observable(''); + this.identities = ko.observableArray([]); + 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(''); + this.contactsSyncUser = ko.observable(''); + this.contactsSyncPass = ko.observable(''); + + this.allowContactsSync = ko.observable(!!Settings.settingsGet('ContactsSyncIsAllowed')); + this.enableContactsSync = ko.observable(!!Settings.settingsGet('EnableContactsSync')); + this.contactsSyncUrl = ko.observable(Settings.settingsGet('ContactsSyncUrl')); + this.contactsSyncUser = ko.observable(Settings.settingsGet('ContactsSyncUser')); + this.contactsSyncPass = ko.observable(Settings.settingsGet('ContactsSyncPassword')); + + // folders + this.namespace = ''; + this.folderList = ko.observableArray([]); + this.folderList.focused = ko.observable(false); + + this.foldersListError = ko.observable(''); + + this.foldersLoading = ko.observable(false); + this.foldersCreating = ko.observable(false); + this.foldersDeleting = ko.observable(false); + this.foldersRenaming = ko.observable(false); + + this.foldersChanging = ko.computed(function () { + var + bLoading = this.foldersLoading(), + bCreating = this.foldersCreating(), + bDeleting = this.foldersDeleting(), + bRenaming = this.foldersRenaming() + ; + return bLoading || bCreating || bDeleting || bRenaming; + }, this); + + this.foldersInboxUnreadCount = ko.observable(0); + + this.currentFolder = ko.observable(null).extend({'toggleSubscribe': [null, + function (oPrev) { + if (oPrev) { - var sUid = self.getItemUid(oItem); + oPrev.selected(false); + } + }, function (oNext) { + if (oNext) + { + oNext.selected(true); + } + } + ]}); - aCache.push(sUid); - if (oItem.checked()) + this.currentFolderFullNameRaw = ko.computed(function () { + return this.currentFolder() ? this.currentFolder().fullNameRaw : ''; + }, this); + + this.currentFolderFullName = ko.computed(function () { + return this.currentFolder() ? this.currentFolder().fullName : ''; + }, this); + + this.currentFolderFullNameHash = ko.computed(function () { + return this.currentFolder() ? this.currentFolder().fullNameHash : ''; + }, this); + + this.currentFolderName = ko.computed(function () { + return this.currentFolder() ? this.currentFolder().name() : ''; + }, this); + + this.folderListSystemNames = ko.computed(function () { + + var + aList = ['INBOX'], + aFolders = this.folderList(), + sSentFolder = this.sentFolder(), + sDraftFolder = this.draftFolder(), + sSpamFolder = this.spamFolder(), + sTrashFolder = this.trashFolder(), + sArchiveFolder = this.archiveFolder() + ; + + if (Utils.isArray(aFolders) && 0 < aFolders.length) + { + if ('' !== sSentFolder && Consts.Values.UnuseOptionValue !== sSentFolder) + { + aList.push(sSentFolder); + } + if ('' !== sDraftFolder && Consts.Values.UnuseOptionValue !== sDraftFolder) + { + aList.push(sDraftFolder); + } + if ('' !== sSpamFolder && Consts.Values.UnuseOptionValue !== sSpamFolder) + { + aList.push(sSpamFolder); + } + if ('' !== sTrashFolder && Consts.Values.UnuseOptionValue !== sTrashFolder) + { + aList.push(sTrashFolder); + } + if ('' !== sArchiveFolder && Consts.Values.UnuseOptionValue !== sArchiveFolder) + { + aList.push(sArchiveFolder); + } + } + + return aList; + + }, this); + + this.folderListSystem = ko.computed(function () { + return _.compact(_.map(this.folderListSystemNames(), function (sName) { + return Cache.getFolderFromCacheList(sName); + })); + }, this); + + this.folderMenuForMove = ko.computed(function () { + return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(), [ + this.currentFolderFullNameRaw() + ], null, null, null, null, function (oItem) { + return oItem ? oItem.localName() : ''; + }); + }, this); + + // message list + this.staticMessageList = []; + + this.messageList = ko.observableArray([]).extend({'rateLimit': 0}); + + this.messageListCount = ko.observable(0); + this.messageListSearch = ko.observable(''); + this.messageListPage = ko.observable(1); + + this.messageListThreadFolder = ko.observable(''); + this.messageListThreadUids = ko.observableArray([]); + + this.messageListThreadFolder.subscribe(function () { + this.messageListThreadUids([]); + }, this); + + 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 = window.Math.ceil(this.messageListCount() / this.messagesPerPage()); + return 0 >= iPage ? 1 : iPage; + }, this); + + this.mainMessageListSearch = ko.computed({ + 'read': this.messageListSearch, + 'write': function (sValue) { + kn.setHash(LinkBuilder.mailBox( + this.currentFolderFullNameHash(), 1, Utils.trim(sValue.toString()) + )); + }, + 'owner': this + }); + + this.messageListError = ko.observable(''); + + this.messageListLoading = ko.observable(false); + this.messageListIsNotCompleted = ko.observable(false); + this.messageListCompleteLoadingThrottle = ko.observable(false).extend({'throttle': 200}); + + this.messageListCompleteLoading = ko.computed(function () { + var + bOne = this.messageListLoading(), + bTwo = this.messageListIsNotCompleted() + ; + return bOne || bTwo; + }, this); + + this.messageListCompleteLoading.subscribe(function (bValue) { + this.messageListCompleteLoadingThrottle(bValue); + }, this); + + this.messageList.subscribe(_.debounce(function (aList) { + _.each(aList, function (oItem) { + if (oItem.newForAnimation()) + { + oItem.newForAnimation(false); + } + }); + }, 500)); + + // message preview + this.staticMessageList = new MessageModel(); + this.message = ko.observable(null); + this.messageLoading = ko.observable(false); + this.messageLoadingThrottle = ko.observable(false).extend({'throttle': 50}); + + this.message.focused = ko.observable(false); + + this.message.subscribe(function (oMessage) { + if (!oMessage) + { + this.message.focused(false); + this.messageFullScreenMode(false); + this.hideMessageBodies(); + + if (Enums.Layout.NoPreview === this.layout() && + -1 < window.location.hash.indexOf('message-preview')) + { + if (Globals.__APP) { - aCheckedCache.push(sUid); + Globals.__APP.historyBack(); } - if (null === mFocused && oItem.focused()) + } + } + else if (Enums.Layout.NoPreview === this.layout()) + { + this.message.focused(true); + } + }, this); + + this.message.focused.subscribe(function (bValue) { + if (bValue) + { + this.folderList.focused(false); + Globals.keyScope(Enums.KeyState.MessageView); + } + else if (Enums.KeyState.MessageView === Globals.keyScope()) + { + if (Enums.Layout.NoPreview === this.layout() && this.message()) + { + Globals.keyScope(Enums.KeyState.MessageView); + } + else + { + Globals.keyScope(Enums.KeyState.MessageList); + } + } + }, this); + + this.folderList.focused.subscribe(function (bValue) { + if (bValue) + { + Globals.keyScope(Enums.KeyState.FolderList); + } + else if (Enums.KeyState.FolderList === Globals.keyScope()) + { + Globals.keyScope(Enums.KeyState.MessageList); + } + }); + + this.messageLoading.subscribe(function (bValue) { + this.messageLoadingThrottle(bValue); + }, this); + + this.messageFullScreenMode = ko.observable(false); + + this.messageError = ko.observable(''); + + this.messagesBodiesDom = ko.observable(null); + + this.messagesBodiesDom.subscribe(function (oDom) { + if (oDom && !(oDom instanceof $)) + { + this.messagesBodiesDom($(oDom)); + } + }, this); + + this.messageActiveDom = ko.observable(null); + + this.isMessageSelected = ko.computed(function () { + return null !== this.message(); + }, 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}); + + this.messageListCheckedOrSelected = ko.computed(function () { + + var + aChecked = this.messageListChecked(), + oSelectedMessage = this.currentMessage() + ; + + return _.union(aChecked, oSelectedMessage ? [oSelectedMessage] : []); + + }, this); + + this.messageListCheckedOrSelectedUidsWithSubMails = ko.computed(function () { + var aList = []; + _.each(this.messageListCheckedOrSelected(), function (oMessage) { + if (oMessage) + { + aList.push(oMessage.uid); + if (0 < oMessage.threadsLen() && 0 === oMessage.parentUid() && oMessage.lastInCollapsedThread()) { - mFocused = sUid; - } - if (null === mSelected && oItem.selected()) - { - mSelected = sUid; + aList = _.union(aList, oMessage.threads()); } } }); - } - }, this, 'beforeChange'); + return aList; + }, this); - this.list.subscribe(function (aItems) { + // quota + this.userQuota = ko.observable(0); + this.userUsageSize = ko.observable(0); + this.userUsageProc = ko.computed(function () { + + var + iQuota = this.userQuota(), + iUsed = this.userUsageSize() + ; + + return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0; + + }, this); + + // other + this.capaOpenPGP = ko.observable(false); + this.openpgpkeys = ko.observableArray([]); + this.openpgpKeyring = null; + + this.openpgpkeysPublic = this.openpgpkeys.filter(function (oItem) { + return !!(oItem && !oItem.isPrivate); + }); + + this.openpgpkeysPrivate = this.openpgpkeys.filter(function (oItem) { + return !!(oItem && oItem.isPrivate); + }); + + // google + this.googleActions = ko.observable(false); + this.googleLoggined = ko.observable(false); + this.googleUserName = ko.observable(''); + + // facebook + this.facebookActions = ko.observable(false); + this.facebookLoggined = ko.observable(false); + this.facebookUserName = ko.observable(''); + + // twitter + this.twitterActions = ko.observable(false); + this.twitterLoggined = ko.observable(false); + this.twitterUserName = ko.observable(''); + + this.customThemeType = ko.observable(Enums.CustomThemeType.Light); + + this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, 1000 * 30); + } + + _.extend(DataStorage.prototype, AbstractData.prototype); + + DataStorage.prototype.purgeMessageBodyCache = function() + { + var + iCount = 0, + oMessagesBodiesDom = null, + iEnd = Globals.iMessageBodyCacheCount - Consts.Values.MessageBodyCacheLimit + ; + + if (0 < iEnd) + { + oMessagesBodiesDom = this.messagesBodiesDom(); + if (oMessagesBodiesDom) + { + oMessagesBodiesDom.find('.rl-cache-class').each(function () { + var oItem = $(this); + if (iEnd > oItem.data('rl-cache-count')) + { + oItem.addClass('rl-cache-purge'); + iCount++; + } + }); + + if (0 < iCount) + { + _.delay(function () { + oMessagesBodiesDom.find('.rl-cache-purge').remove(); + }, 300); + } + } + } + }; + + DataStorage.prototype.populateDataOnStart = function() + { + AbstractData.prototype.populateDataOnStart.call(this); + + this.accountEmail(Settings.settingsGet('Email')); + this.accountIncLogin(Settings.settingsGet('IncLogin')); + this.accountOutLogin(Settings.settingsGet('OutLogin')); + this.projectHash(Settings.settingsGet('ProjectHash')); + + this.defaultIdentityID(Settings.settingsGet('DefaultIdentityID')); + + this.displayName(Settings.settingsGet('DisplayName')); + this.replyTo(Settings.settingsGet('ReplyTo')); + this.signature(Settings.settingsGet('Signature')); + this.signatureToAll(!!Settings.settingsGet('SignatureToAll')); + this.enableTwoFactor(!!Settings.settingsGet('EnableTwoFactor')); + + this.lastFoldersHash = LocalStorage.get(Enums.ClientSideKeyName.FoldersLashHash) || ''; + + this.remoteSuggestions = !!Settings.settingsGet('RemoteSuggestions'); + + this.devEmail = Settings.settingsGet('DevEmail'); + this.devPassword = Settings.settingsGet('DevPassword'); + }; + + DataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUidNext, aNewMessages) + { + if ('INBOX' === sFolder && Utils.isNormal(sUidNext) && sUidNext !== '') + { + if (Utils.isArray(aNewMessages) && 0 < aNewMessages.length) + { + var + self = this, + iIndex = 0, + iLen = aNewMessages.length, + fNotificationHelper = function (sImageSrc, sTitle, sText) + { + var + NotificationClass = Utils.notificationClass(), + oNotification = null + ; + + if (NotificationClass && self.useDesktopNotifications()) + { + oNotification = new NotificationClass(sTitle, { + 'body': sText, + 'icon': sImageSrc + }); + + if (oNotification) + { + if (oNotification.show) + { + oNotification.show(); + } + + window.setTimeout((function (oLocalNotifications) { + return function () { + if (oLocalNotifications.cancel) + { + oLocalNotifications.cancel(); + } + else if (oLocalNotifications.close) + { + oLocalNotifications.close(); + } + }; + }(oNotification)), 7000); + } + } + } + ; + + _.each(aNewMessages, function (oItem) { + Cache.addNewMessageCache(sFolder, oItem.Uid); + }); + + if (3 < iLen) + { + fNotificationHelper( + LinkBuilder.notificationMailIcon(), + this.accountEmail(), + Utils.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', { + 'COUNT': iLen + }) + ); + } + else + { + for (; iIndex < iLen; iIndex++) + { + fNotificationHelper( + LinkBuilder.notificationMailIcon(), + MessageModel.emailsToLine(MessageModel.initEmailsFromJson(aNewMessages[iIndex].From), false), + aNewMessages[iIndex].Subject + ); + } + } + } + + Cache.setFolderUidNext(sFolder, sUidNext); + } + }; + + DataStorage.prototype.hideMessageBodies = function () + { + var oMessagesBodiesDom = this.messagesBodiesDom(); + if (oMessagesBodiesDom) + { + oMessagesBodiesDom.find('.b-text-part').hide(); + } + }; + + /** + * @param {boolean=} bBoot = false + * @returns {Array} + */ + DataStorage.prototype.getNextFolderNames = function (bBoot) + { + bBoot = Utils.isUnd(bBoot) ? false : !!bBoot; + + var + aResult = [], + iLimit = 10, + iUtc = moment().unix(), + iTimeout = iUtc - 60 * 5, + aTimeouts = [], + fSearchFunction = function (aList) { + _.each(aList, function (oFolder) { + if (oFolder && 'INBOX' !== oFolder.fullNameRaw && + oFolder.selectable && oFolder.existen && + iTimeout > oFolder.interval && + (!bBoot || oFolder.subScribed())) + { + aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]); + } + + if (oFolder && 0 < oFolder.subFolders().length) + { + fSearchFunction(oFolder.subFolders()); + } + }); + } + ; + + fSearchFunction(this.folderList()); + + aTimeouts.sort(function(a, b) { + if (a[0] < b[0]) + { + return -1; + } + else if (a[0] > b[0]) + { + return 1; + } + + return 0; + }); + + _.find(aTimeouts, function (aItem) { + var oFolder = Cache.getFolderFromCacheList(aItem[1]); + if (oFolder) + { + oFolder.interval = iUtc; + aResult.push(aItem[1]); + } + + return iLimit <= aResult.length; + }); + + return _.uniq(aResult); + }; + + /** + * @param {string} sFromFolderFullNameRaw + * @param {Array} aUidForRemove + * @param {string=} sToFolderFullNameRaw = '' + * @param {bCopy=} bCopy = false + */ + DataStorage.prototype.removeMessagesFromList = function ( + sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy) + { + sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : ''; + bCopy = Utils.isUnd(bCopy) ? false : !!bCopy; + + aUidForRemove = _.map(aUidForRemove, function (mValue) { + return Utils.pInt(mValue); + }); var self = this, - oTemp = null, - bGetNext = false, - aUids = [], - mNextFocused = mFocused, - bChecked = false, - bSelected = false, + iUnseenCount = 0, + aMessageList = this.messageList(), + oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw), + oToFolder = '' === sToFolderFullNameRaw ? null : Cache.getFolderFromCacheList(sToFolderFullNameRaw || ''), + sCurrentFolderFullNameRaw = this.currentFolderFullNameRaw(), + oCurrentMessage = this.message(), + aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(aMessageList, function (oMessage) { + return oMessage && -1 < Utils.inArray(Utils.pInt(oMessage.uid), aUidForRemove); + }) : [] + ; + + _.each(aMessages, function (oMessage) { + if (oMessage && oMessage.unseen()) + { + iUnseenCount++; + } + }); + + if (oFromFolder && !bCopy) + { + oFromFolder.messageCountAll(0 <= oFromFolder.messageCountAll() - aUidForRemove.length ? + oFromFolder.messageCountAll() - aUidForRemove.length : 0); + + if (0 < iUnseenCount) + { + oFromFolder.messageCountUnread(0 <= oFromFolder.messageCountUnread() - iUnseenCount ? + oFromFolder.messageCountUnread() - iUnseenCount : 0); + } + } + + if (oToFolder) + { + oToFolder.messageCountAll(oToFolder.messageCountAll() + aUidForRemove.length); + if (0 < iUnseenCount) + { + oToFolder.messageCountUnread(oToFolder.messageCountUnread() + iUnseenCount); + } + + oToFolder.actionBlink(true); + } + + if (0 < aMessages.length) + { + if (bCopy) + { + _.each(aMessages, function (oMessage) { + oMessage.checked(false); + }); + } + else + { + this.messageListIsNotCompleted(true); + + _.each(aMessages, function (oMessage) { + if (oCurrentMessage && oCurrentMessage.hash === oMessage.hash) + { + oCurrentMessage = null; + self.message(null); + } + + oMessage.deleted(true); + }); + + _.delay(function () { + _.each(aMessages, function (oMessage) { + self.messageList.remove(oMessage); + }); + }, 400); + } + } + + if ('' !== sFromFolderFullNameRaw) + { + Cache.setFolderHash(sFromFolderFullNameRaw, ''); + } + + if ('' !== sToFolderFullNameRaw) + { + Cache.setFolderHash(sToFolderFullNameRaw, ''); + } + }; + + /** + * @private + * @param {Object} oMessageTextBody + */ + DataStorage.prototype.initBlockquoteSwitcher = function (oMessageTextBody) + { + if (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 () { + var $self = $(this), iH = $self.height(); + if (0 === iH || 100 < iH) + { + $self.addClass('rl-bq-switcher hidden-bq'); + $('') + .insertBefore($self) + .click(function () { + $self.toggleClass('hidden-bq'); + Utils.windowResize(); + }) + .after('
') + .before('
') + ; + } + }); + } + } + }; + + DataStorage.prototype.setMessage = function (oData, bCached) + { + var + bIsHtml = false, + bHasExternals = false, + bHasInternals = false, + oBody = null, + oTextBody = null, + sId = '', + sResultHtml = '', + bPgpSigned = false, + bPgpEncrypted = false, + oMessagesBodiesDom = this.messagesBodiesDom(), + oMessage = this.message() + ; + + if (oData && oMessage && oData.Result && 'Object/Message' === oData.Result['@Object'] && + oMessage.folderFullNameRaw === oData.Result.Folder && oMessage.uid === oData.Result.Uid) + { + this.messageError(''); + + oMessage.initUpdateByMessageJson(oData.Result); + Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid); + + if (!bCached) + { + oMessage.initFlagsByJson(oData.Result); + } + + oMessagesBodiesDom = oMessagesBodiesDom && oMessagesBodiesDom[0] ? oMessagesBodiesDom : null; + if (oMessagesBodiesDom) + { + sId = 'rl-mgs-' + oMessage.hash.replace(/[^a-zA-Z0-9]/g, ''); + oTextBody = oMessagesBodiesDom.find('#' + sId); + if (!oTextBody || !oTextBody[0]) + { + bHasExternals = !!oData.Result.HasExternals; + bHasInternals = !!oData.Result.HasInternals; + + oBody = $('
').hide().addClass('rl-cache-class'); + oBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount); + + if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html) + { + bIsHtml = true; + sResultHtml = oData.Result.Html.toString(); + } + else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain) + { + bIsHtml = false; + sResultHtml = Utils.plainToHtml(oData.Result.Plain.toString(), false); + + if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && this.capaOpenPGP()) + { + oMessage.plainRaw = Utils.pString(oData.Result.Plain); + + bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oMessage.plainRaw); + if (!bPgpEncrypted) + { + bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oMessage.plainRaw) && + /-----BEGIN PGP SIGNATURE-----/.test(oMessage.plainRaw); + } + + Globals.$div.empty(); + if (bPgpSigned && oMessage.isPgpSigned()) + { + sResultHtml = + Globals.$div.append( + $('
').text(oMessage.plainRaw)
+										).html()
+									;
+								}
+								else if (bPgpEncrypted && oMessage.isPgpEncrypted())
+								{
+									sResultHtml =
+										Globals.$div.append(
+											$('
').text(oMessage.plainRaw)
+										).html()
+									;
+								}
+
+								Globals.$div.empty();
+
+								oMessage.isPgpSigned(bPgpSigned);
+								oMessage.isPgpEncrypted(bPgpEncrypted);
+							}
+						}
+						else
+						{
+							bIsHtml = false;
+						}
+
+						oBody
+							.html(Utils.linkify(sResultHtml))
+							.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'))
+						;
+
+						oMessage.isHtml(!!bIsHtml);
+						oMessage.hasImages(!!bHasExternals);
+						oMessage.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);
+						oMessage.pgpSignedVerifyUser('');
+
+						oMessage.body = oBody;
+						if (oMessage.body)
+						{
+							oMessagesBodiesDom.append(oMessage.body);
+						}
+
+						oMessage.storeDataToDom();
+
+						if (bHasInternals)
+						{
+							oMessage.showInternalImages(true);
+						}
+
+						if (oMessage.hasImages() && this.showImages())
+						{
+							oMessage.showExternalImages(true);
+						}
+
+						this.purgeMessageBodyCacheThrottle();
+					}
+					else
+					{
+						oMessage.body = oTextBody;
+						if (oMessage.body)
+						{
+							oMessage.body.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
+							oMessage.fetchDataToDom();
+						}
+					}
+
+					this.messageActiveDom(oMessage.body);
+
+					this.hideMessageBodies();
+					oMessage.body.show();
+
+					if (oBody)
+					{
+						this.initBlockquoteSwitcher(oBody);
+					}
+				}
+
+				Cache.initMessageFlagsFromCache(oMessage);
+				if (oMessage.unseen())
+				{
+					if (Globals.__APP)
+					{
+						Globals.__APP.setMessageSeen(oMessage);
+					}
+				}
+
+				Utils.windowResize();
+			}
+		};
+
+		/**
+		 * @param {Array} aList
+		 * @returns {string}
+		 */
+		DataStorage.prototype.calculateMessageListHash = function (aList)
+		{
+			return _.map(aList, function (oMessage) {
+				return '' + oMessage.hash + '_' + oMessage.threadsLen() + '_' + oMessage.flagHash();
+			}).join('|');
+		};
+
+		DataStorage.prototype.findPublicKeyByHex = function (sHash)
+		{
+			return _.find(this.openpgpkeysPublic(), function (oItem) {
+				return oItem && sHash === oItem.id;
+			});
+		};
+
+		DataStorage.prototype.findPublicKeysByEmail = function (sEmail)
+		{
+			return _.compact(_.map(this.openpgpkeysPublic(), function (oItem) {
+
+				var oKey = null;
+				if (oItem && sEmail === oItem.email)
+				{
+					try
+					{
+						oKey = window.openpgp.key.readArmored(oItem.armor);
+						if (oKey && !oKey.err && oKey.keys && oKey.keys[0])
+						{
+							return oKey.keys[0];
+						}
+					}
+					catch (e) {}
+				}
+
+				return null;
+
+			}));
+		};
+
+		/**
+		 * @param {string} sEmail
+		 * @param {string=} sPassword
+		 * @returns {?}
+		 */
+		DataStorage.prototype.findPrivateKeyByEmail = function (sEmail, sPassword)
+		{
+			var
+				oPrivateKey = null,
+				oKey = _.find(this.openpgpkeysPrivate(), function (oItem) {
+					return oItem && sEmail === oItem.email;
+				})
+			;
+
+			if (oKey)
+			{
+				try
+				{
+					oPrivateKey = window.openpgp.key.readArmored(oKey.armor);
+					if (oPrivateKey && !oPrivateKey.err && oPrivateKey.keys && oPrivateKey.keys[0])
+					{
+						oPrivateKey = oPrivateKey.keys[0];
+						oPrivateKey.decrypt(Utils.pString(sPassword));
+					}
+					else
+					{
+						oPrivateKey = null;
+					}
+				}
+				catch (e)
+				{
+					oPrivateKey = null;
+				}
+			}
+
+			return oPrivateKey;
+		};
+
+		/**
+		 * @param {string=} sPassword
+		 * @returns {?}
+		 */
+		DataStorage.prototype.findSelfPrivateKey = function (sPassword)
+		{
+			return this.findPrivateKeyByEmail(this.accountEmail(), sPassword);
+		};
+
+		module.exports = new DataStorage();
+
+	}());
+
+
+/***/ },
+
+/***/ 13:
+/*!***************************************!*\
+  !*** ./dev/Storages/RemoteStorage.js ***!
+  \***************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
+
+	(function () {
+
+		'use strict';
+
+		var
+			_ = __webpack_require__(/*! _ */ 2),
+
+			Utils = __webpack_require__(/*! Common/Utils */ 1),
+			Consts = __webpack_require__(/*! Common/Consts */ 17),
+			Globals = __webpack_require__(/*! Common/Globals */ 7),
+			Base64 = __webpack_require__(/*! Common/Base64 */ 49),
+
+			Settings = __webpack_require__(/*! Storage:Settings */ 10),
+			Cache = __webpack_require__(/*! Storage:RainLoop:Cache */ 20),
+			Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8),
+
+			AbstractRemoteStorage = __webpack_require__(/*! Storage:Abstract:Remote */ 40)
+		;
+
+		/**
+		 * @constructor
+		 * @extends AbstractRemoteStorage
+		 */
+		function RemoteStorage()
+		{
+			AbstractRemoteStorage.call(this);
+
+			this.oRequests = {};
+		}
+
+		_.extend(RemoteStorage.prototype, AbstractRemoteStorage.prototype);
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.folders = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'Folders', {
+				'SentFolder': Settings.settingsGet('SentFolder'),
+				'DraftFolder': Settings.settingsGet('DraftFolder'),
+				'SpamFolder': Settings.settingsGet('SpamFolder'),
+				'TrashFolder': Settings.settingsGet('TrashFolder'),
+				'ArchiveFolder': Settings.settingsGet('ArchiveFolder')
+			}, null, '', ['Folders']);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sEmail
+		 * @param {string} sLogin
+		 * @param {string} sPassword
+		 * @param {boolean} bSignMe
+		 * @param {string=} sLanguage
+		 * @param {string=} sAdditionalCode
+		 * @param {boolean=} bAdditionalCodeSignMe
+		 */
+		RemoteStorage.prototype.login = function (fCallback, sEmail, sLogin, sPassword, bSignMe, sLanguage, sAdditionalCode, bAdditionalCodeSignMe)
+		{
+			this.defaultRequest(fCallback, 'Login', {
+				'Email': sEmail,
+				'Login': sLogin,
+				'Password': sPassword,
+				'Language': sLanguage || '',
+				'AdditionalCode': sAdditionalCode || '',
+				'AdditionalCodeSignMe': bAdditionalCodeSignMe ? '1' : '0',
+				'SignMe': bSignMe ? '1' : '0'
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.getTwoFactor = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'GetTwoFactorInfo');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.createTwoFactor = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'CreateTwoFactorSecret');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.clearTwoFactor = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'ClearTwoFactorInfo');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.showTwoFactorSecret = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'ShowTwoFactorSecret');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sCode
+		 */
+		RemoteStorage.prototype.testTwoFactor = function (fCallback, sCode)
+		{
+			this.defaultRequest(fCallback, 'TestTwoFactorInfo', {
+				'Code': sCode
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {boolean} bEnable
+		 */
+		RemoteStorage.prototype.enableTwoFactor = function (fCallback, bEnable)
+		{
+			this.defaultRequest(fCallback, 'EnableTwoFactor', {
+				'Enable': bEnable ? '1' : '0'
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.clearTwoFactorInfo = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'ClearTwoFactorInfo');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.contactsSync = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'ContactsSync', null, Consts.Defaults.ContactsSyncAjaxTimeout);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {boolean} bEnable
+		 * @param {string} sUrl
+		 * @param {string} sUser
+		 * @param {string} sPassword
+		 */
+		RemoteStorage.prototype.saveContactsSyncData = function (fCallback, bEnable, sUrl, sUser, sPassword)
+		{
+			this.defaultRequest(fCallback, 'SaveContactsSyncData', {
+				'Enable': bEnable ? '1' : '0',
+				'Url': sUrl,
+				'User': sUser,
+				'Password': sPassword
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sEmail
+		 * @param {string} sLogin
+		 * @param {string} sPassword
+		 */
+		RemoteStorage.prototype.accountAdd = function (fCallback, sEmail, sLogin, sPassword)
+		{
+			this.defaultRequest(fCallback, 'AccountAdd', {
+				'Email': sEmail,
+				'Login': sLogin,
+				'Password': sPassword
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sEmailToDelete
+		 */
+		RemoteStorage.prototype.accountDelete = function (fCallback, sEmailToDelete)
+		{
+			this.defaultRequest(fCallback, 'AccountDelete', {
+				'EmailToDelete': sEmailToDelete
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sId
+		 * @param {string} sEmail
+		 * @param {string} sName
+		 * @param {string} sReplyTo
+		 * @param {string} sBcc
+		 */
+		RemoteStorage.prototype.identityUpdate = function (fCallback, sId, sEmail, sName, sReplyTo, sBcc)
+		{
+			this.defaultRequest(fCallback, 'IdentityUpdate', {
+				'Id': sId,
+				'Email': sEmail,
+				'Name': sName,
+				'ReplyTo': sReplyTo,
+				'Bcc': sBcc
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sIdToDelete
+		 */
+		RemoteStorage.prototype.identityDelete = function (fCallback, sIdToDelete)
+		{
+			this.defaultRequest(fCallback, 'IdentityDelete', {
+				'IdToDelete': sIdToDelete
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.accountsAndIdentities = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'AccountsAndIdentities');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolderFullNameRaw
+		 * @param {number=} iOffset = 0
+		 * @param {number=} iLimit = 20
+		 * @param {string=} sSearch = ''
+		 * @param {boolean=} bSilent = false
+		 */
+		RemoteStorage.prototype.messageList = function (fCallback, sFolderFullNameRaw, iOffset, iLimit, sSearch, bSilent)
+		{
+			sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw);
+
+			var
+				sFolderHash = Cache.getFolderHash(sFolderFullNameRaw)
+			;
+
+			bSilent = Utils.isUnd(bSilent) ? false : !!bSilent;
+			iOffset = Utils.isUnd(iOffset) ? 0 : Utils.pInt(iOffset);
+			iLimit = Utils.isUnd(iOffset) ? 20 : Utils.pInt(iLimit);
+			sSearch = Utils.pString(sSearch);
+
+			if ('' !== sFolderHash && ('' === sSearch || -1 === sSearch.indexOf('is:')))
+			{
+				this.defaultRequest(fCallback, 'MessageList', {},
+					'' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout,
+					'MessageList/' + Base64.urlsafe_encode([
+						sFolderFullNameRaw,
+						iOffset,
+						iLimit,
+						sSearch,
+						Data.projectHash(),
+						sFolderHash,
+						'INBOX' === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
+						Data.threading() && Data.useThreads() ? '1' : '0',
+						Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : ''
+					].join(String.fromCharCode(0))), bSilent ? [] : ['MessageList']);
+			}
+			else
+			{
+				this.defaultRequest(fCallback, 'MessageList', {
+					'Folder': sFolderFullNameRaw,
+					'Offset': iOffset,
+					'Limit': iLimit,
+					'Search': sSearch,
+					'UidNext': 'INBOX' === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
+					'UseThreads': Data.threading() && Data.useThreads() ? '1' : '0',
+					'ExpandedThreadUid': Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : ''
+				}, '' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout, '', bSilent ? [] : ['MessageList']);
+			}
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {Array} aDownloads
+		 */
+		RemoteStorage.prototype.messageUploadAttachments = function (fCallback, aDownloads)
+		{
+			this.defaultRequest(fCallback, 'MessageUploadAttachments', {
+				'Attachments': aDownloads
+			}, 999000);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolderFullNameRaw
+		 * @param {number} iUid
+		 * @return {boolean}
+		 */
+		RemoteStorage.prototype.message = function (fCallback, sFolderFullNameRaw, iUid)
+		{
+			sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw);
+			iUid = Utils.pInt(iUid);
+
+			if (Cache.getFolderFromCacheList(sFolderFullNameRaw) && 0 < iUid)
+			{
+				this.defaultRequest(fCallback, 'Message', {}, null,
+					'Message/' + Base64.urlsafe_encode([
+						sFolderFullNameRaw,
+						iUid,
+						Data.projectHash(),
+						Data.threading() && Data.useThreads() ? '1' : '0'
+					].join(String.fromCharCode(0))), ['Message']);
+
+				return true;
+			}
+
+			return false;
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {Array} aExternals
+		 */
+		RemoteStorage.prototype.composeUploadExternals = function (fCallback, aExternals)
+		{
+			this.defaultRequest(fCallback, 'ComposeUploadExternals', {
+				'Externals': aExternals
+			}, 999000);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sUrl
+		 * @param {string} sAccessToken
+		 */
+		RemoteStorage.prototype.composeUploadDrive = function (fCallback, sUrl, sAccessToken)
+		{
+			this.defaultRequest(fCallback, 'ComposeUploadDrive', {
+				'AccessToken': sAccessToken,
+				'Url': sUrl
+			}, 999000);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolder
+		 * @param {Array=} aList = []
+		 */
+		RemoteStorage.prototype.folderInformation = function (fCallback, sFolder, aList)
+		{
+			var
+				bRequest = true,
+				aUids = []
+			;
+
+			if (Utils.isArray(aList) && 0 < aList.length)
+			{
+				bRequest = false;
+				_.each(aList, function (oMessageListItem) {
+					if (!Cache.getMessageFlagsFromCache(oMessageListItem.folderFullNameRaw, oMessageListItem.uid))
+					{
+						aUids.push(oMessageListItem.uid);
+					}
+
+					if (0 < oMessageListItem.threads().length)
+					{
+						_.each(oMessageListItem.threads(), function (sUid) {
+							if (!Cache.getMessageFlagsFromCache(oMessageListItem.folderFullNameRaw, sUid))
+							{
+								aUids.push(sUid);
+							}
+						});
+					}
+				});
+
+				if (0 < aUids.length)
+				{
+					bRequest = true;
+				}
+			}
+
+			if (bRequest)
+			{
+				this.defaultRequest(fCallback, 'FolderInformation', {
+					'Folder': sFolder,
+					'FlagsUids': Utils.isArray(aUids) ? aUids.join(',') : '',
+					'UidNext': 'INBOX' === sFolder ? Cache.getFolderUidNext(sFolder) : ''
+				});
+			}
+			else if (Data.useThreads())
+			{
+				if (Globals.__APP)
+				{
+					Globals.__APP.reloadFlagsCurrentMessageListAndMessageFromCache();
+				}
+			}
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {Array} aFolders
+		 */
+		RemoteStorage.prototype.folderInformationMultiply = function (fCallback, aFolders)
+		{
+			this.defaultRequest(fCallback, 'FolderInformationMultiply', {
+				'Folders': aFolders
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.logout = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'Logout');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolderFullNameRaw
+		 * @param {Array} aUids
+		 * @param {boolean} bSetFlagged
+		 */
+		RemoteStorage.prototype.messageSetFlagged = function (fCallback, sFolderFullNameRaw, aUids, bSetFlagged)
+		{
+			this.defaultRequest(fCallback, 'MessageSetFlagged', {
+				'Folder': sFolderFullNameRaw,
+				'Uids': aUids.join(','),
+				'SetAction': bSetFlagged ? '1' : '0'
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolderFullNameRaw
+		 * @param {Array} aUids
+		 * @param {boolean} bSetSeen
+		 */
+		RemoteStorage.prototype.messageSetSeen = function (fCallback, sFolderFullNameRaw, aUids, bSetSeen)
+		{
+			this.defaultRequest(fCallback, 'MessageSetSeen', {
+				'Folder': sFolderFullNameRaw,
+				'Uids': aUids.join(','),
+				'SetAction': bSetSeen ? '1' : '0'
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolderFullNameRaw
+		 * @param {boolean} bSetSeen
+		 */
+		RemoteStorage.prototype.messageSetSeenToAll = function (fCallback, sFolderFullNameRaw, bSetSeen)
+		{
+			this.defaultRequest(fCallback, 'MessageSetSeenToAll', {
+				'Folder': sFolderFullNameRaw,
+				'SetAction': bSetSeen ? '1' : '0'
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sMessageFolder
+		 * @param {string} sMessageUid
+		 * @param {string} sDraftFolder
+		 * @param {string} sFrom
+		 * @param {string} sTo
+		 * @param {string} sCc
+		 * @param {string} sBcc
+		 * @param {string} sSubject
+		 * @param {boolean} bTextIsHtml
+		 * @param {string} sText
+		 * @param {Array} aAttachments
+		 * @param {(Array|null)} aDraftInfo
+		 * @param {string} sInReplyTo
+		 * @param {string} sReferences
+		 */
+		RemoteStorage.prototype.saveMessage = function (fCallback, sMessageFolder, sMessageUid, sDraftFolder,
+			sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences)
+		{
+			this.defaultRequest(fCallback, 'SaveMessage', {
+				'MessageFolder': sMessageFolder,
+				'MessageUid': sMessageUid,
+				'DraftFolder': sDraftFolder,
+				'From': sFrom,
+				'To': sTo,
+				'Cc': sCc,
+				'Bcc': sBcc,
+				'Subject': sSubject,
+				'TextIsHtml': bTextIsHtml ? '1' : '0',
+				'Text': sText,
+				'DraftInfo': aDraftInfo,
+				'InReplyTo': sInReplyTo,
+				'References': sReferences,
+				'Attachments': aAttachments
+			}, Consts.Defaults.SaveMessageAjaxTimeout);
+		};
+
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sMessageFolder
+		 * @param {string} sMessageUid
+		 * @param {string} sReadReceipt
+		 * @param {string} sSubject
+		 * @param {string} sText
+		 */
+		RemoteStorage.prototype.sendReadReceiptMessage = function (fCallback, sMessageFolder, sMessageUid, sReadReceipt, sSubject, sText)
+		{
+			this.defaultRequest(fCallback, 'SendReadReceiptMessage', {
+				'MessageFolder': sMessageFolder,
+				'MessageUid': sMessageUid,
+				'ReadReceipt': sReadReceipt,
+				'Subject': sSubject,
+				'Text': sText
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sMessageFolder
+		 * @param {string} sMessageUid
+		 * @param {string} sSentFolder
+		 * @param {string} sFrom
+		 * @param {string} sTo
+		 * @param {string} sCc
+		 * @param {string} sBcc
+		 * @param {string} sSubject
+		 * @param {boolean} bTextIsHtml
+		 * @param {string} sText
+		 * @param {Array} aAttachments
+		 * @param {(Array|null)} aDraftInfo
+		 * @param {string} sInReplyTo
+		 * @param {string} sReferences
+		 * @param {boolean} bRequestReadReceipt
+		 */
+		RemoteStorage.prototype.sendMessage = function (fCallback, sMessageFolder, sMessageUid, sSentFolder,
+			sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences, bRequestReadReceipt)
+		{
+			this.defaultRequest(fCallback, 'SendMessage', {
+				'MessageFolder': sMessageFolder,
+				'MessageUid': sMessageUid,
+				'SentFolder': sSentFolder,
+				'From': sFrom,
+				'To': sTo,
+				'Cc': sCc,
+				'Bcc': sBcc,
+				'Subject': sSubject,
+				'TextIsHtml': bTextIsHtml ? '1' : '0',
+				'Text': sText,
+				'DraftInfo': aDraftInfo,
+				'InReplyTo': sInReplyTo,
+				'References': sReferences,
+				'ReadReceiptRequest': bRequestReadReceipt ? '1' : '0',
+				'Attachments': aAttachments
+			}, Consts.Defaults.SendMessageAjaxTimeout);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {Object} oData
+		 */
+		RemoteStorage.prototype.saveSystemFolders = function (fCallback, oData)
+		{
+			this.defaultRequest(fCallback, 'SystemFoldersUpdate', oData);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {Object} oData
+		 */
+		RemoteStorage.prototype.saveSettings = function (fCallback, oData)
+		{
+			this.defaultRequest(fCallback, 'SettingsUpdate', oData);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sPrevPassword
+		 * @param {string} sNewPassword
+		 */
+		RemoteStorage.prototype.changePassword = function (fCallback, sPrevPassword, sNewPassword)
+		{
+			this.defaultRequest(fCallback, 'ChangePassword', {
+				'PrevPassword': sPrevPassword,
+				'NewPassword': sNewPassword
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sNewFolderName
+		 * @param {string} sParentName
+		 */
+		RemoteStorage.prototype.folderCreate = function (fCallback, sNewFolderName, sParentName)
+		{
+			this.defaultRequest(fCallback, 'FolderCreate', {
+				'Folder': sNewFolderName,
+				'Parent': sParentName
+			}, null, '', ['Folders']);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolderFullNameRaw
+		 */
+		RemoteStorage.prototype.folderDelete = function (fCallback, sFolderFullNameRaw)
+		{
+			this.defaultRequest(fCallback, 'FolderDelete', {
+				'Folder': sFolderFullNameRaw
+			}, null, '', ['Folders']);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sPrevFolderFullNameRaw
+		 * @param {string} sNewFolderName
+		 */
+		RemoteStorage.prototype.folderRename = function (fCallback, sPrevFolderFullNameRaw, sNewFolderName)
+		{
+			this.defaultRequest(fCallback, 'FolderRename', {
+				'Folder': sPrevFolderFullNameRaw,
+				'NewFolderName': sNewFolderName
+			}, null, '', ['Folders']);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolderFullNameRaw
+		 */
+		RemoteStorage.prototype.folderClear = function (fCallback, sFolderFullNameRaw)
+		{
+			this.defaultRequest(fCallback, 'FolderClear', {
+				'Folder': sFolderFullNameRaw
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolderFullNameRaw
+		 * @param {boolean} bSubscribe
+		 */
+		RemoteStorage.prototype.folderSetSubscribe = function (fCallback, sFolderFullNameRaw, bSubscribe)
+		{
+			this.defaultRequest(fCallback, 'FolderSubscribe', {
+				'Folder': sFolderFullNameRaw,
+				'Subscribe': bSubscribe ? '1' : '0'
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolder
+		 * @param {string} sToFolder
+		 * @param {Array} aUids
+		 * @param {string=} sLearning
+		 */
+		RemoteStorage.prototype.messagesMove = function (fCallback, sFolder, sToFolder, aUids, sLearning)
+		{
+			this.defaultRequest(fCallback, 'MessageMove', {
+				'FromFolder': sFolder,
+				'ToFolder': sToFolder,
+				'Uids': aUids.join(','),
+				'Learning': sLearning || ''
+			}, null, '', ['MessageList']);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolder
+		 * @param {string} sToFolder
+		 * @param {Array} aUids
+		 */
+		RemoteStorage.prototype.messagesCopy = function (fCallback, sFolder, sToFolder, aUids)
+		{
+			this.defaultRequest(fCallback, 'MessageCopy', {
+				'FromFolder': sFolder,
+				'ToFolder': sToFolder,
+				'Uids': aUids.join(',')
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sFolder
+		 * @param {Array} aUids
+		 */
+		RemoteStorage.prototype.messagesDelete = function (fCallback, sFolder, aUids)
+		{
+			this.defaultRequest(fCallback, 'MessageDelete', {
+				'Folder': sFolder,
+				'Uids': aUids.join(',')
+			}, null, '', ['MessageList']);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.appDelayStart = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'AppDelayStart');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.quota = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'Quota');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {number} iOffset
+		 * @param {number} iLimit
+		 * @param {string} sSearch
+		 */
+		RemoteStorage.prototype.contacts = function (fCallback, iOffset, iLimit, sSearch)
+		{
+			this.defaultRequest(fCallback, 'Contacts', {
+				'Offset': iOffset,
+				'Limit': iLimit,
+				'Search': sSearch
+			}, null, '', ['Contacts']);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties)
+		{
+			this.defaultRequest(fCallback, 'ContactSave', {
+				'RequestUid': sRequestUid,
+				'Uid': Utils.trim(sUid),
+				'Tags': Utils.trim(sTags),
+				'Properties': aProperties
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {Array} aUids
+		 */
+		RemoteStorage.prototype.contactsDelete = function (fCallback, aUids)
+		{
+			this.defaultRequest(fCallback, 'ContactsDelete', {
+				'Uids': aUids.join(',')
+			});
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 * @param {string} sQuery
+		 * @param {number} iPage
+		 */
+		RemoteStorage.prototype.suggestions = function (fCallback, sQuery, iPage)
+		{
+			this.defaultRequest(fCallback, 'Suggestions', {
+				'Query': sQuery,
+				'Page': iPage
+			}, null, '', ['Suggestions']);
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.facebookUser = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'SocialFacebookUserInformation');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.facebookDisconnect = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'SocialFacebookDisconnect');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.twitterUser = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'SocialTwitterUserInformation');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.twitterDisconnect = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'SocialTwitterDisconnect');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.googleUser = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'SocialGoogleUserInformation');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.googleDisconnect = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'SocialGoogleDisconnect');
+		};
+
+		/**
+		 * @param {?Function} fCallback
+		 */
+		RemoteStorage.prototype.socialUsers = function (fCallback)
+		{
+			this.defaultRequest(fCallback, 'SocialUsers');
+		};
+
+		module.exports = new RemoteStorage();
+
+	}());
+
+/***/ },
+
+/***/ 20:
+/*!**************************************!*\
+  !*** ./dev/Storages/CacheStorage.js ***!
+  \**************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
+
+	(function () {
+
+		'use strict';
+
+		var
+			_ = __webpack_require__(/*! _ */ 2),
+
+			Enums = __webpack_require__(/*! Common/Enums */ 6),
+			Utils = __webpack_require__(/*! Common/Utils */ 1),
+			LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11),
+
+			Settings = __webpack_require__(/*! Storage:Settings */ 10)
+		;
+
+		/**
+		 * @constructor
+		 */
+		function CacheStorage()
+		{
+			this.oFoldersCache = {};
+			this.oFoldersNamesCache = {};
+			this.oFolderHashCache = {};
+			this.oFolderUidNextCache = {};
+			this.oMessageListHashCache = {};
+			this.oMessageFlagsCache = {};
+			this.oNewMessage = {};
+			this.oRequestedMessage = {};
+
+			this.bCapaGravatar = Settings.capa(Enums.Capa.Gravatar);
+		}
+
+		/**
+		 * @type {boolean}
+		 */
+		CacheStorage.prototype.bCapaGravatar = false;
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oFoldersCache = {};
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oFoldersNamesCache = {};
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oFolderHashCache = {};
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oFolderUidNextCache = {};
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oMessageListHashCache = {};
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oMessageFlagsCache = {};
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oBodies = {};
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oNewMessage = {};
+
+		/**
+		 * @type {Object}
+		 */
+		CacheStorage.prototype.oRequestedMessage = {};
+
+		CacheStorage.prototype.clear = function ()
+		{
+			this.oFoldersCache = {};
+			this.oFoldersNamesCache = {};
+			this.oFolderHashCache = {};
+			this.oFolderUidNextCache = {};
+			this.oMessageListHashCache = {};
+			this.oMessageFlagsCache = {};
+			this.oBodies = {};
+		};
+
+
+		/**
+		 * @param {string} sEmail
+		 * @param {Function} fCallback
+		 * @return {string}
+		 */
+		CacheStorage.prototype.getUserPic = function (sEmail, fCallback)
+		{
+			sEmail = Utils.trim(sEmail);
+			fCallback(this.bCapaGravatar && '' !== sEmail ? LinkBuilder.avatarLink(sEmail) : '', sEmail);
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @param {string} sUid
+		 * @return {string}
+		 */
+		CacheStorage.prototype.getMessageKey = function (sFolderFullNameRaw, sUid)
+		{
+			return sFolderFullNameRaw + '#' + sUid;
+		};
+
+		/**
+		 * @param {string} sFolder
+		 * @param {string} sUid
+		 */
+		CacheStorage.prototype.addRequestedMessage = function (sFolder, sUid)
+		{
+			this.oRequestedMessage[this.getMessageKey(sFolder, sUid)] = true;
+		};
+
+		/**
+		 * @param {string} sFolder
+		 * @param {string} sUid
+		 * @return {boolean}
+		 */
+		CacheStorage.prototype.hasRequestedMessage = function (sFolder, sUid)
+		{
+			return true === this.oRequestedMessage[this.getMessageKey(sFolder, sUid)];
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @param {string} sUid
+		 */
+		CacheStorage.prototype.addNewMessageCache = function (sFolderFullNameRaw, sUid)
+		{
+			this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = true;
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @param {string} sUid
+		 */
+		CacheStorage.prototype.hasNewMessageAndRemoveFromCache = function (sFolderFullNameRaw, sUid)
+		{
+			if (this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)])
+			{
+				this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = null;
+				return true;
+			}
+
+			return false;
+		};
+
+		CacheStorage.prototype.clearNewMessageCache = function ()
+		{
+			this.oNewMessage = {};
+		};
+
+		/**
+		 * @param {string} sFolderHash
+		 * @return {string}
+		 */
+		CacheStorage.prototype.getFolderFullNameRaw = function (sFolderHash)
+		{
+			return '' !== sFolderHash && this.oFoldersNamesCache[sFolderHash] ? this.oFoldersNamesCache[sFolderHash] : '';
+		};
+
+		/**
+		 * @param {string} sFolderHash
+		 * @param {string} sFolderFullNameRaw
+		 */
+		CacheStorage.prototype.setFolderFullNameRaw = function (sFolderHash, sFolderFullNameRaw)
+		{
+			this.oFoldersNamesCache[sFolderHash] = sFolderFullNameRaw;
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @return {string}
+		 */
+		CacheStorage.prototype.getFolderHash = function (sFolderFullNameRaw)
+		{
+			return '' !== sFolderFullNameRaw && this.oFolderHashCache[sFolderFullNameRaw] ? this.oFolderHashCache[sFolderFullNameRaw] : '';
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @param {string} sFolderHash
+		 */
+		CacheStorage.prototype.setFolderHash = function (sFolderFullNameRaw, sFolderHash)
+		{
+			this.oFolderHashCache[sFolderFullNameRaw] = sFolderHash;
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @return {string}
+		 */
+		CacheStorage.prototype.getFolderUidNext = function (sFolderFullNameRaw)
+		{
+			return '' !== sFolderFullNameRaw && this.oFolderUidNextCache[sFolderFullNameRaw] ? this.oFolderUidNextCache[sFolderFullNameRaw] : '';
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @param {string} sUidNext
+		 */
+		CacheStorage.prototype.setFolderUidNext = function (sFolderFullNameRaw, sUidNext)
+		{
+			this.oFolderUidNextCache[sFolderFullNameRaw] = sUidNext;
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @return {?FolderModel}
+		 */
+		CacheStorage.prototype.getFolderFromCacheList = function (sFolderFullNameRaw)
+		{
+			return '' !== sFolderFullNameRaw && this.oFoldersCache[sFolderFullNameRaw] ? this.oFoldersCache[sFolderFullNameRaw] : null;
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 * @param {?FolderModel} oFolder
+		 */
+		CacheStorage.prototype.setFolderToCacheList = function (sFolderFullNameRaw, oFolder)
+		{
+			this.oFoldersCache[sFolderFullNameRaw] = oFolder;
+		};
+
+		/**
+		 * @param {string} sFolderFullNameRaw
+		 */
+		CacheStorage.prototype.removeFolderFromCacheList = function (sFolderFullNameRaw)
+		{
+			this.setFolderToCacheList(sFolderFullNameRaw, null);
+		};
+
+		/**
+		 * @param {string} sFolderFullName
+		 * @param {string} sUid
+		 * @return {?Array}
+		 */
+		CacheStorage.prototype.getMessageFlagsFromCache = function (sFolderFullName, sUid)
+		{
+			return this.oMessageFlagsCache[sFolderFullName] && this.oMessageFlagsCache[sFolderFullName][sUid] ?
+				this.oMessageFlagsCache[sFolderFullName][sUid] : null;
+		};
+
+		/**
+		 * @param {string} sFolderFullName
+		 * @param {string} sUid
+		 * @param {Array} aFlagsCache
+		 */
+		CacheStorage.prototype.setMessageFlagsToCache = function (sFolderFullName, sUid, aFlagsCache)
+		{
+			if (!this.oMessageFlagsCache[sFolderFullName])
+			{
+				this.oMessageFlagsCache[sFolderFullName] = {};
+			}
+
+			this.oMessageFlagsCache[sFolderFullName][sUid] = aFlagsCache;
+		};
+
+		/**
+		 * @param {string} sFolderFullName
+		 */
+		CacheStorage.prototype.clearMessageFlagsFromCacheByFolder = function (sFolderFullName)
+		{
+			this.oMessageFlagsCache[sFolderFullName] = {};
+		};
+
+		/**
+		 * @param {(MessageModel|null)} oMessage
+		 */
+		CacheStorage.prototype.initMessageFlagsFromCache = function (oMessage)
+		{
+			if (oMessage)
+			{
+				var
+					self = this,
+					aFlags = this.getMessageFlagsFromCache(oMessage.folderFullNameRaw, oMessage.uid),
+					mUnseenSubUid = null,
+					mFlaggedSubUid = null
+				;
+
+				if (aFlags && 0 < aFlags.length)
+				{
+					oMessage.unseen(!!aFlags[0]);
+					oMessage.flagged(!!aFlags[1]);
+					oMessage.answered(!!aFlags[2]);
+					oMessage.forwarded(!!aFlags[3]);
+					oMessage.isReadReceipt(!!aFlags[4]);
+				}
+
+				if (0 < oMessage.threads().length)
+				{
+					mUnseenSubUid = _.find(oMessage.threads(), function (iSubUid) {
+						var aFlags = self.getMessageFlagsFromCache(oMessage.folderFullNameRaw, iSubUid);
+						return aFlags && 0 < aFlags.length && !!aFlags[0];
+					});
+
+					mFlaggedSubUid = _.find(oMessage.threads(), function (iSubUid) {
+						var aFlags = self.getMessageFlagsFromCache(oMessage.folderFullNameRaw, iSubUid);
+						return aFlags && 0 < aFlags.length && !!aFlags[1];
+					});
+
+					oMessage.hasUnseenSubMessage(mUnseenSubUid && 0 < Utils.pInt(mUnseenSubUid));
+					oMessage.hasFlaggedSubMessage(mFlaggedSubUid && 0 < Utils.pInt(mFlaggedSubUid));
+				}
+			}
+		};
+
+		/**
+		 * @param {(MessageModel|null)} oMessage
+		 */
+		CacheStorage.prototype.storeMessageFlagsToCache = function (oMessage)
+		{
+			if (oMessage)
+			{
+				this.setMessageFlagsToCache(
+					oMessage.folderFullNameRaw,
+					oMessage.uid,
+					[oMessage.unseen(), oMessage.flagged(), oMessage.answered(), oMessage.forwarded(), oMessage.isReadReceipt()]
+				);
+			}
+		};
+		/**
+		 * @param {string} sFolder
+		 * @param {string} sUid
+		 * @param {Array} aFlags
+		 */
+		CacheStorage.prototype.storeMessageFlagsToCacheByFolderAndUid = function (sFolder, sUid, aFlags)
+		{
+			if (Utils.isArray(aFlags) && 0 < aFlags.length)
+			{
+				this.setMessageFlagsToCache(sFolder, sUid, aFlags);
+			}
+		};
+
+		module.exports = new CacheStorage();
+
+	}());
+
+/***/ },
+
+/***/ 27:
+/*!**************************************************************!*\
+  !*** ./dev/ViewModels/Popups/PopupsFolderSystemViewModel.js ***!
+  \**************************************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	
+	(function () {
+
+		'use strict';
+
+		var
+			_ = __webpack_require__(/*! _ */ 2),
+			ko = __webpack_require__(/*! ko */ 3),
+
+			Enums = __webpack_require__(/*! Common/Enums */ 6),
+			Consts = __webpack_require__(/*! Common/Consts */ 17),
+			Utils = __webpack_require__(/*! Common/Utils */ 1),
+
+			Settings = __webpack_require__(/*! Storage:Settings */ 10),
+			Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8),
+			Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13),
+
+			kn = __webpack_require__(/*! App:Knoin */ 5),
+			KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9)
+		;
+
+		/**
+		 * @constructor
+		 * @extends KnoinAbstractViewModel
+		 */
+		function PopupsFolderSystemViewModel()
+		{
+			KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderSystem');
+
+			Utils.initOnStartOrLangChange(function () {
+				this.sChooseOnText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE');
+				this.sUnuseText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME');
+			}, this);
+
+			this.notification = ko.observable('');
+
+			this.folderSelectList = ko.computed(function () {
+				return Utils.folderListOptionsBuilder([], Data.folderList(), Data.folderListSystemNames(), [
+					['', this.sChooseOnText],
+					[Consts.Values.UnuseOptionValue, this.sUnuseText]
+				]);
+			}, this);
+
+			var
+				self = this,
+				fSaveSystemFolders = null,
+				fCallback = null
+			;
+
+			this.sentFolder = Data.sentFolder;
+			this.draftFolder = Data.draftFolder;
+			this.spamFolder = Data.spamFolder;
+			this.trashFolder = Data.trashFolder;
+			this.archiveFolder = Data.archiveFolder;
+
+			fSaveSystemFolders = _.debounce(function () {
+
+				Settings.settingsSet('SentFolder', self.sentFolder());
+				Settings.settingsSet('DraftFolder', self.draftFolder());
+				Settings.settingsSet('SpamFolder', self.spamFolder());
+				Settings.settingsSet('TrashFolder', self.trashFolder());
+				Settings.settingsSet('ArchiveFolder', self.archiveFolder());
+
+				Remote.saveSystemFolders(Utils.emptyFunction, {
+					'SentFolder': self.sentFolder(),
+					'DraftFolder': self.draftFolder(),
+					'SpamFolder': self.spamFolder(),
+					'TrashFolder': self.trashFolder(),
+					'ArchiveFolder': self.archiveFolder(),
+					'NullFolder': 'NullFolder'
+				});
+
+			}, 1000);
+
+			fCallback = function () {
+
+				Settings.settingsSet('SentFolder', self.sentFolder());
+				Settings.settingsSet('DraftFolder', self.draftFolder());
+				Settings.settingsSet('SpamFolder', self.spamFolder());
+				Settings.settingsSet('TrashFolder', self.trashFolder());
+				Settings.settingsSet('ArchiveFolder', self.archiveFolder());
+
+				fSaveSystemFolders();
+			};
+
+			this.sentFolder.subscribe(fCallback);
+			this.draftFolder.subscribe(fCallback);
+			this.spamFolder.subscribe(fCallback);
+			this.trashFolder.subscribe(fCallback);
+			this.archiveFolder.subscribe(fCallback);
+
+			this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
+
+			kn.constructorEnd(this);
+		}
+
+		kn.extendAsViewModel(['View:Popup:FolderSystem', 'PopupsFolderSystemViewModel'], PopupsFolderSystemViewModel);
+		_.extend(PopupsFolderSystemViewModel.prototype, KnoinAbstractViewModel.prototype);
+
+		PopupsFolderSystemViewModel.prototype.sChooseOnText = '';
+		PopupsFolderSystemViewModel.prototype.sUnuseText = '';
+
+		/**
+		 * @param {number=} iNotificationType = Enums.SetSystemFoldersNotification.None
+		 */
+		PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType)
+		{
+			var sNotification = '';
+
+			iNotificationType = Utils.isUnd(iNotificationType) ? Enums.SetSystemFoldersNotification.None : iNotificationType;
+
+			switch (iNotificationType)
+			{
+				case Enums.SetSystemFoldersNotification.Sent:
+					sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT');
+					break;
+				case Enums.SetSystemFoldersNotification.Draft:
+					sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS');
+					break;
+				case Enums.SetSystemFoldersNotification.Spam:
+					sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM');
+					break;
+				case Enums.SetSystemFoldersNotification.Trash:
+					sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH');
+					break;
+				case Enums.SetSystemFoldersNotification.Archive:
+					sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE');
+					break;
+			}
+
+			this.notification(sNotification);
+		};
+
+		module.exports = PopupsFolderSystemViewModel;
+
+	}());
+
+/***/ },
+
+/***/ 30:
+/*!**************************************!*\
+  !*** ./dev/Storages/LocalStorage.js ***!
+  \**************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
+
+	(function () {
+
+		'use strict';
+
+		/**
+		 * @constructor
+		 */
+		function LocalStorage()
+		{
+			var
+				NextStorageDriver = __webpack_require__(/*! _ */ 2).find([
+					__webpack_require__(/*! Storage:LocalStorage:LocalStorage */ 91),
+					__webpack_require__(/*! Storage:LocalStorage:Cookie */ 90)
+				], function (NextStorageDriver) {
+					return NextStorageDriver && NextStorageDriver.supported();
+				})
+			;
+
+			this.oDriver = null;
+
+			if (NextStorageDriver)
+			{
+				this.oDriver = new NextStorageDriver();
+			}
+		}
+
+		/**
+		 * @type {LocalStorageDriver|CookieDriver|null}
+		 */
+		LocalStorage.prototype.oDriver = null;
+
+		/**
+		 * @param {number} iKey
+		 * @param {*} mData
+		 * @return {boolean}
+		 */
+		LocalStorage.prototype.set = function (iKey, mData)
+		{
+			return this.oDriver ? this.oDriver.set('p' + iKey, mData) : false;
+		};
+
+		/**
+		 * @param {number} iKey
+		 * @return {*}
+		 */
+		LocalStorage.prototype.get = function (iKey)
+		{
+			return this.oDriver ? this.oDriver.get('p' + iKey) : null;
+		};
+
+		module.exports = new LocalStorage();
+
+	}());
+
+/***/ },
+
+/***/ 33:
+/*!***********************!*\
+  !*** external "JSON" ***!
+  \***********************/
+/***/ function(module, exports, __webpack_require__) {
+
+	module.exports = JSON;
+
+/***/ },
+
+/***/ 38:
+/*!************************************!*\
+  !*** ./dev/Models/MessageModel.js ***!
+  \************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	
+	(function () {
+
+		'use strict';
+
+		var
+			window = __webpack_require__(/*! window */ 12),
+			_ = __webpack_require__(/*! _ */ 2),
+			$ = __webpack_require__(/*! $ */ 14),
+			ko = __webpack_require__(/*! ko */ 3),
+			moment = __webpack_require__(/*! moment */ 25),
+
+			Enums = __webpack_require__(/*! Common/Enums */ 6),
+			Utils = __webpack_require__(/*! Common/Utils */ 1),
+			Globals = __webpack_require__(/*! Common/Globals */ 7),
+			LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11),
+
+			EmailModel = __webpack_require__(/*! Model:Email */ 23),
+			AttachmentModel = __webpack_require__(/*! Model:Attachment */ 52)
+		;
+
+		/**
+		* @constructor
+		*/
+		function MessageModel()
+		{
+			this.folderFullNameRaw = '';
+			this.uid = '';
+			this.hash = '';
+			this.requestHash = '';
+			this.subject = ko.observable('');
+			this.subjectPrefix = ko.observable('');
+			this.subjectSuffix = ko.observable('');
+			this.size = ko.observable(0);
+			this.dateTimeStampInUTC = ko.observable(0);
+			this.priority = ko.observable(Enums.MessagePriority.Normal);
+
+			this.proxy = false;
+
+			this.fromEmailString = ko.observable('');
+			this.fromClearEmailString = ko.observable('');
+			this.toEmailsString = ko.observable('');
+			this.toClearEmailsString = ko.observable('');
+
+			this.senderEmailsString = ko.observable('');
+			this.senderClearEmailsString = ko.observable('');
+
+			this.emails = [];
+
+			this.from = [];
+			this.to = [];
+			this.cc = [];
+			this.bcc = [];
+			this.replyTo = [];
+			this.deliveredTo = [];
+
+			this.newForAnimation = ko.observable(false);
+
+			this.deleted = ko.observable(false);
+			this.unseen = ko.observable(false);
+			this.flagged = ko.observable(false);
+			this.answered = ko.observable(false);
+			this.forwarded = ko.observable(false);
+			this.isReadReceipt = ko.observable(false);
+
+			this.focused = ko.observable(false);
+			this.selected = ko.observable(false);
+			this.checked = ko.observable(false);
+			this.hasAttachments = ko.observable(false);
+			this.attachmentsMainType = ko.observable('');
+			
+			this.moment = ko.observable(moment(moment.unix(0)));
+			
+			this.attachmentIconClass = ko.computed(function () {
+				var sClass = '';
+				if (this.hasAttachments())
+				{
+					sClass = 'icon-attachment';
+					switch (this.attachmentsMainType())
+					{
+						case 'image':
+							sClass = 'icon-image';
+							break;
+						case 'archive':
+							sClass = 'icon-file-zip';
+							break;
+						case 'doc':
+							sClass = 'icon-file-text';
+							break;
+		 //				case 'pdf':
+		 //					sClass = 'icon-file-pdf';
+		 //					break;
+					}
+				}
+				return sClass;
+			}, this);
+
+			this.fullFormatDateValue = ko.computed(function () {
+				return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC());
+			}, this);
+
+			this.momentDate = Utils.createMomentDate(this);
+			this.momentShortDate = Utils.createMomentShortDate(this);
+
+			this.dateTimeStampInUTC.subscribe(function (iValue) {
+				var iNow = moment().unix();
+				this.moment(moment.unix(iNow < iValue ? iNow : iValue));
+			}, this);
+
+			this.body = null;
+			this.plainRaw = '';
+			this.isHtml = ko.observable(false);
+			this.hasImages = ko.observable(false);
+			this.attachments = ko.observableArray([]);
+
+			this.isPgpSigned = ko.observable(false);
+			this.isPgpEncrypted = ko.observable(false);
+			this.pgpSignedVerifyStatus = ko.observable(Enums.SignedVerifyStatus.None);
+			this.pgpSignedVerifyUser = ko.observable('');
+
+			this.priority = ko.observable(Enums.MessagePriority.Normal);
+			this.readReceipt = ko.observable('');
+
+			this.aDraftInfo = [];
+			this.sMessageId = '';
+			this.sInReplyTo = '';
+			this.sReferences = '';
+
+			this.parentUid = ko.observable(0);
+			this.threads = ko.observableArray([]);
+			this.threadsLen = ko.observable(0);
+			this.hasUnseenSubMessage = ko.observable(false);
+			this.hasFlaggedSubMessage = ko.observable(false);
+
+			this.lastInCollapsedThread = ko.observable(false);
+			this.lastInCollapsedThreadLoading = ko.observable(false);
+
+			this.threadsLenResult = ko.computed(function () {
+				var iCount = this.threadsLen();
+				return 0 === this.parentUid() && 0 < iCount ? iCount + 1 : '';
+			}, this);
+		}
+
+		/**
+		* @static
+		* @param {AjaxJsonMessage} oJsonMessage
+		* @return {?MessageModel}
+		*/
+		MessageModel.newInstanceFromJson = function (oJsonMessage)
+		{
+			var oMessageModel = new MessageModel();
+			return oMessageModel.initByJson(oJsonMessage) ? oMessageModel : null;
+		};
+
+		/**
+		* @static
+		* @param {number} iTimeStampInUTC
+		* @return {string}
+		*/
+		MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC)
+		{
+			return 0 < iTimeStampInUTC ? moment.unix(iTimeStampInUTC).format('LLL') : '';
+		};
+
+		/**
+		* @static
+		* @param {Array} aEmail
+		* @param {boolean=} bFriendlyView
+		* @param {boolean=} bWrapWithLink = false
+		* @return {string}
+		*/
+		MessageModel.emailsToLine = function (aEmail, bFriendlyView, bWrapWithLink)
+		{
+			var
+				aResult = [],
+				iIndex = 0,
 				iLen = 0
 			;
 
-			this.selectedItemUseCallback = false;
-
-			this.focusedItem(null);
-			this.selectedItem(null);
-
-			if (Utils.isArray(aItems))
+			if (Utils.isNonEmptyArray(aEmail))
 			{
-				iLen = aCheckedCache.length;
-
-				_.each(aItems, function (oItem) {
-
-					var sUid = self.getItemUid(oItem);
-					aUids.push(sUid);
-
-					if (null !== mFocused && mFocused === sUid)
-					{
-						self.focusedItem(oItem);
-						mFocused = null;
-					}
-
-					if (0 < iLen && -1 < Utils.inArray(sUid, aCheckedCache))
-					{
-						bChecked = true;
-						oItem.checked(true);
-						iLen--;
-					}
-
-					if (!bChecked && null !== mSelected && mSelected === sUid)
-					{
-						bSelected = true;
-						self.selectedItem(oItem);
-						mSelected = null;
-					}
-				});
-
-				this.selectedItemUseCallback = true;
-
-				if (!bChecked && !bSelected && this.bAutoSelect)
+				for (iIndex = 0, iLen = aEmail.length; iIndex < iLen; iIndex++)
 				{
-					if (self.focusedItem())
-					{
-						self.selectedItem(self.focusedItem());
-					}
-					else if (0 < aItems.length)
-					{
-						if (null !== mNextFocused)
-						{
-							bGetNext = false;
-							mNextFocused = _.find(aCache, function (sUid) {
-								if (bGetNext && -1 < Utils.inArray(sUid, aUids))
-								{
-									return sUid;
-								}
-								else if (mNextFocused === sUid)
-								{
-									bGetNext = true;
-								}
-								return false;
-							});
-
-							if (mNextFocused)
-							{
-								oTemp = _.find(aItems, function (oItem) {
-									return mNextFocused === self.getItemUid(oItem);
-								});
-							}
-						}
-
-						self.selectedItem(oTemp || null);
-						self.focusedItem(self.selectedItem());
-					}
+					aResult.push(aEmail[iIndex].toLine(bFriendlyView, bWrapWithLink));
 				}
 			}
 
-			aCache = [];
-			aCheckedCache = [];
-			mFocused = null;
-			mSelected = null;
-
-		}, this);
-	}
-
-	Selector.prototype.itemSelected = function (oItem)
-	{
-		if (this.isListChecked())
-		{
-			if (!oItem)
-			{
-				(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem || null);
-			}
-		}
-		else
-		{
-			if (oItem)
-			{
-				(this.oCallbacks['onItemSelect'] || this.emptyFunction)(oItem);
-			}
-		}
-	};
-
-	Selector.prototype.goDown = function (bForceSelect)
-	{
-		this.newSelectPosition(Enums.EventKeyCode.Down, false, bForceSelect);
-	};
-
-	Selector.prototype.goUp = function (bForceSelect)
-	{
-		this.newSelectPosition(Enums.EventKeyCode.Up, false, bForceSelect);
-	};
-
-	Selector.prototype.init = function (oContentVisible, oContentScrollable, sKeyScope)
-	{
-		this.oContentVisible = oContentVisible;
-		this.oContentScrollable = oContentScrollable;
-
-		sKeyScope = sKeyScope || 'all';
-
-		if (this.oContentVisible && this.oContentScrollable)
-		{
-			var
-				self = this
-			;
-
-			$(this.oContentVisible)
-				.on('selectstart', function (oEvent) {
-					if (oEvent && oEvent.preventDefault)
-					{
-						oEvent.preventDefault();
-					}
-				})
-				.on('click', this.sItemSelector, function (oEvent) {
-					self.actionClick(ko.dataFor(this), oEvent);
-				})
-				.on('click', this.sItemCheckedSelector, function (oEvent) {
-					var oItem = ko.dataFor(this);
-					if (oItem)
-					{
-						if (oEvent && oEvent.shiftKey)
-						{
-							self.actionClick(oItem, oEvent);
-						}
-						else
-						{
-							self.focusedItem(oItem);
-							oItem.checked(!oItem.checked());
-						}
-					}
-				})
-			;
-
-			key('enter', sKeyScope, function () {
-				if (self.focusedItem() && !self.focusedItem().selected())
-				{
-					self.actionClick(self.focusedItem());
-					return false;
-				}
-
-				return true;
-			});
-
-			key('ctrl+up, command+up, ctrl+down, command+down', sKeyScope, function () {
-				return false;
-			});
-
-			key('up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space', sKeyScope, function (event, handler) {
-				if (event && handler && handler.shortcut)
-				{
-					// TODO
-					var iKey = 0;
-					switch (handler.shortcut)
-					{
-						case 'up':
-						case 'shift+up':
-							iKey = Enums.EventKeyCode.Up;
-							break;
-						case 'down':
-						case 'shift+down':
-							iKey = Enums.EventKeyCode.Down;
-							break;
-						case 'insert':
-							iKey = Enums.EventKeyCode.Insert;
-							break;
-						case 'space':
-							iKey = Enums.EventKeyCode.Space;
-							break;
-						case 'home':
-							iKey = Enums.EventKeyCode.Home;
-							break;
-						case 'end':
-							iKey = Enums.EventKeyCode.End;
-							break;
-						case 'pageup':
-							iKey = Enums.EventKeyCode.PageUp;
-							break;
-						case 'pagedown':
-							iKey = Enums.EventKeyCode.PageDown;
-							break;
-					}
-
-					if (0 < iKey)
-					{
-						self.newSelectPosition(iKey, key.shift);
-						return false;
-					}
-				}
-			});
-		}
-	};
-
-	Selector.prototype.autoSelect = function (bValue)
-	{
-		this.bAutoSelect = !!bValue;
-	};
-
-	/**
-	 * @param {Object} oItem
-	 * @returns {string}
-	 */
-	Selector.prototype.getItemUid = function (oItem)
-	{
-		var
-			sUid = '',
-			fGetItemUidCallback = this.oCallbacks['onItemGetUid'] || null
-		;
-
-		if (fGetItemUidCallback && oItem)
-		{
-			sUid = fGetItemUidCallback(oItem);
-		}
-
-		return sUid.toString();
-	};
-
-	/**
-	 * @param {number} iEventKeyCode
-	 * @param {boolean} bShiftKey
-	 * @param {boolean=} bForceSelect = false
-	 */
-	Selector.prototype.newSelectPosition = function (iEventKeyCode, bShiftKey, bForceSelect)
-	{
-		var
-			iIndex = 0,
-			iPageStep = 10,
-			bNext = false,
-			bStop = false,
-			oResult = null,
-			aList = this.list(),
-			iListLen = aList ? aList.length : 0,
-			oFocused = this.focusedItem()
-		;
-
-		if (0 < iListLen)
-		{
-			if (!oFocused)
-			{
-				if (Enums.EventKeyCode.Down === iEventKeyCode || Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode || Enums.EventKeyCode.Home === iEventKeyCode || Enums.EventKeyCode.PageUp === iEventKeyCode)
-				{
-					oResult = aList[0];
-				}
-				else if (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.End === iEventKeyCode || Enums.EventKeyCode.PageDown === iEventKeyCode)
-				{
-					oResult = aList[aList.length - 1];
-				}
-			}
-			else if (oFocused)
-			{
-				if (Enums.EventKeyCode.Down === iEventKeyCode || Enums.EventKeyCode.Up === iEventKeyCode ||  Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode)
-				{
-					_.each(aList, function (oItem) {
-						if (!bStop)
-						{
-							switch (iEventKeyCode) {
-							case Enums.EventKeyCode.Up:
-								if (oFocused === oItem)
-								{
-									bStop = true;
-								}
-								else
-								{
-									oResult = oItem;
-								}
-								break;
-							case Enums.EventKeyCode.Down:
-							case Enums.EventKeyCode.Insert:
-								if (bNext)
-								{
-									oResult = oItem;
-									bStop = true;
-								}
-								else if (oFocused === oItem)
-								{
-									bNext = true;
-								}
-								break;
-							}
-						}
-					});
-				}
-				else if (Enums.EventKeyCode.Home === iEventKeyCode || Enums.EventKeyCode.End === iEventKeyCode)
-				{
-					if (Enums.EventKeyCode.Home === iEventKeyCode)
-					{
-						oResult = aList[0];
-					}
-					else if (Enums.EventKeyCode.End === iEventKeyCode)
-					{
-						oResult = aList[aList.length - 1];
-					}
-				}
-				else if (Enums.EventKeyCode.PageDown === iEventKeyCode)
-				{
-					for (; iIndex < iListLen; iIndex++)
-					{
-						if (oFocused === aList[iIndex])
-						{
-							iIndex += iPageStep;
-							iIndex = iListLen - 1 < iIndex ? iListLen - 1 : iIndex;
-							oResult = aList[iIndex];
-							break;
-						}
-					}
-				}
-				else if (Enums.EventKeyCode.PageUp === iEventKeyCode)
-				{
-					for (iIndex = iListLen; iIndex >= 0; iIndex--)
-					{
-						if (oFocused === aList[iIndex])
-						{
-							iIndex -= iPageStep;
-							iIndex = 0 > iIndex ? 0 : iIndex;
-							oResult = aList[iIndex];
-							break;
-						}
-					}
-				}
-			}
-		}
-
-		if (oResult)
-		{
-			this.focusedItem(oResult);
-
-			if (oFocused)
-			{
-				if (bShiftKey)
-				{
-					if (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.Down === iEventKeyCode)
-					{
-						oFocused.checked(!oFocused.checked());
-					}
-				}
-				else if (Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode)
-				{
-					oFocused.checked(!oFocused.checked());
-				}
-			}
-
-			if ((this.bAutoSelect || !!bForceSelect) &&
-				!this.isListChecked() && Enums.EventKeyCode.Space !== iEventKeyCode)
-			{
-				this.selectedItem(oResult);
-			}
-
-			this.scrollToFocused();
-		}
-		else if (oFocused)
-		{
-			if (bShiftKey && (Enums.EventKeyCode.Up === iEventKeyCode || Enums.EventKeyCode.Down === iEventKeyCode))
-			{
-				oFocused.checked(!oFocused.checked());
-			}
-			else if (Enums.EventKeyCode.Insert === iEventKeyCode || Enums.EventKeyCode.Space === iEventKeyCode)
-			{
-				oFocused.checked(!oFocused.checked());
-			}
-
-			this.focusedItem(oFocused);
-		}
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	Selector.prototype.scrollToFocused = function ()
-	{
-		if (!this.oContentVisible || !this.oContentScrollable)
-		{
-			return false;
-		}
-
-		var
-			iOffset = 20,
-			oFocused = $(this.sItemFocusedSelector, this.oContentScrollable),
-			oPos = oFocused.position(),
-			iVisibleHeight = this.oContentVisible.height(),
-			iFocusedHeight = oFocused.outerHeight()
-		;
-
-		if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight))
-		{
-			if (oPos.top < 0)
-			{
-				this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
-			}
-			else
-			{
-				this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
-			}
-
-			return true;
-		}
-
-		return false;
-	};
-
-	/**
-	 * @param {boolean=} bFast = false
-	 * @return {boolean}
-	 */
-	Selector.prototype.scrollToTop = function (bFast)
-	{
-		if (!this.oContentVisible || !this.oContentScrollable)
-		{
-			return false;
-		}
-
-		if (bFast)
-		{
-			this.oContentScrollable.scrollTop(0);
-		}
-		else
-		{
-			this.oContentScrollable.stop().animate({'scrollTop': 0}, 200);
-		}
-
-		return true;
-	};
-
-	Selector.prototype.eventClickFunction = function (oItem, oEvent)
-	{
-		var
-			sUid = this.getItemUid(oItem),
-			iIndex = 0,
-			iLength = 0,
-			oListItem = null,
-			sLineUid = '',
-			bChangeRange = false,
-			bIsInRange = false,
-			aList = [],
-			bChecked = false
-		;
-
-		if (oEvent && oEvent.shiftKey)
-		{
-			if ('' !== sUid && '' !== this.sLastUid && sUid !== this.sLastUid)
-			{
-				aList = this.list();
-				bChecked = oItem.checked();
-
-				for (iIndex = 0, iLength = aList.length; iIndex < iLength; iIndex++)
-				{
-					oListItem = aList[iIndex];
-					sLineUid = this.getItemUid(oListItem);
-
-					bChangeRange = false;
-					if (sLineUid === this.sLastUid || sLineUid === sUid)
-					{
-						bChangeRange = true;
-					}
-
-					if (bChangeRange)
-					{
-						bIsInRange = !bIsInRange;
-					}
-
-					if (bIsInRange || bChangeRange)
-					{
-						oListItem.checked(bChecked);
-					}
-				}
-			}
-		}
-
-		this.sLastUid = '' === sUid ? '' : sUid;
-	};
-
-	/**
-	 * @param {Object} oItem
-	 * @param {Object=} oEvent
-	 */
-	Selector.prototype.actionClick = function (oItem, oEvent)
-	{
-		if (oItem)
-		{
-			var
-				bClick = true,
-				sUid = this.getItemUid(oItem)
-			;
-
-			if (oEvent)
-			{
-				if (oEvent.shiftKey && !oEvent.ctrlKey && !oEvent.altKey)
-				{
-					bClick = false;
-					if ('' === this.sLastUid)
-					{
-						this.sLastUid = sUid;
-					}
-
-					oItem.checked(!oItem.checked());
-					this.eventClickFunction(oItem, oEvent);
-
-					this.focusedItem(oItem);
-				}
-				else if (oEvent.ctrlKey && !oEvent.shiftKey && !oEvent.altKey)
-				{
-					bClick = false;
-					this.focusedItem(oItem);
-
-					if (this.selectedItem() && oItem !== this.selectedItem())
-					{
-						this.selectedItem().checked(true);
-					}
-
-					oItem.checked(!oItem.checked());
-				}
-			}
-
-			if (bClick)
-			{
-				this.focusedItem(oItem);
-				this.selectedItem(oItem);
-
-				this.scrollToFocused();
-			}
-		}
-	};
-
-	Selector.prototype.on = function (sEventName, fCallback)
-	{
-		this.oCallbacks[sEventName] = fCallback;
-	};
-
-	module.exports = Selector;
-
-}(module, require));
-},{"$":20,"Enums":7,"Utils":14,"_":25,"key":21,"ko":22}],14:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		Utils = {},
-
-		window = require('window'),
-		_ = require('_'),
-		$ = require('$'),
-		ko = require('ko'),
-
-		Enums = require('Enums'),
-		Consts = require('Consts'),
-		Globals = require('Globals')
-	;
-	
-	Utils.trim = $.trim;
-	Utils.inArray = $.inArray;
-	Utils.isArray = _.isArray;
-	Utils.isFunc = _.isFunction;
-	Utils.isUnd = _.isUndefined;
-	Utils.isNull = _.isNull;
-	Utils.emptyFunction = function () {};
-
-	/**
-	 * @param {*} oValue
-	 * @return {boolean}
-	 */
-	Utils.isNormal = function (oValue)
-	{
-		return !Utils.isUnd(oValue) && !Utils.isNull(oValue);
-	};
-
-	Utils.windowResize = _.debounce(function (iTimeout) {
-		if (Utils.isUnd(iTimeout))
-		{
-			Globals.$win.resize();
-		}
-		else
-		{
-			window.setTimeout(function () {
-				Globals.$win.resize();
-			}, iTimeout);
-		}
-	}, 50);
-
-	/**
-	 * @param {(string|number)} mValue
-	 * @param {boolean=} bIncludeZero
-	 * @return {boolean}
-	 */
-	Utils.isPosNumeric = function (mValue, bIncludeZero)
-	{
-		return Utils.isNormal(mValue) ?
-			((Utils.isUnd(bIncludeZero) ? true : !!bIncludeZero) ?
-				(/^[0-9]*$/).test(mValue.toString()) :
-				(/^[1-9]+[0-9]*$/).test(mValue.toString())) :
-			false;
-	};
-
-	/**
-	 * @param {*} iValue
-	 * @param {number=} iDefault = 0
-	 * @return {number}
-	 */
-	Utils.pInt = function (iValue, iDefault)
-	{
-		var iResult = Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : (iDefault || 0);
-		return window.isNaN(iResult) ? (iDefault || 0) : iResult;
-	};
-
-	/**
-	 * @param {*} mValue
-	 * @return {string}
-	 */
-	Utils.pString = function (mValue)
-	{
-		return Utils.isNormal(mValue) ? '' + mValue : '';
-	};
-
-	/**
-	 * @param {*} aValue
-	 * @return {boolean}
-	 */
-	Utils.isNonEmptyArray = function (aValue)
-	{
-		return Utils.isArray(aValue) && 0 < aValue.length;
-	};
-
-	/**
-	 * @return {*|null}
-	 */
-	Utils.notificationClass = function ()
-	{
-		return window.Notification && window.Notification.requestPermission ? window.Notification : null;
-	};
-
-	/**
-	 * @param {string} sQueryString
-	 * @return {Object}
-	 */
-	Utils.simpleQueryParser = function (sQueryString)
-	{
-		var
-			oParams = {},
-			aQueries = [],
-			aTemp = [],
-			iIndex = 0,
-			iLen = 0
-		;
-
-		aQueries = sQueryString.split('&');
-		for (iIndex = 0, iLen = aQueries.length; iIndex < iLen; iIndex++)
-		{
-			aTemp = aQueries[iIndex].split('=');
-			oParams[window.decodeURIComponent(aTemp[0])] = window.decodeURIComponent(aTemp[1]);
-		}
-
-		return oParams;
-	};
-
-	/**
-	 * @param {string} sMailToUrl
-	 * @param {Function} PopupComposeVoreModel
-	 * @returns {boolean}
-	 */
-	Utils.mailToHelper = function (sMailToUrl, PopupComposeVoreModel)
-	{
-		if (sMailToUrl && 'mailto:' === sMailToUrl.toString().substr(0, 7).toLowerCase())
-		{
-			sMailToUrl = sMailToUrl.toString().substr(7);
-
-			var
-				oParams = {},
-				oEmailModel = null,
-				sEmail = sMailToUrl.replace(/\?.+$/, ''),
-				sQueryString = sMailToUrl.replace(/^[^\?]*\?/, ''),
-				EmailModel = require('Model:Email')
-			;
-
-			oEmailModel = new EmailModel();
-			oEmailModel.parse(window.decodeURIComponent(sEmail));
-
-			if (oEmailModel && oEmailModel.email)
-			{
-				oParams = Utils.simpleQueryParser(sQueryString);
-
-				require('App:Knoin').showScreenPopup(PopupComposeVoreModel, [Enums.ComposeType.Empty, null, [oEmailModel],
-					Utils.isUnd(oParams.subject) ? null : Utils.pString(oParams.subject),
-					Utils.isUnd(oParams.body) ? null : Utils.plainToHtml(Utils.pString(oParams.body))
-				]);
-			}
-
-			return true;
-		}
-
-		return false;
-	};
-
-	/**
-	 * @param {string} sValue
-	 * @param {string} sHash
-	 * @param {string} sKey
-	 * @param {string} sLongKey
-	 * @return {string|boolean}
-	 */
-	Utils.rsaEncode = function (sValue, sHash, sKey, sLongKey)
-	{
-		if (window.crypto && window.crypto.getRandomValues && window.RSAKey && sHash && sKey && sLongKey)
-		{
-			var oRsa = new window.RSAKey();
-			oRsa.setPublic(sLongKey, sKey);
-
-			sValue = oRsa.encrypt(Utils.fakeMd5() + ':' + sValue + ':' + Utils.fakeMd5());
-			if (false !== sValue)
-			{
-				return 'rsa:' + sHash + ':' + sValue;
-			}
-		}
-
-		return false;
-	};
-
-	Utils.rsaEncode.supported = !!(window.crypto && window.crypto.getRandomValues && window.RSAKey);
-
-	/**
-	 * @param {string} sPath
-	 * @param {*=} oObject
-	 * @param {Object=} oObjectToExportTo
-	 */
-	Utils.exportPath = function (sPath, oObject, oObjectToExportTo)
-	{
-		var
-			sPart = null,
-			aParts = sPath.split('.'),
-			oCur = oObjectToExportTo || window
-		;
-
-		for (; aParts.length && (sPart = aParts.shift());)
-		{
-			if (!aParts.length && !Utils.isUnd(oObject))
-			{
-				oCur[sPart] = oObject;
-			}
-			else if (oCur[sPart])
-			{
-				oCur = oCur[sPart];
-			}
-			else
-			{
-				oCur = oCur[sPart] = {};
-			}
-		}
-	};
-
-	/**
-	 * @param {Object} oObject
-	 * @param {string} sName
-	 * @param {*} mValue
-	 */
-	Utils.pImport = function (oObject, sName, mValue)
-	{
-		oObject[sName] = mValue;
-	};
-
-	/**
-	 * @param {Object} oObject
-	 * @param {string} sName
-	 * @param {*} mDefault
-	 * @return {*}
-	 */
-	Utils.pExport = function (oObject, sName, mDefault)
-	{
-		return Utils.isUnd(oObject[sName]) ? mDefault : oObject[sName];
-	};
-
-	/**
-	 * @param {string} sText
-	 * @return {string}
-	 */
-	Utils.encodeHtml = function (sText)
-	{
-		return Utils.isNormal(sText) ? sText.toString()
-			.replace(/&/g, '&').replace(//g, '>')
-			.replace(/"/g, '"').replace(/'/g, ''') : '';
-	};
-
-	/**
-	 * @param {string} sText
-	 * @param {number=} iLen
-	 * @return {string}
-	 */
-	Utils.splitPlainText = function (sText, iLen)
-	{
-		var
-			sPrefix = '',
-			sSubText = '',
-			sResult = sText,
-			iSpacePos = 0,
-			iNewLinePos = 0
-		;
-
-		iLen = Utils.isUnd(iLen) ? 100 : iLen;
-
-		while (sResult.length > iLen)
-		{
-			sSubText = sResult.substring(0, iLen);
-			iSpacePos = sSubText.lastIndexOf(' ');
-			iNewLinePos = sSubText.lastIndexOf('\n');
-
-			if (-1 !== iNewLinePos)
-			{
-				iSpacePos = iNewLinePos;
-			}
-
-			if (-1 === iSpacePos)
-			{
-				iSpacePos = iLen;
-			}
-
-			sPrefix += sSubText.substring(0, iSpacePos) + '\n';
-			sResult = sResult.substring(iSpacePos + 1);
-		}
-
-		return sPrefix + sResult;
-	};
-
-	Utils.timeOutAction = (function () {
-
-		var
-			oTimeOuts = {}
-		;
-
-		return function (sAction, fFunction, iTimeOut)
-		{
-			if (Utils.isUnd(oTimeOuts[sAction]))
-			{
-				oTimeOuts[sAction] = 0;
-			}
-
-			window.clearTimeout(oTimeOuts[sAction]);
-			oTimeOuts[sAction] = window.setTimeout(fFunction, iTimeOut);
-		};
-	}());
-
-	Utils.timeOutActionSecond = (function () {
-
-		var
-			oTimeOuts = {}
-		;
-
-		return function (sAction, fFunction, iTimeOut)
-		{
-			if (!oTimeOuts[sAction])
-			{
-				oTimeOuts[sAction] = window.setTimeout(function () {
-					fFunction();
-					oTimeOuts[sAction] = 0;
-				}, iTimeOut);
-			}
-		};
-	}());
-
-	Utils.audio = (function () {
-
-		var
-			oAudio = false
-		;
-
-		return function (sMp3File, sOggFile) {
-
-			if (false === oAudio)
-			{
-				if (Globals.bIsiOSDevice)
-				{
-					oAudio = null;
-				}
-				else
-				{
-					var
-						bCanPlayMp3	= false,
-						bCanPlayOgg	= false,
-						oAudioLocal = window.Audio ? new window.Audio() : null
-					;
-
-					if (oAudioLocal && oAudioLocal.canPlayType && oAudioLocal.play)
-					{
-						bCanPlayMp3 = '' !== oAudioLocal.canPlayType('audio/mpeg; codecs="mp3"');
-						if (!bCanPlayMp3)
-						{
-							bCanPlayOgg = '' !== oAudioLocal.canPlayType('audio/ogg; codecs="vorbis"');
-						}
-
-						if (bCanPlayMp3 || bCanPlayOgg)
-						{
-							oAudio = oAudioLocal;
-							oAudio.preload = 'none';
-							oAudio.loop = false;
-							oAudio.autoplay = false;
-							oAudio.muted = false;
-							oAudio.src = bCanPlayMp3 ? sMp3File : sOggFile;
-						}
-						else
-						{
-							oAudio = null;
-						}
-					}
-					else
-					{
-						oAudio = null;
-					}
-				}
-			}
-
-			return oAudio;
-		};
-	}());
-
-	/**
-	 * @param {(Object|null|undefined)} oObject
-	 * @param {string} sProp
-	 * @return {boolean}
-	 */
-	Utils.hos = function (oObject, sProp)
-	{
-		return oObject && window.Object && window.Object.hasOwnProperty ? window.Object.hasOwnProperty.call(oObject, sProp) : false;
-	};
-
-	/**
-	 * @param {string} sKey
-	 * @param {Object=} oValueList
-	 * @param {string=} sDefaulValue
-	 * @return {string}
-	 */
-	Utils.i18n = function (sKey, oValueList, sDefaulValue)
-	{
-		var
-			sValueName = '',
-			sResult = Utils.isUnd(Globals.oI18N[sKey]) ? (Utils.isUnd(sDefaulValue) ? sKey : sDefaulValue) : Globals.oI18N[sKey]
-		;
-
-		if (!Utils.isUnd(oValueList) && !Utils.isNull(oValueList))
-		{
-			for (sValueName in oValueList)
-			{
-				if (Utils.hos(oValueList, sValueName))
-				{
-					sResult = sResult.replace('%' + sValueName + '%', oValueList[sValueName]);
-				}
-			}
-		}
-
-		return sResult;
-	};
-
-	/**
-	 * @param {Object} oElement
-	 */
-	Utils.i18nToNode = function (oElement)
-	{
-		_.defer(function () {
-			$('.i18n', oElement).each(function () {
-				var
-					jqThis = $(this),
-					sKey = ''
-				;
-
-				sKey = jqThis.data('i18n-text');
-				if (sKey)
-				{
-					jqThis.text(Utils.i18n(sKey));
-				}
-				else
-				{
-					sKey = jqThis.data('i18n-html');
-					if (sKey)
-					{
-						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)
-					{
-						jqThis.attr('title', Utils.i18n(sKey));
-					}
-				}
-			});
-		});
-	};
-
-	Utils.i18nReload = function ()
-	{
-		if (window['rainloopI18N'])
-		{
-			Globals.oI18N = window['rainloopI18N'] || {};
-
-			Utils.i18nToNode(Globals.$doc);
-
-			Globals.langChangeTrigger(!Globals.langChangeTrigger());
-		}
-
-		window['rainloopI18N'] = null;
-	};
-
-	/**
-	 * @param {Function} fCallback
-	 * @param {Object} oScope
-	 * @param {Function=} fLangCallback
-	 */
-	Utils.initOnStartOrLangChange = function (fCallback, oScope, fLangCallback)
-	{
-		if (fCallback)
-		{
-			fCallback.call(oScope);
-		}
-
-		if (fLangCallback)
-		{
-			Globals.langChangeTrigger.subscribe(function () {
-				if (fCallback)
-				{
-					fCallback.call(oScope);
-				}
-
-				fLangCallback.call(oScope);
-			});
-		}
-		else if (fCallback)
-		{
-			Globals.langChangeTrigger.subscribe(fCallback, oScope);
-		}
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	Utils.inFocus = function ()
-	{
-		if (window.document.activeElement)
-		{
-			if (Utils.isUnd(window.document.activeElement.__inFocusCache))
-			{
-				window.document.activeElement.__inFocusCache = $(window.document.activeElement).is('input,textarea,iframe,.cke_editable');
-			}
-
-			return !!window.document.activeElement.__inFocusCache;
-		}
-
-		return false;
-	};
-
-	Utils.removeInFocus = function ()
-	{
-		if (window.document && window.document.activeElement && window.document.activeElement.blur)
-		{
-			var oA = $(window.document.activeElement);
-			if (oA.is('input,textarea'))
-			{
-				window.document.activeElement.blur();
-			}
-		}
-	};
-
-	Utils.removeSelection = function ()
-	{
-		if (window && window.getSelection)
-		{
-			var oSel = window.getSelection();
-			if (oSel && oSel.removeAllRanges)
-			{
-				oSel.removeAllRanges();
-			}
-		}
-		else if (window.document && window.document.selection && window.document.selection.empty)
-		{
-			window.document.selection.empty();
-		}
-	};
-
-	/**
-	 * @param {string} sPrefix
-	 * @param {string} sSubject
-	 * @return {string}
-	 */
-	Utils.replySubjectAdd = function (sPrefix, sSubject)
-	{
-		sPrefix = Utils.trim(sPrefix.toUpperCase());
-		sSubject = Utils.trim(sSubject.replace(/[\s]+/g, ' '));
-
-		var
-			bDrop = false,
-			aSubject = [],
-			bRe = 'RE' === sPrefix,
-			bFwd = 'FWD' === sPrefix,
-			bPrefixIsRe = !bFwd
-		;
-
-		if ('' !== sSubject)
-		{
-			_.each(sSubject.split(':'), function (sPart) {
-				var sTrimmedPart = Utils.trim(sPart);
-				if (!bDrop && (/^(RE|FWD)$/i.test(sTrimmedPart) || /^(RE|FWD)[\[\(][\d]+[\]\)]$/i.test(sTrimmedPart)))
-				{
-					if (!bRe)
-					{
-						bRe = !!(/^RE/i.test(sTrimmedPart));
-					}
-
-					if (!bFwd)
-					{
-						bFwd = !!(/^FWD/i.test(sTrimmedPart));
-					}
-				}
-				else
-				{
-					aSubject.push(sPart);
-					bDrop = true;
-				}
-			});
-		}
-
-		if (bPrefixIsRe)
-		{
-			bRe = false;
-		}
-		else
-		{
-			bFwd = false;
-		}
-
-		return Utils.trim(
-			(bPrefixIsRe ? 'Re: ' : 'Fwd: ') +
-			(bRe ? 'Re: ' : '') +
-			(bFwd ? 'Fwd: ' : '') +
-			Utils.trim(aSubject.join(':'))
-		);
-	};
-
-	/**
-	 * @param {number} iNum
-	 * @param {number} iDec
-	 * @return {number}
-	 */
-	Utils.roundNumber = function (iNum, iDec)
-	{
-		return window.Math.round(iNum * window.Math.pow(10, iDec)) / window.Math.pow(10, iDec);
-	};
-
-	/**
-	 * @param {(number|string)} iSizeInBytes
-	 * @return {string}
-	 */
-	Utils.friendlySize = function (iSizeInBytes)
-	{
-		iSizeInBytes = Utils.pInt(iSizeInBytes);
-
-		if (iSizeInBytes >= 1073741824)
-		{
-			return Utils.roundNumber(iSizeInBytes / 1073741824, 1) + 'GB';
-		}
-		else if (iSizeInBytes >= 1048576)
-		{
-			return Utils.roundNumber(iSizeInBytes / 1048576, 1) + 'MB';
-		}
-		else if (iSizeInBytes >= 1024)
-		{
-			return Utils.roundNumber(iSizeInBytes / 1024, 0) + 'KB';
-		}
-
-		return iSizeInBytes + 'B';
-	};
-
-	/**
-	 * @param {string} sDesc
-	 */
-	Utils.log = function (sDesc)
-	{
-		if (window.console && window.console.log)
-		{
-			window.console.log(sDesc);
-		}
-	};
-
-	/**
-	 * @param {number} iCode
-	 * @param {*=} mMessage = ''
-	 * @return {string}
-	 */
-	Utils.getNotification = function (iCode, mMessage)
-	{
-		iCode = Utils.pInt(iCode);
-		if (Enums.Notification.ClientViewError === iCode && mMessage)
-		{
-			return mMessage;
-		}
-
-		return Utils.isUnd(Globals.oNotificationI18N[iCode]) ? '' : Globals.oNotificationI18N[iCode];
-	};
-
-	Utils.initNotificationLanguage = function ()
-	{
-		var oN = Globals.oNotificationI18N || {};
-		oN[Enums.Notification.InvalidToken] = Utils.i18n('NOTIFICATIONS/INVALID_TOKEN');
-		oN[Enums.Notification.AuthError] = Utils.i18n('NOTIFICATIONS/AUTH_ERROR');
-		oN[Enums.Notification.AccessError] = Utils.i18n('NOTIFICATIONS/ACCESS_ERROR');
-		oN[Enums.Notification.ConnectionError] = Utils.i18n('NOTIFICATIONS/CONNECTION_ERROR');
-		oN[Enums.Notification.CaptchaError] = Utils.i18n('NOTIFICATIONS/CAPTCHA_ERROR');
-		oN[Enums.Notification.SocialFacebookLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE');
-		oN[Enums.Notification.SocialTwitterLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE');
-		oN[Enums.Notification.SocialGoogleLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE');
-		oN[Enums.Notification.DomainNotAllowed] = Utils.i18n('NOTIFICATIONS/DOMAIN_NOT_ALLOWED');
-		oN[Enums.Notification.AccountNotAllowed] = Utils.i18n('NOTIFICATIONS/ACCOUNT_NOT_ALLOWED');
-
-		oN[Enums.Notification.AccountTwoFactorAuthRequired] = Utils.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED');
-		oN[Enums.Notification.AccountTwoFactorAuthError] = Utils.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR');
-
-		oN[Enums.Notification.CouldNotSaveNewPassword] = Utils.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD');
-		oN[Enums.Notification.CurrentPasswordIncorrect] = Utils.i18n('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT');
-		oN[Enums.Notification.NewPasswordShort] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_SHORT');
-		oN[Enums.Notification.NewPasswordWeak] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_WEAK');
-		oN[Enums.Notification.NewPasswordForbidden] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT');
-
-		oN[Enums.Notification.ContactsSyncError] = Utils.i18n('NOTIFICATIONS/CONTACTS_SYNC_ERROR');
-
-		oN[Enums.Notification.CantGetMessageList] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST');
-		oN[Enums.Notification.CantGetMessage] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE');
-		oN[Enums.Notification.CantDeleteMessage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_MESSAGE');
-		oN[Enums.Notification.CantMoveMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
-		oN[Enums.Notification.CantCopyMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
-
-		oN[Enums.Notification.CantSaveMessage] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_MESSAGE');
-		oN[Enums.Notification.CantSendMessage] = Utils.i18n('NOTIFICATIONS/CANT_SEND_MESSAGE');
-		oN[Enums.Notification.InvalidRecipients] = Utils.i18n('NOTIFICATIONS/INVALID_RECIPIENTS');
-
-		oN[Enums.Notification.CantCreateFolder] = Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER');
-		oN[Enums.Notification.CantRenameFolder] = Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER');
-		oN[Enums.Notification.CantDeleteFolder] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER');
-		oN[Enums.Notification.CantDeleteNonEmptyFolder] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER');
-		oN[Enums.Notification.CantSubscribeFolder] = Utils.i18n('NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER');
-		oN[Enums.Notification.CantUnsubscribeFolder] = Utils.i18n('NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER');
-
-		oN[Enums.Notification.CantSaveSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS');
-		oN[Enums.Notification.CantSavePluginSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS');
-
-		oN[Enums.Notification.DomainAlreadyExists] = Utils.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS');
-
-		oN[Enums.Notification.CantInstallPackage] = Utils.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE');
-		oN[Enums.Notification.CantDeletePackage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE');
-		oN[Enums.Notification.InvalidPluginPackage] = Utils.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE');
-		oN[Enums.Notification.UnsupportedPluginPackage] = Utils.i18n('NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE');
-
-		oN[Enums.Notification.LicensingServerIsUnavailable] = Utils.i18n('NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE');
-		oN[Enums.Notification.LicensingExpired] = Utils.i18n('NOTIFICATIONS/LICENSING_EXPIRED');
-		oN[Enums.Notification.LicensingBanned] = Utils.i18n('NOTIFICATIONS/LICENSING_BANNED');
-
-		oN[Enums.Notification.DemoSendMessageError] = Utils.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR');
-
-		oN[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS');
-
-		oN[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR');
-		oN[Enums.Notification.InvalidInputArgument] = Utils.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT');
-		oN[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
-		oN[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
-	};
-
-	/**
-	 * @param {*} mCode
-	 * @return {string}
-	 */
-	Utils.getUploadErrorDescByCode = function (mCode)
-	{
-		var sResult = '';
-		switch (Utils.pInt(mCode)) {
-		case Enums.UploadErrorCode.FileIsTooBig:
-			sResult = Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG');
-			break;
-		case Enums.UploadErrorCode.FilePartiallyUploaded:
-			sResult = Utils.i18n('UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED');
-			break;
-		case Enums.UploadErrorCode.FileNoUploaded:
-			sResult = Utils.i18n('UPLOAD/ERROR_NO_FILE_UPLOADED');
-			break;
-		case Enums.UploadErrorCode.MissingTempFolder:
-			sResult = Utils.i18n('UPLOAD/ERROR_MISSING_TEMP_FOLDER');
-			break;
-		case Enums.UploadErrorCode.FileOnSaveingError:
-			sResult = Utils.i18n('UPLOAD/ERROR_ON_SAVING_FILE');
-			break;
-		case Enums.UploadErrorCode.FileType:
-			sResult = Utils.i18n('UPLOAD/ERROR_FILE_TYPE');
-			break;
-		default:
-			sResult = Utils.i18n('UPLOAD/ERROR_UNKNOWN');
-			break;
-		}
-
-		return sResult;
-	};
-
-	/**
-	 * @param {?} oObject
-	 * @param {string} sMethodName
-	 * @param {Array=} aParameters
-	 * @param {number=} nDelay
-	 */
-	Utils.delegateRun = function (oObject, sMethodName, aParameters, nDelay)
-	{
-		if (oObject && oObject[sMethodName])
-		{
-			nDelay = Utils.pInt(nDelay);
-			if (0 >= nDelay)
-			{
-				oObject[sMethodName].apply(oObject, Utils.isArray(aParameters) ? aParameters : []);
-			}
-			else
-			{
-				_.delay(function () {
-					oObject[sMethodName].apply(oObject, Utils.isArray(aParameters) ? aParameters : []);
-				}, nDelay);
-			}
-		}
-	};
-
-	/**
-	 * @param {?} oEvent
-	 */
-	Utils.killCtrlAandS = function (oEvent)
-	{
-		oEvent = oEvent || window.event;
-		if (oEvent && oEvent.ctrlKey && !oEvent.shiftKey && !oEvent.altKey)
-		{
-			var
-				oSender = oEvent.target || oEvent.srcElement,
-				iKey = oEvent.keyCode || oEvent.which
-			;
-
-			if (iKey === Enums.EventKeyCode.S)
-			{
-				oEvent.preventDefault();
-				return;
-			}
-
-			if (oSender && oSender.tagName && oSender.tagName.match(/INPUT|TEXTAREA/i))
-			{
-				return;
-			}
-
-			if (iKey === Enums.EventKeyCode.A)
-			{
-				if (window.getSelection)
-				{
-					window.getSelection().removeAllRanges();
-				}
-				else if (window.document.selection && window.document.selection.clear)
-				{
-					window.document.selection.clear();
-				}
-
-				oEvent.preventDefault();
-			}
-		}
-	};
-
-	/**
-	 * @param {(Object|null|undefined)} oContext
-	 * @param {Function} fExecute
-	 * @param {(Function|boolean|null)=} fCanExecute
-	 * @return {Function}
-	 */
-	Utils.createCommand = function (oContext, fExecute, fCanExecute)
-	{
-		var
-			fResult = fExecute ? function () {
-
-				if (fResult && fResult.canExecute && fResult.canExecute())
-				{
-					fExecute.apply(oContext, Array.prototype.slice.call(arguments));
-				}
-
-				return false;
-
-			} : function () {}
-		;
-
-		fResult.enabled = ko.observable(true);
-
-		fCanExecute = Utils.isUnd(fCanExecute) ? true : fCanExecute;
-		if (Utils.isFunc(fCanExecute))
-		{
-			fResult.canExecute = ko.computed(function () {
-				return fResult.enabled() && fCanExecute.call(oContext);
-			});
-		}
-		else
-		{
-			fResult.canExecute = ko.computed(function () {
-				return fResult.enabled() && !!fCanExecute;
-			});
-		}
-
-		return fResult;
-	};
-
-	/**
-	 * @param {Object} oData
-	 */
-	Utils.initDataConstructorBySettings = function (oData)
-	{
-		oData.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html);
-		oData.showImages = ko.observable(false);
-		oData.interfaceAnimation = ko.observable(Enums.InterfaceAnimation.Full);
-		oData.contactsAutosave = ko.observable(false);
-
-		Globals.sAnimationType = Enums.InterfaceAnimation.Full;
-
-		oData.capaThemes = ko.observable(false);
-		oData.allowLanguagesOnSettings = ko.observable(true);
-		oData.allowLanguagesOnLogin = ko.observable(true);
-
-		oData.useLocalProxyForExternalImages = ko.observable(false);
-
-		oData.desktopNotifications = ko.observable(false);
-		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();
-		});
-
-		oData.interfaceAnimation.subscribe(function (sValue) {
-			if (Globals.bMobileDevice || sValue === Enums.InterfaceAnimation.None)
-			{
-				Globals.$html.removeClass('rl-anim rl-anim-full').addClass('no-rl-anim');
-
-				Globals.sAnimationType = Enums.InterfaceAnimation.None;
-			}
-			else
-			{
-				switch (sValue)
-				{
-					case Enums.InterfaceAnimation.Full:
-						Globals.$html.removeClass('no-rl-anim').addClass('rl-anim rl-anim-full');
-						Globals.sAnimationType = sValue;
-						break;
-					case Enums.InterfaceAnimation.Normal:
-						Globals.$html.removeClass('no-rl-anim rl-anim-full').addClass('rl-anim');
-						Globals.sAnimationType = sValue;
-						break;
-				}
-			}
-		});
-
-		oData.interfaceAnimation.valueHasMutated();
-
-		oData.desktopNotificationsPermisions = ko.computed(function () {
-
-			oData.desktopNotifications();
-
-			var
-				NotificationClass = Utils.notificationClass(),
-				iResult = Enums.DesktopNotifications.NotSupported
-			;
-
-			if (NotificationClass && NotificationClass.permission)
-			{
-				switch (NotificationClass.permission.toLowerCase())
-				{
-					case 'granted':
-						iResult = Enums.DesktopNotifications.Allowed;
-						break;
-					case 'denied':
-						iResult = Enums.DesktopNotifications.Denied;
-						break;
-					case 'default':
-						iResult = Enums.DesktopNotifications.NotAllowed;
-						break;
-				}
-			}
-			else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
-			{
-				iResult = window.webkitNotifications.checkPermission();
-			}
-
-			return iResult;
-		});
-
-		oData.useDesktopNotifications = ko.computed({
-			'read': function () {
-				return oData.desktopNotifications() &&
-					Enums.DesktopNotifications.Allowed === oData.desktopNotificationsPermisions();
-			},
-			'write': function (bValue) {
-				if (bValue)
-				{
-					var
-						NotificationClass = Utils.notificationClass(),
-						iPermission = oData.desktopNotificationsPermisions()
-					;
-
-					if (NotificationClass && Enums.DesktopNotifications.Allowed === iPermission)
-					{
-						oData.desktopNotifications(true);
-					}
-					else if (NotificationClass && Enums.DesktopNotifications.NotAllowed === iPermission)
-					{
-						NotificationClass.requestPermission(function () {
-							oData.desktopNotifications.valueHasMutated();
-							if (Enums.DesktopNotifications.Allowed === oData.desktopNotificationsPermisions())
-							{
-								if (oData.desktopNotifications())
-								{
-									oData.desktopNotifications.valueHasMutated();
-								}
-								else
-								{
-									oData.desktopNotifications(true);
-								}
-							}
-							else
-							{
-								if (oData.desktopNotifications())
-								{
-									oData.desktopNotifications(false);
-								}
-								else
-								{
-									oData.desktopNotifications.valueHasMutated();
-								}
-							}
-						});
-					}
-					else
-					{
-						oData.desktopNotifications(false);
-					}
-				}
-				else
-				{
-					oData.desktopNotifications(false);
-				}
-			}
-		});
-
-		oData.language = ko.observable('');
-		oData.languages = ko.observableArray([]);
-
-		oData.mainLanguage = ko.computed({
-			'read': oData.language,
-			'write': function (sValue) {
-				if (sValue !== oData.language())
-				{
-					if (-1 < Utils.inArray(sValue, oData.languages()))
-					{
-						oData.language(sValue);
-					}
-					else if (0 < oData.languages().length)
-					{
-						oData.language(oData.languages()[0]);
-					}
-				}
-				else
-				{
-					oData.language.valueHasMutated();
-				}
-			}
-		});
-
-		oData.theme = ko.observable('');
-		oData.themes = ko.observableArray([]);
-
-		oData.mainTheme = ko.computed({
-			'read': oData.theme,
-			'write': function (sValue) {
-				if (sValue !== oData.theme())
-				{
-					var aThemes = oData.themes();
-					if (-1 < Utils.inArray(sValue, aThemes))
-					{
-						oData.theme(sValue);
-					}
-					else if (0 < aThemes.length)
-					{
-						oData.theme(aThemes[0]);
-					}
-				}
-				else
-				{
-					oData.theme.valueHasMutated();
-				}
-			}
-		});
-
-		oData.capaAdditionalAccounts = ko.observable(false);
-		oData.capaAdditionalIdentities = ko.observable(false);
-		oData.capaGravatar = ko.observable(false);
-		oData.determineUserLanguage = ko.observable(false);
-		oData.determineUserDomain = ko.observable(false);
-
-		oData.messagesPerPage = ko.observable(Consts.Defaults.MessagesPerPage);//.extend({'throttle': 200});
-
-		oData.mainMessagesPerPage = oData.messagesPerPage;
-		oData.mainMessagesPerPage = ko.computed({
-			'read': oData.messagesPerPage,
-			'write': function (iValue) {
-				if (-1 < Utils.inArray(Utils.pInt(iValue), Consts.Defaults.MessagesPerPageArray))
-				{
-					if (iValue !== oData.messagesPerPage())
-					{
-						oData.messagesPerPage(iValue);
-					}
-				}
-				else
-				{
-					oData.messagesPerPage.valueHasMutated();
-				}
-			}
-		});
-
-		oData.facebookSupported = ko.observable(false);
-		oData.facebookEnable = ko.observable(false);
-		oData.facebookAppID = ko.observable('');
-		oData.facebookAppSecret = ko.observable('');
-
-		oData.twitterEnable = ko.observable(false);
-		oData.twitterConsumerKey = ko.observable('');
-		oData.twitterConsumerSecret = ko.observable('');
-
-		oData.googleEnable = ko.observable(false);
-		oData.googleClientID = ko.observable('');
-		oData.googleClientSecret = ko.observable('');
-		oData.googleApiKey = ko.observable('');
-
-		oData.dropboxEnable = ko.observable(false);
-		oData.dropboxApiKey = ko.observable('');
-
-		oData.contactsIsAllowed = ko.observable(false);
-	};
-
-	/**
-	 * @param {{moment:Function}} oObject
-	 */
-	Utils.createMomentDate = function (oObject)
-	{
-		if (Utils.isUnd(oObject.moment))
-		{
-			oObject.moment = ko.observable(moment());
-		}
-
-		return ko.computed(function () {
-			Globals.momentTrigger();
-			var oMoment = this.moment();
-			return 1970 === oMoment.year() ? '' : oMoment.fromNow();
-		}, oObject);
-	};
-
-	/**
-	 * @param {{moment:Function, momentDate:Function}} oObject
-	 */
-	Utils.createMomentShortDate = function (oObject)
-	{
-		return ko.computed(function () {
-
-			var
-				sResult = '',
-				oMomentNow = moment(),
-				oMoment = this.moment(),
-				sMomentDate = this.momentDate()
-			;
-
-			if (1970 === oMoment.year())
-			{
-				sResult = '';
-			}
-			else if (4 >= oMomentNow.diff(oMoment, 'hours'))
-			{
-				sResult = sMomentDate;
-			}
-			else if (oMomentNow.format('L') === oMoment.format('L'))
-			{
-				sResult = Utils.i18n('MESSAGE_LIST/TODAY_AT', {
-					'TIME': oMoment.format('LT')
-				});
-			}
-			else if (oMomentNow.clone().subtract('days', 1).format('L') === oMoment.format('L'))
-			{
-				sResult = Utils.i18n('MESSAGE_LIST/YESTERDAY_AT', {
-					'TIME': oMoment.format('LT')
-				});
-			}
-			else if (oMomentNow.year() === oMoment.year())
-			{
-				sResult = oMoment.format('D MMM.');
-			}
-			else
-			{
-				sResult = oMoment.format('LL');
-			}
-
-			return sResult;
-
-		}, oObject);
-	};
-
-	/**
-	 * @param {string} sTheme
-	 * @return {string}
-	 */
-	Utils.convertThemeName = function (sTheme)
-	{
-		if ('@custom' === sTheme.substr(-7))
-		{
-			sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7));
-		}
-
-		return Utils.trim(sTheme.replace(/[^a-zA-Z0-9]+/g, ' ').replace(/([A-Z])/g, ' $1').replace(/[\s]+/g, ' '));
-	};
-
-	/**
-	 * @param {string} sName
-	 * @return {string}
-	 */
-	Utils.quoteName = function (sName)
-	{
-		return sName.replace(/["]/g, '\\"');
-	};
-
-	/**
-	 * @return {number}
-	 */
-	Utils.microtime = function ()
-	{
-		return (new Date()).getTime();
-	};
-
-	/**
-	 *
-	 * @param {string} sLanguage
-	 * @param {boolean=} bEng = false
-	 * @return {string}
-	 */
-	Utils.convertLangName = function (sLanguage, bEng)
-	{
-		return Utils.i18n('LANGS_NAMES' + (true === bEng ? '_EN' : '') + '/LANG_' +
-			sLanguage.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_'), null, sLanguage);
-	};
-
-	/**
-	 * @param {number=} iLen
-	 * @return {string}
-	 */
-	Utils.fakeMd5 = function(iLen)
-	{
-		var
-			sResult = '',
-			sLine = '0123456789abcdefghijklmnopqrstuvwxyz'
-		;
-
-		iLen = Utils.isUnd(iLen) ? 32 : Utils.pInt(iLen);
-
-		while (sResult.length < iLen)
-		{
-			sResult += sLine.substr(window.Math.round(window.Math.random() * sLine.length), 1);
-		}
-
-		return sResult;
-	};
-
-	/**
-	 * @param {string} sPlain
-	 * @return {string}
-	 */
-	Utils.convertPlainTextToHtml = function (sPlain)
-	{
-		return sPlain.toString()
-			.replace(/&/g, '&').replace(/>/g, '>').replace(/');
-	};
-
-	Utils.draggeblePlace = function ()
-	{
-		return $('
 
').appendTo('#rl-hidden'); - }; - - Utils.defautOptionsAfterRender = function (oDomOption, oItem) - { - if (oItem && !Utils.isUnd(oItem.disabled) && oDomOption) - { - $(oDomOption) - .toggleClass('disabled', oItem.disabled) - .prop('disabled', oItem.disabled) - ; - } - }; - - /** - * @param {Object} oViewModel - * @param {string} sTemplateID - * @param {string} sTitle - * @param {Function=} fCallback - */ - Utils.windowPopupKnockout = function (oViewModel, sTemplateID, sTitle, fCallback) - { - var - oScript = null, - oWin = window.open(''), - sFunc = '__OpenerApplyBindingsUid' + Utils.fakeMd5() + '__', - oTemplate = $('#' + sTemplateID) - ; - - window[sFunc] = function () { - - if (oWin && oWin.document.body && oTemplate && oTemplate[0]) - { - var oBody = $(oWin.document.body); - - $('#rl-content', oBody).html(oTemplate.html()); - $('html', oWin.document).addClass('external ' + $('html').attr('class')); - - Utils.i18nToNode(oBody); - - if (oViewModel && $('#rl-content', oBody)[0]) - { - ko.applyBindings(oViewModel, $('#rl-content', oBody)[0]); - } - - window[sFunc] = null; - - fCallback(oWin); - } + return aResult.join(', '); }; - oWin.document.open(); - oWin.document.write('' + -'' + -'' + -'' + -'' + -'' + -'' + Utils.encodeHtml(sTitle) + '' + -'
'); - oWin.document.close(); - - oScript = oWin.document.createElement('script'); - oScript.type = 'text/javascript'; - oScript.innerHTML = 'if(window&&window.opener&&window.opener[\'' + sFunc + '\']){window.opener[\'' + sFunc + '\']();window.opener[\'' + sFunc + '\']=null}'; - oWin.document.getElementsByTagName('head')[0].appendChild(oScript); - }; - - /** - * @param {Function} fCallback - * @param {?} koTrigger - * @param {?} oContext = null - * @param {number=} iTimer = 1000 - * @return {Function} - */ - Utils.settingsSaveHelperFunction = function (fCallback, koTrigger, oContext, iTimer) - { - oContext = oContext || null; - iTimer = Utils.isUnd(iTimer) ? 1000 : Utils.pInt(iTimer); - - return function (sType, mData, bCached, sRequestAction, oRequestParameters) { - koTrigger.call(oContext, mData && mData['Result'] ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult); - if (fCallback) - { - fCallback.call(oContext, sType, mData, bCached, sRequestAction, oRequestParameters); - } - _.delay(function () { - koTrigger.call(oContext, Enums.SaveSettingsStep.Idle); - }, iTimer); - }; - }; - - Utils.settingsSaveHelperSimpleFunction = function (koTrigger, oContext) - { - return Utils.settingsSaveHelperFunction(null, koTrigger, oContext, 1000); - }; - - /** - * @param {string} sHtml - * @return {string} - */ - Utils.htmlToPlain = function (sHtml) - { - var - iPos = 0, - iP1 = 0, - iP2 = 0, - iP3 = 0, - iLimit = 0, - - sText = '', - - splitPlainText = function (sText) - { - var - iLen = 100, - sPrefix = '', - sSubText = '', - sResult = sText, - iSpacePos = 0, - iNewLinePos = 0 - ; - - while (sResult.length > iLen) - { - sSubText = sResult.substring(0, iLen); - iSpacePos = sSubText.lastIndexOf(' '); - iNewLinePos = sSubText.lastIndexOf('\n'); - - if (-1 !== iNewLinePos) - { - iSpacePos = iNewLinePos; - } - - if (-1 === iSpacePos) - { - iSpacePos = iLen; - } - - sPrefix += sSubText.substring(0, iSpacePos) + '\n'; - sResult = sResult.substring(iSpacePos + 1); - } - - return sPrefix + sResult; - }, - - convertBlockquote = function (sText) { - sText = splitPlainText($.trim(sText)); - sText = '> ' + sText.replace(/\n/gm, '\n> '); - return sText.replace(/(^|\n)([> ]+)/gm, function () { - return (arguments && 2 < arguments.length) ? arguments[1] + $.trim(arguments[2].replace(/[\s]/g, '')) + ' ' : ''; - }); - }, - - convertDivs = function () { - if (arguments && 1 < arguments.length) - { - var sText = $.trim(arguments[1]); - if (0 < sText.length) - { - sText = sText.replace(/]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs); - sText = '\n' + $.trim(sText) + '\n'; - } - - return sText; - } - - return ''; - }, - - convertPre = function () { - return (arguments && 1 < arguments.length) ? arguments[1].toString().replace(/[\n]/gm, '
') : ''; - }, - - fixAttibuteValue = function () { - return (arguments && 1 < arguments.length) ? - '' + arguments[1] + arguments[2].replace(//g, '>') : ''; - }, - - convertLinks = function () { - return (arguments && 1 < arguments.length) ? $.trim(arguments[1]) : ''; - } - ; - - sText = sHtml - .replace(/]*>([\s\S\r\n]*)<\/pre>/gmi, convertPre) - .replace(/[\s]+/gm, ' ') - .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) - .replace(/]*>/gmi, '\n') - .replace(/<\/h[\d]>/gi, '\n') - .replace(/<\/p>/gi, '\n\n') - .replace(/<\/li>/gi, '\n') - .replace(/<\/td>/gi, '\n') - .replace(/<\/tr>/gi, '\n') - .replace(/]*>/gmi, '\n_______________________________\n\n') - .replace(/]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs) - .replace(/]*>/gmi, '\n__bq__start__\n') - .replace(/<\/blockquote>/gmi, '\n__bq__end__\n') - .replace(/]*>([\s\S\r\n]*?)<\/a>/gmi, convertLinks) - .replace(/<\/div>/gi, '\n') - .replace(/ /gi, ' ') - .replace(/"/gi, '"') - .replace(/<[^>]*>/gm, '') - ; - - sText = Globals.$div.html(sText).text(); - - sText = sText - .replace(/\n[ \t]+/gm, '\n') - .replace(/[\n]{3,}/gm, '\n\n') - .replace(/>/gi, '>') - .replace(/</gi, '<') - .replace(/&/gi, '&') - ; - - iPos = 0; - iLimit = 100; - - while (0 < iLimit) + /** + * @static + * @param {Array} aEmail + * @return {string} + */ + MessageModel.emailsToLineClear = function (aEmail) { - iLimit--; - iP1 = sText.indexOf('__bq__start__', iPos); - if (-1 < iP1) - { - iP2 = sText.indexOf('__bq__start__', iP1 + 5); - iP3 = sText.indexOf('__bq__end__', iP1 + 5); - - if ((-1 === iP2 || iP3 < iP2) && iP1 < iP3) - { - sText = sText.substring(0, iP1) + - convertBlockquote(sText.substring(iP1 + 13, iP3)) + - sText.substring(iP3 + 11); - - iPos = 0; - } - else if (-1 < iP2 && iP2 < iP3) - { - iPos = iP2 - 1; - } - else - { - iPos = 0; - } - } - else - { - break; - } - } - - sText = sText - .replace(/__bq__start__/gm, '') - .replace(/__bq__end__/gm, '') - ; - - return sText; - }; - - /** - * @param {string} sPlain - * @param {boolean} bLinkify = false - * @return {string} - */ - Utils.plainToHtml = function (sPlain, bLinkify) - { - sPlain = sPlain.toString().replace(/\r/g, ''); - - var - bIn = false, - bDo = true, - bStart = true, - aNextText = [], - sLine = '', - iIndex = 0, - aText = sPlain.split("\n") - ; - - do - { - bDo = false; - aNextText = []; - for (iIndex = 0; iIndex < aText.length; iIndex++) - { - sLine = aText[iIndex]; - bStart = '>' === sLine.substr(0, 1); - if (bStart && !bIn) - { - bDo = true; - bIn = true; - aNextText.push('~~~blockquote~~~'); - aNextText.push(sLine.substr(1)); - } - else if (!bStart && bIn) - { - bIn = false; - aNextText.push('~~~/blockquote~~~'); - aNextText.push(sLine); - } - else if (bStart && bIn) - { - aNextText.push(sLine.substr(1)); - } - else - { - aNextText.push(sLine); - } - } - - if (bIn) - { - bIn = false; - aNextText.push('~~~/blockquote~~~'); - } - - aText = aNextText; - } - while (bDo); - - sPlain = aText.join("\n"); - - sPlain = sPlain - .replace(/&/g, '&') - .replace(/>/g, '>').replace(/') - .replace(/[\s]*~~~\/blockquote~~~/g, '') - .replace(/[\-_~]{10,}/g, '
') - .replace(/\n/g, '
'); - - return bLinkify ? Utils.linkify(sPlain) : sPlain; - }; - - window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain; - window.rainloop_Utils_plainToHtml = Utils.plainToHtml; - - /** - * @param {string} sHtml - * @return {string} - */ - Utils.linkify = function (sHtml) - { - if ($.fn && $.fn.linkify) - { - sHtml = Globals.$div.html(sHtml.replace(/&/ig, 'amp_amp_12345_amp_amp')) - .linkify() - .find('.linkified').removeClass('linkified').end() - .html() - .replace(/amp_amp_12345_amp_amp/g, '&') - ; - } - - return sHtml; - }; - - /** - * @param {string} sUrl - * @param {number} iValue - * @param {Function} fCallback - */ - Utils.resizeAndCrop = function (sUrl, iValue, fCallback) - { - var oTempImg = new window.Image(); - oTempImg.onload = function() { - var - aDiff = [0, 0], - oCanvas = window.document.createElement('canvas'), - oCtx = oCanvas.getContext('2d') - ; - - oCanvas.width = iValue; - oCanvas.height = iValue; - - if (this.width > this.height) - { - aDiff = [this.width - this.height, 0]; - } - else - { - aDiff = [0, this.height - this.width]; - } - - 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')); - }; - - oTempImg.src = sUrl; - }; - - /** - * @param {Array} aSystem - * @param {Array} aList - * @param {Array=} aDisabled - * @param {Array=} aHeaderLines - * @param {?number=} iUnDeep - * @param {Function=} fDisableCallback - * @param {Function=} fVisibleCallback - * @param {Function=} fRenameCallback - * @param {boolean=} bSystem - * @param {boolean=} bBuildUnvisible - * @return {Array} - */ - Utils.folderListOptionsBuilder = function (aSystem, aList, aDisabled, aHeaderLines, iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible) - { - var - /** - * @type {?FolderModel} - */ - oItem = null, - bSep = false, - iIndex = 0, - iLen = 0, - sDeepPrefix = '\u00A0\u00A0\u00A0', - aResult = [] - ; - - bSystem = !Utils.isNormal(bSystem) ? 0 < aSystem.length : bSystem; - bBuildUnvisible = Utils.isUnd(bBuildUnvisible) ? false : !!bBuildUnvisible; - iUnDeep = !Utils.isNormal(iUnDeep) ? 0 : iUnDeep; - fDisableCallback = Utils.isNormal(fDisableCallback) ? fDisableCallback : null; - fVisibleCallback = Utils.isNormal(fVisibleCallback) ? fVisibleCallback : null; - fRenameCallback = Utils.isNormal(fRenameCallback) ? fRenameCallback : null; - - if (!Utils.isArray(aDisabled)) - { - aDisabled = []; - } - - if (!Utils.isArray(aHeaderLines)) - { - aHeaderLines = []; - } - - for (iIndex = 0, iLen = aHeaderLines.length; iIndex < iLen; iIndex++) - { - aResult.push({ - 'id': aHeaderLines[iIndex][0], - 'name': aHeaderLines[iIndex][1], - 'system': false, - 'seporator': false, - 'disabled': false - }); - } - - bSep = true; - for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++) - { - oItem = aSystem[iIndex]; - if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true) - { - if (bSep && 0 < aResult.length) - { - aResult.push({ - 'id': '---', - 'name': '---', - 'system': false, - 'seporator': true, - 'disabled': true - }); - } - - bSep = false; - aResult.push({ - 'id': oItem.fullNameRaw, - 'name': fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name(), - 'system': true, - 'seporator': false, - 'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) || - (fDisableCallback ? fDisableCallback.call(null, oItem) : false) - }); - } - } - - bSep = true; - for (iIndex = 0, iLen = aList.length; iIndex < iLen; iIndex++) - { - oItem = aList[iIndex]; - if (oItem.subScribed() || !oItem.existen) - { - if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true) - { - if (Enums.FolderType.User === oItem.type() || !bSystem || 0 < oItem.subFolders().length) - { - if (bSep && 0 < aResult.length) - { - aResult.push({ - 'id': '---', - 'name': '---', - 'system': false, - 'seporator': true, - 'disabled': true - }); - } - - bSep = false; - aResult.push({ - 'id': oItem.fullNameRaw, - 'name': (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) + - (fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name()), - 'system': false, - 'seporator': false, - 'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) || - (fDisableCallback ? fDisableCallback.call(null, oItem) : false) - }); - } - } - } - - if (oItem.subScribed() && 0 < oItem.subFolders().length) - { - aResult = aResult.concat(Utils.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [], - iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible)); - } - } - - return aResult; - }; - - Utils.computedPagenatorHelper = function (koCurrentPage, koPageCount) - { - return function() { - - var - iPrev = 0, - iNext = 0, - iLimit = 2, aResult = [], - iCurrentPage = koCurrentPage(), - iPageCount = koPageCount(), - - /** - * @param {number} iIndex - * @param {boolean=} bPush = true - * @param {string=} sCustomName = '' - */ - fAdd = function (iIndex, bPush, sCustomName) { - - var oData = { - 'current': iIndex === iCurrentPage, - 'name': Utils.isUnd(sCustomName) ? iIndex.toString() : sCustomName.toString(), - 'custom': Utils.isUnd(sCustomName) ? false : true, - 'title': Utils.isUnd(sCustomName) ? '' : iIndex.toString(), - 'value': iIndex.toString() - }; - - if (Utils.isUnd(bPush) ? true : !!bPush) - { - aResult.push(oData); - } - else - { - aResult.unshift(oData); - } - } + iIndex = 0, + iLen = 0 ; - if (1 < iPageCount || (0 < iPageCount && iPageCount < iCurrentPage)) - // if (0 < iPageCount && 0 < iCurrentPage) + if (Utils.isNonEmptyArray(aEmail)) { - if (iPageCount < iCurrentPage) + for (iIndex = 0, iLen = aEmail.length; iIndex < iLen; iIndex++) { - fAdd(iPageCount); - iPrev = iPageCount; - iNext = iPageCount; - } - else - { - if (3 >= iCurrentPage || iPageCount - 2 <= iCurrentPage) + if (aEmail[iIndex] && aEmail[iIndex].email && '' !== aEmail[iIndex].name) { - iLimit += 2; - } - - fAdd(iCurrentPage); - iPrev = iCurrentPage; - iNext = iCurrentPage; - } - - while (0 < iLimit) { - - iPrev -= 1; - iNext += 1; - - if (0 < iPrev) - { - fAdd(iPrev, false); - iLimit--; - } - - if (iPageCount >= iNext) - { - fAdd(iNext, true); - iLimit--; - } - else if (0 >= iPrev) - { - break; + aResult.push(aEmail[iIndex].email); } } + } - if (3 === iPrev) - { - fAdd(2, false); - } - else if (3 < iPrev) - { - fAdd(window.Math.round((iPrev - 1) / 2), false, '...'); - } + return aResult.join(', '); + }; - if (iPageCount - 2 === iNext) - { - fAdd(iPageCount - 1, true); - } - else if (iPageCount - 2 > iNext) - { - fAdd(window.Math.round((iPageCount + iNext) / 2), true, '...'); - } + /** + * @static + * @param {?Array} aJsonEmails + * @return {Array.} + */ + MessageModel.initEmailsFromJson = function (aJsonEmails) + { + var + iIndex = 0, + iLen = 0, + oEmailModel = null, + aResult = [] + ; - // first and last - if (1 < iPrev) + if (Utils.isNonEmptyArray(aJsonEmails)) + { + for (iIndex = 0, iLen = aJsonEmails.length; iIndex < iLen; iIndex++) { - fAdd(1, false); - } - - if (iPageCount > iNext) - { - fAdd(iPageCount, true); + oEmailModel = EmailModel.newInstanceFromJson(aJsonEmails[iIndex]); + if (oEmailModel) + { + aResult.push(oEmailModel); + } } } return aResult; }; - }; - Utils.selectElement = function (element) - { - var sel, range; - if (window.getSelection) + /** + * @static + * @param {Array.} aMessageEmails + * @param {Object} oLocalUnic + * @param {Array} aLocalEmails + */ + MessageModel.replyHelper = function (aMessageEmails, oLocalUnic, aLocalEmails) { - sel = window.getSelection(); - sel.removeAllRanges(); - range = window.document.createRange(); - range.selectNodeContents(element); - sel.addRange(range); - } - else if (window.document.selection) - { - range = window.document.body.createTextRange(); - range.moveToElementText(element); - range.select(); - } - }; - - Utils.detectDropdownVisibility = _.debounce(function () { - Globals.dropdownVisibility(!!_.find(Globals.aBootstrapDropdowns, function (oItem) { - return oItem.hasClass('open'); - })); - }, 50); - - /** - * @param {boolean=} bDelay = false - */ - Utils.triggerAutocompleteInputChange = function (bDelay) { - - var fFunc = function () { - $('.checkAutocomplete').trigger('change'); - }; - - if (Utils.isUnd(bDelay) ? false : !!bDelay) - { - _.delay(fFunc, 100); - } - else - { - fFunc(); - } - }; - - module.exports = Utils; - -}(module, require)); -},{"$":20,"App:Knoin":27,"Consts":6,"Enums":7,"Globals":9,"Model:Email":37,"_":25,"ko":22,"window":26}],15:[function(require,module,exports){ -module.exports = JSON; -},{}],16:[function(require,module,exports){ -module.exports = Jua; -},{}],17:[function(require,module,exports){ -module.exports = crossroads; -},{}],18:[function(require,module,exports){ -module.exports = hasher; -},{}],19:[function(require,module,exports){ -module.exports = ifvisible; -},{}],20:[function(require,module,exports){ -module.exports = $; -},{}],21:[function(require,module,exports){ -module.exports = key; -},{}],22:[function(require,module,exports){ - -(function (module, ko) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$') - ; - - ko.bindingHandlers.tooltip = { - 'init': function (oElement, fValueAccessor) { - - var - Globals = require('Globals'), - Utils = require('Utils') - ; - - if (!Globals.bMobileDevice) - { - var - $oEl = $(oElement), - sClass = $oEl.data('tooltip-class') || '', - sPlacement = $oEl.data('tooltip-placement') || 'top' - ; - - $oEl.tooltip({ - 'delay': { - 'show': 500, - 'hide': 100 - }, - 'html': true, - 'container': 'body', - 'placement': sPlacement, - 'trigger': 'hover', - 'title': function () { - return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' : '' + - Utils.i18n(ko.utils.unwrapObservable(fValueAccessor())) + ''; - } - }).click(function () { - $oEl.tooltip('hide'); - }); - - Globals.tooltipTrigger.subscribe(function () { - $oEl.tooltip('hide'); - }); - } - } - }; - - ko.bindingHandlers.tooltip2 = { - 'init': function (oElement, fValueAccessor) { - var - Globals = require('Globals'), - $oEl = $(oElement), - sClass = $oEl.data('tooltip-class') || '', - sPlacement = $oEl.data('tooltip-placement') || 'top' - ; - - $oEl.tooltip({ - 'delay': { - 'show': 500, - 'hide': 100 - }, - 'html': true, - 'container': 'body', - 'placement': sPlacement, - 'title': function () { - return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' : - '' + fValueAccessor()() + ''; - } - }).click(function () { - $oEl.tooltip('hide'); - }); - - Globals.tooltipTrigger.subscribe(function () { - $oEl.tooltip('hide'); - }); - } - }; - - ko.bindingHandlers.tooltip3 = { - 'init': function (oElement) { - - var - $oEl = $(oElement), - Globals = require('Globals') - ; - - $oEl.tooltip({ - 'container': 'body', - 'trigger': 'hover manual', - 'title': function () { - return $oEl.data('tooltip3-data') || ''; - } - }); - - $(window.document).click(function () { - $oEl.tooltip('hide'); - }); - - Globals.tooltipTrigger.subscribe(function () { - $oEl.tooltip('hide'); - }); - }, - 'update': function (oElement, fValueAccessor) { - var sValue = ko.utils.unwrapObservable(fValueAccessor()); - if ('' === sValue) - { - $(oElement).data('tooltip3-data', '').tooltip('hide'); - } - else - { - $(oElement).data('tooltip3-data', sValue).tooltip('show'); - } - } - }; - - ko.bindingHandlers.registrateBootstrapDropdown = { - 'init': function (oElement) { - var Globals = require('Globals'); - Globals.aBootstrapDropdowns.push($(oElement)); - } - }; - - ko.bindingHandlers.openDropdownTrigger = { - 'update': function (oElement, fValueAccessor) { - if (ko.utils.unwrapObservable(fValueAccessor())) - { - var - $el = $(oElement), - Utils = require('Utils') - ; - - if (!$el.hasClass('open')) - { - $el.find('.dropdown-toggle').dropdown('toggle'); - Utils.detectDropdownVisibility(); - } - - fValueAccessor()(false); - } - } - }; - - ko.bindingHandlers.dropdownCloser = { - 'init': function (oElement) { - $(oElement).closest('.dropdown').on('click', '.e-item', function () { - $(oElement).dropdown('toggle'); - }); - } - }; - - ko.bindingHandlers.popover = { - 'init': function (oElement, fValueAccessor) { - $(oElement).popover(ko.utils.unwrapObservable(fValueAccessor())); - } - }; - - ko.bindingHandlers.csstext = { - 'init': function (oElement, fValueAccessor) { - var Utils = require('Utils'); - if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText)) - { - oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor()); - } - else - { - $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); - } - }, - 'update': function (oElement, fValueAccessor) { - var Utils = require('Utils'); - if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText)) - { - oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor()); - } - else - { - $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); - } - } - }; - - ko.bindingHandlers.resizecrop = { - 'init': function (oElement) { - $(oElement).addClass('resizecrop').resizecrop({ - 'width': '100', - 'height': '100', - 'wrapperCSS': { - 'border-radius': '10px' - } - }); - }, - 'update': function (oElement, fValueAccessor) { - fValueAccessor()(); - $(oElement).resizecrop({ - 'width': '100', - 'height': '100' - }); - } - }; - - ko.bindingHandlers.onEnter = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { - $(oElement).on('keypress', function (oEvent) { - if (oEvent && 13 === window.parseInt(oEvent.keyCode, 10)) - { - $(oElement).trigger('change'); - fValueAccessor().call(oViewModel); - } - }); - } - }; - - ko.bindingHandlers.onEsc = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { - $(oElement).on('keypress', function (oEvent) { - if (oEvent && 27 === window.parseInt(oEvent.keyCode, 10)) - { - $(oElement).trigger('change'); - fValueAccessor().call(oViewModel); - } - }); - } - }; - - ko.bindingHandlers.clickOnTrue = { - 'update': function (oElement, fValueAccessor) { - if (ko.utils.unwrapObservable(fValueAccessor())) - { - $(oElement).click(); - } - } - }; - - ko.bindingHandlers.modal = { - 'init': function (oElement, fValueAccessor) { - - var - Globals = require('Globals'), - Utils = require('Utils') - ; - - $(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({ - 'keyboard': false, - 'show': ko.utils.unwrapObservable(fValueAccessor()) - }) - .on('shown', function () { - Utils.windowResize(); - }) - .find('.close').click(function () { - fValueAccessor()(false); - }); - - }, - 'update': function (oElement, fValueAccessor) { - $(oElement).modal(ko.utils.unwrapObservable(fValueAccessor()) ? 'show' : 'hide'); - } - }; - - ko.bindingHandlers.i18nInit = { - 'init': function (oElement) { - var Utils = require('Utils'); - Utils.i18nToNode(oElement); - } - }; - - ko.bindingHandlers.i18nUpdate = { - 'update': function (oElement, fValueAccessor) { - var Utils = require('Utils'); - ko.utils.unwrapObservable(fValueAccessor()); - Utils.i18nToNode(oElement); - } - }; - - ko.bindingHandlers.link = { - 'update': function (oElement, fValueAccessor) { - $(oElement).attr('href', ko.utils.unwrapObservable(fValueAccessor())); - } - }; - - ko.bindingHandlers.title = { - 'update': function (oElement, fValueAccessor) { - $(oElement).attr('title', ko.utils.unwrapObservable(fValueAccessor())); - } - }; - - ko.bindingHandlers.textF = { - 'init': function (oElement, fValueAccessor) { - $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); - } - }; - - ko.bindingHandlers.initDom = { - 'init': function (oElement, fValueAccessor) { - fValueAccessor()(oElement); - } - }; - - ko.bindingHandlers.initResizeTrigger = { - 'init': function (oElement, fValueAccessor) { - var aValues = ko.utils.unwrapObservable(fValueAccessor()); - $(oElement).css({ - 'height': aValues[1], - 'min-height': aValues[1] - }); - }, - 'update': function (oElement, fValueAccessor) { - - var - Utils = require('Utils'), - Globals = require('Globals'), - aValues = ko.utils.unwrapObservable(fValueAccessor()), - iValue = Utils.pInt(aValues[1]), - iSize = 0, - iOffset = $(oElement).offset().top - ; - - if (0 < iOffset) - { - iOffset += Utils.pInt(aValues[2]); - iSize = Globals.$win.height() - iOffset; - - if (iValue < iSize) - { - iValue = iSize; - } - - $(oElement).css({ - 'height': iValue, - 'min-height': iValue - }); - } - } - }; - - ko.bindingHandlers.appendDom = { - 'update': function (oElement, fValueAccessor) { - $(oElement).hide().empty().append(ko.utils.unwrapObservable(fValueAccessor())).show(); - } - }; - - ko.bindingHandlers.draggable = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor) { - var - Globals = require('Globals'), - Utils = require('Utils') - ; - if (!Globals.bMobileDevice) - { - var - iTriggerZone = 100, - iScrollSpeed = 3, - fAllValueFunc = fAllBindingsAccessor(), - sDroppableSelector = fAllValueFunc && fAllValueFunc['droppableSelector'] ? fAllValueFunc['droppableSelector'] : '', - oConf = { - 'distance': 20, - 'handle': '.dragHandle', - 'cursorAt': {'top': 22, 'left': 3}, - 'refreshPositions': true, - 'scroll': true - } - ; - - if (sDroppableSelector) - { - oConf['drag'] = function (oEvent) { - - $(sDroppableSelector).each(function () { - var - moveUp = null, - moveDown = null, - $this = $(this), - oOffset = $this.offset(), - bottomPos = oOffset.top + $this.height() - ; - - window.clearInterval($this.data('timerScroll')); - $this.data('timerScroll', false); - - if (oEvent.pageX >= oOffset.left && oEvent.pageX <= oOffset.left + $this.width()) - { - if (oEvent.pageY >= bottomPos - iTriggerZone && oEvent.pageY <= bottomPos) - { - moveUp = function() { - $this.scrollTop($this.scrollTop() + iScrollSpeed); - Utils.windowResize(); - }; - - $this.data('timerScroll', window.setInterval(moveUp, 10)); - moveUp(); - } - - if (oEvent.pageY >= oOffset.top && oEvent.pageY <= oOffset.top + iTriggerZone) - { - moveDown = function() { - $this.scrollTop($this.scrollTop() - iScrollSpeed); - Utils.windowResize(); - }; - - $this.data('timerScroll', window.setInterval(moveDown, 10)); - moveDown(); - } - } - }); - }; - - oConf['stop'] = function() { - $(sDroppableSelector).each(function () { - window.clearInterval($(this).data('timerScroll')); - $(this).data('timerScroll', false); - }); - }; - } - - oConf['helper'] = function (oEvent) { - return fValueAccessor()(oEvent && oEvent.target ? ko.dataFor(oEvent.target) : null); - }; - - $(oElement).draggable(oConf).on('mousedown', function () { - Utils.removeInFocus(); - }); - } - } - }; - - ko.bindingHandlers.droppable = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor) { - var Globals = require('Globals'); - if (!Globals.bMobileDevice) - { - var - fValueFunc = fValueAccessor(), - fAllValueFunc = fAllBindingsAccessor(), - fOverCallback = fAllValueFunc && fAllValueFunc['droppableOver'] ? fAllValueFunc['droppableOver'] : null, - fOutCallback = fAllValueFunc && fAllValueFunc['droppableOut'] ? fAllValueFunc['droppableOut'] : null, - oConf = { - 'tolerance': 'pointer', - 'hoverClass': 'droppableHover' - } - ; - - if (fValueFunc) - { - oConf['drop'] = function (oEvent, oUi) { - fValueFunc(oEvent, oUi); - }; - - if (fOverCallback) - { - oConf['over'] = function (oEvent, oUi) { - fOverCallback(oEvent, oUi); - }; - } - - if (fOutCallback) - { - oConf['out'] = function (oEvent, oUi) { - fOutCallback(oEvent, oUi); - }; - } - - $(oElement).droppable(oConf); - } - } - } - }; - - ko.bindingHandlers.nano = { - 'init': function (oElement) { - var Globals = require('Globals'); - if (!Globals.bDisableNanoScroll) - { - $(oElement) - .addClass('nano') - .nanoScroller({ - 'iOSNativeScrolling': false, - 'preventPageScrolling': true - }) - ; - } - } - }; - - ko.bindingHandlers.saveTrigger = { - 'init': function (oElement) { - - var $oEl = $(oElement); - - $oEl.data('save-trigger-type', $oEl.is('input[type=text],input[type=email],input[type=password],select,textarea') ? 'input' : 'custom'); - - if ('custom' === $oEl.data('save-trigger-type')) - { - $oEl.append( - '  ' - ).addClass('settings-saved-trigger'); - } - else - { - $oEl.addClass('settings-saved-trigger-input'); - } - }, - 'update': function (oElement, fValueAccessor) { - var - mValue = ko.utils.unwrapObservable(fValueAccessor()), - $oEl = $(oElement) - ; - - if ('custom' === $oEl.data('save-trigger-type')) - { - switch (mValue.toString()) - { - case '1': - $oEl - .find('.animated,.error').hide().removeClass('visible') - .end() - .find('.success').show().addClass('visible') - ; - break; - case '0': - $oEl - .find('.animated,.success').hide().removeClass('visible') - .end() - .find('.error').show().addClass('visible') - ; - break; - case '-2': - $oEl - .find('.error,.success').hide().removeClass('visible') - .end() - .find('.animated').show().addClass('visible') - ; - break; - default: - $oEl - .find('.animated').hide() - .end() - .find('.error,.success').removeClass('visible') - ; - break; - } - } - else - { - switch (mValue.toString()) - { - case '1': - $oEl.addClass('success').removeClass('error'); - break; - case '0': - $oEl.addClass('error').removeClass('success'); - break; - case '-2': - // $oEl; - break; - default: - $oEl.removeClass('error success'); - break; - } - } - } - }; - - ko.bindingHandlers.emailsTags = { - 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { - - var - Utils = require('Utils'), - EmailModel = require('Model:Email'), - - $oEl = $(oElement), - fValue = fValueAccessor(), - fAllBindings = fAllBindingsAccessor(), - fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null, - fFocusCallback = function (bValue) { - if (fValue && fValue.focusTrigger) - { - fValue.focusTrigger(bValue); - } - } - ; - - $oEl.inputosaurus({ - 'parseOnBlur': true, - 'allowDragAndDrop': true, - 'focusCallback': fFocusCallback, - 'inputDelimiters': [',', ';'], - 'autoCompleteSource': fAutoCompleteSource, - 'parseHook': function (aInput) { - return _.map(aInput, function (sInputValue) { - - var - sValue = Utils.trim(sInputValue), - oEmail = null - ; - - if ('' !== sValue) - { - oEmail = new EmailModel(); - oEmail.mailsoParse(sValue); - oEmail.clearDuplicateName(); - return [oEmail.toLine(false), oEmail]; - } - - return [sValue, null]; - - }); - }, - 'change': _.bind(function (oEvent) { - $oEl.data('EmailsTagsValue', oEvent.target.value); - fValue(oEvent.target.value); - }, this) - }); - }, - 'update': function (oElement, fValueAccessor, fAllBindingsAccessor) { - - var - $oEl = $(oElement), - fAllValueFunc = fAllBindingsAccessor(), - fEmailsTagsFilter = fAllValueFunc['emailsTagsFilter'] || null, - sValue = ko.utils.unwrapObservable(fValueAccessor()) - ; - - if ($oEl.data('EmailsTagsValue') !== sValue) - { - $oEl.val(sValue); - $oEl.data('EmailsTagsValue', sValue); - $oEl.inputosaurus('refresh'); - } - - if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter)) - { - $oEl.inputosaurus('focus'); - } - } - }; - - ko.bindingHandlers.contactTags = { - 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { - - var - Utils = require('Utils'), - ContactTagModel = require('Model:ContactTag'), - - $oEl = $(oElement), - fValue = fValueAccessor(), - fAllBindings = fAllBindingsAccessor(), - fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null, - fFocusCallback = function (bValue) { - if (fValue && fValue.focusTrigger) - { - fValue.focusTrigger(bValue); - } - } - ; - - $oEl.inputosaurus({ - 'parseOnBlur': true, - 'allowDragAndDrop': false, - 'focusCallback': fFocusCallback, - 'inputDelimiters': [',', ';'], - 'outputDelimiter': ',', - 'autoCompleteSource': fAutoCompleteSource, - '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('ContactTagsValue', oEvent.target.value); - fValue(oEvent.target.value); - }, this) - }); - }, - 'update': function (oElement, fValueAccessor, fAllBindingsAccessor) { - - var - $oEl = $(oElement), - fAllValueFunc = fAllBindingsAccessor(), - fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null, - sValue = ko.utils.unwrapObservable(fValueAccessor()) - ; - - if ($oEl.data('ContactTagsValue') !== sValue) - { - $oEl.val(sValue); - $oEl.data('ContactTagsValue', sValue); - $oEl.inputosaurus('refresh'); - } - - if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter)) - { - $oEl.inputosaurus('focus'); - } - } - }; - - ko.bindingHandlers.command = { - 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { - var - jqElement = $(oElement), - oCommand = fValueAccessor() - ; - - if (!oCommand || !oCommand.enabled || !oCommand.canExecute) - { - throw new Error('You are not using command function'); - } - - jqElement.addClass('command'); - ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click'].init.apply(oViewModel, arguments); - }, - - 'update': function (oElement, fValueAccessor) { - - var - bResult = true, - jqElement = $(oElement), - oCommand = fValueAccessor() - ; - - bResult = oCommand.enabled(); - jqElement.toggleClass('command-not-enabled', !bResult); - - if (bResult) - { - bResult = oCommand.canExecute(); - jqElement.toggleClass('command-can-not-be-execute', !bResult); - } - - jqElement.toggleClass('command-disabled disable disabled', !bResult).toggleClass('no-disabled', !!bResult); - - if (jqElement.is('input') || jqElement.is('button')) - { - jqElement.prop('disabled', !bResult); - } - } - }; - - ko.extenders.trimmer = function (oTarget) - { - var - Utils = require('Utils'), - oResult = ko.computed({ - 'read': oTarget, - 'write': function (sNewValue) { - oTarget(Utils.trim(sNewValue.toString())); - }, - 'owner': this - }) - ; - - oResult(oTarget()); - return oResult; - }; - - ko.extenders.posInterer = function (oTarget, iDefault) - { - var - Utils = require('Utils'), - oResult = ko.computed({ - 'read': oTarget, - 'write': function (sNewValue) { - var iNew = Utils.pInt(sNewValue.toString(), iDefault); - if (0 >= iNew) - { - iNew = iDefault; - } - - if (iNew === oTarget() && '' + iNew !== '' + sNewValue) - { - oTarget(iNew + 1); - } - - oTarget(iNew); - } - }) - ; - - oResult(oTarget()); - return oResult; - }; - - ko.extenders.reversible = function (oTarget) - { - var mValue = oTarget(); - - oTarget.commit = function () - { - mValue = oTarget(); - }; - - oTarget.reverse = function () - { - oTarget(mValue); - }; - - oTarget.commitedValue = function () - { - return mValue; - }; - - return oTarget; - }; - - ko.extenders.toggleSubscribe = function (oTarget, oOptions) - { - oTarget.subscribe(oOptions[1], oOptions[0], 'beforeChange'); - oTarget.subscribe(oOptions[2], oOptions[0]); - - return oTarget; - }; - - ko.extenders.falseTimeout = function (oTarget, iOption) - { - var Utils = require('Utils'); - - oTarget.iTimeout = 0; - oTarget.subscribe(function (bValue) { - if (bValue) - { - window.clearTimeout(oTarget.iTimeout); - oTarget.iTimeout = window.setTimeout(function () { - oTarget(false); - oTarget.iTimeout = 0; - }, Utils.pInt(iOption)); - } - }); - - return oTarget; - }; - - ko.observable.fn.validateNone = function () - { - this.hasError = ko.observable(false); - return this; - }; - - ko.observable.fn.validateEmail = function () - { - var Utils = require('Utils'); - - this.hasError = ko.observable(false); - - this.subscribe(function (sValue) { - sValue = Utils.trim(sValue); - this.hasError('' !== sValue && !(/^[^@\s]+@[^@\s]+$/.test(sValue))); - }, this); - - this.valueHasMutated(); - return this; - }; - - ko.observable.fn.validateSimpleEmail = function () - { - var Utils = require('Utils'); - - this.hasError = ko.observable(false); - - this.subscribe(function (sValue) { - sValue = Utils.trim(sValue); - this.hasError('' !== sValue && !(/^.+@.+$/.test(sValue))); - }, this); - - this.valueHasMutated(); - return this; - }; - - ko.observable.fn.validateFunc = function (fFunc) - { - var Utils = require('Utils'); - - this.hasFuncError = ko.observable(false); - - if (Utils.isFunc(fFunc)) - { - this.subscribe(function (sValue) { - this.hasFuncError(!fFunc(sValue)); - }, this); - - this.valueHasMutated(); - } - - return this; - }; - - module.exports = ko; - -}(module, ko)); - -},{"$":20,"Globals":9,"Model:ContactTag":36,"Model:Email":37,"Utils":14,"_":25,"window":26}],23:[function(require,module,exports){ -module.exports = moment; -},{}],24:[function(require,module,exports){ -module.exports = ssm; -},{}],25:[function(require,module,exports){ -module.exports = _; -},{}],26:[function(require,module,exports){ -module.exports = window; -},{}],27:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - $ = require('$'), - ko = require('ko'), - hasher = require('hasher'), - crossroads = require('crossroads'), - - Globals = require('Globals'), - Plugins = require('Plugins'), - Utils = require('Utils') - ; - - /** - * @constructor - */ - function Knoin() - { - this.oScreens = {}; - this.sDefaultScreenName = ''; - this.oCurrentScreen = null; - } - - Knoin.prototype.oScreens = {}; - Knoin.prototype.sDefaultScreenName = ''; - Knoin.prototype.oCurrentScreen = null; - - Knoin.prototype.hideLoading = function () - { - $('#rl-loading').hide(); - }; - - /** - * @param {Object} thisObject - */ - Knoin.prototype.constructorEnd = function (thisObject) - { - if (Utils.isFunc(thisObject['__constructor_end'])) - { - thisObject['__constructor_end'].call(thisObject); - } - }; - - /** - * @param {string|Array} mName - * @param {Function} ViewModelClass - */ - Knoin.prototype.extendAsViewModel = function (mName, ViewModelClass) - { - if (ViewModelClass) - { - if (Utils.isArray(mName)) - { - ViewModelClass.__names = mName; - } - else - { - ViewModelClass.__names = [mName]; - } - - ViewModelClass.__name = ViewModelClass.__names[0]; - } - }; - - /** - * @param {Function} SettingsViewModelClass - * @param {string} sLabelName - * @param {string} sTemplate - * @param {string} sRoute - * @param {boolean=} bDefault - */ - Knoin.prototype.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute, bDefault) - { - SettingsViewModelClass.__rlSettingsData = { - 'Label': sLabelName, - 'Template': sTemplate, - 'Route': sRoute, - 'IsDefault': !!bDefault - }; - - Globals.aViewModels['settings'].push(SettingsViewModelClass); - }; - - /** - * @param {Function} SettingsViewModelClass - */ - Knoin.prototype.removeSettingsViewModel = function (SettingsViewModelClass) - { - Globals.aViewModels['settings-removed'].push(SettingsViewModelClass); - }; - - /** - * @param {Function} SettingsViewModelClass - */ - Knoin.prototype.disableSettingsViewModel = function (SettingsViewModelClass) - { - Globals.aViewModels['settings-disabled'].push(SettingsViewModelClass); - }; - - Knoin.prototype.routeOff = function () - { - hasher.changed.active = false; - }; - - Knoin.prototype.routeOn = function () - { - hasher.changed.active = true; - }; - - /** - * @param {string} sScreenName - * @return {?Object} - */ - Knoin.prototype.screen = function (sScreenName) - { - return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null; - }; - - /** - * @param {Function} ViewModelClass - * @param {Object=} oScreen - */ - Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen) - { - if (ViewModelClass && !ViewModelClass.__builded) - { - var - kn = this, - oViewModel = new ViewModelClass(oScreen), - sPosition = oViewModel.viewModelPosition(), - oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()), - oViewModelDom = null - ; - - ViewModelClass.__builded = true; - ViewModelClass.__vm = oViewModel; - - oViewModel.viewModelName = ViewModelClass.__name; - oViewModel.viewModelNames = ViewModelClass.__names; - - if (oViewModelPlace && 1 === oViewModelPlace.length) - { - oViewModelDom = $('
').addClass('rl-view-model').addClass('RL-' + oViewModel.viewModelTemplate()).hide(); - oViewModelDom.appendTo(oViewModelPlace); - - oViewModel.viewModelDom = oViewModelDom; - ViewModelClass.__dom = oViewModelDom; - - if ('Popups' === sPosition) - { - oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, function () { - kn.hideScreenPopup(ViewModelClass); - }); - - oViewModel.modalVisibility.subscribe(function (bValue) { - - var self = this; - if (bValue) - { - this.viewModelDom.show(); - this.storeAndSetKeyScope(); - - Globals.popupVisibilityNames.push(this.viewModelName); - oViewModel.viewModelDom.css('z-index', 3000 + Globals.popupVisibilityNames().length + 10); - - Utils.delegateRun(this, 'onFocus', [], 500); - } - else - { - Utils.delegateRun(this, 'onHide'); - this.restoreKeyScope(); - - _.each(this.viewModelNames, function (sName) { - Plugins.runHook('view-model-on-hide', [sName, self]); - }); - - Globals.popupVisibilityNames.remove(this.viewModelName); - oViewModel.viewModelDom.css('z-index', 2000); - - Globals.tooltipTrigger(!Globals.tooltipTrigger()); - - _.delay(function () { - self.viewModelDom.hide(); - }, 300); - } - - }, oViewModel); - } - - _.each(ViewModelClass.__names, function (sName) { - Plugins.runHook('view-model-pre-build', [sName, oViewModel, oViewModelDom]); - }); - - ko.applyBindingAccessorsToNode(oViewModelDom[0], { - 'i18nInit': true, - 'template': function () { return {'name': oViewModel.viewModelTemplate()};} - }, oViewModel); - - Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]); - if (oViewModel && 'Popups' === sPosition) - { - oViewModel.registerPopupKeyDown(); - } - - _.each(ViewModelClass.__names, function (sName) { - Plugins.runHook('view-model-post-build', [sName, oViewModel, oViewModelDom]); - }); - } - else - { - Utils.log('Cannot find view model position: ' + sPosition); - } - } - - return ViewModelClass ? ViewModelClass.__vm : null; - }; - - /** - * @param {Function} ViewModelClassToHide - */ - Knoin.prototype.hideScreenPopup = function (ViewModelClassToHide) - { - if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) - { - ViewModelClassToHide.__vm.modalVisibility(false); - } - }; - - /** - * @param {Function} ViewModelClassToShow - * @param {Array=} aParameters - */ - Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters) - { - if (ViewModelClassToShow) - { - this.buildViewModel(ViewModelClassToShow); - - if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom) - { - ViewModelClassToShow.__vm.modalVisibility(true); - Utils.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []); - - _.each(ViewModelClassToShow.__names, function (sName) { - Plugins.runHook('view-model-on-show', [sName, ViewModelClassToShow.__vm, aParameters || []]); - }); - } - } - }; - - /** - * @param {Function} ViewModelClassToShow - * @return {boolean} - */ - Knoin.prototype.isPopupVisible = function (ViewModelClassToShow) - { - return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false; - }; - - /** - * @param {string} sScreenName - * @param {string} sSubPart - */ - Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart) - { - var - self = this, - oScreen = null, - oCross = null - ; - - if ('' === Utils.pString(sScreenName)) - { - sScreenName = this.sDefaultScreenName; - } - - if ('' !== sScreenName) - { - oScreen = this.screen(sScreenName); - if (!oScreen) - { - oScreen = this.screen(this.sDefaultScreenName); - if (oScreen) - { - sSubPart = sScreenName + '/' + sSubPart; - sScreenName = this.sDefaultScreenName; - } - } - - if (oScreen && oScreen.__started) - { - if (!oScreen.__builded) - { - oScreen.__builded = true; - - if (Utils.isNonEmptyArray(oScreen.viewModels())) - { - _.each(oScreen.viewModels(), function (ViewModelClass) { - this.buildViewModel(ViewModelClass, oScreen); - }, this); - } - - Utils.delegateRun(oScreen, 'onBuild'); - } - - _.defer(function () { - - // hide screen - if (self.oCurrentScreen) - { - Utils.delegateRun(self.oCurrentScreen, 'onHide'); - - if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels())) - { - _.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) { - - if (ViewModelClass.__vm && ViewModelClass.__dom && - 'Popups' !== ViewModelClass.__vm.viewModelPosition()) - { - ViewModelClass.__dom.hide(); - ViewModelClass.__vm.viewModelVisibility(false); - Utils.delegateRun(ViewModelClass.__vm, 'onHide'); - } - - }); - } - } - // -- - - self.oCurrentScreen = oScreen; - - // show screen - if (self.oCurrentScreen) - { - Utils.delegateRun(self.oCurrentScreen, 'onShow'); - - Plugins.runHook('screen-on-show', [self.oCurrentScreen.screenName(), self.oCurrentScreen]); - - if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels())) - { - _.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) { - - if (ViewModelClass.__vm && ViewModelClass.__dom && - 'Popups' !== ViewModelClass.__vm.viewModelPosition()) - { - ViewModelClass.__dom.show(); - ViewModelClass.__vm.viewModelVisibility(true); - - Utils.delegateRun(ViewModelClass.__vm, 'onShow'); - Utils.delegateRun(ViewModelClass.__vm, 'onFocus', [], 200); - - _.each(ViewModelClass.__names, function (sName) { - Plugins.runHook('view-model-on-show', [sName, ViewModelClass.__vm]); - }); - } - - }, self); - } - } - // -- - - oCross = oScreen.__cross ? oScreen.__cross() : null; - if (oCross) - { - oCross.parse(sSubPart); - } - }); - } - } - }; - - /** - * @param {Array} aScreensClasses - */ - Knoin.prototype.startScreens = function (aScreensClasses) - { - $('#rl-content').css({ - 'visibility': 'hidden' - }); - - _.each(aScreensClasses, function (CScreen) { - - var - oScreen = new CScreen(), - sScreenName = oScreen ? oScreen.screenName() : '' - ; - - if (oScreen && '' !== sScreenName) - { - if ('' === this.sDefaultScreenName) - { - this.sDefaultScreenName = sScreenName; - } - - this.oScreens[sScreenName] = oScreen; - } - - }, this); - - - _.each(this.oScreens, function (oScreen) { - if (oScreen && !oScreen.__started && oScreen.__start) - { - 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]); - } - }, this); - - var oCross = crossroads.create(); - oCross.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/, _.bind(this.screenOnRoute, this)); - - hasher.initialized.add(oCross.parse, oCross); - hasher.changed.add(oCross.parse, oCross); - hasher.init(); - - $('#rl-content').css({ - 'visibility': 'visible' - }); - - _.delay(function () { - Globals.$html.removeClass('rl-started-trigger').addClass('rl-started'); - }, 50); - }; - - /** - * @param {string} sHash - * @param {boolean=} bSilence = false - * @param {boolean=} bReplace = false - */ - Knoin.prototype.setHash = function (sHash, bSilence, bReplace) - { - sHash = '#' === sHash.substr(0, 1) ? sHash.substr(1) : sHash; - sHash = '/' === sHash.substr(0, 1) ? sHash.substr(1) : sHash; - - bReplace = Utils.isUnd(bReplace) ? false : !!bReplace; - - if (Utils.isUnd(bSilence) ? false : !!bSilence) - { - hasher.changed.active = false; - hasher[bReplace ? 'replaceHash' : 'setHash'](sHash); - hasher.changed.active = true; - } - else - { - hasher.changed.active = true; - hasher[bReplace ? 'replaceHash' : 'setHash'](sHash); - hasher.setHash(sHash); - } - }; - - module.exports = new Knoin(); - -}(module, require)); -},{"$":20,"Globals":9,"Plugins":12,"Utils":14,"_":25,"crossroads":17,"hasher":18,"ko":22}],28:[function(require,module,exports){ - -(function (module) { - - 'use strict'; - - /** - * @constructor - */ - function KnoinAbstractBoot() - { - - } - - KnoinAbstractBoot.prototype.bootstart = function () - { - - }; - - module.exports = KnoinAbstractBoot; - -}(module, require)); -},{}],29:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - crossroads = require('crossroads'), - - Utils = require('Utils') - ; - - /** - * @param {string} sScreenName - * @param {?=} aViewModels = [] - * @constructor - */ - function KnoinAbstractScreen(sScreenName, aViewModels) - { - this.sScreenName = sScreenName; - this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : []; - } - - /** - * @type {Array} - */ - KnoinAbstractScreen.prototype.oCross = null; - - /** - * @type {string} - */ - KnoinAbstractScreen.prototype.sScreenName = ''; - - /** - * @type {Array} - */ - KnoinAbstractScreen.prototype.aViewModels = []; - - /** - * @return {Array} - */ - KnoinAbstractScreen.prototype.viewModels = function () - { - return this.aViewModels; - }; - - /** - * @return {string} - */ - KnoinAbstractScreen.prototype.screenName = function () - { - return this.sScreenName; - }; - - KnoinAbstractScreen.prototype.routes = function () - { - return null; - }; - - /** - * @return {?Object} - */ - KnoinAbstractScreen.prototype.__cross = function () - { - return this.oCross; - }; - - KnoinAbstractScreen.prototype.__start = function () - { - var - aRoutes = this.routes(), - oRoute = null, - fMatcher = null - ; - - if (Utils.isNonEmptyArray(aRoutes)) - { - fMatcher = _.bind(this.onRoute || Utils.emptyFunction, this); - oRoute = crossroads.create(); - - _.each(aRoutes, function (aItem) { - oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1]; - }); - - this.oCross = oRoute; - } - }; - - module.exports = KnoinAbstractScreen; - -}(module, require)); -},{"Utils":14,"_":25,"crossroads":17}],30:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - Globals = require('Globals') - ; - - /** - * @constructor - * @param {string=} sPosition = '' - * @param {string=} sTemplate = '' - */ - function KnoinAbstractViewModel(sPosition, sTemplate) - { - this.bDisabeCloseOnEsc = false; - this.sPosition = Utils.pString(sPosition); - this.sTemplate = Utils.pString(sTemplate); - - this.sDefaultKeyScope = Enums.KeyState.None; - this.sCurrentKeyScope = this.sDefaultKeyScope; - - this.viewModelVisibility = ko.observable(false); - this.modalVisibility = ko.observable(false).extend({'rateLimit': 0}); - - this.viewModelName = ''; - this.viewModelNames = []; - this.viewModelDom = null; - } - - /** - * @type {boolean} - */ - KnoinAbstractViewModel.prototype.bDisabeCloseOnEsc = false; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.sPosition = ''; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.sTemplate = ''; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.sDefaultKeyScope = Enums.KeyState.None; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.sCurrentKeyScope = Enums.KeyState.None; - - /** - * @type {string} - */ - KnoinAbstractViewModel.prototype.viewModelName = ''; - - /** - * @type {Array} - */ - KnoinAbstractViewModel.prototype.viewModelNames = []; - - /** - * @type {?} - */ - KnoinAbstractViewModel.prototype.viewModelDom = null; - - /** - * @return {string} - */ - KnoinAbstractViewModel.prototype.viewModelTemplate = function () - { - return this.sTemplate; - }; - - /** - * @return {string} - */ - KnoinAbstractViewModel.prototype.viewModelPosition = function () - { - return this.sPosition; - }; - - KnoinAbstractViewModel.prototype.cancelCommand = function () {}; - KnoinAbstractViewModel.prototype.closeCommand = function () {}; - - KnoinAbstractViewModel.prototype.storeAndSetKeyScope = function () - { - this.sCurrentKeyScope = Globals.keyScope(); - Globals.keyScope(this.sDefaultKeyScope); - }; - - KnoinAbstractViewModel.prototype.restoreKeyScope = function () - { - Globals.keyScope(this.sCurrentKeyScope); - }; - - KnoinAbstractViewModel.prototype.registerPopupKeyDown = function () - { - var self = this; - - Globals.$win.on('keydown', function (oEvent) { - if (oEvent && self.modalVisibility && self.modalVisibility()) - { - 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; - }); - }; - - module.exports = KnoinAbstractViewModel; - -}(module, require)); -},{"Enums":7,"Globals":9,"Utils":14,"ko":22}],31:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Utils = require('Utils') - ; - - /** - * @constructor - * - * @param {string} sEmail - * @param {boolean=} bCanBeDelete = true - */ - function AccountModel(sEmail, bCanBeDelete) - { - this.email = sEmail; - - this.deleteAccess = ko.observable(false); - this.canBeDalete = ko.observable(Utils.isUnd(bCanBeDelete) ? true : !!bCanBeDelete); - } - - /** - * @type {string} - */ - AccountModel.prototype.email = ''; - - /** - * @return {string} - */ - AccountModel.prototype.changeAccountLink = function () - { - return require('LinkBuilder').change(this.email); - }; - - module.exports = AccountModel; - -}(module, require)); -},{"LinkBuilder":11,"Utils":14,"ko":22}],32:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder') - ; - - /** - * @constructor - */ - function AttachmentModel() - { - this.mimeType = ''; - this.fileName = ''; - this.estimatedSize = 0; - this.friendlySize = ''; - this.isInline = false; - this.isLinked = false; - this.cid = ''; - this.cidWithOutTags = ''; - this.contentLocation = ''; - this.download = ''; - this.folder = ''; - this.uid = ''; - this.mimeIndex = ''; - } - - /** - * @static - * @param {AjaxJsonAttachment} oJsonAttachment - * @return {?AttachmentModel} - */ - AttachmentModel.newInstanceFromJson = function (oJsonAttachment) - { - var oAttachmentModel = new AttachmentModel(); - return oAttachmentModel.initByJson(oJsonAttachment) ? oAttachmentModel : null; - }; - - AttachmentModel.prototype.mimeType = ''; - AttachmentModel.prototype.fileName = ''; - AttachmentModel.prototype.estimatedSize = 0; - AttachmentModel.prototype.friendlySize = ''; - AttachmentModel.prototype.isInline = false; - AttachmentModel.prototype.isLinked = false; - AttachmentModel.prototype.cid = ''; - AttachmentModel.prototype.cidWithOutTags = ''; - AttachmentModel.prototype.contentLocation = ''; - AttachmentModel.prototype.download = ''; - AttachmentModel.prototype.folder = ''; - AttachmentModel.prototype.uid = ''; - AttachmentModel.prototype.mimeIndex = ''; - - /** - * @param {AjaxJsonAttachment} oJsonAttachment - */ - AttachmentModel.prototype.initByJson = function (oJsonAttachment) - { - var bResult = false; - if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object']) - { - this.mimeType = (oJsonAttachment.MimeType || '').toLowerCase(); - this.fileName = oJsonAttachment.FileName; - this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize); - this.isInline = !!oJsonAttachment.IsInline; - this.isLinked = !!oJsonAttachment.IsLinked; - this.cid = oJsonAttachment.CID; - this.contentLocation = oJsonAttachment.ContentLocation; - this.download = oJsonAttachment.Download; - - this.folder = oJsonAttachment.Folder; - this.uid = oJsonAttachment.Uid; - this.mimeIndex = oJsonAttachment.MimeIndex; - - this.friendlySize = Utils.friendlySize(this.estimatedSize); - this.cidWithOutTags = this.cid.replace(/^<+/, '').replace(/>+$/, ''); - - bResult = true; - } - - return bResult; - }; - - /** - * @return {boolean} - */ - AttachmentModel.prototype.isImage = function () - { - return -1 < Utils.inArray(this.mimeType.toLowerCase(), - ['image/png', 'image/jpg', 'image/jpeg', 'image/gif'] - ); - }; - - /** - * @return {boolean} - */ - AttachmentModel.prototype.isText = function () - { - return 'text/' === this.mimeType.substr(0, 5) && - -1 === Utils.inArray(this.mimeType, ['text/html']); - }; - - /** - * @return {boolean} - */ - AttachmentModel.prototype.isPdf = function () - { - return Globals.bAllowPdfPreview && 'application/pdf' === this.mimeType; - }; - - /** - * @return {string} - */ - AttachmentModel.prototype.linkDownload = function () - { - return LinkBuilder.attachmentDownload(this.download); - }; - - /** - * @return {string} - */ - AttachmentModel.prototype.linkPreview = function () - { - return LinkBuilder.attachmentPreview(this.download); - }; - - /** - * @return {string} - */ - AttachmentModel.prototype.linkPreviewAsPlain = function () - { - return LinkBuilder.attachmentPreviewAsPlain(this.download); - }; - - /** - * @return {string} - */ - AttachmentModel.prototype.generateTransferDownloadUrl = function () - { - var sLink = this.linkDownload(); - if ('http' !== sLink.substr(0, 4)) - { - sLink = window.location.protocol + '//' + window.location.host + window.location.pathname + sLink; - } - - return this.mimeType + ':' + this.fileName + ':' + sLink; - }; - - /** - * @param {AttachmentModel} oAttachment - * @param {*} oEvent - * @return {boolean} - */ - AttachmentModel.prototype.eventDragStart = function (oAttachment, oEvent) - { - var oLocalEvent = oEvent.originalEvent || oEvent; - if (oAttachment && oLocalEvent && oLocalEvent.dataTransfer && oLocalEvent.dataTransfer.setData) - { - oLocalEvent.dataTransfer.setData('DownloadURL', this.generateTransferDownloadUrl()); - } - - return true; - }; - - AttachmentModel.prototype.iconClass = function () - { - var - aParts = this.mimeType.toLocaleString().split('/'), - sClass = 'icon-file' - ; - - if (aParts && aParts[1]) - { - if ('image' === aParts[0]) - { - sClass = 'icon-file-image'; - } - else if ('text' === aParts[0]) - { - sClass = 'icon-file-text'; - } - else if ('audio' === aParts[0]) - { - sClass = 'icon-file-music'; - } - else if ('video' === aParts[0]) - { - sClass = 'icon-file-movie'; - } - else if (-1 < Utils.inArray(aParts[1], - ['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2', 'x-zip', 'x-7z', 'x-rar', 'x-tar', 'x-gzip', 'x-bzip', 'x-bzip2', 'x-zip-compressed', 'x-7z-compressed', 'x-rar-compressed'])) - { - sClass = 'icon-file-zip'; - } - // else if (-1 < Utils.inArray(aParts[1], - // ['pdf', 'x-pdf'])) - // { - // sClass = 'icon-file-pdf'; - // } - // else if (-1 < Utils.inArray(aParts[1], [ - // 'exe', 'x-exe', 'x-winexe', 'bat' - // ])) - // { - // sClass = 'icon-console'; - // } - else if (-1 < Utils.inArray(aParts[1], [ - 'rtf', 'msword', 'vnd.msword', 'vnd.openxmlformats-officedocument.wordprocessingml.document', - 'vnd.openxmlformats-officedocument.wordprocessingml.template', - 'vnd.ms-word.document.macroEnabled.12', - 'vnd.ms-word.template.macroEnabled.12' - ])) - { - sClass = 'icon-file-text'; - } - else if (-1 < Utils.inArray(aParts[1], [ - 'excel', 'ms-excel', 'vnd.ms-excel', - 'vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'vnd.openxmlformats-officedocument.spreadsheetml.template', - 'vnd.ms-excel.sheet.macroEnabled.12', - 'vnd.ms-excel.template.macroEnabled.12', - 'vnd.ms-excel.addin.macroEnabled.12', - 'vnd.ms-excel.sheet.binary.macroEnabled.12' - ])) - { - sClass = 'icon-file-excel'; - } - else if (-1 < Utils.inArray(aParts[1], [ - 'powerpoint', 'ms-powerpoint', 'vnd.ms-powerpoint', - 'vnd.openxmlformats-officedocument.presentationml.presentation', - 'vnd.openxmlformats-officedocument.presentationml.template', - 'vnd.openxmlformats-officedocument.presentationml.slideshow', - 'vnd.ms-powerpoint.addin.macroEnabled.12', - 'vnd.ms-powerpoint.presentation.macroEnabled.12', - 'vnd.ms-powerpoint.template.macroEnabled.12', - 'vnd.ms-powerpoint.slideshow.macroEnabled.12' - ])) - { - sClass = 'icon-file-chart-graph'; - } - } - - return sClass; - }; - - module.exports = AttachmentModel; - -}(module, require)); -},{"Globals":9,"LinkBuilder":11,"Utils":14,"window":26}],33:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Utils = require('Utils') - ; - - /** - * @constructor - * @param {string} sId - * @param {string} sFileName - * @param {?number=} nSize - * @param {boolean=} bInline - * @param {boolean=} bLinked - * @param {string=} sCID - * @param {string=} sContentLocation - */ - function ComposeAttachmentModel(sId, sFileName, nSize, bInline, bLinked, sCID, sContentLocation) - { - this.id = sId; - this.isInline = Utils.isUnd(bInline) ? false : !!bInline; - this.isLinked = Utils.isUnd(bLinked) ? false : !!bLinked; - this.CID = Utils.isUnd(sCID) ? '' : sCID; - this.contentLocation = Utils.isUnd(sContentLocation) ? '' : sContentLocation; - this.fromMessage = false; - - this.fileName = ko.observable(sFileName); - this.size = ko.observable(Utils.isUnd(nSize) ? null : nSize); - this.tempName = ko.observable(''); - - this.progress = ko.observable(''); - this.error = ko.observable(''); - this.waiting = ko.observable(true); - this.uploading = ko.observable(false); - this.enabled = ko.observable(true); - - this.friendlySize = ko.computed(function () { - var mSize = this.size(); - return null === mSize ? '' : Utils.friendlySize(this.size()); - }, this); - } - - ComposeAttachmentModel.prototype.id = ''; - ComposeAttachmentModel.prototype.isInline = false; - ComposeAttachmentModel.prototype.isLinked = false; - ComposeAttachmentModel.prototype.CID = ''; - ComposeAttachmentModel.prototype.contentLocation = ''; - ComposeAttachmentModel.prototype.fromMessage = false; - ComposeAttachmentModel.prototype.cancel = Utils.emptyFunction; - - /** - * @param {AjaxJsonComposeAttachment} oJsonAttachment - */ - ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment) - { - var bResult = false; - if (oJsonAttachment) - { - this.fileName(oJsonAttachment.Name); - this.size(Utils.isUnd(oJsonAttachment.Size) ? 0 : Utils.pInt(oJsonAttachment.Size)); - this.tempName(Utils.isUnd(oJsonAttachment.TempName) ? '' : oJsonAttachment.TempName); - this.isInline = false; - - bResult = true; - } - - return bResult; - }; - - module.exports = ComposeAttachmentModel; - -}(module, require)); -},{"Utils":14,"ko":22}],34:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder') - ; - - /** - * @constructor - */ - function ContactModel() - { - this.idContact = 0; - this.display = ''; - this.properties = []; - this.tags = ''; - this.readOnly = false; - - this.focused = ko.observable(false); - this.selected = ko.observable(false); - this.checked = ko.observable(false); - this.deleted = ko.observable(false); - } - - /** - * @return {Array|null} - */ - ContactModel.prototype.getNameAndEmailHelper = function () - { - var - sName = '', - sEmail = '' - ; - - if (Utils.isNonEmptyArray(this.properties)) - { - _.each(this.properties, function (aProperty) { - if (aProperty) - { - if (Enums.ContactPropertyType.FirstName === aProperty[0]) - { - sName = Utils.trim(aProperty[1] + ' ' + sName); - } - else if (Enums.ContactPropertyType.LastName === aProperty[0]) - { - sName = Utils.trim(sName + ' ' + aProperty[1]); - } - else if ('' === sEmail && Enums.ContactPropertyType.Email === aProperty[0]) - { - sEmail = aProperty[1]; - } - } - }, this); - } - - return '' === sEmail ? null : [sEmail, sName]; - }; - - ContactModel.prototype.parse = function (oItem) - { - var bResult = false; - if (oItem && 'Object/Contact' === oItem['@Object']) - { - this.idContact = Utils.pInt(oItem['IdContact']); - this.display = Utils.pString(oItem['Display']); - this.readOnly = !!oItem['ReadOnly']; - this.tags = ''; - - if (Utils.isNonEmptyArray(oItem['Properties'])) - { - _.each(oItem['Properties'], function (oProperty) { - if (oProperty && oProperty['Type'] && Utils.isNormal(oProperty['Value']) && Utils.isNormal(oProperty['TypeStr'])) - { - this.properties.push([Utils.pInt(oProperty['Type']), Utils.pString(oProperty['Value']), Utils.pString(oProperty['TypeStr'])]); - } - }, this); - } - - if (Utils.isNonEmptyArray(oItem['Tags'])) - { - this.tags = oItem['Tags'].join(','); - } - - bResult = true; - } - - return bResult; - }; - - /** - * @return {string} - */ - ContactModel.prototype.srcAttr = function () - { - return LinkBuilder.emptyContactPic(); - }; - - /** - * @return {string} - */ - ContactModel.prototype.generateUid = function () - { - return '' + this.idContact; - }; - - /** - * @return string - */ - ContactModel.prototype.lineAsCcc = function () - { - var aResult = []; - if (this.deleted()) - { - aResult.push('deleted'); - } - if (this.selected()) - { - aResult.push('selected'); - } - if (this.checked()) - { - aResult.push('checked'); - } - if (this.focused()) - { - aResult.push('focused'); - } - - return aResult.join(' '); - }; - - module.exports = ContactModel; - -}(module, require)); -},{"Enums":7,"LinkBuilder":11,"Utils":14,"_":25,"ko":22}],35:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils') - ; - - /** - * @constructor - * @param {number=} iType = Enums.ContactPropertyType.Unknown - * @param {string=} sTypeStr = '' - * @param {string=} sValue = '' - * @param {boolean=} bFocused = false - * @param {string=} sPlaceholder = '' - */ - function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder) - { - this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType); - this.typeStr = ko.observable(Utils.isUnd(sTypeStr) ? '' : sTypeStr); - this.focused = ko.observable(Utils.isUnd(bFocused) ? false : !!bFocused); - this.value = ko.observable(Utils.pString(sValue)); - - this.placeholder = ko.observable(sPlaceholder || ''); - - this.placeholderValue = ko.computed(function () { - var sPlaceholder = this.placeholder(); - return sPlaceholder ? Utils.i18n(sPlaceholder) : ''; - }, this); - - this.largeValue = ko.computed(function () { - return Enums.ContactPropertyType.Note === this.type(); - }, this); - } - - module.exports = ContactPropertyModel; - -}(module, require)); -},{"Enums":7,"Utils":14,"ko":22}],36:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Utils = require('Utils') - ; - - /** - * @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(); - }; - - module.exports = ContactTagModel; - -}(module, require)); -},{"Utils":14,"ko":22}],37:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - Utils = require('Utils') - ; - - /** - * @param {string=} sEmail - * @param {string=} sName - * - * @constructor - */ - function EmailModel(sEmail, sName) - { - this.email = sEmail || ''; - this.name = sName || ''; - - this.clearDuplicateName(); - } - - /** - * @static - * @param {AjaxJsonEmail} oJsonEmail - * @return {?EmailModel} - */ - EmailModel.newInstanceFromJson = function (oJsonEmail) - { - var oEmailModel = new EmailModel(); - return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null; - }; - - /** - * @type {string} - */ - EmailModel.prototype.name = ''; - - /** - * @type {string} - */ - EmailModel.prototype.email = ''; - - EmailModel.prototype.clear = function () - { - this.email = ''; - this.name = ''; - }; - - /** - * @returns {boolean} - */ - EmailModel.prototype.validate = function () - { - return '' !== this.name || '' !== this.email; - }; - - /** - * @param {boolean} bWithoutName = false - * @return {string} - */ - EmailModel.prototype.hash = function (bWithoutName) - { - return '#' + (bWithoutName ? '' : this.name) + '#' + this.email + '#'; - }; - - EmailModel.prototype.clearDuplicateName = function () - { - if (this.name === this.email) - { - this.name = ''; - } - }; - - /** - * @param {string} sQuery - * @return {boolean} - */ - EmailModel.prototype.search = function (sQuery) - { - return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(sQuery.toLowerCase()); - }; - - /** - * @param {string} sString - */ - EmailModel.prototype.parse = function (sString) - { - this.clear(); - - sString = Utils.trim(sString); - - var - mRegex = /(?:"([^"]+)")? ?,]+)>?,? ?/g, - mMatch = mRegex.exec(sString) - ; - - if (mMatch) - { - this.name = mMatch[1] || ''; - this.email = mMatch[2] || ''; - - this.clearDuplicateName(); - } - else if ((/^[^@]+@[^@]+$/).test(sString)) - { - this.name = ''; - this.email = sString; - } - }; - - /** - * @param {AjaxJsonEmail} oJsonEmail - * @return {boolean} - */ - EmailModel.prototype.initByJson = function (oJsonEmail) - { - var bResult = false; - if (oJsonEmail && 'Object/Email' === oJsonEmail['@Object']) - { - this.name = Utils.trim(oJsonEmail.Name); - this.email = Utils.trim(oJsonEmail.Email); - - bResult = '' !== this.email; - this.clearDuplicateName(); - } - - return bResult; - }; - - /** - * @param {boolean} bFriendlyView - * @param {boolean=} bWrapWithLink = false - * @param {boolean=} bEncodeHtml = false - * @return {string} - */ - EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtml) - { - var sResult = ''; - if ('' !== this.email) - { - bWrapWithLink = Utils.isUnd(bWrapWithLink) ? false : !!bWrapWithLink; - bEncodeHtml = Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml; - - if (bFriendlyView && '' !== this.name) - { - sResult = bWrapWithLink ? '
') + - '" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.name) + '' : - (bEncodeHtml ? Utils.encodeHtml(this.name) : this.name); - } - else - { - sResult = this.email; - if ('' !== this.name) - { - if (bWrapWithLink) - { - sResult = Utils.encodeHtml('"' + this.name + '" <') + - '') + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(sResult) + '' + Utils.encodeHtml('>'); - } - else - { - sResult = '"' + this.name + '" <' + sResult + '>'; - if (bEncodeHtml) - { - sResult = Utils.encodeHtml(sResult); - } - } - } - else if (bWrapWithLink) - { - sResult = '' + Utils.encodeHtml(this.email) + ''; - } - } - } - - return sResult; - }; - - /** - * @param {string} $sEmailAddress - * @return {boolean} - */ - EmailModel.prototype.mailsoParse = function ($sEmailAddress) - { - $sEmailAddress = Utils.trim($sEmailAddress); - if ('' === $sEmailAddress) - { - return false; - } - - var - substr = function (str, start, len) { - str += ''; - var end = str.length; - - if (start < 0) { - start += end; - } - - end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start); - - return start >= str.length || start < 0 || start > end ? false : str.slice(start, end); - }, - - substr_replace = function (str, replace, start, length) { - if (start < 0) { - start = start + str.length; - } - length = length !== undefined ? length : str.length; - if (length < 0) { - length = length + str.length - start; - } - return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length); - }, - - $sName = '', - $sEmail = '', - $sComment = '', - - $bInName = false, - $bInAddress = false, - $bInComment = false, - - $aRegs = null, - - $iStartIndex = 0, - $iEndIndex = 0, - $iCurrentIndex = 0 - ; - - while ($iCurrentIndex < $sEmailAddress.length) - { - switch ($sEmailAddress.substr($iCurrentIndex, 1)) - { - case '"': - if ((!$bInName) && (!$bInAddress) && (!$bInComment)) - { - $bInName = true; - $iStartIndex = $iCurrentIndex; - } - else if ((!$bInAddress) && (!$bInComment)) - { - $iEndIndex = $iCurrentIndex; - $sName = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); - $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); - $iEndIndex = 0; - $iCurrentIndex = 0; - $iStartIndex = 0; - $bInName = false; - } - break; - case '<': - if ((!$bInName) && (!$bInAddress) && (!$bInComment)) - { - if ($iCurrentIndex > 0 && $sName.length === 0) - { - $sName = substr($sEmailAddress, 0, $iCurrentIndex); - } - - $bInAddress = true; - $iStartIndex = $iCurrentIndex; - } - break; - case '>': - if ($bInAddress) - { - $iEndIndex = $iCurrentIndex; - $sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); - $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); - $iEndIndex = 0; - $iCurrentIndex = 0; - $iStartIndex = 0; - $bInAddress = false; - } - break; - case '(': - if ((!$bInName) && (!$bInAddress) && (!$bInComment)) - { - $bInComment = true; - $iStartIndex = $iCurrentIndex; - } - break; - case ')': - if ($bInComment) - { - $iEndIndex = $iCurrentIndex; - $sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); - $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); - $iEndIndex = 0; - $iCurrentIndex = 0; - $iStartIndex = 0; - $bInComment = false; - } - break; - case '\\': - $iCurrentIndex++; - break; - } - - $iCurrentIndex++; - } - - if ($sEmail.length === 0) - { - $aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i); - if ($aRegs && $aRegs[0]) - { - $sEmail = $aRegs[0]; - } - else - { - $sName = $sEmailAddress; - } - } - - if ($sEmail.length > 0 && $sName.length === 0 && $sComment.length === 0) - { - $sName = $sEmailAddress.replace($sEmail, ''); - } - - $sEmail = Utils.trim($sEmail).replace(/^[<]+/, '').replace(/[>]+$/, ''); - $sName = Utils.trim($sName).replace(/^["']+/, '').replace(/["']+$/, ''); - $sComment = Utils.trim($sComment).replace(/^[(]+/, '').replace(/[)]+$/, ''); - - // Remove backslash - $sName = $sName.replace(/\\\\(.)/g, '$1'); - $sComment = $sComment.replace(/\\\\(.)/g, '$1'); - - this.name = $sName; - this.email = $sEmail; - - this.clearDuplicateName(); - return true; - }; - - /** - * @return {string} - */ - EmailModel.prototype.inputoTagLine = function () - { - return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email; - }; - - module.exports = EmailModel; - -}(module, require)); -},{"Utils":14}],38:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Enums = require('Enums') - ; - - /** - * @param {*} oKoList - * @constructor - */ - function FilterConditionModel(oKoList) - { - this.parentList = oKoList; - - this.field = ko.observable(Enums.FilterConditionField.From); - - this.fieldOptions = [ // TODO i18n - {'id': Enums.FilterConditionField.From, 'name': 'From'}, - {'id': Enums.FilterConditionField.Recipient, 'name': 'Recipient (To or CC)'}, - {'id': Enums.FilterConditionField.To, 'name': 'To'}, - {'id': Enums.FilterConditionField.Subject, 'name': 'Subject'} - ]; - - this.type = ko.observable(Enums.FilterConditionType.EqualTo); - - this.typeOptions = [ // TODO i18n - {'id': Enums.FilterConditionType.EqualTo, 'name': 'Equal To'}, - {'id': Enums.FilterConditionType.NotEqualTo, 'name': 'Not Equal To'}, - {'id': Enums.FilterConditionType.Contains, 'name': 'Contains'}, - {'id': Enums.FilterConditionType.NotContains, 'name': 'Not Contains'} - ]; - - this.value = ko.observable(''); - - this.template = ko.computed(function () { - - var sTemplate = ''; - switch (this.type()) - { - default: - sTemplate = 'SettingsFiltersConditionDefault'; - break; - } - - return sTemplate; - - }, this); - } - - FilterConditionModel.prototype.removeSelf = function () - { - this.parentList.remove(this); - }; - - module.exports = FilterConditionModel; - -}(module, require)); -},{"Enums":7,"ko":22}],39:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - FilterConditionModel = require('Model:FilterCondition') - ; - - /** - * @constructor - */ - function FilterModel() - { - this.isNew = ko.observable(true); - this.enabled = ko.observable(true); - - this.name = ko.observable(''); - - this.conditionsType = ko.observable(Enums.FilterRulesType.And); - - this.conditions = ko.observableArray([]); - - this.conditions.subscribe(function () { - Utils.windowResize(); - }); - - // Actions - this.actionMarkAsRead = ko.observable(false); - this.actionSkipOtherFilters = ko.observable(true); - this.actionValue = ko.observable(''); - - this.actionType = ko.observable(Enums.FiltersAction.Move); - this.actionTypeOptions = [ // TODO i18n - {'id': Enums.FiltersAction.None, 'name': 'Action - None'}, - {'id': Enums.FiltersAction.Move, 'name': 'Action - Move to'}, - // {'id': Enums.FiltersAction.Forward, 'name': 'Action - Forward to'}, - {'id': Enums.FiltersAction.Discard, 'name': 'Action - Discard'} - ]; - - this.actionMarkAsReadVisiblity = ko.computed(function () { - return -1 < Utils.inArray(this.actionType(), [ - Enums.FiltersAction.None, Enums.FiltersAction.Forward, Enums.FiltersAction.Move - ]); - }, this); - - this.actionTemplate = ko.computed(function () { - - var sTemplate = ''; - switch (this.actionType()) - { - default: - case Enums.FiltersAction.Move: - sTemplate = 'SettingsFiltersActionValueAsFolders'; - break; - case Enums.FiltersAction.Forward: - sTemplate = 'SettingsFiltersActionWithValue'; - break; - case Enums.FiltersAction.None: - case Enums.FiltersAction.Discard: - sTemplate = 'SettingsFiltersActionNoValue'; - break; - } - - return sTemplate; - - }, this); - } - - FilterModel.prototype.addCondition = function () - { - this.conditions.push(new FilterConditionModel(this.conditions)); - }; - - FilterModel.prototype.parse = function (oItem) - { - var bResult = false; - if (oItem && 'Object/Filter' === oItem['@Object']) - { - this.name(Utils.pString(oItem['Name'])); - - bResult = true; - } - - return bResult; - }; - - module.exports = FilterModel; - -}(module, require)); -},{"Enums":7,"Model:FilterCondition":38,"Utils":14,"ko":22}],40:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - Events = require('Events') - ; - - /** - * @constructor - */ - function FolderModel() - { - this.name = ko.observable(''); - this.fullName = ''; - this.fullNameRaw = ''; - this.fullNameHash = ''; - this.delimiter = ''; - this.namespace = ''; - this.deep = 0; - this.interval = 0; - - this.selectable = false; - this.existen = true; - - this.type = ko.observable(Enums.FolderType.User); - - this.focused = ko.observable(false); - this.selected = ko.observable(false); - this.edited = ko.observable(false); - this.collapsed = ko.observable(true); - this.subScribed = ko.observable(true); - this.subFolders = ko.observableArray([]); - this.deleteAccess = ko.observable(false); - this.actionBlink = ko.observable(false).extend({'falseTimeout': 1000}); - - this.nameForEdit = ko.observable(''); - - this.privateMessageCountAll = ko.observable(0); - this.privateMessageCountUnread = ko.observable(0); - - this.collapsedPrivate = ko.observable(true); - } - - /** - * @static - * @param {AjaxJsonFolder} oJsonFolder - * @return {?FolderModel} - */ - FolderModel.newInstanceFromJson = function (oJsonFolder) - { - var oFolderModel = new FolderModel(); - return oFolderModel.initByJson(oJsonFolder) ? oFolderModel.initComputed() : null; - }; - - /** - * @return {FolderModel} - */ - FolderModel.prototype.initComputed = function () - { - this.hasSubScribedSubfolders = ko.computed(function () { - return !!_.find(this.subFolders(), function (oFolder) { - return oFolder.subScribed() && !oFolder.isSystemFolder(); - }); - }, this); - - this.canBeEdited = ko.computed(function () { - return Enums.FolderType.User === this.type() && this.existen && this.selectable; - }, this); - - this.visible = ko.computed(function () { - var - bSubScribed = this.subScribed(), - bSubFolders = this.hasSubScribedSubfolders() - ; - - return (bSubScribed || (bSubFolders && (!this.existen || !this.selectable))); - }, this); - - this.isSystemFolder = ko.computed(function () { - return Enums.FolderType.User !== this.type(); - }, this); - - this.hidden = ko.computed(function () { - var - bSystem = this.isSystemFolder(), - bSubFolders = this.hasSubScribedSubfolders() - ; - - return (bSystem && !bSubFolders) || (!this.selectable && !bSubFolders); - - }, this); - - this.selectableForFolderList = ko.computed(function () { - return !this.isSystemFolder() && this.selectable; - }, this); - - this.messageCountAll = ko.computed({ - 'read': this.privateMessageCountAll, - 'write': function (iValue) { - if (Utils.isPosNumeric(iValue, true)) - { - this.privateMessageCountAll(iValue); - } - else - { - this.privateMessageCountAll.valueHasMutated(); - } - }, - 'owner': this - }); - - this.messageCountUnread = ko.computed({ - 'read': this.privateMessageCountUnread, - 'write': function (iValue) { - if (Utils.isPosNumeric(iValue, true)) - { - this.privateMessageCountUnread(iValue); - } - else - { - this.privateMessageCountUnread.valueHasMutated(); - } - }, - 'owner': this - }); - - this.printableUnreadCount = ko.computed(function () { - var - iCount = this.messageCountAll(), - iUnread = this.messageCountUnread(), - iType = this.type() - ; - - if (0 < iCount) - { - if (Enums.FolderType.Draft === iType) - { - return '' + iCount; - } - else if (0 < iUnread && Enums.FolderType.Trash !== iType && Enums.FolderType.Archive !== iType && Enums.FolderType.SentItems !== iType) - { - return '' + iUnread; - } - } - - return ''; - - }, this); - - this.canBeDeleted = ko.computed(function () { - var - bSystem = this.isSystemFolder() - ; - return !bSystem && 0 === this.subFolders().length && 'INBOX' !== this.fullNameRaw; - }, this); - - this.canBeSubScribed = ko.computed(function () { - return !this.isSystemFolder() && this.selectable && 'INBOX' !== this.fullNameRaw; - }, this); - -// this.visible.subscribe(function () { -// Utils.timeOutAction('folder-list-folder-visibility-change', function () { -// Globals.$win.trigger('folder-list-folder-visibility-change'); -// }, 100); -// }); - - this.localName = ko.computed(function () { - - Globals.langChangeTrigger(); - - var - iType = this.type(), - sName = this.name() - ; - - if (this.isSystemFolder()) - { - switch (iType) - { - case Enums.FolderType.Inbox: - sName = Utils.i18n('FOLDER_LIST/INBOX_NAME'); - break; - case Enums.FolderType.SentItems: - sName = Utils.i18n('FOLDER_LIST/SENT_NAME'); - break; - case Enums.FolderType.Draft: - sName = Utils.i18n('FOLDER_LIST/DRAFTS_NAME'); - break; - case Enums.FolderType.Spam: - sName = Utils.i18n('FOLDER_LIST/SPAM_NAME'); - break; - case Enums.FolderType.Trash: - sName = Utils.i18n('FOLDER_LIST/TRASH_NAME'); - break; - case Enums.FolderType.Archive: - sName = Utils.i18n('FOLDER_LIST/ARCHIVE_NAME'); - break; - } - } - - return sName; - - }, this); - - this.manageFolderSystemName = ko.computed(function () { - - Globals.langChangeTrigger(); - - var - sSuffix = '', - iType = this.type(), - sName = this.name() - ; - - if (this.isSystemFolder()) - { - switch (iType) - { - case Enums.FolderType.Inbox: - sSuffix = '(' + Utils.i18n('FOLDER_LIST/INBOX_NAME') + ')'; - break; - case Enums.FolderType.SentItems: - sSuffix = '(' + Utils.i18n('FOLDER_LIST/SENT_NAME') + ')'; - break; - case Enums.FolderType.Draft: - sSuffix = '(' + Utils.i18n('FOLDER_LIST/DRAFTS_NAME') + ')'; - break; - case Enums.FolderType.Spam: - sSuffix = '(' + Utils.i18n('FOLDER_LIST/SPAM_NAME') + ')'; - break; - case Enums.FolderType.Trash: - sSuffix = '(' + Utils.i18n('FOLDER_LIST/TRASH_NAME') + ')'; - break; - case Enums.FolderType.Archive: - sSuffix = '(' + Utils.i18n('FOLDER_LIST/ARCHIVE_NAME') + ')'; - break; - } - } - - if ('' !== sSuffix && '(' + sName + ')' === sSuffix || '(inbox)' === sSuffix.toLowerCase()) - { - sSuffix = ''; - } - - return sSuffix; - - }, this); - - this.collapsed = ko.computed({ - 'read': function () { - return !this.hidden() && this.collapsedPrivate(); - }, - 'write': function (mValue) { - this.collapsedPrivate(mValue); - }, - 'owner': this - }); - - this.hasUnreadMessages = ko.computed(function () { - return 0 < this.messageCountUnread(); - }, this); - - this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function () { - return !!_.find(this.subFolders(), function (oFolder) { - return oFolder.hasUnreadMessages() || oFolder.hasSubScribedUnreadMessagesSubfolders(); - }); - }, this); - - // subscribe - this.name.subscribe(function (sValue) { - this.nameForEdit(sValue); - }, this); - - this.edited.subscribe(function (bValue) { - if (bValue) - { - this.nameForEdit(this.name()); - } - }, this); - - this.messageCountUnread.subscribe(function (iUnread) { - if (Enums.FolderType.Inbox === this.type()) - { - Events.pub('mailbox.inbox-unread-count', [iUnread]); - } - }, this); - - return this; - }; - - FolderModel.prototype.fullName = ''; - FolderModel.prototype.fullNameRaw = ''; - FolderModel.prototype.fullNameHash = ''; - FolderModel.prototype.delimiter = ''; - FolderModel.prototype.namespace = ''; - FolderModel.prototype.deep = 0; - FolderModel.prototype.interval = 0; - - /** - * @return {string} - */ - FolderModel.prototype.collapsedCss = function () - { - return this.hasSubScribedSubfolders() ? - (this.collapsed() ? 'icon-right-mini e-collapsed-sign' : 'icon-down-mini e-collapsed-sign') : 'icon-none e-collapsed-sign'; - }; - - /** - * @param {AjaxJsonFolder} oJsonFolder - * @return {boolean} - */ - FolderModel.prototype.initByJson = function (oJsonFolder) - { - var bResult = false; - if (oJsonFolder && 'Object/Folder' === oJsonFolder['@Object']) - { - this.name(oJsonFolder.Name); - this.delimiter = oJsonFolder.Delimiter; - this.fullName = oJsonFolder.FullName; - this.fullNameRaw = oJsonFolder.FullNameRaw; - this.fullNameHash = oJsonFolder.FullNameHash; - this.deep = oJsonFolder.FullNameRaw.split(this.delimiter).length - 1; - this.selectable = !!oJsonFolder.IsSelectable; - this.existen = !!oJsonFolder.IsExists; - - this.subScribed(!!oJsonFolder.IsSubscribed); - this.type('INBOX' === this.fullNameRaw ? Enums.FolderType.Inbox : Enums.FolderType.User); - - bResult = true; - } - - return bResult; - }; - - /** - * @return {string} - */ - FolderModel.prototype.printableFullName = function () - { - return this.fullName.split(this.delimiter).join(' / '); - }; - - module.exports = FolderModel; - -}(module, require)); -},{"Enums":7,"Events":8,"Globals":9,"Utils":14,"_":25,"ko":22}],41:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Utils = require('Utils') - ; - - /** - * @param {string} sId - * @param {string} sEmail - * @param {boolean=} bCanBeDelete = true - * @constructor - */ - function IdentityModel(sId, sEmail, bCanBeDelete) - { - this.id = sId; - this.email = ko.observable(sEmail); - this.name = ko.observable(''); - this.replyTo = ko.observable(''); - this.bcc = ko.observable(''); - - this.deleteAccess = ko.observable(false); - this.canBeDalete = ko.observable(bCanBeDelete); - } - - IdentityModel.prototype.formattedName = function () - { - var sName = this.name(); - return '' === sName ? this.email() : sName + ' <' + this.email() + '>'; - }; - - IdentityModel.prototype.formattedNameForCompose = function () - { - var sName = this.name(); - return '' === sName ? this.email() : sName + ' (' + this.email() + ')'; - }; - - IdentityModel.prototype.formattedNameForEmail = function () - { - var sName = this.name(); - return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>'; - }; - - module.exports = IdentityModel; - -}(module, require)); -},{"Utils":14,"ko":22}],42:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - ko = require('ko'), - moment = require('moment'), - - Enums = require('Enums'), - Utils = require('Utils'), - Globals = require('Globals'), - LinkBuilder = require('LinkBuilder'), - - EmailModel = require('Model:Email'), - AttachmentModel = require('Model:Attachment') - ; - - /** - * @constructor - */ - function MessageModel() - { - this.folderFullNameRaw = ''; - this.uid = ''; - this.hash = ''; - this.requestHash = ''; - this.subject = ko.observable(''); - this.subjectPrefix = ko.observable(''); - this.subjectSuffix = ko.observable(''); - this.size = ko.observable(0); - this.dateTimeStampInUTC = ko.observable(0); - this.priority = ko.observable(Enums.MessagePriority.Normal); - - this.proxy = false; - - this.fromEmailString = ko.observable(''); - this.fromClearEmailString = ko.observable(''); - this.toEmailsString = ko.observable(''); - this.toClearEmailsString = ko.observable(''); - - this.senderEmailsString = ko.observable(''); - this.senderClearEmailsString = ko.observable(''); - - this.emails = []; - - this.from = []; - this.to = []; - this.cc = []; - this.bcc = []; - this.replyTo = []; - this.deliveredTo = []; - - this.newForAnimation = ko.observable(false); - - this.deleted = ko.observable(false); - this.unseen = ko.observable(false); - this.flagged = ko.observable(false); - this.answered = ko.observable(false); - this.forwarded = ko.observable(false); - this.isReadReceipt = ko.observable(false); - - this.focused = ko.observable(false); - this.selected = ko.observable(false); - this.checked = ko.observable(false); - this.hasAttachments = ko.observable(false); - this.attachmentsMainType = ko.observable(''); - - this.moment = ko.observable(moment(moment.unix(0))); - - this.attachmentIconClass = ko.computed(function () { - var sClass = ''; - if (this.hasAttachments()) - { - sClass = 'icon-attachment'; - switch (this.attachmentsMainType()) - { - case 'image': - sClass = 'icon-image'; - break; - case 'archive': - sClass = 'icon-file-zip'; - break; - case 'doc': - sClass = 'icon-file-text'; - break; - // case 'pdf': - // sClass = 'icon-file-pdf'; - // break; - } - } - return sClass; - }, this); - - this.fullFormatDateValue = ko.computed(function () { - return MessageModel.calculateFullFromatDateValue(this.dateTimeStampInUTC()); - }, this); - - this.momentDate = Utils.createMomentDate(this); - this.momentShortDate = Utils.createMomentShortDate(this); - - this.dateTimeStampInUTC.subscribe(function (iValue) { - var iNow = moment().unix(); - this.moment(moment.unix(iNow < iValue ? iNow : iValue)); - }, this); - - this.body = null; - this.plainRaw = ''; - this.isHtml = ko.observable(false); - this.hasImages = ko.observable(false); - this.attachments = ko.observableArray([]); - - this.isPgpSigned = ko.observable(false); - this.isPgpEncrypted = ko.observable(false); - this.pgpSignedVerifyStatus = ko.observable(Enums.SignedVerifyStatus.None); - this.pgpSignedVerifyUser = ko.observable(''); - - this.priority = ko.observable(Enums.MessagePriority.Normal); - this.readReceipt = ko.observable(''); - - this.aDraftInfo = []; - this.sMessageId = ''; - this.sInReplyTo = ''; - this.sReferences = ''; - - this.parentUid = ko.observable(0); - this.threads = ko.observableArray([]); - this.threadsLen = ko.observable(0); - this.hasUnseenSubMessage = ko.observable(false); - this.hasFlaggedSubMessage = ko.observable(false); - - this.lastInCollapsedThread = ko.observable(false); - this.lastInCollapsedThreadLoading = ko.observable(false); - - this.threadsLenResult = ko.computed(function () { - var iCount = this.threadsLen(); - return 0 === this.parentUid() && 0 < iCount ? iCount + 1 : ''; - }, this); - } - - /** - * @static - * @param {AjaxJsonMessage} oJsonMessage - * @return {?MessageModel} - */ - MessageModel.newInstanceFromJson = function (oJsonMessage) - { - var oMessageModel = new MessageModel(); - return oMessageModel.initByJson(oJsonMessage) ? oMessageModel : null; - }; - - /** - * @static - * @param {number} iTimeStampInUTC - * @return {string} - */ - MessageModel.calculateFullFromatDateValue = function (iTimeStampInUTC) - { - return 0 < iTimeStampInUTC ? moment.unix(iTimeStampInUTC).format('LLL') : ''; - }; - - /** - * @static - * @param {Array} aEmail - * @param {boolean=} bFriendlyView - * @param {boolean=} bWrapWithLink = false - * @return {string} - */ - MessageModel.emailsToLine = function (aEmail, bFriendlyView, bWrapWithLink) - { - var - aResult = [], - iIndex = 0, - iLen = 0 - ; - - if (Utils.isNonEmptyArray(aEmail)) - { - for (iIndex = 0, iLen = aEmail.length; iIndex < iLen; iIndex++) - { - aResult.push(aEmail[iIndex].toLine(bFriendlyView, bWrapWithLink)); - } - } - - return aResult.join(', '); - }; - - /** - * @static - * @param {Array} aEmail - * @return {string} - */ - MessageModel.emailsToLineClear = function (aEmail) - { - var - aResult = [], - iIndex = 0, - iLen = 0 - ; - - if (Utils.isNonEmptyArray(aEmail)) - { - for (iIndex = 0, iLen = aEmail.length; iIndex < iLen; iIndex++) - { - if (aEmail[iIndex] && aEmail[iIndex].email && '' !== aEmail[iIndex].name) - { - aResult.push(aEmail[iIndex].email); - } - } - } - - return aResult.join(', '); - }; - - /** - * @static - * @param {?Array} aJsonEmails - * @return {Array.} - */ - MessageModel.initEmailsFromJson = function (aJsonEmails) - { - var - iIndex = 0, - iLen = 0, - oEmailModel = null, - aResult = [] - ; - - if (Utils.isNonEmptyArray(aJsonEmails)) - { - for (iIndex = 0, iLen = aJsonEmails.length; iIndex < iLen; iIndex++) - { - oEmailModel = EmailModel.newInstanceFromJson(aJsonEmails[iIndex]); - if (oEmailModel) - { - aResult.push(oEmailModel); - } - } - } - - return aResult; - }; - - /** - * @static - * @param {Array.} aMessageEmails - * @param {Object} oLocalUnic - * @param {Array} aLocalEmails - */ - MessageModel.replyHelper = function (aMessageEmails, oLocalUnic, aLocalEmails) - { - if (aMessageEmails && 0 < aMessageEmails.length) - { - var - iIndex = 0, - iLen = aMessageEmails.length - ; - - for (; iIndex < iLen; iIndex++) + if (aMessageEmails && 0 < aMessageEmails.length) { - if (Utils.isUnd(oLocalUnic[aMessageEmails[iIndex].email])) + var + iIndex = 0, + iLen = aMessageEmails.length + ; + + for (; iIndex < iLen; iIndex++) { - oLocalUnic[aMessageEmails[iIndex].email] = true; - aLocalEmails.push(aMessageEmails[iIndex]); - } - } - } - }; - - MessageModel.prototype.clear = function () - { - this.folderFullNameRaw = ''; - this.uid = ''; - this.hash = ''; - this.requestHash = ''; - this.subject(''); - this.subjectPrefix(''); - this.subjectSuffix(''); - this.size(0); - this.dateTimeStampInUTC(0); - this.priority(Enums.MessagePriority.Normal); - - this.proxy = false; - - this.fromEmailString(''); - this.fromClearEmailString(''); - this.toEmailsString(''); - this.toClearEmailsString(''); - this.senderEmailsString(''); - this.senderClearEmailsString(''); - - this.emails = []; - - this.from = []; - this.to = []; - this.cc = []; - this.bcc = []; - this.replyTo = []; - this.deliveredTo = []; - - this.newForAnimation(false); - - this.deleted(false); - this.unseen(false); - this.flagged(false); - this.answered(false); - this.forwarded(false); - this.isReadReceipt(false); - - this.selected(false); - this.checked(false); - this.hasAttachments(false); - this.attachmentsMainType(''); - - this.body = null; - this.isHtml(false); - this.hasImages(false); - this.attachments([]); - - this.isPgpSigned(false); - this.isPgpEncrypted(false); - this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None); - this.pgpSignedVerifyUser(''); - - this.priority(Enums.MessagePriority.Normal); - this.readReceipt(''); - this.aDraftInfo = []; - this.sMessageId = ''; - this.sInReplyTo = ''; - this.sReferences = ''; - - this.parentUid(0); - this.threads([]); - this.threadsLen(0); - this.hasUnseenSubMessage(false); - this.hasFlaggedSubMessage(false); - - this.lastInCollapsedThread(false); - this.lastInCollapsedThreadLoading(false); - }; - - /** - * @return {string} - */ - MessageModel.prototype.friendlySize = function () - { - return Utils.friendlySize(this.size()); - }; - - MessageModel.prototype.computeSenderEmail = function () - { - var - Data = require('Storage:RainLoop:Data'), - sSent = Data.sentFolder(), - sDraft = Data.draftFolder() - ; - - this.senderEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ? - this.toEmailsString() : this.fromEmailString()); - - this.senderClearEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ? - this.toClearEmailsString() : this.fromClearEmailString()); - }; - - /** - * @param {AjaxJsonMessage} oJsonMessage - * @return {boolean} - */ - MessageModel.prototype.initByJson = function (oJsonMessage) - { - var bResult = false; - if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) - { - this.folderFullNameRaw = oJsonMessage.Folder; - this.uid = oJsonMessage.Uid; - this.hash = oJsonMessage.Hash; - this.requestHash = oJsonMessage.RequestHash; - - this.proxy = !!oJsonMessage.ExternalProxy; - - this.size(Utils.pInt(oJsonMessage.Size)); - - this.from = MessageModel.initEmailsFromJson(oJsonMessage.From); - this.to = MessageModel.initEmailsFromJson(oJsonMessage.To); - this.cc = MessageModel.initEmailsFromJson(oJsonMessage.Cc); - this.bcc = MessageModel.initEmailsFromJson(oJsonMessage.Bcc); - this.replyTo = MessageModel.initEmailsFromJson(oJsonMessage.ReplyTo); - this.deliveredTo = MessageModel.initEmailsFromJson(oJsonMessage.DeliveredTo); - - this.subject(oJsonMessage.Subject); - if (Utils.isArray(oJsonMessage.SubjectParts)) - { - this.subjectPrefix(oJsonMessage.SubjectParts[0]); - this.subjectSuffix(oJsonMessage.SubjectParts[1]); - } - else - { - this.subjectPrefix(''); - this.subjectSuffix(this.subject()); - } - - this.dateTimeStampInUTC(Utils.pInt(oJsonMessage.DateTimeStampInUTC)); - this.hasAttachments(!!oJsonMessage.HasAttachments); - this.attachmentsMainType(oJsonMessage.AttachmentsMainType); - - this.fromEmailString(MessageModel.emailsToLine(this.from, true)); - this.fromClearEmailString(MessageModel.emailsToLineClear(this.from)); - this.toEmailsString(MessageModel.emailsToLine(this.to, true)); - this.toClearEmailsString(MessageModel.emailsToLineClear(this.to)); - - this.parentUid(Utils.pInt(oJsonMessage.ParentThread)); - this.threads(Utils.isArray(oJsonMessage.Threads) ? oJsonMessage.Threads : []); - this.threadsLen(Utils.pInt(oJsonMessage.ThreadsLen)); - - this.initFlagsByJson(oJsonMessage); - this.computeSenderEmail(); - - bResult = true; - } - - return bResult; - }; - - /** - * @param {AjaxJsonMessage} oJsonMessage - * @return {boolean} - */ - MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage) - { - var - Data = require('Storage:RainLoop:Data'), - bResult = false, - iPriority = Enums.MessagePriority.Normal - ; - - if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) - { - iPriority = Utils.pInt(oJsonMessage.Priority); - this.priority(-1 < Utils.inArray(iPriority, [Enums.MessagePriority.High, Enums.MessagePriority.Low]) ? - iPriority : Enums.MessagePriority.Normal); - - this.aDraftInfo = oJsonMessage.DraftInfo; - - this.sMessageId = oJsonMessage.MessageId; - this.sInReplyTo = oJsonMessage.InReplyTo; - this.sReferences = oJsonMessage.References; - - this.proxy = !!oJsonMessage.ExternalProxy; - - if (Data.capaOpenPGP()) - { - this.isPgpSigned(!!oJsonMessage.PgpSigned); - this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted); - } - - this.hasAttachments(!!oJsonMessage.HasAttachments); - this.attachmentsMainType(oJsonMessage.AttachmentsMainType); - - this.foundedCIDs = Utils.isArray(oJsonMessage.FoundedCIDs) ? oJsonMessage.FoundedCIDs : []; - this.attachments(this.initAttachmentsFromJson(oJsonMessage.Attachments)); - - this.readReceipt(oJsonMessage.ReadReceipt || ''); - - this.computeSenderEmail(); - - bResult = true; - } - - return bResult; - }; - - /** - * @param {(AjaxJsonAttachment|null)} oJsonAttachments - * @return {Array} - */ - MessageModel.prototype.initAttachmentsFromJson = function (oJsonAttachments) - { - var - iIndex = 0, - iLen = 0, - oAttachmentModel = null, - aResult = [] - ; - - if (oJsonAttachments && 'Collection/AttachmentCollection' === oJsonAttachments['@Object'] && - Utils.isNonEmptyArray(oJsonAttachments['@Collection'])) - { - for (iIndex = 0, iLen = oJsonAttachments['@Collection'].length; iIndex < iLen; iIndex++) - { - oAttachmentModel = AttachmentModel.newInstanceFromJson(oJsonAttachments['@Collection'][iIndex]); - if (oAttachmentModel) - { - if ('' !== oAttachmentModel.cidWithOutTags && 0 < this.foundedCIDs.length && - 0 <= Utils.inArray(oAttachmentModel.cidWithOutTags, this.foundedCIDs)) + if (Utils.isUnd(oLocalUnic[aMessageEmails[iIndex].email])) { - oAttachmentModel.isLinked = true; + oLocalUnic[aMessageEmails[iIndex].email] = true; + aLocalEmails.push(aMessageEmails[iIndex]); } - - aResult.push(oAttachmentModel); } } - } + }; - return aResult; - }; + MessageModel.prototype.clear = function () + { + this.folderFullNameRaw = ''; + this.uid = ''; + this.hash = ''; + this.requestHash = ''; + this.subject(''); + this.subjectPrefix(''); + this.subjectSuffix(''); + this.size(0); + this.dateTimeStampInUTC(0); + this.priority(Enums.MessagePriority.Normal); - /** - * @param {AjaxJsonMessage} oJsonMessage - * @return {boolean} - */ - MessageModel.prototype.initFlagsByJson = function (oJsonMessage) - { - var bResult = false; + this.proxy = false; - if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) - { - this.unseen(!oJsonMessage.IsSeen); - this.flagged(!!oJsonMessage.IsFlagged); - this.answered(!!oJsonMessage.IsAnswered); - this.forwarded(!!oJsonMessage.IsForwarded); - this.isReadReceipt(!!oJsonMessage.IsReadReceipt); + this.fromEmailString(''); + this.fromClearEmailString(''); + this.toEmailsString(''); + this.toClearEmailsString(''); + this.senderEmailsString(''); + this.senderClearEmailsString(''); - bResult = true; - } + this.emails = []; - return bResult; - }; + this.from = []; + this.to = []; + this.cc = []; + this.bcc = []; + this.replyTo = []; + this.deliveredTo = []; - /** - * @param {boolean} bFriendlyView - * @param {boolean=} bWrapWithLink = false - * @return {string} - */ - MessageModel.prototype.fromToLine = function (bFriendlyView, bWrapWithLink) - { - return MessageModel.emailsToLine(this.from, bFriendlyView, bWrapWithLink); - }; + this.newForAnimation(false); - /** - * @param {boolean} bFriendlyView - * @param {boolean=} bWrapWithLink = false - * @return {string} - */ - MessageModel.prototype.toToLine = function (bFriendlyView, bWrapWithLink) - { - return MessageModel.emailsToLine(this.to, bFriendlyView, bWrapWithLink); - }; + this.deleted(false); + this.unseen(false); + this.flagged(false); + this.answered(false); + this.forwarded(false); + this.isReadReceipt(false); - /** - * @param {boolean} bFriendlyView - * @param {boolean=} bWrapWithLink = false - * @return {string} - */ - MessageModel.prototype.ccToLine = function (bFriendlyView, bWrapWithLink) - { - return MessageModel.emailsToLine(this.cc, bFriendlyView, bWrapWithLink); - }; - - /** - * @param {boolean} bFriendlyView - * @param {boolean=} bWrapWithLink = false - * @return {string} - */ - MessageModel.prototype.bccToLine = function (bFriendlyView, bWrapWithLink) - { - return MessageModel.emailsToLine(this.bcc, bFriendlyView, bWrapWithLink); - }; - - /** - * @return string - */ - MessageModel.prototype.lineAsCcc = function () - { - var aResult = []; - if (this.deleted()) - { - aResult.push('deleted'); - } - if (this.selected()) - { - aResult.push('selected'); - } - if (this.checked()) - { - aResult.push('checked'); - } - if (this.flagged()) - { - aResult.push('flagged'); - } - if (this.unseen()) - { - aResult.push('unseen'); - } - if (this.answered()) - { - aResult.push('answered'); - } - if (this.forwarded()) - { - aResult.push('forwarded'); - } - if (this.focused()) - { - aResult.push('focused'); - } - if (this.hasAttachments()) - { - aResult.push('withAttachments'); - switch (this.attachmentsMainType()) - { - case 'image': - aResult.push('imageOnlyAttachments'); - break; - case 'archive': - aResult.push('archiveOnlyAttachments'); - break; - } - } - if (this.newForAnimation()) - { - aResult.push('new'); - } - if ('' === this.subject()) - { - aResult.push('emptySubject'); - } - if (0 < this.parentUid()) - { - aResult.push('hasParentMessage'); - } - if (0 < this.threadsLen() && 0 === this.parentUid()) - { - aResult.push('hasChildrenMessage'); - } - if (this.hasUnseenSubMessage()) - { - aResult.push('hasUnseenSubMessage'); - } - if (this.hasFlaggedSubMessage()) - { - aResult.push('hasFlaggedSubMessage'); - } - - return aResult.join(' '); - }; - - /** - * @return {boolean} - */ - MessageModel.prototype.hasVisibleAttachments = function () - { - return !!_.find(this.attachments(), function (oAttachment) { - return !oAttachment.isLinked; - }); - }; - - /** - * @param {string} sCid - * @return {*} - */ - MessageModel.prototype.findAttachmentByCid = function (sCid) - { - var - oResult = null, - aAttachments = this.attachments() - ; - - if (Utils.isNonEmptyArray(aAttachments)) - { - sCid = sCid.replace(/^<+/, '').replace(/>+$/, ''); - oResult = _.find(aAttachments, function (oAttachment) { - return sCid === oAttachment.cidWithOutTags; - }); - } - - return oResult || null; - }; - - /** - * @param {string} sContentLocation - * @return {*} - */ - MessageModel.prototype.findAttachmentByContentLocation = function (sContentLocation) - { - var - oResult = null, - aAttachments = this.attachments() - ; - - if (Utils.isNonEmptyArray(aAttachments)) - { - oResult = _.find(aAttachments, function (oAttachment) { - return sContentLocation === oAttachment.contentLocation; - }); - } - - return oResult || null; - }; - - - /** - * @return {string} - */ - MessageModel.prototype.messageId = function () - { - return this.sMessageId; - }; - - /** - * @return {string} - */ - MessageModel.prototype.inReplyTo = function () - { - return this.sInReplyTo; - }; - - /** - * @return {string} - */ - MessageModel.prototype.references = function () - { - return this.sReferences; - }; - - /** - * @return {string} - */ - MessageModel.prototype.fromAsSingleEmail = function () - { - return Utils.isArray(this.from) && this.from[0] ? this.from[0].email : ''; - }; - - /** - * @return {string} - */ - MessageModel.prototype.viewLink = function () - { - return LinkBuilder.messageViewLink(this.requestHash); - }; - - /** - * @return {string} - */ - MessageModel.prototype.downloadLink = function () - { - return LinkBuilder.messageDownloadLink(this.requestHash); - }; - - /** - * @param {Object} oExcludeEmails - * @return {Array} - */ - MessageModel.prototype.replyEmails = function (oExcludeEmails) - { - var - aResult = [], - oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails - ; - - MessageModel.replyHelper(this.replyTo, oUnic, aResult); - if (0 === aResult.length) - { - MessageModel.replyHelper(this.from, oUnic, aResult); - } - - return aResult; - }; - - /** - * @param {Object} oExcludeEmails - * @return {Array.} - */ - MessageModel.prototype.replyAllEmails = function (oExcludeEmails) - { - var - aToResult = [], - aCcResult = [], - oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails - ; - - MessageModel.replyHelper(this.replyTo, oUnic, aToResult); - if (0 === aToResult.length) - { - MessageModel.replyHelper(this.from, oUnic, aToResult); - } - - MessageModel.replyHelper(this.to, oUnic, aToResult); - MessageModel.replyHelper(this.cc, oUnic, aCcResult); - - return [aToResult, aCcResult]; - }; - - /** - * @return {string} - */ - MessageModel.prototype.textBodyToString = function () - { - return this.body ? this.body.html() : ''; - }; - - /** - * @return {string} - */ - MessageModel.prototype.attachmentsToStringLine = function () - { - var aAttachLines = _.map(this.attachments(), function (oItem) { - return oItem.fileName + ' (' + oItem.friendlySize + ')'; - }); - - return aAttachLines && 0 < aAttachLines.length ? aAttachLines.join(', ') : ''; - }; - - /** - * @return {Object} - */ - MessageModel.prototype.getDataForWindowPopup = function () - { - return { - 'popupFrom': this.fromToLine(false), - 'popupTo': this.toToLine(false), - 'popupCc': this.ccToLine(false), - 'popupBcc': this.bccToLine(false), - 'popupSubject': this.subject(), - 'popupIsHtml': this.isHtml(), - 'popupDate': this.fullFormatDateValue(), - 'popupAttachments': this.attachmentsToStringLine(), - 'popupBody': this.textBodyToString() - }; - }; - - /** - * @param {boolean=} bPrint = false - */ - MessageModel.prototype.viewPopupMessage = function (bPrint) - { - Utils.windowPopupKnockout(this.getDataForWindowPopup(), 'PopupsWindowSimpleMessage', this.subject(), function (oPopupWin) { - if (oPopupWin && oPopupWin.document && oPopupWin.document.body) - { - $('img.lazy', oPopupWin.document.body).each(function (iIndex, oImg) { - - var - $oImg = $(oImg), - sOrig = $oImg.data('original'), - sSrc = $oImg.attr('src') - ; - - if (0 <= iIndex && sOrig && !sSrc) - { - $oImg.attr('src', sOrig); - } - }); - - if (bPrint) - { - window.setTimeout(function () { - oPopupWin.print(); - }, 100); - } - } - }); - }; - - MessageModel.prototype.printMessage = function () - { - this.viewPopupMessage(true); - }; - - /** - * @returns {string} - */ - MessageModel.prototype.generateUid = function () - { - return this.folderFullNameRaw + '/' + this.uid; - }; - - /** - * @param {MessageModel} oMessage - * @return {MessageModel} - */ - MessageModel.prototype.populateByMessageListItem = function (oMessage) - { - this.folderFullNameRaw = oMessage.folderFullNameRaw; - this.uid = oMessage.uid; - this.hash = oMessage.hash; - this.requestHash = oMessage.requestHash; - this.subject(oMessage.subject()); - this.subjectPrefix(this.subjectPrefix()); - this.subjectSuffix(this.subjectSuffix()); - - this.size(oMessage.size()); - this.dateTimeStampInUTC(oMessage.dateTimeStampInUTC()); - this.priority(oMessage.priority()); - - this.proxy = oMessage.proxy; - - this.fromEmailString(oMessage.fromEmailString()); - this.fromClearEmailString(oMessage.fromClearEmailString()); - this.toEmailsString(oMessage.toEmailsString()); - this.toClearEmailsString(oMessage.toClearEmailsString()); - - this.emails = oMessage.emails; - - this.from = oMessage.from; - this.to = oMessage.to; - this.cc = oMessage.cc; - this.bcc = oMessage.bcc; - this.replyTo = oMessage.replyTo; - this.deliveredTo = oMessage.deliveredTo; - - this.unseen(oMessage.unseen()); - this.flagged(oMessage.flagged()); - this.answered(oMessage.answered()); - this.forwarded(oMessage.forwarded()); - this.isReadReceipt(oMessage.isReadReceipt()); - - this.selected(oMessage.selected()); - this.checked(oMessage.checked()); - this.hasAttachments(oMessage.hasAttachments()); - this.attachmentsMainType(oMessage.attachmentsMainType()); - - this.moment(oMessage.moment()); - - this.body = null; - - this.priority(Enums.MessagePriority.Normal); - this.aDraftInfo = []; - this.sMessageId = ''; - this.sInReplyTo = ''; - this.sReferences = ''; - - this.parentUid(oMessage.parentUid()); - this.threads(oMessage.threads()); - this.threadsLen(oMessage.threadsLen()); - - this.computeSenderEmail(); - - return this; - }; - - MessageModel.prototype.showExternalImages = function (bLazy) - { - if (this.body && this.body.data('rl-has-images')) - { - var sAttr = ''; - bLazy = Utils.isUnd(bLazy) ? false : bLazy; + this.selected(false); + this.checked(false); + this.hasAttachments(false); + this.attachmentsMainType(''); + this.body = null; + this.isHtml(false); this.hasImages(false); - this.body.data('rl-has-images', false); + this.attachments([]); - sAttr = this.proxy ? 'data-x-additional-src' : 'data-x-src'; - $('[' + sAttr + ']', this.body).each(function () { - if (bLazy && $(this).is('img')) + this.isPgpSigned(false); + this.isPgpEncrypted(false); + this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None); + this.pgpSignedVerifyUser(''); + + this.priority(Enums.MessagePriority.Normal); + this.readReceipt(''); + this.aDraftInfo = []; + this.sMessageId = ''; + this.sInReplyTo = ''; + this.sReferences = ''; + + this.parentUid(0); + this.threads([]); + this.threadsLen(0); + this.hasUnseenSubMessage(false); + this.hasFlaggedSubMessage(false); + + this.lastInCollapsedThread(false); + this.lastInCollapsedThreadLoading(false); + }; + + /** + * @return {string} + */ + MessageModel.prototype.friendlySize = function () + { + return Utils.friendlySize(this.size()); + }; + + MessageModel.prototype.computeSenderEmail = function () + { + var + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + sSent = Data.sentFolder(), + sDraft = Data.draftFolder() + ; + + this.senderEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ? + this.toEmailsString() : this.fromEmailString()); + + this.senderClearEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ? + this.toClearEmailsString() : this.fromClearEmailString()); + }; + + /** + * @param {AjaxJsonMessage} oJsonMessage + * @return {boolean} + */ + MessageModel.prototype.initByJson = function (oJsonMessage) + { + var bResult = false; + if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) + { + this.folderFullNameRaw = oJsonMessage.Folder; + this.uid = oJsonMessage.Uid; + this.hash = oJsonMessage.Hash; + this.requestHash = oJsonMessage.RequestHash; + + this.proxy = !!oJsonMessage.ExternalProxy; + + this.size(Utils.pInt(oJsonMessage.Size)); + + this.from = MessageModel.initEmailsFromJson(oJsonMessage.From); + this.to = MessageModel.initEmailsFromJson(oJsonMessage.To); + this.cc = MessageModel.initEmailsFromJson(oJsonMessage.Cc); + this.bcc = MessageModel.initEmailsFromJson(oJsonMessage.Bcc); + this.replyTo = MessageModel.initEmailsFromJson(oJsonMessage.ReplyTo); + this.deliveredTo = MessageModel.initEmailsFromJson(oJsonMessage.DeliveredTo); + + this.subject(oJsonMessage.Subject); + if (Utils.isArray(oJsonMessage.SubjectParts)) { - $(this) - .addClass('lazy') - .attr('data-original', $(this).attr(sAttr)) - .removeAttr(sAttr) - ; + this.subjectPrefix(oJsonMessage.SubjectParts[0]); + this.subjectSuffix(oJsonMessage.SubjectParts[1]); } else { - $(this).attr('src', $(this).attr(sAttr)).removeAttr(sAttr); + this.subjectPrefix(''); + this.subjectSuffix(this.subject()); + } + + this.dateTimeStampInUTC(Utils.pInt(oJsonMessage.DateTimeStampInUTC)); + this.hasAttachments(!!oJsonMessage.HasAttachments); + this.attachmentsMainType(oJsonMessage.AttachmentsMainType); + + this.fromEmailString(MessageModel.emailsToLine(this.from, true)); + this.fromClearEmailString(MessageModel.emailsToLineClear(this.from)); + this.toEmailsString(MessageModel.emailsToLine(this.to, true)); + this.toClearEmailsString(MessageModel.emailsToLineClear(this.to)); + + this.parentUid(Utils.pInt(oJsonMessage.ParentThread)); + this.threads(Utils.isArray(oJsonMessage.Threads) ? oJsonMessage.Threads : []); + this.threadsLen(Utils.pInt(oJsonMessage.ThreadsLen)); + + this.initFlagsByJson(oJsonMessage); + this.computeSenderEmail(); + + bResult = true; + } + + return bResult; + }; + + /** + * @param {AjaxJsonMessage} oJsonMessage + * @return {boolean} + */ + MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage) + { + var + Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8), + bResult = false, + iPriority = Enums.MessagePriority.Normal + ; + + if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) + { + iPriority = Utils.pInt(oJsonMessage.Priority); + this.priority(-1 < Utils.inArray(iPriority, [Enums.MessagePriority.High, Enums.MessagePriority.Low]) ? + iPriority : Enums.MessagePriority.Normal); + + this.aDraftInfo = oJsonMessage.DraftInfo; + + this.sMessageId = oJsonMessage.MessageId; + this.sInReplyTo = oJsonMessage.InReplyTo; + this.sReferences = oJsonMessage.References; + + this.proxy = !!oJsonMessage.ExternalProxy; + + if (Data.capaOpenPGP()) + { + this.isPgpSigned(!!oJsonMessage.PgpSigned); + this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted); + } + + this.hasAttachments(!!oJsonMessage.HasAttachments); + this.attachmentsMainType(oJsonMessage.AttachmentsMainType); + + this.foundedCIDs = Utils.isArray(oJsonMessage.FoundedCIDs) ? oJsonMessage.FoundedCIDs : []; + this.attachments(this.initAttachmentsFromJson(oJsonMessage.Attachments)); + + this.readReceipt(oJsonMessage.ReadReceipt || ''); + + this.computeSenderEmail(); + + bResult = true; + } + + return bResult; + }; + + /** + * @param {(AjaxJsonAttachment|null)} oJsonAttachments + * @return {Array} + */ + MessageModel.prototype.initAttachmentsFromJson = function (oJsonAttachments) + { + var + iIndex = 0, + iLen = 0, + oAttachmentModel = null, + aResult = [] + ; + + if (oJsonAttachments && 'Collection/AttachmentCollection' === oJsonAttachments['@Object'] && + Utils.isNonEmptyArray(oJsonAttachments['@Collection'])) + { + for (iIndex = 0, iLen = oJsonAttachments['@Collection'].length; iIndex < iLen; iIndex++) + { + oAttachmentModel = AttachmentModel.newInstanceFromJson(oJsonAttachments['@Collection'][iIndex]); + if (oAttachmentModel) + { + if ('' !== oAttachmentModel.cidWithOutTags && 0 < this.foundedCIDs.length && + 0 <= Utils.inArray(oAttachmentModel.cidWithOutTags, this.foundedCIDs)) + { + oAttachmentModel.isLinked = true; + } + + aResult.push(oAttachmentModel); + } + } + } + + return aResult; + }; + + /** + * @param {AjaxJsonMessage} oJsonMessage + * @return {boolean} + */ + MessageModel.prototype.initFlagsByJson = function (oJsonMessage) + { + var bResult = false; + + if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) + { + this.unseen(!oJsonMessage.IsSeen); + this.flagged(!!oJsonMessage.IsFlagged); + this.answered(!!oJsonMessage.IsAnswered); + this.forwarded(!!oJsonMessage.IsForwarded); + this.isReadReceipt(!!oJsonMessage.IsReadReceipt); + + bResult = true; + } + + return bResult; + }; + + /** + * @param {boolean} bFriendlyView + * @param {boolean=} bWrapWithLink = false + * @return {string} + */ + MessageModel.prototype.fromToLine = function (bFriendlyView, bWrapWithLink) + { + return MessageModel.emailsToLine(this.from, bFriendlyView, bWrapWithLink); + }; + + /** + * @param {boolean} bFriendlyView + * @param {boolean=} bWrapWithLink = false + * @return {string} + */ + MessageModel.prototype.toToLine = function (bFriendlyView, bWrapWithLink) + { + return MessageModel.emailsToLine(this.to, bFriendlyView, bWrapWithLink); + }; + + /** + * @param {boolean} bFriendlyView + * @param {boolean=} bWrapWithLink = false + * @return {string} + */ + MessageModel.prototype.ccToLine = function (bFriendlyView, bWrapWithLink) + { + return MessageModel.emailsToLine(this.cc, bFriendlyView, bWrapWithLink); + }; + + /** + * @param {boolean} bFriendlyView + * @param {boolean=} bWrapWithLink = false + * @return {string} + */ + MessageModel.prototype.bccToLine = function (bFriendlyView, bWrapWithLink) + { + return MessageModel.emailsToLine(this.bcc, bFriendlyView, bWrapWithLink); + }; + + /** + * @return string + */ + MessageModel.prototype.lineAsCcc = function () + { + var aResult = []; + if (this.deleted()) + { + aResult.push('deleted'); + } + if (this.selected()) + { + aResult.push('selected'); + } + if (this.checked()) + { + aResult.push('checked'); + } + if (this.flagged()) + { + aResult.push('flagged'); + } + if (this.unseen()) + { + aResult.push('unseen'); + } + if (this.answered()) + { + aResult.push('answered'); + } + if (this.forwarded()) + { + aResult.push('forwarded'); + } + if (this.focused()) + { + aResult.push('focused'); + } + if (this.hasAttachments()) + { + aResult.push('withAttachments'); + switch (this.attachmentsMainType()) + { + case 'image': + aResult.push('imageOnlyAttachments'); + break; + case 'archive': + aResult.push('archiveOnlyAttachments'); + break; + } + } + if (this.newForAnimation()) + { + aResult.push('new'); + } + if ('' === this.subject()) + { + aResult.push('emptySubject'); + } + if (0 < this.parentUid()) + { + aResult.push('hasParentMessage'); + } + if (0 < this.threadsLen() && 0 === this.parentUid()) + { + aResult.push('hasChildrenMessage'); + } + if (this.hasUnseenSubMessage()) + { + aResult.push('hasUnseenSubMessage'); + } + if (this.hasFlaggedSubMessage()) + { + aResult.push('hasFlaggedSubMessage'); + } + + return aResult.join(' '); + }; + + /** + * @return {boolean} + */ + MessageModel.prototype.hasVisibleAttachments = function () + { + return !!_.find(this.attachments(), function (oAttachment) { + return !oAttachment.isLinked; + }); + }; + + /** + * @param {string} sCid + * @return {*} + */ + MessageModel.prototype.findAttachmentByCid = function (sCid) + { + var + oResult = null, + aAttachments = this.attachments() + ; + + if (Utils.isNonEmptyArray(aAttachments)) + { + sCid = sCid.replace(/^<+/, '').replace(/>+$/, ''); + oResult = _.find(aAttachments, function (oAttachment) { + return sCid === oAttachment.cidWithOutTags; + }); + } + + return oResult || null; + }; + + /** + * @param {string} sContentLocation + * @return {*} + */ + MessageModel.prototype.findAttachmentByContentLocation = function (sContentLocation) + { + var + oResult = null, + aAttachments = this.attachments() + ; + + if (Utils.isNonEmptyArray(aAttachments)) + { + oResult = _.find(aAttachments, function (oAttachment) { + return sContentLocation === oAttachment.contentLocation; + }); + } + + return oResult || null; + }; + + + /** + * @return {string} + */ + MessageModel.prototype.messageId = function () + { + return this.sMessageId; + }; + + /** + * @return {string} + */ + MessageModel.prototype.inReplyTo = function () + { + return this.sInReplyTo; + }; + + /** + * @return {string} + */ + MessageModel.prototype.references = function () + { + return this.sReferences; + }; + + /** + * @return {string} + */ + MessageModel.prototype.fromAsSingleEmail = function () + { + return Utils.isArray(this.from) && this.from[0] ? this.from[0].email : ''; + }; + + /** + * @return {string} + */ + MessageModel.prototype.viewLink = function () + { + return LinkBuilder.messageViewLink(this.requestHash); + }; + + /** + * @return {string} + */ + MessageModel.prototype.downloadLink = function () + { + return LinkBuilder.messageDownloadLink(this.requestHash); + }; + + /** + * @param {Object} oExcludeEmails + * @return {Array} + */ + MessageModel.prototype.replyEmails = function (oExcludeEmails) + { + var + aResult = [], + oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails + ; + + MessageModel.replyHelper(this.replyTo, oUnic, aResult); + if (0 === aResult.length) + { + MessageModel.replyHelper(this.from, oUnic, aResult); + } + + return aResult; + }; + + /** + * @param {Object} oExcludeEmails + * @return {Array.} + */ + MessageModel.prototype.replyAllEmails = function (oExcludeEmails) + { + var + aToResult = [], + aCcResult = [], + oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails + ; + + MessageModel.replyHelper(this.replyTo, oUnic, aToResult); + if (0 === aToResult.length) + { + MessageModel.replyHelper(this.from, oUnic, aToResult); + } + + MessageModel.replyHelper(this.to, oUnic, aToResult); + MessageModel.replyHelper(this.cc, oUnic, aCcResult); + + return [aToResult, aCcResult]; + }; + + /** + * @return {string} + */ + MessageModel.prototype.textBodyToString = function () + { + return this.body ? this.body.html() : ''; + }; + + /** + * @return {string} + */ + MessageModel.prototype.attachmentsToStringLine = function () + { + var aAttachLines = _.map(this.attachments(), function (oItem) { + return oItem.fileName + ' (' + oItem.friendlySize + ')'; + }); + + return aAttachLines && 0 < aAttachLines.length ? aAttachLines.join(', ') : ''; + }; + + /** + * @return {Object} + */ + MessageModel.prototype.getDataForWindowPopup = function () + { + return { + 'popupFrom': this.fromToLine(false), + 'popupTo': this.toToLine(false), + 'popupCc': this.ccToLine(false), + 'popupBcc': this.bccToLine(false), + 'popupSubject': this.subject(), + 'popupIsHtml': this.isHtml(), + 'popupDate': this.fullFormatDateValue(), + 'popupAttachments': this.attachmentsToStringLine(), + 'popupBody': this.textBodyToString() + }; + }; + + /** + * @param {boolean=} bPrint = false + */ + MessageModel.prototype.viewPopupMessage = function (bPrint) + { + Utils.windowPopupKnockout(this.getDataForWindowPopup(), 'PopupsWindowSimpleMessage', this.subject(), function (oPopupWin) { + if (oPopupWin && oPopupWin.document && oPopupWin.document.body) + { + $('img.lazy', oPopupWin.document.body).each(function (iIndex, oImg) { + + var + $oImg = $(oImg), + sOrig = $oImg.data('original'), + sSrc = $oImg.attr('src') + ; + + if (0 <= iIndex && sOrig && !sSrc) + { + $oImg.attr('src', sOrig); + } + }); + + if (bPrint) + { + window.setTimeout(function () { + oPopupWin.print(); + }, 100); + } } }); + }; - sAttr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url'; - $('[' + sAttr + ']', this.body).each(function () { - var sStyle = Utils.trim($(this).attr('style')); - sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; '); - $(this).attr('style', sStyle + $(this).attr(sAttr)).removeAttr(sAttr); - }); + MessageModel.prototype.printMessage = function () + { + this.viewPopupMessage(true); + }; - if (bLazy) + /** + * @returns {string} + */ + MessageModel.prototype.generateUid = function () + { + return this.folderFullNameRaw + '/' + this.uid; + }; + + /** + * @param {MessageModel} oMessage + * @return {MessageModel} + */ + MessageModel.prototype.populateByMessageListItem = function (oMessage) + { + this.folderFullNameRaw = oMessage.folderFullNameRaw; + this.uid = oMessage.uid; + this.hash = oMessage.hash; + this.requestHash = oMessage.requestHash; + this.subject(oMessage.subject()); + this.subjectPrefix(this.subjectPrefix()); + this.subjectSuffix(this.subjectSuffix()); + + this.size(oMessage.size()); + this.dateTimeStampInUTC(oMessage.dateTimeStampInUTC()); + this.priority(oMessage.priority()); + + this.proxy = oMessage.proxy; + + this.fromEmailString(oMessage.fromEmailString()); + this.fromClearEmailString(oMessage.fromClearEmailString()); + this.toEmailsString(oMessage.toEmailsString()); + this.toClearEmailsString(oMessage.toClearEmailsString()); + + this.emails = oMessage.emails; + + this.from = oMessage.from; + this.to = oMessage.to; + this.cc = oMessage.cc; + this.bcc = oMessage.bcc; + this.replyTo = oMessage.replyTo; + this.deliveredTo = oMessage.deliveredTo; + + this.unseen(oMessage.unseen()); + this.flagged(oMessage.flagged()); + this.answered(oMessage.answered()); + this.forwarded(oMessage.forwarded()); + this.isReadReceipt(oMessage.isReadReceipt()); + + this.selected(oMessage.selected()); + this.checked(oMessage.checked()); + this.hasAttachments(oMessage.hasAttachments()); + this.attachmentsMainType(oMessage.attachmentsMainType()); + + this.moment(oMessage.moment()); + + this.body = null; + + this.priority(Enums.MessagePriority.Normal); + this.aDraftInfo = []; + this.sMessageId = ''; + this.sInReplyTo = ''; + this.sReferences = ''; + + this.parentUid(oMessage.parentUid()); + this.threads(oMessage.threads()); + this.threadsLen(oMessage.threadsLen()); + + this.computeSenderEmail(); + + return this; + }; + + MessageModel.prototype.showExternalImages = function (bLazy) + { + if (this.body && this.body.data('rl-has-images')) { - $('img.lazy', this.body).addClass('lazy-inited').lazyload({ - 'threshold' : 400, - 'effect' : 'fadeIn', - 'skip_invisible' : false, - 'container': $('.RL-MailMessageView .messageView .messageItem .content')[0] + var sAttr = ''; + bLazy = Utils.isUnd(bLazy) ? false : bLazy; + + this.hasImages(false); + this.body.data('rl-has-images', false); + + sAttr = this.proxy ? 'data-x-additional-src' : 'data-x-src'; + $('[' + sAttr + ']', this.body).each(function () { + if (bLazy && $(this).is('img')) + { + $(this) + .addClass('lazy') + .attr('data-original', $(this).attr(sAttr)) + .removeAttr(sAttr) + ; + } + else + { + $(this).attr('src', $(this).attr(sAttr)).removeAttr(sAttr); + } }); - Globals.$win.resize(); + sAttr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url'; + $('[' + sAttr + ']', this.body).each(function () { + var sStyle = Utils.trim($(this).attr('style')); + sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; '); + $(this).attr('style', sStyle + $(this).attr(sAttr)).removeAttr(sAttr); + }); + + if (bLazy) + { + $('img.lazy', this.body).addClass('lazy-inited').lazyload({ + 'threshold' : 400, + 'effect' : 'fadeIn', + 'skip_invisible' : false, + 'container': $('.RL-MailMessageView .messageView .messageItem .content')[0] + }); + + Globals.$win.resize(); + } + + Utils.windowResize(500); } + }; - Utils.windowResize(500); - } - }; - - MessageModel.prototype.showInternalImages = function (bLazy) - { - if (this.body && !this.body.data('rl-init-internal-images')) - { - this.body.data('rl-init-internal-images', true); - - bLazy = Utils.isUnd(bLazy) ? false : bLazy; - - var self = this; - - $('[data-x-src-cid]', this.body).each(function () { - - var oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-cid')); - if (oAttachment && oAttachment.download) - { - if (bLazy && $(this).is('img')) - { - $(this) - .addClass('lazy') - .attr('data-original', oAttachment.linkPreview()); - } - else - { - $(this).attr('src', oAttachment.linkPreview()); - } - } - }); - - $('[data-x-src-location]', this.body).each(function () { - - var oAttachment = self.findAttachmentByContentLocation($(this).attr('data-x-src-location')); - if (!oAttachment) - { - oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-location')); - } - - if (oAttachment && oAttachment.download) - { - if (bLazy && $(this).is('img')) - { - $(this) - .addClass('lazy') - .attr('data-original', oAttachment.linkPreview()); - } - else - { - $(this).attr('src', oAttachment.linkPreview()); - } - } - }); - - $('[data-x-style-cid]', this.body).each(function () { - - var - sStyle = '', - sName = '', - oAttachment = self.findAttachmentByCid($(this).attr('data-x-style-cid')) - ; - - if (oAttachment && oAttachment.linkPreview) - { - sName = $(this).attr('data-x-style-cid-name'); - if ('' !== sName) - { - sStyle = Utils.trim($(this).attr('style')); - sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; '); - $(this).attr('style', sStyle + sName + ': url(\'' + oAttachment.linkPreview() + '\')'); - } - } - }); - - if (bLazy) - { - (function ($oImg, oContainer) { - _.delay(function () { - $oImg.addClass('lazy-inited').lazyload({ - 'threshold' : 400, - 'effect' : 'fadeIn', - 'skip_invisible' : false, - 'container': oContainer - }); - }, 300); - }($('img.lazy', self.body), $('.RL-MailMessageView .messageView .messageItem .content')[0])); - } - - Utils.windowResize(500); - } - }; - - MessageModel.prototype.storeDataToDom = function () - { - if (this.body) - { - this.body.data('rl-is-html', !!this.isHtml()); - this.body.data('rl-has-images', !!this.hasImages()); - - this.body.data('rl-plain-raw', this.plainRaw); - - var Data = require('Storage:RainLoop:Data'); - if (Data.capaOpenPGP()) - { - 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()); - } - } - }; - - MessageModel.prototype.storePgpVerifyDataToDom = function () - { - var Data = require('Storage:RainLoop:Data'); - if (this.body && Data.capaOpenPGP()) + MessageModel.prototype.showInternalImages = function (bLazy) { - this.body.data('rl-pgp-verify-status', this.pgpSignedVerifyStatus()); - this.body.data('rl-pgp-verify-user', this.pgpSignedVerifyUser()); - } - }; - - MessageModel.prototype.fetchDataToDom = function () - { - if (this.body) - { - this.isHtml(!!this.body.data('rl-is-html')); - this.hasImages(!!this.body.data('rl-has-images')); - - this.plainRaw = Utils.pString(this.body.data('rl-plain-raw')); - - var Data = require('Storage:RainLoop:Data'); - if (Data.capaOpenPGP()) - { - 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')); - } - else - { - this.isPgpSigned(false); - this.isPgpEncrypted(false); - this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None); - this.pgpSignedVerifyUser(''); - } - } - }; - - MessageModel.prototype.verifyPgpSignedClearMessage = function () - { - if (this.isPgpSigned()) - { - var - aRes = [], - mPgpMessage = null, - Data = require('Storage:RainLoop:Data'), - sFrom = this.from && this.from[0] && this.from[0].email ? this.from[0].email : '', - aPublicKeys = Data.findPublicKeysByEmail(sFrom), - oValidKey = null, - oValidSysKey = null, - sPlain = '' - ; - - this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Error); - this.pgpSignedVerifyUser(''); - - try + if (this.body && !this.body.data('rl-init-internal-images')) { - mPgpMessage = window.openpgp.cleartext.readArmored(this.plainRaw); - if (mPgpMessage && mPgpMessage.getText) - { - this.pgpSignedVerifyStatus( - aPublicKeys.length ? Enums.SignedVerifyStatus.Unverified : Enums.SignedVerifyStatus.UnknownPublicKeys); + this.body.data('rl-init-internal-images', true); - aRes = mPgpMessage.verify(aPublicKeys); - if (aRes && 0 < aRes.length) + bLazy = Utils.isUnd(bLazy) ? false : bLazy; + + var self = this; + + $('[data-x-src-cid]', this.body).each(function () { + + var oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-cid')); + if (oAttachment && oAttachment.download) { - oValidKey = _.find(aRes, function (oItem) { - return oItem && oItem.keyid && oItem.valid; - }); - - if (oValidKey) + if (bLazy && $(this).is('img')) { - oValidSysKey = Data.findPublicKeyByHex(oValidKey.keyid.toHex()); - if (oValidSysKey) - { - sPlain = mPgpMessage.getText(); - - this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Success); - this.pgpSignedVerifyUser(oValidSysKey.user); - - sPlain = - Globals.$div.empty().append( - $('
').text(sPlain)
-								   ).html()
-							   ;
-
-							   Globals.$div.empty();
-
-							   this.replacePlaneTextBody(sPlain);
-						   }
+						   $(this)
+							   .addClass('lazy')
+							   .attr('data-original', oAttachment.linkPreview());
+					   }
+					   else
+					   {
+						   $(this).attr('src', oAttachment.linkPreview());
 					   }
 				   }
+			   });
+
+			   $('[data-x-src-location]', this.body).each(function () {
+
+				   var oAttachment = self.findAttachmentByContentLocation($(this).attr('data-x-src-location'));
+				   if (!oAttachment)
+				   {
+					   oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-location'));
+				   }
+
+				   if (oAttachment && oAttachment.download)
+				   {
+					   if (bLazy && $(this).is('img'))
+					   {
+						   $(this)
+							   .addClass('lazy')
+							   .attr('data-original', oAttachment.linkPreview());
+					   }
+					   else
+					   {
+						   $(this).attr('src', oAttachment.linkPreview());
+					   }
+				   }
+			   });
+
+			   $('[data-x-style-cid]', this.body).each(function () {
+
+				   var
+					   sStyle = '',
+					   sName = '',
+					   oAttachment = self.findAttachmentByCid($(this).attr('data-x-style-cid'))
+				   ;
+
+				   if (oAttachment && oAttachment.linkPreview)
+				   {
+					   sName = $(this).attr('data-x-style-cid-name');
+					   if ('' !== sName)
+					   {
+						   sStyle = Utils.trim($(this).attr('style'));
+						   sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
+						   $(this).attr('style', sStyle + sName + ': url(\'' + oAttachment.linkPreview() + '\')');
+					   }
+				   }
+			   });
+
+			   if (bLazy)
+			   {
+				   (function ($oImg, oContainer) {
+					   _.delay(function () {
+						   $oImg.addClass('lazy-inited').lazyload({
+							   'threshold' : 400,
+							   'effect' : 'fadeIn',
+							   'skip_invisible' : false,
+							   'container': oContainer
+						   });
+					   }, 300);
+				   }($('img.lazy', self.body), $('.RL-MailMessageView .messageView .messageItem .content')[0]));
+			   }
+
+			   Utils.windowResize(500);
+		   }
+		};
+
+		MessageModel.prototype.storeDataToDom = function ()
+		{
+		   if (this.body)
+		   {
+			   this.body.data('rl-is-html', !!this.isHtml());
+			   this.body.data('rl-has-images', !!this.hasImages());
+
+			   this.body.data('rl-plain-raw', this.plainRaw);
+
+			   var Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8);
+			   if (Data.capaOpenPGP())
+			   {
+				   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());
 			   }
 		   }
-		   catch (oExc) {}
+		};
 
-		   this.storePgpVerifyDataToDom();
-	   }
-	};
+		MessageModel.prototype.storePgpVerifyDataToDom = function ()
+		{
+			var Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8);
+			if (this.body && Data.capaOpenPGP())
+			{
+				this.body.data('rl-pgp-verify-status', this.pgpSignedVerifyStatus());
+				this.body.data('rl-pgp-verify-user', this.pgpSignedVerifyUser());
+			}
+		};
 
-	MessageModel.prototype.decryptPgpEncryptedMessage = function (sPassword)
-	{
-	   if (this.isPgpEncrypted())
-	   {
-		   var
-			   aRes = [],
-			   mPgpMessage = null,
-			   mPgpMessageDecrypted = null,
-			   Data = require('Storage:RainLoop:Data'),
-			   sFrom = this.from && this.from[0] && this.from[0].email ? this.from[0].email : '',
-			   aPublicKey = Data.findPublicKeysByEmail(sFrom),
-			   oPrivateKey = Data.findSelfPrivateKey(sPassword),
-			   oValidKey = null,
-			   oValidSysKey = null,
-			   sPlain = ''
-		   ;
+		MessageModel.prototype.fetchDataToDom = function ()
+		{
+			if (this.body)
+			{
+				this.isHtml(!!this.body.data('rl-is-html'));
+				this.hasImages(!!this.body.data('rl-has-images'));
 
-		   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Error);
-		   this.pgpSignedVerifyUser('');
+				this.plainRaw = Utils.pString(this.body.data('rl-plain-raw'));
 
-		   if (!oPrivateKey)
+				var Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8);
+				if (Data.capaOpenPGP())
+				{
+					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'));
+				}
+				else
+				{
+					this.isPgpSigned(false);
+					this.isPgpEncrypted(false);
+					this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);
+					this.pgpSignedVerifyUser('');
+				}
+			}
+		};
+
+		MessageModel.prototype.verifyPgpSignedClearMessage = function ()
+		{
+		   if (this.isPgpSigned())
 		   {
-			   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.UnknownPrivateKey);
-		   }
+			   var
+				   aRes = [],
+				   mPgpMessage = null,
+				   Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8),
+				   sFrom = this.from && this.from[0] && this.from[0].email ? this.from[0].email : '',
+				   aPublicKeys = Data.findPublicKeysByEmail(sFrom),
+				   oValidKey = null,
+				   oValidSysKey = null,
+				   sPlain = ''
+			   ;
 
-		   try
-		   {
-			   mPgpMessage = window.openpgp.message.readArmored(this.plainRaw);
-			   if (mPgpMessage && oPrivateKey && mPgpMessage.decrypt)
+			   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Error);
+			   this.pgpSignedVerifyUser('');
+
+			   try
 			   {
-				   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Unverified);
-
-				   mPgpMessageDecrypted = mPgpMessage.decrypt(oPrivateKey);
-				   if (mPgpMessageDecrypted)
+				   mPgpMessage = window.openpgp.cleartext.readArmored(this.plainRaw);
+				   if (mPgpMessage && mPgpMessage.getText)
 				   {
-					   aRes = mPgpMessageDecrypted.verify(aPublicKey);
+					   this.pgpSignedVerifyStatus(
+						   aPublicKeys.length ? Enums.SignedVerifyStatus.Unverified : Enums.SignedVerifyStatus.UnknownPublicKeys);
+
+					   aRes = mPgpMessage.verify(aPublicKeys);
 					   if (aRes && 0 < aRes.length)
 					   {
 						   oValidKey = _.find(aRes, function (oItem) {
@@ -10778,12082 +5142,1725 @@ module.exports = window;
 							   oValidSysKey = Data.findPublicKeyByHex(oValidKey.keyid.toHex());
 							   if (oValidSysKey)
 							   {
+								   sPlain = mPgpMessage.getText();
+
 								   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Success);
 								   this.pgpSignedVerifyUser(oValidSysKey.user);
+
+								   sPlain =
+									   Globals.$div.empty().append(
+										   $('
').text(sPlain)
+									   ).html()
+								   ;
+
+								   Globals.$div.empty();
+
+								   this.replacePlaneTextBody(sPlain);
 							   }
 						   }
 					   }
-
-					   sPlain = mPgpMessageDecrypted.getText();
-
-					   sPlain =
-						   Globals.$div.empty().append(
-							   $('
').text(sPlain)
-						   ).html()
-					   ;
-
-					   Globals.$div.empty();
-
-					   this.replacePlaneTextBody(sPlain);
 				   }
 			   }
+			   catch (oExc) {}
+
+			   this.storePgpVerifyDataToDom();
 		   }
-		   catch (oExc) {}
+		};
 
-		   this.storePgpVerifyDataToDom();
-	   }
-	};
-
-	MessageModel.prototype.replacePlaneTextBody = function (sPlain)
-	{
-	   if (this.body)
-	   {
-		   this.body.html(sPlain).addClass('b-text-part plain');
-	   }
-	};
-
-	/**
-	* @return {string}
-	*/
-	MessageModel.prototype.flagHash = function ()
-	{
-	   return [this.deleted(), this.unseen(), this.flagged(), this.answered(), this.forwarded(),
-		   this.isReadReceipt()].join('');
-	};
-
-	module.exports = MessageModel;
-
-}(module, require));
-},{"$":20,"Enums":7,"Globals":9,"LinkBuilder":11,"Model:Attachment":32,"Model:Email":37,"Storage:RainLoop:Data":64,"Utils":14,"_":25,"ko":22,"moment":23,"window":26}],43:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		ko = require('ko')
-	;
-
-	/**
-	 * @param {string} iIndex
-	 * @param {string} sGuID
-	 * @param {string} sID
-	 * @param {string} sUserID
-	 * @param {string} sEmail
-	 * @param {boolean} bIsPrivate
-	 * @param {string} sArmor
-	 * @constructor
-	 */
-	function OpenPgpKeyModel(iIndex, sGuID, sID, sUserID, sEmail, bIsPrivate, sArmor)
-	{
-		this.index = iIndex;
-		this.id = sID;
-		this.guid = sGuID;
-		this.user = sUserID;
-		this.email = sEmail;
-		this.armor = sArmor;
-		this.isPrivate = !!bIsPrivate;
-
-		this.deleteAccess = ko.observable(false);
-	}
-
-	OpenPgpKeyModel.prototype.index = 0;
-	OpenPgpKeyModel.prototype.id = '';
-	OpenPgpKeyModel.prototype.guid = '';
-	OpenPgpKeyModel.prototype.user = '';
-	OpenPgpKeyModel.prototype.email = '';
-	OpenPgpKeyModel.prototype.armor = '';
-	OpenPgpKeyModel.prototype.isPrivate = false;
-
-	module.exports = OpenPgpKeyModel;
-
-}(module, require));
-},{"ko":22}],44:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-
-		KnoinAbstractScreen = require('Knoin:AbstractScreen')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractScreen
-	 */
-	function AboutScreen()
-	{
-		KnoinAbstractScreen.call(this, 'about', [
-			require('View:RainLoop:About')
-		]);
-	}
-
-	_.extend(AboutScreen.prototype, KnoinAbstractScreen.prototype);
-
-	AboutScreen.prototype.onShow = function ()
-	{
-		require('App:RainLoop').setTitle('RainLoop');
-	};
-
-	module.exports = AboutScreen;
-
-}(module, require));
-},{"App:RainLoop":3,"Knoin:AbstractScreen":29,"View:RainLoop:About":70,"_":25}],45:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		$ = require('$'),
-		ko = require('ko'),
-
-		Globals = require('Globals'),
-		Utils = require('Utils'),
-		LinkBuilder = require('LinkBuilder'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractScreen = require('Knoin:AbstractScreen')
-	;
-
-	/**
-	 * @constructor
-	 * @param {Array} aViewModels
-	 * @extends KnoinAbstractScreen
-	 */
-	function AbstractSettingsScreen(aViewModels)
-	{
-		KnoinAbstractScreen.call(this, 'settings', aViewModels);
-
-		this.menu = ko.observableArray([]);
-
-		this.oCurrentSubScreen = null;
-		this.oViewModelPlace = null;
-	}
-
-	_.extend(AbstractSettingsScreen.prototype, KnoinAbstractScreen.prototype);
-
-	AbstractSettingsScreen.prototype.onRoute = function (sSubName)
-	{
-		var
-			self = this,
-			oSettingsScreen = null,
-			RoutedSettingsViewModel = null,
-			oViewModelPlace = null,
-			oViewModelDom = null
-		;
-
-		RoutedSettingsViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) {
-			return SettingsViewModel && SettingsViewModel.__rlSettingsData &&
-				sSubName === SettingsViewModel.__rlSettingsData.Route;
-		});
-
-		if (RoutedSettingsViewModel)
+		MessageModel.prototype.decryptPgpEncryptedMessage = function (sPassword)
 		{
-			if (_.find(Globals.aViewModels['settings-removed'], function (DisabledSettingsViewModel) {
-				return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
-			}))
-			{
-				RoutedSettingsViewModel = null;
-			}
+		   if (this.isPgpEncrypted())
+		   {
+			   var
+				   aRes = [],
+				   mPgpMessage = null,
+				   mPgpMessageDecrypted = null,
+				   Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8),
+				   sFrom = this.from && this.from[0] && this.from[0].email ? this.from[0].email : '',
+				   aPublicKey = Data.findPublicKeysByEmail(sFrom),
+				   oPrivateKey = Data.findSelfPrivateKey(sPassword),
+				   oValidKey = null,
+				   oValidSysKey = null,
+				   sPlain = ''
+			   ;
 
-			if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) {
-				return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
-			}))
-			{
-				RoutedSettingsViewModel = null;
-			}
-		}
+			   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Error);
+			   this.pgpSignedVerifyUser('');
 
-		if (RoutedSettingsViewModel)
+			   if (!oPrivateKey)
+			   {
+				   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.UnknownPrivateKey);
+			   }
+
+			   try
+			   {
+				   mPgpMessage = window.openpgp.message.readArmored(this.plainRaw);
+				   if (mPgpMessage && oPrivateKey && mPgpMessage.decrypt)
+				   {
+					   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Unverified);
+
+					   mPgpMessageDecrypted = mPgpMessage.decrypt(oPrivateKey);
+					   if (mPgpMessageDecrypted)
+					   {
+						   aRes = mPgpMessageDecrypted.verify(aPublicKey);
+						   if (aRes && 0 < aRes.length)
+						   {
+							   oValidKey = _.find(aRes, function (oItem) {
+								   return oItem && oItem.keyid && oItem.valid;
+							   });
+
+							   if (oValidKey)
+							   {
+								   oValidSysKey = Data.findPublicKeyByHex(oValidKey.keyid.toHex());
+								   if (oValidSysKey)
+								   {
+									   this.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.Success);
+									   this.pgpSignedVerifyUser(oValidSysKey.user);
+								   }
+							   }
+						   }
+
+						   sPlain = mPgpMessageDecrypted.getText();
+
+						   sPlain =
+							   Globals.$div.empty().append(
+								   $('
').text(sPlain)
+							   ).html()
+						   ;
+
+						   Globals.$div.empty();
+
+						   this.replacePlaneTextBody(sPlain);
+					   }
+				   }
+			   }
+			   catch (oExc) {}
+
+			   this.storePgpVerifyDataToDom();
+		   }
+		};
+
+		MessageModel.prototype.replacePlaneTextBody = function (sPlain)
 		{
-			if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
-			{
-				oSettingsScreen = RoutedSettingsViewModel.__vm;
-			}
-			else
-			{
-				oViewModelPlace = this.oViewModelPlace;
-				if (oViewModelPlace && 1 === oViewModelPlace.length)
-				{
-					oSettingsScreen = new RoutedSettingsViewModel();
+		   if (this.body)
+		   {
+			   this.body.html(sPlain).addClass('b-text-part plain');
+		   }
+		};
 
-					oViewModelDom = $('
').addClass('rl-settings-view-model').hide(); - oViewModelDom.appendTo(oViewModelPlace); - - oSettingsScreen.viewModelDom = oViewModelDom; - - oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData; - - RoutedSettingsViewModel.__dom = oViewModelDom; - RoutedSettingsViewModel.__builded = true; - RoutedSettingsViewModel.__vm = oSettingsScreen; - - ko.applyBindingAccessorsToNode(oViewModelDom[0], { - 'i18nInit': true, - 'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; } - }, oSettingsScreen); - - Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]); - } - else - { - Utils.log('Cannot find sub settings view model position: SettingsSubScreen'); - } - } - - if (oSettingsScreen) - { - _.defer(function () { - // hide - if (self.oCurrentSubScreen) - { - Utils.delegateRun(self.oCurrentSubScreen, 'onHide'); - self.oCurrentSubScreen.viewModelDom.hide(); - } - // -- - - self.oCurrentSubScreen = oSettingsScreen; - - // show - if (self.oCurrentSubScreen) - { - self.oCurrentSubScreen.viewModelDom.show(); - Utils.delegateRun(self.oCurrentSubScreen, 'onShow'); - Utils.delegateRun(self.oCurrentSubScreen, 'onFocus', [], 200); - - _.each(self.menu(), function (oItem) { - oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route); - }); - - $('#rl-content .b-settings .b-content .content').scrollTop(0); - } - // -- - - Utils.windowResize(); - }); - } - } - else + /** + * @return {string} + */ + MessageModel.prototype.flagHash = function () { - kn.setHash(LinkBuilder.settings(), false, true); - } - }; + return [this.deleted(), this.unseen(), this.flagged(), this.answered(), this.forwarded(), + this.isReadReceipt()].join(''); + }; - AbstractSettingsScreen.prototype.onHide = function () - { - if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom) - { - Utils.delegateRun(this.oCurrentSubScreen, 'onHide'); - this.oCurrentSubScreen.viewModelDom.hide(); - } - }; + module.exports = MessageModel; - AbstractSettingsScreen.prototype.onBuild = function () - { - _.each(Globals.aViewModels['settings'], function (SettingsViewModel) { - if (SettingsViewModel && SettingsViewModel.__rlSettingsData && - !_.find(Globals.aViewModels['settings-removed'], function (RemoveSettingsViewModel) { - return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel; - })) - { - this.menu.push({ - 'route': SettingsViewModel.__rlSettingsData.Route, - 'label': SettingsViewModel.__rlSettingsData.Label, - 'selected': ko.observable(false), - 'disabled': !!_.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { - return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel; - }) - }); - } - }, this); + }()); - this.oViewModelPlace = $('#rl-content #rl-settings-subscreen'); - }; +/***/ }, - AbstractSettingsScreen.prototype.routes = function () - { - var - DefaultViewModel = _.find(Globals.aViewModels['settings'], function (SettingsViewModel) { - return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData['IsDefault']; - }), - sDefaultRoute = DefaultViewModel ? DefaultViewModel.__rlSettingsData['Route'] : 'general', - oRules = { - 'subname': /^(.*)$/, - 'normalize_': function (oRequest, oVals) { - oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname); - return [oVals.subname]; - } - } - ; +/***/ 49: +/*!******************************!*\ + !*** ./dev/Common/Base64.js ***! + \******************************/ +/***/ function(module, exports, __webpack_require__) { - return [ - ['{subname}/', oRules], - ['{subname}', oRules], - ['', oRules] - ]; - }; + // Base64 encode / decode + // http://www.webtoolkit.info/ - module.exports = AbstractSettingsScreen; + (function () { -}(module, require)); -},{"$":20,"App:Knoin":27,"Globals":9,"Knoin:AbstractScreen":29,"LinkBuilder":11,"Utils":14,"_":25,"ko":22}],46:[function(require,module,exports){ + 'use strict'; -(function (module, require) { + /*jslint bitwise: true*/ + var Base64 = { - 'use strict'; + // private property + _keyStr : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', - var - _ = require('_'), + // public method for urlsafe encoding + urlsafe_encode : function (input) { + return Base64.encode(input).replace(/[+]/g, '-').replace(/[\/]/g, '_').replace(/[=]/g, '.'); + }, - KnoinAbstractScreen = require('Knoin:AbstractScreen') - ; - - /** - * @constructor - * @extends KnoinAbstractScreen - */ - function LoginScreen() - { - KnoinAbstractScreen.call(this, 'login', [ - require('View:RainLoop:Login') - ]); - } - - _.extend(LoginScreen.prototype, KnoinAbstractScreen.prototype); - - LoginScreen.prototype.onShow = function () - { - require('App:RainLoop').setTitle(''); - }; - - module.exports = LoginScreen; - -}(module, require)); -},{"App:RainLoop":3,"Knoin:AbstractScreen":29,"View:RainLoop:Login":72,"_":25}],47:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - Events = require('Events'), - - KnoinAbstractScreen = require('Knoin:AbstractScreen'), - - Settings = require('Storage:Settings'), - Data = require('Storage:RainLoop:Data'), - Cache = require('Storage:RainLoop:Cache'), - Remote = require('Storage:RainLoop:Remote') - ; - - /** - * @constructor - * @extends KnoinAbstractScreen - */ - function MailBoxScreen() - { - KnoinAbstractScreen.call(this, 'mailbox', [ - require('View:RainLoop:MailBoxSystemDropDown'), - require('View:RainLoop:MailBoxFolderList'), - require('View:RainLoop:MailBoxMessageList'), - require('View:RainLoop:MailBoxMessageView') - ]); - - this.oLastRoute = {}; - } - - _.extend(MailBoxScreen.prototype, KnoinAbstractScreen.prototype); - - /** - * @type {Object} - */ - MailBoxScreen.prototype.oLastRoute = {}; - - MailBoxScreen.prototype.setNewTitle = function () - { - var - sEmail = Data.accountEmail(), - nFoldersInboxUnreadCount = Data.foldersInboxUnreadCount() - ; - - require('App:RainLoop').setTitle(('' === sEmail ? '' : - (0 < nFoldersInboxUnreadCount ? '(' + nFoldersInboxUnreadCount + ') ' : ' ') + sEmail + ' - ') + Utils.i18n('TITLES/MAILBOX')); - }; - - MailBoxScreen.prototype.onShow = function () - { - this.setNewTitle(); - Globals.keyScope(Enums.KeyState.MessageList); - }; - - /** - * @param {string} sFolderHash - * @param {number} iPage - * @param {string} sSearch - * @param {boolean=} bPreview = false - */ - MailBoxScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch, bPreview) - { - if (Utils.isUnd(bPreview) ? false : !!bPreview) - { - if (Enums.Layout.NoPreview === Data.layout() && !Data.message()) - { - require('App:RainLoop').historyBack(); - } - } - else - { - var - sFolderFullNameRaw = Cache.getFolderFullNameRaw(sFolderHash), - oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw) - ; - - if (oFolder) - { - Data - .currentFolder(oFolder) - .messageListPage(iPage) - .messageListSearch(sSearch) + // public method for encoding + encode : function (input) { + var + output = '', + chr1, chr2, chr3, enc1, enc2, enc3, enc4, + i = 0 ; - if (Enums.Layout.NoPreview === Data.layout() && Data.message()) + input = Base64._utf8_encode(input); + + while (i < input.length) { - Data.message(null); - } + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); - require('App:RainLoop').reloadMessageList(); - } - } - }; + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; - MailBoxScreen.prototype.onStart = function () - { - var - fResizeFunction = function () { - Utils.windowResize(); - } - ; - - if (Settings.capa(Enums.Capa.AdditionalAccounts) || Settings.capa(Enums.Capa.AdditionalIdentities)) - { - require('App:RainLoop').accountsAndIdentities(); - } - - _.delay(function () { - if ('INBOX' !== Data.currentFolderFullNameRaw()) - { - require('App:RainLoop').folderInformation('INBOX'); - } - }, 1000); - - _.delay(function () { - require('App:RainLoop').quota(); - }, 5000); - - _.delay(function () { - Remote.appDelayStart(Utils.emptyFunction); - }, 35000); - - Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === Data.layout()); - - Data.folderList.subscribe(fResizeFunction); - Data.messageList.subscribe(fResizeFunction); - Data.message.subscribe(fResizeFunction); - - Data.layout.subscribe(function (nValue) { - Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue); - }); - - Events.sub('mailbox.inbox-unread-count', function (nCount) { - Data.foldersInboxUnreadCount(nCount); - }); - - Data.foldersInboxUnreadCount.subscribe(function () { - this.setNewTitle(); - }, this); - }; - - /** - * @return {Array} - */ - MailBoxScreen.prototype.routes = function () - { - var - fNormP = function () { - return ['Inbox', 1, '', true]; - }, - fNormS = function (oRequest, oVals) { - oVals[0] = Utils.pString(oVals[0]); - oVals[1] = Utils.pInt(oVals[1]); - oVals[1] = 0 >= oVals[1] ? 1 : oVals[1]; - oVals[2] = Utils.pString(oVals[2]); - - if ('' === oRequest) - { - oVals[0] = 'Inbox'; - oVals[1] = 1; - } - - return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2]), false]; - }, - fNormD = function (oRequest, oVals) { - oVals[0] = Utils.pString(oVals[0]); - oVals[1] = Utils.pString(oVals[1]); - - if ('' === oRequest) - { - oVals[0] = 'Inbox'; - } - - return [decodeURI(oVals[0]), 1, decodeURI(oVals[1]), false]; - } - ; - - return [ - [/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}], - [/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/, {'normalize_': fNormS}], - [/^([a-zA-Z0-9]+)\/(.+)\/?$/, {'normalize_': fNormD}], - [/^message-preview$/, {'normalize_': fNormP}], - [/^([^\/]*)$/, {'normalize_': fNormS}] - ]; - }; - - module.exports = MailBoxScreen; - -}(module, require)); -},{"App:RainLoop":3,"Enums":7,"Events":8,"Globals":9,"Knoin:AbstractScreen":29,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,"Utils":14,"View:RainLoop:MailBoxFolderList":73,"View:RainLoop:MailBoxMessageList":74,"View:RainLoop:MailBoxMessageView":75,"View:RainLoop:MailBoxSystemDropDown":76,"_":25}],48:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - Enums = require('Enums'), - Utils = require('Utils'), - Globals = require('Globals'), - - AbstractSettingsScreen = require('Screen:AbstractSettings') - ; - - /** - * @constructor - * @extends AbstractSettingsScreen - */ - function SettingsScreen() - { - AbstractSettingsScreen.call(this, [ - require('View:RainLoop:SettingsSystemDropDown'), - require('View:RainLoop:SettingsMenu'), - require('View:RainLoop:SettingsPane') - ]); - - Utils.initOnStartOrLangChange(function () { - this.sSettingsTitle = Utils.i18n('TITLES/SETTINGS'); - }, this, function () { - this.setSettingsTitle(); - }); - } - - _.extend(SettingsScreen.prototype, AbstractSettingsScreen.prototype); - - SettingsScreen.prototype.onShow = function () - { - this.setSettingsTitle(); - Globals.keyScope(Enums.KeyState.Settings); - }; - - SettingsScreen.prototype.setSettingsTitle = function () - { - require('App:RainLoop').setTitle(this.sSettingsTitle); - }; - - module.exports = SettingsScreen; - -}(module, require)); -},{"App:RainLoop":3,"Enums":7,"Globals":9,"Screen:AbstractSettings":45,"Utils":14,"View:RainLoop:SettingsMenu":94,"View:RainLoop:SettingsPane":95,"View:RainLoop:SettingsSystemDropDown":96,"_":25}],49:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - Data = require('Storage:RainLoop:Data'), - Remote = require('Storage:RainLoop:Remote') - ; - - /** - * @constructor - */ - function SettingsAccounts() - { - this.accounts = Data.accounts; - - this.processText = ko.computed(function () { - return Data.accountsLoading() ? Utils.i18n('SETTINGS_ACCOUNTS/LOADING_PROCESS') : ''; - }, this); - - this.visibility = ko.computed(function () { - return '' === this.processText() ? 'hidden' : 'visible'; - }, this); - - this.accountForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, - function (oPrev) { - if (oPrev) - { - oPrev.deleteAccess(false); - } - }, function (oNext) { - if (oNext) - { - oNext.deleteAccess(true); - } - } - ]}); - } - - SettingsAccounts.prototype.addNewAccount = function () - { - require('App:Knoin').showScreenPopup(require('View:Popup:AddAccount')); - }; - - /** - * @param {AccountModel} oAccountToRemove - */ - SettingsAccounts.prototype.deleteAccount = function (oAccountToRemove) - { - if (oAccountToRemove && oAccountToRemove.deleteAccess()) - { - this.accountForDeletion(null); - - var - kn = require('App:Knoin'), - fRemoveAccount = function (oAccount) { - return oAccountToRemove === oAccount; - } - ; - - if (oAccountToRemove) - { - this.accounts.remove(fRemoveAccount); - - Remote.accountDelete(function (sResult, oData) { - - if (Enums.StorageResultType.Success === sResult && oData && - oData.Result && oData.Reload) + if (isNaN(chr2)) { - kn.routeOff(); - kn.setHash(LinkBuilder.root(), true); - kn.routeOff(); + enc3 = enc4 = 64; + } + else if (isNaN(chr3)) + { + enc4 = 64; + } - _.defer(function () { - window.location.reload(); - }); + output = output + + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); + } + + return output; + }, + + // public method for decoding + decode : function (input) { + var + output = '', + chr1, chr2, chr3, enc1, enc2, enc3, enc4, + i = 0 + ; + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ''); + + while (i < input.length) + { + enc1 = this._keyStr.indexOf(input.charAt(i++)); + enc2 = this._keyStr.indexOf(input.charAt(i++)); + enc3 = this._keyStr.indexOf(input.charAt(i++)); + enc4 = this._keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 !== 64) + { + output = output + String.fromCharCode(chr2); + } + + if (enc4 !== 64) + { + output = output + String.fromCharCode(chr3); + } + } + + return Base64._utf8_decode(output); + }, + + // private method for UTF-8 encoding + _utf8_encode : function (string) { + + string = string.replace(/\r\n/g, "\n"); + + var + utftext = '', + n = 0, + l = string.length, + c = 0 + ; + + for (; n < l; n++) { + + c = string.charCodeAt(n); + + if (c < 128) + { + utftext += String.fromCharCode(c); + } + else if ((c > 127) && (c < 2048)) + { + utftext += String.fromCharCode((c >> 6) | 192); + utftext += String.fromCharCode((c & 63) | 128); } else { - require('App:RainLoop').accountsAndIdentities(); + utftext += String.fromCharCode((c >> 12) | 224); + utftext += String.fromCharCode(((c >> 6) & 63) | 128); + utftext += String.fromCharCode((c & 63) | 128); } + } - }, oAccountToRemove.email); + return utftext; + }, + + // private method for UTF-8 decoding + _utf8_decode : function (utftext) { + var + string = '', + i = 0, + c = 0, + c2 = 0, + c3 = 0 + ; + + while ( i < utftext.length ) + { + c = utftext.charCodeAt(i); + + if (c < 128) + { + string += String.fromCharCode(c); + i++; + } + else if((c > 191) && (c < 224)) + { + c2 = utftext.charCodeAt(i+1); + string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); + i += 2; + } + else + { + c2 = utftext.charCodeAt(i+1); + c3 = utftext.charCodeAt(i+2); + string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } + } + + return string; } - } - }; + }; - module.exports = SettingsAccounts; + module.exports = Base64; + /*jslint bitwise: false*/ -}(module, require)); -},{"App:Knoin":27,"App:RainLoop":3,"Enums":7,"LinkBuilder":11,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"View:Popup:AddAccount":77,"_":25,"ko":22,"window":26}],50:[function(require,module,exports){ + }()); -(function (module, require) { +/***/ }, - 'use strict'; +/***/ 51: +/*!************************************!*\ + !*** ./dev/Models/AccountModel.js ***! + \************************************/ +/***/ function(module, exports, __webpack_require__) { - var - _ = require('_'), - ko = require('ko'), + + (function () { - Enums = require('Enums'), - Utils = require('Utils'), + 'use strict'; - Remote = require('Storage:RainLoop:Remote') - ; + var + ko = __webpack_require__(/*! ko */ 3), - /** - * @constructor - */ - function SettingsChangePassword() - { - this.changeProcess = ko.observable(false); + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; - this.errorDescription = ko.observable(''); - this.passwordMismatch = ko.observable(false); - this.passwordUpdateError = ko.observable(false); - this.passwordUpdateSuccess = ko.observable(false); - - this.currentPassword = ko.observable(''); - this.currentPassword.error = ko.observable(false); - this.newPassword = ko.observable(''); - this.newPassword2 = ko.observable(''); - - this.currentPassword.subscribe(function () { - this.passwordUpdateError(false); - this.passwordUpdateSuccess(false); - this.currentPassword.error(false); - }, this); - - this.newPassword.subscribe(function () { - this.passwordUpdateError(false); - this.passwordUpdateSuccess(false); - this.passwordMismatch(false); - }, this); - - this.newPassword2.subscribe(function () { - this.passwordUpdateError(false); - this.passwordUpdateSuccess(false); - this.passwordMismatch(false); - }, this); - - this.saveNewPasswordCommand = Utils.createCommand(this, function () { - - if (this.newPassword() !== this.newPassword2()) - { - this.passwordMismatch(true); - this.errorDescription(Utils.i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH')); - } - else - { - this.changeProcess(true); - - this.passwordUpdateError(false); - this.passwordUpdateSuccess(false); - this.currentPassword.error(false); - this.passwordMismatch(false); - this.errorDescription(''); - - Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword()); - } - - }, function () { - return !this.changeProcess() && '' !== this.currentPassword() && - '' !== this.newPassword() && '' !== this.newPassword2(); - }); - - this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this); - } - - SettingsChangePassword.prototype.onHide = function () - { - this.changeProcess(false); - this.currentPassword(''); - this.newPassword(''); - this.newPassword2(''); - this.errorDescription(''); - this.passwordMismatch(false); - this.currentPassword.error(false); - }; - - SettingsChangePassword.prototype.onChangePasswordResponse = function (sResult, oData) - { - this.changeProcess(false); - this.passwordMismatch(false); - this.errorDescription(''); - this.currentPassword.error(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) + /** + * @constructor + * + * @param {string} sEmail + * @param {boolean=} bCanBeDelete = true + */ + function AccountModel(sEmail, bCanBeDelete) { - this.currentPassword(''); - this.newPassword(''); - this.newPassword2(''); + this.email = sEmail; - this.passwordUpdateSuccess(true); - this.currentPassword.error(false); + this.deleteAccess = ko.observable(false); + this.canBeDalete = ko.observable(Utils.isUnd(bCanBeDelete) ? true : !!bCanBeDelete); } - else + + /** + * @type {string} + */ + AccountModel.prototype.email = ''; + + /** + * @return {string} + */ + AccountModel.prototype.changeAccountLink = function () { - if (oData && Enums.Notification.CurrentPasswordIncorrect === oData.ErrorCode) + return __webpack_require__(/*! Common/LinkBuilder */ 11).change(this.email); + }; + + module.exports = AccountModel; + + }()); + +/***/ }, + +/***/ 52: +/*!***************************************!*\ + !*** ./dev/Models/AttachmentModel.js ***! + \***************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11) + ; + + /** + * @constructor + */ + function AttachmentModel() + { + this.mimeType = ''; + this.fileName = ''; + this.estimatedSize = 0; + this.friendlySize = ''; + this.isInline = false; + this.isLinked = false; + this.cid = ''; + this.cidWithOutTags = ''; + this.contentLocation = ''; + this.download = ''; + this.folder = ''; + this.uid = ''; + this.mimeIndex = ''; + } + + /** + * @static + * @param {AjaxJsonAttachment} oJsonAttachment + * @return {?AttachmentModel} + */ + AttachmentModel.newInstanceFromJson = function (oJsonAttachment) + { + var oAttachmentModel = new AttachmentModel(); + return oAttachmentModel.initByJson(oJsonAttachment) ? oAttachmentModel : null; + }; + + AttachmentModel.prototype.mimeType = ''; + AttachmentModel.prototype.fileName = ''; + AttachmentModel.prototype.estimatedSize = 0; + AttachmentModel.prototype.friendlySize = ''; + AttachmentModel.prototype.isInline = false; + AttachmentModel.prototype.isLinked = false; + AttachmentModel.prototype.cid = ''; + AttachmentModel.prototype.cidWithOutTags = ''; + AttachmentModel.prototype.contentLocation = ''; + AttachmentModel.prototype.download = ''; + AttachmentModel.prototype.folder = ''; + AttachmentModel.prototype.uid = ''; + AttachmentModel.prototype.mimeIndex = ''; + + /** + * @param {AjaxJsonAttachment} oJsonAttachment + */ + AttachmentModel.prototype.initByJson = function (oJsonAttachment) + { + var bResult = false; + if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object']) { - this.currentPassword.error(true); + this.mimeType = (oJsonAttachment.MimeType || '').toLowerCase(); + this.fileName = oJsonAttachment.FileName; + this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize); + this.isInline = !!oJsonAttachment.IsInline; + this.isLinked = !!oJsonAttachment.IsLinked; + this.cid = oJsonAttachment.CID; + this.contentLocation = oJsonAttachment.ContentLocation; + this.download = oJsonAttachment.Download; + + this.folder = oJsonAttachment.Folder; + this.uid = oJsonAttachment.Uid; + this.mimeIndex = oJsonAttachment.MimeIndex; + + this.friendlySize = Utils.friendlySize(this.estimatedSize); + this.cidWithOutTags = this.cid.replace(/^<+/, '').replace(/>+$/, ''); + + bResult = true; } - this.passwordUpdateError(true); - this.errorDescription(oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : - Utils.getNotification(Enums.Notification.CouldNotSaveNewPassword)); - } - }; + return bResult; + }; - module.exports = SettingsChangePassword; - -}(module, require)); -},{"Enums":7,"Storage:RainLoop:Remote":68,"Utils":14,"_":25,"ko":22}],51:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Utils = require('Utils'), - - Remote = require('Storage:RainLoop:Remote'), - Data = require('Storage:RainLoop:Data') - ; - - /** - * @constructor - */ - function SettingsContacts() - { - this.contactsAutosave = Data.contactsAutosave; - - this.allowContactsSync = Data.allowContactsSync; - this.enableContactsSync = Data.enableContactsSync; - this.contactsSyncUrl = Data.contactsSyncUrl; - this.contactsSyncUser = Data.contactsSyncUser; - this.contactsSyncPass = Data.contactsSyncPass; - - this.saveTrigger = ko.computed(function () { - return [ - this.enableContactsSync() ? '1' : '0', - this.contactsSyncUrl(), - this.contactsSyncUser(), - this.contactsSyncPass() - ].join('|'); - }, this).extend({'throttle': 500}); - - this.saveTrigger.subscribe(function () { - Remote.saveContactsSyncData(null, - this.enableContactsSync(), - this.contactsSyncUrl(), - this.contactsSyncUser(), - this.contactsSyncPass() + /** + * @return {boolean} + */ + AttachmentModel.prototype.isImage = function () + { + return -1 < Utils.inArray(this.mimeType.toLowerCase(), + ['image/png', 'image/jpg', 'image/jpeg', 'image/gif'] ); - }, this); - } + }; - SettingsContacts.prototype.onBuild = function () - { - Data.contactsAutosave.subscribe(function (bValue) { - Remote.saveSettings(Utils.emptyFunction, { - 'ContactsAutosave': bValue ? '1' : '0' - }); - }); - }; + /** + * @return {boolean} + */ + AttachmentModel.prototype.isText = function () + { + return 'text/' === this.mimeType.substr(0, 5) && + -1 === Utils.inArray(this.mimeType, ['text/html']); + }; - module.exports = SettingsContacts; + /** + * @return {boolean} + */ + AttachmentModel.prototype.isPdf = function () + { + return Globals.bAllowPdfPreview && 'application/pdf' === this.mimeType; + }; -}(module, require)); -},{"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"ko":22}],52:[function(require,module,exports){ + /** + * @return {string} + */ + AttachmentModel.prototype.linkDownload = function () + { + return LinkBuilder.attachmentDownload(this.download); + }; -(function (module, require) { + /** + * @return {string} + */ + AttachmentModel.prototype.linkPreview = function () + { + return LinkBuilder.attachmentPreview(this.download); + }; - 'use strict'; + /** + * @return {string} + */ + AttachmentModel.prototype.linkPreviewAsPlain = function () + { + return LinkBuilder.attachmentPreviewAsPlain(this.download); + }; - var - ko = require('ko'), - - Utils = require('Utils') - ; - - /** - * @constructor - */ - function SettingsFilters() - { - this.filters = ko.observableArray([]); - this.filters.loading = ko.observable(false); - - this.filters.subscribe(function () { - Utils.windowResize(); - }); - } - - SettingsFilters.prototype.deleteFilter = function (oFilter) - { - this.filters.remove(oFilter); - }; - - SettingsFilters.prototype.addFilter = function () - { - var - FilterModel = require('Model:Filter') - ; - - require('App:Knoin').showScreenPopup( - require('View:Popup:Filter'), [new FilterModel()]); - }; - - module.exports = SettingsFilters; - -}(module, require)); -},{"App:Knoin":27,"Model:Filter":39,"Utils":14,"View:Popup:Filter":84,"ko":22}],53:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Settings = require('Storage:Settings'), - Data = require('Storage:RainLoop:Data'), - Cache = require('Storage:RainLoop:Cache'), - Remote = require('Storage:RainLoop:Remote'), - LocalStorage = require('Storage:LocalStorage') - ; - - /** - * @constructor - */ - function SettingsFolders() - { - this.foldersListError = Data.foldersListError; - this.folderList = Data.folderList; - - this.processText = ko.computed(function () { - - var - bLoading = Data.foldersLoading(), - bCreating = Data.foldersCreating(), - bDeleting = Data.foldersDeleting(), - bRenaming = Data.foldersRenaming() - ; - - if (bCreating) + /** + * @return {string} + */ + AttachmentModel.prototype.generateTransferDownloadUrl = function () + { + var sLink = this.linkDownload(); + if ('http' !== sLink.substr(0, 4)) { - return Utils.i18n('SETTINGS_FOLDERS/CREATING_PROCESS'); + sLink = window.location.protocol + '//' + window.location.host + window.location.pathname + sLink; } - else if (bDeleting) + + return this.mimeType + ':' + this.fileName + ':' + sLink; + }; + + /** + * @param {AttachmentModel} oAttachment + * @param {*} oEvent + * @return {boolean} + */ + AttachmentModel.prototype.eventDragStart = function (oAttachment, oEvent) + { + var oLocalEvent = oEvent.originalEvent || oEvent; + if (oAttachment && oLocalEvent && oLocalEvent.dataTransfer && oLocalEvent.dataTransfer.setData) { - return Utils.i18n('SETTINGS_FOLDERS/DELETING_PROCESS'); - } - else if (bRenaming) - { - return Utils.i18n('SETTINGS_FOLDERS/RENAMING_PROCESS'); - } - else if (bLoading) - { - return Utils.i18n('SETTINGS_FOLDERS/LOADING_PROCESS'); + oLocalEvent.dataTransfer.setData('DownloadURL', this.generateTransferDownloadUrl()); } - return ''; - - }, this); - - this.visibility = ko.computed(function () { - return '' === this.processText() ? 'hidden' : 'visible'; - }, this); - - this.folderForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, - function (oPrev) { - if (oPrev) - { - oPrev.deleteAccess(false); - } - }, function (oNext) { - if (oNext) - { - oNext.deleteAccess(true); - } - } - ]}); - - this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this, - function (oPrev) { - if (oPrev) - { - oPrev.edited(false); - } - }, function (oNext) { - if (oNext && oNext.canBeEdited()) - { - oNext.edited(true); - } - } - ]}); - - this.useImapSubscribe = !!Settings.settingsGet('UseImapSubscribe'); - } - - SettingsFolders.prototype.folderEditOnEnter = function (oFolder) - { - var - sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '' - ; - - if ('' !== sEditName && oFolder.name() !== sEditName) - { - LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, ''); - - Data.foldersRenaming(true); - Remote.folderRename(function (sResult, oData) { - - Data.foldersRenaming(false); - if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) - { - Data.foldersListError( - oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER')); - } - - require('App:RainLoop').folders(); - - }, oFolder.fullNameRaw, sEditName); - - Cache.removeFolderFromCacheList(oFolder.fullNameRaw); - - oFolder.name(sEditName); - } - - oFolder.edited(false); - }; - - SettingsFolders.prototype.folderEditOnEsc = function (oFolder) - { - if (oFolder) - { - oFolder.edited(false); - } - }; - - SettingsFolders.prototype.onShow = function () - { - Data.foldersListError(''); - }; - - SettingsFolders.prototype.createFolder = function () - { - require('App:Knoin').showScreenPopup(require('View:Popup:FolderCreate')); - }; - - SettingsFolders.prototype.systemFolder = function () - { - require('App:Knoin').showScreenPopup(require('View:Popup:FolderSystem')); - }; - - SettingsFolders.prototype.deleteFolder = function (oFolderToRemove) - { - if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() && - 0 === oFolderToRemove.privateMessageCountAll()) - { - this.folderForDeletion(null); - - var - fRemoveFolder = function (oFolder) { - - if (oFolderToRemove === oFolder) - { - return true; - } - - oFolder.subFolders.remove(fRemoveFolder); - return false; - } - ; - - if (oFolderToRemove) - { - LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, ''); - - Data.folderList.remove(fRemoveFolder); - - Data.foldersDeleting(true); - Remote.folderDelete(function (sResult, oData) { - - Data.foldersDeleting(false); - if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) - { - Data.foldersListError( - oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER')); - } - - require('App:RainLoop').folders(); - - }, oFolderToRemove.fullNameRaw); - - Cache.removeFolderFromCacheList(oFolderToRemove.fullNameRaw); - } - } - else if (0 < oFolderToRemove.privateMessageCountAll()) - { - Data.foldersListError(Utils.getNotification(Enums.Notification.CantDeleteNonEmptyFolder)); - } - }; - - SettingsFolders.prototype.subscribeFolder = function (oFolder) - { - LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, ''); - Remote.folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, true); - - oFolder.subScribed(true); - }; - - SettingsFolders.prototype.unSubscribeFolder = function (oFolder) - { - LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, ''); - Remote.folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, false); - - oFolder.subScribed(false); - }; - - module.exports = SettingsFolders; - -}(module, require)); -},{"App:Knoin":27,"App:RainLoop":3,"Enums":7,"Storage:LocalStorage":65,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,"Utils":14,"View:Popup:FolderCreate":86,"View:Popup:FolderSystem":87,"ko":22}],54:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - $ = require('$'), - ko = require('ko'), - - Enums = require('Enums'), - Consts = require('Consts'), - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - Data = require('Storage:RainLoop:Data'), - Remote = require('Storage:RainLoop:Remote') - ; - - /** - * @constructor - */ - function SettingsGeneral() - { - this.mainLanguage = Data.mainLanguage; - this.mainMessagesPerPage = Data.mainMessagesPerPage; - this.mainMessagesPerPageArray = Consts.Defaults.MessagesPerPageArray; - this.editorDefaultType = Data.editorDefaultType; - this.showImages = Data.showImages; - this.interfaceAnimation = Data.interfaceAnimation; - this.useDesktopNotifications = Data.useDesktopNotifications; - this.threading = Data.threading; - this.useThreads = Data.useThreads; - this.replySameFolder = Data.replySameFolder; - this.layout = Data.layout; - this.usePreviewPane = Data.usePreviewPane; - this.useCheckboxesInList = Data.useCheckboxesInList; - this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings; - - this.isDesktopNotificationsSupported = ko.computed(function () { - return Enums.DesktopNotifications.NotSupported !== Data.desktopNotificationsPermisions(); - }); - - this.isDesktopNotificationsDenied = ko.computed(function () { - return Enums.DesktopNotifications.NotSupported === Data.desktopNotificationsPermisions() || - Enums.DesktopNotifications.Denied === Data.desktopNotificationsPermisions(); - }); - - this.mainLanguageFullName = ko.computed(function () { - return Utils.convertLangName(this.mainLanguage()); - }, this); - - this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100}); - this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - - this.isAnimationSupported = Globals.bAnimationSupported; - } - - SettingsGeneral.prototype.toggleLayout = function () - { - this.layout(Enums.Layout.NoPreview === this.layout() ? Enums.Layout.SidePreview : Enums.Layout.NoPreview); - }; - - SettingsGeneral.prototype.onBuild = function () - { - var self = this; - - _.delay(function () { - - var - f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self) - ; - - Data.language.subscribe(function (sValue) { - - self.languageTrigger(Enums.SaveSettingsStep.Animate); - - $.ajax({ - 'url': LinkBuilder.langLink(sValue), - 'dataType': 'script', - 'cache': true - }).done(function() { - Utils.i18nReload(); - self.languageTrigger(Enums.SaveSettingsStep.TrueResult); - }).fail(function() { - self.languageTrigger(Enums.SaveSettingsStep.FalseResult); - }).always(function() { - _.delay(function () { - self.languageTrigger(Enums.SaveSettingsStep.Idle); - }, 1000); - }); - - Remote.saveSettings(Utils.emptyFunction, { - 'Language': sValue - }); - }); - - Data.editorDefaultType.subscribe(function (sValue) { - Remote.saveSettings(Utils.emptyFunction, { - 'EditorDefaultType': sValue - }); - }); - - Data.messagesPerPage.subscribe(function (iValue) { - Remote.saveSettings(f1, { - 'MPP': iValue - }); - }); - - Data.showImages.subscribe(function (bValue) { - Remote.saveSettings(Utils.emptyFunction, { - 'ShowImages': bValue ? '1' : '0' - }); - }); - - Data.interfaceAnimation.subscribe(function (sValue) { - Remote.saveSettings(Utils.emptyFunction, { - 'InterfaceAnimation': sValue - }); - }); - - Data.useDesktopNotifications.subscribe(function (bValue) { - Utils.timeOutAction('SaveDesktopNotifications', function () { - Remote.saveSettings(Utils.emptyFunction, { - 'DesktopNotifications': bValue ? '1' : '0' - }); - }, 3000); - }); - - Data.replySameFolder.subscribe(function (bValue) { - Utils.timeOutAction('SaveReplySameFolder', function () { - Remote.saveSettings(Utils.emptyFunction, { - 'ReplySameFolder': bValue ? '1' : '0' - }); - }, 3000); - }); - - Data.useThreads.subscribe(function (bValue) { - - Data.messageList([]); - - Remote.saveSettings(Utils.emptyFunction, { - 'UseThreads': bValue ? '1' : '0' - }); - }); - - Data.layout.subscribe(function (nValue) { - - Data.messageList([]); - - Remote.saveSettings(Utils.emptyFunction, { - 'Layout': nValue - }); - }); - - Data.useCheckboxesInList.subscribe(function (bValue) { - Remote.saveSettings(Utils.emptyFunction, { - 'UseCheckboxesInList': bValue ? '1' : '0' - }); - }); - - }, 50); - }; - - SettingsGeneral.prototype.onShow = function () - { - Data.desktopNotifications.valueHasMutated(); - }; - - SettingsGeneral.prototype.selectLanguage = function () - { - require('App:Knoin').showScreenPopup(require('View:Popup:Languages')); - }; - - module.exports = SettingsGeneral; - -}(module, require)); -},{"$":20,"App:Knoin":27,"Consts":6,"Enums":7,"Globals":9,"LinkBuilder":11,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"View:Popup:Languages":90,"_":25,"ko":22}],55:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - HtmlEditor = require('HtmlEditor'), - - Data = require('Storage:RainLoop:Data'), - Remote = require('Storage:RainLoop:Remote') - ; - - /** - * @constructor - */ - function SettingsIdentities() - { - this.editor = null; - this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; - - this.accountEmail = Data.accountEmail; - this.displayName = Data.displayName; - this.signature = Data.signature; - this.signatureToAll = Data.signatureToAll; - this.replyTo = Data.replyTo; - - this.signatureDom = ko.observable(null); - - this.defaultIdentityIDTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - - this.identities = Data.identities; - this.defaultIdentityID = Data.defaultIdentityID; - - this.identitiesOptions = ko.computed(function () { - - var - aList = this.identities(), - aResult = [] - ; - - if (0 < aList.length) - { - aResult.push({ - 'id': this.accountEmail.peek(), - 'name': this.formattedAccountIdentity(), - 'seporator': false - }); - - aResult.push({ - 'id': '---', - 'name': '---', - 'seporator': true, - 'disabled': true - }); - - _.each(aList, function (oItem) { - aResult.push({ - 'id': oItem.id, - 'name': oItem.formattedNameForEmail(), - 'seporator': false - }); - }); - } - - return aResult; - }, this); - - this.processText = ko.computed(function () { - return Data.identitiesLoading() ? Utils.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : ''; - }, this); - - this.visibility = ko.computed(function () { - return '' === this.processText() ? 'hidden' : 'visible'; - }, this); - - this.identityForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, - function (oPrev) { - if (oPrev) - { - oPrev.deleteAccess(false); - } - }, function (oNext) { - if (oNext) - { - oNext.deleteAccess(true); - } - } - ]}); - } - - /** - * - * @return {string} - */ - SettingsIdentities.prototype.formattedAccountIdentity = function () - { - var - sDisplayName = this.displayName.peek(), - sEmail = this.accountEmail.peek() - ; - - return '' === sDisplayName ? sEmail : '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>'; - }; - - SettingsIdentities.prototype.addNewIdentity = function () - { - require('App:Knoin').showScreenPopup(require('View:Popup:Identity')); - }; - - SettingsIdentities.prototype.editIdentity = function (oIdentity) - { - require('App:Knoin').showScreenPopup(require('View:Popup:Identity'), [oIdentity]); - }; - - /** - * @param {IdentityModel} oIdentityToRemove - */ - SettingsIdentities.prototype.deleteIdentity = function (oIdentityToRemove) - { - if (oIdentityToRemove && oIdentityToRemove.deleteAccess()) - { - this.identityForDeletion(null); - - var - fRemoveFolder = function (oIdentity) { - return oIdentityToRemove === oIdentity; - } - ; - - if (oIdentityToRemove) - { - this.identities.remove(fRemoveFolder); - - Remote.identityDelete(function () { - require('App:RainLoop').accountsAndIdentities(); - }, oIdentityToRemove.id); - } - } - }; - - SettingsIdentities.prototype.onFocus = function () - { - if (!this.editor && this.signatureDom()) - { - var - self = this, - sSignature = Data.signature() - ; - - this.editor = new HtmlEditor(self.signatureDom(), function () { - Data.signature( - (self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData() - ); - }, function () { - if (':HTML:' === sSignature.substr(0, 6)) - { - self.editor.setHtml(sSignature.substr(6), false); - } - else - { - self.editor.setPlain(sSignature, false); - } - }); - } - }; - - SettingsIdentities.prototype.onBuild = function (oDom) - { - var self = this; - - oDom - .on('click', '.identity-item .e-action', function () { - var oIdentityItem = ko.dataFor(this); - if (oIdentityItem) - { - self.editIdentity(oIdentityItem); - } - }) - ; - - _.delay(function () { - - var - f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self), - f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self), - f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self), - f4 = Utils.settingsSaveHelperSimpleFunction(self.defaultIdentityIDTrigger, self) - ; - - Data.defaultIdentityID.subscribe(function (sValue) { - Remote.saveSettings(f4, { - 'DefaultIdentityID': sValue - }); - }); - - Data.displayName.subscribe(function (sValue) { - Remote.saveSettings(f1, { - 'DisplayName': sValue - }); - }); - - Data.replyTo.subscribe(function (sValue) { - Remote.saveSettings(f2, { - 'ReplyTo': sValue - }); - }); - - Data.signature.subscribe(function (sValue) { - Remote.saveSettings(f3, { - 'Signature': sValue - }); - }); - - Data.signatureToAll.subscribe(function (bValue) { - Remote.saveSettings(null, { - 'SignatureToAll': bValue ? '1' : '0' - }); - }); - - }, 50); - }; - - module.exports = SettingsIdentities; - -}(module, require)); -},{"App:Knoin":27,"App:RainLoop":3,"Enums":7,"HtmlEditor":10,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"View:Popup:Identity":88,"_":25,"ko":22}],56:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - HtmlEditor = require('HtmlEditor'), - - Data = require('Storage:RainLoop:Data'), - Remote = require('Storage:RainLoop:Remote') - ; - - /** - * @constructor - */ - function SettingsIdentity() - { - this.editor = null; - - this.displayName = Data.displayName; - this.signature = Data.signature; - this.signatureToAll = Data.signatureToAll; - this.replyTo = Data.replyTo; - - this.signatureDom = ko.observable(null); - - this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - } - - SettingsIdentity.prototype.onFocus = function () - { - if (!this.editor && this.signatureDom()) - { - var - self = this, - sSignature = Data.signature() - ; - - this.editor = new HtmlEditor(self.signatureDom(), function () { - Data.signature( - (self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData() - ); - }, function () { - if (':HTML:' === sSignature.substr(0, 6)) - { - self.editor.setHtml(sSignature.substr(6), false); - } - else - { - self.editor.setPlain(sSignature, false); - } - }); - } - }; - - SettingsIdentity.prototype.onBuild = function () - { - var self = this; - _.delay(function () { - - var - f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self), - f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self), - f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self) - ; - - Data.displayName.subscribe(function (sValue) { - Remote.saveSettings(f1, { - 'DisplayName': sValue - }); - }); - - Data.replyTo.subscribe(function (sValue) { - Remote.saveSettings(f2, { - 'ReplyTo': sValue - }); - }); - - Data.signature.subscribe(function (sValue) { - Remote.saveSettings(f3, { - 'Signature': sValue - }); - }); - - Data.signatureToAll.subscribe(function (bValue) { - Remote.saveSettings(null, { - 'SignatureToAll': bValue ? '1' : '0' - }); - }); - - }, 50); - }; - - module.exports = SettingsIdentity; - -}(module, require)); -},{"Enums":7,"HtmlEditor":10,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"_":25,"ko":22}],57:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - kn = require('App:Knoin'), - - Data = require('Storage:RainLoop:Data') - ; - - /** - * @constructor - */ - function SettingsOpenPGP() - { - this.openpgpkeys = Data.openpgpkeys; - this.openpgpkeysPublic = Data.openpgpkeysPublic; - this.openpgpkeysPrivate = Data.openpgpkeysPrivate; - - this.openPgpKeyForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this, - function (oPrev) { - if (oPrev) - { - oPrev.deleteAccess(false); - } - }, function (oNext) { - if (oNext) - { - oNext.deleteAccess(true); - } - } - ]}); - } - - SettingsOpenPGP.prototype.addOpenPgpKey = function () - { - kn.showScreenPopup(require('View:Popup:AddOpenPgpKey')); - }; - - SettingsOpenPGP.prototype.generateOpenPgpKey = function () - { - kn.showScreenPopup(require('View:Popup:NewOpenPgpKey')); - }; - - SettingsOpenPGP.prototype.viewOpenPgpKey = function (oOpenPgpKey) - { - if (oOpenPgpKey) - { - kn.showScreenPopup(require('View:Popup:ViewOpenPgpKey'), [oOpenPgpKey]); - } - }; - - /** - * @param {OpenPgpKeyModel} oOpenPgpKeyToRemove - */ - SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove) - { - if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess()) - { - this.openPgpKeyForDeletion(null); - - if (oOpenPgpKeyToRemove && Data.openpgpKeyring) - { - this.openpgpkeys.remove(function (oOpenPgpKey) { - return oOpenPgpKeyToRemove === oOpenPgpKey; - }); - - Data.openpgpKeyring[oOpenPgpKeyToRemove.isPrivate ? 'privateKeys' : 'publicKeys'] - .removeForId(oOpenPgpKeyToRemove.guid); - - Data.openpgpKeyring.store(); - - require('App:RainLoop').reloadOpenPgpKeys(); - } - } - }; - - module.exports = SettingsOpenPGP; - -}(module, require)); -},{"App:Knoin":27,"App:RainLoop":3,"Storage:RainLoop:Data":64,"View:Popup:AddOpenPgpKey":78,"View:Popup:NewOpenPgpKey":91,"View:Popup:ViewOpenPgpKey":93,"ko":22}],58:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - ko = require('ko'), - - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - - Remote = require('Storage:RainLoop:Remote') - ; - - /** - * @constructor - */ - function SettingsSecurity() - { - this.processing = ko.observable(false); - this.clearing = ko.observable(false); - this.secreting = ko.observable(false); - - this.viewUser = ko.observable(''); - this.viewEnable = ko.observable(false); - this.viewEnable.subs = true; - this.twoFactorStatus = ko.observable(false); - - this.viewSecret = ko.observable(''); - this.viewBackupCodes = ko.observable(''); - this.viewUrl = ko.observable(''); - - this.bFirst = true; - - this.viewTwoFactorStatus = ko.computed(function () { - Globals.langChangeTrigger(); - return Utils.i18n( - this.twoFactorStatus() ? - 'SETTINGS_SECURITY/TWO_FACTOR_SECRET_CONFIGURED_DESC' : - 'SETTINGS_SECURITY/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC' - ); - }, this); - - this.onResult = _.bind(this.onResult, this); - this.onSecretResult = _.bind(this.onSecretResult, this); - } - - SettingsSecurity.prototype.showSecret = function () - { - this.secreting(true); - Remote.showTwoFactorSecret(this.onSecretResult); - }; - - SettingsSecurity.prototype.hideSecret = function () - { - this.viewSecret(''); - this.viewBackupCodes(''); - this.viewUrl(''); - }; - - SettingsSecurity.prototype.createTwoFactor = function () - { - this.processing(true); - Remote.createTwoFactor(this.onResult); - }; - - SettingsSecurity.prototype.enableTwoFactor = function () - { - this.processing(true); - Remote.enableTwoFactor(this.onResult, this.viewEnable()); - }; - - SettingsSecurity.prototype.testTwoFactor = function () - { - require('App:Knoin').showScreenPopup(require('View:Popup:TwoFactorTest')); - }; - - SettingsSecurity.prototype.clearTwoFactor = function () - { - this.viewSecret(''); - this.viewBackupCodes(''); - this.viewUrl(''); - - this.clearing(true); - Remote.clearTwoFactor(this.onResult); - }; - - SettingsSecurity.prototype.onShow = function () - { - this.viewSecret(''); - this.viewBackupCodes(''); - this.viewUrl(''); - }; - - SettingsSecurity.prototype.onResult = function (sResult, oData) - { - this.processing(false); - this.clearing(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - this.viewUser(Utils.pString(oData.Result.User)); - this.viewEnable(!!oData.Result.Enable); - this.twoFactorStatus(!!oData.Result.IsSet); - - this.viewSecret(Utils.pString(oData.Result.Secret)); - this.viewBackupCodes(Utils.pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' ')); - this.viewUrl(Utils.pString(oData.Result.Url)); - } - else - { - this.viewUser(''); - this.viewEnable(false); - this.twoFactorStatus(false); - - this.viewSecret(''); - this.viewBackupCodes(''); - this.viewUrl(''); - } - - if (this.bFirst) - { - this.bFirst = false; - var self = this; - this.viewEnable.subscribe(function (bValue) { - if (this.viewEnable.subs) - { - Remote.enableTwoFactor(function (sResult, oData) { - if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) - { - self.viewEnable.subs = false; - self.viewEnable(false); - self.viewEnable.subs = true; - } - }, bValue); - } - }, this); - } - }; - - SettingsSecurity.prototype.onSecretResult = function (sResult, oData) - { - this.secreting(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - this.viewSecret(Utils.pString(oData.Result.Secret)); - this.viewUrl(Utils.pString(oData.Result.Url)); - } - else - { - this.viewSecret(''); - this.viewUrl(''); - } - }; - - SettingsSecurity.prototype.onBuild = function () - { - this.processing(true); - Remote.getTwoFactor(this.onResult); - }; - - module.exports = SettingsSecurity; - -}(module, require)); -},{"App:Knoin":27,"Enums":7,"Globals":9,"Storage:RainLoop:Remote":68,"Utils":14,"View:Popup:TwoFactorTest":92,"ko":22}],59:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - /** - * @constructor - */ - function SettingsSocial() - { - var - Utils = require('Utils'), - Data = require('Storage:RainLoop:Data') - ; - - this.googleEnable = Data.googleEnable; - - this.googleActions = Data.googleActions; - this.googleLoggined = Data.googleLoggined; - this.googleUserName = Data.googleUserName; - - this.facebookEnable = Data.facebookEnable; - - this.facebookActions = Data.facebookActions; - this.facebookLoggined = Data.facebookLoggined; - this.facebookUserName = Data.facebookUserName; - - this.twitterEnable = Data.twitterEnable; - - this.twitterActions = Data.twitterActions; - this.twitterLoggined = Data.twitterLoggined; - this.twitterUserName = Data.twitterUserName; - - this.connectGoogle = Utils.createCommand(this, function () { - if (!this.googleLoggined()) - { - require('App:RainLoop').googleConnect(); - } - }, function () { - return !this.googleLoggined() && !this.googleActions(); - }); - - this.disconnectGoogle = Utils.createCommand(this, function () { - require('App:RainLoop').googleDisconnect(); - }); - - this.connectFacebook = Utils.createCommand(this, function () { - if (!this.facebookLoggined()) - { - require('App:RainLoop').facebookConnect(); - } - }, function () { - return !this.facebookLoggined() && !this.facebookActions(); - }); - - this.disconnectFacebook = Utils.createCommand(this, function () { - require('App:RainLoop').facebookDisconnect(); - }); - - this.connectTwitter = Utils.createCommand(this, function () { - if (!this.twitterLoggined()) - { - require('App:RainLoop').twitterConnect(); - } - }, function () { - return !this.twitterLoggined() && !this.twitterActions(); - }); - - this.disconnectTwitter = Utils.createCommand(this, function () { - require('App:RainLoop').twitterDisconnect(); - }); - } - - module.exports = SettingsSocial; - -}(module, require)); -},{"App:RainLoop":3,"Storage:RainLoop:Data":64,"Utils":14}],60:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - Data = require('Storage:RainLoop:Data'), - Remote = require('Storage:RainLoop:Remote') - ; - - /** - * @constructor - */ - function SettingsThemes() - { - var self = this; - - this.mainTheme = Data.mainTheme; - this.themesObjects = ko.observableArray([]); - - this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100}); - - this.oLastAjax = null; - this.iTimer = 0; - - Data.theme.subscribe(function (sValue) { - - _.each(this.themesObjects(), function (oTheme) { - oTheme.selected(sValue === oTheme.name); - }); - - var - oThemeLink = $('#rlThemeLink'), - oThemeStyle = $('#rlThemeStyle'), - sUrl = oThemeLink.attr('href') - ; - - if (!sUrl) - { - sUrl = oThemeStyle.attr('data-href'); - } - - if (sUrl) - { - sUrl = sUrl.toString().replace(/\/-\/[^\/]+\/\-\//, '/-/' + sValue + '/-/'); - sUrl = sUrl.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/0/User/'); - - if ('Json/' !== sUrl.substring(sUrl.length - 5, sUrl.length)) - { - sUrl += 'Json/'; - } - - window.clearTimeout(self.iTimer); - self.themeTrigger(Enums.SaveSettingsStep.Animate); - - if (this.oLastAjax && this.oLastAjax.abort) - { - this.oLastAjax.abort(); - } - - this.oLastAjax = $.ajax({ - 'url': sUrl, - 'dataType': 'json' - }).done(function(aData) { - - if (aData && Utils.isArray(aData) && 2 === aData.length) - { - if (oThemeLink && oThemeLink[0] && (!oThemeStyle || !oThemeStyle[0])) - { - oThemeStyle = $(''); - oThemeLink.after(oThemeStyle); - oThemeLink.remove(); - } - - if (oThemeStyle && oThemeStyle[0]) - { - oThemeStyle.attr('data-href', sUrl).attr('data-theme', aData[0]); - if (oThemeStyle && oThemeStyle[0] && oThemeStyle[0].styleSheet && !Utils.isUnd(oThemeStyle[0].styleSheet.cssText)) - { - oThemeStyle[0].styleSheet.cssText = aData[1]; - } - else - { - oThemeStyle.text(aData[1]); - } - } - - self.themeTrigger(Enums.SaveSettingsStep.TrueResult); - } - - }).always(function() { - - self.iTimer = window.setTimeout(function () { - self.themeTrigger(Enums.SaveSettingsStep.Idle); - }, 1000); - - self.oLastAjax = null; - }); - } - - Remote.saveSettings(null, { - 'Theme': sValue - }); - - }, this); - } - - SettingsThemes.prototype.onBuild = function () - { - var sCurrentTheme = Data.theme(); - this.themesObjects(_.map(Data.themes(), function (sTheme) { - return { - 'name': sTheme, - 'nameDisplay': Utils.convertThemeName(sTheme), - 'selected': ko.observable(sTheme === sCurrentTheme), - 'themePreviewSrc': LinkBuilder.themePreviewLink(sTheme) - }; - })); - }; - - module.exports = SettingsThemes; - -}(module, require)); -},{"$":20,"Enums":7,"LinkBuilder":11,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"_":25,"ko":22,"window":26}],61:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - -(function (module, require) { - - 'use strict'; - - var - Enums = require('Enums'), - Utils = require('Utils'), - - Settings = require('Storage:Settings') - ; - - /** - * @constructor - */ - function AbstractData() - { - Utils.initDataConstructorBySettings(this); - } - - AbstractData.prototype.populateDataOnStart = function() - { - var - mLayout = Utils.pInt(Settings.settingsGet('Layout')), - aLanguages = Settings.settingsGet('Languages'), - aThemes = Settings.settingsGet('Themes') - ; - - if (Utils.isArray(aLanguages)) - { - this.languages(aLanguages); - } - - if (Utils.isArray(aThemes)) - { - this.themes(aThemes); - } - - this.mainLanguage(Settings.settingsGet('Language')); - this.mainTheme(Settings.settingsGet('Theme')); - - this.capaAdditionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts)); - this.capaAdditionalIdentities(Settings.capa(Enums.Capa.AdditionalIdentities)); - this.capaGravatar(Settings.capa(Enums.Capa.Gravatar)); - this.determineUserLanguage(!!Settings.settingsGet('DetermineUserLanguage')); - this.determineUserDomain(!!Settings.settingsGet('DetermineUserDomain')); - - this.capaThemes(Settings.capa(Enums.Capa.Themes)); - this.allowLanguagesOnLogin(!!Settings.settingsGet('AllowLanguagesOnLogin')); - this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings')); - this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages')); - - this.editorDefaultType(Settings.settingsGet('EditorDefaultType')); - this.showImages(!!Settings.settingsGet('ShowImages')); - this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave')); - this.interfaceAnimation(Settings.settingsGet('InterfaceAnimation')); - - this.mainMessagesPerPage(Settings.settingsGet('MPP')); - - this.desktopNotifications(!!Settings.settingsGet('DesktopNotifications')); - this.useThreads(!!Settings.settingsGet('UseThreads')); - this.replySameFolder(!!Settings.settingsGet('ReplySameFolder')); - this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList')); - - this.layout(Enums.Layout.SidePreview); - if (-1 < Utils.inArray(mLayout, [Enums.Layout.NoPreview, Enums.Layout.SidePreview, Enums.Layout.BottomPreview])) - { - this.layout(mLayout); - } - this.facebookSupported(!!Settings.settingsGet('SupportedFacebookSocial')); - this.facebookEnable(!!Settings.settingsGet('AllowFacebookSocial')); - this.facebookAppID(Settings.settingsGet('FacebookAppID')); - this.facebookAppSecret(Settings.settingsGet('FacebookAppSecret')); - - this.twitterEnable(!!Settings.settingsGet('AllowTwitterSocial')); - this.twitterConsumerKey(Settings.settingsGet('TwitterConsumerKey')); - this.twitterConsumerSecret(Settings.settingsGet('TwitterConsumerSecret')); - - this.googleEnable(!!Settings.settingsGet('AllowGoogleSocial')); - this.googleClientID(Settings.settingsGet('GoogleClientID')); - this.googleClientSecret(Settings.settingsGet('GoogleClientSecret')); - this.googleApiKey(Settings.settingsGet('GoogleApiKey')); - - this.dropboxEnable(!!Settings.settingsGet('AllowDropboxSocial')); - this.dropboxApiKey(Settings.settingsGet('DropboxApiKey')); - - this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed')); - }; - - module.exports = AbstractData; - -}(module, require)); -},{"Enums":7,"Storage:Settings":69,"Utils":14}],62:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - - Consts = require('Consts'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - Plugins = require('Plugins'), - LinkBuilder = require('LinkBuilder'), - - Settings = require('Storage:Settings') - ; - - /** - * @constructor - */ - function AbstractRemoteStorage() - { - this.oRequests = {}; - } - - AbstractRemoteStorage.prototype.oRequests = {}; - - /** - * @param {?Function} fCallback - * @param {string} sRequestAction - * @param {string} sType - * @param {?AjaxJsonDefaultResponse} oData - * @param {boolean} bCached - * @param {*=} oRequestParameters - */ - AbstractRemoteStorage.prototype.defaultResponse = function (fCallback, sRequestAction, sType, oData, bCached, oRequestParameters) - { - var - fCall = function () { - if (Enums.StorageResultType.Success !== sType && Globals.bUnload) - { - sType = Enums.StorageResultType.Unload; - } - - if (Enums.StorageResultType.Success === sType && oData && !oData.Result) - { - if (oData && -1 < Utils.inArray(oData.ErrorCode, [ - Enums.Notification.AuthError, Enums.Notification.AccessError, - Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed, - Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError - ])) - { - Globals.iAjaxErrorCount++; - } - - if (oData && Enums.Notification.InvalidToken === oData.ErrorCode) - { - Globals.iTokenErrorCount++; - } - - if (Consts.Values.TokenErrorLimit < Globals.iTokenErrorCount) - { - if (Globals.__APP) - { - Globals.__APP.loginAndLogoutReload(true); - } - } - - if (oData.Logout || Consts.Values.AjaxErrorLimit < Globals.iAjaxErrorCount) - { - if (window.__rlah_clear) - { - window.__rlah_clear(); - } - - if (Globals.__APP) - { - Globals.__APP.loginAndLogoutReload(true); - } - } - } - else if (Enums.StorageResultType.Success === sType && oData && oData.Result) - { - Globals.iAjaxErrorCount = 0; - Globals.iTokenErrorCount = 0; - } - - if (fCallback) - { - Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]); - - fCallback( - sType, - Enums.StorageResultType.Success === sType ? oData : null, - bCached, - sRequestAction, - oRequestParameters - ); - } - } - ; - - switch (sType) - { - case 'success': - sType = Enums.StorageResultType.Success; - break; - case 'abort': - sType = Enums.StorageResultType.Abort; - break; - default: - sType = Enums.StorageResultType.Error; - break; - } - - if (Enums.StorageResultType.Error === sType) - { - _.delay(fCall, 300); - } - else - { - fCall(); - } - }; - - /** - * @param {?Function} fResultCallback - * @param {Object} oParameters - * @param {?number=} iTimeOut = 20000 - * @param {string=} sGetAdd = '' - * @param {Array=} aAbortActions = [] - * @return {jQuery.jqXHR} - */ - AbstractRemoteStorage.prototype.ajaxRequest = function (fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions) - { - var - self = this, - bPost = '' === sGetAdd, - oHeaders = {}, - iStart = (new window.Date()).getTime(), - oDefAjax = null, - sAction = '' - ; - - oParameters = oParameters || {}; - iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000; - sGetAdd = Utils.isUnd(sGetAdd) ? '' : Utils.pString(sGetAdd); - aAbortActions = Utils.isArray(aAbortActions) ? aAbortActions : []; - - sAction = oParameters.Action || ''; - - if (sAction && 0 < aAbortActions.length) - { - _.each(aAbortActions, function (sActionToAbort) { - if (self.oRequests[sActionToAbort]) - { - self.oRequests[sActionToAbort].__aborted = true; - if (self.oRequests[sActionToAbort].abort) - { - self.oRequests[sActionToAbort].abort(); - } - self.oRequests[sActionToAbort] = null; - } - }); - } - - if (bPost) - { - oParameters['XToken'] = Settings.settingsGet('Token'); - } - - oDefAjax = $.ajax({ - 'type': bPost ? 'POST' : 'GET', - 'url': LinkBuilder.ajax(sGetAdd), - 'async': true, - 'dataType': 'json', - 'data': bPost ? oParameters : {}, - 'headers': oHeaders, - 'timeout': iTimeOut, - 'global': true - }); - - oDefAjax.always(function (oData, sType) { - - var bCached = false; - if (oData && oData['Time']) - { - bCached = Utils.pInt(oData['Time']) > (new window.Date()).getTime() - iStart; - } - - if (sAction && self.oRequests[sAction]) - { - if (self.oRequests[sAction].__aborted) - { - sType = 'abort'; - } - - self.oRequests[sAction] = null; - } - - self.defaultResponse(fResultCallback, sAction, sType, oData, bCached, oParameters); - }); - - if (sAction && 0 < aAbortActions.length && -1 < Utils.inArray(sAction, aAbortActions)) - { - if (this.oRequests[sAction]) - { - this.oRequests[sAction].__aborted = true; - if (this.oRequests[sAction].abort) - { - this.oRequests[sAction].abort(); - } - this.oRequests[sAction] = null; - } - - this.oRequests[sAction] = oDefAjax; - } - - return oDefAjax; - }; - - /** - * @param {?Function} fCallback - * @param {string} sAction - * @param {Object=} oParameters - * @param {?number=} iTimeout - * @param {string=} sGetAdd = '' - * @param {Array=} aAbortActions = [] - */ - AbstractRemoteStorage.prototype.defaultRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) - { - oParameters = oParameters || {}; - oParameters.Action = sAction; - - sGetAdd = Utils.pString(sGetAdd); - - Plugins.runHook('ajax-default-request', [sAction, oParameters, sGetAdd]); - - this.ajaxRequest(fCallback, oParameters, - Utils.isUnd(iTimeout) ? Consts.Defaults.DefaultAjaxTimeout : Utils.pInt(iTimeout), sGetAdd, aAbortActions); - }; - - /** - * @param {?Function} fCallback - */ - AbstractRemoteStorage.prototype.noop = function (fCallback) - { - this.defaultRequest(fCallback, 'Noop'); - }; - - /** - * @param {?Function} fCallback - * @param {string} sMessage - * @param {string} sFileName - * @param {number} iLineNo - * @param {string} sLocation - * @param {string} sHtmlCapa - * @param {number} iTime - */ - AbstractRemoteStorage.prototype.jsError = function (fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime) - { - this.defaultRequest(fCallback, 'JsError', { - 'Message': sMessage, - 'FileName': sFileName, - 'LineNo': iLineNo, - 'Location': sLocation, - 'HtmlCapa': sHtmlCapa, - 'TimeOnPage': iTime - }); - }; - - /** - * @param {?Function} fCallback - * @param {string} sType - * @param {Array=} mData = null - * @param {boolean=} bIsError = false - */ - AbstractRemoteStorage.prototype.jsInfo = function (fCallback, sType, mData, bIsError) - { - this.defaultRequest(fCallback, 'JsInfo', { - 'Type': sType, - 'Data': mData, - 'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0' - }); - }; - - /** - * @param {?Function} fCallback - */ - AbstractRemoteStorage.prototype.getPublicKey = function (fCallback) - { - this.defaultRequest(fCallback, 'GetPublicKey'); - }; - - /** - * @param {?Function} fCallback - * @param {string} sVersion - */ - AbstractRemoteStorage.prototype.jsVersion = function (fCallback, sVersion) - { - this.defaultRequest(fCallback, 'Version', { - 'Version': sVersion - }); - }; - - module.exports = AbstractRemoteStorage; - -}(module, require)); -},{"$":20,"Consts":6,"Enums":7,"Globals":9,"LinkBuilder":11,"Plugins":12,"Storage:Settings":69,"Utils":14,"_":25,"window":26}],63:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - Enums = require('Enums'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - Settings = require('Storage:Settings') - ; - - /** - * @constructor - */ - function CacheStorage() - { - this.oFoldersCache = {}; - this.oFoldersNamesCache = {}; - this.oFolderHashCache = {}; - this.oFolderUidNextCache = {}; - this.oMessageListHashCache = {}; - this.oMessageFlagsCache = {}; - this.oNewMessage = {}; - this.oRequestedMessage = {}; - - this.bCapaGravatar = Settings.capa(Enums.Capa.Gravatar); - } - - /** - * @type {boolean} - */ - CacheStorage.prototype.bCapaGravatar = false; - - /** - * @type {Object} - */ - CacheStorage.prototype.oFoldersCache = {}; - - /** - * @type {Object} - */ - CacheStorage.prototype.oFoldersNamesCache = {}; - - /** - * @type {Object} - */ - CacheStorage.prototype.oFolderHashCache = {}; - - /** - * @type {Object} - */ - CacheStorage.prototype.oFolderUidNextCache = {}; - - /** - * @type {Object} - */ - CacheStorage.prototype.oMessageListHashCache = {}; - - /** - * @type {Object} - */ - CacheStorage.prototype.oMessageFlagsCache = {}; - - /** - * @type {Object} - */ - CacheStorage.prototype.oBodies = {}; - - /** - * @type {Object} - */ - CacheStorage.prototype.oNewMessage = {}; - - /** - * @type {Object} - */ - CacheStorage.prototype.oRequestedMessage = {}; - - CacheStorage.prototype.clear = function () - { - this.oFoldersCache = {}; - this.oFoldersNamesCache = {}; - this.oFolderHashCache = {}; - this.oFolderUidNextCache = {}; - this.oMessageListHashCache = {}; - this.oMessageFlagsCache = {}; - this.oBodies = {}; - }; - - - /** - * @param {string} sEmail - * @param {Function} fCallback - * @return {string} - */ - CacheStorage.prototype.getUserPic = function (sEmail, fCallback) - { - sEmail = Utils.trim(sEmail); - fCallback(this.bCapaGravatar && '' !== sEmail ? LinkBuilder.avatarLink(sEmail) : '', sEmail); - }; - - /** - * @param {string} sFolderFullNameRaw - * @param {string} sUid - * @return {string} - */ - CacheStorage.prototype.getMessageKey = function (sFolderFullNameRaw, sUid) - { - return sFolderFullNameRaw + '#' + sUid; - }; - - /** - * @param {string} sFolder - * @param {string} sUid - */ - CacheStorage.prototype.addRequestedMessage = function (sFolder, sUid) - { - this.oRequestedMessage[this.getMessageKey(sFolder, sUid)] = true; - }; - - /** - * @param {string} sFolder - * @param {string} sUid - * @return {boolean} - */ - CacheStorage.prototype.hasRequestedMessage = function (sFolder, sUid) - { - return true === this.oRequestedMessage[this.getMessageKey(sFolder, sUid)]; - }; - - /** - * @param {string} sFolderFullNameRaw - * @param {string} sUid - */ - CacheStorage.prototype.addNewMessageCache = function (sFolderFullNameRaw, sUid) - { - this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = true; - }; - - /** - * @param {string} sFolderFullNameRaw - * @param {string} sUid - */ - CacheStorage.prototype.hasNewMessageAndRemoveFromCache = function (sFolderFullNameRaw, sUid) - { - if (this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)]) - { - this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = null; return true; - } + }; - return false; - }; - - CacheStorage.prototype.clearNewMessageCache = function () - { - this.oNewMessage = {}; - }; - - /** - * @param {string} sFolderHash - * @return {string} - */ - CacheStorage.prototype.getFolderFullNameRaw = function (sFolderHash) - { - return '' !== sFolderHash && this.oFoldersNamesCache[sFolderHash] ? this.oFoldersNamesCache[sFolderHash] : ''; - }; - - /** - * @param {string} sFolderHash - * @param {string} sFolderFullNameRaw - */ - CacheStorage.prototype.setFolderFullNameRaw = function (sFolderHash, sFolderFullNameRaw) - { - this.oFoldersNamesCache[sFolderHash] = sFolderFullNameRaw; - }; - - /** - * @param {string} sFolderFullNameRaw - * @return {string} - */ - CacheStorage.prototype.getFolderHash = function (sFolderFullNameRaw) - { - return '' !== sFolderFullNameRaw && this.oFolderHashCache[sFolderFullNameRaw] ? this.oFolderHashCache[sFolderFullNameRaw] : ''; - }; - - /** - * @param {string} sFolderFullNameRaw - * @param {string} sFolderHash - */ - CacheStorage.prototype.setFolderHash = function (sFolderFullNameRaw, sFolderHash) - { - this.oFolderHashCache[sFolderFullNameRaw] = sFolderHash; - }; - - /** - * @param {string} sFolderFullNameRaw - * @return {string} - */ - CacheStorage.prototype.getFolderUidNext = function (sFolderFullNameRaw) - { - return '' !== sFolderFullNameRaw && this.oFolderUidNextCache[sFolderFullNameRaw] ? this.oFolderUidNextCache[sFolderFullNameRaw] : ''; - }; - - /** - * @param {string} sFolderFullNameRaw - * @param {string} sUidNext - */ - CacheStorage.prototype.setFolderUidNext = function (sFolderFullNameRaw, sUidNext) - { - this.oFolderUidNextCache[sFolderFullNameRaw] = sUidNext; - }; - - /** - * @param {string} sFolderFullNameRaw - * @return {?FolderModel} - */ - CacheStorage.prototype.getFolderFromCacheList = function (sFolderFullNameRaw) - { - return '' !== sFolderFullNameRaw && this.oFoldersCache[sFolderFullNameRaw] ? this.oFoldersCache[sFolderFullNameRaw] : null; - }; - - /** - * @param {string} sFolderFullNameRaw - * @param {?FolderModel} oFolder - */ - CacheStorage.prototype.setFolderToCacheList = function (sFolderFullNameRaw, oFolder) - { - this.oFoldersCache[sFolderFullNameRaw] = oFolder; - }; - - /** - * @param {string} sFolderFullNameRaw - */ - CacheStorage.prototype.removeFolderFromCacheList = function (sFolderFullNameRaw) - { - this.setFolderToCacheList(sFolderFullNameRaw, null); - }; - - /** - * @param {string} sFolderFullName - * @param {string} sUid - * @return {?Array} - */ - CacheStorage.prototype.getMessageFlagsFromCache = function (sFolderFullName, sUid) - { - return this.oMessageFlagsCache[sFolderFullName] && this.oMessageFlagsCache[sFolderFullName][sUid] ? - this.oMessageFlagsCache[sFolderFullName][sUid] : null; - }; - - /** - * @param {string} sFolderFullName - * @param {string} sUid - * @param {Array} aFlagsCache - */ - CacheStorage.prototype.setMessageFlagsToCache = function (sFolderFullName, sUid, aFlagsCache) - { - if (!this.oMessageFlagsCache[sFolderFullName]) - { - this.oMessageFlagsCache[sFolderFullName] = {}; - } - - this.oMessageFlagsCache[sFolderFullName][sUid] = aFlagsCache; - }; - - /** - * @param {string} sFolderFullName - */ - CacheStorage.prototype.clearMessageFlagsFromCacheByFolder = function (sFolderFullName) - { - this.oMessageFlagsCache[sFolderFullName] = {}; - }; - - /** - * @param {(MessageModel|null)} oMessage - */ - CacheStorage.prototype.initMessageFlagsFromCache = function (oMessage) - { - if (oMessage) + AttachmentModel.prototype.iconClass = function () { var - self = this, - aFlags = this.getMessageFlagsFromCache(oMessage.folderFullNameRaw, oMessage.uid), - mUnseenSubUid = null, - mFlaggedSubUid = null + aParts = this.mimeType.toLocaleString().split('/'), + sClass = 'icon-file' ; - if (aFlags && 0 < aFlags.length) + if (aParts && aParts[1]) { - oMessage.unseen(!!aFlags[0]); - oMessage.flagged(!!aFlags[1]); - oMessage.answered(!!aFlags[2]); - oMessage.forwarded(!!aFlags[3]); - oMessage.isReadReceipt(!!aFlags[4]); + if ('image' === aParts[0]) + { + sClass = 'icon-file-image'; + } + else if ('text' === aParts[0]) + { + sClass = 'icon-file-text'; + } + else if ('audio' === aParts[0]) + { + sClass = 'icon-file-music'; + } + else if ('video' === aParts[0]) + { + sClass = 'icon-file-movie'; + } + else if (-1 < Utils.inArray(aParts[1], + ['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2', 'x-zip', 'x-7z', 'x-rar', 'x-tar', 'x-gzip', 'x-bzip', 'x-bzip2', 'x-zip-compressed', 'x-7z-compressed', 'x-rar-compressed'])) + { + sClass = 'icon-file-zip'; + } + // else if (-1 < Utils.inArray(aParts[1], + // ['pdf', 'x-pdf'])) + // { + // sClass = 'icon-file-pdf'; + // } + // else if (-1 < Utils.inArray(aParts[1], [ + // 'exe', 'x-exe', 'x-winexe', 'bat' + // ])) + // { + // sClass = 'icon-console'; + // } + else if (-1 < Utils.inArray(aParts[1], [ + 'rtf', 'msword', 'vnd.msword', 'vnd.openxmlformats-officedocument.wordprocessingml.document', + 'vnd.openxmlformats-officedocument.wordprocessingml.template', + 'vnd.ms-word.document.macroEnabled.12', + 'vnd.ms-word.template.macroEnabled.12' + ])) + { + sClass = 'icon-file-text'; + } + else if (-1 < Utils.inArray(aParts[1], [ + 'excel', 'ms-excel', 'vnd.ms-excel', + 'vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'vnd.openxmlformats-officedocument.spreadsheetml.template', + 'vnd.ms-excel.sheet.macroEnabled.12', + 'vnd.ms-excel.template.macroEnabled.12', + 'vnd.ms-excel.addin.macroEnabled.12', + 'vnd.ms-excel.sheet.binary.macroEnabled.12' + ])) + { + sClass = 'icon-file-excel'; + } + else if (-1 < Utils.inArray(aParts[1], [ + 'powerpoint', 'ms-powerpoint', 'vnd.ms-powerpoint', + 'vnd.openxmlformats-officedocument.presentationml.presentation', + 'vnd.openxmlformats-officedocument.presentationml.template', + 'vnd.openxmlformats-officedocument.presentationml.slideshow', + 'vnd.ms-powerpoint.addin.macroEnabled.12', + 'vnd.ms-powerpoint.presentation.macroEnabled.12', + 'vnd.ms-powerpoint.template.macroEnabled.12', + 'vnd.ms-powerpoint.slideshow.macroEnabled.12' + ])) + { + sClass = 'icon-file-chart-graph'; + } } - if (0 < oMessage.threads().length) - { - mUnseenSubUid = _.find(oMessage.threads(), function (iSubUid) { - var aFlags = self.getMessageFlagsFromCache(oMessage.folderFullNameRaw, iSubUid); - return aFlags && 0 < aFlags.length && !!aFlags[0]; - }); + return sClass; + }; - mFlaggedSubUid = _.find(oMessage.threads(), function (iSubUid) { - var aFlags = self.getMessageFlagsFromCache(oMessage.folderFullNameRaw, iSubUid); - return aFlags && 0 < aFlags.length && !!aFlags[1]; - }); + module.exports = AttachmentModel; - oMessage.hasUnseenSubMessage(mUnseenSubUid && 0 < Utils.pInt(mUnseenSubUid)); - oMessage.hasFlaggedSubMessage(mFlaggedSubUid && 0 < Utils.pInt(mFlaggedSubUid)); - } - } - }; + }()); - /** - * @param {(MessageModel|null)} oMessage - */ - CacheStorage.prototype.storeMessageFlagsToCache = function (oMessage) - { - if (oMessage) - { - this.setMessageFlagsToCache( - oMessage.folderFullNameRaw, - oMessage.uid, - [oMessage.unseen(), oMessage.flagged(), oMessage.answered(), oMessage.forwarded(), oMessage.isReadReceipt()] - ); - } - }; - /** - * @param {string} sFolder - * @param {string} sUid - * @param {Array} aFlags - */ - CacheStorage.prototype.storeMessageFlagsToCacheByFolderAndUid = function (sFolder, sUid, aFlags) - { - if (Utils.isArray(aFlags) && 0 < aFlags.length) - { - this.setMessageFlagsToCache(sFolder, sUid, aFlags); - } - }; +/***/ }, - module.exports = new CacheStorage(); +/***/ 58: +/*!***********************************!*\ + !*** ./dev/Models/FolderModel.js ***! + \***********************************/ +/***/ function(module, exports, __webpack_require__) { -}(module, require)); -},{"Enums":7,"LinkBuilder":11,"Storage:Settings":69,"Utils":14,"_":25}],64:[function(require,module,exports){ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ + + (function () { -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - ko = require('ko'), - moment = require('moment'), - - Consts = require('Consts'), - Enums = require('Enums'), - Globals = require('Globals'), - Utils = require('Utils'), - LinkBuilder = require('LinkBuilder'), - - Settings = require('Storage:Settings'), - Cache = require('Storage:RainLoop:Cache'), - - kn = require('App:Knoin'), - - MessageModel = require('Model:Message'), - - LocalStorage = require('Storage:LocalStorage'), - AbstractData = require('Storage:Abstract:Data') - ; - - /** - * @constructor - * @extends AbstractData - */ - function DataStorage() - { - AbstractData.call(this); + 'use strict'; var - fRemoveSystemFolderType = function (observable) { - return function () { - var oFolder = Cache.getFolderFromCacheList(observable()); - if (oFolder) - { - oFolder.type(Enums.FolderType.User); - } - }; - }, - fSetSystemFolderType = function (iType) { - return function (sValue) { - var oFolder = Cache.getFolderFromCacheList(sValue); - if (oFolder) - { - oFolder.type(iType); - } - }; - } + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + Events = __webpack_require__(/*! Common/Events */ 22) ; - this.devEmail = ''; - this.devPassword = ''; - - this.accountEmail = ko.observable(''); - this.accountIncLogin = ko.observable(''); - this.accountOutLogin = ko.observable(''); - this.projectHash = ko.observable(''); - this.threading = ko.observable(false); - - this.lastFoldersHash = ''; - this.remoteSuggestions = false; - - // system folders - this.sentFolder = ko.observable(''); - this.draftFolder = ko.observable(''); - this.spamFolder = ko.observable(''); - this.trashFolder = ko.observable(''); - this.archiveFolder = ko.observable(''); - - this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange'); - this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange'); - this.spamFolder.subscribe(fRemoveSystemFolderType(this.spamFolder), this, 'beforeChange'); - this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange'); - this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange'); - - this.sentFolder.subscribe(fSetSystemFolderType(Enums.FolderType.SentItems), this); - this.draftFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Draft), this); - this.spamFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Spam), this); - this.trashFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Trash), this); - this.archiveFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Archive), this); - - this.draftFolderNotEnabled = ko.computed(function () { - return '' === this.draftFolder() || Consts.Values.UnuseOptionValue === this.draftFolder(); - }, this); - - // personal - this.displayName = ko.observable(''); - this.signature = ko.observable(''); - this.signatureToAll = ko.observable(false); - this.replyTo = ko.observable(''); - - // security - this.enableTwoFactor = ko.observable(false); - - // accounts - this.accounts = ko.observableArray([]); - this.accountsLoading = ko.observable(false).extend({'throttle': 100}); - - // identities - this.defaultIdentityID = ko.observable(''); - this.identities = ko.observableArray([]); - 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(''); - this.contactsSyncUser = ko.observable(''); - this.contactsSyncPass = ko.observable(''); - - this.allowContactsSync = ko.observable(!!Settings.settingsGet('ContactsSyncIsAllowed')); - this.enableContactsSync = ko.observable(!!Settings.settingsGet('EnableContactsSync')); - this.contactsSyncUrl = ko.observable(Settings.settingsGet('ContactsSyncUrl')); - this.contactsSyncUser = ko.observable(Settings.settingsGet('ContactsSyncUser')); - this.contactsSyncPass = ko.observable(Settings.settingsGet('ContactsSyncPassword')); - - // folders - this.namespace = ''; - this.folderList = ko.observableArray([]); - this.folderList.focused = ko.observable(false); - - this.foldersListError = ko.observable(''); - - this.foldersLoading = ko.observable(false); - this.foldersCreating = ko.observable(false); - this.foldersDeleting = ko.observable(false); - this.foldersRenaming = ko.observable(false); - - this.foldersChanging = ko.computed(function () { - var - bLoading = this.foldersLoading(), - bCreating = this.foldersCreating(), - bDeleting = this.foldersDeleting(), - bRenaming = this.foldersRenaming() - ; - return bLoading || bCreating || bDeleting || bRenaming; - }, this); - - this.foldersInboxUnreadCount = ko.observable(0); - - this.currentFolder = ko.observable(null).extend({'toggleSubscribe': [null, - function (oPrev) { - if (oPrev) - { - oPrev.selected(false); - } - }, function (oNext) { - if (oNext) - { - oNext.selected(true); - } - } - ]}); - - this.currentFolderFullNameRaw = ko.computed(function () { - return this.currentFolder() ? this.currentFolder().fullNameRaw : ''; - }, this); - - this.currentFolderFullName = ko.computed(function () { - return this.currentFolder() ? this.currentFolder().fullName : ''; - }, this); - - this.currentFolderFullNameHash = ko.computed(function () { - return this.currentFolder() ? this.currentFolder().fullNameHash : ''; - }, this); - - this.currentFolderName = ko.computed(function () { - return this.currentFolder() ? this.currentFolder().name() : ''; - }, this); - - this.folderListSystemNames = ko.computed(function () { - - var - aList = ['INBOX'], - aFolders = this.folderList(), - sSentFolder = this.sentFolder(), - sDraftFolder = this.draftFolder(), - sSpamFolder = this.spamFolder(), - sTrashFolder = this.trashFolder(), - sArchiveFolder = this.archiveFolder() - ; - - if (Utils.isArray(aFolders) && 0 < aFolders.length) - { - if ('' !== sSentFolder && Consts.Values.UnuseOptionValue !== sSentFolder) - { - aList.push(sSentFolder); - } - if ('' !== sDraftFolder && Consts.Values.UnuseOptionValue !== sDraftFolder) - { - aList.push(sDraftFolder); - } - if ('' !== sSpamFolder && Consts.Values.UnuseOptionValue !== sSpamFolder) - { - aList.push(sSpamFolder); - } - if ('' !== sTrashFolder && Consts.Values.UnuseOptionValue !== sTrashFolder) - { - aList.push(sTrashFolder); - } - if ('' !== sArchiveFolder && Consts.Values.UnuseOptionValue !== sArchiveFolder) - { - aList.push(sArchiveFolder); - } - } - - return aList; - - }, this); - - this.folderListSystem = ko.computed(function () { - return _.compact(_.map(this.folderListSystemNames(), function (sName) { - return Cache.getFolderFromCacheList(sName); - })); - }, this); - - this.folderMenuForMove = ko.computed(function () { - return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(), [ - this.currentFolderFullNameRaw() - ], null, null, null, null, function (oItem) { - return oItem ? oItem.localName() : ''; - }); - }, this); - - // message list - this.staticMessageList = []; - - this.messageList = ko.observableArray([]).extend({'rateLimit': 0}); - - this.messageListCount = ko.observable(0); - this.messageListSearch = ko.observable(''); - this.messageListPage = ko.observable(1); - - this.messageListThreadFolder = ko.observable(''); - this.messageListThreadUids = ko.observableArray([]); - - this.messageListThreadFolder.subscribe(function () { - this.messageListThreadUids([]); - }, this); - - 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 = window.Math.ceil(this.messageListCount() / this.messagesPerPage()); - return 0 >= iPage ? 1 : iPage; - }, this); - - this.mainMessageListSearch = ko.computed({ - 'read': this.messageListSearch, - 'write': function (sValue) { - kn.setHash(LinkBuilder.mailBox( - this.currentFolderFullNameHash(), 1, Utils.trim(sValue.toString()) - )); - }, - 'owner': this - }); - - this.messageListError = ko.observable(''); - - this.messageListLoading = ko.observable(false); - this.messageListIsNotCompleted = ko.observable(false); - this.messageListCompleteLoadingThrottle = ko.observable(false).extend({'throttle': 200}); - - this.messageListCompleteLoading = ko.computed(function () { - var - bOne = this.messageListLoading(), - bTwo = this.messageListIsNotCompleted() - ; - return bOne || bTwo; - }, this); - - this.messageListCompleteLoading.subscribe(function (bValue) { - this.messageListCompleteLoadingThrottle(bValue); - }, this); - - this.messageList.subscribe(_.debounce(function (aList) { - _.each(aList, function (oItem) { - if (oItem.newForAnimation()) - { - oItem.newForAnimation(false); - } - }); - }, 500)); - - // message preview - this.staticMessageList = new MessageModel(); - this.message = ko.observable(null); - this.messageLoading = ko.observable(false); - this.messageLoadingThrottle = ko.observable(false).extend({'throttle': 50}); - - this.message.focused = ko.observable(false); - - this.message.subscribe(function (oMessage) { - if (!oMessage) - { - this.message.focused(false); - this.messageFullScreenMode(false); - this.hideMessageBodies(); - - if (Enums.Layout.NoPreview === this.layout() && - -1 < window.location.hash.indexOf('message-preview')) - { - if (Globals.__APP) - { - Globals.__APP.historyBack(); - } - } - } - else if (Enums.Layout.NoPreview === this.layout()) - { - this.message.focused(true); - } - }, this); - - this.message.focused.subscribe(function (bValue) { - if (bValue) - { - this.folderList.focused(false); - Globals.keyScope(Enums.KeyState.MessageView); - } - else if (Enums.KeyState.MessageView === Globals.keyScope()) - { - if (Enums.Layout.NoPreview === this.layout() && this.message()) - { - Globals.keyScope(Enums.KeyState.MessageView); - } - else - { - Globals.keyScope(Enums.KeyState.MessageList); - } - } - }, this); - - this.folderList.focused.subscribe(function (bValue) { - if (bValue) - { - Globals.keyScope(Enums.KeyState.FolderList); - } - else if (Enums.KeyState.FolderList === Globals.keyScope()) - { - Globals.keyScope(Enums.KeyState.MessageList); - } - }); - - this.messageLoading.subscribe(function (bValue) { - this.messageLoadingThrottle(bValue); - }, this); - - this.messageFullScreenMode = ko.observable(false); - - this.messageError = ko.observable(''); - - this.messagesBodiesDom = ko.observable(null); - - this.messagesBodiesDom.subscribe(function (oDom) { - if (oDom && !(oDom instanceof $)) - { - this.messagesBodiesDom($(oDom)); - } - }, this); - - this.messageActiveDom = ko.observable(null); - - this.isMessageSelected = ko.computed(function () { - return null !== this.message(); - }, 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}); - - this.messageListCheckedOrSelected = ko.computed(function () { - - var - aChecked = this.messageListChecked(), - oSelectedMessage = this.currentMessage() - ; - - return _.union(aChecked, oSelectedMessage ? [oSelectedMessage] : []); - - }, this); - - this.messageListCheckedOrSelectedUidsWithSubMails = ko.computed(function () { - var aList = []; - _.each(this.messageListCheckedOrSelected(), function (oMessage) { - if (oMessage) - { - aList.push(oMessage.uid); - if (0 < oMessage.threadsLen() && 0 === oMessage.parentUid() && oMessage.lastInCollapsedThread()) - { - aList = _.union(aList, oMessage.threads()); - } - } - }); - return aList; - }, this); - - // quota - this.userQuota = ko.observable(0); - this.userUsageSize = ko.observable(0); - this.userUsageProc = ko.computed(function () { - - var - iQuota = this.userQuota(), - iUsed = this.userUsageSize() - ; - - return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0; - - }, this); - - // other - this.capaOpenPGP = ko.observable(false); - this.openpgpkeys = ko.observableArray([]); - this.openpgpKeyring = null; - - this.openpgpkeysPublic = this.openpgpkeys.filter(function (oItem) { - return !!(oItem && !oItem.isPrivate); - }); - - this.openpgpkeysPrivate = this.openpgpkeys.filter(function (oItem) { - return !!(oItem && oItem.isPrivate); - }); - - // google - this.googleActions = ko.observable(false); - this.googleLoggined = ko.observable(false); - this.googleUserName = ko.observable(''); - - // facebook - this.facebookActions = ko.observable(false); - this.facebookLoggined = ko.observable(false); - this.facebookUserName = ko.observable(''); - - // twitter - this.twitterActions = ko.observable(false); - this.twitterLoggined = ko.observable(false); - this.twitterUserName = ko.observable(''); - - this.customThemeType = ko.observable(Enums.CustomThemeType.Light); - - this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, 1000 * 30); - } - - _.extend(DataStorage.prototype, AbstractData.prototype); - - DataStorage.prototype.purgeMessageBodyCache = function() - { - var - iCount = 0, - oMessagesBodiesDom = null, - iEnd = Globals.iMessageBodyCacheCount - Consts.Values.MessageBodyCacheLimit - ; - - if (0 < iEnd) + /** + * @constructor + */ + function FolderModel() { - oMessagesBodiesDom = this.messagesBodiesDom(); - if (oMessagesBodiesDom) - { - oMessagesBodiesDom.find('.rl-cache-class').each(function () { - var oItem = $(this); - if (iEnd > oItem.data('rl-cache-count')) - { - oItem.addClass('rl-cache-purge'); - iCount++; - } + this.name = ko.observable(''); + this.fullName = ''; + this.fullNameRaw = ''; + this.fullNameHash = ''; + this.delimiter = ''; + this.namespace = ''; + this.deep = 0; + this.interval = 0; + + this.selectable = false; + this.existen = true; + + this.type = ko.observable(Enums.FolderType.User); + + this.focused = ko.observable(false); + this.selected = ko.observable(false); + this.edited = ko.observable(false); + this.collapsed = ko.observable(true); + this.subScribed = ko.observable(true); + this.subFolders = ko.observableArray([]); + this.deleteAccess = ko.observable(false); + this.actionBlink = ko.observable(false).extend({'falseTimeout': 1000}); + + this.nameForEdit = ko.observable(''); + + this.privateMessageCountAll = ko.observable(0); + this.privateMessageCountUnread = ko.observable(0); + + this.collapsedPrivate = ko.observable(true); + } + + /** + * @static + * @param {AjaxJsonFolder} oJsonFolder + * @return {?FolderModel} + */ + FolderModel.newInstanceFromJson = function (oJsonFolder) + { + var oFolderModel = new FolderModel(); + return oFolderModel.initByJson(oJsonFolder) ? oFolderModel.initComputed() : null; + }; + + /** + * @return {FolderModel} + */ + FolderModel.prototype.initComputed = function () + { + this.hasSubScribedSubfolders = ko.computed(function () { + return !!_.find(this.subFolders(), function (oFolder) { + return oFolder.subScribed() && !oFolder.isSystemFolder(); }); + }, this); + + this.canBeEdited = ko.computed(function () { + return Enums.FolderType.User === this.type() && this.existen && this.selectable; + }, this); + + this.visible = ko.computed(function () { + var + bSubScribed = this.subScribed(), + bSubFolders = this.hasSubScribedSubfolders() + ; + + return (bSubScribed || (bSubFolders && (!this.existen || !this.selectable))); + }, this); + + this.isSystemFolder = ko.computed(function () { + return Enums.FolderType.User !== this.type(); + }, this); + + this.hidden = ko.computed(function () { + var + bSystem = this.isSystemFolder(), + bSubFolders = this.hasSubScribedSubfolders() + ; + + return (bSystem && !bSubFolders) || (!this.selectable && !bSubFolders); + + }, this); + + this.selectableForFolderList = ko.computed(function () { + return !this.isSystemFolder() && this.selectable; + }, this); + + this.messageCountAll = ko.computed({ + 'read': this.privateMessageCountAll, + 'write': function (iValue) { + if (Utils.isPosNumeric(iValue, true)) + { + this.privateMessageCountAll(iValue); + } + else + { + this.privateMessageCountAll.valueHasMutated(); + } + }, + 'owner': this + }); + + this.messageCountUnread = ko.computed({ + 'read': this.privateMessageCountUnread, + 'write': function (iValue) { + if (Utils.isPosNumeric(iValue, true)) + { + this.privateMessageCountUnread(iValue); + } + else + { + this.privateMessageCountUnread.valueHasMutated(); + } + }, + 'owner': this + }); + + this.printableUnreadCount = ko.computed(function () { + var + iCount = this.messageCountAll(), + iUnread = this.messageCountUnread(), + iType = this.type() + ; if (0 < iCount) { - _.delay(function () { - oMessagesBodiesDom.find('.rl-cache-purge').remove(); - }, 300); - } - } - } - }; - - DataStorage.prototype.populateDataOnStart = function() - { - AbstractData.prototype.populateDataOnStart.call(this); - - this.accountEmail(Settings.settingsGet('Email')); - this.accountIncLogin(Settings.settingsGet('IncLogin')); - this.accountOutLogin(Settings.settingsGet('OutLogin')); - this.projectHash(Settings.settingsGet('ProjectHash')); - - this.defaultIdentityID(Settings.settingsGet('DefaultIdentityID')); - - this.displayName(Settings.settingsGet('DisplayName')); - this.replyTo(Settings.settingsGet('ReplyTo')); - this.signature(Settings.settingsGet('Signature')); - this.signatureToAll(!!Settings.settingsGet('SignatureToAll')); - this.enableTwoFactor(!!Settings.settingsGet('EnableTwoFactor')); - - this.lastFoldersHash = LocalStorage.get(Enums.ClientSideKeyName.FoldersLashHash) || ''; - - this.remoteSuggestions = !!Settings.settingsGet('RemoteSuggestions'); - - this.devEmail = Settings.settingsGet('DevEmail'); - this.devPassword = Settings.settingsGet('DevPassword'); - }; - - DataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUidNext, aNewMessages) - { - if ('INBOX' === sFolder && Utils.isNormal(sUidNext) && sUidNext !== '') - { - if (Utils.isArray(aNewMessages) && 0 < aNewMessages.length) - { - var - self = this, - iIndex = 0, - iLen = aNewMessages.length, - fNotificationHelper = function (sImageSrc, sTitle, sText) + if (Enums.FolderType.Draft === iType) { - var - NotificationClass = Utils.notificationClass(), - oNotification = null - ; - - if (NotificationClass && self.useDesktopNotifications()) - { - oNotification = new NotificationClass(sTitle, { - 'body': sText, - 'icon': sImageSrc - }); - - if (oNotification) - { - if (oNotification.show) - { - oNotification.show(); - } - - window.setTimeout((function (oLocalNotifications) { - return function () { - if (oLocalNotifications.cancel) - { - oLocalNotifications.cancel(); - } - else if (oLocalNotifications.close) - { - oLocalNotifications.close(); - } - }; - }(oNotification)), 7000); - } - } + return '' + iCount; } + else if (0 < iUnread && Enums.FolderType.Trash !== iType && Enums.FolderType.Archive !== iType && Enums.FolderType.SentItems !== iType) + { + return '' + iUnread; + } + } + + return ''; + + }, this); + + this.canBeDeleted = ko.computed(function () { + var + bSystem = this.isSystemFolder() + ; + return !bSystem && 0 === this.subFolders().length && 'INBOX' !== this.fullNameRaw; + }, this); + + this.canBeSubScribed = ko.computed(function () { + return !this.isSystemFolder() && this.selectable && 'INBOX' !== this.fullNameRaw; + }, this); + + // this.visible.subscribe(function () { + // Utils.timeOutAction('folder-list-folder-visibility-change', function () { + // Globals.$win.trigger('folder-list-folder-visibility-change'); + // }, 100); + // }); + + this.localName = ko.computed(function () { + + Globals.langChangeTrigger(); + + var + iType = this.type(), + sName = this.name() ; - _.each(aNewMessages, function (oItem) { - Cache.addNewMessageCache(sFolder, oItem.Uid); - }); - - if (3 < iLen) + if (this.isSystemFolder()) { - fNotificationHelper( - LinkBuilder.notificationMailIcon(), - this.accountEmail(), - Utils.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', { - 'COUNT': iLen - }) - ); - } - else - { - for (; iIndex < iLen; iIndex++) + switch (iType) { - fNotificationHelper( - LinkBuilder.notificationMailIcon(), - MessageModel.emailsToLine(MessageModel.initEmailsFromJson(aNewMessages[iIndex].From), false), - aNewMessages[iIndex].Subject - ); + case Enums.FolderType.Inbox: + sName = Utils.i18n('FOLDER_LIST/INBOX_NAME'); + break; + case Enums.FolderType.SentItems: + sName = Utils.i18n('FOLDER_LIST/SENT_NAME'); + break; + case Enums.FolderType.Draft: + sName = Utils.i18n('FOLDER_LIST/DRAFTS_NAME'); + break; + case Enums.FolderType.Spam: + sName = Utils.i18n('FOLDER_LIST/SPAM_NAME'); + break; + case Enums.FolderType.Trash: + sName = Utils.i18n('FOLDER_LIST/TRASH_NAME'); + break; + case Enums.FolderType.Archive: + sName = Utils.i18n('FOLDER_LIST/ARCHIVE_NAME'); + break; } } - } - Cache.setFolderUidNext(sFolder, sUidNext); - } - }; + return sName; - DataStorage.prototype.hideMessageBodies = function () - { - var oMessagesBodiesDom = this.messagesBodiesDom(); - if (oMessagesBodiesDom) - { - oMessagesBodiesDom.find('.b-text-part').hide(); - } - }; + }, this); - /** - * @param {boolean=} bBoot = false - * @returns {Array} - */ - DataStorage.prototype.getNextFolderNames = function (bBoot) - { - bBoot = Utils.isUnd(bBoot) ? false : !!bBoot; + this.manageFolderSystemName = ko.computed(function () { - var - aResult = [], - iLimit = 10, - iUtc = moment().unix(), - iTimeout = iUtc - 60 * 5, - aTimeouts = [], - fSearchFunction = function (aList) { - _.each(aList, function (oFolder) { - if (oFolder && 'INBOX' !== oFolder.fullNameRaw && - oFolder.selectable && oFolder.existen && - iTimeout > oFolder.interval && - (!bBoot || oFolder.subScribed())) + Globals.langChangeTrigger(); + + var + sSuffix = '', + iType = this.type(), + sName = this.name() + ; + + if (this.isSystemFolder()) + { + switch (iType) { - aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]); + case Enums.FolderType.Inbox: + sSuffix = '(' + Utils.i18n('FOLDER_LIST/INBOX_NAME') + ')'; + break; + case Enums.FolderType.SentItems: + sSuffix = '(' + Utils.i18n('FOLDER_LIST/SENT_NAME') + ')'; + break; + case Enums.FolderType.Draft: + sSuffix = '(' + Utils.i18n('FOLDER_LIST/DRAFTS_NAME') + ')'; + break; + case Enums.FolderType.Spam: + sSuffix = '(' + Utils.i18n('FOLDER_LIST/SPAM_NAME') + ')'; + break; + case Enums.FolderType.Trash: + sSuffix = '(' + Utils.i18n('FOLDER_LIST/TRASH_NAME') + ')'; + break; + case Enums.FolderType.Archive: + sSuffix = '(' + Utils.i18n('FOLDER_LIST/ARCHIVE_NAME') + ')'; + break; } + } - if (oFolder && 0 < oFolder.subFolders().length) - { - fSearchFunction(oFolder.subFolders()); - } - }); - } - ; + if ('' !== sSuffix && '(' + sName + ')' === sSuffix || '(inbox)' === sSuffix.toLowerCase()) + { + sSuffix = ''; + } - fSearchFunction(this.folderList()); + return sSuffix; - aTimeouts.sort(function(a, b) { - if (a[0] < b[0]) - { - return -1; - } - else if (a[0] > b[0]) - { - return 1; - } + }, this); - return 0; - }); - - _.find(aTimeouts, function (aItem) { - var oFolder = Cache.getFolderFromCacheList(aItem[1]); - if (oFolder) - { - oFolder.interval = iUtc; - aResult.push(aItem[1]); - } - - return iLimit <= aResult.length; - }); - - return _.uniq(aResult); - }; - - /** - * @param {string} sFromFolderFullNameRaw - * @param {Array} aUidForRemove - * @param {string=} sToFolderFullNameRaw = '' - * @param {bCopy=} bCopy = false - */ - DataStorage.prototype.removeMessagesFromList = function ( - sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy) - { - sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : ''; - bCopy = Utils.isUnd(bCopy) ? false : !!bCopy; - - aUidForRemove = _.map(aUidForRemove, function (mValue) { - return Utils.pInt(mValue); - }); - - var - self = this, - iUnseenCount = 0, - aMessageList = this.messageList(), - oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw), - oToFolder = '' === sToFolderFullNameRaw ? null : Cache.getFolderFromCacheList(sToFolderFullNameRaw || ''), - sCurrentFolderFullNameRaw = this.currentFolderFullNameRaw(), - oCurrentMessage = this.message(), - aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(aMessageList, function (oMessage) { - return oMessage && -1 < Utils.inArray(Utils.pInt(oMessage.uid), aUidForRemove); - }) : [] - ; - - _.each(aMessages, function (oMessage) { - if (oMessage && oMessage.unseen()) - { - iUnseenCount++; - } - }); - - if (oFromFolder && !bCopy) - { - oFromFolder.messageCountAll(0 <= oFromFolder.messageCountAll() - aUidForRemove.length ? - oFromFolder.messageCountAll() - aUidForRemove.length : 0); - - if (0 < iUnseenCount) - { - oFromFolder.messageCountUnread(0 <= oFromFolder.messageCountUnread() - iUnseenCount ? - oFromFolder.messageCountUnread() - iUnseenCount : 0); - } - } - - if (oToFolder) - { - oToFolder.messageCountAll(oToFolder.messageCountAll() + aUidForRemove.length); - if (0 < iUnseenCount) - { - oToFolder.messageCountUnread(oToFolder.messageCountUnread() + iUnseenCount); - } - - oToFolder.actionBlink(true); - } - - if (0 < aMessages.length) - { - if (bCopy) - { - _.each(aMessages, function (oMessage) { - oMessage.checked(false); - }); - } - else - { - this.messageListIsNotCompleted(true); - - _.each(aMessages, function (oMessage) { - if (oCurrentMessage && oCurrentMessage.hash === oMessage.hash) - { - oCurrentMessage = null; - self.message(null); - } - - oMessage.deleted(true); - }); - - _.delay(function () { - _.each(aMessages, function (oMessage) { - self.messageList.remove(oMessage); - }); - }, 400); - } - } - - if ('' !== sFromFolderFullNameRaw) - { - Cache.setFolderHash(sFromFolderFullNameRaw, ''); - } - - if ('' !== sToFolderFullNameRaw) - { - Cache.setFolderHash(sToFolderFullNameRaw, ''); - } - }; - - /** - * @private - * @param {Object} oMessageTextBody - */ - DataStorage.prototype.initBlockquoteSwitcher = function (oMessageTextBody) - { - if (oMessageTextBody) - { - var $oList = $('blockquote:not(.rl-bq-switcher)', oMessageTextBody).filter(function () { - return 0 === $(this).parent().closest('blockquote', oMessageTextBody).length; + this.collapsed = ko.computed({ + 'read': function () { + return !this.hidden() && this.collapsedPrivate(); + }, + 'write': function (mValue) { + this.collapsedPrivate(mValue); + }, + 'owner': this }); - if ($oList && 0 < $oList.length) - { - $oList.each(function () { - var $self = $(this), iH = $self.height(); - if (0 === iH || 100 < iH) - { - $self.addClass('rl-bq-switcher hidden-bq'); - $('') - .insertBefore($self) - .click(function () { - $self.toggleClass('hidden-bq'); - Utils.windowResize(); - }) - .after('
') - .before('
') - ; - } + this.hasUnreadMessages = ko.computed(function () { + return 0 < this.messageCountUnread(); + }, this); + + this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function () { + return !!_.find(this.subFolders(), function (oFolder) { + return oFolder.hasUnreadMessages() || oFolder.hasSubScribedUnreadMessagesSubfolders(); }); - } - } - }; + }, this); + + // subscribe + this.name.subscribe(function (sValue) { + this.nameForEdit(sValue); + }, this); + + this.edited.subscribe(function (bValue) { + if (bValue) + { + this.nameForEdit(this.name()); + } + }, this); + + this.messageCountUnread.subscribe(function (iUnread) { + if (Enums.FolderType.Inbox === this.type()) + { + Events.pub('mailbox.inbox-unread-count', [iUnread]); + } + }, this); + + return this; + }; + + FolderModel.prototype.fullName = ''; + FolderModel.prototype.fullNameRaw = ''; + FolderModel.prototype.fullNameHash = ''; + FolderModel.prototype.delimiter = ''; + FolderModel.prototype.namespace = ''; + FolderModel.prototype.deep = 0; + FolderModel.prototype.interval = 0; + + /** + * @return {string} + */ + FolderModel.prototype.collapsedCss = function () + { + return this.hasSubScribedSubfolders() ? + (this.collapsed() ? 'icon-right-mini e-collapsed-sign' : 'icon-down-mini e-collapsed-sign') : 'icon-none e-collapsed-sign'; + }; + + /** + * @param {AjaxJsonFolder} oJsonFolder + * @return {boolean} + */ + FolderModel.prototype.initByJson = function (oJsonFolder) + { + var bResult = false; + if (oJsonFolder && 'Object/Folder' === oJsonFolder['@Object']) + { + this.name(oJsonFolder.Name); + this.delimiter = oJsonFolder.Delimiter; + this.fullName = oJsonFolder.FullName; + this.fullNameRaw = oJsonFolder.FullNameRaw; + this.fullNameHash = oJsonFolder.FullNameHash; + this.deep = oJsonFolder.FullNameRaw.split(this.delimiter).length - 1; + this.selectable = !!oJsonFolder.IsSelectable; + this.existen = !!oJsonFolder.IsExists; + + this.subScribed(!!oJsonFolder.IsSubscribed); + this.type('INBOX' === this.fullNameRaw ? Enums.FolderType.Inbox : Enums.FolderType.User); + + bResult = true; + } + + return bResult; + }; + + /** + * @return {string} + */ + FolderModel.prototype.printableFullName = function () + { + return this.fullName.split(this.delimiter).join(' / '); + }; + + module.exports = FolderModel; + + }()); + +/***/ }, + +/***/ 59: +/*!*************************************!*\ + !*** ./dev/Models/IdentityModel.js ***! + \*************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; - DataStorage.prototype.setMessage = function (oData, bCached) - { var - bIsHtml = false, - bHasExternals = false, - bHasInternals = false, - oBody = null, - oTextBody = null, - sId = '', - sResultHtml = '', - bPgpSigned = false, - bPgpEncrypted = false, - oMessagesBodiesDom = this.messagesBodiesDom(), - oMessage = this.message() + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1) ; - if (oData && oMessage && oData.Result && 'Object/Message' === oData.Result['@Object'] && - oMessage.folderFullNameRaw === oData.Result.Folder && oMessage.uid === oData.Result.Uid) + /** + * @param {string} sId + * @param {string} sEmail + * @param {boolean=} bCanBeDelete = true + * @constructor + */ + function IdentityModel(sId, sEmail, bCanBeDelete) { - this.messageError(''); + this.id = sId; + this.email = ko.observable(sEmail); + this.name = ko.observable(''); + this.replyTo = ko.observable(''); + this.bcc = ko.observable(''); - oMessage.initUpdateByMessageJson(oData.Result); - Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid); - - if (!bCached) - { - oMessage.initFlagsByJson(oData.Result); - } - - oMessagesBodiesDom = oMessagesBodiesDom && oMessagesBodiesDom[0] ? oMessagesBodiesDom : null; - if (oMessagesBodiesDom) - { - sId = 'rl-mgs-' + oMessage.hash.replace(/[^a-zA-Z0-9]/g, ''); - oTextBody = oMessagesBodiesDom.find('#' + sId); - if (!oTextBody || !oTextBody[0]) - { - bHasExternals = !!oData.Result.HasExternals; - bHasInternals = !!oData.Result.HasInternals; - - oBody = $('
').hide().addClass('rl-cache-class'); - oBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount); - - if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html) - { - bIsHtml = true; - sResultHtml = oData.Result.Html.toString(); - } - else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain) - { - bIsHtml = false; - sResultHtml = Utils.plainToHtml(oData.Result.Plain.toString(), false); - - if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && this.capaOpenPGP()) - { - oMessage.plainRaw = Utils.pString(oData.Result.Plain); - - bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oMessage.plainRaw); - if (!bPgpEncrypted) - { - bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oMessage.plainRaw) && - /-----BEGIN PGP SIGNATURE-----/.test(oMessage.plainRaw); - } - - Globals.$div.empty(); - if (bPgpSigned && oMessage.isPgpSigned()) - { - sResultHtml = - Globals.$div.append( - $('
').text(oMessage.plainRaw)
-									).html()
-								;
-							}
-							else if (bPgpEncrypted && oMessage.isPgpEncrypted())
-							{
-								sResultHtml =
-									Globals.$div.append(
-										$('
').text(oMessage.plainRaw)
-									).html()
-								;
-							}
-
-							Globals.$div.empty();
-
-							oMessage.isPgpSigned(bPgpSigned);
-							oMessage.isPgpEncrypted(bPgpEncrypted);
-						}
-					}
-					else
-					{
-						bIsHtml = false;
-					}
-
-					oBody
-						.html(Utils.linkify(sResultHtml))
-						.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'))
-					;
-
-					oMessage.isHtml(!!bIsHtml);
-					oMessage.hasImages(!!bHasExternals);
-					oMessage.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);
-					oMessage.pgpSignedVerifyUser('');
-
-					oMessage.body = oBody;
-					if (oMessage.body)
-					{
-						oMessagesBodiesDom.append(oMessage.body);
-					}
-
-					oMessage.storeDataToDom();
-
-					if (bHasInternals)
-					{
-						oMessage.showInternalImages(true);
-					}
-
-					if (oMessage.hasImages() && this.showImages())
-					{
-						oMessage.showExternalImages(true);
-					}
-
-					this.purgeMessageBodyCacheThrottle();
-				}
-				else
-				{
-					oMessage.body = oTextBody;
-					if (oMessage.body)
-					{
-						oMessage.body.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
-						oMessage.fetchDataToDom();
-					}
-				}
-
-				this.messageActiveDom(oMessage.body);
-
-				this.hideMessageBodies();
-				oMessage.body.show();
-
-				if (oBody)
-				{
-					this.initBlockquoteSwitcher(oBody);
-				}
-			}
-
-			Cache.initMessageFlagsFromCache(oMessage);
-			if (oMessage.unseen())
-			{
-				if (Globals.__APP)
-				{
-					Globals.__APP.setMessageSeen(oMessage);
-				}
-			}
-
-			Utils.windowResize();
+			this.deleteAccess = ko.observable(false);
+			this.canBeDalete = ko.observable(bCanBeDelete);
 		}
-	};
 
-	/**
-	 * @param {Array} aList
-	 * @returns {string}
-	 */
-	DataStorage.prototype.calculateMessageListHash = function (aList)
-	{
-		return _.map(aList, function (oMessage) {
-			return '' + oMessage.hash + '_' + oMessage.threadsLen() + '_' + oMessage.flagHash();
-		}).join('|');
-	};
+		IdentityModel.prototype.formattedName = function ()
+		{
+			var sName = this.name();
+			return '' === sName ? this.email() : sName + ' <' + this.email() + '>';
+		};
 
-	DataStorage.prototype.findPublicKeyByHex = function (sHash)
-	{
-		return _.find(this.openpgpkeysPublic(), function (oItem) {
-			return oItem && sHash === oItem.id;
-		});
-	};
+		IdentityModel.prototype.formattedNameForCompose = function ()
+		{
+			var sName = this.name();
+			return '' === sName ? this.email() : sName + ' (' + this.email() + ')';
+		};
 
-	DataStorage.prototype.findPublicKeysByEmail = function (sEmail)
-	{
-		return _.compact(_.map(this.openpgpkeysPublic(), function (oItem) {
+		IdentityModel.prototype.formattedNameForEmail = function ()
+		{
+			var sName = this.name();
+			return '' === sName ? this.email() : '"' + Utils.quoteName(sName) + '" <' + this.email() + '>';
+		};
 
-			var oKey = null;
-			if (oItem && sEmail === oItem.email)
-			{
-				try
-				{
-					oKey = window.openpgp.key.readArmored(oItem.armor);
-					if (oKey && !oKey.err && oKey.keys && oKey.keys[0])
-					{
-						return oKey.keys[0];
-					}
-				}
-				catch (e) {}
-			}
+		module.exports = IdentityModel;
 
-			return null;
+	}());
 
-		}));
-	};
+/***/ },
+
+/***/ 60:
+/*!***************************************!*\
+  !*** ./dev/Models/OpenPgpKeyModel.js ***!
+  \***************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	
+	(function () {
+
+		'use strict';
 
-	/**
-	 * @param {string} sEmail
-	 * @param {string=} sPassword
-	 * @returns {?}
-	 */
-	DataStorage.prototype.findPrivateKeyByEmail = function (sEmail, sPassword)
-	{
 		var
-			oPrivateKey = null,
-			oKey = _.find(this.openpgpkeysPrivate(), function (oItem) {
-				return oItem && sEmail === oItem.email;
-			})
+			ko = __webpack_require__(/*! ko */ 3)
 		;
 
-		if (oKey)
+		/**
+		 * @param {string} iIndex
+		 * @param {string} sGuID
+		 * @param {string} sID
+		 * @param {string} sUserID
+		 * @param {string} sEmail
+		 * @param {boolean} bIsPrivate
+		 * @param {string} sArmor
+		 * @constructor
+		 */
+		function OpenPgpKeyModel(iIndex, sGuID, sID, sUserID, sEmail, bIsPrivate, sArmor)
 		{
+			this.index = iIndex;
+			this.id = sID;
+			this.guid = sGuID;
+			this.user = sUserID;
+			this.email = sEmail;
+			this.armor = sArmor;
+			this.isPrivate = !!bIsPrivate;
+
+			this.deleteAccess = ko.observable(false);
+		}
+
+		OpenPgpKeyModel.prototype.index = 0;
+		OpenPgpKeyModel.prototype.id = '';
+		OpenPgpKeyModel.prototype.guid = '';
+		OpenPgpKeyModel.prototype.user = '';
+		OpenPgpKeyModel.prototype.email = '';
+		OpenPgpKeyModel.prototype.armor = '';
+		OpenPgpKeyModel.prototype.isPrivate = false;
+
+		module.exports = OpenPgpKeyModel;
+
+	}());
+
+/***/ },
+
+/***/ 64:
+/*!************************************!*\
+  !*** ./dev/Screens/LoginScreen.js ***!
+  \************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	
+	(function () {
+
+		'use strict';
+
+		var
+			_ = __webpack_require__(/*! _ */ 2),
+
+			KnoinAbstractScreen = __webpack_require__(/*! Knoin:AbstractScreen */ 24)
+		;
+
+		/**
+		 * @constructor
+		 * @extends KnoinAbstractScreen
+		 */
+		function LoginScreen()
+		{
+			KnoinAbstractScreen.call(this, 'login', [
+				__webpack_require__(/*! View:RainLoop:Login */ 96)
+			]);
+		}
+
+		_.extend(LoginScreen.prototype, KnoinAbstractScreen.prototype);
+
+		LoginScreen.prototype.onShow = function ()
+		{
+			__webpack_require__(/*! App:RainLoop */ 4).setTitle('');
+		};
+
+		module.exports = LoginScreen;
+
+	}());
+
+/***/ },
+
+/***/ 90:
+/*!****************************************************!*\
+  !*** ./dev/Storages/LocalStorages/CookieDriver.js ***!
+  \****************************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
+
+	(function () {
+
+		'use strict';
+
+		var
+			$ = __webpack_require__(/*! $ */ 14),
+			JSON = __webpack_require__(/*! JSON */ 33),
+
+			Consts = __webpack_require__(/*! Common/Consts */ 17),
+			Utils = __webpack_require__(/*! Common/Utils */ 1)
+		;
+
+		/**
+		 * @constructor
+		 */
+		function CookieDriver()
+		{
+		}
+
+		/**
+		 * @static
+		 * @return {boolean}
+		 */
+		CookieDriver.supported = function ()
+		{
+			return !!(window.navigator && window.navigator.cookieEnabled);
+		};
+
+		/**
+		 * @param {string} sKey
+		 * @param {*} mData
+		 * @return {boolean}
+		 */
+		CookieDriver.prototype.set = function (sKey, mData)
+		{
+			var
+				mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
+				bResult = false,
+				mResult = null
+			;
+
 			try
 			{
-				oPrivateKey = window.openpgp.key.readArmored(oKey.armor);
-				if (oPrivateKey && !oPrivateKey.err && oPrivateKey.keys && oPrivateKey.keys[0])
+				mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
+			}
+			catch (oException) {}
+
+			if (!mResult)
+			{
+				mResult = {};
+			}
+
+			mResult[sKey] = mData;
+
+			try
+			{
+				$.cookie(Consts.Values.ClientSideStorageIndexName, JSON.stringify(mResult), {
+					'expires': 30
+				});
+
+				bResult = true;
+			}
+			catch (oException) {}
+
+			return bResult;
+		};
+
+		/**
+		 * @param {string} sKey
+		 * @return {*}
+		 */
+		CookieDriver.prototype.get = function (sKey)
+		{
+			var
+				mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
+				mResult = null
+			;
+
+			try
+			{
+				mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
+				if (mResult && !Utils.isUnd(mResult[sKey]))
 				{
-					oPrivateKey = oPrivateKey.keys[0];
-					oPrivateKey.decrypt(Utils.pString(sPassword));
+					mResult = mResult[sKey];
 				}
 				else
 				{
-					oPrivateKey = null;
+					mResult = null;
 				}
 			}
-			catch (e)
-			{
-				oPrivateKey = null;
-			}
-		}
+			catch (oException) {}
 
-		return oPrivateKey;
-	};
+			return mResult;
+		};
 
-	/**
-	 * @param {string=} sPassword
-	 * @returns {?}
-	 */
-	DataStorage.prototype.findSelfPrivateKey = function (sPassword)
-	{
-		return this.findPrivateKeyByEmail(this.accountEmail(), sPassword);
-	};
+		module.exports = CookieDriver;
 
-	module.exports = new DataStorage();
+	}());
 
-}(module, require));
+/***/ },
 
-},{"$":20,"App:Knoin":27,"Consts":6,"Enums":7,"Globals":9,"LinkBuilder":11,"Model:Message":42,"Storage:Abstract:Data":61,"Storage:LocalStorage":65,"Storage:RainLoop:Cache":63,"Storage:Settings":69,"Utils":14,"_":25,"ko":22,"moment":23,"window":26}],65:[function(require,module,exports){
-/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
+/***/ 91:
+/*!**********************************************************!*\
+  !*** ./dev/Storages/LocalStorages/LocalStorageDriver.js ***!
+  \**********************************************************/
+/***/ function(module, exports, __webpack_require__) {
 
-(function (module, require) {
+	/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
 
-	'use strict';
+	(function () {
 
-	/**
-	 * @constructor
-	 */
-	function LocalStorage()
-	{
-		var
-			NextStorageDriver = require('_').find([
-				require('Storage:LocalStorage:LocalStorage'),
-				require('Storage:LocalStorage:Cookie')
-			], function (NextStorageDriver) {
-				return NextStorageDriver && NextStorageDriver.supported();
-			})
-		;
-
-		this.oDriver = null;
-
-		if (NextStorageDriver)
-		{
-			this.oDriver = new NextStorageDriver();
-		}
-	}
-
-	/**
-	 * @type {LocalStorageDriver|CookieDriver|null}
-	 */
-	LocalStorage.prototype.oDriver = null;
-
-	/**
-	 * @param {number} iKey
-	 * @param {*} mData
-	 * @return {boolean}
-	 */
-	LocalStorage.prototype.set = function (iKey, mData)
-	{
-		return this.oDriver ? this.oDriver.set('p' + iKey, mData) : false;
-	};
-
-	/**
-	 * @param {number} iKey
-	 * @return {*}
-	 */
-	LocalStorage.prototype.get = function (iKey)
-	{
-		return this.oDriver ? this.oDriver.get('p' + iKey) : null;
-	};
-
-	module.exports = new LocalStorage();
-
-}(module, require));
-},{"Storage:LocalStorage:Cookie":66,"Storage:LocalStorage:LocalStorage":67,"_":25}],66:[function(require,module,exports){
-/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		$ = require('$'),
-		JSON = require('JSON'),
-
-		Consts = require('Consts'),
-		Utils = require('Utils')
-	;
-
-	/**
-	 * @constructor
-	 */
-	function CookieDriver()
-	{
-	}
-
-	/**
-	 * @static
-	 * @return {boolean}
-	 */
-	CookieDriver.supported = function ()
-	{
-		return !!(window.navigator && window.navigator.cookieEnabled);
-	};
-
-	/**
-	 * @param {string} sKey
-	 * @param {*} mData
-	 * @return {boolean}
-	 */
-	CookieDriver.prototype.set = function (sKey, mData)
-	{
-		var
-			mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
-			bResult = false,
-			mResult = null
-		;
-
-		try
-		{
-			mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
-		}
-		catch (oException) {}
-
-		if (!mResult)
-		{
-			mResult = {};
-		}
-
-		mResult[sKey] = mData;
-
-		try
-		{
-			$.cookie(Consts.Values.ClientSideStorageIndexName, JSON.stringify(mResult), {
-				'expires': 30
-			});
-
-			bResult = true;
-		}
-		catch (oException) {}
-
-		return bResult;
-	};
-
-	/**
-	 * @param {string} sKey
-	 * @return {*}
-	 */
-	CookieDriver.prototype.get = function (sKey)
-	{
-		var
-			mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
-			mResult = null
-		;
-
-		try
-		{
-			mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
-			if (mResult && !Utils.isUnd(mResult[sKey]))
-			{
-				mResult = mResult[sKey];
-			}
-			else
-			{
-				mResult = null;
-			}
-		}
-		catch (oException) {}
-
-		return mResult;
-	};
-
-	module.exports = CookieDriver;
-
-}(module, require));
-},{"$":20,"Consts":6,"JSON":15,"Utils":14}],67:[function(require,module,exports){
-/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		window = require('window'),
-		JSON = require('JSON'),
-
-		Consts = require('Consts'),
-		Utils = require('Utils')
-	;
-
-	/**
-	 * @constructor
-	 */
-	function LocalStorageDriver()
-	{
-	}
-
-	/**
-	 * @static
-	 * @return {boolean}
-	 */
-	LocalStorageDriver.supported = function ()
-	{
-		return !!window.localStorage;
-	};
-
-	/**
-	 * @param {string} sKey
-	 * @param {*} mData
-	 * @return {boolean}
-	 */
-	LocalStorageDriver.prototype.set = function (sKey, mData)
-	{
-		var
-			mStorageValue = window.localStorage[Consts.Values.ClientSideStorageIndexName] || null,
-			bResult = false,
-			mResult = null
-		;
-
-		try
-		{
-			mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
-		}
-		catch (oException) {}
-
-		if (!mResult)
-		{
-			mResult = {};
-		}
-
-		mResult[sKey] = mData;
-
-		try
-		{
-			window.localStorage[Consts.Values.ClientSideStorageIndexName] = JSON.stringify(mResult);
-
-			bResult = true;
-		}
-		catch (oException) {}
-
-		return bResult;
-	};
-
-	/**
-	 * @param {string} sKey
-	 * @return {*}
-	 */
-	LocalStorageDriver.prototype.get = function (sKey)
-	{
-		var
-			mStorageValue = window.localStorage[Consts.Values.ClientSideStorageIndexName] || null,
-			mResult = null
-		;
-
-		try
-		{
-			mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
-			if (mResult && !Utils.isUnd(mResult[sKey]))
-			{
-				mResult = mResult[sKey];
-			}
-			else
-			{
-				mResult = null;
-			}
-		}
-		catch (oException) {}
-
-		return mResult;
-	};
-
-	module.exports = LocalStorageDriver;
-
-}(module, require));
-},{"Consts":6,"JSON":15,"Utils":14,"window":26}],68:[function(require,module,exports){
-/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
-
-(function (module, require) {
-	
-	'use strict';
-
-	var
-		_ = require('_'),
-
-		Utils = require('Utils'),
-		Consts = require('Consts'),
-		Globals = require('Globals'),
-		Base64 = require('Base64'),
-
-		Settings = require('Storage:Settings'),
-		Cache = require('Storage:RainLoop:Cache'),
-		Data = require('Storage:RainLoop:Data'),
-
-		AbstractRemoteStorage = require('Storage:Abstract:Remote')
-	;
-
-	/**
-	 * @constructor
-	 * @extends AbstractRemoteStorage
-	 */
-	function RemoteStorage()
-	{
-		AbstractRemoteStorage.call(this);
-
-		this.oRequests = {};
-	}
-
-	_.extend(RemoteStorage.prototype, AbstractRemoteStorage.prototype);
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.folders = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'Folders', {
-			'SentFolder': Settings.settingsGet('SentFolder'),
-			'DraftFolder': Settings.settingsGet('DraftFolder'),
-			'SpamFolder': Settings.settingsGet('SpamFolder'),
-			'TrashFolder': Settings.settingsGet('TrashFolder'),
-			'ArchiveFolder': Settings.settingsGet('ArchiveFolder')
-		}, null, '', ['Folders']);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sEmail
-	 * @param {string} sLogin
-	 * @param {string} sPassword
-	 * @param {boolean} bSignMe
-	 * @param {string=} sLanguage
-	 * @param {string=} sAdditionalCode
-	 * @param {boolean=} bAdditionalCodeSignMe
-	 */
-	RemoteStorage.prototype.login = function (fCallback, sEmail, sLogin, sPassword, bSignMe, sLanguage, sAdditionalCode, bAdditionalCodeSignMe)
-	{
-		this.defaultRequest(fCallback, 'Login', {
-			'Email': sEmail,
-			'Login': sLogin,
-			'Password': sPassword,
-			'Language': sLanguage || '',
-			'AdditionalCode': sAdditionalCode || '',
-			'AdditionalCodeSignMe': bAdditionalCodeSignMe ? '1' : '0',
-			'SignMe': bSignMe ? '1' : '0'
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.getTwoFactor = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'GetTwoFactorInfo');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.createTwoFactor = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'CreateTwoFactorSecret');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.clearTwoFactor = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'ClearTwoFactorInfo');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.showTwoFactorSecret = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'ShowTwoFactorSecret');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sCode
-	 */
-	RemoteStorage.prototype.testTwoFactor = function (fCallback, sCode)
-	{
-		this.defaultRequest(fCallback, 'TestTwoFactorInfo', {
-			'Code': sCode
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {boolean} bEnable
-	 */
-	RemoteStorage.prototype.enableTwoFactor = function (fCallback, bEnable)
-	{
-		this.defaultRequest(fCallback, 'EnableTwoFactor', {
-			'Enable': bEnable ? '1' : '0'
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.clearTwoFactorInfo = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'ClearTwoFactorInfo');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.contactsSync = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'ContactsSync', null, Consts.Defaults.ContactsSyncAjaxTimeout);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {boolean} bEnable
-	 * @param {string} sUrl
-	 * @param {string} sUser
-	 * @param {string} sPassword
-	 */
-	RemoteStorage.prototype.saveContactsSyncData = function (fCallback, bEnable, sUrl, sUser, sPassword)
-	{
-		this.defaultRequest(fCallback, 'SaveContactsSyncData', {
-			'Enable': bEnable ? '1' : '0',
-			'Url': sUrl,
-			'User': sUser,
-			'Password': sPassword
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sEmail
-	 * @param {string} sLogin
-	 * @param {string} sPassword
-	 */
-	RemoteStorage.prototype.accountAdd = function (fCallback, sEmail, sLogin, sPassword)
-	{
-		this.defaultRequest(fCallback, 'AccountAdd', {
-			'Email': sEmail,
-			'Login': sLogin,
-			'Password': sPassword
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sEmailToDelete
-	 */
-	RemoteStorage.prototype.accountDelete = function (fCallback, sEmailToDelete)
-	{
-		this.defaultRequest(fCallback, 'AccountDelete', {
-			'EmailToDelete': sEmailToDelete
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sId
-	 * @param {string} sEmail
-	 * @param {string} sName
-	 * @param {string} sReplyTo
-	 * @param {string} sBcc
-	 */
-	RemoteStorage.prototype.identityUpdate = function (fCallback, sId, sEmail, sName, sReplyTo, sBcc)
-	{
-		this.defaultRequest(fCallback, 'IdentityUpdate', {
-			'Id': sId,
-			'Email': sEmail,
-			'Name': sName,
-			'ReplyTo': sReplyTo,
-			'Bcc': sBcc
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sIdToDelete
-	 */
-	RemoteStorage.prototype.identityDelete = function (fCallback, sIdToDelete)
-	{
-		this.defaultRequest(fCallback, 'IdentityDelete', {
-			'IdToDelete': sIdToDelete
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.accountsAndIdentities = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'AccountsAndIdentities');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolderFullNameRaw
-	 * @param {number=} iOffset = 0
-	 * @param {number=} iLimit = 20
-	 * @param {string=} sSearch = ''
-	 * @param {boolean=} bSilent = false
-	 */
-	RemoteStorage.prototype.messageList = function (fCallback, sFolderFullNameRaw, iOffset, iLimit, sSearch, bSilent)
-	{
-		sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw);
+		'use strict';
 
 		var
-			sFolderHash = Cache.getFolderHash(sFolderFullNameRaw)
+			window = __webpack_require__(/*! window */ 12),
+			JSON = __webpack_require__(/*! JSON */ 33),
+
+			Consts = __webpack_require__(/*! Common/Consts */ 17),
+			Utils = __webpack_require__(/*! Common/Utils */ 1)
 		;
 
-		bSilent = Utils.isUnd(bSilent) ? false : !!bSilent;
-		iOffset = Utils.isUnd(iOffset) ? 0 : Utils.pInt(iOffset);
-		iLimit = Utils.isUnd(iOffset) ? 20 : Utils.pInt(iLimit);
-		sSearch = Utils.pString(sSearch);
-
-		if ('' !== sFolderHash && ('' === sSearch || -1 === sSearch.indexOf('is:')))
+		/**
+		 * @constructor
+		 */
+		function LocalStorageDriver()
 		{
-			this.defaultRequest(fCallback, 'MessageList', {},
-				'' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout,
-				'MessageList/' + Base64.urlsafe_encode([
-					sFolderFullNameRaw,
-					iOffset,
-					iLimit,
-					sSearch,
-					Data.projectHash(),
-					sFolderHash,
-					'INBOX' === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
-					Data.threading() && Data.useThreads() ? '1' : '0',
-					Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : ''
-				].join(String.fromCharCode(0))), bSilent ? [] : ['MessageList']);
-		}
-		else
-		{
-			this.defaultRequest(fCallback, 'MessageList', {
-				'Folder': sFolderFullNameRaw,
-				'Offset': iOffset,
-				'Limit': iLimit,
-				'Search': sSearch,
-				'UidNext': 'INBOX' === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
-				'UseThreads': Data.threading() && Data.useThreads() ? '1' : '0',
-				'ExpandedThreadUid': Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : ''
-			}, '' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout, '', bSilent ? [] : ['MessageList']);
-		}
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {Array} aDownloads
-	 */
-	RemoteStorage.prototype.messageUploadAttachments = function (fCallback, aDownloads)
-	{
-		this.defaultRequest(fCallback, 'MessageUploadAttachments', {
-			'Attachments': aDownloads
-		}, 999000);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolderFullNameRaw
-	 * @param {number} iUid
-	 * @return {boolean}
-	 */
-	RemoteStorage.prototype.message = function (fCallback, sFolderFullNameRaw, iUid)
-	{
-		sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw);
-		iUid = Utils.pInt(iUid);
-
-		if (Cache.getFolderFromCacheList(sFolderFullNameRaw) && 0 < iUid)
-		{
-			this.defaultRequest(fCallback, 'Message', {}, null,
-				'Message/' + Base64.urlsafe_encode([
-					sFolderFullNameRaw,
-					iUid,
-					Data.projectHash(),
-					Data.threading() && Data.useThreads() ? '1' : '0'
-				].join(String.fromCharCode(0))), ['Message']);
-
-			return true;
 		}
 
-		return false;
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {Array} aExternals
-	 */
-	RemoteStorage.prototype.composeUploadExternals = function (fCallback, aExternals)
-	{
-		this.defaultRequest(fCallback, 'ComposeUploadExternals', {
-			'Externals': aExternals
-		}, 999000);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sUrl
-	 * @param {string} sAccessToken
-	 */
-	RemoteStorage.prototype.composeUploadDrive = function (fCallback, sUrl, sAccessToken)
-	{
-		this.defaultRequest(fCallback, 'ComposeUploadDrive', {
-			'AccessToken': sAccessToken,
-			'Url': sUrl
-		}, 999000);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolder
-	 * @param {Array=} aList = []
-	 */
-	RemoteStorage.prototype.folderInformation = function (fCallback, sFolder, aList)
-	{
-		var
-			bRequest = true,
-			aUids = []
-		;
-
-		if (Utils.isArray(aList) && 0 < aList.length)
+		/**
+		 * @static
+		 * @return {boolean}
+		 */
+		LocalStorageDriver.supported = function ()
 		{
-			bRequest = false;
-			_.each(aList, function (oMessageListItem) {
-				if (!Cache.getMessageFlagsFromCache(oMessageListItem.folderFullNameRaw, oMessageListItem.uid))
-				{
-					aUids.push(oMessageListItem.uid);
-				}
+			return !!window.localStorage;
+		};
 
-				if (0 < oMessageListItem.threads().length)
-				{
-					_.each(oMessageListItem.threads(), function (sUid) {
-						if (!Cache.getMessageFlagsFromCache(oMessageListItem.folderFullNameRaw, sUid))
-						{
-							aUids.push(sUid);
-						}
-					});
-				}
-			});
-
-			if (0 < aUids.length)
-			{
-				bRequest = true;
-			}
-		}
-
-		if (bRequest)
+		/**
+		 * @param {string} sKey
+		 * @param {*} mData
+		 * @return {boolean}
+		 */
+		LocalStorageDriver.prototype.set = function (sKey, mData)
 		{
-			this.defaultRequest(fCallback, 'FolderInformation', {
-				'Folder': sFolder,
-				'FlagsUids': Utils.isArray(aUids) ? aUids.join(',') : '',
-				'UidNext': 'INBOX' === sFolder ? Cache.getFolderUidNext(sFolder) : ''
-			});
-		}
-		else if (Data.useThreads())
-		{
-			if (Globals.__APP)
-			{
-				Globals.__APP.reloadFlagsCurrentMessageListAndMessageFromCache();
-			}
-		}
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {Array} aFolders
-	 */
-	RemoteStorage.prototype.folderInformationMultiply = function (fCallback, aFolders)
-	{
-		this.defaultRequest(fCallback, 'FolderInformationMultiply', {
-			'Folders': aFolders
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.logout = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'Logout');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolderFullNameRaw
-	 * @param {Array} aUids
-	 * @param {boolean} bSetFlagged
-	 */
-	RemoteStorage.prototype.messageSetFlagged = function (fCallback, sFolderFullNameRaw, aUids, bSetFlagged)
-	{
-		this.defaultRequest(fCallback, 'MessageSetFlagged', {
-			'Folder': sFolderFullNameRaw,
-			'Uids': aUids.join(','),
-			'SetAction': bSetFlagged ? '1' : '0'
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolderFullNameRaw
-	 * @param {Array} aUids
-	 * @param {boolean} bSetSeen
-	 */
-	RemoteStorage.prototype.messageSetSeen = function (fCallback, sFolderFullNameRaw, aUids, bSetSeen)
-	{
-		this.defaultRequest(fCallback, 'MessageSetSeen', {
-			'Folder': sFolderFullNameRaw,
-			'Uids': aUids.join(','),
-			'SetAction': bSetSeen ? '1' : '0'
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolderFullNameRaw
-	 * @param {boolean} bSetSeen
-	 */
-	RemoteStorage.prototype.messageSetSeenToAll = function (fCallback, sFolderFullNameRaw, bSetSeen)
-	{
-		this.defaultRequest(fCallback, 'MessageSetSeenToAll', {
-			'Folder': sFolderFullNameRaw,
-			'SetAction': bSetSeen ? '1' : '0'
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sMessageFolder
-	 * @param {string} sMessageUid
-	 * @param {string} sDraftFolder
-	 * @param {string} sFrom
-	 * @param {string} sTo
-	 * @param {string} sCc
-	 * @param {string} sBcc
-	 * @param {string} sSubject
-	 * @param {boolean} bTextIsHtml
-	 * @param {string} sText
-	 * @param {Array} aAttachments
-	 * @param {(Array|null)} aDraftInfo
-	 * @param {string} sInReplyTo
-	 * @param {string} sReferences
-	 */
-	RemoteStorage.prototype.saveMessage = function (fCallback, sMessageFolder, sMessageUid, sDraftFolder,
-		sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences)
-	{
-		this.defaultRequest(fCallback, 'SaveMessage', {
-			'MessageFolder': sMessageFolder,
-			'MessageUid': sMessageUid,
-			'DraftFolder': sDraftFolder,
-			'From': sFrom,
-			'To': sTo,
-			'Cc': sCc,
-			'Bcc': sBcc,
-			'Subject': sSubject,
-			'TextIsHtml': bTextIsHtml ? '1' : '0',
-			'Text': sText,
-			'DraftInfo': aDraftInfo,
-			'InReplyTo': sInReplyTo,
-			'References': sReferences,
-			'Attachments': aAttachments
-		}, Consts.Defaults.SaveMessageAjaxTimeout);
-	};
-
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sMessageFolder
-	 * @param {string} sMessageUid
-	 * @param {string} sReadReceipt
-	 * @param {string} sSubject
-	 * @param {string} sText
-	 */
-	RemoteStorage.prototype.sendReadReceiptMessage = function (fCallback, sMessageFolder, sMessageUid, sReadReceipt, sSubject, sText)
-	{
-		this.defaultRequest(fCallback, 'SendReadReceiptMessage', {
-			'MessageFolder': sMessageFolder,
-			'MessageUid': sMessageUid,
-			'ReadReceipt': sReadReceipt,
-			'Subject': sSubject,
-			'Text': sText
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sMessageFolder
-	 * @param {string} sMessageUid
-	 * @param {string} sSentFolder
-	 * @param {string} sFrom
-	 * @param {string} sTo
-	 * @param {string} sCc
-	 * @param {string} sBcc
-	 * @param {string} sSubject
-	 * @param {boolean} bTextIsHtml
-	 * @param {string} sText
-	 * @param {Array} aAttachments
-	 * @param {(Array|null)} aDraftInfo
-	 * @param {string} sInReplyTo
-	 * @param {string} sReferences
-	 * @param {boolean} bRequestReadReceipt
-	 */
-	RemoteStorage.prototype.sendMessage = function (fCallback, sMessageFolder, sMessageUid, sSentFolder,
-		sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences, bRequestReadReceipt)
-	{
-		this.defaultRequest(fCallback, 'SendMessage', {
-			'MessageFolder': sMessageFolder,
-			'MessageUid': sMessageUid,
-			'SentFolder': sSentFolder,
-			'From': sFrom,
-			'To': sTo,
-			'Cc': sCc,
-			'Bcc': sBcc,
-			'Subject': sSubject,
-			'TextIsHtml': bTextIsHtml ? '1' : '0',
-			'Text': sText,
-			'DraftInfo': aDraftInfo,
-			'InReplyTo': sInReplyTo,
-			'References': sReferences,
-			'ReadReceiptRequest': bRequestReadReceipt ? '1' : '0',
-			'Attachments': aAttachments
-		}, Consts.Defaults.SendMessageAjaxTimeout);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {Object} oData
-	 */
-	RemoteStorage.prototype.saveSystemFolders = function (fCallback, oData)
-	{
-		this.defaultRequest(fCallback, 'SystemFoldersUpdate', oData);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {Object} oData
-	 */
-	RemoteStorage.prototype.saveSettings = function (fCallback, oData)
-	{
-		this.defaultRequest(fCallback, 'SettingsUpdate', oData);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sPrevPassword
-	 * @param {string} sNewPassword
-	 */
-	RemoteStorage.prototype.changePassword = function (fCallback, sPrevPassword, sNewPassword)
-	{
-		this.defaultRequest(fCallback, 'ChangePassword', {
-			'PrevPassword': sPrevPassword,
-			'NewPassword': sNewPassword
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sNewFolderName
-	 * @param {string} sParentName
-	 */
-	RemoteStorage.prototype.folderCreate = function (fCallback, sNewFolderName, sParentName)
-	{
-		this.defaultRequest(fCallback, 'FolderCreate', {
-			'Folder': sNewFolderName,
-			'Parent': sParentName
-		}, null, '', ['Folders']);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolderFullNameRaw
-	 */
-	RemoteStorage.prototype.folderDelete = function (fCallback, sFolderFullNameRaw)
-	{
-		this.defaultRequest(fCallback, 'FolderDelete', {
-			'Folder': sFolderFullNameRaw
-		}, null, '', ['Folders']);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sPrevFolderFullNameRaw
-	 * @param {string} sNewFolderName
-	 */
-	RemoteStorage.prototype.folderRename = function (fCallback, sPrevFolderFullNameRaw, sNewFolderName)
-	{
-		this.defaultRequest(fCallback, 'FolderRename', {
-			'Folder': sPrevFolderFullNameRaw,
-			'NewFolderName': sNewFolderName
-		}, null, '', ['Folders']);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolderFullNameRaw
-	 */
-	RemoteStorage.prototype.folderClear = function (fCallback, sFolderFullNameRaw)
-	{
-		this.defaultRequest(fCallback, 'FolderClear', {
-			'Folder': sFolderFullNameRaw
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolderFullNameRaw
-	 * @param {boolean} bSubscribe
-	 */
-	RemoteStorage.prototype.folderSetSubscribe = function (fCallback, sFolderFullNameRaw, bSubscribe)
-	{
-		this.defaultRequest(fCallback, 'FolderSubscribe', {
-			'Folder': sFolderFullNameRaw,
-			'Subscribe': bSubscribe ? '1' : '0'
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolder
-	 * @param {string} sToFolder
-	 * @param {Array} aUids
-	 * @param {string=} sLearning
-	 */
-	RemoteStorage.prototype.messagesMove = function (fCallback, sFolder, sToFolder, aUids, sLearning)
-	{
-		this.defaultRequest(fCallback, 'MessageMove', {
-			'FromFolder': sFolder,
-			'ToFolder': sToFolder,
-			'Uids': aUids.join(','),
-			'Learning': sLearning || ''
-		}, null, '', ['MessageList']);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolder
-	 * @param {string} sToFolder
-	 * @param {Array} aUids
-	 */
-	RemoteStorage.prototype.messagesCopy = function (fCallback, sFolder, sToFolder, aUids)
-	{
-		this.defaultRequest(fCallback, 'MessageCopy', {
-			'FromFolder': sFolder,
-			'ToFolder': sToFolder,
-			'Uids': aUids.join(',')
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sFolder
-	 * @param {Array} aUids
-	 */
-	RemoteStorage.prototype.messagesDelete = function (fCallback, sFolder, aUids)
-	{
-		this.defaultRequest(fCallback, 'MessageDelete', {
-			'Folder': sFolder,
-			'Uids': aUids.join(',')
-		}, null, '', ['MessageList']);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.appDelayStart = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'AppDelayStart');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.quota = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'Quota');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {number} iOffset
-	 * @param {number} iLimit
-	 * @param {string} sSearch
-	 */
-	RemoteStorage.prototype.contacts = function (fCallback, iOffset, iLimit, sSearch)
-	{
-		this.defaultRequest(fCallback, 'Contacts', {
-			'Offset': iOffset,
-			'Limit': iLimit,
-			'Search': sSearch
-		}, null, '', ['Contacts']);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties)
-	{
-		this.defaultRequest(fCallback, 'ContactSave', {
-			'RequestUid': sRequestUid,
-			'Uid': Utils.trim(sUid),
-			'Tags': Utils.trim(sTags),
-			'Properties': aProperties
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {Array} aUids
-	 */
-	RemoteStorage.prototype.contactsDelete = function (fCallback, aUids)
-	{
-		this.defaultRequest(fCallback, 'ContactsDelete', {
-			'Uids': aUids.join(',')
-		});
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 * @param {string} sQuery
-	 * @param {number} iPage
-	 */
-	RemoteStorage.prototype.suggestions = function (fCallback, sQuery, iPage)
-	{
-		this.defaultRequest(fCallback, 'Suggestions', {
-			'Query': sQuery,
-			'Page': iPage
-		}, null, '', ['Suggestions']);
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.facebookUser = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'SocialFacebookUserInformation');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.facebookDisconnect = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'SocialFacebookDisconnect');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.twitterUser = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'SocialTwitterUserInformation');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.twitterDisconnect = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'SocialTwitterDisconnect');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.googleUser = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'SocialGoogleUserInformation');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.googleDisconnect = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'SocialGoogleDisconnect');
-	};
-
-	/**
-	 * @param {?Function} fCallback
-	 */
-	RemoteStorage.prototype.socialUsers = function (fCallback)
-	{
-		this.defaultRequest(fCallback, 'SocialUsers');
-	};
-
-	module.exports = new RemoteStorage();
-
-}(module, require));
-},{"Base64":5,"Consts":6,"Globals":9,"Storage:Abstract:Remote":62,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:Settings":69,"Utils":14,"_":25}],69:[function(require,module,exports){
-/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		window = require('window'),
-		
-		Utils = require('Utils')
-	;
-
-	/**
-	 * @constructor
-	 */
-	function SettingsStorage()
-	{
-		this.oSettings = window['rainloopAppData'] || {};
-		this.oSettings = Utils.isNormal(this.oSettings) ? this.oSettings : {};
-	}
-
-	SettingsStorage.prototype.oSettings = null;
-
-	/**
-	 * @param {string} sName
-	 * @return {?}
-	 */
-	SettingsStorage.prototype.settingsGet = function (sName)
-	{
-		return Utils.isUnd(this.oSettings[sName]) ? null : this.oSettings[sName];
-	};
-
-	/**
-	 * @param {string} sName
-	 * @param {?} mValue
-	 */
-	SettingsStorage.prototype.settingsSet = function (sName, mValue)
-	{
-		this.oSettings[sName] = mValue;
-	};
-
-	/**
-	 * @param {string} sName
-	 * @return {boolean}
-	 */
-	SettingsStorage.prototype.capa = function (sName)
-	{
-		var mCapa = this.settingsGet('Capa');
-		return Utils.isArray(mCapa) && Utils.isNormal(sName) && -1 < Utils.inArray(sName, mCapa);
-	};
-
-
-	module.exports = new SettingsStorage();
-
-}(module, require));
-},{"Utils":14,"window":26}],70:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		ko = require('ko'),
-
-		kn = require('App:Knoin'),
-		Settings = require('Storage:Settings'),
-
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function AboutViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Center', 'About');
-
-		this.version = ko.observable(Settings.settingsGet('Version'));
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:RainLoop:About', 'AboutViewModel'], AboutViewModel);
-	_.extend(AboutViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	module.exports = AboutViewModel;
-
-}(module, require));
-},{"App:Knoin":27,"Knoin:AbstractViewModel":30,"Storage:Settings":69,"_":25,"ko":22}],71:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		window = require('window'),
-		_ = require('_'),
-		ko = require('ko'),
-		key = require('key'),
-
-		Enums = require('Enums'),
-		Utils = require('Utils'),
-		LinkBuilder = require('LinkBuilder'),
-
-		Settings = require('Storage:Settings'),
-		Data = require('Storage:RainLoop:Data'),
-		Remote = require('Storage:RainLoop:Remote'),
-
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function AbstractSystemDropDownViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Right', 'SystemDropDown');
-
-		this.accounts = Data.accounts;
-		this.accountEmail = Data.accountEmail;
-		this.accountsLoading = Data.accountsLoading;
-
-		this.accountMenuDropdownTrigger = ko.observable(false);
-
-		this.capaAdditionalAccounts = Settings.capa(Enums.Capa.AdditionalAccounts);
-
-		this.loading = ko.computed(function () {
-			return this.accountsLoading();
-		}, this);
-
-		this.accountClick = _.bind(this.accountClick, this);
-	}
-
-	_.extend(AbstractSystemDropDownViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	AbstractSystemDropDownViewModel.prototype.accountClick = function (oAccount, oEvent)
-	{
-		if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
-		{
-			var self = this;
-			this.accountsLoading(true);
-			_.delay(function () {
-				self.accountsLoading(false);
-			}, 1000);
-		}
-
-		return true;
-	};
-
-	AbstractSystemDropDownViewModel.prototype.emailTitle = function ()
-	{
-		return Data.accountEmail();
-	};
-
-	AbstractSystemDropDownViewModel.prototype.settingsClick = function ()
-	{
-		require('App:Knoin').setHash(LinkBuilder.settings());
-	};
-
-	AbstractSystemDropDownViewModel.prototype.settingsHelp = function ()
-	{
-		require('App:Knoin').showScreenPopup(require('View:Popup:KeyboardShortcutsHelp'));
-	};
-
-	AbstractSystemDropDownViewModel.prototype.addAccountClick = function ()
-	{
-		if (this.capaAdditionalAccounts)
-		{
-			require('App:Knoin').showScreenPopup(require('View:Popup:AddAccount'));
-		}
-	};
-
-	AbstractSystemDropDownViewModel.prototype.logoutClick = function ()
-	{
-		Remote.logout(function () {
-			if (window.__rlah_clear)
-			{
-				window.__rlah_clear();
-			}
-
-			require('App:RainLoop').loginAndLogoutReload(true,
-				Settings.settingsGet('ParentEmail') && 0 < Settings.settingsGet('ParentEmail').length);
-		});
-	};
-
-	AbstractSystemDropDownViewModel.prototype.onBuild = function ()
-	{
-		var self = this;
-		key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
-			if (self.viewModelVisibility())
-			{
-				self.accountMenuDropdownTrigger(true);
-			}
-		});
-
-		// shortcuts help
-		key('shift+/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
-			if (self.viewModelVisibility())
-			{
-				require('App:Knoin').showScreenPopup(require('View:Popup:KeyboardShortcutsHelp'));
-				return false;
-			}
-		});
-	};
-
-	module.exports = AbstractSystemDropDownViewModel;
-
-}(module, require));
-},{"App:Knoin":27,"App:RainLoop":3,"Enums":7,"Knoin:AbstractViewModel":30,"LinkBuilder":11,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,"Utils":14,"View:Popup:AddAccount":77,"View:Popup:KeyboardShortcutsHelp":89,"_":25,"key":21,"ko":22,"window":26}],72:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		window = require('window'),
-		_ = require('_'),
-		$ = require('$'),
-		ko = require('ko'),
-
-		Enums = require('Enums'),
-		Utils = require('Utils'),
-		LinkBuilder = require('LinkBuilder'),
-
-		Settings = require('Storage:Settings'),
-		Data = require('Storage:RainLoop:Data'),
-		Remote = require('Storage:RainLoop:Remote'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function LoginViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Center', 'Login');
-
-		this.email = ko.observable('');
-		this.password = ko.observable('');
-		this.signMe = ko.observable(false);
-
-		this.additionalCode = ko.observable('');
-		this.additionalCode.error = ko.observable(false);
-		this.additionalCode.focused = ko.observable(false);
-		this.additionalCode.visibility = ko.observable(false);
-		this.additionalCodeSignMe = ko.observable(false);
-
-		this.logoImg = Utils.trim(Settings.settingsGet('LoginLogo'));
-		this.loginDescription = Utils.trim(Settings.settingsGet('LoginDescription'));
-		this.logoCss = Utils.trim(Settings.settingsGet('LoginCss'));
-
-		this.emailError = ko.observable(false);
-		this.passwordError = ko.observable(false);
-
-		this.emailFocus = ko.observable(false);
-		this.submitFocus = ko.observable(false);
-
-		this.email.subscribe(function () {
-			this.emailError(false);
-			this.additionalCode('');
-			this.additionalCode.visibility(false);
-		}, this);
-
-		this.password.subscribe(function () {
-			this.passwordError(false);
-		}, this);
-
-		this.additionalCode.subscribe(function () {
-			this.additionalCode.error(false);
-		}, this);
-
-		this.additionalCode.visibility.subscribe(function () {
-			this.additionalCode.error(false);
-		}, this);
-
-		this.submitRequest = ko.observable(false);
-		this.submitError = ko.observable('');
-
-		this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin;
-
-		this.langRequest = ko.observable(false);
-		this.mainLanguage = Data.mainLanguage;
-		this.bSendLanguage = false;
-
-		this.mainLanguageFullName = ko.computed(function () {
-			return Utils.convertLangName(this.mainLanguage());
-		}, this);
-
-		this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
-
-		this.signMeType.subscribe(function (iValue) {
-			this.signMe(Enums.LoginSignMeType.DefaultOn === iValue);
-		}, this);
-
-		this.signMeVisibility = ko.computed(function () {
-			return Enums.LoginSignMeType.Unused !== this.signMeType();
-		}, this);
-
-		this.submitCommand = Utils.createCommand(this, function () {
-
-			Utils.triggerAutocompleteInputChange();
-
-			this.emailError('' === Utils.trim(this.email()));
-			this.passwordError('' === Utils.trim(this.password()));
-
-			if (this.additionalCode.visibility())
-			{
-				this.additionalCode.error('' === Utils.trim(this.additionalCode()));
-			}
-
-			if (this.emailError() || this.passwordError() || this.additionalCode.error())
-			{
-				return false;
-			}
-
-			this.submitRequest(true);
-
 			var
-				sPassword = this.password(),
+				mStorageValue = window.localStorage[Consts.Values.ClientSideStorageIndexName] || null,
+				bResult = false,
+				mResult = null
+			;
 
-				fLoginRequest = _.bind(function (sPassword) {
+			try
+			{
+				mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
+			}
+			catch (oException) {}
 
-					Remote.login(_.bind(function (sResult, oData) {
+			if (!mResult)
+			{
+				mResult = {};
+			}
 
-						if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
-						{
-							if (oData.Result)
+			mResult[sKey] = mData;
+
+			try
+			{
+				window.localStorage[Consts.Values.ClientSideStorageIndexName] = JSON.stringify(mResult);
+
+				bResult = true;
+			}
+			catch (oException) {}
+
+			return bResult;
+		};
+
+		/**
+		 * @param {string} sKey
+		 * @return {*}
+		 */
+		LocalStorageDriver.prototype.get = function (sKey)
+		{
+			var
+				mStorageValue = window.localStorage[Consts.Values.ClientSideStorageIndexName] || null,
+				mResult = null
+			;
+
+			try
+			{
+				mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
+				if (mResult && !Utils.isUnd(mResult[sKey]))
+				{
+					mResult = mResult[sKey];
+				}
+				else
+				{
+					mResult = null;
+				}
+			}
+			catch (oException) {}
+
+			return mResult;
+		};
+
+		module.exports = LocalStorageDriver;
+
+	}());
+
+/***/ },
+
+/***/ 96:
+/*!******************************************!*\
+  !*** ./dev/ViewModels/LoginViewModel.js ***!
+  \******************************************/
+/***/ function(module, exports, __webpack_require__) {
+
+	
+	(function () {
+
+		'use strict';
+
+		var
+			window = __webpack_require__(/*! window */ 12),
+			_ = __webpack_require__(/*! _ */ 2),
+			$ = __webpack_require__(/*! $ */ 14),
+			ko = __webpack_require__(/*! ko */ 3),
+
+			Enums = __webpack_require__(/*! Common/Enums */ 6),
+			Utils = __webpack_require__(/*! Common/Utils */ 1),
+			LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11),
+
+			Settings = __webpack_require__(/*! Storage:Settings */ 10),
+			Data = __webpack_require__(/*! Storage:RainLoop:Data */ 8),
+			Remote = __webpack_require__(/*! Storage:RainLoop:Remote */ 13),
+
+			kn = __webpack_require__(/*! App:Knoin */ 5),
+			KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9)
+		;
+
+		/**
+		 * @constructor
+		 * @extends KnoinAbstractViewModel
+		 */
+		function LoginViewModel()
+		{
+			KnoinAbstractViewModel.call(this, 'Center', 'Login');
+
+			this.email = ko.observable('');
+			this.password = ko.observable('');
+			this.signMe = ko.observable(false);
+
+			this.additionalCode = ko.observable('');
+			this.additionalCode.error = ko.observable(false);
+			this.additionalCode.focused = ko.observable(false);
+			this.additionalCode.visibility = ko.observable(false);
+			this.additionalCodeSignMe = ko.observable(false);
+
+			this.logoImg = Utils.trim(Settings.settingsGet('LoginLogo'));
+			this.loginDescription = Utils.trim(Settings.settingsGet('LoginDescription'));
+			this.logoCss = Utils.trim(Settings.settingsGet('LoginCss'));
+
+			this.emailError = ko.observable(false);
+			this.passwordError = ko.observable(false);
+
+			this.emailFocus = ko.observable(false);
+			this.submitFocus = ko.observable(false);
+
+			this.email.subscribe(function () {
+				this.emailError(false);
+				this.additionalCode('');
+				this.additionalCode.visibility(false);
+			}, this);
+
+			this.password.subscribe(function () {
+				this.passwordError(false);
+			}, this);
+
+			this.additionalCode.subscribe(function () {
+				this.additionalCode.error(false);
+			}, this);
+
+			this.additionalCode.visibility.subscribe(function () {
+				this.additionalCode.error(false);
+			}, this);
+
+			this.submitRequest = ko.observable(false);
+			this.submitError = ko.observable('');
+
+			this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin;
+
+			this.langRequest = ko.observable(false);
+			this.mainLanguage = Data.mainLanguage;
+			this.bSendLanguage = false;
+
+			this.mainLanguageFullName = ko.computed(function () {
+				return Utils.convertLangName(this.mainLanguage());
+			}, this);
+
+			this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
+
+			this.signMeType.subscribe(function (iValue) {
+				this.signMe(Enums.LoginSignMeType.DefaultOn === iValue);
+			}, this);
+
+			this.signMeVisibility = ko.computed(function () {
+				return Enums.LoginSignMeType.Unused !== this.signMeType();
+			}, this);
+
+			this.submitCommand = Utils.createCommand(this, function () {
+
+				Utils.triggerAutocompleteInputChange();
+
+				this.emailError('' === Utils.trim(this.email()));
+				this.passwordError('' === Utils.trim(this.password()));
+
+				if (this.additionalCode.visibility())
+				{
+					this.additionalCode.error('' === Utils.trim(this.additionalCode()));
+				}
+
+				if (this.emailError() || this.passwordError() || this.additionalCode.error())
+				{
+					return false;
+				}
+
+				this.submitRequest(true);
+
+				var
+					sPassword = this.password(),
+
+					fLoginRequest = _.bind(function (sPassword) {
+
+						Remote.login(_.bind(function (sResult, oData) {
+
+							if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
 							{
-								if (oData.TwoFactorAuth)
+								if (oData.Result)
 								{
-									this.additionalCode('');
-									this.additionalCode.visibility(true);
-									this.additionalCode.focused(true);
+									if (oData.TwoFactorAuth)
+									{
+										this.additionalCode('');
+										this.additionalCode.visibility(true);
+										this.additionalCode.focused(true);
 
+										this.submitRequest(false);
+									}
+									else
+									{
+										__webpack_require__(/*! App:RainLoop */ 4).loginAndLogoutReload();
+									}
+								}
+								else if (oData.ErrorCode)
+								{
 									this.submitRequest(false);
+									this.submitError(Utils.getNotification(oData.ErrorCode));
+
+									if ('' === this.submitError())
+									{
+										this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
+									}
 								}
 								else
 								{
-									require('App:RainLoop').loginAndLogoutReload();
-								}
-							}
-							else if (oData.ErrorCode)
-							{
-								this.submitRequest(false);
-								this.submitError(Utils.getNotification(oData.ErrorCode));
-
-								if ('' === this.submitError())
-								{
-									this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
+									this.submitRequest(false);
 								}
 							}
 							else
 							{
 								this.submitRequest(false);
+								this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
+							}
+
+						}, this), this.email(), '', sPassword, !!this.signMe(),
+							this.bSendLanguage ? this.mainLanguage() : '',
+							this.additionalCode.visibility() ? this.additionalCode() : '',
+							this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
+						);
+
+					}, this)
+				;
+
+				if (!!Settings.settingsGet('UseRsaEncryption') && Utils.rsaEncode.supported)
+				{
+					Remote.getPublicKey(_.bind(function (sResult, oData) {
+
+						var bRequest = false;
+						if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
+							Utils.isArray(oData.Result) && oData.Result[0] && oData.Result[1] && oData.Result[2])
+						{
+							var sEncryptedPassword = Utils.rsaEncode(sPassword, oData.Result[0], oData.Result[1], oData.Result[2]);
+							if (sEncryptedPassword)
+							{
+								fLoginRequest(sEncryptedPassword);
+								bRequest = true;
 							}
 						}
-						else
+
+						if (!bRequest)
 						{
 							this.submitRequest(false);
 							this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
 						}
 
-					}, this), this.email(), '', sPassword, !!this.signMe(),
-						this.bSendLanguage ? this.mainLanguage() : '',
-						this.additionalCode.visibility() ? this.additionalCode() : '',
-						this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
-					);
-
-				}, this)
-			;
-
-			if (!!Settings.settingsGet('UseRsaEncryption') && Utils.rsaEncode.supported)
-			{
-				Remote.getPublicKey(_.bind(function (sResult, oData) {
-
-					var bRequest = false;
-					if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
-						Utils.isArray(oData.Result) && oData.Result[0] && oData.Result[1] && oData.Result[2])
-					{
-						var sEncryptedPassword = Utils.rsaEncode(sPassword, oData.Result[0], oData.Result[1], oData.Result[2]);
-						if (sEncryptedPassword)
-						{
-							fLoginRequest(sEncryptedPassword);
-							bRequest = true;
-						}
-					}
-
-					if (!bRequest)
-					{
-						this.submitRequest(false);
-						this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
-					}
-
-				}, this));
-			}
-			else
-			{
-				fLoginRequest(sPassword);
-			}
-
-			return true;
-
-		}, function () {
-			return !this.submitRequest();
-		});
-
-		this.facebookLoginEnabled = ko.observable(false);
-
-		this.facebookCommand = Utils.createCommand(this, function () {
-
-			window.open(LinkBuilder.socialFacebook(), 'Facebook',
-				'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
-			return true;
-
-		}, function () {
-			return !this.submitRequest() && this.facebookLoginEnabled();
-		});
-
-		this.googleLoginEnabled = ko.observable(false);
-
-		this.googleCommand = Utils.createCommand(this, function () {
-
-			window.open(LinkBuilder.socialGoogle(), 'Google',
-				'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
-			return true;
-
-		}, function () {
-			return !this.submitRequest() && this.googleLoginEnabled();
-		});
-
-		this.twitterLoginEnabled = ko.observable(false);
-
-		this.twitterCommand = Utils.createCommand(this, function () {
-
-			window.open(LinkBuilder.socialTwitter(), 'Twitter',
-				'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
-
-			return true;
-
-		}, function () {
-			return !this.submitRequest() && this.twitterLoginEnabled();
-		});
-
-		this.socialLoginEnabled = ko.computed(function () {
-
-			var
-				bF = this.facebookLoginEnabled(),
-				bG = this.googleLoginEnabled(),
-				bT = this.twitterLoginEnabled()
-			;
-
-			return bF || bG || bT;
-		}, this);
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:RainLoop:Login', 'LoginViewModel'], LoginViewModel);
-	_.extend(LoginViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	LoginViewModel.prototype.onShow = function ()
-	{
-		kn.routeOff();
-
-		_.delay(_.bind(function () {
-			if ('' !== this.email() && '' !== this.password())
-			{
-				this.submitFocus(true);
-			}
-			else
-			{
-				this.emailFocus(true);
-			}
-
-			if (Settings.settingsGet('UserLanguage'))
-			{
-				$.cookie('rllang', Data.language(), {'expires': 30});
-			}
-
-		}, this), 100);
-	};
-
-	LoginViewModel.prototype.onHide = function ()
-	{
-		this.submitFocus(false);
-		this.emailFocus(false);
-	};
-
-	LoginViewModel.prototype.onBuild = function ()
-	{
-		var
-			self = this,
-			sJsHash = Settings.settingsGet('JsHash'),
-			fSocial = function (iErrorCode) {
-				iErrorCode = Utils.pInt(iErrorCode);
-				if (0 === iErrorCode)
-				{
-					self.submitRequest(true);
-					require('App:RainLoop').loginAndLogoutReload();
+					}, this));
 				}
 				else
 				{
-					self.submitError(Utils.getNotification(iErrorCode));
-				}
-			}
-		;
-
-		this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
-		this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
-		this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial'));
-
-		switch ((Settings.settingsGet('SignMe') || 'unused').toLowerCase())
-		{
-			case Enums.LoginSignMeTypeAsString.DefaultOff:
-				this.signMeType(Enums.LoginSignMeType.DefaultOff);
-				break;
-			case Enums.LoginSignMeTypeAsString.DefaultOn:
-				this.signMeType(Enums.LoginSignMeType.DefaultOn);
-				break;
-			default:
-			case Enums.LoginSignMeTypeAsString.Unused:
-				this.signMeType(Enums.LoginSignMeType.Unused);
-				break;
-		}
-
-		this.email(Data.devEmail);
-		this.password(Data.devPassword);
-
-		if (this.googleLoginEnabled())
-		{
-			window['rl_' + sJsHash + '_google_login_service'] = fSocial;
-		}
-
-		if (this.facebookLoginEnabled())
-		{
-			window['rl_' + sJsHash + '_facebook_login_service'] = fSocial;
-		}
-
-		if (this.twitterLoginEnabled())
-		{
-			window['rl_' + sJsHash + '_twitter_login_service'] = fSocial;
-		}
-
-		_.delay(function () {
-			Data.language.subscribe(function (sValue) {
-				self.langRequest(true);
-				$.ajax({
-					'url': LinkBuilder.langLink(sValue),
-					'dataType': 'script',
-					'cache': true
-				}).done(function() {
-					self.bSendLanguage = true;
-					Utils.i18nReload();
-					$.cookie('rllang', Data.language(), {'expires': 30});
-				}).always(function() {
-					self.langRequest(false);
-				});
-			});
-		}, 50);
-
-		Utils.triggerAutocompleteInputChange(true);
-	};
-
-	LoginViewModel.prototype.submitForm = function ()
-	{
-		this.submitCommand();
-	};
-
-	LoginViewModel.prototype.selectLanguage = function ()
-	{
-		kn.showScreenPopup(require('View:Popup:Languages'));
-	};
-
-	module.exports = LoginViewModel;
-
-}(module, require));
-},{"$":20,"App:Knoin":27,"App:RainLoop":3,"Enums":7,"Knoin:AbstractViewModel":30,"LinkBuilder":11,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,"Utils":14,"View:Popup:Languages":90,"_":25,"ko":22,"window":26}],73:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		window = require('window'),
-		_ = require('_'),
-		$ = require('$'),
-		ko = require('ko'),
-		key = require('key'),
-
-		Utils = require('Utils'),
-		Enums = require('Enums'),
-		Globals = require('Globals'),
-		LinkBuilder = require('LinkBuilder'),
-
-		Settings = require('Storage:Settings'),
-		Cache = require('Storage:RainLoop:Cache'),
-		Data = require('Storage:RainLoop:Data'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function MailBoxFolderListViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Left', 'MailFolderList');
-
-		this.oContentVisible = null;
-		this.oContentScrollable = null;
-
-		this.messageList = Data.messageList;
-		this.folderList = Data.folderList;
-		this.folderListSystem = Data.folderListSystem;
-		this.foldersChanging = Data.foldersChanging;
-
-		this.leftPanelDisabled = Globals.leftPanelDisabled;
-
-		this.iDropOverTimer = 0;
-
-		this.allowContacts = !!Settings.settingsGet('ContactsIsAllowed');
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:RainLoop:MailBoxFolderList', 'MailBoxFolderListViewModel'], MailBoxFolderListViewModel);
-	_.extend(MailBoxFolderListViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	MailBoxFolderListViewModel.prototype.onBuild = function (oDom)
-	{
-		this.oContentVisible = $('.b-content', oDom);
-		this.oContentScrollable = $('.content', this.oContentVisible);
-
-		var self = this;
-
-		oDom
-			.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function (oEvent) {
-
-				var
-					oFolder = ko.dataFor(this),
-					bCollapsed = false
-				;
-
-				if (oFolder && oEvent)
-				{
-					bCollapsed = oFolder.collapsed();
-					require('App:RainLoop').setExpandedFolder(oFolder.fullNameHash, bCollapsed);
-
-					oFolder.collapsed(!bCollapsed);
-					oEvent.preventDefault();
-					oEvent.stopPropagation();
-				}
-			})
-			.on('click', '.b-folders .e-item .e-link.selectable', function (oEvent) {
-
-				oEvent.preventDefault();
-
-				var
-					oFolder = ko.dataFor(this)
-				;
-
-				if (oFolder)
-				{
-					if (Enums.Layout.NoPreview === Data.layout())
-					{
-						Data.message(null);
-					}
-
-					if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw())
-					{
-						Cache.setFolderHash(oFolder.fullNameRaw, '');
-					}
-
-					kn.setHash(LinkBuilder.mailBox(oFolder.fullNameHash));
-				}
-			})
-		;
-
-		key('up, down', Enums.KeyState.FolderList, function (event, handler) {
-
-			var
-				iIndex = -1,
-				iKeyCode = handler && 'up' === handler.shortcut ? 38 : 40,
-				$items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom)
-			;
-
-			if (event && $items.length)
-			{
-				iIndex = $items.index($items.filter('.focused'));
-				if (-1 < iIndex)
-				{
-					$items.eq(iIndex).removeClass('focused');
+					fLoginRequest(sPassword);
 				}
 
-				if (iKeyCode === 38 && iIndex > 0)
-				{
-					iIndex--;
-				}
-				else if (iKeyCode === 40 && iIndex < $items.length - 1)
-				{
-					iIndex++;
-				}
-
-				$items.eq(iIndex).addClass('focused');
-				self.scrollToFocused();
-			}
-
-			return false;
-		});
-
-		key('enter', Enums.KeyState.FolderList, function () {
-			var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
-			if ($items.length && $items[0])
-			{
-				self.folderList.focused(false);
-				$items.click();
-			}
-
-			return false;
-		});
-
-		key('space', Enums.KeyState.FolderList, function () {
-			var bCollapsed = true, oFolder = null, $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
-			if ($items.length && $items[0])
-			{
-				oFolder = ko.dataFor($items[0]);
-				if (oFolder)
-				{
-					bCollapsed = oFolder.collapsed();
-					require('App:RainLoop').setExpandedFolder(oFolder.fullNameHash, bCollapsed);
-					oFolder.collapsed(!bCollapsed);
-				}
-			}
-
-			return false;
-		});
-
-		key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function () {
-			self.folderList.focused(false);
-			return false;
-		});
-
-		self.folderList.focused.subscribe(function (bValue) {
-			$('.b-folders .e-item .e-link.focused', oDom).removeClass('focused');
-			if (bValue)
-			{
-				$('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
-			}
-		});
-	};
-
-	MailBoxFolderListViewModel.prototype.messagesDropOver = function (oFolder)
-	{
-		window.clearTimeout(this.iDropOverTimer);
-		if (oFolder && oFolder.collapsed())
-		{
-			this.iDropOverTimer = window.setTimeout(function () {
-				oFolder.collapsed(false);
-				require('App:RainLoop').setExpandedFolder(oFolder.fullNameHash, true);
-				Utils.windowResize();
-			}, 500);
-		}
-	};
-
-	MailBoxFolderListViewModel.prototype.messagesDropOut = function ()
-	{
-		window.clearTimeout(this.iDropOverTimer);
-	};
-
-	MailBoxFolderListViewModel.prototype.scrollToFocused = function ()
-	{
-		if (!this.oContentVisible || !this.oContentScrollable)
-		{
-			return false;
-		}
-
-		var
-			iOffset = 20,
-			oFocused = $('.e-item .e-link.focused', this.oContentScrollable),
-			oPos = oFocused.position(),
-			iVisibleHeight = this.oContentVisible.height(),
-			iFocusedHeight = oFocused.outerHeight()
-		;
-
-		if (oPos && (oPos.top < 0 || oPos.top + iFocusedHeight > iVisibleHeight))
-		{
-			if (oPos.top < 0)
-			{
-				this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
-			}
-			else
-			{
-				this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
-			}
-
-			return true;
-		}
-
-		return false;
-	};
-
-	/**
-	 *
-	 * @param {FolderModel} oToFolder
-	 * @param {{helper:jQuery}} oUi
-	 */
-	MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi)
-	{
-		if (oToFolder && oUi && oUi.helper)
-		{
-			var
-				sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
-				bCopy = Globals.$html.hasClass('rl-ctrl-key-pressed'),
-				aUids = oUi.helper.data('rl-uids')
-			;
-
-			if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
-			{
-				require('App:RainLoop').moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
-			}
-		}
-	};
-
-	MailBoxFolderListViewModel.prototype.composeClick = function ()
-	{
-		kn.showScreenPopup(require('View:Popup:Compose'));
-	};
-
-	MailBoxFolderListViewModel.prototype.createFolder = function ()
-	{
-		kn.showScreenPopup(require('View:Popup:FolderCreate'));
-	};
-
-	MailBoxFolderListViewModel.prototype.configureFolders = function ()
-	{
-		kn.setHash(LinkBuilder.settings('folders'));
-	};
-
-	MailBoxFolderListViewModel.prototype.contactsClick = function ()
-	{
-		if (this.allowContacts)
-		{
-			kn.showScreenPopup(require('View:Popup:Contacts'));
-		}
-	};
-
-	module.exports = MailBoxFolderListViewModel;
-
-}(module, require));
-
-},{"$":20,"App:Knoin":27,"App:RainLoop":3,"Enums":7,"Globals":9,"Knoin:AbstractViewModel":30,"LinkBuilder":11,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:Settings":69,"Utils":14,"View:Popup:Compose":82,"View:Popup:Contacts":83,"View:Popup:FolderCreate":86,"_":25,"key":21,"ko":22,"window":26}],74:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		$ = require('$'),
-		ko = require('ko'),
-		key = require('key'),
-		Jua = require('Jua'),
-		ifvisible = require('ifvisible'),
-
-		Enums = require('Enums'),
-		Consts = require('Consts'),
-		Globals = require('Globals'),
-		Utils = require('Utils'),
-		LinkBuilder = require('LinkBuilder'),
-		Events = require('Events'),
-		Selector = require('Selector'),
-
-		Settings = require('Storage:Settings'),
-		Cache = require('Storage:RainLoop:Cache'),
-		Data = require('Storage:RainLoop:Data'),
-		Remote = require('Storage:RainLoop:Remote'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function MailBoxMessageListViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Right', 'MailMessageList');
-
-		this.sLastUid = null;
-		this.bPrefetch = false;
-		this.emptySubjectValue = '';
-
-		this.hideDangerousActions = !!Settings.settingsGet('HideDangerousActions');
-
-		this.popupVisibility = Globals.popupVisibility;
-
-		this.message = Data.message;
-		this.messageList = Data.messageList;
-		this.folderList = Data.folderList;
-		this.currentMessage = Data.currentMessage;
-		this.isMessageSelected = Data.isMessageSelected;
-		this.messageListSearch = Data.messageListSearch;
-		this.messageListError = Data.messageListError;
-		this.folderMenuForMove = Data.folderMenuForMove;
-
-		this.useCheckboxesInList = Data.useCheckboxesInList;
-
-		this.mainMessageListSearch = Data.mainMessageListSearch;
-		this.messageListEndFolder = Data.messageListEndFolder;
-
-		this.messageListChecked = Data.messageListChecked;
-		this.messageListCheckedOrSelected = Data.messageListCheckedOrSelected;
-		this.messageListCheckedOrSelectedUidsWithSubMails = Data.messageListCheckedOrSelectedUidsWithSubMails;
-		this.messageListCompleteLoadingThrottle = Data.messageListCompleteLoadingThrottle;
-
-		Utils.initOnStartOrLangChange(function () {
-			this.emptySubjectValue = Utils.i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT');
-		}, this);
-
-		this.userQuota = Data.userQuota;
-		this.userUsageSize = Data.userUsageSize;
-		this.userUsageProc = Data.userUsageProc;
-
-		this.moveDropdownTrigger = ko.observable(false);
-		this.moreDropdownTrigger = ko.observable(false);
-
-		// append drag and drop
-		this.dragOver = ko.observable(false).extend({'throttle': 1});
-		this.dragOverEnter = ko.observable(false).extend({'throttle': 1});
-		this.dragOverArea = ko.observable(null);
-		this.dragOverBodyArea = ko.observable(null);
-
-		this.messageListItemTemplate = ko.computed(function () {
-			return Enums.Layout.NoPreview !== Data.layout() ?
-				'MailMessageListItem' : 'MailMessageListItemNoPreviewPane';
-		});
-
-		this.messageListSearchDesc = ko.computed(function () {
-			var sValue = Data.messageListEndSearch();
-			return '' === sValue ? '' : Utils.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue});
-		});
-
-		this.messageListPagenator = ko.computed(Utils.computedPagenatorHelper(Data.messageListPage, Data.messageListPageCount));
-
-		this.checkAll = ko.computed({
-			'read': function () {
-				return 0 < Data.messageListChecked().length;
-			},
-
-			'write': function (bValue) {
-				bValue = !!bValue;
-				_.each(Data.messageList(), function (oMessage) {
-					oMessage.checked(bValue);
-				});
-			}
-		});
-
-		this.inputMessageListSearchFocus = ko.observable(false);
-
-		this.sLastSearchValue = '';
-		this.inputProxyMessageListSearch = ko.computed({
-			'read': this.mainMessageListSearch,
-			'write': function (sValue) {
-				this.sLastSearchValue = sValue;
-			},
-			'owner': this
-		});
-
-		this.isIncompleteChecked = ko.computed(function () {
-			var
-				iM = Data.messageList().length,
-				iC = Data.messageListChecked().length
-			;
-			return 0 < iM && 0 < iC && iM > iC;
-		}, this);
-
-		this.hasMessages = ko.computed(function () {
-			return 0 < this.messageList().length;
-		}, this);
-
-		this.hasCheckedOrSelectedLines = ko.computed(function () {
-			return 0 < this.messageListCheckedOrSelected().length;
-		}, this);
-
-		this.isSpamFolder = ko.computed(function () {
-			return Data.spamFolder() === this.messageListEndFolder() &&
-				'' !== Data.spamFolder();
-		}, this);
-
-		this.isSpamDisabled = ko.computed(function () {
-			return Consts.Values.UnuseOptionValue === Data.spamFolder();
-		}, this);
-
-		this.isTrashFolder = ko.computed(function () {
-			return Data.trashFolder() === this.messageListEndFolder() &&
-				'' !== Data.trashFolder();
-		}, this);
-
-		this.isDraftFolder = ko.computed(function () {
-			return Data.draftFolder() === this.messageListEndFolder() &&
-				'' !== Data.draftFolder();
-		}, this);
-
-		this.isSentFolder = ko.computed(function () {
-			return Data.sentFolder() === this.messageListEndFolder() &&
-				'' !== Data.sentFolder();
-		}, this);
-
-		this.isArchiveFolder = ko.computed(function () {
-			return Data.archiveFolder() === this.messageListEndFolder() &&
-				'' !== Data.archiveFolder();
-		}, this);
-
-		this.isArchiveDisabled = ko.computed(function () {
-			return Consts.Values.UnuseOptionValue === Data.archiveFolder();
-		}, this);
-
-		this.canBeMoved = this.hasCheckedOrSelectedLines;
-
-		this.clearCommand = Utils.createCommand(this, function () {
-			kn.showScreenPopup(require('View:Popup:FolderClear'), [Data.currentFolder()]);
-		});
-
-		this.multyForwardCommand = Utils.createCommand(this, function () {
-			kn.showScreenPopup(require('View:Popup:Compose'), [
-				Enums.ComposeType.ForwardAsAttachment, Data.messageListCheckedOrSelected()]);
-		}, this.canBeMoved);
-
-		this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
-			require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Trash,
-				Data.currentFolderFullNameRaw(),
-				Data.messageListCheckedOrSelectedUidsWithSubMails(), false);
-		}, this.canBeMoved);
-
-		this.deleteCommand = Utils.createCommand(this, function () {
-			require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Trash,
-				Data.currentFolderFullNameRaw(),
-				Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
-		}, this.canBeMoved);
-
-		this.archiveCommand = Utils.createCommand(this, function () {
-			require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Archive,
-				Data.currentFolderFullNameRaw(),
-				Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
-		}, this.canBeMoved);
-
-		this.spamCommand = Utils.createCommand(this, function () {
-			require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Spam,
-				Data.currentFolderFullNameRaw(),
-				Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
-		}, this.canBeMoved);
-
-		this.notSpamCommand = Utils.createCommand(this, function () {
-			require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.NotSpam,
-				Data.currentFolderFullNameRaw(),
-				Data.messageListCheckedOrSelectedUidsWithSubMails(), true);
-		}, this.canBeMoved);
-
-		this.moveCommand = Utils.createCommand(this, Utils.emptyFunction, this.canBeMoved);
-
-		this.reloadCommand = Utils.createCommand(this, function () {
-			if (!Data.messageListCompleteLoadingThrottle())
-			{
-				require('App:RainLoop').reloadMessageList(false, true);
-			}
-		});
-
-		this.quotaTooltip = _.bind(this.quotaTooltip, this);
-
-		this.selector = new Selector(this.messageList, this.currentMessage,
-			'.messageListItem .actionHandle', '.messageListItem.selected', '.messageListItem .checkboxMessage',
-				'.messageListItem.focused');
-
-		this.selector.on('onItemSelect', _.bind(function (oMessage) {
-			if (oMessage)
-			{
-				Data.message(Data.staticMessageList.populateByMessageListItem(oMessage));
-				this.populateMessageBody(Data.message());
-
-				if (Enums.Layout.NoPreview === Data.layout())
-				{
-					kn.setHash(LinkBuilder.messagePreview(), true);
-					Data.message.focused(true);
-				}
-			}
-			else
-			{
-				Data.message(null);
-			}
-		}, this));
-
-		this.selector.on('onItemGetUid', function (oMessage) {
-			return oMessage ? oMessage.generateUid() : '';
-		});
-
-		Data.messageListEndHash.subscribe(function () {
-			this.selector.scrollToTop();
-		}, this);
-
-		Data.layout.subscribe(function (mValue) {
-			this.selector.autoSelect(Enums.Layout.NoPreview !== mValue);
-		}, this);
-
-		Data.layout.valueHasMutated();
-
-		Events
-			.sub('mailbox.message-list.selector.go-down', function () {
-				this.selector.goDown(true);
-			}, this)
-			.sub('mailbox.message-list.selector.go-up', function () {
-				this.selector.goUp(true);
-			}, this)
-		;
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:RainLoop:MailBoxMessageList', 'MailBoxMessageListViewModel'], MailBoxMessageListViewModel);
-	_.extend(MailBoxMessageListViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	/**
-	 * @type {string}
-	 */
-	MailBoxMessageListViewModel.prototype.emptySubjectValue = '';
-
-	MailBoxMessageListViewModel.prototype.searchEnterAction = function ()
-	{
-		this.mainMessageListSearch(this.sLastSearchValue);
-		this.inputMessageListSearchFocus(false);
-	};
-
-	/**
-	 * @returns {string}
-	 */
-	MailBoxMessageListViewModel.prototype.printableMessageCountForDeletion = function ()
-	{
-		var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
-		return 1 < iCnt ? ' (' + (100 > iCnt ? iCnt : '99+') + ')' : '';
-	};
-
-	MailBoxMessageListViewModel.prototype.cancelSearch = function ()
-	{
-		this.mainMessageListSearch('');
-		this.inputMessageListSearchFocus(false);
-	};
-
-	/**
-	 * @param {string} sToFolderFullNameRaw
-	 * @param {boolean} bCopy
-	 * @return {boolean}
-	 */
-	MailBoxMessageListViewModel.prototype.moveSelectedMessagesToFolder = function (sToFolderFullNameRaw, bCopy)
-	{
-		if (this.canBeMoved())
-		{
-			require('App:RainLoop').moveMessagesToFolder(
-				Data.currentFolderFullNameRaw(),
-				Data.messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw, bCopy);
-		}
-
-		return false;
-	};
-
-	MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageListItem)
-	{
-		if (oMessageListItem)
-		{
-			oMessageListItem.checked(true);
-		}
-
-		var
-			oEl = Utils.draggeblePlace(),
-			aUids = Data.messageListCheckedOrSelectedUidsWithSubMails()
-		;
-
-		oEl.data('rl-folder', Data.currentFolderFullNameRaw());
-		oEl.data('rl-uids', aUids);
-		oEl.find('.text').text('' + aUids.length);
-
-		_.defer(function () {
-			var aUids = Data.messageListCheckedOrSelectedUidsWithSubMails();
-
-			oEl.data('rl-uids', aUids);
-			oEl.find('.text').text('' + aUids.length);
-		});
-
-		return oEl;
-	};
-
-	/**
-	 * @param {string} sResult
-	 * @param {AjaxJsonDefaultResponse} oData
-	 * @param {boolean} bCached
-	 */
-	MailBoxMessageListViewModel.prototype.onMessageResponse = function (sResult, oData, bCached)
-	{
-		Data.hideMessageBodies();
-		Data.messageLoading(false);
-
-		if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
-		{
-			Data.setMessage(oData, bCached);
-		}
-		else if (Enums.StorageResultType.Unload === sResult)
-		{
-			Data.message(null);
-			Data.messageError('');
-		}
-		else if (Enums.StorageResultType.Abort !== sResult)
-		{
-			Data.message(null);
-			Data.messageError((oData && oData.ErrorCode ?
-				Utils.getNotification(oData.ErrorCode) :
-				Utils.getNotification(Enums.Notification.UnknownError)));
-		}
-	};
-
-	MailBoxMessageListViewModel.prototype.populateMessageBody = function (oMessage)
-	{
-		if (oMessage)
-		{
-			if (Remote.message(this.onMessageResponse, oMessage.folderFullNameRaw, oMessage.uid))
-			{
-				Data.messageLoading(true);
-			}
-			else
-			{
-				Utils.log('Error: Unknown message request: ' + oMessage.folderFullNameRaw + ' ~ ' + oMessage.uid + ' [e-101]');
-			}
-		}
-	};
-
-	/**
-	 * @param {string} sFolderFullNameRaw
-	 * @param {number} iSetAction
-	 * @param {Array=} aMessages = null
-	 */
-	MailBoxMessageListViewModel.prototype.setAction = function (sFolderFullNameRaw, iSetAction, aMessages)
-	{
-		var
-			aUids = [],
-			oFolder = null,
-			iAlreadyUnread = 0
-		;
-
-		if (Utils.isUnd(aMessages))
-		{
-			aMessages = Data.messageListChecked();
-		}
-
-		aUids = _.map(aMessages, function (oMessage) {
-			return oMessage.uid;
-		});
-
-		if ('' !== sFolderFullNameRaw && 0 < aUids.length)
-		{
-			switch (iSetAction) {
-			case Enums.MessageSetAction.SetSeen:
-				_.each(aMessages, function (oMessage) {
-					if (oMessage.unseen())
-					{
-						iAlreadyUnread++;
-					}
-
-					oMessage.unseen(false);
-					Cache.storeMessageFlagsToCache(oMessage);
-				});
-
-				oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
-				if (oFolder)
-				{
-					oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread);
-				}
-
-				Remote.messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, true);
-				break;
-			case Enums.MessageSetAction.UnsetSeen:
-				_.each(aMessages, function (oMessage) {
-					if (oMessage.unseen())
-					{
-						iAlreadyUnread++;
-					}
-
-					oMessage.unseen(true);
-					Cache.storeMessageFlagsToCache(oMessage);
-				});
-
-				oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
-				if (oFolder)
-				{
-					oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread + aUids.length);
-				}
-				Remote.messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, false);
-				break;
-			case Enums.MessageSetAction.SetFlag:
-				_.each(aMessages, function (oMessage) {
-					oMessage.flagged(true);
-					Cache.storeMessageFlagsToCache(oMessage);
-				});
-				Remote.messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, true);
-				break;
-			case Enums.MessageSetAction.UnsetFlag:
-				_.each(aMessages, function (oMessage) {
-					oMessage.flagged(false);
-					Cache.storeMessageFlagsToCache(oMessage);
-				});
-				Remote.messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, false);
-				break;
-			}
-
-			require('App:RainLoop').reloadFlagsCurrentMessageListAndMessageFromCache();
-		}
-	};
-
-	/**
-	 * @param {string} sFolderFullNameRaw
-	 * @param {number} iSetAction
-	 */
-	MailBoxMessageListViewModel.prototype.setActionForAll = function (sFolderFullNameRaw, iSetAction)
-	{
-		var
-			oFolder = null,
-			aMessages = Data.messageList()
-		;
-
-		if ('' !== sFolderFullNameRaw)
-		{
-			oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
-
-			if (oFolder)
-			{
-				switch (iSetAction) {
-				case Enums.MessageSetAction.SetSeen:
-					oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
-					if (oFolder)
-					{
-						_.each(aMessages, function (oMessage) {
-							oMessage.unseen(false);
-						});
-
-						oFolder.messageCountUnread(0);
-						Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
-					}
-
-					Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, true);
-					break;
-				case Enums.MessageSetAction.UnsetSeen:
-					oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
-					if (oFolder)
-					{
-						_.each(aMessages, function (oMessage) {
-							oMessage.unseen(true);
-						});
-
-						oFolder.messageCountUnread(oFolder.messageCountAll());
-						Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
-					}
-					Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, false);
-					break;
-				}
-
-				require('App:RainLoop').reloadFlagsCurrentMessageListAndMessageFromCache();
-			}
-		}
-	};
-
-	MailBoxMessageListViewModel.prototype.listSetSeen = function ()
-	{
-		this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen, Data.messageListCheckedOrSelected());
-	};
-
-	MailBoxMessageListViewModel.prototype.listSetAllSeen = function ()
-	{
-		this.setActionForAll(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen);
-	};
-
-	MailBoxMessageListViewModel.prototype.listUnsetSeen = function ()
-	{
-		this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetSeen, Data.messageListCheckedOrSelected());
-	};
-
-	MailBoxMessageListViewModel.prototype.listSetFlags = function ()
-	{
-		this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.SetFlag, Data.messageListCheckedOrSelected());
-	};
-
-	MailBoxMessageListViewModel.prototype.listUnsetFlags = function ()
-	{
-		this.setAction(Data.currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetFlag, Data.messageListCheckedOrSelected());
-	};
-
-	MailBoxMessageListViewModel.prototype.flagMessages = function (oCurrentMessage)
-	{
-		var
-			aChecked = this.messageListCheckedOrSelected(),
-			aCheckedUids = []
-		;
-
-		if (oCurrentMessage)
-		{
-			if (0 < aChecked.length)
-			{
-				aCheckedUids = _.map(aChecked, function (oMessage) {
-					return oMessage.uid;
-				});
-			}
-
-			if (0 < aCheckedUids.length && -1 < Utils.inArray(oCurrentMessage.uid, aCheckedUids))
-			{
-				this.setAction(oCurrentMessage.folderFullNameRaw, oCurrentMessage.flagged() ?
-					Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
-			}
-			else
-			{
-				this.setAction(oCurrentMessage.folderFullNameRaw, oCurrentMessage.flagged() ?
-					Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oCurrentMessage]);
-			}
-		}
-	};
-
-	MailBoxMessageListViewModel.prototype.flagMessagesFast = function (bFlag)
-	{
-		var
-			aChecked = this.messageListCheckedOrSelected(),
-			aFlagged = []
-		;
-
-		if (0 < aChecked.length)
-		{
-			aFlagged = _.filter(aChecked, function (oMessage) {
-				return oMessage.flagged();
-			});
-
-			if (Utils.isUnd(bFlag))
-			{
-				this.setAction(aChecked[0].folderFullNameRaw,
-					aChecked.length === aFlagged.length ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
-			}
-			else
-			{
-				this.setAction(aChecked[0].folderFullNameRaw,
-					!bFlag ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
-			}
-		}
-	};
-
-	MailBoxMessageListViewModel.prototype.seenMessagesFast = function (bSeen)
-	{
-		var
-			aChecked = this.messageListCheckedOrSelected(),
-			aUnseen = []
-		;
-
-		if (0 < aChecked.length)
-		{
-			aUnseen = _.filter(aChecked, function (oMessage) {
-				return oMessage.unseen();
-			});
-
-			if (Utils.isUnd(bSeen))
-			{
-				this.setAction(aChecked[0].folderFullNameRaw,
-					0 < aUnseen.length ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked);
-			}
-			else
-			{
-				this.setAction(aChecked[0].folderFullNameRaw,
-					bSeen ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked);
-			}
-		}
-	};
-
-	MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
-	{
-		var self = this;
-
-		this.oContentVisible = $('.b-content', oDom);
-		this.oContentScrollable = $('.content', this.oContentVisible);
-
-		this.oContentVisible.on('click', '.fullThreadHandle', function () {
-			var
-				aList = [],
-				oMessage = ko.dataFor(this)
-			;
-
-			if (oMessage && !oMessage.lastInCollapsedThreadLoading())
-			{
-				Data.messageListThreadFolder(oMessage.folderFullNameRaw);
-
-				aList = Data.messageListThreadUids();
-
-				if (oMessage.lastInCollapsedThread())
-				{
-					aList.push(0 < oMessage.parentUid() ? oMessage.parentUid() : oMessage.uid);
-				}
-				else
-				{
-					aList = _.without(aList, 0 < oMessage.parentUid() ? oMessage.parentUid() : oMessage.uid);
-				}
-
-				Data.messageListThreadUids(_.uniq(aList));
-
-				oMessage.lastInCollapsedThreadLoading(true);
-				oMessage.lastInCollapsedThread(!oMessage.lastInCollapsedThread());
-
-				require('App:RainLoop').reloadMessageList();
-			}
-
-			return false;
-		});
-
-		this.selector.init(this.oContentVisible, this.oContentScrollable, Enums.KeyState.MessageList);
-
-		oDom
-			.on('click', '.messageList .b-message-list-wrapper', function () {
-				if (self.message.focused())
-				{
-					self.message.focused(false);
-				}
-			})
-			.on('click', '.e-pagenator .e-page', function () {
-				var oPage = ko.dataFor(this);
-				if (oPage)
-				{
-					kn.setHash(LinkBuilder.mailBox(
-						Data.currentFolderFullNameHash(),
-						oPage.value,
-						Data.messageListSearch()
-					));
-				}
-			})
-			.on('click', '.messageList .checkboxCkeckAll', function () {
-				self.checkAll(!self.checkAll());
-			})
-			.on('click', '.messageList .messageListItem .flagParent', function () {
-				self.flagMessages(ko.dataFor(this));
-			})
-		;
-
-		this.initUploaderForAppend();
-		this.initShortcuts();
-
-		if (!Globals.bMobileDevice && Settings.capa(Enums.Capa.Prefetch) && ifvisible)
-		{
-			ifvisible.setIdleDuration(10);
-
-			ifvisible.idle(function () {
-				self.prefetchNextTick();
-			});
-		}
-	};
-
-	MailBoxMessageListViewModel.prototype.initShortcuts = function ()
-	{
-		var self = this;
-
-		// disable print
-		key('ctrl+p, command+p', Enums.KeyState.MessageList, function () {
-			return false;
-		});
-
-		// archive (zip)
-		key('z', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			self.archiveCommand();
-			return false;
-		});
-
-		// delete
-		key('delete, shift+delete, shift+3', Enums.KeyState.MessageList, function (event, handler) {
-			if (event)
-			{
-				if (0 < Data.messageListCheckedOrSelected().length)
-				{
-					if (handler && 'shift+delete' === handler.shortcut)
-					{
-						self.deleteWithoutMoveCommand();
-					}
-					else
-					{
-						self.deleteCommand();
-					}
-				}
-
-				return false;
-			}
-		});
-
-		// check mail
-		key('ctrl+r, command+r', [Enums.KeyState.FolderList, Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			self.reloadCommand();
-			return false;
-		});
-
-		// check all
-		key('ctrl+a, command+a', Enums.KeyState.MessageList, function () {
-			self.checkAll(!(self.checkAll() && !self.isIncompleteChecked()));
-			return false;
-		});
-
-		// write/compose (open compose popup)
-		key('w,c', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			kn.showScreenPopup(require('View:Popup:Compose'));
-			return false;
-		});
-
-		// important - star/flag messages
-		key('i', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			self.flagMessagesFast();
-			return false;
-		});
-
-		// move
-		key('m', Enums.KeyState.MessageList, function () {
-			self.moveDropdownTrigger(true);
-			return false;
-		});
-
-		// read
-		key('q', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			self.seenMessagesFast(true);
-			return false;
-		});
-
-		// unread
-		key('u', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			self.seenMessagesFast(false);
-			return false;
-		});
-
-		key('shift+f', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			self.multyForwardCommand();
-			return false;
-		});
-
-		// search input focus
-		key('/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			self.inputMessageListSearchFocus(true);
-			return false;
-		});
-
-		// cancel search
-		key('esc', Enums.KeyState.MessageList, function () {
-			if ('' !== self.messageListSearchDesc())
-			{
-				self.cancelSearch();
-				return false;
-			}
-		});
-
-		// change focused state
-		key('tab, shift+tab, left, right', Enums.KeyState.MessageList, function (event, handler) {
-			if (event && handler && ('shift+tab' === handler.shortcut || 'left' === handler.shortcut))
-			{
-				self.folderList.focused(true);
-			}
-			else if (self.message())
-			{
-				self.message.focused(true);
-			}
-
-			return false;
-		});
-
-		// TODO
-		key('ctrl+left, command+left', Enums.KeyState.MessageView, function () {
-			return false;
-		});
-
-		// TODO
-		key('ctrl+right, command+right', Enums.KeyState.MessageView, function () {
-			return false;
-		});
-	};
-
-	MailBoxMessageListViewModel.prototype.prefetchNextTick = function ()
-	{
-		if (!this.bPrefetch && !ifvisible.now() && this.viewModelVisibility())
-		{
-			var
-				self = this,
-				oMessage = _.find(this.messageList(), function (oMessage) {
-					return oMessage &&
-						!Cache.hasRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
-				})
-			;
-
-			if (oMessage)
-			{
-				this.bPrefetch = true;
-
-				Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
-
-				Remote.message(function (sResult, oData) {
-
-					var bNext = !!(Enums.StorageResultType.Success === sResult && oData && oData.Result);
-
-					_.delay(function () {
-						self.bPrefetch = false;
-						if (bNext)
-						{
-							self.prefetchNextTick();
-						}
-					}, 1000);
-
-				}, oMessage.folderFullNameRaw, oMessage.uid);
-			}
-		}
-	};
-
-	MailBoxMessageListViewModel.prototype.composeClick = function ()
-	{
-		kn.showScreenPopup(require('View:Popup:Compose'));
-	};
-
-	MailBoxMessageListViewModel.prototype.advancedSearchClick = function ()
-	{
-		kn.showScreenPopup(require('View:Popup:AdvancedSearch'));
-	};
-
-	MailBoxMessageListViewModel.prototype.quotaTooltip = function ()
-	{
-		return Utils.i18n('MESSAGE_LIST/QUOTA_SIZE', {
-			'SIZE': Utils.friendlySize(this.userUsageSize()),
-			'PROC': this.userUsageProc(),
-			'LIMIT': Utils.friendlySize(this.userQuota())
-		});
-	};
-
-	MailBoxMessageListViewModel.prototype.initUploaderForAppend = function ()
-	{
-		if (!Settings.settingsGet('AllowAppendMessage') || !this.dragOverArea())
-		{
-			return false;
-		}
-
-		var
-			oJua = new Jua({
-				'action': LinkBuilder.append(),
-				'name': 'AppendFile',
-				'queueSize': 1,
-				'multipleSizeLimit': 1,
-				'disableFolderDragAndDrop': true,
-				'hidden': {
-					'Folder': function () {
-						return Data.currentFolderFullNameRaw();
-					}
-				},
-				'dragAndDropElement': this.dragOverArea(),
-				'dragAndDropBodyElement': this.dragOverBodyArea()
-			})
-		;
-
-		oJua
-			.on('onDragEnter', _.bind(function () {
-				this.dragOverEnter(true);
-			}, this))
-			.on('onDragLeave', _.bind(function () {
-				this.dragOverEnter(false);
-			}, this))
-			.on('onBodyDragEnter', _.bind(function () {
-				this.dragOver(true);
-			}, this))
-			.on('onBodyDragLeave', _.bind(function () {
-				this.dragOver(false);
-			}, this))
-			.on('onSelect', _.bind(function (sUid, oData) {
-				if (sUid && oData && 'message/rfc822' === oData['Type'])
-				{
-					Data.messageListLoading(true);
-					return true;
-				}
-
-				return false;
-			}, this))
-			.on('onComplete', _.bind(function () {
-				require('App:RainLoop').reloadMessageList(true, true);
-			}, this))
-		;
-
-		return !!oJua;
-	};
-
-	module.exports = MailBoxMessageListViewModel;
-
-}(module, require));
-
-},{"$":20,"App:Knoin":27,"App:RainLoop":3,"Consts":6,"Enums":7,"Events":8,"Globals":9,"Jua":16,"Knoin:AbstractViewModel":30,"LinkBuilder":11,"Selector":13,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,"Utils":14,"View:Popup:AdvancedSearch":79,"View:Popup:Compose":82,"View:Popup:FolderClear":85,"_":25,"ifvisible":19,"key":21,"ko":22}],75:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		$ = require('$'),
-		ko = require('ko'),
-		key = require('key'),
-
-		Consts = require('Consts'),
-		Enums = require('Enums'),
-		Globals = require('Globals'),
-		Utils = require('Utils'),
-		Events = require('Events'),
-
-		Cache = require('Storage:RainLoop:Cache'),
-		Data = require('Storage:RainLoop:Data'),
-		Remote = require('Storage:RainLoop:Remote'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function MailBoxMessageViewViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Right', 'MailMessageView');
-
-		var
-			self = this,
-			sLastEmail = '',
-			createCommandHelper = function (sType) {
-				return Utils.createCommand(self, function () {
-					this.replyOrforward(sType);
-				}, self.canBeRepliedOrForwarded);
-			}
-		;
-
-		this.oMessageScrollerDom = null;
-
-		this.message = Data.message;
-		this.currentMessage = Data.currentMessage;
-		this.messageListChecked = Data.messageListChecked;
-		this.hasCheckedMessages = Data.hasCheckedMessages;
-		this.messageListCheckedOrSelectedUidsWithSubMails = Data.messageListCheckedOrSelectedUidsWithSubMails;
-		this.messageLoading = Data.messageLoading;
-		this.messageLoadingThrottle = Data.messageLoadingThrottle;
-		this.messagesBodiesDom = Data.messagesBodiesDom;
-		this.useThreads = Data.useThreads;
-		this.replySameFolder = Data.replySameFolder;
-		this.layout = Data.layout;
-		this.usePreviewPane = Data.usePreviewPane;
-		this.isMessageSelected = Data.isMessageSelected;
-		this.messageActiveDom = Data.messageActiveDom;
-		this.messageError = Data.messageError;
-
-		this.fullScreenMode = Data.messageFullScreenMode;
-
-		this.showFullInfo = ko.observable(false);
-		this.moreDropdownTrigger = ko.observable(false);
-		this.messageDomFocused = ko.observable(false).extend({'rateLimit': 0});
-
-		this.messageVisibility = ko.computed(function () {
-			return !this.messageLoadingThrottle() && !!this.message();
-		}, this);
-
-		this.message.subscribe(function (oMessage) {
-			if (!oMessage)
-			{
-				this.currentMessage(null);
-			}
-		}, this);
-
-		this.canBeRepliedOrForwarded = this.messageVisibility;
-
-		// commands
-		this.closeMessage = Utils.createCommand(this, function () {
-			Data.message(null);
-		});
-
-		this.replyCommand = createCommandHelper(Enums.ComposeType.Reply);
-		this.replyAllCommand = createCommandHelper(Enums.ComposeType.ReplyAll);
-		this.forwardCommand = createCommandHelper(Enums.ComposeType.Forward);
-		this.forwardAsAttachmentCommand = createCommandHelper(Enums.ComposeType.ForwardAsAttachment);
-		this.editAsNewCommand = createCommandHelper(Enums.ComposeType.EditAsNew);
-
-		this.messageVisibilityCommand = Utils.createCommand(this, Utils.emptyFunction, this.messageVisibility);
-
-		this.messageEditCommand = Utils.createCommand(this, function () {
-			this.editMessage();
-		}, this.messageVisibility);
-
-		this.deleteCommand = Utils.createCommand(this, function () {
-			if (this.message())
-			{
-				require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Trash,
-					this.message().folderFullNameRaw,
-					[this.message().uid], true);
-			}
-		}, this.messageVisibility);
-
-		this.deleteWithoutMoveCommand = Utils.createCommand(this, function () {
-			if (this.message())
-			{
-				require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Trash,
-					Data.currentFolderFullNameRaw(),
-					[this.message().uid], false);
-			}
-		}, this.messageVisibility);
-
-		this.archiveCommand = Utils.createCommand(this, function () {
-			if (this.message())
-			{
-				require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Archive,
-					this.message().folderFullNameRaw,
-					[this.message().uid], true);
-			}
-		}, this.messageVisibility);
-
-		this.spamCommand = Utils.createCommand(this, function () {
-			if (this.message())
-			{
-				require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.Spam,
-					this.message().folderFullNameRaw,
-					[this.message().uid], true);
-			}
-		}, this.messageVisibility);
-
-		this.notSpamCommand = Utils.createCommand(this, function () {
-			if (this.message())
-			{
-				require('App:RainLoop').deleteMessagesFromFolder(Enums.FolderType.NotSpam,
-					this.message().folderFullNameRaw,
-					[this.message().uid], true);
-			}
-		}, this.messageVisibility);
-
-		// viewer
-		this.viewHash = '';
-		this.viewSubject = ko.observable('');
-		this.viewFromShort = ko.observable('');
-		this.viewToShort = ko.observable('');
-		this.viewFrom = ko.observable('');
-		this.viewTo = ko.observable('');
-		this.viewCc = ko.observable('');
-		this.viewBcc = ko.observable('');
-		this.viewDate = ko.observable('');
-		this.viewSize = ko.observable('');
-		this.viewMoment = ko.observable('');
-		this.viewLineAsCcc = ko.observable('');
-		this.viewViewLink = ko.observable('');
-		this.viewDownloadLink = ko.observable('');
-		this.viewUserPic = ko.observable(Consts.DataImages.UserDotPic);
-		this.viewUserPicVisible = ko.observable(false);
-
-		this.viewPgpPassword = ko.observable('');
-		this.viewPgpSignedVerifyStatus = ko.computed(function () {
-			return this.message() ? this.message().pgpSignedVerifyStatus() : Enums.SignedVerifyStatus.None;
-		}, this);
-
-		this.viewPgpSignedVerifyUser = ko.computed(function () {
-			return this.message() ? this.message().pgpSignedVerifyUser() : '';
-		}, this);
-
-		this.message.subscribe(function (oMessage) {
-
-			this.messageActiveDom(null);
-
-			this.viewPgpPassword('');
-
-			if (oMessage)
-			{
-				if (this.viewHash !== oMessage.hash)
-				{
-					this.scrollMessageToTop();
-				}
-
-				this.viewHash = oMessage.hash;
-				this.viewSubject(oMessage.subject());
-				this.viewFromShort(oMessage.fromToLine(true, true));
-				this.viewToShort(oMessage.toToLine(true, true));
-				this.viewFrom(oMessage.fromToLine(false));
-				this.viewTo(oMessage.toToLine(false));
-				this.viewCc(oMessage.ccToLine(false));
-				this.viewBcc(oMessage.bccToLine(false));
-				this.viewDate(oMessage.fullFormatDateValue());
-				this.viewSize(oMessage.friendlySize());
-				this.viewMoment(oMessage.momentDate());
-				this.viewLineAsCcc(oMessage.lineAsCcc());
-				this.viewViewLink(oMessage.viewLink());
-				this.viewDownloadLink(oMessage.downloadLink());
-
-				sLastEmail = oMessage.fromAsSingleEmail();
-				Cache.getUserPic(sLastEmail, function (sPic, $sEmail) {
-					if (sPic !== self.viewUserPic() && sLastEmail === $sEmail)
-					{
-						self.viewUserPicVisible(false);
-						self.viewUserPic(Consts.DataImages.UserDotPic);
-						if ('' !== sPic)
-						{
-							self.viewUserPicVisible(true);
-							self.viewUserPic(sPic);
-						}
-					}
-				});
-			}
-			else
-			{
-				this.viewHash = '';
-				this.scrollMessageToTop();
-			}
-
-		}, this);
-
-		this.fullScreenMode.subscribe(function (bValue) {
-			if (bValue)
-			{
-				Globals.$html.addClass('rl-message-fullscreen');
-			}
-			else
-			{
-				Globals.$html.removeClass('rl-message-fullscreen');
-			}
-
-			Utils.windowResize();
-		});
-
-		this.messageLoadingThrottle.subscribe(function (bV) {
-			if (bV)
-			{
-				Utils.windowResize();
-			}
-		});
-
-		this.goUpCommand = Utils.createCommand(this, function () {
-			Events.pub('mailbox.message-list.selector.go-up');
-		});
-
-		this.goDownCommand = Utils.createCommand(this, function () {
-			Events.pub('mailbox.message-list.selector.go-down');
-		});
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:RainLoop:MailBoxMessageView', 'MailBoxMessageViewViewModel'], MailBoxMessageViewViewModel);
-	_.extend(MailBoxMessageViewViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	MailBoxMessageViewViewModel.prototype.isPgpActionVisible = function ()
-	{
-		return Enums.SignedVerifyStatus.Success !== this.viewPgpSignedVerifyStatus();
-	};
-
-	MailBoxMessageViewViewModel.prototype.isPgpStatusVerifyVisible = function ()
-	{
-		return Enums.SignedVerifyStatus.None !== this.viewPgpSignedVerifyStatus();
-	};
-
-	MailBoxMessageViewViewModel.prototype.isPgpStatusVerifySuccess = function ()
-	{
-		return Enums.SignedVerifyStatus.Success === this.viewPgpSignedVerifyStatus();
-	};
-
-	MailBoxMessageViewViewModel.prototype.pgpStatusVerifyMessage = function ()
-	{
-		var sResult = '';
-		switch (this.viewPgpSignedVerifyStatus())
-		{
-			case Enums.SignedVerifyStatus.UnknownPublicKeys:
-				sResult = Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND');
-				break;
-			case Enums.SignedVerifyStatus.UnknownPrivateKey:
-				sResult = Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND');
-				break;
-			case Enums.SignedVerifyStatus.Unverified:
-				sResult = Utils.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE');
-				break;
-			case Enums.SignedVerifyStatus.Error:
-				sResult = Utils.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR');
-				break;
-			case Enums.SignedVerifyStatus.Success:
-				sResult = Utils.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
-					'USER': this.viewPgpSignedVerifyUser()
-				});
-				break;
-		}
-
-		return sResult;
-	};
-
-	MailBoxMessageViewViewModel.prototype.fullScreen = function ()
-	{
-		this.fullScreenMode(true);
-		Utils.windowResize();
-	};
-
-	MailBoxMessageViewViewModel.prototype.unFullScreen = function ()
-	{
-		this.fullScreenMode(false);
-		Utils.windowResize();
-	};
-
-	MailBoxMessageViewViewModel.prototype.toggleFullScreen = function ()
-	{
-		Utils.removeSelection();
-
-		this.fullScreenMode(!this.fullScreenMode());
-		Utils.windowResize();
-	};
-
-	/**
-	 * @param {string} sType
-	 */
-	MailBoxMessageViewViewModel.prototype.replyOrforward = function (sType)
-	{
-		kn.showScreenPopup(require('View:Popup:Compose'), [sType, Data.message()]);
-	};
-
-	MailBoxMessageViewViewModel.prototype.onBuild = function (oDom)
-	{
-		var self = this;
-		this.fullScreenMode.subscribe(function (bValue) {
-			if (bValue)
-			{
-				self.message.focused(true);
-			}
-		}, this);
-
-		$('.attachmentsPlace', oDom).magnificPopup({
-			'delegate': '.magnificPopupImage:visible',
-			'type': 'image',
-			'gallery': {
-				'enabled': true,
-				'preload': [1, 1],
-				'navigateByImgClick': true
-			},
-			'callbacks': {
-				'open': function() {
-					Globals.useKeyboardShortcuts(false);
-				},
-				'close': function() {
-					Globals.useKeyboardShortcuts(true);
-				}
-			},
-			'mainClass': 'mfp-fade',
-			'removalDelay': 400
-		});
-
-		oDom
-			.on('click', 'a', function (oEvent) {
-				// setup maito protocol
-				return !(!!oEvent && 3 !== oEvent['which'] && Utils.mailToHelper($(this).attr('href'), require('View:Popup:Compose')));
-			})
-			.on('click', '.attachmentsPlace .attachmentPreview', function (oEvent) {
-				if (oEvent && oEvent.stopPropagation)
-				{
-					oEvent.stopPropagation();
-				}
-			})
-			.on('click', '.attachmentsPlace .attachmentItem', function () {
-
-				var
-					oAttachment = ko.dataFor(this)
-				;
-
-				if (oAttachment && oAttachment.download)
-				{
-					require('App:RainLoop').download(oAttachment.linkDownload());
-				}
-			})
-		;
-
-		this.message.focused.subscribe(function (bValue) {
-			if (bValue && !Utils.inFocus()) {
-				this.messageDomFocused(true);
-			} else {
-				this.messageDomFocused(false);
-				this.scrollMessageToTop();
-				this.scrollMessageToLeft();
-			}
-		}, this);
-
-		this.messageDomFocused.subscribe(function (bValue) {
-			if (!bValue && Enums.KeyState.MessageView === Globals.keyScope())
-			{
-				this.message.focused(false);
-			}
-		}, this);
-
-		Globals.keyScope.subscribe(function (sValue) {
-			if (Enums.KeyState.MessageView === sValue && this.message.focused())
-			{
-				this.messageDomFocused(true);
-			}
-		}, this);
-
-		this.oMessageScrollerDom = oDom.find('.messageItem .content');
-		this.oMessageScrollerDom = this.oMessageScrollerDom && this.oMessageScrollerDom[0] ? this.oMessageScrollerDom : null;
-
-		this.initShortcuts();
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	MailBoxMessageViewViewModel.prototype.escShortcuts = function ()
-	{
-		if (this.viewModelVisibility() && this.message())
-		{
-			if (this.fullScreenMode())
-			{
-				this.fullScreenMode(false);
-			}
-			else if (Enums.Layout.NoPreview === Data.layout())
-			{
-				this.message(null);
-			}
-			else
-			{
-				this.message.focused(false);
-			}
-
-			return false;
-		}
-	};
-
-	MailBoxMessageViewViewModel.prototype.initShortcuts = function ()
-	{
-		var
-			self = this
-		;
-
-		// exit fullscreen, back
-		key('esc', Enums.KeyState.MessageView, _.bind(this.escShortcuts, this));
-
-		// fullscreen
-		key('enter', Enums.KeyState.MessageView, function () {
-			self.toggleFullScreen();
-			return false;
-		});
-
-		key('enter', Enums.KeyState.MessageList, function () {
-			if (Enums.Layout.NoPreview !== Data.layout() && self.message())
-			{
-				self.toggleFullScreen();
-				return false;
-			}
-		});
-
-		// TODO // more toggle
-	//	key('', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-	//		self.moreDropdownTrigger(true);
-	//		return false;
-	//	});
-
-		// reply
-		key('r', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			if (Data.message())
-			{
-				self.replyCommand();
-				return false;
-			}
-		});
-
-		// replaAll
-		key('a', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			if (Data.message())
-			{
-				self.replyAllCommand();
-				return false;
-			}
-		});
-
-		// forward
-		key('f', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			if (Data.message())
-			{
-				self.forwardCommand();
-				return false;
-			}
-		});
-
-		// message information
-	//	key('i', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-	//		if (oData.message())
-	//		{
-	//			self.showFullInfo(!self.showFullInfo());
-	//			return false;
-	//		}
-	//	});
-
-		// toggle message blockquotes
-		key('b', [Enums.KeyState.MessageList, Enums.KeyState.MessageView], function () {
-			if (Data.message() && Data.message().body)
-			{
-				Data.message().body.find('.rlBlockquoteSwitcher').click();
-				return false;
-			}
-		});
-
-		key('ctrl+left, command+left, ctrl+up, command+up', Enums.KeyState.MessageView, function () {
-			self.goUpCommand();
-			return false;
-		});
-
-		key('ctrl+right, command+right, ctrl+down, command+down', Enums.KeyState.MessageView, function () {
-			self.goDownCommand();
-			return false;
-		});
-
-		// print
-		key('ctrl+p, command+p', Enums.KeyState.MessageView, function () {
-			if (self.message())
-			{
-				self.message().printMessage();
-			}
-
-			return false;
-		});
-
-		// delete
-		key('delete, shift+delete', Enums.KeyState.MessageView, function (event, handler) {
-			if (event)
-			{
-				if (handler && 'shift+delete' === handler.shortcut)
-				{
-					self.deleteWithoutMoveCommand();
-				}
-				else
-				{
-					self.deleteCommand();
-				}
-
-				return false;
-			}
-		});
-
-		// change focused state
-		key('tab, shift+tab, left', Enums.KeyState.MessageView, function (event, handler) {
-			if (!self.fullScreenMode() && self.message() && Enums.Layout.NoPreview !== Data.layout())
-			{
-				if (event && handler && 'left' === handler.shortcut)
-				{
-					if (self.oMessageScrollerDom && 0 < self.oMessageScrollerDom.scrollLeft())
-					{
-						return true;
-					}
-
-					self.message.focused(false);
-				}
-				else
-				{
-					self.message.focused(false);
-				}
-			}
-			else if (self.message() && Enums.Layout.NoPreview === Data.layout() && event && handler && 'left' === handler.shortcut)
-			{
 				return true;
-			}
 
-			return false;
-		});
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	MailBoxMessageViewViewModel.prototype.isDraftFolder = function ()
-	{
-		return Data.message() && Data.draftFolder() === Data.message().folderFullNameRaw;
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	MailBoxMessageViewViewModel.prototype.isSentFolder = function ()
-	{
-		return Data.message() && Data.sentFolder() === Data.message().folderFullNameRaw;
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	MailBoxMessageViewViewModel.prototype.isSpamFolder = function ()
-	{
-		return Data.message() && Data.spamFolder() === Data.message().folderFullNameRaw;
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	MailBoxMessageViewViewModel.prototype.isSpamDisabled = function ()
-	{
-		return Data.message() && Data.spamFolder() === Consts.Values.UnuseOptionValue;
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	MailBoxMessageViewViewModel.prototype.isArchiveFolder = function ()
-	{
-		return Data.message() && Data.archiveFolder() === Data.message().folderFullNameRaw;
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	MailBoxMessageViewViewModel.prototype.isArchiveDisabled = function ()
-	{
-		return Data.message() && Data.archiveFolder() === Consts.Values.UnuseOptionValue;
-	};
-
-	/**
-	 * @return {boolean}
-	 */
-	MailBoxMessageViewViewModel.prototype.isDraftOrSentFolder = function ()
-	{
-		return this.isDraftFolder() || this.isSentFolder();
-	};
-
-	MailBoxMessageViewViewModel.prototype.composeClick = function ()
-	{
-		kn.showScreenPopup(require('View:Popup:Compose'));
-	};
-
-	MailBoxMessageViewViewModel.prototype.editMessage = function ()
-	{
-		if (Data.message())
-		{
-			kn.showScreenPopup(require('View:Popup:Compose'), [Enums.ComposeType.Draft, Data.message()]);
-		}
-	};
-
-	MailBoxMessageViewViewModel.prototype.scrollMessageToTop = function ()
-	{
-		if (this.oMessageScrollerDom)
-		{
-			this.oMessageScrollerDom.scrollTop(0);
-			Utils.windowResize();
-		}
-	};
-
-	MailBoxMessageViewViewModel.prototype.scrollMessageToLeft = function ()
-	{
-		if (this.oMessageScrollerDom)
-		{
-			this.oMessageScrollerDom.scrollLeft(0);
-			Utils.windowResize();
-		}
-	};
-
-	/**
-	 * @param {MessageModel} oMessage
-	 */
-	MailBoxMessageViewViewModel.prototype.showImages = function (oMessage)
-	{
-		if (oMessage && oMessage.showExternalImages)
-		{
-			oMessage.showExternalImages(true);
-		}
-	};
-
-	/**
-	 * @returns {string}
-	 */
-	MailBoxMessageViewViewModel.prototype.printableCheckedMessageCount = function ()
-	{
-		var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
-		return 0 < iCnt ? (100 > iCnt ? iCnt : '99+') : '';
-	};
-
-
-	/**
-	 * @param {MessageModel} oMessage
-	 */
-	MailBoxMessageViewViewModel.prototype.verifyPgpSignedClearMessage = function (oMessage)
-	{
-		if (oMessage)
-		{
-			oMessage.verifyPgpSignedClearMessage();
-		}
-	};
-
-	/**
-	 * @param {MessageModel} oMessage
-	 */
-	MailBoxMessageViewViewModel.prototype.decryptPgpEncryptedMessage = function (oMessage)
-	{
-		if (oMessage)
-		{
-			oMessage.decryptPgpEncryptedMessage(this.viewPgpPassword());
-		}
-	};
-
-	/**
-	 * @param {MessageModel} oMessage
-	 */
-	MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage)
-	{
-		if (oMessage && '' !== oMessage.readReceipt())
-		{
-			Remote.sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
-				oMessage.readReceipt(),
-				Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
-				Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': Data.accountEmail()}));
-
-			oMessage.isReadReceipt(true);
-
-			Cache.storeMessageFlagsToCache(oMessage);
-
-			require('App:RainLoop').reloadFlagsCurrentMessageListAndMessageFromCache();
-		}
-	};
-
-	module.exports = MailBoxMessageViewViewModel;
-
-}(module, require));
-},{"$":20,"App:Knoin":27,"App:RainLoop":3,"Consts":6,"Enums":7,"Events":8,"Globals":9,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"View:Popup:Compose":82,"_":25,"key":21,"ko":22}],76:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		
-		kn = require('App:Knoin'),
-		AbstractSystemDropDownViewModel = require('View:RainLoop:AbstractSystemDropDown')
-	;
-
-	/**
-	 * @constructor
-	 * @extends AbstractSystemDropDownViewModel
-	 */
-	function MailBoxSystemDropDownViewModel()
-	{
-		AbstractSystemDropDownViewModel.call(this);
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:RainLoop:MailBoxSystemDropDown', 'MailBoxSystemDropDownViewModel'], MailBoxSystemDropDownViewModel);
-	_.extend(MailBoxSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype);
-
-	module.exports = MailBoxSystemDropDownViewModel;
-
-}(module, require));
-
-},{"App:Knoin":27,"View:RainLoop:AbstractSystemDropDown":71,"_":25}],77:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		ko = require('ko'),
-
-		Enums = require('Enums'),
-		Utils = require('Utils'),
-
-		Remote = require('Storage:RainLoop:Remote'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function PopupsAddAccountViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddAccount');
-
-		this.email = ko.observable('');
-		this.password = ko.observable('');
-
-		this.emailError = ko.observable(false);
-		this.passwordError = ko.observable(false);
-
-		this.email.subscribe(function () {
-			this.emailError(false);
-		}, this);
-
-		this.password.subscribe(function () {
-			this.passwordError(false);
-		}, this);
-
-		this.submitRequest = ko.observable(false);
-		this.submitError = ko.observable('');
-
-		this.emailFocus = ko.observable(false);
-
-		this.addAccountCommand = Utils.createCommand(this, function () {
-
-			this.emailError('' === Utils.trim(this.email()));
-			this.passwordError('' === Utils.trim(this.password()));
-
-			if (this.emailError() || this.passwordError())
-			{
-				return false;
-			}
-
-			this.submitRequest(true);
-
-			Remote.accountAdd(_.bind(function (sResult, oData) {
-
-				this.submitRequest(false);
-				if (Enums.StorageResultType.Success === sResult && oData && 'AccountAdd' === oData.Action)
-				{
-					if (oData.Result)
-					{
-						require('App:RainLoop').accountsAndIdentities();
-						this.cancelCommand();
-					}
-					else if (oData.ErrorCode)
-					{
-						this.submitError(Utils.getNotification(oData.ErrorCode));
-					}
-				}
-				else
-				{
-					this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
-				}
-
-			}, this), this.email(), '', this.password());
-
-			return true;
-
-		}, function () {
-			return !this.submitRequest();
-		});
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:Popup:AddAccount', 'PopupsAddAccountViewModel'], PopupsAddAccountViewModel);
-	_.extend(PopupsAddAccountViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	PopupsAddAccountViewModel.prototype.clearPopup = function ()
-	{
-		this.email('');
-		this.password('');
-
-		this.emailError(false);
-		this.passwordError(false);
-
-		this.submitRequest(false);
-		this.submitError('');
-	};
-
-	PopupsAddAccountViewModel.prototype.onShow = function ()
-	{
-		this.clearPopup();
-	};
-
-	PopupsAddAccountViewModel.prototype.onFocus = function ()
-	{
-		this.emailFocus(true);
-	};
-
-	module.exports = PopupsAddAccountViewModel;
-
-}(module, require));
-},{"App:Knoin":27,"App:RainLoop":3,"Enums":7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Remote":68,"Utils":14,"_":25,"ko":22}],78:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		ko = require('ko'),
-
-		Utils = require('Utils'),
-
-		Data = require('Storage:RainLoop:Data'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function PopupsAddOpenPgpKeyViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey');
-
-		this.key = ko.observable('');
-		this.key.error = ko.observable(false);
-		this.key.focus = ko.observable(false);
-
-		this.key.subscribe(function () {
-			this.key.error(false);
-		}, this);
-
-		this.addOpenPgpKeyCommand = Utils.createCommand(this, function () {
-
-			var
-				iCount = 30,
-				aMatch = null,
-				sKey = Utils.trim(this.key()),
-				oReg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi,
-				oOpenpgpKeyring = Data.openpgpKeyring
-			;
-
-			sKey = sKey.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g, '\n$1!-!N!-!$2')
-				.replace(/[\n\r]+/g, '\n').replace(/!-!N!-!/g, '\n\n');
-
-			this.key.error('' === sKey);
-
-			if (!oOpenpgpKeyring || this.key.error())
-			{
-				return false;
-			}
-
-			do
-			{
-				aMatch = oReg.exec(sKey);
-				if (!aMatch || 0 > iCount)
-				{
-					break;
-				}
-
-				if (aMatch[0] && aMatch[1] && aMatch[2] && aMatch[1] === aMatch[2])
-				{
-					if ('PRIVATE' === aMatch[1])
-					{
-						oOpenpgpKeyring.privateKeys.importKey(aMatch[0]);
-					}
-					else if ('PUBLIC' === aMatch[1])
-					{
-						oOpenpgpKeyring.publicKeys.importKey(aMatch[0]);
-					}
-				}
-
-				iCount--;
-			}
-			while (true);
-
-			oOpenpgpKeyring.store();
-
-			require('App:RainLoop').reloadOpenPgpKeys();
-			Utils.delegateRun(this, 'cancelCommand');
-
-			return true;
-		});
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:Popup:AddOpenPgpKey', 'PopupsAddOpenPgpKeyViewModel'], PopupsAddOpenPgpKeyViewModel);
-	_.extend(PopupsAddOpenPgpKeyViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function ()
-	{
-		this.key('');
-		this.key.error(false);
-	};
-
-	PopupsAddOpenPgpKeyViewModel.prototype.onShow = function ()
-	{
-		this.clearPopup();
-	};
-
-	PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function ()
-	{
-		this.key.focus(true);
-	};
-
-	module.exports = PopupsAddOpenPgpKeyViewModel;
-
-}(module, require));
-},{"App:Knoin":27,"App:RainLoop":3,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,"Utils":14,"_":25,"ko":22}],79:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		ko = require('ko'),
-		moment = require('moment'),
-
-		Utils = require('Utils'),
-
-		Data = require('Storage:RainLoop:Data'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function PopupsAdvancedSearchViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAdvancedSearch');
-
-		this.fromFocus = ko.observable(false);
-
-		this.from = ko.observable('');
-		this.to = ko.observable('');
-		this.subject = ko.observable('');
-		this.text = ko.observable('');
-		this.selectedDateValue = ko.observable(-1);
-
-		this.hasAttachment = ko.observable(false);
-		this.starred = ko.observable(false);
-		this.unseen = ko.observable(false);
-
-		this.searchCommand = Utils.createCommand(this, function () {
-
-			var sSearch = this.buildSearchString();
-			if ('' !== sSearch)
-			{
-				Data.mainMessageListSearch(sSearch);
-			}
-
-			this.cancelCommand();
-		});
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:Popup:AdvancedSearch', 'PopupsAdvancedSearchViewModel'], PopupsAdvancedSearchViewModel);
-	_.extend(PopupsAdvancedSearchViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	PopupsAdvancedSearchViewModel.prototype.buildSearchStringValue = function (sValue)
-	{
-		if (-1 < sValue.indexOf(' '))
-		{
-			sValue = '"' + sValue + '"';
-		}
-
-		return sValue;
-	};
-
-	PopupsAdvancedSearchViewModel.prototype.buildSearchString = function ()
-	{
-		var
-			aResult = [],
-			sFrom = Utils.trim(this.from()),
-			sTo = Utils.trim(this.to()),
-			sSubject = Utils.trim(this.subject()),
-			sText = Utils.trim(this.text()),
-			aIs = [],
-			aHas = []
-		;
-
-		if (sFrom && '' !== sFrom)
-		{
-			aResult.push('from:' + this.buildSearchStringValue(sFrom));
-		}
-
-		if (sTo && '' !== sTo)
-		{
-			aResult.push('to:' + this.buildSearchStringValue(sTo));
-		}
-
-		if (sSubject && '' !== sSubject)
-		{
-			aResult.push('subject:' + this.buildSearchStringValue(sSubject));
-		}
-
-		if (this.hasAttachment())
-		{
-			aHas.push('attachment');
-		}
-
-		if (this.unseen())
-		{
-			aIs.push('unseen');
-		}
-
-		if (this.starred())
-		{
-			aIs.push('flagged');
-		}
-
-		if (0 < aHas.length)
-		{
-			aResult.push('has:' + aHas.join(','));
-		}
-
-		if (0 < aIs.length)
-		{
-			aResult.push('is:' + aIs.join(','));
-		}
-
-		if (-1 < this.selectedDateValue())
-		{
-			aResult.push('date:' + moment().subtract('days', this.selectedDateValue()).format('YYYY.MM.DD') + '/');
-		}
-
-		if (sText && '' !== sText)
-		{
-			aResult.push('text:' + this.buildSearchStringValue(sText));
-		}
-
-		return Utils.trim(aResult.join(' '));
-	};
-
-	PopupsAdvancedSearchViewModel.prototype.clearPopup = function ()
-	{
-		this.from('');
-		this.to('');
-		this.subject('');
-		this.text('');
-
-		this.selectedDateValue(-1);
-		this.hasAttachment(false);
-		this.starred(false);
-		this.unseen(false);
-
-		this.fromFocus(true);
-	};
-
-	PopupsAdvancedSearchViewModel.prototype.onShow = function ()
-	{
-		this.clearPopup();
-	};
-
-	PopupsAdvancedSearchViewModel.prototype.onFocus = function ()
-	{
-		this.fromFocus(true);
-	};
-
-	module.exports = PopupsAdvancedSearchViewModel;
-
-}(module, require));
-},{"App:Knoin":27,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,"Utils":14,"_":25,"ko":22,"moment":23}],80:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		_ = require('_'),
-		ko = require('ko'),
-		key = require('key'),
-
-		Enums = require('Enums'),
-		Utils = require('Utils'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function PopupsAskViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAsk');
-
-		this.askDesc = ko.observable('');
-		this.yesButton = ko.observable('');
-		this.noButton = ko.observable('');
-
-		this.yesFocus = ko.observable(false);
-		this.noFocus = ko.observable(false);
-
-		this.fYesAction = null;
-		this.fNoAction = null;
-
-		this.bDisabeCloseOnEsc = true;
-		this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:Popup:Ask', 'PopupsAskViewModel'], PopupsAskViewModel);
-	_.extend(PopupsAskViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	PopupsAskViewModel.prototype.clearPopup = function ()
-	{
-		this.askDesc('');
-		this.yesButton(Utils.i18n('POPUPS_ASK/BUTTON_YES'));
-		this.noButton(Utils.i18n('POPUPS_ASK/BUTTON_NO'));
-
-		this.yesFocus(false);
-		this.noFocus(false);
-
-		this.fYesAction = null;
-		this.fNoAction = null;
-	};
-
-	PopupsAskViewModel.prototype.yesClick = function ()
-	{
-		this.cancelCommand();
-
-		if (Utils.isFunc(this.fYesAction))
-		{
-			this.fYesAction.call(null);
-		}
-	};
-
-	PopupsAskViewModel.prototype.noClick = function ()
-	{
-		this.cancelCommand();
-
-		if (Utils.isFunc(this.fNoAction))
-		{
-			this.fNoAction.call(null);
-		}
-	};
-
-	/**
-	 * @param {string} sAskDesc
-	 * @param {Function=} fYesFunc
-	 * @param {Function=} fNoFunc
-	 * @param {string=} sYesButton
-	 * @param {string=} sNoButton
-	 */
-	PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton)
-	{
-		this.clearPopup();
-
-		this.fYesAction = fYesFunc || null;
-		this.fNoAction = fNoFunc || null;
-
-		this.askDesc(sAskDesc || '');
-		if (sYesButton)
-		{
-			this.yesButton(sYesButton);
-		}
-
-		if (sYesButton)
-		{
-			this.yesButton(sNoButton);
-		}
-	};
-
-	PopupsAskViewModel.prototype.onFocus = function ()
-	{
-		this.yesFocus(true);
-	};
-
-	PopupsAskViewModel.prototype.onBuild = function ()
-	{
-		key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function () {
-			if (this.yesFocus())
-			{
-				this.noFocus(true);
-			}
-			else
-			{
-				this.yesFocus(true);
-			}
-			return false;
-		}, this));
-
-		key('esc', Enums.KeyState.PopupAsk, _.bind(function () {
-			this.noClick();
-			return false;
-		}, this));
-	};
-
-	module.exports = PopupsAskViewModel;
-
-}(module, require));
-},{"App:Knoin":27,"Enums":7,"Knoin:AbstractViewModel":30,"Utils":14,"_":25,"key":21,"ko":22}],81:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		window = require('window'),
-		_ = require('_'),
-		ko = require('ko'),
-		key = require('key'),
-
-		Utils = require('Utils'),
-		Enums = require('Enums'),
-
-		Data = require('Storage:RainLoop:Data'),
-
-		EmailModel = require('Model:Email'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function PopupsComposeOpenPgpViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Popups', 'PopupsComposeOpenPgp');
-
-		this.notification = ko.observable('');
-
-		this.sign = ko.observable(true);
-		this.encrypt = ko.observable(true);
-
-		this.password = ko.observable('');
-		this.password.focus = ko.observable(false);
-		this.buttonFocus = ko.observable(false);
-
-		this.from = ko.observable('');
-		this.to = ko.observableArray([]);
-		this.text = ko.observable('');
-
-		this.resultCallback = null;
-
-		this.submitRequest = ko.observable(false);
-
-		// commands
-		this.doCommand = Utils.createCommand(this, function () {
-
-			var
-				self = this,
-				bResult = true,
-				oPrivateKey = null,
-				aPublicKeys = []
-			;
-
-			this.submitRequest(true);
-
-			if (bResult && this.sign() && '' === this.from())
-			{
-				this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_FROM_EMAIL'));
-				bResult = false;
-			}
-
-			if (bResult && this.sign())
-			{
-				oPrivateKey = Data.findPrivateKeyByEmail(this.from(), this.password());
-				if (!oPrivateKey)
-				{
-					this.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
-						'EMAIL': this.from()
-					}));
-
-					bResult = false;
-				}
-			}
-
-			if (bResult && this.encrypt() && 0 === this.to().length)
-			{
-				this.notification(Utils.i18n('PGP_NOTIFICATIONS/SPECIFY_AT_LEAST_ONE_RECIPIENT'));
-				bResult = false;
-			}
-
-			if (bResult && this.encrypt())
-			{
-				aPublicKeys = [];
-				_.each(this.to(), function (sEmail) {
-					var aKeys = Data.findPublicKeysByEmail(sEmail);
-					if (0 === aKeys.length && bResult)
-					{
-						self.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
-							'EMAIL': sEmail
-						}));
-
-						bResult = false;
-					}
-
-					aPublicKeys = aPublicKeys.concat(aKeys);
-				});
-
-				if (bResult && (0 === aPublicKeys.length || this.to().length !== aPublicKeys.length))
-				{
-					bResult = false;
-				}
-			}
-
-			_.delay(function () {
-
-				if (self.resultCallback && bResult)
-				{
-					try {
-
-						if (oPrivateKey && 0 === aPublicKeys.length)
-						{
-							self.resultCallback(
-								window.openpgp.signClearMessage([oPrivateKey], self.text())
-							);
-						}
-						else if (oPrivateKey && 0 < aPublicKeys.length)
-						{
-							self.resultCallback(
-								window.openpgp.signAndEncryptMessage(aPublicKeys, oPrivateKey, self.text())
-							);
-						}
-						else if (!oPrivateKey && 0 < aPublicKeys.length)
-						{
-							self.resultCallback(
-								window.openpgp.encryptMessage(aPublicKeys, self.text())
-							);
-						}
-					}
-					catch (e)
-					{
-						self.notification(Utils.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
-							'ERROR': '' + e
-						}));
-
-						bResult = false;
-					}
-				}
-
-				if (bResult)
-				{
-					self.cancelCommand();
-				}
-
-				self.submitRequest(false);
-
-			}, 10);
-
-		}, function () {
-			return !this.submitRequest() &&	(this.sign() || this.encrypt());
-		});
-
-		this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:Popup:ComposeOpenPgp', 'PopupsComposeOpenPgpViewModel'], PopupsComposeOpenPgpViewModel);
-	_.extend(PopupsComposeOpenPgpViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	PopupsComposeOpenPgpViewModel.prototype.clearPopup = function ()
-	{
-		this.notification('');
-
-		this.password('');
-		this.password.focus(false);
-		this.buttonFocus(false);
-
-		this.from('');
-		this.to([]);
-		this.text('');
-
-		this.submitRequest(false);
-
-		this.resultCallback = null;
-	};
-
-	PopupsComposeOpenPgpViewModel.prototype.onBuild = function ()
-	{
-		key('tab,shift+tab', Enums.KeyState.PopupComposeOpenPGP, _.bind(function () {
-
-			switch (true)
-			{
-				case this.password.focus():
-					this.buttonFocus(true);
-					break;
-				case this.buttonFocus():
-					this.password.focus(true);
-					break;
-			}
-
-			return false;
-
-		}, this));
-	};
-
-	PopupsComposeOpenPgpViewModel.prototype.onHide = function ()
-	{
-		this.clearPopup();
-	};
-
-	PopupsComposeOpenPgpViewModel.prototype.onFocus = function ()
-	{
-		if (this.sign())
-		{
-			this.password.focus(true);
-		}
-		else
-		{
-			this.buttonFocus(true);
-		}
-	};
-
-	PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc)
-	{
-		this.clearPopup();
-
-		var
-			oEmail = new EmailModel(),
-			sResultFromEmail = '',
-			aRec = []
-		;
-
-		this.resultCallback = fCallback;
-
-		oEmail.clear();
-		oEmail.mailsoParse(sFromEmail);
-		if ('' !== oEmail.email)
-		{
-			sResultFromEmail = oEmail.email;
-		}
-
-		if ('' !== sTo)
-		{
-			aRec.push(sTo);
-		}
-
-		if ('' !== sCc)
-		{
-			aRec.push(sCc);
-		}
-
-		if ('' !== sBcc)
-		{
-			aRec.push(sBcc);
-		}
-
-		aRec = aRec.join(', ').split(',');
-		aRec = _.compact(_.map(aRec, function (sValue) {
-			oEmail.clear();
-			oEmail.mailsoParse(Utils.trim(sValue));
-			return '' === oEmail.email ? false : oEmail.email;
-		}));
-
-		this.from(sResultFromEmail);
-		this.to(aRec);
-		this.text(sText);
-	};
-
-	module.exports = PopupsComposeOpenPgpViewModel;
-
-}(module, require));
-},{"App:Knoin":27,"Enums":7,"Knoin:AbstractViewModel":30,"Model:Email":37,"Storage:RainLoop:Data":64,"Utils":14,"_":25,"key":21,"ko":22,"window":26}],82:[function(require,module,exports){
-
-(function (module, require) {
-
-	'use strict';
-
-	var
-		window = require('window'),
-		_ = require('_'),
-		$ = require('$'),
-		ko = require('ko'),
-		moment = require('moment'),
-		JSON = require('JSON'),
-		Jua = require('Jua'),
-
-		Enums = require('Enums'),
-		Consts = require('Consts'),
-		Utils = require('Utils'),
-		Globals = require('Globals'),
-		Events = require('Events'),
-		LinkBuilder = require('LinkBuilder'),
-		HtmlEditor = require('HtmlEditor'),
-
-		Settings = require('Storage:Settings'),
-		Data = require('Storage:RainLoop:Data'),
-		Cache = require('Storage:RainLoop:Cache'),
-		Remote = require('Storage:RainLoop:Remote'),
-
-		ComposeAttachmentModel = require('Model:ComposeAttachment'),
-
-		kn = require('App:Knoin'),
-		KnoinAbstractViewModel = require('Knoin:AbstractViewModel')
-	;
-
-	/**
-	 * @constructor
-	 * @extends KnoinAbstractViewModel
-	 */
-	function PopupsComposeViewModel()
-	{
-		KnoinAbstractViewModel.call(this, 'Popups', 'PopupsCompose');
-
-		this.oEditor = null;
-		this.aDraftInfo = null;
-		this.sInReplyTo = '';
-		this.bFromDraft = false;
-		this.bSkipNext = false;
-		this.sReferences = '';
-
-		this.bCapaAdditionalIdentities = Settings.capa(Enums.Capa.AdditionalIdentities);
-
-		var
-			self = this,
-			fCcAndBccCheckHelper = function (aValue) {
-				if (false === self.showCcAndBcc() && 0 < aValue.length)
-				{
-					self.showCcAndBcc(true);
-				}
-			}
-		;
-
-		this.capaOpenPGP = Data.capaOpenPGP;
-
-		this.resizer = ko.observable(false).extend({'throttle': 50});
-
-		this.identitiesDropdownTrigger = ko.observable(false);
-
-		this.to = ko.observable('');
-		this.to.focusTrigger = ko.observable(false);
-		this.cc = ko.observable('');
-		this.bcc = ko.observable('');
-
-		this.replyTo = ko.observable('');
-		this.subject = ko.observable('');
-		this.isHtml = ko.observable(false);
-
-		this.requestReadReceipt = ko.observable(false);
-
-		this.sendError = ko.observable(false);
-		this.sendSuccessButSaveError = ko.observable(false);
-		this.savedError = ko.observable(false);
-
-		this.savedTime = ko.observable(0);
-		this.savedOrSendingText = ko.observable('');
-
-		this.emptyToError = ko.observable(false);
-		this.attachmentsInProcessError = ko.observable(false);
-		this.showCcAndBcc = ko.observable(false);
-
-		this.cc.subscribe(fCcAndBccCheckHelper, this);
-		this.bcc.subscribe(fCcAndBccCheckHelper, this);
-
-		this.draftFolder = ko.observable('');
-		this.draftUid = ko.observable('');
-		this.sending = ko.observable(false);
-		this.saving = ko.observable(false);
-		this.attachments = ko.observableArray([]);
-
-		this.attachmentsInProcess = this.attachments.filter(function (oItem) {
-			return oItem && '' === oItem.tempName();
-		});
-
-		this.attachmentsInReady = this.attachments.filter(function (oItem) {
-			return oItem && '' !== oItem.tempName();
-		});
-
-		this.attachments.subscribe(function () {
-			this.triggerForResize();
-		}, this);
-
-		this.isDraftFolderMessage = ko.computed(function () {
-			return '' !== this.draftFolder() && '' !== this.draftUid();
-		}, this);
-
-		this.composeUploaderButton = ko.observable(null);
-		this.composeUploaderDropPlace = ko.observable(null);
-		this.dragAndDropEnabled = ko.observable(false);
-		this.dragAndDropOver = ko.observable(false).extend({'throttle': 1});
-		this.dragAndDropVisible = ko.observable(false).extend({'throttle': 1});
-		this.attacheMultipleAllowed = ko.observable(false);
-		this.addAttachmentEnabled = ko.observable(false);
-
-		this.composeEditorArea = ko.observable(null);
-
-		this.identities = Data.identities;
-		this.defaultIdentityID = Data.defaultIdentityID;
-		this.currentIdentityID = ko.observable('');
-
-		this.currentIdentityString = ko.observable('');
-		this.currentIdentityResultEmail = ko.observable('');
-
-		this.identitiesOptions = ko.computed(function () {
-
-			var aList = [{
-				'optValue': Data.accountEmail(),
-				'optText': this.formattedFrom(false)
-			}];
-
-			_.each(Data.identities(), function (oItem) {
-				aList.push({
-					'optValue': oItem.id,
-					'optText': oItem.formattedNameForCompose()
-				});
+			}, function () {
+				return !this.submitRequest();
 			});
 
-			return aList;
+			this.facebookLoginEnabled = ko.observable(false);
 
-		}, this);
+			this.facebookCommand = Utils.createCommand(this, function () {
 
-		ko.computed(function () {
+				window.open(LinkBuilder.socialFacebook(), 'Facebook',
+					'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
+				return true;
 
-			var
-				sResult = '',
-				sResultEmail = '',
-				oItem = null,
-				aList = this.identities(),
-				sID = this.currentIdentityID()
-			;
-
-			if (this.bCapaAdditionalIdentities && sID && sID !== Data.accountEmail())
-			{
-				oItem = _.find(aList, function (oItem) {
-					return oItem && sID === oItem['id'];
-				});
-
-				sResult = oItem ? oItem.formattedNameForCompose() : '';
-				sResultEmail = oItem ? oItem.formattedNameForEmail() : '';
-
-				if ('' === sResult && aList[0])
-				{
-					this.currentIdentityID(aList[0]['id']);
-					return '';
-				}
-			}
-
-			if ('' === sResult)
-			{
-				sResult = this.formattedFrom(false);
-				sResultEmail = this.formattedFrom(true);
-			}
-
-			this.currentIdentityString(sResult);
-			this.currentIdentityResultEmail(sResultEmail);
-
-			return sResult;
-
-		}, this);
-
-		this.to.subscribe(function (sValue) {
-			if (this.emptyToError() && 0 < sValue.length)
-			{
-				this.emptyToError(false);
-			}
-		}, this);
-
-		this.attachmentsInProcess.subscribe(function (aValue) {
-			if (this.attachmentsInProcessError() && Utils.isArray(aValue) && 0 === aValue.length)
-			{
-				this.attachmentsInProcessError(false);
-			}
-		}, this);
-
-		this.editorResizeThrottle = _.throttle(_.bind(this.editorResize, this), 100);
-
-		this.resizer.subscribe(function () {
-			this.editorResizeThrottle();
-		}, this);
-
-		this.canBeSendedOrSaved = ko.computed(function () {
-			return !this.sending() && !this.saving();
-		}, this);
-
-		this.deleteCommand = Utils.createCommand(this, function () {
-
-			require('App:RainLoop').deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]);
-			kn.hideScreenPopup(PopupsComposeViewModel);
-
-		}, function () {
-			return this.isDraftFolderMessage();
-		});
-
-		this.sendMessageResponse = _.bind(this.sendMessageResponse, this);
-		this.saveMessageResponse = _.bind(this.saveMessageResponse, this);
-
-		this.sendCommand = Utils.createCommand(this, function () {
-			var
-				sTo = Utils.trim(this.to()),
-				sSentFolder = Data.sentFolder(),
-				aFlagsCache = []
-			;
-
-			if (0 < this.attachmentsInProcess().length)
-			{
-				this.attachmentsInProcessError(true);
-			}
-			else if (0 === sTo.length)
-			{
-				this.emptyToError(true);
-			}
-			else
-			{
-				if (Data.replySameFolder())
-				{
-					if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && Utils.isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length)
-					{
-						sSentFolder = this.aDraftInfo[2];
-					}
-				}
-
-				if ('' === sSentFolder)
-				{
-					kn.showScreenPopup(require('View:Popup:FolderSystem'), [Enums.SetSystemFoldersNotification.Sent]);
-				}
-				else
-				{
-					this.sendError(false);
-					this.sending(true);
-
-					if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length)
-					{
-						aFlagsCache = Cache.getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]);
-						if (aFlagsCache)
-						{
-							if ('forward' === this.aDraftInfo[0])
-							{
-								aFlagsCache[3] = true;
-							}
-							else
-							{
-								aFlagsCache[2] = true;
-							}
-
-							Cache.setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], aFlagsCache);
-							require('App:RainLoop').reloadFlagsCurrentMessageListAndMessageFromCache();
-							Cache.setFolderHash(this.aDraftInfo[2], '');
-						}
-					}
-
-					sSentFolder = Consts.Values.UnuseOptionValue === sSentFolder ? '' : sSentFolder;
-
-					Cache.setFolderHash(this.draftFolder(), '');
-					Cache.setFolderHash(sSentFolder, '');
-
-					Remote.sendMessage(
-						this.sendMessageResponse,
-						this.draftFolder(),
-						this.draftUid(),
-						sSentFolder,
-						this.currentIdentityResultEmail(),
-						sTo,
-						this.cc(),
-						this.bcc(),
-						this.subject(),
-						this.oEditor ? this.oEditor.isHtml() : false,
-						this.oEditor ? this.oEditor.getData(true) : '',
-						this.prepearAttachmentsForSendOrSave(),
-						this.aDraftInfo,
-						this.sInReplyTo,
-						this.sReferences,
-						this.requestReadReceipt()
-					);
-				}
-			}
-		}, this.canBeSendedOrSaved);
-
-		this.saveCommand = Utils.createCommand(this, function () {
-
-			if (Data.draftFolderNotEnabled())
-			{
-				kn.showScreenPopup(require('View:Popup:FolderSystem'), [Enums.SetSystemFoldersNotification.Draft]);
-			}
-			else
-			{
-				this.savedError(false);
-				this.saving(true);
-
-				this.bSkipNext = true;
-
-				Cache.setFolderHash(Data.draftFolder(), '');
-
-				Remote.saveMessage(
-					this.saveMessageResponse,
-					this.draftFolder(),
-					this.draftUid(),
-					Data.draftFolder(),
-					this.currentIdentityResultEmail(),
-					this.to(),
-					this.cc(),
-					this.bcc(),
-					this.subject(),
-					this.oEditor ? this.oEditor.isHtml() : false,
-					this.oEditor ? this.oEditor.getData(true) : '',
-					this.prepearAttachmentsForSendOrSave(),
-					this.aDraftInfo,
-					this.sInReplyTo,
-					this.sReferences
-				);
-			}
-
-		}, this.canBeSendedOrSaved);
-
-		Events.sub('interval.1m', function () {
-			if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) &&
-				!this.bSkipNext && !this.saving() && !this.sending() && !this.savedError())
-			{
-				this.bSkipNext = false;
-				this.saveCommand();
-			}
-		}, this);
-
-		this.showCcAndBcc.subscribe(function () {
-			this.triggerForResize();
-		}, this);
-
-		this.dropboxEnabled = ko.observable(!!Settings.settingsGet('DropboxApiKey'));
-
-		this.dropboxCommand = Utils.createCommand(this, function () {
-
-			if (window.Dropbox)
-			{
-				window.Dropbox.choose({
-					//'iframe': true,
-					'success': function(aFiles) {
-
-						if (aFiles && aFiles[0] && aFiles[0]['link'])
-						{
-							self.addDropboxAttachment(aFiles[0]);
-						}
-					},
-					'linkType': "direct",
-					'multiselect': false
-				});
-			}
-
-			return true;
-
-		}, function () {
-			return this.dropboxEnabled();
-		});
-
-		this.driveEnabled = ko.observable(Globals.bXMLHttpRequestSupported &&
-			!!Settings.settingsGet('GoogleClientID') && !!Settings.settingsGet('GoogleApiKey'));
-
-		this.driveVisible = ko.observable(false);
-
-		this.driveCommand = Utils.createCommand(this, function () {
-
-			this.driveOpenPopup();
-			return true;
-
-		}, function () {
-			return this.driveEnabled();
-		});
-
-		this.driveCallback = _.bind(this.driveCallback, this);
-
-		this.bDisabeCloseOnEsc = true;
-		this.sDefaultKeyScope = Enums.KeyState.Compose;
-
-		this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
-
-		this.emailsSource = _.bind(this.emailsSource, this);
-
-		kn.constructorEnd(this);
-	}
-
-	kn.extendAsViewModel(['View:Popup:Compose', 'PopupsComposeViewModel'], PopupsComposeViewModel);
-	_.extend(PopupsComposeViewModel.prototype, KnoinAbstractViewModel.prototype);
-
-	PopupsComposeViewModel.prototype.emailsSource = function (oData, fResponse)
-	{
-		require('App:RainLoop').getAutocomplete(oData.term, function (aData) {
-			fResponse(_.map(aData, function (oEmailItem) {
-				return oEmailItem.toLine(false);
-			}));
-		});
-	};
-
-	PopupsComposeViewModel.prototype.openOpenPgpPopup = function ()
-	{
-		if (this.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml())
-		{
-			var self = this;
-			kn.showScreenPopup(require('View:Popup:ComposeOpenPgp'), [
-				function (sResult) {
-					self.editor(function (oEditor) {
-						oEditor.setPlain(sResult);
-					});
-				},
-				this.oEditor.getData(),
-				this.currentIdentityResultEmail(),
-				this.to(),
-				this.cc(),
-				this.bcc()
-			]);
-		}
-	};
-
-	PopupsComposeViewModel.prototype.reloadDraftFolder = function ()
-	{
-		var
-			sDraftFolder = Data.draftFolder()
-		;
-
-		if ('' !== sDraftFolder)
-		{
-			Cache.setFolderHash(sDraftFolder, '');
-			if (Data.currentFolderFullNameRaw() === sDraftFolder)
-			{
-				require('App:RainLoop').reloadMessageList(true);
-			}
-			else
-			{
-				require('App:RainLoop').folderInformation(sDraftFolder);
-			}
-		}
-	};
-
-	PopupsComposeViewModel.prototype.findIdentityIdByMessage = function (sComposeType, oMessage)
-	{
-		var
-			oIDs = {},
-			sResult = '',
-			fFindHelper = function (oItem) {
-				if (oItem && oItem.email && oIDs[oItem.email])
-				{
-					sResult = oIDs[oItem.email];
-					return true;
-				}
-
-				return false;
-			}
-		;
-
-		if (this.bCapaAdditionalIdentities)
-		{
-			_.each(this.identities(), function (oItem) {
-				oIDs[oItem.email()] = oItem['id'];
+			}, function () {
+				return !this.submitRequest() && this.facebookLoginEnabled();
 			});
-		}
 
-		oIDs[Data.accountEmail()] = Data.accountEmail();
+			this.googleLoginEnabled = ko.observable(false);
 
-		if (oMessage)
-		{
-			switch (sComposeType)
-			{
-				case Enums.ComposeType.Empty:
-					break;
-				case Enums.ComposeType.Reply:
-				case Enums.ComposeType.ReplyAll:
-				case Enums.ComposeType.Forward:
-				case Enums.ComposeType.ForwardAsAttachment:
-					_.find(_.union(oMessage.to, oMessage.cc, oMessage.bcc, oMessage.deliveredTo), fFindHelper);
-					break;
-				case Enums.ComposeType.Draft:
-					_.find(_.union(oMessage.from, oMessage.replyTo), fFindHelper);
-					break;
-			}
-		}
+			this.googleCommand = Utils.createCommand(this, function () {
 
-		if ('' === sResult)
-		{
-			sResult = this.defaultIdentityID();
-		}
+				window.open(LinkBuilder.socialGoogle(), 'Google',
+					'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
+				return true;
 
-		if ('' === sResult)
-		{
-			sResult = Data.accountEmail();
-		}
+			}, function () {
+				return !this.submitRequest() && this.googleLoginEnabled();
+			});
 
-		return sResult;
-	};
+			this.twitterLoginEnabled = ko.observable(false);
 
-	PopupsComposeViewModel.prototype.selectIdentity = function (oIdentity)
-	{
-		if (oIdentity)
-		{
-			this.currentIdentityID(oIdentity.optValue);
-		}
-	};
+			this.twitterCommand = Utils.createCommand(this, function () {
 
-	/**
-	 *
-	 * @param {boolean=} bHeaderResult = false
-	 * @returns {string}
-	 */
-	PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult)
-	{
-		var
-			sDisplayName = Data.displayName(),
-			sEmail = Data.accountEmail()
-		;
+				window.open(LinkBuilder.socialTwitter(), 'Twitter',
+					'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
 
-		return '' === sDisplayName ? sEmail :
-			((Utils.isUnd(bHeaderResult) ? false : !!bHeaderResult) ?
-				'"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>' :
-				sDisplayName + ' (' + sEmail + ')')
-		;
-	};
+				return true;
 
-	PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
-	{
-		var
-			bResult = false,
-			sMessage = ''
-		;
+			}, function () {
+				return !this.submitRequest() && this.twitterLoginEnabled();
+			});
 
-		this.sending(false);
-
-		if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
-		{
-			bResult = true;
-			if (this.modalVisibility())
-			{
-				Utils.delegateRun(this, 'closeCommand');
-			}
-		}
-
-		if (this.modalVisibility() && !bResult)
-		{
-			if (oData && Enums.Notification.CantSaveMessage === oData.ErrorCode)
-			{
-				this.sendSuccessButSaveError(true);
-				window.alert(Utils.trim(Utils.i18n('COMPOSE/SAVED_ERROR_ON_SEND')));
-			}
-			else
-			{
-				sMessage = Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage,
-					oData && oData.ErrorMessage ? oData.ErrorMessage : '');
-
-				this.sendError(true);
-				window.alert(sMessage || Utils.getNotification(Enums.Notification.CantSendMessage));
-			}
-		}
-
-		this.reloadDraftFolder();
-	};
-
-	PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData)
-	{
-		var
-			bResult = false,
-			oMessage = null
-		;
-
-		this.saving(false);
-
-		if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
-		{
-			if (oData.Result.NewFolder && oData.Result.NewUid)
-			{
-				if (this.bFromDraft)
-				{
-					oMessage = Data.message();
-					if (oMessage && this.draftFolder() === oMessage.folderFullNameRaw && this.draftUid() === oMessage.uid)
-					{
-						Data.message(null);
-					}
-				}
-
-				this.draftFolder(oData.Result.NewFolder);
-				this.draftUid(oData.Result.NewUid);
-
-				if (this.modalVisibility())
-				{
-					this.savedTime(window.Math.round((new window.Date()).getTime() / 1000));
-
-					this.savedOrSendingText(
-						0 < this.savedTime() ? Utils.i18n('COMPOSE/SAVED_TIME', {
-							'TIME': moment.unix(this.savedTime() - 1).format('LT')
-						}) : ''
-					);
-
-					bResult = true;
-
-					if (this.bFromDraft)
-					{
-						Cache.setFolderHash(this.draftFolder(), '');
-					}
-				}
-			}
-		}
-
-		if (!this.modalVisibility() && !bResult)
-		{
-			this.savedError(true);
-			this.savedOrSendingText(Utils.getNotification(Enums.Notification.CantSaveMessage));
-		}
-
-		this.reloadDraftFolder();
-	};
-
-	PopupsComposeViewModel.prototype.onHide = function ()
-	{
-		this.reset();
-		kn.routeOn();
-	};
-
-	/**
-	 * @param {string} sSignature
-	 * @param {string=} sFrom
-	 * @param {string=} sData
-	 * @param {string=} sComposeType
-	 * @return {string}
-	 */
-	PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom, sData, sComposeType)
-	{
-		var bHtml = false, bData = false;
-		if ('' !== sSignature)
-		{
-			if (':HTML:' === sSignature.substr(0, 6))
-			{
-				bHtml = true;
-				sSignature = sSignature.substr(6);
-			}
-
-			sSignature = sSignature.replace(/[\r]/g, '');
-
-			sFrom = Utils.pString(sFrom);
-			if ('' !== sFrom)
-			{
-				sSignature = sSignature.replace(/{{FROM}}/g, sFrom);
-			}
-
-			sSignature = sSignature.replace(/[\s]{1,2}{{FROM}}/g, '{{FROM}}');
-
-			sSignature = sSignature.replace(/{{FROM}}/g, '');
-			sSignature = sSignature.replace(/{{DATE}}/g, moment().format('llll'));
-
-			if (sData && Enums.ComposeType.Empty === sComposeType &&
-				-1 < sSignature.indexOf('{{DATA}}'))
-			{
-				bData = true;
-				sSignature = sSignature.replace('{{DATA}}', sData);
-			}
-
-			sSignature = sSignature.replace(/{{DATA}}/g, '');
-
-			if (!bHtml)
-			{
-				sSignature = Utils.convertPlainTextToHtml(sSignature);
-			}
-		}
-
-		if (sData && !bData)
-		{
-			switch (sComposeType)
-			{
-				case Enums.ComposeType.Empty:
-					sSignature = sData + '
' + sSignature; - break; - default: - sSignature = sSignature + '
' + sData; - break; - } - } - - return sSignature; - }; - - PopupsComposeViewModel.prototype.editor = function (fOnInit) - { - if (fOnInit) - { - var self = this; - if (!this.oEditor && this.composeEditorArea()) - { - _.delay(function () { - self.oEditor = new HtmlEditor(self.composeEditorArea(), null, function () { - fOnInit(self.oEditor); - }, function (bHtml) { - self.isHtml(!!bHtml); - }); - }, 300); - } - else if (this.oEditor) - { - fOnInit(this.oEditor); - } - } - }; - - /** - * @param {string=} sType = Enums.ComposeType.Empty - * @param {?MessageModel|Array=} oMessageOrArray = null - * @param {Array=} aToEmails = null - * @param {string=} sCustomSubject = null - * @param {string=} sCustomPlainText = null - */ - PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToEmails, sCustomSubject, sCustomPlainText) - { - kn.routeOff(); - - var - self = this, - sFrom = '', - sTo = '', - sCc = '', - sDate = '', - sSubject = '', - oText = null, - sText = '', - sReplyTitle = '', - aResplyAllParts = [], - oExcludeEmail = {}, - mEmail = Data.accountEmail(), - sSignature = Data.signature(), - bSignatureToAll = Data.signatureToAll(), - aDownloads = [], - aDraftInfo = null, - oMessage = null, - sComposeType = sType || Enums.ComposeType.Empty, - fEmailArrayToStringLineHelper = function (aList, bFriendly) { + this.socialLoginEnabled = ko.computed(function () { var - iIndex = 0, - iLen = aList.length, - aResult = [] + bF = this.facebookLoginEnabled(), + bG = this.googleLoginEnabled(), + bT = this.twitterLoginEnabled() ; - for (; iIndex < iLen; iIndex++) + return bF || bG || bT; + }, this); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:RainLoop:Login', 'LoginViewModel'], LoginViewModel); + _.extend(LoginViewModel.prototype, KnoinAbstractViewModel.prototype); + + LoginViewModel.prototype.onShow = function () + { + kn.routeOff(); + + _.delay(_.bind(function () { + if ('' !== this.email() && '' !== this.password()) { - aResult.push(aList[iIndex].toLine(!!bFriendly)); - } - - return aResult.join(', '); - } - ; - - oMessageOrArray = oMessageOrArray || null; - if (oMessageOrArray && Utils.isNormal(oMessageOrArray)) - { - oMessage = Utils.isArray(oMessageOrArray) && 1 === oMessageOrArray.length ? oMessageOrArray[0] : - (!Utils.isArray(oMessageOrArray) ? oMessageOrArray : null); - } - - if (null !== mEmail) - { - oExcludeEmail[mEmail] = true; - } - - this.currentIdentityID(this.findIdentityIdByMessage(sComposeType, oMessage)); - this.reset(); - - if (Utils.isNonEmptyArray(aToEmails)) - { - this.to(fEmailArrayToStringLineHelper(aToEmails)); - } - - if ('' !== sComposeType && oMessage) - { - sDate = oMessage.fullFormatDateValue(); - sSubject = oMessage.subject(); - aDraftInfo = oMessage.aDraftInfo; - - oText = $(oMessage.body).clone(); - if (oText) - { - oText.find('blockquote.rl-bq-switcher').each(function () { - $(this).removeClass('rl-bq-switcher hidden-bq'); - }); - oText.find('.rlBlockquoteSwitcher').each(function () { - $(this).remove(); - }); - } - - oText.find('[data-html-editor-font-wrapper]').removeAttr('data-html-editor-font-wrapper'); - sText = oText.html(); - - switch (sComposeType) - { - case Enums.ComposeType.Empty: - break; - - case Enums.ComposeType.Reply: - this.to(fEmailArrayToStringLineHelper(oMessage.replyEmails(oExcludeEmail))); - this.subject(Utils.replySubjectAdd('Re', sSubject)); - this.prepearMessageAttachments(oMessage, sComposeType); - this.aDraftInfo = ['reply', oMessage.uid, oMessage.folderFullNameRaw]; - this.sInReplyTo = oMessage.sMessageId; - this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences); - break; - - case Enums.ComposeType.ReplyAll: - aResplyAllParts = oMessage.replyAllEmails(oExcludeEmail); - this.to(fEmailArrayToStringLineHelper(aResplyAllParts[0])); - this.cc(fEmailArrayToStringLineHelper(aResplyAllParts[1])); - this.subject(Utils.replySubjectAdd('Re', sSubject)); - this.prepearMessageAttachments(oMessage, sComposeType); - this.aDraftInfo = ['reply', oMessage.uid, oMessage.folderFullNameRaw]; - this.sInReplyTo = oMessage.sMessageId; - this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.references()); - break; - - case Enums.ComposeType.Forward: - this.subject(Utils.replySubjectAdd('Fwd', sSubject)); - this.prepearMessageAttachments(oMessage, sComposeType); - this.aDraftInfo = ['forward', oMessage.uid, oMessage.folderFullNameRaw]; - this.sInReplyTo = oMessage.sMessageId; - this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences); - break; - - case Enums.ComposeType.ForwardAsAttachment: - this.subject(Utils.replySubjectAdd('Fwd', sSubject)); - this.prepearMessageAttachments(oMessage, sComposeType); - this.aDraftInfo = ['forward', oMessage.uid, oMessage.folderFullNameRaw]; - this.sInReplyTo = oMessage.sMessageId; - this.sReferences = Utils.trim(this.sInReplyTo + ' ' + oMessage.sReferences); - break; - - case Enums.ComposeType.Draft: - this.to(fEmailArrayToStringLineHelper(oMessage.to)); - this.cc(fEmailArrayToStringLineHelper(oMessage.cc)); - this.bcc(fEmailArrayToStringLineHelper(oMessage.bcc)); - - this.bFromDraft = true; - - this.draftFolder(oMessage.folderFullNameRaw); - this.draftUid(oMessage.uid); - - this.subject(sSubject); - this.prepearMessageAttachments(oMessage, sComposeType); - - this.aDraftInfo = Utils.isNonEmptyArray(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null; - this.sInReplyTo = oMessage.sInReplyTo; - this.sReferences = oMessage.sReferences; - break; - - case Enums.ComposeType.EditAsNew: - this.to(fEmailArrayToStringLineHelper(oMessage.to)); - this.cc(fEmailArrayToStringLineHelper(oMessage.cc)); - this.bcc(fEmailArrayToStringLineHelper(oMessage.bcc)); - - this.subject(sSubject); - this.prepearMessageAttachments(oMessage, sComposeType); - - this.aDraftInfo = Utils.isNonEmptyArray(aDraftInfo) && 3 === aDraftInfo.length ? aDraftInfo : null; - this.sInReplyTo = oMessage.sInReplyTo; - this.sReferences = oMessage.sReferences; - break; - } - - switch (sComposeType) - { - case Enums.ComposeType.Reply: - case Enums.ComposeType.ReplyAll: - sFrom = oMessage.fromToLine(false, true); - sReplyTitle = Utils.i18n('COMPOSE/REPLY_MESSAGE_TITLE', { - 'DATETIME': sDate, - 'EMAIL': sFrom - }); - - sText = '

' + sReplyTitle + ':' + - '

' + sText + '

'; - - break; - - case Enums.ComposeType.Forward: - sFrom = oMessage.fromToLine(false, true); - sTo = oMessage.toToLine(false, true); - sCc = oMessage.ccToLine(false, true); - sText = '


' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_TITLE') + - '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_FROM') + ': ' + sFrom + - '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_TO') + ': ' + sTo + - (0 < sCc.length ? '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_CC') + ': ' + sCc : '') + - '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_SENT') + ': ' + Utils.encodeHtml(sDate) + - '
' + Utils.i18n('COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT') + ': ' + Utils.encodeHtml(sSubject) + - '

' + sText; - break; - case Enums.ComposeType.ForwardAsAttachment: - sText = ''; - break; - } - - if (bSignatureToAll && '' !== sSignature && - Enums.ComposeType.EditAsNew !== sComposeType && Enums.ComposeType.Draft !== sComposeType) - { - sText = this.convertSignature(sSignature, fEmailArrayToStringLineHelper(oMessage.from, true), sText, sComposeType); - } - - this.editor(function (oEditor) { - oEditor.setHtml(sText, false); - if (!oMessage.isHtml()) - { - oEditor.modeToggle(false); - } - }); - } - else if (Enums.ComposeType.Empty === sComposeType) - { - this.subject(Utils.isNormal(sCustomSubject) ? '' + sCustomSubject : ''); - - sText = Utils.isNormal(sCustomPlainText) ? '' + sCustomPlainText : ''; - if (bSignatureToAll && '' !== sSignature) - { - sText = this.convertSignature(sSignature, '', - Utils.convertPlainTextToHtml(sText), sComposeType); - } - - this.editor(function (oEditor) { - oEditor.setHtml(sText, false); - if (Enums.EditorDefaultType.Html !== Data.editorDefaultType()) - { - oEditor.modeToggle(false); - } - }); - } - else if (Utils.isNonEmptyArray(oMessageOrArray)) - { - _.each(oMessageOrArray, function (oMessage) { - self.addMessageAsAttachment(oMessage); - }); - } - - aDownloads = this.getAttachmentsDownloadsForUpload(); - if (Utils.isNonEmptyArray(aDownloads)) - { - Remote.messageUploadAttachments(function (sResult, oData) { - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - var - oAttachment = null, - sTempName = '' - ; - - if (!self.viewModelVisibility()) - { - for (sTempName in oData.Result) - { - if (oData.Result.hasOwnProperty(sTempName)) - { - oAttachment = self.getAttachmentById(oData.Result[sTempName]); - if (oAttachment) - { - oAttachment.tempName(sTempName); - } - } - } - } + this.submitFocus(true); } else { - self.setMessageAttachmentFailedDowbloadText(); + this.emailFocus(true); } - }, aDownloads); - } - - this.triggerForResize(); - }; - - PopupsComposeViewModel.prototype.onFocus = function () - { - if ('' === this.to()) - { - this.to.focusTrigger(!this.to.focusTrigger()); - } - else if (this.oEditor) - { - this.oEditor.focus(); - } - - this.triggerForResize(); - }; - - PopupsComposeViewModel.prototype.editorResize = function () - { - if (this.oEditor) - { - this.oEditor.resize(); - } - }; - - PopupsComposeViewModel.prototype.tryToClosePopup = function () - { - var - self = this, - PopupsAskViewModel = require('View:Popup:Ask') - ; - - if (!kn.isPopupVisible(PopupsAskViewModel)) - { - kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () { - if (self.modalVisibility()) + if (Settings.settingsGet('UserLanguage')) { - Utils.delegateRun(self, 'closeCommand'); - } - }]); - } - }; - - PopupsComposeViewModel.prototype.onBuild = function () - { - this.initUploader(); - - var - self = this, - oScript = null - ; - - key('ctrl+q, command+q', Enums.KeyState.Compose, function () { - self.identitiesDropdownTrigger(true); - return false; - }); - - key('ctrl+s, command+s', Enums.KeyState.Compose, function () { - self.saveCommand(); - return false; - }); - - key('ctrl+enter, command+enter', Enums.KeyState.Compose, function () { - self.sendCommand(); - return false; - }); - - key('esc', Enums.KeyState.Compose, function () { - if (self.modalVisibility()) - { - self.tryToClosePopup(); - } - return false; - }); - - Globals.$win.on('resize', function () { - self.triggerForResize(); - }); - - if (this.dropboxEnabled()) - { - oScript = window.document.createElement('script'); - oScript.type = 'text/javascript'; - oScript.src = 'https://www.dropbox.com/static/api/1/dropins.js'; - $(oScript).attr('id', 'dropboxjs').attr('data-app-key', Settings.settingsGet('DropboxApiKey')); - - window.document.body.appendChild(oScript); - } - - if (this.driveEnabled()) - { - $.getScript('https://apis.google.com/js/api.js', function () { - if (window.gapi) - { - self.driveVisible(true); - } - }); - } - }; - - PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData) - { - if (oData && window.XMLHttpRequest && window.google && - oData[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED && - oData[window.google.picker.Response.DOCUMENTS] && oData[window.google.picker.Response.DOCUMENTS][0] && - oData[window.google.picker.Response.DOCUMENTS][0]['id']) - { - var - self = this, - oRequest = new window.XMLHttpRequest() - ; - - oRequest.open('GET', 'https://www.googleapis.com/drive/v2/files/' + oData[window.google.picker.Response.DOCUMENTS][0]['id']); - oRequest.setRequestHeader('Authorization', 'Bearer ' + sAccessToken); - oRequest.addEventListener('load', function() { - if (oRequest && oRequest.responseText) - { - var oItem = JSON.parse(oRequest.responseText), fExport = function (oItem, sMimeType, sExt) { - if (oItem && oItem['exportLinks']) - { - if (oItem['exportLinks'][sMimeType]) - { - oItem['downloadUrl'] = oItem['exportLinks'][sMimeType]; - oItem['title'] = oItem['title'] + '.' + sExt; - oItem['mimeType'] = sMimeType; - } - else if (oItem['exportLinks']['application/pdf']) - { - oItem['downloadUrl'] = oItem['exportLinks']['application/pdf']; - oItem['title'] = oItem['title'] + '.pdf'; - oItem['mimeType'] = 'application/pdf'; - } - } - }; - - if (oItem && !oItem['downloadUrl'] && oItem['mimeType'] && oItem['exportLinks']) - { - switch (oItem['mimeType'].toString().toLowerCase()) - { - case 'application/vnd.google-apps.document': - fExport(oItem, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'docx'); - break; - case 'application/vnd.google-apps.spreadsheet': - fExport(oItem, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsx'); - break; - case 'application/vnd.google-apps.drawing': - fExport(oItem, 'image/png', 'png'); - break; - case 'application/vnd.google-apps.presentation': - fExport(oItem, 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pptx'); - break; - default: - fExport(oItem, 'application/pdf', 'pdf'); - break; - } - } - - if (oItem && oItem['downloadUrl']) - { - self.addDriveAttachment(oItem, sAccessToken); - } - } - }); - - oRequest.send(); - } - }; - - PopupsComposeViewModel.prototype.driveCreatePiker = function (oOauthToken) - { - if (window.gapi && oOauthToken && oOauthToken.access_token) - { - var self = this; - - window.gapi.load('picker', {'callback': function () { - - if (window.google && window.google.picker) - { - var drivePicker = new window.google.picker.PickerBuilder() - .addView( - new window.google.picker.DocsView() - .setIncludeFolders(true) - ) - .setAppId(Settings.settingsGet('GoogleClientID')) - .setOAuthToken(oOauthToken.access_token) - .setCallback(_.bind(self.driveCallback, self, oOauthToken.access_token)) - .enableFeature(window.google.picker.Feature.NAV_HIDDEN) - .build() - ; - - drivePicker.setVisible(true); - } - }}); - } - }; - - PopupsComposeViewModel.prototype.driveOpenPopup = function () - { - if (window.gapi) - { - var self = this; - - window.gapi.load('auth', {'callback': function () { - - var oAuthToken = window.gapi.auth.getToken(); - if (!oAuthToken) - { - window.gapi.auth.authorize({ - 'client_id': Settings.settingsGet('GoogleClientID'), - 'scope': 'https://www.googleapis.com/auth/drive.readonly', - 'immediate': true - }, function (oAuthResult) { - if (oAuthResult && !oAuthResult.error) - { - var oAuthToken = window.gapi.auth.getToken(); - if (oAuthToken) - { - self.driveCreatePiker(oAuthToken); - } - } - else - { - window.gapi.auth.authorize({ - 'client_id': Settings.settingsGet('GoogleClientID'), - 'scope': 'https://www.googleapis.com/auth/drive.readonly', - 'immediate': false - }, function (oAuthResult) { - if (oAuthResult && !oAuthResult.error) - { - var oAuthToken = window.gapi.auth.getToken(); - if (oAuthToken) - { - self.driveCreatePiker(oAuthToken); - } - } - }); - } - }); - } - else - { - self.driveCreatePiker(oAuthToken); - } - }}); - } - }; - - /** - * @param {string} sId - * @return {?Object} - */ - PopupsComposeViewModel.prototype.getAttachmentById = function (sId) - { - var - aAttachments = this.attachments(), - iIndex = 0, - iLen = aAttachments.length - ; - - for (; iIndex < iLen; iIndex++) - { - if (aAttachments[iIndex] && sId === aAttachments[iIndex].id) - { - return aAttachments[iIndex]; - } - } - - return null; - }; - - PopupsComposeViewModel.prototype.initUploader = function () - { - if (this.composeUploaderButton()) - { - var - oUploadCache = {}, - iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')), - oJua = new Jua({ - 'action': LinkBuilder.upload(), - 'name': 'uploader', - 'queueSize': 2, - 'multipleSizeLimit': 50, - 'disableFolderDragAndDrop': false, - 'clickElement': this.composeUploaderButton(), - 'dragAndDropElement': this.composeUploaderDropPlace() - }) - ; - - if (oJua) - { - oJua - // .on('onLimitReached', function (iLimit) { - // alert(iLimit); - // }) - .on('onDragEnter', _.bind(function () { - this.dragAndDropOver(true); - }, this)) - .on('onDragLeave', _.bind(function () { - this.dragAndDropOver(false); - }, this)) - .on('onBodyDragEnter', _.bind(function () { - this.dragAndDropVisible(true); - }, this)) - .on('onBodyDragLeave', _.bind(function () { - this.dragAndDropVisible(false); - }, this)) - .on('onProgress', _.bind(function (sId, iLoaded, iTotal) { - var oItem = null; - if (Utils.isUnd(oUploadCache[sId])) - { - oItem = this.getAttachmentById(sId); - if (oItem) - { - oUploadCache[sId] = oItem; - } - } - else - { - oItem = oUploadCache[sId]; - } - - if (oItem) - { - oItem.progress(' - ' + window.Math.floor(iLoaded / iTotal * 100) + '%'); - } - - }, this)) - .on('onSelect', _.bind(function (sId, oData) { - - this.dragAndDropOver(false); - - var - that = this, - sFileName = Utils.isUnd(oData.FileName) ? '' : oData.FileName.toString(), - mSize = Utils.isNormal(oData.Size) ? Utils.pInt(oData.Size) : null, - oAttachment = new ComposeAttachmentModel(sId, sFileName, mSize) - ; - - oAttachment.cancel = (function (sId) { - - return function () { - that.attachments.remove(function (oItem) { - return oItem && oItem.id === sId; - }); - - if (oJua) - { - oJua.cancel(sId); - } - }; - - }(sId)); - - this.attachments.push(oAttachment); - - if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize) - { - oAttachment.error(Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG')); - return false; - } - - return true; - - }, this)) - .on('onStart', _.bind(function (sId) { - - var - oItem = null - ; - - if (Utils.isUnd(oUploadCache[sId])) - { - oItem = this.getAttachmentById(sId); - if (oItem) - { - oUploadCache[sId] = oItem; - } - } - else - { - oItem = oUploadCache[sId]; - } - - if (oItem) - { - oItem.waiting(false); - oItem.uploading(true); - } - - }, this)) - .on('onComplete', _.bind(function (sId, bResult, oData) { - - var - sError = '', - mErrorCode = null, - oAttachmentJson = null, - oAttachment = this.getAttachmentById(sId) - ; - - oAttachmentJson = bResult && oData && oData.Result && oData.Result.Attachment ? oData.Result.Attachment : null; - mErrorCode = oData && oData.Result && oData.Result.ErrorCode ? oData.Result.ErrorCode : null; - - if (null !== mErrorCode) - { - sError = Utils.getUploadErrorDescByCode(mErrorCode); - } - else if (!oAttachmentJson) - { - sError = Utils.i18n('UPLOAD/ERROR_UNKNOWN'); - } - - if (oAttachment) - { - if ('' !== sError && 0 < sError.length) - { - oAttachment - .waiting(false) - .uploading(false) - .error(sError) - ; - } - else if (oAttachmentJson) - { - oAttachment - .waiting(false) - .uploading(false) - ; - - oAttachment.initByUploadJson(oAttachmentJson); - } - - if (Utils.isUnd(oUploadCache[sId])) - { - delete (oUploadCache[sId]); - } - } - - }, this)) - ; - - this - .addAttachmentEnabled(true) - .dragAndDropEnabled(oJua.isDragAndDropSupported()) - ; - } - else - { - this - .addAttachmentEnabled(false) - .dragAndDropEnabled(false) - ; - } - } - }; - - /** - * @return {Object} - */ - PopupsComposeViewModel.prototype.prepearAttachmentsForSendOrSave = function () - { - var oResult = {}; - _.each(this.attachmentsInReady(), function (oItem) { - if (oItem && '' !== oItem.tempName() && oItem.enabled()) - { - oResult[oItem.tempName()] = [ - oItem.fileName(), - oItem.isInline ? '1' : '0', - oItem.CID, - oItem.contentLocation - ]; - } - }); - - return oResult; - }; - - /** - * @param {MessageModel} oMessage - */ - PopupsComposeViewModel.prototype.addMessageAsAttachment = function (oMessage) - { - if (oMessage) - { - var - self = this, - oAttachment = null, - sTemp = oMessage.subject(), - fCancelFunc = function (sId) { - return function () { - self.attachments.remove(function (oItem) { - return oItem && oItem.id === sId; - }); - }; - } - ; - - sTemp = '.eml' === sTemp.substr(-4).toLowerCase() ? sTemp : sTemp + '.eml'; - oAttachment = new ComposeAttachmentModel( - oMessage.requestHash, sTemp, oMessage.size() - ); - - oAttachment.fromMessage = true; - oAttachment.cancel = fCancelFunc(oMessage.requestHash); - oAttachment.waiting(false).uploading(true); - - this.attachments.push(oAttachment); - } - }; - - /** - * @param {Object} oDropboxFile - * @return {boolean} - */ - PopupsComposeViewModel.prototype.addDropboxAttachment = function (oDropboxFile) - { - var - self = this, - oAttachment = null, - fCancelFunc = function (sId) { - return function () { - self.attachments.remove(function (oItem) { - return oItem && oItem.id === sId; - }); - }; - }, - iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')), - mSize = oDropboxFile['bytes'] - ; - - oAttachment = new ComposeAttachmentModel( - oDropboxFile['link'], oDropboxFile['name'], mSize - ); - - oAttachment.fromMessage = false; - oAttachment.cancel = fCancelFunc(oDropboxFile['link']); - oAttachment.waiting(false).uploading(true); - - this.attachments.push(oAttachment); - - if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize) - { - oAttachment.uploading(false); - oAttachment.error(Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG')); - return false; - } - - Remote.composeUploadExternals(function (sResult, oData) { - - var bResult = false; - oAttachment.uploading(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - if (oData.Result[oAttachment.id]) - { - bResult = true; - oAttachment.tempName(oData.Result[oAttachment.id]); - } - } - - if (!bResult) - { - oAttachment.error(Utils.getUploadErrorDescByCode(Enums.UploadErrorCode.FileNoUploaded)); - } - - }, [oDropboxFile['link']]); - - return true; - }; - - /** - * @param {Object} oDriveFile - * @param {string} sAccessToken - * @return {boolean} - */ - PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAccessToken) - { - var - self = this, - fCancelFunc = function (sId) { - return function () { - self.attachments.remove(function (oItem) { - return oItem && oItem.id === sId; - }); - }; - }, - iAttachmentSizeLimit = Utils.pInt(Settings.settingsGet('AttachmentLimit')), - oAttachment = null, - mSize = oDriveFile['fileSize'] ? Utils.pInt(oDriveFile['fileSize']) : 0 - ; - - oAttachment = new ComposeAttachmentModel( - oDriveFile['downloadUrl'], oDriveFile['title'], mSize - ); - - oAttachment.fromMessage = false; - oAttachment.cancel = fCancelFunc(oDriveFile['downloadUrl']); - oAttachment.waiting(false).uploading(true); - - this.attachments.push(oAttachment); - - if (0 < mSize && 0 < iAttachmentSizeLimit && iAttachmentSizeLimit < mSize) - { - oAttachment.uploading(false); - oAttachment.error(Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG')); - return false; - } - - Remote.composeUploadDrive(function (sResult, oData) { - - var bResult = false; - oAttachment.uploading(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - if (oData.Result[oAttachment.id]) - { - bResult = true; - oAttachment.tempName(oData.Result[oAttachment.id][0]); - oAttachment.size(Utils.pInt(oData.Result[oAttachment.id][1])); - } - } - - if (!bResult) - { - oAttachment.error(Utils.getUploadErrorDescByCode(Enums.UploadErrorCode.FileNoUploaded)); - } - - }, oDriveFile['downloadUrl'], sAccessToken); - - return true; - }; - - /** - * @param {MessageModel} oMessage - * @param {string} sType - */ - PopupsComposeViewModel.prototype.prepearMessageAttachments = function (oMessage, sType) - { - if (oMessage) - { - var - self = this, - aAttachments = Utils.isNonEmptyArray(oMessage.attachments()) ? oMessage.attachments() : [], - iIndex = 0, - iLen = aAttachments.length, - oAttachment = null, - oItem = null, - bAdd = false, - fCancelFunc = function (sId) { - return function () { - self.attachments.remove(function (oItem) { - return oItem && oItem.id === sId; - }); - }; - } - ; - - if (Enums.ComposeType.ForwardAsAttachment === sType) - { - this.addMessageAsAttachment(oMessage); - } - else - { - for (; iIndex < iLen; iIndex++) - { - oItem = aAttachments[iIndex]; - - bAdd = false; - switch (sType) { - case Enums.ComposeType.Reply: - case Enums.ComposeType.ReplyAll: - bAdd = oItem.isLinked; - break; - - case Enums.ComposeType.Forward: - case Enums.ComposeType.Draft: - case Enums.ComposeType.EditAsNew: - bAdd = true; - break; - } - - if (bAdd) - { - oAttachment = new ComposeAttachmentModel( - oItem.download, oItem.fileName, oItem.estimatedSize, - oItem.isInline, oItem.isLinked, oItem.cid, oItem.contentLocation - ); - - oAttachment.fromMessage = true; - oAttachment.cancel = fCancelFunc(oItem.download); - oAttachment.waiting(false).uploading(true); - - this.attachments.push(oAttachment); - } - } - } - } - }; - - PopupsComposeViewModel.prototype.removeLinkedAttachments = function () - { - this.attachments.remove(function (oItem) { - return oItem && oItem.isLinked; - }); - }; - - PopupsComposeViewModel.prototype.setMessageAttachmentFailedDowbloadText = function () - { - _.each(this.attachments(), function(oAttachment) { - if (oAttachment && oAttachment.fromMessage) - { - oAttachment - .waiting(false) - .uploading(false) - .error(Utils.getUploadErrorDescByCode(Enums.UploadErrorCode.FileNoUploaded)) - ; - } - }, this); - }; - - /** - * @param {boolean=} bIncludeAttachmentInProgress = true - * @return {boolean} - */ - PopupsComposeViewModel.prototype.isEmptyForm = function (bIncludeAttachmentInProgress) - { - bIncludeAttachmentInProgress = Utils.isUnd(bIncludeAttachmentInProgress) ? true : !!bIncludeAttachmentInProgress; - var bAttach = bIncludeAttachmentInProgress ? - 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 && - bAttach && - (!this.oEditor || '' === this.oEditor.getData()) - ; - }; - - PopupsComposeViewModel.prototype.reset = function () - { - this.to(''); - this.cc(''); - this.bcc(''); - this.replyTo(''); - this.subject(''); - - this.requestReadReceipt(false); - - this.aDraftInfo = null; - this.sInReplyTo = ''; - this.bFromDraft = false; - this.sReferences = ''; - - this.sendError(false); - this.sendSuccessButSaveError(false); - this.savedError(false); - this.savedTime(0); - this.savedOrSendingText(''); - this.emptyToError(false); - this.attachmentsInProcessError(false); - this.showCcAndBcc(false); - - this.attachments([]); - this.dragAndDropOver(false); - this.dragAndDropVisible(false); - - this.draftFolder(''); - this.draftUid(''); - - this.sending(false); - this.saving(false); - - if (this.oEditor) - { - this.oEditor.clear(false); - } - }; - - /** - * @return {Array} - */ - PopupsComposeViewModel.prototype.getAttachmentsDownloadsForUpload = function () - { - return _.map(_.filter(this.attachments(), function (oItem) { - return oItem && '' === oItem.tempName(); - }), function (oItem) { - return oItem.id; - }); - }; - - PopupsComposeViewModel.prototype.triggerForResize = function () - { - this.resizer(!this.resizer()); - this.editorResizeThrottle(); - }; - - module.exports = PopupsComposeViewModel; - -}(module, require)); -},{"$":20,"App:Knoin":27,"App:RainLoop":3,"Consts":6,"Enums":7,"Events":8,"Globals":9,"HtmlEditor":10,"JSON":15,"Jua":16,"Knoin:AbstractViewModel":30,"LinkBuilder":11,"Model:ComposeAttachment":33,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,"Utils":14,"View:Popup:Ask":80,"View:Popup:ComposeOpenPgp":81,"View:Popup:FolderSystem":87,"_":25,"ko":22,"moment":23,"window":26}],83:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - $ = require('$'), - ko = require('ko'), - key = require('key'), - - Enums = require('Enums'), - Consts = require('Consts'), - Globals = require('Globals'), - Utils = require('Utils'), - Selector = require('Selector'), - LinkBuilder = require('LinkBuilder'), - - Data = require('Storage:RainLoop:Data'), - Remote = require('Storage:RainLoop:Remote'), - - EmailModel = require('Model:Email'), - ContactModel = require('Model:Contact'), - ContactTagModel = require('Model:ContactTag'), - ContactPropertyModel = require('Model:ContactProperty'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsContactsViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsContacts'); - - var - self = this, - fFastClearEmptyListHelper = function (aList) { - if (aList && 0 < aList.length) { - self.viewProperties.removeAll(aList); - } - } - ; - - this.allowContactsSync = Data.allowContactsSync; - this.enableContactsSync = Data.enableContactsSync; - this.allowExport = !Globals.bMobileDevice; - - this.search = ko.observable(''); - this.contactsCount = ko.observable(0); - this.contacts = Data.contacts; - this.contactTags = Data.contactTags; - - this.currentContact = ko.observable(null); - - this.importUploaderButton = ko.observable(null); - - this.contactsPage = ko.observable(1); - this.contactsPageCount = ko.computed(function () { - var iPage = window.Math.ceil(this.contactsCount() / Consts.Defaults.ContactsPerPage); - return 0 >= iPage ? 1 : iPage; - }, this); - - this.contactsPagenator = ko.computed(Utils.computedPagenatorHelper(this.contactsPage, this.contactsPageCount)); - - this.emptySelection = ko.observable(true); - this.viewClearSearch = ko.observable(false); - - this.viewID = ko.observable(''); - this.viewReadOnly = ko.observable(false); - this.viewProperties = ko.observableArray([]); - - this.viewTags = ko.observable(''); - this.viewTags.visibility = ko.observable(false); - this.viewTags.focusTrigger = ko.observable(false); - - this.viewTags.focusTrigger.subscribe(function (bValue) { - if (!bValue && '' === this.viewTags()) - { - this.viewTags.visibility(false); - } - else if (bValue) - { - this.viewTags.visibility(true); - } - }, this); - - this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle); - - this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) { - return -1 < Utils.inArray(oProperty.type(), [ - Enums.ContactPropertyType.FirstName, Enums.ContactPropertyType.LastName - ]); - }); - - this.viewPropertiesOther = this.viewProperties.filter(function(oProperty) { - return -1 < Utils.inArray(oProperty.type(), [ - Enums.ContactPropertyType.Note - ]); - }); - - this.viewPropertiesOther = ko.computed(function () { - - var aList = _.filter(this.viewProperties(), function (oProperty) { - return -1 < Utils.inArray(oProperty.type(), [ - Enums.ContactPropertyType.Nick - ]); - }); - - return _.sortBy(aList, function (oProperty) { - return oProperty.type(); - }); - - }, this); - - this.viewPropertiesEmails = this.viewProperties.filter(function(oProperty) { - return Enums.ContactPropertyType.Email === oProperty.type(); - }); - - this.viewPropertiesWeb = this.viewProperties.filter(function(oProperty) { - return Enums.ContactPropertyType.Web === oProperty.type(); - }); - - this.viewHasNonEmptyRequaredProperties = ko.computed(function() { - - var - aNames = this.viewPropertiesNames(), - aEmail = this.viewPropertiesEmails(), - fHelper = function (oProperty) { - return '' !== Utils.trim(oProperty.value()); - } - ; - - return !!(_.find(aNames, fHelper) || _.find(aEmail, fHelper)); - }, this); - - this.viewPropertiesPhones = this.viewProperties.filter(function(oProperty) { - return Enums.ContactPropertyType.Phone === oProperty.type(); - }); - - this.viewPropertiesEmailsNonEmpty = this.viewPropertiesNames.filter(function(oProperty) { - return '' !== Utils.trim(oProperty.value()); - }); - - this.viewPropertiesEmailsEmptyAndOnFocused = this.viewPropertiesEmails.filter(function(oProperty) { - var bF = oProperty.focused(); - return '' === Utils.trim(oProperty.value()) && !bF; - }); - - this.viewPropertiesPhonesEmptyAndOnFocused = this.viewPropertiesPhones.filter(function(oProperty) { - var bF = oProperty.focused(); - return '' === Utils.trim(oProperty.value()) && !bF; - }); - - this.viewPropertiesWebEmptyAndOnFocused = this.viewPropertiesWeb.filter(function(oProperty) { - var bF = oProperty.focused(); - return '' === Utils.trim(oProperty.value()) && !bF; - }); - - this.viewPropertiesOtherEmptyAndOnFocused = ko.computed(function () { - return _.filter(this.viewPropertiesOther(), function (oProperty) { - var bF = oProperty.focused(); - return '' === Utils.trim(oProperty.value()) && !bF; - }); - }, this); - - this.viewPropertiesEmailsEmptyAndOnFocused.subscribe(function(aList) { - fFastClearEmptyListHelper(aList); - }); - - this.viewPropertiesPhonesEmptyAndOnFocused.subscribe(function(aList) { - fFastClearEmptyListHelper(aList); - }); - - this.viewPropertiesWebEmptyAndOnFocused.subscribe(function(aList) { - fFastClearEmptyListHelper(aList); - }); - - this.viewPropertiesOtherEmptyAndOnFocused.subscribe(function(aList) { - fFastClearEmptyListHelper(aList); - }); - - this.viewSaving = ko.observable(false); - - this.useCheckboxesInList = Data.useCheckboxesInList; - - this.search.subscribe(function () { - this.reloadContactList(); - }, this); - - this.contacts.subscribe(function () { - Utils.windowResize(); - }, this); - - this.viewProperties.subscribe(function () { - Utils.windowResize(); - }, this); - - this.contactsChecked = ko.computed(function () { - return _.filter(this.contacts(), function (oItem) { - return oItem.checked(); - }); - }, this); - - this.contactsCheckedOrSelected = ko.computed(function () { - - var - aChecked = this.contactsChecked(), - oSelected = this.currentContact() - ; - - return _.union(aChecked, oSelected ? [oSelected] : []); - - }, this); - - this.contactsCheckedOrSelectedUids = ko.computed(function () { - return _.map(this.contactsCheckedOrSelected(), function (oContact) { - return oContact.idContact; - }); - }, this); - - this.selector = new Selector(this.contacts, this.currentContact, - '.e-contact-item .actionHandle', '.e-contact-item.selected', '.e-contact-item .checkboxItem', - '.e-contact-item.focused'); - - this.selector.on('onItemSelect', _.bind(function (oContact) { - this.populateViewContact(oContact ? oContact : null); - if (!oContact) - { - this.emptySelection(true); - } - }, this)); - - this.selector.on('onItemGetUid', function (oContact) { - return oContact ? oContact.generateUid() : ''; - }); - - this.newCommand = Utils.createCommand(this, function () { - this.populateViewContact(null); - this.currentContact(null); - }); - - this.deleteCommand = Utils.createCommand(this, function () { - this.deleteSelectedContacts(); - this.emptySelection(true); - }, function () { - return 0 < this.contactsCheckedOrSelected().length; - }); - - this.newMessageCommand = Utils.createCommand(this, function () { - var aC = this.contactsCheckedOrSelected(), aE = []; - if (Utils.isNonEmptyArray(aC)) - { - aE = _.map(aC, function (oItem) { - if (oItem) - { - var - aData = oItem.getNameAndEmailHelper(), - oEmail = aData ? new EmailModel(aData[0], aData[1]) : null - ; - - if (oEmail && oEmail.validate()) - { - return oEmail; - } - } - - return null; - }); - - aE = _.compact(aE); - } - - if (Utils.isNonEmptyArray(aE)) - { - kn.hideScreenPopup(require('View:Popup:Contacts')); - kn.showScreenPopup(require('View:Popup:Compose'), [Enums.ComposeType.Empty, null, aE]); - } - - }, function () { - return 0 < this.contactsCheckedOrSelected().length; - }); - - this.clearCommand = Utils.createCommand(this, function () { - this.search(''); - }); - - this.saveCommand = Utils.createCommand(this, function () { - - this.viewSaving(true); - this.viewSaveTrigger(Enums.SaveSettingsStep.Animate); - - var - sRequestUid = Utils.fakeMd5(), - aProperties = [] - ; - - _.each(this.viewProperties(), function (oItem) { - if (oItem.type() && '' !== Utils.trim(oItem.value())) - { - aProperties.push([oItem.type(), oItem.value(), oItem.typeStr()]); - } - }); - - Remote.contactSave(function (sResult, oData) { - - var bRes = false; - self.viewSaving(false); - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result && - oData.Result.RequestUid === sRequestUid && 0 < Utils.pInt(oData.Result.ResultID)) - { - if ('' === self.viewID()) - { - self.viewID(Utils.pInt(oData.Result.ResultID)); - } - - self.reloadContactList(); - bRes = true; + $.cookie('rllang', Data.language(), {'expires': 30}); } - _.delay(function () { - self.viewSaveTrigger(bRes ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult); - }, 300); - - if (bRes) - { - self.watchDirty(false); - - _.delay(function () { - self.viewSaveTrigger(Enums.SaveSettingsStep.Idle); - }, 1000); - } - - }, sRequestUid, this.viewID(), this.viewTags(), aProperties); - - }, function () { - var - bV = this.viewHasNonEmptyRequaredProperties(), - bReadOnly = this.viewReadOnly() - ; - return !this.viewSaving() && bV && !bReadOnly; - }); - - this.syncCommand = Utils.createCommand(this, function () { - - var self = this; - require('App:RainLoop').contactsSync(function (sResult, oData) { - if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) - { - window.alert(Utils.getNotification( - oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.ContactsSyncError)); - } - - self.reloadContactList(true); - }); - - }, function () { - return !this.contacts.syncing() && !this.contacts.importing(); - }); - - this.bDropPageAfterDelete = false; - - this.watchDirty = ko.observable(false); - this.watchHash = ko.observable(false); - - this.viewHash = ko.computed(function () { - return '' + self.viewTags() + '|' + _.map(self.viewProperties(), function (oItem) { - return oItem.value(); - }).join(''); - }); - - // this.saveCommandDebounce = _.debounce(_.bind(this.saveCommand, this), 1000); - - this.viewHash.subscribe(function () { - if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty()) - { - this.watchDirty(true); - } - }, this); - - this.sDefaultKeyScope = Enums.KeyState.ContactList; - - this.contactTagsSource = _.bind(this.contactTagsSource, this); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:Contacts', 'PopupsContactsViewModel'], PopupsContactsViewModel); - _.extend(PopupsContactsViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsContactsViewModel.prototype.contactTagsSource = function (oData, fResponse) - { - require('App:RainLoop').getContactTagsAutocomplete(oData.term, function (aData) { - fResponse(_.map(aData, function (oTagItem) { - return oTagItem.toLine(false); - })); - }); - }; - - PopupsContactsViewModel.prototype.getPropertyPlceholder = function (sType) - { - var sResult = ''; - switch (sType) - { - case Enums.ContactPropertyType.LastName: - sResult = 'CONTACTS/PLACEHOLDER_ENTER_LAST_NAME'; - break; - case Enums.ContactPropertyType.FirstName: - sResult = 'CONTACTS/PLACEHOLDER_ENTER_FIRST_NAME'; - break; - case Enums.ContactPropertyType.Nick: - sResult = 'CONTACTS/PLACEHOLDER_ENTER_NICK_NAME'; - break; - } - - return sResult; - }; - - PopupsContactsViewModel.prototype.addNewProperty = function (sType, sTypeStr) - { - this.viewProperties.push(new ContactPropertyModel(sType, sTypeStr || '', '', true, this.getPropertyPlceholder(sType))); - }; - - PopupsContactsViewModel.prototype.addNewOrFocusProperty = function (sType, sTypeStr) - { - var oItem = _.find(this.viewProperties(), function (oItem) { - return sType === oItem.type(); - }); - - if (oItem) - { - oItem.focused(true); - } - else - { - this.addNewProperty(sType, sTypeStr); - } - }; - - PopupsContactsViewModel.prototype.addNewTag = function () - { - this.viewTags.visibility(true); - this.viewTags.focusTrigger(true); - }; - - PopupsContactsViewModel.prototype.addNewEmail = function () - { - this.addNewProperty(Enums.ContactPropertyType.Email, 'Home'); - }; - - PopupsContactsViewModel.prototype.addNewPhone = function () - { - this.addNewProperty(Enums.ContactPropertyType.Phone, 'Mobile'); - }; - - PopupsContactsViewModel.prototype.addNewWeb = function () - { - this.addNewProperty(Enums.ContactPropertyType.Web); - }; - - PopupsContactsViewModel.prototype.addNewNickname = function () - { - this.addNewOrFocusProperty(Enums.ContactPropertyType.Nick); - }; - - PopupsContactsViewModel.prototype.addNewNotes = function () - { - this.addNewOrFocusProperty(Enums.ContactPropertyType.Note); - }; - - PopupsContactsViewModel.prototype.addNewBirthday = function () - { - this.addNewOrFocusProperty(Enums.ContactPropertyType.Birthday); - }; - - PopupsContactsViewModel.prototype.exportVcf = function () - { - require('App:RainLoop').download(LinkBuilder.exportContactsVcf()); - }; - - PopupsContactsViewModel.prototype.exportCsv = function () - { - require('App:RainLoop').download(LinkBuilder.exportContactsCsv()); - }; - - PopupsContactsViewModel.prototype.initUploader = function () - { - if (this.importUploaderButton()) - { - var - oJua = new Jua({ - 'action': LinkBuilder.uploadContacts(), - 'name': 'uploader', - 'queueSize': 1, - 'multipleSizeLimit': 1, - 'disableFolderDragAndDrop': true, - 'disableDragAndDrop': true, - 'disableMultiple': true, - 'disableDocumentDropPrevent': true, - 'clickElement': this.importUploaderButton() - }) - ; - - if (oJua) - { - oJua - .on('onStart', _.bind(function () { - this.contacts.importing(true); - }, this)) - .on('onComplete', _.bind(function (sId, bResult, oData) { - - this.contacts.importing(false); - this.reloadContactList(); - - if (!sId || !bResult || !oData || !oData.Result) - { - window.alert(Utils.i18n('CONTACTS/ERROR_IMPORT_FILE')); - } - - }, this)) - ; - } - } - }; - - PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = function () - { - var - self = this, - oKoContacts = this.contacts, - oCurrentContact = this.currentContact(), - iCount = this.contacts().length, - aContacts = this.contactsCheckedOrSelected() - ; - - if (0 < aContacts.length) - { - _.each(aContacts, function (oContact) { - - if (oCurrentContact && oCurrentContact.idContact === oContact.idContact) - { - oCurrentContact = null; - self.currentContact(null); - } - - oContact.deleted(true); - iCount--; - }); - - if (iCount <= 0) - { - this.bDropPageAfterDelete = true; - } - - _.delay(function () { - - _.each(aContacts, function (oContact) { - oKoContacts.remove(oContact); - }); - - }, 500); - } - }; - - PopupsContactsViewModel.prototype.deleteSelectedContacts = function () - { - if (0 < this.contactsCheckedOrSelected().length) - { - Remote.contactsDelete( - _.bind(this.deleteResponse, this), - this.contactsCheckedOrSelectedUids() - ); - - this.removeCheckedOrSelectedContactsFromList(); - } - }; - - /** - * @param {string} sResult - * @param {AjaxJsonDefaultResponse} oData - */ - PopupsContactsViewModel.prototype.deleteResponse = function (sResult, oData) - { - if (500 < (Enums.StorageResultType.Success === sResult && oData && oData.Time ? Utils.pInt(oData.Time) : 0)) - { - this.reloadContactList(this.bDropPageAfterDelete); - } - else - { - _.delay((function (self) { - return function () { - self.reloadContactList(self.bDropPageAfterDelete); - }; - }(this)), 500); - } - }; - - PopupsContactsViewModel.prototype.removeProperty = function (oProp) - { - this.viewProperties.remove(oProp); - }; - - /** - * @param {?ContactModel} oContact - */ - PopupsContactsViewModel.prototype.populateViewContact = function (oContact) - { - var - sId = '', - sLastName = '', - sFirstName = '', - aList = [] - ; - - this.watchHash(false); - - this.emptySelection(false); - this.viewReadOnly(false); - this.viewTags(''); - - if (oContact) - { - sId = oContact.idContact; - if (Utils.isNonEmptyArray(oContact.properties)) - { - _.each(oContact.properties, function (aProperty) { - if (aProperty && aProperty[0]) - { - if (Enums.ContactPropertyType.LastName === aProperty[0]) - { - sLastName = aProperty[1]; - } - else if (Enums.ContactPropertyType.FirstName === aProperty[0]) - { - sFirstName = aProperty[1]; - } - else - { - aList.push(new ContactPropertyModel(aProperty[0], aProperty[2] || '', aProperty[1])); - } - } - }); - } - - this.viewTags(oContact.tags); - - this.viewReadOnly(!!oContact.readOnly); - } - - this.viewTags.focusTrigger.valueHasMutated(); - this.viewTags.visibility('' !== this.viewTags()); - - aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.LastName, '', sLastName, false, - this.getPropertyPlceholder(Enums.ContactPropertyType.LastName))); - - aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.FirstName, '', sFirstName, !oContact, - this.getPropertyPlceholder(Enums.ContactPropertyType.FirstName))); - - this.viewID(sId); - this.viewProperties([]); - this.viewProperties(aList); - - this.watchDirty(false); - this.watchHash(true); - }; - - /** - * @param {boolean=} bDropPagePosition = false - */ - PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePosition) - { - var - self = this, - iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage - ; - - this.bDropPageAfterDelete = false; - - if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition) - { - this.contactsPage(1); - iOffset = 0; - } - - this.contacts.loading(true); - Remote.contacts(function (sResult, oData) { - var - iCount = 0, - aList = [], - aTagsList = [] - ; - - if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List) - { - if (Utils.isNonEmptyArray(oData.Result.List)) - { - aList = _.map(oData.Result.List, function (oItem) { - var oContact = new ContactModel(); - return oContact.parse(oItem) ? oContact : null; - }); - - aList = _.compact(aList); - - iCount = Utils.pInt(oData.Result.Count); - iCount = 0 < iCount ? iCount : 0; - } - - if (Utils.isNonEmptyArray(oData.Result.Tags)) - { - aTagsList = _.map(oData.Result.Tags, function (oItem) { - var oContactTag = new ContactTagModel(); - return oContactTag.parse(oItem) ? oContactTag : null; - }); - - aTagsList = _.compact(aTagsList); - } - } - - self.contactsCount(iCount); - - self.contacts(aList); - self.contacts.loading(false); - self.contactTags(aTagsList); - - self.viewClearSearch('' !== self.search()); - - }, iOffset, Consts.Defaults.ContactsPerPage, this.search()); - }; - - PopupsContactsViewModel.prototype.onBuild = function (oDom) - { - this.oContentVisible = $('.b-list-content', oDom); - this.oContentScrollable = $('.content', this.oContentVisible); - - this.selector.init(this.oContentVisible, this.oContentScrollable, Enums.KeyState.ContactList); - - var self = this; - - key('delete', Enums.KeyState.ContactList, function () { - self.deleteCommand(); - return false; - }); - - oDom - .on('click', '.e-pagenator .e-page', function () { - var oPage = ko.dataFor(this); - if (oPage) - { - self.contactsPage(Utils.pInt(oPage.value)); - self.reloadContactList(); - } - }) - ; - - this.initUploader(); - }; - - PopupsContactsViewModel.prototype.onShow = function () - { - kn.routeOff(); - this.reloadContactList(true); - }; - - PopupsContactsViewModel.prototype.onHide = function () - { - kn.routeOn(); - this.currentContact(null); - this.emptySelection(true); - this.search(''); - this.contactsCount(0); - this.contacts([]); - }; - - module.exports = PopupsContactsViewModel; - -}(module, require)); -},{"$":20,"App:Knoin":27,"App:RainLoop":3,"Consts":6,"Enums":7,"Globals":9,"Knoin:AbstractViewModel":30,"LinkBuilder":11,"Model:Contact":34,"Model:ContactProperty":35,"Model:ContactTag":36,"Model:Email":37,"Selector":13,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"View:Popup:Compose":82,"View:Popup:Contacts":83,"_":25,"key":21,"ko":22,"window":26}],84:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Consts = require('Consts'), - Utils = require('Utils'), - - Data = require('Storage:RainLoop:Data'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsFilterViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFilter'); - - this.filter = ko.observable(null); - - this.selectedFolderValue = ko.observable(Consts.Values.UnuseOptionValue); - this.folderSelectList = Data.folderMenuForMove; - this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:Filter', 'PopupsFilterViewModel'], PopupsFilterViewModel); - _.extend(PopupsFilterViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsFilterViewModel.prototype.clearPopup = function () - { - // TODO - }; - - PopupsFilterViewModel.prototype.onShow = function (oFilter) - { - this.clearPopup(); - - this.filter(oFilter); - }; - - module.exports = PopupsFilterViewModel; - -}(module, require)); -},{"App:Knoin":27,"Consts":6,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,"Utils":14,"_":25,"ko":22}],85:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Data = require('Storage:RainLoop:Data'), - Cache = require('Storage:RainLoop:Cache'), - Remote = require('Storage:RainLoop:Remote'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsFolderClearViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderClear'); - - this.selectedFolder = ko.observable(null); - this.clearingProcess = ko.observable(false); - this.clearingError = ko.observable(''); - - this.folderFullNameForClear = ko.computed(function () { - var oFolder = this.selectedFolder(); - return oFolder ? oFolder.printableFullName() : ''; - }, this); - - this.folderNameForClear = ko.computed(function () { - var oFolder = this.selectedFolder(); - return oFolder ? oFolder.localName() : ''; - }, this); - - this.dangerDescHtml = ko.computed(function () { - return Utils.i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', { - 'FOLDER': this.folderNameForClear() - }); - }, this); - - this.clearCommand = Utils.createCommand(this, function () { - - var - self = this, - oFolderToClear = this.selectedFolder() - ; - - if (oFolderToClear) - { - Data.message(null); - Data.messageList([]); - - this.clearingProcess(true); - - oFolderToClear.messageCountAll(0); - oFolderToClear.messageCountUnread(0); - - Cache.setFolderHash(oFolderToClear.fullNameRaw, ''); - - Remote.folderClear(function (sResult, oData) { - - self.clearingProcess(false); - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - require('App:RainLoop').reloadMessageList(true); - self.cancelCommand(); - } - else - { - if (oData && oData.ErrorCode) - { - self.clearingError(Utils.getNotification(oData.ErrorCode)); - } - else - { - self.clearingError(Utils.getNotification(Enums.Notification.MailServerError)); - } - } - }, oFolderToClear.fullNameRaw); - } - - }, function () { - - var - oFolder = this.selectedFolder(), - bIsClearing = this.clearingProcess() - ; - - return !bIsClearing && null !== oFolder; - - }); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:FolderClear', 'PopupsFolderClearViewModel'], PopupsFolderClearViewModel); - _.extend(PopupsFolderClearViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsFolderClearViewModel.prototype.clearPopup = function () - { - this.clearingProcess(false); - this.selectedFolder(null); - }; - - PopupsFolderClearViewModel.prototype.onShow = function (oFolder) - { - this.clearPopup(); - if (oFolder) - { - this.selectedFolder(oFolder); - } - }; - - module.exports = PopupsFolderClearViewModel; - -}(module, require)); - -},{"App:Knoin":27,"App:RainLoop":3,"Enums":7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"_":25,"ko":22}],86:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Consts = require('Consts'), - Utils = require('Utils'), - - Data = require('Storage:RainLoop:Data'), - Remote = require('Storage:RainLoop:Remote'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsFolderCreateViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderCreate'); - - Utils.initOnStartOrLangChange(function () { - this.sNoParentText = Utils.i18n('POPUPS_CREATE_FOLDER/SELECT_NO_PARENT'); - }, this); - - this.folderName = ko.observable(''); - this.folderName.focused = ko.observable(false); - - this.selectedParentValue = ko.observable(Consts.Values.UnuseOptionValue); - - this.parentFolderSelectList = ko.computed(function () { - - var - aTop = [], - fDisableCallback = null, - fVisibleCallback = null, - aList = Data.folderList(), - fRenameCallback = function (oItem) { - return oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : ''; - } - ; - - aTop.push(['', this.sNoParentText]); - - if ('' !== Data.namespace) - { - fDisableCallback = function (oItem) - { - return Data.namespace !== oItem.fullNameRaw.substr(0, Data.namespace.length); - }; - } - - return Utils.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback); - - }, this); - - // commands - this.createFolder = Utils.createCommand(this, function () { - - var - sParentFolderName = this.selectedParentValue() - ; - - if ('' === sParentFolderName && 1 < Data.namespace.length) - { - sParentFolderName = Data.namespace.substr(0, Data.namespace.length - 1); - } - - Data.foldersCreating(true); - Remote.folderCreate(function (sResult, oData) { - - Data.foldersCreating(false); - if (Enums.StorageResultType.Success === sResult && oData && oData.Result) - { - require('App:RainLoop').folders(); - } - else - { - Data.foldersListError( - oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER')); - } - - }, this.folderName(), sParentFolderName); - - this.cancelCommand(); - - }, function () { - return this.simpleFolderNameValidation(this.folderName()); - }); - - this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:FolderCreate', 'PopupsFolderCreateViewModel'], PopupsFolderCreateViewModel); - _.extend(PopupsFolderCreateViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsFolderCreateViewModel.prototype.sNoParentText = ''; - - PopupsFolderCreateViewModel.prototype.simpleFolderNameValidation = function (sName) - { - return (/^[^\\\/]+$/g).test(Utils.trim(sName)); - }; - - PopupsFolderCreateViewModel.prototype.clearPopup = function () - { - this.folderName(''); - this.selectedParentValue(''); - this.folderName.focused(false); - }; - - PopupsFolderCreateViewModel.prototype.onShow = function () - { - this.clearPopup(); - }; - - PopupsFolderCreateViewModel.prototype.onFocus = function () - { - this.folderName.focused(true); - }; - - module.exports = PopupsFolderCreateViewModel; - -}(module, require)); -},{"App:Knoin":27,"App:RainLoop":3,"Consts":6,"Enums":7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"_":25,"ko":22}],87:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Consts = require('Consts'), - Utils = require('Utils'), - - Settings = require('Storage:Settings'), - Data = require('Storage:RainLoop:Data'), - Remote = require('Storage:RainLoop:Remote'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsFolderSystemViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsFolderSystem'); - - Utils.initOnStartOrLangChange(function () { - this.sChooseOnText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE'); - this.sUnuseText = Utils.i18n('POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME'); - }, this); - - this.notification = ko.observable(''); - - this.folderSelectList = ko.computed(function () { - return Utils.folderListOptionsBuilder([], Data.folderList(), Data.folderListSystemNames(), [ - ['', this.sChooseOnText], - [Consts.Values.UnuseOptionValue, this.sUnuseText] - ]); - }, this); - - var - self = this, - fSaveSystemFolders = null, - fCallback = null - ; - - this.sentFolder = Data.sentFolder; - this.draftFolder = Data.draftFolder; - this.spamFolder = Data.spamFolder; - this.trashFolder = Data.trashFolder; - this.archiveFolder = Data.archiveFolder; - - fSaveSystemFolders = _.debounce(function () { - - Settings.settingsSet('SentFolder', self.sentFolder()); - Settings.settingsSet('DraftFolder', self.draftFolder()); - Settings.settingsSet('SpamFolder', self.spamFolder()); - Settings.settingsSet('TrashFolder', self.trashFolder()); - Settings.settingsSet('ArchiveFolder', self.archiveFolder()); - - Remote.saveSystemFolders(Utils.emptyFunction, { - 'SentFolder': self.sentFolder(), - 'DraftFolder': self.draftFolder(), - 'SpamFolder': self.spamFolder(), - 'TrashFolder': self.trashFolder(), - 'ArchiveFolder': self.archiveFolder(), - 'NullFolder': 'NullFolder' - }); - - }, 1000); - - fCallback = function () { - - Settings.settingsSet('SentFolder', self.sentFolder()); - Settings.settingsSet('DraftFolder', self.draftFolder()); - Settings.settingsSet('SpamFolder', self.spamFolder()); - Settings.settingsSet('TrashFolder', self.trashFolder()); - Settings.settingsSet('ArchiveFolder', self.archiveFolder()); - - fSaveSystemFolders(); + }, this), 100); }; - this.sentFolder.subscribe(fCallback); - this.draftFolder.subscribe(fCallback); - this.spamFolder.subscribe(fCallback); - this.trashFolder.subscribe(fCallback); - this.archiveFolder.subscribe(fCallback); - - this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:FolderSystem', 'PopupsFolderSystemViewModel'], PopupsFolderSystemViewModel); - _.extend(PopupsFolderSystemViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsFolderSystemViewModel.prototype.sChooseOnText = ''; - PopupsFolderSystemViewModel.prototype.sUnuseText = ''; - - /** - * @param {number=} iNotificationType = Enums.SetSystemFoldersNotification.None - */ - PopupsFolderSystemViewModel.prototype.onShow = function (iNotificationType) - { - var sNotification = ''; - - iNotificationType = Utils.isUnd(iNotificationType) ? Enums.SetSystemFoldersNotification.None : iNotificationType; - - switch (iNotificationType) + LoginViewModel.prototype.onHide = function () { - case Enums.SetSystemFoldersNotification.Sent: - sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT'); - break; - case Enums.SetSystemFoldersNotification.Draft: - sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS'); - break; - case Enums.SetSystemFoldersNotification.Spam: - sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM'); - break; - case Enums.SetSystemFoldersNotification.Trash: - sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH'); - break; - case Enums.SetSystemFoldersNotification.Archive: - sNotification = Utils.i18n('POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE'); - break; - } + this.submitFocus(false); + this.emailFocus(false); + }; - this.notification(sNotification); - }; - - module.exports = PopupsFolderSystemViewModel; - -}(module, require)); -},{"App:Knoin":27,"Consts":6,"Enums":7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,"Utils":14,"_":25,"ko":22}],88:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Remote = require('Storage:RainLoop:Remote'), - Data = require('Storage:RainLoop:Data'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsIdentityViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsIdentity'); - - this.id = ''; - this.edit = ko.observable(false); - this.owner = ko.observable(false); - - this.email = ko.observable('').validateEmail(); - this.email.focused = ko.observable(false); - this.name = ko.observable(''); - this.name.focused = ko.observable(false); - this.replyTo = ko.observable('').validateSimpleEmail(); - this.replyTo.focused = ko.observable(false); - this.bcc = ko.observable('').validateSimpleEmail(); - this.bcc.focused = ko.observable(false); - - // this.email.subscribe(function () { - // this.email.hasError(false); - // }, this); - - this.submitRequest = ko.observable(false); - this.submitError = ko.observable(''); - - this.addOrEditIdentityCommand = Utils.createCommand(this, function () { - - if (!this.email.hasError()) - { - this.email.hasError('' === Utils.trim(this.email())); - } - - if (this.email.hasError()) - { - if (!this.owner()) - { - this.email.focused(true); - } - - return false; - } - - if (this.replyTo.hasError()) - { - this.replyTo.focused(true); - return false; - } - - if (this.bcc.hasError()) - { - this.bcc.focused(true); - return false; - } - - this.submitRequest(true); - - Remote.identityUpdate(_.bind(function (sResult, oData) { - - this.submitRequest(false); - if (Enums.StorageResultType.Success === sResult && oData) - { - if (oData.Result) - { - require('App:RainLoop').accountsAndIdentities(); - this.cancelCommand(); - } - else if (oData.ErrorCode) - { - this.submitError(Utils.getNotification(oData.ErrorCode)); - } - } - else - { - this.submitError(Utils.getNotification(Enums.Notification.UnknownError)); - } - - }, this), this.id, this.email(), this.name(), this.replyTo(), this.bcc()); - - return true; - - }, function () { - return !this.submitRequest(); - }); - - this.label = ko.computed(function () { - return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'TITLE_UPDATE_IDENTITY': 'TITLE_ADD_IDENTITY')); - }, this); - - this.button = ko.computed(function () { - return Utils.i18n('POPUPS_IDENTITIES/' + (this.edit() ? 'BUTTON_UPDATE_IDENTITY': 'BUTTON_ADD_IDENTITY')); - }, this); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:Identity', 'PopupsIdentityViewModel'], PopupsIdentityViewModel); - _.extend(PopupsIdentityViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsIdentityViewModel.prototype.clearPopup = function () - { - this.id = ''; - this.edit(false); - this.owner(false); - - this.name(''); - this.email(''); - this.replyTo(''); - this.bcc(''); - - this.email.hasError(false); - this.replyTo.hasError(false); - this.bcc.hasError(false); - - this.submitRequest(false); - this.submitError(''); - }; - - /** - * @param {?IdentityModel} oIdentity - */ - PopupsIdentityViewModel.prototype.onShow = function (oIdentity) - { - this.clearPopup(); - - if (oIdentity) + LoginViewModel.prototype.onBuild = function () { - this.edit(true); - - this.id = oIdentity.id; - this.name(oIdentity.name()); - this.email(oIdentity.email()); - this.replyTo(oIdentity.replyTo()); - this.bcc(oIdentity.bcc()); - - this.owner(this.id === Data.accountEmail()); - } - }; - - PopupsIdentityViewModel.prototype.onFocus = function () - { - if (!this.owner()) - { - this.email.focused(true); - } - }; - - module.exports = PopupsIdentityViewModel; - -}(module, require)); -},{"App:Knoin":27,"App:RainLoop":3,"Enums":7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Utils":14,"_":25,"ko":22}],89:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - key = require('key'), - - Enums = require('Enums'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsKeyboardShortcutsHelpViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsKeyboardShortcutsHelp'); - - this.sDefaultKeyScope = Enums.KeyState.PopupKeyboardShortcutsHelp; - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:KeyboardShortcutsHelp', 'PopupsKeyboardShortcutsHelpViewModel'], PopupsKeyboardShortcutsHelpViewModel); - _.extend(PopupsKeyboardShortcutsHelpViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsKeyboardShortcutsHelpViewModel.prototype.onBuild = function (oDom) - { - key('tab, shift+tab, left, right', Enums.KeyState.PopupKeyboardShortcutsHelp, _.bind(function (event, handler) { - if (event && handler) - { - var - $tabs = oDom.find('.nav.nav-tabs > li'), - bNext = handler && ('tab' === handler.shortcut || 'right' === handler.shortcut), - iIndex = $tabs.index($tabs.filter('.active')) - ; - - if (!bNext && iIndex > 0) - { - iIndex--; - } - else if (bNext && iIndex < $tabs.length - 1) - { - iIndex++; - } - else - { - iIndex = bNext ? 0 : $tabs.length - 1; - } - - $tabs.eq(iIndex).find('a[data-toggle="tab"]').tab('show'); - return false; - } - }, this)); - }; - - module.exports = PopupsKeyboardShortcutsHelpViewModel; - -}(module, require)); -},{"App:Knoin":27,"Enums":7,"Knoin:AbstractViewModel":30,"_":25,"key":21}],90:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Utils = require('Utils'), - Globals = require('Globals'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsLanguagesViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsLanguages'); - - this.Data = Globals.__APP.data(); // TODO - - this.exp = ko.observable(false); - - this.languages = ko.computed(function () { - return _.map(this.Data.languages(), function (sLanguage) { - return { - 'key': sLanguage, - 'selected': ko.observable(false), - 'fullName': Utils.convertLangName(sLanguage) - }; - }); - }, this); - - this.Data.mainLanguage.subscribe(function () { - this.resetMainLanguage(); - }, this); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:Languages', 'PopupsLanguagesViewModel'], PopupsLanguagesViewModel); - _.extend(PopupsLanguagesViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsLanguagesViewModel.prototype.languageEnName = function (sLanguage) - { - return Utils.convertLangName(sLanguage, true); - }; - - PopupsLanguagesViewModel.prototype.resetMainLanguage = function () - { - var sCurrent = this.Data.mainLanguage(); - _.each(this.languages(), function (oItem) { - oItem['selected'](oItem['key'] === sCurrent); - }); - }; - - PopupsLanguagesViewModel.prototype.onShow = function () - { - this.exp(true); - - this.resetMainLanguage(); - }; - - PopupsLanguagesViewModel.prototype.onHide = function () - { - this.exp(false); - }; - - PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang) - { - this.Data.mainLanguage(sLang); - this.cancelCommand(); - }; - - module.exports = PopupsLanguagesViewModel; - -}(module, require)); -},{"App:Knoin":27,"Globals":9,"Knoin:AbstractViewModel":30,"Utils":14,"_":25,"ko":22}],91:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - window = require('window'), - _ = require('_'), - ko = require('ko'), - - Utils = require('Utils'), - - Data = require('Storage:RainLoop:Data'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsNewOpenPgpKeyViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsNewOpenPgpKey'); - - this.email = ko.observable(''); - this.email.focus = ko.observable(''); - this.email.error = ko.observable(false); - - this.name = ko.observable(''); - this.password = ko.observable(''); - this.keyBitLength = ko.observable(2048); - - this.submitRequest = ko.observable(false); - - this.email.subscribe(function () { - this.email.error(false); - }, this); - - this.generateOpenPgpKeyCommand = Utils.createCommand(this, function () { - var self = this, - sUserID = '', - mKeyPair = null, - oOpenpgpKeyring = Data.openpgpKeyring + sJsHash = Settings.settingsGet('JsHash'), + fSocial = function (iErrorCode) { + iErrorCode = Utils.pInt(iErrorCode); + if (0 === iErrorCode) + { + self.submitRequest(true); + __webpack_require__(/*! App:RainLoop */ 4).loginAndLogoutReload(); + } + else + { + self.submitError(Utils.getNotification(iErrorCode)); + } + } ; - this.email.error('' === Utils.trim(this.email())); - if (!oOpenpgpKeyring || this.email.error()) + this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial')); + this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial')); + this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial')); + + switch ((Settings.settingsGet('SignMe') || 'unused').toLowerCase()) { - return false; + case Enums.LoginSignMeTypeAsString.DefaultOff: + this.signMeType(Enums.LoginSignMeType.DefaultOff); + break; + case Enums.LoginSignMeTypeAsString.DefaultOn: + this.signMeType(Enums.LoginSignMeType.DefaultOn); + break; + default: + case Enums.LoginSignMeTypeAsString.Unused: + this.signMeType(Enums.LoginSignMeType.Unused); + break; } - sUserID = this.email(); - if ('' !== this.name()) + this.email(Data.devEmail); + this.password(Data.devPassword); + + if (this.googleLoginEnabled()) { - sUserID = this.name() + ' <' + sUserID + '>'; + window['rl_' + sJsHash + '_google_login_service'] = fSocial; } - this.submitRequest(true); + if (this.facebookLoginEnabled()) + { + window['rl_' + sJsHash + '_facebook_login_service'] = fSocial; + } + + if (this.twitterLoginEnabled()) + { + window['rl_' + sJsHash + '_twitter_login_service'] = fSocial; + } _.delay(function () { - // mKeyPair = window.openpgp.generateKeyPair(1, Utils.pInt(self.keyBitLength()), sUserID, Utils.trim(self.password())); - mKeyPair = window.openpgp.generateKeyPair({ - 'userId': sUserID, - 'numBits': Utils.pInt(self.keyBitLength()), - 'passphrase': Utils.trim(self.password()) + Data.language.subscribe(function (sValue) { + self.langRequest(true); + $.ajax({ + 'url': LinkBuilder.langLink(sValue), + 'dataType': 'script', + 'cache': true + }).done(function() { + self.bSendLanguage = true; + Utils.i18nReload(); + $.cookie('rllang', Data.language(), {'expires': 30}); + }).always(function() { + self.langRequest(false); + }); }); + }, 50); - if (mKeyPair && mKeyPair.privateKeyArmored) - { - oOpenpgpKeyring.privateKeys.importKey(mKeyPair.privateKeyArmored); - oOpenpgpKeyring.publicKeys.importKey(mKeyPair.publicKeyArmored); - oOpenpgpKeyring.store(); + Utils.triggerAutocompleteInputChange(true); + }; - require('App:RainLoop').reloadOpenPgpKeys(); - Utils.delegateRun(self, 'cancelCommand'); - } - - self.submitRequest(false); - }, 100); - - return true; - }); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], PopupsNewOpenPgpKeyViewModel); - _.extend(PopupsNewOpenPgpKeyViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsNewOpenPgpKeyViewModel.prototype.clearPopup = function () - { - this.name(''); - this.password(''); - - this.email(''); - this.email.error(false); - this.keyBitLength(2048); - }; - - PopupsNewOpenPgpKeyViewModel.prototype.onShow = function () - { - this.clearPopup(); - }; - - PopupsNewOpenPgpKeyViewModel.prototype.onFocus = function () - { - this.email.focus(true); - }; - - module.exports = PopupsNewOpenPgpKeyViewModel; - -}(module, require)); -},{"App:Knoin":27,"App:RainLoop":3,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,"Utils":14,"_":25,"ko":22,"window":26}],92:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Enums = require('Enums'), - Utils = require('Utils'), - - Remote = require('Storage:RainLoop:Remote'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsTwoFactorTestViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsTwoFactorTest'); - - var self = this; - - this.code = ko.observable(''); - this.code.focused = ko.observable(false); - this.code.status = ko.observable(null); - - this.testing = ko.observable(false); - - // commands - this.testCode = Utils.createCommand(this, function () { - - this.testing(true); - Remote.testTwoFactor(function (sResult, oData) { - - self.testing(false); - self.code.status(Enums.StorageResultType.Success === sResult && oData && oData.Result ? true : false); - - }, this.code()); - - }, function () { - return '' !== this.code() && !this.testing(); - }); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:TwoFactorTest', 'PopupsTwoFactorTestViewModel'], PopupsTwoFactorTestViewModel); - _.extend(PopupsTwoFactorTestViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsTwoFactorTestViewModel.prototype.clearPopup = function () - { - this.code(''); - this.code.focused(false); - this.code.status(null); - this.testing(false); - }; - - PopupsTwoFactorTestViewModel.prototype.onShow = function () - { - this.clearPopup(); - }; - - PopupsTwoFactorTestViewModel.prototype.onFocus = function () - { - this.code.focused(true); - }; - - module.exports = PopupsTwoFactorTestViewModel; - -}(module, require)); -},{"App:Knoin":27,"Enums":7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Remote":68,"Utils":14,"_":25,"ko":22}],93:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - ko = require('ko'), - - Utils = require('Utils'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function PopupsViewOpenPgpKeyViewModel() - { - KnoinAbstractViewModel.call(this, 'Popups', 'PopupsViewOpenPgpKey'); - - this.key = ko.observable(''); - this.keyDom = ko.observable(null); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:Popup:ViewOpenPgpKey', 'PopupsViewOpenPgpKeyViewModel'], PopupsViewOpenPgpKeyViewModel); - _.extend(PopupsViewOpenPgpKeyViewModel.prototype, KnoinAbstractViewModel.prototype); - - PopupsViewOpenPgpKeyViewModel.prototype.clearPopup = function () - { - this.key(''); - }; - - PopupsViewOpenPgpKeyViewModel.prototype.selectKey = function () - { - var oEl = this.keyDom(); - if (oEl) + LoginViewModel.prototype.submitForm = function () { - Utils.selectElement(oEl); - } - }; + this.submitCommand(); + }; - PopupsViewOpenPgpKeyViewModel.prototype.onShow = function (oOpenPgpKey) - { - this.clearPopup(); - - if (oOpenPgpKey) + LoginViewModel.prototype.selectLanguage = function () { - this.key(oOpenPgpKey.armor); - } - }; + kn.showScreenPopup(__webpack_require__(/*! View:Popup:Languages */ 32)); + }; - module.exports = PopupsViewOpenPgpKeyViewModel; + module.exports = LoginViewModel; -}(module, require)); -},{"App:Knoin":27,"Knoin:AbstractViewModel":30,"Utils":14,"_":25,"ko":22}],94:[function(require,module,exports){ + }()); -(function (module, require) { +/***/ } - 'use strict'; - - var - _ = require('_'), - - Globals = require('Globals'), - LinkBuilder = require('LinkBuilder'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @param {?} oScreen - * - * @constructor - * @extends KnoinAbstractViewModel - */ - function SettingsMenuViewModel(oScreen) - { - KnoinAbstractViewModel.call(this, 'Left', 'SettingsMenu'); - - this.leftPanelDisabled = Globals.leftPanelDisabled; - - this.menu = oScreen.menu; - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:RainLoop:SettingsMenu', 'SettingsMenuViewModel'], SettingsMenuViewModel); - _.extend(SettingsMenuViewModel.prototype, KnoinAbstractViewModel.prototype); - - SettingsMenuViewModel.prototype.link = function (sRoute) - { - return LinkBuilder.settings(sRoute); - }; - - SettingsMenuViewModel.prototype.backToMailBoxClick = function () - { - kn.setHash(LinkBuilder.inbox()); - }; - - module.exports = SettingsMenuViewModel; - -}(module, require)); -},{"App:Knoin":27,"Globals":9,"Knoin:AbstractViewModel":30,"LinkBuilder":11,"_":25}],95:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - key = require('key'), - - Enums = require('Enums'), - LinkBuilder = require('LinkBuilder'), - - Data = require('Storage:RainLoop:Data'), - - kn = require('App:Knoin'), - KnoinAbstractViewModel = require('Knoin:AbstractViewModel') - ; - - /** - * @constructor - * @extends KnoinAbstractViewModel - */ - function SettingsPaneViewModel() - { - KnoinAbstractViewModel.call(this, 'Right', 'SettingsPane'); - - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:RainLoop:SettingsPane', 'SettingsPaneViewModel'], SettingsPaneViewModel); - _.extend(SettingsPaneViewModel.prototype, KnoinAbstractViewModel.prototype); - - SettingsPaneViewModel.prototype.onBuild = function () - { - var self = this; - key('esc', Enums.KeyState.Settings, function () { - self.backToMailBoxClick(); - }); - }; - - SettingsPaneViewModel.prototype.onShow = function () - { - Data.message(null); - }; - - SettingsPaneViewModel.prototype.backToMailBoxClick = function () - { - kn.setHash(LinkBuilder.inbox()); - }; - - module.exports = SettingsPaneViewModel; - -}(module, require)); -},{"App:Knoin":27,"Enums":7,"Knoin:AbstractViewModel":30,"LinkBuilder":11,"Storage:RainLoop:Data":64,"_":25,"key":21}],96:[function(require,module,exports){ - -(function (module, require) { - - 'use strict'; - - var - _ = require('_'), - - kn = require('App:Knoin'), - AbstractSystemDropDownViewModel = require('View:RainLoop:AbstractSystemDropDown') - ; - - /** - * @constructor - * @extends AbstractSystemDropDownViewModel - */ - function SettingsSystemDropDownViewModel() - { - AbstractSystemDropDownViewModel.call(this); - kn.constructorEnd(this); - } - - kn.extendAsViewModel(['View:RainLoop:SettingsSystemDropDown', 'SettingsSystemDropDownViewModel'], SettingsSystemDropDownViewModel); - _.extend(SettingsSystemDropDownViewModel.prototype, AbstractSystemDropDownViewModel.prototype); - - module.exports = SettingsSystemDropDownViewModel; - -}(module, require)); -},{"App:Knoin":27,"View:RainLoop:AbstractSystemDropDown":71,"_":25}]},{},[1]); +}); \ 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 deleted file mode 100644 index 00ff25597..000000000 --- a/rainloop/v/0.0.0/static/js/app.min.js +++ /dev/null @@ -1,11 +0,0 @@ -/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -!function e(t,s,i){function o(a,r){if(!s[a]){if(!t[a]){var l="function"==typeof require&&require;if(!r&&l)return l(a,!0);if(n)return n(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=s[a]={exports:{}};t[a][0].call(u.exports,function(e){var s=t[a][1][e];return o(s?s:e)},u,u.exports,e,t,s,i)}return s[a].exports}for(var n="function"==typeof require&&require,a=0;a').appendTo("body"),a.$win.on("error",function(t){t&&t.originalEvent&&t.originalEvent.message&&-1===r.inArray(t.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&e.jsError(r.emptyFunction,t.originalEvent.message,t.originalEvent.filename,t.originalEvent.lineno,i.location&&i.location.toString?i.location.toString():"",a.$html.attr("class"),r.microtime()-a.now)}),a.$doc.on("keydown",function(e){e&&e.ctrlKey&&a.$html.addClass("rl-ctrl-key-pressed")}).on("keyup",function(e){e&&!e.ctrlKey&&a.$html.removeClass("rl-ctrl-key-pressed")})}var i=t("window"),o=t("_"),n=t("$"),a=t("Globals"),r=t("Utils"),l=t("LinkBuilder"),c=t("Events"),u=t("Storage:Settings"),d=t("Knoin:AbstractBoot");o.extend(s.prototype,d.prototype),s.prototype.remote=function(){return null},s.prototype.data=function(){return null},s.prototype.setupSettings=function(){return!0},s.prototype.download=function(e){var t=null,s=null,o=i.navigator.userAgent.toLowerCase();return o&&(o.indexOf("chrome")>-1||o.indexOf("chrome")>-1)&&(s=i.document.createElement("a"),s.href=e,i.document.createEvent&&(t=i.document.createEvent("MouseEvents"),t&&t.initEvent&&s.dispatchEvent))?(t.initEvent("click",!0,!0),s.dispatchEvent(t),!0):(a.bMobileDevice?(i.open(e,"_self"),i.focus()):this.iframe.attr("src",e),!0)},s.prototype.setTitle=function(e){e=(r.isNormal(e)&&0o;o++)g=e.Result["@Collection"][o],g&&"Object/Message"===g["@Object"]&&(m=h[o],m&&m.initByJson(g)||(m=C.newInstanceFromJson(g)),m&&(y.hasNewMessageAndRemoveFromCache(m.folderFullNameRaw,m.uid)&&5>=S&&(S++,m.newForAnimation(!0)),m.deleted(!1),t?y.initMessageFlagsFromCache(m):y.storeMessageFlagsToCache(m),m.lastInCollapsedThread(s&&-1i;i++)n=t[i],n&&(r=n.FullNameRaw,a=y.getFolderFromCacheList(r),a||(a=w.newInstanceFromJson(n),a&&(y.setFolderToCacheList(r,a),y.setFolderFullNameRaw(a.fullNameHash,r))),a&&(a.collapsed(!s.isFolderExpanded(a.fullNameHash)),n.Extended&&(n.Extended.Hash&&y.setFolderHash(a.fullNameRaw,n.Extended.Hash),d.isNormal(n.Extended.MessageCount)&&a.messageCountAll(n.Extended.MessageCount),d.isNormal(n.Extended.MessageUnseenCount)&&a.messageCountUnread(n.Extended.MessageUnseenCount)),l=n.SubFolders,l&&"Collection/FolderCollection"===l["@Object"]&&l["@Collection"]&&d.isArray(l["@Collection"])&&a.subFolders(this.folderResponseParseRec(e,l["@Collection"])),c.push(a)));return c},s.prototype.setFolders=function(e){var t=[],s=!1,i=function(e){return""===e||c.Values.UnuseOptionValue===e||null!==y.getFolderFromCacheList(e)?e:""};e&&e.Result&&"Collection/FolderCollection"===e.Result["@Object"]&&e.Result["@Collection"]&&d.isArray(e.Result["@Collection"])&&(d.isUnd(e.Result.Namespace)||(b.namespace=e.Result.Namespace),b.threading(!!f.settingsGet("UseImapThread")&&e.Result.IsThreadsSupported&&!0),t=this.folderResponseParseRec(b.namespace,e.Result["@Collection"]),b.folderList(t),e.Result.SystemFolders&&""==""+f.settingsGet("SentFolder")+f.settingsGet("DraftFolder")+f.settingsGet("SpamFolder")+f.settingsGet("TrashFolder")+f.settingsGet("ArchiveFolder")+f.settingsGet("NullFolder")&&(f.settingsSet("SentFolder",e.Result.SystemFolders[2]||null),f.settingsSet("DraftFolder",e.Result.SystemFolders[3]||null),f.settingsSet("SpamFolder",e.Result.SystemFolders[4]||null),f.settingsSet("TrashFolder",e.Result.SystemFolders[5]||null),f.settingsSet("ArchiveFolder",e.Result.SystemFolders[12]||null),s=!0),b.sentFolder(i(f.settingsGet("SentFolder"))),b.draftFolder(i(f.settingsGet("DraftFolder"))),b.spamFolder(i(f.settingsGet("SpamFolder"))),b.trashFolder(i(f.settingsGet("TrashFolder"))),b.archiveFolder(i(f.settingsGet("ArchiveFolder"))),s&&S.saveSystemFolders(d.emptyFunction,{SentFolder:b.sentFolder(),DraftFolder:b.draftFolder(),SpamFolder:b.spamFolder(),TrashFolder:b.trashFolder(),ArchiveFolder:b.archiveFolder(),NullFolder:"NullFolder"}),m.set(r.ClientSideKeyName.FoldersLashHash,e.Result.FoldersHash))},s.prototype.isFolderExpanded=function(e){var t=m.get(r.ClientSideKeyName.ExpandedFolders);return d.isArray(t)&&-1!==o.indexOf(t,e)},s.prototype.setExpandedFolder=function(e,t){var s=m.get(r.ClientSideKeyName.ExpandedFolders);d.isArray(s)||(s=[]),t?(s.push(e),s=o.uniq(s)):s=o.without(s,e),m.set(r.ClientSideKeyName.ExpandedFolders,s)},s.prototype.initLayoutResizer=function(e,t,s){var i=60,o=155,a=n(e),r=n(t),l=m.get(s)||null,c=function(e){e&&(a.css({width:""+e+"px"}),r.css({left:""+e+"px"}))},u=function(e){if(e)a.resizable("disable"),c(i);else{a.resizable("enable");var t=d.pInt(m.get(s))||o;c(t>o?t:o)}},p=function(e,t){t&&t.size&&t.size.width&&(m.set(s,t.size.width),r.css({left:""+t.size.width+"px"}))};null!==l&&c(l>o?l:o),a.resizable({helper:"ui-resizable-helper",minWidth:o,maxWidth:350,handles:"e",stop:p}),h.sub("left-panel.off",function(){u(!0)}),h.sub("left-panel.on",function(){u(!1)})},s.prototype.bootstartLoginScreen=function(){var e=d.pString(f.settingsGet("CustomLoginLink"));e?(g.routeOff(),g.setHash(p.root(),!0),g.routeOff(),o.defer(function(){i.location.href=e})):(g.hideLoading(),g.startScreens([t("Screen:RainLoop:Login")]),u.runHook("rl-start-login-screens"),h.pub("rl.bootstart-login-screens"))},s.prototype.bootstart=function(){R.prototype.bootstart.call(this),b.populateDataOnStart();var e=this,s=f.settingsGet("JsHash"),a=d.pInt(f.settingsGet("ContactsSyncInterval")),c=f.settingsGet("AllowGoogleSocial"),m=f.settingsGet("AllowFacebookSocial"),y=f.settingsGet("AllowTwitterSocial");d.initOnStartOrLangChange(function(){n.extend(!0,n.magnificPopup.defaults,{tClose:d.i18n("MAGNIFIC_POPUP/CLOSE"),tLoading:d.i18n("MAGNIFIC_POPUP/LOADING"),gallery:{tPrev:d.i18n("MAGNIFIC_POPUP/GALLERY_PREV"),tNext:d.i18n("MAGNIFIC_POPUP/GALLERY_NEXT"),tCounter:d.i18n("MAGNIFIC_POPUP/GALLERY_COUNTER")},image:{tError:d.i18n("MAGNIFIC_POPUP/IMAGE_ERROR")},ajax:{tError:d.i18n("MAGNIFIC_POPUP/AJAX_ERROR")}})},this),i.SimplePace&&(i.SimplePace.set(70),i.SimplePace.sleep()),l.leftPanelDisabled.subscribe(function(e){h.pub("left-panel."+(e?"off":"on"))}),f.settingsGet("Auth")?(this.setTitle(d.i18n("TITLES/LOADING")),this.folders(o.bind(function(s){g.hideLoading(),s?(i.$LAB&&i.crypto&&i.crypto.getRandomValues&&f.capa(r.Capa.OpenPGP)?i.$LAB.script(i.openpgp?"":p.openPgpJs()).wait(function(){i.openpgp&&(b.openpgpKeyring=new i.openpgp.Keyring,b.capaOpenPGP(!0),h.pub("openpgp.init"),e.reloadOpenPgpKeys())}):b.capaOpenPGP(!1),g.startScreens([t("Screen:RainLoop:MailBox"),t("Screen:RainLoop:Settings"),t("Screen:RainLoop:About")]),(c||m||y)&&e.socialUsers(!0),h.sub("interval.2m",function(){e.folderInformation("INBOX")}),h.sub("interval.2m",function(){var t=b.currentFolderFullNameRaw();"INBOX"!==t&&e.folderInformation(t)}),h.sub("interval.3m",function(){e.folderInformationMultiply()}),h.sub("interval.5m",function(){e.quota()}),h.sub("interval.10m",function(){e.folders()}),a=a>=5?a:20,a=320>=a?a:320,i.setInterval(function(){e.contactsSync()},6e4*a+5e3),o.delay(function(){e.contactsSync()},5e3),o.delay(function(){e.folderInformationMultiply(!0)},500),u.runHook("rl-start-user-screens"),h.pub("rl.bootstart-user-screens"),f.settingsGet("AccountSignMe")&&i.navigator.registerProtocolHandler&&o.delay(function(){try{i.navigator.registerProtocolHandler("mailto",i.location.protocol+"//"+i.location.host+i.location.pathname+"?mailto&to=%s",""+(f.settingsGet("Title")||"RainLoop"))}catch(e){}f.settingsGet("MailToEmail")&&d.mailToHelper(f.settingsGet("MailToEmail"),t("View:Popup:Compose"))},500),l.bMobileDevice||o.defer(function(){e.initLayoutResizer("#rl-left","#rl-right",r.ClientSideKeyName.FolderListSize)})):e.bootstartLoginScreen(),i.SimplePace&&i.SimplePace.set(100)},this))):(this.bootstartLoginScreen(),i.SimplePace&&i.SimplePace.set(100)),c&&(i["rl_"+s+"_google_service"]=function(){b.googleActions(!0),e.socialUsers()}),m&&(i["rl_"+s+"_facebook_service"]=function(){b.facebookActions(!0),e.socialUsers()}),y&&(i["rl_"+s+"_twitter_service"]=function(){b.twitterActions(!0),e.socialUsers()}),h.sub("interval.1m",function(){l.momentTrigger(!l.momentTrigger())}),u.runHook("rl-start-screens"),h.pub("rl.bootstart-end")},e.exports=new s}(t,e)},{$:20,"App:Abstract":2,"App:Knoin":27,Consts:6,Enums:7,Events:8,Globals:9,LinkBuilder:11,"Model:Account":31,"Model:Email":37,"Model:Folder":40,"Model:Identity":41,"Model:Message":42,"Model:OpenPgpKey":43,Plugins:12,"Screen:RainLoop:About":44,"Screen:RainLoop:Login":46,"Screen:RainLoop:MailBox":47,"Screen:RainLoop:Settings":48,"Settings:RainLoop:Accounts":49,"Settings:RainLoop:ChangePassword":50,"Settings:RainLoop:Contacts":51,"Settings:RainLoop:Filters":52,"Settings:RainLoop:Folders":53,"Settings:RainLoop:General":54,"Settings:RainLoop:Identities":55,"Settings:RainLoop:Identity":56,"Settings:RainLoop:OpenPGP":57,"Settings:RainLoop:Security":58,"Settings:RainLoop:Social":59,"Settings:RainLoop:Themes":60,"Storage:LocalStorage":65,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,Utils:14,"View:Popup:Ask":80,"View:Popup:Compose":82,"View:Popup:FolderSystem":87,_:25,moment:23,window:26}],4:[function(e,t){!function(e,t){"use strict";e.exports=function(e){var s=t("window"),i=t("_"),o=t("$"),n=t("Globals"),a=t("Plugins"),r=t("Utils"),l=t("Enums"),c=t("Model:Email");n.__APP=e,e.setupSettings(),a.__boot=e,a.__remote=e.remote(),a.__data=e.data(),n.$html.addClass(n.bMobileDevice?"mobile":"no-mobile"),n.$win.keydown(r.killCtrlAandS).keyup(r.killCtrlAandS),n.$win.unload(function(){n.bUnload=!0}),n.$html.on("click.dropdown.data-api",function(){r.detectDropdownVisibility()}),s.rl=s.rl||{},s.rl.addHook=i.bind(a.addHook,a),s.rl.settingsGet=i.bind(a.mainSettingsGet,a),s.rl.remoteRequest=i.bind(a.remoteRequest,a),s.rl.pluginSettingsGet=i.bind(a.settingsGet,a),s.rl.createCommand=r.createCommand,s.rl.EmailModel=c,s.rl.Enums=l,s.__APP_BOOT=function(t){o(function(){s.rainloopTEMPLATES&&s.rainloopTEMPLATES[0]?(o("#rl-templates").html(s.rainloopTEMPLATES[0]),i.delay(function(){e.bootstart(),n.$html.removeClass("no-js rl-booted-trigger").addClass("rl-booted")},10)):t(!1),s.__APP_BOOT=null})}}}(t,e)},{$:20,Enums:7,Globals:9,"Model:Email":37,Plugins:12,Utils:14,_:25,window:26}],5:[function(e,t){!function(e){"use strict";var t={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(e){return t.encode(e).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(e){var s,i,o,n,a,r,l,c="",u=0;for(e=t._utf8_encode(e);u>2,a=(3&s)<<4|i>>4,r=(15&i)<<2|o>>6,l=63&o,isNaN(i)?r=l=64:isNaN(o)&&(l=64),c=c+this._keyStr.charAt(n)+this._keyStr.charAt(a)+this._keyStr.charAt(r)+this._keyStr.charAt(l);return c},decode:function(e){var s,i,o,n,a,r,l,c="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u>4,i=(15&a)<<4|r>>2,o=(3&r)<<6|l,c+=String.fromCharCode(s),64!==r&&(c+=String.fromCharCode(i)),64!==l&&(c+=String.fromCharCode(o));return t._utf8_decode(c)},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");for(var t="",s=0,i=e.length,o=0;i>s;s++)o=e.charCodeAt(s),128>o?t+=String.fromCharCode(o):o>127&&2048>o?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128));return t},_utf8_decode:function(e){for(var t="",s=0,i=0,o=0,n=0;si?(t+=String.fromCharCode(i),s++):i>191&&224>i?(o=e.charCodeAt(s+1),t+=String.fromCharCode((31&i)<<6|63&o),s+=2):(o=e.charCodeAt(s+1),n=e.charCodeAt(s+2),t+=String.fromCharCode((15&i)<<12|(63&o)<<6|63&n),s+=3);return t}};e.exports=t}(t,e)},{}],6:[function(e,t){!function(e){"use strict";var t={};t.Values={},t.DataImages={},t.Defaults={},t.Defaults.MessagesPerPage=20,t.Defaults.ContactsPerPage=50,t.Defaults.MessagesPerPageArray=[10,20,30,50,100],t.Defaults.DefaultAjaxTimeout=3e4,t.Defaults.SearchAjaxTimeout=3e5,t.Defaults.SendMessageAjaxTimeout=3e5,t.Defaults.SaveMessageAjaxTimeout=2e5,t.Defaults.ContactsSyncAjaxTimeout=2e5,t.Values.UnuseOptionValue="__UNUSE__",t.Values.ClientSideStorageIndexName="rlcsc",t.Values.ImapDefaulPort=143,t.Values.ImapDefaulSecurePort=993,t.Values.SmtpDefaulPort=25,t.Values.SmtpDefaulSecurePort=465,t.Values.MessageBodyCacheLimit=15,t.Values.AjaxErrorLimit=7,t.Values.TokenErrorLimit=10,t.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=",t.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",e.exports=t}(t)},{}],7:[function(e,t){!function(e){"use strict";var t={};t.StorageResultType={Success:"success",Abort:"abort",Error:"error",Unload:"unload"},t.State={Empty:10,Login:20,Auth:30},t.StateType={Webmail:0,Admin:1},t.Capa={Prem:"PREM",TwoFactor:"TWO_FACTOR",OpenPGP:"OPEN_PGP",Prefetch:"PREFETCH",Gravatar:"GRAVATAR",Themes:"THEMES",Filters:"FILTERS",AdditionalAccounts:"ADDITIONAL_ACCOUNTS",AdditionalIdentities:"ADDITIONAL_IDENTITIES"},t.KeyState={All:"all",None:"none",ContactList:"contact-list",MessageList:"message-list",FolderList:"folder-list",MessageView:"message-view",Compose:"compose",Settings:"settings",Menu:"menu",PopupComposeOpenPGP:"compose-open-pgp",PopupKeyboardShortcutsHelp:"popup-keyboard-shortcuts-help",PopupAsk:"popup-ask"},t.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,Archive:15,NotSpam:80,User:99},t.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"},t.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2},t.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft",EditAsNew:"editasnew"},t.UploadErrorCode={Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99},t.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4,Archive:5},t.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3,FolderListSize:4},t.EventKeyCode={Backspace:8,Tab:9,Enter:13,Esc:27,PageUp:33,PageDown:34,Left:37,Right:39,Up:38,Down:40,End:35,Home:36,Space:32,Insert:45,Delete:46,A:65,S:83},t.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3},t.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6},t.DesktopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9},t.MessagePriority={Low:5,Normal:3,High:1},t.EditorDefaultType={Html:"Html",Plain:"Plain"},t.CustomThemeType={Light:"Light",Dark:"Dark"},t.ServerSecure={None:0,SSL:1,TLS:2},t.SearchDateType={All:-1,Days3:3,Days7:7,Month:30},t.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0},t.InterfaceAnimation={None:"None",Normal:"Normal",Full:"Full"},t.Layout={NoPreview:0,SidePreview:1,BottomPreview:2},t.FilterConditionField={From:"From",To:"To",Recipient:"Recipient",Subject:"Subject"},t.FilterConditionType={Contains:"Contains",NotContains:"NotContains",EqualTo:"EqualTo",NotEqualTo:"NotEqualTo"},t.FiltersAction={None:"None",Move:"Move",Discard:"Discard",Forward:"Forward"},t.FilterRulesType={And:"And",Or:"Or"},t.SignedVerifyStatus={UnknownPublicKeys:-4,UnknownPrivateKey:-3,Unverified:-2,Error:-1,None:0,Success:1},t.ContactPropertyType={Unknown:0,FullName:10,FirstName:15,LastName:16,MiddleName:16,Nick:18,NamePrefix:20,NameSuffix:21,Email:30,Phone:31,Web:32,Birthday:40,Facebook:90,Skype:91,GitHub:92,Note:110,Custom:250},t.Notification={InvalidToken:101,AuthError:102,AccessError:103,ConnectionError:104,CaptchaError:105,SocialFacebookLoginAccessDisable:106,SocialTwitterLoginAccessDisable:107,SocialGoogleLoginAccessDisable:108,DomainNotAllowed:109,AccountNotAllowed:110,AccountTwoFactorAuthRequired:120,AccountTwoFactorAuthError:121,CouldNotSaveNewPassword:130,CurrentPasswordIncorrect:131,NewPasswordShort:132,NewPasswordWeak:133,NewPasswordForbidden:134,ContactsSyncError:140,CantGetMessageList:201,CantGetMessage:202,CantDeleteMessage:203,CantMoveMessage:204,CantCopyMessage:205,CantSaveMessage:301,CantSendMessage:302,InvalidRecipients:303,CantCreateFolder:400,CantRenameFolder:401,CantDeleteFolder:402,CantSubscribeFolder:403,CantUnsubscribeFolder:404,CantDeleteNonEmptyFolder:405,CantSaveSettings:501,CantSavePluginSettings:502,DomainAlreadyExists:601,CantInstallPackage:701,CantDeletePackage:702,InvalidPluginPackage:703,UnsupportedPluginPackage:704,LicensingServerIsUnavailable:710,LicensingExpired:711,LicensingBanned:712,DemoSendMessageError:750,AccountAlreadyExists:801,MailServerError:901,ClientViewError:902,InvalidInputArgument:903,UnknownNotification:999,UnknownError:999},e.exports=t -}(t,e)},{}],8:[function(e,t){!function(e,t){"use strict";function s(){this.oSubs={}}var i=t("_"),o=t("Utils"),n=t("Plugins");s.prototype.oSubs={},s.prototype.sub=function(e,t,s){return o.isUnd(this.oSubs[e])&&(this.oSubs[e]=[]),this.oSubs[e].push([t,s]),this},s.prototype.pub=function(e,t){return n.runHook("rl-pub",[e,t]),o.isUnd(this.oSubs[e])||i.each(this.oSubs[e],function(e){e[0]&&e[0].apply(e[1]||null,t||[])}),this},e.exports=new s}(t,e)},{Plugins:12,Utils:14,_:25}],9:[function(e,t){!function(e,t){"use strict";var s={},i=t("window"),o=t("_"),n=t("$"),a=t("ko"),r=t("key"),l=t("Enums");s.$win=n(i),s.$doc=n(i.document),s.$html=n("html"),s.$div=n("
"),s.now=(new i.Date).getTime(),s.momentTrigger=a.observable(!0),s.dropdownVisibility=a.observable(!1).extend({rateLimit:0}),s.tooltipTrigger=a.observable(!1).extend({rateLimit:0}),s.langChangeTrigger=a.observable(!0),s.useKeyboardShortcuts=a.observable(!0),s.iAjaxErrorCount=0,s.iTokenErrorCount=0,s.iMessageBodyCacheCount=0,s.bUnload=!1,s.sUserAgent=(i.navigator.userAgent||"").toLowerCase(),s.bIsiOSDevice=-1'+this.editor.getData()+"
":this.editor.getData():""},s.prototype.modeToggle=function(e){this.editor&&(e?"plain"===this.editor.mode&&this.editor.setMode("wysiwyg"):"wysiwyg"===this.editor.mode&&this.editor.setMode("plain"),this.resize())},s.prototype.setHtml=function(e,t){this.editor&&(this.modeToggle(!0),this.editor.setData(e),t&&this.focus())},s.prototype.setPlain=function(e,t){if(this.editor){if(this.modeToggle(!1),"plain"===this.editor.mode&&this.editor.plugins.plain&&this.editor.__plain)return this.editor.__plain.setRawData(e);this.editor.setData(e),t&&this.focus()}},s.prototype.init=function(){if(this.$element&&this.$element[0]){var e=this,t=function(){var t=n.oHtmlEditorDefaultConfig,s=a.settingsGet("Language"),o=!!a.settingsGet("AllowHtmlEditorSourceButton");o&&t.toolbarGroups&&!t.toolbarGroups.__SourceInited&&(t.toolbarGroups.__SourceInited=!0,t.toolbarGroups.push({name:"document",groups:["mode","document","doctools"]})),t.enterMode=i.CKEDITOR.ENTER_BR,t.shiftEnterMode=i.CKEDITOR.ENTER_BR,t.language=n.oHtmlEditorLangsMap[s]||"en",i.CKEDITOR.env&&(i.CKEDITOR.env.isCompatible=!0),e.editor=i.CKEDITOR.appendTo(e.$element[0],t),e.editor.on("key",function(e){return e&&e.data&&9===e.data.keyCode?!1:void 0}),e.editor.on("blur",function(){e.blurTrigger()}),e.editor.on("mode",function(){e.blurTrigger(),e.fOnModeChange&&e.fOnModeChange("plain"!==e.editor.mode)}),e.editor.on("focus",function(){e.focusTrigger()}),e.fOnReady&&e.editor.on("instanceReady",function(){e.editor.setKeystroke(i.CKEDITOR.CTRL+65,"selectAll"),e.fOnReady(),e.__resizable=!0,e.resize()})};i.CKEDITOR?t():i.__initEditor=t}},s.prototype.focus=function(){this.editor&&this.editor.focus()},s.prototype.blur=function(){this.editor&&this.editor.focusManager.blur(!0)},s.prototype.resize=function(){if(this.editor&&this.__resizable)try{this.editor.resize(this.$element.width(),this.$element.innerHeight())}catch(e){}},s.prototype.clear=function(e){this.setHtml("",e)},e.exports=s}(t,e)},{Globals:9,"Storage:Settings":69,_:25,window:26}],11:[function(e,t){!function(e,t){"use strict";function s(){var e=t("Storage:Settings");this.sBase="#/",this.sServer="./?",this.sVersion=e.settingsGet("Version"),this.sSpecSuffix=e.settingsGet("AuthAccountHash")||"0",this.sStaticPrefix=e.settingsGet("StaticPrefix")||"rainloop/v/"+this.sVersion+"/static/"}var i=t("window"),o=t("Utils");s.prototype.root=function(){return this.sBase},s.prototype.attachmentDownload=function(e){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+e},s.prototype.attachmentPreview=function(e){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+e},s.prototype.attachmentPreviewAsPlain=function(e){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+e},s.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},s.prototype.uploadContacts=function(){return this.sServer+"/UploadContacts/"+this.sSpecSuffix+"/"},s.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},s.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},s.prototype.change=function(e){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+i.encodeURIComponent(e)+"/"},s.prototype.ajax=function(e){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+e},s.prototype.messageViewLink=function(e){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+e},s.prototype.messageDownloadLink=function(e){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+e},s.prototype.avatarLink=function(e){return this.sServer+"/Raw/0/Avatar/"+i.encodeURIComponent(e)+"/"},s.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},s.prototype.messagePreview=function(){return this.sBase+"mailbox/message-preview"},s.prototype.settings=function(e){var t=this.sBase+"settings";return o.isUnd(e)||""===e||(t+="/"+e),t},s.prototype.about=function(){return this.sBase+"about"},s.prototype.admin=function(e){var t=this.sBase;switch(e){case"AdminDomains":t+="domains";break;case"AdminSecurity":t+="security";break;case"AdminLicensing":t+="licensing"}return t},s.prototype.mailBox=function(e,t,s){t=o.isNormal(t)?o.pInt(t):1,s=o.pString(s);var i=this.sBase+"mailbox/";return""!==e&&(i+=encodeURI(e)),t>1&&(i=i.replace(/[\/]+$/,""),i+="/p"+t),""!==s&&(i=i.replace(/[\/]+$/,""),i+="/"+encodeURI(s)),i},s.prototype.phpInfo=function(){return this.sServer+"Info"},s.prototype.langLink=function(e){return this.sServer+"/Lang/0/"+encodeURI(e)+"/"+this.sVersion+"/"},s.prototype.exportContactsVcf=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsVcf/"},s.prototype.exportContactsCsv=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsCsv/"},s.prototype.emptyContactPic=function(){return this.sStaticPrefix+"css/images/empty-contact.png"},s.prototype.sound=function(e){return this.sStaticPrefix+"sounds/"+e},s.prototype.themePreviewLink=function(e){var t="rainloop/v/"+this.sVersion+"/";return"@custom"===e.substr(-7)&&(e=o.trim(e.substring(0,e.length-7)),t=""),t+"themes/"+encodeURI(e)+"/images/preview.png"},s.prototype.notificationMailIcon=function(){return this.sStaticPrefix+"css/images/icom-message-notification.png"},s.prototype.openPgpJs=function(){return this.sStaticPrefix+"js/openpgp.min.js"},s.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},s.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},s.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},e.exports=new s}(t,e)},{"Storage:Settings":69,Utils:14,window:26}],12:[function(e,t){!function(e,t){"use strict";function s(){this.__boot=null,this.__data=null,this.__remote=null,this.oSettings=t("Storage:Settings"),this.oViewModelsHooks={},this.oSimpleHooks={}}var i=t("_"),o=t("Utils");s.prototype.__boot=null,s.prototype.__data=null,s.prototype.__remote=null,s.prototype.oViewModelsHooks={},s.prototype.oSimpleHooks={},s.prototype.addHook=function(e,t){o.isFunc(t)&&(o.isArray(this.oSimpleHooks[e])||(this.oSimpleHooks[e]=[]),this.oSimpleHooks[e].push(t))},s.prototype.runHook=function(e,t){o.isArray(this.oSimpleHooks[e])&&(t=t||[],i.each(this.oSimpleHooks[e],function(e){e.apply(null,t)}))},s.prototype.mainSettingsGet=function(e){return this.oSettings.settingsGet(e)},s.prototype.remoteRequest=function(e,t,s,i,o,n){this.__remote&&this.__remote.defaultRequest(e,t,s,i,o,n)},s.prototype.settingsGet=function(e,t){var s=this.oSettings.settingsGet("Plugins");return s=s&&!o.isUnd(s[e])?s[e]:null,s?o.isUnd(s[t])?null:s[t]:null},e.exports=new s}(t,e)},{"Storage:Settings":69,Utils:14,_:25}],13:[function(e,t){!function(e,t){"use strict";function s(e,t,s,o,a,r){this.list=e,this.listChecked=n.computed(function(){return i.filter(this.list(),function(e){return e.checked()})},this).extend({rateLimit:0}),this.isListChecked=n.computed(function(){return 00&&-10)return i.newSelectPosition(s,a.shift),!1}})}},s.prototype.autoSelect=function(e){this.bAutoSelect=!!e},s.prototype.getItemUid=function(e){var t="",s=this.oCallbacks.onItemGetUid||null;return s&&e&&(t=s(e)),t.toString()},s.prototype.newSelectPosition=function(e,t,s){var o=0,n=10,a=!1,l=!1,c=null,u=this.list(),d=u?u.length:0,p=this.focusedItem();if(d>0)if(p){if(p)if(r.EventKeyCode.Down===e||r.EventKeyCode.Up===e||r.EventKeyCode.Insert===e||r.EventKeyCode.Space===e)i.each(u,function(t){if(!l)switch(e){case r.EventKeyCode.Up:p===t?l=!0:c=t;break;case r.EventKeyCode.Down:case r.EventKeyCode.Insert:a?(c=t,l=!0):p===t&&(a=!0)}});else if(r.EventKeyCode.Home===e||r.EventKeyCode.End===e)r.EventKeyCode.Home===e?c=u[0]:r.EventKeyCode.End===e&&(c=u[u.length-1]);else if(r.EventKeyCode.PageDown===e){for(;d>o;o++)if(p===u[o]){o+=n,o=o>d-1?d-1:o,c=u[o];break}}else if(r.EventKeyCode.PageUp===e)for(o=d;o>=0;o--)if(p===u[o]){o-=n,o=0>o?0:o,c=u[o];break}}else r.EventKeyCode.Down===e||r.EventKeyCode.Insert===e||r.EventKeyCode.Space===e||r.EventKeyCode.Home===e||r.EventKeyCode.PageUp===e?c=u[0]:(r.EventKeyCode.Up===e||r.EventKeyCode.End===e||r.EventKeyCode.PageDown===e)&&(c=u[u.length-1]);c?(this.focusedItem(c),p&&(t?(r.EventKeyCode.Up===e||r.EventKeyCode.Down===e)&&p.checked(!p.checked()):(r.EventKeyCode.Insert===e||r.EventKeyCode.Space===e)&&p.checked(!p.checked())),!this.bAutoSelect&&!s||this.isListChecked()||r.EventKeyCode.Space===e||this.selectedItem(c),this.scrollToFocused()):p&&(!t||r.EventKeyCode.Up!==e&&r.EventKeyCode.Down!==e?(r.EventKeyCode.Insert===e||r.EventKeyCode.Space===e)&&p.checked(!p.checked()):p.checked(!p.checked()),this.focusedItem(p))},s.prototype.scrollToFocused=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var e=20,t=o(this.sItemFocusedSelector,this.oContentScrollable),s=t.position(),i=this.oContentVisible.height(),n=t.outerHeight();return s&&(s.top<0||s.top+n>i)?(this.oContentScrollable.scrollTop(s.top<0?this.oContentScrollable.scrollTop()+s.top-e:this.oContentScrollable.scrollTop()+s.top-i+n+e),!0):!1},s.prototype.scrollToTop=function(e){return this.oContentVisible&&this.oContentScrollable?(e?this.oContentScrollable.scrollTop(0):this.oContentScrollable.stop().animate({scrollTop:0},200),!0):!1},s.prototype.eventClickFunction=function(e,t){var s=this.getItemUid(e),i=0,o=0,n=null,a="",r=!1,l=!1,c=[],u=!1;if(t&&t.shiftKey&&""!==s&&""!==this.sLastUid&&s!==this.sLastUid)for(c=this.list(),u=e.checked(),i=0,o=c.length;o>i;i++)n=c[i],a=this.getItemUid(n),r=!1,(a===this.sLastUid||a===s)&&(r=!0),r&&(l=!l),(l||r)&&n.checked(u);this.sLastUid=""===s?"":s},s.prototype.actionClick=function(e,t){if(e){var s=!0,i=this.getItemUid(e);t&&(!t.shiftKey||t.ctrlKey||t.altKey?!t.ctrlKey||t.shiftKey||t.altKey||(s=!1,this.focusedItem(e),this.selectedItem()&&e!==this.selectedItem()&&this.selectedItem().checked(!0),e.checked(!e.checked())):(s=!1,""===this.sLastUid&&(this.sLastUid=i),e.checked(!e.checked()),this.eventClickFunction(e,t),this.focusedItem(e))),s&&(this.focusedItem(e),this.selectedItem(e),this.scrollToFocused())}},s.prototype.on=function(e,t){this.oCallbacks[e]=t},e.exports=s}(t,e)},{$:20,Enums:7,Utils:14,_:25,key:21,ko:22}],14:[function(e,t){!function(e,t){"use strict";var s={},i=t("window"),o=t("_"),n=t("$"),a=t("ko"),r=t("Enums"),l=t("Consts"),c=t("Globals");s.trim=n.trim,s.inArray=n.inArray,s.isArray=o.isArray,s.isFunc=o.isFunction,s.isUnd=o.isUndefined,s.isNull=o.isNull,s.emptyFunction=function(){},s.isNormal=function(e){return!s.isUnd(e)&&!s.isNull(e)},s.windowResize=o.debounce(function(e){s.isUnd(e)?c.$win.resize():i.setTimeout(function(){c.$win.resize()},e)},50),s.isPosNumeric=function(e,t){return s.isNormal(e)?(s.isUnd(t)?0:!t)?/^[1-9]+[0-9]*$/.test(e.toString()):/^[0-9]*$/.test(e.toString()):!1},s.pInt=function(e,t){var o=s.isNormal(e)&&""!==e?i.parseInt(e,10):t||0;return i.isNaN(o)?t||0:o},s.pString=function(e){return s.isNormal(e)?""+e:""},s.isNonEmptyArray=function(e){return s.isArray(e)&&0n;n++)o=s[n].split("="),t[i.decodeURIComponent(o[0])]=i.decodeURIComponent(o[1]);return t},s.mailToHelper=function(e,o){if(e&&"mailto:"===e.toString().substr(0,7).toLowerCase()){e=e.toString().substr(7);var n={},a=null,l=e.replace(/\?.+$/,""),c=e.replace(/^[^\?]*\?/,""),u=t("Model:Email");return a=new u,a.parse(i.decodeURIComponent(l)),a&&a.email&&(n=s.simpleQueryParser(c),t("App:Knoin").showScreenPopup(o,[r.ComposeType.Empty,null,[a],s.isUnd(n.subject)?null:s.pString(n.subject),s.isUnd(n.body)?null:s.plainToHtml(s.pString(n.body))])),!0}return!1},s.rsaEncode=function(e,t,o,n){if(i.crypto&&i.crypto.getRandomValues&&i.RSAKey&&t&&o&&n){var a=new i.RSAKey;if(a.setPublic(n,o),e=a.encrypt(s.fakeMd5()+":"+e+":"+s.fakeMd5()),!1!==e)return"rsa:"+t+":"+e}return!1},s.rsaEncode.supported=!!(i.crypto&&i.crypto.getRandomValues&&i.RSAKey),s.exportPath=function(e,t,o){for(var n=null,a=e.split("."),r=o||i;a.length&&(n=a.shift());)a.length||s.isUnd(t)?r=r[n]?r[n]:r[n]={}:r[n]=t},s.pImport=function(e,t,s){e[t]=s},s.pExport=function(e,t,i){return s.isUnd(e[t])?i:e[t]},s.encodeHtml=function(e){return s.isNormal(e)?e.toString().replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):""},s.splitPlainText=function(e,t){var i="",o="",n=e,a=0,r=0;for(t=s.isUnd(t)?100:t;n.length>t;)o=n.substring(0,t),a=o.lastIndexOf(" "),r=o.lastIndexOf("\n"),-1!==r&&(a=r),-1===a&&(a=t),i+=o.substring(0,a)+"\n",n=n.substring(a+1);return i+n},s.timeOutAction=function(){var e={};return function(t,o,n){s.isUnd(e[t])&&(e[t]=0),i.clearTimeout(e[t]),e[t]=i.setTimeout(o,n)}}(),s.timeOutActionSecond=function(){var e={};return function(t,s,o){e[t]||(e[t]=i.setTimeout(function(){s(),e[t]=0},o))}}(),s.audio=function(){var e=!1;return function(t,s){if(!1===e)if(c.bIsiOSDevice)e=null;else{var o=!1,n=!1,a=i.Audio?new i.Audio:null;a&&a.canPlayType&&a.play?(o=""!==a.canPlayType('audio/mpeg; codecs="mp3"'),o||(n=""!==a.canPlayType('audio/ogg; codecs="vorbis"')),o||n?(e=a,e.preload="none",e.loop=!1,e.autoplay=!1,e.muted=!1,e.src=o?t:s):e=null):e=null}return e}}(),s.hos=function(e,t){return e&&i.Object&&i.Object.hasOwnProperty?i.Object.hasOwnProperty.call(e,t):!1},s.i18n=function(e,t,i){var o="",n=s.isUnd(c.oI18N[e])?s.isUnd(i)?e:i:c.oI18N[e];if(!s.isUnd(t)&&!s.isNull(t))for(o in t)s.hos(t,o)&&(n=n.replace("%"+o+"%",t[o]));return n},s.i18nToNode=function(e){o.defer(function(){n(".i18n",e).each(function(){var e=n(this),t="";t=e.data("i18n-text"),t?e.text(s.i18n(t)):(t=e.data("i18n-html"),t&&e.html(s.i18n(t)),t=e.data("i18n-placeholder"),t&&e.attr("placeholder",s.i18n(t)),t=e.data("i18n-title"),t&&e.attr("title",s.i18n(t)))})})},s.i18nReload=function(){i.rainloopI18N&&(c.oI18N=i.rainloopI18N||{},s.i18nToNode(c.$doc),c.langChangeTrigger(!c.langChangeTrigger())),i.rainloopI18N=null},s.initOnStartOrLangChange=function(e,t,s){e&&e.call(t),s?c.langChangeTrigger.subscribe(function(){e&&e.call(t),s.call(t)}):e&&c.langChangeTrigger.subscribe(e,t)},s.inFocus=function(){return i.document.activeElement?(s.isUnd(i.document.activeElement.__inFocusCache)&&(i.document.activeElement.__inFocusCache=n(i.document.activeElement).is("input,textarea,iframe,.cke_editable")),!!i.document.activeElement.__inFocusCache):!1},s.removeInFocus=function(){if(i.document&&i.document.activeElement&&i.document.activeElement.blur){var e=n(i.document.activeElement);e.is("input,textarea")&&i.document.activeElement.blur()}},s.removeSelection=function(){if(i&&i.getSelection){var e=i.getSelection();e&&e.removeAllRanges&&e.removeAllRanges()}else i.document&&i.document.selection&&i.document.selection.empty&&i.document.selection.empty()},s.replySubjectAdd=function(e,t){e=s.trim(e.toUpperCase()),t=s.trim(t.replace(/[\s]+/g," "));var i=!1,n=[],a="RE"===e,r="FWD"===e,l=!r;return""!==t&&o.each(t.split(":"),function(e){var t=s.trim(e);i||!/^(RE|FWD)$/i.test(t)&&!/^(RE|FWD)[\[\(][\d]+[\]\)]$/i.test(t)?(n.push(e),i=!0):(a||(a=!!/^RE/i.test(t)),r||(r=!!/^FWD/i.test(t)))}),l?a=!1:r=!1,s.trim((l?"Re: ":"Fwd: ")+(a?"Re: ":"")+(r?"Fwd: ":"")+s.trim(n.join(":")))},s.roundNumber=function(e,t){return i.Math.round(e*i.Math.pow(10,t))/i.Math.pow(10,t)},s.friendlySize=function(e){return e=s.pInt(e),e>=1073741824?s.roundNumber(e/1073741824,1)+"GB":e>=1048576?s.roundNumber(e/1048576,1)+"MB":e>=1024?s.roundNumber(e/1024,0)+"KB":e+"B"},s.log=function(e){i.console&&i.console.log&&i.console.log(e)},s.getNotification=function(e,t){return e=s.pInt(e),r.Notification.ClientViewError===e&&t?t:s.isUnd(c.oNotificationI18N[e])?"":c.oNotificationI18N[e]},s.initNotificationLanguage=function(){var e=c.oNotificationI18N||{};e[r.Notification.InvalidToken]=s.i18n("NOTIFICATIONS/INVALID_TOKEN"),e[r.Notification.AuthError]=s.i18n("NOTIFICATIONS/AUTH_ERROR"),e[r.Notification.AccessError]=s.i18n("NOTIFICATIONS/ACCESS_ERROR"),e[r.Notification.ConnectionError]=s.i18n("NOTIFICATIONS/CONNECTION_ERROR"),e[r.Notification.CaptchaError]=s.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),e[r.Notification.SocialFacebookLoginAccessDisable]=s.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),e[r.Notification.SocialTwitterLoginAccessDisable]=s.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),e[r.Notification.SocialGoogleLoginAccessDisable]=s.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),e[r.Notification.DomainNotAllowed]=s.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),e[r.Notification.AccountNotAllowed]=s.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),e[r.Notification.AccountTwoFactorAuthRequired]=s.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED"),e[r.Notification.AccountTwoFactorAuthError]=s.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR"),e[r.Notification.CouldNotSaveNewPassword]=s.i18n("NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD"),e[r.Notification.CurrentPasswordIncorrect]=s.i18n("NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT"),e[r.Notification.NewPasswordShort]=s.i18n("NOTIFICATIONS/NEW_PASSWORD_SHORT"),e[r.Notification.NewPasswordWeak]=s.i18n("NOTIFICATIONS/NEW_PASSWORD_WEAK"),e[r.Notification.NewPasswordForbidden]=s.i18n("NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT"),e[r.Notification.ContactsSyncError]=s.i18n("NOTIFICATIONS/CONTACTS_SYNC_ERROR"),e[r.Notification.CantGetMessageList]=s.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),e[r.Notification.CantGetMessage]=s.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),e[r.Notification.CantDeleteMessage]=s.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),e[r.Notification.CantMoveMessage]=s.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),e[r.Notification.CantCopyMessage]=s.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),e[r.Notification.CantSaveMessage]=s.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),e[r.Notification.CantSendMessage]=s.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),e[r.Notification.InvalidRecipients]=s.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),e[r.Notification.CantCreateFolder]=s.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),e[r.Notification.CantRenameFolder]=s.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),e[r.Notification.CantDeleteFolder]=s.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),e[r.Notification.CantDeleteNonEmptyFolder]=s.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),e[r.Notification.CantSubscribeFolder]=s.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),e[r.Notification.CantUnsubscribeFolder]=s.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),e[r.Notification.CantSaveSettings]=s.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),e[r.Notification.CantSavePluginSettings]=s.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),e[r.Notification.DomainAlreadyExists]=s.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),e[r.Notification.CantInstallPackage]=s.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),e[r.Notification.CantDeletePackage]=s.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),e[r.Notification.InvalidPluginPackage]=s.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),e[r.Notification.UnsupportedPluginPackage]=s.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),e[r.Notification.LicensingServerIsUnavailable]=s.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),e[r.Notification.LicensingExpired]=s.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),e[r.Notification.LicensingBanned]=s.i18n("NOTIFICATIONS/LICENSING_BANNED"),e[r.Notification.DemoSendMessageError]=s.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),e[r.Notification.AccountAlreadyExists]=s.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),e[r.Notification.MailServerError]=s.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),e[r.Notification.InvalidInputArgument]=s.i18n("NOTIFICATIONS/INVALID_INPUT_ARGUMENT"),e[r.Notification.UnknownNotification]=s.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),e[r.Notification.UnknownError]=s.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},s.getUploadErrorDescByCode=function(e){var t="";switch(s.pInt(e)){case r.UploadErrorCode.FileIsTooBig:t=s.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case r.UploadErrorCode.FilePartiallyUploaded:t=s.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case r.UploadErrorCode.FileNoUploaded:t=s.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case r.UploadErrorCode.MissingTempFolder:t=s.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case r.UploadErrorCode.FileOnSaveingError:t=s.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case r.UploadErrorCode.FileType:t=s.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:t=s.i18n("UPLOAD/ERROR_UNKNOWN")}return t},s.delegateRun=function(e,t,i,n){e&&e[t]&&(n=s.pInt(n),0>=n?e[t].apply(e,s.isArray(i)?i:[]):o.delay(function(){e[t].apply(e,s.isArray(i)?i:[])},n))},s.killCtrlAandS=function(e){if(e=e||i.event,e&&e.ctrlKey&&!e.shiftKey&&!e.altKey){var t=e.target||e.srcElement,s=e.keyCode||e.which;if(s===r.EventKeyCode.S)return void e.preventDefault();if(t&&t.tagName&&t.tagName.match(/INPUT|TEXTAREA/i))return;s===r.EventKeyCode.A&&(i.getSelection?i.getSelection().removeAllRanges():i.document.selection&&i.document.selection.clear&&i.document.selection.clear(),e.preventDefault())}},s.createCommand=function(e,t,i){var o=t?function(){return o&&o.canExecute&&o.canExecute()&&t.apply(e,Array.prototype.slice.call(arguments)),!1}:function(){};return o.enabled=a.observable(!0),i=s.isUnd(i)?!0:i,o.canExecute=a.computed(s.isFunc(i)?function(){return o.enabled()&&i.call(e)}:function(){return o.enabled()&&!!i}),o},s.initDataConstructorBySettings=function(e){e.editorDefaultType=a.observable(r.EditorDefaultType.Html),e.showImages=a.observable(!1),e.interfaceAnimation=a.observable(r.InterfaceAnimation.Full),e.contactsAutosave=a.observable(!1),c.sAnimationType=r.InterfaceAnimation.Full,e.capaThemes=a.observable(!1),e.allowLanguagesOnSettings=a.observable(!0),e.allowLanguagesOnLogin=a.observable(!0),e.useLocalProxyForExternalImages=a.observable(!1),e.desktopNotifications=a.observable(!1),e.useThreads=a.observable(!0),e.replySameFolder=a.observable(!0),e.useCheckboxesInList=a.observable(!0),e.layout=a.observable(r.Layout.SidePreview),e.usePreviewPane=a.computed(function(){return r.Layout.NoPreview!==e.layout()}),e.interfaceAnimation.subscribe(function(e){if(c.bMobileDevice||e===r.InterfaceAnimation.None)c.$html.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),c.sAnimationType=r.InterfaceAnimation.None;else switch(e){case r.InterfaceAnimation.Full:c.$html.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),c.sAnimationType=e;break;case r.InterfaceAnimation.Normal:c.$html.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),c.sAnimationType=e}}),e.interfaceAnimation.valueHasMutated(),e.desktopNotificationsPermisions=a.computed(function(){e.desktopNotifications();var t=s.notificationClass(),o=r.DesktopNotifications.NotSupported;if(t&&t.permission)switch(t.permission.toLowerCase()){case"granted":o=r.DesktopNotifications.Allowed;break;case"denied":o=r.DesktopNotifications.Denied;break;case"default":o=r.DesktopNotifications.NotAllowed}else i.webkitNotifications&&i.webkitNotifications.checkPermission&&(o=i.webkitNotifications.checkPermission());return o}),e.useDesktopNotifications=a.computed({read:function(){return e.desktopNotifications()&&r.DesktopNotifications.Allowed===e.desktopNotificationsPermisions()},write:function(t){if(t){var i=s.notificationClass(),o=e.desktopNotificationsPermisions();i&&r.DesktopNotifications.Allowed===o?e.desktopNotifications(!0):i&&r.DesktopNotifications.NotAllowed===o?i.requestPermission(function(){e.desktopNotifications.valueHasMutated(),r.DesktopNotifications.Allowed===e.desktopNotificationsPermisions()?e.desktopNotifications()?e.desktopNotifications.valueHasMutated():e.desktopNotifications(!0):e.desktopNotifications()?e.desktopNotifications(!1):e.desktopNotifications.valueHasMutated() -}):e.desktopNotifications(!1)}else e.desktopNotifications(!1)}}),e.language=a.observable(""),e.languages=a.observableArray([]),e.mainLanguage=a.computed({read:e.language,write:function(t){t!==e.language()?-1=t.diff(i,"hours")?o:t.format("L")===i.format("L")?s.i18n("MESSAGE_LIST/TODAY_AT",{TIME:i.format("LT")}):t.clone().subtract("days",1).format("L")===i.format("L")?s.i18n("MESSAGE_LIST/YESTERDAY_AT",{TIME:i.format("LT")}):i.format(t.year()===i.year()?"D MMM.":"LL")},e)},s.convertThemeName=function(e){return"@custom"===e.substr(-7)&&(e=s.trim(e.substring(0,e.length-7))),s.trim(e.replace(/[^a-zA-Z0-9]+/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},s.quoteName=function(e){return e.replace(/["]/g,'\\"')},s.microtime=function(){return(new Date).getTime()},s.convertLangName=function(e,t){return s.i18n("LANGS_NAMES"+(!0===t?"_EN":"")+"/LANG_"+e.toUpperCase().replace(/[^a-zA-Z0-9]+/g,"_"),null,e)},s.fakeMd5=function(e){var t="",o="0123456789abcdefghijklmnopqrstuvwxyz";for(e=s.isUnd(e)?32:s.pInt(e);t.length/g,">").replace(/")},s.draggeblePlace=function(){return n('
 
').appendTo("#rl-hidden")},s.defautOptionsAfterRender=function(e,t){t&&!s.isUnd(t.disabled)&&e&&n(e).toggleClass("disabled",t.disabled).prop("disabled",t.disabled)},s.windowPopupKnockout=function(e,t,o,r){var l=null,c=i.open(""),u="__OpenerApplyBindingsUid"+s.fakeMd5()+"__",d=n("#"+t);i[u]=function(){if(c&&c.document.body&&d&&d[0]){var t=n(c.document.body);n("#rl-content",t).html(d.html()),n("html",c.document).addClass("external "+n("html").attr("class")),s.i18nToNode(t),e&&n("#rl-content",t)[0]&&a.applyBindings(e,n("#rl-content",t)[0]),i[u]=null,r(c)}},c.document.open(),c.document.write(''+s.encodeHtml(o)+'
'),c.document.close(),l=c.document.createElement("script"),l.type="text/javascript",l.innerHTML="if(window&&window.opener&&window.opener['"+u+"']){window.opener['"+u+"']();window.opener['"+u+"']=null}",c.document.getElementsByTagName("head")[0].appendChild(l)},s.settingsSaveHelperFunction=function(e,t,i,n){return i=i||null,n=s.isUnd(n)?1e3:s.pInt(n),function(s,a,l,c,u){t.call(i,a&&a.Result?r.SaveSettingsStep.TrueResult:r.SaveSettingsStep.FalseResult),e&&e.call(i,s,a,l,c,u),o.delay(function(){t.call(i,r.SaveSettingsStep.Idle)},n)}},s.settingsSaveHelperSimpleFunction=function(e,t){return s.settingsSaveHelperFunction(null,e,t,1e3)},s.htmlToPlain=function(e){var t=0,s=0,i=0,o=0,a=0,r="",l=function(e){for(var t=100,s="",i="",o=e,n=0,a=0;o.length>t;)i=o.substring(0,t),n=i.lastIndexOf(" "),a=i.lastIndexOf("\n"),-1!==a&&(n=a),-1===n&&(n=t),s+=i.substring(0,n)+"\n",o=o.substring(n+1);return s+o},u=function(e){return e=l(n.trim(e)),e="> "+e.replace(/\n/gm,"\n> "),e.replace(/(^|\n)([> ]+)/gm,function(){return arguments&&2]*>([\s\S\r\n]*)<\/div>/gim,d),e="\n"+n.trim(e)+"\n"),e}return""},p=function(){return arguments&&1"):""},h=function(){return arguments&&1/g,">"):""},g=function(){return arguments&&1]*>([\s\S\r\n]*)<\/pre>/gim,p).replace(/[\s]+/gm," ").replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gim,h).replace(/]*>/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(/]*>([\s\S\r\n]*)<\/div>/gim,d).replace(/]*>/gim,"\n__bq__start__\n").replace(/<\/blockquote>/gim,"\n__bq__end__\n").replace(/]*>([\s\S\r\n]*?)<\/a>/gim,g).replace(/<\/div>/gi,"\n").replace(/ /gi," ").replace(/"/gi,'"').replace(/<[^>]*>/gm,""),r=c.$div.html(r).text(),r=r.replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/>/gi,">").replace(/</gi,"<").replace(/&/gi,"&"),t=0,a=100;a>0&&(a--,s=r.indexOf("__bq__start__",t),s>-1);)i=r.indexOf("__bq__start__",s+5),o=r.indexOf("__bq__end__",s+5),(-1===i||i>o)&&o>s?(r=r.substring(0,s)+u(r.substring(s+13,o))+r.substring(o+11),t=0):t=i>-1&&o>i?i-1:0;return r=r.replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")},s.plainToHtml=function(e,t){e=e.toString().replace(/\r/g,"");var i=!1,o=!0,n=!0,a=[],r="",l=0,c=e.split("\n");do{for(o=!1,a=[],l=0;l"===r.substr(0,1),n&&!i?(o=!0,i=!0,a.push("~~~blockquote~~~"),a.push(r.substr(1))):!n&&i?(i=!1,a.push("~~~/blockquote~~~"),a.push(r)):a.push(n&&i?r.substr(1):r);i&&(i=!1,a.push("~~~/blockquote~~~")),c=a}while(o);return e=c.join("\n"),e=e.replace(/&/g,"&").replace(/>/g,">").replace(/").replace(/[\s]*~~~\/blockquote~~~/g,"").replace(/[\-_~]{10,}/g,"
").replace(/\n/g,"
"),t?s.linkify(e):e},i.rainloop_Utils_htmlToPlain=s.htmlToPlain,i.rainloop_Utils_plainToHtml=s.plainToHtml,s.linkify=function(e){return n.fn&&n.fn.linkify&&(e=c.$div.html(e.replace(/&/gi,"amp_amp_12345_amp_amp")).linkify().find(".linkified").removeClass("linkified").end().html().replace(/amp_amp_12345_amp_amp/g,"&")),e},s.resizeAndCrop=function(e,t,s){var o=new i.Image;o.onload=function(){var e=[0,0],o=i.document.createElement("canvas"),n=o.getContext("2d");o.width=t,o.height=t,e=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width],n.fillStyle="#fff",n.fillRect(0,0,t,t),n.drawImage(this,e[0]/2,e[1]/2,this.width-e[0],this.height-e[1],0,0,t,t),s(o.toDataURL("image/jpeg"))},o.src=e},s.folderListOptionsBuilder=function(e,t,o,n,a,l,c,u,d,p){var h=null,g=!1,m=0,f=0,b="   ",y=[];for(d=s.isNormal(d)?d:0m;m++)y.push({id:n[m][0],name:n[m][1],system:!1,seporator:!1,disabled:!1});for(g=!0,m=0,f=e.length;f>m;m++)h=e[m],(c?c.call(null,h):!0)&&(g&&0m;m++)h=t[m],(h.subScribed()||!h.existen)&&(c?c.call(null,h):!0)&&(r.FolderType.User===h.type()||!d||01||c>0&&l>c){for(l>c?(u(c),o=c,n=c):((3>=l||l>=c-2)&&(a+=2),u(l),o=l,n=l);a>0;)if(o-=1,n+=1,o>0&&(u(o,!1),a--),c>=n)u(n,!0),a--;else if(0>=o)break;3===o?u(2,!1):o>3&&u(i.Math.round((o-1)/2),!1,"..."),c-2===n?u(c-1,!0):c-2>n&&u(i.Math.round((c+n)/2),!0,"..."),o>1&&u(1,!1),c>n&&u(c,!0)}return r}},s.selectElement=function(e){var t,s;i.getSelection?(t=i.getSelection(),t.removeAllRanges(),s=i.document.createRange(),s.selectNodeContents(e),t.addRange(s)):i.document.selection&&(s=i.document.body.createTextRange(),s.moveToElementText(e),s.select())},s.detectDropdownVisibility=o.debounce(function(){c.dropdownVisibility(!!o.find(c.aBootstrapDropdowns,function(e){return e.hasClass("open")}))},50),s.triggerAutocompleteInputChange=function(e){var t=function(){n(".checkAutocomplete").trigger("change")};(s.isUnd(e)?1:!e)?t():o.delay(t,100)},e.exports=s}(t,e)},{$:20,"App:Knoin":27,Consts:6,Enums:7,Globals:9,"Model:Email":37,_:25,ko:22,window:26}],15:[function(e,t){t.exports=JSON},{}],16:[function(e,t){t.exports=Jua},{}],17:[function(e,t){t.exports=crossroads},{}],18:[function(e,t){t.exports=hasher},{}],19:[function(e,t){t.exports=ifvisible},{}],20:[function(e,t){t.exports=$},{}],21:[function(e,t){t.exports=key},{}],22:[function(e,t){!function(t,s){"use strict";var i=e("window"),o=e("_"),n=e("$");s.bindingHandlers.tooltip={init:function(t,i){var o=e("Globals"),a=e("Utils");if(!o.bMobileDevice){var r=n(t),l=r.data("tooltip-class")||"",c=r.data("tooltip-placement")||"top";r.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:c,trigger:"hover",title:function(){return r.is(".disabled")||o.dropdownVisibility()?"":''+a.i18n(s.utils.unwrapObservable(i()))+""}}).click(function(){r.tooltip("hide")}),o.tooltipTrigger.subscribe(function(){r.tooltip("hide")})}}},s.bindingHandlers.tooltip2={init:function(t,s){var i=e("Globals"),o=n(t),a=o.data("tooltip-class")||"",r=o.data("tooltip-placement")||"top";o.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:r,title:function(){return o.is(".disabled")||i.dropdownVisibility()?"":''+s()()+""}}).click(function(){o.tooltip("hide")}),i.tooltipTrigger.subscribe(function(){o.tooltip("hide")})}},s.bindingHandlers.tooltip3={init:function(t){var s=n(t),o=e("Globals");s.tooltip({container:"body",trigger:"hover manual",title:function(){return s.data("tooltip3-data")||""}}),n(i.document).click(function(){s.tooltip("hide")}),o.tooltipTrigger.subscribe(function(){s.tooltip("hide")})},update:function(e,t){var i=s.utils.unwrapObservable(t());""===i?n(e).data("tooltip3-data","").tooltip("hide"):n(e).data("tooltip3-data",i).tooltip("show")}},s.bindingHandlers.registrateBootstrapDropdown={init:function(t){var s=e("Globals");s.aBootstrapDropdowns.push(n(t))}},s.bindingHandlers.openDropdownTrigger={update:function(t,i){if(s.utils.unwrapObservable(i())){var o=n(t),a=e("Utils");o.hasClass("open")||(o.find(".dropdown-toggle").dropdown("toggle"),a.detectDropdownVisibility()),i()(!1)}}},s.bindingHandlers.dropdownCloser={init:function(e){n(e).closest(".dropdown").on("click",".e-item",function(){n(e).dropdown("toggle")})}},s.bindingHandlers.popover={init:function(e,t){n(e).popover(s.utils.unwrapObservable(t()))}},s.bindingHandlers.csstext={init:function(t,i){var o=e("Utils");t&&t.styleSheet&&!o.isUnd(t.styleSheet.cssText)?t.styleSheet.cssText=s.utils.unwrapObservable(i()):n(t).text(s.utils.unwrapObservable(i()))},update:function(t,i){var o=e("Utils");t&&t.styleSheet&&!o.isUnd(t.styleSheet.cssText)?t.styleSheet.cssText=s.utils.unwrapObservable(i()):n(t).text(s.utils.unwrapObservable(i()))}},s.bindingHandlers.resizecrop={init:function(e){n(e).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(e,t){t()(),n(e).resizecrop({width:"100",height:"100"})}},s.bindingHandlers.onEnter={init:function(e,t,s,o){n(e).on("keypress",function(s){s&&13===i.parseInt(s.keyCode,10)&&(n(e).trigger("change"),t().call(o))})}},s.bindingHandlers.onEsc={init:function(e,t,s,o){n(e).on("keypress",function(s){s&&27===i.parseInt(s.keyCode,10)&&(n(e).trigger("change"),t().call(o))})}},s.bindingHandlers.clickOnTrue={update:function(e,t){s.utils.unwrapObservable(t())&&n(e).click()}},s.bindingHandlers.modal={init:function(t,i){var o=e("Globals"),a=e("Utils");n(t).toggleClass("fade",!o.bMobileDevice).modal({keyboard:!1,show:s.utils.unwrapObservable(i())}).on("shown",function(){a.windowResize()}).find(".close").click(function(){i()(!1)})},update:function(e,t){n(e).modal(s.utils.unwrapObservable(t())?"show":"hide")}},s.bindingHandlers.i18nInit={init:function(t){var s=e("Utils");s.i18nToNode(t)}},s.bindingHandlers.i18nUpdate={update:function(t,i){var o=e("Utils");s.utils.unwrapObservable(i()),o.i18nToNode(t)}},s.bindingHandlers.link={update:function(e,t){n(e).attr("href",s.utils.unwrapObservable(t()))}},s.bindingHandlers.title={update:function(e,t){n(e).attr("title",s.utils.unwrapObservable(t()))}},s.bindingHandlers.textF={init:function(e,t){n(e).text(s.utils.unwrapObservable(t()))}},s.bindingHandlers.initDom={init:function(e,t){t()(e)}},s.bindingHandlers.initResizeTrigger={init:function(e,t){var i=s.utils.unwrapObservable(t());n(e).css({height:i[1],"min-height":i[1]})},update:function(t,i){var o=e("Utils"),a=e("Globals"),r=s.utils.unwrapObservable(i()),l=o.pInt(r[1]),c=0,u=n(t).offset().top;u>0&&(u+=o.pInt(r[2]),c=a.$win.height()-u,c>l&&(l=c),n(t).css({height:l,"min-height":l}))}},s.bindingHandlers.appendDom={update:function(e,t){n(e).hide().empty().append(s.utils.unwrapObservable(t())).show()}},s.bindingHandlers.draggable={init:function(t,o,a){var r=e("Globals"),l=e("Utils");if(!r.bMobileDevice){var c=100,u=3,d=a(),p=d&&d.droppableSelector?d.droppableSelector:"",h={distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},refreshPositions:!0,scroll:!0};p&&(h.drag=function(e){n(p).each(function(){var t=null,s=null,o=n(this),a=o.offset(),r=a.top+o.height();i.clearInterval(o.data("timerScroll")),o.data("timerScroll",!1),e.pageX>=a.left&&e.pageX<=a.left+o.width()&&(e.pageY>=r-c&&e.pageY<=r&&(t=function(){o.scrollTop(o.scrollTop()+u),l.windowResize()},o.data("timerScroll",i.setInterval(t,10)),t()),e.pageY>=a.top&&e.pageY<=a.top+c&&(s=function(){o.scrollTop(o.scrollTop()-u),l.windowResize()},o.data("timerScroll",i.setInterval(s,10)),s()))})},h.stop=function(){n(p).each(function(){i.clearInterval(n(this).data("timerScroll")),n(this).data("timerScroll",!1)})}),h.helper=function(e){return o()(e&&e.target?s.dataFor(e.target):null)},n(t).draggable(h).on("mousedown",function(){l.removeInFocus()})}}},s.bindingHandlers.droppable={init:function(t,s,i){var o=e("Globals");if(!o.bMobileDevice){var a=s(),r=i(),l=r&&r.droppableOver?r.droppableOver:null,c=r&&r.droppableOut?r.droppableOut:null,u={tolerance:"pointer",hoverClass:"droppableHover"};a&&(u.drop=function(e,t){a(e,t)},l&&(u.over=function(e,t){l(e,t)}),c&&(u.out=function(e,t){c(e,t)}),n(t).droppable(u))}}},s.bindingHandlers.nano={init:function(t){var s=e("Globals");s.bDisableNanoScroll||n(t).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},s.bindingHandlers.saveTrigger={init:function(e){var t=n(e);t.data("save-trigger-type",t.is("input[type=text],input[type=email],input[type=password],select,textarea")?"input":"custom"),"custom"===t.data("save-trigger-type")?t.append('  ').addClass("settings-saved-trigger"):t.addClass("settings-saved-trigger-input")},update:function(e,t){var i=s.utils.unwrapObservable(t()),o=n(e);if("custom"===o.data("save-trigger-type"))switch(i.toString()){case"1":o.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case"0":o.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case"-2":o.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:o.find(".animated").hide().end().find(".error,.success").removeClass("visible")}else switch(i.toString()){case"1":o.addClass("success").removeClass("error");break;case"0":o.addClass("error").removeClass("success");break;case"-2":break;default:o.removeClass("error success")}}},s.bindingHandlers.emailsTags={init:function(t,s,i){var a=e("Utils"),r=e("Model:Email"),l=n(t),c=s(),u=i(),d=u.autoCompleteSource||null,p=function(e){c&&c.focusTrigger&&c.focusTrigger(e)};l.inputosaurus({parseOnBlur:!0,allowDragAndDrop:!0,focusCallback:p,inputDelimiters:[",",";"],autoCompleteSource:d,parseHook:function(e){return o.map(e,function(e){var t=a.trim(e),s=null;return""!==t?(s=new r,s.mailsoParse(t),s.clearDuplicateName(),[s.toLine(!1),s]):[t,null]})},change:o.bind(function(e){l.data("EmailsTagsValue",e.target.value),c(e.target.value)},this)})},update:function(e,t,i){var o=n(e),a=i(),r=a.emailsTagsFilter||null,l=s.utils.unwrapObservable(t());o.data("EmailsTagsValue")!==l&&(o.val(l),o.data("EmailsTagsValue",l),o.inputosaurus("refresh")),r&&s.utils.unwrapObservable(r)&&o.inputosaurus("focus")}},s.bindingHandlers.contactTags={init:function(t,s,i){var a=e("Utils"),r=e("Model:ContactTag"),l=n(t),c=s(),u=i(),d=u.autoCompleteSource||null,p=function(e){c&&c.focusTrigger&&c.focusTrigger(e)};l.inputosaurus({parseOnBlur:!0,allowDragAndDrop:!1,focusCallback:p,inputDelimiters:[",",";"],outputDelimiter:",",autoCompleteSource:d,parseHook:function(e){return o.map(e,function(e){var t=a.trim(e),s=null;return""!==t?(s=new r,s.name(t),[s.toLine(!1),s]):[t,null]})},change:o.bind(function(e){l.data("ContactTagsValue",e.target.value),c(e.target.value)},this)})},update:function(e,t,i){var o=n(e),a=i(),r=a.contactTagsFilter||null,l=s.utils.unwrapObservable(t());o.data("ContactTagsValue")!==l&&(o.val(l),o.data("ContactTagsValue",l),o.inputosaurus("refresh")),r&&s.utils.unwrapObservable(r)&&o.inputosaurus("focus")}},s.bindingHandlers.command={init:function(e,t,i,o){var a=n(e),r=t();if(!r||!r.enabled||!r.canExecute)throw new Error("You are not using command function");a.addClass("command"),s.bindingHandlers[a.is("form")?"submit":"click"].init.apply(o,arguments)},update:function(e,t){var s=!0,i=n(e),o=t();s=o.enabled(),i.toggleClass("command-not-enabled",!s),s&&(s=o.canExecute(),i.toggleClass("command-can-not-be-execute",!s)),i.toggleClass("command-disabled disable disabled",!s).toggleClass("no-disabled",!!s),(i.is("input")||i.is("button"))&&i.prop("disabled",!s)}},s.extenders.trimmer=function(t){var i=e("Utils"),o=s.computed({read:t,write:function(e){t(i.trim(e.toString()))},owner:this});return o(t()),o},s.extenders.posInterer=function(t,i){var o=e("Utils"),n=s.computed({read:t,write:function(e){var s=o.pInt(e.toString(),i);0>=s&&(s=i),s===t()&&""+s!=""+e&&t(s+1),t(s)}});return n(t()),n},s.extenders.reversible=function(e){var t=e();return e.commit=function(){t=e()},e.reverse=function(){e(t)},e.commitedValue=function(){return t},e},s.extenders.toggleSubscribe=function(e,t){return e.subscribe(t[1],t[0],"beforeChange"),e.subscribe(t[2],t[0]),e},s.extenders.falseTimeout=function(t,s){var o=e("Utils");return t.iTimeout=0,t.subscribe(function(e){e&&(i.clearTimeout(t.iTimeout),t.iTimeout=i.setTimeout(function(){t(!1),t.iTimeout=0},o.pInt(s)))}),t},s.observable.fn.validateNone=function(){return this.hasError=s.observable(!1),this},s.observable.fn.validateEmail=function(){var t=e("Utils");return this.hasError=s.observable(!1),this.subscribe(function(e){e=t.trim(e),this.hasError(""!==e&&!/^[^@\s]+@[^@\s]+$/.test(e))},this),this.valueHasMutated(),this},s.observable.fn.validateSimpleEmail=function(){var t=e("Utils");return this.hasError=s.observable(!1),this.subscribe(function(e){e=t.trim(e),this.hasError(""!==e&&!/^.+@.+$/.test(e))},this),this.valueHasMutated(),this},s.observable.fn.validateFunc=function(t){var i=e("Utils");return this.hasFuncError=s.observable(!1),i.isFunc(t)&&(this.subscribe(function(e){this.hasFuncError(!t(e))},this),this.valueHasMutated()),this},t.exports=s}(t,ko)},{$:20,Globals:9,"Model:ContactTag":36,"Model:Email":37,Utils:14,_:25,window:26}],23:[function(e,t){t.exports=moment},{}],24:[function(e,t){t.exports=ssm},{}],25:[function(e,t){t.exports=_},{}],26:[function(e,t){t.exports=window},{}],27:[function(e,t){!function(e,t){"use strict";function s(){this.oScreens={},this.sDefaultScreenName="",this.oCurrentScreen=null}var i=t("_"),o=t("$"),n=t("ko"),a=t("hasher"),r=t("crossroads"),l=t("Globals"),c=t("Plugins"),u=t("Utils");s.prototype.oScreens={},s.prototype.sDefaultScreenName="",s.prototype.oCurrentScreen=null,s.prototype.hideLoading=function(){o("#rl-loading").hide()},s.prototype.constructorEnd=function(e){u.isFunc(e.__constructor_end)&&e.__constructor_end.call(e)},s.prototype.extendAsViewModel=function(e,t){t&&(t.__names=u.isArray(e)?e:[e],t.__name=t.__names[0])},s.prototype.addSettingsViewModel=function(e,t,s,i,o){e.__rlSettingsData={Label:s,Template:t,Route:i,IsDefault:!!o},l.aViewModels.settings.push(e)},s.prototype.removeSettingsViewModel=function(e){l.aViewModels["settings-removed"].push(e)},s.prototype.disableSettingsViewModel=function(e){l.aViewModels["settings-disabled"].push(e)},s.prototype.routeOff=function(){a.changed.active=!1},s.prototype.routeOn=function(){a.changed.active=!0},s.prototype.screen=function(e){return""===e||u.isUnd(this.oScreens[e])?null:this.oScreens[e]},s.prototype.buildViewModel=function(e,t){if(e&&!e.__builded){var s=this,a=new e(t),r=a.viewModelPosition(),d=o("#rl-content #rl-"+r.toLowerCase()),p=null;e.__builded=!0,e.__vm=a,a.viewModelName=e.__name,a.viewModelNames=e.__names,d&&1===d.length?(p=o("
").addClass("rl-view-model").addClass("RL-"+a.viewModelTemplate()).hide(),p.appendTo(d),a.viewModelDom=p,e.__dom=p,"Popups"===r&&(a.cancelCommand=a.closeCommand=u.createCommand(a,function(){s.hideScreenPopup(e)}),a.modalVisibility.subscribe(function(e){var t=this;e?(this.viewModelDom.show(),this.storeAndSetKeyScope(),l.popupVisibilityNames.push(this.viewModelName),a.viewModelDom.css("z-index",3e3+l.popupVisibilityNames().length+10),u.delegateRun(this,"onFocus",[],500)):(u.delegateRun(this,"onHide"),this.restoreKeyScope(),i.each(this.viewModelNames,function(e){c.runHook("view-model-on-hide",[e,t])}),l.popupVisibilityNames.remove(this.viewModelName),a.viewModelDom.css("z-index",2e3),l.tooltipTrigger(!l.tooltipTrigger()),i.delay(function(){t.viewModelDom.hide()},300))},a)),i.each(e.__names,function(e){c.runHook("view-model-pre-build",[e,a,p])}),n.applyBindingAccessorsToNode(p[0],{i18nInit:!0,template:function(){return{name:a.viewModelTemplate()}}},a),u.delegateRun(a,"onBuild",[p]),a&&"Popups"===r&&a.registerPopupKeyDown(),i.each(e.__names,function(e){c.runHook("view-model-post-build",[e,a,p])})):u.log("Cannot find view model position: "+r)}return e?e.__vm:null},s.prototype.hideScreenPopup=function(e){e&&e.__vm&&e.__dom&&e.__vm.modalVisibility(!1)},s.prototype.showScreenPopup=function(e,t){e&&(this.buildViewModel(e),e.__vm&&e.__dom&&(e.__vm.modalVisibility(!0),u.delegateRun(e.__vm,"onShow",t||[]),i.each(e.__names,function(s){c.runHook("view-model-on-show",[s,e.__vm,t||[]])})))},s.prototype.isPopupVisible=function(e){return e&&e.__vm?e.__vm.modalVisibility():!1},s.prototype.screenOnRoute=function(e,t){var s=this,o=null,n=null;""===u.pString(e)&&(e=this.sDefaultScreenName),""!==e&&(o=this.screen(e),o||(o=this.screen(this.sDefaultScreenName),o&&(t=e+"/"+t,e=this.sDefaultScreenName)),o&&o.__started&&(o.__builded||(o.__builded=!0,u.isNonEmptyArray(o.viewModels())&&i.each(o.viewModels(),function(e){this.buildViewModel(e,o)},this),u.delegateRun(o,"onBuild")),i.defer(function(){s.oCurrentScreen&&(u.delegateRun(s.oCurrentScreen,"onHide"),u.isNonEmptyArray(s.oCurrentScreen.viewModels())&&i.each(s.oCurrentScreen.viewModels(),function(e){e.__vm&&e.__dom&&"Popups"!==e.__vm.viewModelPosition()&&(e.__dom.hide(),e.__vm.viewModelVisibility(!1),u.delegateRun(e.__vm,"onHide"))})),s.oCurrentScreen=o,s.oCurrentScreen&&(u.delegateRun(s.oCurrentScreen,"onShow"),c.runHook("screen-on-show",[s.oCurrentScreen.screenName(),s.oCurrentScreen]),u.isNonEmptyArray(s.oCurrentScreen.viewModels())&&i.each(s.oCurrentScreen.viewModels(),function(e){e.__vm&&e.__dom&&"Popups"!==e.__vm.viewModelPosition()&&(e.__dom.show(),e.__vm.viewModelVisibility(!0),u.delegateRun(e.__vm,"onShow"),u.delegateRun(e.__vm,"onFocus",[],200),i.each(e.__names,function(t){c.runHook("view-model-on-show",[t,e.__vm])}))},s)),n=o.__cross?o.__cross():null,n&&n.parse(t)})))},s.prototype.startScreens=function(e){o("#rl-content").css({visibility:"hidden"}),i.each(e,function(e){var t=new e,s=t?t.screenName():"";t&&""!==s&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=s),this.oScreens[s]=t)},this),i.each(this.oScreens,function(e){e&&!e.__started&&e.__start&&(e.__started=!0,e.__start(),c.runHook("screen-pre-start",[e.screenName(),e]),u.delegateRun(e,"onStart"),c.runHook("screen-post-start",[e.screenName(),e]))},this);var t=r.create();t.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,i.bind(this.screenOnRoute,this)),a.initialized.add(t.parse,t),a.changed.add(t.parse,t),a.init(),o("#rl-content").css({visibility:"visible"}),i.delay(function(){l.$html.removeClass("rl-started-trigger").addClass("rl-started")},50)},s.prototype.setHash=function(e,t,s){e="#"===e.substr(0,1)?e.substr(1):e,e="/"===e.substr(0,1)?e.substr(1):e,s=u.isUnd(s)?!1:!!s,(u.isUnd(t)?1:!t)?(a.changed.active=!0,a[s?"replaceHash":"setHash"](e),a.setHash(e)):(a.changed.active=!1,a[s?"replaceHash":"setHash"](e),a.changed.active=!0)},e.exports=new s}(t,e)},{$:20,Globals:9,Plugins:12,Utils:14,_:25,crossroads:17,hasher:18,ko:22}],28:[function(e,t){!function(e){"use strict";function t(){}t.prototype.bootstart=function(){},e.exports=t}(t,e)},{}],29:[function(e,t){!function(e,t){"use strict";function s(e,t){this.sScreenName=e,this.aViewModels=n.isArray(t)?t:[]}var i=t("_"),o=t("crossroads"),n=t("Utils");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 e=this.routes(),t=null,s=null;n.isNonEmptyArray(e)&&(s=i.bind(this.onRoute||n.emptyFunction,this),t=o.create(),i.each(e,function(e){t.addRoute(e[0],s).rules=e[1]}),this.oCross=t)},e.exports=s}(t,e)},{Utils:14,_:25,crossroads:17}],30:[function(e,t){!function(e,t){"use strict";function s(e,t){this.bDisabeCloseOnEsc=!1,this.sPosition=n.pString(e),this.sTemplate=n.pString(t),this.sDefaultKeyScope=o.KeyState.None,this.sCurrentKeyScope=this.sDefaultKeyScope,this.viewModelVisibility=i.observable(!1),this.modalVisibility=i.observable(!1).extend({rateLimit:0}),this.viewModelName="",this.viewModelNames=[],this.viewModelDom=null}var i=t("ko"),o=t("Enums"),n=t("Utils"),a=t("Globals");s.prototype.bDisabeCloseOnEsc=!1,s.prototype.sPosition="",s.prototype.sTemplate="",s.prototype.sDefaultKeyScope=o.KeyState.None,s.prototype.sCurrentKeyScope=o.KeyState.None,s.prototype.viewModelName="",s.prototype.viewModelNames=[],s.prototype.viewModelDom=null,s.prototype.viewModelTemplate=function(){return this.sTemplate},s.prototype.viewModelPosition=function(){return this.sPosition},s.prototype.cancelCommand=function(){},s.prototype.closeCommand=function(){},s.prototype.storeAndSetKeyScope=function(){this.sCurrentKeyScope=a.keyScope(),a.keyScope(this.sDefaultKeyScope)},s.prototype.restoreKeyScope=function(){a.keyScope(this.sCurrentKeyScope)},s.prototype.registerPopupKeyDown=function(){var e=this;a.$win.on("keydown",function(t){if(t&&e.modalVisibility&&e.modalVisibility()){if(!this.bDisabeCloseOnEsc&&o.EventKeyCode.Esc===t.keyCode)return n.delegateRun(e,"cancelCommand"),!1;if(o.EventKeyCode.Backspace===t.keyCode&&!n.inFocus())return!1}return!0})},e.exports=s}(t,e)},{Enums:7,Globals:9,Utils:14,ko:22}],31:[function(e,t){!function(e,t){"use strict";function s(e,t){this.email=e,this.deleteAccess=i.observable(!1),this.canBeDalete=i.observable(o.isUnd(t)?!0:!!t)}var i=t("ko"),o=t("Utils");s.prototype.email="",s.prototype.changeAccountLink=function(){return t("LinkBuilder").change(this.email)},e.exports=s}(t,e)},{LinkBuilder:11,Utils:14,ko:22}],32:[function(e,t){!function(e,t){"use strict";function s(){this.mimeType="",this.fileName="",this.estimatedSize=0,this.friendlySize="",this.isInline=!1,this.isLinked=!1,this.cid="",this.cidWithOutTags="",this.contentLocation="",this.download="",this.folder="",this.uid="",this.mimeIndex=""}var i=t("window"),o=t("Globals"),n=t("Utils"),a=t("LinkBuilder");s.newInstanceFromJson=function(e){var t=new s;return t.initByJson(e)?t:null},s.prototype.mimeType="",s.prototype.fileName="",s.prototype.estimatedSize=0,s.prototype.friendlySize="",s.prototype.isInline=!1,s.prototype.isLinked=!1,s.prototype.cid="",s.prototype.cidWithOutTags="",s.prototype.contentLocation="",s.prototype.download="",s.prototype.folder="",s.prototype.uid="",s.prototype.mimeIndex="",s.prototype.initByJson=function(e){var t=!1;return e&&"Object/Attachment"===e["@Object"]&&(this.mimeType=(e.MimeType||"").toLowerCase(),this.fileName=e.FileName,this.estimatedSize=n.pInt(e.EstimatedSize),this.isInline=!!e.IsInline,this.isLinked=!!e.IsLinked,this.cid=e.CID,this.contentLocation=e.ContentLocation,this.download=e.Download,this.folder=e.Folder,this.uid=e.Uid,this.mimeIndex=e.MimeIndex,this.friendlySize=n.friendlySize(this.estimatedSize),this.cidWithOutTags=this.cid.replace(/^<+/,"").replace(/>+$/,""),t=!0),t},s.prototype.isImage=function(){return-1,]+)>?,? ?/g,s=t.exec(e);s?(this.name=s[1]||"",this.email=s[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(e)&&(this.name="",this.email=e)},s.prototype.initByJson=function(e){var t=!1;return e&&"Object/Email"===e["@Object"]&&(this.name=i.trim(e.Name),this.email=i.trim(e.Email),t=""!==this.email,this.clearDuplicateName()),t},s.prototype.toLine=function(e,t,s){var o="";return""!==this.email&&(t=i.isUnd(t)?!1:!!t,s=i.isUnd(s)?!1:!!s,e&&""!==this.name?o=t?'
")+'" target="_blank" tabindex="-1">'+i.encodeHtml(this.name)+"":s?i.encodeHtml(this.name):this.name:(o=this.email,""!==this.name?t?o=i.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+i.encodeHtml(o)+""+i.encodeHtml(">"):(o='"'+this.name+'" <'+o+">",s&&(o=i.encodeHtml(o))):t&&(o=''+i.encodeHtml(this.email)+""))),o},s.prototype.mailsoParse=function(e){if(e=i.trim(e),""===e)return!1;for(var t=function(e,t,s){e+="";var i=e.length;return 0>t&&(t+=i),i="undefined"==typeof s?i:0>s?s+i:s+t,t>=e.length||0>t||t>i?!1:e.slice(t,i)},s=function(e,t,s,i){return 0>s&&(s+=e.length),i=void 0!==i?i:e.length,0>i&&(i=i+e.length-s),e.slice(0,s)+t.substr(0,i)+t.slice(i)+e.slice(s+i)},o="",n="",a="",r=!1,l=!1,c=!1,u=null,d=0,p=0,h=0;h0&&0===o.length&&(o=t(e,0,h)),l=!0,d=h);break;case">":l&&(p=h,n=t(e,d+1,p-d-1),e=s(e,"",d,p-d+1),p=0,h=0,d=0,l=!1);break;case"(":r||l||c||(c=!0,d=h);break;case")":c&&(p=h,a=t(e,d+1,p-d-1),e=s(e,"",d,p-d+1),p=0,h=0,d=0,c=!1);break;case"\\":h++}h++}return 0===n.length&&(u=e.match(/[^@\s]+@\S+/i),u&&u[0]?n=u[0]:o=e),n.length>0&&0===o.length&&0===a.length&&(o=e.replace(n,"")),n=i.trim(n).replace(/^[<]+/,"").replace(/[>]+$/,""),o=i.trim(o).replace(/^["']+/,"").replace(/["']+$/,""),a=i.trim(a).replace(/^[(]+/,"").replace(/[)]+$/,""),o=o.replace(/\\\\(.)/g,"$1"),a=a.replace(/\\\\(.)/g,"$1"),this.name=o,this.email=n,this.clearDuplicateName(),!0},s.prototype.inputoTagLine=function(){return 00){if(n.FolderType.Draft===s)return""+e;if(t>0&&n.FolderType.Trash!==s&&n.FolderType.Archive!==s&&n.FolderType.SentItems!==s)return""+t}return""},this),this.canBeDeleted=o.computed(function(){var e=this.isSystemFolder();return!e&&0===this.subFolders().length&&"INBOX"!==this.fullNameRaw},this),this.canBeSubScribed=o.computed(function(){return!this.isSystemFolder()&&this.selectable&&"INBOX"!==this.fullNameRaw},this),this.localName=o.computed(function(){a.langChangeTrigger();var e=this.type(),t=this.name();if(this.isSystemFolder())switch(e){case n.FolderType.Inbox:t=r.i18n("FOLDER_LIST/INBOX_NAME");break;case n.FolderType.SentItems:t=r.i18n("FOLDER_LIST/SENT_NAME");break;case n.FolderType.Draft:t=r.i18n("FOLDER_LIST/DRAFTS_NAME");break;case n.FolderType.Spam:t=r.i18n("FOLDER_LIST/SPAM_NAME");break;case n.FolderType.Trash:t=r.i18n("FOLDER_LIST/TRASH_NAME");break;case n.FolderType.Archive:t=r.i18n("FOLDER_LIST/ARCHIVE_NAME")}return t},this),this.manageFolderSystemName=o.computed(function(){a.langChangeTrigger();var e="",t=this.type(),s=this.name();if(this.isSystemFolder())switch(t){case n.FolderType.Inbox:e="("+r.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case n.FolderType.SentItems:e="("+r.i18n("FOLDER_LIST/SENT_NAME")+")";break;case n.FolderType.Draft:e="("+r.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case n.FolderType.Spam:e="("+r.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case n.FolderType.Trash:e="("+r.i18n("FOLDER_LIST/TRASH_NAME")+")";break;case n.FolderType.Archive:e="("+r.i18n("FOLDER_LIST/ARCHIVE_NAME")+")"}return(""!==e&&"("+s+")"===e||"(inbox)"===e.toLowerCase())&&(e=""),e},this),this.collapsed=o.computed({read:function(){return!this.hidden()&&this.collapsedPrivate()},write:function(e){this.collapsedPrivate(e)},owner:this}),this.hasUnreadMessages=o.computed(function(){return 0"},s.prototype.formattedNameForCompose=function(){var e=this.name();return""===e?this.email():e+" ("+this.email()+")"},s.prototype.formattedNameForEmail=function(){var e=this.name();return""===e?this.email():'"'+o.quoteName(e)+'" <'+this.email()+">"},e.exports=s}(t,e)},{Utils:14,ko:22}],42:[function(e,t){!function(e,t){"use strict";function s(){this.folderFullNameRaw="",this.uid="",this.hash="",this.requestHash="",this.subject=a.observable(""),this.subjectPrefix=a.observable(""),this.subjectSuffix=a.observable(""),this.size=a.observable(0),this.dateTimeStampInUTC=a.observable(0),this.priority=a.observable(l.MessagePriority.Normal),this.proxy=!1,this.fromEmailString=a.observable(""),this.fromClearEmailString=a.observable(""),this.toEmailsString=a.observable(""),this.toClearEmailsString=a.observable(""),this.senderEmailsString=a.observable(""),this.senderClearEmailsString=a.observable(""),this.emails=[],this.from=[],this.to=[],this.cc=[],this.bcc=[],this.replyTo=[],this.deliveredTo=[],this.newForAnimation=a.observable(!1),this.deleted=a.observable(!1),this.unseen=a.observable(!1),this.flagged=a.observable(!1),this.answered=a.observable(!1),this.forwarded=a.observable(!1),this.isReadReceipt=a.observable(!1),this.focused=a.observable(!1),this.selected=a.observable(!1),this.checked=a.observable(!1),this.hasAttachments=a.observable(!1),this.attachmentsMainType=a.observable(""),this.moment=a.observable(r(r.unix(0))),this.attachmentIconClass=a.computed(function(){var e="";if(this.hasAttachments())switch(e="icon-attachment",this.attachmentsMainType()){case"image":e="icon-image";break;case"archive":e="icon-file-zip";break;case"doc":e="icon-file-text"}return e},this),this.fullFormatDateValue=a.computed(function(){return s.calculateFullFromatDateValue(this.dateTimeStampInUTC())},this),this.momentDate=c.createMomentDate(this),this.momentShortDate=c.createMomentShortDate(this),this.dateTimeStampInUTC.subscribe(function(e){var t=r().unix();this.moment(r.unix(e>t?t:e))},this),this.body=null,this.plainRaw="",this.isHtml=a.observable(!1),this.hasImages=a.observable(!1),this.attachments=a.observableArray([]),this.isPgpSigned=a.observable(!1),this.isPgpEncrypted=a.observable(!1),this.pgpSignedVerifyStatus=a.observable(l.SignedVerifyStatus.None),this.pgpSignedVerifyUser=a.observable(""),this.priority=a.observable(l.MessagePriority.Normal),this.readReceipt=a.observable(""),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid=a.observable(0),this.threads=a.observableArray([]),this.threadsLen=a.observable(0),this.hasUnseenSubMessage=a.observable(!1),this.hasFlaggedSubMessage=a.observable(!1),this.lastInCollapsedThread=a.observable(!1),this.lastInCollapsedThreadLoading=a.observable(!1),this.threadsLenResult=a.computed(function(){var e=this.threadsLen();return 0===this.parentUid()&&e>0?e+1:""},this)}var i=t("window"),o=t("_"),n=t("$"),a=t("ko"),r=t("moment"),l=t("Enums"),c=t("Utils"),u=t("Globals"),d=t("LinkBuilder"),p=t("Model:Email"),h=t("Model:Attachment");s.newInstanceFromJson=function(e){var t=new s;return t.initByJson(e)?t:null},s.calculateFullFromatDateValue=function(e){return e>0?r.unix(e).format("LLL"):""},s.emailsToLine=function(e,t,s){var i=[],o=0,n=0;if(c.isNonEmptyArray(e))for(o=0,n=e.length;n>o;o++)i.push(e[o].toLine(t,s));return i.join(", ")},s.emailsToLineClear=function(e){var t=[],s=0,i=0;if(c.isNonEmptyArray(e))for(s=0,i=e.length;i>s;s++)e[s]&&e[s].email&&""!==e[s].name&&t.push(e[s].email);return t.join(", ")},s.initEmailsFromJson=function(e){var t=0,s=0,i=null,o=[];if(c.isNonEmptyArray(e))for(t=0,s=e.length;s>t;t++)i=p.newInstanceFromJson(e[t]),i&&o.push(i);return o},s.replyHelper=function(e,t,s){if(e&&0i;i++)c.isUnd(t[e[i].email])&&(t[e[i].email]=!0,s.push(e[i]))},s.prototype.clear=function(){this.folderFullNameRaw="",this.uid="",this.hash="",this.requestHash="",this.subject(""),this.subjectPrefix(""),this.subjectSuffix(""),this.size(0),this.dateTimeStampInUTC(0),this.priority(l.MessagePriority.Normal),this.proxy=!1,this.fromEmailString(""),this.fromClearEmailString(""),this.toEmailsString(""),this.toClearEmailsString(""),this.senderEmailsString(""),this.senderClearEmailsString(""),this.emails=[],this.from=[],this.to=[],this.cc=[],this.bcc=[],this.replyTo=[],this.deliveredTo=[],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.isHtml(!1),this.hasImages(!1),this.attachments([]),this.isPgpSigned(!1),this.isPgpEncrypted(!1),this.pgpSignedVerifyStatus(l.SignedVerifyStatus.None),this.pgpSignedVerifyUser(""),this.priority(l.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)},s.prototype.friendlySize=function(){return c.friendlySize(this.size())},s.prototype.computeSenderEmail=function(){var e=t("Storage:RainLoop:Data"),s=e.sentFolder(),i=e.draftFolder();this.senderEmailsString(this.folderFullNameRaw===s||this.folderFullNameRaw===i?this.toEmailsString():this.fromEmailString()),this.senderClearEmailsString(this.folderFullNameRaw===s||this.folderFullNameRaw===i?this.toClearEmailsString():this.fromClearEmailString())},s.prototype.initByJson=function(e){var t=!1;return e&&"Object/Message"===e["@Object"]&&(this.folderFullNameRaw=e.Folder,this.uid=e.Uid,this.hash=e.Hash,this.requestHash=e.RequestHash,this.proxy=!!e.ExternalProxy,this.size(c.pInt(e.Size)),this.from=s.initEmailsFromJson(e.From),this.to=s.initEmailsFromJson(e.To),this.cc=s.initEmailsFromJson(e.Cc),this.bcc=s.initEmailsFromJson(e.Bcc),this.replyTo=s.initEmailsFromJson(e.ReplyTo),this.deliveredTo=s.initEmailsFromJson(e.DeliveredTo),this.subject(e.Subject),c.isArray(e.SubjectParts)?(this.subjectPrefix(e.SubjectParts[0]),this.subjectSuffix(e.SubjectParts[1])):(this.subjectPrefix(""),this.subjectSuffix(this.subject())),this.dateTimeStampInUTC(c.pInt(e.DateTimeStampInUTC)),this.hasAttachments(!!e.HasAttachments),this.attachmentsMainType(e.AttachmentsMainType),this.fromEmailString(s.emailsToLine(this.from,!0)),this.fromClearEmailString(s.emailsToLineClear(this.from)),this.toEmailsString(s.emailsToLine(this.to,!0)),this.toClearEmailsString(s.emailsToLineClear(this.to)),this.parentUid(c.pInt(e.ParentThread)),this.threads(c.isArray(e.Threads)?e.Threads:[]),this.threadsLen(c.pInt(e.ThreadsLen)),this.initFlagsByJson(e),this.computeSenderEmail(),t=!0),t},s.prototype.initUpdateByMessageJson=function(e){var s=t("Storage:RainLoop:Data"),i=!1,o=l.MessagePriority.Normal;return e&&"Object/Message"===e["@Object"]&&(o=c.pInt(e.Priority),this.priority(-1t;t++)i=h.newInstanceFromJson(e["@Collection"][t]),i&&(""!==i.cidWithOutTags&&0+$/,""),t=o.find(s,function(t){return e===t.cidWithOutTags})),t||null},s.prototype.findAttachmentByContentLocation=function(e){var t=null,s=this.attachments();return c.isNonEmptyArray(s)&&(t=o.find(s,function(t){return e===t.contentLocation})),t||null},s.prototype.messageId=function(){return this.sMessageId},s.prototype.inReplyTo=function(){return this.sInReplyTo},s.prototype.references=function(){return this.sReferences},s.prototype.fromAsSingleEmail=function(){return c.isArray(this.from)&&this.from[0]?this.from[0].email:""},s.prototype.viewLink=function(){return d.messageViewLink(this.requestHash)},s.prototype.downloadLink=function(){return d.messageDownloadLink(this.requestHash)},s.prototype.replyEmails=function(e){var t=[],i=c.isUnd(e)?{}:e;return s.replyHelper(this.replyTo,i,t),0===t.length&&s.replyHelper(this.from,i,t),t},s.prototype.replyAllEmails=function(e){var t=[],i=[],o=c.isUnd(e)?{}:e;return s.replyHelper(this.replyTo,o,t),0===t.length&&s.replyHelper(this.from,o,t),s.replyHelper(this.to,o,t),s.replyHelper(this.cc,o,i),[t,i]},s.prototype.textBodyToString=function(){return this.body?this.body.html():""},s.prototype.attachmentsToStringLine=function(){var e=o.map(this.attachments(),function(e){return e.fileName+" ("+e.friendlySize+")"});return e&&0=0&&i&&!o&&s.attr("src",i)}),e&&i.setTimeout(function(){t.print()},100))})},s.prototype.printMessage=function(){this.viewPopupMessage(!0)},s.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid},s.prototype.populateByMessageListItem=function(e){return this.folderFullNameRaw=e.folderFullNameRaw,this.uid=e.uid,this.hash=e.hash,this.requestHash=e.requestHash,this.subject(e.subject()),this.subjectPrefix(this.subjectPrefix()),this.subjectSuffix(this.subjectSuffix()),this.size(e.size()),this.dateTimeStampInUTC(e.dateTimeStampInUTC()),this.priority(e.priority()),this.proxy=e.proxy,this.fromEmailString(e.fromEmailString()),this.fromClearEmailString(e.fromClearEmailString()),this.toEmailsString(e.toEmailsString()),this.toClearEmailsString(e.toClearEmailsString()),this.emails=e.emails,this.from=e.from,this.to=e.to,this.cc=e.cc,this.bcc=e.bcc,this.replyTo=e.replyTo,this.deliveredTo=e.deliveredTo,this.unseen(e.unseen()),this.flagged(e.flagged()),this.answered(e.answered()),this.forwarded(e.forwarded()),this.isReadReceipt(e.isReadReceipt()),this.selected(e.selected()),this.checked(e.checked()),this.hasAttachments(e.hasAttachments()),this.attachmentsMainType(e.attachmentsMainType()),this.moment(e.moment()),this.body=null,this.priority(l.MessagePriority.Normal),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid(e.parentUid()),this.threads(e.threads()),this.threadsLen(e.threadsLen()),this.computeSenderEmail(),this},s.prototype.showExternalImages=function(e){if(this.body&&this.body.data("rl-has-images")){var t="";e=c.isUnd(e)?!1:e,this.hasImages(!1),this.body.data("rl-has-images",!1),t=this.proxy?"data-x-additional-src":"data-x-src",n("["+t+"]",this.body).each(function(){e&&n(this).is("img")?n(this).addClass("lazy").attr("data-original",n(this).attr(t)).removeAttr(t):n(this).attr("src",n(this).attr(t)).removeAttr(t)}),t=this.proxy?"data-x-additional-style-url":"data-x-style-url",n("["+t+"]",this.body).each(function(){var e=c.trim(n(this).attr("style"));e=""===e?"":";"===e.substr(-1)?e+" ":e+"; ",n(this).attr("style",e+n(this).attr(t)).removeAttr(t)}),e&&(n("img.lazy",this.body).addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:n(".RL-MailMessageView .messageView .messageItem .content")[0]}),u.$win.resize()),c.windowResize(500)}},s.prototype.showInternalImages=function(e){if(this.body&&!this.body.data("rl-init-internal-images")){this.body.data("rl-init-internal-images",!0),e=c.isUnd(e)?!1:e;var t=this;n("[data-x-src-cid]",this.body).each(function(){var s=t.findAttachmentByCid(n(this).attr("data-x-src-cid"));s&&s.download&&(e&&n(this).is("img")?n(this).addClass("lazy").attr("data-original",s.linkPreview()):n(this).attr("src",s.linkPreview()))}),n("[data-x-src-location]",this.body).each(function(){var s=t.findAttachmentByContentLocation(n(this).attr("data-x-src-location"));s||(s=t.findAttachmentByCid(n(this).attr("data-x-src-location"))),s&&s.download&&(e&&n(this).is("img")?n(this).addClass("lazy").attr("data-original",s.linkPreview()):n(this).attr("src",s.linkPreview()))}),n("[data-x-style-cid]",this.body).each(function(){var e="",s="",i=t.findAttachmentByCid(n(this).attr("data-x-style-cid"));i&&i.linkPreview&&(s=n(this).attr("data-x-style-cid-name"),""!==s&&(e=c.trim(n(this).attr("style")),e=""===e?"":";"===e.substr(-1)?e+" ":e+"; ",n(this).attr("style",e+s+": url('"+i.linkPreview()+"')")))}),e&&!function(e,t){o.delay(function(){e.addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:t})},300)}(n("img.lazy",t.body),n(".RL-MailMessageView .messageView .messageItem .content")[0]),c.windowResize(500) -}},s.prototype.storeDataToDom=function(){if(this.body){this.body.data("rl-is-html",!!this.isHtml()),this.body.data("rl-has-images",!!this.hasImages()),this.body.data("rl-plain-raw",this.plainRaw);var e=t("Storage:RainLoop:Data");e.capaOpenPGP()&&(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()))}},s.prototype.storePgpVerifyDataToDom=function(){var e=t("Storage:RainLoop:Data");this.body&&e.capaOpenPGP()&&(this.body.data("rl-pgp-verify-status",this.pgpSignedVerifyStatus()),this.body.data("rl-pgp-verify-user",this.pgpSignedVerifyUser()))},s.prototype.fetchDataToDom=function(){if(this.body){this.isHtml(!!this.body.data("rl-is-html")),this.hasImages(!!this.body.data("rl-has-images")),this.plainRaw=c.pString(this.body.data("rl-plain-raw"));var e=t("Storage:RainLoop:Data");e.capaOpenPGP()?(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(l.SignedVerifyStatus.None),this.pgpSignedVerifyUser(""))}},s.prototype.verifyPgpSignedClearMessage=function(){if(this.isPgpSigned()){var e=[],s=null,a=t("Storage:RainLoop:Data"),r=this.from&&this.from[0]&&this.from[0].email?this.from[0].email:"",c=a.findPublicKeysByEmail(r),d=null,p=null,h="";this.pgpSignedVerifyStatus(l.SignedVerifyStatus.Error),this.pgpSignedVerifyUser("");try{s=i.openpgp.cleartext.readArmored(this.plainRaw),s&&s.getText&&(this.pgpSignedVerifyStatus(c.length?l.SignedVerifyStatus.Unverified:l.SignedVerifyStatus.UnknownPublicKeys),e=s.verify(c),e&&0').text(h)).html(),u.$div.empty(),this.replacePlaneTextBody(h)))))}catch(g){}this.storePgpVerifyDataToDom()}},s.prototype.decryptPgpEncryptedMessage=function(e){if(this.isPgpEncrypted()){var s=[],a=null,r=null,c=t("Storage:RainLoop:Data"),d=this.from&&this.from[0]&&this.from[0].email?this.from[0].email:"",p=c.findPublicKeysByEmail(d),h=c.findSelfPrivateKey(e),g=null,m=null,f="";this.pgpSignedVerifyStatus(l.SignedVerifyStatus.Error),this.pgpSignedVerifyUser(""),h||this.pgpSignedVerifyStatus(l.SignedVerifyStatus.UnknownPrivateKey);try{a=i.openpgp.message.readArmored(this.plainRaw),a&&h&&a.decrypt&&(this.pgpSignedVerifyStatus(l.SignedVerifyStatus.Unverified),r=a.decrypt(h),r&&(s=r.verify(p),s&&0').text(f)).html(),u.$div.empty(),this.replacePlaneTextBody(f)))}catch(b){}this.storePgpVerifyDataToDom()}},s.prototype.replacePlaneTextBody=function(e){this.body&&this.body.html(e).addClass("b-text-part plain")},s.prototype.flagHash=function(){return[this.deleted(),this.unseen(),this.flagged(),this.answered(),this.forwarded(),this.isReadReceipt()].join("")},e.exports=s}(t,e)},{$:20,Enums:7,Globals:9,LinkBuilder:11,"Model:Attachment":32,"Model:Email":37,"Storage:RainLoop:Data":64,Utils:14,_:25,ko:22,moment:23,window:26}],43:[function(e,t){!function(e,t){"use strict";function s(e,t,s,o,n,a,r){this.index=e,this.id=s,this.guid=t,this.user=o,this.email=n,this.armor=r,this.isPrivate=!!a,this.deleteAccess=i.observable(!1)}var i=t("ko");s.prototype.index=0,s.prototype.id="",s.prototype.guid="",s.prototype.user="",s.prototype.email="",s.prototype.armor="",s.prototype.isPrivate=!1,e.exports=s}(t,e)},{ko:22}],44:[function(e,t){!function(e,t){"use strict";function s(){o.call(this,"about",[t("View:RainLoop:About")])}var i=t("_"),o=t("Knoin:AbstractScreen");i.extend(s.prototype,o.prototype),s.prototype.onShow=function(){t("App:RainLoop").setTitle("RainLoop")},e.exports=s}(t,e)},{"App:RainLoop":3,"Knoin:AbstractScreen":29,"View:RainLoop:About":70,_:25}],45:[function(e,t){!function(e,t){"use strict";function s(e){u.call(this,"settings",e),this.menu=n.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}var i=t("_"),o=t("$"),n=t("ko"),a=t("Globals"),r=t("Utils"),l=t("LinkBuilder"),c=t("App:Knoin"),u=t("Knoin:AbstractScreen");i.extend(s.prototype,u.prototype),s.prototype.onRoute=function(e){var t=this,s=null,u=null,d=null,p=null;u=i.find(a.aViewModels.settings,function(t){return t&&t.__rlSettingsData&&e===t.__rlSettingsData.Route}),u&&(i.find(a.aViewModels["settings-removed"],function(e){return e&&e===u})&&(u=null),u&&i.find(a.aViewModels["settings-disabled"],function(e){return e&&e===u})&&(u=null)),u?(u.__builded&&u.__vm?s=u.__vm:(d=this.oViewModelPlace,d&&1===d.length?(s=new u,p=o("
").addClass("rl-settings-view-model").hide(),p.appendTo(d),s.viewModelDom=p,s.__rlSettingsData=u.__rlSettingsData,u.__dom=p,u.__builded=!0,u.__vm=s,n.applyBindingAccessorsToNode(p[0],{i18nInit:!0,template:function(){return{name:u.__rlSettingsData.Template}}},s),r.delegateRun(s,"onBuild",[p])):r.log("Cannot find sub settings view model position: SettingsSubScreen")),s&&i.defer(function(){t.oCurrentSubScreen&&(r.delegateRun(t.oCurrentSubScreen,"onHide"),t.oCurrentSubScreen.viewModelDom.hide()),t.oCurrentSubScreen=s,t.oCurrentSubScreen&&(t.oCurrentSubScreen.viewModelDom.show(),r.delegateRun(t.oCurrentSubScreen,"onShow"),r.delegateRun(t.oCurrentSubScreen,"onFocus",[],200),i.each(t.menu(),function(e){e.selected(s&&s.__rlSettingsData&&e.route===s.__rlSettingsData.Route)}),o("#rl-content .b-settings .b-content .content").scrollTop(0)),r.windowResize()})):c.setHash(l.settings(),!1,!0)},s.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(r.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},s.prototype.onBuild=function(){i.each(a.aViewModels.settings,function(e){e&&e.__rlSettingsData&&!i.find(a.aViewModels["settings-removed"],function(t){return t&&t===e})&&this.menu.push({route:e.__rlSettingsData.Route,label:e.__rlSettingsData.Label,selected:n.observable(!1),disabled:!!i.find(a.aViewModels["settings-disabled"],function(t){return t&&t===e})})},this),this.oViewModelPlace=o("#rl-content #rl-settings-subscreen")},s.prototype.routes=function(){var e=i.find(a.aViewModels.settings,function(e){return e&&e.__rlSettingsData&&e.__rlSettingsData.IsDefault}),t=e?e.__rlSettingsData.Route:"general",s={subname:/^(.*)$/,normalize_:function(e,s){return s.subname=r.isUnd(s.subname)?t:r.pString(s.subname),[s.subname]}};return[["{subname}/",s],["{subname}",s],["",s]]},e.exports=s}(t,e)},{$:20,"App:Knoin":27,Globals:9,"Knoin:AbstractScreen":29,LinkBuilder:11,Utils:14,_:25,ko:22}],46:[function(e,t){!function(e,t){"use strict";function s(){o.call(this,"login",[t("View:RainLoop:Login")])}var i=t("_"),o=t("Knoin:AbstractScreen");i.extend(s.prototype,o.prototype),s.prototype.onShow=function(){t("App:RainLoop").setTitle("")},e.exports=s}(t,e)},{"App:RainLoop":3,"Knoin:AbstractScreen":29,"View:RainLoop:Login":72,_:25}],47:[function(e,t){!function(e,t){"use strict";function s(){l.call(this,"mailbox",[t("View:RainLoop:MailBoxSystemDropDown"),t("View:RainLoop:MailBoxFolderList"),t("View:RainLoop:MailBoxMessageList"),t("View:RainLoop:MailBoxMessageView")]),this.oLastRoute={}}var i=t("_"),o=t("Enums"),n=t("Globals"),a=t("Utils"),r=t("Events"),l=t("Knoin:AbstractScreen"),c=t("Storage:Settings"),u=t("Storage:RainLoop:Data"),d=t("Storage:RainLoop:Cache"),p=t("Storage:RainLoop:Remote");i.extend(s.prototype,l.prototype),s.prototype.oLastRoute={},s.prototype.setNewTitle=function(){var e=u.accountEmail(),s=u.foldersInboxUnreadCount();t("App:RainLoop").setTitle((""===e?"":(s>0?"("+s+") ":" ")+e+" - ")+a.i18n("TITLES/MAILBOX"))},s.prototype.onShow=function(){this.setNewTitle(),n.keyScope(o.KeyState.MessageList)},s.prototype.onRoute=function(e,s,i,n){if(a.isUnd(n)?1:!n){var r=d.getFolderFullNameRaw(e),l=d.getFolderFromCacheList(r);l&&(u.currentFolder(l).messageListPage(s).messageListSearch(i),o.Layout.NoPreview===u.layout()&&u.message()&&u.message(null),t("App:RainLoop").reloadMessageList())}else o.Layout.NoPreview!==u.layout()||u.message()||t("App:RainLoop").historyBack()},s.prototype.onStart=function(){var e=function(){a.windowResize()};(c.capa(o.Capa.AdditionalAccounts)||c.capa(o.Capa.AdditionalIdentities))&&t("App:RainLoop").accountsAndIdentities(),i.delay(function(){"INBOX"!==u.currentFolderFullNameRaw()&&t("App:RainLoop").folderInformation("INBOX")},1e3),i.delay(function(){t("App:RainLoop").quota()},5e3),i.delay(function(){p.appDelayStart(a.emptyFunction)},35e3),n.$html.toggleClass("rl-no-preview-pane",o.Layout.NoPreview===u.layout()),u.folderList.subscribe(e),u.messageList.subscribe(e),u.message.subscribe(e),u.layout.subscribe(function(e){n.$html.toggleClass("rl-no-preview-pane",o.Layout.NoPreview===e)}),r.sub("mailbox.inbox-unread-count",function(e){u.foldersInboxUnreadCount(e)}),u.foldersInboxUnreadCount.subscribe(function(){this.setNewTitle()},this)},s.prototype.routes=function(){var e=function(){return["Inbox",1,"",!0]},t=function(e,t){return t[0]=a.pString(t[0]),t[1]=a.pInt(t[1]),t[1]=0>=t[1]?1:t[1],t[2]=a.pString(t[2]),""===e&&(t[0]="Inbox",t[1]=1),[decodeURI(t[0]),t[1],decodeURI(t[2]),!1]},s=function(e,t){return t[0]=a.pString(t[0]),t[1]=a.pString(t[1]),""===e&&(t[0]="Inbox"),[decodeURI(t[0]),1,decodeURI(t[1]),!1]};return[[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/,{normalize_:t}],[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/,{normalize_:t}],[/^([a-zA-Z0-9]+)\/(.+)\/?$/,{normalize_:s}],[/^message-preview$/,{normalize_:e}],[/^([^\/]*)$/,{normalize_:t}]]},e.exports=s}(t,e)},{"App:RainLoop":3,Enums:7,Events:8,Globals:9,"Knoin:AbstractScreen":29,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,Utils:14,"View:RainLoop:MailBoxFolderList":73,"View:RainLoop:MailBoxMessageList":74,"View:RainLoop:MailBoxMessageView":75,"View:RainLoop:MailBoxSystemDropDown":76,_:25}],48:[function(e,t){!function(e,t){"use strict";function s(){r.call(this,[t("View:RainLoop:SettingsSystemDropDown"),t("View:RainLoop:SettingsMenu"),t("View:RainLoop:SettingsPane")]),n.initOnStartOrLangChange(function(){this.sSettingsTitle=n.i18n("TITLES/SETTINGS")},this,function(){this.setSettingsTitle()})}var i=t("_"),o=t("Enums"),n=t("Utils"),a=t("Globals"),r=t("Screen:AbstractSettings");i.extend(s.prototype,r.prototype),s.prototype.onShow=function(){this.setSettingsTitle(),a.keyScope(o.KeyState.Settings)},s.prototype.setSettingsTitle=function(){t("App:RainLoop").setTitle(this.sSettingsTitle)},e.exports=s}(t,e)},{"App:RainLoop":3,Enums:7,Globals:9,"Screen:AbstractSettings":45,Utils:14,"View:RainLoop:SettingsMenu":94,"View:RainLoop:SettingsPane":95,"View:RainLoop:SettingsSystemDropDown":96,_:25}],49:[function(e,t){!function(e,t){"use strict";function s(){this.accounts=c.accounts,this.processText=n.computed(function(){return c.accountsLoading()?r.i18n("SETTINGS_ACCOUNTS/LOADING_PROCESS"):""},this),this.visibility=n.computed(function(){return""===this.processText()?"hidden":"visible"},this),this.accountForDeletion=n.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(e){e&&e.deleteAccess(!1)},function(e){e&&e.deleteAccess(!0)}]})}var i=t("window"),o=t("_"),n=t("ko"),a=t("Enums"),r=t("Utils"),l=t("LinkBuilder"),c=t("Storage:RainLoop:Data"),u=t("Storage:RainLoop:Remote");s.prototype.addNewAccount=function(){t("App:Knoin").showScreenPopup(t("View:Popup:AddAccount"))},s.prototype.deleteAccount=function(e){if(e&&e.deleteAccess()){this.accountForDeletion(null);var s=t("App:Knoin"),n=function(t){return e===t};e&&(this.accounts.remove(n),u.accountDelete(function(e,n){a.StorageResultType.Success===e&&n&&n.Result&&n.Reload?(s.routeOff(),s.setHash(l.root(),!0),s.routeOff(),o.defer(function(){i.location.reload()})):t("App:RainLoop").accountsAndIdentities()},e.email))}},e.exports=s}(t,e)},{"App:Knoin":27,"App:RainLoop":3,Enums:7,LinkBuilder:11,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,Utils:14,"View:Popup:AddAccount":77,_:25,ko:22,window:26}],50:[function(e,t){!function(e,t){"use strict";function s(){this.changeProcess=o.observable(!1),this.errorDescription=o.observable(""),this.passwordMismatch=o.observable(!1),this.passwordUpdateError=o.observable(!1),this.passwordUpdateSuccess=o.observable(!1),this.currentPassword=o.observable(""),this.currentPassword.error=o.observable(!1),this.newPassword=o.observable(""),this.newPassword2=o.observable(""),this.currentPassword.subscribe(function(){this.passwordUpdateError(!1),this.passwordUpdateSuccess(!1),this.currentPassword.error(!1)},this),this.newPassword.subscribe(function(){this.passwordUpdateError(!1),this.passwordUpdateSuccess(!1),this.passwordMismatch(!1)},this),this.newPassword2.subscribe(function(){this.passwordUpdateError(!1),this.passwordUpdateSuccess(!1),this.passwordMismatch(!1)},this),this.saveNewPasswordCommand=a.createCommand(this,function(){this.newPassword()!==this.newPassword2()?(this.passwordMismatch(!0),this.errorDescription(a.i18n("SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH"))):(this.changeProcess(!0),this.passwordUpdateError(!1),this.passwordUpdateSuccess(!1),this.currentPassword.error(!1),this.passwordMismatch(!1),this.errorDescription(""),r.changePassword(this.onChangePasswordResponse,this.currentPassword(),this.newPassword()))},function(){return!this.changeProcess()&&""!==this.currentPassword()&&""!==this.newPassword()&&""!==this.newPassword2()}),this.onChangePasswordResponse=i.bind(this.onChangePasswordResponse,this)}var i=t("_"),o=t("ko"),n=t("Enums"),a=t("Utils"),r=t("Storage:RainLoop:Remote");s.prototype.onHide=function(){this.changeProcess(!1),this.currentPassword(""),this.newPassword(""),this.newPassword2(""),this.errorDescription(""),this.passwordMismatch(!1),this.currentPassword.error(!1)},s.prototype.onChangePasswordResponse=function(e,t){this.changeProcess(!1),this.passwordMismatch(!1),this.errorDescription(""),this.currentPassword.error(!1),n.StorageResultType.Success===e&&t&&t.Result?(this.currentPassword(""),this.newPassword(""),this.newPassword2(""),this.passwordUpdateSuccess(!0),this.currentPassword.error(!1)):(t&&n.Notification.CurrentPasswordIncorrect===t.ErrorCode&&this.currentPassword.error(!0),this.passwordUpdateError(!0),this.errorDescription(a.getNotification(t&&t.ErrorCode?t.ErrorCode:n.Notification.CouldNotSaveNewPassword)))},e.exports=s}(t,e)},{Enums:7,"Storage:RainLoop:Remote":68,Utils:14,_:25,ko:22}],51:[function(e,t){!function(e,t){"use strict";function s(){this.contactsAutosave=a.contactsAutosave,this.allowContactsSync=a.allowContactsSync,this.enableContactsSync=a.enableContactsSync,this.contactsSyncUrl=a.contactsSyncUrl,this.contactsSyncUser=a.contactsSyncUser,this.contactsSyncPass=a.contactsSyncPass,this.saveTrigger=i.computed(function(){return[this.enableContactsSync()?"1":"0",this.contactsSyncUrl(),this.contactsSyncUser(),this.contactsSyncPass()].join("|")},this).extend({throttle:500}),this.saveTrigger.subscribe(function(){n.saveContactsSyncData(null,this.enableContactsSync(),this.contactsSyncUrl(),this.contactsSyncUser(),this.contactsSyncPass())},this)}var i=t("ko"),o=t("Utils"),n=t("Storage:RainLoop:Remote"),a=t("Storage:RainLoop:Data");s.prototype.onBuild=function(){a.contactsAutosave.subscribe(function(e){n.saveSettings(o.emptyFunction,{ContactsAutosave:e?"1":"0"})})},e.exports=s}(t,e)},{"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,Utils:14,ko:22}],52:[function(e,t){!function(e,t){"use strict";function s(){this.filters=i.observableArray([]),this.filters.loading=i.observable(!1),this.filters.subscribe(function(){o.windowResize()})}var i=t("ko"),o=t("Utils");s.prototype.deleteFilter=function(e){this.filters.remove(e)},s.prototype.addFilter=function(){var e=t("Model:Filter");t("App:Knoin").showScreenPopup(t("View:Popup:Filter"),[new e])},e.exports=s}(t,e)},{"App:Knoin":27,"Model:Filter":39,Utils:14,"View:Popup:Filter":84,ko:22}],53:[function(e,t){!function(e,t){"use strict";function s(){this.foldersListError=r.foldersListError,this.folderList=r.folderList,this.processText=i.computed(function(){var e=r.foldersLoading(),t=r.foldersCreating(),s=r.foldersDeleting(),i=r.foldersRenaming();return t?n.i18n("SETTINGS_FOLDERS/CREATING_PROCESS"):s?n.i18n("SETTINGS_FOLDERS/DELETING_PROCESS"):i?n.i18n("SETTINGS_FOLDERS/RENAMING_PROCESS"):e?n.i18n("SETTINGS_FOLDERS/LOADING_PROCESS"):""},this),this.visibility=i.computed(function(){return""===this.processText()?"hidden":"visible"},this),this.folderForDeletion=i.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(e){e&&e.deleteAccess(!1)},function(e){e&&e.deleteAccess(!0)}]}),this.folderForEdit=i.observable(null).extend({toggleSubscribe:[this,function(e){e&&e.edited(!1)},function(e){e&&e.canBeEdited()&&e.edited(!0)}]}),this.useImapSubscribe=!!a.settingsGet("UseImapSubscribe")}var i=t("ko"),o=t("Enums"),n=t("Utils"),a=t("Storage:Settings"),r=t("Storage:RainLoop:Data"),l=t("Storage:RainLoop:Cache"),c=t("Storage:RainLoop:Remote"),u=t("Storage:LocalStorage");s.prototype.folderEditOnEnter=function(e){var s=e?n.trim(e.nameForEdit()):"";""!==s&&e.name()!==s&&(u.set(o.ClientSideKeyName.FoldersLashHash,""),r.foldersRenaming(!0),c.folderRename(function(e,s){r.foldersRenaming(!1),o.StorageResultType.Success===e&&s&&s.Result||r.foldersListError(s&&s.ErrorCode?n.getNotification(s.ErrorCode):n.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER")),t("App:RainLoop").folders()},e.fullNameRaw,s),l.removeFolderFromCacheList(e.fullNameRaw),e.name(s)),e.edited(!1)},s.prototype.folderEditOnEsc=function(e){e&&e.edited(!1)},s.prototype.onShow=function(){r.foldersListError("")},s.prototype.createFolder=function(){t("App:Knoin").showScreenPopup(t("View:Popup:FolderCreate"))},s.prototype.systemFolder=function(){t("App:Knoin").showScreenPopup(t("View:Popup:FolderSystem"))},s.prototype.deleteFolder=function(e){if(e&&e.canBeDeleted()&&e.deleteAccess()&&0===e.privateMessageCountAll()){this.folderForDeletion(null);var s=function(t){return e===t?!0:(t.subFolders.remove(s),!1)};e&&(u.set(o.ClientSideKeyName.FoldersLashHash,""),r.folderList.remove(s),r.foldersDeleting(!0),c.folderDelete(function(e,s){r.foldersDeleting(!1),o.StorageResultType.Success===e&&s&&s.Result||r.foldersListError(s&&s.ErrorCode?n.getNotification(s.ErrorCode):n.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER")),t("App:RainLoop").folders()},e.fullNameRaw),l.removeFolderFromCacheList(e.fullNameRaw))}else 0"},s.prototype.addNewIdentity=function(){t("App:Knoin").showScreenPopup(t("View:Popup:Identity"))},s.prototype.editIdentity=function(e){t("App:Knoin").showScreenPopup(t("View:Popup:Identity"),[e])},s.prototype.deleteIdentity=function(e){if(e&&e.deleteAccess()){this.identityForDeletion(null);var s=function(t){return e===t};e&&(this.identities.remove(s),c.identityDelete(function(){t("App:RainLoop").accountsAndIdentities()},e.id))}},s.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var e=this,t=l.signature();this.editor=new r(e.signatureDom(),function(){l.signature((e.editor.isHtml()?":HTML:":"")+e.editor.getData())},function(){":HTML:"===t.substr(0,6)?e.editor.setHtml(t.substr(6),!1):e.editor.setPlain(t,!1)})}},s.prototype.onBuild=function(e){var t=this;e.on("click",".identity-item .e-action",function(){var e=o.dataFor(this);e&&t.editIdentity(e)}),i.delay(function(){var e=a.settingsSaveHelperSimpleFunction(t.displayNameTrigger,t),s=a.settingsSaveHelperSimpleFunction(t.replyTrigger,t),i=a.settingsSaveHelperSimpleFunction(t.signatureTrigger,t),o=a.settingsSaveHelperSimpleFunction(t.defaultIdentityIDTrigger,t);l.defaultIdentityID.subscribe(function(e){c.saveSettings(o,{DefaultIdentityID:e})}),l.displayName.subscribe(function(t){c.saveSettings(e,{DisplayName:t})}),l.replyTo.subscribe(function(e){c.saveSettings(s,{ReplyTo:e})}),l.signature.subscribe(function(e){c.saveSettings(i,{Signature:e})}),l.signatureToAll.subscribe(function(e){c.saveSettings(null,{SignatureToAll:e?"1":"0"})})},50)},e.exports=s}(t,e)},{"App:Knoin":27,"App:RainLoop":3,Enums:7,HtmlEditor:10,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,Utils:14,"View:Popup:Identity":88,_:25,ko:22}],56:[function(e,t){!function(e,t){"use strict";function s(){this.editor=null,this.displayName=l.displayName,this.signature=l.signature,this.signatureToAll=l.signatureToAll,this.replyTo=l.replyTo,this.signatureDom=o.observable(null),this.displayNameTrigger=o.observable(n.SaveSettingsStep.Idle),this.replyTrigger=o.observable(n.SaveSettingsStep.Idle),this.signatureTrigger=o.observable(n.SaveSettingsStep.Idle)}var i=t("_"),o=t("ko"),n=t("Enums"),a=t("Utils"),r=t("HtmlEditor"),l=t("Storage:RainLoop:Data"),c=t("Storage:RainLoop:Remote");s.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var e=this,t=l.signature();this.editor=new r(e.signatureDom(),function(){l.signature((e.editor.isHtml()?":HTML:":"")+e.editor.getData())},function(){":HTML:"===t.substr(0,6)?e.editor.setHtml(t.substr(6),!1):e.editor.setPlain(t,!1)})}},s.prototype.onBuild=function(){var e=this;i.delay(function(){var t=a.settingsSaveHelperSimpleFunction(e.displayNameTrigger,e),s=a.settingsSaveHelperSimpleFunction(e.replyTrigger,e),i=a.settingsSaveHelperSimpleFunction(e.signatureTrigger,e);l.displayName.subscribe(function(e){c.saveSettings(t,{DisplayName:e})}),l.replyTo.subscribe(function(e){c.saveSettings(s,{ReplyTo:e})}),l.signature.subscribe(function(e){c.saveSettings(i,{Signature:e})}),l.signatureToAll.subscribe(function(e){c.saveSettings(null,{SignatureToAll:e?"1":"0"})})},50)},e.exports=s}(t,e)},{Enums:7,HtmlEditor:10,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,Utils:14,_:25,ko:22}],57:[function(e,t){!function(e,t){"use strict";function s(){this.openpgpkeys=n.openpgpkeys,this.openpgpkeysPublic=n.openpgpkeysPublic,this.openpgpkeysPrivate=n.openpgpkeysPrivate,this.openPgpKeyForDeletion=i.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(e){e&&e.deleteAccess(!1)},function(e){e&&e.deleteAccess(!0)}]})}var i=t("ko"),o=t("App:Knoin"),n=t("Storage:RainLoop:Data");s.prototype.addOpenPgpKey=function(){o.showScreenPopup(t("View:Popup:AddOpenPgpKey"))},s.prototype.generateOpenPgpKey=function(){o.showScreenPopup(t("View:Popup:NewOpenPgpKey"))},s.prototype.viewOpenPgpKey=function(e){e&&o.showScreenPopup(t("View:Popup:ViewOpenPgpKey"),[e])},s.prototype.deleteOpenPgpKey=function(e){e&&e.deleteAccess()&&(this.openPgpKeyForDeletion(null),e&&n.openpgpKeyring&&(this.openpgpkeys.remove(function(t){return e===t}),n.openpgpKeyring[e.isPrivate?"privateKeys":"publicKeys"].removeForId(e.guid),n.openpgpKeyring.store(),t("App:RainLoop").reloadOpenPgpKeys()))},e.exports=s}(t,e)},{"App:Knoin":27,"App:RainLoop":3,"Storage:RainLoop:Data":64,"View:Popup:AddOpenPgpKey":78,"View:Popup:NewOpenPgpKey":91,"View:Popup:ViewOpenPgpKey":93,ko:22}],58:[function(e,t){!function(e,t){"use strict";function s(){this.processing=i.observable(!1),this.clearing=i.observable(!1),this.secreting=i.observable(!1),this.viewUser=i.observable(""),this.viewEnable=i.observable(!1),this.viewEnable.subs=!0,this.twoFactorStatus=i.observable(!1),this.viewSecret=i.observable(""),this.viewBackupCodes=i.observable(""),this.viewUrl=i.observable(""),this.bFirst=!0,this.viewTwoFactorStatus=i.computed(function(){return n.langChangeTrigger(),a.i18n(this.twoFactorStatus()?"SETTINGS_SECURITY/TWO_FACTOR_SECRET_CONFIGURED_DESC":"SETTINGS_SECURITY/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC")},this),this.onResult=_.bind(this.onResult,this),this.onSecretResult=_.bind(this.onSecretResult,this)}var i=t("ko"),o=t("Enums"),n=t("Globals"),a=t("Utils"),r=t("Storage:RainLoop:Remote");s.prototype.showSecret=function(){this.secreting(!0),r.showTwoFactorSecret(this.onSecretResult)},s.prototype.hideSecret=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")},s.prototype.createTwoFactor=function(){this.processing(!0),r.createTwoFactor(this.onResult)},s.prototype.enableTwoFactor=function(){this.processing(!0),r.enableTwoFactor(this.onResult,this.viewEnable())},s.prototype.testTwoFactor=function(){t("App:Knoin").showScreenPopup(t("View:Popup:TwoFactorTest"))},s.prototype.clearTwoFactor=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl(""),this.clearing(!0),r.clearTwoFactor(this.onResult)},s.prototype.onShow=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")},s.prototype.onResult=function(e,t){if(this.processing(!1),this.clearing(!1),o.StorageResultType.Success===e&&t&&t.Result?(this.viewUser(a.pString(t.Result.User)),this.viewEnable(!!t.Result.Enable),this.twoFactorStatus(!!t.Result.IsSet),this.viewSecret(a.pString(t.Result.Secret)),this.viewBackupCodes(a.pString(t.Result.BackupCodes).replace(/[\s]+/g," ")),this.viewUrl(a.pString(t.Result.Url))):(this.viewUser(""),this.viewEnable(!1),this.twoFactorStatus(!1),this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")),this.bFirst){this.bFirst=!1;var s=this;this.viewEnable.subscribe(function(e){this.viewEnable.subs&&r.enableTwoFactor(function(e,t){o.StorageResultType.Success===e&&t&&t.Result||(s.viewEnable.subs=!1,s.viewEnable(!1),s.viewEnable.subs=!0)},e)},this)}},s.prototype.onSecretResult=function(e,t){this.secreting(!1),o.StorageResultType.Success===e&&t&&t.Result?(this.viewSecret(a.pString(t.Result.Secret)),this.viewUrl(a.pString(t.Result.Url))):(this.viewSecret(""),this.viewUrl(""))},s.prototype.onBuild=function(){this.processing(!0),r.getTwoFactor(this.onResult)},e.exports=s}(t,e)},{"App:Knoin":27,Enums:7,Globals:9,"Storage:RainLoop:Remote":68,Utils:14,"View:Popup:TwoFactorTest":92,ko:22}],59:[function(e,t){!function(e,t){"use strict";function s(){var e=t("Utils"),s=t("Storage:RainLoop:Data");this.googleEnable=s.googleEnable,this.googleActions=s.googleActions,this.googleLoggined=s.googleLoggined,this.googleUserName=s.googleUserName,this.facebookEnable=s.facebookEnable,this.facebookActions=s.facebookActions,this.facebookLoggined=s.facebookLoggined,this.facebookUserName=s.facebookUserName,this.twitterEnable=s.twitterEnable,this.twitterActions=s.twitterActions,this.twitterLoggined=s.twitterLoggined,this.twitterUserName=s.twitterUserName,this.connectGoogle=e.createCommand(this,function(){this.googleLoggined()||t("App:RainLoop").googleConnect() -},function(){return!this.googleLoggined()&&!this.googleActions()}),this.disconnectGoogle=e.createCommand(this,function(){t("App:RainLoop").googleDisconnect()}),this.connectFacebook=e.createCommand(this,function(){this.facebookLoggined()||t("App:RainLoop").facebookConnect()},function(){return!this.facebookLoggined()&&!this.facebookActions()}),this.disconnectFacebook=e.createCommand(this,function(){t("App:RainLoop").facebookDisconnect()}),this.connectTwitter=e.createCommand(this,function(){this.twitterLoggined()||t("App:RainLoop").twitterConnect()},function(){return!this.twitterLoggined()&&!this.twitterActions()}),this.disconnectTwitter=e.createCommand(this,function(){t("App:RainLoop").twitterDisconnect()})}e.exports=s}(t,e)},{"App:RainLoop":3,"Storage:RainLoop:Data":64,Utils:14}],60:[function(e,t){!function(e,t){"use strict";function s(){var e=this;this.mainTheme=u.mainTheme,this.themesObjects=a.observableArray([]),this.themeTrigger=a.observable(r.SaveSettingsStep.Idle).extend({throttle:100}),this.oLastAjax=null,this.iTimer=0,u.theme.subscribe(function(t){o.each(this.themesObjects(),function(e){e.selected(t===e.name)});var s=n("#rlThemeLink"),a=n("#rlThemeStyle"),c=s.attr("href");c||(c=a.attr("data-href")),c&&(c=c.toString().replace(/\/-\/[^\/]+\/\-\//,"/-/"+t+"/-/"),c=c.toString().replace(/\/Css\/[^\/]+\/User\//,"/Css/0/User/"),"Json/"!==c.substring(c.length-5,c.length)&&(c+="Json/"),i.clearTimeout(e.iTimer),e.themeTrigger(r.SaveSettingsStep.Animate),this.oLastAjax&&this.oLastAjax.abort&&this.oLastAjax.abort(),this.oLastAjax=n.ajax({url:c,dataType:"json"}).done(function(t){t&&l.isArray(t)&&2===t.length&&(!s||!s[0]||a&&a[0]||(a=n(''),s.after(a),s.remove()),a&&a[0]&&(a.attr("data-href",c).attr("data-theme",t[0]),a&&a[0]&&a[0].styleSheet&&!l.isUnd(a[0].styleSheet.cssText)?a[0].styleSheet.cssText=t[1]:a.text(t[1])),e.themeTrigger(r.SaveSettingsStep.TrueResult))}).always(function(){e.iTimer=i.setTimeout(function(){e.themeTrigger(r.SaveSettingsStep.Idle)},1e3),e.oLastAjax=null})),d.saveSettings(null,{Theme:t})},this)}var i=t("window"),o=t("_"),n=t("$"),a=t("ko"),r=t("Enums"),l=t("Utils"),c=t("LinkBuilder"),u=t("Storage:RainLoop:Data"),d=t("Storage:RainLoop:Remote");s.prototype.onBuild=function(){var e=u.theme();this.themesObjects(o.map(u.themes(),function(t){return{name:t,nameDisplay:l.convertThemeName(t),selected:a.observable(t===e),themePreviewSrc:c.themePreviewLink(t)}}))},e.exports=s}(t,e)},{$:20,Enums:7,LinkBuilder:11,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,Utils:14,_:25,ko:22,window:26}],61:[function(e,t){!function(e,t){"use strict";function s(){o.initDataConstructorBySettings(this)}var i=t("Enums"),o=t("Utils"),n=t("Storage:Settings");s.prototype.populateDataOnStart=function(){var e=o.pInt(n.settingsGet("Layout")),t=n.settingsGet("Languages"),s=n.settingsGet("Themes");o.isArray(t)&&this.languages(t),o.isArray(s)&&this.themes(s),this.mainLanguage(n.settingsGet("Language")),this.mainTheme(n.settingsGet("Theme")),this.capaAdditionalAccounts(n.capa(i.Capa.AdditionalAccounts)),this.capaAdditionalIdentities(n.capa(i.Capa.AdditionalIdentities)),this.capaGravatar(n.capa(i.Capa.Gravatar)),this.determineUserLanguage(!!n.settingsGet("DetermineUserLanguage")),this.determineUserDomain(!!n.settingsGet("DetermineUserDomain")),this.capaThemes(n.capa(i.Capa.Themes)),this.allowLanguagesOnLogin(!!n.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!n.settingsGet("AllowLanguagesOnSettings")),this.useLocalProxyForExternalImages(!!n.settingsGet("UseLocalProxyForExternalImages")),this.editorDefaultType(n.settingsGet("EditorDefaultType")),this.showImages(!!n.settingsGet("ShowImages")),this.contactsAutosave(!!n.settingsGet("ContactsAutosave")),this.interfaceAnimation(n.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(n.settingsGet("MPP")),this.desktopNotifications(!!n.settingsGet("DesktopNotifications")),this.useThreads(!!n.settingsGet("UseThreads")),this.replySameFolder(!!n.settingsGet("ReplySameFolder")),this.useCheckboxesInList(!!n.settingsGet("UseCheckboxesInList")),this.layout(i.Layout.SidePreview),-1(new i.Date).getTime()-g),f&&l.oRequests[f]&&(l.oRequests[f].__aborted&&(o="abort"),l.oRequests[f]=null),l.defaultResponse(e,f,o,s,n,t)}),f&&0=e?1:e},this),this.mainMessageListSearch=a.computed({read:this.messageListSearch,write:function(e){m.setHash(p.mailBox(this.currentFolderFullNameHash(),1,d.trim(e.toString())))},owner:this}),this.messageListError=a.observable(""),this.messageListLoading=a.observable(!1),this.messageListIsNotCompleted=a.observable(!1),this.messageListCompleteLoadingThrottle=a.observable(!1).extend({throttle:200}),this.messageListCompleteLoading=a.computed(function(){var e=this.messageListLoading(),t=this.messageListIsNotCompleted();return e||t},this),this.messageListCompleteLoading.subscribe(function(e){this.messageListCompleteLoadingThrottle(e)},this),this.messageList.subscribe(o.debounce(function(e){o.each(e,function(e){e.newForAnimation()&&e.newForAnimation(!1)})},500)),this.staticMessageList=new f,this.message=a.observable(null),this.messageLoading=a.observable(!1),this.messageLoadingThrottle=a.observable(!1).extend({throttle:50}),this.message.focused=a.observable(!1),this.message.subscribe(function(e){e?c.Layout.NoPreview===this.layout()&&this.message.focused(!0):(this.message.focused(!1),this.messageFullScreenMode(!1),this.hideMessageBodies(),c.Layout.NoPreview===this.layout()&&-10?i.Math.ceil(t/e*100):0},this),this.capaOpenPGP=a.observable(!1),this.openpgpkeys=a.observableArray([]),this.openpgpKeyring=null,this.openpgpkeysPublic=this.openpgpkeys.filter(function(e){return!(!e||e.isPrivate)}),this.openpgpkeysPrivate=this.openpgpkeys.filter(function(e){return!(!e||!e.isPrivate)}),this.googleActions=a.observable(!1),this.googleLoggined=a.observable(!1),this.googleUserName=a.observable(""),this.facebookActions=a.observable(!1),this.facebookLoggined=a.observable(!1),this.facebookUserName=a.observable(""),this.twitterActions=a.observable(!1),this.twitterLoggined=a.observable(!1),this.twitterUserName=a.observable(""),this.customThemeType=a.observable(c.CustomThemeType.Light),this.purgeMessageBodyCacheThrottle=o.throttle(this.purgeMessageBodyCache,3e4)}var i=t("window"),o=t("_"),n=t("$"),a=t("ko"),r=t("moment"),l=t("Consts"),c=t("Enums"),u=t("Globals"),d=t("Utils"),p=t("LinkBuilder"),h=t("Storage:Settings"),g=t("Storage:RainLoop:Cache"),m=t("App:Knoin"),f=t("Model:Message"),b=t("Storage:LocalStorage"),y=t("Storage:Abstract:Data");o.extend(s.prototype,y.prototype),s.prototype.purgeMessageBodyCache=function(){var e=0,t=null,s=u.iMessageBodyCacheCount-l.Values.MessageBodyCacheLimit;s>0&&(t=this.messagesBodiesDom(),t&&(t.find(".rl-cache-class").each(function(){var t=n(this);s>t.data("rl-cache-count")&&(t.addClass("rl-cache-purge"),e++)}),e>0&&o.delay(function(){t.find(".rl-cache-purge").remove()},300)))},s.prototype.populateDataOnStart=function(){y.prototype.populateDataOnStart.call(this),this.accountEmail(h.settingsGet("Email")),this.accountIncLogin(h.settingsGet("IncLogin")),this.accountOutLogin(h.settingsGet("OutLogin")),this.projectHash(h.settingsGet("ProjectHash")),this.defaultIdentityID(h.settingsGet("DefaultIdentityID")),this.displayName(h.settingsGet("DisplayName")),this.replyTo(h.settingsGet("ReplyTo")),this.signature(h.settingsGet("Signature")),this.signatureToAll(!!h.settingsGet("SignatureToAll")),this.enableTwoFactor(!!h.settingsGet("EnableTwoFactor")),this.lastFoldersHash=b.get(c.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!h.settingsGet("RemoteSuggestions"),this.devEmail=h.settingsGet("DevEmail"),this.devPassword=h.settingsGet("DevPassword")},s.prototype.initUidNextAndNewMessages=function(e,t,s){if("INBOX"===e&&d.isNormal(t)&&""!==t){if(d.isArray(s)&&03)l(p.notificationMailIcon(),this.accountEmail(),d.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:r}));else for(;r>a;a++)l(p.notificationMailIcon(),f.emailsToLine(f.initEmailsFromJson(s[a].From),!1),s[a].Subject)}g.setFolderUidNext(e,t)}},s.prototype.hideMessageBodies=function(){var e=this.messagesBodiesDom();e&&e.find(".b-text-part").hide()},s.prototype.getNextFolderNames=function(e){e=d.isUnd(e)?!1:!!e;var t=[],s=10,i=r().unix(),n=i-300,a=[],l=function(t){o.each(t,function(t){t&&"INBOX"!==t.fullNameRaw&&t.selectable&&t.existen&&n>t.interval&&(!e||t.subScribed())&&a.push([t.interval,t.fullNameRaw]),t&&0t[0]?1:0}),o.find(a,function(e){var o=g.getFolderFromCacheList(e[1]);return o&&(o.interval=i,t.push(e[1])),s<=t.length}),o.uniq(t)},s.prototype.removeMessagesFromList=function(e,t,s,i){s=d.isNormal(s)?s:"",i=d.isUnd(i)?!1:!!i,t=o.map(t,function(e){return d.pInt(e)});var n=this,a=0,r=this.messageList(),l=g.getFolderFromCacheList(e),c=""===s?null:g.getFolderFromCacheList(s||""),u=this.currentFolderFullNameRaw(),p=this.message(),h=u===e?o.filter(r,function(e){return e&&-10&&l.messageCountUnread(0<=l.messageCountUnread()-a?l.messageCountUnread()-a:0)),c&&(c.messageCountAll(c.messageCountAll()+t.length),a>0&&c.messageCountUnread(c.messageCountUnread()+a),c.actionBlink(!0)),0100)&&(e.addClass("rl-bq-switcher hidden-bq"),n('').insertBefore(e).click(function(){e.toggleClass("hidden-bq"),d.windowResize()}).after("
").before("
"))})}},s.prototype.setMessage=function(e,t){var s=!1,i=!1,o=!1,a=null,r=null,l="",p="",h=!1,m=!1,f=this.messagesBodiesDom(),b=this.message();e&&b&&e.Result&&"Object/Message"===e.Result["@Object"]&&b.folderFullNameRaw===e.Result.Folder&&b.uid===e.Result.Uid&&(this.messageError(""),b.initUpdateByMessageJson(e.Result),g.addRequestedMessage(b.folderFullNameRaw,b.uid),t||b.initFlagsByJson(e.Result),f=f&&f[0]?f:null,f&&(l="rl-mgs-"+b.hash.replace(/[^a-zA-Z0-9]/g,""),r=f.find("#"+l),r&&r[0]?(b.body=r,b.body&&(b.body.data("rl-cache-count",++u.iMessageBodyCacheCount),b.fetchDataToDom())):(i=!!e.Result.HasExternals,o=!!e.Result.HasInternals,a=n('
').hide().addClass("rl-cache-class"),a.data("rl-cache-count",++u.iMessageBodyCacheCount),d.isNormal(e.Result.Html)&&""!==e.Result.Html?(s=!0,p=e.Result.Html.toString()):d.isNormal(e.Result.Plain)&&""!==e.Result.Plain?(s=!1,p=d.plainToHtml(e.Result.Plain.toString(),!1),(b.isPgpSigned()||b.isPgpEncrypted())&&this.capaOpenPGP()&&(b.plainRaw=d.pString(e.Result.Plain),m=/---BEGIN PGP MESSAGE---/.test(b.plainRaw),m||(h=/-----BEGIN PGP SIGNED MESSAGE-----/.test(b.plainRaw)&&/-----BEGIN PGP SIGNATURE-----/.test(b.plainRaw)),u.$div.empty(),h&&b.isPgpSigned()?p=u.$div.append(n('
').text(b.plainRaw)).html():m&&b.isPgpEncrypted()&&(p=u.$div.append(n('
').text(b.plainRaw)).html()),u.$div.empty(),b.isPgpSigned(h),b.isPgpEncrypted(m))):s=!1,a.html(d.linkify(p)).addClass("b-text-part "+(s?"html":"plain")),b.isHtml(!!s),b.hasImages(!!i),b.pgpSignedVerifyStatus(c.SignedVerifyStatus.None),b.pgpSignedVerifyUser(""),b.body=a,b.body&&f.append(b.body),b.storeDataToDom(),o&&b.showInternalImages(!0),b.hasImages()&&this.showImages()&&b.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()),this.messageActiveDom(b.body),this.hideMessageBodies(),b.body.show(),a&&this.initBlockquoteSwitcher(a)),g.initMessageFlagsFromCache(b),b.unseen()&&u.__APP&&u.__APP.setMessageSeen(b),d.windowResize())},s.prototype.calculateMessageListHash=function(e){return o.map(e,function(e){return""+e.hash+"_"+e.threadsLen()+"_"+e.flagHash()}).join("|")},s.prototype.findPublicKeyByHex=function(e){return o.find(this.openpgpkeysPublic(),function(t){return t&&e===t.id})},s.prototype.findPublicKeysByEmail=function(e){return o.compact(o.map(this.openpgpkeysPublic(),function(t){var s=null;if(t&&e===t.email)try{if(s=i.openpgp.key.readArmored(t.armor),s&&!s.err&&s.keys&&s.keys[0])return s.keys[0]}catch(o){}return null}))},s.prototype.findPrivateKeyByEmail=function(e,t){var s=null,n=o.find(this.openpgpkeysPrivate(),function(t){return t&&e===t.email});if(n)try{s=i.openpgp.key.readArmored(n.armor),s&&!s.err&&s.keys&&s.keys[0]?(s=s.keys[0],s.decrypt(d.pString(t))):s=null}catch(a){s=null}return s},s.prototype.findSelfPrivateKey=function(e){return this.findPrivateKeyByEmail(this.accountEmail(),e)},e.exports=new s}(t,e)},{$:20,"App:Knoin":27,Consts:6,Enums:7,Globals:9,LinkBuilder:11,"Model:Message":42,"Storage:Abstract:Data":61,"Storage:LocalStorage":65,"Storage:RainLoop:Cache":63,"Storage:Settings":69,Utils:14,_:25,ko:22,moment:23,window:26}],65:[function(e,t){!function(e,t){"use strict";function s(){var e=t("_").find([t("Storage:LocalStorage:LocalStorage"),t("Storage:LocalStorage:Cookie")],function(e){return e&&e.supported()});this.oDriver=null,e&&(this.oDriver=new e)}s.prototype.oDriver=null,s.prototype.set=function(e,t){return this.oDriver?this.oDriver.set("p"+e,t):!1},s.prototype.get=function(e){return this.oDriver?this.oDriver.get("p"+e):null},e.exports=new s}(t,e)},{"Storage:LocalStorage:Cookie":66,"Storage:LocalStorage:LocalStorage":67,_:25}],66:[function(e,t){!function(e,t){"use strict";function s(){}var i=t("$"),o=t("JSON"),n=t("Consts"),a=t("Utils");s.supported=function(){return!(!window.navigator||!window.navigator.cookieEnabled)},s.prototype.set=function(e,t){var s=i.cookie(n.Values.ClientSideStorageIndexName),a=!1,r=null;try{r=null===s?null:o.parse(s)}catch(l){}r||(r={}),r[e]=t;try{i.cookie(n.Values.ClientSideStorageIndexName,o.stringify(r),{expires:30}),a=!0}catch(l){}return a},s.prototype.get=function(e){var t=i.cookie(n.Values.ClientSideStorageIndexName),s=null;try{s=null===t?null:o.parse(t),s=s&&!a.isUnd(s[e])?s[e]:null}catch(r){}return s},e.exports=s}(t,e)},{$:20,Consts:6,JSON:15,Utils:14}],67:[function(e,t){!function(e,t){"use strict";function s(){}var i=t("window"),o=t("JSON"),n=t("Consts"),a=t("Utils");s.supported=function(){return!!i.localStorage},s.prototype.set=function(e,t){var s=i.localStorage[n.Values.ClientSideStorageIndexName]||null,a=!1,r=null;try{r=null===s?null:o.parse(s)}catch(l){}r||(r={}),r[e]=t;try{i.localStorage[n.Values.ClientSideStorageIndexName]=o.stringify(r),a=!0}catch(l){}return a},s.prototype.get=function(e){var t=i.localStorage[n.Values.ClientSideStorageIndexName]||null,s=null;try{s=null===t?null:o.parse(t),s=s&&!a.isUnd(s[e])?s[e]:null}catch(r){}return s},e.exports=s}(t,e)},{Consts:6,JSON:15,Utils:14,window:26}],68:[function(e,t){!function(e,t){"use strict";function s(){d.call(this),this.oRequests={}}var i=t("_"),o=t("Utils"),n=t("Consts"),a=t("Globals"),r=t("Base64"),l=t("Storage:Settings"),c=t("Storage:RainLoop:Cache"),u=t("Storage:RainLoop:Data"),d=t("Storage:Abstract:Remote");i.extend(s.prototype,d.prototype),s.prototype.folders=function(e){this.defaultRequest(e,"Folders",{SentFolder:l.settingsGet("SentFolder"),DraftFolder:l.settingsGet("DraftFolder"),SpamFolder:l.settingsGet("SpamFolder"),TrashFolder:l.settingsGet("TrashFolder"),ArchiveFolder:l.settingsGet("ArchiveFolder")},null,"",["Folders"])},s.prototype.login=function(e,t,s,i,o,n,a,r){this.defaultRequest(e,"Login",{Email:t,Login:s,Password:i,Language:n||"",AdditionalCode:a||"",AdditionalCodeSignMe:r?"1":"0",SignMe:o?"1":"0"})},s.prototype.getTwoFactor=function(e){this.defaultRequest(e,"GetTwoFactorInfo")},s.prototype.createTwoFactor=function(e){this.defaultRequest(e,"CreateTwoFactorSecret")},s.prototype.clearTwoFactor=function(e){this.defaultRequest(e,"ClearTwoFactorInfo")},s.prototype.showTwoFactorSecret=function(e){this.defaultRequest(e,"ShowTwoFactorSecret")},s.prototype.testTwoFactor=function(e,t){this.defaultRequest(e,"TestTwoFactorInfo",{Code:t})},s.prototype.enableTwoFactor=function(e,t){this.defaultRequest(e,"EnableTwoFactor",{Enable:t?"1":"0"})},s.prototype.clearTwoFactorInfo=function(e){this.defaultRequest(e,"ClearTwoFactorInfo")
-},s.prototype.contactsSync=function(e){this.defaultRequest(e,"ContactsSync",null,n.Defaults.ContactsSyncAjaxTimeout)},s.prototype.saveContactsSyncData=function(e,t,s,i,o){this.defaultRequest(e,"SaveContactsSyncData",{Enable:t?"1":"0",Url:s,User:i,Password:o})},s.prototype.accountAdd=function(e,t,s,i){this.defaultRequest(e,"AccountAdd",{Email:t,Login:s,Password:i})},s.prototype.accountDelete=function(e,t){this.defaultRequest(e,"AccountDelete",{EmailToDelete:t})},s.prototype.identityUpdate=function(e,t,s,i,o,n){this.defaultRequest(e,"IdentityUpdate",{Id:t,Email:s,Name:i,ReplyTo:o,Bcc:n})},s.prototype.identityDelete=function(e,t){this.defaultRequest(e,"IdentityDelete",{IdToDelete:t})},s.prototype.accountsAndIdentities=function(e){this.defaultRequest(e,"AccountsAndIdentities")},s.prototype.messageList=function(e,t,s,i,a,l){t=o.pString(t);var d=c.getFolderHash(t);l=o.isUnd(l)?!1:!!l,s=o.isUnd(s)?0:o.pInt(s),i=o.isUnd(s)?20:o.pInt(i),a=o.pString(a),""===d||""!==a&&-1!==a.indexOf("is:")?this.defaultRequest(e,"MessageList",{Folder:t,Offset:s,Limit:i,Search:a,UidNext:"INBOX"===t?c.getFolderUidNext(t):"",UseThreads:u.threading()&&u.useThreads()?"1":"0",ExpandedThreadUid:u.threading()&&t===u.messageListThreadFolder()?u.messageListThreadUids().join(","):""},""===a?n.Defaults.DefaultAjaxTimeout:n.Defaults.SearchAjaxTimeout,"",l?[]:["MessageList"]):this.defaultRequest(e,"MessageList",{},""===a?n.Defaults.DefaultAjaxTimeout:n.Defaults.SearchAjaxTimeout,"MessageList/"+r.urlsafe_encode([t,s,i,a,u.projectHash(),d,"INBOX"===t?c.getFolderUidNext(t):"",u.threading()&&u.useThreads()?"1":"0",u.threading()&&t===u.messageListThreadFolder()?u.messageListThreadUids().join(","):""].join(String.fromCharCode(0))),l?[]:["MessageList"])},s.prototype.messageUploadAttachments=function(e,t){this.defaultRequest(e,"MessageUploadAttachments",{Attachments:t},999e3)},s.prototype.message=function(e,t,s){return t=o.pString(t),s=o.pInt(s),c.getFolderFromCacheList(t)&&s>0?(this.defaultRequest(e,"Message",{},null,"Message/"+r.urlsafe_encode([t,s,u.projectHash(),u.threading()&&u.useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},s.prototype.composeUploadExternals=function(e,t){this.defaultRequest(e,"ComposeUploadExternals",{Externals:t},999e3)},s.prototype.composeUploadDrive=function(e,t,s){this.defaultRequest(e,"ComposeUploadDrive",{AccessToken:s,Url:t},999e3)},s.prototype.folderInformation=function(e,t,s){var n=!0,r=[];o.isArray(s)&&0-1&&r.eq(o).removeClass("focused"),38===a&&o>0?o--:40===a&&oi)?(this.oContentScrollable.scrollTop(s.top<0?this.oContentScrollable.scrollTop()+s.top-e:this.oContentScrollable.scrollTop()+s.top-i+o+e),!0):!1},s.prototype.messagesDrop=function(e,s){if(e&&s&&s.helper){var i=s.helper.data("rl-folder"),o=u.$html.hasClass("rl-ctrl-key-pressed"),n=s.helper.data("rl-uids");l.isNormal(i)&&""!==i&&l.isArray(n)&&t("App:RainLoop").moveMessagesToFolder(i,n,e.fullNameRaw,o)}},s.prototype.composeClick=function(){m.showScreenPopup(t("View:Popup:Compose"))},s.prototype.createFolder=function(){m.showScreenPopup(t("View:Popup:FolderCreate"))},s.prototype.configureFolders=function(){m.setHash(d.settings("folders"))},s.prototype.contactsClick=function(){this.allowContacts&&m.showScreenPopup(t("View:Popup:Contacts"))},e.exports=s}(t,e)},{$:20,"App:Knoin":27,"App:RainLoop":3,Enums:7,Globals:9,"Knoin:AbstractViewModel":30,LinkBuilder:11,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:Settings":69,Utils:14,"View:Popup:Compose":82,"View:Popup:Contacts":83,"View:Popup:FolderCreate":86,_:25,key:21,ko:22,window:26}],74:[function(e,t){!function(e,t){"use strict";function s(){w.call(this,"Right","MailMessageList"),this.sLastUid=null,this.bPrefetch=!1,this.emptySubjectValue="",this.hideDangerousActions=!!f.settingsGet("HideDangerousActions"),this.popupVisibility=d.popupVisibility,this.message=y.message,this.messageList=y.messageList,this.folderList=y.folderList,this.currentMessage=y.currentMessage,this.isMessageSelected=y.isMessageSelected,this.messageListSearch=y.messageListSearch,this.messageListError=y.messageListError,this.folderMenuForMove=y.folderMenuForMove,this.useCheckboxesInList=y.useCheckboxesInList,this.mainMessageListSearch=y.mainMessageListSearch,this.messageListEndFolder=y.messageListEndFolder,this.messageListChecked=y.messageListChecked,this.messageListCheckedOrSelected=y.messageListCheckedOrSelected,this.messageListCheckedOrSelectedUidsWithSubMails=y.messageListCheckedOrSelectedUidsWithSubMails,this.messageListCompleteLoadingThrottle=y.messageListCompleteLoadingThrottle,p.initOnStartOrLangChange(function(){this.emptySubjectValue=p.i18n("MESSAGE_LIST/EMPTY_SUBJECT_TEXT")},this),this.userQuota=y.userQuota,this.userUsageSize=y.userUsageSize,this.userUsageProc=y.userUsageProc,this.moveDropdownTrigger=n.observable(!1),this.moreDropdownTrigger=n.observable(!1),this.dragOver=n.observable(!1).extend({throttle:1}),this.dragOverEnter=n.observable(!1).extend({throttle:1}),this.dragOverArea=n.observable(null),this.dragOverBodyArea=n.observable(null),this.messageListItemTemplate=n.computed(function(){return c.Layout.NoPreview!==y.layout()?"MailMessageListItem":"MailMessageListItemNoPreviewPane"}),this.messageListSearchDesc=n.computed(function(){var e=y.messageListEndSearch();return""===e?"":p.i18n("MESSAGE_LIST/SEARCH_RESULT_FOR",{SEARCH:e})}),this.messageListPagenator=n.computed(p.computedPagenatorHelper(y.messageListPage,y.messageListPageCount)),this.checkAll=n.computed({read:function(){return 00&&t>0&&e>t},this),this.hasMessages=n.computed(function(){return 01?" ("+(100>e?e:"99+")+")":""},s.prototype.cancelSearch=function(){this.mainMessageListSearch(""),this.inputMessageListSearchFocus(!1)},s.prototype.moveSelectedMessagesToFolder=function(e,s){return this.canBeMoved()&&t("App:RainLoop").moveMessagesToFolder(y.currentFolderFullNameRaw(),y.messageListCheckedOrSelectedUidsWithSubMails(),e,s),!1},s.prototype.dragAndDronHelper=function(e){e&&e.checked(!0);var t=p.draggeblePlace(),s=y.messageListCheckedOrSelectedUidsWithSubMails();return t.data("rl-folder",y.currentFolderFullNameRaw()),t.data("rl-uids",s),t.find(".text").text(""+s.length),i.defer(function(){var e=y.messageListCheckedOrSelectedUidsWithSubMails();t.data("rl-uids",e),t.find(".text").text(""+e.length)}),t},s.prototype.onMessageResponse=function(e,t,s){y.hideMessageBodies(),y.messageLoading(!1),c.StorageResultType.Success===e&&t&&t.Result?y.setMessage(t,s):c.StorageResultType.Unload===e?(y.message(null),y.messageError("")):c.StorageResultType.Abort!==e&&(y.message(null),y.messageError(p.getNotification(t&&t.ErrorCode?t.ErrorCode:c.Notification.UnknownError)))},s.prototype.populateMessageBody=function(e){e&&(S.message(this.onMessageResponse,e.folderFullNameRaw,e.uid)?y.messageLoading(!0):p.log("Error: Unknown message request: "+e.folderFullNameRaw+" ~ "+e.uid+" [e-101]"))},s.prototype.setAction=function(e,s,o){var n=[],a=null,r=0;if(p.isUnd(o)&&(o=y.messageListChecked()),n=i.map(o,function(e){return e.uid}),""!==e&&00?100>e?e:"99+":""},s.prototype.verifyPgpSignedClearMessage=function(e){e&&e.verifyPgpSignedClearMessage()},s.prototype.decryptPgpEncryptedMessage=function(e){e&&e.decryptPgpEncryptedMessage(this.viewPgpPassword())},s.prototype.readReceipt=function(e){e&&""!==e.readReceipt()&&(g.sendReadReceiptMessage(u.emptyFunction,e.folderFullNameRaw,e.uid,e.readReceipt(),u.i18n("READ_RECEIPT/SUBJECT",{SUBJECT:e.subject()}),u.i18n("READ_RECEIPT/BODY",{"READ-RECEIPT":h.accountEmail()})),e.isReadReceipt(!0),p.storeMessageFlagsToCache(e),t("App:RainLoop").reloadFlagsCurrentMessageListAndMessageFromCache())},e.exports=s}(t,e)},{$:20,"App:Knoin":27,"App:RainLoop":3,Consts:6,Enums:7,Events:8,Globals:9,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,Utils:14,"View:Popup:Compose":82,_:25,key:21,ko:22}],76:[function(e,t){!function(e,t){"use strict";function s(){n.call(this),o.constructorEnd(this)}var i=t("_"),o=t("App:Knoin"),n=t("View:RainLoop:AbstractSystemDropDown");o.extendAsViewModel(["View:RainLoop:MailBoxSystemDropDown","MailBoxSystemDropDownViewModel"],s),i.extend(s.prototype,n.prototype),e.exports=s}(t,e)},{"App:Knoin":27,"View:RainLoop:AbstractSystemDropDown":71,_:25}],77:[function(e,t){!function(e,t){"use strict";function s(){c.call(this,"Popups","PopupsAddAccount"),this.email=o.observable(""),this.password=o.observable(""),this.emailError=o.observable(!1),this.passwordError=o.observable(!1),this.email.subscribe(function(){this.emailError(!1)},this),this.password.subscribe(function(){this.passwordError(!1)},this),this.submitRequest=o.observable(!1),this.submitError=o.observable(""),this.emailFocus=o.observable(!1),this.addAccountCommand=a.createCommand(this,function(){return this.emailError(""===a.trim(this.email())),this.passwordError(""===a.trim(this.password())),this.emailError()||this.passwordError()?!1:(this.submitRequest(!0),r.accountAdd(i.bind(function(e,s){this.submitRequest(!1),n.StorageResultType.Success===e&&s&&"AccountAdd"===s.Action?s.Result?(t("App:RainLoop").accountsAndIdentities(),this.cancelCommand()):s.ErrorCode&&this.submitError(a.getNotification(s.ErrorCode)):this.submitError(a.getNotification(n.Notification.UnknownError))},this),this.email(),"",this.password()),!0)},function(){return!this.submitRequest()}),l.constructorEnd(this)}var i=t("_"),o=t("ko"),n=t("Enums"),a=t("Utils"),r=t("Storage:RainLoop:Remote"),l=t("App:Knoin"),c=t("Knoin:AbstractViewModel");l.extendAsViewModel(["View:Popup:AddAccount","PopupsAddAccountViewModel"],s),i.extend(s.prototype,c.prototype),s.prototype.clearPopup=function(){this.email(""),this.password(""),this.emailError(!1),this.passwordError(!1),this.submitRequest(!1),this.submitError("")},s.prototype.onShow=function(){this.clearPopup()},s.prototype.onFocus=function(){this.emailFocus(!0)},e.exports=s}(t,e)},{"App:Knoin":27,"App:RainLoop":3,Enums:7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Remote":68,Utils:14,_:25,ko:22}],78:[function(e,t){!function(e,t){"use strict";function s(){l.call(this,"Popups","PopupsAddOpenPgpKey"),this.key=o.observable(""),this.key.error=o.observable(!1),this.key.focus=o.observable(!1),this.key.subscribe(function(){this.key.error(!1)},this),this.addOpenPgpKeyCommand=n.createCommand(this,function(){var e=30,s=null,i=n.trim(this.key()),o=/[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi,r=a.openpgpKeyring;if(i=i.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g,"\n$1!-!N!-!$2").replace(/[\n\r]+/g,"\n").replace(/!-!N!-!/g,"\n\n"),this.key.error(""===i),!r||this.key.error())return!1;for(;;){if(s=o.exec(i),!s||0>e)break;s[0]&&s[1]&&s[2]&&s[1]===s[2]&&("PRIVATE"===s[1]?r.privateKeys.importKey(s[0]):"PUBLIC"===s[1]&&r.publicKeys.importKey(s[0])),e--}return r.store(),t("App:RainLoop").reloadOpenPgpKeys(),n.delegateRun(this,"cancelCommand"),!0}),r.constructorEnd(this)}var i=t("_"),o=t("ko"),n=t("Utils"),a=t("Storage:RainLoop:Data"),r=t("App:Knoin"),l=t("Knoin:AbstractViewModel");r.extendAsViewModel(["View:Popup:AddOpenPgpKey","PopupsAddOpenPgpKeyViewModel"],s),i.extend(s.prototype,l.prototype),s.prototype.clearPopup=function(){this.key(""),this.key.error(!1)},s.prototype.onShow=function(){this.clearPopup()},s.prototype.onFocus=function(){this.key.focus(!0)},e.exports=s}(t,e)},{"App:Knoin":27,"App:RainLoop":3,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,Utils:14,_:25,ko:22}],79:[function(e,t){!function(e,t){"use strict";function s(){c.call(this,"Popups","PopupsAdvancedSearch"),this.fromFocus=o.observable(!1),this.from=o.observable(""),this.to=o.observable(""),this.subject=o.observable(""),this.text=o.observable(""),this.selectedDateValue=o.observable(-1),this.hasAttachment=o.observable(!1),this.starred=o.observable(!1),this.unseen=o.observable(!1),this.searchCommand=a.createCommand(this,function(){var e=this.buildSearchString();""!==e&&r.mainMessageListSearch(e),this.cancelCommand()}),l.constructorEnd(this)}var i=t("_"),o=t("ko"),n=t("moment"),a=t("Utils"),r=t("Storage:RainLoop:Data"),l=t("App:Knoin"),c=t("Knoin:AbstractViewModel");l.extendAsViewModel(["View:Popup:AdvancedSearch","PopupsAdvancedSearchViewModel"],s),i.extend(s.prototype,c.prototype),s.prototype.buildSearchStringValue=function(e){return-1"},s.prototype.sendMessageResponse=function(e,t){var s=!1,o="";this.sending(!1),u.StorageResultType.Success===e&&t&&t.Result&&(s=!0,this.modalVisibility()&&p.delegateRun(this,"closeCommand")),this.modalVisibility()&&!s&&(t&&u.Notification.CantSaveMessage===t.ErrorCode?(this.sendSuccessButSaveError(!0),i.alert(p.trim(p.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(o=p.getNotification(t&&t.ErrorCode?t.ErrorCode:u.Notification.CantSendMessage,t&&t.ErrorMessage?t.ErrorMessage:""),this.sendError(!0),i.alert(o||p.getNotification(u.Notification.CantSendMessage)))),this.reloadDraftFolder()},s.prototype.saveMessageResponse=function(e,t){var s=!1,o=null;this.saving(!1),u.StorageResultType.Success===e&&t&&t.Result&&t.Result.NewFolder&&t.Result.NewUid&&(this.bFromDraft&&(o=y.message(),o&&this.draftFolder()===o.folderFullNameRaw&&this.draftUid()===o.uid&&y.message(null)),this.draftFolder(t.Result.NewFolder),this.draftUid(t.Result.NewUid),this.modalVisibility()&&(this.savedTime(i.Math.round((new i.Date).getTime()/1e3)),this.savedOrSendingText(0"+e;break;default:e=e+"
"+s}return e},s.prototype.editor=function(e){if(e){var t=this;!this.oEditor&&this.composeEditorArea()?o.delay(function(){t.oEditor=new f(t.composeEditorArea(),null,function(){e(t.oEditor)},function(e){t.isHtml(!!e)})},300):this.oEditor&&e(this.oEditor)}},s.prototype.onShow=function(e,t,s,i,a){C.routeOff();var r=this,l="",c="",d="",h="",g="",m=null,f="",b="",S=[],w={},A=y.accountEmail(),F=y.signature(),T=y.signatureToAll(),R=[],L=null,E=null,N=e||u.ComposeType.Empty,P=function(e,t){for(var s=0,i=e.length,o=[];i>s;s++)o.push(e[s].toLine(!!t));return o.join(", ")};if(t=t||null,t&&p.isNormal(t)&&(E=p.isArray(t)&&1===t.length?t[0]:p.isArray(t)?null:t),null!==A&&(w[A]=!0),this.currentIdentityID(this.findIdentityIdByMessage(N,E)),this.reset(),p.isNonEmptyArray(s)&&this.to(P(s)),""!==N&&E){switch(h=E.fullFormatDateValue(),g=E.subject(),L=E.aDraftInfo,m=n(E.body).clone(),m&&(m.find("blockquote.rl-bq-switcher").each(function(){n(this).removeClass("rl-bq-switcher hidden-bq")}),m.find(".rlBlockquoteSwitcher").each(function(){n(this).remove()})),m.find("[data-html-editor-font-wrapper]").removeAttr("data-html-editor-font-wrapper"),f=m.html(),N){case u.ComposeType.Empty:break;case u.ComposeType.Reply:this.to(P(E.replyEmails(w))),this.subject(p.replySubjectAdd("Re",g)),this.prepearMessageAttachments(E,N),this.aDraftInfo=["reply",E.uid,E.folderFullNameRaw],this.sInReplyTo=E.sMessageId,this.sReferences=p.trim(this.sInReplyTo+" "+E.sReferences);break;case u.ComposeType.ReplyAll:S=E.replyAllEmails(w),this.to(P(S[0])),this.cc(P(S[1])),this.subject(p.replySubjectAdd("Re",g)),this.prepearMessageAttachments(E,N),this.aDraftInfo=["reply",E.uid,E.folderFullNameRaw],this.sInReplyTo=E.sMessageId,this.sReferences=p.trim(this.sInReplyTo+" "+E.references());break;case u.ComposeType.Forward:this.subject(p.replySubjectAdd("Fwd",g)),this.prepearMessageAttachments(E,N),this.aDraftInfo=["forward",E.uid,E.folderFullNameRaw],this.sInReplyTo=E.sMessageId,this.sReferences=p.trim(this.sInReplyTo+" "+E.sReferences);break;case u.ComposeType.ForwardAsAttachment:this.subject(p.replySubjectAdd("Fwd",g)),this.prepearMessageAttachments(E,N),this.aDraftInfo=["forward",E.uid,E.folderFullNameRaw],this.sInReplyTo=E.sMessageId,this.sReferences=p.trim(this.sInReplyTo+" "+E.sReferences);break;case u.ComposeType.Draft:this.to(P(E.to)),this.cc(P(E.cc)),this.bcc(P(E.bcc)),this.bFromDraft=!0,this.draftFolder(E.folderFullNameRaw),this.draftUid(E.uid),this.subject(g),this.prepearMessageAttachments(E,N),this.aDraftInfo=p.isNonEmptyArray(L)&&3===L.length?L:null,this.sInReplyTo=E.sInReplyTo,this.sReferences=E.sReferences;break;case u.ComposeType.EditAsNew:this.to(P(E.to)),this.cc(P(E.cc)),this.bcc(P(E.bcc)),this.subject(g),this.prepearMessageAttachments(E,N),this.aDraftInfo=p.isNonEmptyArray(L)&&3===L.length?L:null,this.sInReplyTo=E.sInReplyTo,this.sReferences=E.sReferences}switch(N){case u.ComposeType.Reply:case u.ComposeType.ReplyAll:l=E.fromToLine(!1,!0),b=p.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:h,EMAIL:l}),f="

"+b+":

"+f+"

";break;case u.ComposeType.Forward:l=E.fromToLine(!1,!0),c=E.toToLine(!1,!0),d=E.ccToLine(!1,!0),f="


"+p.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+p.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+l+"
"+p.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+c+(0"+p.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+d:"")+"
"+p.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+p.encodeHtml(h)+"
"+p.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+p.encodeHtml(g)+"

"+f;break;case u.ComposeType.ForwardAsAttachment:f=""}T&&""!==F&&u.ComposeType.EditAsNew!==N&&u.ComposeType.Draft!==N&&(f=this.convertSignature(F,P(E.from,!0),f,N)),this.editor(function(e){e.setHtml(f,!1),E.isHtml()||e.modeToggle(!1)})}else u.ComposeType.Empty===N?(this.subject(p.isNormal(i)?""+i:""),f=p.isNormal(a)?""+a:"",T&&""!==F&&(f=this.convertSignature(F,"",p.convertPlainTextToHtml(f),N)),this.editor(function(e){e.setHtml(f,!1),u.EditorDefaultType.Html!==y.editorDefaultType()&&e.modeToggle(!1)})):p.isNonEmptyArray(t)&&o.each(t,function(e){r.addMessageAsAttachment(e)});R=this.getAttachmentsDownloadsForUpload(),p.isNonEmptyArray(R)&&v.messageUploadAttachments(function(e,t){if(u.StorageResultType.Success===e&&t&&t.Result){var s=null,i="";if(!r.viewModelVisibility())for(i in t.Result)t.Result.hasOwnProperty(i)&&(s=r.getAttachmentById(t.Result[i]),s&&s.tempName(i))}else r.setMessageAttachmentFailedDowbloadText()},R),this.triggerForResize()},s.prototype.onFocus=function(){""===this.to()?this.to.focusTrigger(!this.to.focusTrigger()):this.oEditor&&this.oEditor.focus(),this.triggerForResize()},s.prototype.editorResize=function(){this.oEditor&&this.oEditor.resize()},s.prototype.tryToClosePopup=function(){var e=this,s=t("View:Popup:Ask");C.isPopupVisible(s)||C.showScreenPopup(s,[p.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){e.modalVisibility()&&p.delegateRun(e,"closeCommand")}])},s.prototype.onBuild=function(){this.initUploader();var e=this,t=null;key("ctrl+q, command+q",u.KeyState.Compose,function(){return e.identitiesDropdownTrigger(!0),!1}),key("ctrl+s, command+s",u.KeyState.Compose,function(){return e.saveCommand(),!1}),key("ctrl+enter, command+enter",u.KeyState.Compose,function(){return e.sendCommand(),!1}),key("esc",u.KeyState.Compose,function(){return e.modalVisibility()&&e.tryToClosePopup(),!1}),h.$win.on("resize",function(){e.triggerForResize()}),this.dropboxEnabled()&&(t=i.document.createElement("script"),t.type="text/javascript",t.src="https://www.dropbox.com/static/api/1/dropins.js",n(t).attr("id","dropboxjs").attr("data-app-key",b.settingsGet("DropboxApiKey")),i.document.body.appendChild(t)),this.driveEnabled()&&n.getScript("https://apis.google.com/js/api.js",function(){i.gapi&&e.driveVisible(!0)})},s.prototype.driveCallback=function(e,t){if(t&&i.XMLHttpRequest&&i.google&&t[i.google.picker.Response.ACTION]===i.google.picker.Action.PICKED&&t[i.google.picker.Response.DOCUMENTS]&&t[i.google.picker.Response.DOCUMENTS][0]&&t[i.google.picker.Response.DOCUMENTS][0].id){var s=this,o=new i.XMLHttpRequest;o.open("GET","https://www.googleapis.com/drive/v2/files/"+t[i.google.picker.Response.DOCUMENTS][0].id),o.setRequestHeader("Authorization","Bearer "+e),o.addEventListener("load",function(){if(o&&o.responseText){var t=l.parse(o.responseText),i=function(e,t,s){e&&e.exportLinks&&(e.exportLinks[t]?(e.downloadUrl=e.exportLinks[t],e.title=e.title+"."+s,e.mimeType=t):e.exportLinks["application/pdf"]&&(e.downloadUrl=e.exportLinks["application/pdf"],e.title=e.title+".pdf",e.mimeType="application/pdf"))};if(t&&!t.downloadUrl&&t.mimeType&&t.exportLinks)switch(t.mimeType.toString().toLowerCase()){case"application/vnd.google-apps.document":i(t,"application/vnd.openxmlformats-officedocument.wordprocessingml.document","docx");break;case"application/vnd.google-apps.spreadsheet":i(t,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","xlsx");break;case"application/vnd.google-apps.drawing":i(t,"image/png","png");break;case"application/vnd.google-apps.presentation":i(t,"application/vnd.openxmlformats-officedocument.presentationml.presentation","pptx");break;default:i(t,"application/pdf","pdf")}t&&t.downloadUrl&&s.addDriveAttachment(t,e)}}),o.send()}},s.prototype.driveCreatePiker=function(e){if(i.gapi&&e&&e.access_token){var t=this;i.gapi.load("picker",{callback:function(){if(i.google&&i.google.picker){var s=(new i.google.picker.PickerBuilder).addView((new i.google.picker.DocsView).setIncludeFolders(!0)).setAppId(b.settingsGet("GoogleClientID")).setOAuthToken(e.access_token).setCallback(o.bind(t.driveCallback,t,e.access_token)).enableFeature(i.google.picker.Feature.NAV_HIDDEN).build();s.setVisible(!0)}}})}},s.prototype.driveOpenPopup=function(){if(i.gapi){var e=this;i.gapi.load("auth",{callback:function(){var t=i.gapi.auth.getToken();t?e.driveCreatePiker(t):i.gapi.auth.authorize({client_id:b.settingsGet("GoogleClientID"),scope:"https://www.googleapis.com/auth/drive.readonly",immediate:!0},function(t){if(t&&!t.error){var s=i.gapi.auth.getToken();s&&e.driveCreatePiker(s)}else i.gapi.auth.authorize({client_id:b.settingsGet("GoogleClientID"),scope:"https://www.googleapis.com/auth/drive.readonly",immediate:!1},function(t){if(t&&!t.error){var s=i.gapi.auth.getToken();s&&e.driveCreatePiker(s)}})})}})}},s.prototype.getAttachmentById=function(e){for(var t=this.attachments(),s=0,i=t.length;i>s;s++)if(t[s]&&e===t[s].id)return t[s];return null},s.prototype.initUploader=function(){if(this.composeUploaderButton()){var e={},t=p.pInt(b.settingsGet("AttachmentLimit")),s=new c({action:m.upload(),name:"uploader",queueSize:2,multipleSizeLimit:50,disableFolderDragAndDrop:!1,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace()});s?(s.on("onDragEnter",o.bind(function(){this.dragAndDropOver(!0)},this)).on("onDragLeave",o.bind(function(){this.dragAndDropOver(!1)},this)).on("onBodyDragEnter",o.bind(function(){this.dragAndDropVisible(!0)},this)).on("onBodyDragLeave",o.bind(function(){this.dragAndDropVisible(!1)},this)).on("onProgress",o.bind(function(t,s,o){var n=null;p.isUnd(e[t])?(n=this.getAttachmentById(t),n&&(e[t]=n)):n=e[t],n&&n.progress(" - "+i.Math.floor(s/o*100)+"%")},this)).on("onSelect",o.bind(function(e,i){this.dragAndDropOver(!1);var o=this,n=p.isUnd(i.FileName)?"":i.FileName.toString(),a=p.isNormal(i.Size)?p.pInt(i.Size):null,r=new w(e,n,a);return r.cancel=function(e){return function(){o.attachments.remove(function(t){return t&&t.id===e}),s&&s.cancel(e)}}(e),this.attachments.push(r),a>0&&t>0&&a>t?(r.error(p.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",o.bind(function(t){var s=null;p.isUnd(e[t])?(s=this.getAttachmentById(t),s&&(e[t]=s)):s=e[t],s&&(s.waiting(!1),s.uploading(!0))},this)).on("onComplete",o.bind(function(t,s,i){var o="",n=null,a=null,r=this.getAttachmentById(t);a=s&&i&&i.Result&&i.Result.Attachment?i.Result.Attachment:null,n=i&&i.Result&&i.Result.ErrorCode?i.Result.ErrorCode:null,null!==n?o=p.getUploadErrorDescByCode(n):a||(o=p.i18n("UPLOAD/ERROR_UNKNOWN")),r&&(""!==o&&00&&o>0&&n>o?(s.uploading(!1),s.error(p.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(v.composeUploadExternals(function(e,t){var i=!1;s.uploading(!1),u.StorageResultType.Success===e&&t&&t.Result&&t.Result[s.id]&&(i=!0,s.tempName(t.Result[s.id])),i||s.error(p.getUploadErrorDescByCode(u.UploadErrorCode.FileNoUploaded))},[e.link]),!0)},s.prototype.addDriveAttachment=function(e,t){var s=this,i=function(e){return function(){s.attachments.remove(function(t){return t&&t.id===e})}},o=p.pInt(b.settingsGet("AttachmentLimit")),n=null,a=e.fileSize?p.pInt(e.fileSize):0;return n=new w(e.downloadUrl,e.title,a),n.fromMessage=!1,n.cancel=i(e.downloadUrl),n.waiting(!1).uploading(!0),this.attachments.push(n),a>0&&o>0&&a>o?(n.uploading(!1),n.error(p.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(v.composeUploadDrive(function(e,t){var s=!1;n.uploading(!1),u.StorageResultType.Success===e&&t&&t.Result&&t.Result[n.id]&&(s=!0,n.tempName(t.Result[n.id][0]),n.size(p.pInt(t.Result[n.id][1]))),s||n.error(p.getUploadErrorDescByCode(u.UploadErrorCode.FileNoUploaded))},e.downloadUrl,t),!0)},s.prototype.prepearMessageAttachments=function(e,t){if(e){var s=this,i=p.isNonEmptyArray(e.attachments())?e.attachments():[],o=0,n=i.length,a=null,r=null,l=!1,c=function(e){return function(){s.attachments.remove(function(t){return t&&t.id===e})}};if(u.ComposeType.ForwardAsAttachment===t)this.addMessageAsAttachment(e);else for(;n>o;o++){switch(r=i[o],l=!1,t){case u.ComposeType.Reply:case u.ComposeType.ReplyAll:l=r.isLinked;break;case u.ComposeType.Forward:case u.ComposeType.Draft:case u.ComposeType.EditAsNew:l=!0}l&&(a=new w(r.download,r.fileName,r.estimatedSize,r.isInline,r.isLinked,r.cid,r.contentLocation),a.fromMessage=!0,a.cancel=c(r.download),a.waiting(!1).uploading(!0),this.attachments.push(a))}}},s.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(e){return e&&e.isLinked})},s.prototype.setMessageAttachmentFailedDowbloadText=function(){o.each(this.attachments(),function(e){e&&e.fromMessage&&e.waiting(!1).uploading(!1).error(p.getUploadErrorDescByCode(u.UploadErrorCode.FileNoUploaded))},this)},s.prototype.isEmptyForm=function(e){e=p.isUnd(e)?!0:!!e;var t=e?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&&t&&(!this.oEditor||""===this.oEditor.getData())},s.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.attachmentsInProcessError(!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)},s.prototype.getAttachmentsDownloadsForUpload=function(){return o.map(o.filter(this.attachments(),function(e){return e&&""===e.tempName()}),function(e){return e.id})},s.prototype.triggerForResize=function(){this.resizer(!this.resizer()),this.editorResizeThrottle()},e.exports=s}(t,e)},{$:20,"App:Knoin":27,"App:RainLoop":3,Consts:6,Enums:7,Events:8,Globals:9,HtmlEditor:10,JSON:15,Jua:16,"Knoin:AbstractViewModel":30,LinkBuilder:11,"Model:ComposeAttachment":33,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,"Storage:Settings":69,Utils:14,"View:Popup:Ask":80,"View:Popup:ComposeOpenPgp":81,"View:Popup:FolderSystem":87,_:25,ko:22,moment:23,window:26}],83:[function(e,t){!function(e,t){"use strict";function s(){w.call(this,"Popups","PopupsContacts");var e=this,s=function(t){t&&0=e?1:e},this),this.contactsPagenator=a.computed(d.computedPagenatorHelper(this.contactsPage,this.contactsPageCount)),this.emptySelection=a.observable(!0),this.viewClearSearch=a.observable(!1),this.viewID=a.observable(""),this.viewReadOnly=a.observable(!1),this.viewProperties=a.observableArray([]),this.viewTags=a.observable(""),this.viewTags.visibility=a.observable(!1),this.viewTags.focusTrigger=a.observable(!1),this.viewTags.focusTrigger.subscribe(function(e){e||""!==this.viewTags()?e&&this.viewTags.visibility(!0):this.viewTags.visibility(!1)},this),this.viewSaveTrigger=a.observable(l.SaveSettingsStep.Idle),this.viewPropertiesNames=this.viewProperties.filter(function(e){return-1=i&&(this.bDropPageAfterDelete=!0),o.delay(function(){o.each(n,function(e){t.remove(e)})},500))},s.prototype.deleteSelectedContacts=function(){00?i:0),d.isNonEmptyArray(s.Result.Tags)&&(a=o.map(s.Result.Tags,function(e){var t=new y;return t.parse(e)?t:null}),a=o.compact(a))),t.contactsCount(i),t.contacts(n),t.contacts.loading(!1),t.contactTags(a),t.viewClearSearch(""!==t.search())},s,c.Defaults.ContactsPerPage,this.search())},s.prototype.onBuild=function(e){this.oContentVisible=n(".b-list-content",e),this.oContentScrollable=n(".content",this.oContentVisible),this.selector.init(this.oContentVisible,this.oContentScrollable,l.KeyState.ContactList);var t=this;r("delete",l.KeyState.ContactList,function(){return t.deleteCommand(),!1}),e.on("click",".e-pagenator .e-page",function(){var e=a.dataFor(this);e&&(t.contactsPage(d.pInt(e.value)),t.reloadContactList())}),this.initUploader()},s.prototype.onShow=function(){v.routeOff(),this.reloadContactList(!0)},s.prototype.onHide=function(){v.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),this.contactsCount(0),this.contacts([])},e.exports=s}(t,e)},{$:20,"App:Knoin":27,"App:RainLoop":3,Consts:6,Enums:7,Globals:9,"Knoin:AbstractViewModel":30,LinkBuilder:11,"Model:Contact":34,"Model:ContactProperty":35,"Model:ContactTag":36,"Model:Email":37,Selector:13,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,Utils:14,"View:Popup:Compose":82,"View:Popup:Contacts":83,_:25,key:21,ko:22,window:26}],84:[function(e,t){!function(e,t){"use strict";function s(){c.call(this,"Popups","PopupsFilter"),this.filter=o.observable(null),this.selectedFolderValue=o.observable(n.Values.UnuseOptionValue),this.folderSelectList=r.folderMenuForMove,this.defautOptionsAfterRender=a.defautOptionsAfterRender,l.constructorEnd(this)}var i=t("_"),o=t("ko"),n=t("Consts"),a=t("Utils"),r=t("Storage:RainLoop:Data"),l=t("App:Knoin"),c=t("Knoin:AbstractViewModel");l.extendAsViewModel(["View:Popup:Filter","PopupsFilterViewModel"],s),i.extend(s.prototype,c.prototype),s.prototype.clearPopup=function(){},s.prototype.onShow=function(e){this.clearPopup(),this.filter(e)},e.exports=s}(t,e)},{"App:Knoin":27,Consts:6,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,Utils:14,_:25,ko:22}],85:[function(e,t){!function(e,t){"use strict";function s(){d.call(this,"Popups","PopupsFolderClear"),this.selectedFolder=o.observable(null),this.clearingProcess=o.observable(!1),this.clearingError=o.observable(""),this.folderFullNameForClear=o.computed(function(){var e=this.selectedFolder();return e?e.printableFullName():""},this),this.folderNameForClear=o.computed(function(){var e=this.selectedFolder();return e?e.localName():""},this),this.dangerDescHtml=o.computed(function(){return a.i18n("POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1",{FOLDER:this.folderNameForClear()})},this),this.clearCommand=a.createCommand(this,function(){var e=this,s=this.selectedFolder();s&&(r.message(null),r.messageList([]),this.clearingProcess(!0),s.messageCountAll(0),s.messageCountUnread(0),l.setFolderHash(s.fullNameRaw,""),c.folderClear(function(s,i){e.clearingProcess(!1),n.StorageResultType.Success===s&&i&&i.Result?(t("App:RainLoop").reloadMessageList(!0),e.cancelCommand()):e.clearingError(i&&i.ErrorCode?a.getNotification(i.ErrorCode):a.getNotification(n.Notification.MailServerError))},s.fullNameRaw))},function(){var e=this.selectedFolder(),t=this.clearingProcess();return!t&&null!==e}),u.constructorEnd(this)}var i=t("_"),o=t("ko"),n=t("Enums"),a=t("Utils"),r=t("Storage:RainLoop:Data"),l=t("Storage:RainLoop:Cache"),c=t("Storage:RainLoop:Remote"),u=t("App:Knoin"),d=t("Knoin:AbstractViewModel");u.extendAsViewModel(["View:Popup:FolderClear","PopupsFolderClearViewModel"],s),i.extend(s.prototype,d.prototype),s.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},s.prototype.onShow=function(e){this.clearPopup(),e&&this.selectedFolder(e)},e.exports=s}(t,e)},{"App:Knoin":27,"App:RainLoop":3,Enums:7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Cache":63,"Storage:RainLoop:Data":64,"Storage:RainLoop:Remote":68,Utils:14,_:25,ko:22}],86:[function(e,t){!function(e,t){"use strict";function s(){d.call(this,"Popups","PopupsFolderCreate"),r.initOnStartOrLangChange(function(){this.sNoParentText=r.i18n("POPUPS_CREATE_FOLDER/SELECT_NO_PARENT")},this),this.folderName=o.observable(""),this.folderName.focused=o.observable(!1),this.selectedParentValue=o.observable(a.Values.UnuseOptionValue),this.parentFolderSelectList=o.computed(function(){var e=[],t=null,s=null,i=l.folderList(),o=function(e){return e?e.isSystemFolder()?e.name()+" "+e.manageFolderSystemName():e.name():""};return e.push(["",this.sNoParentText]),""!==l.namespace&&(t=function(e){return l.namespace!==e.fullNameRaw.substr(0,l.namespace.length)}),r.folderListOptionsBuilder([],i,[],e,null,t,s,o)},this),this.createFolder=r.createCommand(this,function(){var e=this.selectedParentValue();""===e&&1 li"),o=s&&("tab"===s.shortcut||"right"===s.shortcut),n=i.index(i.filter(".active"));return!o&&n>0?n--:o&&n"),this.submitRequest(!0),o.delay(function(){n=i.openpgp.generateKeyPair({userId:s,numBits:a.pInt(e.keyBitLength()),passphrase:a.trim(e.password())}),n&&n.privateKeyArmored&&(l.privateKeys.importKey(n.privateKeyArmored),l.publicKeys.importKey(n.publicKeyArmored),l.store(),t("App:RainLoop").reloadOpenPgpKeys(),a.delegateRun(e,"cancelCommand")),e.submitRequest(!1)},100),!0)}),l.constructorEnd(this)}var i=t("window"),o=t("_"),n=t("ko"),a=t("Utils"),r=t("Storage:RainLoop:Data"),l=t("App:Knoin"),c=t("Knoin:AbstractViewModel");l.extendAsViewModel(["View:Popup:NewOpenPgpKey","PopupsNewOpenPgpKeyViewModel"],s),o.extend(s.prototype,c.prototype),s.prototype.clearPopup=function(){this.name(""),this.password(""),this.email(""),this.email.error(!1),this.keyBitLength(2048)},s.prototype.onShow=function(){this.clearPopup()},s.prototype.onFocus=function(){this.email.focus(!0)},e.exports=s}(t,e)},{"App:Knoin":27,"App:RainLoop":3,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Data":64,Utils:14,_:25,ko:22,window:26}],92:[function(e,t){!function(e,t){"use strict";function s(){c.call(this,"Popups","PopupsTwoFactorTest");var e=this;this.code=o.observable(""),this.code.focused=o.observable(!1),this.code.status=o.observable(null),this.testing=o.observable(!1),this.testCode=a.createCommand(this,function(){this.testing(!0),r.testTwoFactor(function(t,s){e.testing(!1),e.code.status(n.StorageResultType.Success===t&&s&&s.Result?!0:!1)},this.code())},function(){return""!==this.code()&&!this.testing()}),l.constructorEnd(this)}var i=t("_"),o=t("ko"),n=t("Enums"),a=t("Utils"),r=t("Storage:RainLoop:Remote"),l=t("App:Knoin"),c=t("Knoin:AbstractViewModel");l.extendAsViewModel(["View:Popup:TwoFactorTest","PopupsTwoFactorTestViewModel"],s),i.extend(s.prototype,c.prototype),s.prototype.clearPopup=function(){this.code(""),this.code.focused(!1),this.code.status(null),this.testing(!1)},s.prototype.onShow=function(){this.clearPopup()},s.prototype.onFocus=function(){this.code.focused(!0)},e.exports=s}(t,e)},{"App:Knoin":27,Enums:7,"Knoin:AbstractViewModel":30,"Storage:RainLoop:Remote":68,Utils:14,_:25,ko:22}],93:[function(e,t){!function(e,t){"use strict";function s(){r.call(this,"Popups","PopupsViewOpenPgpKey"),this.key=o.observable(""),this.keyDom=o.observable(null),a.constructorEnd(this)}var i=t("_"),o=t("ko"),n=t("Utils"),a=t("App:Knoin"),r=t("Knoin:AbstractViewModel");a.extendAsViewModel(["View:Popup:ViewOpenPgpKey","PopupsViewOpenPgpKeyViewModel"],s),i.extend(s.prototype,r.prototype),s.prototype.clearPopup=function(){this.key("")},s.prototype.selectKey=function(){var e=this.keyDom();e&&n.selectElement(e)},s.prototype.onShow=function(e){this.clearPopup(),e&&this.key(e.armor)},e.exports=s}(t,e)},{"App:Knoin":27,"Knoin:AbstractViewModel":30,Utils:14,_:25,ko:22}],94:[function(e,t){!function(e,t){"use strict";function s(e){r.call(this,"Left","SettingsMenu"),this.leftPanelDisabled=o.leftPanelDisabled,this.menu=e.menu,a.constructorEnd(this)}var i=t("_"),o=t("Globals"),n=t("LinkBuilder"),a=t("App:Knoin"),r=t("Knoin:AbstractViewModel");a.extendAsViewModel(["View:RainLoop:SettingsMenu","SettingsMenuViewModel"],s),i.extend(s.prototype,r.prototype),s.prototype.link=function(e){return n.settings(e)},s.prototype.backToMailBoxClick=function(){a.setHash(n.inbox())},e.exports=s}(t,e)},{"App:Knoin":27,Globals:9,"Knoin:AbstractViewModel":30,LinkBuilder:11,_:25}],95:[function(e,t){!function(e,t){"use strict";function s(){c.call(this,"Right","SettingsPane"),l.constructorEnd(this)}var i=t("_"),o=t("key"),n=t("Enums"),a=t("LinkBuilder"),r=t("Storage:RainLoop:Data"),l=t("App:Knoin"),c=t("Knoin:AbstractViewModel");l.extendAsViewModel(["View:RainLoop:SettingsPane","SettingsPaneViewModel"],s),i.extend(s.prototype,c.prototype),s.prototype.onBuild=function(){var e=this;o("esc",n.KeyState.Settings,function(){e.backToMailBoxClick()})},s.prototype.onShow=function(){r.message(null)},s.prototype.backToMailBoxClick=function(){l.setHash(a.inbox())},e.exports=s}(t,e)},{"App:Knoin":27,Enums:7,"Knoin:AbstractViewModel":30,LinkBuilder:11,"Storage:RainLoop:Data":64,_:25,key:21}],96:[function(e,t){!function(e,t){"use strict";function s(){n.call(this),o.constructorEnd(this)}var i=t("_"),o=t("App:Knoin"),n=t("View:RainLoop:AbstractSystemDropDown");o.extendAsViewModel(["View:RainLoop:SettingsSystemDropDown","SettingsSystemDropDownViewModel"],s),i.extend(s.prototype,n.prototype),e.exports=s}(t,e)},{"App:Knoin":27,"View:RainLoop:AbstractSystemDropDown":71,_:25}]},{},[1]); \ No newline at end of file diff --git a/rainloop/v/0.0.0/static/js/common.js b/rainloop/v/0.0.0/static/js/common.js new file mode 100644 index 000000000..adec44ef0 --- /dev/null +++ b/rainloop/v/0.0.0/static/js/common.js @@ -0,0 +1,6696 @@ +/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ +/******/ (function(modules) { // webpackBootstrap +/******/ // install a JSONP callback for chunk loading +/******/ var parentJsonpFunction = window["webpackJsonp"]; +/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules) { +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0, callbacks = []; +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(installedChunks[chunkId]) +/******/ callbacks.push.apply(callbacks, installedChunks[chunkId]); +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ for(moduleId in moreModules) { +/******/ modules[moduleId] = moreModules[moduleId]; +/******/ } +/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules); +/******/ while(callbacks.length) +/******/ callbacks.shift().call(null, __webpack_require__); +/******/ if(moreModules[0]) { +/******/ installedModules[0] = 0; +/******/ __webpack_require__(0); +/******/ } +/******/ }; +/******/ +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // object to store loaded and loading chunks +/******/ // "0" means "already loaded" +/******/ // Array means "loading", array contains callbacks +/******/ var installedChunks = { +/******/ 1:0 +/******/ }; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = function requireEnsure(chunkId, callback) { +/******/ // "0" is the signal for "already loaded" +/******/ if(installedChunks[chunkId] === 0) +/******/ return callback.call(null, __webpack_require__); +/******/ +/******/ // an array means "currently loading". +/******/ if(installedChunks[chunkId] !== undefined) { +/******/ installedChunks[chunkId].push(callback); +/******/ } else { +/******/ // start chunk loading +/******/ installedChunks[chunkId] = [callback]; +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.type = 'text/javascript'; +/******/ script.charset = 'utf-8'; +/******/ script.src = __webpack_require__.p + "" + {"0":"701a517c70faed82fff3","2":"16ff7c35c340aa129a8c","3":"9970c7a3777d831f5c93"}[chunkId] + ".chunk.js"; +/******/ head.appendChild(script); +/******/ } +/******/ }; +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = "rainloop/v/0.0.0/static/js/"; +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 1: +/*!*****************************!*\ + !*** ./dev/Common/Utils.js ***! + \*****************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + Utils = {}, + + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Consts = __webpack_require__(/*! Common/Consts */ 17), + Globals = __webpack_require__(/*! Common/Globals */ 7) + ; + + Utils.trim = $.trim; + Utils.inArray = $.inArray; + Utils.isArray = _.isArray; + Utils.isFunc = _.isFunction; + Utils.isUnd = _.isUndefined; + Utils.isNull = _.isNull; + Utils.emptyFunction = function () {}; + + /** + * @param {*} oValue + * @return {boolean} + */ + Utils.isNormal = function (oValue) + { + return !Utils.isUnd(oValue) && !Utils.isNull(oValue); + }; + + Utils.windowResize = _.debounce(function (iTimeout) { + if (Utils.isUnd(iTimeout)) + { + Globals.$win.resize(); + } + else + { + window.setTimeout(function () { + Globals.$win.resize(); + }, iTimeout); + } + }, 50); + + /** + * @param {(string|number)} mValue + * @param {boolean=} bIncludeZero + * @return {boolean} + */ + Utils.isPosNumeric = function (mValue, bIncludeZero) + { + return Utils.isNormal(mValue) ? + ((Utils.isUnd(bIncludeZero) ? true : !!bIncludeZero) ? + (/^[0-9]*$/).test(mValue.toString()) : + (/^[1-9]+[0-9]*$/).test(mValue.toString())) : + false; + }; + + /** + * @param {*} iValue + * @param {number=} iDefault = 0 + * @return {number} + */ + Utils.pInt = function (iValue, iDefault) + { + var iResult = Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : (iDefault || 0); + return window.isNaN(iResult) ? (iDefault || 0) : iResult; + }; + + /** + * @param {*} mValue + * @return {string} + */ + Utils.pString = function (mValue) + { + return Utils.isNormal(mValue) ? '' + mValue : ''; + }; + + /** + * @param {string} sComponent + * @return {string} + */ + Utils.encodeURIComponent = function (sComponent) + { + return window.encodeURIComponent(sComponent); + }; + + /** + * @param {*} aValue + * @return {boolean} + */ + Utils.isNonEmptyArray = function (aValue) + { + return Utils.isArray(aValue) && 0 < aValue.length; + }; + + /** + * @return {*|null} + */ + Utils.notificationClass = function () + { + return window.Notification && window.Notification.requestPermission ? window.Notification : null; + }; + + /** + * @param {string} sQueryString + * @return {Object} + */ + Utils.simpleQueryParser = function (sQueryString) + { + var + oParams = {}, + aQueries = [], + aTemp = [], + iIndex = 0, + iLen = 0 + ; + + aQueries = sQueryString.split('&'); + for (iIndex = 0, iLen = aQueries.length; iIndex < iLen; iIndex++) + { + aTemp = aQueries[iIndex].split('='); + oParams[window.decodeURIComponent(aTemp[0])] = window.decodeURIComponent(aTemp[1]); + } + + return oParams; + }; + + /** + * @param {string} sMailToUrl + * @param {Function} PopupComposeVoreModel + * @returns {boolean} + */ + Utils.mailToHelper = function (sMailToUrl, PopupComposeVoreModel) + { + if (sMailToUrl && 'mailto:' === sMailToUrl.toString().substr(0, 7).toLowerCase()) + { + sMailToUrl = sMailToUrl.toString().substr(7); + + var + oParams = {}, + oEmailModel = null, + sEmail = sMailToUrl.replace(/\?.+$/, ''), + sQueryString = sMailToUrl.replace(/^[^\?]*\?/, ''), + EmailModel = __webpack_require__(/*! Model:Email */ 23) + ; + + oEmailModel = new EmailModel(); + oEmailModel.parse(window.decodeURIComponent(sEmail)); + + if (oEmailModel && oEmailModel.email) + { + oParams = Utils.simpleQueryParser(sQueryString); + + __webpack_require__(/*! App:Knoin */ 5).showScreenPopup(PopupComposeVoreModel, [Enums.ComposeType.Empty, null, [oEmailModel], + Utils.isUnd(oParams.subject) ? null : Utils.pString(oParams.subject), + Utils.isUnd(oParams.body) ? null : Utils.plainToHtml(Utils.pString(oParams.body)) + ]); + } + + return true; + } + + return false; + }; + + /** + * @param {string} sValue + * @param {string} sHash + * @param {string} sKey + * @param {string} sLongKey + * @return {string|boolean} + */ + Utils.rsaEncode = function (sValue, sHash, sKey, sLongKey) + { + if (window.crypto && window.crypto.getRandomValues && window.RSAKey && sHash && sKey && sLongKey) + { + var oRsa = new window.RSAKey(); + oRsa.setPublic(sLongKey, sKey); + + sValue = oRsa.encrypt(Utils.fakeMd5() + ':' + sValue + ':' + Utils.fakeMd5()); + if (false !== sValue) + { + return 'rsa:' + sHash + ':' + sValue; + } + } + + return false; + }; + + Utils.rsaEncode.supported = !!(window.crypto && window.crypto.getRandomValues && window.RSAKey); + + /** + * @param {string} sPath + * @param {*=} oObject + * @param {Object=} oObjectToExportTo + */ + Utils.exportPath = function (sPath, oObject, oObjectToExportTo) + { + var + sPart = null, + aParts = sPath.split('.'), + oCur = oObjectToExportTo || window + ; + + for (; aParts.length && (sPart = aParts.shift());) + { + if (!aParts.length && !Utils.isUnd(oObject)) + { + oCur[sPart] = oObject; + } + else if (oCur[sPart]) + { + oCur = oCur[sPart]; + } + else + { + oCur = oCur[sPart] = {}; + } + } + }; + + /** + * @param {Object} oObject + * @param {string} sName + * @param {*} mValue + */ + Utils.pImport = function (oObject, sName, mValue) + { + oObject[sName] = mValue; + }; + + /** + * @param {Object} oObject + * @param {string} sName + * @param {*} mDefault + * @return {*} + */ + Utils.pExport = function (oObject, sName, mDefault) + { + return Utils.isUnd(oObject[sName]) ? mDefault : oObject[sName]; + }; + + /** + * @param {string} sText + * @return {string} + */ + Utils.encodeHtml = function (sText) + { + return Utils.isNormal(sText) ? sText.toString() + .replace(/&/g, '&').replace(//g, '>') + .replace(/"/g, '"').replace(/'/g, ''') : ''; + }; + + /** + * @param {string} sText + * @param {number=} iLen + * @return {string} + */ + Utils.splitPlainText = function (sText, iLen) + { + var + sPrefix = '', + sSubText = '', + sResult = sText, + iSpacePos = 0, + iNewLinePos = 0 + ; + + iLen = Utils.isUnd(iLen) ? 100 : iLen; + + while (sResult.length > iLen) + { + sSubText = sResult.substring(0, iLen); + iSpacePos = sSubText.lastIndexOf(' '); + iNewLinePos = sSubText.lastIndexOf('\n'); + + if (-1 !== iNewLinePos) + { + iSpacePos = iNewLinePos; + } + + if (-1 === iSpacePos) + { + iSpacePos = iLen; + } + + sPrefix += sSubText.substring(0, iSpacePos) + '\n'; + sResult = sResult.substring(iSpacePos + 1); + } + + return sPrefix + sResult; + }; + + Utils.timeOutAction = (function () { + + var + oTimeOuts = {} + ; + + return function (sAction, fFunction, iTimeOut) + { + if (Utils.isUnd(oTimeOuts[sAction])) + { + oTimeOuts[sAction] = 0; + } + + window.clearTimeout(oTimeOuts[sAction]); + oTimeOuts[sAction] = window.setTimeout(fFunction, iTimeOut); + }; + }()); + + Utils.timeOutActionSecond = (function () { + + var + oTimeOuts = {} + ; + + return function (sAction, fFunction, iTimeOut) + { + if (!oTimeOuts[sAction]) + { + oTimeOuts[sAction] = window.setTimeout(function () { + fFunction(); + oTimeOuts[sAction] = 0; + }, iTimeOut); + } + }; + }()); + + Utils.audio = (function () { + + var + oAudio = false + ; + + return function (sMp3File, sOggFile) { + + if (false === oAudio) + { + if (Globals.bIsiOSDevice) + { + oAudio = null; + } + else + { + var + bCanPlayMp3 = false, + bCanPlayOgg = false, + oAudioLocal = window.Audio ? new window.Audio() : null + ; + + if (oAudioLocal && oAudioLocal.canPlayType && oAudioLocal.play) + { + bCanPlayMp3 = '' !== oAudioLocal.canPlayType('audio/mpeg; codecs="mp3"'); + if (!bCanPlayMp3) + { + bCanPlayOgg = '' !== oAudioLocal.canPlayType('audio/ogg; codecs="vorbis"'); + } + + if (bCanPlayMp3 || bCanPlayOgg) + { + oAudio = oAudioLocal; + oAudio.preload = 'none'; + oAudio.loop = false; + oAudio.autoplay = false; + oAudio.muted = false; + oAudio.src = bCanPlayMp3 ? sMp3File : sOggFile; + } + else + { + oAudio = null; + } + } + else + { + oAudio = null; + } + } + } + + return oAudio; + }; + }()); + + /** + * @param {(Object|null|undefined)} oObject + * @param {string} sProp + * @return {boolean} + */ + Utils.hos = function (oObject, sProp) + { + return oObject && window.Object && window.Object.hasOwnProperty ? window.Object.hasOwnProperty.call(oObject, sProp) : false; + }; + + /** + * @param {string} sKey + * @param {Object=} oValueList + * @param {string=} sDefaulValue + * @return {string} + */ + Utils.i18n = function (sKey, oValueList, sDefaulValue) + { + var + sValueName = '', + sResult = Utils.isUnd(Globals.oI18N[sKey]) ? (Utils.isUnd(sDefaulValue) ? sKey : sDefaulValue) : Globals.oI18N[sKey] + ; + + if (!Utils.isUnd(oValueList) && !Utils.isNull(oValueList)) + { + for (sValueName in oValueList) + { + if (Utils.hos(oValueList, sValueName)) + { + sResult = sResult.replace('%' + sValueName + '%', oValueList[sValueName]); + } + } + } + + return sResult; + }; + + /** + * @param {Object} oElement + */ + Utils.i18nToNode = function (oElement) + { + _.defer(function () { + $('.i18n', oElement).each(function () { + var + jqThis = $(this), + sKey = '' + ; + + sKey = jqThis.data('i18n-text'); + if (sKey) + { + jqThis.text(Utils.i18n(sKey)); + } + else + { + sKey = jqThis.data('i18n-html'); + if (sKey) + { + 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) + { + jqThis.attr('title', Utils.i18n(sKey)); + } + } + }); + }); + }; + + Utils.i18nReload = function () + { + if (window['rainloopI18N']) + { + Globals.oI18N = window['rainloopI18N'] || {}; + + Utils.i18nToNode(Globals.$doc); + + Globals.langChangeTrigger(!Globals.langChangeTrigger()); + } + + window['rainloopI18N'] = null; + }; + + /** + * @param {Function} fCallback + * @param {Object} oScope + * @param {Function=} fLangCallback + */ + Utils.initOnStartOrLangChange = function (fCallback, oScope, fLangCallback) + { + if (fCallback) + { + fCallback.call(oScope); + } + + if (fLangCallback) + { + Globals.langChangeTrigger.subscribe(function () { + if (fCallback) + { + fCallback.call(oScope); + } + + fLangCallback.call(oScope); + }); + } + else if (fCallback) + { + Globals.langChangeTrigger.subscribe(fCallback, oScope); + } + }; + + /** + * @return {boolean} + */ + Utils.inFocus = function () + { + if (window.document.activeElement) + { + if (Utils.isUnd(window.document.activeElement.__inFocusCache)) + { + window.document.activeElement.__inFocusCache = $(window.document.activeElement).is('input,textarea,iframe,.cke_editable'); + } + + return !!window.document.activeElement.__inFocusCache; + } + + return false; + }; + + Utils.removeInFocus = function () + { + if (window.document && window.document.activeElement && window.document.activeElement.blur) + { + var oA = $(window.document.activeElement); + if (oA.is('input,textarea')) + { + window.document.activeElement.blur(); + } + } + }; + + Utils.removeSelection = function () + { + if (window && window.getSelection) + { + var oSel = window.getSelection(); + if (oSel && oSel.removeAllRanges) + { + oSel.removeAllRanges(); + } + } + else if (window.document && window.document.selection && window.document.selection.empty) + { + window.document.selection.empty(); + } + }; + + /** + * @param {string} sPrefix + * @param {string} sSubject + * @return {string} + */ + Utils.replySubjectAdd = function (sPrefix, sSubject) + { + sPrefix = Utils.trim(sPrefix.toUpperCase()); + sSubject = Utils.trim(sSubject.replace(/[\s]+/g, ' ')); + + var + bDrop = false, + aSubject = [], + bRe = 'RE' === sPrefix, + bFwd = 'FWD' === sPrefix, + bPrefixIsRe = !bFwd + ; + + if ('' !== sSubject) + { + _.each(sSubject.split(':'), function (sPart) { + var sTrimmedPart = Utils.trim(sPart); + if (!bDrop && (/^(RE|FWD)$/i.test(sTrimmedPart) || /^(RE|FWD)[\[\(][\d]+[\]\)]$/i.test(sTrimmedPart))) + { + if (!bRe) + { + bRe = !!(/^RE/i.test(sTrimmedPart)); + } + + if (!bFwd) + { + bFwd = !!(/^FWD/i.test(sTrimmedPart)); + } + } + else + { + aSubject.push(sPart); + bDrop = true; + } + }); + } + + if (bPrefixIsRe) + { + bRe = false; + } + else + { + bFwd = false; + } + + return Utils.trim( + (bPrefixIsRe ? 'Re: ' : 'Fwd: ') + + (bRe ? 'Re: ' : '') + + (bFwd ? 'Fwd: ' : '') + + Utils.trim(aSubject.join(':')) + ); + }; + + /** + * @param {number} iNum + * @param {number} iDec + * @return {number} + */ + Utils.roundNumber = function (iNum, iDec) + { + return window.Math.round(iNum * window.Math.pow(10, iDec)) / window.Math.pow(10, iDec); + }; + + /** + * @param {(number|string)} iSizeInBytes + * @return {string} + */ + Utils.friendlySize = function (iSizeInBytes) + { + iSizeInBytes = Utils.pInt(iSizeInBytes); + + if (iSizeInBytes >= 1073741824) + { + return Utils.roundNumber(iSizeInBytes / 1073741824, 1) + 'GB'; + } + else if (iSizeInBytes >= 1048576) + { + return Utils.roundNumber(iSizeInBytes / 1048576, 1) + 'MB'; + } + else if (iSizeInBytes >= 1024) + { + return Utils.roundNumber(iSizeInBytes / 1024, 0) + 'KB'; + } + + return iSizeInBytes + 'B'; + }; + + /** + * @param {string} sDesc + */ + Utils.log = function (sDesc) + { + if (window.console && window.console.log) + { + window.console.log(sDesc); + } + }; + + /** + * @param {number} iCode + * @param {*=} mMessage = '' + * @return {string} + */ + Utils.getNotification = function (iCode, mMessage) + { + iCode = Utils.pInt(iCode); + if (Enums.Notification.ClientViewError === iCode && mMessage) + { + return mMessage; + } + + return Utils.isUnd(Globals.oNotificationI18N[iCode]) ? '' : Globals.oNotificationI18N[iCode]; + }; + + Utils.initNotificationLanguage = function () + { + var oN = Globals.oNotificationI18N || {}; + oN[Enums.Notification.InvalidToken] = Utils.i18n('NOTIFICATIONS/INVALID_TOKEN'); + oN[Enums.Notification.AuthError] = Utils.i18n('NOTIFICATIONS/AUTH_ERROR'); + oN[Enums.Notification.AccessError] = Utils.i18n('NOTIFICATIONS/ACCESS_ERROR'); + oN[Enums.Notification.ConnectionError] = Utils.i18n('NOTIFICATIONS/CONNECTION_ERROR'); + oN[Enums.Notification.CaptchaError] = Utils.i18n('NOTIFICATIONS/CAPTCHA_ERROR'); + oN[Enums.Notification.SocialFacebookLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE'); + oN[Enums.Notification.SocialTwitterLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE'); + oN[Enums.Notification.SocialGoogleLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE'); + oN[Enums.Notification.DomainNotAllowed] = Utils.i18n('NOTIFICATIONS/DOMAIN_NOT_ALLOWED'); + oN[Enums.Notification.AccountNotAllowed] = Utils.i18n('NOTIFICATIONS/ACCOUNT_NOT_ALLOWED'); + + oN[Enums.Notification.AccountTwoFactorAuthRequired] = Utils.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED'); + oN[Enums.Notification.AccountTwoFactorAuthError] = Utils.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR'); + + oN[Enums.Notification.CouldNotSaveNewPassword] = Utils.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD'); + oN[Enums.Notification.CurrentPasswordIncorrect] = Utils.i18n('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT'); + oN[Enums.Notification.NewPasswordShort] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_SHORT'); + oN[Enums.Notification.NewPasswordWeak] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_WEAK'); + oN[Enums.Notification.NewPasswordForbidden] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT'); + + oN[Enums.Notification.ContactsSyncError] = Utils.i18n('NOTIFICATIONS/CONTACTS_SYNC_ERROR'); + + oN[Enums.Notification.CantGetMessageList] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST'); + oN[Enums.Notification.CantGetMessage] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE'); + oN[Enums.Notification.CantDeleteMessage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_MESSAGE'); + oN[Enums.Notification.CantMoveMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE'); + oN[Enums.Notification.CantCopyMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE'); + + oN[Enums.Notification.CantSaveMessage] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_MESSAGE'); + oN[Enums.Notification.CantSendMessage] = Utils.i18n('NOTIFICATIONS/CANT_SEND_MESSAGE'); + oN[Enums.Notification.InvalidRecipients] = Utils.i18n('NOTIFICATIONS/INVALID_RECIPIENTS'); + + oN[Enums.Notification.CantCreateFolder] = Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER'); + oN[Enums.Notification.CantRenameFolder] = Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'); + oN[Enums.Notification.CantDeleteFolder] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'); + oN[Enums.Notification.CantDeleteNonEmptyFolder] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER'); + oN[Enums.Notification.CantSubscribeFolder] = Utils.i18n('NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER'); + oN[Enums.Notification.CantUnsubscribeFolder] = Utils.i18n('NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER'); + + oN[Enums.Notification.CantSaveSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS'); + oN[Enums.Notification.CantSavePluginSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS'); + + oN[Enums.Notification.DomainAlreadyExists] = Utils.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS'); + + oN[Enums.Notification.CantInstallPackage] = Utils.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE'); + oN[Enums.Notification.CantDeletePackage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE'); + oN[Enums.Notification.InvalidPluginPackage] = Utils.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE'); + oN[Enums.Notification.UnsupportedPluginPackage] = Utils.i18n('NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE'); + + oN[Enums.Notification.LicensingServerIsUnavailable] = Utils.i18n('NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE'); + oN[Enums.Notification.LicensingExpired] = Utils.i18n('NOTIFICATIONS/LICENSING_EXPIRED'); + oN[Enums.Notification.LicensingBanned] = Utils.i18n('NOTIFICATIONS/LICENSING_BANNED'); + + oN[Enums.Notification.DemoSendMessageError] = Utils.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR'); + + oN[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS'); + + oN[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR'); + oN[Enums.Notification.InvalidInputArgument] = Utils.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT'); + oN[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR'); + oN[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR'); + }; + + /** + * @param {*} mCode + * @return {string} + */ + Utils.getUploadErrorDescByCode = function (mCode) + { + var sResult = ''; + switch (Utils.pInt(mCode)) { + case Enums.UploadErrorCode.FileIsTooBig: + sResult = Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG'); + break; + case Enums.UploadErrorCode.FilePartiallyUploaded: + sResult = Utils.i18n('UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED'); + break; + case Enums.UploadErrorCode.FileNoUploaded: + sResult = Utils.i18n('UPLOAD/ERROR_NO_FILE_UPLOADED'); + break; + case Enums.UploadErrorCode.MissingTempFolder: + sResult = Utils.i18n('UPLOAD/ERROR_MISSING_TEMP_FOLDER'); + break; + case Enums.UploadErrorCode.FileOnSaveingError: + sResult = Utils.i18n('UPLOAD/ERROR_ON_SAVING_FILE'); + break; + case Enums.UploadErrorCode.FileType: + sResult = Utils.i18n('UPLOAD/ERROR_FILE_TYPE'); + break; + default: + sResult = Utils.i18n('UPLOAD/ERROR_UNKNOWN'); + break; + } + + return sResult; + }; + + /** + * @param {?} oObject + * @param {string} sMethodName + * @param {Array=} aParameters + * @param {number=} nDelay + */ + Utils.delegateRun = function (oObject, sMethodName, aParameters, nDelay) + { + if (oObject && oObject[sMethodName]) + { + nDelay = Utils.pInt(nDelay); + if (0 >= nDelay) + { + oObject[sMethodName].apply(oObject, Utils.isArray(aParameters) ? aParameters : []); + } + else + { + _.delay(function () { + oObject[sMethodName].apply(oObject, Utils.isArray(aParameters) ? aParameters : []); + }, nDelay); + } + } + }; + + /** + * @param {?} oEvent + */ + Utils.killCtrlAandS = function (oEvent) + { + oEvent = oEvent || window.event; + if (oEvent && oEvent.ctrlKey && !oEvent.shiftKey && !oEvent.altKey) + { + var + oSender = oEvent.target || oEvent.srcElement, + iKey = oEvent.keyCode || oEvent.which + ; + + if (iKey === Enums.EventKeyCode.S) + { + oEvent.preventDefault(); + return; + } + + if (oSender && oSender.tagName && oSender.tagName.match(/INPUT|TEXTAREA/i)) + { + return; + } + + if (iKey === Enums.EventKeyCode.A) + { + if (window.getSelection) + { + window.getSelection().removeAllRanges(); + } + else if (window.document.selection && window.document.selection.clear) + { + window.document.selection.clear(); + } + + oEvent.preventDefault(); + } + } + }; + + /** + * @param {(Object|null|undefined)} oContext + * @param {Function} fExecute + * @param {(Function|boolean|null)=} fCanExecute + * @return {Function} + */ + Utils.createCommand = function (oContext, fExecute, fCanExecute) + { + var + fResult = fExecute ? function () { + + if (fResult && fResult.canExecute && fResult.canExecute()) + { + fExecute.apply(oContext, Array.prototype.slice.call(arguments)); + } + + return false; + + } : function () {} + ; + + fResult.enabled = ko.observable(true); + + fCanExecute = Utils.isUnd(fCanExecute) ? true : fCanExecute; + if (Utils.isFunc(fCanExecute)) + { + fResult.canExecute = ko.computed(function () { + return fResult.enabled() && fCanExecute.call(oContext); + }); + } + else + { + fResult.canExecute = ko.computed(function () { + return fResult.enabled() && !!fCanExecute; + }); + } + + return fResult; + }; + + /** + * @param {Object} oData + */ + Utils.initDataConstructorBySettings = function (oData) + { + oData.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html); + oData.showImages = ko.observable(false); + oData.interfaceAnimation = ko.observable(Enums.InterfaceAnimation.Full); + oData.contactsAutosave = ko.observable(false); + + Globals.sAnimationType = Enums.InterfaceAnimation.Full; + + oData.capaThemes = ko.observable(false); + oData.allowLanguagesOnSettings = ko.observable(true); + oData.allowLanguagesOnLogin = ko.observable(true); + + oData.useLocalProxyForExternalImages = ko.observable(false); + + oData.desktopNotifications = ko.observable(false); + 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(); + }); + + oData.interfaceAnimation.subscribe(function (sValue) { + if (Globals.bMobileDevice || sValue === Enums.InterfaceAnimation.None) + { + Globals.$html.removeClass('rl-anim rl-anim-full').addClass('no-rl-anim'); + + Globals.sAnimationType = Enums.InterfaceAnimation.None; + } + else + { + switch (sValue) + { + case Enums.InterfaceAnimation.Full: + Globals.$html.removeClass('no-rl-anim').addClass('rl-anim rl-anim-full'); + Globals.sAnimationType = sValue; + break; + case Enums.InterfaceAnimation.Normal: + Globals.$html.removeClass('no-rl-anim rl-anim-full').addClass('rl-anim'); + Globals.sAnimationType = sValue; + break; + } + } + }); + + oData.interfaceAnimation.valueHasMutated(); + + oData.desktopNotificationsPermisions = ko.computed(function () { + + oData.desktopNotifications(); + + var + NotificationClass = Utils.notificationClass(), + iResult = Enums.DesktopNotifications.NotSupported + ; + + if (NotificationClass && NotificationClass.permission) + { + switch (NotificationClass.permission.toLowerCase()) + { + case 'granted': + iResult = Enums.DesktopNotifications.Allowed; + break; + case 'denied': + iResult = Enums.DesktopNotifications.Denied; + break; + case 'default': + iResult = Enums.DesktopNotifications.NotAllowed; + break; + } + } + else if (window.webkitNotifications && window.webkitNotifications.checkPermission) + { + iResult = window.webkitNotifications.checkPermission(); + } + + return iResult; + }); + + oData.useDesktopNotifications = ko.computed({ + 'read': function () { + return oData.desktopNotifications() && + Enums.DesktopNotifications.Allowed === oData.desktopNotificationsPermisions(); + }, + 'write': function (bValue) { + if (bValue) + { + var + NotificationClass = Utils.notificationClass(), + iPermission = oData.desktopNotificationsPermisions() + ; + + if (NotificationClass && Enums.DesktopNotifications.Allowed === iPermission) + { + oData.desktopNotifications(true); + } + else if (NotificationClass && Enums.DesktopNotifications.NotAllowed === iPermission) + { + NotificationClass.requestPermission(function () { + oData.desktopNotifications.valueHasMutated(); + if (Enums.DesktopNotifications.Allowed === oData.desktopNotificationsPermisions()) + { + if (oData.desktopNotifications()) + { + oData.desktopNotifications.valueHasMutated(); + } + else + { + oData.desktopNotifications(true); + } + } + else + { + if (oData.desktopNotifications()) + { + oData.desktopNotifications(false); + } + else + { + oData.desktopNotifications.valueHasMutated(); + } + } + }); + } + else + { + oData.desktopNotifications(false); + } + } + else + { + oData.desktopNotifications(false); + } + } + }); + + oData.language = ko.observable(''); + oData.languages = ko.observableArray([]); + + oData.mainLanguage = ko.computed({ + 'read': oData.language, + 'write': function (sValue) { + if (sValue !== oData.language()) + { + if (-1 < Utils.inArray(sValue, oData.languages())) + { + oData.language(sValue); + } + else if (0 < oData.languages().length) + { + oData.language(oData.languages()[0]); + } + } + else + { + oData.language.valueHasMutated(); + } + } + }); + + oData.theme = ko.observable(''); + oData.themes = ko.observableArray([]); + + oData.mainTheme = ko.computed({ + 'read': oData.theme, + 'write': function (sValue) { + if (sValue !== oData.theme()) + { + var aThemes = oData.themes(); + if (-1 < Utils.inArray(sValue, aThemes)) + { + oData.theme(sValue); + } + else if (0 < aThemes.length) + { + oData.theme(aThemes[0]); + } + } + else + { + oData.theme.valueHasMutated(); + } + } + }); + + oData.capaAdditionalAccounts = ko.observable(false); + oData.capaAdditionalIdentities = ko.observable(false); + oData.capaGravatar = ko.observable(false); + oData.determineUserLanguage = ko.observable(false); + oData.determineUserDomain = ko.observable(false); + + oData.messagesPerPage = ko.observable(Consts.Defaults.MessagesPerPage);//.extend({'throttle': 200}); + + oData.mainMessagesPerPage = oData.messagesPerPage; + oData.mainMessagesPerPage = ko.computed({ + 'read': oData.messagesPerPage, + 'write': function (iValue) { + if (-1 < Utils.inArray(Utils.pInt(iValue), Consts.Defaults.MessagesPerPageArray)) + { + if (iValue !== oData.messagesPerPage()) + { + oData.messagesPerPage(iValue); + } + } + else + { + oData.messagesPerPage.valueHasMutated(); + } + } + }); + + oData.facebookSupported = ko.observable(false); + oData.facebookEnable = ko.observable(false); + oData.facebookAppID = ko.observable(''); + oData.facebookAppSecret = ko.observable(''); + + oData.twitterEnable = ko.observable(false); + oData.twitterConsumerKey = ko.observable(''); + oData.twitterConsumerSecret = ko.observable(''); + + oData.googleEnable = ko.observable(false); + oData.googleClientID = ko.observable(''); + oData.googleClientSecret = ko.observable(''); + oData.googleApiKey = ko.observable(''); + + oData.dropboxEnable = ko.observable(false); + oData.dropboxApiKey = ko.observable(''); + + oData.contactsIsAllowed = ko.observable(false); + }; + + /** + * @param {{moment:Function}} oObject + */ + Utils.createMomentDate = function (oObject) + { + if (Utils.isUnd(oObject.moment)) + { + oObject.moment = ko.observable(moment()); + } + + return ko.computed(function () { + Globals.momentTrigger(); + var oMoment = this.moment(); + return 1970 === oMoment.year() ? '' : oMoment.fromNow(); + }, oObject); + }; + + /** + * @param {{moment:Function, momentDate:Function}} oObject + */ + Utils.createMomentShortDate = function (oObject) + { + return ko.computed(function () { + + var + sResult = '', + oMomentNow = moment(), + oMoment = this.moment(), + sMomentDate = this.momentDate() + ; + + if (1970 === oMoment.year()) + { + sResult = ''; + } + else if (4 >= oMomentNow.diff(oMoment, 'hours')) + { + sResult = sMomentDate; + } + else if (oMomentNow.format('L') === oMoment.format('L')) + { + sResult = Utils.i18n('MESSAGE_LIST/TODAY_AT', { + 'TIME': oMoment.format('LT') + }); + } + else if (oMomentNow.clone().subtract('days', 1).format('L') === oMoment.format('L')) + { + sResult = Utils.i18n('MESSAGE_LIST/YESTERDAY_AT', { + 'TIME': oMoment.format('LT') + }); + } + else if (oMomentNow.year() === oMoment.year()) + { + sResult = oMoment.format('D MMM.'); + } + else + { + sResult = oMoment.format('LL'); + } + + return sResult; + + }, oObject); + }; + + /** + * @param {string} sTheme + * @return {string} + */ + Utils.convertThemeName = function (sTheme) + { + if ('@custom' === sTheme.substr(-7)) + { + sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7)); + } + + return Utils.trim(sTheme.replace(/[^a-zA-Z0-9]+/g, ' ').replace(/([A-Z])/g, ' $1').replace(/[\s]+/g, ' ')); + }; + + /** + * @param {string} sName + * @return {string} + */ + Utils.quoteName = function (sName) + { + return sName.replace(/["]/g, '\\"'); + }; + + /** + * @return {number} + */ + Utils.microtime = function () + { + return (new Date()).getTime(); + }; + + /** + * + * @param {string} sLanguage + * @param {boolean=} bEng = false + * @return {string} + */ + Utils.convertLangName = function (sLanguage, bEng) + { + return Utils.i18n('LANGS_NAMES' + (true === bEng ? '_EN' : '') + '/LANG_' + + sLanguage.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_'), null, sLanguage); + }; + + /** + * @param {number=} iLen + * @return {string} + */ + Utils.fakeMd5 = function(iLen) + { + var + sResult = '', + sLine = '0123456789abcdefghijklmnopqrstuvwxyz' + ; + + iLen = Utils.isUnd(iLen) ? 32 : Utils.pInt(iLen); + + while (sResult.length < iLen) + { + sResult += sLine.substr(window.Math.round(window.Math.random() * sLine.length), 1); + } + + return sResult; + }; + + /** + * @param {string} sPlain + * @return {string} + */ + Utils.convertPlainTextToHtml = function (sPlain) + { + return sPlain.toString() + .replace(/&/g, '&').replace(/>/g, '>').replace(/'); + }; + + Utils.draggeblePlace = function () + { + return $('
 
').appendTo('#rl-hidden'); + }; + + Utils.defautOptionsAfterRender = function (oDomOption, oItem) + { + if (oItem && !Utils.isUnd(oItem.disabled) && oDomOption) + { + $(oDomOption) + .toggleClass('disabled', oItem.disabled) + .prop('disabled', oItem.disabled) + ; + } + }; + + /** + * @param {Object} oViewModel + * @param {string} sTemplateID + * @param {string} sTitle + * @param {Function=} fCallback + */ + Utils.windowPopupKnockout = function (oViewModel, sTemplateID, sTitle, fCallback) + { + var + oScript = null, + oWin = window.open(''), + sFunc = '__OpenerApplyBindingsUid' + Utils.fakeMd5() + '__', + oTemplate = $('#' + sTemplateID) + ; + + window[sFunc] = function () { + + if (oWin && oWin.document.body && oTemplate && oTemplate[0]) + { + var oBody = $(oWin.document.body); + + $('#rl-content', oBody).html(oTemplate.html()); + $('html', oWin.document).addClass('external ' + $('html').attr('class')); + + Utils.i18nToNode(oBody); + + if (oViewModel && $('#rl-content', oBody)[0]) + { + ko.applyBindings(oViewModel, $('#rl-content', oBody)[0]); + } + + window[sFunc] = null; + + fCallback(oWin); + } + }; + + oWin.document.open(); + oWin.document.write('' + + '' + + '' + + '' + + '' + + '' + + '' + Utils.encodeHtml(sTitle) + '' + + '
'); + oWin.document.close(); + + oScript = oWin.document.createElement('script'); + oScript.type = 'text/javascript'; + oScript.innerHTML = 'if(window&&window.opener&&window.opener[\'' + sFunc + '\']){window.opener[\'' + sFunc + '\']();window.opener[\'' + sFunc + '\']=null}'; + oWin.document.getElementsByTagName('head')[0].appendChild(oScript); + }; + + /** + * @param {Function} fCallback + * @param {?} koTrigger + * @param {?} oContext = null + * @param {number=} iTimer = 1000 + * @return {Function} + */ + Utils.settingsSaveHelperFunction = function (fCallback, koTrigger, oContext, iTimer) + { + oContext = oContext || null; + iTimer = Utils.isUnd(iTimer) ? 1000 : Utils.pInt(iTimer); + + return function (sType, mData, bCached, sRequestAction, oRequestParameters) { + koTrigger.call(oContext, mData && mData['Result'] ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult); + if (fCallback) + { + fCallback.call(oContext, sType, mData, bCached, sRequestAction, oRequestParameters); + } + _.delay(function () { + koTrigger.call(oContext, Enums.SaveSettingsStep.Idle); + }, iTimer); + }; + }; + + Utils.settingsSaveHelperSimpleFunction = function (koTrigger, oContext) + { + return Utils.settingsSaveHelperFunction(null, koTrigger, oContext, 1000); + }; + + /** + * @param {string} sHtml + * @return {string} + */ + Utils.htmlToPlain = function (sHtml) + { + var + iPos = 0, + iP1 = 0, + iP2 = 0, + iP3 = 0, + iLimit = 0, + + sText = '', + + splitPlainText = function (sText) + { + var + iLen = 100, + sPrefix = '', + sSubText = '', + sResult = sText, + iSpacePos = 0, + iNewLinePos = 0 + ; + + while (sResult.length > iLen) + { + sSubText = sResult.substring(0, iLen); + iSpacePos = sSubText.lastIndexOf(' '); + iNewLinePos = sSubText.lastIndexOf('\n'); + + if (-1 !== iNewLinePos) + { + iSpacePos = iNewLinePos; + } + + if (-1 === iSpacePos) + { + iSpacePos = iLen; + } + + sPrefix += sSubText.substring(0, iSpacePos) + '\n'; + sResult = sResult.substring(iSpacePos + 1); + } + + return sPrefix + sResult; + }, + + convertBlockquote = function (sText) { + sText = splitPlainText($.trim(sText)); + sText = '> ' + sText.replace(/\n/gm, '\n> '); + return sText.replace(/(^|\n)([> ]+)/gm, function () { + return (arguments && 2 < arguments.length) ? arguments[1] + $.trim(arguments[2].replace(/[\s]/g, '')) + ' ' : ''; + }); + }, + + convertDivs = function () { + if (arguments && 1 < arguments.length) + { + var sText = $.trim(arguments[1]); + if (0 < sText.length) + { + sText = sText.replace(/]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs); + sText = '\n' + $.trim(sText) + '\n'; + } + + return sText; + } + + return ''; + }, + + convertPre = function () { + return (arguments && 1 < arguments.length) ? arguments[1].toString().replace(/[\n]/gm, '
') : ''; + }, + + fixAttibuteValue = function () { + return (arguments && 1 < arguments.length) ? + '' + arguments[1] + arguments[2].replace(//g, '>') : ''; + }, + + convertLinks = function () { + return (arguments && 1 < arguments.length) ? $.trim(arguments[1]) : ''; + } + ; + + sText = sHtml + .replace(/]*>([\s\S\r\n]*)<\/pre>/gmi, convertPre) + .replace(/[\s]+/gm, ' ') + .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) + .replace(/]*>/gmi, '\n') + .replace(/<\/h[\d]>/gi, '\n') + .replace(/<\/p>/gi, '\n\n') + .replace(/<\/li>/gi, '\n') + .replace(/<\/td>/gi, '\n') + .replace(/<\/tr>/gi, '\n') + .replace(/]*>/gmi, '\n_______________________________\n\n') + .replace(/]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs) + .replace(/]*>/gmi, '\n__bq__start__\n') + .replace(/<\/blockquote>/gmi, '\n__bq__end__\n') + .replace(/]*>([\s\S\r\n]*?)<\/a>/gmi, convertLinks) + .replace(/<\/div>/gi, '\n') + .replace(/ /gi, ' ') + .replace(/"/gi, '"') + .replace(/<[^>]*>/gm, '') + ; + + sText = Globals.$div.html(sText).text(); + + sText = sText + .replace(/\n[ \t]+/gm, '\n') + .replace(/[\n]{3,}/gm, '\n\n') + .replace(/>/gi, '>') + .replace(/</gi, '<') + .replace(/&/gi, '&') + ; + + iPos = 0; + iLimit = 100; + + while (0 < iLimit) + { + iLimit--; + iP1 = sText.indexOf('__bq__start__', iPos); + if (-1 < iP1) + { + iP2 = sText.indexOf('__bq__start__', iP1 + 5); + iP3 = sText.indexOf('__bq__end__', iP1 + 5); + + if ((-1 === iP2 || iP3 < iP2) && iP1 < iP3) + { + sText = sText.substring(0, iP1) + + convertBlockquote(sText.substring(iP1 + 13, iP3)) + + sText.substring(iP3 + 11); + + iPos = 0; + } + else if (-1 < iP2 && iP2 < iP3) + { + iPos = iP2 - 1; + } + else + { + iPos = 0; + } + } + else + { + break; + } + } + + sText = sText + .replace(/__bq__start__/gm, '') + .replace(/__bq__end__/gm, '') + ; + + return sText; + }; + + /** + * @param {string} sPlain + * @param {boolean} bLinkify = false + * @return {string} + */ + Utils.plainToHtml = function (sPlain, bLinkify) + { + sPlain = sPlain.toString().replace(/\r/g, ''); + + var + bIn = false, + bDo = true, + bStart = true, + aNextText = [], + sLine = '', + iIndex = 0, + aText = sPlain.split("\n") + ; + + do + { + bDo = false; + aNextText = []; + for (iIndex = 0; iIndex < aText.length; iIndex++) + { + sLine = aText[iIndex]; + bStart = '>' === sLine.substr(0, 1); + if (bStart && !bIn) + { + bDo = true; + bIn = true; + aNextText.push('~~~blockquote~~~'); + aNextText.push(sLine.substr(1)); + } + else if (!bStart && bIn) + { + bIn = false; + aNextText.push('~~~/blockquote~~~'); + aNextText.push(sLine); + } + else if (bStart && bIn) + { + aNextText.push(sLine.substr(1)); + } + else + { + aNextText.push(sLine); + } + } + + if (bIn) + { + bIn = false; + aNextText.push('~~~/blockquote~~~'); + } + + aText = aNextText; + } + while (bDo); + + sPlain = aText.join("\n"); + + sPlain = sPlain + .replace(/&/g, '&') + .replace(/>/g, '>').replace(/') + .replace(/[\s]*~~~\/blockquote~~~/g, '') + .replace(/[\-_~]{10,}/g, '
') + .replace(/\n/g, '
'); + + return bLinkify ? Utils.linkify(sPlain) : sPlain; + }; + + window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain; + window.rainloop_Utils_plainToHtml = Utils.plainToHtml; + + /** + * @param {string} sHtml + * @return {string} + */ + Utils.linkify = function (sHtml) + { + if ($.fn && $.fn.linkify) + { + sHtml = Globals.$div.html(sHtml.replace(/&/ig, 'amp_amp_12345_amp_amp')) + .linkify() + .find('.linkified').removeClass('linkified').end() + .html() + .replace(/amp_amp_12345_amp_amp/g, '&') + ; + } + + return sHtml; + }; + + /** + * @param {string} sUrl + * @param {number} iValue + * @param {Function} fCallback + */ + Utils.resizeAndCrop = function (sUrl, iValue, fCallback) + { + var oTempImg = new window.Image(); + oTempImg.onload = function() { + + var + aDiff = [0, 0], + oCanvas = window.document.createElement('canvas'), + oCtx = oCanvas.getContext('2d') + ; + + oCanvas.width = iValue; + oCanvas.height = iValue; + + if (this.width > this.height) + { + aDiff = [this.width - this.height, 0]; + } + else + { + aDiff = [0, this.height - this.width]; + } + + 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')); + }; + + oTempImg.src = sUrl; + }; + + /** + * @param {Array} aSystem + * @param {Array} aList + * @param {Array=} aDisabled + * @param {Array=} aHeaderLines + * @param {?number=} iUnDeep + * @param {Function=} fDisableCallback + * @param {Function=} fVisibleCallback + * @param {Function=} fRenameCallback + * @param {boolean=} bSystem + * @param {boolean=} bBuildUnvisible + * @return {Array} + */ + Utils.folderListOptionsBuilder = function (aSystem, aList, aDisabled, aHeaderLines, iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible) + { + var + /** + * @type {?FolderModel} + */ + oItem = null, + bSep = false, + iIndex = 0, + iLen = 0, + sDeepPrefix = '\u00A0\u00A0\u00A0', + aResult = [] + ; + + bSystem = !Utils.isNormal(bSystem) ? 0 < aSystem.length : bSystem; + bBuildUnvisible = Utils.isUnd(bBuildUnvisible) ? false : !!bBuildUnvisible; + iUnDeep = !Utils.isNormal(iUnDeep) ? 0 : iUnDeep; + fDisableCallback = Utils.isNormal(fDisableCallback) ? fDisableCallback : null; + fVisibleCallback = Utils.isNormal(fVisibleCallback) ? fVisibleCallback : null; + fRenameCallback = Utils.isNormal(fRenameCallback) ? fRenameCallback : null; + + if (!Utils.isArray(aDisabled)) + { + aDisabled = []; + } + + if (!Utils.isArray(aHeaderLines)) + { + aHeaderLines = []; + } + + for (iIndex = 0, iLen = aHeaderLines.length; iIndex < iLen; iIndex++) + { + aResult.push({ + 'id': aHeaderLines[iIndex][0], + 'name': aHeaderLines[iIndex][1], + 'system': false, + 'seporator': false, + 'disabled': false + }); + } + + bSep = true; + for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++) + { + oItem = aSystem[iIndex]; + if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true) + { + if (bSep && 0 < aResult.length) + { + aResult.push({ + 'id': '---', + 'name': '---', + 'system': false, + 'seporator': true, + 'disabled': true + }); + } + + bSep = false; + aResult.push({ + 'id': oItem.fullNameRaw, + 'name': fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name(), + 'system': true, + 'seporator': false, + 'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) || + (fDisableCallback ? fDisableCallback.call(null, oItem) : false) + }); + } + } + + bSep = true; + for (iIndex = 0, iLen = aList.length; iIndex < iLen; iIndex++) + { + oItem = aList[iIndex]; + if (oItem.subScribed() || !oItem.existen) + { + if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true) + { + if (Enums.FolderType.User === oItem.type() || !bSystem || 0 < oItem.subFolders().length) + { + if (bSep && 0 < aResult.length) + { + aResult.push({ + 'id': '---', + 'name': '---', + 'system': false, + 'seporator': true, + 'disabled': true + }); + } + + bSep = false; + aResult.push({ + 'id': oItem.fullNameRaw, + 'name': (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) + + (fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name()), + 'system': false, + 'seporator': false, + 'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) || + (fDisableCallback ? fDisableCallback.call(null, oItem) : false) + }); + } + } + } + + if (oItem.subScribed() && 0 < oItem.subFolders().length) + { + aResult = aResult.concat(Utils.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [], + iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible)); + } + } + + return aResult; + }; + + Utils.computedPagenatorHelper = function (koCurrentPage, koPageCount) + { + return function() { + + var + iPrev = 0, + iNext = 0, + iLimit = 2, + aResult = [], + iCurrentPage = koCurrentPage(), + iPageCount = koPageCount(), + + /** + * @param {number} iIndex + * @param {boolean=} bPush = true + * @param {string=} sCustomName = '' + */ + fAdd = function (iIndex, bPush, sCustomName) { + + var oData = { + 'current': iIndex === iCurrentPage, + 'name': Utils.isUnd(sCustomName) ? iIndex.toString() : sCustomName.toString(), + 'custom': Utils.isUnd(sCustomName) ? false : true, + 'title': Utils.isUnd(sCustomName) ? '' : iIndex.toString(), + 'value': iIndex.toString() + }; + + if (Utils.isUnd(bPush) ? true : !!bPush) + { + aResult.push(oData); + } + else + { + aResult.unshift(oData); + } + } + ; + + if (1 < iPageCount || (0 < iPageCount && iPageCount < iCurrentPage)) + // if (0 < iPageCount && 0 < iCurrentPage) + { + if (iPageCount < iCurrentPage) + { + fAdd(iPageCount); + iPrev = iPageCount; + iNext = iPageCount; + } + else + { + if (3 >= iCurrentPage || iPageCount - 2 <= iCurrentPage) + { + iLimit += 2; + } + + fAdd(iCurrentPage); + iPrev = iCurrentPage; + iNext = iCurrentPage; + } + + while (0 < iLimit) { + + iPrev -= 1; + iNext += 1; + + if (0 < iPrev) + { + fAdd(iPrev, false); + iLimit--; + } + + if (iPageCount >= iNext) + { + fAdd(iNext, true); + iLimit--; + } + else if (0 >= iPrev) + { + break; + } + } + + if (3 === iPrev) + { + fAdd(2, false); + } + else if (3 < iPrev) + { + fAdd(window.Math.round((iPrev - 1) / 2), false, '...'); + } + + if (iPageCount - 2 === iNext) + { + fAdd(iPageCount - 1, true); + } + else if (iPageCount - 2 > iNext) + { + fAdd(window.Math.round((iPageCount + iNext) / 2), true, '...'); + } + + // first and last + if (1 < iPrev) + { + fAdd(1, false); + } + + if (iPageCount > iNext) + { + fAdd(iPageCount, true); + } + } + + return aResult; + }; + }; + + Utils.selectElement = function (element) + { + var sel, range; + if (window.getSelection) + { + sel = window.getSelection(); + sel.removeAllRanges(); + range = window.document.createRange(); + range.selectNodeContents(element); + sel.addRange(range); + } + else if (window.document.selection) + { + range = window.document.body.createTextRange(); + range.moveToElementText(element); + range.select(); + } + }; + + Utils.detectDropdownVisibility = _.debounce(function () { + Globals.dropdownVisibility(!!_.find(Globals.aBootstrapDropdowns, function (oItem) { + return oItem.hasClass('open'); + })); + }, 50); + + /** + * @param {boolean=} bDelay = false + */ + Utils.triggerAutocompleteInputChange = function (bDelay) { + + var fFunc = function () { + $('.checkAutocomplete').trigger('change'); + }; + + if (Utils.isUnd(bDelay) ? false : !!bDelay) + { + _.delay(fFunc, 100); + } + else + { + fFunc(); + } + }; + + module.exports = Utils; + + }()); + +/***/ }, + +/***/ 2: +/*!********************!*\ + !*** external "_" ***! + \********************/ +/***/ function(module, exports, __webpack_require__) { + + module.exports = _; + +/***/ }, + +/***/ 3: +/*!****************************!*\ + !*** ./dev/External/ko.js ***! + \****************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function (module, ko) { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14) + ; + + ko.bindingHandlers.tooltip = { + 'init': function (oElement, fValueAccessor) { + + var + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + if (!Globals.bMobileDevice) + { + var + $oEl = $(oElement), + sClass = $oEl.data('tooltip-class') || '', + sPlacement = $oEl.data('tooltip-placement') || 'top' + ; + + $oEl.tooltip({ + 'delay': { + 'show': 500, + 'hide': 100 + }, + 'html': true, + 'container': 'body', + 'placement': sPlacement, + 'trigger': 'hover', + 'title': function () { + return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' : '' + + Utils.i18n(ko.utils.unwrapObservable(fValueAccessor())) + ''; + } + }).click(function () { + $oEl.tooltip('hide'); + }); + + Globals.tooltipTrigger.subscribe(function () { + $oEl.tooltip('hide'); + }); + } + } + }; + + ko.bindingHandlers.tooltip2 = { + 'init': function (oElement, fValueAccessor) { + var + Globals = __webpack_require__(/*! Common/Globals */ 7), + $oEl = $(oElement), + sClass = $oEl.data('tooltip-class') || '', + sPlacement = $oEl.data('tooltip-placement') || 'top' + ; + + $oEl.tooltip({ + 'delay': { + 'show': 500, + 'hide': 100 + }, + 'html': true, + 'container': 'body', + 'placement': sPlacement, + 'title': function () { + return $oEl.is('.disabled') || Globals.dropdownVisibility() ? '' : + '' + fValueAccessor()() + ''; + } + }).click(function () { + $oEl.tooltip('hide'); + }); + + Globals.tooltipTrigger.subscribe(function () { + $oEl.tooltip('hide'); + }); + } + }; + + ko.bindingHandlers.tooltip3 = { + 'init': function (oElement) { + + var + $oEl = $(oElement), + Globals = __webpack_require__(/*! Common/Globals */ 7) + ; + + $oEl.tooltip({ + 'container': 'body', + 'trigger': 'hover manual', + 'title': function () { + return $oEl.data('tooltip3-data') || ''; + } + }); + + $(window.document).click(function () { + $oEl.tooltip('hide'); + }); + + Globals.tooltipTrigger.subscribe(function () { + $oEl.tooltip('hide'); + }); + }, + 'update': function (oElement, fValueAccessor) { + var sValue = ko.utils.unwrapObservable(fValueAccessor()); + if ('' === sValue) + { + $(oElement).data('tooltip3-data', '').tooltip('hide'); + } + else + { + $(oElement).data('tooltip3-data', sValue).tooltip('show'); + } + } + }; + + ko.bindingHandlers.registrateBootstrapDropdown = { + 'init': function (oElement) { + var Globals = __webpack_require__(/*! Common/Globals */ 7); + Globals.aBootstrapDropdowns.push($(oElement)); + } + }; + + ko.bindingHandlers.openDropdownTrigger = { + 'update': function (oElement, fValueAccessor) { + if (ko.utils.unwrapObservable(fValueAccessor())) + { + var + $el = $(oElement), + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + if (!$el.hasClass('open')) + { + $el.find('.dropdown-toggle').dropdown('toggle'); + Utils.detectDropdownVisibility(); + } + + fValueAccessor()(false); + } + } + }; + + ko.bindingHandlers.dropdownCloser = { + 'init': function (oElement) { + $(oElement).closest('.dropdown').on('click', '.e-item', function () { + $(oElement).dropdown('toggle'); + }); + } + }; + + ko.bindingHandlers.popover = { + 'init': function (oElement, fValueAccessor) { + $(oElement).popover(ko.utils.unwrapObservable(fValueAccessor())); + } + }; + + ko.bindingHandlers.csstext = { + 'init': function (oElement, fValueAccessor) { + var Utils = __webpack_require__(/*! Common/Utils */ 1); + if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText)) + { + oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor()); + } + else + { + $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); + } + }, + 'update': function (oElement, fValueAccessor) { + var Utils = __webpack_require__(/*! Common/Utils */ 1); + if (oElement && oElement.styleSheet && !Utils.isUnd(oElement.styleSheet.cssText)) + { + oElement.styleSheet.cssText = ko.utils.unwrapObservable(fValueAccessor()); + } + else + { + $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); + } + } + }; + + ko.bindingHandlers.resizecrop = { + 'init': function (oElement) { + $(oElement).addClass('resizecrop').resizecrop({ + 'width': '100', + 'height': '100', + 'wrapperCSS': { + 'border-radius': '10px' + } + }); + }, + 'update': function (oElement, fValueAccessor) { + fValueAccessor()(); + $(oElement).resizecrop({ + 'width': '100', + 'height': '100' + }); + } + }; + + ko.bindingHandlers.onEnter = { + 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { + $(oElement).on('keypress', function (oEvent) { + if (oEvent && 13 === window.parseInt(oEvent.keyCode, 10)) + { + $(oElement).trigger('change'); + fValueAccessor().call(oViewModel); + } + }); + } + }; + + ko.bindingHandlers.onEsc = { + 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { + $(oElement).on('keypress', function (oEvent) { + if (oEvent && 27 === window.parseInt(oEvent.keyCode, 10)) + { + $(oElement).trigger('change'); + fValueAccessor().call(oViewModel); + } + }); + } + }; + + ko.bindingHandlers.clickOnTrue = { + 'update': function (oElement, fValueAccessor) { + if (ko.utils.unwrapObservable(fValueAccessor())) + { + $(oElement).click(); + } + } + }; + + ko.bindingHandlers.modal = { + 'init': function (oElement, fValueAccessor) { + + var + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + $(oElement).toggleClass('fade', !Globals.bMobileDevice).modal({ + 'keyboard': false, + 'show': ko.utils.unwrapObservable(fValueAccessor()) + }) + .on('shown', function () { + Utils.windowResize(); + }) + .find('.close').click(function () { + fValueAccessor()(false); + }); + + }, + 'update': function (oElement, fValueAccessor) { + $(oElement).modal(ko.utils.unwrapObservable(fValueAccessor()) ? 'show' : 'hide'); + } + }; + + ko.bindingHandlers.i18nInit = { + 'init': function (oElement) { + var Utils = __webpack_require__(/*! Common/Utils */ 1); + Utils.i18nToNode(oElement); + } + }; + + ko.bindingHandlers.i18nUpdate = { + 'update': function (oElement, fValueAccessor) { + var Utils = __webpack_require__(/*! Common/Utils */ 1); + ko.utils.unwrapObservable(fValueAccessor()); + Utils.i18nToNode(oElement); + } + }; + + ko.bindingHandlers.link = { + 'update': function (oElement, fValueAccessor) { + $(oElement).attr('href', ko.utils.unwrapObservable(fValueAccessor())); + } + }; + + ko.bindingHandlers.title = { + 'update': function (oElement, fValueAccessor) { + $(oElement).attr('title', ko.utils.unwrapObservable(fValueAccessor())); + } + }; + + ko.bindingHandlers.textF = { + 'init': function (oElement, fValueAccessor) { + $(oElement).text(ko.utils.unwrapObservable(fValueAccessor())); + } + }; + + ko.bindingHandlers.initDom = { + 'init': function (oElement, fValueAccessor) { + fValueAccessor()(oElement); + } + }; + + ko.bindingHandlers.initResizeTrigger = { + 'init': function (oElement, fValueAccessor) { + var aValues = ko.utils.unwrapObservable(fValueAccessor()); + $(oElement).css({ + 'height': aValues[1], + 'min-height': aValues[1] + }); + }, + 'update': function (oElement, fValueAccessor) { + + var + Utils = __webpack_require__(/*! Common/Utils */ 1), + Globals = __webpack_require__(/*! Common/Globals */ 7), + aValues = ko.utils.unwrapObservable(fValueAccessor()), + iValue = Utils.pInt(aValues[1]), + iSize = 0, + iOffset = $(oElement).offset().top + ; + + if (0 < iOffset) + { + iOffset += Utils.pInt(aValues[2]); + iSize = Globals.$win.height() - iOffset; + + if (iValue < iSize) + { + iValue = iSize; + } + + $(oElement).css({ + 'height': iValue, + 'min-height': iValue + }); + } + } + }; + + ko.bindingHandlers.appendDom = { + 'update': function (oElement, fValueAccessor) { + $(oElement).hide().empty().append(ko.utils.unwrapObservable(fValueAccessor())).show(); + } + }; + + ko.bindingHandlers.draggable = { + 'init': function (oElement, fValueAccessor, fAllBindingsAccessor) { + var + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + if (!Globals.bMobileDevice) + { + var + iTriggerZone = 100, + iScrollSpeed = 3, + fAllValueFunc = fAllBindingsAccessor(), + sDroppableSelector = fAllValueFunc && fAllValueFunc['droppableSelector'] ? fAllValueFunc['droppableSelector'] : '', + oConf = { + 'distance': 20, + 'handle': '.dragHandle', + 'cursorAt': {'top': 22, 'left': 3}, + 'refreshPositions': true, + 'scroll': true + } + ; + + if (sDroppableSelector) + { + oConf['drag'] = function (oEvent) { + + $(sDroppableSelector).each(function () { + var + moveUp = null, + moveDown = null, + $this = $(this), + oOffset = $this.offset(), + bottomPos = oOffset.top + $this.height() + ; + + window.clearInterval($this.data('timerScroll')); + $this.data('timerScroll', false); + + if (oEvent.pageX >= oOffset.left && oEvent.pageX <= oOffset.left + $this.width()) + { + if (oEvent.pageY >= bottomPos - iTriggerZone && oEvent.pageY <= bottomPos) + { + moveUp = function() { + $this.scrollTop($this.scrollTop() + iScrollSpeed); + Utils.windowResize(); + }; + + $this.data('timerScroll', window.setInterval(moveUp, 10)); + moveUp(); + } + + if (oEvent.pageY >= oOffset.top && oEvent.pageY <= oOffset.top + iTriggerZone) + { + moveDown = function() { + $this.scrollTop($this.scrollTop() - iScrollSpeed); + Utils.windowResize(); + }; + + $this.data('timerScroll', window.setInterval(moveDown, 10)); + moveDown(); + } + } + }); + }; + + oConf['stop'] = function() { + $(sDroppableSelector).each(function () { + window.clearInterval($(this).data('timerScroll')); + $(this).data('timerScroll', false); + }); + }; + } + + oConf['helper'] = function (oEvent) { + return fValueAccessor()(oEvent && oEvent.target ? ko.dataFor(oEvent.target) : null); + }; + + $(oElement).draggable(oConf).on('mousedown', function () { + Utils.removeInFocus(); + }); + } + } + }; + + ko.bindingHandlers.droppable = { + 'init': function (oElement, fValueAccessor, fAllBindingsAccessor) { + var Globals = __webpack_require__(/*! Common/Globals */ 7); + if (!Globals.bMobileDevice) + { + var + fValueFunc = fValueAccessor(), + fAllValueFunc = fAllBindingsAccessor(), + fOverCallback = fAllValueFunc && fAllValueFunc['droppableOver'] ? fAllValueFunc['droppableOver'] : null, + fOutCallback = fAllValueFunc && fAllValueFunc['droppableOut'] ? fAllValueFunc['droppableOut'] : null, + oConf = { + 'tolerance': 'pointer', + 'hoverClass': 'droppableHover' + } + ; + + if (fValueFunc) + { + oConf['drop'] = function (oEvent, oUi) { + fValueFunc(oEvent, oUi); + }; + + if (fOverCallback) + { + oConf['over'] = function (oEvent, oUi) { + fOverCallback(oEvent, oUi); + }; + } + + if (fOutCallback) + { + oConf['out'] = function (oEvent, oUi) { + fOutCallback(oEvent, oUi); + }; + } + + $(oElement).droppable(oConf); + } + } + } + }; + + ko.bindingHandlers.nano = { + 'init': function (oElement) { + var Globals = __webpack_require__(/*! Common/Globals */ 7); + if (!Globals.bDisableNanoScroll) + { + $(oElement) + .addClass('nano') + .nanoScroller({ + 'iOSNativeScrolling': false, + 'preventPageScrolling': true + }) + ; + } + } + }; + + ko.bindingHandlers.saveTrigger = { + 'init': function (oElement) { + + var $oEl = $(oElement); + + $oEl.data('save-trigger-type', $oEl.is('input[type=text],input[type=email],input[type=password],select,textarea') ? 'input' : 'custom'); + + if ('custom' === $oEl.data('save-trigger-type')) + { + $oEl.append( + '  ' + ).addClass('settings-saved-trigger'); + } + else + { + $oEl.addClass('settings-saved-trigger-input'); + } + }, + 'update': function (oElement, fValueAccessor) { + var + mValue = ko.utils.unwrapObservable(fValueAccessor()), + $oEl = $(oElement) + ; + + if ('custom' === $oEl.data('save-trigger-type')) + { + switch (mValue.toString()) + { + case '1': + $oEl + .find('.animated,.error').hide().removeClass('visible') + .end() + .find('.success').show().addClass('visible') + ; + break; + case '0': + $oEl + .find('.animated,.success').hide().removeClass('visible') + .end() + .find('.error').show().addClass('visible') + ; + break; + case '-2': + $oEl + .find('.error,.success').hide().removeClass('visible') + .end() + .find('.animated').show().addClass('visible') + ; + break; + default: + $oEl + .find('.animated').hide() + .end() + .find('.error,.success').removeClass('visible') + ; + break; + } + } + else + { + switch (mValue.toString()) + { + case '1': + $oEl.addClass('success').removeClass('error'); + break; + case '0': + $oEl.addClass('error').removeClass('success'); + break; + case '-2': + // $oEl; + break; + default: + $oEl.removeClass('error success'); + break; + } + } + } + }; + + ko.bindingHandlers.emailsTags = { + 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { + + var + Utils = __webpack_require__(/*! Common/Utils */ 1), + EmailModel = __webpack_require__(/*! Model:Email */ 23), + + $oEl = $(oElement), + fValue = fValueAccessor(), + fAllBindings = fAllBindingsAccessor(), + fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null, + fFocusCallback = function (bValue) { + if (fValue && fValue.focusTrigger) + { + fValue.focusTrigger(bValue); + } + } + ; + + $oEl.inputosaurus({ + 'parseOnBlur': true, + 'allowDragAndDrop': true, + 'focusCallback': fFocusCallback, + 'inputDelimiters': [',', ';'], + 'autoCompleteSource': fAutoCompleteSource, + 'parseHook': function (aInput) { + return _.map(aInput, function (sInputValue) { + + var + sValue = Utils.trim(sInputValue), + oEmail = null + ; + + if ('' !== sValue) + { + oEmail = new EmailModel(); + oEmail.mailsoParse(sValue); + oEmail.clearDuplicateName(); + return [oEmail.toLine(false), oEmail]; + } + + return [sValue, null]; + + }); + }, + 'change': _.bind(function (oEvent) { + $oEl.data('EmailsTagsValue', oEvent.target.value); + fValue(oEvent.target.value); + }, this) + }); + }, + 'update': function (oElement, fValueAccessor, fAllBindingsAccessor) { + + var + $oEl = $(oElement), + fAllValueFunc = fAllBindingsAccessor(), + fEmailsTagsFilter = fAllValueFunc['emailsTagsFilter'] || null, + sValue = ko.utils.unwrapObservable(fValueAccessor()) + ; + + if ($oEl.data('EmailsTagsValue') !== sValue) + { + $oEl.val(sValue); + $oEl.data('EmailsTagsValue', sValue); + $oEl.inputosaurus('refresh'); + } + + if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter)) + { + $oEl.inputosaurus('focus'); + } + } + }; + + ko.bindingHandlers.contactTags = { + 'init': function(oElement, fValueAccessor, fAllBindingsAccessor) { + + var + Utils = __webpack_require__(/*! Common/Utils */ 1), + ContactTagModel = __webpack_require__(/*! Model:ContactTag */ 37), + + $oEl = $(oElement), + fValue = fValueAccessor(), + fAllBindings = fAllBindingsAccessor(), + fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null, + fFocusCallback = function (bValue) { + if (fValue && fValue.focusTrigger) + { + fValue.focusTrigger(bValue); + } + } + ; + + $oEl.inputosaurus({ + 'parseOnBlur': true, + 'allowDragAndDrop': false, + 'focusCallback': fFocusCallback, + 'inputDelimiters': [',', ';'], + 'outputDelimiter': ',', + 'autoCompleteSource': fAutoCompleteSource, + '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('ContactTagsValue', oEvent.target.value); + fValue(oEvent.target.value); + }, this) + }); + }, + 'update': function (oElement, fValueAccessor, fAllBindingsAccessor) { + + var + $oEl = $(oElement), + fAllValueFunc = fAllBindingsAccessor(), + fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null, + sValue = ko.utils.unwrapObservable(fValueAccessor()) + ; + + if ($oEl.data('ContactTagsValue') !== sValue) + { + $oEl.val(sValue); + $oEl.data('ContactTagsValue', sValue); + $oEl.inputosaurus('refresh'); + } + + if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter)) + { + $oEl.inputosaurus('focus'); + } + } + }; + + ko.bindingHandlers.command = { + 'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { + var + jqElement = $(oElement), + oCommand = fValueAccessor() + ; + + if (!oCommand || !oCommand.enabled || !oCommand.canExecute) + { + throw new Error('You are not using command function'); + } + + jqElement.addClass('command'); + ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click'].init.apply(oViewModel, arguments); + }, + + 'update': function (oElement, fValueAccessor) { + + var + bResult = true, + jqElement = $(oElement), + oCommand = fValueAccessor() + ; + + bResult = oCommand.enabled(); + jqElement.toggleClass('command-not-enabled', !bResult); + + if (bResult) + { + bResult = oCommand.canExecute(); + jqElement.toggleClass('command-can-not-be-execute', !bResult); + } + + jqElement.toggleClass('command-disabled disable disabled', !bResult).toggleClass('no-disabled', !!bResult); + + if (jqElement.is('input') || jqElement.is('button')) + { + jqElement.prop('disabled', !bResult); + } + } + }; + + ko.extenders.trimmer = function (oTarget) + { + var + Utils = __webpack_require__(/*! Common/Utils */ 1), + oResult = ko.computed({ + 'read': oTarget, + 'write': function (sNewValue) { + oTarget(Utils.trim(sNewValue.toString())); + }, + 'owner': this + }) + ; + + oResult(oTarget()); + return oResult; + }; + + ko.extenders.posInterer = function (oTarget, iDefault) + { + var + Utils = __webpack_require__(/*! Common/Utils */ 1), + oResult = ko.computed({ + 'read': oTarget, + 'write': function (sNewValue) { + var iNew = Utils.pInt(sNewValue.toString(), iDefault); + if (0 >= iNew) + { + iNew = iDefault; + } + + if (iNew === oTarget() && '' + iNew !== '' + sNewValue) + { + oTarget(iNew + 1); + } + + oTarget(iNew); + } + }) + ; + + oResult(oTarget()); + return oResult; + }; + + ko.extenders.reversible = function (oTarget) + { + var mValue = oTarget(); + + oTarget.commit = function () + { + mValue = oTarget(); + }; + + oTarget.reverse = function () + { + oTarget(mValue); + }; + + oTarget.commitedValue = function () + { + return mValue; + }; + + return oTarget; + }; + + ko.extenders.toggleSubscribe = function (oTarget, oOptions) + { + oTarget.subscribe(oOptions[1], oOptions[0], 'beforeChange'); + oTarget.subscribe(oOptions[2], oOptions[0]); + + return oTarget; + }; + + ko.extenders.falseTimeout = function (oTarget, iOption) + { + var Utils = __webpack_require__(/*! Common/Utils */ 1); + + oTarget.iTimeout = 0; + oTarget.subscribe(function (bValue) { + if (bValue) + { + window.clearTimeout(oTarget.iTimeout); + oTarget.iTimeout = window.setTimeout(function () { + oTarget(false); + oTarget.iTimeout = 0; + }, Utils.pInt(iOption)); + } + }); + + return oTarget; + }; + + ko.observable.fn.validateNone = function () + { + this.hasError = ko.observable(false); + return this; + }; + + ko.observable.fn.validateEmail = function () + { + var Utils = __webpack_require__(/*! Common/Utils */ 1); + + this.hasError = ko.observable(false); + + this.subscribe(function (sValue) { + sValue = Utils.trim(sValue); + this.hasError('' !== sValue && !(/^[^@\s]+@[^@\s]+$/.test(sValue))); + }, this); + + this.valueHasMutated(); + return this; + }; + + ko.observable.fn.validateSimpleEmail = function () + { + var Utils = __webpack_require__(/*! Common/Utils */ 1); + + this.hasError = ko.observable(false); + + this.subscribe(function (sValue) { + sValue = Utils.trim(sValue); + this.hasError('' !== sValue && !(/^.+@.+$/.test(sValue))); + }, this); + + this.valueHasMutated(); + return this; + }; + + ko.observable.fn.validateFunc = function (fFunc) + { + var Utils = __webpack_require__(/*! Common/Utils */ 1); + + this.hasFuncError = ko.observable(false); + + if (Utils.isFunc(fFunc)) + { + this.subscribe(function (sValue) { + this.hasFuncError(!fFunc(sValue)); + }, this); + + this.valueHasMutated(); + } + + return this; + }; + + module.exports = ko; + + }(module, ko)); + + +/***/ }, + +/***/ 5: +/*!****************************!*\ + !*** ./dev/Knoin/Knoin.js ***! + \****************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + hasher = __webpack_require__(/*! hasher */ 115), + crossroads = __webpack_require__(/*! crossroads */ 48), + + Globals = __webpack_require__(/*! Common/Globals */ 7), + Plugins = __webpack_require__(/*! Common/Plugins */ 26), + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + */ + function Knoin() + { + this.oScreens = {}; + this.sDefaultScreenName = ''; + this.oCurrentScreen = null; + } + + Knoin.prototype.oScreens = {}; + Knoin.prototype.sDefaultScreenName = ''; + Knoin.prototype.oCurrentScreen = null; + + Knoin.prototype.hideLoading = function () + { + $('#rl-loading').hide(); + }; + + /** + * @param {Object} thisObject + */ + Knoin.prototype.constructorEnd = function (thisObject) + { + if (Utils.isFunc(thisObject['__constructor_end'])) + { + thisObject['__constructor_end'].call(thisObject); + } + }; + + /** + * @param {string|Array} mName + * @param {Function} ViewModelClass + */ + Knoin.prototype.extendAsViewModel = function (mName, ViewModelClass) + { + if (ViewModelClass) + { + if (Utils.isArray(mName)) + { + ViewModelClass.__names = mName; + } + else + { + ViewModelClass.__names = [mName]; + } + + ViewModelClass.__name = ViewModelClass.__names[0]; + } + }; + + /** + * @param {Function} SettingsViewModelClass + * @param {string} sLabelName + * @param {string} sTemplate + * @param {string} sRoute + * @param {boolean=} bDefault + */ + Knoin.prototype.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute, bDefault) + { + SettingsViewModelClass.__rlSettingsData = { + 'Label': sLabelName, + 'Template': sTemplate, + 'Route': sRoute, + 'IsDefault': !!bDefault + }; + + Globals.aViewModels['settings'].push(SettingsViewModelClass); + }; + + /** + * @param {Function} SettingsViewModelClass + */ + Knoin.prototype.removeSettingsViewModel = function (SettingsViewModelClass) + { + Globals.aViewModels['settings-removed'].push(SettingsViewModelClass); + }; + + /** + * @param {Function} SettingsViewModelClass + */ + Knoin.prototype.disableSettingsViewModel = function (SettingsViewModelClass) + { + Globals.aViewModels['settings-disabled'].push(SettingsViewModelClass); + }; + + Knoin.prototype.routeOff = function () + { + hasher.changed.active = false; + }; + + Knoin.prototype.routeOn = function () + { + hasher.changed.active = true; + }; + + /** + * @param {string} sScreenName + * @return {?Object} + */ + Knoin.prototype.screen = function (sScreenName) + { + return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null; + }; + + /** + * @param {Function} ViewModelClass + * @param {Object=} oScreen + */ + Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen) + { + if (ViewModelClass && !ViewModelClass.__builded) + { + var + kn = this, + oViewModel = new ViewModelClass(oScreen), + sPosition = oViewModel.viewModelPosition(), + oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()), + oViewModelDom = null + ; + + ViewModelClass.__builded = true; + ViewModelClass.__vm = oViewModel; + + oViewModel.viewModelName = ViewModelClass.__name; + oViewModel.viewModelNames = ViewModelClass.__names; + + if (oViewModelPlace && 1 === oViewModelPlace.length) + { + oViewModelDom = $('
').addClass('rl-view-model').addClass('RL-' + oViewModel.viewModelTemplate()).hide(); + oViewModelDom.appendTo(oViewModelPlace); + + oViewModel.viewModelDom = oViewModelDom; + ViewModelClass.__dom = oViewModelDom; + + if ('Popups' === sPosition) + { + oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, function () { + kn.hideScreenPopup(ViewModelClass); + }); + + oViewModel.modalVisibility.subscribe(function (bValue) { + + var self = this; + if (bValue) + { + this.viewModelDom.show(); + this.storeAndSetKeyScope(); + + Globals.popupVisibilityNames.push(this.viewModelName); + oViewModel.viewModelDom.css('z-index', 3000 + Globals.popupVisibilityNames().length + 10); + + Utils.delegateRun(this, 'onFocus', [], 500); + } + else + { + Utils.delegateRun(this, 'onHide'); + this.restoreKeyScope(); + + _.each(this.viewModelNames, function (sName) { + Plugins.runHook('view-model-on-hide', [sName, self]); + }); + + Globals.popupVisibilityNames.remove(this.viewModelName); + oViewModel.viewModelDom.css('z-index', 2000); + + Globals.tooltipTrigger(!Globals.tooltipTrigger()); + + _.delay(function () { + self.viewModelDom.hide(); + }, 300); + } + + }, oViewModel); + } + + _.each(ViewModelClass.__names, function (sName) { + Plugins.runHook('view-model-pre-build', [sName, oViewModel, oViewModelDom]); + }); + + ko.applyBindingAccessorsToNode(oViewModelDom[0], { + 'i18nInit': true, + 'template': function () { return {'name': oViewModel.viewModelTemplate()};} + }, oViewModel); + + Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]); + if (oViewModel && 'Popups' === sPosition) + { + oViewModel.registerPopupKeyDown(); + } + + _.each(ViewModelClass.__names, function (sName) { + Plugins.runHook('view-model-post-build', [sName, oViewModel, oViewModelDom]); + }); + } + else + { + Utils.log('Cannot find view model position: ' + sPosition); + } + } + + return ViewModelClass ? ViewModelClass.__vm : null; + }; + + /** + * @param {Function} ViewModelClassToHide + */ + Knoin.prototype.hideScreenPopup = function (ViewModelClassToHide) + { + if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) + { + ViewModelClassToHide.__vm.modalVisibility(false); + } + }; + + /** + * @param {Function} ViewModelClassToShow + * @param {Array=} aParameters + */ + Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters) + { + if (ViewModelClassToShow) + { + this.buildViewModel(ViewModelClassToShow); + + if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom) + { + ViewModelClassToShow.__vm.modalVisibility(true); + Utils.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []); + + _.each(ViewModelClassToShow.__names, function (sName) { + Plugins.runHook('view-model-on-show', [sName, ViewModelClassToShow.__vm, aParameters || []]); + }); + } + } + }; + + /** + * @param {Function} ViewModelClassToShow + * @return {boolean} + */ + Knoin.prototype.isPopupVisible = function (ViewModelClassToShow) + { + return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false; + }; + + /** + * @param {string} sScreenName + * @param {string} sSubPart + */ + Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart) + { + var + self = this, + oScreen = null, + oCross = null + ; + + if ('' === Utils.pString(sScreenName)) + { + sScreenName = this.sDefaultScreenName; + } + + if ('' !== sScreenName) + { + oScreen = this.screen(sScreenName); + if (!oScreen) + { + oScreen = this.screen(this.sDefaultScreenName); + if (oScreen) + { + sSubPart = sScreenName + '/' + sSubPart; + sScreenName = this.sDefaultScreenName; + } + } + + if (oScreen && oScreen.__started) + { + if (!oScreen.__builded) + { + oScreen.__builded = true; + + if (Utils.isNonEmptyArray(oScreen.viewModels())) + { + _.each(oScreen.viewModels(), function (ViewModelClass) { + this.buildViewModel(ViewModelClass, oScreen); + }, this); + } + + Utils.delegateRun(oScreen, 'onBuild'); + } + + _.defer(function () { + + // hide screen + if (self.oCurrentScreen) + { + Utils.delegateRun(self.oCurrentScreen, 'onHide'); + + if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels())) + { + _.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) { + + if (ViewModelClass.__vm && ViewModelClass.__dom && + 'Popups' !== ViewModelClass.__vm.viewModelPosition()) + { + ViewModelClass.__dom.hide(); + ViewModelClass.__vm.viewModelVisibility(false); + Utils.delegateRun(ViewModelClass.__vm, 'onHide'); + } + + }); + } + } + // -- + + self.oCurrentScreen = oScreen; + + // show screen + if (self.oCurrentScreen) + { + Utils.delegateRun(self.oCurrentScreen, 'onShow'); + + Plugins.runHook('screen-on-show', [self.oCurrentScreen.screenName(), self.oCurrentScreen]); + + if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels())) + { + _.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) { + + if (ViewModelClass.__vm && ViewModelClass.__dom && + 'Popups' !== ViewModelClass.__vm.viewModelPosition()) + { + ViewModelClass.__dom.show(); + ViewModelClass.__vm.viewModelVisibility(true); + + Utils.delegateRun(ViewModelClass.__vm, 'onShow'); + Utils.delegateRun(ViewModelClass.__vm, 'onFocus', [], 200); + + _.each(ViewModelClass.__names, function (sName) { + Plugins.runHook('view-model-on-show', [sName, ViewModelClass.__vm]); + }); + } + + }, self); + } + } + // -- + + oCross = oScreen.__cross ? oScreen.__cross() : null; + if (oCross) + { + oCross.parse(sSubPart); + } + }); + } + } + }; + + /** + * @param {Array} aScreensClasses + */ + Knoin.prototype.startScreens = function (aScreensClasses) + { + $('#rl-content').css({ + 'visibility': 'hidden' + }); + + _.each(aScreensClasses, function (CScreen) { + + var + oScreen = new CScreen(), + sScreenName = oScreen ? oScreen.screenName() : '' + ; + + if (oScreen && '' !== sScreenName) + { + if ('' === this.sDefaultScreenName) + { + this.sDefaultScreenName = sScreenName; + } + + this.oScreens[sScreenName] = oScreen; + } + + }, this); + + + _.each(this.oScreens, function (oScreen) { + if (oScreen && !oScreen.__started && oScreen.__start) + { + 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]); + } + }, this); + + var oCross = crossroads.create(); + oCross.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/, _.bind(this.screenOnRoute, this)); + + hasher.initialized.add(oCross.parse, oCross); + hasher.changed.add(oCross.parse, oCross); + hasher.init(); + + $('#rl-content').css({ + 'visibility': 'visible' + }); + + _.delay(function () { + Globals.$html.removeClass('rl-started-trigger').addClass('rl-started'); + }, 50); + }; + + /** + * @param {string} sHash + * @param {boolean=} bSilence = false + * @param {boolean=} bReplace = false + */ + Knoin.prototype.setHash = function (sHash, bSilence, bReplace) + { + sHash = '#' === sHash.substr(0, 1) ? sHash.substr(1) : sHash; + sHash = '/' === sHash.substr(0, 1) ? sHash.substr(1) : sHash; + + bReplace = Utils.isUnd(bReplace) ? false : !!bReplace; + + if (Utils.isUnd(bSilence) ? false : !!bSilence) + { + hasher.changed.active = false; + hasher[bReplace ? 'replaceHash' : 'setHash'](sHash); + hasher.changed.active = true; + } + else + { + hasher.changed.active = true; + hasher[bReplace ? 'replaceHash' : 'setHash'](sHash); + hasher.setHash(sHash); + } + }; + + module.exports = new Knoin(); + + }()); + +/***/ }, + +/***/ 6: +/*!*****************************!*\ + !*** ./dev/Common/Enums.js ***! + \*****************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var Enums = {}; + + /** + * @enum {string} + */ + Enums.StorageResultType = { + 'Success': 'success', + 'Abort': 'abort', + 'Error': 'error', + 'Unload': 'unload' + }; + + /** + * @enum {number} + */ + Enums.State = { + 'Empty': 10, + 'Login': 20, + 'Auth': 30 + }; + + /** + * @enum {number} + */ + Enums.StateType = { + 'Webmail': 0, + 'Admin': 1 + }; + + /** + * @enum {string} + */ + Enums.Capa = { + 'Prem': 'PREM', + 'TwoFactor': 'TWO_FACTOR', + 'OpenPGP': 'OPEN_PGP', + 'Prefetch': 'PREFETCH', + 'Gravatar': 'GRAVATAR', + 'Themes': 'THEMES', + 'Filters': 'FILTERS', + 'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS', + 'AdditionalIdentities': 'ADDITIONAL_IDENTITIES' + }; + + /** + * @enum {string} + */ + Enums.KeyState = { + 'All': 'all', + 'None': 'none', + 'ContactList': 'contact-list', + 'MessageList': 'message-list', + 'FolderList': 'folder-list', + 'MessageView': 'message-view', + 'Compose': 'compose', + 'Settings': 'settings', + 'Menu': 'menu', + 'PopupComposeOpenPGP': 'compose-open-pgp', + 'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help', + 'PopupAsk': 'popup-ask' + }; + + /** + * @enum {number} + */ + Enums.FolderType = { + 'Inbox': 10, + 'SentItems': 11, + 'Draft': 12, + 'Trash': 13, + 'Spam': 14, + 'Archive': 15, + 'NotSpam': 80, + 'User': 99 + }; + + /** + * @enum {string} + */ + Enums.LoginSignMeTypeAsString = { + 'DefaultOff': 'defaultoff', + 'DefaultOn': 'defaulton', + 'Unused': 'unused' + }; + + /** + * @enum {number} + */ + Enums.LoginSignMeType = { + 'DefaultOff': 0, + 'DefaultOn': 1, + 'Unused': 2 + }; + + /** + * @enum {string} + */ + Enums.ComposeType = { + 'Empty': 'empty', + 'Reply': 'reply', + 'ReplyAll': 'replyall', + 'Forward': 'forward', + 'ForwardAsAttachment': 'forward-as-attachment', + 'Draft': 'draft', + 'EditAsNew': 'editasnew' + }; + + /** + * @enum {number} + */ + Enums.UploadErrorCode = { + 'Normal': 0, + 'FileIsTooBig': 1, + 'FilePartiallyUploaded': 2, + 'FileNoUploaded': 3, + 'MissingTempFolder': 4, + 'FileOnSaveingError': 5, + 'FileType': 98, + 'Unknown': 99 + }; + + /** + * @enum {number} + */ + Enums.SetSystemFoldersNotification = { + 'None': 0, + 'Sent': 1, + 'Draft': 2, + 'Spam': 3, + 'Trash': 4, + 'Archive': 5 + }; + + /** + * @enum {number} + */ + Enums.ClientSideKeyName = { + 'FoldersLashHash': 0, + 'MessagesInboxLastHash': 1, + 'MailBoxListSize': 2, + 'ExpandedFolders': 3, + 'FolderListSize': 4 + }; + + /** + * @enum {number} + */ + Enums.EventKeyCode = { + 'Backspace': 8, + 'Tab': 9, + 'Enter': 13, + 'Esc': 27, + 'PageUp': 33, + 'PageDown': 34, + 'Left': 37, + 'Right': 39, + 'Up': 38, + 'Down': 40, + 'End': 35, + 'Home': 36, + 'Space': 32, + 'Insert': 45, + 'Delete': 46, + 'A': 65, + 'S': 83 + }; + + /** + * @enum {number} + */ + Enums.MessageSetAction = { + 'SetSeen': 0, + 'UnsetSeen': 1, + 'SetFlag': 2, + 'UnsetFlag': 3 + }; + + /** + * @enum {number} + */ + Enums.MessageSelectAction = { + 'All': 0, + 'None': 1, + 'Invert': 2, + 'Unseen': 3, + 'Seen': 4, + 'Flagged': 5, + 'Unflagged': 6 + }; + + /** + * @enum {number} + */ + Enums.DesktopNotifications = { + 'Allowed': 0, + 'NotAllowed': 1, + 'Denied': 2, + 'NotSupported': 9 + }; + + /** + * @enum {number} + */ + Enums.MessagePriority = { + 'Low': 5, + 'Normal': 3, + 'High': 1 + }; + + /** + * @enum {string} + */ + Enums.EditorDefaultType = { + 'Html': 'Html', + 'Plain': 'Plain' + }; + + /** + * @enum {string} + */ + Enums.CustomThemeType = { + 'Light': 'Light', + 'Dark': 'Dark' + }; + + /** + * @enum {number} + */ + Enums.ServerSecure = { + 'None': 0, + 'SSL': 1, + 'TLS': 2 + }; + + /** + * @enum {number} + */ + Enums.SearchDateType = { + 'All': -1, + 'Days3': 3, + 'Days7': 7, + 'Month': 30 + }; + + /** + * @enum {number} + */ + Enums.SaveSettingsStep = { + 'Animate': -2, + 'Idle': -1, + 'TrueResult': 1, + 'FalseResult': 0 + }; + + /** + * @enum {string} + */ + Enums.InterfaceAnimation = { + 'None': 'None', + 'Normal': 'Normal', + 'Full': 'Full' + }; + + /** + * @enum {number} + */ + Enums.Layout = { + 'NoPreview': 0, + 'SidePreview': 1, + 'BottomPreview': 2 + }; + + /** + * @enum {string} + */ + Enums.FilterConditionField = { + 'From': 'From', + 'To': 'To', + 'Recipient': 'Recipient', + 'Subject': 'Subject' + }; + + /** + * @enum {string} + */ + Enums.FilterConditionType = { + 'Contains': 'Contains', + 'NotContains': 'NotContains', + 'EqualTo': 'EqualTo', + 'NotEqualTo': 'NotEqualTo' + }; + + /** + * @enum {string} + */ + Enums.FiltersAction = { + 'None': 'None', + 'Move': 'Move', + 'Discard': 'Discard', + 'Forward': 'Forward' + }; + + /** + * @enum {string} + */ + Enums.FilterRulesType = { + 'And': 'And', + 'Or': 'Or' + }; + + /** + * @enum {number} + */ + Enums.SignedVerifyStatus = { + 'UnknownPublicKeys': -4, + 'UnknownPrivateKey': -3, + 'Unverified': -2, + 'Error': -1, + 'None': 0, + 'Success': 1 + }; + + /** + * @enum {number} + */ + Enums.ContactPropertyType = { + + 'Unknown': 0, + + 'FullName': 10, + + 'FirstName': 15, + 'LastName': 16, + 'MiddleName': 16, + 'Nick': 18, + + 'NamePrefix': 20, + 'NameSuffix': 21, + + 'Email': 30, + 'Phone': 31, + 'Web': 32, + + 'Birthday': 40, + + 'Facebook': 90, + 'Skype': 91, + 'GitHub': 92, + + 'Note': 110, + + 'Custom': 250 + }; + + /** + * @enum {number} + */ + Enums.Notification = { + 'InvalidToken': 101, + 'AuthError': 102, + 'AccessError': 103, + 'ConnectionError': 104, + 'CaptchaError': 105, + 'SocialFacebookLoginAccessDisable': 106, + 'SocialTwitterLoginAccessDisable': 107, + 'SocialGoogleLoginAccessDisable': 108, + 'DomainNotAllowed': 109, + 'AccountNotAllowed': 110, + + 'AccountTwoFactorAuthRequired': 120, + 'AccountTwoFactorAuthError': 121, + + 'CouldNotSaveNewPassword': 130, + 'CurrentPasswordIncorrect': 131, + 'NewPasswordShort': 132, + 'NewPasswordWeak': 133, + 'NewPasswordForbidden': 134, + + 'ContactsSyncError': 140, + + 'CantGetMessageList': 201, + 'CantGetMessage': 202, + 'CantDeleteMessage': 203, + 'CantMoveMessage': 204, + 'CantCopyMessage': 205, + + 'CantSaveMessage': 301, + 'CantSendMessage': 302, + 'InvalidRecipients': 303, + + 'CantCreateFolder': 400, + 'CantRenameFolder': 401, + 'CantDeleteFolder': 402, + 'CantSubscribeFolder': 403, + 'CantUnsubscribeFolder': 404, + 'CantDeleteNonEmptyFolder': 405, + + 'CantSaveSettings': 501, + 'CantSavePluginSettings': 502, + + 'DomainAlreadyExists': 601, + + 'CantInstallPackage': 701, + 'CantDeletePackage': 702, + 'InvalidPluginPackage': 703, + 'UnsupportedPluginPackage': 704, + + 'LicensingServerIsUnavailable': 710, + 'LicensingExpired': 711, + 'LicensingBanned': 712, + + 'DemoSendMessageError': 750, + + 'AccountAlreadyExists': 801, + + 'MailServerError': 901, + 'ClientViewError': 902, + 'InvalidInputArgument': 903, + 'UnknownNotification': 999, + 'UnknownError': 999 + }; + + module.exports = Enums; + + }()); + +/***/ }, + +/***/ 7: +/*!*******************************!*\ + !*** ./dev/Common/Globals.js ***! + \*******************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + Globals = {}, + + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Enums = __webpack_require__(/*! Common/Enums */ 6) + ; + + Globals.$win = $(window); + Globals.$doc = $(window.document); + Globals.$html = $('html'); + Globals.$div = $('
'); + + /** + * @type {?} + */ + Globals.now = (new window.Date()).getTime(); + + /** + * @type {?} + */ + Globals.momentTrigger = ko.observable(true); + + /** + * @type {?} + */ + Globals.dropdownVisibility = ko.observable(false).extend({'rateLimit': 0}); + + /** + * @type {?} + */ + Globals.tooltipTrigger = ko.observable(false).extend({'rateLimit': 0}); + + /** + * @type {?} + */ + Globals.langChangeTrigger = ko.observable(true); + + /** + * @type {boolean} + */ + Globals.useKeyboardShortcuts = ko.observable(true); + + /** + * @type {number} + */ + Globals.iAjaxErrorCount = 0; + + /** + * @type {number} + */ + Globals.iTokenErrorCount = 0; + + /** + * @type {number} + */ + Globals.iMessageBodyCacheCount = 0; + + /** + * @type {boolean} + */ + Globals.bUnload = false; + + /** + * @type {string} + */ + Globals.sUserAgent = (window.navigator.userAgent || '').toLowerCase(); + + /** + * @type {boolean} + */ + Globals.bIsiOSDevice = -1 < Globals.sUserAgent.indexOf('iphone') || -1 < Globals.sUserAgent.indexOf('ipod') || -1 < Globals.sUserAgent.indexOf('ipad'); + + /** + * @type {boolean} + */ + Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android'); + + /** + * @type {boolean} + */ + Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice; + + /** + * @type {boolean} + */ + Globals.bDisableNanoScroll = Globals.bMobileDevice; + + /** + * @type {boolean} + */ + Globals.bAllowPdfPreview = !Globals.bMobileDevice; + + /** + * @type {boolean} + */ + Globals.bAnimationSupported = !Globals.bMobileDevice && Globals.$html.hasClass('csstransitions'); + + /** + * @type {boolean} + */ + Globals.bXMLHttpRequestSupported = !!window.XMLHttpRequest; + + /** + * @type {string} + */ + Globals.sAnimationType = ''; + + /** + * @type {*} + */ + Globals.__APP = null; + + /** + * @type {Object} + */ + Globals.oHtmlEditorDefaultConfig = { + 'title': false, + 'stylesSet': false, + 'customConfig': '', + 'contentsCss': '', + 'toolbarGroups': [ + {name: 'spec'}, + {name: 'styles'}, + {name: 'basicstyles', groups: ['basicstyles', 'cleanup']}, + {name: 'colors'}, + {name: 'paragraph', groups: ['list', 'indent', 'blocks', 'align']}, + {name: 'links'}, + {name: 'insert'}, + {name: 'others'} + // {name: 'document', groups: ['mode', 'document', 'doctools']} + ], + + 'removePlugins': 'contextmenu', //blockquote + 'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll', + 'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced', + + 'extraPlugins': 'plain', + + 'allowedContent': true, + 'autoParagraph': false, + + 'font_defaultLabel': 'Arial', + 'fontSize_defaultLabel': '13', + 'fontSize_sizes': '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px' + }; + + /** + * @type {Object} + */ + Globals.oHtmlEditorLangsMap = { + 'de': 'de', + 'es': 'es', + 'fr': 'fr', + 'hu': 'hu', + 'is': 'is', + 'it': 'it', + 'ja': 'ja', + 'ja-jp': 'ja', + 'ko': 'ko', + 'ko-kr': 'ko', + 'lv': 'lv', + 'nl': 'nl', + 'no': 'no', + 'pl': 'pl', + 'pt': 'pt', + 'pt-pt': 'pt', + 'pt-br': 'pt-br', + 'ro': 'ro', + 'ru': 'ru', + 'sk': 'sk', + 'tr': 'tr', + 'ua': 'ru', + 'zh': 'zh', + 'zh-cn': 'zh-cn' + }; + + if (Globals.bAllowPdfPreview && window.navigator && window.navigator.mimeTypes) + { + Globals.bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function (oType) { + return oType && 'application/pdf' === oType.type; + }); + } + + Globals.oI18N = window['rainloopI18N'] || {}; + + Globals.oNotificationI18N = {}; + + Globals.aBootstrapDropdowns = []; + + Globals.aViewModels = { + 'settings': [], + 'settings-removed': [], + 'settings-disabled': [] + }; + + Globals.leftPanelDisabled = ko.observable(false); + + // popups + Globals.popupVisibilityNames = ko.observableArray([]); + + Globals.popupVisibility = ko.computed(function () { + return 0 < Globals.popupVisibilityNames().length; + }, this); + + // keys + Globals.keyScopeReal = ko.observable(Enums.KeyState.All); + Globals.keyScopeFake = ko.observable(Enums.KeyState.All); + + Globals.keyScope = ko.computed({ + 'owner': this, + 'read': function () { + return Globals.keyScopeFake(); + }, + 'write': function (sValue) { + + if (Enums.KeyState.Menu !== sValue) + { + if (Enums.KeyState.Compose === sValue) + { + // disableKeyFilter + key.filter = function () { + return Globals.useKeyboardShortcuts(); + }; + } + else + { + // restoreKeyFilter + key.filter = function (event) { + + if (Globals.useKeyboardShortcuts()) + { + var + oElement = event.target || event.srcElement, + sTagName = oElement ? oElement.tagName : '' + ; + + sTagName = sTagName.toUpperCase(); + return !(sTagName === 'INPUT' || sTagName === 'SELECT' || sTagName === 'TEXTAREA' || + (oElement && sTagName === 'DIV' && 'editorHtmlArea' === oElement.className && oElement.contentEditable) + ); + } + + return false; + }; + } + + Globals.keyScopeFake(sValue); + if (Globals.dropdownVisibility()) + { + sValue = Enums.KeyState.Menu; + } + } + + Globals.keyScopeReal(sValue); + } + }); + + Globals.keyScopeReal.subscribe(function (sValue) { + // window.console.log(sValue); + key.setScope(sValue); + }); + + Globals.dropdownVisibility.subscribe(function (bValue) { + if (bValue) + { + Globals.tooltipTrigger(!Globals.tooltipTrigger()); + Globals.keyScope(Enums.KeyState.Menu); + } + else if (Enums.KeyState.Menu === key.getScope()) + { + Globals.keyScope(Globals.keyScopeFake()); + } + }); + + module.exports = Globals; + + }()); + +/***/ }, + +/***/ 9: +/*!*********************************************!*\ + !*** ./dev/Knoin/KnoinAbstractViewModel.js ***! + \*********************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + ko = __webpack_require__(/*! ko */ 3), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + Globals = __webpack_require__(/*! Common/Globals */ 7) + ; + + /** + * @constructor + * @param {string=} sPosition = '' + * @param {string=} sTemplate = '' + */ + function KnoinAbstractViewModel(sPosition, sTemplate) + { + this.bDisabeCloseOnEsc = false; + this.sPosition = Utils.pString(sPosition); + this.sTemplate = Utils.pString(sTemplate); + + this.sDefaultKeyScope = Enums.KeyState.None; + this.sCurrentKeyScope = this.sDefaultKeyScope; + + this.viewModelVisibility = ko.observable(false); + this.modalVisibility = ko.observable(false).extend({'rateLimit': 0}); + + this.viewModelName = ''; + this.viewModelNames = []; + this.viewModelDom = null; + } + + /** + * @type {boolean} + */ + KnoinAbstractViewModel.prototype.bDisabeCloseOnEsc = false; + + /** + * @type {string} + */ + KnoinAbstractViewModel.prototype.sPosition = ''; + + /** + * @type {string} + */ + KnoinAbstractViewModel.prototype.sTemplate = ''; + + /** + * @type {string} + */ + KnoinAbstractViewModel.prototype.sDefaultKeyScope = Enums.KeyState.None; + + /** + * @type {string} + */ + KnoinAbstractViewModel.prototype.sCurrentKeyScope = Enums.KeyState.None; + + /** + * @type {string} + */ + KnoinAbstractViewModel.prototype.viewModelName = ''; + + /** + * @type {Array} + */ + KnoinAbstractViewModel.prototype.viewModelNames = []; + + /** + * @type {?} + */ + KnoinAbstractViewModel.prototype.viewModelDom = null; + + /** + * @return {string} + */ + KnoinAbstractViewModel.prototype.viewModelTemplate = function () + { + return this.sTemplate; + }; + + /** + * @return {string} + */ + KnoinAbstractViewModel.prototype.viewModelPosition = function () + { + return this.sPosition; + }; + + KnoinAbstractViewModel.prototype.cancelCommand = function () {}; + KnoinAbstractViewModel.prototype.closeCommand = function () {}; + + KnoinAbstractViewModel.prototype.storeAndSetKeyScope = function () + { + this.sCurrentKeyScope = Globals.keyScope(); + Globals.keyScope(this.sDefaultKeyScope); + }; + + KnoinAbstractViewModel.prototype.restoreKeyScope = function () + { + Globals.keyScope(this.sCurrentKeyScope); + }; + + KnoinAbstractViewModel.prototype.registerPopupKeyDown = function () + { + var self = this; + + Globals.$win.on('keydown', function (oEvent) { + if (oEvent && self.modalVisibility && self.modalVisibility()) + { + 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; + }); + }; + + module.exports = KnoinAbstractViewModel; + + }()); + +/***/ }, + +/***/ 10: +/*!*****************************************!*\ + !*** ./dev/Storages/SettingsStorage.js ***! + \*****************************************/ +/***/ function(module, exports, __webpack_require__) { + + /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + */ + function SettingsStorage() + { + this.oSettings = window['rainloopAppData'] || {}; + this.oSettings = Utils.isNormal(this.oSettings) ? this.oSettings : {}; + } + + SettingsStorage.prototype.oSettings = null; + + /** + * @param {string} sName + * @return {?} + */ + SettingsStorage.prototype.settingsGet = function (sName) + { + return Utils.isUnd(this.oSettings[sName]) ? null : this.oSettings[sName]; + }; + + /** + * @param {string} sName + * @param {?} mValue + */ + SettingsStorage.prototype.settingsSet = function (sName, mValue) + { + this.oSettings[sName] = mValue; + }; + + /** + * @param {string} sName + * @return {boolean} + */ + SettingsStorage.prototype.capa = function (sName) + { + var mCapa = this.settingsGet('Capa'); + return Utils.isArray(mCapa) && Utils.isNormal(sName) && -1 < Utils.inArray(sName, mCapa); + }; + + + module.exports = new SettingsStorage(); + + }()); + +/***/ }, + +/***/ 11: +/*!***********************************!*\ + !*** ./dev/Common/LinkBuilder.js ***! + \***********************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + */ + function LinkBuilder() + { + var Settings = __webpack_require__(/*! Storage:Settings */ 10); + + this.sBase = '#/'; + this.sServer = './?'; + this.sVersion = Settings.settingsGet('Version'); + this.sSpecSuffix = Settings.settingsGet('AuthAccountHash') || '0'; + this.sStaticPrefix = Settings.settingsGet('StaticPrefix') || 'rainloop/v/' + this.sVersion + '/static/'; + } + + /** + * @return {string} + */ + LinkBuilder.prototype.root = function () + { + return this.sBase; + }; + + /** + * @param {string} sDownload + * @return {string} + */ + LinkBuilder.prototype.attachmentDownload = function (sDownload) + { + return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sDownload; + }; + + /** + * @param {string} sDownload + * @return {string} + */ + LinkBuilder.prototype.attachmentPreview = function (sDownload) + { + return this.sServer + '/Raw/' + this.sSpecSuffix + '/View/' + sDownload; + }; + + /** + * @param {string} sDownload + * @return {string} + */ + LinkBuilder.prototype.attachmentPreviewAsPlain = function (sDownload) + { + return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sDownload; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.upload = function () + { + return this.sServer + '/Upload/' + this.sSpecSuffix + '/'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.uploadContacts = function () + { + return this.sServer + '/UploadContacts/' + this.sSpecSuffix + '/'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.uploadBackground = function () + { + return this.sServer + '/UploadBackground/' + this.sSpecSuffix + '/'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.append = function () + { + return this.sServer + '/Append/' + this.sSpecSuffix + '/'; + }; + + /** + * @param {string} sEmail + * @return {string} + */ + LinkBuilder.prototype.change = function (sEmail) + { + return this.sServer + '/Change/' + this.sSpecSuffix + '/' + Utils.encodeURIComponent(sEmail) + '/'; + }; + + /** + * @param {string=} sAdd + * @return {string} + */ + LinkBuilder.prototype.ajax = function (sAdd) + { + return this.sServer + '/Ajax/' + this.sSpecSuffix + '/' + sAdd; + }; + + /** + * @param {string} sRequestHash + * @return {string} + */ + LinkBuilder.prototype.messageViewLink = function (sRequestHash) + { + return this.sServer + '/Raw/' + this.sSpecSuffix + '/ViewAsPlain/' + sRequestHash; + }; + + /** + * @param {string} sRequestHash + * @return {string} + */ + LinkBuilder.prototype.messageDownloadLink = function (sRequestHash) + { + return this.sServer + '/Raw/' + this.sSpecSuffix + '/Download/' + sRequestHash; + }; + + /** + * @param {string} sEmail + * @return {string} + */ + LinkBuilder.prototype.avatarLink = function (sEmail) + { + return this.sServer + '/Raw/0/Avatar/' + Utils.encodeURIComponent(sEmail) + '/'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.inbox = function () + { + return this.sBase + 'mailbox/Inbox'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.messagePreview = function () + { + return this.sBase + 'mailbox/message-preview'; + }; + + /** + * @param {string=} sScreenName + * @return {string} + */ + LinkBuilder.prototype.settings = function (sScreenName) + { + var sResult = this.sBase + 'settings'; + if (!Utils.isUnd(sScreenName) && '' !== sScreenName) + { + sResult += '/' + sScreenName; + } + + return sResult; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.about = function () + { + return this.sBase + 'about'; + }; + + /** + * @param {string} sScreenName + * @return {string} + */ + LinkBuilder.prototype.admin = function (sScreenName) + { + var sResult = this.sBase; + switch (sScreenName) { + case 'AdminDomains': + sResult += 'domains'; + break; + case 'AdminSecurity': + sResult += 'security'; + break; + case 'AdminLicensing': + sResult += 'licensing'; + break; + } + + return sResult; + }; + + /** + * @param {string} sFolder + * @param {number=} iPage = 1 + * @param {string=} sSearch = '' + * @return {string} + */ + LinkBuilder.prototype.mailBox = function (sFolder, iPage, sSearch) + { + iPage = Utils.isNormal(iPage) ? Utils.pInt(iPage) : 1; + sSearch = Utils.pString(sSearch); + + var sResult = this.sBase + 'mailbox/'; + if ('' !== sFolder) + { + sResult += encodeURI(sFolder); + } + if (1 < iPage) + { + sResult = sResult.replace(/[\/]+$/, ''); + sResult += '/p' + iPage; + } + if ('' !== sSearch) + { + sResult = sResult.replace(/[\/]+$/, ''); + sResult += '/' + encodeURI(sSearch); + } + + return sResult; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.phpInfo = function () + { + return this.sServer + 'Info'; + }; + + /** + * @param {string} sLang + * @return {string} + */ + LinkBuilder.prototype.langLink = function (sLang) + { + return this.sServer + '/Lang/0/' + encodeURI(sLang) + '/' + this.sVersion + '/'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.exportContactsVcf = function () + { + return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsVcf/'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.exportContactsCsv = function () + { + return this.sServer + '/Raw/' + this.sSpecSuffix + '/ContactsCsv/'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.emptyContactPic = function () + { + return this.sStaticPrefix + 'css/images/empty-contact.png'; + }; + + /** + * @param {string} sFileName + * @return {string} + */ + LinkBuilder.prototype.sound = function (sFileName) + { + return this.sStaticPrefix + 'sounds/' + sFileName; + }; + + /** + * @param {string} sTheme + * @return {string} + */ + LinkBuilder.prototype.themePreviewLink = function (sTheme) + { + var sPrefix = 'rainloop/v/' + this.sVersion + '/'; + if ('@custom' === sTheme.substr(-7)) + { + sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7)); + sPrefix = ''; + } + + return sPrefix + 'themes/' + encodeURI(sTheme) + '/images/preview.png'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.notificationMailIcon = function () + { + return this.sStaticPrefix + 'css/images/icom-message-notification.png'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.openPgpJs = function () + { + return this.sStaticPrefix + 'js/min/openpgp.js'; + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.socialGoogle = function () + { + return this.sServer + 'SocialGoogle' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.socialTwitter = function () + { + return this.sServer + 'SocialTwitter' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); + }; + + /** + * @return {string} + */ + LinkBuilder.prototype.socialFacebook = function () + { + return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); + }; + + module.exports = new LinkBuilder(); + + }()); + +/***/ }, + +/***/ 12: +/*!*************************!*\ + !*** external "window" ***! + \*************************/ +/***/ function(module, exports, __webpack_require__) { + + module.exports = window; + +/***/ }, + +/***/ 14: +/*!*************************!*\ + !*** external "jQuery" ***! + \*************************/ +/***/ function(module, exports, __webpack_require__) { + + module.exports = jQuery; + +/***/ }, + +/***/ 17: +/*!******************************!*\ + !*** ./dev/Common/Consts.js ***! + \******************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var Consts = {}; + + Consts.Values = {}; + Consts.DataImages = {}; + Consts.Defaults = {}; + + /** + * @const + * @type {number} + */ + Consts.Defaults.MessagesPerPage = 20; + + /** + * @const + * @type {number} + */ + Consts.Defaults.ContactsPerPage = 50; + + /** + * @const + * @type {Array} + */ + Consts.Defaults.MessagesPerPageArray = [10, 20, 30, 50, 100/*, 150, 200, 300*/]; + + /** + * @const + * @type {number} + */ + Consts.Defaults.DefaultAjaxTimeout = 30000; + + /** + * @const + * @type {number} + */ + Consts.Defaults.SearchAjaxTimeout = 300000; + + /** + * @const + * @type {number} + */ + Consts.Defaults.SendMessageAjaxTimeout = 300000; + + /** + * @const + * @type {number} + */ + Consts.Defaults.SaveMessageAjaxTimeout = 200000; + + /** + * @const + * @type {number} + */ + Consts.Defaults.ContactsSyncAjaxTimeout = 200000; + + /** + * @const + * @type {string} + */ + Consts.Values.UnuseOptionValue = '__UNUSE__'; + + /** + * @const + * @type {string} + */ + Consts.Values.ClientSideStorageIndexName = 'rlcsc'; + + /** + * @const + * @type {number} + */ + Consts.Values.ImapDefaulPort = 143; + + /** + * @const + * @type {number} + */ + Consts.Values.ImapDefaulSecurePort = 993; + + /** + * @const + * @type {number} + */ + Consts.Values.SmtpDefaulPort = 25; + + /** + * @const + * @type {number} + */ + Consts.Values.SmtpDefaulSecurePort = 465; + + /** + * @const + * @type {number} + */ + Consts.Values.MessageBodyCacheLimit = 15; + + /** + * @const + * @type {number} + */ + Consts.Values.AjaxErrorLimit = 7; + + /** + * @const + * @type {number} + */ + Consts.Values.TokenErrorLimit = 10; + + /** + * @const + * @type {string} + */ + Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII='; + + /** + * @const + * @type {string} + */ + Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII='; + + module.exports = Consts; + + }(module)); + +/***/ }, + +/***/ 19: +/*!**********************!*\ + !*** external "key" ***! + \**********************/ +/***/ function(module, exports, __webpack_require__) { + + module.exports = key; + +/***/ }, + +/***/ 22: +/*!******************************!*\ + !*** ./dev/Common/Events.js ***! + \******************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + Plugins = __webpack_require__(/*! Common/Plugins */ 26) + ; + + /** + * @constructor + */ + function Events() + { + this.oSubs = {}; + } + + Events.prototype.oSubs = {}; + + /** + * @param {string} sName + * @param {Function} fFunc + * @param {Object=} oContext + * @return {Events} + */ + Events.prototype.sub = function (sName, fFunc, oContext) + { + if (Utils.isUnd(this.oSubs[sName])) + { + this.oSubs[sName] = []; + } + + this.oSubs[sName].push([fFunc, oContext]); + + return this; + }; + + /** + * @param {string} sName + * @param {Array=} aArgs + * @return {Events} + */ + Events.prototype.pub = function (sName, aArgs) + { + Plugins.runHook('rl-pub', [sName, aArgs]); + + if (!Utils.isUnd(this.oSubs[sName])) + { + _.each(this.oSubs[sName], function (aItem) { + if (aItem[0]) + { + aItem[0].apply(aItem[1] || null, aArgs || []); + } + }); + } + + return this; + }; + + module.exports = new Events(); + + }()); + +/***/ }, + +/***/ 23: +/*!**********************************!*\ + !*** ./dev/Models/EmailModel.js ***! + \**********************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @param {string=} sEmail + * @param {string=} sName + * + * @constructor + */ + function EmailModel(sEmail, sName) + { + this.email = sEmail || ''; + this.name = sName || ''; + + this.clearDuplicateName(); + } + + /** + * @static + * @param {AjaxJsonEmail} oJsonEmail + * @return {?EmailModel} + */ + EmailModel.newInstanceFromJson = function (oJsonEmail) + { + var oEmailModel = new EmailModel(); + return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null; + }; + + /** + * @type {string} + */ + EmailModel.prototype.name = ''; + + /** + * @type {string} + */ + EmailModel.prototype.email = ''; + + EmailModel.prototype.clear = function () + { + this.email = ''; + this.name = ''; + }; + + /** + * @returns {boolean} + */ + EmailModel.prototype.validate = function () + { + return '' !== this.name || '' !== this.email; + }; + + /** + * @param {boolean} bWithoutName = false + * @return {string} + */ + EmailModel.prototype.hash = function (bWithoutName) + { + return '#' + (bWithoutName ? '' : this.name) + '#' + this.email + '#'; + }; + + EmailModel.prototype.clearDuplicateName = function () + { + if (this.name === this.email) + { + this.name = ''; + } + }; + + /** + * @param {string} sQuery + * @return {boolean} + */ + EmailModel.prototype.search = function (sQuery) + { + return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(sQuery.toLowerCase()); + }; + + /** + * @param {string} sString + */ + EmailModel.prototype.parse = function (sString) + { + this.clear(); + + sString = Utils.trim(sString); + + var + mRegex = /(?:"([^"]+)")? ?,]+)>?,? ?/g, + mMatch = mRegex.exec(sString) + ; + + if (mMatch) + { + this.name = mMatch[1] || ''; + this.email = mMatch[2] || ''; + + this.clearDuplicateName(); + } + else if ((/^[^@]+@[^@]+$/).test(sString)) + { + this.name = ''; + this.email = sString; + } + }; + + /** + * @param {AjaxJsonEmail} oJsonEmail + * @return {boolean} + */ + EmailModel.prototype.initByJson = function (oJsonEmail) + { + var bResult = false; + if (oJsonEmail && 'Object/Email' === oJsonEmail['@Object']) + { + this.name = Utils.trim(oJsonEmail.Name); + this.email = Utils.trim(oJsonEmail.Email); + + bResult = '' !== this.email; + this.clearDuplicateName(); + } + + return bResult; + }; + + /** + * @param {boolean} bFriendlyView + * @param {boolean=} bWrapWithLink = false + * @param {boolean=} bEncodeHtml = false + * @return {string} + */ + EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtml) + { + var sResult = ''; + if ('' !== this.email) + { + bWrapWithLink = Utils.isUnd(bWrapWithLink) ? false : !!bWrapWithLink; + bEncodeHtml = Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml; + + if (bFriendlyView && '' !== this.name) + { + sResult = bWrapWithLink ? '
') + + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(this.name) + '' : + (bEncodeHtml ? Utils.encodeHtml(this.name) : this.name); + } + else + { + sResult = this.email; + if ('' !== this.name) + { + if (bWrapWithLink) + { + sResult = Utils.encodeHtml('"' + this.name + '" <') + + '') + '" target="_blank" tabindex="-1">' + Utils.encodeHtml(sResult) + '' + Utils.encodeHtml('>'); + } + else + { + sResult = '"' + this.name + '" <' + sResult + '>'; + if (bEncodeHtml) + { + sResult = Utils.encodeHtml(sResult); + } + } + } + else if (bWrapWithLink) + { + sResult = '' + Utils.encodeHtml(this.email) + ''; + } + } + } + + return sResult; + }; + + /** + * @param {string} $sEmailAddress + * @return {boolean} + */ + EmailModel.prototype.mailsoParse = function ($sEmailAddress) + { + $sEmailAddress = Utils.trim($sEmailAddress); + if ('' === $sEmailAddress) + { + return false; + } + + var + substr = function (str, start, len) { + str += ''; + var end = str.length; + + if (start < 0) { + start += end; + } + + end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start); + + return start >= str.length || start < 0 || start > end ? false : str.slice(start, end); + }, + + substr_replace = function (str, replace, start, length) { + if (start < 0) { + start = start + str.length; + } + length = length !== undefined ? length : str.length; + if (length < 0) { + length = length + str.length - start; + } + return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length); + }, + + $sName = '', + $sEmail = '', + $sComment = '', + + $bInName = false, + $bInAddress = false, + $bInComment = false, + + $aRegs = null, + + $iStartIndex = 0, + $iEndIndex = 0, + $iCurrentIndex = 0 + ; + + while ($iCurrentIndex < $sEmailAddress.length) + { + switch ($sEmailAddress.substr($iCurrentIndex, 1)) + { + case '"': + if ((!$bInName) && (!$bInAddress) && (!$bInComment)) + { + $bInName = true; + $iStartIndex = $iCurrentIndex; + } + else if ((!$bInAddress) && (!$bInComment)) + { + $iEndIndex = $iCurrentIndex; + $sName = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); + $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); + $iEndIndex = 0; + $iCurrentIndex = 0; + $iStartIndex = 0; + $bInName = false; + } + break; + case '<': + if ((!$bInName) && (!$bInAddress) && (!$bInComment)) + { + if ($iCurrentIndex > 0 && $sName.length === 0) + { + $sName = substr($sEmailAddress, 0, $iCurrentIndex); + } + + $bInAddress = true; + $iStartIndex = $iCurrentIndex; + } + break; + case '>': + if ($bInAddress) + { + $iEndIndex = $iCurrentIndex; + $sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); + $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); + $iEndIndex = 0; + $iCurrentIndex = 0; + $iStartIndex = 0; + $bInAddress = false; + } + break; + case '(': + if ((!$bInName) && (!$bInAddress) && (!$bInComment)) + { + $bInComment = true; + $iStartIndex = $iCurrentIndex; + } + break; + case ')': + if ($bInComment) + { + $iEndIndex = $iCurrentIndex; + $sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); + $sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); + $iEndIndex = 0; + $iCurrentIndex = 0; + $iStartIndex = 0; + $bInComment = false; + } + break; + case '\\': + $iCurrentIndex++; + break; + } + + $iCurrentIndex++; + } + + if ($sEmail.length === 0) + { + $aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i); + if ($aRegs && $aRegs[0]) + { + $sEmail = $aRegs[0]; + } + else + { + $sName = $sEmailAddress; + } + } + + if ($sEmail.length > 0 && $sName.length === 0 && $sComment.length === 0) + { + $sName = $sEmailAddress.replace($sEmail, ''); + } + + $sEmail = Utils.trim($sEmail).replace(/^[<]+/, '').replace(/[>]+$/, ''); + $sName = Utils.trim($sName).replace(/^["']+/, '').replace(/["']+$/, ''); + $sComment = Utils.trim($sComment).replace(/^[(]+/, '').replace(/[)]+$/, ''); + + // Remove backslash + $sName = $sName.replace(/\\\\(.)/g, '$1'); + $sComment = $sComment.replace(/\\\\(.)/g, '$1'); + + this.name = $sName; + this.email = $sEmail; + + this.clearDuplicateName(); + return true; + }; + + /** + * @return {string} + */ + EmailModel.prototype.inputoTagLine = function () + { + return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email; + }; + + module.exports = EmailModel; + + }()); + +/***/ }, + +/***/ 24: +/*!******************************************!*\ + !*** ./dev/Knoin/KnoinAbstractScreen.js ***! + \******************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + crossroads = __webpack_require__(/*! crossroads */ 48), + + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @param {string} sScreenName + * @param {?=} aViewModels = [] + * @constructor + */ + function KnoinAbstractScreen(sScreenName, aViewModels) + { + this.sScreenName = sScreenName; + this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : []; + } + + /** + * @type {Array} + */ + KnoinAbstractScreen.prototype.oCross = null; + + /** + * @type {string} + */ + KnoinAbstractScreen.prototype.sScreenName = ''; + + /** + * @type {Array} + */ + KnoinAbstractScreen.prototype.aViewModels = []; + + /** + * @return {Array} + */ + KnoinAbstractScreen.prototype.viewModels = function () + { + return this.aViewModels; + }; + + /** + * @return {string} + */ + KnoinAbstractScreen.prototype.screenName = function () + { + return this.sScreenName; + }; + + KnoinAbstractScreen.prototype.routes = function () + { + return null; + }; + + /** + * @return {?Object} + */ + KnoinAbstractScreen.prototype.__cross = function () + { + return this.oCross; + }; + + KnoinAbstractScreen.prototype.__start = function () + { + var + aRoutes = this.routes(), + oRoute = null, + fMatcher = null + ; + + if (Utils.isNonEmptyArray(aRoutes)) + { + fMatcher = _.bind(this.onRoute || Utils.emptyFunction, this); + oRoute = crossroads.create(); + + _.each(aRoutes, function (aItem) { + oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1]; + }); + + this.oCross = oRoute; + } + }; + + module.exports = KnoinAbstractScreen; + + }()); + +/***/ }, + +/***/ 25: +/*!*************************!*\ + !*** external "moment" ***! + \*************************/ +/***/ function(module, exports, __webpack_require__) { + + module.exports = moment; + +/***/ }, + +/***/ 26: +/*!*******************************!*\ + !*** ./dev/Common/Plugins.js ***! + \*******************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + + Utils = __webpack_require__(/*! Common/Utils */ 1) + ; + + /** + * @constructor + */ + function Plugins() + { + this.__boot = null; + this.__data = null; + this.__remote = null; + + this.oSettings = __webpack_require__(/*! Storage:Settings */ 10); + + this.oViewModelsHooks = {}; + this.oSimpleHooks = {}; + } + + Plugins.prototype.__boot = null; + Plugins.prototype.__data = null; + Plugins.prototype.__remote = null; + + /** + * @type {Object} + */ + Plugins.prototype.oViewModelsHooks = {}; + + /** + * @type {Object} + */ + Plugins.prototype.oSimpleHooks = {}; + + /** + * @param {string} sName + * @param {Function} fCallback + */ + Plugins.prototype.addHook = function (sName, fCallback) + { + if (Utils.isFunc(fCallback)) + { + if (!Utils.isArray(this.oSimpleHooks[sName])) + { + this.oSimpleHooks[sName] = []; + } + + this.oSimpleHooks[sName].push(fCallback); + } + }; + + /** + * @param {string} sName + * @param {Array=} aArguments + */ + Plugins.prototype.runHook = function (sName, aArguments) + { + if (Utils.isArray(this.oSimpleHooks[sName])) + { + aArguments = aArguments || []; + + _.each(this.oSimpleHooks[sName], function (fCallback) { + fCallback.apply(null, aArguments); + }); + } + }; + + /** + * @param {string} sName + * @return {?} + */ + Plugins.prototype.mainSettingsGet = function (sName) + { + return this.oSettings.settingsGet(sName); + }; + + /** + * @param {Function} fCallback + * @param {string} sAction + * @param {Object=} oParameters + * @param {?number=} iTimeout + * @param {string=} sGetAdd = '' + * @param {Array=} aAbortActions = [] + */ + Plugins.prototype.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) + { + if (this.__remote) + { + this.__remote.defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions); + } + }; + + /** + * @param {string} sPluginSection + * @param {string} sName + * @return {?} + */ + Plugins.prototype.settingsGet = function (sPluginSection, sName) + { + var oPlugin = this.oSettings.settingsGet('Plugins'); + oPlugin = oPlugin && !Utils.isUnd(oPlugin[sPluginSection]) ? oPlugin[sPluginSection] : null; + return oPlugin ? (Utils.isUnd(oPlugin[sName]) ? null : oPlugin[sName]) : null; + }; + + module.exports = new Plugins(); + + }()); + +/***/ }, + +/***/ 31: +/*!*****************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsAskViewModel.js ***! + \*****************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + key = __webpack_require__(/*! key */ 19), + + Enums = __webpack_require__(/*! Common/Enums */ 6), + Utils = __webpack_require__(/*! Common/Utils */ 1), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsAskViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAsk'); + + this.askDesc = ko.observable(''); + this.yesButton = ko.observable(''); + this.noButton = ko.observable(''); + + this.yesFocus = ko.observable(false); + this.noFocus = ko.observable(false); + + this.fYesAction = null; + this.fNoAction = null; + + this.bDisabeCloseOnEsc = true; + this.sDefaultKeyScope = Enums.KeyState.PopupAsk; + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:Ask', 'PopupsAskViewModel'], PopupsAskViewModel); + _.extend(PopupsAskViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsAskViewModel.prototype.clearPopup = function () + { + this.askDesc(''); + this.yesButton(Utils.i18n('POPUPS_ASK/BUTTON_YES')); + this.noButton(Utils.i18n('POPUPS_ASK/BUTTON_NO')); + + this.yesFocus(false); + this.noFocus(false); + + this.fYesAction = null; + this.fNoAction = null; + }; + + PopupsAskViewModel.prototype.yesClick = function () + { + this.cancelCommand(); + + if (Utils.isFunc(this.fYesAction)) + { + this.fYesAction.call(null); + } + }; + + PopupsAskViewModel.prototype.noClick = function () + { + this.cancelCommand(); + + if (Utils.isFunc(this.fNoAction)) + { + this.fNoAction.call(null); + } + }; + + /** + * @param {string} sAskDesc + * @param {Function=} fYesFunc + * @param {Function=} fNoFunc + * @param {string=} sYesButton + * @param {string=} sNoButton + */ + PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton) + { + this.clearPopup(); + + this.fYesAction = fYesFunc || null; + this.fNoAction = fNoFunc || null; + + this.askDesc(sAskDesc || ''); + if (sYesButton) + { + this.yesButton(sYesButton); + } + + if (sYesButton) + { + this.yesButton(sNoButton); + } + }; + + PopupsAskViewModel.prototype.onFocus = function () + { + this.yesFocus(true); + }; + + PopupsAskViewModel.prototype.onBuild = function () + { + key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function () { + if (this.yesFocus()) + { + this.noFocus(true); + } + else + { + this.yesFocus(true); + } + return false; + }, this)); + + key('esc', Enums.KeyState.PopupAsk, _.bind(function () { + this.noClick(); + return false; + }, this)); + }; + + module.exports = PopupsAskViewModel; + + }()); + +/***/ }, + +/***/ 32: +/*!***********************************************************!*\ + !*** ./dev/ViewModels/Popups/PopupsLanguagesViewModel.js ***! + \***********************************************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + _ = __webpack_require__(/*! _ */ 2), + ko = __webpack_require__(/*! ko */ 3), + + Utils = __webpack_require__(/*! Common/Utils */ 1), + Globals = __webpack_require__(/*! Common/Globals */ 7), + + kn = __webpack_require__(/*! App:Knoin */ 5), + KnoinAbstractViewModel = __webpack_require__(/*! Knoin:AbstractViewModel */ 9) + ; + + /** + * @constructor + * @extends KnoinAbstractViewModel + */ + function PopupsLanguagesViewModel() + { + KnoinAbstractViewModel.call(this, 'Popups', 'PopupsLanguages'); + + this.Data = Globals.__APP.data(); // TODO + + this.exp = ko.observable(false); + + this.languages = ko.computed(function () { + return _.map(this.Data.languages(), function (sLanguage) { + return { + 'key': sLanguage, + 'selected': ko.observable(false), + 'fullName': Utils.convertLangName(sLanguage) + }; + }); + }, this); + + this.Data.mainLanguage.subscribe(function () { + this.resetMainLanguage(); + }, this); + + kn.constructorEnd(this); + } + + kn.extendAsViewModel(['View:Popup:Languages', 'PopupsLanguagesViewModel'], PopupsLanguagesViewModel); + _.extend(PopupsLanguagesViewModel.prototype, KnoinAbstractViewModel.prototype); + + PopupsLanguagesViewModel.prototype.languageEnName = function (sLanguage) + { + return Utils.convertLangName(sLanguage, true); + }; + + PopupsLanguagesViewModel.prototype.resetMainLanguage = function () + { + var sCurrent = this.Data.mainLanguage(); + _.each(this.languages(), function (oItem) { + oItem['selected'](oItem['key'] === sCurrent); + }); + }; + + PopupsLanguagesViewModel.prototype.onShow = function () + { + this.exp(true); + + this.resetMainLanguage(); + }; + + PopupsLanguagesViewModel.prototype.onHide = function () + { + this.exp(false); + }; + + PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang) + { + this.Data.mainLanguage(sLang); + this.cancelCommand(); + }; + + module.exports = PopupsLanguagesViewModel; + + }()); + +/***/ }, + +/***/ 34: +/*!*********************************!*\ + !*** ./dev/Apps/AbstractApp.js ***! + \*********************************/ +/***/ function(module, exports, __webpack_require__) { + + + (function () { + + 'use strict'; + + var + window = __webpack_require__(/*! window */ 12), + _ = __webpack_require__(/*! _ */ 2), + $ = __webpack_require__(/*! $ */ 14), + + Globals = __webpack_require__(/*! Common/Globals */ 7), + Utils = __webpack_require__(/*! Common/Utils */ 1), + LinkBuilder = __webpack_require__(/*! Common/LinkBuilder */ 11), + Events = __webpack_require__(/*! Common/Events */ 22), + + Settings = __webpack_require__(/*! Storage:Settings */ 10), + + KnoinAbstractBoot = __webpack_require__(/*! Knoin:AbstractBoot */ 50) + ; + + /** + * @constructor + * @param {RemoteStorage|AdminRemoteStorage} Remote + * @extends KnoinAbstractBoot + */ + function AbstractApp(Remote) + { + KnoinAbstractBoot.call(this); + + this.isLocalAutocomplete = true; + + this.iframe = $('
',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){t.types.push(q),x("BeforeChange",function(e,t,i){t!==i&&(t===q?K():i===q&&K(!0))}),x(l+"."+q,function(){K()})},getIframe:function(i,n){var o=i.src,r=t.st.iframe;e.each(r.patterns,function(){return o.indexOf(this.index)>-1?(this.id&&(o="string"==typeof this.id?o.substr(o.lastIndexOf(this.id)+this.id.length,o.length):this.id.call(this,o)),o=this.src.replace("%id%",o),!1):void 0});var a={};return r.srcAction&&(a[r.srcAction]=o),t._parseMarkup(n,a,i),t.updateStatus("ready"),n}}});var Y=function(e){var i=t.items.length;return e>i-1?e-i:0>e?i+e:e},U=function(e,t,i){return e.replace(/%curr%/gi,t+1).replace(/%total%/gi,i)};e.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var i=t.st.gallery,n=".mfp-gallery",r=Boolean(e.fn.mfpFastClick);return t.direction=!0,i&&i.enabled?(a+=" mfp-gallery",x(f+n,function(){i.navigateByImgClick&&t.wrap.on("click"+n,".mfp-img",function(){return t.items.length>1?(t.next(),!1):void 0}),o.on("keydown"+n,function(e){37===e.keyCode?t.prev():39===e.keyCode&&t.next()})}),x("UpdateStatus"+n,function(e,i){i.text&&(i.text=U(i.text,t.currItem.index,t.items.length))}),x(p+n,function(e,n,o,r){var a=t.items.length;o.counter=a>1?U(i.tCounter,r.index,a):""}),x("BuildControls"+n,function(){if(t.items.length>1&&i.arrows&&!t.arrowLeft){var n=i.arrowMarkup,o=t.arrowLeft=e(n.replace(/%title%/gi,i.tPrev).replace(/%dir%/gi,"left")).addClass(y),a=t.arrowRight=e(n.replace(/%title%/gi,i.tNext).replace(/%dir%/gi,"right")).addClass(y),s=r?"mfpFastClick":"click";o[s](function(){t.prev()}),a[s](function(){t.next()}),t.isIE7&&(k("b",o[0],!1,!0),k("a",o[0],!1,!0),k("b",a[0],!1,!0),k("a",a[0],!1,!0)),t.container.append(o.add(a))}}),x(m+n,function(){t._preloadTimeout&&clearTimeout(t._preloadTimeout),t._preloadTimeout=setTimeout(function(){t.preloadNearbyImages(),t._preloadTimeout=null},16)}),x(l+n,function(){o.off(n),t.wrap.off("click"+n),t.arrowLeft&&r&&t.arrowLeft.add(t.arrowRight).destroyMfpFastClick(),t.arrowRight=t.arrowLeft=null}),void 0):!1},next:function(){t.direction=!0,t.index=Y(t.index+1),t.updateItemHTML()},prev:function(){t.direction=!1,t.index=Y(t.index-1),t.updateItemHTML()},goTo:function(e){t.direction=e>=t.index,t.index=e,t.updateItemHTML()},preloadNearbyImages:function(){var e,i=t.st.gallery.preload,n=Math.min(i[0],t.items.length),o=Math.min(i[1],t.items.length);for(e=1;(t.direction?o:n)>=e;e++)t._preloadItem(t.index+e);for(e=1;(t.direction?n:o)>=e;e++)t._preloadItem(t.index-e)},_preloadItem:function(i){if(i=Y(i),!t.items[i].preloaded){var n=t.items[i];n.parsed||(n=t.parseEl(i)),T("LazyLoad",n),"image"===n.type&&(n.img=e('').on("load.mfploader",function(){n.hasSize=!0}).on("error.mfploader",function(){n.hasSize=!0,n.loadError=!0,T("LazyLoadError",n)}).attr("src",n.src)),n.preloaded=!0}}}});var G="retina";e.magnificPopup.registerModule(G,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=t.st.retina,i=e.ratio;i=isNaN(i)?i():i,i>1&&(x("ImageHasSize."+G,function(e,t){t.img.css({"max-width":t.img[0].naturalWidth/i,width:"100%"})}),x("ElementParse."+G,function(t,n){n.src=e.replaceSrc(n,i)}))}}}}),function(){var t=1e3,i="ontouchstart"in window,n=function(){I.off("touchmove"+r+" touchend"+r)},o="mfpFastClick",r="."+o;e.fn.mfpFastClick=function(o){return e(this).each(function(){var a,s=e(this);if(i){var l,c,d,u,p,f;s.on("touchstart"+r,function(e){u=!1,f=1,p=e.originalEvent?e.originalEvent.touches[0]:e.touches[0],c=p.clientX,d=p.clientY,I.on("touchmove"+r,function(e){p=e.originalEvent?e.originalEvent.touches:e.touches,f=p.length,p=p[0],(Math.abs(p.clientX-c)>10||Math.abs(p.clientY-d)>10)&&(u=!0,n())}).on("touchend"+r,function(e){n(),u||f>1||(a=!0,e.preventDefault(),clearTimeout(l),l=setTimeout(function(){a=!1},t),o())})})}s.on("click"+r,function(){a||o()})})},e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+r+" click"+r),i&&I.off("touchmove"+r+" touchend"+r)}}()})(window.jQuery||window.Zepto); +(function(e){var t,i,n,o,r,a,s,l="Close",c="BeforeClose",d="AfterClose",u="BeforeAppend",p="MarkupParse",f="Open",m="Change",g="mfp",v="."+g,h="mfp-ready",C="mfp-removing",y="mfp-prevent-close",w=function(){},b=!!window.jQuery,I=e(window),x=function(e,i){t.ev.on(g+e+v,i)},k=function(t,i,n,o){var r=document.createElement("div");return r.className="mfp-"+t,n&&(r.innerHTML=n),o?i&&i.appendChild(r):(r=e(r),i&&r.appendTo(i)),r},T=function(i,n){t.ev.triggerHandler(g+i,n),t.st.callbacks&&(i=i.charAt(0).toLowerCase()+i.slice(1),t.st.callbacks[i]&&t.st.callbacks[i].apply(t,e.isArray(n)?n:[n]))},E=function(){(t.st.focus?t.content.find(t.st.focus).eq(0):t.wrap).focus()},S=function(i){return i===s&&t.currTemplate.closeBtn||(t.currTemplate.closeBtn=e(t.st.closeMarkup.replace("%title%",t.st.tClose)),s=i),t.currTemplate.closeBtn},P=function(){e.magnificPopup.instance||(t=new w,t.init(),e.magnificPopup.instance=t)},_=function(){var e=document.createElement("p").style,t=["ms","O","Moz","Webkit"];if(void 0!==e.transition)return!0;for(;t.length;)if(t.pop()+"Transition"in e)return!0;return!1};w.prototype={constructor:w,init:function(){var i=navigator.appVersion;t.isIE7=-1!==i.indexOf("MSIE 7."),t.isIE8=-1!==i.indexOf("MSIE 8."),t.isLowIE=t.isIE7||t.isIE8,t.isAndroid=/android/gi.test(i),t.isIOS=/iphone|ipad|ipod/gi.test(i),t.supportsTransition=_(),t.probablyMobile=t.isAndroid||t.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),n=e(document.body),o=e(document),t.popupsCache={}},open:function(i){var n;if(i.isObj===!1){t.items=i.items.toArray(),t.index=0;var r,s=i.items;for(n=0;s.length>n;n++)if(r=s[n],r.parsed&&(r=r.el[0]),r===i.el[0]){t.index=n;break}}else t.items=e.isArray(i.items)?i.items:[i.items],t.index=i.index||0;if(t.isOpen)return t.updateItemHTML(),void 0;t.types=[],a="",t.ev=i.mainEl&&i.mainEl.length?i.mainEl.eq(0):o,i.key?(t.popupsCache[i.key]||(t.popupsCache[i.key]={}),t.currTemplate=t.popupsCache[i.key]):t.currTemplate={},t.st=e.extend(!0,{},e.magnificPopup.defaults,i),t.fixedContentPos="auto"===t.st.fixedContentPos?!t.probablyMobile:t.st.fixedContentPos,t.st.modal&&(t.st.closeOnContentClick=!1,t.st.closeOnBgClick=!1,t.st.showCloseBtn=!1,t.st.enableEscapeKey=!1),t.bgOverlay||(t.bgOverlay=k("bg").on("click"+v,function(){t.close()}),t.wrap=k("wrap").attr("tabindex",-1).on("click"+v,function(e){t._checkIfClose(e.target)&&t.close()}),t.container=k("container",t.wrap)),t.contentContainer=k("content"),t.st.preloader&&(t.preloader=k("preloader",t.container,t.st.tLoading));var l=e.magnificPopup.modules;for(n=0;l.length>n;n++){var c=l[n];c=c.charAt(0).toUpperCase()+c.slice(1),t["init"+c].call(t)}T("BeforeOpen"),t.st.showCloseBtn&&(t.st.closeBtnInside?(x(p,function(e,t,i,n){i.close_replaceWith=S(n.type)}),a+=" mfp-close-btn-in"):t.wrap.append(S())),t.st.alignTop&&(a+=" mfp-align-top"),t.fixedContentPos?t.wrap.css({overflow:t.st.overflowY,overflowX:"hidden",overflowY:t.st.overflowY}):t.wrap.css({top:I.scrollTop(),position:"absolute"}),(t.st.fixedBgPos===!1||"auto"===t.st.fixedBgPos&&!t.fixedContentPos)&&t.bgOverlay.css({height:o.height(),position:"absolute"}),t.st.enableEscapeKey&&o.on("keyup"+v,function(e){27===e.keyCode&&t.close()}),I.on("resize"+v,function(){t.updateSize()}),t.st.closeOnContentClick||(a+=" mfp-auto-cursor"),a&&t.wrap.addClass(a);var d=t.wH=I.height(),u={};if(t.fixedContentPos&&t._hasScrollBar(d)){var m=t._getScrollbarSize();m&&(u.marginRight=m)}t.fixedContentPos&&(t.isIE7?e("body, html").css("overflow","hidden"):u.overflow="hidden");var g=t.st.mainClass;return t.isIE7&&(g+=" mfp-ie7"),g&&t._addClassToMFP(g),t.updateItemHTML(),T("BuildControls"),e("html").css(u),t.bgOverlay.add(t.wrap).prependTo(document.body),t._lastFocusedEl=document.activeElement,setTimeout(function(){t.content?(t._addClassToMFP(h),E()):t.bgOverlay.addClass(h),o.on("focusin"+v,function(i){return i.target===t.wrap[0]||e.contains(t.wrap[0],i.target)?void 0:(E(),!1)})},16),t.isOpen=!0,t.updateSize(d),T(f),i},close:function(){t.isOpen&&(T(c),t.isOpen=!1,t.st.removalDelay&&!t.isLowIE&&t.supportsTransition?(t._addClassToMFP(C),setTimeout(function(){t._close()},t.st.removalDelay)):t._close())},_close:function(){T(l);var i=C+" "+h+" ";if(t.bgOverlay.detach(),t.wrap.detach(),t.container.empty(),t.st.mainClass&&(i+=t.st.mainClass+" "),t._removeClassFromMFP(i),t.fixedContentPos){var n={marginRight:""};t.isIE7?e("body, html").css("overflow",""):n.overflow="",e("html").css(n)}o.off("keyup"+v+" focusin"+v),t.ev.off(v),t.wrap.attr("class","mfp-wrap").removeAttr("style"),t.bgOverlay.attr("class","mfp-bg"),t.container.attr("class","mfp-container"),!t.st.showCloseBtn||t.st.closeBtnInside&&t.currTemplate[t.currItem.type]!==!0||t.currTemplate.closeBtn&&t.currTemplate.closeBtn.detach(),t._lastFocusedEl&&e(t._lastFocusedEl).focus(),t.currItem=null,t.content=null,t.currTemplate=null,t.prevHeight=0,T(d)},updateSize:function(e){if(t.isIOS){var i=document.documentElement.clientWidth/window.innerWidth,n=window.innerHeight*i;t.wrap.css("height",n),t.wH=n}else t.wH=e||I.height();t.fixedContentPos||t.wrap.css("height",t.wH),T("Resize")},updateItemHTML:function(){var i=t.items[t.index];t.contentContainer.detach(),t.content&&t.content.detach(),i.parsed||(i=t.parseEl(t.index));var n=i.type;if(T("BeforeChange",[t.currItem?t.currItem.type:"",n]),t.currItem=i,!t.currTemplate[n]){var o=t.st[n]?t.st[n].markup:!1;T("FirstMarkupParse",o),t.currTemplate[n]=o?e(o):!0}r&&r!==i.type&&t.container.removeClass("mfp-"+r+"-holder");var a=t["get"+n.charAt(0).toUpperCase()+n.slice(1)](i,t.currTemplate[n]);t.appendContent(a,n),i.preloaded=!0,T(m,i),r=i.type,t.container.prepend(t.contentContainer),T("AfterChange")},appendContent:function(e,i){t.content=e,e?t.st.showCloseBtn&&t.st.closeBtnInside&&t.currTemplate[i]===!0?t.content.find(".mfp-close").length||t.content.append(S()):t.content=e:t.content="",T(u),t.container.addClass("mfp-"+i+"-holder"),t.contentContainer.append(t.content)},parseEl:function(i){var n=t.items[i],o=n.type;if(n=n.tagName?{el:e(n)}:{data:n,src:n.src},n.el){for(var r=t.types,a=0;r.length>a;a++)if(n.el.hasClass("mfp-"+r[a])){o=r[a];break}n.src=n.el.attr("data-mfp-src"),n.src||(n.src=n.el.attr("href"))}return n.type=o||t.st.type||"inline",n.index=i,n.parsed=!0,t.items[i]=n,T("ElementParse",n),t.items[i]},addGroup:function(e,i){var n=function(n){n.mfpEl=this,t._openClick(n,e,i)};i||(i={});var o="click.magnificPopup";i.mainEl=e,i.items?(i.isObj=!0,e.off(o).on(o,n)):(i.isObj=!1,i.delegate?e.off(o).on(o,i.delegate,n):(i.items=e,e.off(o).on(o,n)))},_openClick:function(i,n,o){var r=void 0!==o.midClick?o.midClick:e.magnificPopup.defaults.midClick;if(r||2!==i.which&&!i.ctrlKey&&!i.metaKey){var a=void 0!==o.disableOn?o.disableOn:e.magnificPopup.defaults.disableOn;if(a)if(e.isFunction(a)){if(!a.call(t))return!0}else if(a>I.width())return!0;i.type&&(i.preventDefault(),t.isOpen&&i.stopPropagation()),o.el=e(i.mfpEl),o.delegate&&(o.items=n.find(o.delegate)),t.open(o)}},updateStatus:function(e,n){if(t.preloader){i!==e&&t.container.removeClass("mfp-s-"+i),n||"loading"!==e||(n=t.st.tLoading);var o={status:e,text:n};T("UpdateStatus",o),e=o.status,n=o.text,t.preloader.html(n),t.preloader.find("a").on("click",function(e){e.stopImmediatePropagation()}),t.container.addClass("mfp-s-"+e),i=e}},_checkIfClose:function(i){if(!e(i).hasClass(y)){var n=t.st.closeOnContentClick,o=t.st.closeOnBgClick;if(n&&o)return!0;if(!t.content||e(i).hasClass("mfp-close")||t.preloader&&i===t.preloader[0])return!0;if(i===t.content[0]||e.contains(t.content[0],i)){if(n)return!0}else if(o&&e.contains(document,i))return!0;return!1}},_addClassToMFP:function(e){t.bgOverlay.addClass(e),t.wrap.addClass(e)},_removeClassFromMFP:function(e){this.bgOverlay.removeClass(e),t.wrap.removeClass(e)},_hasScrollBar:function(e){return(t.isIE7?o.height():document.body.scrollHeight)>(e||I.height())},_parseMarkup:function(t,i,n){var o;n.data&&(i=e.extend(n.data,i)),T(p,[t,i,n]),e.each(i,function(e,i){if(void 0===i||i===!1)return!0;if(o=e.split("_"),o.length>1){var n=t.find(v+"-"+o[0]);if(n.length>0){var r=o[1];"replaceWith"===r?n[0]!==i[0]&&n.replaceWith(i):"img"===r?n.is("img")?n.attr("src",i):n.replaceWith(''):n.attr(o[1],i)}}else t.find(v+"-"+e).html(i)})},_getScrollbarSize:function(){if(void 0===t.scrollbarSize){var e=document.createElement("div");e.id="mfp-sbm",e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(e),t.scrollbarSize=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return t.scrollbarSize}},e.magnificPopup={instance:null,proto:w.prototype,modules:[],open:function(t,i){return P(),t=t?e.extend(!0,{},t):{},t.isObj=!0,t.index=i||0,this.instance.open(t)},close:function(){return e.magnificPopup.instance&&e.magnificPopup.instance.close()},registerModule:function(t,i){i.options&&(e.magnificPopup.defaults[t]=i.options),e.extend(this.proto,i.proto),this.modules.push(t)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'',tClose:"Close (Esc)",tLoading:"Loading..."}},e.fn.magnificPopup=function(i){P();var n=e(this);if("string"==typeof i)if("open"===i){var o,r=b?n.data("magnificPopup"):n[0].magnificPopup,a=parseInt(arguments[1],10)||0;r.items?o=r.items[a]:(o=n,r.delegate&&(o=o.find(r.delegate)),o=o.eq(a)),t._openClick({mfpEl:o},n,r)}else t.isOpen&&t[i].apply(t,Array.prototype.slice.call(arguments,1));else i=e.extend(!0,{},i),b?n.data("magnificPopup",i):n[0].magnificPopup=i,t.addGroup(n,i);return n};var O,z,M,B="inline",H=function(){M&&(z.after(M.addClass(O)).detach(),M=null)};e.magnificPopup.registerModule(B,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){t.types.push(B),x(l+"."+B,function(){H()})},getInline:function(i,n){if(H(),i.src){var o=t.st.inline,r=e(i.src);if(r.length){var a=r[0].parentNode;a&&a.tagName&&(z||(O=o.hiddenClass,z=k(O),O="mfp-"+O),M=r.after(z).detach().removeClass(O)),t.updateStatus("ready")}else t.updateStatus("error",o.tNotFound),r=e("
");return i.inlineElement=r,r}return t.updateStatus("ready"),t._parseMarkup(n,{},i),n}}});var L,A="ajax",F=function(){L&&n.removeClass(L)},j=function(){F(),t.req&&t.req.abort()};e.magnificPopup.registerModule(A,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'The content could not be loaded.'},proto:{initAjax:function(){t.types.push(A),L=t.st.ajax.cursor,x(l+"."+A,j),x("BeforeChange."+A,j)},getAjax:function(i){L&&n.addClass(L),t.updateStatus("loading");var o=e.extend({url:i.src,success:function(n,o,r){var a={data:n,xhr:r};T("ParseAjax",a),t.appendContent(e(a.data),A),i.finished=!0,F(),E(),setTimeout(function(){t.wrap.addClass(h)},16),t.updateStatus("ready"),T("AjaxContentAdded")},error:function(){F(),i.finished=i.loadError=!0,t.updateStatus("error",t.st.ajax.tError.replace("%url%",i.src))}},t.st.ajax.settings);return t.req=e.ajax(o),""}}});var N,W=function(i){if(i.data&&void 0!==i.data.title)return i.data.title;var n=t.st.image.titleSrc;if(n){if(e.isFunction(n))return n.call(t,i);if(i.el)return i.el.attr(n)||""}return""};e.magnificPopup.registerModule("image",{options:{markup:'
',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'The image could not be loaded.'},proto:{initImage:function(){var e=t.st.image,i=".image";t.types.push("image"),x(f+i,function(){"image"===t.currItem.type&&e.cursor&&n.addClass(e.cursor)}),x(l+i,function(){e.cursor&&n.removeClass(e.cursor),I.off("resize"+v)}),x("Resize"+i,t.resizeImage),t.isLowIE&&x("AfterChange",t.resizeImage)},resizeImage:function(){var e=t.currItem;if(e&&e.img&&t.st.image.verticalFit){var i=0;t.isLowIE&&(i=parseInt(e.img.css("padding-top"),10)+parseInt(e.img.css("padding-bottom"),10)),e.img.css("max-height",t.wH-i)}},_onImageHasSize:function(e){e.img&&(e.hasSize=!0,N&&clearInterval(N),e.isCheckingImgSize=!1,T("ImageHasSize",e),e.imgHidden&&(t.content&&t.content.removeClass("mfp-loading"),e.imgHidden=!1))},findImageSize:function(e){var i=0,n=e.img[0],o=function(r){N&&clearInterval(N),N=setInterval(function(){return n.naturalWidth>0?(t._onImageHasSize(e),void 0):(i>200&&clearInterval(N),i++,3===i?o(10):40===i?o(50):100===i&&o(500),void 0)},r)};o(1)},getImage:function(i,n){var o=0,r=function(){i&&(i.img[0].complete?(i.img.off(".mfploader"),i===t.currItem&&(t._onImageHasSize(i),t.updateStatus("ready")),i.hasSize=!0,i.loaded=!0,T("ImageLoadComplete")):(o++,200>o?setTimeout(r,100):a()))},a=function(){i&&(i.img.off(".mfploader"),i===t.currItem&&(t._onImageHasSize(i),t.updateStatus("error",s.tError.replace("%url%",i.src))),i.hasSize=!0,i.loaded=!0,i.loadError=!0)},s=t.st.image,l=n.find(".mfp-img");if(l.length){var c=document.createElement("img");c.className="mfp-img",i.img=e(c).on("load.mfploader",r).on("error.mfploader",a),c.src=i.src,l.is("img")&&(i.img=i.img.clone()),i.img[0].naturalWidth>0&&(i.hasSize=!0)}return t._parseMarkup(n,{title:W(i),img_replaceWith:i.img},i),t.resizeImage(),i.hasSize?(N&&clearInterval(N),i.loadError?(n.addClass("mfp-loading"),t.updateStatus("error",s.tError.replace("%url%",i.src))):(n.removeClass("mfp-loading"),t.updateStatus("ready")),n):(t.updateStatus("loading"),i.loading=!0,i.hasSize||(i.imgHidden=!0,n.addClass("mfp-loading"),t.findImageSize(i)),n)}}});var R,Z=function(){return void 0===R&&(R=void 0!==document.createElement("p").style.MozTransform),R};e.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(e){return e.is("img")?e:e.find("img")}},proto:{initZoom:function(){var e,i=t.st.zoom,n=".zoom";if(i.enabled&&t.supportsTransition){var o,r,a=i.duration,s=function(e){var t=e.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),n="all "+i.duration/1e3+"s "+i.easing,o={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},r="transition";return o["-webkit-"+r]=o["-moz-"+r]=o["-o-"+r]=o[r]=n,t.css(o),t},d=function(){t.content.css("visibility","visible")};x("BuildControls"+n,function(){if(t._allowZoom()){if(clearTimeout(o),t.content.css("visibility","hidden"),e=t._getItemToZoom(),!e)return d(),void 0;r=s(e),r.css(t._getOffset()),t.wrap.append(r),o=setTimeout(function(){r.css(t._getOffset(!0)),o=setTimeout(function(){d(),setTimeout(function(){r.remove(),e=r=null,T("ZoomAnimationEnded")},16)},a)},16)}}),x(c+n,function(){if(t._allowZoom()){if(clearTimeout(o),t.st.removalDelay=a,!e){if(e=t._getItemToZoom(),!e)return;r=s(e)}r.css(t._getOffset(!0)),t.wrap.append(r),t.content.css("visibility","hidden"),setTimeout(function(){r.css(t._getOffset())},16)}}),x(l+n,function(){t._allowZoom()&&(d(),r&&r.remove(),e=null)})}},_allowZoom:function(){return"image"===t.currItem.type},_getItemToZoom:function(){return t.currItem.hasSize?t.currItem.img:!1},_getOffset:function(i){var n;n=i?t.currItem.img:t.st.zoom.opener(t.currItem.el||t.currItem);var o=n.offset(),r=parseInt(n.css("padding-top"),10),a=parseInt(n.css("padding-bottom"),10);o.top-=e(window).scrollTop()-r;var s={width:n.width(),height:(b?n.innerHeight():n[0].offsetHeight)-a-r};return Z()?s["-moz-transform"]=s.transform="translate("+o.left+"px,"+o.top+"px)":(s.left=o.left,s.top=o.top),s}}});var q="iframe",D="//about:blank",K=function(e){if(t.currTemplate[q]){var i=t.currTemplate[q].find("iframe");i.length&&(e||(i[0].src=D),t.isIE8&&i.css("display",e?"block":"none"))}};e.magnificPopup.registerModule(q,{options:{markup:'
',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){t.types.push(q),x("BeforeChange",function(e,t,i){t!==i&&(t===q?K():i===q&&K(!0))}),x(l+"."+q,function(){K()})},getIframe:function(i,n){var o=i.src,r=t.st.iframe;e.each(r.patterns,function(){return o.indexOf(this.index)>-1?(this.id&&(o="string"==typeof this.id?o.substr(o.lastIndexOf(this.id)+this.id.length,o.length):this.id.call(this,o)),o=this.src.replace("%id%",o),!1):void 0});var a={};return r.srcAction&&(a[r.srcAction]=o),t._parseMarkup(n,a,i),t.updateStatus("ready"),n}}});var Y=function(e){var i=t.items.length;return e>i-1?e-i:0>e?i+e:e},U=function(e,t,i){return e.replace(/%curr%/gi,t+1).replace(/%total%/gi,i)};e.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var i=t.st.gallery,n=".mfp-gallery",r=Boolean(e.fn.mfpFastClick);return t.direction=!0,i&&i.enabled?(a+=" mfp-gallery",x(f+n,function(){i.navigateByImgClick&&t.wrap.on("click"+n,".mfp-img",function(){return t.items.length>1?(t.next(),!1):void 0}),o.on("keydown"+n,function(e){37===e.keyCode?t.prev():39===e.keyCode&&t.next()})}),x("UpdateStatus"+n,function(e,i){i.text&&(i.text=U(i.text,t.currItem.index,t.items.length))}),x(p+n,function(e,n,o,r){var a=t.items.length;o.counter=a>1?U(i.tCounter,r.index,a):""}),x("BuildControls"+n,function(){if(t.items.length>1&&i.arrows&&!t.arrowLeft){var n=i.arrowMarkup,o=t.arrowLeft=e(n.replace(/%title%/gi,i.tPrev).replace(/%dir%/gi,"left")).addClass(y),a=t.arrowRight=e(n.replace(/%title%/gi,i.tNext).replace(/%dir%/gi,"right")).addClass(y),s=r?"mfpFastClick":"click";o[s](function(){t.prev()}),a[s](function(){t.next()}),t.isIE7&&(k("b",o[0],!1,!0),k("a",o[0],!1,!0),k("b",a[0],!1,!0),k("a",a[0],!1,!0)),t.container.append(o.add(a))}}),x(m+n,function(){t._preloadTimeout&&clearTimeout(t._preloadTimeout),t._preloadTimeout=setTimeout(function(){t.preloadNearbyImages(),t._preloadTimeout=null},16)}),x(l+n,function(){o.off(n),t.wrap.off("click"+n),t.arrowLeft&&r&&t.arrowLeft.add(t.arrowRight).destroyMfpFastClick(),t.arrowRight=t.arrowLeft=null}),void 0):!1},next:function(){t.direction=!0,t.index=Y(t.index+1),t.updateItemHTML()},prev:function(){t.direction=!1,t.index=Y(t.index-1),t.updateItemHTML()},goTo:function(e){t.direction=e>=t.index,t.index=e,t.updateItemHTML()},preloadNearbyImages:function(){var e,i=t.st.gallery.preload,n=Math.min(i[0],t.items.length),o=Math.min(i[1],t.items.length);for(e=1;(t.direction?o:n)>=e;e++)t._preloadItem(t.index+e);for(e=1;(t.direction?n:o)>=e;e++)t._preloadItem(t.index-e)},_preloadItem:function(i){if(i=Y(i),!t.items[i].preloaded){var n=t.items[i];n.parsed||(n=t.parseEl(i)),T("LazyLoad",n),"image"===n.type&&(n.img=e('').on("load.mfploader",function(){n.hasSize=!0}).on("error.mfploader",function(){n.hasSize=!0,n.loadError=!0,T("LazyLoadError",n)}).attr("src",n.src)),n.preloaded=!0}}}});var G="retina";e.magnificPopup.registerModule(G,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=t.st.retina,i=e.ratio;i=isNaN(i)?i():i,i>1&&(x("ImageHasSize."+G,function(e,t){t.img.css({"max-width":t.img[0].naturalWidth/i,width:"100%"})}),x("ElementParse."+G,function(t,n){n.src=e.replaceSrc(n,i)}))}}}}),function(){var t=1e3,i="ontouchstart"in window,n=function(){I.off("touchmove"+r+" touchend"+r)},o="mfpFastClick",r="."+o;e.fn.mfpFastClick=function(o){return e(this).each(function(){var a,s=e(this);if(i){var l,c,d,u,p,f;s.on("touchstart"+r,function(e){u=!1,f=1,p=e.originalEvent?e.originalEvent.touches[0]:e.touches[0],c=p.clientX,d=p.clientY,I.on("touchmove"+r,function(e){p=e.originalEvent?e.originalEvent.touches:e.touches,f=p.length,p=p[0],(Math.abs(p.clientX-c)>10||Math.abs(p.clientY-d)>10)&&(u=!0,n())}).on("touchend"+r,function(e){n(),u||f>1||(a=!0,e.preventDefault(),clearTimeout(l),l=setTimeout(function(){a=!1},t),o())})})}s.on("click"+r,function(){a||o()})})},e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+r+" click"+r),i&&I.off("touchmove"+r+" touchend"+r)}}()})(window.jQuery||window.Zepto); /*! * Bootstrap.js by @fat & @mdo * Copyright 2013 Twitter, Inc. diff --git a/rainloop/v/0.0.0/static/js/openpgp.min.js b/rainloop/v/0.0.0/static/js/min/openpgp.js similarity index 100% rename from rainloop/v/0.0.0/static/js/openpgp.min.js rename to rainloop/v/0.0.0/static/js/min/openpgp.js diff --git a/vendors/jsbn/_encrypt.min.js b/vendors/jsbn/bundle.js similarity index 100% rename from vendors/jsbn/_encrypt.min.js rename to vendors/jsbn/bundle.js diff --git a/vendors/jsbn/_fix.js b/vendors/jsbn/fix.js similarity index 100% rename from vendors/jsbn/_fix.js rename to vendors/jsbn/fix.js diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 000000000..ad6445973 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,148 @@ +var webpack = require('webpack'); + +module.exports = { + entry: { + 'app': __dirname + '/dev/RainLoop.js', + 'admin': __dirname + '/dev/Admin.js' + }, + output: { + pathinfo: true, + path: __dirname + '/rainloop/v/0.0.0/static/js/', + filename: '[name].js', + publicPath: 'rainloop/v/0.0.0/static/js/', + chunkFilename: '[chunkhash].chunk.js' + }, + plugins: [ + new webpack.optimize.OccurenceOrderPlugin(), + new webpack.optimize.CommonsChunkPlugin('common.js') + ], + resolve: { + modulesDirectories: [__dirname + '/dev/'], + extensions: ['', '.js'], + alias: { + "ko": __dirname + "/dev/External/ko.js", + + "Knoin:AbstractBoot": __dirname + "/dev/Knoin/KnoinAbstractBoot.js", + "Knoin:AbstractScreen": __dirname + "/dev/Knoin/KnoinAbstractScreen.js", + "Knoin:AbstractViewModel": __dirname + "/dev/Knoin/KnoinAbstractViewModel.js", + + "App:Boot": __dirname + "/dev/Boot.js", + "App:Knoin": __dirname + "/dev/Knoin/Knoin.js", + "App:Abstract": __dirname + "/dev/Apps/AbstractApp.js", + "App:RainLoop": __dirname + "/dev/Apps/RainLoopApp.js", + "App:Admin": __dirname + "/dev/Apps/AdminApp.js", + + "Model:Account": __dirname + "/dev/Models/AccountModel.js", + "Model:Attachment": __dirname + "/dev/Models/AttachmentModel.js", + "Model:ComposeAttachment": __dirname + "/dev/Models/ComposeAttachmentModel.js", + "Model:Contact": __dirname + "/dev/Models/ContactModel.js", + "Model:ContactProperty": __dirname + "/dev/Models/ContactPropertyModel.js", + "Model:ContactTag": __dirname + "/dev/Models/ContactTagModel.js", + "Model:Email": __dirname + "/dev/Models/EmailModel.js", + "Model:Filter": __dirname + "/dev/Models/FilterModel.js", + "Model:FilterCondition": __dirname + "/dev/Models/FilterConditionModel.js", + "Model:Folder": __dirname + "/dev/Models/FolderModel.js", + "Model:Identity": __dirname + "/dev/Models/IdentityModel.js", + "Model:Message": __dirname + "/dev/Models/MessageModel.js", + "Model:OpenPgpKey": __dirname + "/dev/Models/OpenPgpKeyModel.js", + + "Storage:LocalStorage": __dirname + "/dev/Storages/LocalStorage.js", + "Storage:LocalStorage:Cookie": __dirname + "/dev/Storages/LocalStorages/CookieDriver.js", + "Storage:LocalStorage:LocalStorage": __dirname + "/dev/Storages/LocalStorages/LocalStorageDriver.js", + + "Storage:Settings": __dirname + "/dev/Storages/SettingsStorage.js", + + "Storage:Abstract:Remote": __dirname + "/dev/Storages/AbstractRemoteStorage.js", + "Storage:Abstract:Data": __dirname + "/dev/Storages/AbstractData.js", + + "Storage:RainLoop:Cache": __dirname + "/dev/Storages/CacheStorage.js", + "Storage:RainLoop:Remote": __dirname + "/dev/Storages/RemoteStorage.js", + "Storage:RainLoop:Data": __dirname + "/dev/Storages/DataStorage.js", + + "Storage:Admin:Remote": __dirname + "/dev/Storages/AdminRemoteStorage.js", + "Storage:Admin:Data": __dirname + "/dev/Storages/AdminDataStorage.js", + + "Screen:AbstractSettings": __dirname + "/dev/Screens/AbstractSettingsScreen.js", + "Screen:RainLoop:Login": __dirname + "/dev/Screens/LoginScreen.js", + "Screen:RainLoop:About": __dirname + "/dev/Screens/AboutScreen.js", + "Screen:RainLoop:MailBox": __dirname + "/dev/Screens/MailBoxScreen.js", + "Screen:RainLoop:Settings": __dirname + "/dev/Screens/SettingsScreen.js", + "Screen:Admin:Login": __dirname + "/dev/Screens/AdminLoginScreen.js", + "Screen:Admin:Settings": __dirname + "/dev/Screens/AdminSettingsScreen.js", + + "Settings:RainLoop:General": __dirname + "/dev/Settings/App/SettingsGeneral.js", + "Settings:RainLoop:ChangePassword": __dirname + "/dev/Settings/App/SettingsChangePassword.js", + "Settings:RainLoop:Accounts": __dirname + "/dev/Settings/App/SettingsAccounts.js", + "Settings:RainLoop:Contacts": __dirname + "/dev/Settings/App/SettingsContacts.js", + "Settings:RainLoop:Filters": __dirname + "/dev/Settings/App/SettingsFilters.js", + "Settings:RainLoop:Folders": __dirname + "/dev/Settings/App/SettingsFolders.js", + "Settings:RainLoop:Identity": __dirname + "/dev/Settings/App/SettingsIdentity.js", + "Settings:RainLoop:Identities": __dirname + "/dev/Settings/App/SettingsIdentities.js", + "Settings:RainLoop:OpenPGP": __dirname + "/dev/Settings/App/SettingsOpenPGP.js", + "Settings:RainLoop:Security": __dirname + "/dev/Settings/App/SettingsSecurity.js", + "Settings:RainLoop:Social": __dirname + "/dev/Settings/App/SettingsSocial.js", + "Settings:RainLoop:Themes": __dirname + "/dev/Settings/App/SettingsThemes.js", + + "Settings:Admin:General": __dirname + "/dev/Settings/Admin/AdminSettingsGeneral.js", + "Settings:Admin:Login": __dirname + "/dev/Settings/Admin/AdminSettingsLogin.js", + "Settings:Admin:Branding": __dirname + "/dev/Settings/Admin/AdminSettingsBranding.js", + "Settings:Admin:Contacts": __dirname + "/dev/Settings/Admin/AdminSettingsContacts.js", + "Settings:Admin:Domains": __dirname + "/dev/Settings/Admin/AdminSettingsDomains.js", + "Settings:Admin:Social": __dirname + "/dev/Settings/Admin/AdminSettingsSocial.js", + "Settings:Admin:Security": __dirname + "/dev/Settings/Admin/AdminSettingsSecurity.js", + "Settings:Admin:Plugins": __dirname + "/dev/Settings/Admin/AdminSettingsPlugins.js", + "Settings:Admin:Packages": __dirname + "/dev/Settings/Admin/AdminSettingsPackages.js", + "Settings:Admin:Licensing": __dirname + "/dev/Settings/Admin/AdminSettingsLicensing.js", + "Settings:Admin:About": __dirname + "/dev/Settings/Admin/AdminSettingsAbout.js", + + "View:Admin:Login": __dirname + "/dev/ViewModels/AdminLoginViewModel.js", + "View:Admin:SettingsMenu": __dirname + "/dev/ViewModels/AdminSettingsMenuViewModel.js", + "View:Admin:SettingsPane": __dirname + "/dev/ViewModels/AdminSettingsPaneViewModel.js", + + "View:RainLoop:AbstractSystemDropDown": __dirname + "/dev/ViewModels/AbstractSystemDropDownViewModel.js", + "View:RainLoop:MailBoxSystemDropDown": __dirname + "/dev/ViewModels/MailBoxSystemDropDownViewModel.js", + "View:RainLoop:SettingsSystemDropDown": __dirname + "/dev/ViewModels/SettingsSystemDropDownViewModel.js", + "View:RainLoop:SettingsMenu": __dirname + "/dev/ViewModels/SettingsMenuViewModel.js", + "View:RainLoop:SettingsPane": __dirname + "/dev/ViewModels/SettingsPaneViewModel.js", + "View:RainLoop:MailBoxMessageView": __dirname + "/dev/ViewModels/MailBoxMessageViewViewModel.js", + "View:RainLoop:MailBoxMessageList": __dirname + "/dev/ViewModels/MailBoxMessageListViewModel.js", + "View:RainLoop:MailBoxFolderList": __dirname + "/dev/ViewModels/MailBoxFolderListViewModel.js", + "View:RainLoop:Login": __dirname + "/dev/ViewModels/LoginViewModel.js", + "View:RainLoop:About": __dirname + "/dev/ViewModels/AboutViewModel.js", + + "View:Popup:Activate": __dirname + "/dev/ViewModels/Popups/PopupsActivateViewModel.js", + "View:Popup:AddAccount": __dirname + "/dev/ViewModels/Popups/PopupsAddAccountViewModel.js", + "View:Popup:AddOpenPgpKey": __dirname + "/dev/ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js", + "View:Popup:AdvancedSearch": __dirname + "/dev/ViewModels/Popups/PopupsAdvancedSearchViewModel.js", + "View:Popup:Ask": __dirname + "/dev/ViewModels/Popups/PopupsAskViewModel.js", + "View:Popup:ComposeOpenPgp": __dirname + "/dev/ViewModels/Popups/PopupsComposeOpenPgpViewModel.js", + "View:Popup:Compose": __dirname + "/dev/ViewModels/Popups/PopupsComposeViewModel.js", + "View:Popup:Contacts": __dirname + "/dev/ViewModels/Popups/PopupsContactsViewModel.js", + "View:Popup:Domain": __dirname + "/dev/ViewModels/Popups/PopupsDomainViewModel.js", + "View:Popup:Filter": __dirname + "/dev/ViewModels/Popups/PopupsFilterViewModel.js", + "View:Popup:FolderClear": __dirname + "/dev/ViewModels/Popups/PopupsFolderClearViewModel.js", + "View:Popup:FolderCreate": __dirname + "/dev/ViewModels/Popups/PopupsFolderCreateViewModel.js", + "View:Popup:FolderSystem": __dirname + "/dev/ViewModels/Popups/PopupsFolderSystemViewModel.js", + "View:Popup:Identity": __dirname + "/dev/ViewModels/Popups/PopupsIdentityViewModel.js", + "View:Popup:KeyboardShortcutsHelp": __dirname + "/dev/ViewModels/Popups/PopupsKeyboardShortcutsHelpViewModel.js", + "View:Popup:Languages": __dirname + "/dev/ViewModels/Popups/PopupsLanguagesViewModel.js", + "View:Popup:NewOpenPgpKey": __dirname + "/dev/ViewModels/Popups/PopupsNewOpenPgpKeyViewModel.js", + "View:Popup:Plugin": __dirname + "/dev/ViewModels/Popups/PopupsPluginViewModel.js", + "View:Popup:TwoFactorTest": __dirname + "/dev/ViewModels/Popups/PopupsTwoFactorTestViewModel.js", + "View:Popup:ViewOpenPgpKey": __dirname + "/dev/ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js" + } + }, + externals: { + 'window': 'window', + 'JSON': 'JSON', + 'moment': 'moment', + 'ifvisible': 'ifvisible', + 'crossroads': 'crossroads', + 'Jua': 'Jua', + 'hasher': 'hasher', + 'ssm': 'ssm', + 'key': 'key', + '_': '_', + '$': 'jQuery' + } +}; \ No newline at end of file