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/* Slick image slide 84/* ------------------------------------ */ 85 $('.slick-image-slide').each( function() { 86 $( this ).slick( { 87 dots: true, 88 adaptiveHeight: true, 89 appendArrows: $(this).parents('.slick-image-slide-wrapper').find('.slick-image-slide-nav'), 90 appendDots: $(this).parents('.slick-image-slide-wrapper').find('.slick-image-slide-dots') 91 } ); 92 } ); 93 94/* Move sidebar 95/* ------------------------------------ */ 96 $(window).on('load resize',function(){ 97 if ($(window).width() < 960) { 98 $(".sidebar.s1").appendTo("#move-sidebar-content"); 99 } 100 else { 101 $(".sidebar.s1").appendTo("#move-sidebar-header"); 102 } 103 }); 104 105/* Trap focus 106/* ------------------------------------ */ 107 // add all the elements inside modal which you want to make focusable 108 const focusableElements = 109 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'; 110 const modal = document.querySelector('.search-trap-focus'); // select the modal by it's id 111 112 if ( modal ) { 113 const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal 114 const focusableContent = modal.querySelectorAll(focusableElements); 115 const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal 116 117 118 document.addEventListener('keydown', function(e) { 119 let isTabPressed = e.key === 'Tab' || e.keyCode === 9; 120 121 if (!isTabPressed) { 122 return; 123 } 124 125 if (e.shiftKey) { // if shift key pressed for shift + tab combination 126 if (document.activeElement === firstFocusableElement) { 127 lastFocusableElement.focus();
127 // add focus for the last focusable element 128 e.preventDefault(); 129 } 130 } else { // if tab key is pressed 131 if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab 132 firstFocusableElement.focus(); // add focus for the first focusable element 133 e.preventDefault(); 134 } 135 } 136 }); 137 } 138 139});
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.