| @@ -1,4 +1,5 @@ | ||
| 1 | +import './actions' | |
| 1 | 2 | import './videos' |
| 2 | 3 | |
| 3 | 4 | ( function ( $ ) { |
| 4 | 5 | $( document ).on( 'ready', function () { |
| @@ -56,8 +57,26 @@ | ||
| 56 | 57 | knowledgeCard.click( function () { |
| 57 | 58 | window.open( 'https://support.hostinger.com/en/?q=WordPress', '_blank' ); |
| 58 | 59 | } ); |
| 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 | + | |
| 60 | 79 | document.querySelectorAll( '.hsr-playlist-item' ).forEach( function ( item ) { |
| 61 | 80 | const firstItem = document.querySelector( '.hsr-playlist-item:first-child' ); |
| 62 | 81 | firstItem.classList.add( 'hsr-active-video' ); |
| 63 | 82 | firstItem.querySelector( '.hsr-playlist-item-arrow' ).style.visibility = 'visible'; |
| @@ -109,7 +128,53 @@ | ||
| 109 | 128 | document.execCommand('copy'); |
| 110 | 129 | document.body.removeChild(textArea); |
| 111 | 130 | } |
| 112 | 131 | |
| 113 | - } ); | |
| 132 | + //Sidebar menu script | |
| 133 | + window.addEventListener( 'resize', function () { | |
| 134 | + | |
| 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 | + | |
| 114 | 179 | |
| 115 | 180 | } )( jQuery ); |