| 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 |
$('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 |
|
| 79 |
document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) { |
| 80 |
const firstItem = document.querySelector( '.hsr-playlist-item:first-child' ); |
| 81 |
firstItem.classList.add( 'hsr-active-video' ); |
| 82 |
firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible'; |
| 83 |
item.addEventListener( 'click', function () { |
| 84 |
document.querySelectorAll( '.hsr-playlist-item.hsr-active-video' ).forEach( function ( selectedItem ) { |
| 85 |
selectedItem.classList.remove( 'hsr-active-video' ); |
| 86 |
selectedItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'hidden'; |
| 87 |
} ); |
| 88 |
this.classList.add( 'hsr-active-video' ); |
| 89 |
this.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible'; |
| 90 |
} ); |
| 91 |
} ); |
| 92 |
|
| 93 |
function add_admin_menu_class () { |
| 94 |
const hostingerSubMenu = document.querySelectorAll( '#toplevel_page_hostinger .wp-submenu li' ); |
| 95 |
|
| 96 |
if ( hostingerSubMenu ) { |
| 97 |
hostingerSubMenu.forEach( item => { |
| 98 |
item.classList.remove( 'current' ); |
| 99 |
} ); |
| 100 |
|
| 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 |
} |
| 108 |
} |
| 109 |
} ); |
| 110 |
} |
| 111 |
} |
| 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); |
| 130 |
} |
| 131 |
|
| 132 |
} ); |
| 133 |
|
| 134 |
} )( jQuery ); |
| 135 |
|