//multiple small fix on carrier wizard

This commit is contained in:
Vincent Augagneur committed 2013-11-28 17:38:05 +01:00
1 parent d46feffcf1
commit 66947b5354
3 files changed
+64 -43

No files matched your search

@@ -59,14 +59,9 @@
</p> </p>
</div> </div>
<script> <script>
var attachement_clicked = false;
$(document).ready(function(){ $(document).ready(function(){
$('#attachement_fileselectbutton').click(function(e){ $('#attachement_fileselectbutton').click(function(e){
if (!attachement_clicked)
{
$('#carrier_logo_input').trigger('click'); $('#carrier_logo_input').trigger('click');
attachement_clicked = true;
}
return false; return false;
}); });
$('#carrier_logo_input').change(function(e){ $('#carrier_logo_input').change(function(e){
@@ -80,7 +80,10 @@
<td> <td>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon">{$currency_sign}</span> <span class="input-group-addon">{$currency_sign}</span>
<input class="form-control" name="fees[{$zone.id_zone|intval}][{$range.id_range|intval}]" type="text" {if !isset($fields_value['zones'][$zone.id_zone]) || (isset($fields_value['zones'][$zone.id_zone]) && !$fields_value['zones'][$zone.id_zone])} disabled="disabled"{/if} {if isset($price_by_range[$range.id_range][$zone.id_zone]) && $price_by_range[$range.id_range][$zone.id_zone] && isset($fields_value['zones'][$zone.id_zone]) && $fields_value['zones'][$zone.id_zone]} value="{$price_by_range[$range.id_range][$zone.id_zone]|string_format:'%.6f'}" {else} value="" {/if} /> <input class="form-control" name="fees[{$zone.id_zone|intval}][{$range.id_range|intval}]" type="text"
{if !isset($fields_value['zones'][$zone.id_zone]) || (isset($fields_value['zones'][$zone.id_zone]) && !$fields_value['zones'][$zone.id_zone])} disabled="disabled"{/if}
{if isset($price_by_range[$range.id_range][$zone.id_zone]) && $price_by_range[$range.id_range][$zone.id_zone] && isset($fields_value['zones'][$zone.id_zone]) && $fields_value['zones'][$zone.id_zone]} value="{$price_by_range[$range.id_range][$zone.id_zone]|string_format:'%.6f'}" {else} value="" {/if} />
</div> </div>
</td> </td>
{/foreach} {/foreach}
+60 -37
View File
@@ -23,6 +23,7 @@
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
var fees_is_hide = false;
$(document).ready(function() { $(document).ready(function() {
bind_inputs(); bind_inputs();
@@ -30,7 +31,7 @@ $(document).ready(function() {
if (parseInt($('input[name="is_free"]:checked').val())) if (parseInt($('input[name="is_free"]:checked').val()))
is_freeClick($('input[name="is_free"]:checked')); is_freeClick($('input[name="is_free"]:checked'));
displayRangeType(); displayRangeType();
checkAllZones();
}); });
function initCarrierWizard() function initCarrierWizard()
@@ -218,7 +219,7 @@ function validateSteps(fromStep, toStep)
{ {
is_ok = false; is_ok = false;
$('input').focus( function () { $('div.input-group input').focus(function () {
$(this).removeClass('field_error'); $(this).removeClass('field_error');
}); });
displayError(datas.errors, fromStep); displayError(datas.errors, fromStep);
@@ -254,7 +255,7 @@ function resizeWizard()
function bind_inputs() function bind_inputs()
{ {
$('input').focus( function () { $('div.input-group input').focus(function () {
$(this).removeClass('field_error'); $(this).removeClass('field_error');
$('.wizard_error').fadeOut('fast', function () { $(this).remove()}); $('.wizard_error').fadeOut('fast', function () { $(this).remove()});
}); });
@@ -272,17 +273,24 @@ function bind_inputs()
return false; return false;
}); });
$('tr.fees td input:checkbox').off('change').on('change', function () { $('tr.fees td input:checkbox').off('change').on('change', function ()
{
if($(this).is(':checked')) if($(this).is(':checked'))
{ {
$(this).closest('tr').find('td').each(function () { $(this).closest('tr').find('td').each(function () {
index = $(this).index(); index = $(this).index();
if ($('tr.fees_all td:eq('+index+')').hasClass('validated')) if ($('tr.fees_all td:eq('+index+')').hasClass('validated'))
$(this).find('input:text').removeAttr('disabled'); {
enableGlobalFees(index);
$(this).find('div.input-group input:text').removeAttr('disabled');
}
else
disabledGlobalFees(index);
}); });
} }
else else
$(this).closest('tr').find('td').find('input:text').attr('disabled', 'disabled'); $(this).closest('tr').find('td').find('div.input-group input:text').attr('disabled', 'disabled');
return false; return false;
}); });
@@ -314,8 +322,8 @@ function bind_inputs()
wait: 1000, wait: 1000,
callback: function() { callback: function() {
index = $(this.el).closest('td').index(); index = $(this.el).closest('td').index();
range_sup = $('tr.range_sup td:eq('+index+')').children('input:text').val().trim(); range_sup = $('tr.range_sup td:eq('+index+')').find('div.input-group input:text').val().trim();
range_inf = $('tr.range_inf td:eq('+index+')').children('input:text').val().trim(); range_inf = $('tr.range_inf td:eq('+index+')').find('div.input-group input:text').val().trim();
if (range_sup != '' && range_inf != '') if (range_sup != '' && range_inf != '')
{ {
if (validateRange(index)) if (validateRange(index))
@@ -369,7 +377,7 @@ function is_freeClick(elt)
var is_free = $(elt); var is_free = $(elt);
if (parseInt(is_free.val())) if (parseInt(is_free.val()))
hideFees(); hideFees();
else else if (fees_is_hide)
showFees(); showFees();
} }
@@ -382,6 +390,7 @@ function hideFees()
$(this).css('background-color', '#999999'); $(this).css('background-color', '#999999');
} }
}); });
fees_is_hide = true;
} }
function showFees() function showFees()
@@ -393,7 +402,7 @@ function showFees()
tr = $(this).closest('tr'); tr = $(this).closest('tr');
validate = $('tr.fees_all td:eq('+$(this).index()+')').hasClass('validated'); validate = $('tr.fees_all td:eq('+$(this).index()+')').hasClass('validated');
if ($(tr).index() > 2 && $(tr).find('td:eq(1) input').attr('checked') && validate || !$(tr).hasClass('range_sup') || !$(tr).hasClass('range_inf')) if ($(tr).index() > 2 && $(tr).find('td:eq(1) input').attr('checked') && validate || !$(tr).hasClass('range_sup') || !$(tr).hasClass('range_inf'))
$(this).find('input:text').removeAttr('disabled'); $(this).find('div.input-group input:text').removeAttr('disabled');
$(this).find('input:text, button').css('background-color', '').css('border-color', ''); $(this).find('input:text, button').css('background-color', '').css('border-color', '');
$(this).find('button').css('background-color', '').css('border-color', '').removeAttr('disabled'); $(this).find('button').css('background-color', '').css('border-color', '').removeAttr('disabled');
$(this).css('background-color', ''); $(this).css('background-color', '');
@@ -409,25 +418,25 @@ function validateRange(index)
$('tr.range_inf td input:text').removeClass('field_error'); $('tr.range_inf td input:text').removeClass('field_error');
is_ok = true; is_ok = true;
range_sup = parseFloat($('tr.range_sup td:eq('+index+')').find('input:text').val().trim()); range_sup = parseFloat($('tr.range_sup td:eq('+index+')').find('div.input-group input:text').val().trim());
range_inf = parseFloat($('tr.range_inf td:eq('+index+')').find('input:text').val().trim()); range_inf = parseFloat($('tr.range_inf td:eq('+index+')').find('div.input-group input:text').val().trim());
if (isNaN(range_sup) || range_sup.length === 0) if (isNaN(range_sup) || range_sup.length === 0)
{ {
$('tr.range_sup td:eq('+index+')').find('input:text').addClass('field_error'); $('tr.range_sup td:eq('+index+')').find('div.input-group input:text').addClass('field_error');
is_ok = false; is_ok = false;
displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep')); displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep'));
} }
else if (is_ok && (isNaN(range_inf) || range_inf.length === 0)) else if (is_ok && (isNaN(range_inf) || range_inf.length === 0))
{ {
$('tr.range_inf td:eq('+index+')').closest('input:text').addClass('field_error'); $('tr.range_inf td:eq('+index+')').closest('div.input-group input:text').addClass('field_error');
is_ok = false; is_ok = false;
displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep')); displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep'));
} }
else if (is_ok && range_inf >= range_sup) else if (is_ok && range_inf >= range_sup)
{ {
$('tr.range_sup td:eq('+index+')').find('input:text').addClass('field_error'); $('tr.range_sup td:eq('+index+')').find('div.input-group input:text').addClass('field_error');
$('tr.range_inf td:eq('+index+')').find('input:text').addClass('field_error'); $('tr.range_inf td:eq('+index+')').find('div.input-group input:text').addClass('field_error');
is_ok = false; is_ok = false;
displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep')); displayError([invalid_range], $("#carrier_wizard").smartWizard('currentStep'));
} }
@@ -440,7 +449,7 @@ function validateRange(index)
is_ok = false; is_ok = false;
curent_index = $(this).index(); curent_index = $(this).index();
current_sup = $(this).find('input').val(); current_sup = $(this).find('div.input-group input').val();
current_inf = $('tr.range_inf td:eq('+curent_index+') input').val(); current_inf = $('tr.range_inf td:eq('+curent_index+') input').val();
if ($('tr.range_inf td:eq('+curent_index+1+') input').length) if ($('tr.range_inf td:eq('+curent_index+1+') input').length)
@@ -458,8 +467,8 @@ function validateRange(index)
if (!is_ok) if (!is_ok)
{ {
$('tr.range_sup td:eq('+index+')').find('input:text').addClass('field_error'); $('tr.range_sup td:eq('+index+')').find('div.input-group input:text').addClass('field_error');
$('tr.range_inf td:eq('+index+')').find('input:text').addClass('field_error'); $('tr.range_inf td:eq('+index+')').find('div.input-group input:text').addClass('field_error');
displayError([range_is_overlapping], $("#carrier_wizard").smartWizard('currentStep')); displayError([range_is_overlapping], $("#carrier_wizard").smartWizard('currentStep'));
} }
else else
@@ -471,18 +480,23 @@ function validateRange(index)
function enableZone(index) function enableZone(index)
{ {
$('tr.fees').each(function () { $('tr.fees').each(function () {
if ($(this).find('td:eq(1)').children('input[type=checkbox]:checked').length) if ($(this).find('td:eq(1)').find('input[type=checkbox]:checked').length)
$(this).find('td:eq('+index+')').children('input').removeAttr('disabled'); $(this).find('td:eq('+index+')').find('div.input-group input').removeAttr('disabled');
}); });
} }
function disableZone(index) function disableZone(index)
{ {
$('tr.fees').each(function () { $('tr.fees').each(function () {
$(this).find('td:eq('+index+')').children('input').attr('disabled', 'disabled'); $(this).find('td:eq('+index+')').find('div.input-group input').attr('disabled', 'disabled');
}); });
} }
function checkAllRanges()
{
}
function enableRange(index) function enableRange(index)
{ {
$('tr.fees').each(function () { $('tr.fees').each(function () {
@@ -491,7 +505,8 @@ function enableRange(index)
enableZone(index); enableZone(index);
}); });
$('tr.fees_all td:eq('+index+')').addClass('validated').removeClass('not_validated'); $('tr.fees_all td:eq('+index+')').addClass('validated').removeClass('not_validated');
if ($('.zone input[type=checkbox]:checked').length)
//if ($('.zone input[type=checkbox]:checked').length)
enableGlobalFees(index); enableGlobalFees(index);
bind_inputs(); bind_inputs();
} }
@@ -499,10 +514,18 @@ function enableRange(index)
function enableGlobalFees(index) function enableGlobalFees(index)
{ {
$('span.fees_all').show(); $('span.fees_all').show();
$('tr.fees_all td:eq('+index+')').find('input').show().removeAttr('disabled'); $('tr.fees_all td:eq('+index+')').find('div.input-group input').show().removeAttr('disabled');
$('tr.fees_all td:eq('+index+')').find('.currency_sign').show(); $('tr.fees_all td:eq('+index+')').find('div.input-group .currency_sign').show();
} }
function disabledGlobalFees(index)
{
$('span.fees_all').hide();
$('tr.fees_all td:eq('+index+')').find('div.input-group input').hide().attr('disabled', 'disabled');
$('tr.fees_all td:eq('+index+')').find('div.input-group .currency_sign').hide();
}
function disableRange(index) function disableRange(index)
{ {
$('tr.fees').each(function () { $('tr.fees').each(function () {
@@ -510,7 +533,7 @@ function disableRange(index)
if ($(this).find('td').find('input:checkbox').attr('checked') == 'checked') if ($(this).find('td').find('input:checkbox').attr('checked') == 'checked')
disableZone(index); disableZone(index);
}); });
$('tr.fees_all td:eq('+index+')').find('input').attr('disabled', 'disabled'); $('tr.fees_all td:eq('+index+')').find('div.input-group input').attr('disabled', 'disabled');
$('tr.fees_all td:eq('+index+')').removeClass('validated').addClass('not_validated'); $('tr.fees_all td:eq('+index+')').removeClass('validated').addClass('not_validated');
} }
@@ -564,8 +587,8 @@ function rebuildTabindex()
$(this).find('td').each(function () $(this).find('td').each(function ()
{ {
j = zones_nbr + j; j = zones_nbr + j;
if ($(this).index() >= 2 && $(this).find('input')) if ($(this).index() >= 2 && $(this).find('div.input-group input'))
$(this).find('input').attr('tabindex', j); $(this).find('div.input-group input').attr('tabindex', j);
}); });
i++; i++;
}); });
@@ -592,11 +615,11 @@ function checkRangeContinuity(reordering)
index = $(this).index(); index = $(this).index();
if (index > 2) if (index > 2)
{ {
range_sup = parseFloat($('tr.range_sup td:eq('+index+')').find('input:text').val().trim()); range_sup = parseFloat($('tr.range_sup td:eq('+index+')').find('div.input-group input:text').val().trim());
range_inf = parseFloat($('tr.range_inf td:eq('+index+')').find('input:text').val().trim()); range_inf = parseFloat($('tr.range_inf td:eq('+index+')').find('div.input-group input:text').val().trim());
prev_index = index-1; prev_index = index-1;
prev_range_sup = parseFloat($('tr.range_sup td:eq('+prev_index+')').find('input:text').val().trim()); prev_range_sup = parseFloat($('tr.range_sup td:eq('+prev_index+')').find('div.input-group input:text').val().trim());
prev_range_inf = parseFloat($('tr.range_inf td:eq('+prev_index+')').find('input:text').val().trim()); prev_range_inf = parseFloat($('tr.range_inf td:eq('+prev_index+')').find('div.input-group input:text').val().trim());
if (range_inf < prev_range_inf || range_sup < prev_range_sup) if (range_inf < prev_range_inf || range_sup < prev_range_sup)
{ {
res = false; res = false;
@@ -622,10 +645,10 @@ function getCorrectRangePosistion(current_inf, current_sup)
$('tr.range_sup td').not('.range_type, .range_sign').each(function () $('tr.range_sup td').not('.range_type, .range_sign').each(function ()
{ {
index = $(this).index(); index = $(this).index();
range_sup = parseFloat($('tr.range_sup td:eq('+index+')').children('input:text').val().trim()); range_sup = parseFloat($('tr.range_sup td:eq('+index+')').find('div.input-group input:text').val().trim());
next_range_inf = 0 next_range_inf = 0
if ($('tr.range_inf td:eq('+index+1+')').length) if ($('tr.range_inf td:eq('+index+1+')').length)
next_range_inf = parseFloat($('tr.range_inf td:eq('+index+1+')').children('input:text').val().trim()); next_range_inf = parseFloat($('tr.range_inf td:eq('+index+1+')').find('div.input-group input:text').val().trim());
if (current_inf >= range_sup && current_sup < next_range_inf) if (current_inf >= range_sup && current_sup < next_range_inf)
new_position = index; new_position = index;
}); });
@@ -637,20 +660,20 @@ function checkAllZones(elt)
if($(elt).is(':checked')) if($(elt).is(':checked'))
{ {
$('.input_zone').attr('checked', 'checked'); $('.input_zone').attr('checked', 'checked');
$('.fees input:text').each( function () { $('.fees div.input-group input:text').each(function () {
index = $(this).closest('td').index(); index = $(this).closest('td').index();
enableGlobalFees(index); enableGlobalFees(index);
if ($('tr.fees_all td:eq('+index+')').hasClass('validated')) if ($('tr.fees_all td:eq('+index+')').hasClass('validated'))
{ {
$(this).removeAttr('disabled'); $(this).removeAttr('disabled');
$('.fees_all td:eq('+index+') input:text').removeAttr('disabled'); $('.fees_all td:eq('+index+') div.input-group input:text').removeAttr('disabled');
} }
}); });
} }
else else
{ {
$('.input_zone').removeAttr('checked'); $('.input_zone').removeAttr('checked');
$('.fees input:text, .fees_all input:text').attr('disabled', 'disabled').val(''); $('.fees div.input-group input:text, .fees_all div.input-group input:text').attr('disabled', 'disabled').val('');
} }
} }