PluginProbe
Hostinger Tools / 1.9.7
Hostinger Tools v1.9.7
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.7, at src/js/main.js

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