1(function () { 2 const { mergeObjects } = BreakdanceFrontend.utils; 3 4 class BreakdanceDualHeading { 5 options = { 6 primary: { 7 brackets: { bottom: true }, 8 color: "#DA2E2E", 9 duration: 3000, 10 iterations: 4, 11 multiline: true, 12 stroke_width: 4, 13 rtl: false, 14 type: "underline", 15 }, 16 secondary: { 17 brackets: { bottom: true }, 18 duration: 3000, 19 iterations: 4, 20 color: "#EFB500", 21 multiline: true, 22 stroke_width: 4, 23 rtl: false, 24 type: "highlight", 25 }, 26 }; 27 28 constructor(selector, options) { 29 this.selector = selector; 30 this.element = document.querySelector(`${this.selector}`); 31 this.options = mergeObjects(this.options, options); 32 this.init(); 33 } 34 35 initObserver() { 36 if (!this.element) return; 37 38 this.ob = new IntersectionObserver( 39 (entries, observer) => { 40 if (!entries) return; 41 entries.forEach((entry) => { 42 if (entry.isIntersecting) { 43 this.initRoughNotation(); 44 observer.unobserve(this.element); 45 } 46 }); 47 }, 48 { 49 root: null, 50 rootMargin: "0px", 51 threshold: 0.5, 52 } 53 ); 54 this.ob.observe(this.element); 55 } 56 57 // Init RoughNotation.js 58 initRoughNotation() { 59 const annotate = RoughNotation.annotate; 60 61 this.notationElements = document.querySelectorAll( 62 `${this.selector} .js-annotate` 63 ); 64 65 if (!this.notationElements) return; 66 67 this.notationElements.forEach((item) => { 68 const style = item.dataset.style; 69 const brackets = this.options[style].brackets; 70 71 item.notation = annotate(item, { 72 brackets: Object.keys(brackets).filter((k) => brackets[k]), 73 type: this.options[style].type, 74 color: this.options[style].color, 75 animate: 1, 76 animationDuration: this.options[style].duration, 77 strokeWidth: this.options[style].stroke_width, 78 multiline: this.options[style].multiline, 79 iterations: this.options[style].iterations, 80 rtl: this.options[style].rtl, 81 }); 82 83 item.notation.show(); 84 }); 85 } 86 87 // Update plugin 88 destroyRoughNotation() { 89 if (!this.notationElements) return; 90 91 this.notationElements.forEach((item) => { 92 item.notation.remove(); 93 }); 94 this.notationElements = null; 95 } 96 97 // Update plugin 98 update(options = {}) { 99 this.options = mergeObjects(this.defaultOptions, options); 100 this.destroy(); 101 this.init(); 102 } 103 104 // Destory plugin 105 destroy() { 106 this.destroyRoughNotation(); 107 this.ob.unobserve(this.element); 108 } 109 110 // Init plugin 111 init() { 112 this.initObserver(); 113 } 114 } 115 window.BreakdanceDualHeading = BreakdanceDualHeading; 116})();
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.