diff --git a/dev/Admin/Contacts.js b/dev/Admin/Contacts.js index 7d8e916be..e0b440b6f 100644 --- a/dev/Admin/Contacts.js +++ b/dev/Admin/Contacts.js @@ -9,6 +9,7 @@ function AdminContacts() this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; this.enableContacts = ko.observable(!!RL.settingsGet('ContactsEnable')); + this.contactsSharing = ko.observable(!!RL.settingsGet('ContactsSharing')); var aTypes = ['sqlite', 'mysql', 'pgsql'], @@ -176,6 +177,12 @@ AdminContacts.prototype.onBuild = function () 'ContactsEnable': bValue ? '1' : '0' }); }); + + self.contactsSharing.subscribe(function (bValue) { + RL.remote().saveAdminConfig(null, { + 'ContactsSharing': bValue ? '1' : '0' + }); + }); self.contactsType.subscribe(function (sValue) { RL.remote().saveAdminConfig(f5, { diff --git a/dev/Common/Enums.js b/dev/Common/Enums.js index a3481d732..91ff21e6d 100644 --- a/dev/Common/Enums.js +++ b/dev/Common/Enums.js @@ -238,12 +238,7 @@ Enums.InterfaceAnimation = { Enums.ContactScopeType = { 'Default': 0, - - 'Auto': 1, - - 'ShareAll': 2, - 'ShareDomain': 3, - 'ShareEmail': 4 + 'ShareAll': 2 }; /** diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index f3bba391f..4e2e9ab72 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -719,6 +719,7 @@ 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; diff --git a/dev/Models/ContactModel.js b/dev/Models/ContactModel.js index 91bba6f6d..e190cbaa6 100644 --- a/dev/Models/ContactModel.js +++ b/dev/Models/ContactModel.js @@ -10,7 +10,6 @@ function ContactModel() this.properties = []; this.readOnly = false; this.scopeType = Enums.ContactScopeType.Default; - this.scopeValue = ''; this.checked = ko.observable(false); this.selected = ko.observable(false); @@ -61,7 +60,6 @@ ContactModel.prototype.parse = function (oItem) this.display = Utils.pString(oItem['Display']); this.readOnly = !!oItem['ReadOnly']; this.scopeType = Utils.pInt(oItem['ScopeType']); - this.scopeValue = Utils.pString(oItem['ScopeValue']); if (Utils.isNonEmptyArray(oItem['Properties'])) { @@ -73,10 +71,7 @@ ContactModel.prototype.parse = function (oItem) }, this); } - this.shared(-1 < Utils.inArray(this.scopeType, [ - Enums.ContactScopeType.ShareAll, Enums.ContactScopeType.ShareDomain, Enums.ContactScopeType.ShareEmail - ])); - + this.shared(Enums.ContactScopeType.ShareAll === this.scopeType); bResult = true; } diff --git a/dev/Models/ContactPropertyModel.js b/dev/Models/ContactPropertyModel.js index 8d2496af3..83b76f73b 100644 --- a/dev/Models/ContactPropertyModel.js +++ b/dev/Models/ContactPropertyModel.js @@ -4,12 +4,20 @@ * @param {number=} iType = Enums.ContactPropertyType.Unknown * @param {string=} sValue = '' * @param {boolean=} bFocused = false + * @param {string=} sPlaceholder = '' * * @constructor */ -function ContactPropertyModel(iType, sValue, bFocused) +function ContactPropertyModel(iType, sValue, bFocused, sPlaceholder) { this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType); 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); } diff --git a/dev/Settings/General.js b/dev/Settings/General.js index ee19158c6..3a90c969f 100644 --- a/dev/Settings/General.js +++ b/dev/Settings/General.js @@ -12,6 +12,7 @@ function SettingsGeneral() this.mainMessagesPerPageArray = Consts.Defaults.MessagesPerPageArray; this.editorDefaultType = oData.editorDefaultType; this.showImages = oData.showImages; + this.contactsAutosave = oData.contactsAutosave; this.interfaceAnimation = oData.interfaceAnimation; this.useDesktopNotifications = oData.useDesktopNotifications; this.threading = oData.threading; @@ -95,6 +96,12 @@ SettingsGeneral.prototype.onBuild = function () }); }); + oData.contactsAutosave.subscribe(function (bValue) { + RL.remote().saveSettings(Utils.emptyFunction, { + 'ContactsAutosave': bValue ? '1' : '0' + }); + }); + oData.interfaceAnimation.subscribe(function (sValue) { RL.remote().saveSettings(Utils.emptyFunction, { 'InterfaceAnimation': sValue diff --git a/dev/Storages/AbstractData.js b/dev/Storages/AbstractData.js index 77c0d9fa5..c3a2a9d73 100644 --- a/dev/Storages/AbstractData.js +++ b/dev/Storages/AbstractData.js @@ -40,6 +40,7 @@ AbstractData.prototype.populateDataOnStart = function() this.editorDefaultType(RL.settingsGet('EditorDefaultType')); this.showImages(!!RL.settingsGet('ShowImages')); + this.contactsAutosave(!!RL.settingsGet('ContactsAutosave')); this.interfaceAnimation(RL.settingsGet('InterfaceAnimation')); this.mainMessagesPerPage(RL.settingsGet('MPP')); diff --git a/dev/Storages/WebMailAjaxRemote.js b/dev/Storages/WebMailAjaxRemote.js index 5dfd7c358..ad0a2b4f3 100644 --- a/dev/Storages/WebMailAjaxRemote.js +++ b/dev/Storages/WebMailAjaxRemote.js @@ -570,11 +570,12 @@ WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, iOffset, iLim /** * @param {?Function} fCallback */ -WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, aProperties) +WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, nScopeType, aProperties) { this.defaultRequest(fCallback, 'ContactSave', { 'RequestUid': sRequestUid, 'Uid': Utils.trim(sUid), + 'ScopeType': nScopeType, 'Properties': aProperties }); }; diff --git a/dev/Styles/Contacts.less b/dev/Styles/Contacts.less index 0241fc600..90767c4f5 100644 --- a/dev/Styles/Contacts.less +++ b/dev/Styles/Contacts.less @@ -5,10 +5,10 @@ .control-group { .control-label.fix-width { - width: 110px; + width: 90px; } .controls.fix-width { - margin-left: 135px; + margin-left: 110px; } } @@ -319,6 +319,12 @@ } } + .e-save-trigger { + position: absolute; + top: 25px; + left: 10px; + } + .e-read-only-sign { display: none; position: absolute; @@ -328,14 +334,14 @@ .e-share-sign { position: absolute; - top: 60px; + top: 20px; right: 20px; cursor: pointer; } .button-save-contact { position: absolute; - top: 20px; + top: 100px; right: 20px; } diff --git a/dev/Styles/Ui.less b/dev/Styles/Ui.less index bd70f16d5..17db51298 100644 --- a/dev/Styles/Ui.less +++ b/dev/Styles/Ui.less @@ -46,6 +46,10 @@ cursor: pointer; } + .e-item.selected > .e-link { + background-color: #eee; + } + .e-item > .e-link:hover { background-color: #555; background-image: none; diff --git a/dev/ViewModels/PopupsContactsViewModel.js b/dev/ViewModels/PopupsContactsViewModel.js index 6dbac1e29..60d9b8a40 100644 --- a/dev/ViewModels/PopupsContactsViewModel.js +++ b/dev/ViewModels/PopupsContactsViewModel.js @@ -9,8 +9,8 @@ function PopupsContactsViewModel() KnoinAbstractViewModel.call(this, 'Popups', 'PopupsContacts'); var - oT = Enums.ContactPropertyType, self = this, + oT = Enums.ContactPropertyType, aNameTypes = [oT.FullName, oT.FirstName, oT.SurName, oT.MiddleName], aEmailTypes = [oT.EmailPersonal, oT.EmailBussines, oT.EmailOther], aPhonesTypes = [ @@ -34,6 +34,8 @@ function PopupsContactsViewModel() this.contacts.loading = ko.observable(false).extend({'throttle': 200}); this.currentContact = ko.observable(null); + this.contactsSharingIsAllowed = !!RL.settingsGet('ContactsSharingIsAllowed'); + this.contactsPage = ko.observable(1); this.contactsPageCount = ko.computed(function () { var iPage = Math.ceil(this.contactsCount() / Consts.Defaults.ContactsPerPage); @@ -48,9 +50,10 @@ function PopupsContactsViewModel() this.viewID = ko.observable(''); this.viewReadOnly = ko.observable(false); this.viewScopeType = ko.observable(Enums.ContactScopeType.Default); - this.viewScopeValue = ko.observable(''); this.viewProperties = ko.observableArray([]); + this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) { return -1 < Utils.inArray(oProperty.type(), aNameTypes); }); @@ -59,24 +62,18 @@ function PopupsContactsViewModel() return -1 < Utils.inArray(oProperty.type(), aEmailTypes); }); + this.shareIcon = ko.computed(function() { + return Enums.ContactScopeType.ShareAll === this.viewScopeType() ? 'icon-earth' : 'icon-share'; + }, this); + this.shareToNone = ko.computed(function() { - return -1 === Utils.inArray(this.viewScopeType(), [ - Enums.ContactScopeType.ShareAll, Enums.ContactScopeType.ShareDomain, Enums.ContactScopeType.ShareEmail - ]); + return Enums.ContactScopeType.ShareAll !== this.viewScopeType(); }, this); this.shareToAll = ko.computed(function() { return Enums.ContactScopeType.ShareAll === this.viewScopeType(); }, this); - this.shareToDomain = ko.computed(function() { - return Enums.ContactScopeType.ShareDomain === this.viewScopeType(); - }, this); - - this.shareToEmail = ko.computed(function() { - return Enums.ContactScopeType.ShareEmail === this.viewScopeType(); - }, this); - this.viewHasNonEmptyRequaredProperties = ko.computed(function() { var @@ -98,6 +95,10 @@ function PopupsContactsViewModel() return -1 < Utils.inArray(oProperty.type(), aOtherTypes); }); + 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; @@ -223,6 +224,7 @@ function PopupsContactsViewModel() this.saveCommand = Utils.createCommand(this, function () { this.viewSaving(true); + this.viewSaveTrigger(Enums.SaveSettingsStep.Animate); var sRequestUid = Utils.fakeMd5(), @@ -238,7 +240,9 @@ function PopupsContactsViewModel() RL.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)) { @@ -248,13 +252,25 @@ function PopupsContactsViewModel() } self.reloadContactList(); + bRes = true; } // else // { // // TODO // } + + _.delay(function () { + self.viewSaveTrigger(bRes ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult); + }, 300); + + if (bRes) + { + _.delay(function () { + self.viewSaveTrigger(Enums.SaveSettingsStep.Idle); + }, 1000); + } - }, sRequestUid, this.viewID(), aProperties); + }, sRequestUid, this.viewID(), this.viewScopeType(), aProperties); }, function () { var @@ -266,11 +282,36 @@ function PopupsContactsViewModel() this.bDropPageAfterDelete = false; + this.watchHash = ko.observable(false); + this.viewHash = ko.computed(function () { + return '' + self.viewScopeType() + ' - ' + _.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.saveCommandDebounce(); + } + }, this); + Knoin.constructorEnd(this); } Utils.extendAsViewModel('PopupsContactsViewModel', PopupsContactsViewModel); +PopupsContactsViewModel.prototype.setShareToNone = function () +{ + this.viewScopeType(Enums.ContactScopeType.Default); +}; + +PopupsContactsViewModel.prototype.setShareToAll = function () +{ + this.viewScopeType(Enums.ContactScopeType.ShareAll); +}; PopupsContactsViewModel.prototype.addNewProperty = function (sType) { @@ -377,10 +418,11 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact) aList = [] ; + this.watchHash(false); + this.emptySelection(false); this.viewReadOnly(false); this.viewScopeType(Enums.ContactScopeType.Default); - this.viewScopeValue(''); if (oContact) { @@ -391,7 +433,9 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact) _.each(oContact.properties, function (aProperty) { if (aProperty && aProperty[0]) { - aList.push(new ContactPropertyModel(aProperty[0], aProperty[1])); + aList.push(new ContactPropertyModel(aProperty[0], aProperty[1], false, + Enums.ContactPropertyType.FullName === aProperty[0] ? 'CONTACTS/PLACEHOLDER_ENTER_DISPLAY_NAME' : '')); + if (Enums.ContactPropertyType.FullName === aProperty[0]) { bHasName = true; @@ -402,17 +446,18 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact) this.viewReadOnly(!!oContact.readOnly); this.viewScopeType(oContact.scopeType); - this.viewScopeValue(oContact.scopeValue); } - + if (!bHasName) { - aList.push(new ContactPropertyModel(Enums.ContactPropertyType.FullName, '', true)); + aList.push(new ContactPropertyModel(Enums.ContactPropertyType.FullName, '', !oContact, 'CONTACTS/PLACEHOLDER_ENTER_DISPLAY_NAME')); } this.viewID(sId); this.viewProperties([]); this.viewProperties(aList); + + this.watchHash(true); }; /** @@ -446,7 +491,7 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio { aList = _.map(oData.Result.List, function (oItem) { var oContact = new ContactModel(); - return oContact.parse(oItem) ? oContact : null; + return oContact.parse(oItem, self.contactsSharingIsAllowed) ? oContact : null; }); aList = _.compact(aList); diff --git a/package.json b/package.json index 4b935701a..1e818da26 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "RainLoop", "title": "RainLoop Webmail", "version": "1.5.1", - "release": "554", + "release": "555", "description": "Simple, modern & fast web-based email client", "homepage": "http://rainloop.net", "main": "Gruntfile.js", diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index d8abb08c3..9912bafbf 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -562,6 +562,9 @@ class Actions { $this->oPersonalAddressBookProvider = new \RainLoop\Providers\PersonalAddressBook( $this->Config()->Get('contacts', 'enable', false) || $bForceEnable ? $this->fabrica('personal-address-book', $oAccount) : null); + + $this->oPersonalAddressBookProvider->ConsiderShare( + !!$this->Config()->Get('contacts', 'allow_sharing', false)); } else if ($oAccount && $this->oPersonalAddressBookProvider->IsSupported()) { @@ -932,6 +935,7 @@ class Actions $aResult['AccountHash'] = $oAccount->Hash(); $aResult['ChangePasswordIsAllowed'] = $this->ChangePasswordProvider()->PasswordChangePossibility($oAccount); $aResult['ContactsIsAllowed'] = $this->PersonalAddressBookProvider($oAccount)->IsActive(); + $aResult['ContactsSharingIsAllowed'] = $this->PersonalAddressBookProvider($oAccount)->IsSharingAllowed(); $oSettings = $this->SettingsProvider()->Load($oAccount); } @@ -990,6 +994,7 @@ class Actions $aResult['PostgreSqlIsSupported'] = \is_array($aDrivers) ? \in_array('pgsql', $aDrivers) : false; $aResult['ContactsEnable'] = (bool) $oConfig->Get('contacts', 'enable', false); + $aResult['ContactsSharing'] = (bool) $oConfig->Get('contacts', 'allow_sharing', false); $aResult['ContactsPdoType'] = $this->ValidateContactPdoType(\trim($this->Config()->Get('contacts', 'type', 'sqlite'))); $aResult['ContactsPdoDsn'] = (string) $oConfig->Get('contacts', 'pdo_dsn', ''); $aResult['ContactsPdoType'] = (string) $oConfig->Get('contacts', 'type', ''); @@ -1033,6 +1038,7 @@ class Actions // user $aResult['EditorDefaultType'] = (string) $oConfig->Get('webmail', 'editor_default_type', ''); $aResult['ShowImages'] = (bool) $oConfig->Get('webmail', 'show_images', false); + $aResult['ContactsAutosave'] = true; $aResult['MPP'] = (int) $oConfig->Get('webmail', 'messages_per_page', 25); $aResult['DesktopNotifications'] = false; $aResult['UseThreads'] = false; @@ -1066,6 +1072,7 @@ class Actions $aResult['NullFolder'] = $oSettings->GetConf('NullFolder', ''); $aResult['EditorDefaultType'] = $oSettings->GetConf('EditorDefaultType', $aResult['EditorDefaultType']); $aResult['ShowImages'] = (bool) $oSettings->GetConf('ShowImages', $aResult['ShowImages']); + $aResult['ContactsAutosave'] = (bool) $oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']); $aResult['MPP'] = (int) $oSettings->GetConf('MPP', $aResult['MPP']); $aResult['DesktopNotifications'] = (bool) $oSettings->GetConf('DesktopNotifications', $aResult['DesktopNotifications']); $aResult['UseThreads'] = (bool) $oSettings->GetConf('UseThreads', $aResult['UseThreads']); @@ -1867,6 +1874,7 @@ class Actions $this->setConfigFromParams($oConfig, 'LoginDefaultDomain', 'login', 'default_domain', 'string'); $this->setConfigFromParams($oConfig, 'ContactsEnable', 'contacts', 'enable', 'bool'); + $this->setConfigFromParams($oConfig, 'ContactsSharing', 'contacts', 'allow_sharing', 'bool'); $this->setConfigFromParams($oConfig, 'ContactsPdoDsn', 'contacts', 'pdo_dsn', 'string'); $this->setConfigFromParams($oConfig, 'ContactsPdoUser', 'contacts', 'pdo_user', 'string'); $this->setConfigFromParams($oConfig, 'ContactsPdoPassword', 'contacts', 'pdo_password', 'dummy'); @@ -3000,6 +3008,7 @@ class Actions $this->setSettingsFromParams($oSettings, 'EditorDefaultType', 'string'); $this->setSettingsFromParams($oSettings, 'ShowImages', 'bool'); + $this->setSettingsFromParams($oSettings, 'ContactsAutosave', 'bool'); $this->setSettingsFromParams($oSettings, 'InterfaceAnimation', 'string', function ($sValue) { return (\in_array($sValue, array(\RainLoop\Enumerations\InterfaceAnimation::NONE, @@ -4153,7 +4162,10 @@ class Actions if (0 < \count($aArrayToFrec)) { - $this->PersonalAddressBookProvider($oAccount)->IncFrec($oAccount, \array_values($aArrayToFrec)); + $oSettings = $this->SettingsProvider()->Load($oAccount); + + $this->PersonalAddressBookProvider($oAccount)->IncFrec($oAccount, \array_values($aArrayToFrec), + !!$oSettings->GetConf('ContactsAutosave', false)); } } @@ -4196,7 +4208,7 @@ class Actions { $iCount = 0; $mResult = $this->PersonalAddressBookProvider($oAccount)->GetContacts($oAccount, - $iOffset, $iLimit, $sSearch, \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_, $iCount); + $iOffset, $iLimit, $sSearch, $iCount); } return $this->DefaultResponse(__FUNCTION__, array( @@ -4244,6 +4256,13 @@ class Actions if ($oPab && $oPab->IsActive() && 0 < \strlen($sRequestUid)) { $sUid = \trim($this->GetActionParam('Uid', '')); + $iScopeType = (int) $this->GetActionParam('ScopeType', null); + if (!in_array($iScopeType, array( + \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_, + \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL))) + { + $iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_; + } $oContact = new \RainLoop\Providers\PersonalAddressBook\Classes\Contact(); if (0 < \strlen($sUid)) @@ -4251,6 +4270,8 @@ class Actions $oContact->IdContact = $sUid; } + $oContact->ScopeType = $iScopeType; + $aProperties = $this->GetActionParam('Properties', array()); if (\is_array($aProperties)) { @@ -4262,6 +4283,7 @@ class Actions $oProp = new \RainLoop\Providers\PersonalAddressBook\Classes\Property(); $oProp->Type = (int) $aItem[0]; $oProp->Value = $aItem[1]; + $oProp->ScopeType = $iScopeType; $oContact->Properties[] = $oProp; } @@ -5911,16 +5933,6 @@ class Actions 'Email' => \MailSo\Base\Utils::Utf8Clear($mResponse->GetEmail()) )); } - else if ('RainLoop\Providers\Contacts\Classes\Contact' === $sClassName) - { - $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array( - 'IdContact' => $mResponse->IdContact, - 'ImageHash' => $mResponse->ImageHash, - 'ListName' => \MailSo\Base\Utils::Utf8Clear($mResponse->ListName), - 'Name' => \MailSo\Base\Utils::Utf8Clear($mResponse->Name), - 'Emails' => $mResponse->Emails - )); - } else if ('RainLoop\Providers\PersonalAddressBook\Classes\Contact' === $sClassName) { $mResult = \array_merge($this->objectData($mResponse, $sParent, $aParameters), array( @@ -5929,7 +5941,6 @@ class Actions 'Display' => \MailSo\Base\Utils::Utf8Clear($mResponse->Display), 'ReadOnly' => $mResponse->ReadOnly, 'ScopeType' => $mResponse->ScopeType, - 'ScopeValue' => $mResponse->ScopeValue, 'IdPropertyFromSearch' => $mResponse->IdPropertyFromSearch, 'Properties' => $this->responseObject($mResponse->Properties, $sParent, $aParameters) )); @@ -5942,7 +5953,7 @@ class Actions 'Type' => $mResponse->Type, 'TypeCustom' => $mResponse->TypeCustom, 'Value' => \MailSo\Base\Utils::Utf8Clear($mResponse->Value), - 'ValueClear' => \MailSo\Base\Utils::Utf8Clear($mResponse->ValueClear) + 'ValueCustom' => \MailSo\Base\Utils::Utf8Clear($mResponse->ValueCustom) )); } else if ('MailSo\Mail\Attachment' === $sClassName) diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php index d08d99c74..390b89ce2 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -83,6 +83,7 @@ class Application extends \RainLoop\Config\AbstractConfig 'contacts' => array( 'enable' => array(false, 'Enable contacts'), + 'allow_sharing' => array(true), 'suggestions_limit' => array(30), 'type' => array('sqlite', ''), 'pdo_dsn' => array('mysql:host=127.0.0.1;port=3306;dbname=rainloop', ''), diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts.php deleted file mode 100644 index 134bf4823..000000000 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts.php +++ /dev/null @@ -1,121 +0,0 @@ -oDriver = null; - if ($oDriver instanceof \RainLoop\Providers\Contacts\ContactsInterface) - { - $this->oDriver = $oDriver; - } - } - - /** - * @return bool - */ - public function IsActive() - { - return $this->oDriver instanceof \RainLoop\Providers\Contacts\ContactsInterface && - $this->oDriver->IsSupported(); - } - - /** - * @return bool - */ - public function IsSupported() - { - return $this->oDriver instanceof \RainLoop\Providers\Contacts\ContactsInterface && - $this->oDriver->IsSupported(); - } - - /** - * @param \RainLoop\Account $oAccount - * @param int $iIdContact - * - * @return array - */ - public function GetContactById($oAccount, $iIdContact) - { - return $this->oDriver ? $this->oDriver->GetContactById($oAccount, $iIdContact) : null; - } - - /** - * @param \RainLoop\Account $oAccount - * @param int $iOffset = 0 - * @param int $iLimit = 20 - * @param string $sSearch = '' - * - * @return array - */ - public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '') - { - return $this->oDriver ? $this->oDriver->GetContacts($oAccount, $iOffset, $iLimit, $sSearch) : array(); - } - - /** - * @param \RainLoop\Account $oAccount - * - * @return array - */ - public function GetContactsImageHashes($oAccount) - { - return $this->oDriver ? $this->oDriver->GetContactsImageHashes($oAccount) : array(); - } - - /** - * @param \RainLoop\Account $oAccount - * @param \RainLoop\Providers\Contacts\Classes\Contact $oContact - * - * @return bool - */ - public function CreateContact($oAccount, &$oContact) - { - return $this->oDriver ? $this->oDriver->CreateContact($oAccount, $oContact) : false; - } - - /** - * @param \RainLoop\Account $oAccount - * @param \RainLoop\Providers\Contacts\Classes\Contact $oContact - * - * @return bool - */ - public function UpdateContact($oAccount, &$oContact) - { - return $this->oDriver ? $this->oDriver->UpdateContact($oAccount, $oContact) : false; - } - - /** - * @param \RainLoop\Account $oAccount - * @param array $aContactIds - * - * @return bool - */ - public function DeleteContacts($oAccount, $aContactIds) - { - return $this->oDriver ? $this->oDriver->DeleteContacts($oAccount, $aContactIds) : false; - } - - /** - * @param \RainLoop\Account $oAccount - * @param array $aContactIds - * - * @return bool - */ - public function IncFrec($oAccount, $aContactIds) - { - return $this->oDriver ? $this->oDriver->IncFrec($oAccount, $aContactIds) : false; - } -} \ No newline at end of file diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/Classes/Contact.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/Classes/Contact.php deleted file mode 100644 index e91d9a478..000000000 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/Classes/Contact.php +++ /dev/null @@ -1,111 +0,0 @@ -Clear(); - } - - public function Clear() - { - $this->IdContact = 0; - $this->IdUser = 0; - $this->Type = 0; - $this->Frec = 0; - $this->ListName = ''; - $this->Name = ''; - $this->ImageHash = ''; - $this->Emails = array(); - $this->Data = array(); - } - - /** - * @return string - */ - public function GenarateListName() - { - return 0 < \strlen($this->Name) ? $this->Name : (!empty($this->Emails[0]) ? $this->Emails[0] : ''); - } - - /** - * @return string - */ - public function EmailsAsString() - { - return \trim(\implode(' ', $this->Emails)); - } - - /** - * @return string - */ - public function DataAsString() - { - return @\serialize($this->Data); - } - - /** - * @param string $sData - */ - public function ParseData($sData) - { - $sData = (string) $sData; - $sData = \trim($sData); - - if (!empty($sData)) - { - $aData = @\unserialize($sData); - if (\is_array($aData)) - { - $this->Data = $aData; - } - } - } -} diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/Classes/Db.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/Classes/Db.php deleted file mode 100644 index 3cf7ae6a1..000000000 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/Classes/Db.php +++ /dev/null @@ -1,38 +0,0 @@ - array( - 'IdUser' => 'INTEGER PRIMARY KEY', - 'Email' => 'TEXT' - ), - 'rlContactsItems' => array( - 'IdContact' => 'INTEGER PRIMARY KEY', - 'IdUser' => 'INTEGER', - 'Type' => 'INTEGER', - 'Frec' => 'INTEGER', - 'ImageHash' => 'TEXT', - 'ListName' => 'TEXT', - 'Name' => 'TEXT', - 'Emails' => 'TEXT', - 'Data' => 'TEXT' - ) - ); - } -} diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/ContactsInterface.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/ContactsInterface.php deleted file mode 100644 index 6f08e605d..000000000 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/Contacts/ContactsInterface.php +++ /dev/null @@ -1,68 +0,0 @@ -oLogger = $oLogger instanceof \MailSo\Log\Logger ? $oLogger : null; - $this->bUseDbPerUser = true; - } - - /** - * @param \RainLoop\Account $oAccount - * @staticvar array $aPdoCache - * @return \PDO - */ - private function getPDO($oAccount) - { - static $aPdoCache = array(); - - $sEmail = $oAccount->ParentEmailHelper(); - if (isset($aPdoCache[$sEmail])) - { - return $aPdoCache[$sEmail]; - } - - if (!\class_exists('PDO')) - { - throw new \Exception('class_exists=PDO'); - } - - $sVersionFile = ''; - $sDsn = ''; - - if ($this->bUseDbPerUser) - { - $sSubPath = APP_PRIVATE_DATA.'storage/contacts/'.\rtrim(\substr($sEmail, 0, 2), '@').'/'.$sEmail.'/'; - if (!\is_dir($sSubPath)) - { - if (\mkdir($sSubPath, 0755, true) && \is_dir($sSubPath)) - { - $sVersionFile = $sSubPath.'.version'; - $sDsn = 'sqlite:'.$sSubPath.'contacts.sqlite'; - } - } - else - { - $sVersionFile = $sSubPath.'.version'; - $sDsn = 'sqlite:'.$sSubPath.'contacts.sqlite'; - } - } - else - { - $sVersionFile = APP_PRIVATE_DATA.'.version'; - $sDsn = 'sqlite:'.APP_PRIVATE_DATA.'contacts.sqlite'; - } - - $sDbLogin = ''; - $sDbPassword = ''; - - $oPdo = false; - try - { - $oPdo = new \PDO($sDsn, $sDbLogin, $sDbPassword); - if ($oPdo) - { - $oPdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - - if (!@\file_exists($sVersionFile) || - (string) @file_get_contents($sVersionFile) !== (string) \RainLoop\Providers\Contacts\Classes\Db::Version()) - { - $this->syncTables($oPdo, $sVersionFile); - } - - $oPdo->sqliteCreateFunction('SIMPLESEARCH', function ($sEmailValue, $sNameValue, $sMask) { - return \preg_match('/'.\preg_quote($sMask, '/').'/ui', - $sEmailValue.' '.$sNameValue) ? 1 : 0; - }); - - } - } - catch (\Exception $oException) - { - throw $oException; - $oPdo = false; - } - - if ($oPdo) - { - $aPdoCache[$oAccount->ParentEmailHelper()] = $oPdo; - } - - return $oPdo; - } - - protected function getWantedColumnsInfo($sTableName, $aCurrent) - { - $aColumns = array(); - foreach ($aCurrent as $sName => $sType) - { - $sSql = $sName.' '.$sType; - switch ($sType) - { - case 'INTEGER': - $sSql .= ' DEFAILT \'0\''; - break; - case 'TEXT': - $sSql .= ' DEFAILT \'\''; - break; - } - - $aColumns[$sName] = $sSql; - } - - if (0 === \count($aColumns)) - { - return ''; - } - - return 'CREATE TABLE '.$sTableName.' (' .\implode(', ', $aColumns).')'; - } - - /** - * @param \PDO $oAccount - * @param string $sTableName - */ - protected function getCurrentColumnsInfo($oPdo, $sTableName) - { - $oStmt = $this->prepareAndExecute($oPdo, 'SELECT `sql` FROM `sqlite_master` WHERE `tbl_name` = :TableName AND `type` = :Type', array( - ':TableName' => array($sTableName, \PDO::PARAM_STR), - ':Type' => array('table', \PDO::PARAM_STR) - )); - - if ($oStmt) - { - $mRow = $oStmt->fetch(\PDO::FETCH_ASSOC); - if ($mRow && isset($mRow['sql'])) - { - return (string) $mRow['sql']; - } - } - - return ''; - } - - /** - * @param \PDO $oPdo - * @param string $sVersionFile = '' - */ - private function syncTables($oPdo, $sVersionFile = '') - { - if ($this->oLogger) - { - $this->oLogger->Write('Start to sync', \MailSo\Log\Enumerations\Type::INFO); - } - - $aStrucure = \RainLoop\Providers\Contacts\Classes\Db::Strucure(); - foreach ($aStrucure as $sTableName => $aField) - { - $sCurrent = $this->getCurrentColumnsInfo($oPdo, $sTableName); - $sWanted = $this->getWantedColumnsInfo($sTableName, $aField); - - if (empty($sCurrent)) - { - $this->prepareAndExecute($oPdo, $sWanted); - } - else if ($sCurrent !== $sWanted) - { - $this->prepareAndExecute($oPdo, 'DROP TABLE IF EXISTS `'.$sTableName.'_old`'); - $this->prepareAndExecute($oPdo, 'ALTER TABLE `'.$sTableName.'` RENAME TO `'.$sTableName.'_old`'); - $this->prepareAndExecute($oPdo, $sWanted); - - $aNewKeys = array(); - $aOldKeys = array(); - foreach ($aField as $sKey => $sType) - { - $aNewKeys[] = $sKey; - $aOldKeys[] = false !== \strpos($sCurrent, $sKey.' ') ? $sKey : - (0 === \strpos($sType, 'INT') ? '\'0\'' : '\'\''); - } - - $sNewKeys = \implode(', ', $aNewKeys); - $sOldKeys = \implode(', ', $aOldKeys); - $this->prepareAndExecute($oPdo, 'INSERT INTO `'.$sTableName.'` ('.$sNewKeys.') SELECT '.$sOldKeys.' FROM `'.$sTableName.'_old`'); - - $this->prepareAndExecute($oPdo, 'DROP TABLE `'.$sTableName.'_old`'); - } - } - - @\file_put_contents($sVersionFile, \RainLoop\Providers\Contacts\Classes\Db::Version()); - - if ($this->oLogger) - { - $this->oLogger->Write('Stop to sync', \MailSo\Log\Enumerations\Type::INFO); - } - } - - /** - * @param \RainLoop\Account|\PDO $oAccountOrPdo - * @param string $sSql - * @param array $aParams - * - * @return \PDOStatement|null - */ - private function prepareAndExecute($oAccountOrPdo, $sSql, $aParams = array()) - { - if ($this->oLogger) - { - $this->oLogger->Write($sSql, \MailSo\Log\Enumerations\Type::INFO, 'SQLITE'); - } - - $oPdo = $oAccountOrPdo instanceof \PDO ? $oAccountOrPdo : $this->getPDO($oAccountOrPdo); - $oStmt = $oPdo->prepare($sSql); - foreach ($aParams as $sName => $aValue) - { - $oStmt->bindValue($sName, $aValue[0], $aValue[1]); - } - -// $sLogSql = $sSql; -// foreach($aParams as $sName => $aValue) -// { -// $sLogSql = \str_replace($sName, $aValue[1] === \PDO::PARAM_INT ? $aValue[0] : '\''.$aValue[0].'\'', $sLogSql); -// } -// -// if ($this->oLogger) -// { -// $this->oLogger->Write($sLogSql, \MailSo\Log\Enumerations\Type::INFO, 'SQLITE'); -// } - - $mResult = $oStmt->execute() ? $oStmt : null; - -// if ($this->oLogger) -// { -// $this->oLogger->Write('RESULT: '.($mResult ? 'true' : 'false'), \MailSo\Log\Enumerations\Type::INFO, 'SQLITE'); -// } - - return $mResult; - } - - /** - * @param \RainLoop\Account|null $oAccount - * @param bool $bSkipInsert = false - * - * @return int - */ - private function getUserId($oAccount, $bSkipInsert = false) - { - if (!$this->bUseDbPerUser) - { - $oStmt = $this->prepareAndExecute($oAccount, - 'SELECT IdUser FROM rlContactsUsers WHERE Email = :Email LIMIT 1', - array( - ':Email' => array($oAccount->ParentEmailHelper(), \PDO::PARAM_STR) - )); - - $mRow = $oStmt->fetch(\PDO::FETCH_ASSOC); - if ($mRow && isset($mRow['IdUser']) && \is_numeric($mRow['IdUser'])) - { - return (int) $mRow['IdUser']; - } - - if (!$bSkipInsert) - { - $oStmt->closeCursor(); - - $oStmt = $this->prepareAndExecute($oAccount, - 'INSERT INTO rlContactsUsers (Email) VALUES (:Email)', - array( - ':Email' => array($oAccount->ParentEmailHelper(), \PDO::PARAM_STR) - )); - - return $this->getUserId($oAccount, true); - } - - throw new \Exception('IdUser=0'); - } - - return 0; - } - - /** - * @param string $sSearch - * @return string - */ - private function convertSearchValue($sSearch) - { - return '%'.$sSearch.'%'; - } - - private function populateContactFromDB($iUserID, $aItem) - { - $oContact = null; - if (isset($aItem['IdContact'])) - { - $oContact = new \RainLoop\Providers\Contacts\Classes\Contact(); - $oContact->IdContact = (int) $aItem['IdContact']; - $oContact->IdUser = $iUserID; - $oContact->Type = (int) $aItem['Type']; - $oContact->Frec = (int) $aItem['Frec']; - $oContact->ListName = (string) $aItem['ListName']; - $oContact->Name = (string) $aItem['Name']; - $oContact->Emails = \explode(' ', \trim((string) $aItem['Emails'])); - $oContact->ImageHash = (string) $aItem['ImageHash']; - - $oContact->ParseData($aItem['Data']); - } - - return $oContact; - } - - /** - * @param \RainLoop\Account $oAccount - * @param int $iIdContact - * - * @return $oContact|null - */ - public function GetContactById($oAccount, $iIdContact) - { - $oResultContact = null; - - $iUserID = $this->getUserId($oAccount); - - $oStmt = $this->prepareAndExecute($oAccount, - 'SELECT IdContact, Type, Frec, ListName, Name, Emails, ImageHash, Data'. - ' FROM rlContactsItems WHERE IdContact = :IdContact AND IdUser = :IdUser LIMIT 1', - array( - ':IdContact' => array($iIdContact, \PDO::PARAM_INT), - ':IdUser' => array($iUserID, \PDO::PARAM_INT) - )); - - $aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC); - if (\is_array($aFetch) && isset($aFetch[0]) && \is_array($aFetch[0])) - { - $oContact = $this->populateContactFromDB($iUserID, $aFetch[0]); - if ($oContact instanceof \RainLoop\Providers\Contacts\Classes\Contact) - { - $oResultContact = $oContact; - } - } - - return $oResultContact; - } - - /** - * @param \RainLoop\Account $oAccount - * @param int $iOffset = 0 - * @param int $iLimit = 20 - * @param string $sSearch = '' - * - * @return array - */ - public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '') - { - $iOffset = 0 <= $iOffset ? $iOffset : 0; - $iLimit = 0 < $iLimit ? (int) $iLimit : 0; - $sSearch = \trim($sSearch); - - $iUserID = $this->getUserId($oAccount); - - $sSql = 'SELECT IdContact, Type, Frec, ListName, Name, Emails, ImageHash, Data'. - ' FROM rlContactsItems WHERE IdUser = :IdUser' - ; - - $aParams = array( - ':IdUser' => array($iUserID, \PDO::PARAM_INT), - ':limit' => array($iLimit, \PDO::PARAM_INT), - ':offset' => array($iOffset, \PDO::PARAM_INT) - ); - - if (0 < strlen($sSearch)) - { - if (\MailSo\Base\Utils::IsAscii($sSearch)) - { - $sSql .= ' AND Name LIKE :Search OR Emails LIKE :Search'; - $aParams[':Search'] = array($this->convertSearchValue($sSearch), \PDO::PARAM_STR); - } - else - { - $sSql .= ' AND SIMPLESEARCH(Emails, Name, :Search)'; - $aParams[':Search'] = array($sSearch, \PDO::PARAM_STR); - } - } - - $sSql .= ' ORDER BY ListName ASC LIMIT :limit OFFSET :offset'; - - $oStmt = $this->prepareAndExecute($oAccount, $sSql, $aParams); - - $aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC); - $aResult = array(); - if (\is_array($aFetch) && 0 < \count($aFetch)) - { - foreach ($aFetch as $aItem) - { - $oContact = $this->populateContactFromDB($iUserID, $aItem); - if ($oContact instanceof \RainLoop\Providers\Contacts\Classes\Contact) - { - $aResult[] = $oContact; - } - } - } - - unset($aFetch); - return $aResult; - } - - /** - * @param \RainLoop\Account $oAccount - * - * @return array - */ - public function GetContactsImageHashes($oAccount) - { - $iUserID = $this->getUserId($oAccount); - - $oStmt = $this->prepareAndExecute($oAccount, - 'SELECT Emails, ImageHash FROM rlContactsItems WHERE IdUser = :IdUser AND ImageHash <> :ImageHash', - array( - ':IdUser' => array($iUserID, \PDO::PARAM_INT), - ':ImageHash' => array('', \PDO::PARAM_STR) - )); - - $aFetch = $oStmt->fetchAll(\PDO::FETCH_ASSOC); - $aResult = array(); - - if (\is_array($aFetch) && 0 < \count($aFetch)) - { - foreach ($aFetch as $aItem) - { - if (!empty($aItem['Emails']) && !empty($aItem['ImageHash'])) - { - $aEmails = \explode(' ', $aItem['Emails']); - foreach ($aEmails as $sEmail) - { - $sEmail = \trim($sEmail); - if (0 < strlen($sEmail)) - { - $aResult[$sEmail] = $aItem['ImageHash']; - } - } - } - } - } - - unset($aFetch); - return $aResult; - } - - /** - * @param \RainLoop\Account $oAccount - * @param \RainLoop\Providers\Contacts\Classes\Contact $oContact - * - * @return bool - */ - public function CreateContact($oAccount, &$oContact) - { - $iUserID = $this->getUserId($oAccount); - - $oContact->IdUser = $iUserID; - - $oStmt = $this->prepareAndExecute($oAccount, - 'INSERT INTO rlContactsItems '. - '( IdUser, Type, Frec, ListName, Name, Emails, ImageHash, Data) VALUES '. - '(:IdUser, :Type, 0, :ListName, :Name, :Emails, :ImageHash, :Data)', - array( - ':IdUser' => array($oContact->IdUser, \PDO::PARAM_INT), - ':Type' => array($oContact->Type, \PDO::PARAM_INT), - ':ListName' => array($oContact->GenarateListName(), \PDO::PARAM_STR), - ':Name' => array($oContact->Name, \PDO::PARAM_STR), - ':Emails' => array($oContact->EmailsAsString(), \PDO::PARAM_STR), - ':ImageHash' => array($oContact->ImageHash, \PDO::PARAM_STR), - ':Data' => array($oContact->DataAsString(), \PDO::PARAM_STR), - )); - - if ($oStmt) - { - $iContactID = $this->getPDO($oAccount)->lastInsertId('IdContact'); - if (is_numeric($iContactID) && 0 < (int) $iContactID) - { - $oContact->IdContact = (int) $iContactID; - return true; - } - } - - throw new \Exception('CreateContact'); - } - - /** - * @param \RainLoop\Account $oAccount - * @param \RainLoop\Providers\Contacts\Classes\Contact $oContact - * - * @return bool - */ - public function UpdateContact($oAccount, &$oContact) - { - $iUserID = $this->getUserId($oAccount); - - $oContact->IdUser = $iUserID; - - return !!$this->prepareAndExecute($oAccount, - 'UPDATE rlContactsItems SET'. - ' Type = :Type, ListName = :ListName, Name = :Name, Emails = :Emails,'. - ' ImageHash = :ImageHash, Data = :Data'. - ' WHERE IdContact = :IdContact AND IdUser = :IdUser', - array( - ':IdContact' => array($oContact->IdContact, \PDO::PARAM_INT), - ':IdUser' => array($oContact->IdUser, \PDO::PARAM_INT), - ':Type' => array($oContact->Type, \PDO::PARAM_INT), - ':ListName' => array($oContact->GenarateListName(), \PDO::PARAM_STR), - ':Name' => array($oContact->Name, \PDO::PARAM_STR), - ':Emails' => array($oContact->EmailsAsString(), \PDO::PARAM_STR), - ':ImageHash' => array($oContact->ImageHash, \PDO::PARAM_STR), - ':Data' => array($oContact->DataAsString(), \PDO::PARAM_STR), - )); - } - - /** - * @param \RainLoop\Account $oAccount - * @param array $aContactIds - * - * @return bool - */ - public function DeleteContacts($oAccount, $aContactIds) - { - $iUserID = $this->getUserId($oAccount); - - $aParams = array( - ':IdUser' => array($iUserID, \PDO::PARAM_INT), - ); - - $aInQuery = array(); - foreach ($aContactIds as $iIndex => $iId) - { - $aInQuery[] = ':IdContact_'.$iIndex; - $aParams[':IdContact_'.$iIndex] = array($iId, \PDO::PARAM_INT); - } - - if (0 === \count($aInQuery)) - { - return false; - } - - return !!$this->prepareAndExecute($oAccount, - 'DELETE FROM rlContactsItems WHERE IdUser = :IdUser AND IdContact IN ('.\implode(', ', $aInQuery).')', - $aParams); - } - - /** - * @return bool - */ - public function IsSupported() - { - $aDrivers = \class_exists('PDO') ? \PDO::getAvailableDrivers() : array(); - return \is_array($aDrivers) ? \in_array('sqlite', $aDrivers) : false; - } - - /** - * @param \RainLoop\Account $oAccount - * @param array $aContactIds - * - * @return bool - */ - public function IncFrec($oAccount, $aContactIds) - { - if (\is_array($aContactIds) && 0 < \count($aContactIds)) - { - $iUserID = $this->getUserId($oAccount); - - $aParams = array( - ':IdUser' => array($iUserID, \PDO::PARAM_INT), - ); - - $aInQuery = array(); - foreach ($aContactIds as $iIndex => $iId) - { - $aInQuery[] = ':IdContact_'.$iIndex; - $aParams[':IdContact_'.$iIndex] = array($iId, \PDO::PARAM_INT); - } - - return !!$this->prepareAndExecute($oAccount, - 'UPDATE rlContactsItems SET Frec = Frec + 1 WHERE IdUser = :IdUser AND IdContact IN ('.\implode(', ', $aInQuery).')', - $aParams); - } - - return false; - } -} \ No newline at end of file diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook.php index 5d35af879..31d38df8c 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook.php @@ -42,6 +42,15 @@ class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider $this->oDriver->IsSupported(); } + /** + * @return bool + */ + public function IsSharingAllowed() + { + return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface && + $this->oDriver->IsSharingAllowed(); + } + /** * @return bool */ @@ -51,6 +60,19 @@ class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider $this->oDriver->IsSupported(); } + /** + * @param bool $bConsiderShare = true + */ + public function ConsiderShare($bConsiderShare = true) + { + if ($this->oDriver) + { + $this->oDriver->ConsiderShare($bConsiderShare); + } + + return $this; + } + /** * @param \RainLoop\Account $oAccount * @param \RainLoop\Providers\PersonalAddressBook\Classes\Contact $oContact @@ -78,16 +100,14 @@ class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider * @param int $iOffset = 0 * @param type $iLimit = 20 * @param string $sSearch = '' - * @param int $iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_ * @param int $iResultCount = 0 * * @return array */ - public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', - $iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_, &$iResultCount = 0) + public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0) { return $this->IsActive() ? $this->oDriver->GetContacts($oAccount, - $iOffset, $iLimit, $sSearch, $iScopeType, $iResultCount) : array(); + $iOffset, $iLimit, $sSearch, $iResultCount) : array(); } /** diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Classes/Contact.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Classes/Contact.php index b3a9efcbd..09723ccd4 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Classes/Contact.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Classes/Contact.php @@ -29,11 +29,6 @@ class Contact */ public $ScopeType; - /** - * @var string - */ - public $ScopeValue; - /** * @var int */ @@ -67,7 +62,6 @@ class Contact $this->DisplayName = ''; $this->DisplayEmail = ''; $this->ScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_; - $this->ScopeValue = ''; $this->Changed = \time(); $this->IdPropertyFromSearch = 0; $this->Properties = array(); @@ -84,7 +78,6 @@ class Contact if ($oProperty) { $oProperty->ScopeType = $this->ScopeType; - $oProperty->ScopeValue = $this->ScopeValue; $oProperty->UpdateDependentValues(); if ('' === $sDisplayName && \RainLoop\Providers\PersonalAddressBook\Enumerations\PropertyType::FULLNAME === $oProperty->Type && diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Classes/Property.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Classes/Property.php index 976a35f1e..58f86c0cf 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Classes/Property.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Classes/Property.php @@ -21,11 +21,6 @@ class Property */ public $ScopeType; - /** - * @var string - */ - public $ScopeValue; - /** * @var string */ @@ -39,7 +34,7 @@ class Property /** * @var string */ - public $ValueClear; + public $ValueCustom; /** * @var int @@ -57,11 +52,10 @@ class Property $this->Type = PropertyType::UNKNOWN; $this->ScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_; - $this->ScopeValue = ''; $this->TypeCustom = ''; $this->Value = ''; - $this->ValueClear = ''; + $this->ValueCustom = ''; $this->Frec = 0; } @@ -92,7 +86,7 @@ class Property { // trimer $this->Value = \trim($this->Value); - $this->ValueClear = \trim($this->ValueClear); + $this->ValueCustom = \trim($this->ValueCustom); $this->TypeCustom = \trim($this->TypeCustom); if (0 < \strlen($this->Value)) @@ -109,7 +103,7 @@ class Property $sPhone = $this->Value; $sPhone = \preg_replace('/^[+]+/', '', $sPhone); $sPhone = \preg_replace('/[^\d]/', '', $sPhone); - $this->ValueClear = $sPhone; + $this->ValueCustom = $sPhone; } } } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Enumerations/ScopeType.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Enumerations/ScopeType.php index 979df04f3..2e94c3cff 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Enumerations/ScopeType.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/Enumerations/ScopeType.php @@ -5,8 +5,5 @@ namespace RainLoop\Providers\PersonalAddressBook\Enumerations; class ScopeType { const DEFAULT_ = 0; - const AUTO = 1; const SHARE_ALL = 2; - const SHARE_DOMAIN = 3; - const SHARE_EMAIL = 4; } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/PdoPersonalAddressBook.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/PdoPersonalAddressBook.php index b3687359e..d68ce3c37 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/PdoPersonalAddressBook.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/PdoPersonalAddressBook.php @@ -28,16 +28,35 @@ class PdoPersonalAddressBook */ private $sPassword; + /** + * @var bool + */ + private $bConsiderShare; + public function __construct($sDsn, $sUser = '', $sPassword = '', $sDsnType = 'mysql') { $this->sDsn = $sDsn; $this->sUser = $sUser; $this->sPassword = $sPassword; $this->sDsnType = $sDsnType; + + $this->bConsiderShare = true; $this->bExplain = false; } + /** + * @param bool $bConsiderShare + * + * @return \RainLoop\Providers\PersonalAddressBook\PdoPersonalAddressBook + */ + public function ConsiderShare($bConsiderShare = true) + { + $this->bConsiderShare = !!$bConsiderShare; + + return $this; + } + /** * @return bool */ @@ -47,6 +66,22 @@ class PdoPersonalAddressBook return \is_array($aDrivers) ? \in_array($this->sDsnType, $aDrivers) : false; } + /** + * @return bool + */ + public function IsConsiderShare() + { + return $this->bConsiderShare; + } + + /** + * @return bool + */ + public function IsSharingAllowed() + { + return $this->IsConsiderShare() && $this->IsSupported(); + } + /** * @param \RainLoop\Account $oAccount * @param \RainLoop\Providers\PersonalAddressBook\Classes\Contact $oContact @@ -62,42 +97,14 @@ class PdoPersonalAddressBook $bUpdate = 0 < $iIdContact; - $oContact->UpdateDependentValues(); - $oContact->Changed = \time(); - - if (\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::AUTO !== $oContact->ScopeType) + if (!$this->bConsiderShare) { - $aEmail = $oContact->GetEmails(); - if (0 < \count($aEmail)) - { - $aEmail = \array_map(function ($sValue) { - return \strtolower(\trim($sValue)); - }, $aEmail); - - $aEmail = \array_filter($aEmail, function ($sValue) { - return !empty($sValue); - }); - - if (0 < \count($aEmail)) - { - $self = $this; - $aEmail = \array_map(function ($sValue) use ($self) { - return $self->quoteValue($sValue); - }, $aEmail); - - - // clear autocreated contacts - $this->prepareAndExecute( - 'DELETE FROM rainloop_pab_contacts WHERE id_user = :id_user AND scope_type = :scope_type AND display_email IN ('.\implode(',', $aEmail).')', - array( - ':scope_type' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::AUTO, \PDO::PARAM_INT), - ':id_user' => array($iUserID, \PDO::PARAM_INT) - ) - ); - } - } + $oContact->ScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_; } + $oContact->UpdateDependentValues(); + $oContact->Changed = \time(); + try { if ($this->isTransactionSupported()) @@ -111,7 +118,7 @@ class PdoPersonalAddressBook $aFreq = $this->getContactFreq($iUserID, $iIdContact); $sSql = 'UPDATE rainloop_pab_contacts SET display = :display, display_name = :display_name, display_email = :display_email, '. - 'scope_type = :scope_type, scope_value = :scope_value, changed = :changed WHERE id_user = :id_user AND id_contact = :id_contact'; + 'scope_type = :scope_type, changed = :changed WHERE id_user = :id_user AND id_contact = :id_contact'; $this->prepareAndExecute($sSql, array( @@ -121,7 +128,6 @@ class PdoPersonalAddressBook ':display_name' => array($oContact->DisplayName, \PDO::PARAM_STR), ':display_email' => array($oContact->DisplayEmail, \PDO::PARAM_STR), ':scope_type' => array($oContact->ScopeType, \PDO::PARAM_INT), - ':scope_value' => array($oContact->ScopeValue, \PDO::PARAM_STR), ':changed' => array($oContact->Changed, \PDO::PARAM_INT), ) ); @@ -138,8 +144,8 @@ class PdoPersonalAddressBook else { $sSql = 'INSERT INTO rainloop_pab_contacts '. - '( id_user, display, display_name, display_email, scope_type, scope_value, changed) VALUES '. - '(:id_user, :display, :display_name, :display_email, :scope_type, :scope_value, :changed)'; + '( id_user, display, display_name, display_email, scope_type, changed) VALUES '. + '(:id_user, :display, :display_name, :display_email, :scope_type, :changed)'; $this->prepareAndExecute($sSql, array( @@ -148,7 +154,6 @@ class PdoPersonalAddressBook ':display_name' => array($oContact->DisplayName, \PDO::PARAM_STR), ':display_email' => array($oContact->DisplayEmail, \PDO::PARAM_STR), ':scope_type' => array($oContact->ScopeType, \PDO::PARAM_INT), - ':scope_value' => array($oContact->ScopeValue, \PDO::PARAM_STR), ':changed' => array($oContact->Changed, \PDO::PARAM_INT) ) ); @@ -176,18 +181,17 @@ class PdoPersonalAddressBook ':id_contact' => array($iIdContact, \PDO::PARAM_INT), ':id_user' => array($iUserID, \PDO::PARAM_INT), ':scope_type' => array($oContact->ScopeType, \PDO::PARAM_INT), - ':scope_value' => array($oContact->ScopeValue, \PDO::PARAM_STR), ':prop_type' => array($oProp->Type, \PDO::PARAM_INT), ':prop_type_custom' => array($oProp->TypeCustom, \PDO::PARAM_STR), ':prop_value' => array($oProp->Value, \PDO::PARAM_STR), - ':prop_value_custom' => array($oProp->ValueClear, \PDO::PARAM_STR), + ':prop_value_custom' => array($oProp->ValueCustom, \PDO::PARAM_STR), ':prop_frec' => array($iFreq, \PDO::PARAM_INT), ); } $sSql = 'INSERT INTO rainloop_pab_properties '. - '( id_contact, id_user, prop_type, prop_type_custom, prop_value, prop_value_custom, scope_type, scope_value, prop_frec) VALUES '. - '(:id_contact, :id_user, :prop_type, :prop_type_custom, :prop_value, :prop_value_custom, :scope_type, :scope_value, :prop_frec)'; + '( id_contact, id_user, prop_type, prop_type_custom, prop_value, prop_value_custom, scope_type, prop_frec) VALUES '. + '(:id_contact, :id_user, :prop_type, :prop_type_custom, :prop_value, :prop_value_custom, :scope_type, :prop_frec)'; $this->prepareAndExecute($sSql, $aParams, true); } @@ -275,13 +279,11 @@ class PdoPersonalAddressBook * @param int $iOffset = 0 * @param int $iLimit = 20 * @param string $sSearch = '' - * @param bool $iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_ * @param int $iResultCount = 0 * * @return array */ - public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', - $iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_, &$iResultCount = 0) + public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0) { $this->Sync(); @@ -289,10 +291,7 @@ class PdoPersonalAddressBook $iLimit = 0 < $iLimit ? (int) $iLimit : 20; $sSearch = \trim($sSearch); - $sEmail = $oAccount->ParentEmailHelper(); - $sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail); - - $iUserID = $this->getUserId($sEmail); + $iUserID = $this->getUserId($oAccount->ParentEmailHelper()); $iCount = 0; $aSearchIds = array(); @@ -302,22 +301,27 @@ class PdoPersonalAddressBook { $sSql = 'SELECT id_user, id_prop, id_contact FROM rainloop_pab_properties '. 'WHERE ('. - '(id_user = :id_user)'. - ' OR (scope_type = :scope_type_share_all)'. - ' OR (scope_type = :scope_type_share_domain AND scope_value = :scope_value_domain)'. - ' OR (scope_type = :scope_type_share_email AND scope_value = :scope_value_email)'. - ') AND prop_value LIKE :search ESCAPE \'=\' GROUP BY id_contact, id_prop'; + 'id_user = :id_user'. + ($this->bConsiderShare ? ' OR scope_type = :scope_type_share_all' : ''). + ') AND (prop_value LIKE :search ESCAPE \'=\' OR ('. + 'prop_type IN ('.\implode(',', array( + PropertyType::PHONE_PERSONAL, PropertyType::PHONE_BUSSINES, PropertyType::PHONE_OTHER, + PropertyType::MOBILE_PERSONAL, PropertyType::MOBILE_BUSSINES, PropertyType::MOBILE_OTHER, + PropertyType::FAX_PERSONAL, PropertyType::FAX_BUSSINES, PropertyType::FAX_OTHER + )).') AND prop_value_custom LIKE :search_custom_phone'. + ')) GROUP BY id_contact, id_prop'; $aParams = array( ':id_user' => array($iUserID, \PDO::PARAM_INT), - ':scope_type_share_all' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL, \PDO::PARAM_INT), - ':scope_type_share_domain' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_DOMAIN, \PDO::PARAM_INT), - ':scope_type_share_email' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_EMAIL, \PDO::PARAM_INT), - ':scope_value_domain' => array($sDomain, \PDO::PARAM_STR), - ':scope_value_email' => array($sEmail, \PDO::PARAM_STR), - ':search' => array($this->specialConvertSearchValue($sSearch, '='), \PDO::PARAM_STR) + ':search' => array($this->specialConvertSearchValue($sSearch, '='), \PDO::PARAM_STR), + ':search_custom_phone' => array($this->specialConvertSearchValueCustomPhone($sSearch), \PDO::PARAM_STR) ); - + + if ($this->bConsiderShare) + { + $aParams[':scope_type_share_all'] = array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL, \PDO::PARAM_INT); + } + $oStmt = $this->prepareAndExecute($sSql, $aParams); if ($oStmt) { @@ -341,23 +345,19 @@ class PdoPersonalAddressBook else { $sSql = 'SELECT COUNT(DISTINCT id_contact) as contact_count FROM rainloop_pab_properties '. - 'WHERE ('. - '(id_user = :id_user)'. - ' OR (scope_type = :scope_type_share_all)'. - ' OR (scope_type = :scope_type_share_domain AND scope_value = :scope_value_domain)'. - ' OR (scope_type = :scope_type_share_email AND scope_value = :scope_value_email)'. - ')' + 'WHERE id_user = :id_user'. + ($this->bConsiderShare ? ' OR scope_type = :scope_type_share_all' : '') ; $aParams = array( - ':id_user' => array($iUserID, \PDO::PARAM_INT), - ':scope_type_share_all' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL, \PDO::PARAM_INT), - ':scope_type_share_domain' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_DOMAIN, \PDO::PARAM_INT), - ':scope_type_share_email' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_EMAIL, \PDO::PARAM_INT), - ':scope_value_domain' => array($sDomain, \PDO::PARAM_STR), - ':scope_value_email' => array($sEmail, \PDO::PARAM_STR) + ':id_user' => array($iUserID, \PDO::PARAM_INT) ); + if ($this->bConsiderShare) + { + $aParams[':scope_type_share_all'] = array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL, \PDO::PARAM_INT); + } + $oStmt = $this->prepareAndExecute($sSql, $aParams); if ($oStmt) { @@ -374,23 +374,19 @@ class PdoPersonalAddressBook if (0 < $iCount) { $sSql = 'SELECT * FROM rainloop_pab_contacts '. - 'WHERE ('. - '(id_user = :id_user)'. - ' OR (scope_type = :scope_type_share_all)'. - ' OR (scope_type = :scope_type_share_domain AND scope_value = :scope_value_domain)'. - ' OR (scope_type = :scope_type_share_email AND scope_value = :scope_value_email)'. - ')' + 'WHERE id_user = :id_user'. + ($this->bConsiderShare ? ' OR scope_type = :scope_type_share_all' : '') ; $aParams = array( - ':id_user' => array($iUserID, \PDO::PARAM_INT), - ':scope_type_share_all' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL, \PDO::PARAM_INT), - ':scope_type_share_domain' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_DOMAIN, \PDO::PARAM_INT), - ':scope_type_share_email' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_EMAIL, \PDO::PARAM_INT), - ':scope_value_domain' => array($sDomain, \PDO::PARAM_STR), - ':scope_value_email' => array($sEmail, \PDO::PARAM_STR) + ':id_user' => array($iUserID, \PDO::PARAM_INT) ); + if ($this->bConsiderShare) + { + $aParams[':scope_type_share_all'] = array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL, \PDO::PARAM_INT); + } + if (0 < \count($aSearchIds)) { $sSql .= ' AND id_contact IN ('.implode(',', $aSearchIds).')'; @@ -423,7 +419,6 @@ class PdoPersonalAddressBook $oContact->DisplayEmail = isset($aItem['display_email']) ? (string) $aItem['display_email'] : ''; $oContact->ScopeType = isset($aItem['scope_type']) ? (int) $aItem['scope_type'] : \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_; - $oContact->ScopeValue = isset($aItem['scope_value']) ? (string) $aItem['scope_value'] : ''; $oContact->Changed = isset($aItem['changed']) ? (int) $aItem['changed'] : 0; $oContact->ReadOnly = $iUserID !== (isset($aItem['id_user']) ? (int) $aItem['id_user'] : 0); @@ -460,11 +455,10 @@ class PdoPersonalAddressBook $oProperty->IdProperty = (int) $aItem['id_prop']; $oProperty->ScopeType = isset($aItem['scope_type']) ? (int) $aItem['scope_type'] : \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_; - $oProperty->ScopeValue = isset($aItem['scope_value']) ? (string) $aItem['scope_value'] : ''; $oProperty->Type = (int) $aItem['prop_type']; $oProperty->TypeCustom = isset($aItem['prop_type_custom']) ? (string) $aItem['prop_type_custom'] : ''; $oProperty->Value = (string) $aItem['prop_value']; - $oProperty->ValueClear = isset($aItem['prop_value_clear']) ? (string) $aItem['prop_value_clear'] : ''; + $oProperty->ValueCustom = isset($aItem['prop_value_custom']) ? (string) $aItem['prop_value_custom'] : ''; $oProperty->Frec = isset($aItem['prop_frec']) ? (int) $aItem['prop_frec'] : 0; $aContacts[$iId]->Properties[] = $oProperty; @@ -508,34 +502,29 @@ class PdoPersonalAddressBook $this->Sync(); - $sEmail = $oAccount->ParentEmailHelper(); - $sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail); - - $iUserID = $this->getUserId($sEmail); + $iUserID = $this->getUserId($oAccount->ParentEmailHelper()); $sTypes = implode(',', array( PropertyType::EMAIl_PERSONAL, PropertyType::EMAIl_BUSSINES, PropertyType::EMAIl_OTHER, PropertyType::FULLNAME )); - + $sSql = 'SELECT id_contact, id_prop, prop_type, prop_value FROM rainloop_pab_properties '. 'WHERE ('. - '(id_user = :id_user)'. - ' OR (scope_type = :scope_type_share_all)'. - ' OR (scope_type = :scope_type_share_domain AND scope_value = :scope_value_domain)'. - ' OR (scope_type = :scope_type_share_email AND scope_value = :scope_value_email)'. + 'id_user = :id_user'. + ($this->bConsiderShare ? ' OR scope_type = :scope_type_share_all' : ''). ') AND prop_type IN ('.$sTypes.') AND prop_value LIKE :search ESCAPE \'=\''; $aParams = array( ':id_user' => array($iUserID, \PDO::PARAM_INT), ':limit' => array($iLimit, \PDO::PARAM_INT), - ':scope_type_share_all' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL, \PDO::PARAM_INT), - ':scope_type_share_domain' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_DOMAIN, \PDO::PARAM_INT), - ':scope_type_share_email' => array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_EMAIL, \PDO::PARAM_INT), - ':scope_value_domain' => array($sDomain, \PDO::PARAM_STR), - ':scope_value_email' => array($sEmail, \PDO::PARAM_STR), ':search' => array($this->specialConvertSearchValue($sSearch, '='), \PDO::PARAM_STR) ); + if ($this->bConsiderShare) + { + $aParams[':scope_type_share_all'] = array(\RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::SHARE_ALL, \PDO::PARAM_INT); + } + $sSql .= ' ORDER BY prop_frec DESC'; $sSql .= ' LIMIT :limit'; @@ -765,7 +754,7 @@ class PdoPersonalAddressBook $oContact = new \RainLoop\Providers\PersonalAddressBook\Classes\Contact(); foreach ($aEmailsToCreate as $oEmail) { - $oContact->ScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::AUTO; + $oContact->ScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_; if ('' !== \trim($oEmail->GetEmail())) { @@ -1042,27 +1031,15 @@ SQLITEINITIAL; { case 'mysql': return $this->dataBaseUpgrade($this->sDsnType.'-pab-version', array( - 1 => $this->getInitialTablesArray($this->sDsnType), - 2 => array( - 'ALTER TABLE rainloop_pab_contacts ADD scope_value varchar(128) NOT NULL DEFAULT \'\' AFTER scope_type', - 'ALTER TABLE rainloop_pab_properties ADD scope_value varchar(128) NOT NULL DEFAULT \'\' AFTER scope_type' - ) + 1 => $this->getInitialTablesArray($this->sDsnType) )); case 'pgsql': return $this->dataBaseUpgrade($this->sDsnType.'-pab-version', array( - 1 => $this->getInitialTablesArray($this->sDsnType), - 2 => array( - 'ALTER TABLE rainloop_pab_contacts ADD scope_value varchar(128) NOT NULL DEFAULT \'\'', - 'ALTER TABLE rainloop_pab_properties ADD scope_value varchar(128) NOT NULL DEFAULT \'\'' - ) + 1 => $this->getInitialTablesArray($this->sDsnType) )); case 'sqlite': return $this->dataBaseUpgrade($this->sDsnType.'-pab-version', array( - 1 => $this->getInitialTablesArray($this->sDsnType), - 2 => array( - 'ALTER TABLE rainloop_pab_contacts ADD scope_value text NOT NULL default \'\'', - 'ALTER TABLE rainloop_pab_properties ADD scope_value text NOT NULL default \'\'' - ) + 1 => $this->getInitialTablesArray($this->sDsnType) )); } @@ -1109,6 +1086,7 @@ SQLITEINITIAL; /** * @param string $sSearch + * @param string $sEscapeSign = '=' * * @return string */ @@ -1118,6 +1096,16 @@ SQLITEINITIAL; array($sEscapeSign.$sEscapeSign, $sEscapeSign.'_', $sEscapeSign.'%'), $sSearch).'%'; } + /** + * @param string $sSearch + * + * @return string + */ + private function specialConvertSearchValueCustomPhone($sSearch) + { + return '%'.\preg_replace('/[^\d]/', '', $sSearch).'%'; + } + /** * @return array */ diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/PersonalAddressBookInterface.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/PersonalAddressBookInterface.php index c8f5887f4..482ad89d6 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/PersonalAddressBookInterface.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Providers/PersonalAddressBook/PersonalAddressBookInterface.php @@ -38,13 +38,11 @@ interface PersonalAddressBookInterface * @param int $iOffset = 0 * @param int $iLimit = 20 * @param string $sSearch = '' - * @param bool $iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_ * @param int $iResultCount = 0 * * @return array */ - public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', - $iScopeType = \RainLoop\Providers\PersonalAddressBook\Enumerations\ScopeType::DEFAULT_, &$iResultCount = 0); + public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0); /** * @param \RainLoop\Account $oAccount diff --git a/rainloop/v/0.0.0/app/templates/Themes/custom-values-dark.less b/rainloop/v/0.0.0/app/templates/Themes/custom-values-dark.less index 0b4733c28..ece02a71b 100644 --- a/rainloop/v/0.0.0/app/templates/Themes/custom-values-dark.less +++ b/rainloop/v/0.0.0/app/templates/Themes/custom-values-dark.less @@ -1,56 +1,56 @@ - -// MAIN -@main-color: #333; -@main-background-color: #48525C; -@main-background-image: link; - -// LOADING -@loading-color: #ddd; -@loading-text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.5); - -// LOGIN -@login-color: #eee; -@login-background-color: #2b333d; -@login-rgba-background-color: rgba(0,0,0,0.5); -@login-box-shadow: 0px 2px 10px rgba(0,0,0,0.5); -@login-border: none; -@login-border-radius: 7px; - -// MENU -@dropdown-menu-color: #333; -@dropdown-menu-background-color: #fff; -@dropdown-menu-hover-background-color: #48525C; -@dropdown-menu-hover-color: #eee; -@dropdown-menu-disable-color: #999; - -// FOLDERS -@folders-color: #fff; -@folders-disabled-color: #aaa; -@folders-selected-color: #fff; -@folders-selected-background-color: #2b333d; -@folders-selected-rgba-background-color: rgba(0,0,0,0.5); -@folders-hover-color: #fff; -@folders-hover-background-color: #2b333d; -@folders-hover-rgba-background-color: rgba(0,0,0,0.5); -@folders-drop-color: #fff; -@folders-drop-background-color: #2b333d; -@folders-drop-rgba-background-color: rgba(0,0,0,0.5); - -// SETTINGS -@settings-menu-color: #fff; -@settings-menu-disabled-color: #aaa; -@settings-menu-selected-color: #fff; -@settings-menu-selected-background-color: #2b333d; -@settings-menu-selected-rgba-background-color: rgba(0,0,0,0.5); -@settings-menu-hover-color: #fff; -@settings-menu-hover-background-color: #2b333d; -@settings-menu-hover-rgba-background-color: rgba(0,0,0,0.5); - -// MESSAGE LIST -@message-list-toolbar-background-color: #eee; -@message-list-toolbar-gradient-start: #f4f4f4; -@message-list-toolbar-gradient-end: #dfdfdf; - -// MESSAGE -@message-background-color: #fff; -@message-rgba-background-color: rgba(255,255,255,0.95); + +// MAIN +@main-color: #333; +@main-background-color: #48525C; +@main-background-image: link; + +// LOADING +@loading-color: #ddd; +@loading-text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.5); + +// LOGIN +@login-color: #eee; +@login-background-color: #2b333d; +@login-rgba-background-color: rgba(0,0,0,0.5); +@login-box-shadow: 0px 2px 10px rgba(0,0,0,0.5); +@login-border: none; +@login-border-radius: 7px; + +// MENU +@dropdown-menu-color: #333; +@dropdown-menu-background-color: #fff; +@dropdown-menu-hover-background-color: #48525C; +@dropdown-menu-hover-color: #eee; +@dropdown-menu-disable-color: #999; + +// FOLDERS +@folders-color: #fff; +@folders-disabled-color: #aaa; +@folders-selected-color: #fff; +@folders-selected-background-color: #2b333d; +@folders-selected-rgba-background-color: rgba(0,0,0,0.5); +@folders-hover-color: #fff; +@folders-hover-background-color: #2b333d; +@folders-hover-rgba-background-color: rgba(0,0,0,0.5); +@folders-drop-color: #fff; +@folders-drop-background-color: #2b333d; +@folders-drop-rgba-background-color: rgba(0,0,0,0.5); + +// SETTINGS +@settings-menu-color: #fff; +@settings-menu-disabled-color: #aaa; +@settings-menu-selected-color: #fff; +@settings-menu-selected-background-color: #2b333d; +@settings-menu-selected-rgba-background-color: rgba(0,0,0,0.5); +@settings-menu-hover-color: #fff; +@settings-menu-hover-background-color: #2b333d; +@settings-menu-hover-rgba-background-color: rgba(0,0,0,0.5); + +// MESSAGE LIST +@message-list-toolbar-background-color: #eee; +@message-list-toolbar-gradient-start: #f4f4f4; +@message-list-toolbar-gradient-end: #dfdfdf; + +// MESSAGE +@message-background-color: #fff; +@message-rgba-background-color: rgba(255,255,255,0.95); diff --git a/rainloop/v/0.0.0/app/templates/Themes/custom-values-light.less b/rainloop/v/0.0.0/app/templates/Themes/custom-values-light.less index 0061e6e61..7b0eef25b 100644 --- a/rainloop/v/0.0.0/app/templates/Themes/custom-values-light.less +++ b/rainloop/v/0.0.0/app/templates/Themes/custom-values-light.less @@ -1,55 +1,55 @@ - -// MAIN -@main-color: #333; -@main-background-color: #eee; -@main-background-image: link; - -// LOADING -@loading-color: #000; - -// LOGIN -@login-color: #eee; -@login-background-color: #757575; -@login-rgba-background-color: rgba(0,0,0,0.5); -@login-box-shadow: none; -@login-border: none; -@login-border-radius: 7px; - -// MENU -@dropdown-menu-color: #333; -@dropdown-menu-background-color: #fff; -@dropdown-menu-hover-background-color: #757575; -@dropdown-menu-hover-color: #eee; -@dropdown-menu-disable-color: #999; - -// FOLDERS -@folders-color: #000; -@folders-disabled-color: #999; -@folders-selected-color: #eee; -@folders-selected-background-color: #757575; -@folders-selected-rgba-background-color: rgba(0,0,0,0.5); -@folders-hover-color: #eee; -@folders-hover-background-color: #757575; -@folders-hover-rgba-background-color: rgba(0,0,0,0.5); -@folders-drop-color: #eee; -@folders-drop-background-color: #757575; -@folders-drop-rgba-background-color: rgba(0,0,0,0.5); - -// SETTINGS -@settings-menu-color: #000; -@settings-menu-disabled-color: #999; -@settings-menu-selected-color: #eee; -@settings-menu-selected-background-color: #757575; -@settings-menu-selected-rgba-background-color: rgba(0,0,0,0.5); -@settings-menu-hover-color: #eee; -@settings-menu-hover-background-color: #757575; -@settings-menu-hover-rgba-background-color: rgba(0,0,0,0.5); - -// MESSAGE LIST -@message-list-toolbar-background-color: #eee; -@message-list-toolbar-gradient-start: #f4f4f4; -@message-list-toolbar-gradient-end: #dfdfdf; - -// MESSAGE -@message-background-color: #fff; + +// MAIN +@main-color: #333; +@main-background-color: #eee; +@main-background-image: link; + +// LOADING +@loading-color: #000; + +// LOGIN +@login-color: #eee; +@login-background-color: #757575; +@login-rgba-background-color: rgba(0,0,0,0.5); +@login-box-shadow: none; +@login-border: none; +@login-border-radius: 7px; + +// MENU +@dropdown-menu-color: #333; +@dropdown-menu-background-color: #fff; +@dropdown-menu-hover-background-color: #757575; +@dropdown-menu-hover-color: #eee; +@dropdown-menu-disable-color: #999; + +// FOLDERS +@folders-color: #000; +@folders-disabled-color: #999; +@folders-selected-color: #eee; +@folders-selected-background-color: #757575; +@folders-selected-rgba-background-color: rgba(0,0,0,0.5); +@folders-hover-color: #eee; +@folders-hover-background-color: #757575; +@folders-hover-rgba-background-color: rgba(0,0,0,0.5); +@folders-drop-color: #eee; +@folders-drop-background-color: #757575; +@folders-drop-rgba-background-color: rgba(0,0,0,0.5); + +// SETTINGS +@settings-menu-color: #000; +@settings-menu-disabled-color: #999; +@settings-menu-selected-color: #eee; +@settings-menu-selected-background-color: #757575; +@settings-menu-selected-rgba-background-color: rgba(0,0,0,0.5); +@settings-menu-hover-color: #eee; +@settings-menu-hover-background-color: #757575; +@settings-menu-hover-rgba-background-color: rgba(0,0,0,0.5); + +// MESSAGE LIST +@message-list-toolbar-background-color: #eee; +@message-list-toolbar-gradient-start: #f4f4f4; +@message-list-toolbar-gradient-end: #dfdfdf; + +// MESSAGE +@message-background-color: #fff; @message-rgba-background-color: rgba(255,255,255,0.95); \ No newline at end of file diff --git a/rainloop/v/0.0.0/app/templates/Themes/template.less b/rainloop/v/0.0.0/app/templates/Themes/template.less index 6ca0ada70..6aedb2393 100644 --- a/rainloop/v/0.0.0/app/templates/Themes/template.less +++ b/rainloop/v/0.0.0/app/templates/Themes/template.less @@ -75,6 +75,10 @@ } } +.g-ui-menu .e-item.selected > .e-link { + background-color: @dropdown-menu-selected-background-color !important; +} + .g-ui-menu .e-item > .e-link:hover { color: @dropdown-menu-hover-color !important; background-color: @dropdown-menu-hover-background-color !important; diff --git a/rainloop/v/0.0.0/app/templates/Themes/values.less b/rainloop/v/0.0.0/app/templates/Themes/values.less index 090756782..c46a42665 100644 --- a/rainloop/v/0.0.0/app/templates/Themes/values.less +++ b/rainloop/v/0.0.0/app/templates/Themes/values.less @@ -1,59 +1,60 @@ - -// MAIN -@main-color: #333; -@main-background-color: #e3e3e3; -@main-background-image: none; // "images/background.png" - -// LOADING -@loading-color: #000; // #ddd -@loading-text-shadow: none; // 0px 1px 0px rgba(0, 0, 0, 0.5); - -// LOGIN -@login-color: #555; -@login-background-color: #eee; -@login-rgba-background-color: false; // rgba(0,0,0,0.7) -@login-box-shadow: none; // 0px 2px 10px rgba(0,0,0,0.5) -@login-border: 1px solid #ccc; -@login-border-radius: 7px; -@login-gradient-start: none; // #f4f4f4 -@login-gradient-end: none; // #dfdfdf - -// MENU -@dropdown-menu-color: #333; -@dropdown-menu-background-color: #fff; -@dropdown-menu-hover-background-color: #444; -@dropdown-menu-hover-color: #eee; -@dropdown-menu-disable-color: #999; - -// FOLDERS -@folders-color: #333; -@folders-disabled-color: #666; -@folders-selected-color: #eee; -@folders-selected-background-color: #333; -@folders-selected-rgba-background-color: false; -@folders-hover-color: #eee; -@folders-hover-background-color: #333; -@folders-hover-rgba-background-color: false; -@folders-drop-color: #eee; -@folders-drop-background-color: #333; -@folders-drop-rgba-background-color: false; - -// SETTINGS -@settings-menu-color: #333; -@settings-menu-disabled-color: #666; -@settings-menu-selected-color: #eee; -@settings-menu-selected-background-color: #333; -@settings-menu-selected-rgba-background-color: false; -@settings-menu-hover-color: #eee; -@settings-menu-hover-background-color: #333; -@settings-menu-hover-rgba-background-color: false; - -// MESSAGE LIST -@message-list-toolbar-background-color: #eee; -@message-list-toolbar-rgba-background-color: false; -@message-list-toolbar-gradient-start: none; // #f4f4f4 -@message-list-toolbar-gradient-end: none; // #dfdfdf - -// MESSAGE -@message-background-color: #fff; -@message-rgba-background-color: false; + +// MAIN +@main-color: #333; +@main-background-color: #e3e3e3; +@main-background-image: none; // "images/background.png" + +// LOADING +@loading-color: #000; // #ddd +@loading-text-shadow: none; // 0px 1px 0px rgba(0, 0, 0, 0.5); + +// LOGIN +@login-color: #555; +@login-background-color: #eee; +@login-rgba-background-color: false; // rgba(0,0,0,0.7) +@login-box-shadow: none; // 0px 2px 10px rgba(0,0,0,0.5) +@login-border: 1px solid #ccc; +@login-border-radius: 7px; +@login-gradient-start: none; // #f4f4f4 +@login-gradient-end: none; // #dfdfdf + +// MENU +@dropdown-menu-color: #333; +@dropdown-menu-background-color: #fff; +@dropdown-menu-hover-background-color: #444; +@dropdown-menu-hover-color: #eee; +@dropdown-menu-disable-color: #999; +@dropdown-menu-selected-background-color: #eee; + +// FOLDERS +@folders-color: #333; +@folders-disabled-color: #666; +@folders-selected-color: #eee; +@folders-selected-background-color: #333; +@folders-selected-rgba-background-color: false; +@folders-hover-color: #eee; +@folders-hover-background-color: #333; +@folders-hover-rgba-background-color: false; +@folders-drop-color: #eee; +@folders-drop-background-color: #333; +@folders-drop-rgba-background-color: false; + +// SETTINGS +@settings-menu-color: #333; +@settings-menu-disabled-color: #666; +@settings-menu-selected-color: #eee; +@settings-menu-selected-background-color: #333; +@settings-menu-selected-rgba-background-color: false; +@settings-menu-hover-color: #eee; +@settings-menu-hover-background-color: #333; +@settings-menu-hover-rgba-background-color: false; + +// MESSAGE LIST +@message-list-toolbar-background-color: #eee; +@message-list-toolbar-rgba-background-color: false; +@message-list-toolbar-gradient-start: none; // #f4f4f4 +@message-list-toolbar-gradient-end: none; // #dfdfdf + +// MESSAGE +@message-background-color: #fff; +@message-rgba-background-color: false; diff --git a/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html b/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html index b521e4c6a..038bdec5b 100644 --- a/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html +++ b/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html @@ -19,6 +19,10 @@ Enable contacts +
]*>/gim,"\n__bq__start__\n").replace(/<\/blockquote>/gim,"\n__bq__end__\n").replace(/]*>([\s\S]*?)<\/a>/gim,f).replace(/ /gi," ").replace(/<[^>]*>/gm,"").replace(/>/gi,">").replace(/</gi,"<").replace(/&/gi,"&").replace(/&\w{2,6};/gi,""),(a?pb.splitPlainText(b):b).replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/__bq__start__([\s\S]*)__bq__end__/gm,d).replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")},j.prototype.getHtmlFromText=function(){return pb.convertPlainTextToHtml(this.textarea.val())},j.prototype.switchToggle=function(){this.isHtml()?this.switchToPlain():this.switchToHtml() -},j.prototype.switchToPlain=function(c){c=pb.isUnd(c)?!0:c;var d=this.getTextFromHtml(),e=h.bind(function(a){a&&(this.toolbar.addClass("editorHideToolbar"),b(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!1)),this.textarea.val(d),this.textarea.show(),this.htmlarea.hide(),this.fOnSwitch&&this.fOnSwitch(!1))},this);c&&0!==pb.trim(d).length?e(a.confirm(this.oOptions.LangSwitcherConferm)):e(!0)},j.prototype.switcherLinkText=function(a){return a?this.oOptions.LangSwitcherTextLabel:this.oOptions.LangSwitcherHtmlLabel},j.prototype.switchToHtml=function(){this.toolbar.removeClass("editorHideToolbar"),b(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!0)),this.textarea.val(this.getHtmlFromText()),this.updateHtmlArea(),this.textarea.hide(),this.htmlarea.show(),this.fOnSwitch&&this.fOnSwitch(!0)},j.prototype.addButton=function(c,d){var e=this;b("").addClass("editorToolbarButtom").append(b('').addClass(c)).attr("title",d).click(function(d){pb.isUnd(j.htmlFunctions[c])?a.alert(c):j.htmlFunctions[c].apply(e,[b(this),d])}).appendTo(this.toolbar)},j.htmlInitToolbar=function(){this.bOnlyPlain||(this.addButton("bold","Bold"),this.addButton("italic","Italic"),this.addButton("underline","Underline"),this.addButton("strikethrough","Strikethrough"),this.addButton("removeformat","removeformat"),this.addButton("justifyleft","justifyleft"),this.addButton("justifycenter","justifycenter"),this.addButton("justifyright","justifyright"),this.addButton("horizontalrule","horizontalrule"),this.addButton("orderedlist","orderedlist"),this.addButton("unorderedlist","unorderedlist"),this.addButton("indent","indent"),this.addButton("outdent","outdent"),this.addButton("forecolor","forecolor"),function(a,b){a("").addClass("editorSwitcher").text(b.switcherLinkText(!0)).click(function(){b.switchToggle()}).appendTo(b.toolbar)}(b,this))},j.htmlInitEditor=function(){this.editor=this.htmlarea[0],this.editor.innerHTML=this.textarea.val()},j.htmlAttachEditorEvents=function(){var b=this,c=function(a){return a&&a.type&&0===a.type.indexOf("image/")},d=function(d){if(d=(d&&d.originalEvent?d.originalEvent:d)||a.event){d.stopPropagation(),d.preventDefault();var e=null,f=null,g=d.files||(d.dataTransfer?d.dataTransfer.files:null);g&&1===g.length&&c(g[0])&&(f=g[0],e=new a.FileReader,e.onload=function(a){return function(c){b.insertImage(c.target.result,a.name)}}(f),e.readAsDataURL(f))}b.htmlarea.removeClass("editorDragOver")},e=function(){b.htmlarea.removeClass("editorDragOver")},f=function(a){a.stopPropagation(),a.preventDefault(),b.htmlarea.addClass("editorDragOver")},g=function(d){var e=d&&d.clipboardData?d.clipboardData:d&&d.originalEvent&&d.originalEvent.clipboardData?d.originalEvent.clipboardData:null;e&&e.items&&h.each(e.items,function(d){if(c(d)&&d.getAsFile){var e=null,f=d.getAsFile();f&&(e=new a.FileReader,e.onload=function(a){return function(c){b.insertImage(c.target.result,a.name)}}(f),e.readAsDataURL(f))}})};this.bOnlyPlain||a.File&&a.FileReader&&a.FileList&&(this.htmlarea.bind("dragover",f),this.htmlarea.bind("dragleave",e),this.htmlarea.bind("drop",d),this.htmlarea.bind("paste",g))},j.htmlColorPickerColors=function(){var a=[],b=[],c=0,d=0,e=0,f=0,g="";for(c=0;256>c;c+=85)g=c.toString(16),a.push(1===g.length?"0"+g:g);for(f=a.length,c=0;f>c;c++)for(d=0;f>d;d++)for(e=0;f>e;e++)b.push("#"+a[c]+a[d]+a[e]);return b}(),j.htmlFontPicker=function(){var c=b(a.document),d=!1,e=b(''),f=e.find(".editorFpFonts"),g=function(){};return b.each(["Arial","Arial Black","Courier New","Tahoma","Times New Roman","Verdana"],function(a,c){f.append(b(''+c+"").click(function(){g(c)})),f.append("
")}),e.hide(),function(f,h,i){d||(e.appendTo(i),d=!0),g=h,c.unbind("click.fpNamespace"),a.setTimeout(function(){c.one("click.fpNamespace",function(){e.hide()})},500);var j=b(f).position();e.css("top",5+j.top+b(f).height()+"px").css("left",j.left+"px").show()}}(),j.htmlColorPicker=function(){var c=b(a.document),d=!1,e=b(''),f=e.find(".editorCpColors"),g=function(){};return b.each(j.htmlColorPickerColors,function(a,b){f.append('')}),e.hide(),b(".editorCpColor",f).click(function(a){var c=1,d="#000000",e=b(a.target).css("background-color"),f=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(null!==f){for(delete f[0];3>=c;++c)f[c]=pb.pInt(f[c]).toString(16),1===f[c].length&&(f[c]="0"+f[c]);d="#"+f.join("")}else d=e;g(d)}),function(f,h,i){d||(e.appendTo(i),d=!0);var j=b(f).position();g=h,c.unbind("click.cpNamespace"),a.setTimeout(function(){c.one("click.cpNamespace",function(){e.hide()})},100),e.css("top",5+j.top+b(f).height()+"px").css("left",j.left+"px").show()}}(),j.htmlFunctions={bold:function(){this.ec("bold")},italic:function(){this.ec("italic")},underline:function(){this.ec("underline")},strikethrough:function(){this.ec("strikethrough")},indent:function(){this.ec("indent")},outdent:function(){this.ec("outdent")},justifyleft:function(){this.ec("justifyLeft")},justifycenter:function(){this.ec("justifyCenter")},justifyright:function(){this.ec("justifyRight")},horizontalrule:function(){this.ec("insertHorizontalRule",!1,"ht")},removeformat:function(){this.ec("removeFormat")},orderedlist:function(){this.ec("insertorderedlist")},unorderedlist:function(){this.ec("insertunorderedlist")},forecolor:function(a){j.htmlColorPicker(a,h.bind(function(a){this.setcolor("forecolor",a)},this),this.toolbar)},backcolor:function(a){j.htmlColorPicker(a,h.bind(function(a){this.setcolor("backcolor",a)},this),this.toolbar)},fontname:function(a){j.htmlFontPicker(a,h.bind(function(a){this.ec("fontname",!1,a)},this),this.toolbar)}},k.prototype.selectItemCallbacks=function(a){(this.oCallbacks.onItemSelect||this.emptyFunction)(a)},k.prototype.goDown=function(){this.newSelectPosition(nb.EventKeyCode.Down,!1)},k.prototype.goUp=function(){this.newSelectPosition(nb.EventKeyCode.Up,!1)},k.prototype.init=function(d,e){if(this.oContentVisible=d,this.oContentScrollable=e,this.oContentVisible&&this.oContentScrollable){var f=this;b(this.oContentVisible).on("click",this.sItemSelector,function(a){f.actionClick(c.dataFor(this),a)}).on("click",this.sItemCheckedSelector,function(a){var b=c.dataFor(this);b&&(a&&a.shiftKey?f.actionClick(b,a):(f.sLastUid=f.getItemUid(b),b.selected()?(b.checked(!1),f.selectedItem(null)):b.checked(!b.checked())))}),b(a.document).on("keydown",function(a){var b=!0;return a&&f.bUseKeyboard&&!pb.inFocus()&&(-10)if(m){if(m)if(nb.EventKeyCode.Down===b||nb.EventKeyCode.Up===b||nb.EventKeyCode.Insert===b)h.each(k,function(a){if(!i)switch(b){case nb.EventKeyCode.Up:m===a?i=!0:j=a;break;case nb.EventKeyCode.Down:case nb.EventKeyCode.Insert:g?(j=a,i=!0):m===a&&(g=!0)}});else if(nb.EventKeyCode.Home===b||nb.EventKeyCode.End===b)nb.EventKeyCode.Home===b?j=k[0]:nb.EventKeyCode.End===b&&(j=k[k.length-1]);else if(nb.EventKeyCode.PageDown===b){for(;l>e;e++)if(m===k[e]){e+=f,e=e>l-1?l-1:e,j=k[e];break}}else if(nb.EventKeyCode.PageUp===b)for(e=l;e>=0;e--)if(m===k[e]){e-=f,e=0>e?0:e,j=k[e];break}}else nb.EventKeyCode.Down===b||nb.EventKeyCode.Insert===b||nb.EventKeyCode.Home===b||nb.EventKeyCode.PageUp===b?j=k[0]:(nb.EventKeyCode.Up===b||nb.EventKeyCode.End===b||nb.EventKeyCode.PageDown===b)&&(j=k[k.length-1]);j?(m&&(c?(nb.EventKeyCode.Up===b||nb.EventKeyCode.Down===b)&&m.checked(!m.checked()):nb.EventKeyCode.Insert===b&&m.checked(!m.checked())),this.throttleSelection=!0,this.selectedItem(j),this.throttleSelection=!0,0!==this.iSelectTimer?(a.clearTimeout(this.iSelectTimer),this.iSelectTimer=a.setTimeout(function(){d.iSelectTimer=0,d.actionClick(j)},1e3)):(this.iSelectTimer=a.setTimeout(function(){d.iSelectTimer=0},200),this.actionClick(j)),this.scrollToSelected()):m&&(!c||nb.EventKeyCode.Up!==b&&nb.EventKeyCode.Down!==b?nb.EventKeyCode.Insert===b&&m.checked(!m.checked()):m.checked(!m.checked()))},k.prototype.scrollToSelected=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var a=20,c=b(this.sItemSelectedSelector,this.oContentScrollable),d=c.position(),e=this.oContentVisible.height(),f=c.outerHeight();return d&&(d.top<0||d.top+f>e)?(d.top<0?this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+d.top-a):this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+d.top-e+f+a),!0):!1},k.prototype.eventClickFunction=function(a,b){var c=this.getItemUid(a),d=0,e=0,f=null,g="",h=!1,i=!1,j=[],k=!1;if(b&&b.shiftKey&&""!==c&&""!==this.sLastUid&&c!==this.sLastUid)for(j=this.list(),k=a.checked(),d=0,e=j.length;e>d;d++)f=j[d],g=this.getItemUid(f),h=!1,(g===this.sLastUid||g===c)&&(h=!0),h&&(i=!i),(i||h)&&f.checked(k);this.sLastUid=""===c?"":c},k.prototype.actionClick=function(a,b){if(a){var c=!0,d=this.getItemUid(a);b&&(b.shiftKey?(c=!1,""===this.sLastUid&&(this.sLastUid=d),a.checked(!a.checked()),this.eventClickFunction(a,b)):b.ctrlKey&&(c=!1,this.sLastUid=d,a.checked(!a.checked()))),c&&(this.selectedItem(a),this.sLastUid=d)}},k.prototype.on=function(a,b){this.oCallbacks[a]=b},l.supported=function(){return!0},l.prototype.set=function(a,c){var d=b.cookie(mb.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(mb.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},l.prototype.get=function(a){var c=b.cookie(mb.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!pb.isUnd(d[a])?d[a]:null}catch(e){}return d},m.supported=function(){return!!a.localStorage},m.prototype.set=function(b,c){var d=a.localStorage[mb.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[mb.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},m.prototype.get=function(b){var c=a.localStorage[mb.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!pb.isUnd(d[b])?d[b]:null}catch(e){}return d},n.prototype.oDriver=null,n.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},n.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},o.prototype.bootstart=function(){},p.prototype.sPosition="",p.prototype.sTemplate="",p.prototype.viewModelName="",p.prototype.viewModelDom=null,p.prototype.viewModelTemplate=function(){return this.sTemplate},p.prototype.viewModelPosition=function(){return this.sPosition},p.prototype.cancelCommand=p.prototype.closeCommand=function(){},q.prototype.oCross=null,q.prototype.sScreenName="",q.prototype.aViewModels=[],q.prototype.viewModels=function(){return this.aViewModels},q.prototype.screenName=function(){return this.sScreenName},q.prototype.routes=function(){return null},q.prototype.__cross=function(){return this.oCross},q.prototype.__start=function(){var a=this.routes(),b=null,c=null;pb.isNonEmptyArray(a)&&(c=h.bind(this.onRoute||pb.emptyFunction,this),b=d.create(),h.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},r.constructorEnd=function(a){pb.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},r.prototype.sDefaultScreenName="",r.prototype.oScreens={},r.prototype.oBoot=null,r.prototype.oCurrentScreen=null,r.prototype.showLoading=function(){b("#rl-loading").show()},r.prototype.hideLoading=function(){b("#rl-loading").hide()},r.prototype.routeOff=function(){e.changed.active=!1},r.prototype.routeOn=function(){e.changed.active=!0},r.prototype.setBoot=function(a){return pb.isNormal(a)&&(this.oBoot=a),this},r.prototype.screen=function(a){return""===a||pb.isUnd(this.oScreens[a])?null:this.oScreens[a]},r.prototype.delegateRun=function(a,b,c){a&&a[b]&&a[b].apply(a,pb.isArray(c)?c:[])},r.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),f=e.viewModelPosition(),g=b("#rl-content #rl-"+f.toLowerCase()),h=null;a.__builded=!0,a.__vm=e,e.data=Bb.data(),e.viewModelName=a.__name,g&&1===g.length?(h=b(" ").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),h.appendTo(g),e.viewModelDom=h,a.__dom=h,"Popups"===f&&(e.cancelCommand=e.closeCommand=pb.createCommand(e,function(){ub.hideScreenPopup(a)})),qb.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),this.delegateRun(e,"onBuild",[h]),qb.runHook("view-model-post-build",[a.__name,e,h])):pb.log("Cannot find view model position: "+f)}return a?a.__vm:null},r.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},r.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1))},r.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),this.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),qb.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},r.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===pb.pString(a)&&(a=this.sDefaultScreenName),""!==a&&(d=this.screen(a),d||(d=this.screen(this.sDefaultScreenName),d&&(b=a+"/"+b,a=this.sDefaultScreenName)),d&&d.__started&&(d.__builded||(d.__builded=!0,pb.isNonEmptyArray(d.viewModels())&&h.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),this.delegateRun(d,"onBuild")),h.defer(function(){c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onHide"),pb.isNonEmptyArray(c.oCurrentScreen.viewModels())&&h.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),c.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onShow"),qb.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),pb.isNonEmptyArray(c.oCurrentScreen.viewModels())&&h.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),c.delegateRun(a.__vm,"onShow"),qb.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},r.prototype.startScreens=function(a){h.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),h.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),qb.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),qb.runHook("screen-post-start",[a.screenName(),a]))},this);var b=d.create();b.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,h.bind(this.screenOnRoute,this)),e.initialized.add(b.parse,b),e.changed.add(b.parse,b),e.init()},r.prototype.setHash=function(a,b,c){a="#"===a.substr(0,1)?a.substr(1):a,a="/"===a.substr(0,1)?a.substr(1):a,c=pb.isUnd(c)?!1:!!c,(pb.isUnd(b)?1:!b)?(e.changed.active=!0,e[c?"replaceHash":"setHash"](a),e.setHash(a)):(e.changed.active=!1,e[c?"replaceHash":"setHash"](a),e.changed.active=!0)},r.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},ub=new r,s.newInstanceFromJson=function(a){var b=new s;return b.initByJson(a)?b:null},s.prototype.name="",s.prototype.email="",s.prototype.privateType=null,s.prototype.clear=function(){this.email="",this.name="",this.privateType=null},s.prototype.validate=function(){return""!==this.name||""!==this.email},s.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},s.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},s.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=nb.EmailType.Facebook),null===this.privateType&&(this.privateType=nb.EmailType.Default)),this.privateType},s.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},s.prototype.parse=function(a){this.clear(),a=pb.trim(a);var b=/(?:"([^"]+)")? ?(.*?@[^>,]+)>?,? ?/g,c=b.exec(a);c?(this.name=c[1]||"",this.email=c[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)},s.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=pb.trim(a.Name),this.email=pb.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},s.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=pb.isUnd(b)?!1:!!b,c=pb.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+pb.encodeHtml(this.name)+"":c?pb.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=pb.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+pb.encodeHtml(d)+""+pb.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=pb.encodeHtml(d))):b&&(d=''+pb.encodeHtml(this.email)+""))),d},s.prototype.mailsoParse=function(a){if(a=pb.trim(a),""===a)return!1;for(var b=function(a,b,c){a+="";var d=a.length;return 0>b&&(b+=d),d="undefined"==typeof c?d:0>c?c+d:c+b,b>=a.length||0>b||b>d?!1:a.slice(b,d)},c=function(a,b,c,d){return 0>c&&(c+=a.length),d=void 0!==d?d:a.length,0>d&&(d=d+a.length-c),a.slice(0,c)+b.substr(0,d)+b.slice(d)+a.slice(c+d)},d="",e="",f="",g=!1,h=!1,i=!1,j=null,k=0,l=0,m=0;m").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+f.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(g),e.data=Bb.data(),e.viewModelDom=i,e.__rlSettingsData=f.__rlSettingsData,f.__dom=i,f.__builded=!0,f.__vm=e,c.applyBindings(e,i[0]),ub.delegateRun(e,"onBuild",[i])):pb.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&h.defer(function(){d.oCurrentSubScreen&&(ub.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),ub.delegateRun(d.oCurrentSubScreen,"onShow"),h.each(d.menu(),function(a){a.selected(e&&e.__rlSettingsData&&a.route===e.__rlSettingsData.Route)}),b("#rl-content .b-settings .b-content .content").scrollTop(0)),pb.windowResize()})):ub.setHash(Bb.link().settings(),!1,!0)},gb.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(ub.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},gb.prototype.onBuild=function(){h.each(tb.settings,function(a){a&&a.__rlSettingsData&&!h.find(tb["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!h.find(tb["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},gb.prototype.routes=function(){var a=h.find(tb.settings,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",c={subname:/^(.*)$/,normalize_:function(a,c){return c.subname=pb.isUnd(c.subname)?b:pb.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},h.extend(hb.prototype,q.prototype),hb.prototype.onShow=function(){Bb.setTitle(pb.i18n("TITLES/LOGIN"))},h.extend(ib.prototype,q.prototype),ib.prototype.oLastRoute={},ib.prototype.setNewTitle=function(){var a=Bb.data().accountEmail(),b=Bb.data().foldersInboxUnreadCount();Bb.setTitle((""===a?"":(b>0?"("+b+") ":" ")+a+" - ")+pb.i18n("TITLES/MAILBOX"))},ib.prototype.onShow=function(){this.setNewTitle()},ib.prototype.onRoute=function(a,b,c){var d=Bb.data(),e=Bb.cache().getFolderFullNameRaw(a),f=Bb.cache().getFolderFromCacheList(e);f&&(d.currentFolder(f).messageListPage(b).messageListSearch(c),!d.usePreviewPane()&&d.message()&&d.message(null),Bb.reloadMessageList())},ib.prototype.onStart=function(){var a=Bb.data(),b=function(){pb.windowResize()};(Bb.settingsGet("AllowAdditionalAccounts")||Bb.settingsGet("AllowIdentities"))&&Bb.accountsAndIdentities(),h.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&Bb.folderInformation("INBOX")},1e3),h.delay(function(){Bb.quota()},5e3),h.delay(function(){Bb.remote().appDelayStart(pb.emptyFunction)},35e3),xb.toggleClass("rl-no-preview-pane",!a.usePreviewPane()),a.folderList.subscribe(b),a.messageList.subscribe(b),a.message.subscribe(b),a.usePreviewPane.subscribe(function(a){xb.toggleClass("rl-no-preview-pane",!a)}),a.foldersInboxUnreadCount.subscribe(function(){this.setNewTitle()},this)},ib.prototype.onBuild=function(){sb.bMobileDevice||h.defer(function(){pb.initLayoutResizer("#rl-resizer-left","#rl-resizer-right","#rl-right",350,800,350,350,nb.ClientSideKeyName.MailBoxListSize)})},ib.prototype.routes=function(){var a=function(a,b){return b[0]=pb.pString(b[0]),b[1]=pb.pInt(b[1]),b[1]=0>=b[1]?1:b[1],b[2]=pb.pString(b[2]),""===a&&(b[0]="Inbox",b[1]=1),[decodeURI(b[0]),b[1],decodeURI(b[2])]},b=function(a,b){return b[0]=pb.pString(b[0]),b[1]=pb.pString(b[1]),""===a&&(b[0]="Inbox"),[decodeURI(b[0]),1,decodeURI(b[1])]};return[[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/,{normalize_:a}],[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/,{normalize_:a}],[/^([a-zA-Z0-9]+)\/(.+)\/?$/,{normalize_:b}],[/^([^\/]*)$/,{normalize_:a}]]},h.extend(jb.prototype,gb.prototype),jb.prototype.onShow=function(){Bb.setTitle(this.sSettingsTitle)},h.extend(kb.prototype,o.prototype),kb.prototype.oSettings=null,kb.prototype.oPlugins=null,kb.prototype.oLocal=null,kb.prototype.oLink=null,kb.prototype.oSubs={},kb.prototype.download=function(b){var c=null,d=null,e=navigator.userAgent.toLowerCase();return e&&(e.indexOf("chrome")>-1||e.indexOf("chrome")>-1)&&(c=document.createElement("a"),c.href=b,document.createEvent&&(d=document.createEvent("MouseEvents"),d&&d.initEvent&&c.dispatchEvent))?(d.initEvent("click",!0,!0),c.dispatchEvent(d),!0):(sb.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},kb.prototype.link=function(){return null===this.oLink&&(this.oLink=new i),this.oLink},kb.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new n),this.oLocal},kb.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=pb.isNormal(vb)?vb:{}),pb.isUnd(this.oSettings[a])?null:this.oSettings[a]},kb.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=pb.isNormal(vb)?vb:{}),this.oSettings[a]=b},kb.prototype.setTitle=function(b){b=(00&&0===d.length&&(d=b(a,0,m)),h=!0,k=m);break;case">":h&&(l=m,e=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,h=!1);break;case"(":g||h||i||(i=!0,k=m);break;case")":i&&(l=m,f=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,i=!1);break;case"\\":m++}m++}return 0===e.length&&(j=a.match(/[^@\s]+@\S+/i),j&&j[0]?e=j[0]:d=a),e.length>0&&0===d.length&&0===f.length&&(d=a.replace(e,"")),e=pb.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=pb.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=pb.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},s.prototype.inputoTagLine=function(){return 0 +$/,""),b=!0),b},v.prototype.isImage=function(){return-1 e;e++)d.push(a[e].toLine(b,c));return d.join(", ")},x.initEmailsFromJson=function(a){var b=0,c=0,d=null,e=[];if(pb.isNonEmptyArray(a))for(b=0,c=a.length;c>b;b++)d=s.newInstanceFromJson(a[b]),d&&e.push(d);return e},x.replyHelper=function(a,b,c){if(a&&0 d;d++)pb.isUnd(b[a[d].email])&&(b[a[d].email]=!0,c.push(a[d]))},x.prototype.clear=function(){this.folderFullNameRaw="",this.uid="",this.requestHash="",this.subject(""),this.size(0),this.dateTimeStampInUTC(0),this.priority(nb.MessagePriority.Normal),this.fromEmailString(""),this.toEmailsString(""),this.senderEmailsString(""),this.prefetched=!1,this.emails=[],this.from=[],this.to=[],this.cc=[],this.bcc=[],this.replyTo=[],this.newForAnimation(!1),this.deleted(!1),this.unseen(!1),this.flagged(!1),this.answered(!1),this.forwarded(!1),this.selected(!1),this.checked(!1),this.hasAttachments(!1),this.attachmentsMainType(""),this.body=null,this.isRtl(!1),this.isHtml(!1),this.hasImages(!1),this.attachments([]),this.priority(nb.MessagePriority.Normal),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)},x.prototype.initByJson=function(a){var b=!1;return a&&"Object/Message"===a["@Object"]&&(this.folderFullNameRaw=a.Folder,this.uid=a.Uid,this.requestHash=a.RequestHash,this.prefetched=!1,this.size(pb.pInt(a.Size)),this.from=x.initEmailsFromJson(a.From),this.to=x.initEmailsFromJson(a.To),this.cc=x.initEmailsFromJson(a.Cc),this.bcc=x.initEmailsFromJson(a.Bcc),this.replyTo=x.initEmailsFromJson(a.ReplyTo),this.subject(a.Subject),this.dateTimeStampInUTC(pb.pInt(a.DateTimeStampInUTC)),this.hasAttachments(!!a.HasAttachments),this.attachmentsMainType(a.AttachmentsMainType),this.fromEmailString(x.emailsToLine(this.from,!0)),this.toEmailsString(x.emailsToLine(this.to,!0)),this.parentUid(pb.pInt(a.ParentThread)),this.threads(pb.isArray(a.Threads)?a.Threads:[]),this.threadsLen(pb.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0),b},x.prototype.computeSenderEmail=function(){var a=Bb.data().sentFolder(),b=Bb.data().draftFolder();this.senderEmailsString(this.folderFullNameRaw===a||this.folderFullNameRaw===b?this.toEmailsString():this.fromEmailString())},x.prototype.initUpdateByMessageJson=function(a){var b=!1,c=nb.MessagePriority.Normal;return a&&"Object/Message"===a["@Object"]&&(c=pb.pInt(a.Priority),this.priority(-1 b;b++)d=v.newInstanceFromJson(a["@Collection"][b]),d&&(""!==d.cidWithOutTags&&0 +$/,""),b=h.find(c,function(b){return a===b.cidWithOutTags})),b||null},x.prototype.findAttachmentByContentLocation=function(a){var b=null,c=this.attachments();return pb.isNonEmptyArray(c)&&(b=h.find(c,function(b){return a===b.contentLocation})),b||null},x.prototype.messageId=function(){return this.sMessageId},x.prototype.inReplyTo=function(){return this.sInReplyTo},x.prototype.references=function(){return this.sReferences},x.prototype.fromAsSingleEmail=function(){return pb.isArray(this.from)&&this.from[0]?this.from[0].email:""},x.prototype.viewLink=function(){return Bb.link().messageViewLink(this.requestHash)},x.prototype.downloadLink=function(){return Bb.link().messageDownloadLink(this.requestHash)},x.prototype.replyEmails=function(a){var b=[],c=pb.isUnd(a)?{}:a;return x.replyHelper(this.replyTo,c,b),0===b.length&&x.replyHelper(this.from,c,b),b},x.prototype.replyAllEmails=function(a){var b=[],c=[],d=pb.isUnd(a)?{}:a;return x.replyHelper(this.replyTo,d,b),0===b.length&&x.replyHelper(this.from,d,b),x.replyHelper(this.to,d,b),x.replyHelper(this.cc,d,c),[b,c]},x.prototype.textBodyToString=function(){return this.body?this.body.html():""},x.prototype.attachmentsToStringLine=function(){var a=h.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0 =0&&e&&!f&&d.attr("src",e)}),c&&a.setTimeout(function(){d.print()},100))})},x.prototype.printMessage=function(){this.viewPopupMessage(!0)},x.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid},x.prototype.populateByMessageListItem=function(a){return this.folderFullNameRaw=a.folderFullNameRaw,this.uid=a.uid,this.requestHash=a.requestHash,this.subject(a.subject()),this.size(a.size()),this.dateTimeStampInUTC(a.dateTimeStampInUTC()),this.priority(a.priority()),this.fromEmailString(a.fromEmailString()),this.toEmailsString(a.toEmailsString()),this.emails=a.emails,this.from=a.from,this.to=a.to,this.cc=a.cc,this.bcc=a.bcc,this.replyTo=a.replyTo,this.unseen(a.unseen()),this.flagged(a.flagged()),this.answered(a.answered()),this.forwarded(a.forwarded()),this.selected(a.selected()),this.checked(a.checked()),this.hasAttachments(a.hasAttachments()),this.attachmentsMainType(a.attachmentsMainType()),this.moment(a.moment()),this.body=null,this.priority(nb.MessagePriority.Normal),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid(a.parentUid()),this.threads(a.threads()),this.threadsLen(a.threadsLen()),this.computeSenderEmail(),this -},x.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=pb.isUnd(a)?!1:a,this.hasImages(!1),this.body.data("rl-has-images",!1),b("[data-x-src]",this.body).each(function(){a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",b(this).attr("data-x-src")).removeAttr("data-x-src"):b(this).attr("src",b(this).attr("data-x-src")).removeAttr("data-x-src")}),b("[data-x-style-url]",this.body).each(function(){var a=pb.trim(b(this).attr("style"));a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+b(this).attr("data-x-style-url")).removeAttr("data-x-style-url")}),a&&(b("img.lazy",this.body).addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b(".RL-MailMessageView .messageView .messageItem .content")[0]}),yb.resize()),pb.windowResize(500))},x.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){a=pb.isUnd(a)?!1:a;var c=this;this.body.data("rl-init-internal-images",!0),b("[data-x-src-cid]",this.body).each(function(){var d=c.findAttachmentByCid(b(this).attr("data-x-src-cid"));d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-src-location]",this.body).each(function(){var d=c.findAttachmentByContentLocation(b(this).attr("data-x-src-location"));d||(d=c.findAttachmentByCid(b(this).attr("data-x-src-location"))),d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-style-cid]",this.body).each(function(){var a="",d="",e=c.findAttachmentByCid(b(this).attr("data-x-style-cid"));e&&e.linkPreview&&(d=b(this).attr("data-x-style-cid-name"),""!==d&&(a=pb.trim(b(this).attr("style")),a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+d+": url('"+e.linkPreview()+"')")))}),a&&!function(a,b){h.delay(function(){a.addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b})},300)}(b("img.lazy",c.body),b(".RL-MailMessageView .messageView .messageItem .content")[0]),pb.windowResize(500)}},y.newInstanceFromJson=function(a){var b=new y;return b.initByJson(a)?b.initComputed():null},y.prototype.initComputed=function(){return this.hasSubScribedSubfolders=c.computed(function(){return!!h.find(this.subFolders(),function(a){return a.subScribed()})},this),this.canBeEdited=c.computed(function(){return nb.FolderType.User===this.type()&&this.existen&&this.selectable},this),this.visible=c.computed(function(){var a=this.subScribed(),b=this.hasSubScribedSubfolders();return a||b&&(!this.existen||!this.selectable)},this),this.isSystemFolder=c.computed(function(){return nb.FolderType.User!==this.type()},this),this.hidden=c.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return this.isGmailFolder||a&&this.isNamespaceFolder||a&&!b},this),this.selectableForFolderList=c.computed(function(){return!this.isSystemFolder()&&this.selectable},this),this.messageCountAll=c.computed({read:this.privateMessageCountAll,write:function(a){pb.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this}),this.messageCountUnread=c.computed({read:this.privateMessageCountUnread,write:function(a){pb.isPosNumeric(a,!0)?this.privateMessageCountUnread(a):this.privateMessageCountUnread.valueHasMutated()},owner:this}),this.printableUnreadCount=c.computed(function(){var a=this.messageCountAll(),b=this.messageCountUnread(),c=this.type();if(nb.FolderType.Inbox===c&&Bb.data().foldersInboxUnreadCount(b),a>0){if(nb.FolderType.Draft===c)return""+a;if(b>0&&nb.FolderType.Trash!==c&&nb.FolderType.SentItems!==c)return""+b}return""},this),this.canBeDeleted=c.computed(function(){var a=this.isSystemFolder();return!a&&0===this.subFolders().length&&"INBOX"!==this.fullNameRaw},this),this.canBeSubScribed=c.computed(function(){return!this.isSystemFolder()&&this.selectable&&"INBOX"!==this.fullNameRaw},this),this.visible.subscribe(function(){pb.timeOutAction("folder-list-folder-visibility-change",function(){yb.trigger("folder-list-folder-visibility-change")},100)}),this.localName=c.computed(function(){sb.langChangeTrigger();var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case nb.FolderType.Inbox:b=pb.i18n("FOLDER_LIST/INBOX_NAME");break;case nb.FolderType.SentItems:b=pb.i18n("FOLDER_LIST/SENT_NAME");break;case nb.FolderType.Draft:b=pb.i18n("FOLDER_LIST/DRAFTS_NAME");break;case nb.FolderType.Spam:b=pb.i18n("FOLDER_LIST/SPAM_NAME");break;case nb.FolderType.Trash:b=pb.i18n("FOLDER_LIST/TRASH_NAME")}return b},this),this.manageFolderSystemName=c.computed(function(){sb.langChangeTrigger();var a="",b=this.type(),c=this.name();if(this.isSystemFolder())switch(b){case nb.FolderType.Inbox:a="("+pb.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case nb.FolderType.SentItems:a="("+pb.i18n("FOLDER_LIST/SENT_NAME")+")";break;case nb.FolderType.Draft:a="("+pb.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case nb.FolderType.Spam:a="("+pb.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case nb.FolderType.Trash:a="("+pb.i18n("FOLDER_LIST/TRASH_NAME")+")"}return(""!==a&&"("+c+")"===a||"(inbox)"===a.toLowerCase())&&(a=""),a},this),this.collapsed=c.computed({read:function(){return!this.hidden()&&this.collapsedPrivate()},write:function(a){this.collapsedPrivate(a)},owner:this}),this},y.prototype.fullName="",y.prototype.fullNameRaw="",y.prototype.fullNameHash="",y.prototype.delimiter="",y.prototype.namespace="",y.prototype.deep=0,y.prototype.interval=0,y.prototype.isNamespaceFolder=!1,y.prototype.isGmailFolder=!1,y.prototype.isUnpaddigFolder=!1,y.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"},y.prototype.initByJson=function(a){var b=!1;return a&&"Object/Folder"===a["@Object"]&&(this.name(a.Name),this.delimiter=a.Delimiter,this.fullName=a.FullName,this.fullNameRaw=a.FullNameRaw,this.fullNameHash=a.FullNameHash,this.deep=a.FullNameRaw.split(this.delimiter).length-1,this.selectable=!!a.IsSelectable,this.existen=!!a.IsExisten,this.subScribed(!!a.IsSubscribed),this.type("INBOX"===this.fullNameRaw?nb.FolderType.Inbox:nb.FolderType.User),b=!0),b},y.prototype.printableFullName=function(){return this.fullName.split(this.delimiter).join(" / ")},z.prototype.email="",z.prototype.changeAccountLink=function(){return Bb.link().change(this.email)},A.prototype.formattedName=function(){var a=this.name();return""===a?this.email():a+" <"+this.email()+">"},A.prototype.formattedNameForCompose=function(){var a=this.name();return""===a?this.email():a+" ("+this.email()+")"},A.prototype.formattedNameForEmail=function(){var a=this.name();return""===a?this.email():'"'+pb.quoteName(a)+'" <'+this.email()+">"},pb.extendAsViewModel("PopupsFolderClearViewModel",B),B.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},B.prototype.onShow=function(a){this.clearPopup(),a&&this.selectedFolder(a)},B.prototype.onBuild=function(){var a=this;yb.on("keydown",function(b){var c=!0;return b&&nb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(ub.delegateRun(a,"cancelCommand"),c=!1),c})},pb.extendAsViewModel("PopupsFolderCreateViewModel",C),C.prototype.sNoParentText="",C.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(pb.trim(a))},C.prototype.clearPopup=function(){this.folderName(""),this.selectedParentValue(""),this.focusTrigger(!1)},C.prototype.onShow=function(){this.clearPopup(),this.focusTrigger(!0)},C.prototype.onBuild=function(){var a=this;yb.on("keydown",function(b){var c=!0;return b&&nb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(ub.delegateRun(a,"cancelCommand"),c=!1),c})},pb.extendAsViewModel("PopupsFolderSystemViewModel",D),D.prototype.sChooseOnText="",D.prototype.sUnuseText="",D.prototype.onShow=function(a){var b="";switch(a=pb.isUnd(a)?nb.SetSystemFoldersNotification.None:a){case nb.SetSystemFoldersNotification.Sent:b=pb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case nb.SetSystemFoldersNotification.Draft:b=pb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case nb.SetSystemFoldersNotification.Spam:b=pb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case nb.SetSystemFoldersNotification.Trash:b=pb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH")}this.notification(b)},D.prototype.onBuild=function(){var a=this;yb.on("keydown",function(b){var c=!0;return b&&nb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(ub.delegateRun(a,"cancelCommand"),c=!1),c})},pb.extendAsViewModel("PopupsComposeViewModel",E),E.prototype.findIdentityIdByMessage=function(a,b){var c={},d="",e=function(a){return a&&a.email&&c[a.email]?(d=c[a.email],!0):!1};switch(this.bAllowIdentities&&h.each(this.identities(),function(a){c[a.email()]=a.id}),c[Bb.data().accountEmail()]=Bb.data().accountEmail(),a){case nb.ComposeType.Empty:d=Bb.data().accountEmail();break;case nb.ComposeType.Reply:case nb.ComposeType.ReplyAll:case nb.ComposeType.Forward:case nb.ComposeType.ForwardAsAttachment:h.find(h.union(b.to,b.cc,b.bcc),e);break;case nb.ComposeType.Draft:h.find(h.union(b.from,b.replyTo),e)}return d},E.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)},E.prototype.formattedFrom=function(a){var b=Bb.data().displayName(),c=Bb.data().accountEmail();return""===b?c:(pb.isUnd(a)?1:!a)?b+" ("+c+")":'"'+pb.quoteName(b)+'" <'+c+">"},E.prototype.sendMessageResponse=function(b,c){var d=!1;this.sending(!1),nb.StorageResultType.Success===b&&c&&c.Result&&(d=!0,this.modalVisibility()&&ub.delegateRun(this,"closeCommand")),this.modalVisibility()&&!d&&(c&&nb.Notification.CantSaveMessage===c.ErrorCode?(this.sendSuccessButSaveError(!0),a.alert(pb.trim(pb.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(this.sendError(!0),a.alert(pb.getNotification(c&&c.ErrorCode?c.ErrorCode:nb.Notification.CantSendMessage))))},E.prototype.saveMessageResponse=function(b,c){var d=!1,e=null;this.saving(!1),nb.StorageResultType.Success===b&&c&&c.Result&&c.Result.NewFolder&&c.Result.NewUid&&(this.bFromDraft&&(e=Bb.data().message(),e&&this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid&&Bb.data().message(null)),this.draftFolder(c.Result.NewFolder),this.draftUid(c.Result.NewUid),this.modalVisibility()&&(this.savedTime(Math.round((new a.Date).getTime()/1e3)),this.savedOrSendingText(0 b;b++)d.push(a[b].toLine(!1));return d.join(", ")};if(c=c||null,c&&pb.isNormal(c)&&(t=pb.isArray(c)&&1===c.length?c[0]:pb.isArray(c)?null:c),null!==q&&(p[q]=!0,this.currentIdentityID(this.findIdentityIdByMessage(v,t))),this.reset(),pb.isNonEmptyArray(d)&&this.to(w(d)),""!==v&&t){switch(j=t.fullFormatDateValue(),k=t.subject(),s=t.aDraftInfo,l=b(t.body).clone(),pb.removeBlockquoteSwitcher(l),m=l.html(),v){case nb.ComposeType.Empty:break;case nb.ComposeType.Reply:this.to(w(t.replyEmails(p))),this.subject(pb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(t,v),this.aDraftInfo=["reply",t.uid,t.folderFullNameRaw],this.sInReplyTo=t.sMessageId,this.sReferences=pb.trim(this.sInReplyTo+" "+t.sReferences),u=!0;break;case nb.ComposeType.ReplyAll:o=t.replyAllEmails(p),this.to(w(o[0])),this.cc(w(o[1])),this.subject(pb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(t,v),this.aDraftInfo=["reply",t.uid,t.folderFullNameRaw],this.sInReplyTo=t.sMessageId,this.sReferences=pb.trim(this.sInReplyTo+" "+t.references()),u=!0;break;case nb.ComposeType.Forward:this.subject(pb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(t,v),this.aDraftInfo=["forward",t.uid,t.folderFullNameRaw],this.sInReplyTo=t.sMessageId,this.sReferences=pb.trim(this.sInReplyTo+" "+t.sReferences);break;case nb.ComposeType.ForwardAsAttachment:this.subject(pb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(t,v),this.aDraftInfo=["forward",t.uid,t.folderFullNameRaw],this.sInReplyTo=t.sMessageId,this.sReferences=pb.trim(this.sInReplyTo+" "+t.sReferences);break;case nb.ComposeType.Draft:this.to(w(t.to)),this.cc(w(t.cc)),this.bcc(w(t.bcc)),this.bFromDraft=!0,this.draftFolder(t.folderFullNameRaw),this.draftUid(t.uid),this.subject(k),this.prepearMessageAttachments(t,v),this.aDraftInfo=pb.isNonEmptyArray(s)&&3===s.length?s:null,this.sInReplyTo=t.sInReplyTo,this.sReferences=t.sReferences}if(this.oEditor){switch(v){case nb.ComposeType.Reply:case nb.ComposeType.ReplyAll:f=t.fromToLine(!1,!0),n=pb.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:j,EMAIL:f}),m="
"+n+":";break;case nb.ComposeType.Forward:f=t.fromToLine(!1,!0),g=t.toToLine(!1,!0),i=t.ccToLine(!1,!0),m="
"+m+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+f+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+g+(0"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+i:"")+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+pb.encodeHtml(j)+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+pb.encodeHtml(k)+"
"+m;break;case nb.ComposeType.ForwardAsAttachment:m=""}this.oEditor.setRawText(m,t.isHtml())}}else this.oEditor&&nb.ComposeType.Empty===v?this.oEditor.setRawText("
"+pb.convertPlainTextToHtml(Bb.data().signature()),nb.EditorDefaultType.Html===Bb.data().editorDefaultType()):pb.isNonEmptyArray(c)&&h.each(c,function(a){e.addMessageAsAttachment(a)});""===this.to()&&this.to.focusTrigger(!this.to.focusTrigger()),r=this.getAttachmentsDownloadsForUpload(),pb.isNonEmptyArray(r)&&Bb.remote().messageUploadAttachments(function(a,b){if(nb.StorageResultType.Success===a&&b&&b.Result){var c=null,d="";if(!e.viewModelVisibility())for(d in b.Result)b.Result.hasOwnProperty(d)&&(c=e.getAttachmentById(b.Result[d]),c&&c.tempName(d))}else e.setMessageAttachmentFailedDowbloadText()},r),u&&this.oEditor&&this.oEditor.focus(),this.triggerForResize()},E.prototype.tryToClosePopup=function(){var a=this;ub.showScreenPopup(K,[pb.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&ub.delegateRun(a,"closeCommand")}])},E.prototype.onBuild=function(){this.initEditor(),this.initUploader();var a=this,c=null;yb.on("keydown",function(b){var c=!0;return b&&a.modalVisibility()&&Bb.data().useKeyboardShortcuts()&&(b.ctrlKey&&nb.EventKeyCode.S===b.keyCode?(a.saveCommand(),c=!1):b.ctrlKey&&nb.EventKeyCode.Enter===b.keyCode?(a.sendCommand(),c=!1):nb.EventKeyCode.Esc===b.keyCode&&(a.tryToClosePopup(),c=!1)),c}),yb.on("resize",function(){a.triggerForResize()}),this.dropboxEnabled()&&(c=document.createElement("script"),c.type="text/javascript",c.src="https://www.dropbox.com/static/api/1/dropins.js",b(c).attr("id","dropboxjs").attr("data-app-key",Bb.settingsGet("DropboxApiKey")),document.body.appendChild(c))},E.prototype.getAttachmentById=function(a){for(var b=this.attachments(),c=0,d=b.length;d>c;c++)if(b[c]&&a===b[c].id)return b[c];return null},E.prototype.initEditor=function(){if(this.composeEditorTextArea()&&this.composeEditorHtmlArea()&&this.composeEditorToolbar()){var a=this;this.oEditor=new j(this.composeEditorTextArea(),this.composeEditorHtmlArea(),this.composeEditorToolbar(),{onSwitch:function(b){b||a.removeLinkedAttachments()}}),this.oEditor.initLanguage(pb.i18n("EDITOR/TEXT_SWITCHER_CONFIRM"),pb.i18n("EDITOR/TEXT_SWITCHER_PLAINT_TEXT"),pb.i18n("EDITOR/TEXT_SWITCHER_RICH_FORMATTING"))}},E.prototype.initUploader=function(){if(this.composeUploaderButton()){var a={},b=pb.pInt(Bb.settingsGet("AttachmentLimit")),c=new g({action:Bb.link().upload(),name:"uploader",queueSize:2,multipleSizeLimit:50,disableFolderDragAndDrop:!1,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace()});c?(c.on("onDragEnter",h.bind(function(){this.dragAndDropOver(!0)},this)).on("onDragLeave",h.bind(function(){this.dragAndDropOver(!1)},this)).on("onBodyDragEnter",h.bind(function(){this.dragAndDropVisible(!0)},this)).on("onBodyDragLeave",h.bind(function(){this.dragAndDropVisible(!1)},this)).on("onProgress",h.bind(function(b,c,d){var e=null;pb.isUnd(a[b])?(e=this.getAttachmentById(b),e&&(a[b]=e)):e=a[b],e&&e.progress(" - "+Math.floor(c/d*100)+"%")},this)).on("onSelect",h.bind(function(a,d){this.dragAndDropOver(!1);var e=this,f=pb.isUnd(d.FileName)?"":d.FileName.toString(),g=pb.isNormal(d.Size)?pb.pInt(d.Size):null,h=new w(a,f,g);return h.cancel=function(a){return function(){e.attachments.remove(function(b){return b&&b.id===a}),c&&c.cancel(a)}}(a),this.attachments.push(h),g>0&&b>0&&g>b?(h.error(pb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(b){var c=null;pb.isUnd(a[b])?(c=this.getAttachmentById(b),c&&(a[b]=c)):c=a[b],c&&(c.waiting(!1),c.uploading(!0))},this)).on("onComplete",h.bind(function(b,c,d){var e="",f=null,g=null,h=this.getAttachmentById(b);g=c&&d&&d.Result&&d.Result.Attachment?d.Result.Attachment:null,f=d&&d.Result&&d.Result.ErrorCode?d.Result.ErrorCode:null,null!==f?e=pb.getUploadErrorDescByCode(f):g||(e=pb.i18n("UPLOAD/ERROR_UNKNOWN")),h&&(""!==e&&00&&d>0&&f>d?(e.uploading(!1),e.error(pb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(Bb.remote().composeUploadExternals(function(a,b){var c=!1;e.uploading(!1),nb.StorageResultType.Success===a&&b&&b.Result&&b.Result[e.id]&&(c=!0,e.tempName(b.Result[e.id])),c||e.error(pb.getUploadErrorDescByCode(nb.UploadErrorCode.FileNoUploaded))},[a.link]),!0)},E.prototype.prepearMessageAttachments=function(a,b){if(a){var c=this,d=pb.isNonEmptyArray(a.attachments())?a.attachments():[],e=0,f=d.length,g=null,h=null,i=!1,j=function(a){return function(){c.attachments.remove(function(b){return b&&b.id===a})}};if(nb.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f>e;e++){switch(h=d[e],i=!1,b){case nb.ComposeType.Reply:case nb.ComposeType.ReplyAll:i=h.isLinked;break;case nb.ComposeType.Forward:case nb.ComposeType.Draft:i=!0}i=!0,i&&(g=new w(h.download,h.fileName,h.estimatedSize,h.isInline,h.isLinked,h.cid,h.contentLocation),g.fromMessage=!0,g.cancel=j(h.download),g.waiting(!1).uploading(!0),this.attachments.push(g))}}},E.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})},E.prototype.setMessageAttachmentFailedDowbloadText=function(){h.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(pb.getUploadErrorDescByCode(nb.UploadErrorCode.FileNoUploaded))},this)},E.prototype.isEmptyForm=function(a){a=pb.isUnd(a)?!0:!!a;var b=a?0===this.attachments().length:0===this.attachmentsInReady().length;return 0===this.to().length&&0===this.cc().length&&0===this.bcc().length&&0===this.subject().length&&b&&""===this.oEditor.getTextForRequest()},E.prototype.reset=function(){this.to(""),this.cc(""),this.bcc(""),this.replyTo(""),this.subject(""),this.aDraftInfo=null,this.sInReplyTo="",this.bFromDraft=!1,this.sReferences="",this.bReloadFolder=!1,this.sendError(!1),this.sendSuccessButSaveError(!1),this.savedError(!1),this.savedTime(0),this.savedOrSendingText(""),this.emptyToError(!1),this.showCcAndBcc(!1),this.attachments([]),this.dragAndDropOver(!1),this.dragAndDropVisible(!1),this.draftFolder(""),this.draftUid(""),this.sending(!1),this.saving(!1),this.oEditor&&this.oEditor.clear()},E.prototype.getAttachmentsDownloadsForUpload=function(){return h.map(h.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})},E.prototype.triggerForResize=function(){this.resizer(!this.resizer())},pb.extendAsViewModel("PopupsContactsViewModel",F),F.prototype.addNewProperty=function(a){var b=new u(a,"");b.focused(!0),this.viewProperties.push(b)},F.prototype.addNewEmail=function(){this.addNewProperty(nb.ContactPropertyType.EmailPersonal)},F.prototype.addNewPhone=function(){this.addNewProperty(nb.ContactPropertyType.PhonePersonal)},F.prototype.removeCheckedOrSelectedContactsFromList=function(){var a=this,b=this.contacts,c=this.currentContact(),d=this.contacts().length,e=this.contactsCheckedOrSelected();0 =d&&(this.bDropPageAfterDelete=!0),h.delay(function(){h.each(e,function(a){b.remove(a)})},500))},F.prototype.deleteSelectedContacts=function(){0 0?d:0),b.contactsCount(d),b.contacts(e),b.viewClearSearch(""!==b.search()),b.contacts.loading(!1),""!==b.viewID()&&!b.currentContact()&&b.contacts.setSelectedByUid&&b.contacts.setSelectedByUid(""+b.viewID())},c,mb.Defaults.ContactsPerPage,this.search())},F.prototype.onBuild=function(a){this.oContentVisible=b(".b-list-content",a),this.oContentScrollable=b(".content",this.oContentVisible),this.selector.init(this.oContentVisible,this.oContentScrollable);var d=this;c.computed(function(){var a=this.modalVisibility(),b=Bb.data().useKeyboardShortcuts();this.selector.useKeyboard(a&&b)},this).extend({notify:"always"}),a.on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&(d.contactsPage(pb.pInt(a.value)),d.reloadContactList())}),yb.on("keydown",function(a){var b=!0;return a&&nb.EventKeyCode.Esc===a.keyCode&&d.modalVisibility()&&(ub.delegateRun(d,"closeCommand"),b=!1),b})},F.prototype.onShow=function(){ub.routeOff(),this.reloadContactList(!0)},F.prototype.onHide=function(){ub.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),h.each(this.contacts(),function(a){a.checked(!1)})},pb.extendAsViewModel("PopupsAdvancedSearchViewModel",G),G.prototype.buildSearchStringValue=function(a){return-1 0&&g.messageCountUnread(0<=g.messageCountUnread()-e?g.messageCountUnread()-e:0)),i&&(i.messageCountAll(i.messageCountAll()+b.length),e>0&&i.messageCountUnread(i.messageCountUnread()+e)),0 0&&(nb.EventKeyCode.Backspace===c||nb.EventKeyCode.Esc===c)&&d.viewModelVisibility()&&e.useKeyboardShortcuts()&&!pb.inFocus()&&e.message()&&(d.fullScreenMode(!1),e.usePreviewPane()||e.message(null),b=!1),b}),b(".attachmentsPlace",a).magnificPopup({delegate:".magnificPopupImage:visible",type:"image",gallery:{enabled:!0,preload:[1,1],navigateByImgClick:!0},callbacks:{open:function(){e.useKeyboardShortcuts(!1)},close:function(){e.useKeyboardShortcuts(!0)}},mainClass:"mfp-fade",removalDelay:400}),a.on("click",".attachmentsPlace .attachmentPreview",function(a){a&&a.stopPropagation&&a.stopPropagation()}).on("click",".attachmentsPlace .attachmentItem",function(){var a=c.dataFor(this);a&&a.download&&Bb.download(a.linkDownload())}),this.oMessageScrollerDom=a.find(".messageItem .content"),this.oMessageScrollerDom=this.oMessageScrollerDom&&this.oMessageScrollerDom[0]?this.oMessageScrollerDom:null},R.prototype.isDraftFolder=function(){return Bb.data().message()&&Bb.data().draftFolder()===Bb.data().message().folderFullNameRaw},R.prototype.isSentFolder=function(){return Bb.data().message()&&Bb.data().sentFolder()===Bb.data().message().folderFullNameRaw},R.prototype.isDraftOrSentFolder=function(){return this.isDraftFolder()||this.isSentFolder()},R.prototype.composeClick=function(){ub.showScreenPopup(E)},R.prototype.editMessage=function(){Bb.data().message()&&ub.showScreenPopup(E,[nb.ComposeType.Draft,Bb.data().message()])},R.prototype.scrollMessageToTop=function(){this.oMessageScrollerDom&&this.oMessageScrollerDom.scrollTop(0)},R.prototype.showImages=function(a){a&&a.showExternalImages&&a.showExternalImages(!0)},pb.extendAsViewModel("SettingsMenuViewModel",S),S.prototype.link=function(a){return Bb.link().settings(a)},S.prototype.backToMailBoxClick=function(){ub.setHash(Bb.link().inbox())},pb.extendAsViewModel("SettingsPaneViewModel",T),T.prototype.onShow=function(){Bb.data().message(null)},T.prototype.backToMailBoxClick=function(){ub.setHash(Bb.link().inbox())},pb.addSettingsViewModel(U,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0),U.prototype.onBuild=function(){var a=this;h.delay(function(){var c=Bb.data(),d=pb.settingsSaveHelperSimpleFunction(a.mppTrigger,a);c.language.subscribe(function(c){a.languageTrigger(nb.SaveSettingsStep.Animate),b.ajax({url:Bb.link().langLink(c),dataType:"script",cache:!0}).done(function(){pb.i18nToDoc(),a.languageTrigger(nb.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(nb.SaveSettingsStep.FalseResult)}).always(function(){h.delay(function(){a.languageTrigger(nb.SaveSettingsStep.Idle)},1e3)}),Bb.remote().saveSettings(pb.emptyFunction,{Language:c})}),c.editorDefaultType.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{EditorDefaultType:a})}),c.messagesPerPage.subscribe(function(a){Bb.remote().saveSettings(d,{MPP:a})}),c.showImages.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{ShowImages:a?"1":"0"})}),c.interfaceAnimation.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{InterfaceAnimation:a})}),c.useDesktopNotifications.subscribe(function(a){pb.timeOutAction("SaveDesktopNotifications",function(){Bb.remote().saveSettings(pb.emptyFunction,{DesktopNotifications:a?"1":"0"})},3e3)}),c.replySameFolder.subscribe(function(a){pb.timeOutAction("SaveReplySameFolder",function(){Bb.remote().saveSettings(pb.emptyFunction,{ReplySameFolder:a?"1":"0"})},3e3)}),c.useThreads.subscribe(function(a){c.messageList([]),Bb.remote().saveSettings(pb.emptyFunction,{UseThreads:a?"1":"0"})}),c.usePreviewPane.subscribe(function(a){c.messageList([]),Bb.remote().saveSettings(pb.emptyFunction,{UsePreviewPane:a?"1":"0"})}),c.useCheckboxesInList.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)},U.prototype.onShow=function(){Bb.data().desktopNotifications.valueHasMutated()},U.prototype.selectLanguage=function(){ub.showScreenPopup(J)},pb.addSettingsViewModel(V,"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts"),V.prototype.addNewAccount=function(){ub.showScreenPopup(H)},V.prototype.deleteAccount=function(a){if(a&&a.deleteAccess()){this.accountForDeletion(null);var b=function(b){return a===b};a&&(this.accounts.remove(b),Bb.remote().accountDelete(function(){Bb.accountsAndIdentities()},a.email))}},pb.addSettingsViewModel(W,"SettingsIdentity","SETTINGS_LABELS/LABEL_IDENTITY_NAME","identity"),W.prototype.onBuild=function(){var a=this;h.delay(function(){var b=Bb.data(),c=pb.settingsSaveHelperSimpleFunction(a.displayNameTrigger,a),d=pb.settingsSaveHelperSimpleFunction(a.replyTrigger,a),e=pb.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){Bb.remote().saveSettings(c,{DisplayName:a})}),b.replyTo.subscribe(function(a){Bb.remote().saveSettings(d,{ReplyTo:a})}),b.signature.subscribe(function(a){Bb.remote().saveSettings(e,{Signature:a})})},50)},pb.addSettingsViewModel(X,"SettingsIdentities","SETTINGS_LABELS/LABEL_IDENTITIES_NAME","identities"),X.prototype.addNewIdentity=function(){ub.showScreenPopup(I)},X.prototype.editIdentity=function(a){ub.showScreenPopup(I,[a])},X.prototype.deleteIdentity=function(a){if(a&&a.deleteAccess()){this.identityForDeletion(null);var b=function(b){return a===b};a&&(this.identities.remove(b),Bb.remote().identityDelete(function(){Bb.accountsAndIdentities()},a.id))}},X.prototype.onBuild=function(a){var b=this;a.on("click",".identity-item .e-action",function(){var a=c.dataFor(this);a&&b.editIdentity(a)}),h.delay(function(){var a=Bb.data(),c=pb.settingsSaveHelperSimpleFunction(b.displayNameTrigger,b),d=pb.settingsSaveHelperSimpleFunction(b.replyTrigger,b),e=pb.settingsSaveHelperSimpleFunction(b.signatureTrigger,b);a.displayName.subscribe(function(a){Bb.remote().saveSettings(c,{DisplayName:a})}),a.replyTo.subscribe(function(a){Bb.remote().saveSettings(d,{ReplyTo:a})}),a.signature.subscribe(function(a){Bb.remote().saveSettings(e,{Signature:a})})},50)},pb.addSettingsViewModel(Y,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social"),pb.addSettingsViewModel(Z,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME","change-password"),Z.prototype.onHide=function(){this.changeProcess(!1),this.currentPassword(""),this.newPassword("")},Z.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1),nb.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.passwordUpdateSuccess(!0)):this.passwordUpdateError(!0)},pb.addSettingsViewModel($,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders"),$.prototype.folderEditOnEnter=function(a){var b=a?pb.trim(a.nameForEdit()):"";""!==b&&a.name()!==b&&(Bb.local().set(nb.ClientSideKeyName.FoldersLashHash,""),Bb.data().foldersRenaming(!0),Bb.remote().folderRename(function(a,b){Bb.data().foldersRenaming(!1),nb.StorageResultType.Success===a&&b&&b.Result||Bb.data().foldersListError(b&&b.ErrorCode?pb.getNotification(b.ErrorCode):pb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER")),Bb.folders()},a.fullNameRaw,b),Bb.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b)),a.edited(!1)},$.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)},$.prototype.onShow=function(){Bb.data().foldersListError("")},$.prototype.createFolder=function(){ub.showScreenPopup(C)},$.prototype.systemFolder=function(){ub.showScreenPopup(D)},$.prototype.deleteFolder=function(a){if(a&&a.canBeDeleted()&&a.deleteAccess()&&0===a.privateMessageCountAll()){this.folderForDeletion(null);var b=function(c){return a===c?!0:(c.subFolders.remove(b),!1)};a&&(Bb.local().set(nb.ClientSideKeyName.FoldersLashHash,""),Bb.data().folderList.remove(b),Bb.data().foldersDeleting(!0),Bb.remote().folderDelete(function(a,b){Bb.data().foldersDeleting(!1),nb.StorageResultType.Success===a&&b&&b.Result||Bb.data().foldersListError(b&&b.ErrorCode?pb.getNotification(b.ErrorCode):pb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER")),Bb.folders()},a.fullNameRaw),Bb.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0 1048576?(a.alert(pb.i18n("SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(){this.customThemeUploaderProgress(!0)},this)).on("onComplete",h.bind(function(b,c,d){c&&d&&d.Result?this.customThemeImg(d.Result):a.alert(d&&d.ErrorCode?pb.getUploadErrorDescByCode(d.ErrorCode):pb.getUploadErrorDescByCode(nb.UploadErrorCode.Unknown)),this.customThemeUploaderProgress(!1)},this)),!!b}return!1},ab.prototype.populateDataOnStart=function(){var a=Bb.settingsGet("Languages"),b=Bb.settingsGet("Themes");pb.isArray(a)&&this.languages(a),pb.isArray(b)&&this.themes(b),this.mainLanguage(Bb.settingsGet("Language")),this.mainTheme(Bb.settingsGet("Theme")),this.allowCustomTheme(!!Bb.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!Bb.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!Bb.settingsGet("AllowIdentities")),this.determineUserLanguage(!!Bb.settingsGet("DetermineUserLanguage")),this.allowThemes(!!Bb.settingsGet("AllowThemes")),this.allowCustomLogin(!!Bb.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!Bb.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!Bb.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(Bb.settingsGet("EditorDefaultType")),this.showImages(!!Bb.settingsGet("ShowImages")),this.interfaceAnimation(Bb.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(Bb.settingsGet("MPP")),this.desktopNotifications(!!Bb.settingsGet("DesktopNotifications")),this.useThreads(!!Bb.settingsGet("UseThreads")),this.replySameFolder(!!Bb.settingsGet("ReplySameFolder")),this.usePreviewPane(!!Bb.settingsGet("UsePreviewPane")),this.useCheckboxesInList(!!Bb.settingsGet("UseCheckboxesInList")),this.facebookEnable(!!Bb.settingsGet("AllowFacebookSocial")),this.facebookAppID(Bb.settingsGet("FacebookAppID")),this.facebookAppSecret(Bb.settingsGet("FacebookAppSecret")),this.twitterEnable(!!Bb.settingsGet("AllowTwitterSocial")),this.twitterConsumerKey(Bb.settingsGet("TwitterConsumerKey")),this.twitterConsumerSecret(Bb.settingsGet("TwitterConsumerSecret")),this.googleEnable(!!Bb.settingsGet("AllowGoogleSocial")),this.googleClientID(Bb.settingsGet("GoogleClientID")),this.googleClientSecret(Bb.settingsGet("GoogleClientSecret")),this.dropboxEnable(!!Bb.settingsGet("AllowDropboxSocial")),this.dropboxApiKey(Bb.settingsGet("DropboxApiKey")),this.contactsIsAllowed(!!Bb.settingsGet("ContactsIsAllowed"))},h.extend(bb.prototype,ab.prototype),bb.prototype.purgeMessageBodyCache=function(){var a=0,c=null,d=sb.iMessageBodyCacheCount-mb.Values.MessageBodyCacheLimit;d>0&&(c=this.messagesBodiesDom(),c&&(c.find(".rl-cache-class").each(function(){var c=b(this);d>c.data("rl-cache-count")&&(c.addClass("rl-cache-purge"),a++)}),a>0&&h.delay(function(){c.find(".rl-cache-purge").remove()},300)))},bb.prototype.populateDataOnStart=function(){ab.prototype.populateDataOnStart.call(this),this.accountEmail(Bb.settingsGet("Email")),this.accountIncLogin(Bb.settingsGet("IncLogin")),this.accountOutLogin(Bb.settingsGet("OutLogin")),this.projectHash(Bb.settingsGet("ProjectHash")),this.displayName(Bb.settingsGet("DisplayName")),this.replyTo(Bb.settingsGet("ReplyTo")),this.signature(Bb.settingsGet("Signature")),this.lastFoldersHash=Bb.local().get(nb.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!Bb.settingsGet("RemoteSuggestions"),this.devEmail=Bb.settingsGet("DevEmail"),this.devLogin=Bb.settingsGet("DevLogin"),this.devPassword=Bb.settingsGet("DevPassword")},bb.prototype.initUidNextAndNewMessages=function(b,c,d){if("INBOX"===b&&pb.isNormal(c)&&""!==c){if(pb.isArray(d)&&0 3)i(Bb.link().notificationMailIcon(),Bb.data().accountEmail(),pb.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:g}));else for(;g>f;f++)i(Bb.link().notificationMailIcon(),x.emailsToLine(x.initEmailsFromJson(d[f].From),!1),d[f].Subject)}Bb.cache().setFolderUidNext(b,c)}},bb.prototype.folderResponseParseRec=function(a,b){var c=0,d=0,e=null,f=null,g="",h=[],i=[];for(c=0,d=b.length;d>c;c++)e=b[c],e&&(g=e.FullNameRaw,f=Bb.cache().getFolderFromCacheList(g),f||(f=y.newInstanceFromJson(e),f&&(Bb.cache().setFolderToCacheList(g,f),Bb.cache().setFolderFullNameRaw(f.fullNameHash,g),f.isGmailFolder=mb.Values.GmailFolderName.toLowerCase()===g.toLowerCase(),""!==a&&a===f.fullNameRaw+f.delimiter&&(f.isNamespaceFolder=!0),(f.isNamespaceFolder||f.isGmailFolder)&&(f.isUnpaddigFolder=!0))),f&&(f.collapsed(!pb.isFolderExpanded(f.fullNameHash)),e.Extended&&(e.Extended.Hash&&Bb.cache().setFolderHash(f.fullNameRaw,e.Extended.Hash),pb.isNormal(e.Extended.MessageCount)&&f.messageCountAll(e.Extended.MessageCount),pb.isNormal(e.Extended.MessageUnseenCount)&&f.messageCountUnread(e.Extended.MessageUnseenCount)),h=e.SubFolders,h&&"Collection/FolderCollection"===h["@Object"]&&h["@Collection"]&&pb.isArray(h["@Collection"])&&f.subFolders(this.folderResponseParseRec(a,h["@Collection"])),i.push(f)));return i},bb.prototype.setFolders=function(a){var b=[],c=!1,d=Bb.data(),e=function(a){return""===a||mb.Values.UnuseOptionValue===a||null!==Bb.cache().getFolderFromCacheList(a)?a:""};a&&a.Result&&"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&pb.isArray(a.Result["@Collection"])&&(pb.isUnd(a.Result.Namespace)||(d.namespace=a.Result.Namespace),this.threading(!!Bb.settingsGet("UseImapThread")&&a.Result.IsThreadsSupported&&!0),b=this.folderResponseParseRec(d.namespace,a.Result["@Collection"]),d.folderList(b),a.Result.SystemFolders&&""==""+Bb.settingsGet("SentFolder")+Bb.settingsGet("DraftFolder")+Bb.settingsGet("SpamFolder")+Bb.settingsGet("TrashFolder")+Bb.settingsGet("NullFolder")&&(Bb.settingsSet("SentFolder",a.Result.SystemFolders[2]||null),Bb.settingsSet("DraftFolder",a.Result.SystemFolders[3]||null),Bb.settingsSet("SpamFolder",a.Result.SystemFolders[4]||null),Bb.settingsSet("TrashFolder",a.Result.SystemFolders[5]||null),c=!0),d.sentFolder(e(Bb.settingsGet("SentFolder"))),d.draftFolder(e(Bb.settingsGet("DraftFolder"))),d.spamFolder(e(Bb.settingsGet("SpamFolder"))),d.trashFolder(e(Bb.settingsGet("TrashFolder"))),c&&Bb.remote().saveSystemFolders(pb.emptyFunction,{SentFolder:d.sentFolder(),DraftFolder:d.draftFolder(),SpamFolder:d.spamFolder(),TrashFolder:d.trashFolder(),NullFolder:"NullFolder"}),Bb.local().set(nb.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash))},bb.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()},bb.prototype.getNextFolderNames=function(a){a=pb.isUnd(a)?!1:!!a;var b=[],c=10,d=f().unix(),e=d-300,g=[],i=function(b){h.each(b,function(b){b&&"INBOX"!==b.fullNameRaw&&b.selectable&&b.existen&&e>b.interval&&(!a||b.subScribed())&&g.push([b.interval,b.fullNameRaw]),b&&0 b[0]?1:0}),h.find(g,function(a){var e=Bb.cache().getFolderFromCacheList(a[1]);return e&&(e.interval=d,b.push(a[1])),c<=b.length}),h.uniq(b)},bb.prototype.setMessage=function(a,c){var d=!1,e=!1,f=!1,g=null,h=null,i="",j=this.messagesBodiesDom(),k=this.message();a&&k&&a.Result&&"Object/Message"===a.Result["@Object"]&&k.folderFullNameRaw===a.Result.Folder&&k.uid===a.Result.Uid&&(this.messageError(""),k.initUpdateByMessageJson(a.Result),Bb.cache().addRequestedMessage(k.folderFullNameRaw,k.uid),c||k.initFlagsByJson(a.Result),j=j&&j[0]?j:null,j&&(i="rl-"+k.requestHash.replace(/[^a-zA-Z0-9]/g,""),h=j.find("#"+i),h&&h[0]?(h.data("rl-cache-count",++sb.iMessageBodyCacheCount),k.isRtl(!!h.data("rl-is-rtl")),k.isHtml(!!h.data("rl-is-html")),k.hasImages(!!h.data("rl-has-images")),k.body=h):(e=!!a.Result.HasExternals,f=!!a.Result.HasInternals,g=b('').hide().addClass("rl-cache-class"),g.data("rl-cache-count",++sb.iMessageBodyCacheCount),pb.isNormal(a.Result.Html)&&""!==a.Result.Html?(d=!0,g.html(a.Result.Html.toString()).addClass("b-text-part html")):pb.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(d=!1,g.html(a.Result.Plain.toString()).addClass("b-text-part plain")):d=!1,a.Result.Rtl&&(g.data("rl-is-rtl",!0),g.addClass("rtl-text-part")),j.append(g),g.data("rl-is-html",d),g.data("rl-has-images",e),k.isRtl(!!g.data("rl-is-rtl")),k.isHtml(!!g.data("rl-is-html")),k.hasImages(!!g.data("rl-has-images")),k.body=g,f&&k.showInternalImages(!0),k.hasImages()&&this.showImages()&&k.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()),this.messageActiveDom(k.body),this.hideMessageBodies(),k.body.show(),g&&pb.initBlockquoteSwitcher(g)),Bb.cache().initMessageFlagsFromCache(k),k.unseen()&&Bb.setMessageSeen(k),pb.windowResize())},bb.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&pb.isArray(a.Result["@Collection"])){var c=Bb.data(),d=Bb.cache(),e=null,g=0,h=0,i=0,j=0,k=[],l=f().unix(),m=c.staticMessageList,n=null,o=null,p=null,q=0,r=!1;for(i=pb.pInt(a.Result.MessageResultCount),j=pb.pInt(a.Result.Offset),pb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),p=Bb.cache().getFolderFromCacheList(pb.isNormal(a.Result.Folder)?a.Result.Folder:""),p&&!b&&(p.interval=l,Bb.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),pb.isNormal(a.Result.MessageCount)&&p.messageCountAll(a.Result.MessageCount),pb.isNormal(a.Result.MessageUnseenCount)&&(pb.pInt(p.messageCountUnread())!==pb.pInt(a.Result.MessageUnseenCount)&&(r=!0),p.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(p.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),r&&p&&Bb.cache().clearMessageFlagsFromCacheByFolder(p.fullNameRaw),g=0,h=a.Result["@Collection"].length;h>g;g++)n=a.Result["@Collection"][g],n&&"Object/Message"===n["@Object"]&&(o=m[g],o&&o.initByJson(n)||(o=x.newInstanceFromJson(n)),o&&(d.hasNewMessageAndRemoveFromCache(o.folderFullNameRaw,o.uid)&&5>=q&&(q++,o.newForAnimation(!0)),o.deleted(!1),b?Bb.cache().initMessageFlagsFromCache(o):Bb.cache().storeMessageFlagsToCache(o),o.lastInCollapsedThread(e&&-1 (new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="abort"),i.oRequests[n]=null),i.defaultResponse(c,n,e,b,f,d)}),n&&0 0?(this.defaultRequest(a,"Message",{},null,"Message/"+rb.urlsafe_encode([b,c,Bb.data().projectHash(),Bb.data().threading()&&Bb.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},db.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999e3)},db.prototype.folderInformation=function(a,b,c){var d=!0,e=Bb.cache(),f=[];pb.isArray(c)&&0 l;l++)p.push({id:e[l][0],name:e[l][1],disable:!1});for(l=0,m=b.length;m>l;l++)n=b[l],(h?h.call(null,n):!0)&&p.push({id:n.fullNameRaw,system:!0,name:i?i.call(null,n):n.name(),disable:!n.selectable||-1 l;l++)n=c[l],n.isGmailFolder||!n.subScribed()&&n.existen||(h?h.call(null,n):!0)&&(nb.FolderType.User===n.type()||!j||!n.isNamespaceFolder&&0 0&&-1 b?b:a))},this),this.body=null,this.isRtl=c.observable(!1),this.isHtml=c.observable(!1),this.hasImages=c.observable(!1),this.attachments=c.observableArray([]),this.priority=c.observable(nb.MessagePriority.Normal),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid=c.observable(0),this.threads=c.observableArray([]),this.threadsLen=c.observable(0),this.hasUnseenSubMessage=c.observable(!1),this.hasFlaggedSubMessage=c.observable(!1),this.lastInCollapsedThread=c.observable(!1),this.lastInCollapsedThreadLoading=c.observable(!1),this.threadsLenResult=c.computed(function(){var a=this.threadsLen();return 0===this.parentUid()&&a>0?a+1:""},this)}function y(){this.name=c.observable(""),this.fullName="",this.fullNameRaw="",this.fullNameHash="",this.delimiter="",this.namespace="",this.deep=0,this.selectable=!1,this.existen=!0,this.isNamespaceFolder=!1,this.isGmailFolder=!1,this.isUnpaddigFolder=!1,this.interval=0,this.type=c.observable(nb.FolderType.User),this.selected=c.observable(!1),this.edited=c.observable(!1),this.collapsed=c.observable(!0),this.subScribed=c.observable(!0),this.subFolders=c.observableArray([]),this.deleteAccess=c.observable(!1),this.actionBlink=c.observable(!1).extend({falseTimeout:1e3}),this.nameForEdit=c.observable(""),this.name.subscribe(function(a){this.nameForEdit(a)},this),this.edited.subscribe(function(a){a&&this.nameForEdit(this.name())},this),this.privateMessageCountAll=c.observable(0),this.privateMessageCountUnread=c.observable(0),this.collapsedPrivate=c.observable(!0)}function z(a,b){this.email=a,this.deleteAccess=c.observable(!1),this.canBeDalete=c.observable(b)}function A(a,b,d){this.id=a,this.email=c.observable(b),this.name=c.observable(""),this.replyTo=c.observable(""),this.bcc=c.observable(""),this.deleteAccess=c.observable(!1),this.canBeDalete=c.observable(d)}function B(){p.call(this,"Popups","PopupsFolderClear"),this.selectedFolder=c.observable(null),this.clearingProcess=c.observable(!1),this.clearingError=c.observable(""),this.folderFullNameForClear=c.computed(function(){var a=this.selectedFolder();return a?a.printableFullName():""},this),this.folderNameForClear=c.computed(function(){var a=this.selectedFolder();return a?a.localName():""},this),this.dangerDescHtml=c.computed(function(){return pb.i18n("POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1",{FOLDER:this.folderNameForClear()})},this),this.clearCommand=pb.createCommand(this,function(){var a=this,b=this.selectedFolder();b&&(Bb.data().message(null),Bb.data().messageList([]),this.clearingProcess(!0),Bb.cache().setFolderHash(b.fullNameRaw,""),Bb.remote().folderClear(function(b,c){a.clearingProcess(!1),nb.StorageResultType.Success===b&&c&&c.Result?(Bb.reloadMessageList(!0),a.cancelCommand()):c&&c.ErrorCode?a.clearingError(pb.getNotification(c.ErrorCode)):a.clearingError(pb.getNotification(nb.Notification.MailServerError))},b.fullNameRaw))},function(){var a=this.selectedFolder(),b=this.clearingProcess();return!b&&null!==a}),r.constructorEnd(this)}function C(){p.call(this,"Popups","PopupsFolderCreate"),pb.initOnStartOrLangChange(function(){this.sNoParentText=pb.i18n("POPUPS_CREATE_FOLDER/SELECT_NO_PARENT")},this),this.folderName=c.observable(""),this.focusTrigger=c.observable(!1),this.selectedParentValue=c.observable(mb.Values.UnuseOptionValue),this.parentFolderSelectList=c.computed(function(){var a=Bb.data(),b=[],c=null,d=null,e=a.folderList(),f=function(a){return a?a.isSystemFolder()?a.name()+" "+a.manageFolderSystemName():a.name():""};return b.push(["",this.sNoParentText]),""!==a.namespace&&(c=function(b){return a.namespace!==b.fullNameRaw.substr(0,a.namespace.length)}),Bb.folderListOptionsBuilder([],e,[],b,null,c,d,f)},this),this.createFolder=pb.createCommand(this,function(){var a=Bb.data(),b=this.selectedParentValue();""===b&&1 =a?1:a},this),this.contactsPagenator=c.computed(pb.computedPagenatorHelper(this.contactsPage,this.contactsPageCount)),this.emptySelection=c.observable(!0),this.viewClearSearch=c.observable(!1),this.viewID=c.observable(""),this.viewReadOnly=c.observable(!1),this.viewScopeType=c.observable(nb.ContactScopeType.Default),this.viewProperties=c.observableArray([]),this.viewSaveTrigger=c.observable(nb.SaveSettingsStep.Idle),this.viewPropertiesNames=this.viewProperties.filter(function(a){return-1 0&&b>0&&a>b},this),this.hasMessages=c.computed(function(){return 0 '),e.after(f),e.remove()),f&&f[0]&&f.attr("data-href",g).attr("data-theme",a[0]).text(a[1]),d.themeTrigger(nb.SaveSettingsStep.TrueResult))}).always(function(){d.iTimer=a.setTimeout(function(){d.themeTrigger(nb.SaveSettingsStep.Idle)},1e3),d.oLastAjax=null})),Bb.remote().saveSettings(null,{Theme:c})},this)}function ab(){pb.initDataConstructorBySettings(this)}function bb(){ab.call(this);var a=function(a){return function(){var b=Bb.cache().getFolderFromCacheList(a());b&&b.type(nb.FolderType.User)}},d=function(a){return function(b){var c=Bb.cache().getFolderFromCacheList(b);c&&c.type(a)}};this.devEmail="",this.devLogin="",this.devPassword="",this.accountEmail=c.observable(""),this.accountIncLogin=c.observable(""),this.accountOutLogin=c.observable(""),this.projectHash=c.observable(""),this.threading=c.observable(!1),this.lastFoldersHash="",this.remoteSuggestions=!1,this.sentFolder=c.observable(""),this.draftFolder=c.observable(""),this.spamFolder=c.observable(""),this.trashFolder=c.observable(""),this.sentFolder.subscribe(a(this.sentFolder),this,"beforeChange"),this.draftFolder.subscribe(a(this.draftFolder),this,"beforeChange"),this.spamFolder.subscribe(a(this.spamFolder),this,"beforeChange"),this.trashFolder.subscribe(a(this.trashFolder),this,"beforeChange"),this.sentFolder.subscribe(d(nb.FolderType.SentItems),this),this.draftFolder.subscribe(d(nb.FolderType.Draft),this),this.spamFolder.subscribe(d(nb.FolderType.Spam),this),this.trashFolder.subscribe(d(nb.FolderType.Trash),this),this.draftFolderNotEnabled=c.computed(function(){return""===this.draftFolder()||mb.Values.UnuseOptionValue===this.draftFolder()},this),this.displayName=c.observable(""),this.signature=c.observable(""),this.replyTo=c.observable(""),this.accounts=c.observableArray([]),this.accountsLoading=c.observable(!1).extend({throttle:100}),this.identities=c.observableArray([]),this.identitiesLoading=c.observable(!1).extend({throttle:100}),this.namespace="",this.folderList=c.observableArray([]),this.foldersListError=c.observable(""),this.foldersLoading=c.observable(!1),this.foldersCreating=c.observable(!1),this.foldersDeleting=c.observable(!1),this.foldersRenaming=c.observable(!1),this.foldersInboxUnreadCount=c.observable(0),this.currentFolder=c.observable(null).extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]}),this.currentFolderFullNameRaw=c.computed(function(){return this.currentFolder()?this.currentFolder().fullNameRaw:""},this),this.currentFolderFullName=c.computed(function(){return this.currentFolder()?this.currentFolder().fullName:""},this),this.currentFolderFullNameHash=c.computed(function(){return this.currentFolder()?this.currentFolder().fullNameHash:""},this),this.currentFolderName=c.computed(function(){return this.currentFolder()?this.currentFolder().name():""},this),this.folderListSystemNames=c.computed(function(){var a=["INBOX"],b=this.folderList(),c=this.sentFolder(),d=this.draftFolder(),e=this.spamFolder(),f=this.trashFolder();return pb.isArray(b)&&0 =a?1:a},this),this.mainMessageListSearch=c.computed({read:this.messageListSearch,write:function(a){ub.setHash(Bb.link().mailBox(this.currentFolderFullNameHash(),1,pb.trim(a.toString())))},owner:this}),this.messageListError=c.observable(""),this.messageListLoading=c.observable(!1),this.messageListIsNotCompleted=c.observable(!1),this.messageListCompleteLoadingThrottle=c.observable(!1).extend({throttle:200}),this.messageListCompleteLoading=c.computed(function(){var a=this.messageListLoading(),b=this.messageListIsNotCompleted();return a||b},this),this.messageListCompleteLoading.subscribe(function(a){this.messageListCompleteLoadingThrottle(a)},this),this.messageList.subscribe(h.debounce(function(a){h.each(a,function(a){a.newForAnimation()&&a.newForAnimation(!1)})},500)),this.staticMessageList=new x,this.message=c.observable(null),this.messageLoading=c.observable(!1),this.messageLoadingThrottle=c.observable(!1).extend({throttle:50}),this.messageLoading.subscribe(function(a){this.messageLoadingThrottle(a)},this),this.messageFullScreenMode=c.observable(!1),this.messageError=c.observable(""),this.messagesBodiesDom=c.observable(null),this.messagesBodiesDom.subscribe(function(a){!a||a instanceof jQuery||this.messagesBodiesDom(b(a))},this),this.messageActiveDom=c.observable(null),this.isMessageSelected=c.computed(function(){return null!==this.message()},this),this.currentMessage=c.observable(null),this.message.subscribe(function(a){null===a&&(this.currentMessage(null),this.hideMessageBodies())},this),this.messageListChecked=c.computed(function(){return h.filter(this.messageList(),function(a){return a.checked()})},this),this.messageListCheckedOrSelected=c.computed(function(){var a=this.messageListChecked(),b=this.currentMessage();return h.union(a,b?[b]:[])},this),this.messageListCheckedUids=c.computed(function(){var a=[];return h.each(this.messageListChecked(),function(b){b&&(a.push(b.uid),0 0?Math.ceil(b/a*100):0},this),this.useKeyboardShortcuts=c.observable(!0),this.googleActions=c.observable(!1),this.googleLoggined=c.observable(!1),this.googleUserName=c.observable(""),this.facebookActions=c.observable(!1),this.facebookLoggined=c.observable(!1),this.facebookUserName=c.observable(""),this.twitterActions=c.observable(!1),this.twitterLoggined=c.observable(!1),this.twitterUserName=c.observable(""),this.customThemeType=c.observable(nb.CustomThemeType.Light),this.purgeMessageBodyCacheThrottle=h.throttle(this.purgeMessageBodyCache,3e4)}function cb(){this.oRequests={}}function db(){cb.call(this),this.oRequests={}}function eb(){this.oEmailsPicsHashes={},this.oServices={}}function fb(){eb.call(this),this.oFoldersCache={},this.oFoldersNamesCache={},this.oFolderHashCache={},this.oFolderUidNextCache={},this.oMessageListHashCache={},this.oMessageFlagsCache={},this.oNewMessage={},this.oRequestedMessage={}}function gb(a){q.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function hb(){q.call(this,"login",[L])}function ib(){q.call(this,"mailbox",[N,P,Q,R]),this.oLastRoute={}}function jb(){gb.call(this,[O,S,T]),pb.initOnStartOrLangChange(function(){this.sSettingsTitle=pb.i18n("TITLES/SETTINGS")},this,function(){Bb.setTitle(this.sSettingsTitle)})}function kb(){o.call(this),this.oSettings=null,this.oPlugins=null,this.oLocal=null,this.oLink=null,this.oSubs={},this.isLocalAutocomplete=!0,this.popupVisibility=c.observable(!1),this.iframe=b('').appendTo("body"),yb.on("error",function(a){Bb&&a&&a.originalEvent&&a.originalEvent.message&&-1===pb.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&Bb.remote().jsError(pb.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",xb.attr("class"),pb.microtime()-sb.now)})}function lb(){kb.call(this),this.oData=null,this.oRemote=null,this.oCache=null,this.quotaDebounce=h.debounce(this.quota,3e4),a.setInterval(function(){Bb.pub("interval.30s")},3e4),a.setInterval(function(){Bb.pub("interval.1m")},6e4),a.setInterval(function(){Bb.pub("interval.2m")},12e4),a.setInterval(function(){Bb.pub("interval.3m")},18e4),a.setInterval(function(){Bb.pub("interval.5m")},3e5),a.setInterval(function(){Bb.pub("interval.10m")},6e5),b.wakeUp(function(){Bb.remote().jsVersion(function(b,c){nb.StorageResultType.Success===b&&c&&!c.Result&&(a.parent&&Bb.settingsGet("InIframe")?a.parent.location.reload():a.location.reload())},Bb.settingsGet("Version"))},{},36e5)}var mb={},nb={},ob={},pb={},qb={},rb={},sb={},tb={settings:[],"settings-removed":[],"settings-disabled":[]},ub=null,vb=a.rainloopAppData||{},wb=a.rainloopI18N||{},xb=b("html"),yb=b(a),zb=b(a.document),Ab=a.Notification&&a.Notification.requestPermission?a.Notification:null,Bb=null;sb.now=(new Date).getTime(),sb.momentTrigger=c.observable(!0),sb.langChangeTrigger=c.observable(!0),sb.iAjaxErrorCount=0,sb.iTokenErrorCount=0,sb.iMessageBodyCacheCount=0,sb.bUnload=!1,sb.sUserAgent=(navigator.userAgent||"").toLowerCase(),sb.bIsiOSDevice=-1 /g,">").replace(/"/g,""").replace(/'/g,"'"):""},pb.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=pb.isUnd(b)?100:b;e.length>b;)d=e.substring(0,b),f=d.lastIndexOf(" "),g=d.lastIndexOf("\n"),-1!==g&&(f=g),-1===f&&(f=b),c+=d.substring(0,f)+"\n",e=e.substring(f+1);return c+e},pb.timeOutAction=function(){var b={};return function(c,d,e){pb.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),pb.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),pb.audio=function(){var b=!1;return function(c,d){if(!1===b)if(sb.bIsiOSDevice)b=null;else{var e=!1,f=!1,g=a.Audio?new a.Audio:null;g&&g.canPlayType&&g.play?(e=""!==g.canPlayType('audio/mpeg; codecs="mp3"'),e||(f=""!==g.canPlayType('audio/ogg; codecs="vorbis"')),e||f?(b=g,b.preload="none",b.loop=!1,b.autoplay=!1,b.muted=!1,b.src=e?c:d):b=null):b=null}return b}}(),pb.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},pb.i18n=function(a,b,c){var d="",e=pb.isUnd(wb[a])?pb.isUnd(c)?a:c:wb[a];if(!pb.isUnd(b)&&!pb.isNull(b))for(d in b)pb.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},pb.i18nToNode=function(a){h.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(pb.i18n(c)):(c=a.data("i18n-html"),c&&a.html(pb.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",pb.i18n(c)))})})},pb.i18nToDoc=function(){a.rainloopI18N&&(wb=a.rainloopI18N||{},pb.i18nToNode(zb),sb.langChangeTrigger(!sb.langChangeTrigger())),a.rainloopI18N={} +},pb.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?sb.langChangeTrigger.subscribe(function(){a&&a.call(b),c.call(b)}):a&&sb.langChangeTrigger.subscribe(a,b)},pb.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&a.contentEditable)},pb.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},pb.removeSelection=function(){if(a&&a.getSelection){var b=a.getSelection();b&&b.removeAllRanges&&b.removeAllRanges()}else document&&document.selection&&document.selection.empty&&document.selection.empty()},pb.replySubjectAdd=function(b,c,d){var e=null,f=pb.trim(c);return null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||pb.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||pb.isUnd(e[1])||pb.isUnd(e[2])||pb.isUnd(e[3])?f=b+": "+c:(f=e[1]+(pb.pInt(e[2])+1)+e[3],f=e[1]+(pb.pInt(e[2])+1)+e[3]):f=b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),(pb.isUnd(d)?!0:d)?pb.fixLongSubject(f):f},pb.fixLongSubject=function(a){var b=0,c=null;a=pb.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||pb.isUnd(c[0]))&&(c=null),c&&(b=0,b+=pb.isUnd(c[2])?1:0+pb.pInt(c[2]),b+=pb.isUnd(c[4])?1:0+pb.pInt(c[4]),a=a.replace(/^Re(\[[\d]+\]|):[\s]{0,3}Re(\[[\d]+\]|):/gi,"Re"+(b>0?"["+b+"]":"")+":"));while(c);return a=a.replace(/[\s]+/," ")},pb.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},pb.friendlySize=function(a){return a=pb.pInt(a),a>=1073741824?pb.roundNumber(a/1073741824,1)+"GB":a>=1048576?pb.roundNumber(a/1048576,1)+"MB":a>=1024?pb.roundNumber(a/1024,0)+"KB":a+"B"},pb.log=function(b){a.console&&a.console.log&&a.console.log(b)},pb.getNotification=function(a){return a=pb.pInt(a),pb.isUnd(ob[a])?"":ob[a]},pb.initNotificationLanguage=function(){ob[nb.Notification.InvalidToken]=pb.i18n("NOTIFICATIONS/INVALID_TOKEN"),ob[nb.Notification.AuthError]=pb.i18n("NOTIFICATIONS/AUTH_ERROR"),ob[nb.Notification.AccessError]=pb.i18n("NOTIFICATIONS/ACCESS_ERROR"),ob[nb.Notification.ConnectionError]=pb.i18n("NOTIFICATIONS/CONNECTION_ERROR"),ob[nb.Notification.CaptchaError]=pb.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),ob[nb.Notification.SocialFacebookLoginAccessDisable]=pb.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),ob[nb.Notification.SocialTwitterLoginAccessDisable]=pb.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),ob[nb.Notification.SocialGoogleLoginAccessDisable]=pb.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),ob[nb.Notification.DomainNotAllowed]=pb.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),ob[nb.Notification.AccountNotAllowed]=pb.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),ob[nb.Notification.CantGetMessageList]=pb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),ob[nb.Notification.CantGetMessage]=pb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),ob[nb.Notification.CantDeleteMessage]=pb.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),ob[nb.Notification.CantMoveMessage]=pb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),ob[nb.Notification.CantCopyMessage]=pb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),ob[nb.Notification.CantSaveMessage]=pb.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),ob[nb.Notification.CantSendMessage]=pb.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),ob[nb.Notification.InvalidRecipients]=pb.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),ob[nb.Notification.CantCreateFolder]=pb.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),ob[nb.Notification.CantRenameFolder]=pb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),ob[nb.Notification.CantDeleteFolder]=pb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),ob[nb.Notification.CantDeleteNonEmptyFolder]=pb.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),ob[nb.Notification.CantSubscribeFolder]=pb.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),ob[nb.Notification.CantUnsubscribeFolder]=pb.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),ob[nb.Notification.CantSaveSettings]=pb.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),ob[nb.Notification.CantSavePluginSettings]=pb.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),ob[nb.Notification.DomainAlreadyExists]=pb.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),ob[nb.Notification.CantInstallPackage]=pb.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),ob[nb.Notification.CantDeletePackage]=pb.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),ob[nb.Notification.InvalidPluginPackage]=pb.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),ob[nb.Notification.UnsupportedPluginPackage]=pb.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),ob[nb.Notification.LicensingServerIsUnavailable]=pb.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),ob[nb.Notification.LicensingExpired]=pb.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),ob[nb.Notification.LicensingBanned]=pb.i18n("NOTIFICATIONS/LICENSING_BANNED"),ob[nb.Notification.DemoSendMessageError]=pb.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),ob[nb.Notification.AccountAlreadyExists]=pb.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),ob[nb.Notification.MailServerError]=pb.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),ob[nb.Notification.UnknownNotification]=pb.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),ob[nb.Notification.UnknownError]=pb.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},pb.getUploadErrorDescByCode=function(a){var b="";switch(pb.pInt(a)){case nb.UploadErrorCode.FileIsTooBig:b=pb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case nb.UploadErrorCode.FilePartiallyUploaded:b=pb.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case nb.UploadErrorCode.FileNoUploaded:b=pb.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case nb.UploadErrorCode.MissingTempFolder:b=pb.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case nb.UploadErrorCode.FileOnSaveingError:b=pb.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case nb.UploadErrorCode.FileType:b=pb.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=pb.i18n("UPLOAD/ERROR_UNKNOWN")}return b},pb.killCtrlAandS=function(b){if(b=b||a.event){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(b.ctrlKey&&d===nb.EventKeyCode.S)return b.preventDefault(),void 0;if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;b.ctrlKey&&d===nb.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},pb.createCommand=function(a,b,d){var e=b?function(){return e.canExecute&&e.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments)),!1}:function(){};return e.enabled=c.observable(!0),d=pb.isUnd(d)?!0:d,e.canExecute=pb.isFunc(d)?c.computed(function(){return e.enabled()&&d.call(a)}):c.computed(function(){return e.enabled()&&!!d}),e},pb.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(nb.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(nb.InterfaceAnimation.Full),b.contactsAutosave=c.observable(!1),sb.sAnimationType=nb.InterfaceAnimation.Full,b.allowThemes=c.observable(!0),b.allowCustomLogin=c.observable(!1),b.allowLanguagesOnSettings=c.observable(!0),b.allowLanguagesOnLogin=c.observable(!0),b.desktopNotifications=c.observable(!1),b.useThreads=c.observable(!0),b.replySameFolder=c.observable(!0),b.usePreviewPane=c.observable(!0),b.useCheckboxesInList=c.observable(!0),b.interfaceAnimation.subscribe(function(a){if(sb.bMobileDevice||a===nb.InterfaceAnimation.None)xb.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),sb.sAnimationType=nb.InterfaceAnimation.None;else switch(a){case nb.InterfaceAnimation.Full:xb.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),sb.sAnimationType=a;break;case nb.InterfaceAnimation.Normal:xb.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),sb.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=nb.DesktopNotifications.NotSupported;if(Ab&&Ab.permission)switch(Ab.permission.toLowerCase()){case"granted":c=nb.DesktopNotifications.Allowed;break;case"denied":c=nb.DesktopNotifications.Denied;break;case"default":c=nb.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&nb.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();nb.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):nb.DesktopNotifications.NotAllowed===c?Ab.requestPermission(function(){b.desktopNotifications.valueHasMutated(),nb.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()?b.desktopNotifications()?b.desktopNotifications.valueHasMutated():b.desktopNotifications(!0):b.desktopNotifications()?b.desktopNotifications(!1):b.desktopNotifications.valueHasMutated()}):b.desktopNotifications(!1)}else b.desktopNotifications(!1)}}),b.language=c.observable(""),b.languages=c.observableArray([]),b.mainLanguage=c.computed({read:b.language,write:function(a){a!==b.language()?-1 =b.diff(c,"hours")?d:b.format("L")===c.format("L")?pb.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?pb.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},pb.isFolderExpanded=function(a){var b=Bb.local().get(nb.ClientSideKeyName.ExpandedFolders);return h.isArray(b)&&-1!==h.indexOf(b,a)},pb.setExpandedFolder=function(a,b){var c=Bb.local().get(nb.ClientSideKeyName.ExpandedFolders);h.isArray(c)||(c=[]),b?(c.push(a),c=h.uniq(c)):c=h.without(c,a),Bb.local().set(nb.ClientSideKeyName.ExpandedFolders,c)},pb.initLayoutResizer=function(a,c,d,e,f,g,i,j){e=e||300,f=f||500,g=g||f-e/2,i=i||300;var k=0,l=b(a),m=b(c),n=b(d),o=Bb.local().get(j)||g,p=function(a,b,c){if(b||c){var d=n.width(),e=b?b.size.width/d*100:null;null===e&&c&&(e=l.width()/d*100),null!==e&&(l.css({width:"",height:"",right:""+(100-e)+"%"}),m.css({width:"",height:"",left:""+e+"%"}))}},q=function(b,c){if(c&&c.element&&c.element[0].id&&"#"+c.element[0].id==""+a){var d=n.width();k=d-i,k=f>k?k:f,l.resizable("option","maxWidth",k),c.size&&c.size.width&&Bb.local().set(j,c.size.width),p(null,null,!0)}};o&&l.width(o),k=n.width()-i,k=f>k?k:f,l.resizable({minWidth:e,maxWidth:k,handles:"e",resize:p,stop:p}),p(null,null,!0),yb.resize(h.throttle(q,400))},pb.initBlockquoteSwitcher=function(a){if(a){var c=b("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===b(this).parent().closest("blockquote",a).length});c&&0 100)&&(a.addClass("rl-bq-switcher hidden-bq"),b('').insertBefore(a).click(function(){a.toggleClass("hidden-bq"),pb.windowResize()}).after("
").before("
"))})}},pb.removeBlockquoteSwitcher=function(a){a&&(b(a).find("blockquote.rl-bq-switcher").each(function(){b(this).removeClass("rl-bq-switcher hidden-bq")}),b(a).find(".rlBlockquoteSwitcher").each(function(){b(this).remove()}))},pb.extendAsViewModel=function(a,b,c){b&&(c||(c=p),b.__name=a,qb.regViewModelHook(a,b),h.extend(b.prototype,c.prototype))},pb.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},tb.settings.push(a)},pb.removeSettingsViewModel=function(a){tb["settings-removed"].push(a)},pb.disableSettingsViewModel=function(a){tb["settings-disabled"].push(a)},pb.convertThemeName=function(a){return pb.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},pb.quoteName=function(a){return a.replace(/["]/g,'\\"')},pb.microtime=function(){return(new Date).getTime()},pb.convertLangName=function(a,b){return pb.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},pb.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=pb.isUnd(a)?32:pb.pInt(a);b.length/g,">").replace(/")},pb.draggeblePlace=function(){return b('').appendTo("#rl-hidden")},pb.defautOptionsAfterRender=function(a,b){b&&!pb.isUnd(b.disable)&&c.applyBindingsToNode(a,{disable:b.disable},b)},pb.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+pb.fakeMd5()+"__",j=b("#"+d);a[i]=function(){if(h&&h.document.body&&j&&j[0]){var d=b(h.document.body);b("#rl-content",d).html(j.html()),b("html",h.document).addClass("external "+b("html").attr("class")),pb.i18nToNode(d),r.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.document.write(''+pb.encodeHtml(e)+' '),h.document.close(),g=h.document.createElement("script"),g.type="text/javascript",g.innerHTML="if(window&&window.opener&&window.opener['"+i+"']){window.opener['"+i+"']();window.opener['"+i+"']=null}",h.document.getElementsByTagName("head")[0].appendChild(g)},pb.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=pb.isUnd(d)?1e3:pb.pInt(d),function(e,f,g,i,j){b.call(c,f&&f.Result?nb.SaveSettingsStep.TrueResult:nb.SaveSettingsStep.FalseResult),a&&a.call(c,e,f,g,i,j),h.delay(function(){b.call(c,nb.SaveSettingsStep.Idle)},d)}},pb.settingsSaveHelperSimpleFunction=function(a,b){return pb.settingsSaveHelperFunction(null,a,b,1e3)},pb.resizeAndCrop=function(b,c,d){var e=new a.Image;e.onload=function(){var a=[0,0],b=document.createElement("canvas"),e=b.getContext("2d");b.width=c,b.height=c,a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width],e.fillStyle="#fff",e.fillRect(0,0,c,c),e.drawImage(this,a[0]/2,a[1]/2,this.width-a[0],this.height-a[1],0,0,c,c),d(b.toDataURL("image/jpeg"))},e.src=b},pb.computedPagenatorHelper=function(a,b){return function(){var c=0,d=0,e=2,f=[],g=a(),h=b(),i=function(a,b,c){var d={current:a===g,name:pb.isUnd(c)?a.toString():c.toString(),custom:pb.isUnd(c)?!1:!0,title:pb.isUnd(c)?"":a.toString(),value:a.toString()};(pb.isUnd(b)?0:!b)?f.unshift(d):f.push(d)};if(h>1||h>0&&g>h){for(g>h?(i(h),c=h,d=h):((3>=g||g>=h-2)&&(e+=2),i(g),c=g,d=g);e>0;)if(c-=1,d+=1,c>0&&(i(c,!1),e--),h>=d)i(d,!0),e--;else if(0>=c)break;3===c?i(2,!1):c>3&&i(Math.round((c-1)/2),!1,"..."),h-2===d?i(h-1,!0):h-2>d&&i(Math.round((h+d)/2),!0,"..."),c>1&&i(1,!1),h>d&&i(h,!0)}return f}},rb={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return rb.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=rb._utf8_encode(a);j>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+this._keyStr.charAt(e)+this._keyStr.charAt(f)+this._keyStr.charAt(g)+this._keyStr.charAt(h);return i},decode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");j >4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,i+=String.fromCharCode(b),64!==g&&(i+=String.fromCharCode(c)),64!==h&&(i+=String.fromCharCode(d));return rb._utf8_decode(i)},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0,d=a.length,e=0;d>c;c++)e=a.charCodeAt(c),128>e?b+=String.fromCharCode(e):e>127&&2048>e?(b+=String.fromCharCode(e>>6|192),b+=String.fromCharCode(63&e|128)):(b+=String.fromCharCode(e>>12|224),b+=String.fromCharCode(e>>6&63|128),b+=String.fromCharCode(63&e|128));return b},_utf8_decode:function(a){for(var b="",c=0,d=0,e=0,f=0;c d?(b+=String.fromCharCode(d),c++):d>191&&224>d?(e=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&e),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&e)<<6|63&f),c+=3);return b}},c.bindingHandlers.tooltip={init:function(a,d){if(!sb.bMobileDevice){var e=b(a).data("tooltip-class")||"",f=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:f,trigger:"hover",title:function(){return''+pb.i18n(c.utils.unwrapObservable(d()))+""}})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a).data("tooltip-class")||"",e=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:e,title:function(){return''+c()()+""}})}},c.bindingHandlers.dropdown={init:function(a){b(a).closest(".dropdown").on("click",".e-item",function(){b(a).dropdown("toggle")})}},c.bindingHandlers.popover={init:function(a,d){b(a).popover(c.utils.unwrapObservable(d()))}},c.bindingHandlers.resizecrop={init:function(a){b(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,c){c()(),b(a).resizecrop({width:"100",height:"100"})}},c.bindingHandlers.onEnter={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&13===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.onEsc={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&27===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.modal={init:function(a,d){b(a).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("hidden",function(){d()(!1)})},update:function(a,d){var e=c.utils.unwrapObservable(d());b(a).modal(e?"show":"hide"),h.delay(function(){b(a).toggleClass("popup-active",e)},1)}},c.bindingHandlers.i18nInit={init:function(a){pb.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),pb.i18nToNode(a)}},c.bindingHandlers.link={update:function(a,d){b(a).attr("href",c.utils.unwrapObservable(d()))}},c.bindingHandlers.title={update:function(a,d){b(a).attr("title",c.utils.unwrapObservable(d()))}},c.bindingHandlers.textF={init:function(a,d){b(a).text(c.utils.unwrapObservable(d()))}},c.bindingHandlers.initDom={init:function(a,b){b()(a)}},c.bindingHandlers.initResizeTrigger={init:function(a,d){var e=c.utils.unwrapObservable(d());b(a).css({height:e[1],"min-height":e[1]})},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=pb.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=pb.pInt(e[2]),g=yb.height()-h,g>f&&(f=g),b(a).css({height:f,"min-height":f}))}},c.bindingHandlers.appendDom={update:function(a,d){b(a).hide().empty().append(c.utils.unwrapObservable(d())).show()}},c.bindingHandlers.draggable={init:function(d,e,f){if(!sb.bMobileDevice){var g=100,h=3,i=f(),j=i&&i.droppableSelector?i.droppableSelector:"",k={distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},refreshPositions:!0,scroll:!0};j&&(k.drag=function(c){b(j).each(function(){var d=null,e=null,f=b(this),i=f.offset(),j=i.top+f.height();a.clearInterval(f.data("timerScroll")),f.data("timerScroll",!1),c.pageX>=i.left&&c.pageX<=i.left+f.width()&&(c.pageY>=j-g&&c.pageY<=j&&(d=function(){f.scrollTop(f.scrollTop()+h),pb.windowResize()},f.data("timerScroll",a.setInterval(d,10)),d()),c.pageY>=i.top&&c.pageY<=i.top+g&&(e=function(){f.scrollTop(f.scrollTop()-h),pb.windowResize()},f.data("timerScroll",a.setInterval(e,10)),e()))})},k.stop=function(){b(j).each(function(){a.clearInterval(b(this).data("timerScroll")),b(this).data("timerScroll",!1)})}),k.helper=function(a){return e()(a&&a.target?c.dataFor(a.target):null,!!a.shiftKey)},b(d).draggable(k).on("mousedown",function(){pb.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!sb.bMobileDevice){var e=c(),f=d(),g=f&&f.droppableOver?f.droppableOver:null,h=f&&f.droppableOut?f.droppableOut:null,i={tolerance:"pointer",hoverClass:"droppableHover"};e&&(i.drop=function(a,b){e(a,b)},g&&(i.over=function(a,b){g(a,b)}),h&&(i.out=function(a,b){h(a,b)}),b(a).droppable(i))}}},c.bindingHandlers.nano={init:function(a){sb.bDisableNanoScroll||b(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},c.bindingHandlers.saveTrigger={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text],input[type=email],input[type=password],select,textarea")?"input":"custom"),"custom"===c.data("save-trigger-type")?c.append(' ').addClass("settings-saved-trigger"):c.addClass("settings-saved-trigger-input")},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=b(a);if("custom"===f.data("save-trigger-type"))switch(e.toString()){case"1":f.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case"0":f.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case"-2":f.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:f.find(".animated").hide().end().find(".error,.success").removeClass("visible")}else switch(e.toString()){case"1":f.addClass("success").removeClass("error");break;case"0":f.addClass("error").removeClass("success");break;case"-2":break;default:f.removeClass("error success")}}},c.bindingHandlers.emailsTags={init:function(a,c){var d=b(a),e=c();d.inputosaurus({parseOnBlur:!0,inputDelimiters:[",",";"],autoCompleteSource:function(a,b){Bb.getAutocomplete(a.term,function(a){b(h.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return h.map(a,function(a){var b=pb.trim(a),c=null;return""!==b?(c=new s,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:h.bind(function(a){d.data("EmailsTagsValue",a.target.value),e(a.target.value)},this)}),e.subscribe(function(a){d.data("EmailsTagsValue")!==a&&(d.val(a),d.inputosaurus("refresh"))}),e.focusTrigger&&e.focusTrigger.subscribe(function(){d.inputosaurus("focus")})}},c.bindingHandlers.command={init:function(a,d,e,f){var g=b(a),h=d();if(!h||!h.enabled||!h.canExecute)throw new Error("You are not using command function");g.addClass("command"),c.bindingHandlers[g.is("form")?"submit":"click"].init.apply(f,arguments)},update:function(a,c){var d=!0,e=b(a),f=c();d=f.enabled(),e.toggleClass("command-not-enabled",!d),d&&(d=f.canExecute(),e.toggleClass("command-can-not-be-execute",!d)),e.toggleClass("command-disabled disable disabled",!d),(e.is("input")||e.is("button"))&&e.prop("disabled",!d)}},c.extenders.trimmer=function(a){var b=c.computed({read:a,write:function(b){a(pb.trim(b.toString()))},owner:this});return b(a()),b},c.extenders.reversible=function(a){var b=a();return a.commit=function(){b=a()},a.reverse=function(){a(b)},a.commitedValue=function(){return b},a},c.extenders.toggleSubscribe=function(a,b){return a.subscribe(b[1],b[0],"beforeChange"),a.subscribe(b[2],b[0]),a},c.extenders.falseTimeout=function(b,c){return b.iTimeout=0,b.subscribe(function(d){d&&(a.clearTimeout(b.iTimeout),b.iTimeout=a.setTimeout(function(){b(!1),b.iTimeout=0},pb.pInt(c)))}),b},c.observable.fn.validateNone=function(){return this.hasError=c.observable(!1),this},c.observable.fn.validateEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=pb.trim(a),this.hasError(""!==a&&!/^[^@\s]+@[^@\s]+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateSimpleEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=pb.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),pb.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},i.prototype.root=function(){return this.sBase},i.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},i.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},i.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},i.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},i.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},i.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},i.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},i.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},i.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},i.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},i.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},i.prototype.settings=function(a){var b=this.sBase+"settings";return pb.isUnd(a)||""===a||(b+="/"+a),b},i.prototype.admin=function(a){var b=this.sBase;switch(a){case"AdminDomains":b+="domains";break;case"AdminSecurity":b+="security";break;case"AdminLicensing":b+="licensing"}return b},i.prototype.mailBox=function(a,b,c){b=pb.isNormal(b)?pb.pInt(b):1,c=pb.pString(c);var d=this.sBase+"mailbox/";return""!==a&&(d+=encodeURI(a)),b>1&&(d=d.replace(/[\/]+$/,""),d+="/p"+b),""!==c&&(d=d.replace(/[\/]+$/,""),d+="/"+encodeURI(c)),d},i.prototype.phpInfo=function(){return this.sServer+"Info"},i.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},i.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},i.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"},i.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a},i.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"},i.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"},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+"/":"")},qb.oViewModelsHooks={},qb.oSimpleHooks={},qb.regViewModelHook=function(a,b){b&&(b.__hookName=a)},qb.addHook=function(a,b){pb.isFunc(b)&&(pb.isArray(qb.oSimpleHooks[a])||(qb.oSimpleHooks[a]=[]),qb.oSimpleHooks[a].push(b))},qb.runHook=function(a,b){pb.isArray(qb.oSimpleHooks[a])&&(b=b||[],h.each(qb.oSimpleHooks[a],function(a){a.apply(null,b)}))},qb.mainSettingsGet=function(a){return Bb?Bb.settingsGet(a):null},qb.remoteRequest=function(a,b,c,d,e,f){Bb&&Bb.remote().defaultRequest(a,b,c,d,e,f)},qb.settingsGet=function(a,b){var c=qb.mainSettingsGet("Plugins");return c=c&&pb.isUnd(c[a])?null:c[a],c?pb.isUnd(c[b])?null:c[b]:null},j.prototype.initLanguage=function(a,b,c){this.oOptions.LangSwitcherConferm=a,this.oOptions.LangSwitcherTextLabel=b,this.oOptions.LangSwitcherHtmlLabel=c},j.prototype.execCom=function(b,c,d){a.document&&(a.document.execCommand(b,c||!1,d||null),this.updateTextArea())},j.prototype.getEditorSelection=function(){var b=null;return a.getSelection?b=a.getSelection():a.document.getSelection?b=a.document.getSelection():a.document.selection&&(b=a.document.selection),b},j.prototype.getEditorRange=function(){var a=this.getEditorSelection();return a&&0!==a.rangeCount?a.getRangeAt?a.getRangeAt(0):a.createRange():null},j.prototype.ec=function(a,b,c){this.execCom(a,b,c)},j.prototype.heading=function(a){this.ec("formatblock",!1,this.bIe?"Heading "+a:"h"+a)},j.prototype.insertImage=function(a){this.isHtml()&&!this.bOnlyPlain&&(this.htmlarea.focus(),this.ec("insertImage",!1,a))},j.prototype.focus=function(){this.isHtml()&&!this.bOnlyPlain?this.htmlarea.focus():this.textarea.focus()},j.prototype.setcolor=function(a,b){var c=null,d="";this.bIe&&!document.addEventListener?(c=this.getEditorRange(),c&&c.execCommand("forecolor"===a?"ForeColor":"BackColor",!1,b)):(d=this.bIe?"forecolor"===a?"ForeColor":"BackColor":"forecolor"===a?"foreColor":"backColor",this.ec(d,!1,b))},j.prototype.isHtml=function(){return!0===this.bOnlyPlain?!1:this.textarea.is(":hidden")},j.prototype.toHtmlString=function(){return this.editor.innerHTML},j.prototype.toString=function(){return this.editor.innerText},j.prototype.updateTextArea=function(){this.textarea.val(this.toHtmlString())},j.prototype.updateHtmlArea=function(){this.editor.innerHTML=this.textarea.val()},j.prototype.setRawText=function(a,b){b&&!this.bOnlyPlain?(this.isHtml()||(this.textarea.val(""),this.switchToHtml()),this.textarea.val(a.toString()),this.updateHtmlArea()):(this.textarea.val(a.toString()),this.updateHtmlArea(),this.switchToPlain(!1))},j.prototype.clear=function(){this.textarea.val(""),this.editor.innerHTML="",this.bOnlyPlain?(this.toolbar.hide(),this.switchToPlain(!1)):this.switchToHtml()},j.prototype.getTextForRequest=function(){return this.isHtml()?(this.updateTextArea(),this.textarea.val()):this.textarea.val()},j.prototype.getTextFromHtml=function(a){var b="",c="> ",d=function(){if(arguments&&1 \n",a.replace(/\n([> ]+)/gm,function(){return arguments&&1 ]*>([\s\S]*)<\/div>/gim,e),a="\n"+pb.trim(a)+"\n"),a}return""},f=function(){if(arguments&&1 /gim,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,"\n").replace(/<\/tr>/gi,"\n").replace(/
]*>/gim,"\n_______________________________\n\n").replace(/]*>/gim,"").replace(/
]*>([\s\S]*)<\/div>/gim,e).replace(/]*>/gim,"\n__bq__start__\n").replace(/<\/blockquote>/gim,"\n__bq__end__\n").replace(/]*>([\s\S]*?)<\/a>/gim,f).replace(/ /gi," ").replace(/<[^>]*>/gm,"").replace(/>/gi,">").replace(/</gi,"<").replace(/&/gi,"&").replace(/&\w{2,6};/gi,""),(a?pb.splitPlainText(b):b).replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/__bq__start__([\s\S]*)__bq__end__/gm,d).replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")},j.prototype.getHtmlFromText=function(){return pb.convertPlainTextToHtml(this.textarea.val())},j.prototype.switchToggle=function(){this.isHtml()?this.switchToPlain():this.switchToHtml()},j.prototype.switchToPlain=function(c){c=pb.isUnd(c)?!0:c;var d=this.getTextFromHtml(),e=h.bind(function(a){a&&(this.toolbar.addClass("editorHideToolbar"),b(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!1)),this.textarea.val(d),this.textarea.show(),this.htmlarea.hide(),this.fOnSwitch&&this.fOnSwitch(!1))},this);c&&0!==pb.trim(d).length?e(a.confirm(this.oOptions.LangSwitcherConferm)):e(!0)},j.prototype.switcherLinkText=function(a){return a?this.oOptions.LangSwitcherTextLabel:this.oOptions.LangSwitcherHtmlLabel},j.prototype.switchToHtml=function(){this.toolbar.removeClass("editorHideToolbar"),b(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!0)),this.textarea.val(this.getHtmlFromText()),this.updateHtmlArea(),this.textarea.hide(),this.htmlarea.show(),this.fOnSwitch&&this.fOnSwitch(!0)},j.prototype.addButton=function(c,d){var e=this;b("").addClass("editorToolbarButtom").append(b('').addClass(c)).attr("title",d).click(function(d){pb.isUnd(j.htmlFunctions[c])?a.alert(c):j.htmlFunctions[c].apply(e,[b(this),d])}).appendTo(this.toolbar)},j.htmlInitToolbar=function(){this.bOnlyPlain||(this.addButton("bold","Bold"),this.addButton("italic","Italic"),this.addButton("underline","Underline"),this.addButton("strikethrough","Strikethrough"),this.addButton("removeformat","removeformat"),this.addButton("justifyleft","justifyleft"),this.addButton("justifycenter","justifycenter"),this.addButton("justifyright","justifyright"),this.addButton("horizontalrule","horizontalrule"),this.addButton("orderedlist","orderedlist"),this.addButton("unorderedlist","unorderedlist"),this.addButton("indent","indent"),this.addButton("outdent","outdent"),this.addButton("forecolor","forecolor"),function(a,b){a("").addClass("editorSwitcher").text(b.switcherLinkText(!0)).click(function(){b.switchToggle()}).appendTo(b.toolbar)}(b,this))},j.htmlInitEditor=function(){this.editor=this.htmlarea[0],this.editor.innerHTML=this.textarea.val()},j.htmlAttachEditorEvents=function(){var b=this,c=function(a){return a&&a.type&&0===a.type.indexOf("image/")},d=function(d){if(d=(d&&d.originalEvent?d.originalEvent:d)||a.event){d.stopPropagation(),d.preventDefault();var e=null,f=null,g=d.files||(d.dataTransfer?d.dataTransfer.files:null);g&&1===g.length&&c(g[0])&&(f=g[0],e=new a.FileReader,e.onload=function(a){return function(c){b.insertImage(c.target.result,a.name)}}(f),e.readAsDataURL(f))}b.htmlarea.removeClass("editorDragOver")},e=function(){b.htmlarea.removeClass("editorDragOver")},f=function(a){a.stopPropagation(),a.preventDefault(),b.htmlarea.addClass("editorDragOver")},g=function(d){var e=d&&d.clipboardData?d.clipboardData:d&&d.originalEvent&&d.originalEvent.clipboardData?d.originalEvent.clipboardData:null;e&&e.items&&h.each(e.items,function(d){if(c(d)&&d.getAsFile){var e=null,f=d.getAsFile();f&&(e=new a.FileReader,e.onload=function(a){return function(c){b.insertImage(c.target.result,a.name)}}(f),e.readAsDataURL(f))}})};this.bOnlyPlain||a.File&&a.FileReader&&a.FileList&&(this.htmlarea.bind("dragover",f),this.htmlarea.bind("dragleave",e),this.htmlarea.bind("drop",d),this.htmlarea.bind("paste",g))},j.htmlColorPickerColors=function(){var a=[],b=[],c=0,d=0,e=0,f=0,g="";for(c=0;256>c;c+=85)g=c.toString(16),a.push(1===g.length?"0"+g:g);for(f=a.length,c=0;f>c;c++)for(d=0;f>d;d++)for(e=0;f>e;e++)b.push("#"+a[c]+a[d]+a[e]);return b}(),j.htmlFontPicker=function(){var c=b(a.document),d=!1,e=b(''),f=e.find(".editorFpFonts"),g=function(){};return b.each(["Arial","Arial Black","Courier New","Tahoma","Times New Roman","Verdana"],function(a,c){f.append(b(''+c+"").click(function(){g(c)})),f.append("
")}),e.hide(),function(f,h,i){d||(e.appendTo(i),d=!0),g=h,c.unbind("click.fpNamespace"),a.setTimeout(function(){c.one("click.fpNamespace",function(){e.hide()})},500);var j=b(f).position();e.css("top",5+j.top+b(f).height()+"px").css("left",j.left+"px").show()}}(),j.htmlColorPicker=function(){var c=b(a.document),d=!1,e=b(''),f=e.find(".editorCpColors"),g=function(){};return b.each(j.htmlColorPickerColors,function(a,b){f.append('')}),e.hide(),b(".editorCpColor",f).click(function(a){var c=1,d="#000000",e=b(a.target).css("background-color"),f=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(null!==f){for(delete f[0];3>=c;++c)f[c]=pb.pInt(f[c]).toString(16),1===f[c].length&&(f[c]="0"+f[c]);d="#"+f.join("")}else d=e;g(d)}),function(f,h,i){d||(e.appendTo(i),d=!0);var j=b(f).position();g=h,c.unbind("click.cpNamespace"),a.setTimeout(function(){c.one("click.cpNamespace",function(){e.hide()})},100),e.css("top",5+j.top+b(f).height()+"px").css("left",j.left+"px").show()}}(),j.htmlFunctions={bold:function(){this.ec("bold")},italic:function(){this.ec("italic")},underline:function(){this.ec("underline")},strikethrough:function(){this.ec("strikethrough")},indent:function(){this.ec("indent")},outdent:function(){this.ec("outdent")},justifyleft:function(){this.ec("justifyLeft")},justifycenter:function(){this.ec("justifyCenter")},justifyright:function(){this.ec("justifyRight")},horizontalrule:function(){this.ec("insertHorizontalRule",!1,"ht")},removeformat:function(){this.ec("removeFormat")},orderedlist:function(){this.ec("insertorderedlist")},unorderedlist:function(){this.ec("insertunorderedlist")},forecolor:function(a){j.htmlColorPicker(a,h.bind(function(a){this.setcolor("forecolor",a)},this),this.toolbar)},backcolor:function(a){j.htmlColorPicker(a,h.bind(function(a){this.setcolor("backcolor",a)},this),this.toolbar)},fontname:function(a){j.htmlFontPicker(a,h.bind(function(a){this.ec("fontname",!1,a)},this),this.toolbar)}},k.prototype.selectItemCallbacks=function(a){(this.oCallbacks.onItemSelect||this.emptyFunction)(a)},k.prototype.goDown=function(){this.newSelectPosition(nb.EventKeyCode.Down,!1)},k.prototype.goUp=function(){this.newSelectPosition(nb.EventKeyCode.Up,!1)},k.prototype.init=function(d,e){if(this.oContentVisible=d,this.oContentScrollable=e,this.oContentVisible&&this.oContentScrollable){var f=this;b(this.oContentVisible).on("click",this.sItemSelector,function(a){f.actionClick(c.dataFor(this),a)}).on("click",this.sItemCheckedSelector,function(a){var b=c.dataFor(this);b&&(a&&a.shiftKey?f.actionClick(b,a):(f.sLastUid=f.getItemUid(b),b.selected()?(b.checked(!1),f.selectedItem(null)):b.checked(!b.checked())))}),b(a.document).on("keydown",function(a){var b=!0;return a&&f.bUseKeyboard&&!pb.inFocus()&&(-10)if(m){if(m)if(nb.EventKeyCode.Down===b||nb.EventKeyCode.Up===b||nb.EventKeyCode.Insert===b)h.each(k,function(a){if(!i)switch(b){case nb.EventKeyCode.Up:m===a?i=!0:j=a;break;case nb.EventKeyCode.Down:case nb.EventKeyCode.Insert:g?(j=a,i=!0):m===a&&(g=!0)}});else if(nb.EventKeyCode.Home===b||nb.EventKeyCode.End===b)nb.EventKeyCode.Home===b?j=k[0]:nb.EventKeyCode.End===b&&(j=k[k.length-1]);else if(nb.EventKeyCode.PageDown===b){for(;l>e;e++)if(m===k[e]){e+=f,e=e>l-1?l-1:e,j=k[e];break}}else if(nb.EventKeyCode.PageUp===b)for(e=l;e>=0;e--)if(m===k[e]){e-=f,e=0>e?0:e,j=k[e];break}}else nb.EventKeyCode.Down===b||nb.EventKeyCode.Insert===b||nb.EventKeyCode.Home===b||nb.EventKeyCode.PageUp===b?j=k[0]:(nb.EventKeyCode.Up===b||nb.EventKeyCode.End===b||nb.EventKeyCode.PageDown===b)&&(j=k[k.length-1]);j?(m&&(c?(nb.EventKeyCode.Up===b||nb.EventKeyCode.Down===b)&&m.checked(!m.checked()):nb.EventKeyCode.Insert===b&&m.checked(!m.checked())),this.throttleSelection=!0,this.selectedItem(j),this.throttleSelection=!0,0!==this.iSelectTimer?(a.clearTimeout(this.iSelectTimer),this.iSelectTimer=a.setTimeout(function(){d.iSelectTimer=0,d.actionClick(j)},1e3)):(this.iSelectTimer=a.setTimeout(function(){d.iSelectTimer=0},200),this.actionClick(j)),this.scrollToSelected()):m&&(!c||nb.EventKeyCode.Up!==b&&nb.EventKeyCode.Down!==b?nb.EventKeyCode.Insert===b&&m.checked(!m.checked()):m.checked(!m.checked()))},k.prototype.scrollToSelected=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var a=20,c=b(this.sItemSelectedSelector,this.oContentScrollable),d=c.position(),e=this.oContentVisible.height(),f=c.outerHeight();return d&&(d.top<0||d.top+f>e)?(d.top<0?this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+d.top-a):this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+d.top-e+f+a),!0):!1},k.prototype.eventClickFunction=function(a,b){var c=this.getItemUid(a),d=0,e=0,f=null,g="",h=!1,i=!1,j=[],k=!1;if(b&&b.shiftKey&&""!==c&&""!==this.sLastUid&&c!==this.sLastUid)for(j=this.list(),k=a.checked(),d=0,e=j.length;e>d;d++)f=j[d],g=this.getItemUid(f),h=!1,(g===this.sLastUid||g===c)&&(h=!0),h&&(i=!i),(i||h)&&f.checked(k);this.sLastUid=""===c?"":c},k.prototype.actionClick=function(a,b){if(a){var c=!0,d=this.getItemUid(a);b&&(b.shiftKey?(c=!1,""===this.sLastUid&&(this.sLastUid=d),a.checked(!a.checked()),this.eventClickFunction(a,b)):b.ctrlKey&&(c=!1,this.sLastUid=d,a.checked(!a.checked()))),c&&(this.selectedItem(a),this.sLastUid=d)}},k.prototype.on=function(a,b){this.oCallbacks[a]=b},l.supported=function(){return!0},l.prototype.set=function(a,c){var d=b.cookie(mb.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(mb.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},l.prototype.get=function(a){var c=b.cookie(mb.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!pb.isUnd(d[a])?d[a]:null}catch(e){}return d},m.supported=function(){return!!a.localStorage},m.prototype.set=function(b,c){var d=a.localStorage[mb.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[mb.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},m.prototype.get=function(b){var c=a.localStorage[mb.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!pb.isUnd(d[b])?d[b]:null}catch(e){}return d},n.prototype.oDriver=null,n.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},n.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},o.prototype.bootstart=function(){},p.prototype.sPosition="",p.prototype.sTemplate="",p.prototype.viewModelName="",p.prototype.viewModelDom=null,p.prototype.viewModelTemplate=function(){return this.sTemplate},p.prototype.viewModelPosition=function(){return this.sPosition},p.prototype.cancelCommand=p.prototype.closeCommand=function(){},q.prototype.oCross=null,q.prototype.sScreenName="",q.prototype.aViewModels=[],q.prototype.viewModels=function(){return this.aViewModels},q.prototype.screenName=function(){return this.sScreenName},q.prototype.routes=function(){return null},q.prototype.__cross=function(){return this.oCross},q.prototype.__start=function(){var a=this.routes(),b=null,c=null;pb.isNonEmptyArray(a)&&(c=h.bind(this.onRoute||pb.emptyFunction,this),b=d.create(),h.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},r.constructorEnd=function(a){pb.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},r.prototype.sDefaultScreenName="",r.prototype.oScreens={},r.prototype.oBoot=null,r.prototype.oCurrentScreen=null,r.prototype.showLoading=function(){b("#rl-loading").show()},r.prototype.hideLoading=function(){b("#rl-loading").hide()},r.prototype.routeOff=function(){e.changed.active=!1},r.prototype.routeOn=function(){e.changed.active=!0},r.prototype.setBoot=function(a){return pb.isNormal(a)&&(this.oBoot=a),this},r.prototype.screen=function(a){return""===a||pb.isUnd(this.oScreens[a])?null:this.oScreens[a]},r.prototype.delegateRun=function(a,b,c){a&&a[b]&&a[b].apply(a,pb.isArray(c)?c:[])},r.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),f=e.viewModelPosition(),g=b("#rl-content #rl-"+f.toLowerCase()),h=null;a.__builded=!0,a.__vm=e,e.data=Bb.data(),e.viewModelName=a.__name,g&&1===g.length?(h=b(" ").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),h.appendTo(g),e.viewModelDom=h,a.__dom=h,"Popups"===f&&(e.cancelCommand=e.closeCommand=pb.createCommand(e,function(){ub.hideScreenPopup(a)})),qb.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),this.delegateRun(e,"onBuild",[h]),qb.runHook("view-model-post-build",[a.__name,e,h])):pb.log("Cannot find view model position: "+f)}return a?a.__vm:null},r.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},r.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1))},r.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),this.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),qb.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},r.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===pb.pString(a)&&(a=this.sDefaultScreenName),""!==a&&(d=this.screen(a),d||(d=this.screen(this.sDefaultScreenName),d&&(b=a+"/"+b,a=this.sDefaultScreenName)),d&&d.__started&&(d.__builded||(d.__builded=!0,pb.isNonEmptyArray(d.viewModels())&&h.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),this.delegateRun(d,"onBuild")),h.defer(function(){c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onHide"),pb.isNonEmptyArray(c.oCurrentScreen.viewModels())&&h.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),c.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onShow"),qb.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),pb.isNonEmptyArray(c.oCurrentScreen.viewModels())&&h.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),c.delegateRun(a.__vm,"onShow"),qb.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},r.prototype.startScreens=function(a){h.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),h.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),qb.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),qb.runHook("screen-post-start",[a.screenName(),a]))},this);var b=d.create();b.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,h.bind(this.screenOnRoute,this)),e.initialized.add(b.parse,b),e.changed.add(b.parse,b),e.init()},r.prototype.setHash=function(a,b,c){a="#"===a.substr(0,1)?a.substr(1):a,a="/"===a.substr(0,1)?a.substr(1):a,c=pb.isUnd(c)?!1:!!c,(pb.isUnd(b)?1:!b)?(e.changed.active=!0,e[c?"replaceHash":"setHash"](a),e.setHash(a)):(e.changed.active=!1,e[c?"replaceHash":"setHash"](a),e.changed.active=!0)},r.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},ub=new r,s.newInstanceFromJson=function(a){var b=new s;return b.initByJson(a)?b:null},s.prototype.name="",s.prototype.email="",s.prototype.privateType=null,s.prototype.clear=function(){this.email="",this.name="",this.privateType=null},s.prototype.validate=function(){return""!==this.name||""!==this.email},s.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},s.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},s.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=nb.EmailType.Facebook),null===this.privateType&&(this.privateType=nb.EmailType.Default)),this.privateType},s.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},s.prototype.parse=function(a){this.clear(),a=pb.trim(a);var b=/(?:"([^"]+)")? ?(.*?@[^>,]+)>?,? ?/g,c=b.exec(a);c?(this.name=c[1]||"",this.email=c[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)},s.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=pb.trim(a.Name),this.email=pb.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},s.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=pb.isUnd(b)?!1:!!b,c=pb.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+pb.encodeHtml(this.name)+"":c?pb.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=pb.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+pb.encodeHtml(d)+""+pb.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=pb.encodeHtml(d))):b&&(d=''+pb.encodeHtml(this.email)+""))),d},s.prototype.mailsoParse=function(a){if(a=pb.trim(a),""===a)return!1;for(var b=function(a,b,c){a+="";var d=a.length;return 0>b&&(b+=d),d="undefined"==typeof c?d:0>c?c+d:c+b,b>=a.length||0>b||b>d?!1:a.slice(b,d)},c=function(a,b,c,d){return 0>c&&(c+=a.length),d=void 0!==d?d:a.length,0>d&&(d=d+a.length-c),a.slice(0,c)+b.substr(0,d)+b.slice(d)+a.slice(c+d)},d="",e="",f="",g=!1,h=!1,i=!1,j=null,k=0,l=0,m=0;m").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+f.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(g),e.data=Bb.data(),e.viewModelDom=i,e.__rlSettingsData=f.__rlSettingsData,f.__dom=i,f.__builded=!0,f.__vm=e,c.applyBindings(e,i[0]),ub.delegateRun(e,"onBuild",[i])):pb.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&h.defer(function(){d.oCurrentSubScreen&&(ub.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),ub.delegateRun(d.oCurrentSubScreen,"onShow"),h.each(d.menu(),function(a){a.selected(e&&e.__rlSettingsData&&a.route===e.__rlSettingsData.Route)}),b("#rl-content .b-settings .b-content .content").scrollTop(0)),pb.windowResize()})):ub.setHash(Bb.link().settings(),!1,!0)},gb.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(ub.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},gb.prototype.onBuild=function(){h.each(tb.settings,function(a){a&&a.__rlSettingsData&&!h.find(tb["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!h.find(tb["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},gb.prototype.routes=function(){var a=h.find(tb.settings,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",c={subname:/^(.*)$/,normalize_:function(a,c){return c.subname=pb.isUnd(c.subname)?b:pb.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},h.extend(hb.prototype,q.prototype),hb.prototype.onShow=function(){Bb.setTitle(pb.i18n("TITLES/LOGIN"))},h.extend(ib.prototype,q.prototype),ib.prototype.oLastRoute={},ib.prototype.setNewTitle=function(){var a=Bb.data().accountEmail(),b=Bb.data().foldersInboxUnreadCount();Bb.setTitle((""===a?"":(b>0?"("+b+") ":" ")+a+" - ")+pb.i18n("TITLES/MAILBOX"))},ib.prototype.onShow=function(){this.setNewTitle()},ib.prototype.onRoute=function(a,b,c){var d=Bb.data(),e=Bb.cache().getFolderFullNameRaw(a),f=Bb.cache().getFolderFromCacheList(e);f&&(d.currentFolder(f).messageListPage(b).messageListSearch(c),!d.usePreviewPane()&&d.message()&&d.message(null),Bb.reloadMessageList())},ib.prototype.onStart=function(){var a=Bb.data(),b=function(){pb.windowResize()};(Bb.settingsGet("AllowAdditionalAccounts")||Bb.settingsGet("AllowIdentities"))&&Bb.accountsAndIdentities(),h.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&Bb.folderInformation("INBOX")},1e3),h.delay(function(){Bb.quota()},5e3),h.delay(function(){Bb.remote().appDelayStart(pb.emptyFunction)},35e3),xb.toggleClass("rl-no-preview-pane",!a.usePreviewPane()),a.folderList.subscribe(b),a.messageList.subscribe(b),a.message.subscribe(b),a.usePreviewPane.subscribe(function(a){xb.toggleClass("rl-no-preview-pane",!a)}),a.foldersInboxUnreadCount.subscribe(function(){this.setNewTitle()},this)},ib.prototype.onBuild=function(){sb.bMobileDevice||h.defer(function(){pb.initLayoutResizer("#rl-resizer-left","#rl-resizer-right","#rl-right",350,800,350,350,nb.ClientSideKeyName.MailBoxListSize)})},ib.prototype.routes=function(){var a=function(a,b){return b[0]=pb.pString(b[0]),b[1]=pb.pInt(b[1]),b[1]=0>=b[1]?1:b[1],b[2]=pb.pString(b[2]),""===a&&(b[0]="Inbox",b[1]=1),[decodeURI(b[0]),b[1],decodeURI(b[2])]},b=function(a,b){return b[0]=pb.pString(b[0]),b[1]=pb.pString(b[1]),""===a&&(b[0]="Inbox"),[decodeURI(b[0]),1,decodeURI(b[1])]};return[[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/,{normalize_:a}],[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/,{normalize_:a}],[/^([a-zA-Z0-9]+)\/(.+)\/?$/,{normalize_:b}],[/^([^\/]*)$/,{normalize_:a}]]},h.extend(jb.prototype,gb.prototype),jb.prototype.onShow=function(){Bb.setTitle(this.sSettingsTitle)},h.extend(kb.prototype,o.prototype),kb.prototype.oSettings=null,kb.prototype.oPlugins=null,kb.prototype.oLocal=null,kb.prototype.oLink=null,kb.prototype.oSubs={},kb.prototype.download=function(b){var c=null,d=null,e=navigator.userAgent.toLowerCase();return e&&(e.indexOf("chrome")>-1||e.indexOf("chrome")>-1)&&(c=document.createElement("a"),c.href=b,document.createEvent&&(d=document.createEvent("MouseEvents"),d&&d.initEvent&&c.dispatchEvent))?(d.initEvent("click",!0,!0),c.dispatchEvent(d),!0):(sb.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},kb.prototype.link=function(){return null===this.oLink&&(this.oLink=new i),this.oLink},kb.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new n),this.oLocal},kb.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=pb.isNormal(vb)?vb:{}),pb.isUnd(this.oSettings[a])?null:this.oSettings[a]},kb.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=pb.isNormal(vb)?vb:{}),this.oSettings[a]=b},kb.prototype.setTitle=function(b){b=(00&&0===d.length&&(d=b(a,0,m)),h=!0,k=m);break;case">":h&&(l=m,e=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,h=!1);break;case"(":g||h||i||(i=!0,k=m);break;case")":i&&(l=m,f=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,i=!1);break;case"\\":m++}m++}return 0===e.length&&(j=a.match(/[^@\s]+@\S+/i),j&&j[0]?e=j[0]:d=a),e.length>0&&0===d.length&&0===f.length&&(d=a.replace(e,"")),e=pb.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=pb.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=pb.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},s.prototype.inputoTagLine=function(){return 0 +$/,""),b=!0),b},v.prototype.isImage=function(){return-1 e;e++)d.push(a[e].toLine(b,c));return d.join(", ")},x.initEmailsFromJson=function(a){var b=0,c=0,d=null,e=[];if(pb.isNonEmptyArray(a))for(b=0,c=a.length;c>b;b++)d=s.newInstanceFromJson(a[b]),d&&e.push(d);return e},x.replyHelper=function(a,b,c){if(a&&0 d;d++)pb.isUnd(b[a[d].email])&&(b[a[d].email]=!0,c.push(a[d]))},x.prototype.clear=function(){this.folderFullNameRaw="",this.uid="",this.requestHash="",this.subject(""),this.size(0),this.dateTimeStampInUTC(0),this.priority(nb.MessagePriority.Normal),this.fromEmailString(""),this.toEmailsString(""),this.senderEmailsString(""),this.prefetched=!1,this.emails=[],this.from=[],this.to=[],this.cc=[],this.bcc=[],this.replyTo=[],this.newForAnimation(!1),this.deleted(!1),this.unseen(!1),this.flagged(!1),this.answered(!1),this.forwarded(!1),this.selected(!1),this.checked(!1),this.hasAttachments(!1),this.attachmentsMainType(""),this.body=null,this.isRtl(!1),this.isHtml(!1),this.hasImages(!1),this.attachments([]),this.priority(nb.MessagePriority.Normal),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)},x.prototype.initByJson=function(a){var b=!1;return a&&"Object/Message"===a["@Object"]&&(this.folderFullNameRaw=a.Folder,this.uid=a.Uid,this.requestHash=a.RequestHash,this.prefetched=!1,this.size(pb.pInt(a.Size)),this.from=x.initEmailsFromJson(a.From),this.to=x.initEmailsFromJson(a.To),this.cc=x.initEmailsFromJson(a.Cc),this.bcc=x.initEmailsFromJson(a.Bcc),this.replyTo=x.initEmailsFromJson(a.ReplyTo),this.subject(a.Subject),this.dateTimeStampInUTC(pb.pInt(a.DateTimeStampInUTC)),this.hasAttachments(!!a.HasAttachments),this.attachmentsMainType(a.AttachmentsMainType),this.fromEmailString(x.emailsToLine(this.from,!0)),this.toEmailsString(x.emailsToLine(this.to,!0)),this.parentUid(pb.pInt(a.ParentThread)),this.threads(pb.isArray(a.Threads)?a.Threads:[]),this.threadsLen(pb.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0),b},x.prototype.computeSenderEmail=function(){var a=Bb.data().sentFolder(),b=Bb.data().draftFolder();this.senderEmailsString(this.folderFullNameRaw===a||this.folderFullNameRaw===b?this.toEmailsString():this.fromEmailString())},x.prototype.initUpdateByMessageJson=function(a){var b=!1,c=nb.MessagePriority.Normal;return a&&"Object/Message"===a["@Object"]&&(c=pb.pInt(a.Priority),this.priority(-1 b;b++)d=v.newInstanceFromJson(a["@Collection"][b]),d&&(""!==d.cidWithOutTags&&0 +$/,""),b=h.find(c,function(b){return a===b.cidWithOutTags})),b||null},x.prototype.findAttachmentByContentLocation=function(a){var b=null,c=this.attachments();return pb.isNonEmptyArray(c)&&(b=h.find(c,function(b){return a===b.contentLocation})),b||null},x.prototype.messageId=function(){return this.sMessageId},x.prototype.inReplyTo=function(){return this.sInReplyTo},x.prototype.references=function(){return this.sReferences},x.prototype.fromAsSingleEmail=function(){return pb.isArray(this.from)&&this.from[0]?this.from[0].email:""},x.prototype.viewLink=function(){return Bb.link().messageViewLink(this.requestHash)},x.prototype.downloadLink=function(){return Bb.link().messageDownloadLink(this.requestHash)},x.prototype.replyEmails=function(a){var b=[],c=pb.isUnd(a)?{}:a;return x.replyHelper(this.replyTo,c,b),0===b.length&&x.replyHelper(this.from,c,b),b},x.prototype.replyAllEmails=function(a){var b=[],c=[],d=pb.isUnd(a)?{}:a;return x.replyHelper(this.replyTo,d,b),0===b.length&&x.replyHelper(this.from,d,b),x.replyHelper(this.to,d,b),x.replyHelper(this.cc,d,c),[b,c]},x.prototype.textBodyToString=function(){return this.body?this.body.html():"" +},x.prototype.attachmentsToStringLine=function(){var a=h.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0 =0&&e&&!f&&d.attr("src",e)}),c&&a.setTimeout(function(){d.print()},100))})},x.prototype.printMessage=function(){this.viewPopupMessage(!0)},x.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid},x.prototype.populateByMessageListItem=function(a){return this.folderFullNameRaw=a.folderFullNameRaw,this.uid=a.uid,this.requestHash=a.requestHash,this.subject(a.subject()),this.size(a.size()),this.dateTimeStampInUTC(a.dateTimeStampInUTC()),this.priority(a.priority()),this.fromEmailString(a.fromEmailString()),this.toEmailsString(a.toEmailsString()),this.emails=a.emails,this.from=a.from,this.to=a.to,this.cc=a.cc,this.bcc=a.bcc,this.replyTo=a.replyTo,this.unseen(a.unseen()),this.flagged(a.flagged()),this.answered(a.answered()),this.forwarded(a.forwarded()),this.selected(a.selected()),this.checked(a.checked()),this.hasAttachments(a.hasAttachments()),this.attachmentsMainType(a.attachmentsMainType()),this.moment(a.moment()),this.body=null,this.priority(nb.MessagePriority.Normal),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid(a.parentUid()),this.threads(a.threads()),this.threadsLen(a.threadsLen()),this.computeSenderEmail(),this},x.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=pb.isUnd(a)?!1:a,this.hasImages(!1),this.body.data("rl-has-images",!1),b("[data-x-src]",this.body).each(function(){a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",b(this).attr("data-x-src")).removeAttr("data-x-src"):b(this).attr("src",b(this).attr("data-x-src")).removeAttr("data-x-src")}),b("[data-x-style-url]",this.body).each(function(){var a=pb.trim(b(this).attr("style"));a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+b(this).attr("data-x-style-url")).removeAttr("data-x-style-url")}),a&&(b("img.lazy",this.body).addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b(".RL-MailMessageView .messageView .messageItem .content")[0]}),yb.resize()),pb.windowResize(500))},x.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){a=pb.isUnd(a)?!1:a;var c=this;this.body.data("rl-init-internal-images",!0),b("[data-x-src-cid]",this.body).each(function(){var d=c.findAttachmentByCid(b(this).attr("data-x-src-cid"));d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-src-location]",this.body).each(function(){var d=c.findAttachmentByContentLocation(b(this).attr("data-x-src-location"));d||(d=c.findAttachmentByCid(b(this).attr("data-x-src-location"))),d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-style-cid]",this.body).each(function(){var a="",d="",e=c.findAttachmentByCid(b(this).attr("data-x-style-cid"));e&&e.linkPreview&&(d=b(this).attr("data-x-style-cid-name"),""!==d&&(a=pb.trim(b(this).attr("style")),a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+d+": url('"+e.linkPreview()+"')")))}),a&&!function(a,b){h.delay(function(){a.addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b})},300)}(b("img.lazy",c.body),b(".RL-MailMessageView .messageView .messageItem .content")[0]),pb.windowResize(500)}},y.newInstanceFromJson=function(a){var b=new y;return b.initByJson(a)?b.initComputed():null},y.prototype.initComputed=function(){return this.hasSubScribedSubfolders=c.computed(function(){return!!h.find(this.subFolders(),function(a){return a.subScribed()})},this),this.canBeEdited=c.computed(function(){return nb.FolderType.User===this.type()&&this.existen&&this.selectable},this),this.visible=c.computed(function(){var a=this.subScribed(),b=this.hasSubScribedSubfolders();return a||b&&(!this.existen||!this.selectable)},this),this.isSystemFolder=c.computed(function(){return nb.FolderType.User!==this.type()},this),this.hidden=c.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return this.isGmailFolder||a&&this.isNamespaceFolder||a&&!b},this),this.selectableForFolderList=c.computed(function(){return!this.isSystemFolder()&&this.selectable},this),this.messageCountAll=c.computed({read:this.privateMessageCountAll,write:function(a){pb.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this}),this.messageCountUnread=c.computed({read:this.privateMessageCountUnread,write:function(a){pb.isPosNumeric(a,!0)?this.privateMessageCountUnread(a):this.privateMessageCountUnread.valueHasMutated()},owner:this}),this.printableUnreadCount=c.computed(function(){var a=this.messageCountAll(),b=this.messageCountUnread(),c=this.type();if(nb.FolderType.Inbox===c&&Bb.data().foldersInboxUnreadCount(b),a>0){if(nb.FolderType.Draft===c)return""+a;if(b>0&&nb.FolderType.Trash!==c&&nb.FolderType.SentItems!==c)return""+b}return""},this),this.canBeDeleted=c.computed(function(){var a=this.isSystemFolder();return!a&&0===this.subFolders().length&&"INBOX"!==this.fullNameRaw},this),this.canBeSubScribed=c.computed(function(){return!this.isSystemFolder()&&this.selectable&&"INBOX"!==this.fullNameRaw},this),this.visible.subscribe(function(){pb.timeOutAction("folder-list-folder-visibility-change",function(){yb.trigger("folder-list-folder-visibility-change")},100)}),this.localName=c.computed(function(){sb.langChangeTrigger();var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case nb.FolderType.Inbox:b=pb.i18n("FOLDER_LIST/INBOX_NAME");break;case nb.FolderType.SentItems:b=pb.i18n("FOLDER_LIST/SENT_NAME");break;case nb.FolderType.Draft:b=pb.i18n("FOLDER_LIST/DRAFTS_NAME");break;case nb.FolderType.Spam:b=pb.i18n("FOLDER_LIST/SPAM_NAME");break;case nb.FolderType.Trash:b=pb.i18n("FOLDER_LIST/TRASH_NAME")}return b},this),this.manageFolderSystemName=c.computed(function(){sb.langChangeTrigger();var a="",b=this.type(),c=this.name();if(this.isSystemFolder())switch(b){case nb.FolderType.Inbox:a="("+pb.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case nb.FolderType.SentItems:a="("+pb.i18n("FOLDER_LIST/SENT_NAME")+")";break;case nb.FolderType.Draft:a="("+pb.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case nb.FolderType.Spam:a="("+pb.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case nb.FolderType.Trash:a="("+pb.i18n("FOLDER_LIST/TRASH_NAME")+")"}return(""!==a&&"("+c+")"===a||"(inbox)"===a.toLowerCase())&&(a=""),a},this),this.collapsed=c.computed({read:function(){return!this.hidden()&&this.collapsedPrivate()},write:function(a){this.collapsedPrivate(a)},owner:this}),this},y.prototype.fullName="",y.prototype.fullNameRaw="",y.prototype.fullNameHash="",y.prototype.delimiter="",y.prototype.namespace="",y.prototype.deep=0,y.prototype.interval=0,y.prototype.isNamespaceFolder=!1,y.prototype.isGmailFolder=!1,y.prototype.isUnpaddigFolder=!1,y.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"},y.prototype.initByJson=function(a){var b=!1;return a&&"Object/Folder"===a["@Object"]&&(this.name(a.Name),this.delimiter=a.Delimiter,this.fullName=a.FullName,this.fullNameRaw=a.FullNameRaw,this.fullNameHash=a.FullNameHash,this.deep=a.FullNameRaw.split(this.delimiter).length-1,this.selectable=!!a.IsSelectable,this.existen=!!a.IsExisten,this.subScribed(!!a.IsSubscribed),this.type("INBOX"===this.fullNameRaw?nb.FolderType.Inbox:nb.FolderType.User),b=!0),b},y.prototype.printableFullName=function(){return this.fullName.split(this.delimiter).join(" / ")},z.prototype.email="",z.prototype.changeAccountLink=function(){return Bb.link().change(this.email)},A.prototype.formattedName=function(){var a=this.name();return""===a?this.email():a+" <"+this.email()+">"},A.prototype.formattedNameForCompose=function(){var a=this.name();return""===a?this.email():a+" ("+this.email()+")"},A.prototype.formattedNameForEmail=function(){var a=this.name();return""===a?this.email():'"'+pb.quoteName(a)+'" <'+this.email()+">"},pb.extendAsViewModel("PopupsFolderClearViewModel",B),B.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},B.prototype.onShow=function(a){this.clearPopup(),a&&this.selectedFolder(a)},B.prototype.onBuild=function(){var a=this;yb.on("keydown",function(b){var c=!0;return b&&nb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(ub.delegateRun(a,"cancelCommand"),c=!1),c})},pb.extendAsViewModel("PopupsFolderCreateViewModel",C),C.prototype.sNoParentText="",C.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(pb.trim(a))},C.prototype.clearPopup=function(){this.folderName(""),this.selectedParentValue(""),this.focusTrigger(!1)},C.prototype.onShow=function(){this.clearPopup(),this.focusTrigger(!0)},C.prototype.onBuild=function(){var a=this;yb.on("keydown",function(b){var c=!0;return b&&nb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(ub.delegateRun(a,"cancelCommand"),c=!1),c})},pb.extendAsViewModel("PopupsFolderSystemViewModel",D),D.prototype.sChooseOnText="",D.prototype.sUnuseText="",D.prototype.onShow=function(a){var b="";switch(a=pb.isUnd(a)?nb.SetSystemFoldersNotification.None:a){case nb.SetSystemFoldersNotification.Sent:b=pb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case nb.SetSystemFoldersNotification.Draft:b=pb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case nb.SetSystemFoldersNotification.Spam:b=pb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case nb.SetSystemFoldersNotification.Trash:b=pb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH")}this.notification(b)},D.prototype.onBuild=function(){var a=this;yb.on("keydown",function(b){var c=!0;return b&&nb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(ub.delegateRun(a,"cancelCommand"),c=!1),c})},pb.extendAsViewModel("PopupsComposeViewModel",E),E.prototype.findIdentityIdByMessage=function(a,b){var c={},d="",e=function(a){return a&&a.email&&c[a.email]?(d=c[a.email],!0):!1};switch(this.bAllowIdentities&&h.each(this.identities(),function(a){c[a.email()]=a.id}),c[Bb.data().accountEmail()]=Bb.data().accountEmail(),a){case nb.ComposeType.Empty:d=Bb.data().accountEmail();break;case nb.ComposeType.Reply:case nb.ComposeType.ReplyAll:case nb.ComposeType.Forward:case nb.ComposeType.ForwardAsAttachment:h.find(h.union(b.to,b.cc,b.bcc),e);break;case nb.ComposeType.Draft:h.find(h.union(b.from,b.replyTo),e)}return d},E.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)},E.prototype.formattedFrom=function(a){var b=Bb.data().displayName(),c=Bb.data().accountEmail();return""===b?c:(pb.isUnd(a)?1:!a)?b+" ("+c+")":'"'+pb.quoteName(b)+'" <'+c+">"},E.prototype.sendMessageResponse=function(b,c){var d=!1;this.sending(!1),nb.StorageResultType.Success===b&&c&&c.Result&&(d=!0,this.modalVisibility()&&ub.delegateRun(this,"closeCommand")),this.modalVisibility()&&!d&&(c&&nb.Notification.CantSaveMessage===c.ErrorCode?(this.sendSuccessButSaveError(!0),a.alert(pb.trim(pb.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(this.sendError(!0),a.alert(pb.getNotification(c&&c.ErrorCode?c.ErrorCode:nb.Notification.CantSendMessage))))},E.prototype.saveMessageResponse=function(b,c){var d=!1,e=null;this.saving(!1),nb.StorageResultType.Success===b&&c&&c.Result&&c.Result.NewFolder&&c.Result.NewUid&&(this.bFromDraft&&(e=Bb.data().message(),e&&this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid&&Bb.data().message(null)),this.draftFolder(c.Result.NewFolder),this.draftUid(c.Result.NewUid),this.modalVisibility()&&(this.savedTime(Math.round((new a.Date).getTime()/1e3)),this.savedOrSendingText(0 b;b++)d.push(a[b].toLine(!1));return d.join(", ")};if(c=c||null,c&&pb.isNormal(c)&&(t=pb.isArray(c)&&1===c.length?c[0]:pb.isArray(c)?null:c),null!==q&&(p[q]=!0,this.currentIdentityID(this.findIdentityIdByMessage(v,t))),this.reset(),pb.isNonEmptyArray(d)&&this.to(w(d)),""!==v&&t){switch(j=t.fullFormatDateValue(),k=t.subject(),s=t.aDraftInfo,l=b(t.body).clone(),pb.removeBlockquoteSwitcher(l),m=l.html(),v){case nb.ComposeType.Empty:break;case nb.ComposeType.Reply:this.to(w(t.replyEmails(p))),this.subject(pb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(t,v),this.aDraftInfo=["reply",t.uid,t.folderFullNameRaw],this.sInReplyTo=t.sMessageId,this.sReferences=pb.trim(this.sInReplyTo+" "+t.sReferences),u=!0;break;case nb.ComposeType.ReplyAll:o=t.replyAllEmails(p),this.to(w(o[0])),this.cc(w(o[1])),this.subject(pb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(t,v),this.aDraftInfo=["reply",t.uid,t.folderFullNameRaw],this.sInReplyTo=t.sMessageId,this.sReferences=pb.trim(this.sInReplyTo+" "+t.references()),u=!0;break;case nb.ComposeType.Forward:this.subject(pb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(t,v),this.aDraftInfo=["forward",t.uid,t.folderFullNameRaw],this.sInReplyTo=t.sMessageId,this.sReferences=pb.trim(this.sInReplyTo+" "+t.sReferences);break;case nb.ComposeType.ForwardAsAttachment:this.subject(pb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(t,v),this.aDraftInfo=["forward",t.uid,t.folderFullNameRaw],this.sInReplyTo=t.sMessageId,this.sReferences=pb.trim(this.sInReplyTo+" "+t.sReferences);break;case nb.ComposeType.Draft:this.to(w(t.to)),this.cc(w(t.cc)),this.bcc(w(t.bcc)),this.bFromDraft=!0,this.draftFolder(t.folderFullNameRaw),this.draftUid(t.uid),this.subject(k),this.prepearMessageAttachments(t,v),this.aDraftInfo=pb.isNonEmptyArray(s)&&3===s.length?s:null,this.sInReplyTo=t.sInReplyTo,this.sReferences=t.sReferences}if(this.oEditor){switch(v){case nb.ComposeType.Reply:case nb.ComposeType.ReplyAll:f=t.fromToLine(!1,!0),n=pb.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:j,EMAIL:f}),m="
"+n+":";break;case nb.ComposeType.Forward:f=t.fromToLine(!1,!0),g=t.toToLine(!1,!0),i=t.ccToLine(!1,!0),m="
"+m+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+f+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+g+(0"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+i:"")+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+pb.encodeHtml(j)+"
"+pb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+pb.encodeHtml(k)+"
"+m;break;case nb.ComposeType.ForwardAsAttachment:m=""}this.oEditor.setRawText(m,t.isHtml())}}else this.oEditor&&nb.ComposeType.Empty===v?this.oEditor.setRawText("
"+pb.convertPlainTextToHtml(Bb.data().signature()),nb.EditorDefaultType.Html===Bb.data().editorDefaultType()):pb.isNonEmptyArray(c)&&h.each(c,function(a){e.addMessageAsAttachment(a)});""===this.to()&&this.to.focusTrigger(!this.to.focusTrigger()),r=this.getAttachmentsDownloadsForUpload(),pb.isNonEmptyArray(r)&&Bb.remote().messageUploadAttachments(function(a,b){if(nb.StorageResultType.Success===a&&b&&b.Result){var c=null,d="";if(!e.viewModelVisibility())for(d in b.Result)b.Result.hasOwnProperty(d)&&(c=e.getAttachmentById(b.Result[d]),c&&c.tempName(d))}else e.setMessageAttachmentFailedDowbloadText()},r),u&&this.oEditor&&this.oEditor.focus(),this.triggerForResize()},E.prototype.tryToClosePopup=function(){var a=this;ub.showScreenPopup(K,[pb.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&ub.delegateRun(a,"closeCommand")}])},E.prototype.onBuild=function(){this.initEditor(),this.initUploader();var a=this,c=null;yb.on("keydown",function(b){var c=!0;return b&&a.modalVisibility()&&Bb.data().useKeyboardShortcuts()&&(b.ctrlKey&&nb.EventKeyCode.S===b.keyCode?(a.saveCommand(),c=!1):b.ctrlKey&&nb.EventKeyCode.Enter===b.keyCode?(a.sendCommand(),c=!1):nb.EventKeyCode.Esc===b.keyCode&&(a.tryToClosePopup(),c=!1)),c}),yb.on("resize",function(){a.triggerForResize()}),this.dropboxEnabled()&&(c=document.createElement("script"),c.type="text/javascript",c.src="https://www.dropbox.com/static/api/1/dropins.js",b(c).attr("id","dropboxjs").attr("data-app-key",Bb.settingsGet("DropboxApiKey")),document.body.appendChild(c))},E.prototype.getAttachmentById=function(a){for(var b=this.attachments(),c=0,d=b.length;d>c;c++)if(b[c]&&a===b[c].id)return b[c];return null},E.prototype.initEditor=function(){if(this.composeEditorTextArea()&&this.composeEditorHtmlArea()&&this.composeEditorToolbar()){var a=this;this.oEditor=new j(this.composeEditorTextArea(),this.composeEditorHtmlArea(),this.composeEditorToolbar(),{onSwitch:function(b){b||a.removeLinkedAttachments()}}),this.oEditor.initLanguage(pb.i18n("EDITOR/TEXT_SWITCHER_CONFIRM"),pb.i18n("EDITOR/TEXT_SWITCHER_PLAINT_TEXT"),pb.i18n("EDITOR/TEXT_SWITCHER_RICH_FORMATTING"))}},E.prototype.initUploader=function(){if(this.composeUploaderButton()){var a={},b=pb.pInt(Bb.settingsGet("AttachmentLimit")),c=new g({action:Bb.link().upload(),name:"uploader",queueSize:2,multipleSizeLimit:50,disableFolderDragAndDrop:!1,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace()});c?(c.on("onDragEnter",h.bind(function(){this.dragAndDropOver(!0)},this)).on("onDragLeave",h.bind(function(){this.dragAndDropOver(!1)},this)).on("onBodyDragEnter",h.bind(function(){this.dragAndDropVisible(!0)},this)).on("onBodyDragLeave",h.bind(function(){this.dragAndDropVisible(!1)},this)).on("onProgress",h.bind(function(b,c,d){var e=null;pb.isUnd(a[b])?(e=this.getAttachmentById(b),e&&(a[b]=e)):e=a[b],e&&e.progress(" - "+Math.floor(c/d*100)+"%")},this)).on("onSelect",h.bind(function(a,d){this.dragAndDropOver(!1);var e=this,f=pb.isUnd(d.FileName)?"":d.FileName.toString(),g=pb.isNormal(d.Size)?pb.pInt(d.Size):null,h=new w(a,f,g);return h.cancel=function(a){return function(){e.attachments.remove(function(b){return b&&b.id===a}),c&&c.cancel(a)}}(a),this.attachments.push(h),g>0&&b>0&&g>b?(h.error(pb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(b){var c=null;pb.isUnd(a[b])?(c=this.getAttachmentById(b),c&&(a[b]=c)):c=a[b],c&&(c.waiting(!1),c.uploading(!0))},this)).on("onComplete",h.bind(function(b,c,d){var e="",f=null,g=null,h=this.getAttachmentById(b);g=c&&d&&d.Result&&d.Result.Attachment?d.Result.Attachment:null,f=d&&d.Result&&d.Result.ErrorCode?d.Result.ErrorCode:null,null!==f?e=pb.getUploadErrorDescByCode(f):g||(e=pb.i18n("UPLOAD/ERROR_UNKNOWN")),h&&(""!==e&&00&&d>0&&f>d?(e.uploading(!1),e.error(pb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(Bb.remote().composeUploadExternals(function(a,b){var c=!1;e.uploading(!1),nb.StorageResultType.Success===a&&b&&b.Result&&b.Result[e.id]&&(c=!0,e.tempName(b.Result[e.id])),c||e.error(pb.getUploadErrorDescByCode(nb.UploadErrorCode.FileNoUploaded))},[a.link]),!0)},E.prototype.prepearMessageAttachments=function(a,b){if(a){var c=this,d=pb.isNonEmptyArray(a.attachments())?a.attachments():[],e=0,f=d.length,g=null,h=null,i=!1,j=function(a){return function(){c.attachments.remove(function(b){return b&&b.id===a})}};if(nb.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f>e;e++){switch(h=d[e],i=!1,b){case nb.ComposeType.Reply:case nb.ComposeType.ReplyAll:i=h.isLinked;break;case nb.ComposeType.Forward:case nb.ComposeType.Draft:i=!0}i=!0,i&&(g=new w(h.download,h.fileName,h.estimatedSize,h.isInline,h.isLinked,h.cid,h.contentLocation),g.fromMessage=!0,g.cancel=j(h.download),g.waiting(!1).uploading(!0),this.attachments.push(g))}}},E.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})},E.prototype.setMessageAttachmentFailedDowbloadText=function(){h.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(pb.getUploadErrorDescByCode(nb.UploadErrorCode.FileNoUploaded))},this)},E.prototype.isEmptyForm=function(a){a=pb.isUnd(a)?!0:!!a;var b=a?0===this.attachments().length:0===this.attachmentsInReady().length;return 0===this.to().length&&0===this.cc().length&&0===this.bcc().length&&0===this.subject().length&&b&&""===this.oEditor.getTextForRequest()},E.prototype.reset=function(){this.to(""),this.cc(""),this.bcc(""),this.replyTo(""),this.subject(""),this.aDraftInfo=null,this.sInReplyTo="",this.bFromDraft=!1,this.sReferences="",this.bReloadFolder=!1,this.sendError(!1),this.sendSuccessButSaveError(!1),this.savedError(!1),this.savedTime(0),this.savedOrSendingText(""),this.emptyToError(!1),this.showCcAndBcc(!1),this.attachments([]),this.dragAndDropOver(!1),this.dragAndDropVisible(!1),this.draftFolder(""),this.draftUid(""),this.sending(!1),this.saving(!1),this.oEditor&&this.oEditor.clear()},E.prototype.getAttachmentsDownloadsForUpload=function(){return h.map(h.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})},E.prototype.triggerForResize=function(){this.resizer(!this.resizer())},pb.extendAsViewModel("PopupsContactsViewModel",F),F.prototype.setShareToNone=function(){this.viewScopeType(nb.ContactScopeType.Default)},F.prototype.setShareToAll=function(){this.viewScopeType(nb.ContactScopeType.ShareAll)},F.prototype.addNewProperty=function(a){var b=new u(a,"");b.focused(!0),this.viewProperties.push(b)},F.prototype.addNewEmail=function(){this.addNewProperty(nb.ContactPropertyType.EmailPersonal)},F.prototype.addNewPhone=function(){this.addNewProperty(nb.ContactPropertyType.PhonePersonal)},F.prototype.removeCheckedOrSelectedContactsFromList=function(){var a=this,b=this.contacts,c=this.currentContact(),d=this.contacts().length,e=this.contactsCheckedOrSelected();0 =d&&(this.bDropPageAfterDelete=!0),h.delay(function(){h.each(e,function(a){b.remove(a)})},500))},F.prototype.deleteSelectedContacts=function(){0 0?d:0),b.contactsCount(d),b.contacts(e),b.viewClearSearch(""!==b.search()),b.contacts.loading(!1),""!==b.viewID()&&!b.currentContact()&&b.contacts.setSelectedByUid&&b.contacts.setSelectedByUid(""+b.viewID())},c,mb.Defaults.ContactsPerPage,this.search())},F.prototype.onBuild=function(a){this.oContentVisible=b(".b-list-content",a),this.oContentScrollable=b(".content",this.oContentVisible),this.selector.init(this.oContentVisible,this.oContentScrollable);var d=this;c.computed(function(){var a=this.modalVisibility(),b=Bb.data().useKeyboardShortcuts();this.selector.useKeyboard(a&&b)},this).extend({notify:"always"}),a.on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&(d.contactsPage(pb.pInt(a.value)),d.reloadContactList())}),yb.on("keydown",function(a){var b=!0;return a&&nb.EventKeyCode.Esc===a.keyCode&&d.modalVisibility()&&(ub.delegateRun(d,"closeCommand"),b=!1),b})},F.prototype.onShow=function(){ub.routeOff(),this.reloadContactList(!0)},F.prototype.onHide=function(){ub.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),h.each(this.contacts(),function(a){a.checked(!1)})},pb.extendAsViewModel("PopupsAdvancedSearchViewModel",G),G.prototype.buildSearchStringValue=function(a){return-1 0&&g.messageCountUnread(0<=g.messageCountUnread()-e?g.messageCountUnread()-e:0)),i&&(i.messageCountAll(i.messageCountAll()+b.length),e>0&&i.messageCountUnread(i.messageCountUnread()+e)),0 0&&(nb.EventKeyCode.Backspace===c||nb.EventKeyCode.Esc===c)&&d.viewModelVisibility()&&e.useKeyboardShortcuts()&&!pb.inFocus()&&e.message()&&(d.fullScreenMode(!1),e.usePreviewPane()||e.message(null),b=!1),b}),b(".attachmentsPlace",a).magnificPopup({delegate:".magnificPopupImage:visible",type:"image",gallery:{enabled:!0,preload:[1,1],navigateByImgClick:!0},callbacks:{open:function(){e.useKeyboardShortcuts(!1)},close:function(){e.useKeyboardShortcuts(!0)}},mainClass:"mfp-fade",removalDelay:400}),a.on("click",".attachmentsPlace .attachmentPreview",function(a){a&&a.stopPropagation&&a.stopPropagation()}).on("click",".attachmentsPlace .attachmentItem",function(){var a=c.dataFor(this);a&&a.download&&Bb.download(a.linkDownload())}),this.oMessageScrollerDom=a.find(".messageItem .content"),this.oMessageScrollerDom=this.oMessageScrollerDom&&this.oMessageScrollerDom[0]?this.oMessageScrollerDom:null},R.prototype.isDraftFolder=function(){return Bb.data().message()&&Bb.data().draftFolder()===Bb.data().message().folderFullNameRaw},R.prototype.isSentFolder=function(){return Bb.data().message()&&Bb.data().sentFolder()===Bb.data().message().folderFullNameRaw},R.prototype.isDraftOrSentFolder=function(){return this.isDraftFolder()||this.isSentFolder()},R.prototype.composeClick=function(){ub.showScreenPopup(E)},R.prototype.editMessage=function(){Bb.data().message()&&ub.showScreenPopup(E,[nb.ComposeType.Draft,Bb.data().message()])},R.prototype.scrollMessageToTop=function(){this.oMessageScrollerDom&&this.oMessageScrollerDom.scrollTop(0)},R.prototype.showImages=function(a){a&&a.showExternalImages&&a.showExternalImages(!0)},pb.extendAsViewModel("SettingsMenuViewModel",S),S.prototype.link=function(a){return Bb.link().settings(a)},S.prototype.backToMailBoxClick=function(){ub.setHash(Bb.link().inbox())},pb.extendAsViewModel("SettingsPaneViewModel",T),T.prototype.onShow=function(){Bb.data().message(null)},T.prototype.backToMailBoxClick=function(){ub.setHash(Bb.link().inbox())},pb.addSettingsViewModel(U,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0),U.prototype.onBuild=function(){var a=this;h.delay(function(){var c=Bb.data(),d=pb.settingsSaveHelperSimpleFunction(a.mppTrigger,a);c.language.subscribe(function(c){a.languageTrigger(nb.SaveSettingsStep.Animate),b.ajax({url:Bb.link().langLink(c),dataType:"script",cache:!0}).done(function(){pb.i18nToDoc(),a.languageTrigger(nb.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(nb.SaveSettingsStep.FalseResult)}).always(function(){h.delay(function(){a.languageTrigger(nb.SaveSettingsStep.Idle)},1e3)}),Bb.remote().saveSettings(pb.emptyFunction,{Language:c})}),c.editorDefaultType.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{EditorDefaultType:a})}),c.messagesPerPage.subscribe(function(a){Bb.remote().saveSettings(d,{MPP:a})}),c.showImages.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{ShowImages:a?"1":"0"})}),c.contactsAutosave.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{ContactsAutosave:a?"1":"0"})}),c.interfaceAnimation.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{InterfaceAnimation:a})}),c.useDesktopNotifications.subscribe(function(a){pb.timeOutAction("SaveDesktopNotifications",function(){Bb.remote().saveSettings(pb.emptyFunction,{DesktopNotifications:a?"1":"0"})},3e3)}),c.replySameFolder.subscribe(function(a){pb.timeOutAction("SaveReplySameFolder",function(){Bb.remote().saveSettings(pb.emptyFunction,{ReplySameFolder:a?"1":"0"})},3e3)}),c.useThreads.subscribe(function(a){c.messageList([]),Bb.remote().saveSettings(pb.emptyFunction,{UseThreads:a?"1":"0"})}),c.usePreviewPane.subscribe(function(a){c.messageList([]),Bb.remote().saveSettings(pb.emptyFunction,{UsePreviewPane:a?"1":"0"})}),c.useCheckboxesInList.subscribe(function(a){Bb.remote().saveSettings(pb.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)},U.prototype.onShow=function(){Bb.data().desktopNotifications.valueHasMutated()},U.prototype.selectLanguage=function(){ub.showScreenPopup(J)},pb.addSettingsViewModel(V,"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts"),V.prototype.addNewAccount=function(){ub.showScreenPopup(H)},V.prototype.deleteAccount=function(a){if(a&&a.deleteAccess()){this.accountForDeletion(null);var b=function(b){return a===b};a&&(this.accounts.remove(b),Bb.remote().accountDelete(function(){Bb.accountsAndIdentities()},a.email))}},pb.addSettingsViewModel(W,"SettingsIdentity","SETTINGS_LABELS/LABEL_IDENTITY_NAME","identity"),W.prototype.onBuild=function(){var a=this;h.delay(function(){var b=Bb.data(),c=pb.settingsSaveHelperSimpleFunction(a.displayNameTrigger,a),d=pb.settingsSaveHelperSimpleFunction(a.replyTrigger,a),e=pb.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){Bb.remote().saveSettings(c,{DisplayName:a})}),b.replyTo.subscribe(function(a){Bb.remote().saveSettings(d,{ReplyTo:a})}),b.signature.subscribe(function(a){Bb.remote().saveSettings(e,{Signature:a})})},50)},pb.addSettingsViewModel(X,"SettingsIdentities","SETTINGS_LABELS/LABEL_IDENTITIES_NAME","identities"),X.prototype.addNewIdentity=function(){ub.showScreenPopup(I)},X.prototype.editIdentity=function(a){ub.showScreenPopup(I,[a])},X.prototype.deleteIdentity=function(a){if(a&&a.deleteAccess()){this.identityForDeletion(null);var b=function(b){return a===b};a&&(this.identities.remove(b),Bb.remote().identityDelete(function(){Bb.accountsAndIdentities()},a.id))}},X.prototype.onBuild=function(a){var b=this;a.on("click",".identity-item .e-action",function(){var a=c.dataFor(this);a&&b.editIdentity(a)}),h.delay(function(){var a=Bb.data(),c=pb.settingsSaveHelperSimpleFunction(b.displayNameTrigger,b),d=pb.settingsSaveHelperSimpleFunction(b.replyTrigger,b),e=pb.settingsSaveHelperSimpleFunction(b.signatureTrigger,b);a.displayName.subscribe(function(a){Bb.remote().saveSettings(c,{DisplayName:a})}),a.replyTo.subscribe(function(a){Bb.remote().saveSettings(d,{ReplyTo:a})}),a.signature.subscribe(function(a){Bb.remote().saveSettings(e,{Signature:a})})},50)},pb.addSettingsViewModel(Y,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social"),pb.addSettingsViewModel(Z,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME","change-password"),Z.prototype.onHide=function(){this.changeProcess(!1),this.currentPassword(""),this.newPassword("")},Z.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1),nb.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.passwordUpdateSuccess(!0)):this.passwordUpdateError(!0)},pb.addSettingsViewModel($,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders"),$.prototype.folderEditOnEnter=function(a){var b=a?pb.trim(a.nameForEdit()):"";""!==b&&a.name()!==b&&(Bb.local().set(nb.ClientSideKeyName.FoldersLashHash,""),Bb.data().foldersRenaming(!0),Bb.remote().folderRename(function(a,b){Bb.data().foldersRenaming(!1),nb.StorageResultType.Success===a&&b&&b.Result||Bb.data().foldersListError(b&&b.ErrorCode?pb.getNotification(b.ErrorCode):pb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER")),Bb.folders()},a.fullNameRaw,b),Bb.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b)),a.edited(!1)},$.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)},$.prototype.onShow=function(){Bb.data().foldersListError("")},$.prototype.createFolder=function(){ub.showScreenPopup(C)},$.prototype.systemFolder=function(){ub.showScreenPopup(D)},$.prototype.deleteFolder=function(a){if(a&&a.canBeDeleted()&&a.deleteAccess()&&0===a.privateMessageCountAll()){this.folderForDeletion(null);var b=function(c){return a===c?!0:(c.subFolders.remove(b),!1)};a&&(Bb.local().set(nb.ClientSideKeyName.FoldersLashHash,""),Bb.data().folderList.remove(b),Bb.data().foldersDeleting(!0),Bb.remote().folderDelete(function(a,b){Bb.data().foldersDeleting(!1),nb.StorageResultType.Success===a&&b&&b.Result||Bb.data().foldersListError(b&&b.ErrorCode?pb.getNotification(b.ErrorCode):pb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER")),Bb.folders()},a.fullNameRaw),Bb.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0 1048576?(a.alert(pb.i18n("SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(){this.customThemeUploaderProgress(!0)},this)).on("onComplete",h.bind(function(b,c,d){c&&d&&d.Result?this.customThemeImg(d.Result):a.alert(d&&d.ErrorCode?pb.getUploadErrorDescByCode(d.ErrorCode):pb.getUploadErrorDescByCode(nb.UploadErrorCode.Unknown)),this.customThemeUploaderProgress(!1)},this)),!!b}return!1},ab.prototype.populateDataOnStart=function(){var a=Bb.settingsGet("Languages"),b=Bb.settingsGet("Themes");pb.isArray(a)&&this.languages(a),pb.isArray(b)&&this.themes(b),this.mainLanguage(Bb.settingsGet("Language")),this.mainTheme(Bb.settingsGet("Theme")),this.allowCustomTheme(!!Bb.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!Bb.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!Bb.settingsGet("AllowIdentities")),this.determineUserLanguage(!!Bb.settingsGet("DetermineUserLanguage")),this.allowThemes(!!Bb.settingsGet("AllowThemes")),this.allowCustomLogin(!!Bb.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!Bb.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!Bb.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(Bb.settingsGet("EditorDefaultType")),this.showImages(!!Bb.settingsGet("ShowImages")),this.contactsAutosave(!!Bb.settingsGet("ContactsAutosave")),this.interfaceAnimation(Bb.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(Bb.settingsGet("MPP")),this.desktopNotifications(!!Bb.settingsGet("DesktopNotifications")),this.useThreads(!!Bb.settingsGet("UseThreads")),this.replySameFolder(!!Bb.settingsGet("ReplySameFolder")),this.usePreviewPane(!!Bb.settingsGet("UsePreviewPane")),this.useCheckboxesInList(!!Bb.settingsGet("UseCheckboxesInList")),this.facebookEnable(!!Bb.settingsGet("AllowFacebookSocial")),this.facebookAppID(Bb.settingsGet("FacebookAppID")),this.facebookAppSecret(Bb.settingsGet("FacebookAppSecret")),this.twitterEnable(!!Bb.settingsGet("AllowTwitterSocial")),this.twitterConsumerKey(Bb.settingsGet("TwitterConsumerKey")),this.twitterConsumerSecret(Bb.settingsGet("TwitterConsumerSecret")),this.googleEnable(!!Bb.settingsGet("AllowGoogleSocial")),this.googleClientID(Bb.settingsGet("GoogleClientID")),this.googleClientSecret(Bb.settingsGet("GoogleClientSecret")),this.dropboxEnable(!!Bb.settingsGet("AllowDropboxSocial")),this.dropboxApiKey(Bb.settingsGet("DropboxApiKey")),this.contactsIsAllowed(!!Bb.settingsGet("ContactsIsAllowed"))},h.extend(bb.prototype,ab.prototype),bb.prototype.purgeMessageBodyCache=function(){var a=0,c=null,d=sb.iMessageBodyCacheCount-mb.Values.MessageBodyCacheLimit;d>0&&(c=this.messagesBodiesDom(),c&&(c.find(".rl-cache-class").each(function(){var c=b(this);d>c.data("rl-cache-count")&&(c.addClass("rl-cache-purge"),a++)}),a>0&&h.delay(function(){c.find(".rl-cache-purge").remove()},300)))},bb.prototype.populateDataOnStart=function(){ab.prototype.populateDataOnStart.call(this),this.accountEmail(Bb.settingsGet("Email")),this.accountIncLogin(Bb.settingsGet("IncLogin")),this.accountOutLogin(Bb.settingsGet("OutLogin")),this.projectHash(Bb.settingsGet("ProjectHash")),this.displayName(Bb.settingsGet("DisplayName")),this.replyTo(Bb.settingsGet("ReplyTo")),this.signature(Bb.settingsGet("Signature")),this.lastFoldersHash=Bb.local().get(nb.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!Bb.settingsGet("RemoteSuggestions"),this.devEmail=Bb.settingsGet("DevEmail"),this.devLogin=Bb.settingsGet("DevLogin"),this.devPassword=Bb.settingsGet("DevPassword")},bb.prototype.initUidNextAndNewMessages=function(b,c,d){if("INBOX"===b&&pb.isNormal(c)&&""!==c){if(pb.isArray(d)&&0 3)i(Bb.link().notificationMailIcon(),Bb.data().accountEmail(),pb.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:g}));else for(;g>f;f++)i(Bb.link().notificationMailIcon(),x.emailsToLine(x.initEmailsFromJson(d[f].From),!1),d[f].Subject)}Bb.cache().setFolderUidNext(b,c)}},bb.prototype.folderResponseParseRec=function(a,b){var c=0,d=0,e=null,f=null,g="",h=[],i=[];for(c=0,d=b.length;d>c;c++)e=b[c],e&&(g=e.FullNameRaw,f=Bb.cache().getFolderFromCacheList(g),f||(f=y.newInstanceFromJson(e),f&&(Bb.cache().setFolderToCacheList(g,f),Bb.cache().setFolderFullNameRaw(f.fullNameHash,g),f.isGmailFolder=mb.Values.GmailFolderName.toLowerCase()===g.toLowerCase(),""!==a&&a===f.fullNameRaw+f.delimiter&&(f.isNamespaceFolder=!0),(f.isNamespaceFolder||f.isGmailFolder)&&(f.isUnpaddigFolder=!0))),f&&(f.collapsed(!pb.isFolderExpanded(f.fullNameHash)),e.Extended&&(e.Extended.Hash&&Bb.cache().setFolderHash(f.fullNameRaw,e.Extended.Hash),pb.isNormal(e.Extended.MessageCount)&&f.messageCountAll(e.Extended.MessageCount),pb.isNormal(e.Extended.MessageUnseenCount)&&f.messageCountUnread(e.Extended.MessageUnseenCount)),h=e.SubFolders,h&&"Collection/FolderCollection"===h["@Object"]&&h["@Collection"]&&pb.isArray(h["@Collection"])&&f.subFolders(this.folderResponseParseRec(a,h["@Collection"])),i.push(f)));return i},bb.prototype.setFolders=function(a){var b=[],c=!1,d=Bb.data(),e=function(a){return""===a||mb.Values.UnuseOptionValue===a||null!==Bb.cache().getFolderFromCacheList(a)?a:""};a&&a.Result&&"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&pb.isArray(a.Result["@Collection"])&&(pb.isUnd(a.Result.Namespace)||(d.namespace=a.Result.Namespace),this.threading(!!Bb.settingsGet("UseImapThread")&&a.Result.IsThreadsSupported&&!0),b=this.folderResponseParseRec(d.namespace,a.Result["@Collection"]),d.folderList(b),a.Result.SystemFolders&&""==""+Bb.settingsGet("SentFolder")+Bb.settingsGet("DraftFolder")+Bb.settingsGet("SpamFolder")+Bb.settingsGet("TrashFolder")+Bb.settingsGet("NullFolder")&&(Bb.settingsSet("SentFolder",a.Result.SystemFolders[2]||null),Bb.settingsSet("DraftFolder",a.Result.SystemFolders[3]||null),Bb.settingsSet("SpamFolder",a.Result.SystemFolders[4]||null),Bb.settingsSet("TrashFolder",a.Result.SystemFolders[5]||null),c=!0),d.sentFolder(e(Bb.settingsGet("SentFolder"))),d.draftFolder(e(Bb.settingsGet("DraftFolder"))),d.spamFolder(e(Bb.settingsGet("SpamFolder"))),d.trashFolder(e(Bb.settingsGet("TrashFolder"))),c&&Bb.remote().saveSystemFolders(pb.emptyFunction,{SentFolder:d.sentFolder(),DraftFolder:d.draftFolder(),SpamFolder:d.spamFolder(),TrashFolder:d.trashFolder(),NullFolder:"NullFolder"}),Bb.local().set(nb.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash))},bb.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()},bb.prototype.getNextFolderNames=function(a){a=pb.isUnd(a)?!1:!!a;var b=[],c=10,d=f().unix(),e=d-300,g=[],i=function(b){h.each(b,function(b){b&&"INBOX"!==b.fullNameRaw&&b.selectable&&b.existen&&e>b.interval&&(!a||b.subScribed())&&g.push([b.interval,b.fullNameRaw]),b&&0 b[0]?1:0}),h.find(g,function(a){var e=Bb.cache().getFolderFromCacheList(a[1]);return e&&(e.interval=d,b.push(a[1])),c<=b.length}),h.uniq(b)},bb.prototype.setMessage=function(a,c){var d=!1,e=!1,f=!1,g=null,h=null,i="",j=this.messagesBodiesDom(),k=this.message();a&&k&&a.Result&&"Object/Message"===a.Result["@Object"]&&k.folderFullNameRaw===a.Result.Folder&&k.uid===a.Result.Uid&&(this.messageError(""),k.initUpdateByMessageJson(a.Result),Bb.cache().addRequestedMessage(k.folderFullNameRaw,k.uid),c||k.initFlagsByJson(a.Result),j=j&&j[0]?j:null,j&&(i="rl-"+k.requestHash.replace(/[^a-zA-Z0-9]/g,""),h=j.find("#"+i),h&&h[0]?(h.data("rl-cache-count",++sb.iMessageBodyCacheCount),k.isRtl(!!h.data("rl-is-rtl")),k.isHtml(!!h.data("rl-is-html")),k.hasImages(!!h.data("rl-has-images")),k.body=h):(e=!!a.Result.HasExternals,f=!!a.Result.HasInternals,g=b('').hide().addClass("rl-cache-class"),g.data("rl-cache-count",++sb.iMessageBodyCacheCount),pb.isNormal(a.Result.Html)&&""!==a.Result.Html?(d=!0,g.html(a.Result.Html.toString()).addClass("b-text-part html")):pb.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(d=!1,g.html(a.Result.Plain.toString()).addClass("b-text-part plain")):d=!1,a.Result.Rtl&&(g.data("rl-is-rtl",!0),g.addClass("rtl-text-part")),j.append(g),g.data("rl-is-html",d),g.data("rl-has-images",e),k.isRtl(!!g.data("rl-is-rtl")),k.isHtml(!!g.data("rl-is-html")),k.hasImages(!!g.data("rl-has-images")),k.body=g,f&&k.showInternalImages(!0),k.hasImages()&&this.showImages()&&k.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()),this.messageActiveDom(k.body),this.hideMessageBodies(),k.body.show(),g&&pb.initBlockquoteSwitcher(g)),Bb.cache().initMessageFlagsFromCache(k),k.unseen()&&Bb.setMessageSeen(k),pb.windowResize()) +},bb.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&pb.isArray(a.Result["@Collection"])){var c=Bb.data(),d=Bb.cache(),e=null,g=0,h=0,i=0,j=0,k=[],l=f().unix(),m=c.staticMessageList,n=null,o=null,p=null,q=0,r=!1;for(i=pb.pInt(a.Result.MessageResultCount),j=pb.pInt(a.Result.Offset),pb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),p=Bb.cache().getFolderFromCacheList(pb.isNormal(a.Result.Folder)?a.Result.Folder:""),p&&!b&&(p.interval=l,Bb.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),pb.isNormal(a.Result.MessageCount)&&p.messageCountAll(a.Result.MessageCount),pb.isNormal(a.Result.MessageUnseenCount)&&(pb.pInt(p.messageCountUnread())!==pb.pInt(a.Result.MessageUnseenCount)&&(r=!0),p.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(p.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),r&&p&&Bb.cache().clearMessageFlagsFromCacheByFolder(p.fullNameRaw),g=0,h=a.Result["@Collection"].length;h>g;g++)n=a.Result["@Collection"][g],n&&"Object/Message"===n["@Object"]&&(o=m[g],o&&o.initByJson(n)||(o=x.newInstanceFromJson(n)),o&&(d.hasNewMessageAndRemoveFromCache(o.folderFullNameRaw,o.uid)&&5>=q&&(q++,o.newForAnimation(!0)),o.deleted(!1),b?Bb.cache().initMessageFlagsFromCache(o):Bb.cache().storeMessageFlagsToCache(o),o.lastInCollapsedThread(e&&-1 (new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="abort"),i.oRequests[n]=null),i.defaultResponse(c,n,e,b,f,d)}),n&&0 0?(this.defaultRequest(a,"Message",{},null,"Message/"+rb.urlsafe_encode([b,c,Bb.data().projectHash(),Bb.data().threading()&&Bb.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},db.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999e3)},db.prototype.folderInformation=function(a,b,c){var d=!0,e=Bb.cache(),f=[];pb.isArray(c)&&0 l;l++)p.push({id:e[l][0],name:e[l][1],disable:!1});for(l=0,m=b.length;m>l;l++)n=b[l],(h?h.call(null,n):!0)&&p.push({id:n.fullNameRaw,system:!0,name:i?i.call(null,n):n.name(),disable:!n.selectable||-1 l;l++)n=c[l],n.isGmailFolder||!n.subScribed()&&n.existen||(h?h.call(null,n):!0)&&(nb.FolderType.User===n.type()||!j||!n.isNamespaceFolder&&0 - - @@ -86,21 +84,24 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/vendors/fontastic/fonts/rainloop.ttf b/vendors/fontastic/fonts/rainloop.ttf index b412ae61f..1704be700 100644 Binary files a/vendors/fontastic/fonts/rainloop.ttf and b/vendors/fontastic/fonts/rainloop.ttf differ diff --git a/vendors/fontastic/fonts/rainloop.woff b/vendors/fontastic/fonts/rainloop.woff index 41d630139..6f67c58ec 100644 Binary files a/vendors/fontastic/fonts/rainloop.woff and b/vendors/fontastic/fonts/rainloop.woff differ diff --git a/vendors/fontastic/icons-reference.html b/vendors/fontastic/icons-reference.html index 2466c70e2..5ad579101 100644 --- a/vendors/fontastic/icons-reference.html +++ b/vendors/fontastic/icons-reference.html @@ -325,14 +325,6 @@ h2{font-size:18px;padding:0 0 21px 5px;margin:45px 0 0 0;text-transform:uppercas - - - - -- - - @@ -429,6 +421,18 @@ h2{font-size:18px;padding:0 0 21px 5px;margin:45px 0 0 0;text-transform:uppercas ++ + + ++ + + ++ + + CSS mapping
@@ -712,14 +716,6 @@ h2{font-size:18px;padding:0 0 21px 5px;margin:45px 0 0 0;text-transform:uppercas -
- - - -
-- - - -
- @@ -748,10 +744,6 @@ h2{font-size:18px;padding:0 0 21px 5px;margin:45px 0 0 0;text-transform:uppercas
-- - - -
- @@ -764,10 +756,6 @@ h2{font-size:18px;padding:0 0 21px 5px;margin:45px 0 0 0;text-transform:uppercas
-- - - -
- @@ -813,8 +801,28 @@ h2{font-size:18px;padding:0 0 21px 5px;margin:45px 0 0 0;text-transform:uppercas
- - - + + +
+- + + +
+- + + +
+- + + +
+- + + +
+- + +