From 9f296a4866e854554c683b464be31110503cab5a Mon Sep 17 00:00:00 2001 From: Alex Sampaio Date: Fri, 21 Oct 2016 14:56:22 +0200 Subject: [PATCH 001/117] CO: fix path for asset directory --- src/Adapter/Assets/AssetUrlGeneratorTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapter/Assets/AssetUrlGeneratorTrait.php b/src/Adapter/Assets/AssetUrlGeneratorTrait.php index 4a21600c99a..b3e65cb7eea 100644 --- a/src/Adapter/Assets/AssetUrlGeneratorTrait.php +++ b/src/Adapter/Assets/AssetUrlGeneratorTrait.php @@ -34,7 +34,7 @@ trait AssetUrlGeneratorTrait protected function getUriFromPath($fullPath) { $uri = str_replace( - $this->configuration->get('_PS_ROOT_DIR_').'/', + $this->configuration->get('_PS_ROOT_DIR_').DIRECTORY_SEPARATOR, $this->configuration->get('__PS_BASE_URI__'), $fullPath ); -- GitLab From cb05a5b49fe8a1f35578a65f258ef05f00c95e0e Mon Sep 17 00:00:00 2001 From: Alex Sampaio Date: Fri, 21 Oct 2016 17:15:58 +0200 Subject: [PATCH 002/117] BO: fix delete combination --- ...minAttributeGeneratorControllerWrapper.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Adapter/Attribute/AdminAttributeGeneratorControllerWrapper.php b/src/Adapter/Attribute/AdminAttributeGeneratorControllerWrapper.php index 805f8d28674..d5260189489 100644 --- a/src/Adapter/Attribute/AdminAttributeGeneratorControllerWrapper.php +++ b/src/Adapter/Attribute/AdminAttributeGeneratorControllerWrapper.php @@ -26,11 +26,21 @@ namespace PrestaShop\PrestaShop\Adapter\Attribute; +use Context; + /** * Admin controller wrapper for new Architecture, about Category admin controller. */ class AdminAttributeGeneratorControllerWrapper { + private $translator; + + public function __construct() + { + $context = Context::getContext(); + $this->translator = $context->getTranslator(); + } + /** * Generate product attributes * @@ -70,13 +80,11 @@ class AdminAttributeGeneratorControllerWrapper return false; } - $translator = $this->container->get('translator'); - if ($idProduct && \ValidateCore::isUnsignedId($idProduct) && \ValidateCore::isLoadedObject($product = new \ProductCore($idProduct))) { if (($depends_on_stock = \StockAvailableCore::dependsOnStock($idProduct)) && \StockAvailableCore::getQuantityAvailableByProduct($idProduct, $idAttribute)) { return array( 'status' => 'error', - 'message'=> $translator->trans('It is not possible to delete a combination while it still has some quantities in the Advanced Stock Management. You must delete its stock first.', array(), 'Admin.Catalog.Notification'), + 'message'=> $this->translator->trans('It is not possible to delete a combination while it still has some quantities in the Advanced Stock Management. You must delete its stock first.', array(), 'Admin.Catalog.Notification'), ); } else { $product->deleteAttributeCombination((int)$idAttribute); @@ -92,19 +100,19 @@ class AdminAttributeGeneratorControllerWrapper if ($depends_on_stock && !\StockCore::deleteStockByIds($idProduct, $idAttribute)) { return array( 'status' => 'error', - 'message'=> $translator->trans('Error while deleting the stock', array(), 'Admin.Catalog.Notification'), + 'message'=> $this->translator->trans('Error while deleting the stock', array(), 'Admin.Catalog.Notification'), ); } else { return array( 'status' => 'ok', - 'message'=> $translator->trans('Successful deletion', array(), 'Admin.Catalog.Notification'), + 'message'=> $this->translator->trans('Successful deletion', array(), 'Admin.Catalog.Notification'), ); } } } else { return array( 'status' => 'error', - 'message'=> $translator->trans('You cannot delete this attribute.', array(), 'Admin.Catalog.Notification'), + 'message'=> $this->translator->trans('You cannot delete this attribute.', array(), 'Admin.Catalog.Notification'), ); } } -- GitLab From f4235a64fa7caeef18959213808483d13e56661b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Salvador=20P=C3=A9rez?= Date: Sat, 22 Oct 2016 00:05:51 +0200 Subject: [PATCH 003/117] FO: extra tag block closed (cherry picked from commit 4b7537bbc77c3cb00ed6aaffc94e1d1f5eea95b8) --- themes/classic/templates/index.tpl | 2 -- 1 file changed, 2 deletions(-) diff --git a/themes/classic/templates/index.tpl b/themes/classic/templates/index.tpl index e02ef01e353..1da6a724b25 100644 --- a/themes/classic/templates/index.tpl +++ b/themes/classic/templates/index.tpl @@ -8,5 +8,3 @@ {/block} {/block} - -{/block} -- GitLab From 525bf0fe1c7f21b165e2a889ce26939946fc83a4 Mon Sep 17 00:00:00 2001 From: Anthony Girard Date: Mon, 24 Oct 2016 00:17:23 +0200 Subject: [PATCH 004/117] CO: Fixed customer account add/update hook call (cherry picked from commit c134dad4660a241498f2574d9f5d1d786cecb30b) --- classes/form/CustomerPersister.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/form/CustomerPersister.php b/classes/form/CustomerPersister.php index 1c5d6bf4a40..f5eba14c35d 100644 --- a/classes/form/CustomerPersister.php +++ b/classes/form/CustomerPersister.php @@ -111,8 +111,8 @@ class CustomerPersisterCore if ($ok) { $this->context->updateCustomer($customer); $this->context->cart->update(); - Hook::exec('actionCustomerAccountAdd', [ - 'newCustomer' => $customer + Hook::exec('actionCustomerAccountUpdate', [ + 'customer' => $customer, ]); if ($guest_to_customer) { $this->sendConfirmationMail($customer); @@ -167,8 +167,8 @@ class CustomerPersisterCore $this->context->updateCustomer($customer); $this->context->cart->update(); $this->sendConfirmationMail($customer); - Hook::exec('actionCustomerAccountUpdate', array( - 'customer' => $customer + Hook::exec('actionCustomerAccountAdd', array( + 'newCustomer' => $customer, )); } -- GitLab From 6d415c98173180c236854453c6d9915f475838f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Fri, 21 Oct 2016 16:34:06 +0200 Subject: [PATCH 005/117] BO: fixed customers registration --- classes/Customer.php | 140 +++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 66 deletions(-) diff --git a/classes/Customer.php b/classes/Customer.php index ecdc37e5523..c834d3a29dd 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -1,6 +1,6 @@ array( 'groups' => array('resource' => 'group'), - ) + ), ); /** @@ -177,7 +176,7 @@ class CustomerCore extends ObjectModel 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255), 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 255), 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128), - 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isHashedPassword', 'required' => true, 'size' => 60), + 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 60), 'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'), @@ -224,12 +223,13 @@ class CustomerCore extends ObjectModel } /** - * Adds current Customer as a new Object to the database + * Adds current Customer as a new Object to the database. * * @param bool $autoDate Automatically set `date_upd` and `date_add` columns * @param bool $nullValues Whether we want to use NULL values instead of empty quotes values * * @return bool Indicates whether the Customer has been successfully added + * * @throws PrestaShopDatabaseException * @throws PrestaShopException */ @@ -265,17 +265,18 @@ class CustomerCore extends ObjectModel } /** - * Updates the current Customer in the database + * Updates the current Customer in the database. * * @param bool $nullValues Whether we want to use NULL values instead of empty quotes values * * @return bool Indicates whether the Customer has been successfully updated + * * @throws PrestaShopDatabaseException * @throws PrestaShopException */ public function update($nullValues = false) { - $this->birthday = (empty($this->years) ? $this->birthday : (int)$this->years.'-'.(int)$this->months.'-'.(int)$this->days); + $this->birthday = (empty($this->years) ? $this->birthday : (int) $this->years.'-'.(int) $this->months.'-'.(int) $this->days); if ($this->newsletter && !Validate::isDate($this->newsletter_date_add)) { $this->newsletter_date_add = date('Y-m-d H:i:s'); @@ -296,9 +297,10 @@ class CustomerCore extends ObjectModel } /** - * Deletes current Customer from the database + * Deletes current Customer from the database. * * @return bool True if delete was successful + * * @throws PrestaShopException */ public function delete() @@ -336,7 +338,7 @@ class CustomerCore extends ObjectModel } /** - * Return customers list + * Return customers list. * * @param null|bool $onlyActive Returns only active customers when `true` * @@ -354,7 +356,7 @@ class CustomerCore extends ObjectModel } /** - * Return customer instance from its e-mail (optionally check password) + * Return customer instance from its e-mail (optionally check password). * * @param string $email e-mail * @param string $plaintextPassword Password is also checked if specified @@ -432,7 +434,7 @@ class CustomerCore extends ObjectModel } /** - * Retrieve customers by email address + * Retrieve customers by email address. * * @param string $email * @@ -449,7 +451,7 @@ class CustomerCore extends ObjectModel } /** - * Check id the customer is active or not + * Check id the customer is active or not. * * @param int $idCustomer * @@ -462,7 +464,7 @@ class CustomerCore extends ObjectModel } $cacheId = 'Customer::isBanned_'.(int) $idCustomer; if (!Cache::isStored($cacheId)) { - $result = (bool)!Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' + $result = (bool) !Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT `id_customer` FROM `'._DB_PREFIX_.'customer` WHERE `id_customer` = \''.(int) $idCustomer.'\' @@ -477,7 +479,7 @@ class CustomerCore extends ObjectModel } /** - * Check if e-mail is already registered in database + * Check if e-mail is already registered in database. * * @param string $email e-mail * @param bool $returnId @@ -503,11 +505,11 @@ class CustomerCore extends ObjectModel '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).' '.($ignoreGuest ? ' AND `is_guest` = 0' : '')); - return ($returnId ? (int) $result : (bool) $result); + return $returnId ? (int) $result : (bool) $result; } /** - * Check if an address is owned by a customer + * Check if an address is owned by a customer. * * @param int $idCustomer Customer ID * @param int $idAddress Address ID @@ -530,7 +532,7 @@ class CustomerCore extends ObjectModel } /** - * Reset Address cache + * Reset Address cache. * * @param int $idCustomer Customer ID * @param int $idAddress Address ID @@ -544,7 +546,7 @@ class CustomerCore extends ObjectModel } /** - * Return customer addresses + * Return customer addresses. * * @param int $idLang Language ID * @@ -552,7 +554,7 @@ class CustomerCore extends ObjectModel */ public function getAddresses($idLang) { - $shareOrder = (bool)Context::getContext()->shop->getGroup()->share_order; + $shareOrder = (bool) Context::getContext()->shop->getGroup()->share_order; $cacheId = 'Customer::getAddresses'.(int) $this->id.'-'.(int) $idLang.'-'.$shareOrder; if (!Cache::isStored($cacheId)) { $sql = 'SELECT DISTINCT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso @@ -573,7 +575,7 @@ class CustomerCore extends ObjectModel } /** - * Get simplified Addresses arrays + * Get simplified Addresses arrays. * * @param int|null $idLang Language ID * @@ -582,7 +584,7 @@ class CustomerCore extends ObjectModel public function getSimpleAddresses($idLang = null) { if (!$this->id) { - return []; + return array(); } if (is_null($idLang)) { @@ -591,7 +593,7 @@ class CustomerCore extends ObjectModel $sql = $this->getSimpleAddressSql(null, $idLang); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); - $addresses = []; + $addresses = array(); foreach ($result as $addr) { $addresses[$addr['id']] = $addr; } @@ -600,7 +602,7 @@ class CustomerCore extends ObjectModel } /** - * Get Address as array + * Get Address as array. * * @param int $idAddress Address ID * @param int|null $idLang Language ID @@ -609,8 +611,8 @@ class CustomerCore extends ObjectModel */ public function getSimpleAddress($idAddress, $idLang = null) { - if (!$this->id ||!intval($idAddress) || !$idAddress) { - return [ + if (!$this->id || !intval($idAddress) || !$idAddress) { + return array( 'id' => '', 'alias' => '', 'firstname' => '', @@ -631,7 +633,7 @@ class CustomerCore extends ObjectModel 'phone_mobile' => '', 'vat_number' => '', 'dni' => '', - ]; + ); } $sql = $this->getSimpleAddressSql($idAddress, $idLang); @@ -644,7 +646,7 @@ class CustomerCore extends ObjectModel } /** - * Get SQL query to retrieve Address in an array + * Get SQL query to retrieve Address in an array. * * @param int|null $idAddress Address ID * @param int|null $idLang Language ID @@ -656,7 +658,7 @@ class CustomerCore extends ObjectModel if (is_null($idLang)) { $idLang = Context::getContext()->language->id; } - $shareOrder = (bool)Context::getContext()->shop->getGroup()->share_order; + $shareOrder = (bool) Context::getContext()->shop->getGroup()->share_order; $sql = 'SELECT DISTINCT a.`id_address` AS `id`, @@ -698,7 +700,7 @@ class CustomerCore extends ObjectModel } /** - * Count the number of addresses for a customer + * Count the number of addresses for a customer. * * @param int $idCustomer Customer ID * @@ -715,7 +717,7 @@ class CustomerCore extends ObjectModel } /** - * Check if customer password is the right one + * Check if customer password is the right one. * * @param int $idCustomer Customer ID * @param string $passwordHash Hashed password @@ -746,12 +748,13 @@ class CustomerCore extends ObjectModel } /** - * Light back office search for customers + * Light back office search for customers. * - * @param string $query Searched string + * @param string $query Searched string * @param null|int $limit Limit query results * * @return array|false|mysqli_result|null|PDOStatement|resource Corresponding customers + * * @throws PrestaShopDatabaseException */ public static function searchByName($query, $limit = null) @@ -775,7 +778,7 @@ class CustomerCore extends ObjectModel } /** - * Search for customers by ip address + * Search for customers by ip address. * * @param string $ip Searched string * @@ -792,7 +795,7 @@ class CustomerCore extends ObjectModel } /** - * Return several useful statistics about customer + * Return several useful statistics about customer. * * @return array Stats */ @@ -806,9 +809,9 @@ class CustomerCore extends ObjectModel $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT c.`date_add` AS last_visit - FROM `'._DB_PREFIX_.'connections` c + FROM `'._DB_PREFIX_.'connections` c LEFT JOIN `'._DB_PREFIX_.'guest` g USING (id_guest) - WHERE g.`id_customer` = '.(int)$this->id.' ORDER BY c.`date_add` DESC '); + WHERE g.`id_customer` = '.(int) $this->id.' ORDER BY c.`date_add` DESC '); $result3 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT (YEAR(CURRENT_DATE)-YEAR(c.`birthday`)) - (RIGHT(CURRENT_DATE, 5)id) { return array(); } + return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT m.*, l.name as language FROM `'._DB_PREFIX_.'mail` m @@ -841,7 +845,7 @@ class CustomerCore extends ObjectModel } /** - * Get last 10 Connections of the Customer + * Get last 10 Connections of the Customer. * * @return array|false|mysqli_result|null|PDOStatement|resource */ @@ -850,12 +854,13 @@ class CustomerCore extends ObjectModel if (!$this->id) { return array(); } + return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT c.id_connections, c.date_add, COUNT(cp.id_page) AS pages, TIMEDIFF(MAX(cp.time_end), c.date_add) as time, http_referer,INET_NTOA(ip_address) as ipaddress FROM `'._DB_PREFIX_.'guest` g LEFT JOIN `'._DB_PREFIX_.'connections` c ON c.id_guest = g.id_guest LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections - WHERE g.`id_customer` = '.(int)$this->id.' + WHERE g.`id_customer` = '.(int) $this->id.' GROUP BY c.`id_connections` ORDER BY c.date_add DESC LIMIT 10' @@ -863,7 +868,7 @@ class CustomerCore extends ObjectModel } /** - * Check if Customer ID exists + * Check if Customer ID exists. * * @param int $idCustomer Customer ID * @@ -886,7 +891,7 @@ class CustomerCore extends ObjectModel } /** - * Update customer groups associated to the object + * Update customer groups associated to the object. * * @param array $list groups */ @@ -902,7 +907,7 @@ class CustomerCore extends ObjectModel } /** - * Remove this Customer ID from Customer Groups + * Remove this Customer ID from Customer Groups. * * @return bool Indicates whether the Customer ID has been successfully removed * from the Customer Group Db table @@ -913,7 +918,7 @@ class CustomerCore extends ObjectModel } /** - * Add the Customer to the given Customer Groups + * Add the Customer to the given Customer Groups. * * @param array $groups Customer Group IDs */ @@ -927,7 +932,7 @@ class CustomerCore extends ObjectModel } /** - * Get Groups that have the given Customer ID + * Get Groups that have the given Customer ID. * * @param int $idCustomer Customer ID * @@ -963,7 +968,7 @@ class CustomerCore extends ObjectModel } /** - * Get Products bought by this Customer + * Get Products bought by this Customer. * * @return array|false|mysqli_result|null|PDOStatement|resource */ @@ -976,7 +981,7 @@ class CustomerCore extends ObjectModel } /** - * Get Default Customer Group ID + * Get Default Customer Group ID. * * @param int $idCustomer Customer ID * @@ -1005,7 +1010,7 @@ class CustomerCore extends ObjectModel } /** - * Get current Country + * Get current Country. * * @param int $idCustomer * @param Cart|null $cart @@ -1018,7 +1023,7 @@ class CustomerCore extends ObjectModel $cart = Context::getContext()->cart; } if (!$cart || !$cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) { - $idAddress = (int)Db::getInstance()->getValue(' + $idAddress = (int) Db::getInstance()->getValue(' SELECT `id_address` FROM `'._DB_PREFIX_.'address` WHERE `id_customer` = '.(int) $idCustomer.' @@ -1033,7 +1038,7 @@ class CustomerCore extends ObjectModel } /** - * Toggle Customer status + * Toggle Customer status. * * @return bool Indicates whether the status has been successfully toggled */ @@ -1059,7 +1064,7 @@ class CustomerCore extends ObjectModel } /** - * Transform the Guest to a Customer + * Transform the Guest to a Customer. * * @param int $idLang Language ID * @param string|null $password Password @@ -1125,7 +1130,7 @@ class CustomerCore extends ObjectModel /** * Set password - * (for webservice) + * (for webservice). * * @param string $passwd Password * @@ -1143,10 +1148,12 @@ class CustomerCore extends ObjectModel } /** - * Check customer information and return customer validity + * Check customer information and return customer validity. * * @since 1.5.0 + * * @param bool $withGuest + * * @return bool customer validity */ public function isLogged($withGuest = false) @@ -1156,11 +1163,11 @@ class CustomerCore extends ObjectModel } /* Customer is valid only if it can be load and if object password is the same as database one */ - return ($this->logged == 1 && $this->id && Validate::isUnsignedId($this->id) && Customer::checkPassword($this->id, $this->passwd)); + return $this->logged == 1 && $this->id && Validate::isUnsignedId($this->id) && Customer::checkPassword($this->id, $this->passwd); } /** - * Logout + * Logout. * * @since 1.5.0 */ @@ -1179,7 +1186,7 @@ class CustomerCore extends ObjectModel /** * Soft logout, delete everything that links to the customer - * but leave there affiliate's information + * but leave there affiliate's information. * * @since 1.5.0 */ @@ -1197,7 +1204,7 @@ class CustomerCore extends ObjectModel } /** - * Get last empty Cart for this Customer, when last cart is not empty return false + * Get last empty Cart for this Customer, when last cart is not empty return false. * * @param bool|true $withOrder * @@ -1211,11 +1218,12 @@ class CustomerCore extends ObjectModel } $cart = array_shift($carts); $cart = new Cart((int) $cart['id_cart']); - return ($cart->nbProducts() === 0 ? (int) $cart->id : false); + + return $cart->nbProducts() === 0 ? (int) $cart->id : false; } /** - * Validate controller + * Validate controller. * * @param bool $htmlentities * @@ -1234,7 +1242,7 @@ class CustomerCore extends ObjectModel } /** - * Get outstanding amount + * Get outstanding amount. * * @return float Outstanding amount */ @@ -1262,7 +1270,7 @@ class CustomerCore extends ObjectModel /** * Get Customer Groups - * (for webservice) + * (for webservice). * * @return array|false|mysqli_result|null|PDOStatement|resource */ @@ -1278,7 +1286,7 @@ class CustomerCore extends ObjectModel /** * Set Customer Groups - * (for webservice) + * (for webservice). * * @param $result * @@ -1313,7 +1321,7 @@ class CustomerCore extends ObjectModel { $salt = $this->id.'-'.$this->secure_key; $this->reset_password_token = sha1(time().$salt); - $validity = (int) Configuration::get('PS_PASSWD_RESET_VALIDITY')?:1440; + $validity = (int) Configuration::get('PS_PASSWD_RESET_VALIDITY') ?: 1440; $this->reset_password_validity = date('Y-m-d H:i:s', strtotime('+'.$validity.' minutes')); } @@ -1351,7 +1359,7 @@ class CustomerCore extends ObjectModel } /** - * Delete reset password token data + * Delete reset password token data. */ public function removeResetPasswordToken() { -- GitLab From 18530da6f7317db2caaf76cf0aa904ea12fdd51a Mon Sep 17 00:00:00 2001 From: joce Date: Fri, 21 Oct 2016 14:20:19 +0200 Subject: [PATCH 006/117] CO: Improve global performances --- classes/Cart.php | 8 +- classes/Link.php | 140 +++++++++++++++--- classes/Product.php | 6 +- classes/SpecificPrice.php | 7 +- src/Adapter/Cart/CartPresenter.php | 2 +- .../Addon/Module/ModuleManagerBuilder.php | 20 ++- src/Core/Product/ProductPresenter.php | 10 +- 7 files changed, 161 insertions(+), 32 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 010e1e171e8..4cc9b507bcf 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -348,13 +348,15 @@ class CartCore extends ObjectModel /** * Calculate average Tax rate in Cart * - * @param int $id_cart Cart ID + * @param mixed $cart Cart ID or Cart Object * * @return float Average Tax used in Cart */ - public static function getTaxesAverageUsed($id_cart) + public static function getTaxesAverageUsed($cart) { - $cart = new Cart((int)$id_cart); + if (!is_object($cart)) { + $cart = new Cart((int)$cart); + } if (!Validate::isLoadedObject($cart)) { die(Tools::displayError()); } diff --git a/classes/Link.php b/classes/Link.php index 3ba7ee85f1a..1ddba0c9bb3 100644 --- a/classes/Link.php +++ b/classes/Link.php @@ -80,6 +80,28 @@ class LinkCore return $url.((strpos($url, '?')) ? '&' : '?').'deletePicture='.$idPicture; } + /** + * Return a product object from various product format + * + * @param $product + * @param $idLang + * @param $idShop + * @return Product + * @throws PrestaShopException + */ + public function getProductObject($product, $idLang, $idShop) { + if (!is_object($product)) { + if (is_array($product) && isset($product['id_product'])) { + $product = new Product($product['id_product'], false, $idLang, $idShop); + } elseif ((int) $product) { + $product = new Product((int) $product, false, $idLang, $idShop); + } else { + throw new PrestaShopException('Invalid product vars'); + } + } + return $product; + } + /** * Create a link to a product. * @@ -114,50 +136,73 @@ class LinkCore $url = $this->getBaseLink($idShop, null, $relativeProtocol).$this->getLangLink($idLang, null, $idShop); + // Set available keywords + $params = array(); + if (!is_object($product)) { if (is_array($product) && isset($product['id_product'])) { - $product = new Product($product['id_product'], false, $idLang, $idShop); + $params['id'] = $product['id_product']; } elseif ((int) $product) { - $product = new Product((int) $product, false, $idLang, $idShop); + $params['id'] = $product; } else { throw new PrestaShopException('Invalid product vars'); } + } else { + $params['id'] = $product->id; } - // Set available keywords - $params = array(); - $params['id'] = $product->id; $params['id_product_attribute'] = $ipa; + if (!$alias) { + $product = $this->getProductObject($product, $idLang, $idShop); + } $params['rewrite'] = (!$alias) ? $product->getFieldByLang('link_rewrite') : $alias; + if (!$ean13) { + $product = $this->getProductObject($product, $idLang, $idShop); + } $params['ean13'] = (!$ean13) ? $product->ean13 : $ean13; - $params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords')); - $params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title')); + if ($dispatcher->hasKeyword('product_rule', $idLang, 'meta_keywords', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords')); + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'meta_title', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title')); + } if ($dispatcher->hasKeyword('product_rule', $idLang, 'manufacturer', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); $params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer)); } if ($dispatcher->hasKeyword('product_rule', $idLang, 'supplier', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); $params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier)); } - + if ($dispatcher->hasKeyword('product_rule', $idLang, 'price', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); $params['price'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specificPrice); } if ($dispatcher->hasKeyword('product_rule', $idLang, 'tags', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); $params['tags'] = Tools::str2url($product->getTags($idLang)); } if ($dispatcher->hasKeyword('product_rule', $idLang, 'category', $idShop)) { - $params['category'] = (!is_null($product->category) && !empty($product->category)) ? Tools::str2url($product->category) : Tools::str2url($category); + if (!$category) { + $product = $this->getProductObject($product, $idLang, $idShop); + } + $params['category'] = (!$category) ? $product->category : $category; } if ($dispatcher->hasKeyword('product_rule', $idLang, 'reference', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); $params['reference'] = Tools::str2url($product->reference); } if ($dispatcher->hasKeyword('product_rule', $idLang, 'categories', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); $params['category'] = (!$category) ? $product->category : $category; $cats = array(); foreach ($product->getParentCategories($idLang) as $cat) { @@ -168,6 +213,9 @@ class LinkCore } $params['categories'] = implode('/', $cats); } + if ($ipa) { + $product = $this->getProductObject($product, $idLang, $idShop); + } $anchor = $ipa ? $product->getAnchor((int) $ipa, (bool) $addAnchor) : ''; return $url.$dispatcher->createUrl('product_rule', $idLang, array_merge($params, $extraParams), $force_routes, $anchor, $idShop); @@ -305,6 +353,28 @@ class LinkCore ); } + /** + * Return a category object from various category format + * + * @param $product + * @param $idLang + * @return Category + * @throws PrestaShopException + */ + public function getCategoryObject($category, $idLang) { + if (!is_object($category)) { + if (is_array($category) && isset($category['id_category'])) { + $category = new Category($category, $idLang); + } elseif ((int) $category) { + $category = new Category((int) $category, $idLang); + } else { + throw new PrestaShopException('Invalid category vars'); + } + } + return $category; + } + + /** * Create a link to a category. * @@ -323,24 +393,24 @@ class LinkCore $idShop = null, $relativeProtocol = false ) { + $dispatcher = Dispatcher::getInstance(); + if (!$idLang) { $idLang = Context::getContext()->language->id; } $url = $this->getBaseLink($idShop, null, $relativeProtocol).$this->getLangLink($idLang, null, $idShop); - if (!is_object($category)) { - $category = new Category($category, $idLang); - } - // Set available keywords $params = array(); - $params['id'] = $category->id; - $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; - $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); - $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); - // Selected filters is used by the module blocklayered + if (!is_object($category)) { + $params['id'] = $category; + } else { + $params['id'] = $category->id; + } + + // Selected filters is used by the module ps_facetedsearch $selectedFilters = is_null($selectedFilters) ? '' : $selectedFilters; if (empty($selectedFilters)) { @@ -350,6 +420,19 @@ class LinkCore $params['selected_filters'] = $selectedFilters; } + if (!$alias) { + $category = $this->getCategoryObject($category, $idLang); + } + $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; + if ($dispatcher->hasKeyword($rule, $idLang, 'meta_keywords', $idShop)) { + $category = $this->getCategoryObject($category, $idLang); + $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); + } + if ($dispatcher->hasKeyword($rule, $idLang, 'meta_title', $idShop)) { + $category = $this->getCategoryObject($category, $idLang); + $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); + } + return $url.Dispatcher::getInstance()->createUrl($rule, $idLang, $params, $this->allow, '', $idShop); } @@ -665,15 +748,23 @@ class LinkCore $notDefault = false; $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); $moduleManager = $moduleManagerBuilder->build(); + static $watermarkLogged = null; + static $watermarkHash = null; + static $psLegacyImages = null; + if ($watermarkLogged === null) { + $watermarkLogged = Configuration::get('WATERMARK_LOGGED'); + $watermarkHash = Configuration::get('WATERMARK_HASH'); + $psLegacyImages = Configuration::get('PS_LEGACY_IMAGES'); + } // Check if module is installed, enabled, customer is logged in and watermark logged option is on - if (Configuration::get('WATERMARK_LOGGED') && ($moduleManager->isInstalled('watermark') && $moduleManager->isEnabled('watermark')) && isset(Context::getContext()->customer->id)) { - $type .= '-'.Configuration::get('WATERMARK_HASH'); + if ($watermarkLogged && ($moduleManager->isInstalled('watermark') && $moduleManager->isEnabled('watermark')) && isset(Context::getContext()->customer->id)) { + $type .= '-'.$watermarkHash; } // legacy mode or default image $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'-'.Context::getContext()->shop->theme_name.'.jpg')) ? '-'.Context::getContext()->shop->theme_name : ''); - if ((Configuration::get('PS_LEGACY_IMAGES') + if (($psLegacyImages && (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg'))) || ($notDefault = strpos($ids, 'default') !== false)) { if ($this->allow == 1 && !$notDefault) { @@ -986,11 +1077,16 @@ class LinkCore */ protected function getLangLink($idLang = null, Context $context = null, $idShop = null) { + static $psRewritingSettings = null; + if ($psRewritingSettings === null) { + $psRewritingSettings = (int) Configuration::get('PS_REWRITING_SETTINGS', null, null, $idShop); + } + if (!$context) { $context = Context::getContext(); } - if ((!$this->allow && in_array($idShop, array($context->shop->id, null))) || !Language::isMultiLanguageActivated($idShop) || !(int) Configuration::get('PS_REWRITING_SETTINGS', null, null, $idShop)) { + if ((!$this->allow && in_array($idShop, array($context->shop->id, null))) || !Language::isMultiLanguageActivated($idShop) || !$psRewritingSettings) { return ''; } diff --git a/classes/Product.php b/classes/Product.php index ec5462d1a95..cc1c2ce043d 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3101,10 +3101,14 @@ class ProductCore extends ObjectModel $ecotax = Tools::convertPrice($ecotax, $id_currency); } if ($use_tax) { + static $psEcotaxTaxRulesGroupId = null; + if ($psEcotaxTaxRulesGroupId === null) { + $psEcotaxTaxRulesGroupId = (int) Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID'); + } // reinit the tax manager for ecotax handling $tax_manager = TaxManagerFactory::getManager( $address, - (int) Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID') + $psEcotaxTaxRulesGroupId ); $ecotax_tax_calculator = $tax_manager->getTaxCalculator(); $price += $ecotax_tax_calculator->addTaxes($ecotax); diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 2ebb9f4a1e4..5b4a5fdaa49 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -338,6 +338,11 @@ class SpecificPriceCore extends ObjectModel ** The price must not change between the top and the bottom of the page */ + static $psQtyDiscountOnCombination = null; + if ($psQtyDiscountOnCombination === null) { + $psQtyDiscountOnCombination = Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION'); + } + $key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity.'-'.(int)$id_product_attribute.'-'.(int)$id_cart.'-'.(int)$id_customer.'-'.(int)$real_quantity); if (!array_key_exists($key, SpecificPrice::$_specificPriceCache)) { $query_extra = self::computeExtraConditions($id_product, $id_product_attribute, $id_customer, $id_cart); @@ -351,7 +356,7 @@ class SpecificPriceCore extends ObjectModel `id_group` '.self::formatIntInQuery(0, $id_group).' '.$query_extra.' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= '; - $query .= (Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION') || !$id_cart || !$real_quantity) ? (int)$quantity : max(1, (int)$real_quantity); + $query .= ($psQtyDiscountOnCombination || !$id_cart || !$real_quantity) ? (int)$quantity : max(1, (int)$real_quantity); $query .= ' ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC, `to` DESC, `from` DESC'; SpecificPrice::$_specificPriceCache[$key] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); diff --git a/src/Adapter/Cart/CartPresenter.php b/src/Adapter/Cart/CartPresenter.php index 4019564a903..708be295913 100644 --- a/src/Adapter/Cart/CartPresenter.php +++ b/src/Adapter/Cart/CartPresenter.php @@ -406,7 +406,7 @@ class CartPresenter implements PresenterInterface $cartVouchers = $cart->getCartRules(); $vouchers = array(); - $cartHasTax = is_null($cart->id) ? false : $cart::getTaxesAverageUsed($cart->id); + $cartHasTax = is_null($cart->id) ? false : $cart::getTaxesAverageUsed($cart); foreach ($cartVouchers as $cartVoucher) { $vouchers[$cartVoucher['id_cart_rule']]['id_cart_rule'] = $cartVoucher['id_cart_rule']; diff --git a/src/Core/Addon/Module/ModuleManagerBuilder.php b/src/Core/Addon/Module/ModuleManagerBuilder.php index 5c05b691890..ede3c45e13e 100644 --- a/src/Core/Addon/Module/ModuleManagerBuilder.php +++ b/src/Core/Addon/Module/ModuleManagerBuilder.php @@ -41,6 +41,7 @@ use Symfony\Component\Routing\Router; use Symfony\Component\Routing\Loader\YamlFileLoader; use Symfony\Component\Yaml\Yaml; use GuzzleHttp\Client; +use Symfony\Component\Filesystem\Exception\IOException; class ModuleManagerBuilder { @@ -127,7 +128,24 @@ class ModuleManagerBuilder private function __construct() { - $config = Yaml::parse(file_get_contents(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.yml')); + $phpConfigFile = $this->getConfigDir().'/config.php'; + if (file_exists($phpConfigFile) + && filemtime($phpConfigFile) >= filemtime(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.yml')) { + $config = require($phpConfigFile); + } else { + $config = Yaml::parse( + file_get_contents( + _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.yml' + ) + ); + try { + $filesystem = new Filesystem(); + $filesystem->dumpFile($phpConfigFile, 'link->getProductLink( $product['id_product'], - null, - null, - null, + $linkRewrite, + $category, + $ean13, $language->id, null, (!$canonical) ? $product['id_product_attribute'] : null, -- GitLab From 69573de8921d159173017f54d17ebf7f28b247e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Mon, 24 Oct 2016 09:43:12 +0000 Subject: [PATCH 007/117] IN: added PS_MAINTENANCE_TEXT key in database --- install-dev/data/xml/configuration.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install-dev/data/xml/configuration.xml b/install-dev/data/xml/configuration.xml index f3d11cae3cd..df7ac73e432 100644 --- a/install-dev/data/xml/configuration.xml +++ b/install-dev/data/xml/configuration.xml @@ -820,5 +820,8 @@ Country 1 + + + -- GitLab From 8af35bba9426fb6a2ad541fdaa73fb17756270d1 Mon Sep 17 00:00:00 2001 From: Thomas Nabord Date: Mon, 24 Oct 2016 10:25:25 +0100 Subject: [PATCH 008/117] CO: Clean installations files from deleted hooks --- install-dev/data/xml/hook.xml | 24 ------------------------ install-dev/data/xml/hook_alias.xml | 20 -------------------- install-dev/upgrade/sql/1.7.0.0.sql | 17 +++++++++++++++-- 3 files changed, 15 insertions(+), 46 deletions(-) diff --git a/install-dev/data/xml/hook.xml b/install-dev/data/xml/hook.xml index e7e3f58b37f..ed7b5a5788a 100644 --- a/install-dev/data/xml/hook.xml +++ b/install-dev/data/xml/hook.xml @@ -6,9 +6,6 @@ - - displayPaymentPaymentThis hook displays new elements on the payment page - actionValidateOrderNew orders @@ -114,9 +111,6 @@ displayCustomerAccountCustomer account displayed in Front OfficeThis hook displays new elements on the customer account page - - displayCustomerIdentityFormCustomer identity form displayed in Front OfficeThis hook displays new elements on the form to update a customer identity - actionOrderSlipAddOrder slip creationThis hook is called when a new credit slip is added regarding client order @@ -171,9 +165,6 @@ displayShoppingCartShopping cart - Additional buttonThis hook displays new action buttons within the shopping cart - - actionSearchSearch - actionCarrierUpdateCarrier UpdateThis hook is called when a carrier is updated @@ -198,9 +189,6 @@ actionCarrierProcessCarrier process - - actionOrderDetailOrder detailThis hook is used to set the follow-up in Smarty when an order's detail is called - displayBeforeCarrierBefore carriers listThis hook is displayed before the carrier list in Front Office @@ -222,9 +210,6 @@ actionCategoryDeleteCategory deletionThis hook is displayed when a category is deleted - - actionBeforeAuthenticationBefore authenticationThis hook is displayed before the customer's authentication - displayPaymentTopTop of payment pageThis hook is displayed at the top of the payment page @@ -255,9 +240,6 @@ actionProductSaveSaving productsThis hook is called while saving products - - actionProductListOverrideAssign a products list to a categoryThis hook assigns a products list to a category - displayAttributeGroupPostProcessOn post-process in admin attribute groupThis hook is called on post-process in admin attribute group @@ -300,12 +282,6 @@ actionModuleInstallAfteractionModuleInstallAfter - - displayHomeTabHome Page TabsThis hook displays new elements on the homepage tabs - - - displayHomeTabContentHome Page Tabs ContentThis hook displays new elements on the homepage tabs content - displayTopColumnTop column blocksThis hook displays new elements in the top of columns diff --git a/install-dev/data/xml/hook_alias.xml b/install-dev/data/xml/hook_alias.xml index bc99c629dab..e9d425e4cea 100644 --- a/install-dev/data/xml/hook_alias.xml +++ b/install-dev/data/xml/hook_alias.xml @@ -5,10 +5,6 @@ - - payment - displayPayment - newOrder actionValidateOrder @@ -173,10 +169,6 @@ shoppingCartExtra displayShoppingCart - - search - actionSearch - updateCarrier actionCarrierUpdate @@ -209,10 +201,6 @@ processCarrier actionCarrierProcess - - orderDetail - actionOrderDetail - beforeCarrier displayBeforeCarrier @@ -237,10 +225,6 @@ categoryDeletion actionCategoryDelete - - beforeAuthentication - actionBeforeAuthentication - paymentTop displayPaymentTop @@ -281,10 +265,6 @@ afterSaveProduct actionProductSave - - productListAssign - actionProductListOverride - postProcessAttributeGroup displayAttributeGroupPostProcess diff --git a/install-dev/upgrade/sql/1.7.0.0.sql b/install-dev/upgrade/sql/1.7.0.0.sql index 9b67f2a14a8..d909a93e410 100644 --- a/install-dev/upgrade/sql/1.7.0.0.sql +++ b/install-dev/upgrade/sql/1.7.0.0.sql @@ -154,12 +154,25 @@ INSERT INTO `PREFIX_hook` (`name`, `title`, `description`, `position`) VALUES DELETE FROM `PREFIX_hook` WHERE `name` IN ( 'displayProductTab', 'displayProductTabContent', - 'displayBeforePayment'); + 'displayBeforePayment', + 'actionBeforeAuthentication', + 'actionOrderDetail', + 'actionProductListOverride', + 'actionSearch', + 'displayCustomerIdentityForm', + 'displayHomeTab', + 'displayHomeTabContent', + 'displayPayment'); DELETE FROM `PREFIX_hook_alias` WHERE `name` IN ( + 'beforeAuthentication', 'displayProductTab', 'displayProductTabContent', - 'displayBeforePayment'); + 'displayBeforePayment', + 'orderDetail', + 'payment', + 'productListAssign', + 'search'); DELETE FROM `PREFIX_configuration` WHERE `name` IN ( '_MEDIA_SERVER_2_', -- GitLab From 99416ff81f85fdf9b50e121ebf3a64cd5095fff1 Mon Sep 17 00:00:00 2001 From: Thierry Marianne Date: Mon, 24 Oct 2016 13:59:46 +0200 Subject: [PATCH 009/117] FO: Export translations on theme export --- src/Core/Addon/Theme/ThemeExporter.php | 46 +++++- .../Command/ExportThemeCommand.php | 5 +- .../Resources/config/services.yml | 2 + .../Tests/Command/ExportThemeCommandTest.php | 140 ++++++++++++++++++ .../Translation/Exporter/ThemeExporter.php | 29 +++- .../Translation/Extractor/ThemeExtractor.php | 5 +- 6 files changed, 217 insertions(+), 10 deletions(-) create mode 100644 src/PrestaShopBundle/Tests/Command/ExportThemeCommandTest.php diff --git a/src/Core/Addon/Theme/ThemeExporter.php b/src/Core/Addon/Theme/ThemeExporter.php index e838e95595e..2044e848da3 100644 --- a/src/Core/Addon/Theme/ThemeExporter.php +++ b/src/Core/Addon/Theme/ThemeExporter.php @@ -27,21 +27,33 @@ namespace PrestaShop\PrestaShop\Core\Addon\Theme; use PrestaShop\PrestaShop\Core\ConfigurationInterface; +use PrestaShopBundle\Entity\Repository\LangRepository; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; use ZipArchive; +use PrestaShopBundle\Translation\Exporter\ThemeExporter as TranslationsExporter; class ThemeExporter { protected $configuration; protected $fileSystem; protected $finder; - - public function __construct(ConfigurationInterface $configuration, Filesystem $fileSystem, Finder $finder) + protected $langRepository; + protected $translationsExporter; + + public function __construct( + ConfigurationInterface $configuration, + Filesystem $fileSystem, + Finder $finder, + LangRepository $langRepository, + TranslationsExporter $translationsExporter + ) { $this->configuration = $configuration; $this->fileSystem = $fileSystem; $this->finder = $finder; + $this->langRepository = $langRepository; + $this->translationsExporter = $translationsExporter; } public function export(Theme $theme) @@ -50,6 +62,7 @@ class ThemeExporter $this->copyTheme($theme->getDirectory(), $cacheDir); $this->copyModuleDependencies((array) $theme->get('dependencies.modules'), $cacheDir); + $this->copyTranslations($theme, $cacheDir); $finalFile = $this->configuration->get('_PS_ALL_THEMES_DIR_').'/'.$theme->getName().'.zip'; $this->createZip($cacheDir, $finalFile); @@ -86,6 +99,35 @@ class ThemeExporter } } + /** + * @param Theme $theme + * @param $cacheDir + */ + protected function copyTranslations(Theme $theme, $cacheDir) + { + $translationsDir = $cacheDir . 'translations'; + + $this->fileSystem->remove($translationsDir); + $this->fileSystem->mkdir($translationsDir); + + $languages = $this->langRepository->findAll(); + if (count($languages) > 0) { + /** + * @var \PrestaShopBundle\Entity\Lang $lang + */ + foreach ($languages as $lang) { + $locale = $lang->getLocale(); + $catalogueDir = $this->translationsExporter->exportCatalogues($theme->getName(), $locale); + } + + $catalogueDirParts = explode('/', $catalogueDir); + array_pop($catalogueDirParts); // Remove locale + + $cataloguesDir = implode('/', $catalogueDirParts); + $this->fileSystem->mirror($cataloguesDir, $translationsDir); + } + } + private function createZip($sourceDir, $destinationFileName) { $zip = new ZipArchive(); diff --git a/src/PrestaShopBundle/Command/ExportThemeCommand.php b/src/PrestaShopBundle/Command/ExportThemeCommand.php index a08838bb06f..17a4e953a6c 100644 --- a/src/PrestaShopBundle/Command/ExportThemeCommand.php +++ b/src/PrestaShopBundle/Command/ExportThemeCommand.php @@ -26,12 +26,13 @@ namespace PrestaShopBundle\Command; -use PrestaShop\PrestaShop\Core\Addon\Theme\Theme; +require dirname(__FILE__) . '/../../../vendor/prestashop/smarty/Autoloader.php'; +\Smarty_Autoloader::register(); + use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Yaml\Parser; class ExportThemeCommand extends ContainerAwareCommand { diff --git a/src/PrestaShopBundle/Resources/config/services.yml b/src/PrestaShopBundle/Resources/config/services.yml index 774a8e91617..3973e05998f 100644 --- a/src/PrestaShopBundle/Resources/config/services.yml +++ b/src/PrestaShopBundle/Resources/config/services.yml @@ -267,6 +267,8 @@ services: - "@prestashop.adapter.legacy.configuration" - "@filesystem" - "@finder" + - "@prestashop.core.admin.lang.repository" + - "@prestashop.translation.theme.exporter" prestashop.core.admin.translation.repository: class: PrestaShopBundle\Entity\Repository\TranslationRepository diff --git a/src/PrestaShopBundle/Tests/Command/ExportThemeCommandTest.php b/src/PrestaShopBundle/Tests/Command/ExportThemeCommandTest.php new file mode 100644 index 00000000000..9234b28e1d7 --- /dev/null +++ b/src/PrestaShopBundle/Tests/Command/ExportThemeCommandTest.php @@ -0,0 +1,140 @@ + +* @copyright 2007-2015 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +namespace PrestaShopBundle\Tests\Command; + +use PrestaShopBundle\Command\ExportThemeCommand; +use Symfony\Component\Console\Tester\CommandTester; + +class ExportThemeCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testExecute() + { + $command = new ExportThemeCommand(); + $commandTester = new CommandTester($command); + + $containerMock = $this->mockContainer(); + $command->setContainer($containerMock); + + $helperSetMock = $this->mockHelperSet(); + $command->setHelperSet($helperSetMock); + + $this->assertEquals(0, $commandTester->execute(array('theme' => 'classic'))); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function mockThemeRepository() + { + $themeMock = $this->getMockBuilder('\PrestaShop\PrestaShop\Core\Addon\Theme\Theme') + ->disableOriginalConstructor() + ->getMock(); + + $themeRepositoryMock = $this->getMockBuilder('\PrestaShop\PrestaShop\Core\Addon\Theme\ThemeRepository') + ->disableOriginalConstructor() + ->getMock(); + + $themeRepositoryMock->method('getInstanceByName') + ->willReturn($themeMock); + + return $themeRepositoryMock; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function mockTranslator() + { + $translatorMock = $this->getMockBuilder('\Symfony\Component\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + return $translatorMock; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function mockThemeExporter() + { + $themeExporterMock = $this->getMockBuilder('\PrestaShop\PrestaShop\Core\Addon\Theme\ThemeExporter') + ->disableOriginalConstructor() + ->getMock(); + + return $themeExporterMock; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function mockContainer() + { + $containerMock = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') + ->disableOriginalConstructor() + ->getMock(); + + $themeRepositoryMock = $this->mockThemeRepository(); + $translatorMock = $this->mockTranslator(); + $themeExporterMock = $this->mockThemeExporter(); + + $containerMock->method('get') + ->will($this->returnCallback(function ($serviceId) use ( + $themeRepositoryMock, + $translatorMock, + $themeExporterMock + ) { + $services = array( + 'prestashop.core.addon.theme.repository' => $themeRepositoryMock, + 'translator' => $translatorMock, + 'prestashop.core.addon.theme.exporter' => $themeExporterMock + ); + + return $services[$serviceId]; + })); + + return $containerMock; + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function mockHelperSet() + { + $helperSetMock = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperSet') + ->disableOriginalConstructor() + ->getMock(); + + $formatterHelperMock = $this->getMockBuilder('\Symfony\Component\Console\Helper\FormatterHelper') + ->disableOriginalConstructor() + ->getMock(); + + $helperSetMock->method('get') + ->with('formatter') + ->willReturn($formatterHelperMock); + return $helperSetMock; + } +} diff --git a/src/PrestaShopBundle/Translation/Exporter/ThemeExporter.php b/src/PrestaShopBundle/Translation/Exporter/ThemeExporter.php index 9975d7a5bf4..c239b427d7a 100644 --- a/src/PrestaShopBundle/Translation/Exporter/ThemeExporter.php +++ b/src/PrestaShopBundle/Translation/Exporter/ThemeExporter.php @@ -80,8 +80,23 @@ class ThemeExporter * @return string */ public function createZipArchive($themeName, $locale) + { + $archiveParentDirectory = $this->exportCatalogues($themeName, $locale); + $zipFilename = $this->makeZipFilename($themeName, $locale); + $this->zipManager->createArchive($zipFilename, $archiveParentDirectory); + + return $zipFilename; + } + + /** + * @param $themeName + * @param $locale + * @return string + */ + public function exportCatalogues($themeName, $locale) { $this->themeProvider->setLocale($locale); + $this->themeProvider->setThemeName($themeName); $mergedTranslations = $this->getCatalogueExtractedFromTemplates($themeName, $locale); try { @@ -110,10 +125,7 @@ class ThemeExporter $this->renameCatalogues($locale, $archiveParentDirectory); - $zipFilename = $this->makeZipFilename($themeName, $locale); - $this->zipManager->createArchive($zipFilename, $archiveParentDirectory); - - return $zipFilename; + return $archiveParentDirectory; } /** @@ -126,6 +138,9 @@ class ThemeExporter $tmpFolderPath = $this->getTemporaryExtractionFolder($themeName); $folderPath = $this->getFlattenizationFolder($themeName); + $this->filesystem->remove($folderPath); + $this->filesystem->remove($tmpFolderPath); + $this->filesystem->mkdir($folderPath); $this->filesystem->mkdir($tmpFolderPath); @@ -153,7 +168,11 @@ class ThemeExporter $archiveParentDirectory, $parentDirectoryParts[count($parentDirectoryParts) - 1] . '.' . $locale . '.xlf' ); - $this->filesystem->rename($file->getPathname(), implode('/', $destinationFilenameParts)); + $destinationFilename = implode('/', $destinationFilenameParts); + if ($this->filesystem->exists($destinationFilename)) { + $this->filesystem->remove($destinationFilename); + } + $this->filesystem->rename($file->getPathname(), $destinationFilename); } $this->filesystem->remove($archiveParentDirectory . '/' . $locale); diff --git a/src/PrestaShopBundle/Translation/Extractor/ThemeExtractor.php b/src/PrestaShopBundle/Translation/Extractor/ThemeExtractor.php index e7a11f905a3..eeb9909e879 100644 --- a/src/PrestaShopBundle/Translation/Extractor/ThemeExtractor.php +++ b/src/PrestaShopBundle/Translation/Extractor/ThemeExtractor.php @@ -69,7 +69,10 @@ class ThemeExtractor // remove the last "/" $themeDirectory = substr($theme->getDirectory(), 0, -1); - $options = array('path' => $themeDirectory); + $options = array( + 'path' => $themeDirectory, + 'default_locale' => $locale, + ); $this->smartyExtractor->extract($themeDirectory, $this->catalog); if ($this->overrideFromDatabase) { -- GitLab From 90db9fa11df74c9ea74adaca346e164732d0ec76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Bilo=C3=A9?= Date: Mon, 24 Oct 2016 16:32:42 +0200 Subject: [PATCH 010/117] BO: Do not submit product form on combination generation --- admin-dev/themes/new-theme/js/product-page/combination.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin-dev/themes/new-theme/js/product-page/combination.js b/admin-dev/themes/new-theme/js/product-page/combination.js index 451419d1c8c..d0d1aec718a 100644 --- a/admin-dev/themes/new-theme/js/product-page/combination.js +++ b/admin-dev/themes/new-theme/js/product-page/combination.js @@ -19,7 +19,8 @@ export default function() { if (idsProductAttribute[0] != '') { getCombinations(response); } - $('#create-combinations').click(function() { + $('#create-combinations').click(function(event) { + event.preventDefault(); generate(); }); }); -- GitLab From 861394041975e34bfaf57071991efca1a31c16c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Bilo=C3=A9?= Date: Mon, 24 Oct 2016 16:34:16 +0200 Subject: [PATCH 011/117] BO: Update new theme assets --- admin-dev/themes/new-theme/public/bundle.js | 75 ++++++++++----------- admin-dev/themes/new-theme/public/theme.css | 6 +- 2 files changed, 37 insertions(+), 44 deletions(-) diff --git a/admin-dev/themes/new-theme/public/bundle.js b/admin-dev/themes/new-theme/public/bundle.js index 9bf9a431ca8..4d6bd1f00ca 100644 --- a/admin-dev/themes/new-theme/public/bundle.js +++ b/admin-dev/themes/new-theme/public/bundle.js @@ -1,41 +1,34 @@ -!function(e){function t(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return e[i].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){n(1),n(3),n(7),n(8),n(20),n(21),n(125),n(210),n(211),n(212),n(213),n(216),n(21),n(217),n(218),n(219),n(220),n(221),n(222),n(223),n(224),e.exports=n(225)},function(e,t,n){(function(t){e.exports=t.Tether=n(2)}).call(t,function(){return this}())},function(e,t,n){var i,s;!function(a,r){i=r,s="function"==typeof i?i.call(t,n,t,e):i,!(void 0!==s&&(e.exports=s))}(this,function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e){var t=e.getBoundingClientRect(),n={};for(var i in t)n[i]=t[i];if(e.ownerDocument!==document){var a=e.ownerDocument.defaultView.frameElement;if(a){var r=s(a);n.top+=r.top,n.bottom+=r.top,n.left+=r.left,n.right+=r.left}}return n}function a(e){var t=getComputedStyle(e)||{},n=t.position,i=[];if("fixed"===n)return[e];for(var s=e;(s=s.parentNode)&&s&&1===s.nodeType;){var a=void 0;try{a=getComputedStyle(s)}catch(r){}if("undefined"==typeof a||null===a)return i.push(s),i;var o=a,l=o.overflow,d=o.overflowX,u=o.overflowY;/(auto|scroll)/.test(l+u+d)&&("absolute"!==n||["relative","absolute","fixed"].indexOf(a.position)>=0)&&i.push(s)}return i.push(e.ownerDocument.body),e.ownerDocument!==document&&i.push(e.ownerDocument.defaultView),i}function r(){Y&&document.body.removeChild(Y),Y=null}function o(e){var t=void 0;e===document?(t=document,e=document.documentElement):t=e.ownerDocument;var n=t.documentElement,i=s(e),a=x();return i.top-=a.top,i.left-=a.left,"undefined"==typeof i.width&&(i.width=document.body.scrollWidth-i.left-i.right),"undefined"==typeof i.height&&(i.height=document.body.scrollHeight-i.top-i.bottom),i.top=i.top-n.clientTop,i.left=i.left-n.clientLeft,i.right=t.body.clientWidth-i.width-i.left,i.bottom=t.body.clientHeight-i.height-i.top,i}function l(e){return e.offsetParent||document.documentElement}function d(){var e=document.createElement("div");e.style.width="100%",e.style.height="200px";var t=document.createElement("div");u(t.style,{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",width:"200px",height:"150px",overflow:"hidden"}),t.appendChild(e),document.body.appendChild(t);var n=e.offsetWidth;t.style.overflow="scroll";var i=e.offsetWidth;n===i&&(i=t.clientWidth),document.body.removeChild(t);var s=n-i;return{width:s,height:s}}function u(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=[];return Array.prototype.push.apply(t,arguments),t.slice(1).forEach(function(t){if(t)for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}),e}function c(e,t){if("undefined"!=typeof e.classList)t.split(" ").forEach(function(t){t.trim()&&e.classList.remove(t)});else{var n=new RegExp("(^| )"+t.split(" ").join("|")+"( |$)","gi"),i=_(e).replace(n," ");m(e,i)}}function h(e,t){if("undefined"!=typeof e.classList)t.split(" ").forEach(function(t){t.trim()&&e.classList.add(t)});else{c(e,t);var n=_(e)+(" "+t);m(e,n)}}function p(e,t){if("undefined"!=typeof e.classList)return e.classList.contains(t);var n=_(e);return new RegExp("(^| )"+t+"( |$)","gi").test(n)}function _(e){return e.className instanceof e.ownerDocument.defaultView.SVGAnimatedString?e.className.baseVal:e.className}function m(e,t){e.setAttribute("class",t)}function f(e,t,n){n.forEach(function(n){t.indexOf(n)===-1&&p(e,n)&&c(e,n)}),t.forEach(function(t){p(e,t)||h(e,t)})}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function y(e,t){var n=arguments.length<=2||void 0===arguments[2]?1:arguments[2];return e+n>=t&&t>=e-n}function v(){return"undefined"!=typeof performance&&"undefined"!=typeof performance.now?performance.now():+new Date}function M(){for(var e={top:0,left:0},t=arguments.length,n=Array(t),i=0;i1?n-1:0),s=1;s16?(t=Math.min(t-16,250),void(n=setTimeout(s,250))):void("undefined"!=typeof e&&v()-e<10||(null!=n&&(clearTimeout(n),n=null),e=v(),W(),t=v()-e))};"undefined"!=typeof window&&"undefined"!=typeof window.addEventListener&&["resize","scroll","touchmove"].forEach(function(e){window.addEventListener(e,i)})}();var F={center:"center",left:"right",right:"left"},z={middle:"middle",top:"bottom",bottom:"top"},N={top:0,left:0,middle:"50%",center:"50%",bottom:"100%",right:"100%"},$=function(e,t){var n=e.left,i=e.top;return"auto"===n&&(n=F[t.left]),"auto"===i&&(i=z[t.top]),{left:n,top:i}},R=function(e){var t=e.left,n=e.top;return"undefined"!=typeof N[e.left]&&(t=N[e.left]),"undefined"!=typeof N[e.top]&&(n=N[e.top]),{left:t,top:n}},q=function(e){var t=e.split(" "),n=j(t,2),i=n[0],s=n[1];return{top:i,left:s}},B=q,U=function(e){function t(e){var n=this;i(this,t),A(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),this.position=this.position.bind(this),O.push(this),this.history=[],this.setOptions(e,!1),w.modules.forEach(function(e){"undefined"!=typeof e.initialize&&e.initialize.call(n)}),this.position()}return g(t,e),k(t,[{key:"getClass",value:function(){var e=arguments.length<=0||void 0===arguments[0]?"":arguments[0],t=this.options.classes;return"undefined"!=typeof t&&t[e]?this.options.classes[e]:this.options.classPrefix?this.options.classPrefix+"-"+e:e}},{key:"setOptions",value:function(e){var t=this,n=arguments.length<=1||void 0===arguments[1]||arguments[1],i={offset:"0 0",targetOffset:"0 0",targetAttachment:"auto auto",classPrefix:"tether"};this.options=u(i,e);var s=this.options,r=s.element,o=s.target,l=s.targetModifier;if(this.element=r,this.target=o,this.targetModifier=l,"viewport"===this.target?(this.target=document.body,this.targetModifier="visible"):"scroll-handle"===this.target&&(this.target=document.body,this.targetModifier="scroll-handle"),["element","target"].forEach(function(e){if("undefined"==typeof t[e])throw new Error("Tether Error: Both element and target must be defined");"undefined"!=typeof t[e].jquery?t[e]=t[e][0]:"string"==typeof t[e]&&(t[e]=document.querySelector(t[e]))}),h(this.element,this.getClass("element")),this.options.addTargetClasses!==!1&&h(this.target,this.getClass("target")),!this.options.attachment)throw new Error("Tether Error: You must provide an attachment");this.targetAttachment=B(this.options.targetAttachment),this.attachment=B(this.options.attachment),this.offset=q(this.options.offset),this.targetOffset=q(this.options.targetOffset),"undefined"!=typeof this.scrollParents&&this.disable(),"scroll-handle"===this.targetModifier?this.scrollParents=[this.target]:this.scrollParents=a(this.target),this.options.enabled!==!1&&this.enable(n)}},{key:"getTargetBounds",value:function(){if("undefined"==typeof this.targetModifier)return o(this.target);if("visible"===this.targetModifier){if(this.target===document.body)return{top:pageYOffset,left:pageXOffset,height:innerHeight,width:innerWidth};var e=o(this.target),t={height:e.height,width:e.width,top:e.top,left:e.left};return t.height=Math.min(t.height,e.height-(pageYOffset-e.top)),t.height=Math.min(t.height,e.height-(e.top+e.height-(pageYOffset+innerHeight))),t.height=Math.min(innerHeight,t.height),t.height-=2,t.width=Math.min(t.width,e.width-(pageXOffset-e.left)),t.width=Math.min(t.width,e.width-(e.left+e.width-(pageXOffset+innerWidth))),t.width=Math.min(innerWidth,t.width),t.width-=2,t.topn.clientWidth||[i.overflow,i.overflowX].indexOf("scroll")>=0||this.target!==document.body,a=0;s&&(a=15);var r=e.height-parseFloat(i.borderTopWidth)-parseFloat(i.borderBottomWidth)-a,t={width:15,height:.975*r*(r/n.scrollHeight),left:e.left+e.width-parseFloat(i.borderLeftWidth)-15},l=0;r<408&&this.target===document.body&&(l=-11e-5*Math.pow(r,2)-.00727*r+22.58),this.target!==document.body&&(t.height=Math.max(t.height,24));var d=this.target.scrollTop/(n.scrollHeight-r);return t.top=d*(r-t.height-l)+e.top+parseFloat(i.borderTopWidth),this.target===document.body&&(t.height=Math.max(t.height,24)),t}}},{key:"clearCache",value:function(){this._cache={}}},{key:"cache",value:function(e,t){return"undefined"==typeof this._cache&&(this._cache={}),"undefined"==typeof this._cache[e]&&(this._cache[e]=t.call(this)),this._cache[e]}},{key:"enable",value:function(){var e=this,t=arguments.length<=0||void 0===arguments[0]||arguments[0];this.options.addTargetClasses!==!1&&h(this.target,this.getClass("enabled")),h(this.element,this.getClass("enabled")),this.enabled=!0,this.scrollParents.forEach(function(t){t!==e.target.ownerDocument&&t.addEventListener("scroll",e.position)}),t&&this.position()}},{key:"disable",value:function(){var e=this;c(this.target,this.getClass("enabled")),c(this.element,this.getClass("enabled")),this.enabled=!1,"undefined"!=typeof this.scrollParents&&this.scrollParents.forEach(function(t){t.removeEventListener("scroll",e.position)})}},{key:"destroy",value:function(){var e=this;this.disable(),O.forEach(function(t,n){t===e&&O.splice(n,1)}),0===O.length&&r()}},{key:"updateAttachClasses",value:function(e,t){var n=this;e=e||this.attachment,t=t||this.targetAttachment;var i=["left","top","bottom","right","middle","center"];"undefined"!=typeof this._addAttachClasses&&this._addAttachClasses.length&&this._addAttachClasses.splice(0,this._addAttachClasses.length),"undefined"==typeof this._addAttachClasses&&(this._addAttachClasses=[]);var s=this._addAttachClasses;e.top&&s.push(this.getClass("element-attached")+"-"+e.top),e.left&&s.push(this.getClass("element-attached")+"-"+e.left),t.top&&s.push(this.getClass("target-attached")+"-"+t.top),t.left&&s.push(this.getClass("target-attached")+"-"+t.left);var a=[];i.forEach(function(e){a.push(n.getClass("element-attached")+"-"+e),a.push(n.getClass("target-attached")+"-"+e)}),C(function(){"undefined"!=typeof n._addAttachClasses&&(f(n.element,n._addAttachClasses,a),n.options.addTargetClasses!==!1&&f(n.target,n._addAttachClasses,a),delete n._addAttachClasses)})}},{key:"position",value:function(){var e=this,t=arguments.length<=0||void 0===arguments[0]||arguments[0];if(this.enabled){this.clearCache();var n=$(this.targetAttachment,this.attachment);this.updateAttachClasses(this.attachment,n);var i=this.cache("element-bounds",function(){return o(e.element)}),s=i.width,a=i.height;if(0===s&&0===a&&"undefined"!=typeof this.lastSize){var r=this.lastSize;s=r.width,a=r.height}else this.lastSize={width:s,height:a};var u=this.cache("target-bounds",function(){return e.getTargetBounds()}),c=u,h=L(R(this.attachment),{width:s,height:a}),p=L(R(n),c),_=L(this.offset,{width:s,height:a}),m=L(this.targetOffset,c);h=M(h,_),p=M(p,m);for(var f=u.left+p.left-h.left,g=u.top+p.top-h.top,y=0;yD.innerWidth&&(T=this.cache("scrollbar-size",d),k.viewport.bottom-=T.height),Y.body.scrollHeight>D.innerHeight&&(T=this.cache("scrollbar-size",d),k.viewport.right-=T.width),["","static"].indexOf(Y.body.style.position)!==-1&&["","static"].indexOf(Y.body.parentElement.style.position)!==-1||(k.page.bottom=Y.body.scrollHeight-g-a,k.page.right=Y.body.scrollWidth-f-s),"undefined"!=typeof this.options.optimizations&&this.options.optimizations.moveElement!==!1&&"undefined"==typeof this.targetModifier&&!function(){var t=e.cache("target-offsetparent",function(){return l(e.target)}),n=e.cache("target-offsetparent-bounds",function(){return o(t)}),i=getComputedStyle(t),s=n,a={};if(["Top","Left","Bottom","Right"].forEach(function(e){a[e.toLowerCase()]=parseFloat(i["border"+e+"Width"])}),n.right=Y.body.scrollWidth-n.left-s.width+a.right,n.bottom=Y.body.scrollHeight-n.top-s.height+a.bottom,k.page.top>=n.top+a.top&&k.page.bottom>=n.bottom&&k.page.left>=n.left+a.left&&k.page.right>=n.right){var r=t.scrollTop,d=t.scrollLeft;k.offset={top:k.page.top-n.top+r-a.top,left:k.page.left-n.left+d-a.left}}}(),this.move(k),this.history.unshift(k),this.history.length>3&&this.history.pop(),t&&H(),!0}}},{key:"move",value:function(e){var t=this;if("undefined"!=typeof this.element.parentNode){var n={};for(var i in e){n[i]={};for(var s in e[i]){for(var a=!1,r=0;r=0){var _=o.split(" "),f=j(_,2);c=f[0],u=f[1]}else u=c=o;var v=b(t,a);"target"!==c&&"both"!==c||(nv[3]&&"bottom"===g.top&&(n-=h,g.top="top")),"together"===c&&("top"===g.top&&("bottom"===y.top&&nv[3]&&n-(r-h)>=v[1]&&(n-=r-h,g.top="bottom",y.top="bottom")),"bottom"===g.top&&("top"===y.top&&n+r>v[3]?(n-=h,g.top="top",n-=r,y.top="bottom"):"bottom"===y.top&&nv[3]&&"top"===y.top?(n-=r,y.top="bottom"):nv[2]&&"right"===g.left&&(i-=p,g.left="left")),"together"===u&&(iv[2]&&"right"===g.left?"left"===y.left?(i-=p,g.left="left",i-=l,y.left="right"):"right"===y.left&&(i-=p,g.left="left",i+=l,y.left="left"):"center"===g.left&&(i+l>v[2]&&"left"===y.left?(i-=l,y.left="right"):iv[3]&&"top"===y.top&&(n-=r,y.top="bottom")),"element"!==u&&"both"!==u||(iv[2]&&("left"===y.left?(i-=l,y.left="right"):"center"===y.left&&(i-=l/2,y.left="right"))),"string"==typeof d?d=d.split(",").map(function(e){return e.trim()}):d===!0&&(d=["top","left","right","bottom"]),d=d||[];var M=[],L=[];n=0?(n=v[1],M.push("top")):L.push("top")),n+r>v[3]&&(d.indexOf("bottom")>=0?(n=v[3]-r,M.push("bottom")):L.push("bottom")),i=0?(i=v[0],M.push("left")):L.push("left")),i+l>v[2]&&(d.indexOf("right")>=0?(i=v[2]-l,M.push("right")):L.push("right")),M.length&&!function(){var e=void 0;e="undefined"!=typeof t.options.pinnedClass?t.options.pinnedClass:t.getClass("pinned"),m.push(e),M.forEach(function(t){m.push(e+"-"+t)})}(),L.length&&!function(){var e=void 0;e="undefined"!=typeof t.options.outOfBoundsClass?t.options.outOfBoundsClass:t.getClass("out-of-bounds"),m.push(e),L.forEach(function(t){m.push(e+"-"+t)})}(),(M.indexOf("left")>=0||M.indexOf("right")>=0)&&(y.left=g.left=!1),(M.indexOf("top")>=0||M.indexOf("bottom")>=0)&&(y.top=g.top=!1),g.top===s.top&&g.left===s.left&&y.top===t.attachment.top&&y.left===t.attachment.left||(t.updateAttachClasses(y,g),t.trigger("update",{attachment:y,targetAttachment:g}))}),C(function(){t.options.addTargetClasses!==!1&&f(t.target,m,_),f(t.element,m,_)}),{top:n,left:i}}});var P=w.Utils,o=P.getBounds,f=P.updateClasses,C=P.defer;w.modules.push({position:function(e){var t=this,n=e.top,i=e.left,s=this.cache("element-bounds",function(){return o(t.element)}),a=s.height,r=s.width,l=this.getTargetBounds(),d=n+a,u=i+r,c=[];n<=l.bottom&&d>=l.top&&["left","right"].forEach(function(e){var t=l[e];t!==i&&t!==u||c.push(e)}),i<=l.right&&u>=l.left&&["top","bottom"].forEach(function(e){var t=l[e];t!==n&&t!==d||c.push(e)});var h=[],p=[],_=["left","top","right","bottom"];return h.push(this.getClass("abutted")),_.forEach(function(e){h.push(t.getClass("abutted")+"-"+e)}),c.length&&p.push(this.getClass("abutted")),c.forEach(function(e){p.push(t.getClass("abutted")+"-"+e)}),C(function(){t.options.addTargetClasses!==!1&&f(t.target,p,h),f(t.element,p,h)}),!0}});var j=function(){function e(e,t){var n=[],i=!0,s=!1,a=void 0;try{for(var r,o=e[Symbol.iterator]();!(i=(r=o.next()).done)&&(n.push(r.value),!t||n.length!==t);i=!0);}catch(l){s=!0,a=l}finally{try{!i&&o["return"]&&o["return"]()}finally{if(s)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();return w.modules.push({position:function(e){var t=e.top,n=e.left;if(this.options.shift){var i=this.options.shift;"function"==typeof this.options.shift&&(i=this.options.shift.call(this,{top:t,left:n}));var s=void 0,a=void 0;if("string"==typeof i){i=i.split(" "),i[1]=i[1]||i[0];var r=i,o=j(r,2);s=o[0],a=o[1],s=parseFloat(s,10),a=parseFloat(a,10)}else s=i.top,a=i.left;return t+=s,n+=a,{top:t,left:n}}}}),J})},function(e,t,n){(function(t){e.exports=t.jquery=n(4)}).call(t,function(){return this}())},function(e,t,n){(function(t){e.exports=t.jQuery=n(5)}).call(t,function(){return this}())},function(e,t,n){(function(t){e.exports=t.$=n(6)}).call(t,function(){return this}())},function(e,t,n){var i,s;!function(t,n){"object"==typeof e&&"object"==typeof e.exports?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:this,function(n,a){function r(e){var t=!!e&&"length"in e&&e.length,n=de.type(e);return"function"!==n&&!de.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function o(e,t,n){if(de.isFunction(t))return de.grep(e,function(e,i){return!!t.call(e,i,e)!==n});if(t.nodeType)return de.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(ve.test(t))return de.filter(t,e,n);t=de.filter(t,e)}return de.grep(e,function(e){return ie.call(t,e)>-1!==n})}function l(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function d(e){var t={};return de.each(e.match(Ye)||[],function(e,n){t[n]=!0}),t}function u(){Z.removeEventListener("DOMContentLoaded",u),n.removeEventListener("load",u),de.ready()}function c(){this.expando=de.expando+c.uid++}function h(e,t,n){var i;if(void 0===n&&1===e.nodeType)if(i="data-"+t.replace(Ee,"-$&").toLowerCase(),n=e.getAttribute(i),"string"==typeof n){try{n="true"===n||"false"!==n&&("null"===n?null:+n+""===n?+n:He.test(n)?de.parseJSON(n):n)}catch(s){}Ce.set(e,t,n)}else n=void 0;return n}function p(e,t,n,i){var s,a=1,r=20,o=i?function(){return i.cur()}:function(){return de.css(e,t,"")},l=o(),d=n&&n[3]||(de.cssNumber[t]?"":"px"),u=(de.cssNumber[t]||"px"!==d&&+l)&&Ae.exec(de.css(e,t));if(u&&u[3]!==d){d=d||u[3],n=n||[],u=+l||1;do a=a||".5",u/=a,de.style(e,t,u+d);while(a!==(a=o()/l)&&1!==a&&--r)}return n&&(u=+u||+l||0,s=n[1]?u+(n[1]+1)*n[2]:+n[2],i&&(i.unit=d,i.start=u,i.end=s)),s}function _(e,t){var n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[];return void 0===t||t&&de.nodeName(e,t)?de.merge([e],n):n}function m(e,t){for(var n=0,i=e.length;n-1)s&&s.push(a);else if(d=de.contains(a.ownerDocument,a),r=_(c.appendChild(a),"script"),d&&m(r),n)for(u=0;a=r[u++];)Fe.test(a.type||"")&&n.push(a);return c}function g(){return!0}function y(){return!1}function v(){try{return Z.activeElement}catch(e){}}function M(e,t,n,i,s,a){var r,o;if("object"==typeof t){"string"!=typeof n&&(i=i||n,n=void 0);for(o in t)M(e,o,n,i,t[o],a);return e}if(null==i&&null==s?(s=n,i=n=void 0):null==s&&("string"==typeof n?(s=i,i=void 0):(s=i,i=n,n=void 0)),s===!1)s=y;else if(!s)return e;return 1===a&&(r=s,s=function(e){return de().off(e),r.apply(this,arguments)},s.guid=r.guid||(r.guid=de.guid++)),e.each(function(){de.event.add(this,t,s,i,n)})}function L(e,t){return de.nodeName(e,"table")&&de.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function b(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function k(e){var t=Ve.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function w(e,t){var n,i,s,a,r,o,l,d;if(1===t.nodeType){if(Se.hasData(e)&&(a=Se.access(e),r=Se.set(t,a),d=a.events)){delete r.handle,r.events={};for(s in d)for(n=0,i=d[s].length;n1&&"string"==typeof p&&!oe.checkClone&&Je.test(p))return e.each(function(s){var a=e.eq(s);m&&(t[0]=p.call(this,s,a.html())),D(a,t,n,i)});if(c&&(s=f(t,e[0].ownerDocument,!1,e,i),a=s.firstChild,1===s.childNodes.length&&(s=a),a||i)){for(r=de.map(_(s,"script"),b),o=r.length;u")).appendTo(t.documentElement),t=Ke[0].contentDocument,t.write(),t.close(),n=x(e,t),Ke.detach()),Qe[e]=n),n}function C(e,t,n){var i,s,a,r,o=e.style;return n=n||et(e),r=n?n.getPropertyValue(t)||n[t]:void 0,""!==r&&void 0!==r||de.contains(e.ownerDocument,e)||(r=de.style(e,t)),n&&!oe.pixelMarginRight()&&Ze.test(r)&&Xe.test(t)&&(i=o.width,s=o.minWidth,a=o.maxWidth,o.minWidth=o.maxWidth=o.width=r,r=n.width,o.width=i,o.minWidth=s,o.maxWidth=a),void 0!==r?r+"":r}function H(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function E(e){if(e in ot)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=rt.length;n--;)if(e=rt[n]+t,e in ot)return e}function j(e,t,n){var i=Ae.exec(t);return i?Math.max(0,i[2]-(n||0))+(i[3]||"px"):t}function A(e,t,n,i,s){for(var a=n===(i?"border":"content")?4:"width"===t?1:0,r=0;a<4;a+=2)"margin"===n&&(r+=de.css(e,n+Pe[a],!0,s)),i?("content"===n&&(r-=de.css(e,"padding"+Pe[a],!0,s)),"margin"!==n&&(r-=de.css(e,"border"+Pe[a]+"Width",!0,s))):(r+=de.css(e,"padding"+Pe[a],!0,s),"padding"!==n&&(r+=de.css(e,"border"+Pe[a]+"Width",!0,s)));return r}function P(e,t,n){var i=!0,s="width"===t?e.offsetWidth:e.offsetHeight,a=et(e),r="border-box"===de.css(e,"boxSizing",!1,a);if(s<=0||null==s){if(s=C(e,t,a),(s<0||null==s)&&(s=e.style[t]),Ze.test(s))return s;i=r&&(oe.boxSizingReliable()||s===e.style[t]),s=parseFloat(s)||0}return s+A(e,t,n||(r?"border":"content"),i,a)+"px"}function I(e,t){for(var n,i,s,a=[],r=0,o=e.length;r=0&&n=0},isPlainObject:function(e){var t;if("object"!==de.type(e)||e.nodeType||de.isWindow(e))return!1;if(e.constructor&&!re.call(e,"constructor")&&!re.call(e.constructor.prototype||{},"isPrototypeOf"))return!1;for(t in e);return void 0===t||re.call(e,t)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?se[ae.call(e)]||"object":typeof e},globalEval:function(e){var t,n=eval;e=de.trim(e),e&&(1===e.indexOf("use strict")?(t=Z.createElement("script"),t.text=e,Z.head.appendChild(t).parentNode.removeChild(t)):n(e))},camelCase:function(e){return e.replace(ce,"ms-").replace(he,pe)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t){var n,i=0;if(r(e))for(n=e.length;ib.cacheLength&&delete e[t.shift()],e[n+" "]=i}var t=[];return e}function i(e){return e[F]=!0,e}function s(e){var t=E.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function a(e,t){for(var n=e.split("|"),i=n.length;i--;)b.attrHandle[n[i]]=t}function r(e,t){var n=t&&e,i=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||J)-(~e.sourceIndex||J);if(i)return i;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function o(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function l(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function d(e){return i(function(t){return t=+t,i(function(n,i){for(var s,a=e([],n.length,t),r=a.length;r--;)n[s=a[r]]&&(n[s]=!(i[s]=n[s]))})})}function u(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function c(){}function h(e){for(var t=0,n=e.length,i="";t1?function(t,n,i){for(var s=e.length;s--;)if(!e[s](t,n,i))return!1;return!0}:e[0]}function m(e,n,i){for(var s=0,a=n.length;s-1&&(i[d]=!(r[d]=c))}}else v=f(v===r?v.splice(_,v.length):v),a?a(null,r,v,l):X.apply(r,v)})}function y(e){for(var t,n,i,s=e.length,a=b.relative[e[0].type],r=a||b.relative[" "],o=a?1:0,l=p(function(e){return e===t},r,!0),d=p(function(e){return ee(t,e)>-1},r,!0),u=[function(e,n,i){var s=!a&&(i||n!==x)||((t=n).nodeType?l(e,n,i):d(e,n,i));return t=null,s}];o1&&_(u),o>1&&h(e.slice(0,o-1).concat({value:" "===e[o-2].type?"*":""})).replace(oe,"$1"),n,o0,a=e.length>0,r=function(i,r,o,l,d){var u,c,h,p=0,_="0",m=i&&[],g=[],y=x,v=i||a&&b.find.TAG("*",d),M=N+=null==y?1:Math.random()||.1,L=v.length;for(d&&(x=r===E||r||d);_!==L&&null!=(u=v[_]);_++){if(a&&u){for(c=0,r||u.ownerDocument===E||(H(u),o=!A);h=e[c++];)if(h(u,r||E,o)){l.push(u);break}d&&(N=M)}s&&((u=!h&&u)&&p--,i&&m.push(u))}if(p+=_,s&&_!==p){for(c=0;h=n[c++];)h(m,g,r,o);if(i){if(p>0)for(;_--;)m[_]||g[_]||(g[_]=K.call(l));g=f(g)}X.apply(l,g),d&&!i&&g.length>0&&p+n.length>1&&t.uniqueSort(l)}return d&&(N=M,x=y),m};return s?i(r):r}var M,L,b,k,w,Y,D,T,x,S,C,H,E,j,A,P,I,O,W,F="sizzle"+1*new Date,z=e.document,N=0,$=0,R=n(),q=n(),B=n(),U=function(e,t){return e===t&&(C=!0),0},J=1<<31,V={}.hasOwnProperty,G=[],K=G.pop,Q=G.push,X=G.push,Z=G.slice,ee=function(e,t){for(var n=0,i=e.length;n+~]|"+ne+")"+ne+"*"),ue=new RegExp("="+ne+"*([^\\]'\"]*?)"+ne+"*\\]","g"),ce=new RegExp(ae),he=new RegExp("^"+ie+"$"),pe={ID:new RegExp("^#("+ie+")"),CLASS:new RegExp("^\\.("+ie+")"),TAG:new RegExp("^("+ie+"|[*])"),ATTR:new RegExp("^"+se),PSEUDO:new RegExp("^"+ae),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ne+"*(even|odd|(([+-]|)(\\d*)n|)"+ne+"*(?:([+-]|)"+ne+"*(\\d+)|))"+ne+"*\\)|)","i"),bool:new RegExp("^(?:"+te+")$","i"),needsContext:new RegExp("^"+ne+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ne+"*((?:-\\d)?\\d*)"+ne+"*\\)|)(?=[^-]|$)","i")},_e=/^(?:input|select|textarea|button)$/i,me=/^h\d$/i,fe=/^[^{]+\{\s*\[native \w/,ge=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ye=/[+~]/,ve=/'|\\/g,Me=new RegExp("\\\\([\\da-f]{1,6}"+ne+"?|("+ne+")|.)","ig"),Le=function(e,t,n){var i="0x"+t-65536;return i!==i||n?t:i<0?String.fromCharCode(i+65536):String.fromCharCode(i>>10|55296,1023&i|56320)},be=function(){H()};try{X.apply(G=Z.call(z.childNodes),z.childNodes),G[z.childNodes.length].nodeType}catch(ke){X={apply:G.length?function(e,t){Q.apply(e,Z.call(t))}:function(e,t){for(var n=e.length,i=0;e[n++]=t[i++];);e.length=n-1}}}L=t.support={},w=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},H=t.setDocument=function(e){var t,n,i=e?e.ownerDocument||e:z;return i!==E&&9===i.nodeType&&i.documentElement?(E=i,j=E.documentElement,A=!w(E),(n=E.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",be,!1):n.attachEvent&&n.attachEvent("onunload",be)),L.attributes=s(function(e){return e.className="i",!e.getAttribute("className")}),L.getElementsByTagName=s(function(e){return e.appendChild(E.createComment("")),!e.getElementsByTagName("*").length}),L.getElementsByClassName=fe.test(E.getElementsByClassName),L.getById=s(function(e){return j.appendChild(e).id=F,!E.getElementsByName||!E.getElementsByName(F).length}),L.getById?(b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&A){var n=t.getElementById(e);return n?[n]:[]}},b.filter.ID=function(e){var t=e.replace(Me,Le);return function(e){return e.getAttribute("id")===t}}):(delete b.find.ID,b.filter.ID=function(e){var t=e.replace(Me,Le);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}}),b.find.TAG=L.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):L.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,i=[],s=0,a=t.getElementsByTagName(e);if("*"===e){for(;n=a[s++];)1===n.nodeType&&i.push(n);return i}return a},b.find.CLASS=L.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&A)return t.getElementsByClassName(e)},I=[],P=[],(L.qsa=fe.test(E.querySelectorAll))&&(s(function(e){j.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&P.push("[*^$]="+ne+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||P.push("\\["+ne+"*(?:value|"+te+")"),e.querySelectorAll("[id~="+F+"-]").length||P.push("~="),e.querySelectorAll(":checked").length||P.push(":checked"),e.querySelectorAll("a#"+F+"+*").length||P.push(".#.+[+~]")}),s(function(e){var t=E.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&P.push("name"+ne+"*[*^$|!~]?="),e.querySelectorAll(":enabled").length||P.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),P.push(",.*:")})),(L.matchesSelector=fe.test(O=j.matches||j.webkitMatchesSelector||j.mozMatchesSelector||j.oMatchesSelector||j.msMatchesSelector))&&s(function(e){L.disconnectedMatch=O.call(e,"div"),O.call(e,"[s!='']:x"),I.push("!=",ae)}),P=P.length&&new RegExp(P.join("|")),I=I.length&&new RegExp(I.join("|")),t=fe.test(j.compareDocumentPosition),W=t||fe.test(j.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,i=t&&t.parentNode;return e===i||!(!i||1!==i.nodeType||!(n.contains?n.contains(i):e.compareDocumentPosition&&16&e.compareDocumentPosition(i)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},U=t?function(e,t){if(e===t)return C=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n?n:(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!L.sortDetached&&t.compareDocumentPosition(e)===n?e===E||e.ownerDocument===z&&W(z,e)?-1:t===E||t.ownerDocument===z&&W(z,t)?1:S?ee(S,e)-ee(S,t):0:4&n?-1:1)}:function(e,t){if(e===t)return C=!0,0;var n,i=0,s=e.parentNode,a=t.parentNode,o=[e],l=[t];if(!s||!a)return e===E?-1:t===E?1:s?-1:a?1:S?ee(S,e)-ee(S,t):0;if(s===a)return r(e,t);for(n=e;n=n.parentNode;)o.unshift(n);for(n=t;n=n.parentNode;)l.unshift(n);for(;o[i]===l[i];)i++;return i?r(o[i],l[i]):o[i]===z?-1:l[i]===z?1:0},E):E},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==E&&H(e),n=n.replace(ue,"='$1']"),L.matchesSelector&&A&&!B[n+" "]&&(!I||!I.test(n))&&(!P||!P.test(n)))try{var i=O.call(e,n);if(i||L.disconnectedMatch||e.document&&11!==e.document.nodeType)return i}catch(s){}return t(n,E,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==E&&H(e),W(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==E&&H(e);var n=b.attrHandle[t.toLowerCase()],i=n&&V.call(b.attrHandle,t.toLowerCase())?n(e,t,!A):void 0;return void 0!==i?i:L.attributes||!A?e.getAttribute(t):(i=e.getAttributeNode(t))&&i.specified?i.value:null},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],i=0,s=0;if(C=!L.detectDuplicates,S=!L.sortStable&&e.slice(0),e.sort(U),C){for(;t=e[s++];)t===e[s]&&(i=n.push(s));for(;i--;)e.splice(n[i],1)}return S=null,e},k=t.getText=function(e){var t,n="",i=0,s=e.nodeType;if(s){if(1===s||9===s||11===s){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=k(e)}else if(3===s||4===s)return e.nodeValue}else for(;t=e[i++];)n+=k(t);return n},b=t.selectors={cacheLength:50,createPseudo:i,match:pe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Me,Le),e[3]=(e[3]||e[4]||e[5]||"").replace(Me,Le),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return pe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&ce.test(n)&&(t=Y(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Me,Le).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=R[e+" "];return t||(t=new RegExp("(^|"+ne+")"+e+"("+ne+"|$)"))&&R(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,i){return function(s){var a=t.attr(s,e);return null==a?"!="===n:!n||(a+="","="===n?a===i:"!="===n?a!==i:"^="===n?i&&0===a.indexOf(i):"*="===n?i&&a.indexOf(i)>-1:"$="===n?i&&a.slice(-i.length)===i:"~="===n?(" "+a.replace(re," ")+" ").indexOf(i)>-1:"|="===n&&(a===i||a.slice(0,i.length+1)===i+"-"))}},CHILD:function(e,t,n,i,s){var a="nth"!==e.slice(0,3),r="last"!==e.slice(-4),o="of-type"===t;return 1===i&&0===s?function(e){return!!e.parentNode}:function(t,n,l){var d,u,c,h,p,_,m=a!==r?"nextSibling":"previousSibling",f=t.parentNode,g=o&&t.nodeName.toLowerCase(),y=!l&&!o,v=!1;if(f){if(a){for(;m;){for(h=t;h=h[m];)if(o?h.nodeName.toLowerCase()===g:1===h.nodeType)return!1;_=m="only"===e&&!_&&"nextSibling"}return!0}if(_=[r?f.firstChild:f.lastChild],r&&y){for(h=f,c=h[F]||(h[F]={}),u=c[h.uniqueID]||(c[h.uniqueID]={}),d=u[e]||[],p=d[0]===N&&d[1],v=p&&d[2],h=p&&f.childNodes[p];h=++p&&h&&h[m]||(v=p=0)||_.pop();)if(1===h.nodeType&&++v&&h===t){u[e]=[N,p,v];break}}else if(y&&(h=t,c=h[F]||(h[F]={}),u=c[h.uniqueID]||(c[h.uniqueID]={}),d=u[e]||[],p=d[0]===N&&d[1],v=p),v===!1)for(;(h=++p&&h&&h[m]||(v=p=0)||_.pop())&&((o?h.nodeName.toLowerCase()!==g:1!==h.nodeType)||!++v||(y&&(c=h[F]||(h[F]={}),u=c[h.uniqueID]||(c[h.uniqueID]={}),u[e]=[N,v]),h!==t)););return v-=s,v===i||v%i===0&&v/i>=0}}},PSEUDO:function(e,n){var s,a=b.pseudos[e]||b.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return a[F]?a(n):a.length>1?(s=[e,e,"",n],b.setFilters.hasOwnProperty(e.toLowerCase())?i(function(e,t){for(var i,s=a(e,n),r=s.length;r--;)i=ee(e,s[r]),e[i]=!(t[i]=s[r])}):function(e){return a(e,0,s)}):a}},pseudos:{not:i(function(e){var t=[],n=[],s=D(e.replace(oe,"$1"));return s[F]?i(function(e,t,n,i){for(var a,r=s(e,null,i,[]),o=e.length;o--;)(a=r[o])&&(e[o]=!(t[o]=a))}):function(e,i,a){return t[0]=e,s(t,null,a,n),t[0]=null,!n.pop()}}),has:i(function(e){return function(n){return t(e,n).length>0}}),contains:i(function(e){return e=e.replace(Me,Le),function(t){return(t.textContent||t.innerText||k(t)).indexOf(e)>-1}}),lang:i(function(e){return he.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(Me,Le).toLowerCase(),function(t){var n;do if(n=A?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===j},focus:function(e){return e===E.activeElement&&(!E.hasFocus||E.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!b.pseudos.empty(e)},header:function(e){return me.test(e.nodeName)},input:function(e){return _e.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:d(function(){return[0]}),last:d(function(e,t){return[t-1]}),eq:d(function(e,t,n){return[n<0?n+t:n]}),even:d(function(e,t){for(var n=0;n=0;)e.push(i);return e}),gt:d(function(e,t,n){for(var i=n<0?n+t:n;++i2&&"ID"===(r=a[0]).type&&L.getById&&9===t.nodeType&&A&&b.relative[a[1].type]){if(t=(b.find.ID(r.matches[0].replace(Me,Le),t)||[])[0],!t)return n;d&&(t=t.parentNode),e=e.slice(a.shift().value.length)}for(s=pe.needsContext.test(e)?0:a.length;s--&&(r=a[s],!b.relative[o=r.type]);)if((l=b.find[o])&&(i=l(r.matches[0].replace(Me,Le),ye.test(a[0].type)&&u(t.parentNode)||t))){if(a.splice(s,1),e=i.length&&h(a),!e)return X.apply(n,i),n;break}}return(d||D(e,c))(i,t,!A,n,!t||ye.test(e)&&u(t.parentNode)||t),n},L.sortStable=F.split("").sort(U).join("")===F,L.detectDuplicates=!!C,H(),L.sortDetached=s(function(e){return 1&e.compareDocumentPosition(E.createElement("div"))}),s(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||a("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),L.attributes&&s(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||a("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),s(function(e){return null==e.getAttribute("disabled")})||a(te,function(e,t,n){var i;if(!n)return e[t]===!0?t.toLowerCase():(i=e.getAttributeNode(t))&&i.specified?i.value:null}),t}(n);de.find=_e,de.expr=_e.selectors,de.expr[":"]=de.expr.pseudos,de.uniqueSort=de.unique=_e.uniqueSort,de.text=_e.getText,de.isXMLDoc=_e.isXML,de.contains=_e.contains;var me=function(e,t,n){for(var i=[],s=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(s&&de(e).is(n))break;i.push(e)}return i},fe=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},ge=de.expr.match.needsContext,ye=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,ve=/^.[^:#\[\.,]*$/;de.filter=function(e,t,n){var i=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===i.nodeType?de.find.matchesSelector(i,e)?[i]:[]:de.find.matches(e,de.grep(t,function(e){return 1===e.nodeType}))},de.fn.extend({find:function(e){var t,n=this.length,i=[],s=this;if("string"!=typeof e)return this.pushStack(de(e).filter(function(){for(t=0;t1?de.unique(i):i),i.selector=this.selector?this.selector+" "+e:e,i},filter:function(e){return this.pushStack(o(this,e||[],!1))},not:function(e){return this.pushStack(o(this,e||[],!0))},is:function(e){return!!o(this,"string"==typeof e&&ge.test(e)?de(e):e||[],!1).length}});var Me,Le=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,be=de.fn.init=function(e,t,n){var i,s;if(!e)return this;if(n=n||Me,"string"==typeof e){if(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:Le.exec(e),!i||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof de?t[0]:t,de.merge(this,de.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:Z,!0)),ye.test(i[1])&&de.isPlainObject(t))for(i in t)de.isFunction(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return s=Z.getElementById(i[2]),s&&s.parentNode&&(this.length=1,this[0]=s),this.context=Z,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):de.isFunction(e)?void 0!==n.ready?n.ready(e):e(de):(void 0!==e.selector&&(this.selector=e.selector,this.context=e.context),de.makeArray(e,this))};be.prototype=de.fn,Me=de(Z);var ke=/^(?:parents|prev(?:Until|All))/,we={children:!0,contents:!0,next:!0,prev:!0};de.fn.extend({has:function(e){var t=de(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&de.find.matchesSelector(n,e))){a.push(n);break}return this.pushStack(a.length>1?de.uniqueSort(a):a)},index:function(e){return e?"string"==typeof e?ie.call(de(e),this[0]):ie.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(de.uniqueSort(de.merge(this.get(),de(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),de.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return me(e,"parentNode")},parentsUntil:function(e,t,n){return me(e,"parentNode",n)},next:function(e){return l(e,"nextSibling")},prev:function(e){return l(e,"previousSibling")},nextAll:function(e){return me(e,"nextSibling")},prevAll:function(e){return me(e,"previousSibling")},nextUntil:function(e,t,n){return me(e,"nextSibling",n)},prevUntil:function(e,t,n){return me(e,"previousSibling",n)},siblings:function(e){return fe((e.parentNode||{}).firstChild,e)},children:function(e){return fe(e.firstChild)},contents:function(e){return e.contentDocument||de.merge([],e.childNodes)}},function(e,t){de.fn[e]=function(n,i){var s=de.map(this,t,n);return"Until"!==e.slice(-5)&&(i=n),i&&"string"==typeof i&&(s=de.filter(i,s)),this.length>1&&(we[e]||de.uniqueSort(s),ke.test(e)&&s.reverse()),this.pushStack(s)}});var Ye=/\S+/g;de.Callbacks=function(e){e="string"==typeof e?d(e):de.extend({},e);var t,n,i,s,a=[],r=[],o=-1,l=function(){for(s=e.once,i=t=!0;r.length;o=-1)for(n=r.shift();++o-1;)a.splice(n,1),n<=o&&o--}),this},has:function(e){return e?de.inArray(e,a)>-1:a.length>0},empty:function(){return a&&(a=[]),this},disable:function(){return s=r=[],a=n="",this},disabled:function(){return!a},lock:function(){return s=r=[],n||(a=n=""),this},locked:function(){return!!s},fireWith:function(e,n){return s||(n=n||[],n=[e,n.slice?n.slice():n],r.push(n),t||l()),this},fire:function(){return u.fireWith(this,arguments),this},fired:function(){return!!i}};return u},de.extend({Deferred:function(e){var t=[["resolve","done",de.Callbacks("once memory"),"resolved"],["reject","fail",de.Callbacks("once memory"),"rejected"],["notify","progress",de.Callbacks("memory")]],n="pending",i={state:function(){return n},always:function(){return s.done(arguments).fail(arguments),this},then:function(){var e=arguments;return de.Deferred(function(n){de.each(t,function(t,a){var r=de.isFunction(e[t])&&e[t];s[a[1]](function(){var e=r&&r.apply(this,arguments);e&&de.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[a[0]+"With"](this===i?n.promise():this,r?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?de.extend(e,i):i}},s={};return i.pipe=i.then,de.each(t,function(e,a){var r=a[2],o=a[3];i[a[1]]=r.add,o&&r.add(function(){n=o},t[1^e][2].disable,t[2][2].lock),s[a[0]]=function(){return s[a[0]+"With"](this===s?i:this,arguments),this},s[a[0]+"With"]=r.fireWith}),i.promise(s),e&&e.call(s,s),s},when:function(e){var t,n,i,s=0,a=ee.call(arguments),r=a.length,o=1!==r||e&&de.isFunction(e.promise)?r:0,l=1===o?e:de.Deferred(),d=function(e,n,i){return function(s){n[e]=this,i[e]=arguments.length>1?ee.call(arguments):s,i===t?l.notifyWith(n,i):--o||l.resolveWith(n,i)}};if(r>1)for(t=new Array(r),n=new Array(r),i=new Array(r);s0||(De.resolveWith(Z,[de]),de.fn.triggerHandler&&(de(Z).triggerHandler("ready"),de(Z).off("ready"))))}}),de.ready.promise=function(e){return De||(De=de.Deferred(),"complete"===Z.readyState||"loading"!==Z.readyState&&!Z.documentElement.doScroll?n.setTimeout(de.ready):(Z.addEventListener("DOMContentLoaded",u),n.addEventListener("load",u))),De.promise(e)},de.ready.promise();var Te=function(e,t,n,i,s,a,r){var o=0,l=e.length,d=null==n;if("object"===de.type(n)){s=!0;for(o in n)Te(e,t,o,n[o],!0,a,r)}else if(void 0!==i&&(s=!0,de.isFunction(i)||(r=!0),d&&(r?(t.call(e,i),t=null):(d=t,t=function(e,t,n){return d.call(de(e),n)})),t))for(;o-1&&void 0!==n&&Ce.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){Ce.remove(this,e)})}}),de.extend({queue:function(e,t,n){var i;if(e)return t=(t||"fx")+"queue",i=Se.get(e,t),n&&(!i||de.isArray(n)?i=Se.access(e,t,de.makeArray(n)):i.push(n)),i||[]},dequeue:function(e,t){t=t||"fx";var n=de.queue(e,t),i=n.length,s=n.shift(),a=de._queueHooks(e,t),r=function(){de.dequeue(e,t)};"inprogress"===s&&(s=n.shift(),i--),s&&("fx"===t&&n.unshift("inprogress"),delete a.stop,s.call(e,r,a)),!i&&a&&a.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Se.get(e,n)||Se.access(e,n,{empty:de.Callbacks("once memory").add(function(){Se.remove(e,[t+"queue",n])})})}}),de.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length",""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ze.optgroup=ze.option,ze.tbody=ze.tfoot=ze.colgroup=ze.caption=ze.thead,ze.th=ze.td;var Ne=/<|&#?\w+;/;!function(){var e=Z.createDocumentFragment(),t=e.appendChild(Z.createElement("div")),n=Z.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),oe.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="",oe.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var $e=/^key/,Re=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,qe=/^([^.]*)(?:\.(.+)|)/;de.event={global:{},add:function(e,t,n,i,s){var a,r,o,l,d,u,c,h,p,_,m,f=Se.get(e);if(f)for(n.handler&&(a=n,n=a.handler,s=a.selector),n.guid||(n.guid=de.guid++),(l=f.events)||(l=f.events={}),(r=f.handle)||(r=f.handle=function(t){return"undefined"!=typeof de&&de.event.triggered!==t.type?de.event.dispatch.apply(e,arguments):void 0}),t=(t||"").match(Ye)||[""],d=t.length;d--;)o=qe.exec(t[d])||[],p=m=o[1],_=(o[2]||"").split(".").sort(),p&&(c=de.event.special[p]||{},p=(s?c.delegateType:c.bindType)||p,c=de.event.special[p]||{},u=de.extend({type:p,origType:m,data:i,handler:n,guid:n.guid,selector:s,needsContext:s&&de.expr.match.needsContext.test(s),namespace:_.join(".")},a),(h=l[p])||(h=l[p]=[],h.delegateCount=0,c.setup&&c.setup.call(e,i,_,r)!==!1||e.addEventListener&&e.addEventListener(p,r)),c.add&&(c.add.call(e,u),u.handler.guid||(u.handler.guid=n.guid)),s?h.splice(h.delegateCount++,0,u):h.push(u),de.event.global[p]=!0)},remove:function(e,t,n,i,s){var a,r,o,l,d,u,c,h,p,_,m,f=Se.hasData(e)&&Se.get(e);if(f&&(l=f.events)){for(t=(t||"").match(Ye)||[""],d=t.length;d--;)if(o=qe.exec(t[d])||[],p=m=o[1],_=(o[2]||"").split(".").sort(),p){for(c=de.event.special[p]||{},p=(i?c.delegateType:c.bindType)||p,h=l[p]||[],o=o[2]&&new RegExp("(^|\\.)"+_.join("\\.(?:.*\\.|)")+"(\\.|$)"),r=a=h.length;a--;)u=h[a],!s&&m!==u.origType||n&&n.guid!==u.guid||o&&!o.test(u.namespace)||i&&i!==u.selector&&("**"!==i||!u.selector)||(h.splice(a,1),u.selector&&h.delegateCount--,c.remove&&c.remove.call(e,u));r&&!h.length&&(c.teardown&&c.teardown.call(e,_,f.handle)!==!1||de.removeEvent(e,p,f.handle),delete l[p])}else for(p in l)de.event.remove(e,p+t[d],n,i,!0);de.isEmptyObject(l)&&Se.remove(e,"handle events")}},dispatch:function(e){e=de.event.fix(e);var t,n,i,s,a,r=[],o=ee.call(arguments),l=(Se.get(this,"events")||{})[e.type]||[],d=de.event.special[e.type]||{};if(o[0]=e,e.delegateTarget=this,!d.preDispatch||d.preDispatch.call(this,e)!==!1){for(r=de.event.handlers.call(this,e,l),t=0;(s=r[t++])&&!e.isPropagationStopped();)for(e.currentTarget=s.elem,n=0;(a=s.handlers[n++])&&!e.isImmediatePropagationStopped();)e.rnamespace&&!e.rnamespace.test(a.namespace)||(e.handleObj=a,e.data=a.data,i=((de.event.special[a.origType]||{}).handle||a.handler).apply(s.elem,o),void 0!==i&&(e.result=i)===!1&&(e.preventDefault(),e.stopPropagation()));return d.postDispatch&&d.postDispatch.call(this,e),e.result}},handlers:function(e,t){var n,i,s,a,r=[],o=t.delegateCount,l=e.target;if(o&&l.nodeType&&("click"!==e.type||isNaN(e.button)||e.button<1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(i=[],n=0;n-1:de.find(s,this,null,[l]).length),i[s]&&i.push(a);i.length&&r.push({elem:l,handlers:i})}return o]*)\/>/gi,Ue=/\s*$/g;de.extend({htmlPrefilter:function(e){return e.replace(Be,"<$1>")},clone:function(e,t,n){var i,s,a,r,o=e.cloneNode(!0),l=de.contains(e.ownerDocument,e);if(!(oe.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||de.isXMLDoc(e)))for(r=_(o),a=_(e),i=0,s=a.length;i0&&m(r,!l&&_(e,"script")),o},cleanData:function(e){for(var t,n,i,s=de.event.special,a=0;void 0!==(n=e[a]);a++)if(xe(n)){if(t=n[Se.expando]){if(t.events)for(i in t.events)s[i]?de.event.remove(n,i):de.removeEvent(n,i,t.handle);n[Se.expando]=void 0}n[Ce.expando]&&(n[Ce.expando]=void 0)}}}),de.fn.extend({domManip:D,detach:function(e){return T(this,e,!0)},remove:function(e){return T(this,e)},text:function(e){return Te(this,function(e){return void 0===e?de.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return D(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=L(this,e);t.appendChild(e)}})},prepend:function(){return D(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=L(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return D(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return D(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(de.cleanData(_(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return de.clone(this,e,t)})},html:function(e){return Te(this,function(e){var t=this[0]||{},n=0,i=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ue.test(e)&&!ze[(We.exec(e)||["",""])[1].toLowerCase()]){e=de.htmlPrefilter(e);try{for(;n1)},show:function(){return I(this,!0)},hide:function(){return I(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Ie(this)?de(this).show():de(this).hide()})}}),de.Tween=O,O.prototype={constructor:O,init:function(e,t,n,i,s,a){this.elem=e,this.prop=n,this.easing=s||de.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=i,this.unit=a||(de.cssNumber[n]?"":"px")},cur:function(){var e=O.propHooks[this.prop];return e&&e.get?e.get(this):O.propHooks._default.get(this)},run:function(e){var t,n=O.propHooks[this.prop];return this.options.duration?this.pos=t=de.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):O.propHooks._default.set(this),this}},O.prototype.init.prototype=O.prototype,O.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=de.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){de.fx.step[e.prop]?de.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[de.cssProps[e.prop]]&&!de.cssHooks[e.prop]?e.elem[e.prop]=e.now:de.style(e.elem,e.prop,e.now+e.unit)}}},O.propHooks.scrollTop=O.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},de.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},de.fx=O.prototype.init,de.fx.step={};var lt,dt,ut=/^(?:toggle|show|hide)$/,ct=/queueHooks$/;de.Animation=de.extend(R,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return p(n.elem,e,Ae.exec(t),n),n}]},tweener:function(e,t){de.isFunction(e)?(t=e,e=["*"]):e=e.match(Ye);for(var n,i=0,s=e.length;i1)},removeAttr:function(e){return this.each(function(){de.removeAttr(this,e)})}}),de.extend({attr:function(e,t,n){var i,s,a=e.nodeType;if(3!==a&&8!==a&&2!==a)return"undefined"==typeof e.getAttribute?de.prop(e,t,n):(1===a&&de.isXMLDoc(e)||(t=t.toLowerCase(),s=de.attrHooks[t]||(de.expr.match.bool.test(t)?ht:void 0)),void 0!==n?null===n?void de.removeAttr(e,t):s&&"set"in s&&void 0!==(i=s.set(e,n,t))?i:(e.setAttribute(t,n+""),n):s&&"get"in s&&null!==(i=s.get(e,t))?i:(i=de.find.attr(e,t),null==i?void 0:i))},attrHooks:{type:{set:function(e,t){if(!oe.radioValue&&"radio"===t&&de.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,i,s=0,a=t&&t.match(Ye);if(a&&1===e.nodeType)for(;n=a[s++];)i=de.propFix[n]||n,de.expr.match.bool.test(n)&&(e[i]=!1),e.removeAttribute(n)}}),ht={set:function(e,t,n){return t===!1?de.removeAttr(e,n):e.setAttribute(n,n),n}},de.each(de.expr.match.bool.source.match(/\w+/g),function(e,t){var n=pt[t]||de.find.attr;pt[t]=function(e,t,i){var s,a;return i||(a=pt[t],pt[t]=s,s=null!=n(e,t,i)?t.toLowerCase():null,pt[t]=a),s}});var _t=/^(?:input|select|textarea|button)$/i,mt=/^(?:a|area)$/i;de.fn.extend({prop:function(e,t){return Te(this,de.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[de.propFix[e]||e]})}}),de.extend({prop:function(e,t,n){var i,s,a=e.nodeType;if(3!==a&&8!==a&&2!==a)return 1===a&&de.isXMLDoc(e)||(t=de.propFix[t]||t,s=de.propHooks[t]),void 0!==n?s&&"set"in s&&void 0!==(i=s.set(e,n,t))?i:e[t]=n:s&&"get"in s&&null!==(i=s.get(e,t))?i:e[t]},propHooks:{tabIndex:{get:function(e){var t=de.find.attr(e,"tabindex");return t?parseInt(t,10):_t.test(e.nodeName)||mt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),oe.optSelected||(de.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),de.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){de.propFix[this.toLowerCase()]=this});var ft=/[\t\r\n\f]/g;de.fn.extend({addClass:function(e){var t,n,i,s,a,r,o,l=0;if(de.isFunction(e))return this.each(function(t){de(this).addClass(e.call(this,t,q(this)))});if("string"==typeof e&&e)for(t=e.match(Ye)||[];n=this[l++];)if(s=q(n),i=1===n.nodeType&&(" "+s+" ").replace(ft," ")){for(r=0;a=t[r++];)i.indexOf(" "+a+" ")<0&&(i+=a+" ");o=de.trim(i),s!==o&&n.setAttribute("class",o)}return this},removeClass:function(e){var t,n,i,s,a,r,o,l=0;if(de.isFunction(e))return this.each(function(t){de(this).removeClass(e.call(this,t,q(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof e&&e)for(t=e.match(Ye)||[];n=this[l++];)if(s=q(n),i=1===n.nodeType&&(" "+s+" ").replace(ft," ")){for(r=0;a=t[r++];)for(;i.indexOf(" "+a+" ")>-1;)i=i.replace(" "+a+" "," ");o=de.trim(i),s!==o&&n.setAttribute("class",o)}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):de.isFunction(e)?this.each(function(n){de(this).toggleClass(e.call(this,n,q(this),t),t)}):this.each(function(){var t,i,s,a;if("string"===n)for(i=0,s=de(this),a=e.match(Ye)||[];t=a[i++];)s.hasClass(t)?s.removeClass(t):s.addClass(t);else void 0!==e&&"boolean"!==n||(t=q(this),t&&Se.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||e===!1?"":Se.get(this,"__className__")||""))})},hasClass:function(e){var t,n,i=0;for(t=" "+e+" ";n=this[i++];)if(1===n.nodeType&&(" "+q(n)+" ").replace(ft," ").indexOf(t)>-1)return!0;return!1}});var gt=/\r/g,yt=/[\x20\t\r\n\f]+/g;de.fn.extend({val:function(e){var t,n,i,s=this[0];{if(arguments.length)return i=de.isFunction(e),this.each(function(n){var s;1===this.nodeType&&(s=i?e.call(this,n,de(this).val()):e,null==s?s="":"number"==typeof s?s+="":de.isArray(s)&&(s=de.map(s,function(e){return null==e?"":e+""})),t=de.valHooks[this.type]||de.valHooks[this.nodeName.toLowerCase()],t&&"set"in t&&void 0!==t.set(this,s,"value")||(this.value=s))});if(s)return t=de.valHooks[s.type]||de.valHooks[s.nodeName.toLowerCase()],t&&"get"in t&&void 0!==(n=t.get(s,"value"))?n:(n=s.value,"string"==typeof n?n.replace(gt,""):null==n?"":n)}}}),de.extend({valHooks:{option:{get:function(e){var t=de.find.attr(e,"value");return null!=t?t:de.trim(de.text(e)).replace(yt," ")}},select:{get:function(e){for(var t,n,i=e.options,s=e.selectedIndex,a="select-one"===e.type||s<0,r=a?null:[],o=a?s+1:i.length,l=s<0?o:a?s:0;l-1)&&(n=!0);return n||(e.selectedIndex=-1),a}}}}),de.each(["radio","checkbox"],function(){de.valHooks[this]={set:function(e,t){if(de.isArray(t))return e.checked=de.inArray(de(e).val(),t)>-1}},oe.checkOn||(de.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var vt=/^(?:focusinfocus|focusoutblur)$/;de.extend(de.event,{trigger:function(e,t,i,s){var a,r,o,l,d,u,c,h=[i||Z],p=re.call(e,"type")?e.type:e,_=re.call(e,"namespace")?e.namespace.split("."):[];if(r=o=i=i||Z,3!==i.nodeType&&8!==i.nodeType&&!vt.test(p+de.event.triggered)&&(p.indexOf(".")>-1&&(_=p.split("."),p=_.shift(),_.sort()),d=p.indexOf(":")<0&&"on"+p,e=e[de.expando]?e:new de.Event(p,"object"==typeof e&&e),e.isTrigger=s?2:3,e.namespace=_.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+_.join("\\.(?:.*\\.|)")+"(\\.|$)"):null, -e.result=void 0,e.target||(e.target=i),t=null==t?[e]:de.makeArray(t,[e]),c=de.event.special[p]||{},s||!c.trigger||c.trigger.apply(i,t)!==!1)){if(!s&&!c.noBubble&&!de.isWindow(i)){for(l=c.delegateType||p,vt.test(l+p)||(r=r.parentNode);r;r=r.parentNode)h.push(r),o=r;o===(i.ownerDocument||Z)&&h.push(o.defaultView||o.parentWindow||n)}for(a=0;(r=h[a++])&&!e.isPropagationStopped();)e.type=a>1?l:c.bindType||p,u=(Se.get(r,"events")||{})[e.type]&&Se.get(r,"handle"),u&&u.apply(r,t),u=d&&r[d],u&&u.apply&&xe(r)&&(e.result=u.apply(r,t),e.result===!1&&e.preventDefault());return e.type=p,s||e.isDefaultPrevented()||c._default&&c._default.apply(h.pop(),t)!==!1||!xe(i)||d&&de.isFunction(i[p])&&!de.isWindow(i)&&(o=i[d],o&&(i[d]=null),de.event.triggered=p,i[p](),de.event.triggered=void 0,o&&(i[d]=o)),e.result}},simulate:function(e,t,n){var i=de.extend(new de.Event,n,{type:e,isSimulated:!0});de.event.trigger(i,null,t)}}),de.fn.extend({trigger:function(e,t){return this.each(function(){de.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return de.event.trigger(e,t,n,!0)}}),de.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){de.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),de.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),oe.focusin="onfocusin"in n,oe.focusin||de.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){de.event.simulate(t,e.target,de.event.fix(e))};de.event.special[t]={setup:function(){var i=this.ownerDocument||this,s=Se.access(i,t);s||i.addEventListener(e,n,!0),Se.access(i,t,(s||0)+1)},teardown:function(){var i=this.ownerDocument||this,s=Se.access(i,t)-1;s?Se.access(i,t,s):(i.removeEventListener(e,n,!0),Se.remove(i,t))}}});var Mt=n.location,Lt=de.now(),bt=/\?/;de.parseJSON=function(e){return JSON.parse(e+"")},de.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new n.DOMParser).parseFromString(e,"text/xml")}catch(i){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||de.error("Invalid XML: "+e),t};var kt=/#.*$/,wt=/([?&])_=[^&]*/,Yt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Dt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Tt=/^(?:GET|HEAD)$/,xt=/^\/\//,St={},Ct={},Ht="*/".concat("*"),Et=Z.createElement("a");Et.href=Mt.href,de.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Mt.href,type:"GET",isLocal:Dt.test(Mt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ht,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":de.parseJSON,"text xml":de.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?J(J(e,de.ajaxSettings),t):J(de.ajaxSettings,e)},ajaxPrefilter:B(St),ajaxTransport:B(Ct),ajax:function(e,t){function i(e,t,i,o){var d,c,y,v,L,k=t;2!==M&&(M=2,l&&n.clearTimeout(l),s=void 0,r=o||"",b.readyState=e>0?4:0,d=e>=200&&e<300||304===e,i&&(v=V(h,b,i)),v=G(h,v,b,d),d?(h.ifModified&&(L=b.getResponseHeader("Last-Modified"),L&&(de.lastModified[a]=L),L=b.getResponseHeader("etag"),L&&(de.etag[a]=L)),204===e||"HEAD"===h.type?k="nocontent":304===e?k="notmodified":(k=v.state,c=v.data,y=v.error,d=!y)):(y=k,!e&&k||(k="error",e<0&&(e=0))),b.status=e,b.statusText=(t||k)+"",d?m.resolveWith(p,[c,k,b]):m.rejectWith(p,[b,k,y]),b.statusCode(g),g=void 0,u&&_.trigger(d?"ajaxSuccess":"ajaxError",[b,h,d?c:y]),f.fireWith(p,[b,k]),u&&(_.trigger("ajaxComplete",[b,h]),--de.active||de.event.trigger("ajaxStop")))}"object"==typeof e&&(t=e,e=void 0),t=t||{};var s,a,r,o,l,d,u,c,h=de.ajaxSetup({},t),p=h.context||h,_=h.context&&(p.nodeType||p.jquery)?de(p):de.event,m=de.Deferred(),f=de.Callbacks("once memory"),g=h.statusCode||{},y={},v={},M=0,L="canceled",b={readyState:0,getResponseHeader:function(e){var t;if(2===M){if(!o)for(o={};t=Yt.exec(r);)o[t[1].toLowerCase()]=t[2];t=o[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===M?r:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return M||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return M||(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(M<2)for(t in e)g[t]=[g[t],e[t]];else b.always(e[b.status]);return this},abort:function(e){var t=e||L;return s&&s.abort(t),i(0,t),this}};if(m.promise(b).complete=f.add,b.success=b.done,b.error=b.fail,h.url=((e||h.url||Mt.href)+"").replace(kt,"").replace(xt,Mt.protocol+"//"),h.type=t.method||t.type||h.method||h.type,h.dataTypes=de.trim(h.dataType||"*").toLowerCase().match(Ye)||[""],null==h.crossDomain){d=Z.createElement("a");try{d.href=h.url,d.href=d.href,h.crossDomain=Et.protocol+"//"+Et.host!=d.protocol+"//"+d.host}catch(k){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=de.param(h.data,h.traditional)),U(St,h,t,b),2===M)return b;u=de.event&&h.global,u&&0===de.active++&&de.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Tt.test(h.type),a=h.url,h.hasContent||(h.data&&(a=h.url+=(bt.test(a)?"&":"?")+h.data,delete h.data),h.cache===!1&&(h.url=wt.test(a)?a.replace(wt,"$1_="+Lt++):a+(bt.test(a)?"&":"?")+"_="+Lt++)),h.ifModified&&(de.lastModified[a]&&b.setRequestHeader("If-Modified-Since",de.lastModified[a]),de.etag[a]&&b.setRequestHeader("If-None-Match",de.etag[a])),(h.data&&h.hasContent&&h.contentType!==!1||t.contentType)&&b.setRequestHeader("Content-Type",h.contentType),b.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+Ht+"; q=0.01":""):h.accepts["*"]);for(c in h.headers)b.setRequestHeader(c,h.headers[c]);if(h.beforeSend&&(h.beforeSend.call(p,b,h)===!1||2===M))return b.abort();L="abort";for(c in{success:1,error:1,complete:1})b[c](h[c]);if(s=U(Ct,h,t,b)){if(b.readyState=1,u&&_.trigger("ajaxSend",[b,h]),2===M)return b;h.async&&h.timeout>0&&(l=n.setTimeout(function(){b.abort("timeout")},h.timeout));try{M=1,s.send(y,i)}catch(k){if(!(M<2))throw k;i(-1,k)}}else i(-1,"No Transport");return b},getJSON:function(e,t,n){return de.get(e,t,n,"json")},getScript:function(e,t){return de.get(e,void 0,t,"script")}}),de.each(["get","post"],function(e,t){de[t]=function(e,n,i,s){return de.isFunction(n)&&(s=s||i,i=n,n=void 0),de.ajax(de.extend({url:e,type:t,dataType:s,data:n,success:i},de.isPlainObject(e)&&e))}}),de._evalUrl=function(e){return de.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},de.fn.extend({wrapAll:function(e){var t;return de.isFunction(e)?this.each(function(t){de(this).wrapAll(e.call(this,t))}):(this[0]&&(t=de(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this)},wrapInner:function(e){return de.isFunction(e)?this.each(function(t){de(this).wrapInner(e.call(this,t))}):this.each(function(){var t=de(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=de.isFunction(e);return this.each(function(n){de(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){de.nodeName(this,"body")||de(this).replaceWith(this.childNodes)}).end()}}),de.expr.filters.hidden=function(e){return!de.expr.filters.visible(e)},de.expr.filters.visible=function(e){return e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0};var jt=/%20/g,At=/\[\]$/,Pt=/\r?\n/g,It=/^(?:submit|button|image|reset|file)$/i,Ot=/^(?:input|select|textarea|keygen)/i;de.param=function(e,t){var n,i=[],s=function(e,t){t=de.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(void 0===t&&(t=de.ajaxSettings&&de.ajaxSettings.traditional),de.isArray(e)||e.jquery&&!de.isPlainObject(e))de.each(e,function(){s(this.name,this.value)});else for(n in e)K(n,e[n],t,s);return i.join("&").replace(jt,"+")},de.fn.extend({serialize:function(){return de.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=de.prop(this,"elements");return e?de.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!de(this).is(":disabled")&&Ot.test(this.nodeName)&&!It.test(e)&&(this.checked||!Oe.test(e))}).map(function(e,t){var n=de(this).val();return null==n?null:de.isArray(n)?de.map(n,function(e){return{name:t.name,value:e.replace(Pt,"\r\n")}}):{name:t.name,value:n.replace(Pt,"\r\n")}}).get()}}),de.ajaxSettings.xhr=function(){try{return new n.XMLHttpRequest}catch(e){}};var Wt={0:200,1223:204},Ft=de.ajaxSettings.xhr();oe.cors=!!Ft&&"withCredentials"in Ft,oe.ajax=Ft=!!Ft,de.ajaxTransport(function(e){var t,i;if(oe.cors||Ft&&!e.crossDomain)return{send:function(s,a){var r,o=e.xhr();if(o.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(r in e.xhrFields)o[r]=e.xhrFields[r];e.mimeType&&o.overrideMimeType&&o.overrideMimeType(e.mimeType),e.crossDomain||s["X-Requested-With"]||(s["X-Requested-With"]="XMLHttpRequest");for(r in s)o.setRequestHeader(r,s[r]);t=function(e){return function(){t&&(t=i=o.onload=o.onerror=o.onabort=o.onreadystatechange=null,"abort"===e?o.abort():"error"===e?"number"!=typeof o.status?a(0,"error"):a(o.status,o.statusText):a(Wt[o.status]||o.status,o.statusText,"text"!==(o.responseType||"text")||"string"!=typeof o.responseText?{binary:o.response}:{text:o.responseText},o.getAllResponseHeaders()))}},o.onload=t(),i=o.onerror=t("error"),void 0!==o.onabort?o.onabort=i:o.onreadystatechange=function(){4===o.readyState&&n.setTimeout(function(){t&&i()})},t=t("abort");try{o.send(e.hasContent&&e.data||null)}catch(l){if(t)throw l}},abort:function(){t&&t()}}}),de.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return de.globalEval(e),e}}}),de.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),de.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,s){t=de("