// Adding a new admin list action "details"

This commit is contained in:
mDeflotte
2011-10-17 15:19:25 +00:00
parent 5f77f314e0
commit ef0184a6fb
2 changed files with 132 additions and 21 deletions
@@ -0,0 +1,89 @@
{*
* 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$
* @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">
$(document).ready(function() {
$('#details_{$id}').click(function() {
if (typeof(this.dataMaped) == 'undefined') {
$.ajax({
url: 'index.php',
data: {
id : {$id},
controller: '{$controller}',
token: '{$token}',
action: '{$action}',
ajax: true
},
context: document.body,
dataType: 'json',
context: this,
async: false,
success: function(data) {
$.each(data.data, function(it, row)
{
//console.log(row);
if($('#details_{$id}').parent().parent().hasClass('alt_row'))
var content = $('<tr class="details_{$id} alt_row"></tr>');
else
var content = $('<tr class="details_{$id}"></tr>');
content.append($('<td></td>'));
$.each(data.fields_display, function(it, line)
{
if (typeof(row[it]) == 'undefined')
content.append($('<td class="'+this.align+'"></td>'));
else
content.append($('<td class="'+this.align+'">'+row[it]+'</td>'));
});
console.log($(this));
content.append($('<td></td>'));
$('#details_{$id}').parent().parent().after(content);
});
this.dataMaped = true;
this.opened = false;
}
});
}
if(this.opened)
{
console.log($(this).find('img'));
$(this).find('img').attr('src', '../img/admin/more.png');
$(this).parent().parent().parent().find('.details_{$id}').hide();
this.opened = false
}
else
{
$(this).find('img').attr('src', '../img/admin/less.png');
$(this).parent().parent().parent().find('.details_{$id}').show();
this.opened = true;
}
return false;
});
});
</script>
<a href="#" id="details_{$id}">
<img src="../img/admin/more.png" alt="{$action}" title="{$action}" />
</a>