PluginProbe
Hostinger Tools / 2.1.6
Hostinger Tools v2.1.6
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 +112 -122 1.8.22.1.6 View file →
@@ -1,145 +1,57 @@
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' );
24 13
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 14 stepsTitle.on( 'click', function () {
60 15 $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass );
61 16 $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 );
62 17 } )
63 18
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 19 closeBtn.on( 'click', function () {
94 20 $( '.hsr-modal' ).removeClass( 'open' );
95 21 $( 'body' ).removeClass( 'modal-open' );
96 22 } )
23 +
97 24 navigationItem.click( function () {
98 - var clickedItem = $( this );
25 + let clickedItem = $( this );
26 +
99 27 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
28 +
100 29 clickedItem.addClass( 'hsr-active' );
101 30 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 - }
31 +
32 + $( '.hsr-tab-content' ).hide();
33 + $( '.hsr-tab-content[data-name="' + selectedTab + '"]' ).show();
34 +
115 35 add_admin_menu_class();
116 36 } );
117 37
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 - }
38 + if( window.location.hash ) {
39 + let tab = $( '.hsr-onboarding-navbar .hsr-wrapper__list .hsr-list__item[data-name="' + window.location.hash.split('#')[1] + '"]' )
125 40
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 - }
41 + if(tab.length > 0) {
42 + $( '.hsr-list__item' ).removeClass( 'hsr-active' );
43 + tab.addClass( 'hsr-active' );
133 44
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 - }
45 + $( '.hsr-tab-content' ).hide();
46 + $( '.hsr-tab-content[data-name="' + window.location.hash.split('#')[1] + '"]' ).show();
47 + }
48 + } else {
141 49
50 + $( '.hsr-wrapper__list .hsr-list__item:first-of-type' ).addClass( 'hsr-active' );
51 +
52 + }
53 +
142 54 helpCard.click( function () {
143 55 window.open( 'https://hostinger.com/cpanel-login?r=jump-to/new-panel/section/help', '_blank' );
144 56 } );
145 57 knowledgeCard.click( function () {
@@ -145,8 +57,26 @@
145 57 knowledgeCard.click( function () {
146 58 window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' );
147 59 } );
148 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 +
149 79 document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) {
150 80 const firstItem = document.querySelector( '.hsr-playlist-item:first-child' );
151 81 firstItem.classList.add( 'hsr-active-video' );
152 82 firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
@@ -160,31 +90,91 @@
160 90 } );
161 91 } );
162 92
163 93 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 - ];
94 + const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
169 95
170 - const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
171 96 if ( hostingerSubMenu ) {
172 97 hostingerSubMenu.forEach( item => {
173 98 item.classList.remove( 'current' );
174 99 } );
175 100
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' );
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' ) ) {
105 + if ( typeof hostingerSubMenu[ index + 1 ] !== "undefined" ) {
106 + hostingerSubMenu[ index + 1 ].classList.add( 'current' );
107 + }
180 108 }
181 109 } );
182 110 }
111 + }
183 112
113 + add_admin_menu_class();
114 +
115 + // Copy nameservers to clipboard
116 + $(document).ready(function() {
117 + $('.hts-nameservers svg').click(function() {
118 + let textToCopy = $(this).closest('div').find('b').text();
119 + copyTextToClipboard(textToCopy);
120 + });
121 + });
122 +
123 + function copyTextToClipboard(text) {
124 + let textArea = document.createElement('textarea');
125 + textArea.value = text;
126 + document.body.appendChild(textArea);
127 + textArea.select();
128 + document.execCommand('copy');
129 + document.body.removeChild(textArea);
184 130 }
185 131
186 - add_admin_menu_class();
132 + //Sidebar menu script
133 + window.addEventListener( 'resize', function () {
187 134
188 - } );
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 +
189 179
190 180 } )( jQuery );