admin-currency-selector.js
1 year ago
admin-currency-selector.min.js
1 year ago
bacs-accounts-currencies.js
5 years ago
bacs-accounts-currencies.min.js
5 years ago
cart_widget.js
2 months ago
cart_widget.min.js
2 months ago
currency-switcher-settings.js
1 year ago
currency-switcher-settings.min.js
1 year ago
dialogs.js
5 years ago
dialogs.min.js
5 years ago
exchange-rates.js
3 years ago
exchange-rates.min.js
3 years ago
files.js
5 years ago
files.min.js
5 years ago
languages_notice.js
5 years ago
languages_notice.min.js
5 years ago
lock_fields.js
2 years ago
lock_fields.min.js
2 years ago
multi-currency.js
5 years ago
multi-currency.min.js
5 years ago
pointer.js
1 year ago
pointer.min.js
1 year ago
prices.js
5 years ago
prices.min.js
5 years ago
products-screen-option.js
5 years ago
products-screen-option.min.js
5 years ago
scripts.js
1 year ago
scripts.min.js
1 year ago
taxonomy_translation.js
1 year ago
taxonomy_translation.min.js
1 year ago
tooltip_init.js
5 years ago
tooltip_init.min.js
5 years ago
trnsl_interface_dialog_warning.js
5 years ago
trnsl_interface_dialog_warning.min.js
5 years ago
troubleshooting.js
1 year ago
troubleshooting.min.js
1 year ago
wcml-attributes.js
5 years ago
wcml-attributes.min.js
5 years ago
wcml-messages.js
5 years ago
wcml-messages.min.js
5 years ago
wcml-multi-currency.js
2 months ago
wcml-multi-currency.min.js
2 months ago
wcml-setup.js
3 years ago
wcml-setup.min.js
3 years ago
wcml-translation-editor.js
3 weeks ago
wcml-translation-editor.min.js
3 weeks ago
widgets.js
5 years ago
widgets.min.js
5 years ago
wpml_tm.js
5 years ago
wpml_tm.min.js
5 years ago
multi-currency.js
102 lines
| 1 | jQuery( function($){ |
| 2 | WCML_Multi_Currency = { |
| 3 | |
| 4 | _currency_languages_saving : 0, |
| 5 | |
| 6 | init: function(){ |
| 7 | |
| 8 | $(function(){ |
| 9 | |
| 10 | WCML_Multi_Currency.setup_multi_currency_toggle(); |
| 11 | |
| 12 | WCML_Multi_Currency.setup_currencies_sorting(); |
| 13 | |
| 14 | if($('#wcml_mc_options').length){ |
| 15 | WCML_Multi_Currency.wcml_mc_form_submitted = false; |
| 16 | WCML_Multi_Currency.read_form_fields_status(); |
| 17 | |
| 18 | window.onbeforeunload = function(e) { |
| 19 | if( |
| 20 | !WCML_Multi_Currency.wcml_mc_form_submitted |
| 21 | && WCML_Multi_Currency.form_fields_changed() |
| 22 | ){ |
| 23 | return $('#wcml_warn_message').val(); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | $('#wcml_mc_options').on('submit', function(){ |
| 28 | WCML_Multi_Currency.wcml_mc_form_submitted = true; |
| 29 | }) |
| 30 | } |
| 31 | |
| 32 | } ); |
| 33 | |
| 34 | }, |
| 35 | |
| 36 | setup_multi_currency_toggle: function(){ |
| 37 | |
| 38 | $('#multi_currency_independent').change(function(){ |
| 39 | |
| 40 | if($(this).prop('checked')){ |
| 41 | if($('#currency_mode').val()){ |
| 42 | $('#currency-switcher, #currency-switcher-widget, #currency-switcher-product, #multi-currency-per-language-details, #online-exchange-rates').fadeIn(); |
| 43 | }else{ |
| 44 | $('#multi-currency-per-language-details').fadeIn(); |
| 45 | } |
| 46 | }else{ |
| 47 | $('#currency-switcher, #currency-switcher-widget, #currency-switcher-product, #multi-currency-per-language-details, #online-exchange-rates').fadeOut(); |
| 48 | } |
| 49 | |
| 50 | }) |
| 51 | }, |
| 52 | |
| 53 | setup_currencies_sorting: function(){ |
| 54 | |
| 55 | $('#wcml_currencies_order').sortable({ |
| 56 | update: function(){ |
| 57 | var currencies_order = []; |
| 58 | $('#wcml_currencies_order').find('li').each(function(){ |
| 59 | currencies_order.push($(this).attr('cur')); |
| 60 | }); |
| 61 | $.ajax({ |
| 62 | type: "POST", |
| 63 | url: ajaxurl, |
| 64 | dataType: 'json', |
| 65 | data: { |
| 66 | action: 'wcml_currencies_order', |
| 67 | wcml_nonce: $('#wcml_currencies_order_order_nonce').val(), |
| 68 | order: currencies_order.join(';') |
| 69 | }, |
| 70 | success: function(resp){ |
| 71 | if ( resp.success ) { |
| 72 | fadeInAjxResp('.wcml_currencies_order_ajx_resp', resp.data.message); |
| 73 | $('.wcml-ui-dialog').each(function(){ |
| 74 | WCML_Currency_Switcher_Settings.currency_switcher_preview( $(this) ); |
| 75 | }); |
| 76 | } |
| 77 | } |
| 78 | }); |
| 79 | } |
| 80 | }); |
| 81 | |
| 82 | }, |
| 83 | |
| 84 | read_form_fields_status: function(){ |
| 85 | this.mc_form_status = this.get_serialized_options(); |
| 86 | }, |
| 87 | |
| 88 | form_fields_changed: function(){ |
| 89 | return this.mc_form_status != this.get_serialized_options(); |
| 90 | }, |
| 91 | |
| 92 | get_serialized_options: function() { |
| 93 | var reactUiElements = $('#wcml_mc_options .js-wcml-react-ui').find('input, select, textarea'); |
| 94 | reactUiElements.prop('disabled', true); |
| 95 | var serializedData = $('#wcml_mc_options').serialize(); |
| 96 | reactUiElements.prop('disabled', false); |
| 97 | return serializedData; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | WCML_Multi_Currency.init(); |
| 102 | } ); |