| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | const closeBtn = $( '.hsr-close-btn' ); |
| 10 | 10 | const navigationItem = $( '.hsr-list__item' ); |
| 11 | 11 | const knowledgeCard = $( '#card-knowledge' ); |
| 12 | 12 | const helpCard = $( '#card-help' ); |
| 13 | + const adminBarGenerateContent = $( '#wp-admin-bar-create_content_with_ai' ); | |
| 13 | 14 | |
| 14 | 15 | stepsTitle.on( 'click', function () { |
| 15 | 16 | $( this ).find( '.hsr-onboarding-step--expand' ).toggleClass( openClass ); |
| 16 | 17 | $( this ).parent().find( '.hsr-onboarding-step--content' ).slideToggle( 200 ); |
| @@ -20,8 +21,15 @@ | ||
| 20 | 21 | $( '.hsr-modal' ).removeClass( 'open' ); |
| 21 | 22 | $( 'body' ).removeClass( 'modal-open' ); |
| 22 | 23 | } ) |
| 23 | 24 | |
| 25 | + adminBarGenerateContent.click( function () { | |
| 26 | + $( '.hsr-list__item' ).removeClass( 'hsr-active' ); | |
| 27 | + $('.hts-ai-assistant-tab').addClass( 'hsr-active' ); | |
| 28 | + $( '.hsr-tab-content' ).hide(); | |
| 29 | + $( ".hsr-tab-content[data-name='ai-assistant']" ).show(); | |
| 30 | + } ); | |
| 31 | + | |
| 24 | 32 | navigationItem.click( function () { |
| 25 | 33 | let clickedItem = $( this ); |
| 26 | 34 | |
| 27 | 35 | $( '.hsr-list__item' ).removeClass( 'hsr-active' ); |
| @@ -128,7 +136,53 @@ | ||
| 128 | 136 | document.execCommand('copy'); |
| 129 | 137 | document.body.removeChild(textArea); |
| 130 | 138 | } |
| 131 | 139 | |
| 132 | - } ); | |
| 140 | + //Sidebar menu script | |
| 141 | + window.addEventListener( 'resize', function () { | |
| 142 | + | |
| 143 | + var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; | |
| 144 | + var navbarWrapper = document.querySelector( '.hsr-wrapper__list' ); | |
| 145 | + var mobileSidebar = document.querySelector( '.hsr-mobile-sidebar .hsr-wrapper' ); | |
| 146 | + var hpanelLink = document.querySelector( '.hsr-go-to-hpanel' ); | |
| 147 | + | |
| 148 | + | |
| 149 | + if ( windowWidth <= 1000 ) { | |
| 150 | + if ( navbarWrapper && mobileSidebar ) { | |
| 151 | + mobileSidebar.appendChild( navbarWrapper ); | |
| 152 | + mobileSidebar.appendChild( hpanelLink ); | |
| 153 | + } | |
| 154 | + } else { | |
| 155 | + var originalParent = document.querySelector( '.hsr-onboarding-navbar__wrapper' ); | |
| 156 | + if ( navbarWrapper && originalParent ) { | |
| 157 | + originalParent.appendChild( navbarWrapper ); | |
| 158 | + originalParent.appendChild( hpanelLink ); | |
| 159 | + document.querySelector( '.hsr-mobile-sidebar' ).classList.remove( 'hsr-active' ); | |
| 160 | + } | |
| 161 | + } | |
| 162 | + } ); | |
| 163 | + | |
| 164 | + window.dispatchEvent( new Event( 'resize' ) ); | |
| 165 | + | |
| 166 | + | |
| 167 | + var mobileSidebar = document.querySelector( '.hsr-mobile-sidebar' ); | |
| 168 | + var closeButtons = document.querySelectorAll( '.hsr-close, .hsr-mobile-menu-icon' ); | |
| 169 | + | |
| 170 | + closeButtons.forEach( function ( button ) { | |
| 171 | + button.addEventListener( 'click', function ( event ) { | |
| 172 | + mobileSidebar.classList.toggle( 'hsr-active' ); | |
| 173 | + document.querySelector('body').classList.toggle( 'hsr-sidebar-active' ); | |
| 174 | + event.stopPropagation(); | |
| 175 | + } ); | |
| 176 | + } ); | |
| 177 | + | |
| 178 | + document.addEventListener( 'click', function ( event ) { | |
| 179 | + if ( ! mobileSidebar.contains( event.target ) ) { | |
| 180 | + mobileSidebar.classList.remove( 'hsr-active' ); | |
| 181 | + document.querySelector('body').classList.remove( 'hsr-sidebar-active' ); | |
| 182 | + } | |
| 183 | + } ); | |
| 184 | + } ); | |
| 185 | + | |
| 186 | + | |
| 133 | 187 | |
| 134 | 188 | } )( jQuery ); |