PageSourceSearch

https://adm-zheleznovodsk.ru/static/uil/export/project_mo_theme_sh…/scripts/ad-selector.js?20260220202336

js adm-zheleznovodsk.ru collected 2026-10-02 18:01:41 UTC 6,568 bytes, 141 lines download raw bytes

1// Селектор типов сделок при создании объявления
2$(function () {
3
4    $('.uil-ad-create-selector').each(function () {
5
6        var dpref = 'data-td-selector__';
7
8        var $selector = $(this);
9
10        var $category_list = $selector.find('ul[' + dpref + 'category-list]');
11        var $subcategory_list = $selector.find('ul[' + dpref + 'subcategory-list]');
12        var $typedeal_list = $selector.find('ul[' + dpref + 'typedeal-list]');
13
14        var sel_category_pk = $selector.attr(dpref + 'selected-category');
15        var sel_subcategory_pk = $selector.attr(dpref + 'selected-subcategory');
16        if (sel_category_pk == '') sel_category_pk = undefined;
17        if (sel_subcategory_pk == '') sel_subcategory_pk = undefined;
18        var sel_typedeal_pks = [];
19        $.each($selector.attr(dpref + 'selected-typedeals').split(','), function (i, value) {
20            if (value != '') sel_typedeal_pks.push(value);
21        });
22
23        $category_list.on('click', 'li', function () {
24            var $category = $(this);
25            sel_category_pk = $category.attr(dpref + 'category-pk');
26            $subcategory_list.html('<li>Подождите...<li>');
27            $typedeal_list.html('<li>Подождите...<li>');
28            $category_list.find('li').removeClass('active');
29            $category.addClass('active');
30            $.ajax({
31                type: 'GET',
32                url: '/ad/subcategory_list_ajax/',
33                dataType: 'json',
34                contentType: 'application/json',
35                data: {
36                    category_pk: sel_category_pk
37                },
38                success: function (data) {
39                    $subcategory_list.empty();
40                    var html = '';
41                    $.each(data, function (i, item) {
42                        html += '<li ' + dpref + 'subcategory-pk="' + item['pk'] + '" title="' + item['title'] + '">';
43                        html += '<span class="title">' + item['title'] + '</span>';
44                        html += '<span class="counter">(' + item['counter'] + ')</span>';
45                        html += '</li>';
46                    });
47                    $subcategory_list.html(html);
48                    if (sel_category_pk == undefined || sel_subcategory_pk == undefined || sel_typedeal_pks.length == 0)
49                        $subcategory_list.find('li:first').click();
50                    else
51                        $subcategory_list.find('li[' + dpref + 'subcategory-pk=' + sel_subcategory_pk + ']').click();
52                    sel_subcategory_pk = undefined;
53                },
54                error: function () {
55                    $subcategory_list.html('<li>Ошибка<li>');
56                    $typedeal_list.html('<li>Ошибка<li>');
57                }
58            });
59        });
60
61        $subcategory_list.on('click', 'li', function () {
62            var $subcategory = $(this);
63            sel_subcategory_pk = $subcategory.attr(dpref + 'subcategory-pk');
64            $typedeal_list.html('<li>Подождите...<li>');
65            $subcategory_list.find('li').removeClass('active');
66            $subcategory.addClass('active');
67            $.ajax({
68                type: 'GET',
69                url: '/ad/typedeal_list_ajax/',
70                dataType: 'json',
71                contentType: 'application/json',
72                data: {
73                    subcategory_pk: sel_subcategory_pk
74                },
75                success: function (data) {
76                    $typedeal_list.empty();
77                    var html = '';
78                    $.each(data, function (i, item) {
79                        html += '<li ' + dpref + 'typedeal-pk="' + item['pk'] + '" title="' + item['title'] + '">';
80                        html += '<label class="checkbox"><input type="checkbox" name="types_deals" value="' + item['pk'] + '"></label>';
81                        html += '<span class="title">' + item['title'] + '</span>';
82                        html += '<span class="counter">(' + item['counter'] + ')</span>';
83                        html += '</li>';
84                    });
85                    $typedeal_list.html(html);
86                    if (sel_typedeal_pks.length > 0)
87                        $typedeal_list.find('li').find('input').each(function () {
88                            var $checkbox = $(this);
89                            var typedeal_pk = $checkbox.attr('value');
90                            if ($.inArray(typedeal_pk, sel_typedeal_pks) > -1)
91                                $checkbox.prop('checked', true);
92                        });
93                    sel_typedeal_pks = [];
94                },
95                error: function () {
96                    $typedeal_list.html('<li>Ошибка<li>');
97                }
98            });
99        });
100
101        $typedeal_list.on('click', 'li .title, li .counter', function () {
102            var $typedeal = $(this).closest('li');
103            var $checkbox = $typedeal.find('input');
104            $checkbox.prop('checked', !$checkbox.prop('checked'));
105        });
106
107        $category_list.html('<li>Подождите...<li>');
108        $subcategory_list.html('<li>Подождите...<li>');
109        $typedeal_list.html('<li>Подождите...<li>');
110
111        $.ajax({
112            type: 'GET',
113            url: '/ad/category_list_ajax/',
114            dataType: 'json',
115            contentType: 'application/json',
116            success: function (data) {
117                $category_list.empty();
118                var html = '';
119                $.each(data, function (i, item) {
120                    html += '<li ' + dpref + 'category-pk="' + item['pk'] + '" title="' + item['title'] + '">';
121                    html += '<span class="title">' + item['title'] + '</span>';
122                    html += '<span class="counter">(' + item['counter'] + ')</span>';
123                    html += '</li>';
124                });
125                $category_list.html(html);
126                if (sel_category_pk == undefined || sel_subcategory_pk == undefined || sel_typedeal_pks.length == 0)
127                    $category_list.find('li:first').click();
128                else
129                    $category_list.find('li[' + dpref + 'category-pk=' + sel_category_pk + ']').click();
130            },
131            error: function () {
132                $category_list.html('<li>Ошибка<li>');
133                $subcategory_list.html('<li>Ошибка<li>');
134                $typedeal_list.html('<li>Ошибка<li>');
135            }
136        });
137
138    });
139
140});
141

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.