PageSourceSearch

https://sembarang.com/wp/wp-content/themes/grayzone/js/scripts.js?ver=6.6.9

js sembarang.com collected 2026-10-02 00:33:08 UTC 7,035 bytes, 258 lines download raw bytes

1/*
2	scripts.js
3	
4	License: GNU General Public License v3.0
5	License URI: http://www.gnu.org/licenses/gpl-3.0.html
6	
7	Copyright: (c) 2013 Alexander "Alx" Agnarson, http://alx.media
8*/
9
10"use strict";
11
12jQuery(document).ready(function($) {
13
14/*  Toggle header search
15/* ------------------------------------ */
16	$('.toggle-search').on('click', function() {
17		$('.toggle-search').toggleClass('active');
18		$('.search-expand').fadeToggle(250);
19            setTimeout(function(){
20                $('.search-expand input').focus();
21            }, 300);
22	});
23
24/*  Scroll to top
25/* ------------------------------------ */
26	$('a#back-to-top').on('click', function() {
27		$('html, body').animate({scrollTop:0},'slow');
28		return false;
29	});
30	
31/*  Tabs widget
32/* ------------------------------------ */	
33	(function() {
34		var $tabsNav       = $('.alx-tabs-nav'),
35			$tabsNavLis    = $tabsNav.children('li'),
36			$tabsContainer = $('.alx-tabs-container');
37
38		$tabsNav.each(function() {
39			var $this = $(this);
40			$this.next().children('.alx-tab').stop(true,true).hide()
41			.siblings( $this.find('a').attr('href') ).show();
42			$this.children('li').first().addClass('active').stop(true,true).show();
43		});
44
45		$tabsNavLis.on('click', function(e) {
46			var $this = $(this);
47
48			$this.siblings().removeClass('active').end()
49			.addClass('active');
50			
51			$this.parent().next().children('.alx-tab').stop(true,true).hide()
52			.siblings( $this.find('a').attr('href') ).fadeIn();
53			e.preventDefault();
54		}).children( window.location.hash ? 'a[href="' + window.location.hash + '"]' : 'a:first' ).trigger('click');
55
56	})();
57	
58/*  Comments / pingbacks tabs
59/* ------------------------------------ */	
60	$('.comment-tabs li').on('click', function() {
61		$('.comment-tabs li').removeClass('active');
62		$(this).addClass('active');
63		$('.comment-tab').hide();
64		var selected_tab = $(this).find('a').attr('href');
65		$(selected_tab).fadeIn();
66		return false;
67	});
68
69/*  Table odd row class
70/* ------------------------------------ */
71	$('table tr:odd').addClass('alt');
72
73/*  Fitvids
74/* ------------------------------------ */
75	function responsiveVideo() {
76			if ( $().fitVids ) {
77				$('#wrapper').fitVids();
78			}	
79		}
80		
81	responsiveVideo();
82	
83/*  Header Sticky
84/* ------------------------------------ */	
85	$('.logged-out #header-sticky').stickThis({
86		top:            0,
87		minscreenwidth: 1081,
88		maxscreenwidth: 999999,
89		zindex:         99,
90		debugmode:      false,
91		pushup:         ''
92	});
93	
94	$('.admin-bar #header-sticky').stickThis({
95		top:            32,
96		minscreenwidth: 1081,
97		maxscreenwidth: 999999,
98		zindex:         99,
99		debugmode:      false,
100		pushup:         ''
101	});
102
103/*  Jetpack infinite scroll
104/* ------------------------------------ */
105	var infiniteCount = 2;
106	$( document.body ).on( 'post-load', function () {
107		var elements = $('.infinite-wrap.infinite-view-' + infiniteCount + ' article');		
108		
109		$('#masonry').imagesLoaded().done( function(){
110			$('#masonry').masonry( 'appended', elements );
111			infiniteCount++;
112		});
113	});
114	
115/*  Hide on scroll down
116/* ------------------------------------ */
117	var scrollTimeOut = true,
118		lastYPos = 0,
119		yPos = 0,
120		yPosDelta = 5,
121		nav = $('.hide-on-scroll-down'),
122		navHeight = nav.outerHeight(),
123		setNavClass = function() {
124			scrollTimeOut = false;
125			yPos = $(window).scrollTop();
126
127			if(Math.abs(lastYPos - yPos) >= yPosDelta) {
128				if (yPos > lastYPos && yPos > navHeight){
129					nav.addClass('hide-scroll');
130				} else {
131					nav.removeClass('hide-scroll');
132				}
133				lastYPos = yPos;
134			}
135		};
136
137	$(window).scroll(function(e){
138		scrollTimeOut = true;
139	});
140
141	setInterval(function() {
142		if (scrollTimeOut) {
143			setNavClass();
144		}
145
146	}, 250);
147
148/*  Slick featured posts
149/* ------------------------------------ */
150	$.fn.randomize = function (selector) {
151		var $elems = selector ? $(this).find(selector) : $(this).children(),
152			$parents = $elems.parent();
153
154		$parents.each(function () {
155			$(this).children(selector).sort(function (childA, childB) {
156				// * Prevent last slide from being reordered
157				if($(childB).index() !== $(this).children(selector).length - 0.5) {
158					return Math.round(Math.random()) - 0.5;
159				}
160			}.bind(this)).detach().appendTo(this);
161		});
162
163		return this;
164	};
165
166	$(".slick-featured").randomize().slick({
167	  centerMode: true,
168	  centerPadding: '0',
169	  slidesToShow: 1,
170	  appendArrows: '.slick-featured-nav',
171	  dots: true,
172	  responsive: [
173		 {
174		  breakpoint: 1280,
175		  settings: {
176			arrows: true,
177			centerMode: true,
178			centerPadding: '0',
179			slidesToShow: 1
180		  }
181		},
182		{
183		  breakpoint: 1024,
184		  settings: {
185			arrows: true,
186			centerMode: true,
187			centerPadding: '0',
188			slidesToShow: 1
189		  }
190		},
191		{
192		  breakpoint: 768,
193		  settings: {
194			arrows: true,
195			centerMode: true,
196			centerPadding: '0',
197			slidesToShow: 1
198		  }
199		},
200		{
201		  breakpoint: 480,
202		  settings: {
203			arrows: true,
204			centerMode: true,
205			centerPadding: '0',
206			slidesToShow: 1
207		  }
208		}
209	  ]
210	});
211	$('.slick-featured-wrap-outer').show();	
212
213/*  Slick image slide
214/* ------------------------------------ */	
215	$('.slick-image-slide').each( function() {
216        $( this ).slick( {
217            dots: false,
218			adaptiveHeight: true,
219            appendArrows: $(this).parents('.slick-image-slide-wrapper').find('.slick-image-slide-nav'),
220			appendDots: $(this).parents('.slick-image-slide-wrapper').find('.slick-image-slide-dots')
221        } );
222    } );
223
224/*  Trap focus
225/* ------------------------------------ */	
226	// add all the elements inside modal which you want to make focusable
227	const  focusableElements =
228		'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
229	const modal = document.querySelector('.search-trap-focus'); // select the modal by it's id
230
231	if ( modal ) { 
232		const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
233		const focusableContent = modal.querySelectorAll(focusableElements);
234		const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
235
236
237		document.addEventListener('keydown', function(e) {
238		  let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
239
240		  if (!isTabPressed) {
241			return;
242		  }
243
244		  if (e.shiftKey) { // if shift key pressed for shift + tab combination
245			if (document.activeElement === firstFocusableElement) {
246			  lastFocusableElement.focus(); // add focus for the last focusable element
247			  e.preventDefault();
248			}
249		  } else { // if tab key is pressed
250			if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab
251			  firstFocusableElement.focus();
251 // add focus for the first focusable element
252			  e.preventDefault();
253			}
254		  }
255		});	
256	}
257	
258});

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.