| @@ -1,85 +1,22 @@ | ||
| 1 | +import './actions' | |
| 1 | 2 | import './videos' |
| 2 | 3 | |
| 3 | 4 | ( function ( $ ) { |
| 4 | 5 | $( document ).on( 'ready', function () { |
| 5 | 6 | const openClass = 'open'; |
| 6 | - const completedClass = 'completed'; | |
| 7 | 7 | let selectedTab = 'Home'; |
| 8 | 8 | const stepsTitle = $( '.hsr-onboarding-step--title' ) |
| 9 | - const gotItBtn = $( '.hsr-got-it-btn' ); | |
| 10 | - const publishBtn = $( '.hsr-publish-btn' ); | |
| 11 | 9 | const closeBtn = $( '.hsr-close-btn' ); |
| 12 | 10 | const navigationItem = $( '.hsr-list__item' ); |
| 13 | 11 | const knowledgeCard = $( '#card-knowledge' ); |
| 14 | 12 | const helpCard = $( '#card-help' ); |
| 15 | 13 | |
| 16 | - gotItBtn.on( 'click', function ( e ) { | |
| 17 | - e.preventDefault(); | |
| 18 | - const element = $( this ); | |
| 19 | - const step = $( this ).data( 'step' ); | |
| 20 | - let remaining_tasks = $( '.hsr-onboarding-steps' ).data( 'remaining-tasks' ); | |
| 21 | - | |
| 22 | - $.ajax( { | |
| 23 | - type: 'post', | |
| 24 | - dataType: 'json', | |
| 25 | - url: ajaxurl, | |
| 26 | - data: { | |
| 27 | - action: 'hostinger_complete_onboarding_step', | |
| 28 | - step: step, | |
| 29 | - }, | |
| 30 | - success: function () { | |
| 31 | - element.closest( '.hsr-onboarding-step--content' ).slideUp() | |
| 32 | - element.parents( '.hsr-onboarding-step' ) | |
| 33 | - .find( '.hsr-onboarding-step--status' ) | |
| 34 | - .addClass( completedClass ) | |
| 35 | - | |
| 36 | - if ( remaining_tasks > 0 ) { | |
| 37 | - remaining_tasks = remaining_tasks - 1; | |
| 38 | - $( '.hsr-onboarding-steps' ).data( 'remaining-tasks', remaining_tasks ) | |
| 39 | - | |
| 40 | - if ( remaining_tasks === 0 ) { | |
| 41 | - $( '.hsr-publish-btn' ).addClass( completedClass ); | |
| 42 | - } | |
| 43 | - | |
| 44 | - } | |
| 45 | - }, | |
| 46 | - } ) | |
| 47 | - } ) | |
| 48 | - | |
| 49 | 14 | stepsTitle.on( 'click', function () { |
| 50 | 15 | $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass ); |
| 51 | 16 | $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 ); |
| 52 | 17 | } ) |
| 53 | 18 | |
| 54 | - publishBtn.on( 'click', function ( e ) { | |
| 55 | - e.preventDefault(); | |
| 56 | - $( '.hsr-modal' ).addClass( 'open' ); | |
| 57 | - $( 'body' ).addClass( 'modal-open' ); | |
| 58 | - $.ajax( { | |
| 59 | - type: 'post', | |
| 60 | - dataType: 'json', | |
| 61 | - url: ajaxurl, | |
| 62 | - data: { | |
| 63 | - action: 'hostinger_publish_website', | |
| 64 | - maintenance: 0, | |
| 65 | - }, | |
| 66 | - success: function ( result ) { | |
| 67 | - const previewBtn = $( '.hsr-preview-btn' ); | |
| 68 | - $( '.hsr-circular' ).addClass( 'hsr-hide' ) | |
| 69 | - $( '.hsr-success-circular' ).addClass( 'hsr-show' ) | |
| 70 | - $( '.hsr-publish-modal--footer' ).addClass( 'show' ) | |
| 71 | - $( '.hsr-publish-modal--body h3' ).text( result.data.title ); | |
| 72 | - $( '.hsr-publish-modal--body__description' ).text( result.data.description ); | |
| 73 | - $( '.hsr-publish-btn' ).addClass( 'hsr-preview' ) | |
| 74 | - previewBtn.addClass( 'hsr-preview' ) | |
| 75 | - previewBtn.text( result.data.content.btn.text ) | |
| 76 | - $( '.hsr-onboarding__title' ).text( result.data.content.title ); | |
| 77 | - $( '.hsr-onboarding__description' ).text( result.data.content.description ); | |
| 78 | - }, | |
| 79 | - } ) | |
| 80 | - } ) | |
| 81 | - | |
| 82 | 19 | closeBtn.on( 'click', function () { |
| 83 | 20 | $( '.hsr-modal' ).removeClass( 'open' ); |
| 84 | 21 | $( 'body' ).removeClass( 'modal-open' ); |
| 85 | 22 | } ) |
| @@ -119,8 +56,26 @@ | ||
| 119 | 56 | } ); |
| 120 | 57 | knowledgeCard.click( function () { |
| 121 | 58 | window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' ); |
| 122 | 59 | } ); |
| 60 | + | |
| 61 | + $('body').on('click', '.hst-open-affiliate-tab', function(e) { | |
| 62 | + e.preventDefault(); | |
| 63 | + | |
| 64 | + $( 'li.hsr-list__item[data-name="amazon_affiliate"]' ).trigger( 'click' ); | |
| 65 | + } ); | |
| 66 | + | |
| 67 | + $('body').on('click', '#hst-connect_affiliate_settings', function(e) { | |
| 68 | + e.preventDefault(); | |
| 69 | + | |
| 70 | + $( 'li.hsr-list__item[data-name="amazon_affiliate"]' ).trigger( 'click' ); | |
| 71 | + | |
| 72 | + document.dispatchEvent( | |
| 73 | + new CustomEvent('scrollToAffiliateSettings', { | |
| 74 | + bubbles: true | |
| 75 | + }) | |
| 76 | + ); | |
| 77 | + } ); | |
| 123 | 78 | |
| 124 | 79 | document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) { |
| 125 | 80 | const firstItem = document.querySelector( '.hsr-playlist-item:first-child' ); |
| 126 | 81 | firstItem.classList.add( 'hsr-active-video' ); |