|
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 User : jackjohn ( 502) PHP Version : 5.3.17 Disable Function : NONE Directory : /home/jackjohn/www/shopsite-images/en-NZ/javascript/ |
Upload File : |
"use_strict";
ss_jQuery(function($){
let s_country=['US','CA']/* If state list in old format */,
f=document.billing,checkState=function(e){
let ship=(this.name != 'Country'),
state= ((ship&&f.ShipState) || f.State),
country=((ship&&f.ShipCountry) || f.Country),
hstate= ((ship&&f.hiddenShipState) || f.hiddenState),
state_name=state.value,
country_name=$(':selected',country).data('cc'),
cc=country.querySelector('option:checked').dataset.cc,
opt,hname,name,og;
if(typeof state != 'undefined' && state.type == 'select-one'){
opt = $('optgroup[data-country="'+country_name+'"]', state);
if((og=$('optgroup option:checked',state)).length==1){og.parent().data('selected',og.val());}
if(opt.length != 1 && !s_country.includes(cc)){
hname=hstate.name,name=state.name;
$(hstate).attr('name',name).show();
$(state).attr('name',hname).hide();
} else {
$('optgroup',state).hide();
opt.show();
if(og=opt.data('selected')){state.value=og}
else if((og=$('option[value="n"]',opt)).length>0){og.prop('selected',true)}
else if(opt.length>0){state.value='n'}
}
} else {
opt = $('optgroup[data-country="'+country_name+'"]', hstate);
if(opt.length == 1 || s_country.includes(cc)){
hname=hstate.name,name=state.name;
$(hstate).attr('name',name).show();
$(state).attr('name',hname).hide();
if(opt.length == 1){
$('optgroup',hstate).hide();
opt.show();
if(og=opt.data('selected')){hstate.value=og}
else if((og=$('option[value="n"]',opt)).length>0){og.prop('selected',true)}
}
}
}
};
if(f.State && f.State.type == 'select-one'){
$('<input class="addr" type="text" aria-labelledby="ss-address-required E_State" name="hiddenState" value="" size="28" maxlength="30">').hide().insertAfter(f.State);
$(f.Country).change(checkState).change()
}
if(f.ShipState && f.ShipState.type == 'select-one'){
$('<input class="addr" type="text" aria-labelledby="ss-address-required E_ShipState" name="hiddenShipState" value="" size="28" maxlength="30">').hide().insertAfter(f.ShipState);
$(f.ShipCountry).change(checkState).change();
}
});