1/** 2 * ÐлаÑÑ Ð²ÐµÑÐ°ÐµÑ Ð½Ð° вÑе кнопки нового конÑÑÑÑкÑоÑа Ñ ÐºÐ»Ð°ÑÑами .button и .btn 3 * ÑобÑÑие клика Ð´Ð»Ñ Ð¾ÑпÑавки в Ð¯Ð½Ð´ÐµÐºÑ ÐеÑÑÐ¸ÐºÑ 4 * */ 5class AllButtonsClickHandler { 6 _WRAPPER_CLASS = '.js-constructor-page' 7 _BUTTON_CLASS = '.button' 8 _BTN_CLASS = '.btn' 9 _buttons = [] 10 11 constructor() { 12 if (typeof window.mgoTriggerEvent === 'function') { 13 this.run() 14 } 15 } 16 17 run() { 18 this.wrapper = this.getWrapper() 19 if (!this.wrapper) { 20 console.error('Can\'t find ' + this._WRAPPER_CLASS + ' class') 21 return 22 } 23 24 this.getButtons() 25 if (this._buttons.length < 1) { 26 return 27 } 28 29 this.addEvents() 30 } 31 32 getWrapper() { 33 return document.querySelector(this._WRAPPER_CLASS) 34 } 35 36 getButtons() { 37 let buttons = this.wrapper.querySelectorAll(this._BUTTON_CLASS) 38 if (buttons && buttons.length > 0) { 39 buttons.forEach(button => { 40 this.addButtonToArray(button) 41 }); 42 } 43 44 let btns = this.wrapper.querySelectorAll(this._BTN_CLASS) 45 if (btns && btns.length > 0) { 46 btns.forEach(button => { 47 this.addButtonToArray(button) 48 }); 49 } 50 } 51 52 addButtonToArray(button) { 53 if (this._buttons.indexOf(button) === -1) { 54 this._buttons.push(button) 55 } 56 } 57 58 addEvents() { 59 this._buttons.forEach(button => { 60 button.addEventListener('click', () => { 61 mgoTriggerEvent('allButtons') 62 }) 63 }) 64 } 65} 66 67window.addEventListener('DOMContentLoaded', () => { 68 new AllButtonsClickHandler() 69})
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.