1(function () { 2 class BreakdanceLinkAction { 3 constructor(link) { 4 this.link = link; 5 this.action = JSON.parse(this.link.dataset.action); 6 7 if (!this.action) return; 8 9 this.actionType = this.action.type; 10 this.init(); 11 } 12 13 initSliderLink() { 14 this.slideClickHandler = this.slideClick.bind(this); 15 16 if (!this.action.sliderOptions) return; 17 18 const sliderId = this.action.sliderOptions.elementId; 19 if (!sliderId) return; 20 const slider = document.querySelector("." + sliderId); 21 if (!slider) return; 22 this.swiperInstanceId = sliderId; 23 this.link.addEventListener("click", this.slideClickHandler); 24 } 25 26 destroySliderLink() { 27 this.link.removeEventListener("click", this.slideClickHandler); 28 } 29 30 slideClick(event) { 31 event.preventDefault(); 32 const index = this.action.sliderOptions.slideIndex 33 ? parseInt(this.action.sliderOptions.slideIndex) - 1 34 : 0; 35 36 if ( 37 this.swiperInstanceId && 38 window.swiperInstances && 39 window.swiperInstances[this.swiperInstanceId] 40 ) { 41 const slider = window.swiperInstances[this.swiperInstanceId]; 42 const type = this.action.sliderOptions.actionType; 43 44 if (type === "goto") { 45 if (slider.loopedSlides) { 46 slider.slideToLoop(index); 47 } else { 48 slider.slideTo(index); 49 } 50 } else if (type === "next") { 51 slider.slideNext(); 52 } else if (type === "previous") { 53 slider.slidePrev(); 54 } 55 } 56 } 57 58 destroy() { 59 if (this.actionType === "slider") { 60 this.destroySliderLink(); 61 } 62 if (this.action === "popup") { 63 this.destroyPopupLink(); 64 } 65 } 66 67 init() { 68 if (this.actionType === "slider") { 69 this.initSliderLink(); 70 } 71 if (this.actionType === "popup") { 72 this.initPopupLink(); 73 } 74 } 75 76 static autoload(parent = null) { 77 const element = parent ?? document; 78 // Autoload link actions from macros 79 const selector = ".breakdance-link[data-type='action'], .oxygen-link[data-type='action']"; 80 const links = element.querySelectorAll(selector); 81 82 links.forEach((link) => { 83 new this(link); 84 }); 85 } 86 87 initPopupLink() { 88 this.link.addEventListener("click", this.popupClick.bind(this)); 89 } 90 91 destroyPopupLink() { 92 this.link.removeEventListener("click", this.popupClick); 93 } 94 95 popupClick(event) { 96 event.preventDefault(); 97 if (!this.action.popupOptions || !this.action.popupOptions.popupId) { 98 return; 99 } 100 101 const popupId = parseInt(this.action.popupOptions.popupId); 102 const popupAction = this.action.popupOptions.popupAction; 103 BreakdancePopup.runAction(popupId, popupAction); 104 } 105 } 106 107 document.addEventListener("DOMContentLoaded", () => 108 BreakdanceLinkAction.autoload() 109 ); 110 window.BreakdanceLinkAction = BreakdanceLinkAction; 111})();
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.