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