PageSourceSearch

https://gdekomfort.ru/modules/shop/view/js/rscomponent/selectcity.js

js gdekomfort.ru collected 2026-10-05 02:26:14 UTC 1,941 bytes, 59 lines download raw bytes

1/**
2 * Компонент - выбор города.
3 * Может использоваться в сторонних блоках, например в блоке стоимость доставки в карточке товара
4 */
5new class SelectCity extends RsJsCore.classes.component
6{
7    constructor()
8    {
9        super();
10        let defaults = {
11            changeCity: '.rs-change-city' //Элемент, клик на который будет открывать окно выбора города
12        };
13
14        this.settings = {...defaults, ...this.getExtendsSettings()};
15    }
16
17    /**
18     * Инициализирует компонент
19     */
20    init() {
21        this.utils.on('click', this.settings.changeCity, event => this.changeCityDialog(event));
22    }
23
24    /**
25     *
26     * @param event
27     */
28    changeCityDialog(event) {
29        let setAddressUrl = event.rsTarget.dataset.setAddressUrl;
30        let dialogUrl = event.rsTarget.dataset.selectAddressUrl;
31
32        this.plugins.openDialog.show({
33            url: dialogUrl,
34            bindSubmit:false,
35            callback: (response, element) => {
36                //Инициализируем диалог выбора города
37                new SelectedAddressChange(element, (address) => {
38                    let formData = new FormData();
39                    for (let key in address) {
40                        formData.append(key, address[key]);
41                    }
42
43                    this.utils.fetchJSON(setAddressUrl, {
44                        method:'POST',
45                        body: formData
46                    }).then(response => {
47                        if (response.success) {
48                            location.replace(location.href.replace(location.hash,""));
49                        }
50                    });
51                });
52            }
53        });
54    }
55
56    onDocumentReady() {
57        this.init();
58    }
59};

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.