@penskemediacorp/larva-js 1.20.0 → 1.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/video-showcase.js +1 -1
- package/package.json +2 -2
- package/src/__tests__/fixtures/markup.js +1 -1
- package/src/__tests__/utils/removeDesktopXlClasses.test.js +6 -4
- package/src/interface/Collapsible/Collapsible.js +31 -17
- package/src/interface/Collapsible/index.js +6 -2
- package/src/interface/EmailCapture/EmailCapture.js +17 -13
- package/src/interface/EmailCapture/index.js +6 -3
- package/src/interface/ExpandableSearch/ExpandableSearch.js +21 -21
- package/src/interface/ExpandableSearch/index.js +4 -4
- package/src/interface/Flickity/index.js +16 -11
- package/src/interface/MegaMenu/MegaMenu.js +22 -13
- package/src/interface/MegaMenu/index.js +12 -10
- package/src/interface/MobileHeightToggle/MobileHeightToggle.js +5 -4
- package/src/interface/MobileHeightToggle/MobileHeightToggle.test.js +22 -21
- package/src/interface/MobileHeightToggle/index.js +9 -8
- package/src/interface/Navigable/Navigable.js +29 -18
- package/src/interface/Navigable/index.js +1 -1
- package/src/interface/PopOver/PopOver.js +15 -15
- package/src/interface/PopOver/index.js +4 -4
- package/src/interface/ProfileFilter/ProfileFilter.js +40 -35
- package/src/interface/ProfileFilter/__test__/ProfileFilter.test.js +38 -31
- package/src/interface/ProfileFilter/index.js +2 -2
- package/src/interface/SelectNav/SelectNav.js +8 -6
- package/src/interface/SelectNav/index.js +2 -3
- package/src/interface/SideSkinAd/SideSkinAd.js +0 -2
- package/src/interface/SideSkinAd/index.js +10 -10
- package/src/interface/TabsManager/TabsManager.js +11 -6
- package/src/interface/TabsManager/index.js +1 -1
- package/src/interface/Tooltip/Tooltip.js +0 -1
- package/src/interface/VideoShowcase/VideoShowcase.js +77 -49
- package/src/interface/VideoShowcase/index.js +6 -2
- package/src/utils/ajaxIconSprite.js +4 -4
- package/src/utils/dom.js +6 -3
- package/src/utils/removeDesktopXlClasses.js +5 -7
- package/src/utils/webfontConfig.js +26 -40
package/build/video-showcase.js
CHANGED
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
* Unidragger v2.3.1
|
|
24
24
|
* Draggable base class
|
|
25
25
|
* MIT license
|
|
26
|
-
*/!function(o,r){s=[i(3)],void 0===(n=function(t){return function(t,e){"use strict";function i(){}var s=i.prototype=Object.create(e.prototype);s.bindHandles=function(){this._bindHandles(!0)},s.unbindHandles=function(){this._bindHandles(!1)},s._bindHandles=function(e){for(var i=(e=void 0===e||e)?"addEventListener":"removeEventListener",s=e?this._touchActionValue:"",n=0;n<this.handles.length;n++){var o=this.handles[n];this._bindStartEvent(o,e),o[i]("click",this),t.PointerEvent&&(o.style.touchAction=s)}},s._touchActionValue="none",s.pointerDown=function(t,e){this.okayPointerDown(t)&&(this.pointerDownPointer={pageX:e.pageX,pageY:e.pageY},t.preventDefault(),this.pointerDownBlur(),this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,e]))};var n={TEXTAREA:!0,INPUT:!0,SELECT:!0,OPTION:!0},o={radio:!0,checkbox:!0,button:!0,submit:!0,image:!0,file:!0};return s.okayPointerDown=function(t){var e=n[t.target.nodeName],i=o[t.target.type],s=!e||i;return s||this._pointerReset(),s},s.pointerDownBlur=function(){var t=document.activeElement;t&&t.blur&&t!=document.body&&t.blur()},s.pointerMove=function(t,e){var i=this._dragPointerMove(t,e);this.emitEvent("pointerMove",[t,e,i]),this._dragMove(t,e,i)},s._dragPointerMove=function(t,e){var i={x:e.pageX-this.pointerDownPointer.pageX,y:e.pageY-this.pointerDownPointer.pageY};return!this.isDragging&&this.hasDragStarted(i)&&this._dragStart(t,e),i},s.hasDragStarted=function(t){return Math.abs(t.x)>3||Math.abs(t.y)>3},s.pointerUp=function(t,e){this.emitEvent("pointerUp",[t,e]),this._dragPointerUp(t,e)},s._dragPointerUp=function(t,e){this.isDragging?this._dragEnd(t,e):this._staticClick(t,e)},s._dragStart=function(t,e){this.isDragging=!0,this.isPreventingClicks=!0,this.dragStart(t,e)},s.dragStart=function(t,e){this.emitEvent("dragStart",[t,e])},s._dragMove=function(t,e,i){this.isDragging&&this.dragMove(t,e,i)},s.dragMove=function(t,e,i){t.preventDefault(),this.emitEvent("dragMove",[t,e,i])},s._dragEnd=function(t,e){this.isDragging=!1,setTimeout(function(){delete this.isPreventingClicks}.bind(this)),this.dragEnd(t,e)},s.dragEnd=function(t,e){this.emitEvent("dragEnd",[t,e])},s.onclick=function(t){this.isPreventingClicks&&t.preventDefault()},s._staticClick=function(t,e){this.isIgnoringMouseUp&&"mouseup"==t.type||(this.staticClick(t,e),"mouseup"!=t.type&&(this.isIgnoringMouseUp=!0,setTimeout(function(){delete this.isIgnoringMouseUp}.bind(this),400)))},s.staticClick=function(t,e){this.emitEvent("staticClick",[t,e])},i.getPointerPoint=e.getPointerPoint,i}(o,t)}.apply(e,s))||(t.exports=n)}(window)},function(t,e,i){var s,n;window,s=[i(1),i(3),i(0)],void 0===(n=function(t,e,i){return function(t,e,i,s){"use strict";var n="http://www.w3.org/2000/svg";function o(t,e){this.direction=t,this.parent=e,this._create()}o.prototype=Object.create(i.prototype),o.prototype._create=function(){this.isEnabled=!0,this.isPrevious=-1==this.direction;var t=this.parent.options.rightToLeft?1:-1;this.isLeft=this.direction==t;var e=this.element=document.createElement("button");e.className="flickity-button flickity-prev-next-button",e.className+=this.isPrevious?" previous":" next",e.setAttribute("type","button"),this.disable(),e.setAttribute("aria-label",this.isPrevious?"Previous":"Next");var i=this.createSVG();e.appendChild(i),this.parent.on("select",this.update.bind(this)),this.on("pointerDown",this.parent.childUIPointerDown.bind(this.parent))},o.prototype.activate=function(){this.bindStartEvent(this.element),this.element.addEventListener("click",this),this.parent.element.appendChild(this.element)},o.prototype.deactivate=function(){this.parent.element.removeChild(this.element),this.unbindStartEvent(this.element),this.element.removeEventListener("click",this)},o.prototype.createSVG=function(){var t=document.createElementNS(n,"svg");t.setAttribute("class","flickity-button-icon"),t.setAttribute("viewBox","0 0 100 100");var e,i=document.createElementNS(n,"path"),s="string"==typeof(e=this.parent.options.arrowShape)?e:"M "+e.x0+",50 L "+e.x1+","+(e.y1+50)+" L "+e.x2+","+(e.y2+50)+" L "+e.x3+",50 L "+e.x2+","+(50-e.y2)+" L "+e.x1+","+(50-e.y1)+" Z";return i.setAttribute("d",s),i.setAttribute("class","arrow"),this.isLeft||i.setAttribute("transform","translate(100, 100) rotate(180) "),t.appendChild(i),t},o.prototype.handleEvent=s.handleEvent,o.prototype.onclick=function(){if(this.isEnabled){this.parent.uiChange();var t=this.isPrevious?"previous":"next";this.parent[t]()}},o.prototype.enable=function(){this.isEnabled||(this.element.disabled=!1,this.isEnabled=!0)},o.prototype.disable=function(){this.isEnabled&&(this.element.disabled=!0,this.isEnabled=!1)},o.prototype.update=function(){var t=this.parent.slides;if(this.parent.options.wrapAround&&t.length>1)this.enable();else{var e=t.length?t.length-1:0,i=this.isPrevious?0:e;this[this.parent.selectedIndex==i?"disable":"enable"]()}},o.prototype.destroy=function(){this.deactivate(),this.allOff()},s.extend(e.defaults,{prevNextButtons:!0,arrowShape:{x0:10,x1:60,y1:50,x2:70,y2:40,x3:30}}),e.createMethods.push("_createPrevNextButtons");var r=e.prototype;return r._createPrevNextButtons=function(){this.options.prevNextButtons&&(this.prevButton=new o(-1,this),this.nextButton=new o(1,this),this.on("activate",this.activatePrevNextButtons))},r.activatePrevNextButtons=function(){this.prevButton.activate(),this.nextButton.activate(),this.on("deactivate",this.deactivatePrevNextButtons)},r.deactivatePrevNextButtons=function(){this.prevButton.deactivate(),this.nextButton.deactivate(),this.off("deactivate",this.deactivatePrevNextButtons)},e.PrevNextButton=o,e}(0,t,e,i)}.apply(e,s))||(t.exports=n)},function(t,e,i){var s,n;window,s=[i(1),i(3),i(0)],void 0===(n=function(t,e,i){return function(t,e,i,s){"use strict";function n(t){this.parent=t,this._create()}n.prototype=Object.create(i.prototype),n.prototype._create=function(){this.holder=document.createElement("ol"),this.holder.className="flickity-page-dots",this.dots=[],this.handleClick=this.onClick.bind(this),this.on("pointerDown",this.parent.childUIPointerDown.bind(this.parent))},n.prototype.activate=function(){this.setDots(),this.holder.addEventListener("click",this.handleClick),this.bindStartEvent(this.holder),this.parent.element.appendChild(this.holder)},n.prototype.deactivate=function(){this.holder.removeEventListener("click",this.handleClick),this.unbindStartEvent(this.holder),this.parent.element.removeChild(this.holder)},n.prototype.setDots=function(){var t=this.parent.slides.length-this.dots.length;t>0?this.addDots(t):t<0&&this.removeDots(-t)},n.prototype.addDots=function(t){for(var e=document.createDocumentFragment(),i=[],s=this.dots.length,n=s+t,o=s;o<n;o++){var r=document.createElement("li");r.className="dot",r.setAttribute("aria-label","Page dot "+(o+1)),e.appendChild(r),i.push(r)}this.holder.appendChild(e),this.dots=this.dots.concat(i)},n.prototype.removeDots=function(t){this.dots.splice(this.dots.length-t,t).forEach((function(t){this.holder.removeChild(t)}),this)},n.prototype.updateSelected=function(){this.selectedDot&&(this.selectedDot.className="dot",this.selectedDot.removeAttribute("aria-current")),this.dots.length&&(this.selectedDot=this.dots[this.parent.selectedIndex],this.selectedDot.className="dot is-selected",this.selectedDot.setAttribute("aria-current","step"))},n.prototype.onTap=n.prototype.onClick=function(t){var e=t.target;if("LI"==e.nodeName){this.parent.uiChange();var i=this.dots.indexOf(e);this.parent.select(i)}},n.prototype.destroy=function(){this.deactivate(),this.allOff()},e.PageDots=n,s.extend(e.defaults,{pageDots:!0}),e.createMethods.push("_createPageDots");var o=e.prototype;return o._createPageDots=function(){this.options.pageDots&&(this.pageDots=new n(this),this.on("activate",this.activatePageDots),this.on("select",this.updateSelectedPageDots),this.on("cellChange",this.updatePageDots),this.on("resize",this.updatePageDots),this.on("deactivate",this.deactivatePageDots))},o.activatePageDots=function(){this.pageDots.activate()},o.updateSelectedPageDots=function(){this.pageDots.updateSelected()},o.updatePageDots=function(){this.pageDots.setDots()},o.deactivatePageDots=function(){this.pageDots.deactivate()},e.PageDots=n,e}(0,t,e,i)}.apply(e,s))||(t.exports=n)},function(t,e,i){var s,n;window,s=[i(2),i(0),i(1)],void 0===(n=function(t,e,i){return function(t,e,i){"use strict";function s(t){this.parent=t,this.state="stopped",this.onVisibilityChange=this.visibilityChange.bind(this),this.onVisibilityPlay=this.visibilityPlay.bind(this)}s.prototype=Object.create(t.prototype),s.prototype.play=function(){"playing"!=this.state&&(document.hidden?document.addEventListener("visibilitychange",this.onVisibilityPlay):(this.state="playing",document.addEventListener("visibilitychange",this.onVisibilityChange),this.tick()))},s.prototype.tick=function(){if("playing"==this.state){var t=this.parent.options.autoPlay;t="number"==typeof t?t:3e3;var e=this;this.clear(),this.timeout=setTimeout((function(){e.parent.next(!0),e.tick()}),t)}},s.prototype.stop=function(){this.state="stopped",this.clear(),document.removeEventListener("visibilitychange",this.onVisibilityChange)},s.prototype.clear=function(){clearTimeout(this.timeout)},s.prototype.pause=function(){"playing"==this.state&&(this.state="paused",this.clear())},s.prototype.unpause=function(){"paused"==this.state&&this.play()},s.prototype.visibilityChange=function(){this[document.hidden?"pause":"unpause"]()},s.prototype.visibilityPlay=function(){this.play(),document.removeEventListener("visibilitychange",this.onVisibilityPlay)},e.extend(i.defaults,{pauseAutoPlayOnHover:!0}),i.createMethods.push("_createPlayer");var n=i.prototype;return n._createPlayer=function(){this.player=new s(this),this.on("activate",this.activatePlayer),this.on("uiChange",this.stopPlayer),this.on("pointerDown",this.stopPlayer),this.on("deactivate",this.deactivatePlayer)},n.activatePlayer=function(){this.options.autoPlay&&(this.player.play(),this.element.addEventListener("mouseenter",this))},n.playPlayer=function(){this.player.play()},n.stopPlayer=function(){this.player.stop()},n.pausePlayer=function(){this.player.pause()},n.unpausePlayer=function(){this.player.unpause()},n.deactivatePlayer=function(){this.player.stop(),this.element.removeEventListener("mouseenter",this)},n.onmouseenter=function(){this.options.pauseAutoPlayOnHover&&(this.player.pause(),this.element.addEventListener("mouseleave",this))},n.onmouseleave=function(){this.player.unpause(),this.element.removeEventListener("mouseleave",this)},i.Player=s,i}(t,e,i)}.apply(e,s))||(t.exports=n)},function(t,e,i){var s,n;window,s=[i(1),i(0)],void 0===(n=function(t,e){return function(t,e,i){"use strict";var s=e.prototype;return s.insert=function(t,e){var i=this._makeCells(t);if(i&&i.length){var s=this.cells.length;e=void 0===e?s:e;var n=function(t){var e=document.createDocumentFragment();return t.forEach((function(t){e.appendChild(t.element)})),e}(i),o=e==s;if(o)this.slider.appendChild(n);else{var r=this.cells[e].element;this.slider.insertBefore(n,r)}if(0===e)this.cells=i.concat(this.cells);else if(o)this.cells=this.cells.concat(i);else{var a=this.cells.splice(e,s-e);this.cells=this.cells.concat(i).concat(a)}this._sizeCells(i),this.cellChange(e,!0)}},s.append=function(t){this.insert(t,this.cells.length)},s.prepend=function(t){this.insert(t,0)},s.remove=function(t){var e=this.getCells(t);if(e&&e.length){var s=this.cells.length-1;e.forEach((function(t){t.remove();var e=this.cells.indexOf(t);s=Math.min(e,s),i.removeFrom(this.cells,t)}),this),this.cellChange(s,!0)}},s.cellSizeChange=function(t){var e=this.getCell(t);if(e){e.getSize();var i=this.cells.indexOf(e);this.cellChange(i)}},s.cellChange=function(t,e){var i=this.selectedElement;this._positionCells(t),this._getWrapShiftCells(),this.setGallerySize();var s=this.getCell(i);s&&(this.selectedIndex=this.getCellSlideIndex(s)),this.selectedIndex=Math.min(this.slides.length-1,this.selectedIndex),this.emitEvent("cellChange",[t]),this.select(this.selectedIndex),e&&this.positionSliderAtSelected()},e}(0,t,e)}.apply(e,s))||(t.exports=n)},function(t,e,i){var s,n;window,s=[i(1),i(0)],void 0===(n=function(t,e){return function(t,e,i){"use strict";e.createMethods.push("_createLazyload");var s=e.prototype;function n(t,e){this.img=t,this.flickity=e,this.load()}return s._createLazyload=function(){this.on("select",this.lazyLoad)},s.lazyLoad=function(){var t=this.options.lazyLoad;if(t){var e="number"==typeof t?t:0,s=this.getAdjacentCellElements(e),o=[];s.forEach((function(t){var e=function(t){if("IMG"==t.nodeName){var e=t.getAttribute("data-flickity-lazyload"),s=t.getAttribute("data-flickity-lazyload-src"),n=t.getAttribute("data-flickity-lazyload-srcset");if(e||s||n)return[t]}var o=t.querySelectorAll("img[data-flickity-lazyload], img[data-flickity-lazyload-src], img[data-flickity-lazyload-srcset]");return i.makeArray(o)}(t);o=o.concat(e)})),o.forEach((function(t){new n(t,this)}),this)}},n.prototype.handleEvent=i.handleEvent,n.prototype.load=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this);var t=this.img.getAttribute("data-flickity-lazyload")||this.img.getAttribute("data-flickity-lazyload-src"),e=this.img.getAttribute("data-flickity-lazyload-srcset");this.img.src=t,e&&this.img.setAttribute("srcset",e),this.img.removeAttribute("data-flickity-lazyload"),this.img.removeAttribute("data-flickity-lazyload-src"),this.img.removeAttribute("data-flickity-lazyload-srcset")},n.prototype.onload=function(t){this.complete(t,"flickity-lazyloaded")},n.prototype.onerror=function(t){this.complete(t,"flickity-lazyerror")},n.prototype.complete=function(t,e){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this);var i=this.flickity.getParentCell(this.img),s=i&&i.element;this.flickity.cellSizeChange(s),this.img.classList.add(e),this.flickity.dispatchEvent("lazyLoad",t,s)},e.LazyLoader=n,e}(0,t,e)}.apply(e,s))||(t.exports=n)},function(t,e,i){"use strict";i.r(e);class s{constructor(t){this.el=t,this.toggleEl=this.el.querySelector("[data-collapsible-toggle]"),this.panels=[...this.el.querySelectorAll("[data-collapsible-panel]")],this.group=this.findGroup(),this.toggle=this.toggle.bind(this),this.onClick=this.onClick.bind(this),this.toggleEl&&this.toggleEl.addEventListener("click",this.onClick)}destroy(){this.toggleEl&&this.toggleEl.removeEventListener("click",this.onClick),this.isCollapsed||this.toggle()}get state(){return this.el.dataset.collapsible}set state(t){this.el.dataset.collapsible=t,this.isCollapsed?this.el.classList.remove("is-expanded"):this.el.classList.add("is-expanded")}get isCollapsed(){return"collapsed"===this.state}get container(){return document.querySelector(this.el.dataset.collapsibleContainer)}get closeOnClick(){return void 0!==this.el.dataset.collapsibleCloseOnClick}findGroup(){return[...document.body.querySelectorAll("[data-collapsible-group]")].find(t=>t.contains(this.el))||null}onClick(t){t.preventDefault(),this.toggle()}toggle(){this.state=this.isCollapsed?"expanded":"collapsed",this.maybeRepositionPanel(),this.maybeCloseOnClick(),"expanded"===this.state&&(document.querySelector("[data-collapsible-toggle] + li > a").focus(),null!==this.group&&this.closeOthersInGroup())}collapse(){"expanded"===this.state&&this.toggle()}closeOthersInGroup(){[...this.group.querySelectorAll("[data-collapsible]")].forEach(t=>{t!==this.el&&t.pmcCollapsible.collapse()})}maybeRepositionPanel(){if(this.container)if(this.isCollapsed)this.panels.forEach(t=>t.style.marginLeft="");else{const t=this.container.getBoundingClientRect().left;this.panels.forEach(e=>{const i=e.getBoundingClientRect();if(0===i.width&&0===i.height)return;const s=parseInt(window.getComputedStyle(e).marginLeft,10),n=i.left-2*s;n<t&&(e.style.marginLeft=t-n+"px")})}}maybeCloseOnClick(){this.closeOnClick&&(this.isCollapsed?document.body.removeEventListener("click",this.toggle):setTimeout(()=>document.body.addEventListener("click",this.toggle),1))}}function n(){[...document.querySelectorAll("[data-collapsible]")].forEach(t=>t.pmcCollapsible=new s(t))}var o=i(5),r=i.n(o);class a{constructor(t){var e,i,s,n;this.el=t,this.triggers=[...t.querySelectorAll("[data-video-showcase-trigger]")],this.player=t.querySelector("[data-video-showcase-player]"),this.elementsToHide=[...this.el.querySelectorAll(".is-to-be-hidden")],this.attributesToRemoveFromPlayer=["data-video-showcase-trigger","data-video-showcase-title","data-video-showcase-dek","data-video-showcase-permalink","data-video-showcase-type","href"],this.state={isPlayerSetup:!1,hasSocialShare:!1,videoID:"",videoType:""},this.playerUI={title:t.querySelector(".js-VideoShowcase-title"),sponsoredBadge:t.querySelector(".js-video-showcase-sponsored-badge"),dek:t.querySelector(".js-VideoShowcase-dek"),iframe:t.querySelector("[data-video-showcase-iframe]"),jwplayerContainer:t.querySelector("[data-video-showcase-jwplayer], #jwplayerContainer"),social:t.querySelector("[data-video-showcase-player-social-share]")},this.init(),this.player.dataset.videoShowcaseAutoplay?this.handleTriggerClick(null,this.triggers[0]):(e=this.el,i="click",s="[data-video-showcase-trigger]",n=this.handleTriggerClick.bind(this),e.addEventListener(i,t=>{const e=((t,e)=>e.matches&&e.matches(t))(s,t.target)?t.target:t.target.closest(s);e&&n(t,e)}))}init(){null!==this.playerUI.social&&(this.state.hasSocialShare=!0)}getPlayerCardData(t){const e=t.dataset.videoShowcaseTrigger,i=this.state.hasSocialShare;return{title:t.dataset.videoShowcaseTitle,sponsored:t.dataset.videoShowcaseSponsored,dek:t.dataset.videoShowcaseDek,permalink:t.dataset.videoShowcasePermalink,socialString:function(t){if(window.wp&&i){return wp.template("trigger-social-share-"+e)(void 0)}}()}}updatePlayerCardData(t,e){this.playerUI.title&&e.title&&(this.playerUI.title.innerText=e.title),this.playerUI.title&&e.permalink&&this.playerUI.title.setAttribute("href",e.permalink),e.dek&&(this.playerUI.dek.innerText=e.dek),e.socialString&&this.state.hasSocialShare&&this.updateCardSocialShare(e.socialString),null!==this.playerUI.sponsoredBadge&&(e.sponsored?this.playerUI.sponsoredBadge.classList.remove("u-hidden"):this.playerUI.sponsoredBadge.classList.add("u-hidden"))}updateCardSocialShare(t){this.playerUI.social.removeChild(this.playerUI.social.querySelector("ul")),this.playerUI.social.insertAdjacentHTML("beforeend",t),n()}returnUrl(t,e){return"youtube"===e?"https://www.youtube.com/embed/"+t:"jwplayer"===e?`https://content.jwplatform.com/feeds/${t}.json`:"twitch"===e?"https://player.twitch.tv/?video="+t:void 0}playYoutube(t){this.playerUI.iframe.removeAttribute("hidden"),this.playerUI.iframe.setAttribute("src",t+"?rel=0&autoplay=1&showinfo=0&controls=2&rel=0&modestbranding=0")}playTwitch(t){this.playerUI.iframe.removeAttribute("hidden"),this.playerUI.iframe.setAttribute("src",`${t}&autoplay=true&parent=${window.location.hostname}`)}playJW(t){this.playerUI.jwplayerContainer.removeAttribute("hidden"),window.pmc_jwplayer&&window.pmc_jwplayer(this.playerUI.jwplayerContainer.id).setup({playlist:t,aspectratio:"16:9"}).play()}handleTriggerClick(t,e){t&&t.preventDefault();let i=this.state.videoType;this.state.videoType=e.dataset.videoShowcaseType,this.state.videoID=e.dataset.videoShowcaseTrigger,this.resetPlayer(i),this.playVideo(this.state.videoID,this.state.videoType),this.updatePlayerUI(this.state.videoID),this.onFirstTimePlay()}playVideo(t,e){let i=this.returnUrl(t,e);"youtube"===e&&this.playYoutube(i),"jwplayer"===e&&this.playJW(i),"twitch"===e&&this.playTwitch(i)}onFirstTimePlay(){!1===this.state.isPlayerSetup&&(this.el.dispatchEvent(new CustomEvent("firstVideoPlay")),this.elementsToHide.forEach(t=>t.setAttribute("hidden","")),this.attributesToRemoveFromPlayer.forEach(t=>this.player.parentNode.removeAttribute(t)),this.state.isPlayerSetup=!0)}updatePlayerUI(t){const e=this.el.querySelector(`[data-video-showcase-trigger="${t}"]`),i=this.getPlayerCardData(e);this.setActiveTrigger(t),this.updatePlayerCardData(e,i)}resetPlayer(t){"jwplayer"===t&&window.pmc_jwplayer&&(window.pmc_jwplayer("jwplayerContainer").remove(),this.playerUI.jwplayerContainer.setAttribute("hidden","")),"youtube"===t&&(this.playerUI.iframe.setAttribute("src",""),this.playerUI.iframe.setAttribute("hidden",""))}resetAllTriggers(){this.triggers.forEach(t=>t.classList.remove("is-playing"))}setActiveTrigger(t){let e=this.el.querySelector(`[data-video-showcase-trigger="${t}"]`);this.resetAllTriggers(),null!==e&&e.classList.add("is-playing")}}document.addEventListener("DOMContentLoaded",()=>{n(),[...document.querySelectorAll(".js-Flickity")].forEach(t=>{let e=t.classList.contains("js-Flickity--isContained"),i=t.classList.contains("js-Flickity--isFreeScroll"),s=t.classList.contains("js-Flickity--isWrapAround"),n=t.classList.contains("js-Flickity--pageDots");return new r.a(t,{cellSelector:".js-Flickity-cell",pageDots:n,imagesLoaded:!0,groupCells:!0,contain:e,wrapAround:s,freeScroll:i,arrowShape:{x0:10,x1:60,y1:50,x2:65,y2:45,x3:20}})}),function(){const t=[...document.querySelectorAll("[data-video-showcase]")];t.length&&t.forEach(t=>t.pmcVideoShowcase=new a(t))}()})}]);
|
|
26
|
+
*/!function(o,r){s=[i(3)],void 0===(n=function(t){return function(t,e){"use strict";function i(){}var s=i.prototype=Object.create(e.prototype);s.bindHandles=function(){this._bindHandles(!0)},s.unbindHandles=function(){this._bindHandles(!1)},s._bindHandles=function(e){for(var i=(e=void 0===e||e)?"addEventListener":"removeEventListener",s=e?this._touchActionValue:"",n=0;n<this.handles.length;n++){var o=this.handles[n];this._bindStartEvent(o,e),o[i]("click",this),t.PointerEvent&&(o.style.touchAction=s)}},s._touchActionValue="none",s.pointerDown=function(t,e){this.okayPointerDown(t)&&(this.pointerDownPointer={pageX:e.pageX,pageY:e.pageY},t.preventDefault(),this.pointerDownBlur(),this._bindPostStartEvents(t),this.emitEvent("pointerDown",[t,e]))};var n={TEXTAREA:!0,INPUT:!0,SELECT:!0,OPTION:!0},o={radio:!0,checkbox:!0,button:!0,submit:!0,image:!0,file:!0};return s.okayPointerDown=function(t){var e=n[t.target.nodeName],i=o[t.target.type],s=!e||i;return s||this._pointerReset(),s},s.pointerDownBlur=function(){var t=document.activeElement;t&&t.blur&&t!=document.body&&t.blur()},s.pointerMove=function(t,e){var i=this._dragPointerMove(t,e);this.emitEvent("pointerMove",[t,e,i]),this._dragMove(t,e,i)},s._dragPointerMove=function(t,e){var i={x:e.pageX-this.pointerDownPointer.pageX,y:e.pageY-this.pointerDownPointer.pageY};return!this.isDragging&&this.hasDragStarted(i)&&this._dragStart(t,e),i},s.hasDragStarted=function(t){return Math.abs(t.x)>3||Math.abs(t.y)>3},s.pointerUp=function(t,e){this.emitEvent("pointerUp",[t,e]),this._dragPointerUp(t,e)},s._dragPointerUp=function(t,e){this.isDragging?this._dragEnd(t,e):this._staticClick(t,e)},s._dragStart=function(t,e){this.isDragging=!0,this.isPreventingClicks=!0,this.dragStart(t,e)},s.dragStart=function(t,e){this.emitEvent("dragStart",[t,e])},s._dragMove=function(t,e,i){this.isDragging&&this.dragMove(t,e,i)},s.dragMove=function(t,e,i){t.preventDefault(),this.emitEvent("dragMove",[t,e,i])},s._dragEnd=function(t,e){this.isDragging=!1,setTimeout(function(){delete this.isPreventingClicks}.bind(this)),this.dragEnd(t,e)},s.dragEnd=function(t,e){this.emitEvent("dragEnd",[t,e])},s.onclick=function(t){this.isPreventingClicks&&t.preventDefault()},s._staticClick=function(t,e){this.isIgnoringMouseUp&&"mouseup"==t.type||(this.staticClick(t,e),"mouseup"!=t.type&&(this.isIgnoringMouseUp=!0,setTimeout(function(){delete this.isIgnoringMouseUp}.bind(this),400)))},s.staticClick=function(t,e){this.emitEvent("staticClick",[t,e])},i.getPointerPoint=e.getPointerPoint,i}(o,t)}.apply(e,s))||(t.exports=n)}(window)},function(t,e,i){var s,n;window,s=[i(1),i(3),i(0)],void 0===(n=function(t,e,i){return function(t,e,i,s){"use strict";var n="http://www.w3.org/2000/svg";function o(t,e){this.direction=t,this.parent=e,this._create()}o.prototype=Object.create(i.prototype),o.prototype._create=function(){this.isEnabled=!0,this.isPrevious=-1==this.direction;var t=this.parent.options.rightToLeft?1:-1;this.isLeft=this.direction==t;var e=this.element=document.createElement("button");e.className="flickity-button flickity-prev-next-button",e.className+=this.isPrevious?" previous":" next",e.setAttribute("type","button"),this.disable(),e.setAttribute("aria-label",this.isPrevious?"Previous":"Next");var i=this.createSVG();e.appendChild(i),this.parent.on("select",this.update.bind(this)),this.on("pointerDown",this.parent.childUIPointerDown.bind(this.parent))},o.prototype.activate=function(){this.bindStartEvent(this.element),this.element.addEventListener("click",this),this.parent.element.appendChild(this.element)},o.prototype.deactivate=function(){this.parent.element.removeChild(this.element),this.unbindStartEvent(this.element),this.element.removeEventListener("click",this)},o.prototype.createSVG=function(){var t=document.createElementNS(n,"svg");t.setAttribute("class","flickity-button-icon"),t.setAttribute("viewBox","0 0 100 100");var e,i=document.createElementNS(n,"path"),s="string"==typeof(e=this.parent.options.arrowShape)?e:"M "+e.x0+",50 L "+e.x1+","+(e.y1+50)+" L "+e.x2+","+(e.y2+50)+" L "+e.x3+",50 L "+e.x2+","+(50-e.y2)+" L "+e.x1+","+(50-e.y1)+" Z";return i.setAttribute("d",s),i.setAttribute("class","arrow"),this.isLeft||i.setAttribute("transform","translate(100, 100) rotate(180) "),t.appendChild(i),t},o.prototype.handleEvent=s.handleEvent,o.prototype.onclick=function(){if(this.isEnabled){this.parent.uiChange();var t=this.isPrevious?"previous":"next";this.parent[t]()}},o.prototype.enable=function(){this.isEnabled||(this.element.disabled=!1,this.isEnabled=!0)},o.prototype.disable=function(){this.isEnabled&&(this.element.disabled=!0,this.isEnabled=!1)},o.prototype.update=function(){var t=this.parent.slides;if(this.parent.options.wrapAround&&t.length>1)this.enable();else{var e=t.length?t.length-1:0,i=this.isPrevious?0:e;this[this.parent.selectedIndex==i?"disable":"enable"]()}},o.prototype.destroy=function(){this.deactivate(),this.allOff()},s.extend(e.defaults,{prevNextButtons:!0,arrowShape:{x0:10,x1:60,y1:50,x2:70,y2:40,x3:30}}),e.createMethods.push("_createPrevNextButtons");var r=e.prototype;return r._createPrevNextButtons=function(){this.options.prevNextButtons&&(this.prevButton=new o(-1,this),this.nextButton=new o(1,this),this.on("activate",this.activatePrevNextButtons))},r.activatePrevNextButtons=function(){this.prevButton.activate(),this.nextButton.activate(),this.on("deactivate",this.deactivatePrevNextButtons)},r.deactivatePrevNextButtons=function(){this.prevButton.deactivate(),this.nextButton.deactivate(),this.off("deactivate",this.deactivatePrevNextButtons)},e.PrevNextButton=o,e}(0,t,e,i)}.apply(e,s))||(t.exports=n)},function(t,e,i){var s,n;window,s=[i(1),i(3),i(0)],void 0===(n=function(t,e,i){return function(t,e,i,s){"use strict";function n(t){this.parent=t,this._create()}n.prototype=Object.create(i.prototype),n.prototype._create=function(){this.holder=document.createElement("ol"),this.holder.className="flickity-page-dots",this.dots=[],this.handleClick=this.onClick.bind(this),this.on("pointerDown",this.parent.childUIPointerDown.bind(this.parent))},n.prototype.activate=function(){this.setDots(),this.holder.addEventListener("click",this.handleClick),this.bindStartEvent(this.holder),this.parent.element.appendChild(this.holder)},n.prototype.deactivate=function(){this.holder.removeEventListener("click",this.handleClick),this.unbindStartEvent(this.holder),this.parent.element.removeChild(this.holder)},n.prototype.setDots=function(){var t=this.parent.slides.length-this.dots.length;t>0?this.addDots(t):t<0&&this.removeDots(-t)},n.prototype.addDots=function(t){for(var e=document.createDocumentFragment(),i=[],s=this.dots.length,n=s+t,o=s;o<n;o++){var r=document.createElement("li");r.className="dot",r.setAttribute("aria-label","Page dot "+(o+1)),e.appendChild(r),i.push(r)}this.holder.appendChild(e),this.dots=this.dots.concat(i)},n.prototype.removeDots=function(t){this.dots.splice(this.dots.length-t,t).forEach((function(t){this.holder.removeChild(t)}),this)},n.prototype.updateSelected=function(){this.selectedDot&&(this.selectedDot.className="dot",this.selectedDot.removeAttribute("aria-current")),this.dots.length&&(this.selectedDot=this.dots[this.parent.selectedIndex],this.selectedDot.className="dot is-selected",this.selectedDot.setAttribute("aria-current","step"))},n.prototype.onTap=n.prototype.onClick=function(t){var e=t.target;if("LI"==e.nodeName){this.parent.uiChange();var i=this.dots.indexOf(e);this.parent.select(i)}},n.prototype.destroy=function(){this.deactivate(),this.allOff()},e.PageDots=n,s.extend(e.defaults,{pageDots:!0}),e.createMethods.push("_createPageDots");var o=e.prototype;return o._createPageDots=function(){this.options.pageDots&&(this.pageDots=new n(this),this.on("activate",this.activatePageDots),this.on("select",this.updateSelectedPageDots),this.on("cellChange",this.updatePageDots),this.on("resize",this.updatePageDots),this.on("deactivate",this.deactivatePageDots))},o.activatePageDots=function(){this.pageDots.activate()},o.updateSelectedPageDots=function(){this.pageDots.updateSelected()},o.updatePageDots=function(){this.pageDots.setDots()},o.deactivatePageDots=function(){this.pageDots.deactivate()},e.PageDots=n,e}(0,t,e,i)}.apply(e,s))||(t.exports=n)},function(t,e,i){var s,n;window,s=[i(2),i(0),i(1)],void 0===(n=function(t,e,i){return function(t,e,i){"use strict";function s(t){this.parent=t,this.state="stopped",this.onVisibilityChange=this.visibilityChange.bind(this),this.onVisibilityPlay=this.visibilityPlay.bind(this)}s.prototype=Object.create(t.prototype),s.prototype.play=function(){"playing"!=this.state&&(document.hidden?document.addEventListener("visibilitychange",this.onVisibilityPlay):(this.state="playing",document.addEventListener("visibilitychange",this.onVisibilityChange),this.tick()))},s.prototype.tick=function(){if("playing"==this.state){var t=this.parent.options.autoPlay;t="number"==typeof t?t:3e3;var e=this;this.clear(),this.timeout=setTimeout((function(){e.parent.next(!0),e.tick()}),t)}},s.prototype.stop=function(){this.state="stopped",this.clear(),document.removeEventListener("visibilitychange",this.onVisibilityChange)},s.prototype.clear=function(){clearTimeout(this.timeout)},s.prototype.pause=function(){"playing"==this.state&&(this.state="paused",this.clear())},s.prototype.unpause=function(){"paused"==this.state&&this.play()},s.prototype.visibilityChange=function(){this[document.hidden?"pause":"unpause"]()},s.prototype.visibilityPlay=function(){this.play(),document.removeEventListener("visibilitychange",this.onVisibilityPlay)},e.extend(i.defaults,{pauseAutoPlayOnHover:!0}),i.createMethods.push("_createPlayer");var n=i.prototype;return n._createPlayer=function(){this.player=new s(this),this.on("activate",this.activatePlayer),this.on("uiChange",this.stopPlayer),this.on("pointerDown",this.stopPlayer),this.on("deactivate",this.deactivatePlayer)},n.activatePlayer=function(){this.options.autoPlay&&(this.player.play(),this.element.addEventListener("mouseenter",this))},n.playPlayer=function(){this.player.play()},n.stopPlayer=function(){this.player.stop()},n.pausePlayer=function(){this.player.pause()},n.unpausePlayer=function(){this.player.unpause()},n.deactivatePlayer=function(){this.player.stop(),this.element.removeEventListener("mouseenter",this)},n.onmouseenter=function(){this.options.pauseAutoPlayOnHover&&(this.player.pause(),this.element.addEventListener("mouseleave",this))},n.onmouseleave=function(){this.player.unpause(),this.element.removeEventListener("mouseleave",this)},i.Player=s,i}(t,e,i)}.apply(e,s))||(t.exports=n)},function(t,e,i){var s,n;window,s=[i(1),i(0)],void 0===(n=function(t,e){return function(t,e,i){"use strict";var s=e.prototype;return s.insert=function(t,e){var i=this._makeCells(t);if(i&&i.length){var s=this.cells.length;e=void 0===e?s:e;var n=function(t){var e=document.createDocumentFragment();return t.forEach((function(t){e.appendChild(t.element)})),e}(i),o=e==s;if(o)this.slider.appendChild(n);else{var r=this.cells[e].element;this.slider.insertBefore(n,r)}if(0===e)this.cells=i.concat(this.cells);else if(o)this.cells=this.cells.concat(i);else{var a=this.cells.splice(e,s-e);this.cells=this.cells.concat(i).concat(a)}this._sizeCells(i),this.cellChange(e,!0)}},s.append=function(t){this.insert(t,this.cells.length)},s.prepend=function(t){this.insert(t,0)},s.remove=function(t){var e=this.getCells(t);if(e&&e.length){var s=this.cells.length-1;e.forEach((function(t){t.remove();var e=this.cells.indexOf(t);s=Math.min(e,s),i.removeFrom(this.cells,t)}),this),this.cellChange(s,!0)}},s.cellSizeChange=function(t){var e=this.getCell(t);if(e){e.getSize();var i=this.cells.indexOf(e);this.cellChange(i)}},s.cellChange=function(t,e){var i=this.selectedElement;this._positionCells(t),this._getWrapShiftCells(),this.setGallerySize();var s=this.getCell(i);s&&(this.selectedIndex=this.getCellSlideIndex(s)),this.selectedIndex=Math.min(this.slides.length-1,this.selectedIndex),this.emitEvent("cellChange",[t]),this.select(this.selectedIndex),e&&this.positionSliderAtSelected()},e}(0,t,e)}.apply(e,s))||(t.exports=n)},function(t,e,i){var s,n;window,s=[i(1),i(0)],void 0===(n=function(t,e){return function(t,e,i){"use strict";e.createMethods.push("_createLazyload");var s=e.prototype;function n(t,e){this.img=t,this.flickity=e,this.load()}return s._createLazyload=function(){this.on("select",this.lazyLoad)},s.lazyLoad=function(){var t=this.options.lazyLoad;if(t){var e="number"==typeof t?t:0,s=this.getAdjacentCellElements(e),o=[];s.forEach((function(t){var e=function(t){if("IMG"==t.nodeName){var e=t.getAttribute("data-flickity-lazyload"),s=t.getAttribute("data-flickity-lazyload-src"),n=t.getAttribute("data-flickity-lazyload-srcset");if(e||s||n)return[t]}var o=t.querySelectorAll("img[data-flickity-lazyload], img[data-flickity-lazyload-src], img[data-flickity-lazyload-srcset]");return i.makeArray(o)}(t);o=o.concat(e)})),o.forEach((function(t){new n(t,this)}),this)}},n.prototype.handleEvent=i.handleEvent,n.prototype.load=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this);var t=this.img.getAttribute("data-flickity-lazyload")||this.img.getAttribute("data-flickity-lazyload-src"),e=this.img.getAttribute("data-flickity-lazyload-srcset");this.img.src=t,e&&this.img.setAttribute("srcset",e),this.img.removeAttribute("data-flickity-lazyload"),this.img.removeAttribute("data-flickity-lazyload-src"),this.img.removeAttribute("data-flickity-lazyload-srcset")},n.prototype.onload=function(t){this.complete(t,"flickity-lazyloaded")},n.prototype.onerror=function(t){this.complete(t,"flickity-lazyerror")},n.prototype.complete=function(t,e){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this);var i=this.flickity.getParentCell(this.img),s=i&&i.element;this.flickity.cellSizeChange(s),this.img.classList.add(e),this.flickity.dispatchEvent("lazyLoad",t,s)},e.LazyLoader=n,e}(0,t,e)}.apply(e,s))||(t.exports=n)},function(t,e,i){"use strict";i.r(e);class s{constructor(t){this.el=t,this.toggleEl=this.el.querySelector("[data-collapsible-toggle]"),this.panels=[...this.el.querySelectorAll("[data-collapsible-panel]")],this.group=this.findGroup(),this.toggle=this.toggle.bind(this),this.onClick=this.onClick.bind(this),this.toggleEl&&this.toggleEl.addEventListener("click",this.onClick)}destroy(){this.toggleEl&&this.toggleEl.removeEventListener("click",this.onClick),this.isCollapsed||this.toggle()}get state(){return this.el.dataset.collapsible}set state(t){this.el.dataset.collapsible=t,this.isCollapsed?this.el.classList.remove("is-expanded"):this.el.classList.add("is-expanded")}get isCollapsed(){return"collapsed"===this.state}get container(){return document.querySelector(this.el.dataset.collapsibleContainer)}get closeOnClick(){return void 0!==this.el.dataset.collapsibleCloseOnClick}findGroup(){return[...document.body.querySelectorAll("[data-collapsible-group]")].find(t=>t.contains(this.el))||null}onClick(t){t.preventDefault(),this.toggle()}toggle(){this.state=this.isCollapsed?"expanded":"collapsed",this.maybeRepositionPanel(),this.maybeCloseOnClick(),"expanded"===this.state&&(document.querySelector("[data-collapsible-toggle] + li > a").focus(),null!==this.group&&this.closeOthersInGroup())}collapse(){"expanded"===this.state&&this.toggle()}closeOthersInGroup(){[...this.group.querySelectorAll("[data-collapsible]")].forEach(t=>{t!==this.el&&t.pmcCollapsible.collapse()})}maybeRepositionPanel(){if(this.container)if(this.isCollapsed)this.panels.forEach(t=>t.style.marginLeft="");else{const t=this.container.getBoundingClientRect().left;this.panels.forEach(e=>{const i=e.getBoundingClientRect();if(0===i.width&&0===i.height)return;const s=parseInt(window.getComputedStyle(e).marginLeft,10),n=i.left-2*s;n<t&&(e.style.marginLeft=t-n+"px")})}}maybeCloseOnClick(){this.closeOnClick&&(this.isCollapsed?document.body.removeEventListener("click",this.toggle):setTimeout(()=>document.body.addEventListener("click",this.toggle),1))}}function n(){[...document.querySelectorAll("[data-collapsible]")].forEach(t=>t.pmcCollapsible=new s(t))}var o=i(5),r=i.n(o);class a{constructor(t){var e,i,s,n;this.el=t,this.triggers=[...t.querySelectorAll("[data-video-showcase-trigger]")],this.player=t.querySelector("[data-video-showcase-player]"),this.elementsToHide=[...this.el.querySelectorAll(".is-to-be-hidden")],this.attributesToRemoveFromPlayer=["data-video-showcase-trigger","data-video-showcase-title","data-video-showcase-dek","data-video-showcase-permalink","data-video-showcase-type","href"],this.state={isPlayerSetup:!1,hasSocialShare:!1,videoID:"",videoType:""},this.playerUI={title:t.querySelector(".js-VideoShowcase-title"),sponsoredBadge:t.querySelector(".js-video-showcase-sponsored-badge"),dek:t.querySelector(".js-VideoShowcase-dek"),iframe:t.querySelector("[data-video-showcase-iframe]"),jwplayerContainer:t.querySelector("[data-video-showcase-jwplayer], #jwplayerContainer"),social:t.querySelector("[data-video-showcase-player-social-share]")},this.init(),this.player.dataset.videoShowcaseAutoplay?this.handleTriggerClick(null,this.triggers[0]):(e=this.el,i="click",s="[data-video-showcase-trigger]",n=this.handleTriggerClick.bind(this),e.addEventListener(i,t=>{const e=((t,e)=>e.matches&&e.matches(t))(s,t.target)?t.target:t.target.closest(s);e&&n(t,e)}))}init(){null!==this.playerUI.social&&(this.state.hasSocialShare=!0)}getPlayerCardData(t){const e=t.dataset.videoShowcaseTrigger,i=this.state.hasSocialShare;return{title:t.dataset.videoShowcaseTitle,sponsored:t.dataset.videoShowcaseSponsored,dek:t.dataset.videoShowcaseDek,permalink:t.dataset.videoShowcasePermalink,socialString:function(t){if(window.wp&&i){return wp.template("trigger-social-share-"+e)(void 0)}}()}}updatePlayerCardData(t,e){this.playerUI.title&&e.title&&(this.playerUI.title.innerText=e.title),this.playerUI.title&&e.permalink&&this.playerUI.title.setAttribute("href",e.permalink),e.dek&&(this.playerUI.dek.innerText=e.dek),e.socialString&&this.state.hasSocialShare&&this.updateCardSocialShare(e.socialString),null!==this.playerUI.sponsoredBadge&&(e.sponsored?this.playerUI.sponsoredBadge.classList.remove("u-hidden"):this.playerUI.sponsoredBadge.classList.add("u-hidden"))}updateCardSocialShare(t){this.playerUI.social.removeChild(this.playerUI.social.querySelector("ul")),this.playerUI.social.insertAdjacentHTML("beforeend",t),n()}returnUrl(t,e){return"youtube"===e?"https://www.youtube.com/embed/"+t:"jwplayer"===e?`https://content.jwplatform.com/feeds/${t}.json`:"twitch"===e?"https://player.twitch.tv/?video="+t:void 0}playYoutube(t){this.playerUI.iframe.removeAttribute("hidden"),this.playerUI.iframe.setAttribute("src",t+"?rel=0&autoplay=1&showinfo=0&controls=2&rel=0&modestbranding=0")}playTwitch(t){this.playerUI.iframe.removeAttribute("hidden"),this.playerUI.iframe.setAttribute("src",`${t}&autoplay=true&parent=${window.location.hostname}`)}playJW(t){this.playerUI.jwplayerContainer.removeAttribute("hidden"),window.pmc_jwplayer&&window.pmc_jwplayer(this.playerUI.jwplayerContainer.id).setup({playlist:t,aspectratio:"16:9"}).play()}handleTriggerClick(t,e){t&&t.preventDefault();const i=this.state.videoType;this.state.videoType=e.dataset.videoShowcaseType,this.state.videoID=e.dataset.videoShowcaseTrigger,this.resetPlayer(i),this.playVideo(this.state.videoID,this.state.videoType),this.updatePlayerUI(this.state.videoID),this.onFirstTimePlay()}playVideo(t,e){const i=this.returnUrl(t,e);"youtube"===e&&this.playYoutube(i),"jwplayer"===e&&this.playJW(i),"twitch"===e&&this.playTwitch(i)}onFirstTimePlay(){!1===this.state.isPlayerSetup&&(this.el.dispatchEvent(new CustomEvent("firstVideoPlay")),this.elementsToHide.forEach(t=>t.setAttribute("hidden","")),this.attributesToRemoveFromPlayer.forEach(t=>this.player.parentNode.removeAttribute(t)),this.state.isPlayerSetup=!0)}updatePlayerUI(t){const e=this.el.querySelector(`[data-video-showcase-trigger="${t}"]`),i=this.getPlayerCardData(e);this.setActiveTrigger(t),this.updatePlayerCardData(e,i)}resetPlayer(t){"jwplayer"===t&&window.pmc_jwplayer&&(window.pmc_jwplayer("jwplayerContainer").remove(),this.playerUI.jwplayerContainer.setAttribute("hidden","")),"youtube"===t&&(this.playerUI.iframe.setAttribute("src",""),this.playerUI.iframe.setAttribute("hidden",""))}resetAllTriggers(){this.triggers.forEach(t=>t.classList.remove("is-playing"))}setActiveTrigger(t){const e=this.el.querySelector(`[data-video-showcase-trigger="${t}"]`);this.resetAllTriggers(),null!==e&&e.classList.add("is-playing")}}document.addEventListener("DOMContentLoaded",()=>{n(),[...document.querySelectorAll(".js-Flickity")].forEach(t=>{const e=t.classList.contains("js-Flickity--isContained"),i=t.classList.contains("js-Flickity--isFreeScroll"),s=t.classList.contains("js-Flickity--isWrapAround"),n=t.classList.contains("js-Flickity--pageDots");return new r.a(t,{cellSelector:".js-Flickity-cell",pageDots:n,imagesLoaded:!0,groupCells:!0,contain:e,wrapAround:s,freeScroll:i,arrowShape:{x0:10,x1:60,y1:50,x2:65,y2:45,x3:20}})}),function(){const t=[...document.querySelectorAll("[data-video-showcase]")];t.length&&t.forEach(t=>t.pmcVideoShowcase=new a(t))}()})}]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@penskemediacorp/larva-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.1",
|
|
4
4
|
"description": "Larva JS patterns.",
|
|
5
5
|
"author": "laras126 <laras126@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/penske-media-corp/pmc-larva#readme",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"webpack": "^4.43.0",
|
|
27
27
|
"webpack-cli": "^3.3.12"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "cb5a91282f5e1f4f023f2c2f8a97752c2918868c"
|
|
30
30
|
}
|
|
@@ -11,15 +11,17 @@ describe( 'removeDesktopXlClasses', () => {
|
|
|
11
11
|
setup();
|
|
12
12
|
|
|
13
13
|
it( 'rebuilds the class name without @desktop-xl classes', () => {
|
|
14
|
-
|
|
15
14
|
const el = document.querySelector( '.module' );
|
|
16
15
|
|
|
17
|
-
expect( el.className ).toBe(
|
|
18
|
-
|
|
16
|
+
expect( el.className ).toBe(
|
|
17
|
+
' module // u-margin-t-125 lrv-a-wrapper lrv-a-grid u-grid-gap-0'
|
|
18
|
+
);
|
|
19
19
|
} );
|
|
20
20
|
|
|
21
21
|
it( 'removes all @desktop-xl classes', () => {
|
|
22
|
-
const desktopXlEls = [
|
|
22
|
+
const desktopXlEls = [
|
|
23
|
+
...document.querySelectorAll( '[class*="@desktop-xl"]' ),
|
|
24
|
+
];
|
|
23
25
|
|
|
24
26
|
expect( desktopXlEls.length ).toBe( 0 );
|
|
25
27
|
} );
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// Copied from Deadline
|
|
2
2
|
export default class Collapsible {
|
|
3
3
|
constructor( el ) {
|
|
4
|
-
this.el
|
|
4
|
+
this.el = el;
|
|
5
5
|
this.toggleEl = this.el.querySelector( '[data-collapsible-toggle]' );
|
|
6
|
-
this.panels
|
|
7
|
-
|
|
6
|
+
this.panels = [
|
|
7
|
+
...this.el.querySelectorAll( '[data-collapsible-panel]' ),
|
|
8
|
+
];
|
|
9
|
+
this.group = this.findGroup();
|
|
8
10
|
|
|
9
|
-
this.toggle
|
|
11
|
+
this.toggle = this.toggle.bind( this );
|
|
10
12
|
this.onClick = this.onClick.bind( this );
|
|
11
13
|
|
|
12
14
|
if ( this.toggleEl ) {
|
|
@@ -51,8 +53,10 @@ export default class Collapsible {
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
findGroup() {
|
|
54
|
-
const groups = [
|
|
55
|
-
|
|
56
|
+
const groups = [
|
|
57
|
+
...document.body.querySelectorAll( '[data-collapsible-group]' ),
|
|
58
|
+
];
|
|
59
|
+
return groups.find( ( g ) => g.contains( this.el ) ) || null;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
onClick( e ) {
|
|
@@ -61,12 +65,14 @@ export default class Collapsible {
|
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
toggle() {
|
|
64
|
-
this.state =
|
|
68
|
+
this.state = this.isCollapsed ? 'expanded' : 'collapsed';
|
|
65
69
|
this.maybeRepositionPanel();
|
|
66
70
|
this.maybeCloseOnClick();
|
|
67
71
|
|
|
68
72
|
if ( 'expanded' === this.state ) {
|
|
69
|
-
document
|
|
73
|
+
document
|
|
74
|
+
.querySelector( '[data-collapsible-toggle] + li > a' )
|
|
75
|
+
.focus();
|
|
70
76
|
|
|
71
77
|
if ( null !== this.group ) {
|
|
72
78
|
this.closeOthersInGroup();
|
|
@@ -81,11 +87,13 @@ export default class Collapsible {
|
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
closeOthersInGroup() {
|
|
84
|
-
[ ...
|
|
85
|
-
|
|
86
|
-
collapsible.
|
|
90
|
+
[ ...this.group.querySelectorAll( '[data-collapsible]' ) ].forEach(
|
|
91
|
+
( collapsible ) => {
|
|
92
|
+
if ( collapsible !== this.el ) {
|
|
93
|
+
collapsible.pmcCollapsible.collapse();
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
|
-
|
|
96
|
+
);
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
maybeRepositionPanel() {
|
|
@@ -94,19 +102,22 @@ export default class Collapsible {
|
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
if ( this.isCollapsed ) {
|
|
97
|
-
this.panels.forEach( panel => panel.style.marginLeft = '' );
|
|
105
|
+
this.panels.forEach( ( panel ) => ( panel.style.marginLeft = '' ) );
|
|
98
106
|
} else {
|
|
99
107
|
const containerLeft = this.container.getBoundingClientRect().left;
|
|
100
108
|
|
|
101
|
-
this.panels.forEach( panel => {
|
|
109
|
+
this.panels.forEach( ( panel ) => {
|
|
102
110
|
const panelRect = panel.getBoundingClientRect();
|
|
103
111
|
|
|
104
112
|
if ( 0 === panelRect.width && 0 === panelRect.height ) {
|
|
105
113
|
return;
|
|
106
114
|
}
|
|
107
115
|
|
|
108
|
-
const panelMarginLeft = parseInt(
|
|
109
|
-
|
|
116
|
+
const panelMarginLeft = parseInt(
|
|
117
|
+
window.getComputedStyle( panel ).marginLeft,
|
|
118
|
+
10
|
|
119
|
+
);
|
|
120
|
+
const left = panelRect.left - panelMarginLeft * 2;
|
|
110
121
|
|
|
111
122
|
if ( left < containerLeft ) {
|
|
112
123
|
panel.style.marginLeft = `${ containerLeft - left }px`;
|
|
@@ -123,7 +134,10 @@ export default class Collapsible {
|
|
|
123
134
|
if ( this.isCollapsed ) {
|
|
124
135
|
document.body.removeEventListener( 'click', this.toggle );
|
|
125
136
|
} else {
|
|
126
|
-
setTimeout(
|
|
137
|
+
setTimeout(
|
|
138
|
+
() => document.body.addEventListener( 'click', this.toggle ),
|
|
139
|
+
1
|
|
140
|
+
);
|
|
127
141
|
}
|
|
128
142
|
}
|
|
129
143
|
}
|
|
@@ -2,6 +2,10 @@ import Collapsible from './Collapsible';
|
|
|
2
2
|
|
|
3
3
|
// Initialize all Dropdowns.
|
|
4
4
|
export default function initCollapsible() {
|
|
5
|
-
const collapsibles
|
|
6
|
-
|
|
5
|
+
const collapsibles = [
|
|
6
|
+
...document.querySelectorAll( '[data-collapsible]' ),
|
|
7
|
+
];
|
|
8
|
+
collapsibles.forEach(
|
|
9
|
+
( el ) => ( el.pmcCollapsible = new Collapsible( el ) )
|
|
10
|
+
);
|
|
7
11
|
}
|
|
@@ -11,44 +11,48 @@
|
|
|
11
11
|
* - `data-email-capture-success-url` - added to the hidden input with the name `__successPage`
|
|
12
12
|
* and value attribute set to success page URL.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* The UI pattern `c-email-field` can be used for the email input portion of this feature.
|
|
16
16
|
*
|
|
17
17
|
* @since 2019-04-15
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
export default class EmailCapture {
|
|
21
|
-
|
|
22
21
|
constructor( el ) {
|
|
23
22
|
this.el = el;
|
|
24
23
|
|
|
25
24
|
this.emailInput = this.el.querySelector( 'input[type="email"]' );
|
|
26
|
-
this.successEl = this.el.querySelector(
|
|
25
|
+
this.successEl = this.el.querySelector(
|
|
26
|
+
'[data-email-capture-success-url]'
|
|
27
|
+
);
|
|
27
28
|
|
|
28
|
-
this.updateSuccessUrlInputValue =
|
|
29
|
+
this.updateSuccessUrlInputValue =
|
|
30
|
+
this.updateSuccessUrlInputValue.bind( this );
|
|
29
31
|
|
|
30
32
|
this.successUrlBase = this.getSuccessUrlBase();
|
|
31
33
|
|
|
32
|
-
this.emailInput.addEventListener(
|
|
33
|
-
|
|
34
|
+
this.emailInput.addEventListener(
|
|
35
|
+
'blur',
|
|
36
|
+
this.updateSuccessUrlInputValue
|
|
37
|
+
);
|
|
38
|
+
this.emailInput.addEventListener(
|
|
39
|
+
'keyup',
|
|
40
|
+
this.updateSuccessUrlInputValue
|
|
41
|
+
);
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
getSuccessUrlBase() {
|
|
37
|
-
|
|
38
45
|
if ( null !== this.successEl ) {
|
|
39
46
|
return this.successEl.dataset.emailCaptureSuccessUrl;
|
|
40
|
-
} else {
|
|
41
|
-
return undefined;
|
|
42
47
|
}
|
|
43
|
-
|
|
48
|
+
return undefined;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
updateSuccessUrlInputValue( e ) {
|
|
47
|
-
|
|
52
|
+
const email = encodeURIComponent( e.target.value );
|
|
48
53
|
|
|
49
54
|
if ( undefined !== this.successUrlBase ) {
|
|
50
|
-
this.successEl.value = `${this.successUrlBase}&email=${email}`;
|
|
55
|
+
this.successEl.value = `${ this.successUrlBase }&email=${ email }`;
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
|
-
|
|
54
58
|
}
|
|
@@ -2,8 +2,11 @@ import EmailCapture from './EmailCapture';
|
|
|
2
2
|
|
|
3
3
|
// Initialize EmailCapture.
|
|
4
4
|
export default function initEmailCaptures() {
|
|
5
|
+
const emailCaptures = [
|
|
6
|
+
...document.querySelectorAll( '.lrv-js-EmailCapture' ),
|
|
7
|
+
];
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
emailCaptures.forEach(
|
|
10
|
+
( el ) => ( el.pmcEmailCapture = new EmailCapture( el ) )
|
|
11
|
+
);
|
|
9
12
|
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
export default class ExpandableSearch {
|
|
2
|
-
constructor(el) {
|
|
2
|
+
constructor( el ) {
|
|
3
3
|
this.el = el;
|
|
4
4
|
this.isOpen = false;
|
|
5
|
-
this.trigger = this.el.querySelector('.js-ExpandableSearch-trigger');
|
|
6
|
-
this.target = this.el.querySelector('.js-ExpandableSearch-target');
|
|
7
|
-
this.targetInput = this.target.querySelector('input');
|
|
5
|
+
this.trigger = this.el.querySelector( '.js-ExpandableSearch-trigger' );
|
|
6
|
+
this.target = this.el.querySelector( '.js-ExpandableSearch-target' );
|
|
7
|
+
this.targetInput = this.target.querySelector( 'input' );
|
|
8
8
|
|
|
9
|
-
this.trigger.addEventListener('click', () => {
|
|
9
|
+
this.trigger.addEventListener( 'click', () => {
|
|
10
10
|
this.toggleSearch();
|
|
11
|
-
});
|
|
11
|
+
} );
|
|
12
12
|
|
|
13
13
|
// TODO: remove these event listeners when search is closed.
|
|
14
14
|
|
|
15
15
|
// Collapse search on ESC.
|
|
16
|
-
document.addEventListener('keydown', (e) => {
|
|
17
|
-
if (27 === e.keyCode) {
|
|
16
|
+
document.addEventListener( 'keydown', ( e ) => {
|
|
17
|
+
if ( 27 === e.keyCode ) {
|
|
18
18
|
this.collapseSearch();
|
|
19
19
|
}
|
|
20
|
-
});
|
|
20
|
+
} );
|
|
21
21
|
|
|
22
22
|
// Collapse search on body click, outside of search el.
|
|
23
|
-
document.body.addEventListener('click', (e) => {
|
|
24
|
-
if (!this.el.contains(e.target)) {
|
|
23
|
+
document.body.addEventListener( 'click', ( e ) => {
|
|
24
|
+
if ( ! this.el.contains( e.target ) ) {
|
|
25
25
|
this.collapseSearch();
|
|
26
26
|
}
|
|
27
|
-
});
|
|
27
|
+
} );
|
|
28
28
|
|
|
29
29
|
// Collapse search when focus leaves search el.
|
|
30
|
-
document.addEventListener('focusin', () => {
|
|
30
|
+
document.addEventListener( 'focusin', () => {
|
|
31
31
|
// eslint-disable-next-line @wordpress/no-global-active-element
|
|
32
|
-
if (!this.el.contains(document.activeElement) && this.isOpen) {
|
|
32
|
+
if ( ! this.el.contains( document.activeElement ) && this.isOpen ) {
|
|
33
33
|
this.collapseSearch();
|
|
34
34
|
}
|
|
35
|
-
});
|
|
35
|
+
} );
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
updateState() {
|
|
@@ -40,22 +40,22 @@ export default class ExpandableSearch {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
toggleSearch() {
|
|
43
|
-
this.target.toggleAttribute('hidden');
|
|
44
|
-
this.target.classList.toggle('js-fade-is-out');
|
|
45
|
-
this.target.classList.toggle('js-fade-is-in');
|
|
46
|
-
this.trigger.classList.toggle('is-ExpandableSearch-open');
|
|
43
|
+
this.target.toggleAttribute( 'hidden' );
|
|
44
|
+
this.target.classList.toggle( 'js-fade-is-out' );
|
|
45
|
+
this.target.classList.toggle( 'js-fade-is-in' );
|
|
46
|
+
this.trigger.classList.toggle( 'is-ExpandableSearch-open' );
|
|
47
47
|
|
|
48
48
|
this.updateState();
|
|
49
49
|
|
|
50
50
|
// Switch focus to input if it is opened
|
|
51
|
-
if (this.isOpen) {
|
|
51
|
+
if ( this.isOpen ) {
|
|
52
52
|
this.targetInput.focus();
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// Switch focus back to trigger when search is closed.
|
|
57
57
|
collapseSearch() {
|
|
58
|
-
if (this.isOpen) {
|
|
58
|
+
if ( this.isOpen ) {
|
|
59
59
|
this.toggleSearch();
|
|
60
60
|
this.trigger.focus();
|
|
61
61
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import ExpandableSearch from './ExpandableSearch.js';
|
|
2
2
|
|
|
3
3
|
export default function initExpandableSearch() {
|
|
4
|
-
const searches = [...document.querySelectorAll('.js-ExpandableSearch')];
|
|
4
|
+
const searches = [ ...document.querySelectorAll( '.js-ExpandableSearch' ) ];
|
|
5
5
|
|
|
6
|
-
searches.forEach((el) => {
|
|
7
|
-
return new ExpandableSearch(el);
|
|
8
|
-
});
|
|
6
|
+
searches.forEach( ( el ) => {
|
|
7
|
+
return new ExpandableSearch( el );
|
|
8
|
+
} );
|
|
9
9
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import Flickity from '@npm/flickity';
|
|
2
2
|
|
|
3
3
|
export default function initFlickity() {
|
|
4
|
-
const carousels = [ ...
|
|
4
|
+
const carousels = [ ...document.querySelectorAll( '.js-Flickity' ) ];
|
|
5
5
|
|
|
6
6
|
carousels.forEach( ( el ) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const isContained = el.classList.contains( 'js-Flickity--isContained' );
|
|
8
|
+
const isFreeScroll = el.classList.contains(
|
|
9
|
+
'js-Flickity--isFreeScroll'
|
|
10
|
+
);
|
|
11
|
+
const isWrapAround = el.classList.contains(
|
|
12
|
+
'js-Flickity--isWrapAround'
|
|
13
|
+
);
|
|
14
|
+
const hasPageDots = el.classList.contains( 'js-Flickity--pageDots' );
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
const slider = new Flickity( el, {
|
|
13
17
|
cellSelector: '.js-Flickity-cell',
|
|
14
18
|
pageDots: hasPageDots,
|
|
15
19
|
imagesLoaded: true,
|
|
@@ -19,13 +23,14 @@ export default function initFlickity() {
|
|
|
19
23
|
freeScroll: isFreeScroll,
|
|
20
24
|
arrowShape: {
|
|
21
25
|
x0: 10,
|
|
22
|
-
x1: 60,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
x1: 60,
|
|
27
|
+
y1: 50,
|
|
28
|
+
x2: 65,
|
|
29
|
+
y2: 45,
|
|
30
|
+
x3: 20,
|
|
31
|
+
},
|
|
26
32
|
} );
|
|
27
33
|
|
|
28
34
|
return slider;
|
|
29
35
|
} );
|
|
30
|
-
|
|
31
36
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
1
|
export default class MegaMenu {
|
|
3
2
|
constructor( el ) {
|
|
4
3
|
this.el = el;
|
|
5
|
-
this.inputs = [ ...
|
|
4
|
+
this.inputs = [ ...this.el.querySelectorAll( 'input' ) ];
|
|
6
5
|
this.container = document.documentElement;
|
|
7
6
|
|
|
8
|
-
this.inputs.forEach( input => {
|
|
7
|
+
this.inputs.forEach( ( input ) => {
|
|
9
8
|
input.addEventListener( 'focus', () => this.handleFocus( input ) );
|
|
10
9
|
} );
|
|
11
10
|
|
|
@@ -24,7 +23,6 @@ export default class MegaMenu {
|
|
|
24
23
|
* @return {void}
|
|
25
24
|
*/
|
|
26
25
|
trapFocus( modal ) {
|
|
27
|
-
|
|
28
26
|
/**
|
|
29
27
|
* .js-MegaMenu class has been added twice in the template, we may remove this check after removing
|
|
30
28
|
* this other class from div.mega-menu__main from all themes.
|
|
@@ -33,11 +31,14 @@ export default class MegaMenu {
|
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
const focusableElements =
|
|
34
|
+
const focusableElements =
|
|
35
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
37
36
|
|
|
38
|
-
const firstFocusableElement =
|
|
37
|
+
const firstFocusableElement =
|
|
38
|
+
modal.querySelectorAll( focusableElements )[ 0 ];
|
|
39
39
|
const focusableContent = modal.querySelectorAll( focusableElements );
|
|
40
|
-
const lastFocusableElement =
|
|
40
|
+
const lastFocusableElement =
|
|
41
|
+
focusableContent[ focusableContent.length - 1 ];
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Handle keydown event.
|
|
@@ -47,24 +48,32 @@ export default class MegaMenu {
|
|
|
47
48
|
* @return {void}
|
|
48
49
|
*/
|
|
49
50
|
const handleKeyDown = ( event ) => {
|
|
50
|
-
|
|
51
|
+
const isTabPressed = event.key === 'Tab' || event.keyCode === 9;
|
|
51
52
|
|
|
52
53
|
if ( ! isTabPressed ) {
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
if ( event.shiftKey ) {
|
|
57
|
-
|
|
57
|
+
if ( event.shiftKey ) {
|
|
58
|
+
// shift + tab combination
|
|
59
|
+
if (
|
|
60
|
+
document.activeElement === firstFocusableElement &&
|
|
61
|
+
lastFocusableElement
|
|
62
|
+
) {
|
|
58
63
|
lastFocusableElement.focus();
|
|
59
64
|
event.preventDefault();
|
|
60
65
|
}
|
|
61
|
-
} else {
|
|
62
|
-
|
|
66
|
+
} else {
|
|
67
|
+
// tab key
|
|
68
|
+
if (
|
|
69
|
+
document.activeElement === lastFocusableElement &&
|
|
70
|
+
firstFocusableElement
|
|
71
|
+
) {
|
|
63
72
|
firstFocusableElement.focus();
|
|
64
73
|
event.preventDefault();
|
|
65
74
|
}
|
|
66
75
|
}
|
|
67
|
-
}
|
|
76
|
+
};
|
|
68
77
|
|
|
69
78
|
document.addEventListener( 'keydown', handleKeyDown );
|
|
70
79
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import MegaMenu from './MegaMenu.js';
|
|
2
2
|
|
|
3
3
|
export default function initMegaMenu() {
|
|
4
|
-
const megaMenus = [ ...
|
|
5
|
-
const triggers = [ ...
|
|
4
|
+
const megaMenus = [ ...document.querySelectorAll( '.js-MegaMenu' ) ];
|
|
5
|
+
const triggers = [ ...document.querySelectorAll( '.js-MegaMenu-Trigger' ) ];
|
|
6
6
|
|
|
7
7
|
let lastFocusedElement;
|
|
8
8
|
|
|
9
|
-
megaMenus.forEach( el => el.pmcMegaMenu = new MegaMenu( el ) );
|
|
9
|
+
megaMenus.forEach( ( el ) => ( el.pmcMegaMenu = new MegaMenu( el ) ) );
|
|
10
10
|
|
|
11
|
-
triggers.forEach( trigger => {
|
|
11
|
+
triggers.forEach( ( trigger ) => {
|
|
12
12
|
trigger.addEventListener( 'click', openOrCloseMegaMenu );
|
|
13
13
|
} );
|
|
14
14
|
|
|
@@ -19,21 +19,23 @@ export default function initMegaMenu() {
|
|
|
19
19
|
} );
|
|
20
20
|
|
|
21
21
|
function openOrCloseMegaMenu() {
|
|
22
|
-
|
|
22
|
+
const isMegaOpen =
|
|
23
|
+
document.documentElement.classList.contains( 'is-mega-open' );
|
|
23
24
|
|
|
24
25
|
// This is a very brittle focus switching solution.
|
|
25
26
|
// @TODO: Move this into the MegaMenu class.
|
|
26
27
|
const menu = document.querySelector( '.js-MegaMenu' );
|
|
27
28
|
const focusableElementsString = 'input, [tabindex="0"]';
|
|
28
|
-
const focusableElements = [
|
|
29
|
+
const focusableElements = [
|
|
30
|
+
...menu.querySelectorAll( focusableElementsString ),
|
|
31
|
+
];
|
|
29
32
|
|
|
30
33
|
if ( ! isMegaOpen ) {
|
|
31
34
|
document.documentElement.classList.add( 'is-mega-open' );
|
|
32
35
|
|
|
33
|
-
if ( focusableElements[0] !== document.activeElement ) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
focusableElements[0].focus();
|
|
36
|
+
if ( focusableElements[ 0 ] !== document.activeElement ) {
|
|
37
|
+
setTimeout( function () {
|
|
38
|
+
focusableElements[ 0 ].focus();
|
|
37
39
|
}, 100 );
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -40,11 +40,13 @@ export default class MobileHeightToggle {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
onClick( e ) {
|
|
43
|
-
|
|
44
43
|
if ( undefined !== this.el.pmcMobileHeightToggle ) {
|
|
45
|
-
|
|
46
44
|
// Bubble event
|
|
47
|
-
if (
|
|
45
|
+
if (
|
|
46
|
+
e.target.classList.contains(
|
|
47
|
+
'lrv-js-MobileHeightToggle-trigger'
|
|
48
|
+
)
|
|
49
|
+
) {
|
|
48
50
|
this.toggle( e );
|
|
49
51
|
}
|
|
50
52
|
}
|
|
@@ -60,5 +62,4 @@ export default class MobileHeightToggle {
|
|
|
60
62
|
this.isExpanded = false;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
|
|
64
65
|
}
|