PluginProbe
Hostinger Tools / 1.9.4
Hostinger Tools v1.9.4
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.9.4, at src/js/main.js

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