PluginProbe
Hostinger Tools / 2.0.0
Hostinger Tools v2.0.0
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 2.0.0, at src/js/main.js

117 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import './actions'
2 import './videos'
3
4 ( function ( $ ) {
5 $( document ).on( 'ready', function () {
6 const openClass = 'open';
7 let selectedTab = 'Home';
8 const stepsTitle = $( '.hsr-onboarding-step--title' )
9 const closeBtn = $( '.hsr-close-btn' );
10 const navigationItem = $( '.hsr-list__item' );
11 const knowledgeCard = $( '#card-knowledge' );
12 const helpCard = $( '#card-help' );
13
14 stepsTitle.on( 'click', function () {
15 $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass );
16 $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 );
17 } )
18
19 closeBtn.on( 'click', function () {
20 $( '.hsr-modal' ).removeClass( 'open' );
21 $( 'body' ).removeClass( 'modal-open' );
22 } )
23
24 navigationItem.click( function () {
25 let clickedItem = $( this );
26
27 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
28
29 clickedItem.addClass( 'hsr-active' );
30 selectedTab = clickedItem.data( 'name' );
31
32 $( '.hsr-tab-content' ).hide();
33 $( '.hsr-tab-content[data-name="' + selectedTab + '"]' ).show();
34
35 add_admin_menu_class();
36 } );
37
38 if( window.location.hash ) {
39 let tab = $( '.hsr-onboarding-navbar .hsr-wrapper__list .hsr-list__item[data-name="' + window.location.hash.split('#')[1] + '"]' )
40
41 if(tab.length > 0) {
42 $( '.hsr-list__item' ).removeClass( 'hsr-active' );
43 tab.addClass( 'hsr-active' );
44
45 $( '.hsr-tab-content' ).hide();
46 $( '.hsr-tab-content[data-name="' + window.location.hash.split('#')[1] + '"]' ).show();
47 }
48 } else {
49
50 $( '.hsr-wrapper__list .hsr-list__item:first-of-type' ).addClass( 'hsr-active' );
51
52 }
53
54 helpCard.click( function () {
55 window.open( 'https://hostinger.com/cpanel-login?r=jump-to/new-panel/section/help', '_blank' );
56 } );
57 knowledgeCard.click( function () {
58 window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' );
59 } );
60
61 document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) {
62 const firstItem = document.querySelector( '.hsr-playlist-item:first-child' );
63 firstItem.classList.add( 'hsr-active-video' );
64 firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
65 item.addEventListener( 'click', function () {
66 document.querySelectorAll( '.hsr-playlist-item.hsr-active-video' ).forEach( function ( selectedItem ) {
67 selectedItem.classList.remove( 'hsr-active-video' );
68 selectedItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'hidden';
69 } );
70 this.classList.add( 'hsr-active-video' );
71 this.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible';
72 } );
73 } );
74
75 function add_admin_menu_class () {
76 const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' );
77
78 if ( hostingerSubMenu ) {
79 hostingerSubMenu.forEach( item => {
80 item.classList.remove( 'current' );
81 } );
82
83 const tabSelectors = document.querySelectorAll( '.hsr-onboarding-navbar .hsr-wrapper__list .hsr-list__item' );
84
85 tabSelectors.forEach( ( item, index ) => {
86 if ( item.classList.contains( 'hsr-active' ) ) {
87 if ( typeof hostingerSubMenu[ index + 1 ] !== "undefined" ) {
88 hostingerSubMenu[ index + 1 ].classList.add( 'current' );
89 }
90 }
91 } );
92 }
93 }
94
95 add_admin_menu_class();
96
97 // Copy nameservers to clipboard
98 $(document).ready(function() {
99 $('.hts-nameservers svg').click(function() {
100 let textToCopy = $(this).closest('div').find('b').text();
101 copyTextToClipboard(textToCopy);
102 });
103 });
104
105 function copyTextToClipboard(text) {
106 let textArea = document.createElement('textarea');
107 textArea.value = text;
108 document.body.appendChild(textArea);
109 textArea.select();
110 document.execCommand('copy');
111 document.body.removeChild(textArea);
112 }
113
114 } );
115
116 } )( jQuery );
117