PageSourceSearch

https://rikasale.ru/local/templates/.default/components/bitrix/system.pagenavigation/ajax/script.js

js rikasale.ru collected 2026-10-07 17:38:38 UTC 3,566 bytes, 108 lines download raw bytes

1const PagerApp = function (settings) {
2    this._settings = {
3        preloaderContainer: '.catalog-product-list',
4        defaultOffsetSelector: '.breadcrumb',
5        paginationItemClass: '.paginations__link',
6    }
7    for (let propName in settings) {
8        if (settings.hasOwnProperty(propName)) {
9            this._settings[propName] = settings[propName];
10        }
11    }
12    this._$preloaderContainer = document.querySelector(this._settings.preloaderContainer);
13    this._init();
14}
15PagerApp.prototype._init = function () {
16    this._setupListener.call(this);
17}
18PagerApp.prototype._setupListener = function () {
19    const _this = this,
20        paginationItemSelector = _this._settings.paginationItemClass,
21        paginationItemClass = paginationItemSelector.substring(paginationItemSelector.indexOf('.') + 1);
22
23    if (_this._$preloaderContainer){
24        _this._$preloaderContainer.addEventListener('click', (e) =>
25        {
26            if (e.target.classList.contains(paginationItemClass) || e.target.closest('.' + paginationItemClass) !== null)
27            {
28                e.preventDefault();
29                let link = e.target.getAttribute('href');
30                if (!link)
31                {
32                    link = e.target.closest('.' + paginationItemClass).getAttribute('href')
33                }
34                _this._send({reload_ajax: 'y'}, link, link);
35            }
36        });
37    }
38}
39PagerApp.prototype._send = function (data = {}, link = window.location.href, changeLink = '', scroll = true) {
40    const _this = this;
41    if (data.length === 0 || link === '#' || !link) return;
42
43    _this._displayLoading();
44    if (scroll)
45    {
46        let $topOffset = (document.querySelector(this._settings.defaultOffsetSelector)
47            .getBoundingClientRect().top - 300 + document.body.scrollTop);
48
49        window.scrollBy({
50            top: $topOffset,
51            behavior: 'smooth'
52        });
53    }
54
55    fetch(link, {
56        method: 'POST',
57        cache: 'no-cache',
58        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
59        body: new URLSearchParams(data)
60    }).then(function(response) {
61        return response.text();
62    }).then(function(text) {
63        let template = document.createElement('div');
64        template.innerHTML = text;
65        setTimeout(() => {
66            if (template.querySelector(_this._settings.preloaderContainer))
67            {
68                _this._$preloaderContainer.innerHTML = template.querySelector(_this._settings.preloaderContainer).innerHTML;
69                if (changeLink !== '')
70                {
71                    history.pushState(null, null, changeLink);
72                }
73            }
74
75            new LazyLoad({
76                elements_selector: ".lazy-img",
77                threshold: 0,
78            });
79
80
81            window.reinit?.productImagesCarousel && window.reinit?.productImagesCarousel(); // for rikasale
82            _this._hideLoading();
83
84        }, 100);
85    })
86    .catch(error => {
87        console.log(error);
88    });
89}
90PagerApp.prototype._displayLoading = function() {
91    this._$preloaderContainer.classList.add('preloader');
92    setTimeout(() => {
93        this._hideLoading();
94    }, 8000);
95}
96PagerApp.prototype._hideLoading = function() {
97    this._$preloaderContainer.classList.remove('preloader')
98}
99
100window.addEventListener('DOMContentLoaded', () => {
101
102    new PagerApp({
103        preloaderContainer: '.preloader_container',
104        defaultOffsetSelector: '.preloader_container',
105        paginationItemClass: '.paginations__link',
106    });
107})
108

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.