PluginProbe
Hostinger Tools / 2.1.1
Hostinger Tools v2.1.1
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
← All changes | src/js/main.js +91 -136 1.9.42.1.1 View file →
@@ -1,160 +1,57 @@
1 -import './autocomplete_steps';
1 +import './actions'
2 2 import './videos'
3 3
4 4 ( function ( $ ) {
5 5 $( document ).on( 'ready', function () {
6 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 7 let selectedTab = 'Home';
16 8 const stepsTitle = $( '.hsr-onboarding-step--title' )
17 - const gotItBtn = $( '.hsr-got-it-btn' );
18 - const publishBtn = $( '.hsr-publish-btn' );
19 9 const closeBtn = $( '.hsr-close-btn' );
20 10 const navigationItem = $( '.hsr-list__item' );
21 11 const knowledgeCard = $( '#card-knowledge' );
22 12 const helpCard = $( '#card-help' );
23 13
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 14 stepsTitle.on( 'click', function () {
58 15 $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass );
59 16 $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 );
60 17 } )
61 18
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 19 closeBtn.on( 'click', function () {
91 20 $( '.hsr-modal' ).removeClass( 'open' );
92 21 $( 'body' ).removeClass( 'modal-open' );
93 22 } )
23 +
94 24 navigationItem.click( function () {
95 - var clickedItem = $( this );
25 + let clickedItem = $( this );
26 +
96 27 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
28 +
97 29 clickedItem.addClass( 'hsr-active' );
98 30 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 - }
31 +
32 + $( '.hsr-tab-content' ).hide();
33 + $( '.hsr-tab-content[data-name="' + selectedTab + '"]' ).show();
34 +
121 35 add_admin_menu_class();
122 36 } );
123 37
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 - }
38 + if( window.location.hash ) {
39 + let tab = $( '.hsr-onboarding-navbar .hsr-wrapper__list .hsr-list__item[data-name="' + window.location.hash.split('#')[1] + '"]' )
131 40
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 - }
41 + if(tab.length > 0) {
42 + $( '.hsr-list__item' ).removeClass( 'hsr-active' );
43 + tab.addClass( 'hsr-active' );
139 44
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 - }
45 + $( '.hsr-tab-content' ).hide();
46 + $( '.hsr-tab-content[data-name="' + window.location.hash.split('#')[1] + '"]' ).show();
47 + }
48 + } else {
147 49
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 - }
50 + $( '.hsr-wrapper__list .hsr-list__item:first-of-type' ).addClass( 'hsr-active' );
156 51
52 + }
53 +
157 54 helpCard.click( function () {
158 55 window.open( 'https://hostinger.com/cpanel-login?r=jump-to/new-panel/section/help', '_blank' );
159 56 } );
160 57 knowledgeCard.click( function () {
@@ -160,8 +57,26 @@
160 57 knowledgeCard.click( function () {
161 58 window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' );
162 59 } );
163 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 + } );
78 +
164 79 document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) {
165 80 const firstItem = document.querySelector( '.hsr-playlist-item:first-child' );
166 81 firstItem.classList.add( 'hsr-active-video' );
167 82 firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
@@ -175,24 +90,19 @@
175 90 } );
176 91 } );
177 92
178 93 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 - ];
94 + const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
185 95
186 - const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
187 96 if ( hostingerSubMenu ) {
188 97 hostingerSubMenu.forEach( item => {
189 98 item.classList.remove( 'current' );
190 99 } );
191 100
192 - tabSelectors.forEach( ( selector, index ) => {
193 - const tab = document.querySelector( selector );
194 - if ( tab && tab.classList.contains( 'hsr-active' ) ) {
101 + const tabSelectors = document.querySelectorAll( '.hsr-onboarding-navbar .hsr-wrapper__list .hsr-list__item' );
102 +
103 + tabSelectors.forEach( ( item, index ) => {
104 + if ( item.classList.contains( 'hsr-active' ) ) {
195 105 if ( typeof hostingerSubMenu[ index + 1 ] !== "undefined" ) {
196 106 hostingerSubMenu[ index + 1 ].classList.add( 'current' );
197 107 }
198 108 }
@@ -197,9 +107,8 @@
197 107 }
198 108 }
199 109 } );
200 110 }
201 -
202 111 }
203 112
204 113 add_admin_menu_class();
205 114
@@ -219,7 +128,53 @@
219 128 document.execCommand('copy');
220 129 document.body.removeChild(textArea);
221 130 }
222 131
223 - } );
132 + //Sidebar menu script
133 + window.addEventListener( 'resize', function () {
134 +
135 + var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
136 + var navbarWrapper = document.querySelector( '.hsr-wrapper__list' );
137 + var mobileSidebar = document.querySelector( '.hsr-mobile-sidebar .hsr-wrapper' );
138 + var hpanelLink = document.querySelector( '.hsr-go-to-hpanel' );
139 +
140 +
141 + if ( windowWidth <= 1000 ) {
142 + if ( navbarWrapper && mobileSidebar ) {
143 + mobileSidebar.appendChild( navbarWrapper );
144 + mobileSidebar.appendChild( hpanelLink );
145 + }
146 + } else {
147 + var originalParent = document.querySelector( '.hsr-onboarding-navbar__wrapper' );
148 + if ( navbarWrapper && originalParent ) {
149 + originalParent.appendChild( navbarWrapper );
150 + originalParent.appendChild( hpanelLink );
151 + document.querySelector( '.hsr-mobile-sidebar' ).classList.remove( 'hsr-active' );
152 + }
153 + }
154 + } );
155 +
156 + window.dispatchEvent( new Event( 'resize' ) );
157 +
158 +
159 + var mobileSidebar = document.querySelector( '.hsr-mobile-sidebar' );
160 + var closeButtons = document.querySelectorAll( '.hsr-close, .hsr-mobile-menu-icon' );
161 +
162 + closeButtons.forEach( function ( button ) {
163 + button.addEventListener( 'click', function ( event ) {
164 + mobileSidebar.classList.toggle( 'hsr-active' );
165 + document.querySelector('body').classList.toggle( 'hsr-sidebar-active' );
166 + event.stopPropagation();
167 + } );
168 + } );
169 +
170 + document.addEventListener( 'click', function ( event ) {
171 + if ( ! mobileSidebar.contains( event.target ) ) {
172 + mobileSidebar.classList.remove( 'hsr-active' );
173 + document.querySelector('body').classList.remove( 'hsr-sidebar-active' );
174 + }
175 + } );
176 + } );
177 +
178 +
224 179
225 180 } )( jQuery );