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 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.9.0 4.9.1 5.0.1 5.0.2 5.1.1 5.1.2 5.1.3 5.2.0 5.2.1 5.3.2 5.3.3.1 5.3.4 5.3.5 5.3.6 5.3.7
woocommerce-multilingual / res / js / currency-switcher-settings.js
woocommerce-multilingual / res / js Last commit date
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
currency-switcher-settings.js
315 lines
1
2 jQuery( function($){
3
4 WCML_Currency_Switcher_Settings = {
5
6 _currency_languages_saving : 0,
7
8 init: function(){
9
10 $(function(){
11
12 $(document).on('change','#currency_switcher_style', WCML_Currency_Switcher_Settings.update_currency_switcher_style);
13 $(document).on('click','.currency_switcher_save', WCML_Currency_Switcher_Settings.save_currency_switcher_settings);
14 $(document).on('click','.delete_currency_switcher', WCML_Currency_Switcher_Settings.delete_currency_switcher);
15
16 $(document).on('change','.js-wcml-cs-colorpicker-preset', WCML_Currency_Switcher_Settings.set_currency_switcher_color_pre_set );
17
18 $(document).on('keyup','input[name="wcml_curr_template"]', WCML_Currency_Switcher_Settings.setup_currency_switcher_template_keyup);
19 $(document).on('change','input[name="wcml_curr_template"]', WCML_Currency_Switcher_Settings.setup_currency_switcher_template_change);
20
21 $( document ).on( 'click', '.js-wcml-learn-more-button', WCML_Currency_Switcher_Settings.open_learn_more_diaglog );
22
23 WCML_Currency_Switcher_Settings.open_dialog_from_hash();
24
25 document.addEventListener('wcmlActiveCurrenciesChange', function(e) {
26 var action = e.detail.action;
27 var currency = e.detail.currency;
28 var currencyData = e.detail.currencyData;
29 var isAddingFirstSecondaryCurrency = function() {
30 return wcmlMultiCurrency && wcmlMultiCurrency.activeCurrencies && wcmlMultiCurrency.activeCurrencies.length < 2;
31 };
32
33 if (isAddingFirstSecondaryCurrency()) {
34 $('#wcml_mc_options_submit').click();
35 return;
36 }
37
38 if ('add' === action) {
39 $('#wcml_currencies_order').append('<li class="wcml_currencies_order_'+currency.code+' ui-sortable-handle" cur="'+currency.code+'">'+ currencyData.label + ' (' + currencyData.symbol + ')</li>');
40 } else if ('remove' === action) {
41 $('#wcml_currencies_order .wcml_currencies_order_'+ currency.code).remove();
42 }
43 });
44
45 document.addEventListener('wcmlCurrencyModeChange', function(e) {
46 $('#display_custom_prices_select,#currency-switcher, #currency-switcher-widget, #currency-switcher-product, #multi-currency-per-language-details, #online-exchange-rates').fadeIn();
47 });
48 } );
49
50 },
51
52 initColorPicker : function() {
53 $('.wcml-ui-dialog .js-wcml-cs-panel-colors').find('.js-wcml-cs-colorpicker').wpColorPicker({
54 change: function(e){
55 var dialog = $( this ).closest( '.wcml-ui-dialog' );
56 WCML_Currency_Switcher_Settings.currency_switcher_preview( dialog );
57 },
58 clear: function(e){
59 var dialog = $( this ).closest( '.wcml-ui-dialog' );
60 WCML_Currency_Switcher_Settings.currency_switcher_preview( dialog );
61 }
62 });
63 },
64
65 save_currency_switcher_settings: function(){
66
67 var dialog = $( this ).closest( '.wcml-ui-dialog' );
68 var ajaxLoader = $('<span class="spinner" style="visibility: visible;"></span>');
69 var widget_name = dialog.find('#wcml-cs-widget option:selected').text();
70 var switcher_id = dialog.find('#wcml_currencies_switcher_id').val();
71 var widget_id = dialog.find('#wcml-cs-widget').val();
72 var widget_title = dialog.find('input[name="wcml_cs_widget_title"]').val();
73 var switcher_style = dialog.find('#currency_switcher_style').val();
74
75 ajaxLoader.show();
76 $(this).parent().append(ajaxLoader);
77 dialog.find(':submit,:button').prop('disabled', true);
78
79 var template = dialog.find('input[name="wcml_curr_template"]').val();
80 if(!template){
81 template = dialog.find('#currency_switcher_default').val();
82 }
83
84 var color_scheme = {};
85 dialog.find('input.js-wcml-cs-colorpicker').each( function(){
86 color_scheme[ $(this).attr('name') ] = $(this).val();
87 });
88
89 $.ajax({
90 type: 'POST',
91 dataType: 'json',
92 url: ajaxurl,
93 data: {
94 action: 'wcml_currencies_switcher_save_settings',
95 wcml_nonce: dialog.find('#wcml_currencies_switcher_save_settings_nonce').val(),
96 switcher_id: switcher_id,
97 widget_id: widget_id,
98 widget_title: widget_title,
99 switcher_style: switcher_style,
100 template: template,
101 color_scheme: color_scheme
102 },
103 success: function(e) {
104 dialog.find('.ui-dialog-titlebar-close').trigger('click');
105
106 if( typeof widget_id == 'undefined' ){
107 widget_id = switcher_id;
108 }
109
110 $('#wcml_currency_switcher_options_form_new_widget #wcml-cs-widget option').each( function(){
111 if( $(this).val() == widget_id ){
112 $(this).remove();
113 }
114 });
115
116 if( $('#wcml_currency_switcher_options_form_new_widget #wcml-cs-widget option').length == 0 ){
117 $('.wcml_add_cs_sidebar').fadeOut();
118 }
119
120 if( $('#currency-switcher-widget .wcml-cs-list').find('thead tr').is(':hidden') ){
121 $('#currency-switcher-widget .wcml-cs-list').find('thead tr').fadeIn();
122 }
123
124 if( $('.wcml-currency-preview.' + widget_id ).length == 0 ){
125
126 var widget_row = $('.wcml-cs-empty-row').clone();
127 widget_row.removeClass('wcml-cs-empty-row');
128 widget_row.find('.wcml-currency-preview').addClass(widget_id);
129 widget_row.find('.wcml-cs-widget-name').html( widget_name );
130 widget_row.find('.edit_currency_switcher').attr('data-switcher', widget_id );
131 widget_row.find('.edit_currency_switcher').attr('data-dialog', 'wcml_currency_switcher_options_' + widget_id );
132 widget_row.find('.edit_currency_switcher').attr('data-content', 'wcml_currency_switcher_options_' + widget_id );
133 widget_row.find('.delete_currency_switcher').attr('data-switcher', widget_id );
134 widget_row.show();
135
136 $('.wcml-cs-list').find('tr.wcml-cs-empty-row').before( widget_row );
137 if( $('.wcml-cs-list').is(':hidden') ){
138 $('.wcml-cs-list').fadeIn();
139 }
140 }
141 $('#wcml_currency_switcher_options_' + widget_id).remove();
142 dialog.find('.wcml-dialog-container').attr('id','wcml-dialog-wcml_currency_switcher_options_'+ widget_id );
143 dialog.find(':submit,:button').prop('disabled', false);
144 dialog.find('#wcml_currencies_switcher_id').val( widget_id );
145 ajaxLoader.remove();
146
147 WCML_Currency_Switcher_Settings.currency_switcher_preview( dialog, true );
148 }
149 });
150
151 return false;
152 },
153
154 delete_currency_switcher: function(e){
155
156 e.preventDefault();
157
158 var switcher_id = $(this).data( 'switcher' );
159 var switcher_row = $(this).closest('tr');
160 var ajaxLoader = $('<span class="spinner" style="visibility: visible;">');
161 $(this).parent().html( ajaxLoader );
162
163 $.ajax({
164 type: 'POST',
165 dataType: 'json',
166 url: ajaxurl,
167 data: {
168 action: 'wcml_delete_currency_switcher',
169 wcml_nonce: $('#wcml_delete_currency_switcher_nonce').val(),
170 switcher_id: switcher_id
171 },
172 success: function(e){
173 var sidebar_name = switcher_row.find('.wcml-cs-widget-name').html();
174 $('#wcml_currency_switcher_options_form_new_widget #wcml-cs-widget').append( '<option value="'+switcher_id+'">'+sidebar_name+'</option>');
175
176 switcher_row.remove();
177
178 if( $('#currency-switcher-widget .wcml-cs-list').find('tbody tr').length == 1 ){
179 $('#currency-switcher-widget .wcml-cs-list').find('thead tr').fadeOut();
180 }
181 if( $('.wcml_add_cs_sidebar').is(':hidden') ){
182 $('.wcml_add_cs_sidebar').fadeIn();
183 }
184 }
185 });
186 },
187
188 currency_switcher_preview: _.debounce( function ( dialog, update_settings ){
189
190 var template = dialog.find('input[name="wcml_curr_template"]').val();
191 if(!template){
192 template = dialog.find('#currency_switcher_default').val();
193 }
194
195 var ajaxLoader = $('<span class="spinner" style="visibility: visible;">');
196 dialog.find('#wcml_curr_sel_preview_wrap').append(ajaxLoader);
197
198 var color_scheme = {};
199 dialog.find('input.js-wcml-cs-colorpicker').each( function(){
200 color_scheme[ $(this).attr('name') ] = $(this).val();
201 });
202
203 var switcher_id = dialog.find('#wcml_currencies_switcher_id').val();
204 var switcher_style = dialog.find('#currency_switcher_style').val();
205
206 $.ajax({
207 type: "POST",
208 url: ajaxurl,
209 dataType: 'json',
210 data: {
211 action: 'wcml_currencies_switcher_preview',
212 wcml_nonce: dialog.find('#wcml_currencies_switcher_preview_nonce').val(),
213 switcher_id: switcher_id,
214 switcher_style: switcher_style,
215 template: template,
216 color_scheme: color_scheme
217 },
218 success: function(resp){
219 if( resp.success ) {
220 resp = resp.data;
221 if( $( '#'+resp.inline_styles_id).length == 0 ){
222 $('head').append( '<style type="text/css" id="'+resp.inline_styles_id+'">'+ resp.inline_css+'</style>' );
223 }else{
224 $( '#'+resp.inline_styles_id).html( resp.inline_css );
225 }
226 ajaxLoader.remove();
227 if( update_settings ){
228 if( switcher_id == 'new_widget'){
229 switcher_id = dialog.find('#wcml-cs-widget').val();
230 }
231 $('.wcml-currency-preview.'+switcher_id).html(resp.preview);
232 }else{
233 dialog.find('.wcml-currency-preview').html(resp.preview);
234 }
235
236 if( switcher_style == 'wcml-dropdown-click' ){
237 WCMLCurrecnySwitcherDropdownClick.init();
238 }
239 }
240
241 }
242 });
243 }, 500),
244
245 set_currency_switcher_color_pre_set: function (){
246
247 var color_sheme = $(this).val();
248 var dialog = $( this ).closest( '.wcml-ui-dialog' );
249
250 if( settings.pre_selected_colors[color_sheme] != 'undefined' ){
251 var selected_scheme = settings.pre_selected_colors[color_sheme];
252 var color;
253 for ( color in selected_scheme ) {
254 $('.wcml-ui-dialog input[name="'+color+'"]').val( selected_scheme[ color ] );
255 $('.wcml-ui-dialog input[name="'+color+'"]').closest('.wp-picker-container').find('.wp-color-result').css( 'background-color', selected_scheme[color] );
256 }
257 }
258
259 WCML_Currency_Switcher_Settings.currency_switcher_preview( dialog );
260 },
261
262 update_currency_switcher_style: function(e){
263 var dialog = $( this ).closest( '.wcml-ui-dialog' );
264 WCML_Currency_Switcher_Settings.currency_switcher_preview( dialog );
265 },
266
267 setup_currency_switcher_template_keyup: function(e){
268 var dialog = $( this ).closest( '.wcml-ui-dialog' );
269 discard = true;
270 $(this).closest('.wcml-section').find('.button-wrap input').css("border-color","#1e8cbe");
271 WCML_Currency_Switcher_Settings.currency_switcher_preview( dialog );
272 },
273
274 setup_currency_switcher_template_change: function(e){
275 if(!$(this).val()){
276 $(this).val($('#currency_switcher_default').val())
277 }
278 },
279
280 open_learn_more_diaglog: function( event ){
281 event.preventDefault();
282
283 const arrow = $( this ).closest( '.wcml-ui-dialog' ).find( '.js-arrow-toggle' );
284 const description = $( '.js-wcml-learn-more-content' );
285 const learnLabel = $( this ).closest( '.wcml-ui-dialog' ).find( '.js-wcml-learn-more-text' );
286 const hideLabel = $( this ).closest( '.wcml-ui-dialog' ).find( '.js-wcml-hide-more-text' );
287
288 description.toggle();
289
290 const isVisible = description.is( ':visible' );
291
292 learnLabel.toggle( !isVisible );
293 hideLabel.toggle( isVisible );
294
295 arrow
296 .toggleClass( 'otgs-ico-caret-down', !isVisible )
297 .toggleClass( 'otgs-ico-caret-up', isVisible );
298 },
299
300 open_dialog_from_hash: function(){
301 var hashParts = window.location.hash.substring(1).split('/'),
302 type = hashParts[0] || '',
303 slug = hashParts[1] || '';
304
305 if ( type == 'currency-switcher' ) {
306 $('.edit_currency_switcher[data-switcher="'+slug+'"]').trigger('click');
307 parent.location.hash = '';
308 }
309 }
310
311 }
312
313 WCML_Currency_Switcher_Settings.init();
314
315 } );