PluginProbe
Hostinger Tools / 2.2.3
Hostinger Tools v2.2.3
3.0.79 3.0.78 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 All 110 releases
← All changes | src/js/main.js +99 -136 1.9.1 → 2.2.3 View file →
@@ -1,160 +1,65 @@
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' );
13 + const adminBarGenerateContent = $( '#wp-admin-bar-create_content_with_ai' );
23 14
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 15 stepsTitle.on( 'click', function () {
58 16 $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass );
59 17 $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 );
60 18 } )
61 19
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 20 closeBtn.on( 'click', function () {
91 21 $( '.hsr-modal' ).removeClass( 'open' );
92 22 $( 'body' ).removeClass( 'modal-open' );
93 23 } )
24 +
25 + adminBarGenerateContent.click( function () {
26 + $( '.hsr-list__item' ).removeClass( 'hsr-active' );
27 + $('.hts-ai-assistant-tab').addClass( 'hsr-active' );
28 + $( '.hsr-tab-content' ).hide();
29 + $( ".hsr-tab-content[data-name='ai-assistant']" ).show();
30 + } );
31 +
94 32 navigationItem.click( function () {
95 - var clickedItem = $( this );
33 + let clickedItem = $( this );
34 +
96 35 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
36 +
97 37 clickedItem.addClass( 'hsr-active' );
98 38 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 - }
39 +
40 + $( '.hsr-tab-content' ).hide();
41 + $( '.hsr-tab-content[data-name="' + selectedTab + '"]' ).show();
42 +
121 43 add_admin_menu_class();
122 44 } );
123 45
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 - }
46 + if( window.location.hash ) {
47 + let tab = $( '.hsr-onboarding-navbar .hsr-wrapper__list .hsr-list__item[data-name="' + window.location.hash.split('#')[1] + '"]' )
131 48
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 - }
49 + if(tab.length > 0) {
50 + $( '.hsr-list__item' ).removeClass( 'hsr-active' );
51 + tab.addClass( 'hsr-active' );
139 52
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 - }
53 + $( '.hsr-tab-content' ).hide();
54 + $( '.hsr-tab-content[data-name="' + window.location.hash.split('#')[1] + '"]' ).show();
55 + }
56 + } else {
147 57
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 - }
58 + $( '.hsr-wrapper__list .hsr-list__item:first-of-type' ).addClass( 'hsr-active' );
156 59
60 + }
61 +
157 62 helpCard.click( function () {
158 63 window.open( 'https://hostinger.com/cpanel-login?r=jump-to/new-panel/section/help', '_blank' );
159 64 } );
160 65 knowledgeCard.click( function () {
@@ -160,8 +65,26 @@
160 65 knowledgeCard.click( function () {
161 66 window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' );
162 67 } );
163 68
69 + $('body').on('click', '.hst-open-affiliate-tab', function(e) {
70 + e.preventDefault();
71 +
72 + $( 'li.hsr-list__item[data-name="amazon_affiliate"]' ).trigger( 'click' );
73 + } );
74 +
75 + $('body').on('click', '#hst-connect_affiliate_settings', function(e) {
76 + e.preventDefault();
77 +
78 + $( 'li.hsr-list__item[data-name="amazon_affiliate"]' ).trigger( 'click' );
79 +
80 + document.dispatchEvent(
81 + new CustomEvent('scrollToAffiliateSettings', {
82 + bubbles: true
83 + })
84 + );
85 + } );
86 +
164 87 document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) {
165 88 const firstItem = document.querySelector( '.hsr-playlist-item:first-child' );
166 89 firstItem.classList.add( 'hsr-active-video' );
167 90 firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
@@ -175,24 +98,19 @@
175 98 } );
176 99 } );
177 100
178 101 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 - ];
102 + const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
185 103
186 - const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
187 104 if ( hostingerSubMenu ) {
188 105 hostingerSubMenu.forEach( item => {
189 106 item.classList.remove( 'current' );
190 107 } );
191 108
192 - tabSelectors.forEach( ( selector, index ) => {
193 - const tab = document.querySelector( selector );
194 - if ( tab && tab.classList.contains( 'hsr-active' ) ) {
109 + const tabSelectors = document.querySelectorAll( '.hsr-onboarding-navbar .hsr-wrapper__list .hsr-list__item' );
110 +
111 + tabSelectors.forEach( ( item, index ) => {
112 + if ( item.classList.contains( 'hsr-active' ) ) {
195 113 if ( typeof hostingerSubMenu[ index + 1 ] !== "undefined" ) {
196 114 hostingerSubMenu[ index + 1 ].classList.add( 'current' );
197 115 }
198 116 }
@@ -197,9 +115,8 @@
197 115 }
198 116 }
199 117 } );
200 118 }
201 -
202 119 }
203 120
204 121 add_admin_menu_class();
205 122
@@ -219,7 +136,53 @@
219 136 document.execCommand('copy');
220 137 document.body.removeChild(textArea);
221 138 }
222 139
223 - } );
140 + //Sidebar menu script
141 + window.addEventListener( 'resize', function () {
142 +
143 + var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
144 + var navbarWrapper = document.querySelector( '.hsr-wrapper__list' );
145 + var mobileSidebar = document.querySelector( '.hsr-mobile-sidebar .hsr-wrapper' );
146 + var hpanelLink = document.querySelector( '.hsr-go-to-hpanel' );
147 +
148 +
149 + if ( windowWidth <= 1000 ) {
150 + if ( navbarWrapper && mobileSidebar ) {
151 + mobileSidebar.appendChild( navbarWrapper );
152 + mobileSidebar.appendChild( hpanelLink );
153 + }
154 + } else {
155 + var originalParent = document.querySelector( '.hsr-onboarding-navbar__wrapper' );
156 + if ( navbarWrapper && originalParent ) {
157 + originalParent.appendChild( navbarWrapper );
158 + originalParent.appendChild( hpanelLink );
159 + document.querySelector( '.hsr-mobile-sidebar' ).classList.remove( 'hsr-active' );
160 + }
161 + }
162 + } );
163 +
164 + window.dispatchEvent( new Event( 'resize' ) );
165 +
166 +
167 + var mobileSidebar = document.querySelector( '.hsr-mobile-sidebar' );
168 + var closeButtons = document.querySelectorAll( '.hsr-close, .hsr-mobile-menu-icon' );
169 +
170 + closeButtons.forEach( function ( button ) {
171 + button.addEventListener( 'click', function ( event ) {
172 + mobileSidebar.classList.toggle( 'hsr-active' );
173 + document.querySelector('body').classList.toggle( 'hsr-sidebar-active' );
174 + event.stopPropagation();
175 + } );
176 + } );
177 +
178 + document.addEventListener( 'click', function ( event ) {
179 + if ( ! mobileSidebar.contains( event.target ) ) {
180 + mobileSidebar.classList.remove( 'hsr-active' );
181 + document.querySelector('body').classList.remove( 'hsr-sidebar-active' );
182 + }
183 + } );
184 + } );
185 +
186 +
224 187
225 188 } )( jQuery );