`; const storeUIState=function(type) { var store; try { store=window[type]; var x='__storage_test__'; store.setItem(x, x); store.removeItem(x); return { tempStorage: UI_USE_WBSTORE, seen: function () { if (sessionStorage.getItem(ANIM_SEEN_WB_STORE)) { return true; } else { return false; } }, setSeen: function() { sessionStorage.setItem(ANIM_SEEN_WB_STORE, true) } }; } catch (e) { return { tempStorage: UI_USE_CKIE, seen: function () { if (document.cookie.indexOf(ANIM_SEEN_CKIE) == -1) { return false; } else { return true; } }, setSeen: function () { document.cookie=ANIM_SEEN_CKIE + '; expires=0; path=/;'; } }; } }; function pinBasedOnPlatform(choice) { switch (choice) { case PIN_TOP: case PIN_BOTTOM: return choice; case PIN_PLATFORM: if (window.innerWidth < PIN_PLATFORM_BRKPOINT) { return PIN_BOTTOM; } else { return PIN_TOP; } default: return PIN_TOP; } } var addEvent=function (el, evt, fn, bubble) { if ("addEventListener" in el) { el.addEventListener(evt, fn, bubble); } else if ("attachEvent" in el) { if (typeof fn === "object" && fn.handleEvent) { el.attachEvent("on" + evt, function () { fn.handleEvent.call(fn); }); } else { el.attachEvent("on" + evt, fn); } } }, setAttributes=function (el, attrs) { for (var key in attrs) { el.setAttribute(key, attrs[key]); } }, addClass=function (el, cls) { if (el.className.indexOf(cls) !== 0) { el.className += " " + cls; el.className=el.className.replace(/(^\s*)|(\s*$)/g,""); } }, removeClass=function (el, cls) { var reg=new RegExp("(\\s|^)" + cls + "(\\s|$)"); el.className=el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g,""); }, forEach=function (array, callback, scope) { for (var i=0; i < array.length; i++) { callback.call(scope, i, array[i]); } }; const addAnimClass=function(elBnr, pinnedTo, elSpacing) { addClass(elBnr, "animation-" + pinnedTo); addClass(elVertSpace,"animation-"+pinnedTo); elSpacing.style.cssText=`margin-top: 0 ${elBnr.offsetHeight}px;`; }; const removeAnimClass=function(elBnr, pinnedTo, elSpacing) { removeClass(elBnr, "animation-" + pinnedTo); removeClass(elVertSpace,"animation-"+pinnedTo); elSpacing.style.cssText=`margin-top: 0 ${elBnr.offsetHeight}px;`; }; const MsgBarControl=function (el, cfg) { this.cfg={ UIStateVal: storeUIState('sessionStorage'), openPos: "relative", animate: cfg.barAnimate, barPin: pinBasedOnPlatform(cfg.barPinTo), barClass: "db-frame-pinned " + pinBasedOnPlatform(cfg.barPinTo), barActiveClass: "js-bar-active", jsClass: "js", close: function(){}, }; for (let i in cfg) { this.cfg[i]=cfg[i]; } addClass(elHTML, this.cfg.jsClass); this.wrapper=document.getElementById("body"); sets=this.cfg; this.el=el.replace("#", ""); this._init(this); }; MsgBarControl.prototype={ setCookie: function (){ const endDate=new Date(cfg.mbEndDatetimeEncoded).toUTCString(); document.cookie=COOKIE_NAME+cfg.mbCookie+'; expires='+endDate+'; path=/;isSession=false;'; }, engage: function () { this.close(); }, cancel: function () { dataLayer.push({ event: cfg.mbGADLPushEvent, gaAction: cfg.mbGADLPushCloseAction, }); this.close(); }, close: function () { if (barOpen) { removeClass(elBnr, "opened"); addClass(elBnr, "closed"); setAttributes(elBnr, {"aria-hidden": "true"}); } else { elBnr.style.position="absolute"; } barOpen=false; this.resize(); this.setCookie(); sets.close(); }, resize: function () { if (window.getComputedStyle(elBnr, null).getPropertyValue("display") !== "none") { removeClass(elVertSpace,"animation-top" ); this._transitions(); setAttributes(elBnr, {"aria-hidden": "false"}); if (elBnr.className.match(/(^|\s)closed(\s|$)/)) { setAttributes(elBnr, {"aria-hidden": "true"}); elBnr.style.position="absolute"; } this._calcHeight(); } }, handleEvent: function (e) { var evt=e || window.event; switch (evt.type) { case "resize": this.resize(evt); break; case "focus": case "click": break; } }, _init: function () { let elExists=document.querySelector(this.el+'.db-frame-pinned'); if (!elExists){ elBnr=document.createElement(this.el); } else { elExists.nextSibling.remove(); elExists.remove(); elBnr=document.createElement(this.el); } document.body.insertBefore(elBnr, document.body.firstChild); elBnr.innerHTML=DB_TEMPLATE_LITERAL; addClass(elBnr, sets.barClass); addClass(elBnr, "opened"); setAttributes(elBnr, {"aria-hidden": "false"}); elVertSpace=document.createElement("div"); elVertSpace.setAttribute("id", VSPC_DIV_ID); addClass(elVertSpace, "db-height-tracker "); elBnr.parentNode.insertBefore(elVertSpace, elBnr.nextSibling); barOpen=true; addEvent(window, "focus", this, false); addEvent(window, "resize", this, false); addEvent(elBnr, "click", this, false); this._closeOnClick(); this.resize(); }, _closeOnClick: function () { let cancelActionEls=elBnr.getElementsByClassName("db-cancel-button"); let thisCancel=this; forEach(cancelActionEls, function (i) { addEvent(cancelActionEls[i], "click", function () { thisCancel.cancel(); }, false); }, this ); let links=elBnr.getElementsByTagName("a"); let thisLink=this; forEach(links, function (i) { addEvent(links[i], "click", function () { thisLink.engage(links[i].getAttribute("href")); }, true); }, this ); }, _transitions: function () { switch (sets.animate) { case ANIM_ONCE: if (!sets.UIStateVal.seen()) { sets.UIStateVal.setSeen(); addAnimClass(elBnr, sets.barPin, elVertSpace); } else { removeAnimClass(elBnr, sets.barPin, elVertSpace); } break; case ANIM_ALWAYS: if (!elBnr.classList.contains("animation-top") && !elBnr.classList.contains("animation-bottom")){ addAnimClass(elBnr, sets.barPin, elVertSpace); } break; default: removeAnimClass(elBnr, sets.barPin, elVertSpace); break; } }, _calcHeight: function () { if (sets.barPin === PIN_TOP) { elVertSpace.style.marginTop=elBnr.offsetHeight+"px"; } } }; return new MsgBarControl(el, cfg); }; function launchIfCampaignActive(cfg){ let nowDateTimeObj=new Date(); if ( ((Date.parse(cfg.mbStartDatetimeEncoded) <= nowDateTimeObj) & (nowDateTimeObj <= Date.parse(cfg.mbEndDatetimeEncoded) ) & (document.cookie.indexOf(cfg.mbCookie)== -1) )){ msgBarLoader("aside", cfg); } } const cfg={ styleTemplate:'Membership', mbSimulcast:'No', barPrefixText:'', btnText:'Take our reader survey.', btnURL:'https://survey.cmix.com/E84ADAD3/7E302C4Q/en-US?ws=7', barAnimate:'always', barPinTo:'platform', mbCookie:'seen', mbId:'message-bar-id', mbGAEvtCat:'message bar', mbGAEvtAct:'cta', mbGADLPushCloseAction:'close', mbGADLPushEvent:'customMessageBar', mbMobileOnly:'No', mbDesktopOnly:'No', mbStartDatetimeEncoded:'2022/02/15 00:00', mbEndDatetimeEncoded:'2022/02/18 23:59', mbBarTextFinalEncode:'Help shape The Texas Tribune’s future.', MB_VERSION:1644875129756}; launchIfCampaignActive(cfg); if (typeof module !== "undefined" && module.exports) { module.exports=msgBarLoader; } else { window.msgBarLoader=msgBarLoader; } }(document, window, 0));