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