PageSourceSearch

https://www.azimiao.com/wp-content/themes/typeflow-azimiao/js/scripts.js?ver=6.8.11

js azimiao.com collected 2026-10-08 13:13:45 UTC 4,495 bytes, 148 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) 2024 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/*  Parallax single post featured image
32/* ------------------------------------ */		
33	$(window).scroll(function () {
34		$(".main-header-single").css("background-position","center " + ($(this).scrollTop() / 20 + 50) + "%");
35	});	
36	
37	$(window).scroll(function() {
38		var scroll = $(window).scrollTop();
39		if (scroll >= 60) {
40			$('body').addClass("header-scrolled");
41		} else {
42			$('body').removeClass("header-scrolled");
43		}
44	});
45	
46/*  Tabs widget
47/* ------------------------------------ */	
48	(function() {
49		var $tabsNav       = $('.alx-tabs-nav'),
50			$tabsNavLis    = $tabsNav.children('li'),
51			$tabsContainer = $('.alx-tabs-container');
52
53		$tabsNav.each(function() {
54			var $this = $(this);
55			$this.next().children('.alx-tab').stop(true,true).hide()
56			.siblings( $this.find('a').attr('href') ).show();
57			$this.children('li').first().addClass('active').stop(true,true).show();
58		});
59
60		$tabsNavLis.on('click', function(e) {
61			var $this = $(this);
62
63			$this.siblings().removeClass('active').end()
64			.addClass('active');
65			
66			$this.parent().next().children('.alx-tab').stop(true,true).hide()
67			.siblings( $this.find('a').attr('href') ).fadeIn();
68			e.preventDefault();
69		}).children( window.location.hash ? 'a[href="' + window.location.hash + '"]' : 'a:first' ).trigger('click');
70
71	})();
72	
73/*  Slick featured posts
74/* ------------------------------------ */
75	$.fn.randomize = function (selector) {
76		var $elems = selector ? $(this).find(selector) : $(this).children(),
77			$parents = $elems.parent();
78
79		$parents.each(function () {
80			$(this).children(selector).sort(function (childA, childB) {
81				// * Prevent last slide from being reordered
82				if($(childB).index() !== $(this).children(selector).length - 0.5) {
83					return Math.round(Math.random()) - 0.5;
84				}
85			}.bind(this)).detach().appendTo(this);
86		});
87
88		return this;
89	};
90
91	// $(".slick-posts").randomize().slick({ // we dont need this
92	$(".slick-posts").slick({
93	  slidesToShow: 3,
94	  appendArrows: '.slick-posts-nav',
95	  dots: true,
96	  arrows: false,
97	  responsive: [
98	    {
99		  breakpoint: 920,
100		  settings: {
101			slidesToShow: 2
102		  }
103		},
104		{
105		  breakpoint: 620,
106		  settings: {
107			slidesToShow: 1
108		  }
109		}
110	  ]
111	});
112	$('.slick-posts').show();
113
114/*  Trap focus
115/* ------------------------------------ */	
116	// add all the elements inside modal which you want to make focusable
117	const  focusableElements =
118		'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
119	const modal = document.querySelector('.search-trap-focus'); // select the modal by it's id
120
121	if ( modal ) { 
122		const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
123		const focusableContent = modal.querySelectorAll(focusableElements);
124		const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
125
126
127		document.addEventListener('keydown', function(e) {
128		  let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
129
130		  if (!isTabPressed) {
131			return;
132		  }
133
134		  if (e.shiftKey) { // if shift key pressed for shift + tab combination
135			if (document.activeElement === firstFocusableElement) {
136			  lastFocusableElement.focus();
136 // add focus for the last focusable element
137			  e.preventDefault();
138			}
139		  } else { // if tab key is pressed
140			if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab
141			  firstFocusableElement.focus(); // add focus for the first focusable element
142			  e.preventDefault();
143			}
144		  }
145		});	
146	}
147	
148});

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.