PageSourceSearch

https://puch-vesti.ru/static/uil/export/project_mo_theme_short_01/…/scripts/inova-admin-form.js?20260220202336

js puch-vesti.ru collected 2026-10-02 20:50:45 UTC 4,348 bytes, 117 lines download raw bytes

1$(function uil_init_inova_admin_form() {
2
3  var SELECTOR_FORM = '.uil-inova-admin-form',
4      SELECTOR_JSON = 'div[data-json]';
5
6  var $source;
7
8  function handler_link_click(e) {
9    var $this = $(e.currentTarget);
10    if ($this.attr('target') !== '_blank' &&
11      ($this.attr('rel') || '').indexOf('lightbox') === -1 &&
12      !$this.hasClass('b-admin-object__action_sort') &&
13      $this.closest('.mceEditor').length === 0
14    ) {
15      e.preventDefault();
16      if ($this.attr('data-admin-popup') !== undefined)
17        $source = $this;
18      var title = $this.attr('data-title');
19      if (title === undefined) title = $this.attr('title');
20      if (title === undefined) title = $this.text();
21      inova_popup.set_url($this.attr('href'), title);
22    }
23  }
24
25  function handler_form_click(e) {
26    var $sbt = $(e.target);
27    $sbt.parent().append('<input type="hidden" name="' + $sbt.attr('name') + '" value="' + $sbt.attr('value') + '" style="display: none"/>');
28  }
29
30  function handler_form_submit(e) {
31    var $form     = $(e.target),
32        form_data = new FormData($form[0]);
33    // for (var pair of form_data.entries())
34    //     console.log(pair[0] + ': ' + pair[1]);
35
36    function failPing() {
37      alert('Ошибка отправки формы. Попробуйте позже.');
38      inova_popup.freeze(false);
39      return false;
40    }
41
42    $.ajax({
43      type:       'POST',
44      url:        '/general/ping/',
45      cache:      false,
46      beforeSend: function () {
47        inova_popup.freeze();
48      },
49      error:      failPing,
50      success:    function (ping_resp) {
51        if (ping_resp !== 'PONG') return failPing();
52        $.ajax({
53          type:        'POST',
54          url:         $form.attr('action'),
55          data:        form_data,
56          cache:       false,
57          contentType: false,
58          processData: false,
59          beforeSend:  function () {
60            if (inova_popup.is_shown())
61              inova_popup.freeze();
62            else
63              inova_popup.set_message('Подождите...').freeze();
64          },
65          complete:    function (data) {
66            var html = data.responseText, $html = $(html), form_html = $html.find(SELECTOR_FORM).add($html.filter(SELECTOR_FORM));
67
68            if (form_html.length === 1) {
69              inova_popup.set_html(form_html);
70
71            } else {
72              var raw_json = $html.find(SELECTOR_JSON).add($html.filter(SELECTOR_JSON)).text();
73              if (raw_json.length > 0) {
74                var json = JSON.parse(raw_json);
75                var success_url = json.success_url;
76                var is_redirect = 'false';
77                if ($source !== undefined)
78                  is_redirect = $source.attr('data-admin-popup-redirect');
79
80                if (is_redirect === 'true' && success_url !== undefined && success_url.length > 0) {
81                  if (success_url.indexOf('#') === -1)
82                    location.href = success_url;
83                  else {
84                    if (success_url.split('#', 1)[0] === location.pathname)
85                      location.href = success_url.split('#', 1)[0];
86                    else
87                      location.href = success_url;
88                  }
89                } else if (is_redirect === 'false' && success_url !== undefined && success_url.length > 0 && (success_url.indexOf('create') > -1 || success_url.indexOf('update') > -1 || success_url.indexOf('delete') > -1)) {
90                  inova_popup.set_url(success_url);
91                } else if (is_redirect !== undefined && is_redirect.indexOf('/') > -1) {
92                  location.href = is_redirect.split('#', 1)[0];
93                } else {
94                  location.href = location.href.split('#', 1)[0];
95                }
96
97              } else {
98                inova_popup.refresh_page();
99              }
100
101            }
102          }
103        });
104      }
105    });
106    return false;
107  }
108
109  $(document).on('inova_popup.hide:after', function () {
110    $source = undefined;
111  });
112  $(document).on('click', 'a[data-admin-popup]', handler_link_click);
113  inova_popup.on('click', '.uil-inova-admin-form a', handler_link_click);
114  inova_popup.on('click', '.uil-inova-admin-form form *[type=submit]', handler_form_click);
115  inova_popup.on('submit', '.uil-inova-admin-form form', handler_form_submit);
116
117});

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.