(function(){ var loadScript = function(url, callback) { var script = document.createElement("script"); script.type = "text/javascript"; if (script.readyState){ script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; } else { script.onload = function() { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }; var fix = function($) { var ml_lang; var listen = false; var env = ''; window.ml_domains_local = {}; function interceptCartSubmit() { $('form[action=\\/cart] input[name=checkout],form[action=\\/cart] button[name=checkout], a[href=\\/checkout],button.shopify-payment-button__button').click(function(e) { e.preventDefault(); var note_f = $('textarea[name=note]'); var note = ''; if(note_f.length > 0) { if(note_f.val().length > 0) note='¬e='+note_f.val(); } location.href='/checkout?locale='+ml_lang+note; }); } function setCookie(v) { document.cookie = "redirected="+v+"; path=/;"; } function delCookie() { document.cookie = "redirected=; path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC"; } function getCookie() { var name = "redirected="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1); if (c.indexOf(name) == 0) { return c.substring(name.length,c.length); } } return ""; } function swap(json) { var ret = {}; for(var key in json) ret[json[key]] = key; return ret; } function getUrlVars() { var vars = []; var jvars = {}; var hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); var cloc = window.location.host; for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); if(hash[1]!=null) jvars[hash[0]] = hash[1]; } return jvars; } window.setAtt = function(target) { var url = location.href.split('?'); if(url[0].charAt(url[0].length-1) =='#') url[0]=url[0].substr(0,url[0].length-1); var new_qs_arr = []; var new_qs = ''; var qs = getUrlVars(); for(var j=0; j< qs.length; j++) { if(qs[j]!='lang') new_qs_arr.push(qs[j]+'='+qs[qs[j]]); } new_qs = new_qs_arr.join('&'); if(new_qs.length>0) new_qs = '?'+new_qs; var dest = ''; var path = window.location.pathname; var update_url = ''; if(ml_domains_local[target]!=null) { update_url = 'https://'+ml_domains_local[target]; dest ='https://'+ml_domains_local[target]+path+new_qs; } else { update_url = 'https://'+location.host; dest =url[0]+new_qs; } update_url = update_url+'/cart/update?attributes[ml_lang]='+target; $('body').append(''); $('#ml_cart_update').attr('src', update_url) .on('error', function() { location.href = dest; }); return; }; function getLang() { $.ajax({ url : '/cart.js', type : 'GET', crossDomain: false, dataType:'json', success : function(data) { if(typeof ml_def_language_mf !== 'undefined') def_loc = ml_def_language_mf; ml_lang = data['attributes']['ml_lang']; if(ml_lang==null) ml_lang=def_loc; var bidi = ['ar','fa','ur','he','he-IL']; if( bidi.indexOf(ml_lang)>=0 && ($('#ml_lang_selector').attr('rtl') == 'rtl')) { //$('body').attr('dir','rtl'); $('body').css('direction','rtl'); $('body').addClass('rtl'); } else { $('body').css('direction',''); $('body').removeClass('rtl'); } var redirect; if(typeof ml_redirect_mf != 'undefined') redirect = ml_redirect_mf; else redirect = $('#ml_lang_selector').attr('redirect'); if(redirect===null) redirect = 'off'; if(redirect!='off') { var br_locale = 'en'; var br_locale_short = 'en'; var l_loc = new Array(); var target=''; var keys = ''; if(typeof ml_available_languages_mf != 'undefined') keys = Object.keys(ml_available_languages_mf); else keys = Object.keys(ml_loc); for(var i=0;i< keys.length;i++) l_loc.push(keys[i].toLowerCase()); if(l_loc.indexOf(br_locale) >=0 ) target = keys[l_loc.indexOf(br_locale)]; else if(l_loc.indexOf(br_locale_short) >=0 ) target = keys[l_loc.indexOf(br_locale_short)]; var t = location.href.split('#')[0] t = t.split('?')[0]+'?lang='+target; if(redirect=='once' && target != '' && target==ml_lang && getCookie().length==0) { setCookie('once'); return; } if(redirect=='once' && target != '' && target!=ml_lang && getCookie().length==0) { setCookie('once'); setAtt(target); return; } else if(redirect=='force' && target != '' && target!=ml_lang) { setAtt(target); return; } } $('#ml_switch_loc,#ml_custom_switch').val(ml_lang); var type = $('#ml_lang_selector').attr('type'); if(typeof type=='undefined') type =''; if(type.indexOf('flag_')==0) triggerFlagSelect($('.lang_tab[value="'+ml_lang+'"]')); var qs = getUrlVars(); if ('lang' in qs && ml_lang != qs['lang']) { setAtt(qs['lang']); return; } if(Object.keys(ml_domains_local).length >0) { var d_k = Object.keys(ml_domains_local); var c_host = location.host; for(var i=0;i< d_k.length;i++) { var t_host = ml_domains_local[d_k[i]]; if(t_host==c_host) { if(ml_lang!=d_k[i]) { setAtt(d_k[i]); return; } } } } $('#ml_lang_selector').show(); }, error : function(request,error) { } }); } function createFlagDropdown() { $('head').append(''); var sel = $('#ml_lang_selector'); sel.css('direction','ltr'); sel.hide(); var has_txt = true; var width_class = 'ml_lang_texts_long'; if (sel.attr('type')=='flag_no_txt_dropdown') { has_txt = false; width_class= 'ml_lang_texts_short'; } sel.append('
'); $('#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); } })();