[-] MO : fixed bug #PSCFV-2270 - JS refacto module favorite products

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15151 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vAugagneur
2012-05-10 09:10:52 +00:00
parent 8f6c9671f5
commit 8cede91978
5 changed files with 108 additions and 78 deletions
+74
View File
@@ -0,0 +1,74 @@
$('document').ready(function(){
$('#favoriteproducts_block_extra_add').click(function(){
$.ajax({
url: favorite_products_url_add,
type: "POST",
data: {
"id_product": favorite_products_id_product
},
success: function(result){
if (result == '0')
{
$('#favoriteproducts_block_extra_add').slideUp(function() {
$('#favoriteproducts_block_extra_added').slideDown("slow");
});
}
}
});
});
$('#favoriteproducts_block_extra_remove').click(function(){
$.ajax({
url: favorite_products_url_remove,
type: "POST",
data: {
"id_product": favorite_products_id_product
},
success: function(result){
if (result == '0')
{
$('#favoriteproducts_block_extra_remove').slideUp(function() {
$('#favoriteproducts_block_extra_removed').slideDown("slow");
});
}
}
});
});
$('#favoriteproducts_block_extra_added').click(function(){
$.ajax({
url: favorite_products_url_remove,
type: "POST",
data: {
"id_product": favorite_products_id_product
},
success: function(result){
if (result == '0')
{
$('#favoriteproducts_block_extra_added').slideUp(function() {
$('#favoriteproducts_block_extra_removed').slideDown("slow");
});
}
}
});
});
$('#favoriteproducts_block_extra_removed').click(function(){
$.ajax({
url: favorite_products_url_add,
type: "POST",
data: {
"id_product": favorite_products_id_product
},
success: function(result){
if (result == '0')
{
$('#favoriteproducts_block_extra_removed').slideUp(function() {
$('#favoriteproducts_block_extra_added').slideDown("slow");
});
}
}
});
});
})
@@ -107,6 +107,8 @@ class FavoriteProducts extends Module
public function hookDisplayHeader($params)
{
$this->context->controller->addCSS($this->_path.'favoriteproducts.css', 'all');
$this->context->controller->addJS($this->_path.'favoriteproducts.js');
return $this->display(__FILE__, 'favoriteproducts-header.tpl');
}
}
@@ -24,83 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<script type="text/javascript">
$('document').ready(function(){
$('#favoriteproducts_block_extra_add').click(function(){
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'add'], true)}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
},
success: function(result){
if (result == '0')
{
$('#favoriteproducts_block_extra_add').slideUp(function() {
$('#favoriteproducts_block_extra_added').slideDown("slow");
});
}
}
});
});
$('#favoriteproducts_block_extra_remove').click(function(){
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'remove'], true)}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
},
success: function(result){
if (result == '0')
{
$('#favoriteproducts_block_extra_remove').slideUp(function() {
$('#favoriteproducts_block_extra_removed').slideDown("slow");
});
}
}
});
});
$('#favoriteproducts_block_extra_added').click(function(){
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'remove'], true)}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
},
success: function(result){
if (result == '0')
{
$('#favoriteproducts_block_extra_added').slideUp(function() {
$('#favoriteproducts_block_extra_removed').slideDown("slow");
});
}
}
});
});
$('#favoriteproducts_block_extra_removed').click(function(){
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'add'], true)}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
},
success: function(result){
if (result == '0')
{
$('#favoriteproducts_block_extra_removed').slideUp(function() {
$('#favoriteproducts_block_extra_added').slideDown("slow");
});
}
}
});
});
})
</script>
{if !$isCustomerFavoriteProduct AND $isLogged}
<li id="favoriteproducts_block_extra_add" class="add">
{l s='Add this product to my favorites' mod='favoriteproducts'}
@@ -0,0 +1,31 @@
{*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @version Release: $Revision: 14978 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<script type="text/javascript">
var favorite_products_url_add = '{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'add'], true)}';
var favorite_products_url_remove = '{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'remove'], true)}';
var favorite_products_id_product = '{$smarty.get.id_product}';
</script>
@@ -25,7 +25,7 @@
*}
<li class="favorite products">
<a href="{$link->getModuleLink('favorite products', 'account')}" title="{l s='My favorite products' mod='favorite products'}">
<a href="{$link->getModuleLink('favoriteproducts', 'account')}" title="{l s='My favorite products' mod='favorite products'}">
<img src="{$module_template_dir}img/favorites.png" class="icon" />
{l s='My favorite products' mod='favorite products'}
</a>