[-] FO : Fix #PSCFV-4885 for DNI field, states and postcode display

This commit is contained in:
gRoussac
2013-01-04 16:31:05 +01:00
parent c339f585d0
commit 34f98b0987
5 changed files with 105 additions and 117 deletions
+17 -22
View File
@@ -5,30 +5,28 @@ $(document).ready(function()
function bindStateInputAndUpdate()
{
$('.id_state, .dni, .postcode').css({'display':'none'});
updateState();
updateNeedIDNumber();
updateZipCode();
$('select#id_country').change(function(){
updateState();
updateNeedIDNumber();
updateZipCode();
});
if ($('select#id_country_invoice').length !== 0)
{
$('select#id_country_invoice').change(function(){
updateState('invoice');
updateNeedIDNumber('invoice');
updateZipCode();
});
if ($('select#id_country_invoice:visible').length !== 0)
{
$('select#id_country_invoice').change(function(){
updateState('invoice');
updateNeedIDNumber('invoice');
updateZipCode('invoice');
}
});
updateState('invoice');
updateNeedIDNumber('invoice');
updateZipCode('invoice');
}
updateState();
updateNeedIDNumber();
updateZipCode();
}
function updateState(suffix)
@@ -40,29 +38,26 @@ function updateState(suffix)
$(states).each(function (key, item){
$('select#id_state'+(suffix !== undefined ? '_'+suffix : '')).append('<option value="'+item.id+'"'+ (idSelectedCountry === item.id ? ' selected="selected"' : '') + '>'+item.name+'</option>');
});
$('p.id_state'+(suffix !== undefined ? '_'+suffix : '')+':hidden, div.id_state'+(suffix !== undefined ? '_'+suffix : '')).slideDown('slow');
$('.id_state'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');;
}
else
$('p.id_state'+(suffix !== undefined ? '_'+suffix : '')+', div.id_state'+(suffix !== undefined ? '_'+suffix : '')).hide();
$('.id_state'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
}
function updateNeedIDNumber(suffix)
{
var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());
if ($.inArray(idCountry, countriesNeedIDNumber) >= 0)
$('.dni'+(suffix !== undefined ? '_'+suffix : '')).slideDown('slow');
$('.dni'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');
else
$('.dni'+(suffix !== undefined ? '_'+suffix : '')).slideUp('fast');
$('.dni'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
}
function updateZipCode(suffix)
{
var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());
if (countriesNeedZipCode[idCountry] !== 0)
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')).slideDown('slow');
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')+':hidden').fadeIn('slow');
else
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')).slideUp('fast');
$('.postcode'+(suffix !== undefined ? '_'+suffix : '')).fadeOut('fast');
}