PageSourceSearch

https://www.mango-office.ru/local/modules/mango.pages/static_files…all-buttons-click-handler.js?17906266291778

js mango-office.ru collected 2026-10-01 12:08:55 UTC 1,778 bytes, 69 lines download raw bytes

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.