1(function () { 2 class BreakdanceSearchForm { 3 constructor(selector) { 4 this.selector = selector; 5 this.element = this.queryElement(`${this.selector} .js-search-form`); 6 this.type = this.element.dataset.type; 7 this.expandButton = this.queryElement( 8 `${this.selector} .js-search-form-expand-button` 9 ); 10 this.closeButton = this.queryElement( 11 `${this.selector} .js-search-form-close` 12 ); 13 this.searchField = this.queryElement( 14 `${this.selector} .js-search-form-field` 15 ); 16 this.lightboxBg = this.queryElement( 17 `${this.selector} .js-search-form-lightbox-bg` 18 ); 19 20 this.init(); 21 } 22 23 queryElement(element) { 24 if (typeof element == "string") { 25 return document.querySelector(element); 26 } 27 return element; 28 } 29 30 toggleForm() { 31 this.element.classList.toggle("is-active"); 32 this.element.setAttribute("aria-hidden", "false"); 33 this.expandButton.setAttribute("aria-expanded", "true"); 34 35 this.searchField.focus(); 36 } 37 38 closeFormEscape(event) { 39 if (event.key === "Escape") { 40 this.closeForm(); 41 } 42 } 43 44 closeForm() { 45 this.element.classList.remove("is-active"); 46 this.element.setAttribute("aria-hidden", "true"); 47 this.expandButton.setAttribute("aria-expanded", "false"); 48 this.searchField.blur(); 49 } 50 51 // Methods 52 destroy() { 53 if (this.type == "expand") { 54 this.expandButton.removeEventListener("click", this.handleToggleForm); 55 } 56 57 if (this.type == "full-screen") { 58 this.expandButton.removeEventListener("click", this.handleToggleForm); 59 this.closeButton.removeEventListener("click", this.handleCloseForm); 60 this.lightboxBg.removeEventListener("click", this.handleCloseForm); 61 this.element.removeEventListener("keyup", this.handleCloseFromEscape); 62 } 63 } 64 65 update() { 66 this.destroy(); 67 this.init(); 68 } 69 70 bindListeners() { 71 this.handleToggleForm = this.toggleForm.bind(this); 72 this.handleCloseForm = this.closeForm.bind(this); 73 this.handleCloseFromEscape = this.closeFormEscape.bind(this); 74 75 if (this.type == "expand") { 76 this.expandButton.addEventListener("click", this.handleToggleForm); 77 } 78 79 if (this.type == "full-screen") { 80 this.expandButton.addEventListener("click", this.handleToggleForm); 81 this.closeButton.addEventListener("click", this.handleCloseForm); 82 this.lightboxBg.addEventListener("click", this.handleCloseForm); 83 this.element.addEventListener("keyup", this.handleCloseFromEscape); 84 } 85 } 86 87 init() { 88 this.bindListeners(); 89 } 90 } 91 92 window.BreakdanceSearchForm = BreakdanceSearchForm; 93})();
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.