PluginProbe
Hostinger Tools / 1.9.6
Hostinger Tools v1.9.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
hostinger / src / js / main.js

main.js in Hostinger Tools 1.9.6, at src/js/main.js

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