PageSourceSearch

https://dalnegorsk-mo.ru/static/inova_admin/scripts/inova_admin.js?20211220222647

js dalnegorsk-mo.ru collected 2026-10-02 18:14:50 UTC 16,690 bytes, 335 lines download raw bytes

1// TODO: Временная блокировка сортировки в мобильном режиме
2var is_mobile = false;
3try {
4    document.createEvent('TouchEvent');
5    is_mobile = true;
6}
7catch (e) {
8}
9
10// Скрытие иконок сортировки там, где они не настроены
11$(function () {
12    // TODO: Временная блокировка сортировки в мобильном режиме
13    if (is_mobile)
14        $('.b-admin-object__action_sort, .b-admin-object__action_blocks-order').hide();
15    // TODO: Временная блокировка сортировки в мобильном режиме
16    if (!is_mobile && localStorage['inova_admin_state'] === 'true') {
17        $('.b-admin-object__action_sort').each(function () {
18            var $self = $(this);
19            var $sort_item = $self.closest('*[data-sort_item]');
20            if ($sort_item.length === 0)
21                $self.hide();
22            else {
23                var $sort_item_list = $sort_item.closest('*[data-sort_list=' + $sort_item.attr('data-sort_list_id') + ']');
24                if ($sort_item_list.length === 0)
25                    $self.hide();
26                else if ($sort_item_list.find('*[data-sort_list_id=' + $sort_item_list.attr('data-sort_list') + ']').length <= 1)
27                    $self.hide();
28            }
29        });
30    }
31});
32
33// TODO: Временная блокировка сортировки в мобильном режиме
34if (!is_mobile)
35    $(document).on('click', '.b-admin-object__action_sort', function () {
36        var $action = $(this);
37        if ($action.closest('.uil-inova-admin-sort-list').length > 0)
38            return false;
39        if ($action.attr('href') !== undefined && !$action.attr('data-sort_link_applied')) {
40            var $sort_item = $action.closest('*[data-sort_item]');
41            var $sort_list = $sort_item.closest('*[data-sort_list="' + $sort_item.attr('data-sort_list_id') + '"]');
42            var sorted_items = [];
43            var selector = '*[data-sort_item][data-sort_list_id=' + $sort_list.attr('data-sort_list') + ']';
44            $sort_list.find(selector).each(function () {
45                sorted_items.push($(this).attr('data-sort_item'));
46            });
47            $action.attr('data-sort_link_applied', true);
48            $action.attr('href', $action.attr('href') + '?' + decodeURIComponent($.param({'sorted_items': sorted_items})));
49        }
50        var title = $action.attr('data-title');
51        if (title === undefined) title = $action.attr('title');
52        if (title === undefined) title = $action.text();
53        inova_popup.set_url($action.attr('href'), title);
54        return false;
55    });
56
57// Переключение в режим редактирования
58$(function () {
59    //var fade_time = 200;
60    var $switcher = $('#inova-admin__toggle-ui');
61    var $body = $('html, body');
62    var $window = $(window);
63    $(document).on('inova_admin.toggle_ui', function (e, state, $root) {
64        if (state === undefined)
65            state = localStorage['inova_admin_state'];
66        localStorage['inova_admin_state'] = state;
67        if ($root === undefined)
68            $root = $(document.body);
69        var stored_scroll = $window.scrollTop() * 100 / $(document).height();
70        $root.find('.b-admin-object[data-admin-is-show-always=1], .b-block-create[data-admin-is-show-always=1], .b-admin-dependent[data-admin-is-show-always=1]').each(function () {
71            var $this = $(this);
72            if ($this.is('span'))
73                $this.css('display', 'inline-block');
74            else
75                $this.css('display', 'block');
76        });
77        var $ui = $root.find('.b-admin-object[data-admin-is-show-always!=1], .b-block-create[data-admin-is-show-always!=1], .b-admin-dependent[data-admin-is-show-always!=1]');
78        if (state) {
79            $ui.each(function () {
80                var $this = $(this);
81                if ($this.is('span'))
82                    $this.css('display', 'inline-block');
83                else
84                    $this.css('display', 'block');
85            });
86        } else {
87            $ui.css('display', 'none');
88        }
89        $body.scrollTop(parseInt($(document).height() * stored_scroll / 100));
90    });
91
92    var toggle_ui = localStorage['inova_admin_state'] === 'true';
93    $switcher.attr('checked', toggle_ui);
94    $(document).trigger('inova_admin.toggle_ui', [toggle_ui]);
95    $switcher.change(function () {
96        $(document).trigger('inova_admin.toggle_ui', [this.checked]);
97    });
98    $(document).on('inova_popup.set_html:after', function () {
99        $(document).trigger('inova_admin.toggle_ui', [localStorage['inova_admin_state'] === 'true'], inova_popup.content);
100    });
101
102});
103
104// Сортировка
105// TODO: Временная блокировка сортировки в мобильном режиме
106if (!is_mobile)
107    $(function () {
108
109        function run($root, silent) {
110            var $items = $root.find('*[data-sort_list]').not('[data-sort_list_applied="true"]').not('[data-sort_list_enable="false"]');
111            if ($items.length > 0) {
112                var is_popup_refresh = false;
113                $items.each(function () {
114                    var $sort_list = $(this);
115                    $sort_list.attr('data-sort_list_applied', true);
116                    var axis = $sort_list.attr('data-sort_list__axis');
117                    if (axis !== 'false' && axis !== 'y' && axis !== 'x') axis = 'y';
118                    var reload_page = false;
119                    if ($sort_list.attr('data-sort_list__reload_page') === 'true')
120                        reload_page = true;
121                    var items_selector = '*[data-sort_item][data-sort_list_id=' + $sort_list.attr('data-sort_list') + ']';
122                    $sort_list.sortable({
123                        axis: axis,
124                        cursor: 'move',
125                        delay: 100,
126                        handle: '.b-admin-object__action_sort',
127                        helper: 'clone',
128                        items: items_selector,
129                        placeholder: 'b-admin-sort-placeholder',
130                        forcePlaceholderSize: true,
131                        tolerance: 'pointer',
132                        stop: function (e, ui) {
133                            var $sort_item = ui.item;
134                            var $sort_list = $sort_item.closest('*[data-sort_list="' + $sort_item.attr('data-sort_list_id') + '"]');
135                            var item_obj_str = $sort_item.attr('data-sort_item');
136                            var sorted_items = [];
137                            var items_selector = '*[data-sort_item][data-sort_list_id=' + $sort_list.attr('data-sort_list') + ']';
138                            $sort_list.find(items_selector).each(function () {
139                                var $this = $(this);
140                                var index = $sort_list.find(items_selector).index($this);
141                                var stored_index = parseInt($this.attr('data-sort_item__index'));
142                                var obj_str = $this.attr('data-sort_item');
143                                var is_moved_item = obj_str === item_obj_str;
144                                //if (index != stored_index)
145                                sorted_items.push({
146                                    obj_str: obj_str,
147                                    index: index,
148                                    stored_index: stored_index,
149                                    is_moved_item: is_moved_item
150                                });
151                            });
152                            var url = $sort_item.find('.b-admin-object__action_sort').attr('data-href');
153                            if (silent)
154                                url += '?silent=yes';
155                            $.ajax({
156                                type: 'POST',
157                                url: url,
158                                dataType: 'json',
159                                data: {
160                                    sorted_items: JSON.stringify(sorted_items)
161                                },
162                                beforeSend: function () {
163                                    inova_popup.freeze(true);
164                                },
165                                success: function () {
166                                    if (reload_page === true)
167                                        inova_popup.refresh_page();
168                                    else {
169                                        inova_popup.freeze(false);
170                                        is_popup_refresh = true;
171                                    }
172                                }
173                            });
174                        }
175                    });
176                });
177                if (inova_popup.is_shown())
178                    $(document).one('inova_popup.hide:after', function () {
179                        if (is_popup_refresh)
180                            inova_popup.refresh_page();
181                    });
182            }
183        }
184
185        run($(document.body));
186        $(document).on('inova_popup.set_html:after', function () {
187            run(inova_popup.content, true);
188        });
189
190    });
191
192/*
193function form_actions_disable($el) {
194    if ($el.attr('data-disabled') !== undefined)
195        return false;
196    $el.attr('data-disabled', true);
197    $el.find('.b-form-actions__action').css('opacity', '.5');
198}
199
200function form_actions_enable($el) {
201    $el.removeAttr('data-disabled');
202    $el.find('.b-form-actions__action').css('opacity', '');
203}
204
205// Всплывающие администраторские окна
206
207$(function () {
208    // Если страница, предназначенная для всплывающего окна, открывается не в окне, то переход на главную
209//    if ($('.b-popup-form').length > 0 && window.top == window.self) {
210//        $(document.body).hide();
211//        location.href = '/';
212//        return;
213//    }
214    // Блокировка кнопок после нажатия
215    var $form_actions = $('.b-form-actions');
216    $form_actions.find('input, button, a').click(function () {
217        return form_actions_disable($form_actions);
218    });
219    if (window === window.top) {
220        $(document).on('click', 'a[data-admin-popup_]', function () {
221            var $action = $(this);
222            var title = $action.attr('data-title');
223            if (title === undefined) title = $action.attr('title');
224            if (title === undefined) title = $action.text();
225            var height_max = ($(window).height() - 250);
226            var $modal_popup = get_modal_popup();
227            $modal_popup.html('<iframe frameborder="0" marginwidth="0" marginheight="0" allowfullscreen height="0" src="" style="width: 100%"/>');
228
229            var height_old = 0;
230            var ah_interval = setInterval(function () {
231                var $iframe = $modal_popup.find('iframe');
232                if ($iframe.length === 0) {
233                    clearInterval(ah_interval);
234                    return;
235                }
236                var height_new = 0;
237                $iframe.contents().find('body').find('*:visible').each(function () {
238                    var $this = $(this), n = $this.offset().top + $this.outerHeight();
239                    if (n > height_new) {
240                        height_new = n;
241                    }
242                });
243                height_new += 5;
244                if (height_new > height_max)
245                    height_new = height_max;
246                if (height_old !== height_new)
247                    $iframe.css('height', height_new);
248                height_old = height_new;
249            }, 1000);
250
251            $modal_popup.find('iframe')
252                .iframeAutoHeight({
253                    maxHeight: height_max,
254                    callback: function () {
255                        $modal_popup.dialog({position: {'my': 'center', 'at': 'center'}, title: title});
256                    }
257                })
258                .load(function () {
259                    var $iframe = $(this);
260                    $iframe.css({
261                        opacity: 0.01
262                    });
263                    // Если страница, НЕ предназначенная для всплывающего окна, открывается во всплывающем окне, то открыие этой страницы в окне браузера
264                    var INOVA_ADMIN_NOT_POPUP_SELECTOR = window['INOVA_ADMIN_NOT_POPUP_SELECTOR'];
265                    if (INOVA_ADMIN_NOT_POPUP_SELECTOR !== undefined && $iframe.contents().find(INOVA_ADMIN_NOT_POPUP_SELECTOR).length > 0) {
266                        location.href = $iframe.attr('src').split('#', 1)[0];
267                        return;
268                    }
269                    // Автоматическая высота высплывающего окна
270                    // var height_new = $iframe.contents().find('body').height() + 20;
271                    //if (height_new < height_max) {
272                    //    $iframe.attr('height', height_new);
273                    //} else {
274                    //    $iframe.attr('height', height_max);
275                    //}
276                    // $modal_popup.dialog({position: {'my': 'center', 'at': 'center'}, title: title});
277                    var _title = $iframe.contents().find('head').find('title').text();
278                    if (_title.length > 0)
279                        $modal_popup.dialog('option', 'title', _title);
280                    // Анализ команд при окончании работы в окне
281                    var raw_json = $iframe.contents().find('div[data-json]').text();
282                    if (raw_json.length > 0) {
283                        $modal_popup.dialog('option', 'title', 'Подождите...');
284                        var json = JSON.parse(raw_json);
285                        var success_url = json.success_url;
286                        var is_redirect = $action.attr('data-admin-popup-redirect');
287                        if (is_redirect === 'true' && success_url !== undefined && success_url.length > 0) {
288                            if (success_url.indexOf('#') === -1)
289                                location.href = success_url.split('#', 1)[0];
290                            else if (success_url.split('#', 1)[0] === window.top.location.href.split(window.top.location.host)[1].split('#', 1)[0])
291                                location.href = success_url.split('#', 1)[0];
292                            else
293                                $iframe.attr('src', success_url);
294                        } else if (is_redirect === 'false' && success_url !== undefined && success_url.length > 0 &&
295                            (success_url.indexOf('create') > -1 || success_url.indexOf('update') > -1 || success_url.indexOf('delete') > -1)) {
296                            $iframe.attr('src', success_url);
297                        } else if (is_redirect !== undefined && is_redirect.indexOf('/') > -1) {
298                            location.href = is_redirect.split('#', 1)[0];
299                        } else {
300                            location.href = location.href.split('#', 1)[0];
301                        }
302                        return;
303                    }
304                    $iframe.css({
305                        opacity: 1
306                    });
307                    // $modal_popup.dialog({position: {'my': 'center', 'at': 'center'}, title: title});
308                })
309                .attr('src', $action.attr('href'));
310            $modal_popup.dialog({
311                title: 'Подождите...',
312                resizable: false,
313                draggable: false,
314                modal: true,
315                position: 'center',
316                width: 640,
317                create: function (e, ui) {
318                    $(e.target).parent().css('position', 'fixed');
319                },
320                resizeStop: function (e, ui) {
321                    var position = [(Math.floor(ui.position.left) - $(window).scrollLeft()),
322                        (Math.floor(ui.position.top) - $(window).scrollTop())];
323                    $(e.target).parent().css('position', 'fixed');
324                    $modal_popup.dialog('option', 'position', position);
325                },
326                close: function (e, ui) {
327                    $modal_popup.html('');
328                    form_actions_enable($form_actions);
329                }
330            });
331            return false;
332        });
333    }
334});
335*/

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.