PluginProbe
Hostinger Tools / 2.1.8
Hostinger Tools v2.1.8
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 2.0.1 All 109 releases
← All changes | src/js/main.js +99 -117 1.9.52.1.8 View file →
@@ -1,141 +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 - 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' );
13 + const adminBarGenerateContent = $( '#wp-admin-bar-create_content_with_ai' );
21 14
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 15 stepsTitle.on( 'click', function () {
56 16 $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass );
57 17 $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 );
58 18 } )
59 19
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 20 closeBtn.on( 'click', function () {
89 21 $( '.hsr-modal' ).removeClass( 'open' );
90 22 $( 'body' ).removeClass( 'modal-open' );
91 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 +
92 32 navigationItem.click( function () {
93 - var clickedItem = $( this );
33 + let clickedItem = $( this );
34 +
94 35 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
36 +
95 37 clickedItem.addClass( 'hsr-active' );
96 38 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 39
40 + $( '.hsr-tab-content' ).hide();
41 + $( '.hsr-tab-content[data-name="' + selectedTab + '"]' ).show();
42 +
111 43 add_admin_menu_class();
112 44 } );
113 45
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 - }
46 + if( window.location.hash ) {
47 + let tab = $( '.hsr-onboarding-navbar .hsr-wrapper__list .hsr-list__item[data-name="' + window.location.hash.split('#')[1] + '"]' )
121 48
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 - }
49 + if(tab.length > 0) {
50 + $( '.hsr-list__item' ).removeClass( 'hsr-active' );
51 + tab.addClass( 'hsr-active' );
129 52
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 - }
53 + $( '.hsr-tab-content' ).hide();
54 + $( '.hsr-tab-content[data-name="' + window.location.hash.split('#')[1] + '"]' ).show();
55 + }
56 + } else {
137 57
58 + $( '.hsr-wrapper__list .hsr-list__item:first-of-type' ).addClass( 'hsr-active' );
59 +
60 + }
61 +
138 62 helpCard.click( function () {
139 63 window.open( 'https://hostinger.com/cpanel-login?r=jump-to/new-panel/section/help', '_blank' );
140 64 } );
141 65 knowledgeCard.click( function () {
@@ -141,8 +65,26 @@
141 65 knowledgeCard.click( function () {
142 66 window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' );
143 67 } );
144 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 +
145 87 document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) {
146 88 const firstItem = document.querySelector( '.hsr-playlist-item:first-child' );
147 89 firstItem.classList.add( 'hsr-active-video' );
148 90 firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
@@ -156,24 +98,19 @@
156 98 } );
157 99 } );
158 100
159 101 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 - ];
102 + const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
166 103
167 - const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
168 104 if ( hostingerSubMenu ) {
169 105 hostingerSubMenu.forEach( item => {
170 106 item.classList.remove( 'current' );
171 107 } );
172 108
173 - tabSelectors.forEach( ( selector, index ) => {
174 - const tab = document.querySelector( selector );
175 - 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' ) ) {
176 113 if ( typeof hostingerSubMenu[ index + 1 ] !== "undefined" ) {
177 114 hostingerSubMenu[ index + 1 ].classList.add( 'current' );
178 115 }
179 116 }
@@ -178,9 +115,8 @@
178 115 }
179 116 }
180 117 } );
181 118 }
182 -
183 119 }
184 120
185 121 add_admin_menu_class();
186 122
@@ -200,7 +136,53 @@
200 136 document.execCommand('copy');
201 137 document.body.removeChild(textArea);
202 138 }
203 139
204 - } );
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 +
205 187
206 188 } )( jQuery );