PageSourceSearch

https://poda.gov.ua/js/main.js

js poda.gov.ua collected 2026-10-02 16:21:30 UTC 15,811 bytes, 526 lines download raw bytes

1// (function ($, window, document, undefined) {
2/**
3 *  Add Background to parent element image
4 */
5
6function imgToBg(img_sel, parent_sel) {
7  if (!img_sel) {
8    console.info('no img selector');
9    return false;
10  }
11
12  var $parent, _this;
13
14  $(img_sel).each(function () {
15    _this = $(this);
16    $parent = _this.closest(parent_sel);
17    $parent = $parent.length ? $parent : _this.parent();
18    $parent.css('background-image', 'url(' + this.src + ')');
19    _this.hide();
20  });
21}
22imgToBg('.js-bg-img');
23
24/**
25 *  Add Background to parent element image
26 */
27
28function insertAfterNode(referenceNode, newNode) {
29  referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
30}
31
32function addCaptionPhoto(imageArray) {
33  const rtf = document.getElementById('rtf');
34  const rtfImages = rtf ? rtf.querySelectorAll('img') : [];
35  const images = imageArray || rtfImages;
36
37  images.forEach(image => {
38    if (!image.parentElement.classList.contains('floating-arrow')) {
39      const nodeElement = document.createElement('p');
40
41      nodeElement.innerHTML = image.getAttribute('alt');
42      nodeElement.classList.add('caption-photo');
43
44      insertAfterNode(image, nodeElement);
45    }
46  })
47}
48
49function handleHomePageSections() {
50  const homePageSections = document.querySelectorAll('#main-governance .home-page__sm-responsive');
51
52  homePageSections.forEach(item => {
53    const blocks = item.querySelectorAll('.home-page__row > div');
54
55    updateInformBlocks(blocks);
56  })
57}
58
59function updateInformBlocks(blocks) {
60  const count = blocks.length;
61
62  blocks.forEach(item => item.setAttribute('class', setInformBlockClass(count)));
63}
64
65function setInformBlockClass(count) {
66  const blockClass = 'col-12 md-top-margin';
67  let desktopSize = 3;
68
69  if (count === 3 || count === 5 || count === 6) {
70    desktopSize = 4;
71  }
72
73  if (count === 2) {
74    desktopSize = 6
75  }
76
77  return count === 1 ? blockClass : `col-xl-${desktopSize} col-md-6 ${blockClass}`
78}
79
80function setTitleStatClass(first, second) {
81  const titleStatistics = document.querySelectorAll('.title-statistics-covid');
82
83  if (titleStatistics.length) {
84    titleStatistics.forEach((item, index) => {
85      item.classList.add(!index ? first : second)
86    });
87  }
88}
89
90function toggleModalTagsNewsPage() {
91  $('#news-input').on('click', () => {
92    if ($(window).width() < 576) {
93      $('.news-main-aside__tags-container').addClass('active');
94      $('.news-main-aside').addClass('active');
95      $('.news-main-aside__x').addClass('active');
96      $('html').css('overflow', 'hidden');
97    }
98  });
99
100  $('.news-main-aside__x').on('click', () => {
101    if ($(window).width() < 576) {
102      $('.news-main-aside__tags-container').removeClass('active');
103      $('.news-main-aside').removeClass('active');
104      $('.news-main-aside__x').removeClass('active');
105      $('html').css('overflow', 'auto');
106    }
107  });
108}
109
110$(document).ready(toggleModalTagsNewsPage);
111$(window).resize(toggleModalTagsNewsPage);
112
113$('.news-main-aside__tag').on('click', function () {
114  $(this).toggleClass('active');
115});
116
117$(window).on ('popstate', function() {
118  const isRelDocuments = document.location.href.includes('#rel-documents');
119  const isContacts = document.location.href.includes('contacts#');
120
121  if (isRelDocuments || isContacts) return;
122
123  document.location.reload();
124});
125
126
127$(window).scroll(() => {
128    const stickyTagsBlock = $('.news-main-aside.sticky-block');
129    let sliderDivHeight = $('#sliderDiv').height() ? $('#sliderDiv').height() : 0;
130  if (stickyTagsBlock.length && window.screen.width >= 960) {
131    if($(window).scrollTop() + $(window).height() > $(document).height() - $('.footer').height() * 1.5) {
132      stickyTagsBlock.addClass('stop');
133    } else {
134      stickyTagsBlock.removeClass('stop');
135    }
136    
137      if (($(window).scrollTop() > sliderDivHeight + 130) && stickyTagsBlock.parent().height() > stickyTagsBlock.height()){
138      stickyTagsBlock.addClass('scrolled');
139    } else {
140      stickyTagsBlock.removeClass('scrolled');
141    }
142  }
143});
144
145/**
146 * Equal height lib
147 */
148
149function equal_height() {
150  if ($(window).width() > 576) {
151    $('.jQueryEqualHeight').jQueryEqualHeight('.media-main__item--title');
152  } else {
153    $('.media-main__item--title').css('height', 'auto');
154  }
155}
156
157 $(document).ajaxStop(function () {
158    const dispayProperty = $('#cookies-content')[0].style.display;
159    const isDisplayNone = dispayProperty === 'none' || !dispayProperty;
160
161    setTimeout(function () {
162      $(".loader-block").remove();
163      $('html').css('overflow-y', isDisplayNone ? 'auto' : 'hidden');
164      scrollToSection();
165  }, 750);
166});
167
168$(window).resize(function () {
169  equal_height();
170});
171
172$('.media-main__icon').click(function () {
173  $(this).toggleClass('open');
174  // $('.media-main__mobile-date-type-wr').toggleClass('open');
175  $('#media-dropdow').toggleClass('open');
176  $('#media-date').toggleClass('open');
177});
178
179/**
180 * Equal height lib
181 */
182
183/**
184 * Dropdown on the main media page
185 */
186
187function handleMediaMainDropdown() {
188  const media = '.media-main__drop-down';
189
190  $(media).each(function() {
191    const dropdown = $(this).find(`${media}--selected`);
192    const span = $(dropdown).find('span');
193    const ul = $(this).find('.options ul');
194    const li = $(ul).find('li');
195    const first = $(li).first();
196
197    $(dropdown).on('keydown', function (event) {
198      if (event.key === 'Enter') {
199        $(ul).show();
200      }
201
202      if (event.key === 'Escape') {
203        $(ul).hide();
204        setTimeout(() => {
205          $(this).focus();
206        })
207      }
208    });
209
210    $(span).on('click', function(event) {
211      $(`${media} ul`).not(ul).hide();
212      $(ul).toggle();
213      event.stopPropagation();
214    });
215
216    $(li).on('click', function() {
217      $(span).html($(this).html());
218      $(span).attr('data-value', $(this).data('value'));
219      $(ul).hide();
220    })
221
222    $(li).on('keydown', function (event) {
223      if (event.key === 'Enter') {
224        $(this).trigger('click');
225        $(dropdown).focus();
226      }
227
228      if (event.key === 'Escape') {
229        $(ul).hide();
230        setTimeout(() => {
231          $(dropdown).focus();
232        },0)
233      }
234
235      if (event.key === 'Tab' && !event.shiftKey) {
236        if (!event.target.nextElementSibling) {
237          $(first).focus();
238          event.preventDefault();
239        }
240      }
241    });
242  })
243}
244
245handleMediaMainDropdown();
246
247function setDatePickerAccessibility(picker, wrapper) {
248  const dprCalendarLeft = '.drp-calendar.left';
249  const dprCalendarRight = '.drp-calendar.right';
250  let isDropdownFocus = false;
251
252  $(picker.container).on('click', function() {
253    const isTabIndex = $(this).find('[tabindex]').length;
254
255    isDropdownFocus = false;
256
257    if (!isTabIndex) {
258      setDayNavigation();
259    }
260  })
261
262  $(picker.container).on('keydown', function(event) {
263    const isAvailable = $(event.target).hasClass('available');
264
265    if (event.key === 'Enter' && isAvailable) {
266      picker.clickDate(event);
267      setDayNavigation();
268      $('td.active').focus();
269    }
270
271    if (event.key === 'Enter' && $(event.target).hasClass('btn')) {
272      setTimeout(() => {
273        $(wrapper).focus();
274      }, 0)
275    }
276
277    if (event.key === 'ArrowLeft' && isAvailable) {
278      handleArrowNavigation(event.target, 'left');
279    }
280
281    if (event.key === 'ArrowRight' && isAvailable) {
282      handleArrowNavigation(event.target, 'right');
283    }
284
285    if (event.key === 'ArrowUp' && isAvailable) {
286      handleArrowNavigation(event.target, 'up');
287      event.preventDefault();
288    }
289
290    if (event.key === 'ArrowDown' && isAvailable) {
291      handleArrowNavigation(event.target, 'down');
292      event.preventDefault();
293    }
294
295    if (event.key === 'Escape') {
296      picker.hide();
297      setTimeout(() => {
298        $(wrapper).focus();
299      },0)
300    }
301  });
302
303  $(dprCalendarLeft).on('change', function(event){
304    handleSelectChange(dprCalendarLeft, event, isDropdownFocus);
305  })
306
307  $(dprCalendarLeft).on('keydown', function() {
308    isDropdownFocus = true;
309  })
310
311  $(dprCalendarRight).on('change', function(event){
312    handleSelectChange(dprCalendarRight, event, isDropdownFocus);
313  })
314
315  $(dprCalendarRight).on('keydown', function() {
316    isDropdownFocus = true;
317  })
318
319  $(wrapper).on('keydown', function(event) {
320    if (event.key === 'Enter') {
321      picker.show(event);
322      setDayNavigation();
323      setTimeout(() => {
324        $('.drp-calendar.left .monthselect').focus();
325      },0);
326    }
327  })
328
329  function handleArrowNavigation(td, direction) {
330    const dataTable = td.getAttribute('data-title');
331    const side = td.getAttribute('data-calendar');
332    let row = dataTable.slice(1, 2);
333    let col = dataTable.slice(3);
334
335    switch (direction) {
336      case 'left':
337        col--;
338        break;
339      case 'right':
340        col++;
341        break;
342      case 'up':
343        row--;
344        break;
345      default:
346        row++;
347    }
348
349    const dataTitleValue = `r${row}c${col}`;
350    const newCell = [...document.querySelectorAll(`[data-title=${dataTitleValue}]`)]
351        .filter(item => item.getAttribute('data-calendar') === side)
352
353    if (newCell.length) {
354      newCell[0].focus();
355    }
356  }
357
358  function setDayNavigation() {
359    const dateCellsLeft = $('.drp-calendar.left tbody td.available:not(.off)');
360    const dateCellsRight = $('.drp-calendar.right tbody td.available:not(.off)');
361
362    $(dateCellsLeft).each(function() {
363      $(this).attr('tabindex', '0');
364      $(this).attr('data-calendar', 'left');
365    })
366
367    $(dateCellsRight).each(function() {
368      $(this).attr('tabindex', '0');
369      $(this).attr('data-calendar', 'right');
370    })
371  }
372
373  function handleSelectChange(calendar, event, isFocus) {
374    if ($(event.target).hasClass('monthselect') || $(event.target).hasClass('yearselect')) {
375      setDayNavigation();
376
377      if (isFocus) {
378        setTimeout(() => {
379          const cls = $(event.target).attr('class');
380          const select = `${calendar} .${cls}`
381
382          $(select).focus();
383          isDropdownFocus = false;
384        },0)
385      }
386    }
387  }
388}
389
390$(document).bind('click', function (e) {
391  var $clicked = $(e.target);
392  if (!$clicked.parents().hasClass('media-main__drop-down'))
393    $('.media-main__drop-down .options ul').hide();
394});
395
396/**
397 * Dropdown on the main media page
398 */
399
400/**
401 * Validation search page
402 */
403if ($('.search-main__input-wr').length) {
404  $('.search-main__input-wr').validate({
405    rules: {
406      search: {
407        minlength: 2,
408      },
409    },
410    messages: {
411      search: {
412        minlength: 'Пошуковий запит має містити більше ніж 2 символи',
413      },
414    },
415  });
416}
417
418/**
419 * Validation search page
420 */
421
422$('.search-main__input').on('keyup', function (e) {
423  var btnElement = $('.search-main__btn');
424  if (e.target.value.length >= 2) {
425    btnElement.css('color', '#000');
426  } else {
427    btnElement.css('color', '#777575');
428  }
429});
430
431$('.search-main__input').keypress(function (e) {
432  if (e.target.value.length >= 100) {
433    e.preventDefault();
434  }
435});
436
437function mobileCheck() {
438  var check = false;
439  (function (a) {
440    if (
441      /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(
442        a
443      ) ||
444      /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
444sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(
445        a.substr(0, 4)
446      )
447    ) {
448      $('.news-gallery-swiper-container-modal__btns-wr').addClass(
449        'news-gallery-swiper-container-modal__btns-mobile-wr'
450      );
451      check = true;
452    }
453  })(navigator.userAgent || navigator.vendor || window.opera);
454
455  return check;
456}
457
458function scrollToSection() {
459    const ids = ['main-priorities', 'main-gis', 'main-governance', 'main-report', 'structure-and-contacts', 'information-about-activity', 'useful-info', 'main - services', 'public-procurement'];
460  const pathname = window.location.pathname;
461  const findIds = ids.find(el => pathname.indexOf(el) > -1);
462  ids.forEach((el) => {
463      if (el === findIds) {
464        $('html, body').animate({
465          scrollTop: $(`${'#' + el}`).offset().top
466      }, 100)}
467  });
468}
469
470mobileCheck();
471
472if ($(window).width() <= 576) {
473  $('.leaders-main__leader--name').each(function () {
474    $(this).removeAttr('href');
475  });
476  $('.leaders-main__head-name').removeAttr('href');
477}
478
479if ($(window).width() < 992) {
480  $('body').css('overflow-x', 'hidden');
481}
482
483$(document).ready(function () {
484  if ($('#mediaType').text() !== 'Полтавська обласна військова адміністрація') {
485    $('.media-main__icon').addClass('applied');
486  }
487});
488
489if ($('.daterangepicker').length) {
490  var datepickerNode = document.querySelector('.daterangepicker');
491  var datepickerNodeObserverOptions = {
492    childList: true,
493    attributes: true,
494    subtree: true,
495  };
496
497  function removeDateAttr() {
498    $('.off').each(function () {
499      if ($(this).hasClass('off')) {
500        $(this).attr('data-title', null);
501      }
502    });
503  }
504
505  var datepickerObserver = new MutationObserver(removeDateAttr);
506  datepickerObserver.observe(datepickerNode, datepickerNodeObserverOptions);
507}
508
509$(document).ready(function () {
510  $(".backdrop").show();
511
512  if ($('.news-main-content__title-content--search-rss-wr')[0]) {
513    if ($(window).width() >= 992) {
514      $('.news-main-aside').css(
515        'padding-top',
516        66 + $('.news-main-content__title-content--search-tag-title').height()
517      );
518    }
519  }
520
521  if ($('.news-main-aside.sticky-block') && window.screen.width >= 520) {
522    setTimeout(() => {
523      $('.news-main-aside.sticky-block').parent().css('min-height',$('.news-main-aside.sticky-block').height());
524    }, 750);
525  }
526});

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.