PluginProbe
Hostinger Tools / 1.8.3
Hostinger Tools v1.8.3
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 / main.js

main.js in Hostinger Tools 1.8.3, at src/js/main.js

191 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import './autocomplete_steps';
2 import './survey'
3 import './amplitude-events'
4 import './videos'
5
6 ( function ( $ ) {
7
8 $( document ).on( 'ready', function () {
9 const openClass = 'open';
10 const completedClass = 'completed';
11 const homeTab = $( '.hostinger.hsr-onboarding' );
12 const learnTab = $( '.hsr-learn-more' );
13 const aiAssistantTab = $( '.hsr-ai-assistant-tab' );
14 aiAssistantTab.hide();
15 learnTab.hide();
16 let selectedTab = 'Home';
17 const stepsTitle = $( '.hsr-onboarding-step--title' )
18 const gotItBtn = $( '.hsr-got-it-btn' );
19 const publishBtn = $( '.hsr-publish-btn' );
20 const closeBtn = $( '.hsr-close-btn' );
21 const navigationItem = $( '.hsr-list__item' );
22 const knowledgeCard = $( '#card-knowledge' );
23 const helpCard = $( '#card-help' );
24
25 gotItBtn.on( 'click', function ( e ) {
26 e.preventDefault();
27 const element = $( this );
28 const step = $( this ).data( 'step' );
29 let remaining_tasks = $( '.hsr-onboarding-steps' ).data( 'remaining-tasks' );
30
31 $.ajax( {
32 type: 'post',
33 dataType: 'json',
34 nonce: ajax_var.nonce,
35 url: ajaxurl,
36 data: {
37 action: 'hostinger_complete_onboarding_step',
38 step: step,
39 },
40 success: function () {
41 element.closest( '.hsr-onboarding-step--content' ).slideUp()
42 element.parents( '.hsr-onboarding-step' )
43 .find( '.hsr-onboarding-step--status' )
44 .addClass( completedClass )
45
46 if ( remaining_tasks > 0 ) {
47 remaining_tasks = remaining_tasks - 1;
48 $( '.hsr-onboarding-steps' ).data( 'remaining-tasks', remaining_tasks )
49
50 if ( remaining_tasks === 0 ) {
51 $( '.hsr-publish-btn' ).addClass( completedClass );
52 }
53
54 }
55 },
56 } )
57 } )
58
59 stepsTitle.on( 'click', function () {
60 $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass );
61 $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 );
62 } )
63
64 publishBtn.on( 'click', function ( e ) {
65 e.preventDefault();
66 $( '.hsr-modal' ).addClass( 'open' );
67 $( 'body' ).addClass( 'modal-open' );
68 $.ajax( {
69 type: 'post',
70 dataType: 'json',
71 nonce: ajax_var.nonce,
72 url: ajaxurl,
73 data: {
74 action: 'hostinger_publish_website',
75 maintenance: 0,
76 },
77 success: function ( result ) {
78 const previewBtn = $( '.hsr-preview-btn' );
79 $( '.hsr-circular' ).addClass( 'hsr-hide' )
80 $( '.hsr-success-circular' ).addClass( 'hsr-show' )
81 $( '.hsr-publish-modal--footer' ).addClass( 'show' )
82 $( '.hsr-publish-modal--body h3' ).text( result.data.title );
83 $( '.hsr-publish-modal--body__description' ).text( result.data.description );
84 $( '.hsr-publish-btn' ).addClass( 'hsr-preview' )
85 previewBtn.addClass( 'hsr-preview' )
86 previewBtn.text( result.data.content.btn.text )
87 $( '.hsr-onboarding__title' ).text( result.data.content.title );
88 $( '.hsr-onboarding__description' ).text( result.data.content.description );
89 },
90 } )
91 } )
92
93 closeBtn.on( 'click', function () {
94 $( '.hsr-modal' ).removeClass( 'open' );
95 $( 'body' ).removeClass( 'modal-open' );
96 } )
97 navigationItem.click( function () {
98 var clickedItem = $( this );
99 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
100 clickedItem.addClass( 'hsr-active' );
101 selectedTab = clickedItem.data( 'name' );
102 if ( selectedTab === 'home' ) {
103 homeTab.show();
104 aiAssistantTab.hide();
105 learnTab.hide();
106 } else if ( selectedTab === 'learn' ) {
107 homeTab.hide();
108 aiAssistantTab.hide();
109 learnTab.show();
110 } else if ( selectedTab === 'ai-assistant' ) {
111 homeTab.hide();
112 learnTab.hide();
113 aiAssistantTab.show();
114 }
115 add_admin_menu_class();
116 } );
117
118 if ( window.location.hash === "#ai-assistant" ) {
119 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
120 $( '.hsr-list__item.hts-ai-assistant-tab' ).addClass( 'hsr-active' );
121 homeTab.hide();
122 learnTab.hide();
123 aiAssistantTab.show();
124 }
125
126 if ( window.location.hash === "#home" ) {
127 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
128 $( '.hsr-list__item.hts-home-tab' ).addClass( 'hsr-active' );
129 homeTab.show();
130 aiAssistantTab.hide();
131 learnTab.hide();
132 }
133
134 if ( window.location.hash === "#learn" ) {
135 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
136 $( '.hsr-list__item.hts-learn-tab' ).addClass( 'hsr-active' );
137 homeTab.hide();
138 aiAssistantTab.hide();
139 learnTab.show();
140 }
141
142 helpCard.click( function () {
143 window.open( 'https://hostinger.com/cpanel-login?r=jump-to/new-panel/section/help', '_blank' );
144 } );
145 knowledgeCard.click( function () {
146 window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' );
147 } );
148
149 document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) {
150 const firstItem = document.querySelector( '.hsr-playlist-item:first-child' );
151 firstItem.classList.add( 'hsr-active-video' );
152 firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
153 item.addEventListener( 'click', function () {
154 document.querySelectorAll( '.hsr-playlist-item.hsr-active-video' ).forEach( function ( selectedItem ) {
155 selectedItem.classList.remove( 'hsr-active-video' );
156 selectedItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'hidden';
157 } );
158 this.classList.add( 'hsr-active-video' );
159 this.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
160 } );
161 } );
162
163 function add_admin_menu_class () {
164 const tabSelectors = [
165 '.hsr-list__item.hts-home-tab',
166 '.hsr-list__item.hts-learn-tab',
167 '.hsr-list__item.hts-ai-assistant-tab'
168 ];
169
170 const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
171 if ( hostingerSubMenu ) {
172 hostingerSubMenu.forEach( item => {
173 item.classList.remove( 'current' );
174 } );
175
176 tabSelectors.forEach( ( selector, index ) => {
177 const tab = document.querySelector( selector );
178 if ( tab && tab.classList.contains( 'hsr-active' ) ) {
179 hostingerSubMenu[ index + 1 ].classList.add( 'current' );
180 }
181 } );
182 }
183
184 }
185
186 add_admin_menu_class();
187
188 } );
189
190 } )( jQuery );
191