81 lines
3.3 KiB
JavaScript
81 lines
3.3 KiB
JavaScript
|
jQuery(document).ready(function($) {
|
||
|
// Stuff to do as soon as the DOM is ready. Use $() w/o colliding with other libs;
|
||
|
var current_textarea = {};
|
||
|
current_textarea['en'] = $("textarea[for=en]").val();
|
||
|
current_textarea['zh_tw'] = $("textarea[for=zh_tw]").val();
|
||
|
$("div.controls").on("click","a.edit-btn",function(){
|
||
|
switch($(this).parent().parent().find("ul li.active a").attr("href")){
|
||
|
case ".tab1":
|
||
|
$("#tab3").addClass("active in");
|
||
|
$(".modal-body li").eq(0).addClass("active");
|
||
|
break;
|
||
|
case ".tab2":
|
||
|
$("#tab4").addClass("active in");
|
||
|
$(".modal-body li").eq(1).addClass("active");
|
||
|
break;
|
||
|
}
|
||
|
var lang = ["en","zh_tw"];
|
||
|
for(i=0;i<2;i++){
|
||
|
|
||
|
var sa = $(".tab-content input.street_address_"+lang[i]).val();
|
||
|
var city = $(".tab-content input.city_"+lang[i]).val();
|
||
|
var county = $(".tab-content input.county_"+lang[i]).val();
|
||
|
var zip = $(".tab-content input.zip_"+lang[i]).val();
|
||
|
var country = $(".tab-content input.country_"+lang[i]).val();
|
||
|
$(".modal-body").find('#street_address_'+lang[i]).val(sa)
|
||
|
$(".modal-body").find('#city_'+lang[i]).val(city);
|
||
|
$(".modal-body").find('#counties_'+lang[i]).val(county);
|
||
|
$(".modal-body").find('#zip_'+lang[i]).val(zip);
|
||
|
$(".modal-body").find('#country_'+lang[i]).val(country);
|
||
|
var verify = sa + city + country +county + zip;
|
||
|
var combined = "";
|
||
|
if(verify!="")
|
||
|
combined = sa + "\n" + city + "\n" + county + "\n" + zip + "\n" + country;
|
||
|
|
||
|
if($(".tab-content textarea[for="+lang[i]+"]").val() != combined){
|
||
|
$(".tab-content").find('#street_address_'+lang[i]).val($(".tab-content textarea[for="+lang[i]+"]").val());
|
||
|
$(".modal-body input").val("");
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
$("textarea.dummy").change(function(){
|
||
|
var lang = $(this).attr("for");
|
||
|
if(current_textarea[lang] != $(this).val())
|
||
|
$("input.indicator_"+lang).val("true");
|
||
|
else
|
||
|
$("input.indicator_"+lang).val("false");
|
||
|
})
|
||
|
|
||
|
$(".address-edit").on("hidden",function(){
|
||
|
$("#tab3").removeClass("active in");
|
||
|
$("#tab4").removeClass("active in");
|
||
|
$(".modal-body li").removeClass("active");
|
||
|
$(".modal-body input, .modal-body textarea").val("");
|
||
|
|
||
|
})
|
||
|
$(".bt-save").click(function(){
|
||
|
var lang = ["en","zh_tw"];
|
||
|
for(i=0;i<2;i++){
|
||
|
var sa = $(".tab-content").find('#street_address_'+lang[i]).val();
|
||
|
var city = $(".tab-content").find('#city_'+lang[i]).val();
|
||
|
var county = $(".tab-content").find('#counties_'+lang[i]).val();
|
||
|
var zip = $(".tab-content").find('#zip_'+lang[i]).val();
|
||
|
var country = $(".tab-content").find('#country_'+lang[i]).val();
|
||
|
$(".tab-content input.street_address_"+lang[i]).val(sa);
|
||
|
$(".tab-content input.city_"+lang[i]).val(city);
|
||
|
$(".tab-content input.county_"+lang[i]).val(county);
|
||
|
$(".tab-content input.zip_"+lang[i]).val(zip);
|
||
|
$(".tab-content input.country_"+lang[i]).val(country);
|
||
|
var verify = sa + city + country +county + zip;
|
||
|
var combined = "";
|
||
|
if(verify!="")
|
||
|
combined = sa + "\n" + city + "\n" + county + "\n" + zip + "\n" + country;
|
||
|
$(".tab-content textarea[for="+lang[i]+"]").val(combined);
|
||
|
$("input.indicator_"+lang[i]).val("false");
|
||
|
current_textarea[lang[i]] = combined;
|
||
|
}
|
||
|
|
||
|
})
|
||
|
|
||
|
});
|