%PDF- %PDF-
Direktori : /var/www/html/itworks/wp-content/plugins/woocommerce-multilingual/res/js/ |
Current File : /var/www/html/itworks/wp-content/plugins/woocommerce-multilingual/res/js/multi-currency.min.js |
jQuery(function(u){WCML_Multi_Currency={_currency_languages_saving:0,init:function(){u(document).ready(function(){WCML_Multi_Currency.setup_multi_currency_toggle(),u(document).on("change",".currency_code select",WCML_Multi_Currency.select_currency),u(document).on("click",".delete_currency",WCML_Multi_Currency.delete_currency),u(document).on("click",".wcml_currency_options .currency_options_save",WCML_Multi_Currency.save_currency),u(document).on("click",".js-display-tooltip",WCML_Multi_Currency.tooltip),u(document).on("click",".currency_languages a.otgs-ico-no",WCML_Multi_Currency.enable_currency_for_language),u(document).on("click",".currency_languages a.otgs-ico-yes",WCML_Multi_Currency.disable_currency_for_language),u(document).on("change",".default_currency select",WCML_Multi_Currency.change_default_currency),WCML_Multi_Currency.setup_currencies_sorting(),u(document).on("change",".currency_option_position",WCML_Multi_Currency.price_preview),u(document).on("change",".currency_option_thousand_sep",WCML_Multi_Currency.price_preview),u(document).on("change",".currency_option_decimal_sep",WCML_Multi_Currency.price_preview),u(document).on("change",".currency_option_decimals",WCML_Multi_Currency.price_preview),u(document).on("change",".currency_code select",WCML_Multi_Currency.price_preview),u(document).on("change",".wcml-gateways-enabled",WCML_Multi_Currency.display_gateways),u(document).on("change","#wcml_currency_options_gateway_code_paypal",WCML_Multi_Currency.preset_paypal_email),u(document).on("change","#wcml_currency_options_gateway_code_stripe",WCML_Multi_Currency.preset_stripe_settings),u(document).on("keypress",".currency_option_decimals",function(e){(8!=e.which&&0!=e.which&&e.which<48||57<e.which)&&e.preventDefault()}),u(document).on("keyup",".wcml-exchange-rate",WCML_Multi_Currency.exchange_rate_check),u("#wcml_mc_options").length&&(WCML_Multi_Currency.wcml_mc_form_submitted=!1,WCML_Multi_Currency.read_form_fields_status(),window.onbeforeunload=function(e){if(!WCML_Multi_Currency.wcml_mc_form_submitted&&WCML_Multi_Currency.form_fields_changed()||WCML_Multi_Currency.is_update_currency_lang_in_progress())return u("#wcml_warn_message").val()},u("#wcml_mc_options").on("submit",function(){WCML_Multi_Currency.wcml_mc_form_submitted=!0}))})},setup_multi_currency_toggle:function(){u("#multi_currency_independent").change(function(){"checked"==u(this).attr("checked")?u("#currency-switcher, #currency-switcher-widget, #currency-switcher-product, #multi-currency-per-language-details, #online-exchange-rates").fadeIn():u("#currency-switcher, #currency-switcher-widget, #currency-switcher-product, #multi-currency-per-language-details, #online-exchange-rates").fadeOut()})},select_currency:function(){var e=u(this).closest(".wcml_currency_options"),c=e.find(".wcml-dialog-close-button"),r=e.find(".this-currency").text(),n=e.find(".wcml-gateways-switcher"),t=e.find('.wcml-gateways select[name*="[currency]"] option[value="'+r+'"]'),a=n.find("label.otgs-on-off-switch").text().replace(r,u(this).val());c.attr("data-currency",u(this).val()),c.attr("data-symbol",u(this).find("option:selected").attr("data-symbol")),e.find(".this-currency").html(u(this).val()),n.find("label.otgs-on-off-switch").text(a),t.val(u(this).val()),t.html(u(this).val())},delete_currency:function(e){e.preventDefault();var c=!1,r=u(this).data("currency"),n=u(this).data("currency_name"),t=u(this).data("currency_symbol");if(u(".currency_lang_table .wcml-row-currency-lang:first .currency_languages").each(function(){if(!WCML_Multi_Currency.check_currency_language(u(this).find("li").data("lang"),r))return!(c=!0)}),!c){u("#currency_row_"+r+" .currency_action_update").hide();var a=u('<span class="spinner" style="visibility: visible;margin:0;">');return u(this).hide(),u(this).parent().append(a).show(),u.ajax({type:"post",url:ajaxurl,data:{action:"wcml_delete_currency",wcml_nonce:u("#del_currency_nonce").val(),code:r},success:function(e){u("#currency_row_"+r).remove(),u("#currency_row_langs_"+r).remove(),u("#wcml-row-currency-actions-"+r).remove(),u("#wcml_currencies_order .wcml_currencies_order_"+r).remove(),u("#wcml_currency_options_code_").prepend('<option data-symbol="'+t+'" value="'+r+'">'+n+"</option>"),u("#wcml_currency_options_code_").val(r).trigger("change"),u("#currency-lang-table").find("tr.default_currency select").each(function(){u(this).find("option[value='"+r+"']").remove()}),u(".wcml-ui-dialog").each(function(){WCML_Currency_Switcher_Settings.currency_switcher_preview(u(this))}),1==u(".wcml-row-currency").length&&(u("#online-exchange-rates-no-currencies").next().hide(),u("#online-exchange-rates-no-currencies").show())},done:function(){a.remove()}}),!1}},save_currency:function(){var l=u(this).closest(".wcml-dialog-container");if(WCML_Multi_Currency.check_on_numeric(l,".abstract_amount"))return!1;u(".wcml-currency-options-dialog :submit, .wcml-currency-options-dialog :button").prop("disabled",!0);var _=l.find('[name="currency_options[code]"]').val(),e=u('<span class="spinner" style="visibility:visible;position:absolute;margin-left:10px;"></span>');return e.show(),u(this).parent().prepend(e),u.ajax({url:ajaxurl,type:"POST",dataType:"json",data:l.find('[name^="currency_options"]').serialize()+"&action=wcml_save_currency&wcml_nonce="+jQuery("#wcml_save_currency_nonce").val(),success:function(e){if(l.find(".wcml-dialog-close-button").trigger("click"),u(".wcml-ui-dialog").each(function(){WCML_Currency_Switcher_Settings.currency_switcher_preview(u(this))}),0==u("#currency_row_"+_).length){var c;(c=u("#currency-table tr.wcml-row-currency:last").clone()).attr("id","currency_row_"+_),u("#currency-table").find("tr.default_currency").before(c),(c=u(".empty-currency-language-row").clone()).attr("id","currency_row_langs_"+_),u("#currency-lang-table").find("tr.default_currency").before(c),c.removeClass("hidden empty-currency-language-row"),c.find(".on a").each(function(){u(this).attr("data-currency",_),u(this).attr("title",u(this).attr("title").replace("%code%",e.currency_name)),u(this).attr("data-title-alt",u(this).attr("data-title-alt").replace("%code%",e.currency_name))}),u("#currency-lang-table").find("tr.default_currency select").each(function(){u(this).append('<option value="'+_+'">'+_+"</option>")}),u("#wcml_currencies_order").append('<li class="wcml_currencies_order_'+_+' ui-sortable-handle" cur="'+_+'">'+e.currency_name_formatted+"</li>");var r=u("#currency-settings-table tr.wcml-row-currencies-actions:last").clone();r.attr("id","wcml-row-currency-actions-"+_);var n=r.find(".wcml-col-edit a");n.attr("data-content","wcml_currency_options_"+_),n.attr("data-currency",_),n.data("dialog","wcml_currency_options_"+_),n.removeClass("hidden");var t=r.find(".delete_currency");t.removeClass("hidden"),t.attr("data-currency",_),t.attr("data-currency_name",e.currency_name),t.attr("data-currency_symbol",e.currency_symbol),u("#currency-settings-table").find("tr.default_currency").before(r)}u("#currency_row_"+_+" .wcml-col-currency").html(e.currency_name_formatted),u("#currency_row_"+_+" .wcml-col-rate").html(e.currency_meta_info);var a=u("#wcml_currency_options_"+_).find(".wcml-gateways-switcher");0==a.length&&(a=u("#wcml_currency_options_").find(".wcml-gateways-switcher").clone()),u("#wcml_currency_options_"+_).remove(),u("#wcml_mc_options").before(e.currency_options),u('#wcml_currency_options_code_ option[value="'+_+'"]').remove(),u("#online-exchange-rates-no-currencies").is(":visible")&&(u("#online-exchange-rates-no-currencies").hide(),u("#online-exchange-rates-no-currencies").next().show());var i=u("#wcml_currency_options_"+_),s=0<i.find('.wcml-gateways-switcher input[type="checkbox"]:checked').length;i.find(".wcml-gateways-switcher").remove(),i.find(".wcml-gateways").before(a),s?i.find('.wcml-gateways-switcher input[type="checkbox"]').attr("checked","checked"):i.find('.wcml-gateways-switcher input[type="checkbox"]').removeAttr("checked")}}),!1},check_on_numeric:function(e,c){var r=u('<span class="wcml-error">');return WCML_Multi_Currency.is_number(e.find(c).val())?(0<e.find(c).parent().find(".wcml-error").size()&&e.find(c).parent().find(".wcml-error").remove(),!1):(0==e.find(c).parent().find(".wcml-error").size()&&(e.find(c).parent().append(r),r.text(e.find(c).data("message"))),!0)},tooltip:function(){var e=u(this);u(".wp-pointer").fadeOut(100),u(this).pointer({content:"<h3>"+e.data("header")+"</h3><p>"+e.data("content")+"</p>",position:{edge:"left",align:"center",offset:"15 0"}}).pointer("open")},enable_currency_for_language:function(e){if(WCML_Multi_Currency.is_update_currency_lang_in_progress())return!1;e.preventDefault(),u(this).addClass("spinner").removeClass("otgs-ico-no").css("visibility","visible");u(this).closest("tr")[0].rowIndex;u('.default_currency select[rel="'+u(this).data("language")+'"]').append('<option value="'+u(this).data("currency")+'">'+u(this).data("currency")+"</option>"),WCML_Multi_Currency.update_currency_lang(u(this),1,0);var c=u(this).data("title-alt");u(this).data("title-alt",u(this).attr("title")),u(this).attr("title",c)},disable_currency_for_language:function(e){if(WCML_Multi_Currency.is_update_currency_lang_in_progress())return!1;e.preventDefault(),u(this).addClass("spinner").removeClass("otgs-ico-yes").css("visibility","visible");var c=u(this).data("language");if(WCML_Multi_Currency.check_currency_language(c)){u(this).closest("tr")[0].rowIndex;u('.currency_languages select[rel="'+u(this).data("language")+'"]').val()==u(this).data("currency")?WCML_Multi_Currency.update_currency_lang(u(this),0,1):WCML_Multi_Currency.update_currency_lang(u(this),0,0),u('.default_currency select[rel="'+u(this).data("language")+'"] option[value="'+u(this).data("currency")+'"]').remove();var r=u(this).data("title-alt");u(this).data("title-alt",u(this).attr("title")),u(this).attr("title",r)}else u(this).removeClass("spinner").addClass("otgs-ico-yes")},check_currency_language:function(e,c){var r=u('#currency-lang-table a.otgs-ico-yes[data-language="'+e+'"]');return c&&(r=u('#currency-lang-table a.otgs-ico-yes[data-language="'+e+'"]').not(u('[data-currency="'+c+'"]'))),0!=r.length||(alert(u("#wcml_warn_disable_language_massage").val()),!1)},is_update_currency_lang_in_progress:function(){return void 0!==WCML_Multi_Currency._update_currency_lang_sync_flag&&1==WCML_Multi_Currency._update_currency_lang_sync_flag},set_update_currency_lang_in_progress:function(e){WCML_Multi_Currency._update_currency_lang_sync_flag=e},update_currency_lang:function(e,c,r){WCML_Multi_Currency._currency_languages_saving++,u("#wcml_mc_options :submit").attr("disabled","disabled"),u('input[name="wcml_mc_options"]').attr("disabled","disabled");var n=e.data("language"),t=e.data("currency");discard=!0,WCML_Multi_Currency.set_update_currency_lang_in_progress(1),u.ajax({type:"post",url:ajaxurl,data:{action:"wcml_update_currency_lang",value:c,lang:n,code:t,wcml_nonce:u("#update_currency_lang_nonce").val()},success:function(){r&&WCML_Multi_Currency.update_default_currency(n,0)},complete:function(){u('input[name="wcml_mc_options"]').removeAttr("disabled"),discard=!1,e.removeClass("spinner").css("visibility","visible"),c?e.addClass("otgs-ico-yes"):e.addClass("otgs-ico-no"),WCML_Multi_Currency._currency_languages_saving--,0==WCML_Multi_Currency._currency_languages_saving&&u("#wcml_mc_options :submit").removeAttr("disabled"),WCML_Multi_Currency.set_update_currency_lang_in_progress(0)}})},change_default_currency:function(){WCML_Multi_Currency.update_default_currency(u(this).attr("rel"),u(this).val(),u(this))},update_default_currency:function(e,c,r){if(u("#wcml_mc_options_submit").attr("disabled","disabled"),r){var n=u('<span class="spinner" style="visibility: visible;float:none;position: absolute">');r.parent().append(n)}discard=!0,u.ajax({type:"post",url:ajaxurl,data:{action:"wcml_update_default_currency",lang:e,code:c,wcml_nonce:u("#wcml_update_default_currency_nonce").val()},complete:function(){discard=!1,u("#wcml_mc_options_submit").removeAttr("disabled"),r&&r.parent().find(".spinner").remove()}})},is_number:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},setup_currencies_sorting:function(){u("#wcml_currencies_order").sortable({update:function(){var e=[];u("#wcml_currencies_order").find("li").each(function(){e.push(u(this).attr("cur"))}),u.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"wcml_currencies_order",wcml_nonce:u("#wcml_currencies_order_order_nonce").val(),order:e.join(";")},success:function(e){e.success&&(fadeInAjxResp(".wcml_currencies_order_ajx_resp",e.data.message),u(".wcml-ui-dialog").each(function(){WCML_Currency_Switcher_Settings.currency_switcher_preview(u(this))}))}})}})},price_preview:function(){var e=u(this).closest(".wcml_currency_options"),c=e.find(".currency_option_position").val(),r=e.find(".currency_option_thousand_sep").val(),n=(r=e.find(".currency_option_thousand_sep").val(),e.find(".currency_option_decimal_sep").val()),t=u(this).closest(".wcml_currency_options").find(".wcml-dialog-close-button").attr("data-symbol"),a="56789".substr(0,e.find(".currency_option_decimals").val());""==a&&(n="");var i="";switch(c){case"left":i="{symbol}1{thousand_sep}234{decimal_sep}{decimals}";break;case"right":i="1{thousand_sep}234{decimal_sep}{decimals}{symbol}";break;case"left_space":i="{symbol} 1{thousand_sep}234{decimal_sep}{decimals}";break;case"right_space":i="1{thousand_sep}234{decimal_sep}{decimals} {symbol}"}var s=i.replace(/\{symbol\}/,t).replace(/\{thousand_sep\}/,r).replace(/\{decimal_sep\}/,n).replace(/\{decimals\}/,a);return e.find(".wcml-co-preview-value").html(s),!1},display_gateways:function(){"checked"==u(this).attr("checked")?(u(".wcml-gateways").slideDown(),WCML_Tooltip.init()):u(".wcml-gateways").slideUp()},preset_paypal_email:function(){var e=u('input[name="currency_options[gateways_settings][paypal][value]"]'),c=u(".paypal-gateway-warning");e.val(u(this).find(":selected").data("email")),u(this).find(":selected").data("is-valid")?(c.hide(),e.removeAttr("readonly")):(c.show(),e.val(""),e.attr("readonly","readonly"))},preset_stripe_settings:function(){u('input[name="currency_options[gateways_settings][stripe][publishable_key]"]').val(u(this).find(":selected").data("publishable-key")),u('input[name="currency_options[gateways_settings][stripe][secret_key]"]').val(u(this).find(":selected").data("secret-key"))},read_form_fields_status:function(){this.mc_form_status=u("#wcml_mc_options").serialize()},form_fields_changed:function(){return this.mc_form_status!=u("#wcml_mc_options").serialize()},exchange_rate_check:function(e){if(void 0===c)var c={DOM_SUBTRACT:109,DOM_DASH:189,DOM_E:69};u(this).val()<=0||!WCML_Multi_Currency.is_number(u(this).val())||e.keyCode==c.DOM_SUBTRACT||e.keyCode==c.DOM_DASH||e.keyCode==c.DOM_E?(u(".wcml-co-set-rate .wcml-error").fadeIn(),u(".currency_options_save").attr("disabled","disabled")):(u(".wcml-co-set-rate .wcml-error").fadeOut(),u(".currency_options_save").removeAttr("disabled"))}},WCML_Multi_Currency.init()});