From 60ecfaafd2adcd6af10c3ac6606be1a8d8a65420 Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Wed, 31 Jul 2013 17:16:52 +0200 Subject: [PATCH] //fixed bug on carrier wizard tabindex --- .../helpers/form/form_ranges.tpl | 2 +- .../carrier_wizard/helpers/view/view.tpl | 2 + js/admin_carrier_wizard.js | 51 +++++++++++++------ 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/carrier_wizard/helpers/form/form_ranges.tpl b/admin-dev/themes/default/template/controllers/carrier_wizard/helpers/form/form_ranges.tpl index 8a3bf9428..18920cdcc 100644 --- a/admin-dev/themes/default/template/controllers/carrier_wizard/helpers/form/form_ranges.tpl +++ b/admin-dev/themes/default/template/controllers/carrier_wizard/helpers/form/form_ranges.tpl @@ -1,4 +1,4 @@ - +
diff --git a/admin-dev/themes/default/template/controllers/carrier_wizard/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/carrier_wizard/helpers/view/view.tpl index aea0be3e4..aaf11bee4 100644 --- a/admin-dev/themes/default/template/controllers/carrier_wizard/helpers/view/view.tpl +++ b/admin-dev/themes/default/template/controllers/carrier_wizard/helpers/view/view.tpl @@ -35,6 +35,8 @@ var carrierlist_url = '{$carrierlist_url|addslashes}'; var nbr_steps = {$wizard_steps.steps|count}; var enableAllSteps = {if $enableAllSteps|intval == 1}true{else}false{/if}; + var need_to_validate = '{l s='Please validate the last range before create a new one.' js=1}'; + var delete_range_confirm = '{l s='Are you sure to delete this range ?' js=1}';
    diff --git a/js/admin_carrier_wizard.js b/js/admin_carrier_wizard.js index 9050ad383..c01b9e307 100644 --- a/js/admin_carrier_wizard.js +++ b/js/admin_carrier_wizard.js @@ -209,12 +209,15 @@ function resizeWizard() function bind_inputs() { $('tr.delete_range td button').off('click').on('click', function () { - index = $(this).parent('td').index(); - $('tr.range_sup td:eq('+index+'), tr.range_inf td:eq('+index+'), tr.fees_all td:eq('+index+'), tr.delete_range td:eq('+index+')').remove(); - $('tr.fees').each( function () { - $(this).children('td:eq('+index+')').remove(); - }); - rebuildTabindex(); + if (confirm(delete_range_confirm)) + { + index = $(this).parent('td').index(); + $('tr.range_sup td:eq('+index+'), tr.range_inf td:eq('+index+'), tr.fees_all td:eq('+index+'), tr.delete_range td:eq('+index+')').remove(); + $('tr.fees').each( function () { + $(this).children('td:eq('+index+')').remove(); + }); + rebuildTabindex(); + } return false; }); @@ -397,6 +400,12 @@ function disableRange(index) function add_new_range() { + if (!$('tr.fees_all td:last').hasClass('validated')) + { + alert(need_to_validate); + return false; + } + last_sup_val = $('tr.range_sup td:last input').val(); //add new rand sup input $('tr.range_sup td:last').after('
'); @@ -417,6 +426,21 @@ function add_new_range() return false; } +function checkFeesForEnableZone(index) +{ + is_ok = true; + $('tr.fees').each( function () { + $(this).find('td:eq('+index+') input').each( function () { + if (!$(this).attr('disabled')) + { + if ($(this).val() == '') + is_ok = false; + } + }); + }); + return is_ok; +} + function delete_new_range() { if ($('#new_range_form_placeholder').children('td').length = 1) @@ -427,19 +451,16 @@ function delete_new_range() function rebuildTabindex() { i = 1; - zones_nbr +=3; // corresponds to the third input text (max, min and all) $('#zones_table tr').each( function () - { + { + j = i; $(this).children('td').each( function () { - if ($(this).index() > 2) - j = i + zones_nbr; - else if ($(this).index() == 2) - j = i; - + j = zones_nbr + j; if ($(this).index() >= 2 && $(this).find('input')) - $(this).find('input').attr('tabindex', j); + $(this).find('input').attr('tabindex', j); + console.log(j); }); - i ++; + i++; }); } \ No newline at end of file
*