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
4 weeks ago
wcml-translation-editor.min.js
4 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
exchange-rates.js
105 lines
| 1 | jQuery( function($){ |
| 2 | |
| 3 | WCMLExchangeRates = { |
| 4 | |
| 5 | init: function(){ |
| 6 | |
| 7 | $('#online-exchange-rates').on( 'change', '#exchange-rates-automatic', WCMLExchangeRates.toggleManualAutomatic ); |
| 8 | $('#online-exchange-rates').on( 'click', '#update-rates-manually', WCMLExchangeRates.updateRatesManually); |
| 9 | $('#online-exchange-rates').on( 'change', 'input[name=exchange-rates-service]', WCMLExchangeRates.selectService ); |
| 10 | $('#online-exchange-rates').on( 'change', 'input[name=update-schedule]', WCMLExchangeRates.updateFrequency ); |
| 11 | |
| 12 | WCMLExchangeRates.selectedService = $('input[name=exchange-rates-service]:checked').val(); |
| 13 | $('#online-exchange-rates').on( 'change', 'input[name=exchange-rates-service]', WCMLExchangeRates.toggleUpdateManuallyButton ); |
| 14 | $('#online-exchange-rates').on( 'change', 'input[name=lifting_charge]', WCMLExchangeRates.toggleUpdateManuallyButton ); |
| 15 | |
| 16 | }, |
| 17 | |
| 18 | toggleManualAutomatic: function(){ |
| 19 | |
| 20 | if($(this).prop('checked')){ |
| 21 | $('#exchange-rates-online-wrap').fadeIn(); |
| 22 | WCML_Tooltip && WCML_Tooltip.init(); // Re-init tooltips for the previously invisible ones. |
| 23 | }else{ |
| 24 | $('#exchange-rates-online-wrap').fadeOut(); |
| 25 | } |
| 26 | |
| 27 | }, |
| 28 | |
| 29 | updateRatesManually: function(){ |
| 30 | |
| 31 | var updateButton = $(this); |
| 32 | |
| 33 | $('#exchange-rates-error').html('').hide(); |
| 34 | $('#update-rates-spinner').css({ visibility: 'visible' }); |
| 35 | $('.exchange-rates-sources .notice-error').html('').hide(); |
| 36 | updateButton.prop('disabled', true); |
| 37 | |
| 38 | $.ajax({ |
| 39 | type: "post", |
| 40 | url: ajaxurl, |
| 41 | dataType: 'json', |
| 42 | data: { |
| 43 | action: "wcml_update_exchange_rates", |
| 44 | wcml_nonce: $('#update-exchange-rates-nonce').val() |
| 45 | }, |
| 46 | success: function (response) { |
| 47 | |
| 48 | if (response.success) { |
| 49 | $('#exchange-rates-success').fadeIn(); |
| 50 | $('#update-rates-time .time').text( response.last_updated ); |
| 51 | }else{ |
| 52 | if( response.error ){ |
| 53 | var serviceErrorWrap = $('#service-error-' + response.service.replace(/[^\w]/g, '') ); |
| 54 | serviceErrorWrap.text( response.error ).fadeIn(); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | $('#update-rates-spinner').css({ visibility: 'hidden' }); |
| 59 | updateButton.prop('disabled', false); |
| 60 | |
| 61 | for( code in response.rates ){ |
| 62 | $('#currency_row_' + code.replace(/[^\w]/g, '') + ' span.rate').hide().text( response.rates[code] ).fadeIn('slow'); |
| 63 | } |
| 64 | |
| 65 | } |
| 66 | }) |
| 67 | |
| 68 | }, |
| 69 | |
| 70 | /** |
| 71 | * @todo remove when moving to auto-saving forms |
| 72 | */ |
| 73 | toggleUpdateManuallyButton: function(){ |
| 74 | |
| 75 | if( WCMLExchangeRates.selectedService == $(this).val() ){ |
| 76 | $('#update-rates-manually').prop( 'disabled', false ); |
| 77 | $('#update-rates-manually').next('.wcml-tip').hide(); |
| 78 | } else { |
| 79 | $('#update-rates-manually').prop( 'disabled', true ); |
| 80 | $('#update-rates-manually').next('.wcml-tip').show().tipTip( WCML_Tooltip.default_args); |
| 81 | } |
| 82 | |
| 83 | }, |
| 84 | |
| 85 | selectService: function(){ |
| 86 | |
| 87 | $('.service-details-wrap').hide(); |
| 88 | $(this).parent().find('.service-details-wrap').show(); |
| 89 | |
| 90 | }, |
| 91 | |
| 92 | updateFrequency: function(){ |
| 93 | |
| 94 | $('[name="update-weekly-day"], [name="update-monthly-day"]').prop('disabled', true); |
| 95 | $(this).parent().find('select').prop('disabled', false); |
| 96 | |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | |
| 101 | |
| 102 | WCMLExchangeRates.init(); |
| 103 | |
| 104 | }); |
| 105 |