diff --git a/dev/Admin/Contacts.js b/dev/Admin/Contacts.js index eebab46bc..7d8e916be 100644 --- a/dev/Admin/Contacts.js +++ b/dev/Admin/Contacts.js @@ -7,9 +7,86 @@ function AdminContacts() { // var oData = RL.data(); - this.contactsSupported = !!RL.settingsGet('ContactsIsSupported'); + this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; this.enableContacts = ko.observable(!!RL.settingsGet('ContactsEnable')); + + var + aTypes = ['sqlite', 'mysql', 'pgsql'], + aSupportedTypes = [], + getTypeName = function(sName) { + switch (sName) + { + case 'sqlite': + sName = 'SQLite'; + break; + case 'mysql': + sName = 'MySQL'; + break; + case 'pgsql': + sName = 'PostgreSQL'; + break; + } + + return sName; + } + ; + + if (!!RL.settingsGet('SQLiteIsSupported')) + { + aSupportedTypes.push('sqlite'); + } + if (!!RL.settingsGet('MySqlIsSupported')) + { + aSupportedTypes.push('mysql'); + } + if (!!RL.settingsGet('PostgreSqlIsSupported')) + { + aSupportedTypes.push('pgsql'); + } + this.contactsSupported = 0 < aSupportedTypes.length; + + this.contactsTypes = ko.observableArray([]); + this.contactsTypesOptions = this.contactsTypes.map(function (sValue) { + var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes); + return { + 'id': sValue, + 'name': getTypeName(sValue) + (bDisabled ? ' (not supported)' : ''), + 'disable': bDisabled + }; + }); + + this.contactsTypes(aTypes); + this.contactsType = ko.observable(''); + + this.mainContactsType = ko.computed({ + 'owner': this, + 'read': this.contactsType, + 'write': function (sValue) { + if (sValue !== this.contactsType()) + { + if (-1 < Utils.inArray(sValue, aSupportedTypes)) + { + this.contactsType(sValue); + } + else if (0 < aSupportedTypes.length) + { + this.contactsType(''); + } + } + else + { + this.contactsType.valueHasMutated(); + } + } + }); + + this.contactsType.subscribe(function () { + this.testContactsSuccess(false); + this.testContactsError(false); + this.testContactsErrorMessage(''); + }, this); + this.pdoDsn = ko.observable(RL.settingsGet('ContactsPdoDsn')); this.pdoUser = ko.observable(RL.settingsGet('ContactsPdoUser')); this.pdoPassword = ko.observable(RL.settingsGet('ContactsPdoPassword')); @@ -17,6 +94,7 @@ function AdminContacts() this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.testing = ko.observable(false); this.testContactsSuccess = ko.observable(false); @@ -31,6 +109,7 @@ function AdminContacts() this.testing(true); RL.remote().testContacts(this.onTestContactsResponse, { + 'ContactsPdoType': this.contactsType(), 'ContactsPdoDsn': this.pdoDsn(), 'ContactsPdoUser': this.pdoUser(), 'ContactsPdoPassword': this.pdoPassword() @@ -40,6 +119,8 @@ function AdminContacts() return '' !== this.pdoDsn() && '' !== this.pdoUser(); }); + this.contactsType(RL.settingsGet('ContactsPdoType')); + this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this); } @@ -58,7 +139,14 @@ AdminContacts.prototype.onTestContactsResponse = function (sResult, oData) else { this.testContactsError(true); - this.testContactsErrorMessage(oData.Result.Message || ''); + if (oData && oData.Result) + { + this.testContactsErrorMessage(oData.Result.Message || ''); + } + else + { + this.testContactsErrorMessage(''); + } } this.testing(false); @@ -78,8 +166,9 @@ AdminContacts.prototype.onBuild = function () var f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self), - f2 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self), - f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self) + f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self), + f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self), + f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self) ; self.enableContacts.subscribe(function (bValue) { @@ -88,23 +177,31 @@ AdminContacts.prototype.onBuild = function () }); }); + self.contactsType.subscribe(function (sValue) { + RL.remote().saveAdminConfig(f5, { + 'ContactsPdoType': sValue + }); + }); + self.pdoDsn.subscribe(function (sValue) { RL.remote().saveAdminConfig(f1, { 'ContactsPdoDsn': Utils.trim(sValue) }); }); - + self.pdoUser.subscribe(function (sValue) { - RL.remote().saveAdminConfig(f2, { + RL.remote().saveAdminConfig(f3, { 'ContactsPdoUser': Utils.trim(sValue) }); }); self.pdoPassword.subscribe(function (sValue) { - RL.remote().saveAdminConfig(f3, { + RL.remote().saveAdminConfig(f4, { 'ContactsPdoPassword': Utils.trim(sValue) }); }); + self.contactsType(RL.settingsGet('ContactsPdoType')); + }, 50); }; diff --git a/dev/Common/Knockout.js b/dev/Common/Knockout.js index 9c38e57cd..93939e509 100644 --- a/dev/Common/Knockout.js +++ b/dev/Common/Knockout.js @@ -402,7 +402,7 @@ ko.bindingHandlers.saveTrigger = { var $oEl = $(oElement); - $oEl.data('save-trigger-type', $oEl.is('input[type=text],select,textarea') ? 'input' : 'custom'); + $oEl.data('save-trigger-type', $oEl.is('input[type=text],input[type=email],input[type=password],select,textarea') ? 'input' : 'custom'); if ('custom' === $oEl.data('save-trigger-type')) { 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 3e3f7454b..06e26e909 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -233,7 +233,17 @@ class Actions $sUser = \trim($this->Config()->Get('contacts', 'pdo_user', '')); $sPassword = (string) $this->Config()->Get('contacts', 'pdo_password', ''); - $oResult = new \RainLoop\Providers\PersonalAddressBook\PdoPersonalAddressBook($sDsn, $sUser, $sPassword); + $sDsnType = $this->ValidateContactPdoType(\trim($this->Config()->Get('contacts', 'type', 'sqlite'))); + if ('sqlite' === $sDsnType) + { + $oResult = new \RainLoop\Providers\PersonalAddressBook\PdoPersonalAddressBook( + 'sqlite:'.APP_PRIVATE_DATA.'PersonalAddressBook.sqlite', '', '', 'sqlite'); + } + else + { + $oResult = new \RainLoop\Providers\PersonalAddressBook\PdoPersonalAddressBook($sDsn, $sUser, $sPassword, $sDsnType); + } + $oResult->SetLogger($this->Logger()); break; case 'suggestions': @@ -974,10 +984,15 @@ class Actions $aResult['UseTokenProtection'] = (bool) $oConfig->Get('security', 'csrf_protection', true); $aResult['EnabledPlugins'] = (bool) $oConfig->Get('plugins', 'enable', false); - $aResult['ContactsIsSupported'] = (bool) $this->PersonalAddressBookProvider(null, true)->IsSupported(); - + $aDrivers = \class_exists('PDO') ? \PDO::getAvailableDrivers() : array(); + $aResult['MySqlIsSupported'] = \is_array($aDrivers) ? \in_array('mysql', $aDrivers) : false; + $aResult['SQLiteIsSupported'] = \is_array($aDrivers) ? \in_array('sqlite', $aDrivers) : false; + $aResult['PostgreSqlIsSupported'] = \is_array($aDrivers) ? \in_array('pgsql', $aDrivers) : false; + $aResult['ContactsEnable'] = (bool) $oConfig->Get('contacts', 'enable', 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', ''); $aResult['ContactsPdoUser'] = (string) $oConfig->Get('contacts', 'pdo_user', ''); $aResult['ContactsPdoPassword'] = APP_DUMMY; @@ -1854,6 +1869,10 @@ class Actions $this->setConfigFromParams($oConfig, 'ContactsPdoUser', 'contacts', 'pdo_user', 'string'); $this->setConfigFromParams($oConfig, 'ContactsPdoPassword', 'contacts', 'pdo_password', 'dummy'); + $this->setConfigFromParams($oConfig, 'ContactsPdoType', 'contacts', 'type', 'string', function ($sType) use ($self) { + return $self->ValidateContactPdoType($sType); + }); + $this->setConfigFromParams($oConfig, 'AllowAdditionalAccounts', 'webmail', 'allow_additional_accounts', 'bool'); $this->setConfigFromParams($oConfig, 'AllowIdentities', 'webmail', 'allow_identities', 'bool'); @@ -1941,6 +1960,11 @@ class Actions $this->setConfigFromParams($oConfig, 'ContactsPdoUser', 'contacts', 'pdo_user', 'string'); $this->setConfigFromParams($oConfig, 'ContactsPdoPassword', 'contacts', 'pdo_password', 'dummy'); + $self = $this; + $this->setConfigFromParams($oConfig, 'ContactsPdoType', 'contacts', 'type', 'string', function ($sType) use ($self) { + return $self->ValidateContactPdoType($sType); + }); + $sTestMessage = $this->PersonalAddressBookProvider(null, true)->Test(); return $this->DefaultResponse(__FUNCTION__, array( 'Result' => '' === $sTestMessage, @@ -5097,21 +5121,31 @@ class Actions */ public function ValidateTheme($sTheme) { - return in_array($sTheme, $this->GetThemes()) ? + return \in_array($sTheme, $this->GetThemes()) ? $sTheme : $this->Config()->Get('themes', 'default', 'Default'); } /** - * @param $sLanguage $sLanguage + * @param string $sLanguage * - * @return $sLanguage + * @return string */ public function ValidateLanguage($sLanguage) { - return in_array($sLanguage, $this->GetLanguages()) ? + return \in_array($sLanguage, $this->GetLanguages()) ? $sLanguage : $this->Config()->Get('i18n', 'default', 'en'); } + /** + * @param string $sType + * + * @return string + */ + public function ValidateContactPdoType($sType) + { + return \in_array($sType, array('mysql', 'pgsql', 'sqlite')) ? $sType : 'sqlite'; + } + /** * @staticvar array $aCache * @param bool $bAdmin = false diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Common/PdoAbstract.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Common/PdoAbstract.php index 2046de554..a7d958cd8 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Common/PdoAbstract.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Common/PdoAbstract.php @@ -48,6 +48,14 @@ abstract class PdoAbstract return array('', '', '', ''); } + /** + * @return bool + */ + protected function isTransactionSupported() + { + return \in_array($this->sDbType, array('mysql')); + } + /** * @return \PDO * @@ -67,6 +75,11 @@ abstract class PdoAbstract $sType = $sDsn = $sDbLogin = $sDbPassword = ''; list($sType, $sDsn, $sDbLogin, $sDbPassword) = $this->getPdoAccessData(); + if (!\in_array($sType, array('mysql', 'sqlite', 'pgsql'))) + { + throw new \Exception('Unknown PDO SQL connection type'); + } + $this->sDbType = $sType; $oPdo = false; @@ -76,7 +89,7 @@ abstract class PdoAbstract if ($oPdo) { $oPdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - if ('mysql' === $oPdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) + if ('mysql' === $sType && 'mysql' === $oPdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { $oPdo->exec('SET NAMES utf8 COLLATE utf8_general_ci'); // $oPdo->exec('SET NAMES utf8'); @@ -111,7 +124,7 @@ abstract class PdoAbstract } /** - * @return nool + * @return bool */ protected function beginTransaction() { @@ -119,7 +132,7 @@ abstract class PdoAbstract } /** - * @return nool + * @return bool */ protected function commit() { @@ -127,7 +140,7 @@ abstract class PdoAbstract } /** - * @return nool + * @return bool */ protected function rollBack() { @@ -322,7 +335,10 @@ abstract class PdoAbstract $oPdo = $this->getPDO(); if ($oPdo) { - $oPdo->beginTransaction(); + if ($this->isTransactionSupported()) + { + $oPdo->beginTransaction(); + } $sQuery = 'DELETE FROM rainloop_system WHERE sys_name = ? AND value_int <= ?;'; $this->writeLog($sQuery); @@ -341,13 +357,16 @@ abstract class PdoAbstract } } - if ($bResult) + if ($this->isTransactionSupported()) { - $oPdo->commit(); - } - else - { - $oPdo->rollBack(); + if ($bResult) + { + $oPdo->commit(); + } + else + { + $oPdo->rollBack(); + } } } @@ -371,17 +390,17 @@ abstract class PdoAbstract sys_name varchar(50) NOT NULL, value_int int UNSIGNED NOT NULL DEFAULT 0, value_str varchar(128) NOT NULL DEFAULT \'\', - INDEX `sys_name_index` (`sys_name`) + INDEX sys_name_rainloop_system_index (sys_name) ) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;'; $aQ[] = 'CREATE TABLE IF NOT EXISTS rainloop_users ( id_user int UNSIGNED NOT NULL AUTO_INCREMENT, rl_email varchar(128) NOT NULL DEFAULT \'\', - PRIMARY KEY(`id_user`), - INDEX `rl_email_index` (`rl_email`) + PRIMARY KEY(id_user), + INDEX rl_email_rainloop_users_index (rl_email) ) /*!40000 ENGINE=INNODB */;'; } - else if ('postgres' === $this->sDbType) + else if ('pgsql' === $this->sDbType) { $aQ[] = 'CREATE TABLE rainloop_system ( sys_name varchar(50) NOT NULL, @@ -389,22 +408,41 @@ abstract class PdoAbstract value_str varchar(128) NOT NULL DEFAULT \'\' );'; - $aQ[] = 'CREATE INDEX sys_name_index ON rainloop_system (sys_name);'; + $aQ[] = 'CREATE INDEX sys_name_rainloop_system_index ON rainloop_system (sys_name);'; - $aQ[] = 'CREATE SEQUENCE rainloop_users_seq START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;'; + $aQ[] = 'CREATE SEQUENCE id_user START WITH 1 INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;'; $aQ[] = 'CREATE TABLE rainloop_users ( - id_user integer DEFAULT nextval(\'rainloop_users_seq\'::text) PRIMARY KEY, + id_user integer DEFAULT nextval(\'id_user\'::text) PRIMARY KEY, rl_email varchar(128) NOT NULL DEFAULT \'\' );'; - $aQ[] = 'CREATE INDEX rl_email_index ON rainloop_users (rl_email);'; + $aQ[] = 'CREATE INDEX rl_email_rainloop_users_index ON rainloop_users (rl_email);'; + } + else if ('sqlite' === $this->sDbType) + { + $aQ[] = 'CREATE TABLE rainloop_system ( + sys_name text NOT NULL, + value_int integer NOT NULL default 0, + value_str text NOT NULL default \'\' +);'; + + $aQ[] = 'CREATE INDEX sys_name_rainloop_system_index ON rainloop_system (sys_name);'; + + $aQ[] = 'CREATE TABLE rainloop_users ( + id_user integer NOT NULL PRIMARY KEY, + rl_email text NOT NULL default \'\' +);'; + $aQ[] = 'CREATE INDEX rl_email_rainloop_users_index ON rainloop_users (rl_email);'; } if (0 < \count($aQ)) { try { - $oPdo->beginTransaction(); + if ($this->isTransactionSupported()) + { + $oPdo->beginTransaction(); + } foreach ($aQ as $sQuery) { @@ -412,23 +450,37 @@ abstract class PdoAbstract { $this->writeLog($sQuery); $bResult = false !== $oPdo->exec($sQuery); + if (!$bResult) + { + $this->writeLog('Result=false'); + } + else + { + $this->writeLog('Result=true'); + } } } - if ($bResult) + if ($this->isTransactionSupported()) { - $oPdo->rollBack(); - } - else - { - $oPdo->commit(); + if ($bResult) + { + $oPdo->rollBack(); + } + else + { + $oPdo->commit(); + } } } catch (\Exception $oException) { - $oPdo->rollBack(); - $this->writeLog($oException); + if ($this->isTransactionSupported()) + { + $oPdo->rollBack(); + } + throw $oException; } } @@ -453,18 +505,32 @@ abstract class PdoAbstract catch (\PDOException $oException) { $this->writeLog($oException); - - $this->initSystemTables(); - - $iFromVersion = $this->getVersion($sName); + + try + { + $this->initSystemTables(); + + $iFromVersion = $this->getVersion($sName); + } + catch (\PDOException $oSubException) + { + $this->writeLog($oSubException); + throw $oSubException; + } } - if (0 <= $iFromVersion) + if (\is_int($iFromVersion) && 0 <= $iFromVersion) { $oPdo = false; $bResult = false; + foreach ($aData as $iVersion => $aQuery) { + if (0 === \count($aQuery)) + { + continue; + } + if (!$oPdo) { $oPdo = $this->getPDO(); @@ -475,30 +541,44 @@ abstract class PdoAbstract { try { - $oPdo->beginTransaction(); + if ($this->isTransactionSupported()) + { + $oPdo->beginTransaction(); + } foreach ($aQuery as $sQuery) { $this->writeLog($sQuery); - if (false === $oPdo->exec($sQuery)) + $bExec = $oPdo->exec($sQuery); + if (false === $bExec) { + $this->writeLog('Result: false'); + $bResult = false; break; } } - if ($bResult) + if ($this->isTransactionSupported()) { - $oPdo->commit(); - } - else - { - $oPdo->rollBack(); + if ($bResult) + { + $oPdo->commit(); + } + else + { + $oPdo->rollBack(); + } } } catch (\Exception $oException) { - $oPdo->rollBack(); + $this->writeLog($oException); + if ($this->isTransactionSupported()) + { + $oPdo->rollBack(); + } + throw $oException; } 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 2afa65b79..e5087a218 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 @@ -84,7 +84,7 @@ class Application extends \RainLoop\Config\AbstractConfig 'contacts' => array( 'enable' => array(false, 'Enable contacts'), 'suggestions_limit' => array(30), - 'type' => array('mysql', ''), + 'type' => array('sqlite', ''), 'pdo_dsn' => array('mysql:host=127.0.0.1;port=3306;dbname=rainloop', ''), 'pdo_user' => array('root', ''), 'pdo_password' => array('', ''), 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 6bebc6332..40fea1830 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 @@ -12,6 +12,11 @@ class PdoPersonalAddressBook * @var string */ private $sDsn; + + /** + * @var string + */ + private $sDsnType; /** * @var string @@ -23,11 +28,12 @@ class PdoPersonalAddressBook */ private $sPassword; - public function __construct($sDsn, $sUser, $sPassword) + public function __construct($sDsn, $sUser = '', $sPassword = '', $sDsnType = 'mysql') { $this->sDsn = $sDsn; $this->sUser = $sUser; $this->sPassword = $sPassword; + $this->sDsnType = $sDsnType; $this->bExplain = false; } @@ -38,7 +44,7 @@ class PdoPersonalAddressBook public function IsSupported() { $aDrivers = \class_exists('PDO') ? \PDO::getAvailableDrivers() : array(); - return \is_array($aDrivers) ? \in_array('mysql', $aDrivers) : false; + return \is_array($aDrivers) ? \in_array($this->sDsnType, $aDrivers) : false; } /** @@ -94,7 +100,10 @@ class PdoPersonalAddressBook try { - $this->beginTransaction(); + if ($this->isTransactionSupported()) + { + $this->beginTransaction(); + } $aFreq = array(); if ($bUpdate) @@ -182,11 +191,18 @@ class PdoPersonalAddressBook } catch (\Exception $oException) { - $this->rollBack(); + if ($this->isTransactionSupported()) + { + $this->rollBack(); + } + throw $oException; } - $this->commit(); + if ($this->isTransactionSupported()) + { + $this->commit(); + } return 0 < $iIdContact; } @@ -199,7 +215,6 @@ class PdoPersonalAddressBook */ public function DeleteContacts($oAccount, $aContactIds) { - $this->Sync(); $iUserID = $this->getUserId($oAccount->ParentEmailHelper()); $aContactIds = \array_filter($aContactIds, function (&$mItem) { @@ -279,7 +294,9 @@ class PdoPersonalAddressBook if (0 < \strlen($sSearch)) { - $sSql = 'SELECT id_prop, id_contact FROM rainloop_pab_properties WHERE id_user = :id_user AND scope_type = :scope_type AND prop_value LIKE :search ESCAPE \'=\' GROUP BY id_contact'; + $sSql = 'SELECT id_prop, id_contact FROM rainloop_pab_properties WHERE id_user = :id_user'. + ' AND scope_type = :scope_type AND prop_value LIKE :search ESCAPE \'=\' GROUP BY id_contact, id_prop'; + $aParams = array( ':id_user' => array($iUserID, \PDO::PARAM_INT), ':scope_type' => array($iScopeType, \PDO::PARAM_INT), @@ -756,8 +773,7 @@ class PdoPersonalAddressBook try { $this->Sync(); - - if (0 >= $this->getVersion('mysql-pab-version')) + if (0 >= $this->getVersion($this->sDsnType.'-pab-version')) { $sResult = 'Unknown database error'; } @@ -779,73 +795,214 @@ class PdoPersonalAddressBook return $sResult; } - /** - * @return bool - */ - public function Sync() + private function getInitialTablesArray($sDbType) { - return $this->dataBaseUpgrade('mysql-pab-version', array( - 1 => array( + $sInitial = ''; + $aResult = array(); + + switch ($sDbType) + { + case 'mysql': + $sInitial = <<sDsnType) + { + case 'mysql': + return $this->dataBaseUpgrade($this->sDsnType.'-pab-version', array( + 1 => $this->getInitialTablesArray($this->sDsnType) + )); + case 'pgsql': + return $this->dataBaseUpgrade($this->sDsnType.'-pab-version', array( + 1 => $this->getInitialTablesArray($this->sDsnType) + )); + case 'sqlite': + return $this->dataBaseUpgrade($this->sDsnType.'-pab-version', array( + 1 => $this->getInitialTablesArray($this->sDsnType) + )); + } + + return false; } /** @@ -902,6 +1059,6 @@ class PdoPersonalAddressBook */ protected function getPdoAccessData() { - return array('mysql', $this->sDsn, $this->sUser, $this->sPassword); + return array($this->sDsnType, $this->sDsn, $this->sUser, $this->sPassword); } } \ No newline at end of file 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 ea421f56f..6aba2b56a 100644 --- a/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html +++ b/rainloop/v/0.0.0/app/templates/Views/AdminSettingsContacts.html @@ -5,10 +5,11 @@
Your system doesn't support contacts.
- You need to install or enable PDO (MySQL) exstenstion on your web server. + You need to install or enable PDO (SQLite / MySQL / PostgreSQL) exstenstion on your server.
+
Contacts
@@ -20,43 +21,87 @@
-
- PDO (MySQL) -
- +
- -
+ +
-
- -
- -
+
+
+ PDO (MySQL / PostgreSQL / ...) +
+
+ +
+ +
+
+

+ Examples: +
+ mysql:host=127.0.0.1;port=3306;dbname=rainloop +
+ pgsql:host=127.0.0.1;port=5432;dbname=rainloop +

+
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
-
- -
- -
+
+
+ PDO (SQLite)
-
-
-
- - -    - Test - +
+
+
+

Notice!

+
+ Don't use this type of database with a large number of active users. +
+
+
+
diff --git a/rainloop/v/0.0.0/static/js/admin.js b/rainloop/v/0.0.0/static/js/admin.js index bbb8c5a3d..fb4498505 100644 --- a/rainloop/v/0.0.0/static/js/admin.js +++ b/rainloop/v/0.0.0/static/js/admin.js @@ -2655,7 +2655,7 @@ ko.bindingHandlers.saveTrigger = { var $oEl = $(oElement); - $oEl.data('save-trigger-type', $oEl.is('input[type=text],select,textarea') ? 'input' : 'custom'); + $oEl.data('save-trigger-type', $oEl.is('input[type=text],input[type=email],input[type=password],select,textarea') ? 'input' : 'custom'); if ('custom' === $oEl.data('save-trigger-type')) { @@ -5252,9 +5252,86 @@ function AdminContacts() { // var oData = RL.data(); - this.contactsSupported = !!RL.settingsGet('ContactsIsSupported'); + this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; this.enableContacts = ko.observable(!!RL.settingsGet('ContactsEnable')); + + var + aTypes = ['sqlite', 'mysql', 'pgsql'], + aSupportedTypes = [], + getTypeName = function(sName) { + switch (sName) + { + case 'sqlite': + sName = 'SQLite'; + break; + case 'mysql': + sName = 'MySQL'; + break; + case 'pgsql': + sName = 'PostgreSQL'; + break; + } + + return sName; + } + ; + + if (!!RL.settingsGet('SQLiteIsSupported')) + { + aSupportedTypes.push('sqlite'); + } + if (!!RL.settingsGet('MySqlIsSupported')) + { + aSupportedTypes.push('mysql'); + } + if (!!RL.settingsGet('PostgreSqlIsSupported')) + { + aSupportedTypes.push('pgsql'); + } + this.contactsSupported = 0 < aSupportedTypes.length; + + this.contactsTypes = ko.observableArray([]); + this.contactsTypesOptions = this.contactsTypes.map(function (sValue) { + var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes); + return { + 'id': sValue, + 'name': getTypeName(sValue) + (bDisabled ? ' (not supported)' : ''), + 'disable': bDisabled + }; + }); + + this.contactsTypes(aTypes); + this.contactsType = ko.observable(''); + + this.mainContactsType = ko.computed({ + 'owner': this, + 'read': this.contactsType, + 'write': function (sValue) { + if (sValue !== this.contactsType()) + { + if (-1 < Utils.inArray(sValue, aSupportedTypes)) + { + this.contactsType(sValue); + } + else if (0 < aSupportedTypes.length) + { + this.contactsType(''); + } + } + else + { + this.contactsType.valueHasMutated(); + } + } + }); + + this.contactsType.subscribe(function () { + this.testContactsSuccess(false); + this.testContactsError(false); + this.testContactsErrorMessage(''); + }, this); + this.pdoDsn = ko.observable(RL.settingsGet('ContactsPdoDsn')); this.pdoUser = ko.observable(RL.settingsGet('ContactsPdoUser')); this.pdoPassword = ko.observable(RL.settingsGet('ContactsPdoPassword')); @@ -5262,6 +5339,7 @@ function AdminContacts() this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle); + this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.testing = ko.observable(false); this.testContactsSuccess = ko.observable(false); @@ -5276,6 +5354,7 @@ function AdminContacts() this.testing(true); RL.remote().testContacts(this.onTestContactsResponse, { + 'ContactsPdoType': this.contactsType(), 'ContactsPdoDsn': this.pdoDsn(), 'ContactsPdoUser': this.pdoUser(), 'ContactsPdoPassword': this.pdoPassword() @@ -5285,6 +5364,8 @@ function AdminContacts() return '' !== this.pdoDsn() && '' !== this.pdoUser(); }); + this.contactsType(RL.settingsGet('ContactsPdoType')); + this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this); } @@ -5303,7 +5384,14 @@ AdminContacts.prototype.onTestContactsResponse = function (sResult, oData) else { this.testContactsError(true); - this.testContactsErrorMessage(oData.Result.Message || ''); + if (oData && oData.Result) + { + this.testContactsErrorMessage(oData.Result.Message || ''); + } + else + { + this.testContactsErrorMessage(''); + } } this.testing(false); @@ -5323,8 +5411,9 @@ AdminContacts.prototype.onBuild = function () var f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self), - f2 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self), - f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self) + f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self), + f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self), + f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self) ; self.enableContacts.subscribe(function (bValue) { @@ -5333,24 +5422,32 @@ AdminContacts.prototype.onBuild = function () }); }); + self.contactsType.subscribe(function (sValue) { + RL.remote().saveAdminConfig(f5, { + 'ContactsPdoType': sValue + }); + }); + self.pdoDsn.subscribe(function (sValue) { RL.remote().saveAdminConfig(f1, { 'ContactsPdoDsn': Utils.trim(sValue) }); }); - + self.pdoUser.subscribe(function (sValue) { - RL.remote().saveAdminConfig(f2, { + RL.remote().saveAdminConfig(f3, { 'ContactsPdoUser': Utils.trim(sValue) }); }); self.pdoPassword.subscribe(function (sValue) { - RL.remote().saveAdminConfig(f3, { + RL.remote().saveAdminConfig(f4, { 'ContactsPdoPassword': Utils.trim(sValue) }); }); + self.contactsType(RL.settingsGet('ContactsPdoType')); + }, 50); }; diff --git a/rainloop/v/0.0.0/static/js/admin.min.js b/rainloop/v/0.0.0/static/js/admin.min.js index f82a3d48d..b70ffc5b5 100644 --- a/rainloop/v/0.0.0/static/js/admin.min.js +++ b/rainloop/v/0.0.0/static/js/admin.min.js @@ -1,4 +1,4 @@ /*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ -!function(a,b,c,d,e,f){"use strict";function g(){this.sBase="#/",this.sCdnStaticDomain=db.settingsGet("CdnStaticDomain"),this.sVersion=db.settingsGet("Version"),this.sSpecSuffix=db.settingsGet("AuthAccountHash")||"0",this.sServer=(db.settingsGet("IndexFile")||"./")+"?",this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function h(){}function i(){}function j(){var a=[i,h],b=f.find(a,function(a){return a.supported()});b&&(b=b,this.oDriver=new b)}function k(){}function l(a,b){this.sPosition=T.pString(a),this.sTemplate=T.pString(b),this.viewModelName="",this.viewModelVisibility=c.observable(!1),"Popups"===this.sPosition&&(this.modalVisibility=c.observable(!1)),this.viewModelDom=null}function m(a,b){this.sScreenName=a,this.aViewModels=T.isArray(b)?b:[]}function n(){this.sDefaultScreenName="",this.oScreens={},this.oBoot=null,this.oCurrentScreen=null,this.popupVisibility=c.observable(!1),this.popupVisibility.subscribe(function(a){db&&db.popupVisibility(a)})}function o(a,b){this.email=a||"",this.name=b||"",this.privateType=null,this.clearDuplicateName()}function p(){l.call(this,"Popups","PopupsDomain"),this.edit=c.observable(!1),this.saving=c.observable(!1),this.savingError=c.observable(""),this.whiteListPage=c.observable(!1),this.testing=c.observable(!1),this.testingDone=c.observable(!1),this.testingImapError=c.observable(!1),this.testingSmtpError=c.observable(!1),this.imapServerFocus=c.observable(!1),this.smtpServerFocus=c.observable(!1),this.name=c.observable(""),this.imapServer=c.observable(""),this.imapPort=c.observable(Q.Values.ImapDefaulPort),this.imapSecure=c.observable(R.ServerSecure.None),this.imapShortLogin=c.observable(!1),this.smtpServer=c.observable(""),this.smtpPort=c.observable(Q.Values.SmtpDefaulPort),this.smtpSecure=c.observable(R.ServerSecure.None),this.smtpShortLogin=c.observable(!1),this.smtpAuth=c.observable(!0),this.whiteList=c.observable(""),this.imapServerFocus.subscribe(function(a){a&&""!==this.name()&&""===this.imapServer()&&this.imapServer(this.name())},this),this.smtpServerFocus.subscribe(function(a){a&&""!==this.imapServer()&&""===this.smtpServer()&&this.smtpServer(this.imapServer())},this),this.headerText=c.computed(function(){var a=this.name();return this.edit()?'Edit Domain "'+a+'"':"Add Domain"+(""===a?"":' "'+a+'"')},this),this.domainIsComputed=c.computed(function(){return""!==this.name()&&""!==this.imapServer()&&""!==this.imapPort()&&""!==this.smtpServer()&&""!==this.smtpPort()},this),this.canBeTested=c.computed(function(){return!this.testing()&&this.domainIsComputed()},this),this.canBeSaved=c.computed(function(){return!this.saving()&&this.domainIsComputed()},this),this.createOrAddCommand=T.createCommand(this,function(){this.saving(!0),db.remote().createOrUpdateDomain(f.bind(this.onDomainCreateOrSaveResponse,this),!this.edit(),this.name(),this.imapServer(),this.imapPort(),this.imapSecure(),this.imapShortLogin(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpShortLogin(),this.smtpAuth(),this.whiteList())},this.canBeSaved),this.testConnectionCommand=T.createCommand(this,function(){this.whiteListPage(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.testing(!0),db.remote().testConnectionForDomain(f.bind(this.onTestConnectionResponse,this),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeTested),this.whiteListCommand=T.createCommand(this,function(){this.whiteListPage(!this.whiteListPage())}),n.constructorEnd(this)}function q(){l.call(this,"Popups","PopupsPlugin");var a=this;this.onPluginSettingsUpdateResponse=f.bind(this.onPluginSettingsUpdateResponse,this),this.saveError=c.observable(""),this.name=c.observable(""),this.readme=c.observable(""),this.configures=c.observableArray([]),this.hasReadme=c.computed(function(){return""!==this.readme()},this),this.hasConfiguration=c.computed(function(){return 0').appendTo("body"),ab.on("error",function(a){db&&a&&a.originalEvent&&a.originalEvent.message&&-1===T.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&db.remote().jsError(T.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",_.attr("class"),T.microtime()-W.now)})}function P(){O.call(this),this.oData=null,this.oRemote=null,this.oCache=null}var Q={},R={},S={},T={},U={},V={},W={},X={settings:[],"settings-removed":[],"settings-disabled":[]},Y=null,Z=a.rainloopAppData||{},$=a.rainloopI18N||{},_=b("html"),ab=b(a),bb=b(a.document),cb=a.Notification&&a.Notification.requestPermission?a.Notification:null,db=null;W.now=(new Date).getTime(),W.minuteTick=c.observable(!0),W.fiveMinuteTick=c.observable(!0),W.langChangeTick=c.observable(!0),W.iAjaxErrorCount=0,W.iTokenErrorCount=0,W.iMessageBodyCacheCount=0,W.bUnload=!1,W.sUserAgent=(navigator.userAgent||"").toLowerCase(),W.bIsiOSDevice=-1/g,">").replace(/"/g,""").replace(/'/g,"'"):""},T.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=T.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},T.timeOutAction=function(){var b={};return function(c,d,e){T.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),T.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),T.audio=function(){var b=!1;return function(c,d){if(!1===b)if(W.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}}(),T.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},T.i18n=function(a,b,c){var d="",e=T.isUnd($[a])?T.isUnd(c)?a:c:$[a];if(!T.isUnd(b)&&!T.isNull(b))for(d in b)T.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},T.i18nToNode=function(a){f.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(T.i18n(c)):(c=a.data("i18n-html"),c&&a.html(T.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",T.i18n(c)))})})},T.i18nToDoc=function(){a.rainloopI18N&&($=a.rainloopI18N||{},T.i18nToNode(bb),W.langChangeTick(!W.langChangeTick())),a.rainloopI18N={}},T.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?W.langChangeTick.subscribe(function(){a&&a.call(b),c.call(b)}):a&&W.langChangeTick.subscribe(a,b)},T.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)},T.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},T.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()},T.replySubjectAdd=function(b,c,d){var e=null,f=T.trim(c);return null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||T.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||T.isUnd(e[1])||T.isUnd(e[2])||T.isUnd(e[3])?f=b+": "+c:(f=e[1]+(T.pInt(e[2])+1)+e[3],f=e[1]+(T.pInt(e[2])+1)+e[3]):f=b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),(T.isUnd(d)?!0:d)?T.fixLongSubject(f):f},T.fixLongSubject=function(a){var b=0,c=null;a=T.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||T.isUnd(c[0]))&&(c=null),c&&(b=0,b+=T.isUnd(c[2])?1:0+T.pInt(c[2]),b+=T.isUnd(c[4])?1:0+T.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]+/," ")},T.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},T.friendlySize=function(a){return a=T.pInt(a),a>=1073741824?T.roundNumber(a/1073741824,1)+"GB":a>=1048576?T.roundNumber(a/1048576,1)+"MB":a>=1024?T.roundNumber(a/1024,0)+"KB":a+"B"},T.log=function(b){a.console&&a.console.log&&a.console.log(b)},T.getNotification=function(a){return a=T.pInt(a),T.isUnd(S[a])?"":S[a]},T.initNotificationLanguage=function(){S[R.Notification.InvalidToken]=T.i18n("NOTIFICATIONS/INVALID_TOKEN"),S[R.Notification.AuthError]=T.i18n("NOTIFICATIONS/AUTH_ERROR"),S[R.Notification.AccessError]=T.i18n("NOTIFICATIONS/ACCESS_ERROR"),S[R.Notification.ConnectionError]=T.i18n("NOTIFICATIONS/CONNECTION_ERROR"),S[R.Notification.CaptchaError]=T.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),S[R.Notification.SocialFacebookLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),S[R.Notification.SocialTwitterLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),S[R.Notification.SocialGoogleLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),S[R.Notification.DomainNotAllowed]=T.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),S[R.Notification.AccountNotAllowed]=T.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),S[R.Notification.CantGetMessageList]=T.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),S[R.Notification.CantGetMessage]=T.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),S[R.Notification.CantDeleteMessage]=T.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),S[R.Notification.CantMoveMessage]=T.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),S[R.Notification.CantCopyMessage]=T.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),S[R.Notification.CantSaveMessage]=T.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),S[R.Notification.CantSendMessage]=T.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),S[R.Notification.InvalidRecipients]=T.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),S[R.Notification.CantCreateFolder]=T.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),S[R.Notification.CantRenameFolder]=T.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),S[R.Notification.CantDeleteFolder]=T.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),S[R.Notification.CantDeleteNonEmptyFolder]=T.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),S[R.Notification.CantSubscribeFolder]=T.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),S[R.Notification.CantUnsubscribeFolder]=T.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),S[R.Notification.CantSaveSettings]=T.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),S[R.Notification.CantSavePluginSettings]=T.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),S[R.Notification.DomainAlreadyExists]=T.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),S[R.Notification.CantInstallPackage]=T.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),S[R.Notification.CantDeletePackage]=T.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),S[R.Notification.InvalidPluginPackage]=T.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),S[R.Notification.UnsupportedPluginPackage]=T.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),S[R.Notification.LicensingServerIsUnavailable]=T.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),S[R.Notification.LicensingExpired]=T.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),S[R.Notification.LicensingBanned]=T.i18n("NOTIFICATIONS/LICENSING_BANNED"),S[R.Notification.DemoSendMessageError]=T.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),S[R.Notification.AccountAlreadyExists]=T.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),S[R.Notification.MailServerError]=T.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),S[R.Notification.UnknownNotification]=T.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),S[R.Notification.UnknownError]=T.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},T.getUploadErrorDescByCode=function(a){var b="";switch(T.pInt(a)){case R.UploadErrorCode.FileIsTooBig:b=T.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case R.UploadErrorCode.FilePartiallyUploaded:b=T.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case R.UploadErrorCode.FileNoUploaded:b=T.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case R.UploadErrorCode.MissingTempFolder:b=T.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case R.UploadErrorCode.FileOnSaveingError:b=T.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case R.UploadErrorCode.FileType:b=T.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=T.i18n("UPLOAD/ERROR_UNKNOWN")}return b},T.killCtrlAandS=function(b){if(b=b||a.event){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(b.ctrlKey&&d===R.EventKeyCode.S)return b.preventDefault(),void 0;if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;b.ctrlKey&&d===R.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},T.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=T.isUnd(d)?!0:d,e.canExecute=T.isFunc(d)?c.computed(function(){return e.enabled()&&d.call(a)}):c.computed(function(){return e.enabled()&&!!d}),e},T.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(R.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(R.InterfaceAnimation.Full),W.sAnimationType=R.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(W.bMobileDevice||a===R.InterfaceAnimation.None)_.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),W.sAnimationType=R.InterfaceAnimation.None;else switch(a){case R.InterfaceAnimation.Full:_.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),W.sAnimationType=a;break;case R.InterfaceAnimation.Normal:_.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),W.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=R.DesktopNotifications.NotSupported;if(cb&&cb.permission)switch(cb.permission.toLowerCase()){case"granted":c=R.DesktopNotifications.Allowed;break;case"denied":c=R.DesktopNotifications.Denied;break;case"default":c=R.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&R.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();R.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):R.DesktopNotifications.NotAllowed===c?cb.requestPermission(function(){b.desktopNotifications.valueHasMutated(),R.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")?T.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?T.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},T.isFolderExpanded=function(a){var b=db.local().get(R.ClientSideKeyName.ExpandedFolders);return f.isArray(b)&&-1!==f.indexOf(b,a)},T.setExpandedFolder=function(a,b){var c=db.local().get(R.ClientSideKeyName.ExpandedFolders);f.isArray(c)||(c=[]),b?(c.push(a),c=f.uniq(c)):c=f.without(c,a),db.local().set(R.ClientSideKeyName.ExpandedFolders,c)},T.initLayoutResizer=function(a,c,d,e,g,h,i,j){e=e||300,g=g||500,h=h||g-e/2,i=i||300;var k=0,l=b(a),m=b(c),n=b(d),o=db.local().get(j)||h,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=g>k?k:g,l.resizable("option","maxWidth",k),c.size&&c.size.width&&db.local().set(j,c.size.width),p(null,null,!0)}};o&&l.width(o),k=n.width()-i,k=g>k?k:g,l.resizable({minWidth:e,maxWidth:k,handles:"e",resize:p,stop:p}),p(null,null,!0),ab.resize(f.throttle(q,400))},T.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&&0100)&&(a.addClass("rl-bq-switcher hidden-bq"),b('').insertBefore(a).click(function(){a.toggleClass("hidden-bq"),T.windowResize()}).after("
").before("
"))})}},T.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()}))},T.extendAsViewModel=function(a,b,c){b&&(c||(c=l),b.__name=a,U.regViewModelHook(a,b),f.extend(b.prototype,c.prototype))},T.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},X.settings.push(a)},T.removeSettingsViewModel=function(a){X["settings-removed"].push(a)},T.disableSettingsViewModel=function(a){X["settings-disabled"].push(a)},T.convertThemeName=function(a){return T.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},T.quoteName=function(a){return a.replace(/["]/g,'\\"')},T.microtime=function(){return(new Date).getTime()},T.convertLangName=function(a,b){return T.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},T.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=T.isUnd(a)?32:T.pInt(a);b.length/g,">").replace(/")},T.draggeblePlace=function(){return b('
 
').appendTo("#rl-hidden")},T.defautOptionsAfterRender=function(a,b){b&&!T.isUnd(b.disable)&&c.applyBindingsToNode(a,{disable:b.disable},b)},T.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+T.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")),T.i18nToNode(d),n.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.document.write(''+T.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)},T.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=T.isUnd(d)?1e3:T.pInt(d),function(e,g,h,i,j){b.call(c,g&&g.Result?R.SaveSettingsStep.TrueResult:R.SaveSettingsStep.FalseResult),a&&a.call(c,e,g,h,i,j),f.delay(function(){b.call(c,R.SaveSettingsStep.Idle)},d)}},T.settingsSaveHelperSimpleFunction=function(a,b){return T.settingsSaveHelperFunction(null,a,b,1e3)},T.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},T.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:T.isUnd(c)?a.toString():c.toString(),custom:T.isUnd(c)?!1:!0,title:T.isUnd(c)?"":a.toString(),value:a.toString()};(T.isUnd(b)?0:!b)?f.unshift(d):f.push(d)};if(h>1||h>0&&g>h){for(g>h?(i(h),c=h,d=h):((3>=g||g>=h-2)&&(e+=2),i(g),c=g,d=g);e>0;)if(c-=1,d+=1,c>0&&(i(c,!1),e--),h>=d)i(d,!0),e--;else if(0>=c)break;3===c?i(2,!1):c>3&&i(Math.round((c-1)/2),!1,"..."),h-2===d?i(h-1,!0):h-2>d&&i(Math.round((h+d)/2),!0,"..."),c>1&&i(1,!1),h>d&&i(h,!0)}return f}},V={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return V.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=V._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 V._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;cd?(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(!W.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''+T.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"),f.delay(function(){b(a).toggleClass("popup-active",e)},1)}},c.bindingHandlers.i18nInit={init:function(a){T.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),T.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=T.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=T.pInt(e[2]),g=ab.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(!W.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),T.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),T.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(){T.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!W.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){W.bDisableNanoScroll||b(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},c.bindingHandlers.saveTrigger1={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text]")?"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),g="custom"===f.data("save-trigger-type"),h=g?"":"-input";switch(e.toString()){case"1":f.find(".sst-animated"+h+",.sst-error"+h).hide().removeClass("sst-visible"+h).end().find(".sst-success"+h).show().addClass("sst-visible"+h);break;case"0":f.find(".sst-animated"+h+",.sst-success"+h).hide().removeClass("sst-visible"+h).end().find(".sst-error"+h).show().addClass("sst-visible"+h);break;case"-2":f.find(".sst-error"+h+",.sst-success"+h).hide().removeClass("sst-visible"+h).end().find(".sst-animated"+h).show().addClass("sst-visible"+h);break;default:f.find(".sst-animated"+h).hide().end().find(".sst-error"+h+",.sst-success"+h).removeClass("sst-visible"+h)}}},c.bindingHandlers.saveTrigger={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text],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){db.getAutocomplete(a.term,function(a){b(f.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return f.map(a,function(a){var b=T.trim(a),c=null;return""!==b?(c=new o,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:f.bind(function(a){d.data("EmailsTagsValue",a.target.value),e(a.target.value)},this)}),e.subscribe(function(a){d.data("EmailsTagsValue")!==a&&(d.val(a),d.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(T.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},T.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=T.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=T.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),T.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},g.prototype.root=function(){return this.sBase},g.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},g.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},g.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},g.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},g.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},g.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},g.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},g.prototype.settings=function(a){var b=this.sBase+"settings";return T.isUnd(a)||""===a||(b+="/"+a),b},g.prototype.admin=function(a){var b=this.sBase;switch(a){case"AdminDomains":b+="domains";break;case"AdminSecurity":b+="security";break;case"AdminLicensing":b+="licensing"}return b},g.prototype.mailBox=function(a,b,c){b=T.isNormal(b)?T.pInt(b):1,c=T.pString(c);var d=this.sBase+"mailbox/";return""!==a&&(d+=encodeURI(a)),b>1&&(d=d.replace(/[\/]+$/,""),d+="/p"+b),""!==c&&(d=d.replace(/[\/]+$/,""),d+="/"+encodeURI(c)),d},g.prototype.phpInfo=function(){return this.sServer+"Info"},g.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},g.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},g.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"},g.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a},g.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"},g.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"},g.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},U.oViewModelsHooks={},U.oSimpleHooks={},U.regViewModelHook=function(a,b){b&&(b.__hookName=a)},U.addHook=function(a,b){T.isFunc(b)&&(T.isArray(U.oSimpleHooks[a])||(U.oSimpleHooks[a]=[]),U.oSimpleHooks[a].push(b))},U.runHook=function(a,b){T.isArray(U.oSimpleHooks[a])&&(b=b||[],f.each(U.oSimpleHooks[a],function(a){a.apply(null,b)}))},U.mainSettingsGet=function(a){return db?db.settingsGet(a):null},U.remoteRequest=function(a,b,c,d,e,f){db&&db.remote().defaultRequest(a,b,c,d,e,f)},U.settingsGet=function(a,b){var c=U.mainSettingsGet("Plugins");return c=c&&T.isUnd(c[a])?null:c[a],c?T.isUnd(c[b])?null:c[b]:null},h.supported=function(){return!0},h.prototype.set=function(a,c){var d=b.cookie(Q.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(Q.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},h.prototype.get=function(a){var c=b.cookie(Q.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!T.isUnd(d[a])?d[a]:null}catch(e){}return d},i.supported=function(){return!!a.localStorage},i.prototype.set=function(b,c){var d=a.localStorage[Q.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[Q.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},i.prototype.get=function(b){var c=a.localStorage[Q.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!T.isUnd(d[b])?d[b]:null}catch(e){}return d},j.prototype.oDriver=null,j.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},j.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},k.prototype.bootstart=function(){},l.prototype.sPosition="",l.prototype.sTemplate="",l.prototype.viewModelName="",l.prototype.viewModelDom=null,l.prototype.viewModelTemplate=function(){return this.sTemplate},l.prototype.viewModelPosition=function(){return this.sPosition},l.prototype.cancelCommand=l.prototype.closeCommand=function(){},m.prototype.oCross=null,m.prototype.sScreenName="",m.prototype.aViewModels=[],m.prototype.viewModels=function(){return this.aViewModels},m.prototype.screenName=function(){return this.sScreenName},m.prototype.routes=function(){return null},m.prototype.__cross=function(){return this.oCross},m.prototype.__start=function(){var a=this.routes(),b=null,c=null;T.isNonEmptyArray(a)&&(c=f.bind(this.onRoute||T.emptyFunction,this),b=d.create(),f.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},n.constructorEnd=function(a){T.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},n.prototype.sDefaultScreenName="",n.prototype.oScreens={},n.prototype.oBoot=null,n.prototype.oCurrentScreen=null,n.prototype.showLoading=function(){b("#rl-loading").show()},n.prototype.hideLoading=function(){b("#rl-loading").hide()},n.prototype.routeOff=function(){e.changed.active=!1},n.prototype.routeOn=function(){e.changed.active=!0},n.prototype.setBoot=function(a){return T.isNormal(a)&&(this.oBoot=a),this},n.prototype.screen=function(a){return""===a||T.isUnd(this.oScreens[a])?null:this.oScreens[a]},n.prototype.delegateRun=function(a,b,c){a&&a[b]&&a[b].apply(a,T.isArray(c)?c:[])},n.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=db.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=T.createCommand(e,function(){Y.hideScreenPopup(a)})),U.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),this.delegateRun(e,"onBuild",[h]),U.runHook("view-model-post-build",[a.__name,e,h])):T.log("Cannot find view model position: "+f)}return a?a.__vm:null},n.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},n.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1))},n.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),U.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},n.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===T.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,T.isNonEmptyArray(d.viewModels())&&f.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),this.delegateRun(d,"onBuild")),f.defer(function(){c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onHide"),T.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),c.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onShow"),U.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),T.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),c.delegateRun(a.__vm,"onShow"),U.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},n.prototype.startScreens=function(a){f.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),f.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),U.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),U.runHook("screen-post-start",[a.screenName(),a]))},this);var b=d.create();b.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,f.bind(this.screenOnRoute,this)),e.initialized.add(b.parse,b),e.changed.add(b.parse,b),e.init()},n.prototype.setHash=function(a,b,c){a="#"===a.substr(0,1)?a.substr(1):a,a="/"===a.substr(0,1)?a.substr(1):a,c=T.isUnd(c)?!1:!!c,(T.isUnd(b)?1:!b)?(e.changed.active=!0,e[c?"replaceHash":"setHash"](a),e.setHash(a)):(e.changed.active=!1,e[c?"replaceHash":"setHash"](a),e.changed.active=!0)},n.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},Y=new n,o.newInstanceFromJson=function(a){var b=new o;return b.initByJson(a)?b:null},o.prototype.name="",o.prototype.email="",o.prototype.privateType=null,o.prototype.clear=function(){this.email="",this.name="",this.privateType=null},o.prototype.validate=function(){return""!==this.name||""!==this.email},o.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},o.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},o.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=R.EmailType.Facebook),null===this.privateType&&(this.privateType=R.EmailType.Default)),this.privateType},o.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},o.prototype.parse=function(a){this.clear(),a=T.trim(a);var b=/(?:"([^"]+)")? ?,]+)>?,? ?/g,c=b.exec(a);c?(this.name=c[1]||"",this.email=c[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)},o.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=T.trim(a.Name),this.email=T.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},o.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=T.isUnd(b)?!1:!!b,c=T.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+T.encodeHtml(this.name)+"":c?T.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=T.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+T.encodeHtml(d)+""+T.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=T.encodeHtml(d))):b&&(d=''+T.encodeHtml(this.email)+""))),d},o.prototype.select2Result=function(){var a="",b=db.cache().getUserPic(this.email);return a+=""!==b?'':'',R.EmailType.Facebook===this.type()?(a+=""+(0'):a+=""+(0('+this.name+")":this.email),a+""},o.prototype.select2Selection=function(a){var c="";if(R.EmailType.Facebook===this.type()){if(c=0").text(c).appendTo(a),a.append(''),null}else c=0b&&(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;m0&&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=T.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=T.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=T.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},o.prototype.inputoTagLine=function(){return 0(new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="abort"),i.oRequests[n]=null),i.defaultResponse(c,n,e,b,f,d)}),n&&0
").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(h),e.data=db.data(),e.viewModelDom=i,e.__rlSettingsData=g.__rlSettingsData,g.__dom=i,g.__builded=!0,g.__vm=e,c.applyBindings(e,i[0]),Y.delegateRun(e,"onBuild",[i])):T.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&f.defer(function(){d.oCurrentSubScreen&&(Y.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),Y.delegateRun(d.oCurrentSubScreen,"onShow"),f.each(d.menu(),function(a){a.selected(e&&e.__rlSettingsData&&a.route===e.__rlSettingsData.Route)}),b("#rl-content .b-settings .b-content .content").scrollTop(0)),T.windowResize()})):Y.setHash(db.link().settings(),!1,!0)},L.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(Y.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},L.prototype.onBuild=function(){f.each(X.settings,function(a){a&&a.__rlSettingsData&&!f.find(X["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!f.find(X["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},L.prototype.routes=function(){var a=f.find(X.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=T.isUnd(c.subname)?b:T.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},f.extend(M.prototype,m.prototype),M.prototype.onShow=function(){db.setTitle("")},f.extend(N.prototype,L.prototype),N.prototype.onShow=function(){db.setTitle("")},f.extend(O.prototype,k.prototype),O.prototype.oSettings=null,O.prototype.oPlugins=null,O.prototype.oLocal=null,O.prototype.oLink=null,O.prototype.oSubs={},O.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):(W.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},O.prototype.link=function(){return null===this.oLink&&(this.oLink=new g),this.oLink},O.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new j),this.oLocal},O.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=T.isNormal(Z)?Z:{}),T.isUnd(this.oSettings[a])?null:this.oSettings[a]},O.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=T.isNormal(Z)?Z:{}),this.oSettings[a]=b},O.prototype.setTitle=function(b){b=(0').appendTo("body"),ab.on("error",function(a){db&&a&&a.originalEvent&&a.originalEvent.message&&-1===T.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&db.remote().jsError(T.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",_.attr("class"),T.microtime()-W.now)})}function P(){O.call(this),this.oData=null,this.oRemote=null,this.oCache=null}var Q={},R={},S={},T={},U={},V={},W={},X={settings:[],"settings-removed":[],"settings-disabled":[]},Y=null,Z=a.rainloopAppData||{},$=a.rainloopI18N||{},_=b("html"),ab=b(a),bb=b(a.document),cb=a.Notification&&a.Notification.requestPermission?a.Notification:null,db=null;W.now=(new Date).getTime(),W.minuteTick=c.observable(!0),W.fiveMinuteTick=c.observable(!0),W.langChangeTick=c.observable(!0),W.iAjaxErrorCount=0,W.iTokenErrorCount=0,W.iMessageBodyCacheCount=0,W.bUnload=!1,W.sUserAgent=(navigator.userAgent||"").toLowerCase(),W.bIsiOSDevice=-1/g,">").replace(/"/g,""").replace(/'/g,"'"):""},T.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=T.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},T.timeOutAction=function(){var b={};return function(c,d,e){T.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),T.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),T.audio=function(){var b=!1;return function(c,d){if(!1===b)if(W.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}}(),T.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},T.i18n=function(a,b,c){var d="",e=T.isUnd($[a])?T.isUnd(c)?a:c:$[a];if(!T.isUnd(b)&&!T.isNull(b))for(d in b)T.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},T.i18nToNode=function(a){f.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(T.i18n(c)):(c=a.data("i18n-html"),c&&a.html(T.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",T.i18n(c)))})})},T.i18nToDoc=function(){a.rainloopI18N&&($=a.rainloopI18N||{},T.i18nToNode(bb),W.langChangeTick(!W.langChangeTick())),a.rainloopI18N={}},T.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?W.langChangeTick.subscribe(function(){a&&a.call(b),c.call(b)}):a&&W.langChangeTick.subscribe(a,b)},T.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)},T.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},T.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()},T.replySubjectAdd=function(b,c,d){var e=null,f=T.trim(c);return null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||T.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||T.isUnd(e[1])||T.isUnd(e[2])||T.isUnd(e[3])?f=b+": "+c:(f=e[1]+(T.pInt(e[2])+1)+e[3],f=e[1]+(T.pInt(e[2])+1)+e[3]):f=b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),(T.isUnd(d)?!0:d)?T.fixLongSubject(f):f},T.fixLongSubject=function(a){var b=0,c=null;a=T.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||T.isUnd(c[0]))&&(c=null),c&&(b=0,b+=T.isUnd(c[2])?1:0+T.pInt(c[2]),b+=T.isUnd(c[4])?1:0+T.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]+/," ")},T.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},T.friendlySize=function(a){return a=T.pInt(a),a>=1073741824?T.roundNumber(a/1073741824,1)+"GB":a>=1048576?T.roundNumber(a/1048576,1)+"MB":a>=1024?T.roundNumber(a/1024,0)+"KB":a+"B"},T.log=function(b){a.console&&a.console.log&&a.console.log(b)},T.getNotification=function(a){return a=T.pInt(a),T.isUnd(S[a])?"":S[a]},T.initNotificationLanguage=function(){S[R.Notification.InvalidToken]=T.i18n("NOTIFICATIONS/INVALID_TOKEN"),S[R.Notification.AuthError]=T.i18n("NOTIFICATIONS/AUTH_ERROR"),S[R.Notification.AccessError]=T.i18n("NOTIFICATIONS/ACCESS_ERROR"),S[R.Notification.ConnectionError]=T.i18n("NOTIFICATIONS/CONNECTION_ERROR"),S[R.Notification.CaptchaError]=T.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),S[R.Notification.SocialFacebookLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),S[R.Notification.SocialTwitterLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),S[R.Notification.SocialGoogleLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),S[R.Notification.DomainNotAllowed]=T.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),S[R.Notification.AccountNotAllowed]=T.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),S[R.Notification.CantGetMessageList]=T.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),S[R.Notification.CantGetMessage]=T.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),S[R.Notification.CantDeleteMessage]=T.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),S[R.Notification.CantMoveMessage]=T.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),S[R.Notification.CantCopyMessage]=T.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),S[R.Notification.CantSaveMessage]=T.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),S[R.Notification.CantSendMessage]=T.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),S[R.Notification.InvalidRecipients]=T.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),S[R.Notification.CantCreateFolder]=T.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),S[R.Notification.CantRenameFolder]=T.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),S[R.Notification.CantDeleteFolder]=T.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),S[R.Notification.CantDeleteNonEmptyFolder]=T.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),S[R.Notification.CantSubscribeFolder]=T.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),S[R.Notification.CantUnsubscribeFolder]=T.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),S[R.Notification.CantSaveSettings]=T.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),S[R.Notification.CantSavePluginSettings]=T.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),S[R.Notification.DomainAlreadyExists]=T.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),S[R.Notification.CantInstallPackage]=T.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),S[R.Notification.CantDeletePackage]=T.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),S[R.Notification.InvalidPluginPackage]=T.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),S[R.Notification.UnsupportedPluginPackage]=T.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),S[R.Notification.LicensingServerIsUnavailable]=T.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),S[R.Notification.LicensingExpired]=T.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),S[R.Notification.LicensingBanned]=T.i18n("NOTIFICATIONS/LICENSING_BANNED"),S[R.Notification.DemoSendMessageError]=T.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),S[R.Notification.AccountAlreadyExists]=T.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),S[R.Notification.MailServerError]=T.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),S[R.Notification.UnknownNotification]=T.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),S[R.Notification.UnknownError]=T.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},T.getUploadErrorDescByCode=function(a){var b="";switch(T.pInt(a)){case R.UploadErrorCode.FileIsTooBig:b=T.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case R.UploadErrorCode.FilePartiallyUploaded:b=T.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case R.UploadErrorCode.FileNoUploaded:b=T.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case R.UploadErrorCode.MissingTempFolder:b=T.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case R.UploadErrorCode.FileOnSaveingError:b=T.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case R.UploadErrorCode.FileType:b=T.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=T.i18n("UPLOAD/ERROR_UNKNOWN")}return b},T.killCtrlAandS=function(b){if(b=b||a.event){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(b.ctrlKey&&d===R.EventKeyCode.S)return b.preventDefault(),void 0;if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;b.ctrlKey&&d===R.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},T.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=T.isUnd(d)?!0:d,e.canExecute=T.isFunc(d)?c.computed(function(){return e.enabled()&&d.call(a)}):c.computed(function(){return e.enabled()&&!!d}),e},T.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(R.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(R.InterfaceAnimation.Full),W.sAnimationType=R.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(W.bMobileDevice||a===R.InterfaceAnimation.None)_.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),W.sAnimationType=R.InterfaceAnimation.None;else switch(a){case R.InterfaceAnimation.Full:_.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),W.sAnimationType=a;break;case R.InterfaceAnimation.Normal:_.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),W.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=R.DesktopNotifications.NotSupported;if(cb&&cb.permission)switch(cb.permission.toLowerCase()){case"granted":c=R.DesktopNotifications.Allowed;break;case"denied":c=R.DesktopNotifications.Denied;break;case"default":c=R.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&R.DesktopNotifications.Allowed===b.desktopNotificationsPermisions() +},write:function(a){if(a){var c=b.desktopNotificationsPermisions();R.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):R.DesktopNotifications.NotAllowed===c?cb.requestPermission(function(){b.desktopNotifications.valueHasMutated(),R.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")?T.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?T.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},T.isFolderExpanded=function(a){var b=db.local().get(R.ClientSideKeyName.ExpandedFolders);return f.isArray(b)&&-1!==f.indexOf(b,a)},T.setExpandedFolder=function(a,b){var c=db.local().get(R.ClientSideKeyName.ExpandedFolders);f.isArray(c)||(c=[]),b?(c.push(a),c=f.uniq(c)):c=f.without(c,a),db.local().set(R.ClientSideKeyName.ExpandedFolders,c)},T.initLayoutResizer=function(a,c,d,e,g,h,i,j){e=e||300,g=g||500,h=h||g-e/2,i=i||300;var k=0,l=b(a),m=b(c),n=b(d),o=db.local().get(j)||h,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=g>k?k:g,l.resizable("option","maxWidth",k),c.size&&c.size.width&&db.local().set(j,c.size.width),p(null,null,!0)}};o&&l.width(o),k=n.width()-i,k=g>k?k:g,l.resizable({minWidth:e,maxWidth:k,handles:"e",resize:p,stop:p}),p(null,null,!0),ab.resize(f.throttle(q,400))},T.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&&0100)&&(a.addClass("rl-bq-switcher hidden-bq"),b('').insertBefore(a).click(function(){a.toggleClass("hidden-bq"),T.windowResize()}).after("
").before("
"))})}},T.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()}))},T.extendAsViewModel=function(a,b,c){b&&(c||(c=l),b.__name=a,U.regViewModelHook(a,b),f.extend(b.prototype,c.prototype))},T.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},X.settings.push(a)},T.removeSettingsViewModel=function(a){X["settings-removed"].push(a)},T.disableSettingsViewModel=function(a){X["settings-disabled"].push(a)},T.convertThemeName=function(a){return T.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},T.quoteName=function(a){return a.replace(/["]/g,'\\"')},T.microtime=function(){return(new Date).getTime()},T.convertLangName=function(a,b){return T.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},T.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=T.isUnd(a)?32:T.pInt(a);b.length/g,">").replace(/")},T.draggeblePlace=function(){return b('
 
').appendTo("#rl-hidden")},T.defautOptionsAfterRender=function(a,b){b&&!T.isUnd(b.disable)&&c.applyBindingsToNode(a,{disable:b.disable},b)},T.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+T.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")),T.i18nToNode(d),n.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.document.write(''+T.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)},T.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=T.isUnd(d)?1e3:T.pInt(d),function(e,g,h,i,j){b.call(c,g&&g.Result?R.SaveSettingsStep.TrueResult:R.SaveSettingsStep.FalseResult),a&&a.call(c,e,g,h,i,j),f.delay(function(){b.call(c,R.SaveSettingsStep.Idle)},d)}},T.settingsSaveHelperSimpleFunction=function(a,b){return T.settingsSaveHelperFunction(null,a,b,1e3)},T.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},T.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:T.isUnd(c)?a.toString():c.toString(),custom:T.isUnd(c)?!1:!0,title:T.isUnd(c)?"":a.toString(),value:a.toString()};(T.isUnd(b)?0:!b)?f.unshift(d):f.push(d)};if(h>1||h>0&&g>h){for(g>h?(i(h),c=h,d=h):((3>=g||g>=h-2)&&(e+=2),i(g),c=g,d=g);e>0;)if(c-=1,d+=1,c>0&&(i(c,!1),e--),h>=d)i(d,!0),e--;else if(0>=c)break;3===c?i(2,!1):c>3&&i(Math.round((c-1)/2),!1,"..."),h-2===d?i(h-1,!0):h-2>d&&i(Math.round((h+d)/2),!0,"..."),c>1&&i(1,!1),h>d&&i(h,!0)}return f}},V={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return V.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=V._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 V._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;cd?(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(!W.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''+T.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"),f.delay(function(){b(a).toggleClass("popup-active",e)},1)}},c.bindingHandlers.i18nInit={init:function(a){T.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),T.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=T.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=T.pInt(e[2]),g=ab.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(!W.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),T.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),T.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(){T.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!W.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){W.bDisableNanoScroll||b(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},c.bindingHandlers.saveTrigger1={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text]")?"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),g="custom"===f.data("save-trigger-type"),h=g?"":"-input";switch(e.toString()){case"1":f.find(".sst-animated"+h+",.sst-error"+h).hide().removeClass("sst-visible"+h).end().find(".sst-success"+h).show().addClass("sst-visible"+h);break;case"0":f.find(".sst-animated"+h+",.sst-success"+h).hide().removeClass("sst-visible"+h).end().find(".sst-error"+h).show().addClass("sst-visible"+h);break;case"-2":f.find(".sst-error"+h+",.sst-success"+h).hide().removeClass("sst-visible"+h).end().find(".sst-animated"+h).show().addClass("sst-visible"+h);break;default:f.find(".sst-animated"+h).hide().end().find(".sst-error"+h+",.sst-success"+h).removeClass("sst-visible"+h)}}},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){db.getAutocomplete(a.term,function(a){b(f.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return f.map(a,function(a){var b=T.trim(a),c=null;return""!==b?(c=new o,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:f.bind(function(a){d.data("EmailsTagsValue",a.target.value),e(a.target.value)},this)}),e.subscribe(function(a){d.data("EmailsTagsValue")!==a&&(d.val(a),d.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(T.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},T.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=T.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=T.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),T.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},g.prototype.root=function(){return this.sBase},g.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},g.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},g.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},g.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},g.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},g.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},g.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},g.prototype.settings=function(a){var b=this.sBase+"settings";return T.isUnd(a)||""===a||(b+="/"+a),b},g.prototype.admin=function(a){var b=this.sBase;switch(a){case"AdminDomains":b+="domains";break;case"AdminSecurity":b+="security";break;case"AdminLicensing":b+="licensing"}return b},g.prototype.mailBox=function(a,b,c){b=T.isNormal(b)?T.pInt(b):1,c=T.pString(c);var d=this.sBase+"mailbox/";return""!==a&&(d+=encodeURI(a)),b>1&&(d=d.replace(/[\/]+$/,""),d+="/p"+b),""!==c&&(d=d.replace(/[\/]+$/,""),d+="/"+encodeURI(c)),d},g.prototype.phpInfo=function(){return this.sServer+"Info"},g.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},g.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},g.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"},g.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a},g.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"},g.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"},g.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},U.oViewModelsHooks={},U.oSimpleHooks={},U.regViewModelHook=function(a,b){b&&(b.__hookName=a)},U.addHook=function(a,b){T.isFunc(b)&&(T.isArray(U.oSimpleHooks[a])||(U.oSimpleHooks[a]=[]),U.oSimpleHooks[a].push(b))},U.runHook=function(a,b){T.isArray(U.oSimpleHooks[a])&&(b=b||[],f.each(U.oSimpleHooks[a],function(a){a.apply(null,b)}))},U.mainSettingsGet=function(a){return db?db.settingsGet(a):null},U.remoteRequest=function(a,b,c,d,e,f){db&&db.remote().defaultRequest(a,b,c,d,e,f)},U.settingsGet=function(a,b){var c=U.mainSettingsGet("Plugins");return c=c&&T.isUnd(c[a])?null:c[a],c?T.isUnd(c[b])?null:c[b]:null},h.supported=function(){return!0},h.prototype.set=function(a,c){var d=b.cookie(Q.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(Q.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},h.prototype.get=function(a){var c=b.cookie(Q.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!T.isUnd(d[a])?d[a]:null}catch(e){}return d},i.supported=function(){return!!a.localStorage},i.prototype.set=function(b,c){var d=a.localStorage[Q.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[Q.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},i.prototype.get=function(b){var c=a.localStorage[Q.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!T.isUnd(d[b])?d[b]:null}catch(e){}return d},j.prototype.oDriver=null,j.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},j.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},k.prototype.bootstart=function(){},l.prototype.sPosition="",l.prototype.sTemplate="",l.prototype.viewModelName="",l.prototype.viewModelDom=null,l.prototype.viewModelTemplate=function(){return this.sTemplate},l.prototype.viewModelPosition=function(){return this.sPosition},l.prototype.cancelCommand=l.prototype.closeCommand=function(){},m.prototype.oCross=null,m.prototype.sScreenName="",m.prototype.aViewModels=[],m.prototype.viewModels=function(){return this.aViewModels},m.prototype.screenName=function(){return this.sScreenName},m.prototype.routes=function(){return null},m.prototype.__cross=function(){return this.oCross},m.prototype.__start=function(){var a=this.routes(),b=null,c=null;T.isNonEmptyArray(a)&&(c=f.bind(this.onRoute||T.emptyFunction,this),b=d.create(),f.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},n.constructorEnd=function(a){T.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},n.prototype.sDefaultScreenName="",n.prototype.oScreens={},n.prototype.oBoot=null,n.prototype.oCurrentScreen=null,n.prototype.showLoading=function(){b("#rl-loading").show()},n.prototype.hideLoading=function(){b("#rl-loading").hide()},n.prototype.routeOff=function(){e.changed.active=!1},n.prototype.routeOn=function(){e.changed.active=!0},n.prototype.setBoot=function(a){return T.isNormal(a)&&(this.oBoot=a),this},n.prototype.screen=function(a){return""===a||T.isUnd(this.oScreens[a])?null:this.oScreens[a]},n.prototype.delegateRun=function(a,b,c){a&&a[b]&&a[b].apply(a,T.isArray(c)?c:[])},n.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=db.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=T.createCommand(e,function(){Y.hideScreenPopup(a)})),U.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),this.delegateRun(e,"onBuild",[h]),U.runHook("view-model-post-build",[a.__name,e,h])):T.log("Cannot find view model position: "+f)}return a?a.__vm:null},n.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},n.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1))},n.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),U.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},n.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===T.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,T.isNonEmptyArray(d.viewModels())&&f.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),this.delegateRun(d,"onBuild")),f.defer(function(){c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onHide"),T.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),c.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onShow"),U.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),T.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),c.delegateRun(a.__vm,"onShow"),U.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},n.prototype.startScreens=function(a){f.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),f.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),U.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),U.runHook("screen-post-start",[a.screenName(),a]))},this);var b=d.create();b.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,f.bind(this.screenOnRoute,this)),e.initialized.add(b.parse,b),e.changed.add(b.parse,b),e.init()},n.prototype.setHash=function(a,b,c){a="#"===a.substr(0,1)?a.substr(1):a,a="/"===a.substr(0,1)?a.substr(1):a,c=T.isUnd(c)?!1:!!c,(T.isUnd(b)?1:!b)?(e.changed.active=!0,e[c?"replaceHash":"setHash"](a),e.setHash(a)):(e.changed.active=!1,e[c?"replaceHash":"setHash"](a),e.changed.active=!0)},n.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},Y=new n,o.newInstanceFromJson=function(a){var b=new o;return b.initByJson(a)?b:null},o.prototype.name="",o.prototype.email="",o.prototype.privateType=null,o.prototype.clear=function(){this.email="",this.name="",this.privateType=null},o.prototype.validate=function(){return""!==this.name||""!==this.email},o.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},o.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},o.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=R.EmailType.Facebook),null===this.privateType&&(this.privateType=R.EmailType.Default)),this.privateType},o.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},o.prototype.parse=function(a){this.clear(),a=T.trim(a);var b=/(?:"([^"]+)")? ?,]+)>?,? ?/g,c=b.exec(a);c?(this.name=c[1]||"",this.email=c[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)},o.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=T.trim(a.Name),this.email=T.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},o.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=T.isUnd(b)?!1:!!b,c=T.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+T.encodeHtml(this.name)+"":c?T.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=T.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+T.encodeHtml(d)+""+T.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=T.encodeHtml(d))):b&&(d=''+T.encodeHtml(this.email)+""))),d},o.prototype.select2Result=function(){var a="",b=db.cache().getUserPic(this.email);return a+=""!==b?'':'',R.EmailType.Facebook===this.type()?(a+=""+(0'):a+=""+(0('+this.name+")":this.email),a+""},o.prototype.select2Selection=function(a){var c="";if(R.EmailType.Facebook===this.type()){if(c=0").text(c).appendTo(a),a.append(''),null}else c=0b&&(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;m0&&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=T.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=T.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=T.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},o.prototype.inputoTagLine=function(){return 0(new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="abort"),i.oRequests[n]=null),i.defaultResponse(c,n,e,b,f,d)}),n&&0
").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(h),e.data=db.data(),e.viewModelDom=i,e.__rlSettingsData=g.__rlSettingsData,g.__dom=i,g.__builded=!0,g.__vm=e,c.applyBindings(e,i[0]),Y.delegateRun(e,"onBuild",[i])):T.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&f.defer(function(){d.oCurrentSubScreen&&(Y.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),Y.delegateRun(d.oCurrentSubScreen,"onShow"),f.each(d.menu(),function(a){a.selected(e&&e.__rlSettingsData&&a.route===e.__rlSettingsData.Route)}),b("#rl-content .b-settings .b-content .content").scrollTop(0)),T.windowResize()})):Y.setHash(db.link().settings(),!1,!0)},L.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(Y.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},L.prototype.onBuild=function(){f.each(X.settings,function(a){a&&a.__rlSettingsData&&!f.find(X["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!f.find(X["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},L.prototype.routes=function(){var a=f.find(X.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=T.isUnd(c.subname)?b:T.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},f.extend(M.prototype,m.prototype),M.prototype.onShow=function(){db.setTitle("")},f.extend(N.prototype,L.prototype),N.prototype.onShow=function(){db.setTitle("")},f.extend(O.prototype,k.prototype),O.prototype.oSettings=null,O.prototype.oPlugins=null,O.prototype.oLocal=null,O.prototype.oLink=null,O.prototype.oSubs={},O.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):(W.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},O.prototype.link=function(){return null===this.oLink&&(this.oLink=new g),this.oLink},O.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new j),this.oLocal},O.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=T.isNormal(Z)?Z:{}),T.isUnd(this.oSettings[a])?null:this.oSettings[a]},O.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=T.isNormal(Z)?Z:{}),this.oSettings[a]=b},O.prototype.setTitle=function(b){b=(00&&-1b?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(mb.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.type=c.observable(mb.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.canBeEdited=c.computed(function(){return mb.FolderType.User===this.type()},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 ob.i18n("POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1",{FOLDER:this.folderNameForClear()})},this),this.clearCommand=ob.createCommand(this,function(){var a=this,b=this.selectedFolder();b&&(Ab.data().message(null),Ab.data().messageList([]),this.clearingProcess(!0),Ab.cache().setFolderHash(b.fullNameRaw,""),Ab.remote().folderClear(function(b,c){a.clearingProcess(!1),mb.StorageResultType.Success===b&&c&&c.Result?(Ab.reloadMessageList(!0),a.cancelCommand()):c&&c.ErrorCode?a.clearingError(ob.getNotification(c.ErrorCode)):a.clearingError(ob.getNotification(mb.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"),ob.initOnStartOrLangChange(function(){this.sNoParentText=ob.i18n("POPUPS_CREATE_FOLDER/SELECT_NO_PARENT")},this),this.folderName=c.observable(""),this.focusTrigger=c.observable(!1),this.selectedParentValue=c.observable(lb.Values.UnuseOptionValue),this.parentFolderSelectList=c.computed(function(){var a=Ab.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)}),Ab.folderListOptionsBuilder([],e,[],b,null,c,d,f)},this),this.createFolder=ob.createCommand(this,function(){var a=Ab.data(),b=this.selectedParentValue();""===b&&1=a?1:a},this),this.contactsPagenator=c.computed(ob.computedPagenatorHelper(this.contactsPage,this.contactsPageCount)),this.emptySelection=c.observable(!0),this.viewClearSearch=c.observable(!1),this.viewID=c.observable(""),this.viewProperties=c.observableArray([]),this.viewPropertiesNames=this.viewProperties.filter(function(a){return-10&&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(mb.SaveSettingsStep.TrueResult))}).always(function(){d.iTimer=a.setTimeout(function(){d.themeTrigger(mb.SaveSettingsStep.Idle)},1e3),d.oLastAjax=null})),Ab.remote().saveSettings(null,{Theme:c})},this)}function _(){ob.initDataConstructorBySettings(this)}function ab(){_.call(this);var a=function(a){return function(){var b=Ab.cache().getFolderFromCacheList(a());b&&b.type(mb.FolderType.User)}},d=function(a){return function(b){var c=Ab.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(mb.FolderType.SentItems),this),this.draftFolder.subscribe(d(mb.FolderType.Draft),this),this.spamFolder.subscribe(d(mb.FolderType.Spam),this),this.trashFolder.subscribe(d(mb.FolderType.Trash),this),this.draftFolderNotEnabled=c.computed(function(){return""===this.draftFolder()||lb.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 ob.isArray(b)&&0=a?1:a},this),this.mainMessageListSearch=c.computed({read:this.messageListSearch,write:function(a){tb.setHash(Ab.link().mailBox(this.currentFolderFullNameHash(),1,ob.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),00?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(mb.CustomThemeType.Light),this.purgeMessageBodyCacheThrottle=h.throttle(this.purgeMessageBodyCache,3e4)}function bb(){this.oRequests={}}function cb(){bb.call(this),this.oRequests={}}function db(){this.oEmailsPicsHashes={},this.oServices={}}function eb(){db.call(this),this.oFoldersCache={},this.oFoldersNamesCache={},this.oFolderHashCache={},this.oFolderUidNextCache={},this.oMessageListHashCache={},this.oMessageFlagsCache={},this.oNewMessage={},this.oRequestedMessage={}}function fb(a){q.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function gb(){q.call(this,"login",[K])}function hb(){q.call(this,"mailbox",[M,O,P,Q]),this.oLastRoute={}}function ib(){fb.call(this,[N,R,S]),ob.initOnStartOrLangChange(function(){this.sSettingsTitle=ob.i18n("TITLES/SETTINGS")},this,function(){Ab.setTitle(this.sSettingsTitle)})}function jb(){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('