PageSourceSearch

https://cmcuitegi.pb.gov.br/wp-content/themes/magazinenp/assets/js/magazinenp.js?ver=1.2.7

js cmcuitegi.pb.gov.br collected 2026-10-03 18:18:55 UTC 9,222 bytes, 320 lines download raw bytes

1jQuery(function ($) {
2	var magazineNPLastFocusableEl;
3
4	var magazineNPJs = {
5
6		init: function () {
7			this.initEvents();
8			this.iniNav();
9			this.initSearch();
10			this.initGoToTop();
11			this.initTicker();
12			this.matchHeight();
13			this.initSlider();
14			this.initSticky();
15			this.initStickyMenu();
16			this.initAccessibility();
17			this.keyPressInit();
18		},
19		initEvents: function () {
20
21			var _this = this;
22			$(document).on('magazinenp_focus_inside_element', function (event, parent_id, focusable_el, trap_class) {
23				$('#' + parent_id).find(focusable_el).focus();
24				var el = document.getElementById(parent_id);
25				_this.trapFocus(el, trap_class);
26
27			});
28		},
29		iniNav: function () {
30
31
32			$('.mnp-top-header-nav-menu-toggle').on('click', function () {
33				$('.mnp-top-header .mnp-top-header-nav').toggleClass('toggled-link-on');
34			});
35			$('.main-navigation').find('.sub-menu, .children').before('<span class="dropdown-toggle"><button class="dropdown-icon"></button></span>');
36			$('.main-navigation').find('.sub-menu, .children').parent().addClass('dropdown-parent');
37			$('.main-navigation').find('.dropdown-toggle').on('click', function (e) {
38				e.preventDefault();
39				$(this).next('.sub-menu, .children').toggleClass('dropdown-active');
40				$(this).toggleClass('toggle-on');
41			});
42			$(window).on('load resize', function () {
43				var screenwidth = $(window).outerWidth();
44				if (screenwidth >= 992) {
45					$('.main-navigation').find('.sub-menu.dropdown-active, .children.dropdown-active').removeClass('dropdown-active');
46					$('.main-navigation').find('.dropdown-toggle.toggle-on').removeClass('toggle-on');
47				}
48			});
49			$('#navbarCollapse').on('shown.bs.collapse', function () {
50				var mnp_navbar_id = 'navbarCollapse';
51				$('#' + mnp_navbar_id).addClass('mnp-navbar-open');
52				$('#' + mnp_navbar_id).find('a').eq(0).focus();
53				$(document).trigger('magazinenp_focus_inside_element', [mnp_navbar_id, '#navbarCollapse a:first-child', 'show']);
54
55
56			});
57
58			$('.navbar-toggler.menu-toggle').on('click', function () {
59				var expanded = $(this).attr('aria-expanded');
60				if (expanded === 'true') {
61					if ($('.mnp-bottom-header').length > 0) {
62						if ($('#masthead.site-header').find('#sticky-wrapper').length > 0) {
63							var bottom_header_height = $('.mnp-bottom-header .navigation-bar-top').height();
64							$('#masthead.site-header').find('#sticky-wrapper').css({
65								'height': bottom_header_height + 'px'
66							});
67						}
68					}
69				}
70			});
71
72		},
73		initSearch: function () {
74			$('.search-toggle').on('click', function (event) {
75				var parentEvent = event;
76				var this_toggle = $(this);
77				var that = $('.search-toggle'),
78					wrapper = $('.search-block');
79
80				that.toggleClass('active');
81				wrapper.toggleClass('off').toggleClass('on');
82				$('.search-block.on').fadeIn('slow', function () {
83					if (this_toggle.hasClass('active')) {
84						if (that.is('.active') || $('.search-toggle')[0] === parentEvent.target) {
85							wrapper.find('.s').focus();
86						}
87						var mnp_search_box_id = 'magazinenp-search-block';
88						$('#' + mnp_search_box_id).addClass('magazinenp-searchbox-open');
89						$(document).trigger('magazinenp_focus_inside_element', [mnp_search_box_id, '#magazinenp-search-block input.form-control.s', 'on']);
90					}
91				});
92				$('.search-block.off').fadeOut();
93
94
95				// search form escape while pressing ESC key
96				$(document).on('keydown', function (e) {
97					if (e.keyCode === 27 && that.hasClass('active')) {
98						that.removeClass('active');
99						wrapper.addClass('off').removeClass('on');
100						$('.search-block.off').fadeOut();
101						this_toggle.focus();
102					}
103				});
104
105
106			});
107
108
109		},
110		initGoToTop: function () {
111			$('.back-to-top').hide();
112			$(window).scroll(function () {
113				if ($(this).scrollTop() > 1000) {
114					$('.back-to-top').fadeIn();
115				} else {
116					$('.back-to-top').fadeOut();
117				}
118			});
119
120			// scroll body to 0px on click
121			$('.back-to-top a').on('click', function () {
122				$('body,html,header').animate({
123					scrollTop: 0
124				}, 800);
125				return false;
126			});
127		},
128		initTicker: function () {
129			if ($('.mnp-news-ticker-slide').length < 1) {
130				return;
131			}
132			let direction = magazinenp_script.ticker_direction === "right" ? "right" : "left";
133			$('.mnp-news-ticker-slide').marquee({
134				//speed in milliseconds of the marquee
135				speed: 50,
136				//gap in pixels between the tickers
137				gap: 0,
138				//time in milliseconds before the marquee will start animating
139				delayBeforeStart: 0,
140				//'left' or 'right'
141				direction: direction,
142				//true or false - should the marquee be duplicated to show an effect of continues flow
143				duplicated: true,
144				pauseOnHover: true,
145				startVisible: true
146			});
147		},
148		matchHeight: function () {
149			if ($('.featured-section .title-wrap').length < 1) {
150				return;
151			}
152			$('.featured-section .title-wrap').matchHeight({
153				property: 'min-height'
154			});
155		},
156		initSlider: function () {
157			if ($('.owl-carousel').length < 1) {
158				return;
159			}
160			$('.owl-carousel.mnp-owl-before').find('.item').removeClass('col-sm-6 col-lg-3');
161			$('.owl-carousel.mnp-owl-before').removeClass('mnp-owl-before');
162			$('.featured-slider .owl-carousel').owlCarousel({
163				loop: true,
164				margin: 0,
165				nav: true,
166				navText: ['', ''],
167				autoplay: true,
168				dots: false,
169				smartSpeed: 800,
170				autoHeight: true,
171				autoplayTimeout: 5500,
172				responsive: {
173					0: {
174						items: 1
175					}
176				}
177			});
178
179			$('.related-posts .owl-carousel').owlCarousel({
180				loop: true,
181				margin: 15,
182				nav: true,
183				navText: ['', ''],
184				autoplay: true,
185				dots: false,
186				smartSpeed: 800,
187				autoHeight: true,
188				autoplayTimeout: 5500,
189				responsive: {
190					0: {
191						items: 1
192					},
193					480: {
194						items: 1
195					},
196					768: {
197						items: 2
198					},
199					992: {
200						items: 4
201					}
202				}
203			});
204		},
205		initSticky: function () {
206
207			$(window).load(function () {
208				if ($('.sticky-sidebar').length < 1) {
209					return;
210				}
211				var after_height = 0;
212
213				var site_content_row = $('.site-content-row')[0],
214					wp_adminBar = $('#wpadminbar').outerHeight(),
215					doc_width = $(window).outerWidth(),
216					top_spacing = 20 + wp_adminBar;
217
218				if (site_content_row) {
219					var page_height = $('body.theme-body').outerHeight(),
220						page_before_height = $('body.theme-body').offset().top,
221						total_page_height = page_height + page_before_height,
222						before_content_height = $('.site-content-row').offset().top,
223						content_height = $('.site-content-row').outerHeight();
224					after_height = total_page_height - before_content_height - content_height;
225				}
226
227				if (doc_width >= 992) {
228					if (wp_adminBar) {
229						$('.sticky-sidebar').MNPsticky({topSpacing: top_spacing, bottomSpacing: after_height});
230					} else {
231						$('.sticky-sidebar').MNPsticky({topSpacing: 20, bottomSpacing: after_height});
232					}
233				}
234			});
235		},
236		initStickyMenu: function () {
237			$(window).load(function () {
238
239				var wpAdminBar = jQuery('#wpadminbar');
240				if (wpAdminBar.length) {
241					var doc_width = $(document).width();
242					if (doc_width < 601) {
243						$('.mnp-bottom-header.mnp-sticky').MNPsticky({
244							topSpacing: 0,
245							zIndex: 99
246						});
247					} else {
248						$('.mnp-bottom-header.mnp-sticky').MNPsticky({
249							topSpacing: wpAdminBar.height(),
250							zIndex: 99
251						});
252					}
253				} else {
254					$('.mnp-bottom-header.mnp-sticky').MNPsticky({
255						topSpacing: 0,
256						zIndex: 99
257					});
258				}
259			});
260		},
261		initAccessibility: function () {
262			var main_menu_container = $('.main-navigation ul.nav-menu');
263			main_menu_container.find('li.menu-item, li.page_item').focusin(function () {
264				if (!$(this).hasClass('focus')) {
265					$(this).addClass('focus');
266				}
267			});
268			main_menu_container.find('li.menu-item, li.page_item').focusout(function () {
269				$(this).removeClass('focus');
270
271			});
272		},
273		trapFocus: function (element, open_class) {
274			var focusableEls = element.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="search"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])'),
275				firstFocusableEl = focusableEls[0];
276			magazineNPLastFocusableEl = focusableEls[focusableEls.length - 1];
277			var KEYCODE_TAB = 9;
278			element.addEventListener('keydown', function (e) {
279				var isTabPressed = (e.key === 'Tab' || e.keyCode === KEYCODE_TAB);
280
281				if (!isTabPressed) {
282					return;
283				}
284				if (!element.classList.contains(open_class)) {
285					element.removeEventListener('keydown', this);
286					return;
287
288				}
289
290				if (e.shiftKey) /* shift + tab */ {
291					if (document.activeElement === firstFocusableEl) {
292						magazineNPLastFocusableEl.focus();
293						e.preventDefault();
294					}
295				} else /* tab */ {
296
297					if (document.activeElement === magazineNPLastFocusableEl) {
298						firstFocusableEl.focus();
299						e.preventDefault();
300					}
301				}
302
303			});
304		},
305		keyPressInit: function () {
306			$(document).keydown(function (e) {
307				var key_code = e.keyCode || e.which;
308				if (key_code === 27) {
309					$('button.navbar-toggler.menu-toggle:not(.collapsed)').trigger('click').focus();
310				}
311			});
312		}
313
314
315	};
316
317
318	magazineNPJs.init();
319
320});

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.