');
$('#ml_lang_selector select option').each(function() {
var bg = $(this).attr('flag');
var dd_txt = $(this).text();
if(!has_txt)
dd_txt='';
$('.ml_select-list').append('
' + dd_txt + '');
});
$('#ml_lang_selector .ml_button').html('
' +
$('#ml_switch_loc option:selected').text() + '');
var sel_val = $('#ml_switch_loc option:selected').val();
$('#ml_lang_selector ul li span[value='+sel_val+']').addClass('active');
$('#ml_lang_selector .ml_select-list span').click(function()
{
var sl = $(this).attr('value');
$('#ml_switch_loc').val( sl );
$('#ml_switch_loc').change();
});
$('#ml_lang_selector .ml_button').click(function()
{
$('#ml_lang_selector ul li').slideToggle();
});
}
function triggerFlagSelect(t)
{
t.hide();
var width_class = 'ml_lang_texts_long';
if ($('#ml_lang_selector').attr('type')=='flag_no_txt_dropdown')
{
has_txt = false;
width_class= 'ml_lang_texts_short';
}
var dd_text = t.text();
var dd_img = t.attr('flag');
var dd_val = t.attr('value');
$('#ml_lang_selector .ml_button').html('
' + dd_text + '');
$('#ml_lang_selector .ml_select-list span').parent().removeClass('active');
t.parent().addClass('active');
$('#ml_switch_loc').val( dd_val );
$('#ml_lang_selector .ml_select-list li').slideUp();
}
window.inspectDOM = function()
{
$('body').off();
interceptCartSubmit();
if(typeof ml_opts === 'undefined' && typeof ml_frontend_replace === 'undefined')
return;
if($('.single-option-selector-product').length || $('.single-option-selector').length || $('.single-option-radio').length || typeof ml_frontend_replace != 'undefined')
{
window.setTimeout(translateOptions,500);
window.setTimeout(translateFrontendVars,500);
window.setTimeout(attachDOMChangeListener,1000);
}
};
function attachDOMChangeListener()
{
$('body').on("DOMSubtreeModified",function(){inspectDOM()});
}
window.MLupdateProductOptions = function(){
translateOptions();
};
window.MLtranslateFrontendVars = function(){
translateFrontendVars();
};
function translateOptions()
{
if(typeof ml_opts === 'undefined')
return;
var opt_key_val = {};
var opt_labels = {};
var ok = Object.keys(ml_opts);
for(var i=0;i < ok.length ;i++)
{
var trans_opts = JSON.parse(ml_opts[ok[i]]);
if(trans_opts===null)
trans_opts = {};
var trans_opts_keys = Object.keys(trans_opts);
for(var j=0;j < trans_opts_keys.length;j++)
{
if(trans_opts_keys[j]!='ml_trans')
opt_key_val[trans_opts_keys[j]] = trans_opts[trans_opts_keys[j]];
else
{
if(trans_opts_keys[j]!='')
opt_labels[ok[i]] = trans_opts[trans_opts_keys[j]];
}
}
}
listen = true;
$('.single-option-selector,.single-option-radio,.single-option-selector-product,.single-option-radio').each(function(){
var par = $(this).closest('div:has(label)');
var opt_name = '';
opt_name = $('label',par).first().text();
opt_name = $.trim(opt_name);
opt_name = opt_name.replace(/\s/g,'_');
opt_name = opt_name.replace(/\./g,'_');
if(opt_labels[opt_name])
{
$('label',par).first().text(opt_labels[opt_name]);
$('span.option-selector__label',par).first().text(opt_labels[opt_name]+':');
}
$('option,label,li',this).each(function(){
//$(this).attr('default_txt', $(this).text());
var co = $(this).html();
co = co.trim();
co = co.replace(/&/g,'&');
if(opt_key_val[co])
{
$(this).text(opt_key_val[co]);
}
});
var st = $('option:selected',this).text();
$('.selected-text',par).first().text(st);
});
/* custom option replacements */
$('.ml_option,.ml_selected_option').each(function(){
var co = $(this).html();
co = co.trim();
co = co.replace(/&/g,'&');
if(opt_key_val[co])
$(this).text(opt_key_val[co]);
});
$('.ml_opt_label').each(function(){
var cust_opt_name = $.trim($(this).text());
cust_opt_name = cust_opt_name.replace(/\s/g,'_');
cust_opt_name = cust_opt_name.replace(/\./g,'_');
if(opt_labels[cust_opt_name])
$(this).text(opt_labels[cust_opt_name]);
});
listen=false;
}
function translateFrontendVars(node)
{
if(typeof ml_frontend_replace === 'undefined')
return;
listen=true;
if(node==null)
node = $('body');
var keys = Object.keys(ml_frontend_replace);
node.contents().each(function(){
var tname = this.tagName;
if(tname!=null)
{
if( tname.toUpperCase() =='IFRAME' )
return;
}
$(this).contents().filter(function() {
return this.nodeType == 3
}).each(function(){
var txt = this.textContent;
txt = txt.trim();
for(var i=0;i < keys.length;i++)
{
if(txt=='')
continue;
if(txt == keys[i])
this.textContent = this.textContent.replace(keys[i],ml_frontend_replace[keys[i]]);
}
});
if( $(this).children().length > 0 )
translateFrontendVars( $(this) );
});
listen=false;
}
function preloadImage(url)
{
var img=new Image();
img.src=url;
}
$(document).ready( function()
{
if(typeof ml_domains != 'undefined')
ml_domains_local = ml_domains;
if(typeof ml_domains_mf != 'undefined')
ml_domains_local = ml_domains_mf;
$('#ml_lang_selector').hide();
var keys = '';
if(typeof ml_available_languages_mf != 'undefined')
keys = Object.keys(ml_available_languages_mf);
else
keys = Object.keys(ml_loc);
keys.sort();
var sel = $('#ml_lang_selector');
sel.css('justify-content','flex-end');
sel.css('display','flex');
sel.css('float','none');
var pos = sel.attr('position');
var type = sel.attr('type');
if(typeof type==='undefined')
type = '';
if(typeof pos==='undefined')
pos = '';
var version = sel.attr('version');
var st = '';
st = ' style="max-width:300px;"';
var s = '';
var link_arr = new Array();
for(var j=0;j < keys.length;j++)
{
var k = keys[j];
var flag = k.toLowerCase().substr(-2);
if(flag=='en')flag='gb';
if(flag=='ar')flag='ae';
if(flag=='ko')flag='kr';
if(flag=='hi')flag='in';
if(flag=='fa')flag='ir';
if(flag=='el')flag='gr';
if(flag=='ja')flag='jp';
if(flag=='zh')flag='cn';
if(flag=='vi')flag='vn';
if(flag=='sv')flag='se';
if(flag=='da')flag='dk';
if(flag=='nt')flag='hk';
if(flag=='ns')flag='cn';
if(flag=='uk')flag='ua';
if(flag=='sq')flag='al';
if(flag=='ca')flag='es-ct';
if(flag=='cs')flag='cz';
if(flag=='et')flag='ee';
if(flag=='he')flag='il';
if(flag=='sr')flag='rs';
if(flag=='cy')flag='gb-wls';
if(flag=='sl')flag='si';
if(typeof flag_overrides != 'undefined')
if(flag_overrides[flag]!=null)flag=flag_overrides[flag];
var lang_name = '';
if(typeof ml_available_languages_mf != 'undefined')
lang_name = ml_available_languages_mf[k];
else
lang_name = ml_loc[k];
if(typeof lang_overrides != 'undefined')
if(lang_overrides[k]!=null)lang_name=lang_overrides[k];
preloadImage('https://www.modules4u.biz/shopify/flags/4x3/'+flag+'.svg');
var nl = location.href.split('?')[0];
if(type=='flags')
s+='

';
else if(type=='links')
link_arr.push('
'+lang_name+'');
else if(type.indexOf('dropdown')>=0)
s+='
';
}
if(type=='links')
s = link_arr.join(' | ');
if(type=='flags' || type=='links')
sel.html(s);
else if(type.indexOf('dropdown')>=0)
sel.html('
');
if(type.indexOf('flag_')==0 )
createFlagDropdown();
if(pos.indexOf('fixed_')==0)
{
sel.css('position','fixed');
sel.css('z-index','99999999999');
if(pos=='fixed_top_right')
{
sel.css('top','0');
sel.css('right','0');
}
else if(pos=='fixed_top_left')
{
sel.css('top','0');
sel.css('left','0');
}
} else
{
sel.css('z-index','99999999999');
if(pos=='top_right')
{
sel.css('justify-content','flex-end');
$('.ml_select-list').css('left','');
$('.ml_select-list').css('right','0');
}
else if(pos=='top_left')
{
sel.css('justify-content','flex-start');
$('.ml_select-list').css('right','');
$('.ml_select-list').css('left','0');
}
}
getLang();
$('#ml_switch_loc,#ml_custom_switch').change(function(){
var v= $(this).val();
setAtt(v);
});
$('.ml_link').click(function(){
var v = '';
if($(this).attr('lang_id'))
var v =$(this).attr('lang_id');
else
v = $(this).attr('id');
setAtt(v);
});
interceptCartSubmit();
attachDOMChangeListener();
});
};
if ((typeof jQuery === 'undefined') || (parseFloat(jQuery.fn.jquery) < 3))
{
loadScript('//modules4u.biz/shopify/js/jquery/jquery-3.2.1.min.js', function() {
jQuery32 = jQuery.noConflict(true);
fix(jQuery32);
}
);
}
else
{ fix(jQuery); }
})();