// refactor product attribute ajax actions

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13439 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2012-02-17 15:16:09 +00:00
parent 650aedd44a
commit f41fbf40a8
5 changed files with 19 additions and 73 deletions
@@ -1,28 +0,0 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 9197 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<a class="pointer default" onclick="javascript:defaultProductAttribute('{$id}', '{getAdminToken tab='AdminProducts'}', $(this).parent('td').parent('tr'));" title="{$action}" >
<img src="../img/admin/asterisk.gif" alt="{$action}" />
</a>
@@ -1,28 +0,0 @@
{*
* 2007-2011 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-2011 PrestaShop SA
* @version Release: $Revision: 9197 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<a class="pointer delete" onclick="javascript:deleteProductAttribute('{$id}', '{getAdminToken tab='AdminProducts'}', $(this).parent('td').parent('tr'));" title="{$action}" >
<img src="../img/admin/delete.gif" alt="{$action}" />
</a>
@@ -23,6 +23,6 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<a href="{$href}" title="{$action}">
<a href="{$href}" class="default" title="{$action}">
<img src="../img/admin/asterisk.gif" alt="{$action}" />
</a>
@@ -23,6 +23,6 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<a href="{$href}" {if isset($confirm)}onclick="return confirm('{$confirm}');"{/if} title="{$action}">
<a href="{$href}" class="delete" {if isset($confirm)}onclick="return confirm('{$confirm}');"{/if} title="{$action}">
<img src="../img/admin/delete.gif" alt="{$action}" />
</a>
+17 -15
View File
@@ -55,16 +55,12 @@ function addButtonCombination(item)
posC = true;
}
function deleteProductAttribute(ids, token, parent)
function deleteProductAttribute(url, parent)
{
var id = ids.split('||');
$.ajax({
url: 'index.php',
url: url,
data: {
id_product: id[0],
id_product_attribute: id[1],
controller: 'AdminProducts',
token: token,
id_product: id_product,
action: 'deleteProductAttribute',
ajax: true
},
@@ -76,7 +72,7 @@ function deleteProductAttribute(ids, token, parent)
if (data.status == 'ok')
{
showSuccessMessage(data.message);
parent.hide();
parent.remove();
}
else
showErrorMessage(data.message);
@@ -84,16 +80,12 @@ function deleteProductAttribute(ids, token, parent)
});
}
function defaultProductAttribute(ids, token, parent)
function defaultProductAttribute(url, parent)
{
var id = ids.split('||');
$.ajax({
url: 'index.php',
url: url,
data: {
id_product: id[0],
id_product_attribute: id[1],
controller: 'AdminProducts',
token: token,
id_product: id_product,
action: 'defaultProductAttribute',
ajax: true
},
@@ -449,5 +441,15 @@ $(document).ready(function() {
e.preventDefault();
editProductAttribute(this.href, $(this).closest('tr'));
});
$('table[name=list_table]').delegate('a.delete', 'click', function(e){
e.preventDefault();
deleteProductAttribute(this.href, $(this).closest('tr'));
});
$('table[name=list_table]').delegate('a.default', 'click', function(e){
e.preventDefault();
defaultProductAttribute(this.href, $(this).closest('tr'));
});
});
});