PluginProbe
Hostinger Tools / 2.1.8
Hostinger Tools v2.1.8
3.0.77 3.0.76 3.0.75 3.0.74 3.0.73 3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 All 108 releases
hostinger / src / js / woo-onboarding.js

woo-onboarding.js in Hostinger Tools 2.1.8, at src/js/woo-onboarding.js

58 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2
3 $( document ).ready(function() {
4
5 /**
6 * Button text switcher
7 */
8 $('body').on('change', 'input[name="chosen_onboarding"]:radio', function(e) {
9 let buttonLabel = $(this).data('button-label');
10 let imagePath = $(this).data('image-path');
11
12 $('.js-complete-woo-onboarding').html(buttonLabel);
13 $('.hostinger-woo-onboarding__column.hostinger-woo-onboarding__column--is-second img').attr('src', imagePath);
14 });
15
16 /**
17 * Button AJAX
18 */
19 $('body').on('click', 'a.js-complete-woo-onboarding', function(e) {
20 e.preventDefault();
21
22 if($('.hostinger-woo-onboarding').hasClass('hostinger-woo-onboarding--is-loading')) {
23 return;
24 }
25
26 $('.hostinger-woo-onboarding').addClass('hostinger-woo-onboarding--is-loading');
27
28 let choice = $('input[name="chosen_onboarding"]:checked').val();
29
30 $.ajax( {
31 url: ajaxurl,
32 method: 'POST',
33 beforeSend: function(request) {
34 request.setRequestHeader('Cache-Control', 'no-cache');
35 },
36 data: {
37 action: 'hostinger_woo_onboarding_choice',
38 nonce: hostingerContainer.nonce,
39 choice: choice
40 },
41 success: function ( response ) {
42
43 if( response.data.redirect_url ) {
44 window.location.href = response.data.redirect_url;
45 } else {
46 $('.hostinger-woo-onboarding').removeClass('hostinger-woo-onboarding--is-loading');
47 }
48
49 },
50 error: function ( xhr, status, error ) {
51 console.log( 'AJAX request failed: ' + error );
52 }
53 } );
54 });
55 });
56
57 })(jQuery);
58