PageSourceSearch

https://znanium.ru/assets/178d915e/widesearch.js?v=1788532008

js znanium.ru collected 2026-10-02 17:13:37 UTC 53,171 bytes, 1,219 lines download raw bytes

1var __extends = (this && this.__extends) || (function () {
2    var extendStatics = function (d, b) {
3        extendStatics = Object.setPrototypeOf ||
4            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b }) ||
5            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p] }
6        return extendStatics(d, b)
7    }
8    return function (d, b) {
9        extendStatics(d, b)
10        function __() { this.constructor = d }
11        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __())
12    }
13})()
14var ws;
15(function (ws) {
16    var Ltr;
17    (function (Ltr) {
18        Ltr["EXPANDED"] = "expanded"
19        Ltr["COLLAPSED"] = "collapsed"
20        Ltr["ALARM"] = "alarm"
21        Ltr[Ltr["MODE_STARTUP"] = 1] = "MODE_STARTUP"
22        Ltr[Ltr["MODE_SHORT"] = 2] = "MODE_SHORT"
23        Ltr[Ltr["MODE_EXPANDED"] = 3] = "MODE_EXPANDED"
24        Ltr[Ltr["MODE_POPULUS"] = 4] = "MODE_POPULUS"
25        Ltr[Ltr["MODE_FILTER"] = -1] = "MODE_FILTER"
26        Ltr[Ltr["MODE_SHORT_FILTER"] = 5] = "MODE_SHORT_FILTER"
27        Ltr["EVENT_DIRECT_CLICK"] = "direct:click"
28    })(Ltr = ws.Ltr || (ws.Ltr = {}))
29
30    ws.UN_HREF_FIELDS = ['direction', 'nostore_insubscribe']
31    var TWideSearch = (function () {
32        function TWideSearch(options) {
33            this.changeInsubscribe = false
34            this.clusterClick = false
35            Objects.setDefinition(options, 'ajaxInsubscribe', false)
36            $.extend(this, options)
37        }
38        TWideSearch.prototype.formSubmit = function () { }
39        TWideSearch.prototype.init = function () {
40            var _this = this
41            var _that = this
42            this.model.contextPath = location.pathname
43            if (!this.expandDuration) {
44                this.expandDuration = 100
45            }
46            this._element.eventListener(this._directClick)
47            this._directClick = this._element.eventListener(Ltr.EVENT_DIRECT_CLICK, function (ev) {
48                _that.clusterClick = true
49                _that.collapseDirectionHandler = ev.detail
50                _that.canCollapseDirections(ev.detail)
51            })
52            this.form.eventListener(this._formKeydown)
53            this._formKeydown = this.form.eventListener('keydown', function (ev) {
54                ev.stopPropagation()
55                if (ev.key == 'Enter') {
56                    _that.submitButton.stfire('click', EventClasses.EVENT_Mouse)
57                }
58            })
59            try {
60                this.expandButton.eventListener(this._expandClick)
61                this._expandClick = this.expandButton.eventListener('click', function (ev) {
62                    ev.preventDefault()
63                    var _wideZone = _that.wideZone
64                    if (!_wideZone && _that.mode == Ltr.MODE_FILTER) {
65                        _that.loadExtendForm()
66                        return
67                    }
68                    if ([Ltr.MODE_EXPANDED, Ltr.MODE_FILTER].includes(_that.mode)) {
69                        if (_that.wideZone.classList.contains(Ltr.EXPANDED)) {
70                            _that.collapse()
71                        }
72                        else if (_that.wideZone.classList.contains(Ltr.COLLAPSED)) {
73                            _that.expand()
74                        }
75                    }
76                })
77            }
78            catch (err) {
79            }
80            document.eventListener(this._documentClick)
81            this._documentClick = document.eventListener('click', function (ev) {
82                if (ev.target.classList.contains('reset')) {
83                    ev.preventDefault()
84                    ev.stopPropagation()
85                    if (ev.target.classList.contains('reset--quick')) {
86                        _that.resetConditions()
87                    } else {
88                        _that.resetForm()
89                    }
90                }
91                if (ev.target.classList.contains('clean-input')) {
92                    ev.preventDefault()
93                    ev.stopPropagation()
94                    _that.shortInput.setCurPosition(0).value = ''
95                }
96                if (ev.target.classList.contains('submit')) {
97                    ev.preventDefault()
98                    ev.stopPropagation()
99                    var _url = new URL(location.href)
100                    var btnDirect = Number(ev.target.dataset['dir'])
101                    var direction = _that.dirRules[btnDirect]
102                    direction.id = btnDirect
103                    if (btnDirect == -1) {
104                        return
105                    }
106                    if (_that.model.direction == btnDirect
107                        && ev.target.classList.contains('direction')) {
108                    }
109                    try {
110                        if (!direction.method) {
111                            direction.method = 'post'
112                        }
113                        _that.form.method = direction.method
114                        if (direction.method == 'post') {
115                            Html.createElementEx('input', _that.form, {
116                                type: 'hidden',
117                                name: yii.getCsrfParam(),
118                                value: yii.getCsrfToken()
119                            })
120                        }
121                        _that.form.fields.findByName('direction').value = ev.target.dataset['dir']
122                        if (btnDirect != _that.model.direction) {
123                            _that.model.mode = direction.mode
124                        }
125                    }
126                    catch (err) {
127                        console.error(err)
128                    }
129                    try {
130                        if (direction.rename) {
131                            for (var p in direction.rename) {
132                                var field = _that.form.fields.findByName(p)
133                                if (field) {
134                                    field.fieldElement.name = direction.rename[p]
135                                }
136                            }
137                        }
138                    }
139                    catch (err) {
140                        console.error(err)
141                    }
142                    if (_that.model.localSearch && !ev.target.classList.contains('direction')) {
143                    }
144                    else {
145                        if (direction.hasOwnProperty('redirect') && direction.redirect) {
146                            if (ev.target.classList.contains('direction')) {
147                                _that.form.action = direction.redirect[0]
148                                try {
149                                    _that.conditions.resetConditions(['insubscribe'])
150                                }
151                                catch (err) {
152                                }
153                            }
154                            else {
155                                if (_that.model.mode == Ltr.MODE_FILTER) {
156                                    _that.form.action = window.location.pathname
157                                }
158                                else {
159                                    _that.form.action = _that.getRedirect(direction)
160                                }
161                            }
162                        }
163                    }
164                    if (direction.hasOwnProperty('target') && direction.target
165                        && (ev.target.dataset.dir != _that.model.direction.toString())) {
166                        _that.form.target = direction.target
167                    }
168                    if (ev.target.classList.contains('direction')) {
169                        _that._element.fire(Ltr.EVENT_DIRECT_CLICK, ev.target)
170                    }
171                    _that.beforeSubmit(btnDirect)
172                    _that.form.submit()
173                }
174                if (ev.target.classList.contains('hidden-expand')) {
175                    [].map.call(_that.directionsPanel.querySelectorAll('.hidden-direct'), function (_el) {
176                        _el.classList.remove('hidden-direct')
177                    })
178                    ev.target.hidden = true
179                    ev.target.previousElementSibling.hidden = true
180                    _that._element.fire(Ltr.EVENT_DIRECT_CLICK, ev.target)
181                }
182                if (ev.target.classList.contains('special-search-fields')) {
183                    var spf_1 = ev.target.closest('.special-search-fields')
184                        .parentElement.children[1]
185                    setTimeout(function () {
186                        cookie.write('special-search-fields', spf_1.style.display)
187                    }, 100)
188                }
189            })
190            this.shortInput.eventListener('focus', function (ev) {
191                _that.expandDirections()
192            })
193            this.shortInput.eventListener('blur', function (ev) {
194                setTimeout(function () {
195                    _that.canCollapseDirections(ev.target)
196                }, 300)
197            })
198            $('.special-search-fields').on('filter:expand', function () {
199                var args = []
200                for (var _i = 0; _i < arguments.length; _i++) {
201                    args[_i] = arguments[_i]
202                }
203                try {
204                    cookie.write('special-search-fields', args[1]['block'].style.display)
205                }
206                catch (err) {
207                }
208            })
209            if ([Ltr.MODE_EXPANDED, Ltr.MODE_FILTER].includes(this.mode)) {
210                this.conditions = new ws.TConditionsPanel({
211                    owner: this,
212                    element: '[data-anc="conditions-panel"]'
213                })
214                window.setTimeout(function () {
215                    _this.conditions.fillConditions()
216                }, 200)
217            }
218            this._windowResize = window.eventListener('resize', function (ev) {
219                _that.resizeInput()
220            })
221            _that.resizeInput()
222            _that.hlwords()
223            $('select.perpagesel').addClass('ws')
224            this.form.stfire('change', 'Event')
225        }
226        TWideSearch.prototype.beforeSubmit = function (direction) {
227            this.shortInput.value = this.shortInput.value.replace(/(<([^>]+)>)/gi, "")
228            for (var f = 0; f < this.form.fields.length; f++) {
229                var field = this.form.fields.item(f)
230                if ('insubscribe' == field.origName && this.changeInsubscribe) {
231                    continue
232                }
233                if ('submitted' == field.origName) {
234                    if (this.clusterClick && direction == 1 && this.form.fields.findByName('title').isEmpty()) {
235                        field.fieldElement.disabled = true
236                    }
237                    continue
238                }
239                if ('_zrd' == field.origName && Number(field.value) < 1) {
240                    field.fieldElement.disabled = true
241                }
242                var isEmpty = false
243                try {
244                    isEmpty = field.isEmpty() || this.conditions.findCondition(field.origName).isEmpty
245                }
246                catch (err) {
247                }
248                if (isEmpty || ws.UN_HREF_FIELDS.includes(field.origName)) {
249                    field.fieldElement.disabled = true
250                }
251            }
252            var _url = new URL(location.href)
253            if (_url.searchParams.has('letter')) {
254                Html.createElementEx('input', this.form, { type: 'hidden', name: 'letter', value: _url.searchParams.get('letter') })
255            }
256            if (_url.searchParams.has('page')) {
257                Html.createElementEx('input', this.form, { type: 'hidden', name: 'page', value: _url.searchParams.get('page') })
258            }
259            this.clusterClick = false
260        }
261        TWideSearch.prototype.getRedirect = function (direction) {
262            var _url = new URL(location.href)
263
264            if (isArray(direction.redirect) && direction.redirect.length > 1 && _url.pathname.indexOf('catalog/wide-search') < 0) {
265                if (location.href.search('catalog/books|catalog/articles') >= 0) {
266                    var redirectMatches = _url.pathname.match(/\/catalog\/.*\/(.*)/)
267                    var currentMatches = _url.pathname.match(/(\/catalog\/.*\/).*/)
268
269                    if (location.href.indexOf('catalog/articles') > -1) {
270                        return direction.redirect[1]
271                    }
272
273                    return direction.redirect[0]
274
275                    // if (redirectMatches[1] === 'theme') {
276                    //     return direction.redirect[0];
277                    // }
278
279                    // return currentMatches[1] + redirectMatches[1];
280                }
281                return direction.redirect[0]
282            }
283            else if (isArray(direction.redirect)) {
284                return direction.redirect[0]
285            }
286            else {
287                return '/catalog/wide-search'
288            }
289        }
290        TWideSearch.prototype.getAction = function (path) {
291            var _url = new URL(location.href)
292            if (path) {
293                _url.pathname = path
294            }
295            _url.search = ''
296            for (var f = 0; f < this.form.fields.length; f++) {
297                var field = this.form.fields.item(f)
298                var isEmpty = false
299                try {
300                    isEmpty = field.isEmpty()
301                }
302                catch (err) {
303                    isEmpty = true
304                }
305                if (!isEmpty && !ws.UN_HREF_FIELDS.includes(field.origName)) {
306                    try {
307                        var _cond = this.conditions.findCondition(field.origName)
308                        if (_cond && _cond.isEmpty) {
309                            continue
310                        }
311                    }
312                    catch (err) {
313                    }
314                    if (isScalar(field.value)) {
315                        _url.searchParams.append(field.origName, field.value)
316                    }
317                    else if (isArray(field.value)) {
318                        for (var i = 0; i < field.value.length; i++) {
319                            _url.searchParams.append(field.origName, field.value[i])
320                        }
321                    }
322                }
323            }
324            return _url.toString()
325        }
326        TWideSearch.prototype.hlwords = function () {
327            if (this.model.direction == 12 && isArray(this.morphyWords)) {
328                var blocks = $('.site-static-content').find('*:not(".wide-search-form *")')
329                var reg = new RegExp('(' + this.morphyWords.reverse().join('|') + ')', 'gi')
330                blocks.each(function () {
331                    if (!this.childElementCount) {
332                        var text = $(this).text()
333                    }
334                })
335            }
336        }
337        TWideSearch.prototype.resizeInput = function () {
338            this.titleElement.style.width = this.shortwrapElement.clientWidth - (((this.subscribeElement
339                instanceof HTMLElement) ? this.subscribeElement.clientWidth : 0)
340                + this.submitElement.clientWidth + ((this.wideElement
341                    instanceof HTMLElement) ? this.wideElement.clientWidth : 0))
342                - 1 + 'px'
343        }
344        TWideSearch.prototype.prepareModelToShort = function () {
345            for (var p in this.attributeLabels) {
346                var fld = p.replace('[]', '')
347                if (typeof this.model[fld] == 'string' || typeof this.model[fld] == 'number') {
348                    if (this.model[fld] != '') {
349                        Html.createElementEx('input', this.form, { type: 'hidden', name: p, value: this.model[fld] })
350                    }
351                }
352                else if (typeof this.model[fld] == 'object') {
353                    if (this.model[fld]) {
354                        for (var a = 0; a < this.model[fld].length; a++) {
355                            Html.createElementEx('input', this.form, { type: 'hidden', name: p, value: this.model[fld] })
356                        }
357                    }
358                }
359            }
360        }
361        TWideSearch.prototype.loadExtendForm = function () {
362            var _that = this
363            var _tmp
364            _that.conditions.element.classList.add('wite')
365            $.post({
366                url: '/widesearch/extend-form',
367                headers: { 'Z-Clean': '1' },
368                data: this.formData,
369                success: function (data, textStatus, jqXHR) {
370                    _that.cleanWideZone()
371                    _that.conditions.clearHiddenFields()
372                    _tmp = Html.createElementEx('div', document.body, { id: 'invisible_wide_zone' }, data.html)
373                    var _tmpZone = _tmp.querySelector('.wide-zone')
374                    _that.form.appendChild(_tmpZone)
375                    var dialogs = _tmp.querySelectorAll('[role="dialog"]')
376                    for (var di = 0; di < dialogs.length; di++) {
377                        try {
378                            _that._element.insertAdjacentElement('afterend', dialogs[di])
379                        }
380                        catch (err) {
381                        }
382                    }
383                    document.body.removeChild(_tmp)
384                    for (var jsObj in data.js) {
385                        for (var id in data.js[jsObj]) {
386                            new Function(data.js[jsObj][id])()
387                        }
388                    }
389                    $('.wide-zone .fstyler').styler()
390                    zcore.modal({ control: '.js-show-modal' })
391                    $('.js-close-modal').click(function (e) {
392                        zcore.modalclose()
393                    })
394                    searchform.initDateTimePicker()
395                    _that.mode = Ltr.MODE_EXPANDED
396                    _that.conditions.container.classList.toggleClass(Ltr.EXPANDED, Ltr.COLLAPSED)
397                    _that.expand()
398                    _that.conditions.element.classList.remove('wite')
399                },
400            })
401        }
402        TWideSearch.prototype.cleanWideZone = function () {
403            var wideZone = this.wideZone
404            if (wideZone instanceof HTMLElement) {
405                wideZone.parentElement.removeChild(wideZone)
406            }
407        }
408        Object.defineProperty(TWideSearch.prototype, "formData", {
409            get: function () {
410                var form = this.form
411                for (var p in this.model) {
412                    try {
413                        var _fld = form.fields.findByName(p) || form.fields.findByName(p + '[]')
414                        if (_fld instanceof HTMLFormField) {
415                            this.model[p] = _fld.value
416                        }
417                        else if (_fld instanceof Array) {
418                            this.model[p] = _fld[0].value
419                        }
420                    }
421                    catch (err) {
422                        console.warn(err)
423                    }
424                }
425                return this.model
426            },
427            enumerable: false,
428            configurable: true
429        })
430        TWideSearch.prototype.canCollapseDirections = function (handler) {
431            var _this = this
432            if (handler instanceof HTMLInputElement) {
433                if (!this.model.submitted && this.mode != 3) {
434                    var isDir = this.collapseDirectionHandler
435                        && this.collapseDirectionHandler.closest('.direction-list')
436                    if (this.shortInput.value == '' && !isDir) {
437                        this.collapseDirections()
438                        this.collapseDirectionHandler = null
439                    }
440                }
441            }
442            if (handler.closest('.direction-list')) {
443                this.expandDirections()
444                setTimeout(function () {
445                    _this.collapseDirectionHandler = null
446                }, 400)
447            }
448        }
449        TWideSearch.prototype.expand = function () {
450            var _that = this
451            $(this.wideZone).slideDown(this.expandDuration, function () {
452                _that.wideZone.classList.toggleClass(Ltr.EXPANDED, Ltr.COLLAPSED)
453                try {
454                    _that.conditions.container.classList.toggleClass(Ltr.EXPANDED, Ltr.COLLAPSED)
455                }
456                catch (err) {
457                }
458            })
459        }
460        TWideSearch.prototype.collapse = function () {
461            var _that = this
462            $(this.wideZone).slideUp(this.expandDuration, function () {
463                _that.wideZone.classList.toggleClass(Ltr.COLLAPSED, Ltr.EXPANDED)
464                try {
465                    _that.conditions.container.classList.toggleClass(Ltr.COLLAPSED, Ltr.EXPANDED)
466                }
467                catch (err) {
468                }
469            })
470        }
471        TWideSearch.prototype.expandDirections = function () {
472            if (this.mode == Ltr.MODE_STARTUP) {
473                return
474            }
475            this.directionsPanel.classList.remove(Ltr.COLLAPSED)
476            this.directionsPanel.classList.add(Ltr.EXPANDED)
477        }
478        TWideSearch.prototype.collapseDirections = function () {
479            if (this.mode == Ltr.MODE_STARTUP) {
480                return
481            }
482            this.directionsPanel.classList.remove(Ltr.EXPANDED)
483            this.directionsPanel.classList.add(Ltr.COLLAPSED)
484        }
485        TWideSearch.prototype.resetConditions = function () {
486            while (this.conditions.hasChanged) {
487                [...this.element.querySelectorAll(".condition .fa.fa-del-cross._rc")].at(-1).click()
488            }
489        }
490        TWideSearch.prototype.resetForm = function () {
491            [].map.call(this.conditions.buffer, function (_el) {
492                if (_el.field.origName == 'insubscribe') {
493                    return false
494                }
495                if (['select-one', 'select-multiple'].includes(_el.field.type)) {
496                    var clearbtn = $(_el.field.fieldElement).parent().parent().find('.js-show-modal')
497                    if (clearbtn.length) {
498                        var _target_1 = clearbtn.data('target')
499                        _el.element.eventListener('onReset', function (ev) {
500                            ztreeselect2.jstree('#' + _target_1).clearTheme(
500)
501                        })
502                    }
503                }
504                _el.reset()
505            })
506            this.form.fields.findByName('title').clear()
507            document.body.scrollIntoView({ behavior: "smooth" })
508        }
509        Object.defineProperty(TWideSearch.prototype, "wideZone", {
510            get: function () {
511                return this._element.querySelector('.wide-zone')
512            },
513            enumerable: false,
514            configurable: true
515        })
516        Object.defineProperty(TWideSearch.prototype, "expandButton", {
517            get: function () {
518                return this._element.querySelector('.wide-expand')
519            },
520            enumerable: false,
521            configurable: true
522        })
523        Object.defineProperty(TWideSearch.prototype, "submitButton", {
524            get: function () {
525                return this._element.querySelector('.submit')
526            },
527            enumerable: false,
528            configurable: true
529        })
530        Object.defineProperty(TWideSearch.prototype, "form", {
531            get: function () {
532                return this._element.querySelector('form')
533            },
534            enumerable: false,
535            configurable: true
536        })
537        Object.defineProperty(TWideSearch.prototype, "element", {
538            get: function () {
539                return this._element
540            },
541            set: function (sel) {
542                this._element = document.querySelector(sel)
543                if (!this._element) {
544                    throw new Error('Нет эелемента ' + sel)
545                }
546            },
547            enumerable: false,
548            configurable: true
549        })
550        Object.defineProperty(TWideSearch.prototype, "directionsPanel", {
551            get: function () {
552                return this._element.querySelector('.direction-list')
553            },
554            enumerable: false,
555            configurable: true
556        })
557        Object.defineProperty(TWideSearch.prototype, "shortInput", {
558            get: function () {
559                return this._element.querySelector('[name="title"]')
560            },
561            enumerable: false,
562            configurable: true
563        })
564        Object.defineProperty(TWideSearch.prototype, "novfrom", {
565            get: function () {
566                return $(this.form.querySelector('#nov-from')).data('DateTimePicker')
567            },
568            enumerable: false,
569            configurable: true
570        })
571        Object.defineProperty(TWideSearch.prototype, "specialFieldsZone", {
572            get: function () {
573                return this._element.querySelector('.special-search-fields')
574            },
575            enumerable: false,
576            configurable: true
577        })
578        Object.defineProperty(TWideSearch.prototype, "subscribeElement", {
579            get: function () {
580                if (!this.elementSubscribe) {
581                    this.elementSubscribe = this._element.querySelector('.insubscribe-wrap')
582                }
583                return this.elementSubscribe
584            },
585            enumerable: false,
586            configurable: true
587        })
588        Object.defineProperty(TWideSearch.prototype, "titleElement", {
589            get: function () {
590                if (!this.elementTitle) {
591                    this.elementTitle = this._element.querySelector('.short-input-wrap')
592                }
593                return this.elementTitle
594            },
595            enumerable: false,
596            configurable: true
597        })
598        Object.defineProperty(TWideSearch.prototype, "submitElement", {
599            get: function () {
600                if (!this.elementSubmit) {
601                    this.elementSubmit = this._element.querySelector('.submit-wrap')
602                }
603                return this.elementSubmit
604            },
605            enumerable: false,
606            configurable: true
607        })
608        Object.defineProperty(TWideSearch.prototype, "wideElement", {
609            get: function () {
610                if (!this.elementWide) {
611                    this.elementWide = this._element.querySelector('.wide-search-wrap')
612                }
613                return this.elementWide
614            },
615            enumerable: false,
616            configurable: true
617        })
618        Object.defineProperty(TWideSearch.prototype, "shortwrapElement", {
619            get: function () {
620                if (!this.elementShortWrap) {
621                    this.elementShortWrap = this._element.querySelector('.inline-wrap')
622                }
623                return this.elementShortWrap
624            },
625            enumerable: false,
626            configurable: true
627        })
628        Object.defineProperty(TWideSearch.prototype, "exactInput", {
629            get: function () {
630                return this.form.querySelector('[name="exact"]')
631            },
632            enumerable: false,
633            configurable: true
634        })
635        Object.defineProperty(TWideSearch.prototype, "ownInput", {
636            get: function () {
637                return this.form.querySelector('[name="own"]')
638            },
639            enumerable: false,
640            configurable: true
641        })
642        Object.defineProperty(TWideSearch.prototype, "insubscribeSelect", {
643            get: function () {
644                return this.form.querySelector('[name="insubscribe"]')
645            },
646            enumerable: false,
647            configurable: true
648        })
649        return TWideSearch
650    }())
651    ws.TWideSearch = TWideSearch
652})(ws || (ws = {}))
653window._cpClickEvent = null
654var ws;
655(function (ws) {
656    var TConditionsPanel = (function () {
657        function TConditionsPanel(options) {
658            $.extend(this, options)
659            this.init()
660        }
661        TConditionsPanel.prototype.init = function () {
662            var _that = this;
663            [].map.call(this.owner.form.fields.list, function (fld) {
664                if (['select-multiple', 'select-one'].includes(fld.type) && fld.origName != 'insubscribe') {
665                    $(fld.fieldElement)
666                        .off('change select2:select select2:clear select2:unselect')
667                        .on('change select2:select select2:clear select2:unselect', function () {
668                            _that.owner.form.stfire('change', 'Event')
669                        })
670                }
671            })
672            $(this.owner.form.querySelector('#nov-from'))
673                .off('dp.change')
674                .on('dp.change', function () {
675                    _that.owner.form.stfire('change', 'Event')
676                })
677            this.owner.form.addEventListener('change', function (ev) {
678                try {
679                    _that.owner.exactInput.disabled = Number(_that.owner.form.fields.findByName('sub')[0].value) != 2
680                    if (_that.owner.exactInput.disabled) {
681                        _that.owner.exactInput.checked = false
682                    }
683                }
684                catch (err) {
685                }
686                try {
687                    if (_that.owner.ownInput.checked) {
688                        _that.owner.form.fields.findByName('publishers[]').fieldElement.disabled = true
689                    }
690                    else {
691                        _that.owner.form.fields.findByName('publishers[]').fieldElement.disabled = false
692                    }
693                }
694                catch (err) {
695                }
696                _that.fillConditions()
697            })
698            this._element.eventListener(window._cpClickEvent)
699            window._cpClickEvent = this._element.eventListener('click', function (ev) {
700                if (ev.target.classList.contains('_rc')) {
701                    ev.stopPropagation()
702                    ev.preventDefault()
703                    var _obj = ev.target.closest('.condition')['_obj']
704                    _obj.reset(ev.target)
705                    _that.fillConditions()
706                }
707            })
708        }
709        TConditionsPanel.prototype.fillConditions = function (callback) {
710            this._buffer = []
711            this._count = 0
712            var form = this.owner.form
713            for (var f in this.owner.attributeLabels) {
714                var fld = form.fields.findByName(f)
715                try {
716                    if (fld.fieldElement.disabled) {
717                        continue
718                    }
719                }
720                catch (err) {
721                }
722                if (!fld) {
723                    fld = this.createHiddenField(f)
724                }
725                if (isArray(fld)) {
726                    fld = fld[0]
727                }
728                var _item = void 0
729                var _class = void 0
730                switch (fld.type) {
731                    case HTMLFormFieldTypes.TYPE_TEXT:
732                        _class = ws.TBaseCondition
733                        break
734                    case HTMLFormFieldTypes.TYPE_CHECKBOX:
735                        _class = ws.TBooleanCondition
736                        break
737                    case HTMLFormFieldTypes.TYPE_RADIO:
738                        _class = ws.TRadioCondition
739                        break
740                    case HTMLFormFieldTypes.TYPE_SELECT_MULTIPLE:
741                        _class = ws.TSelectCondition
742                        break
743                    case HTMLFormFieldTypes.TYPE_SELECT_ONE:
744                        _class = ws.TSelect2OneCondition
745                        break
746                }
747                if (!_class) {
748                    continue
749                }
750                try {
751                    _item = new _class({
752                        label: this.owner.attributeLabels[f],
753                        field: fld
754                    })
755                    if (_item instanceof TBaseCondition) {
756                        _item.draw()
757
758                        this._buffer.push(_item)
759                    }
760
761                }
762                catch (err) {
763                    console.error(err)
764                }
765            }
766            if (this._buffer.length) {
767                var container = this.container
768                this.clearConditions()
769                for (var i = 0; i < this._buffer.length; i++) {
770                    if (!this._buffer[i].isEmpty) {
771                        container.appendChild(this._buffer[i].element)
772                        this._count++
773                    }
774                }
775            }
776            if (this._count) {
777                this.container.classList.remove('conditions-clear')
778                $(this.container.children[0].children[0]).html('<span class="fa fa-cog"></span><span>Изменить условия поиска</span>')
779            }
780            else {
781                this.container.classList.add('conditions-clear')
782                $(this.container.children[0].children[0]).html('<span class="fa fa-cog"></span><span>Добавить условия поиска</span>')
783            }
784
785            this.owner._element.classList.toggle("is-changed", this.hasChanged)
786
787            if (callback) {
788                callback()
789            }
790        }
791        TConditionsPanel.prototype.clearHiddenFields = function () {
792            this.hiddenContainer.removeChildren()
793        }
794        TConditionsPanel.prototype.createHiddenField = function (fldName) {
795            var _f = this.owner.attributeLabels[fldName]
796            if (_f) {
797                switch (_f.type) {
798                    case HTMLFormFieldTypes.TYPE_TEXT:
799                    case HTMLFormFieldTypes.TYPE_HIDDEN:
800                        Html.createElementEx('input', this.hiddenContainer, {
801                            type: _f.type,
802                            name: fldName,
803                            value: _f.value == undefined ? '' : _f.value
804                        })
805                        break
806                    case HTMLFormFieldTypes.TYPE_SELECT_MULTIPLE:
807                        var select = Html.createElementEx('select', this.hiddenContainer, {
808                            name: fldName,
809                            multiple: true,
810                            class: 'select2'
811                        })
812                        if (_f.value.constructor.name == 'Object') {
813                            for (var p in _f.value) {
814                                var option = Html.createElementEx('option', select, {
815                                    value: p,
816                                }, _f.value[p])
817                                option.selected = true
818                            }
819                        }
820                        break
821                    case HTMLFormFieldTypes.TYPE_SELECT_ONE:
822                        var selectOne = Html.createElementEx('select', this.hiddenContainer, {
823                            name: fldName,
824                        })
825                        try {
826                            if (_f.value.constructor.name == 'Object') {
827                                for (var p in _f.value) {
828                                    var option = Html.createElementEx('option', selectOne, {
829                                        value: p,
830                                    }, _f.value[p])
831                                    option.selected = true
832                                }
833                            }
834                        }
835                        catch (err) {
836                        }
837                        try {
838                            if (_f.css) {
839                                selectOne.classList.addMany(_f.css)
840                            }
841                        }
842                        catch (err) {
843                        }
844                        break
845                    case HTMLFormFieldTypes.TYPE_RADIO:
846                        for (var p in _f.value) {
847                            var _el_1 = Html.createElementEx('input', this.hiddenContainer, {
848                                type: HTMLFormFieldTypes.TYPE_RADIO,
849                                name: fldName,
850                                value: p,
851                            })
852                            _el_1.checked = true
853                            _el_1.id = 'radio_' + fldName + '_' + p
854                            var _label = Html.createElementEx('label', this.hiddenContainer, {
855                                for: _el_1.id
856                            }, _f.value[p])
857                        }
858                        break
859                    case HTMLFormFieldTypes.TYPE_CHECKBOX:
860                        var _el = Html.createElementEx('input', this.hiddenContainer, {
861                            type: HTMLFormFieldTypes.TYPE_CHECKBOX,
862                            name: fldName,
863                            value: 1,
864                        })
865                        _el.checked = 1 == _f.value
866                        break
867                }
868                return this.owner.form.fields.findByName(fldName)
869            }
870        }
871        TConditionsPanel.prototype.clearConditions = function () {
872            $(this.container).find('.condition').remove()
873        }
874        TConditionsPanel.prototype.resetConditions = function (exclude) {
875            var _that = this;
876            [].map.call(_that._buffer, function (_condition) {
877                if (!exclude.includes(_condition.field.origName)) {
878                    _condition.reset()
879                }
880            })
881        }
882        TConditionsPanel.prototype.findCondition = function (fieldName) {
883            for (var i = 0; i < this._buffer.length; i++) {
884                if (this._buffer[i].field.origName == fieldName) {
885                    return this._buffer[i]
886                }
887            }
888        }
889        Object.defineProperty(TConditionsPanel.prototype, "hasChanged", {
890            get: function () {
891                const hasChanged = !![...this.owner.conditions.allConditions].reduce((accumulator, condition) => {
892                    const label = condition._obj.label
893
894                    if (lab
894el.type == "select-one") {
895                        if (!label.value[0]) {
896                            return true
897                        }
898                    } else if (label.type == "radio") {
899                        if (Object.keys(label.value)[0] != label.defaultValue) {
900                            return true
901                        }
902                    } else {
903                        return true
904                    }
905                }, false)
906
907                return hasChanged
908            },
909            enumerable: false,
910            configurable: true
911        })
912        Object.defineProperty(TConditionsPanel.prototype, "container", {
913            get: function () {
914                return this._element.children[0].children[0].children[1]
915            },
916            enumerable: false,
917            configurable: true
918        })
919        Object.defineProperty(TConditionsPanel.prototype, "element", {
920            get: function () {
921                return this._element
922            },
923            set: function (val) {
924                if (typeof val == 'string') {
925                    this._element = this.owner.element.querySelector(val)
926                }
927            },
928            enumerable: false,
929            configurable: true
930        })
931        Object.defineProperty(TConditionsPanel.prototype, "buffer", {
932            get: function () {
933                return this._buffer
934            },
935            enumerable: false,
936            configurable: true
937        })
938        Object.defineProperty(TConditionsPanel.prototype, "allConditions", {
939            get: function () {
940                return this.element.querySelectorAll('.condition')
941            },
942            enumerable: false,
943            configurable: true
944        })
945        Object.defineProperty(TConditionsPanel.prototype, "hiddenContainer", {
946            get: function () {
947                return this.owner.form.querySelector('.hidden-fields')
948            },
949            enumerable: false,
950            configurable: true
951        })
952        return TConditionsPanel
953    }())
954    ws.TConditionsPanel = TConditionsPanel
955    var TBaseCondition = (function () {
956        function TBaseCondition(options) {
957            this.isEmpty = true
958            var _that = this
959            $.extend(this, options)
960            this.element = $('<div class="condition"></div>').get(0)
961            this.element['_obj'] = this
962            if (this.label.invisibleValue != undefined && isScalar(this.label.invisibleValue)) {
963                this.label.invisibleValue = [this.label.invisibleValue]
964                this.label.invisibleValue.valuesAsString()
965            }
966            this.element.eventListener('onReset', function (ev) {
967                if (_that.label.onReset) {
968                    eval(_that.label.onReset)
969                }
970            })
971        }
972        TBaseCondition.prototype.draw = function () {
973            this.label.value = this.field.value
974            var _el = '<i>' + this.label.caption + '</i><b>' + this.field.value
975                + '</b><span class="fa fa-del-cross _rc">×</span>'
976            $(_el).appendTo(this.element)
977            this.isEmpty = !this.field.value.length
978        }
979        TBaseCondition.prototype.reset = function (_e) {
980            this.field.fieldElement.value = ''
981            this.element.fire('onReset')
982        }
983        Object.defineProperty(TBaseCondition.prototype, "hiddenContainer", {
984            get: function () {
985                return this.field.fieldElement.form.querySelector('.hidden-fields')
986            },
987            enumerable: false,
988            configurable: true
989        })
990        return TBaseCondition
991    }())
992    ws.TBaseCondition = TBaseCondition
993    var TRadioCondition = (function (_super) {
994        __extends(TRadioCondition, _super)
995        function TRadioCondition() {
996            return _super !== null && _super.apply(this, arguments) || this
997        }
998        TRadioCondition.prototype.draw = function () {
999            try {
1000                var _checked = this.field.checkedElement
1001
1002                this.label.value = {
1003                    [this.field.value]: _checked.labels[0].innerHTML
1004                }
1005
1006                var _el = '<i>' + this.label.caption
1007                    + '</i><b>' + _checked.labels[0].innerHTML
1008                    + '</b><span class="fa fa-del-cross _rc">×</span>'
1009                $(_el).appendTo(this.element)
1010                try {
1011                    this.isEmpty = this.label.invisibleValue.valuesAsString().includes(_checked.value)
1012                }
1013                catch (err) {
1014                    this.isEmpty = false
1015                }
1016            }
1017            catch (err) { }
1018        }
1019        TRadioCondition.prototype.reset = function (_e) {
1020            var _els = this.field.fieldElement.form.fields.findByName(this.field.origName)
1021            if (!isArray(_els) && isObject(_els)) {
1022                _els = [_els]
1023            }
1024            try {
1025                for (var i = 0; i < _els.length; i++) {
1026                    try {
1027                        _els[i].fieldElement.checked = _els[i].fieldElement.value
1028                            == String(this.label.defaultValue)
1029                    }
1030                    catch (err) {
1031                        _els[i].fieldElement.checked = false
1032                    }
1033                }
1034            }
1035            catch (err) {
1036            }
1037            this.element.fire('onReset')
1038        }
1039        return TRadioCondition
1040    }(TBaseCondition))
1041    ws.TRadioCondition = TRadioCondition
1042    var TBooleanCondition = (function (_super) {
1043        __extends(TBooleanCondition, _super)
1044        function TBooleanCondition() {
1045            return _super !== null && _super.apply(this, arguments) || this
1046        }
1047        TBooleanCondition.prototype.draw = function () {
1048            this.label.value = this.field.fieldElement.checked ? 1 : 0
1049
1050            var _el = '<i>' + this.label.caption
1051                + '</i><b class="fa fa-check"></b><span class="fa fa-del-cross _rc">×</span>'
1052            $(_el).appendTo(this.element)
1053            this.isEmpty = !this.field.fieldElement.checked
1054        }
1055        TBooleanCondition.prototype.reset = function (_e) {
1056            this.field.fieldElement.checked = false
1057            this.element.fire('onReset')
1058        }
1059        return TBooleanCondition
1060    }(TBaseCondition))
1061    ws.TBooleanCondition = TBooleanCondition
1062    var TSelect2Condition = (function (_super) {
1063        // нигде не используется
1064        __extends(TSelect2Condition, _super)
1065        function TSelect2Condition(options) {
1066            var _this = _super.call(this, options) || this
1067            _this.element.classList.add('multi')
1068            return _this
1069        }
1070        TSelect2Condition.prototype.draw = function () {
1071            var _options = $(this.field.fieldElement).parent().find('[class$="__choice"]')
1072            var _el = '<i>' + this.label.caption + '</i>'
1073            for (var i = 0; i < _options.length; i++) {
1074                var _txt = _options[i].getAttribute('title').trim().replace(/&amp;emsp;|&emsp;/g, '')
1075                _el += '<b title="' + _txt + '">' + _txt + '</b>'
1076            }
1077            _el += '<span class="fa fa-del-cross _rc">×</span>'
1078            $(_el).appendTo(this.element)
1079            this.isEmpty = !_options.length
1080        }
1081        TSelect2Condition.prototype.reset = function (_e) {
1082            $(this.field.fieldElement).val(null).trigger('change')
1083            $(this.field.fieldElement).trigger('select2:unselect')
1084            this.element.fire('onReset')
1085        }
1086        return TSelect2Condition
1087    }(TBaseCondition))
1088    ws.TSelect2Condition = TSelect2Condition
1089    var TSelectCondition = (function (_super) {
1090        __extends(TSelectCondition, _super)
1091        function TSelectCondition(options) {
1092            var _this = _super.call(this, options) || this
1093            _this.element.classList.add('multi')
1094            return _this
1095        }
1096        TSelectCondition.prototype.draw = function () {
1097            this.label.value = {}
1098
1099            var _options = this.field.fieldElement.selectedOptions
1100            var _el = '<i>' + this.label.caption + '</i>'
1101            var _itemCnt = 0
1102            for (var i = 0; i < _options.length; i++) {
1103                var _txt = _options[i].textContent.trim().replace(/&amp;emsp;|&emsp;/g, '')
1104                const temp = document.createElement("span")
1105                temp.innerHTML = _txt
1106                _txt = temp.innerText
1107                temp.remove()
1108
1109                this.label.value[_options[i].value] = _txt
1110
1111                if (this.label.invisibleValue != undefined
1112                    && this.label.invisibleValue.includes(_options[i].value)) {
1113                    continue
1114                }
1115                _el += '<b title="' + _txt + '">'
1116                    + _txt
1117                    + '<span class="fa fa-del-cross _rc" val="' + _options[i].value + '">×</span>'
1118                    + '</b>'
1119                _itemCnt++
1120            }
1121            $(_el).appendTo(this.element)
1122            this.isEmpty = !_options.length || !_itemCnt
1123        }
1124        TSelectCondition.prototype.reset = function (_e) {
1125            if (this.field.fieldElement.classList.contains('select2')
1126                || this.field.fieldElement.parentElement.querySelector('[class*="select2"]')) {
1127                if (_e) {
1128                    var vals = this.field.fieldElement.value
1129                    vals.splice(vals.indexOf(_e.getAttribute('val')), 1)
1130                    $(this.field.fieldElement).val(vals).trigger('change')
1131                    $(this.field.fieldElement).trigger('select2:unselect')
1132                }
1133                else {
1134                    $(this.field.fieldElement).val(null).trigger('change')
1135                    $(this.field.fieldElement).trigger('select2:unselect')
1136                }
1137            }
1138            else if (this.field.fieldElement.classList.contains('fstyler')) {
1139                try {
1140                    this.field.fieldElement.value = String(this.label.defaultValue)
1141                }
1142                catch (err) {
1143                    this.field.fieldElement.value = ''
1144                }
1145                $(this.field.fieldElement).trigger('refresh')
1146                $(this.field.fieldElement).trigger('change')
1147            }
1148            else {
1149                try {
1150                    this.field.fieldElement.removeChildren()
1151                    $(this.field.fieldElement).trigger('change')
1152                }
1153                catch (err) {
1154                }
1155            }
1156            this.element.fire('onReset')
1157        }
1158        return TSelectCondition
1159    }(TBaseCondition))
1160    ws.TSelectCondition = TSelectCondition
1161    var TSelect2OneCondition = (function (_super) {
1162        __extends(TSelect2OneCondition, _super)
1163        function TSelect2OneCondition() {
1164            return _super !== null && _super.apply(this, arguments) || this
1165        }
1166        TSelect2OneCondition.prototype.draw = function () {
1167            try {
1168                this.label.value = [this.field.fieldElement.selectedOptions[0].innerHTML]
1169
1170                var _el = '<i>' + this.label.caption + '</i><b>'
1171                    + this.field.fieldElement.selectedOptions[0].innerHTML
1172                        .trim().replace(/&amp;emsp;|&emsp;/g, '')
1173                    + '</b><span class="fa fa-del-cross _rc">×</span>'
1174                $(_el).appendTo(this.element)
1175                this.isEmpty = this.label.invisibleValue != undefined
1176                    && this.label.invisibleValue
1177                        .includes(this.field.fieldElement.selectedOptions[0].value)
1178            }
1179            catch (err) {
1180                this.isEmpty = true
1181            }
1182        }
1183        TSelect2OneCondition.prototype.reset = function (_e) {
1184            if (this.field.fieldElement.classList.contains('select2')
1185                || this.field.fieldElement.parentElement.querySelector('[class*="select2"]')) {
1186                $(this.field.fieldElement).val(null).trigger('change')
1187                $(this.field.fieldElement).trigger('select2:unselect')
1188            }
1189            else if (this.field.fieldElement.classList.contains('fstyler')) {
1190                try {
1191                    this.setDefaultIsHidden(String(this.label.defaultValue))
1192                    this.field.fieldElement.value = String(this.label.defaultValue)
1193                }
1194                catch (err) {
1195                    this.field.fieldElement.value = ''
1196                }
1197                $(this.field.fieldElement).trigger('refresh')
1198                $(this.field.fieldElement).trigger('change')
1199            }
1200            else {
1201                try {
1202                    this.field.fieldElement.removeChildren()
1203                    $(this.field.fieldElement).trigger('change')
1204                }
1205                catch (err) {
1206                }
1207            }
1208            this.element.fire('onReset')
1209        }
1210        TSelect2OneCondition.prototype.setDefaultIsHidden = function (val) {
1211            if (this.field.fieldElement.closest('.hidden-fields')) {
1212                var _el = this.field.fieldElement;
1213                (_el).selectedOptions[_el.selectedIndex].value = val
1214            }
1215        }
1216        return TSelect2OneCondition
1217    }(TBaseCondition))
1218    ws.TSelect2OneCondition = TSelect2OneCondition
1219})(ws || (ws = {}))

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.