PageSourceSearch

https://www.birdsandblooms.com/wp-content/themes/bumblebee/js/cm-ribbon.js?ver=30.6.0

js birdsandblooms.com collected 2026-10-02 05:23:30 UTC 3,440 bytes, 94 lines download raw bytes

1/**
2 * Initialize the CM Ribbon with the provided configuration.
3 *
4 * @param {*} cmRibbonConfig - The configuration object for the CM Ribbon.
5 * @returns {void}
6 */
7function initCMRibbon( cmRibbonConfig ) { // eslint-disable-line no-unused-vars
8	// Ensure the ribbon element exists.
9	const rootStyles = getComputedStyle(document.documentElement);
10	const cmRibbonWrap = document.querySelector( '.info-bar' );
11	const cmRibbon = document.querySelector( '.cm-ribbon' );
12	const headerWrap = document.querySelector( '#header-wrapper .nav-wrapper.fixed-header' );
13	const primaryNav = document.querySelector( '#header-wrapper .fixed-header .primary-nav' );
14	const cnx_player = document.querySelector( '.right-rail .cnx-inline-player-wrapper' );
15	const recircStrip = document.querySelector( '.tmbi-recirc-strip-sticky-desktop' );
16
17	if ( ! cmRibbon ) {
18		return;
19	}
20
21	if ( 'undefined' === typeof cmRibbonConfig ) {
22		cmRibbon.style.display = 'none';
23		cmRibbonWrap.style.display = 'none';
24		return;
25	}
26
27	// Set view link URL for ad impression tracking.
28	const viewLinkElem = document.getElementById( 'cm-ribbon-img-view' );
29	if ( viewLinkElem && 'undefined' !== typeof cmRibbonConfig.viewURL ) {
30		viewLinkElem.src = cmRibbonConfig.viewURL;
31	}
32
33	// Set promo text.
34	const promoTextElem = cmRibbon.querySelector( '.cm-ribbon-text' );
35	if ( promoTextElem && 'undefined' !== typeof cmRibbonConfig.promoText ) {
36		promoTextElem.textContent = cmRibbonConfig.promoText;
37		promoTextElem.setAttribute( 'data-name', cmRibbonConfig.promoText );
38	}
39	if ( 'undefined' !== typeof cmRibbonConfig.textColor && cmRibbonConfig.textColor ) {
40		promoTextElem.style.color = cmRibbonConfig.textColor;
41	}
42
43	// Set CTA text and URL.
44	const ctaElem = cmRibbon.querySelector( '.cm-ribbon-cta' );
45	if ( ctaElem && 'undefined' !== typeof cmRibbonConfig.ctaText && 'undefined' !== typeof cmRibbonConfig.ctaUrl ) {
46		ctaElem.textContent = cmRibbonConfig.ctaText;
47		ctaElem.href = cmRibbonConfig.ctaUrl;
48		promoTextElem.href = cmRibbonConfig.ctaUrl;
49
50		ctaElem.setAttribute( 'data-name', cmRibbonConfig.ctaText );
51
52		if ( 'undefined' !== typeof cmRibbonConfig.textColor && cmRibbonConfig.textColor ) {
53			ctaElem.style.color = cmRibbonConfig.textColor;
54		}
55	}
56
57	// Apply background and text colors if specified.
58	if ( 'undefined' !== typeof cmRibbonConfig.backgroundColor && cmRibbonConfig.backgroundColor ) {
59		cmRibbonWrap.style.backgroundColor = cmRibbonConfig.backgroundColor;
60	} else {
61		// set background to root var --brand-color-primary if no background color is provided
62		const brandColorPrimary = rootStyles.getPropertyValue('--brand-color-primary').trim();
63		cmRibbonWrap.style.backgroundColor = brandColorPrimary;
64	}
65
66	// Hide Exit button if configured.
67	const closeButton = cmRibbon.querySelector( '.cm-ribbon-close' );
68	if ( closeButton ) {
69		if ( 'undefined' !== typeof cmRibbonConfig.showCloseButton && true !== cmRibbonConfig.showCloseButton ) {
70			closeButton.style.display = 'none';
71		}
72	
73
74		closeButton.addEventListener( 'click', function () {
75			const headerHeight = headerWrap ? headerWrap.offsetHeight + 'px' : '80px';
76
77			if ( primaryNav ) {
78				primaryNav.style.paddingTop = '16px';
79			}
80
81			if ( cnx_player ) {
82				cnx_player.style.top = headerHeight;
83			}
84
85			if ( recircStrip ) {
86				recircStrip.style.top = headerHeight;
87			}
88
89			cmRibbon.style.display = 'none';
90			cmRibbonWrap.style.display = 'none';
91		});
92	}
93	cmRibbon.style.display = 'block';
94}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.