Changeset 13306
- Timestamp:
- 03/11/2024 11:26:16 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-also-viewing/wporg-bbp-also-viewing.js
r12577 r13306 12 12 $adminbar = false, 13 13 $header = false, 14 $localNavBar = false, 15 $langBanner = false, 14 16 bannerOffset = 200, 15 17 isTyping = false, … … 25 27 $adminbar = jQuery('#wpadminbar'); 26 28 $header = jQuery('header.global-header'); 29 $localNavBar = jQuery('.wp-block-wporg-local-navigation-bar'); 30 $langBanner = jQuery('.wp-block-wporg-language-suggest'); 27 31 28 32 maybeDisplay(); … … 48 52 } 49 53 50 jQuery('#main').before( 51 '<div id="also-viewing-banner" style="display: none; font-size: 0.8rem; color: #fff; line-height: 2rem; background: #d54e21; width:100%; text-align: center; position: initial; top: 32px; left: 0; z-index: 150;"></div>' 52 ); 54 // If using a block based theme with the local nav bar block 55 if ( $localNavBar.length ) { 56 // Insert the banner after the language banner if present, 57 // otherwise after the local nav 58 $element = $langBanner.length ? $langBanner : $localNavBar; 59 60 $element.after( 61 '<div id="also-viewing-banner" style="display: none; font-size: var(--wp--preset--font-size--extra-small, 12px); color: var(--wp--preset--color--charcoal-1, #1E1E1E); line-height: 18px; padding-top: 8px; padding-bottom: 8px; background: var(--wp--preset--color--acid-green-3, #E2FFED); width: 100%; text-align: center; position: initial; top: 32px; left: 0; z-index: 150;"></div>' 62 ); 63 } else { 64 jQuery('#main').before( 65 '<div id="also-viewing-banner" style="display: none; font-size: 0.8rem; color: #fff; line-height: 2rem; background: #d54e21; width:100%; text-align: center; position: initial; top: 32px; left: 0; z-index: 150;"></div>' 66 ); 67 } 68 53 69 banner = jQuery( '#also-viewing-banner' ); 54 70 } … … 106 122 } 107 123 108 var offset = 'var(--wp-admin--admin-bar--height, 0px)'; 109 if ( 'fixed' === $header.css('position') ) { 110 offset = 'var(--wp-global-header-offset, 0px)'; 111 } 112 113 if ( jQuery(window).scrollTop() > bannerOffset ) { 114 banner.css( 'position', 'fixed' ); 115 banner.css( 'top', offset ); 124 if ( $localNavBar.length ) { 125 // Local nav bar position is set to relative on small screens to stop it being sticky 126 if ( $localNavBar.hasClass( 'is-sticking' ) && $localNavBar.css( 'position' ) !== 'relative' ) { 127 banner.css( 'position', 'sticky' ); 128 banner.css( 'top', 'calc(var(--wp-admin--admin-bar--height, 0px) + var(--wp--custom--local-navigation-bar--spacing--height, 60px))' ); 129 } else { 130 banner.css( 'position', 'initial' ); 131 banner.css( 'top', '' ); 132 } 116 133 } else { 117 banner.css( 'position', 'initial' ); 118 banner.css( 'top', '' ); 134 var offset = 'var(--wp-admin--admin-bar--height, 0px)'; 135 if ( 'fixed' === $header.css('position') ) { 136 offset = 'var(--wp-global-header-offset, 0px)'; 137 } 138 139 if ( jQuery(window).scrollTop() > bannerOffset ) { 140 banner.css( 'position', 'fixed' ); 141 banner.css( 'top', offset ); 142 } else { 143 banner.css( 'position', 'initial' ); 144 banner.css( 'top', '' ); 145 } 119 146 } 120 147 } );
Note: See TracChangeset
for help on using the changeset viewer.