{combine_script id='jquery.dataTables' load='footer' path='themes/default/js/plugins/jquery.dataTables.js'} {combine_css path="themes/default/js/plugins/datatables/css/jquery.dataTables.css"} {combine_css path=$MPS_PATH|@cat:"admin/template/style.css"} {combine_script id='jquery.ui.sortable' load='footer' path='themes/default/js/ui/minified/jquery.ui.sortable.min.js'} {combine_script id='jquery.chosen' load='footer' path='themes/default/js/plugins/chosen.jquery.min.js'} {combine_css path="themes/default/js/plugins/chosen.css"} {footer_script}{literal} (function($) { $(document).ready(function(){ var $oTable, $nEditing = null, $val = $('.val').html(), $add_opt = $('#add_option_prod').html(); $('#product_list input[type=checkbox]').each(function(){ $(this).prop('checked', false) }); $('#AddProd').click(function() { $('.add_content').css('top','100px') $('.Tadd').show(); $('#Add_product').fadeIn(); $('#showAddProd .infos').hide(); $('input[name=product]').focus(); return false; }); $('#close_Add_product').click(function() { $('#Add_product').fadeOut(function(){ $('#add_option_prod').hide(); $('.tit').hide(); $('#AddProdForm input[type=text]').attr('value',''); $('#AddProdForm textarea#noteAdmin').val(''); $('li.search-choice').remove(); $('select.chzn-select option').each(function(){ $(this).removeAttr('selected'); }) }); return false; }); $('#AddProdForm').submit(function(){ var $return = true; if($.trim($('input#product',this).val()).length==0 || $.trim($('input#price',this).val()).length==0){ $return = false; $('.errors').show(); setTimeout(function(){ $('.errors').hide() },3000); } return $return }) $('#permitAction input[type="submit"]').click(function() { if (!confirm("{/literal}{'Are you sure?'|translate|escape:javascript}{literal}")) { $('#product_list input[type=checkbox]').each(function(){ $(this).prop('checked', false); delet_button() }); } else { $('#formTab_prod').submit(); } return false; } ); $oTable = $('#product_list').dataTable({ "bAutoWidth": false, "bStateSave": true, "aoColumns" : [ { sWidth: '2%','sClass': 'center', 'bSortable': false}, { sWidth: '38%','sClass': 'product_row' }, { sWidth: '38%'}, { sWidth: '12%', 'bSortable': false, }, { sWidth: '8%', }, ], "oLanguage": { "sProcessing": "{/literal}{'Loading...'|translate|escape:'javascript'}{literal}", "sSearch": ''+"{/literal}{'Search'|translate|escape:'javascript'}{literal}", "sLengthMenu": "{/literal}{'Display _MENU_ records per page'|translate|escape:'javascript'}{literal}", "sInfo": "{/literal}{'Showing _START_ to _END_ of _TOTAL_ records'|translate|escape:'javascript'}{literal}", "sInfoEmpty": "{/literal}{'Showing 0 to 0 of 0 records'|translate|escape:'javascript'}{literal}", "sInfoFiltered": "{/literal}{'(filtered from _MAX_ total records)'|translate|escape:'javascript'}{literal}", "sInfoPostFix": "", "sLoadingRecords": "{/literal}{'Loading...'|translate|escape:'javascript'}{literal}", "sZeroRecords": "{/literal}{'No matching option found'|translate|escape:'javascript'}{literal}", "oPaginate": { "sFirst": "{/literal}{'First'|translate|escape:'javascript'}{literal}", "sPrevious": '← '+"{/literal}{'Previous'|translate|escape:'javascript'}{literal}", "sNext": "{/literal}{'Next'|translate|escape:'javascript'}{literal}"+' →', "sLast": "{/literal}{'Last'|translate|escape:'javascript'}{literal}", }, }, }); function _rempform($this){ var $nRow = $this.parents('tr')[0], $jqInputs = $('input', $nRow), $id = $jqInputs[0].value, $prod = $('#prodvar').data('product'), $product = $prod[$id].product, $Nadmin = $prod[$id].noteAdmin, $price = $prod[$id].price, $option = $prod[$id].option; for(key in $option) { $('.chzn-select option').each(function(){ if($(this).text()==$option[key]){ $(this).attr('selected','selected'); } }); } $('.chzn-select').trigger("chosen:updated"); $('input#product_id').attr('value',$id); $('input#product').attr('value',$product); $('textarea#noteAdmin').val($Nadmin); $('input#price').attr('value',$price); } $(document).on('click','#formTab_prod .prodEdit', function () { var $this = $(this), $pos = $(document).scrollTop(), $pos = $pos + 100; $('.add_content').css('top',$pos) $('.Tedit').show(); _rempform($this); $('#Add_product').fadeIn(); return false; }); $(document).on('click','#formTab_prod .prodDupli', function () { var $this = $(this); $pos = $(document).scrollTop(), $pos = $pos + 100; $('.add_content').css('top',$pos) $('.Tdupli').show(); _rempform($this); $('input#product_id').attr('value',''); $('#Add_product').fadeIn(); return false }); $(document).on('click', '#selectAll', function () { $('#product_list input[type=checkbox]').prop('checked', true); delet_button() return false; }); $(document).on('click', '#selectNone', function () { $('#product_list input[type=checkbox]').prop('checked', false); delet_button() return false; }); $(document).on('click', '#selectInvert', function () { $('#product_list input[type=checkbox]').each(function(){ if($(this).is (':checked')){ $(this).prop('checked', false); }else{ $(this).prop('checked', true); } delet_button() }); return false; }); $(document).on('change','#product_list input[type=checkbox]', function () { delet_button() }); function delet_button(){ if($('#product_list input[type=checkbox]:checked').length > 0){ $('#forbidAction').css('display','none'); $('#permitAction').css('display','block'); }else{ $('#forbidAction').css('display','block'); $('#permitAction').css('display','none'); } }; $("#listOrder").sortable({ placeholder: 'highlight', update: function() { var $order = $("#listOrder").sortable("toArray"); $('#newOrder').val($order.join(",")); } }); $("#listOrder").disableSelection(); $('#ChangeOrder').click(function() { $("#change_Order").fadeIn( ); return false; }); $('#close_changeOrder').click(function() { $("#change_Order").fadeOut(); return false; }); $('.chzn-select').chosen({width:"400px"}) $('.addopt').click(function(){ $('#add_option_prod').show(); $('#sub_add_product').hide(); }); $(document).on('change','#optType',function(){ var $valSel = $('.addopt_table select#optType option:selected').attr('value'); if($valSel=="text" || $valSel=="textarea"){ $('.valeur').fadeOut('fast'); } else { $('.valeur').fadeIn('fast') } }); $('.addVal').click(function() { $('.valeur').append($('
').addClass('val').append($val)); ;return false; }) $(document).on('click','.delVal',function(){ if (confirm("{/literal}{'Are you sure?'|translate|escape:javascript}{literal}")) { var $Nval = $('.addopt_table .valeur input').length; if($Nval>1){ $(this).parents('div.val').remove(); }else{ var $val = $(this).parents('div.val'); $('input', $val).val('').attr('value',''); } } return false }); $(document).on('submit','#addopt_form',function(){ if($.trim($('input#optName',this).val()).length==0){ $('.erroropt').show(); setTimeout(function(){ $('.erroropt').hide() },3000); }else{ var $optecour = $('input#optName').val(); if($('.valeur').is(':hidden')){ $('.valeur').remove(); } $('.optadded').show(); setTimeout(function(){ $('.optadded').hide() },3000); $.ajax({ type:"POST", data: $(this).serialize(), success: function(html){ var $idlo = $(html).find('#idlastopt').text(); console.debug($idlo); $('#opt select').append($('