mirror of
https://ghproxy.net/https://github.com/AlxMedia/halftype.git
synced 2025-08-26 10:56:19 +08:00
Initial commit
This commit is contained in:
commit
920eb77a74
356 changed files with 89194 additions and 0 deletions
5
js/jq-sticky-anything.min.js
vendored
Normal file
5
js/jq-sticky-anything.min.js
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* @preserve Sticky Anything 2.0.1 | @senff | GPL2 Licensed
|
||||
*/
|
||||
|
||||
!function(a){function b(b,c,d,e,f,g,h){$listenerElement=a(".sticky-element-active");var i=$listenerElement.offset();if(orgElementTop=i.top,f){var j=a(f).offset();pushElementTop=j.top}var k=window,l="inner";if("innerWidth"in window||(l="client",k=document.documentElement||document.body),viewport=k[l+"Width"],a(window).scrollTop()>=orgElementTop-b&&viewport>=c&&viewport<=d){coordsOrgElement=$listenerElement.offset(),leftOrgElement=coordsOrgElement.left,widthPlaceholder=$listenerElement[0].getBoundingClientRect().width,widthPlaceholder||(widthPlaceholder=$listenerElement.css("width")),heightPlaceholder=$listenerElement[0].getBoundingClientRect().height,heightPlaceholder||(heightPlaceholder=$listenerElement.css("height")),widthSticky=a(".sticky-element-original").css("width"),"0px"==widthSticky&&(widthSticky=a(".sticky-element-original")[0].getBoundingClientRect().width),heightSticky=a(".sticky-element-original").height(),paddingOrgElement=[a(".sticky-element-original").css("padding-top"),a(".sticky-element-original").css("padding-right"),a(".sticky-element-original").css("padding-bottom"),a(".sticky-element-original").css("padding-left")],paddingSticky=paddingOrgElement[0]+" "+paddingOrgElement[1]+" "+paddingOrgElement[2]+" "+paddingOrgElement[3],marginOrgElement=[$listenerElement.css("margin-top"),$listenerElement.css("margin-right"),$listenerElement.css("margin-bottom"),$listenerElement.css("margin-left")],marginPlaceholder=marginOrgElement[0]+" "+marginOrgElement[1]+" "+marginOrgElement[2]+" "+marginOrgElement[3],assignedStyles="";for(var m in g)"inline"==g[m]?assignedStyles+=m+":inline-block; ":assignedStyles+=m+":"+g[m]+"; ";elementHeight=0,heightPlaceholder<1?elementHeight=a(".sticky-element-cloned").outerHeight():elementHeight=a(".sticky-element-original").outerHeight(),f&&a(window).scrollTop()>pushElementTop-b-elementHeight?stickyTopMargin=pushElementTop-b-elementHeight-a(window).scrollTop():stickyTopMargin=0,assignedStyles+="width:"+widthPlaceholder+"px; height:"+heightPlaceholder+"px; margin:"+marginPlaceholder+";",a(".sticky-element-original").removeClass("sticky-element-not-sticky").addClass("sticky-element-sticky").removeClass("sticky-element-active").css("position","fixed").css("left",leftOrgElement+"px").css("top",b+"px").css("width",widthSticky).css("margin-left",0).css("padding",paddingSticky).css("margin-top",stickyTopMargin).css("z-index",e),a(".sticky-element-placeholder").hasClass("sticky-element-active")||a(".sticky-element-placeholder").addClass("sticky-element-active").attr("style",assignedStyles)}else a(".sticky-element-original").addClass("sticky-element-not-sticky").removeClass("sticky-element-sticky").addClass("sticky-element-active").attr("style",h),a(".sticky-element-placeholder").hasClass("sticky-element-active")&&a(".sticky-element-placeholder").removeClass("sticky-element-active").removeAttr("style").css("width","0").css("height","0").css("margin","0").css("padding","0")}function c(){a(".sticky-element-original").addClass("sticky-element-active").before('<div class="sticky-element-placeholder" style="width:0; height:0; margin:0; padding:0; visibility:hidden;"></div>')}function d(a){return o={},o.display=a.css("display"),o.float=a.css("float"),o.flex=a.css("flex"),o["box-sizing"]=a.css("box-sizing"),o.clear=a.css("clear"),o.overflow=a.css("overflow"),o.transform=a.css("transform"),o}a.fn.stickThis=function(e){var f=a.extend({top:0,minscreenwidth:0,maxscreenwidth:99999,zindex:1,debugmode:!1,pushup:""},e),g=a(this).length,h=a(f.pushup).length;return h<1?(1==f.debugmode&&f.pushup&&console.error('STICKY ANYTHING DEBUG: There are no elements with the selector/class/ID you selected for the Push-up element ("'+f.pushup+'").'),f.pushup=""):h>1&&(1==f.debugmode&&console.error("STICKY ANYTHING DEBUG: There are "+h+' elements on the page with the selector/class/ID you selected for the push-up element ("'+f.pushup+'"). You can select only ONE element to push the sticky element up.'),f.pushup=""),g<1?1==f.debugmode&&console.error('STICKY ANYTHING DEBUG: There are no elements with the selector/class/ID you selected for the sticky element ("'+this.selector+'").'):g>1?1==f.debugmode&&console.error("STICKY ANYTHING DEBUG: There There are "+h+' elements with the selector/class/ID you selected for the sticky element ("'+this.selector+'"). You can only make ONE element sticky.'):(a(this).addClass("sticky-element-original").addClass("sticky-element-not-sticky"),orgAssignedStyles=d(a(this)),orgInlineStyles=a(".sticky-element-original").attr("style"),null==orgInlineStyles&&(orgInlineStyles=""),c(),checkElement=setInterval(function(){b(f.top,f.minscreenwidth,f.maxscreenwidth,f.zindex,f.pushup,orgAssignedStyles,orgInlineStyles)},10)),this}}(jQuery);
|
82
js/jquery.fitvids.js
Normal file
82
js/jquery.fitvids.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*jshint browser:true */
|
||||
/*!
|
||||
* FitVids 1.1
|
||||
*
|
||||
* Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
|
||||
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
|
||||
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
|
||||
*
|
||||
*/
|
||||
|
||||
;(function( $ ){
|
||||
|
||||
'use strict';
|
||||
|
||||
$.fn.fitVids = function( options ) {
|
||||
var settings = {
|
||||
customSelector: null,
|
||||
ignore: null
|
||||
};
|
||||
|
||||
if(!document.getElementById('fit-vids-style')) {
|
||||
// appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
|
||||
var head = document.head || document.getElementsByTagName('head')[0];
|
||||
var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
|
||||
head.appendChild(div.childNodes[1]);
|
||||
}
|
||||
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
var selectors = [
|
||||
'iframe[src*="player.vimeo.com"]',
|
||||
'iframe[src*="youtube.com"]',
|
||||
'iframe[src*="youtube-nocookie.com"]',
|
||||
'iframe[src*="kickstarter.com"][src*="video.html"]',
|
||||
'object',
|
||||
'embed'
|
||||
];
|
||||
|
||||
if (settings.customSelector) {
|
||||
selectors.push(settings.customSelector);
|
||||
}
|
||||
|
||||
var ignoreList = '.fitvidsignore';
|
||||
|
||||
if(settings.ignore) {
|
||||
ignoreList = ignoreList + ', ' + settings.ignore;
|
||||
}
|
||||
|
||||
var $allVideos = $(this).find(selectors.join(','));
|
||||
$allVideos = $allVideos.not('object object'); // SwfObj conflict patch
|
||||
$allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
|
||||
|
||||
$allVideos.each(function(count){
|
||||
var $this = $(this);
|
||||
if($this.parents(ignoreList).length > 0) {
|
||||
return; // Disable FitVids on this video.
|
||||
}
|
||||
if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
|
||||
if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
|
||||
{
|
||||
$this.attr('height', 9);
|
||||
$this.attr('width', 16);
|
||||
}
|
||||
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
|
||||
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
|
||||
aspectRatio = height / width;
|
||||
if(!$this.attr('id')){
|
||||
var videoID = 'fitvid' + count;
|
||||
$this.attr('id', videoID);
|
||||
}
|
||||
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
|
||||
$this.removeAttr('height').removeAttr('width');
|
||||
});
|
||||
});
|
||||
};
|
||||
// Works with either jQuery or Zepto
|
||||
})( window.jQuery || window.Zepto );
|
319
js/nav.js
Normal file
319
js/nav.js
Normal file
|
@ -0,0 +1,319 @@
|
|||
/**
|
||||
* Polyfill for IE11 - adds NodeList.foreach().
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach
|
||||
*/
|
||||
if ( window.NodeList && ! NodeList.prototype.forEach ) {
|
||||
NodeList.prototype.forEach = function( callback, thisArg ) {
|
||||
thisArg = thisArg || window;
|
||||
for ( var i = 0; i < this.length; i++ ) { // eslint-disable-line vars-on-top
|
||||
callback.call( thisArg, this[ i ], i, this );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
window.alxMediaMenu = {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Object} args - The arguments.
|
||||
* @param {string} args.selector - The navigation selector.
|
||||
* @param {int} args.breakpoint - The breakpoint in pixels.
|
||||
*/
|
||||
init: function( args ) {
|
||||
var self = this,
|
||||
navs = document.querySelectorAll( args.selector );
|
||||
|
||||
if ( ! navs.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
navs.forEach( function( nav ) {
|
||||
var menuToggler = nav.querySelector( '.menu-toggle' );
|
||||
|
||||
// Hide menu toggle button if menu is empty and return early.
|
||||
if ( ! nav.querySelector( 'ul' ) && nav.querySelector( '.menu-toggle' ) ) {
|
||||
nav.querySelector( '.menu-toggle' ).style.display = 'none';
|
||||
}
|
||||
|
||||
// Add nav-menu class.
|
||||
if ( ! nav.classList.contains( 'nav-menu' ) ) {
|
||||
nav.classList.add( 'nav-menu' );
|
||||
}
|
||||
|
||||
// Toggle the hover event listeners.
|
||||
self.toggleHoverEventListeners( nav );
|
||||
|
||||
// Toggle focus classes on links.
|
||||
nav.querySelectorAll( 'a,button' ).forEach( function( link ) {
|
||||
link.addEventListener( 'focus', window.alxMediaMenu.toggleFocus, true );
|
||||
link.addEventListener( 'blur', window.alxMediaMenu.toggleFocus, true );
|
||||
});
|
||||
|
||||
menuToggler.addEventListener( 'click', function() {
|
||||
if ( nav.classList.contains( 'toggled' ) ) {
|
||||
menuToggler.setAttribute( 'aria-expanded', 'false' );
|
||||
nav.classList.remove( 'toggled' );
|
||||
} else {
|
||||
menuToggler.setAttribute( 'aria-expanded', 'true' );
|
||||
nav.classList.add( 'toggled' );
|
||||
}
|
||||
});
|
||||
|
||||
// If on mobile nav, close it when clicking outside.
|
||||
// If on desktop, close expanded submenus when clicking outside.
|
||||
document.addEventListener( 'click', function( event ) {
|
||||
if ( ! nav.contains( event.target ) ) {
|
||||
|
||||
// Mobile.
|
||||
nav.classList.remove( 'toggled' );
|
||||
|
||||
// Desktop.
|
||||
nav.querySelectorAll( 'button.active,.sub-menu.active' ).forEach( function( el ) {
|
||||
el.classList.remove( 'active' );
|
||||
});
|
||||
|
||||
menuToggler.setAttribute( 'aria-expanded', 'false' );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Toggle mobile classes on initial load.
|
||||
window.alxMediaMenu.toggleMobile( args.selector, args.breakpoint );
|
||||
|
||||
// Toggle mobile classes on resize.
|
||||
window.addEventListener( 'resize', function() {
|
||||
|
||||
// If timer is null, reset it to our bounceDelay and run, otherwise wait until timer is cleared.
|
||||
if ( ! window.resizeDebouncedTimeout ) {
|
||||
window.resizeDebouncedTimeout = setTimeout( function() {
|
||||
window.resizeDebouncedTimeout = null;
|
||||
window.alxMediaMenu.toggleMobile( args.selector, args.breakpoint );
|
||||
}, 250 );
|
||||
}
|
||||
});
|
||||
|
||||
// Toggle focus classes to allow submenu access on tables.
|
||||
document.querySelectorAll( args.selector ).forEach( function( el ) {
|
||||
window.alxMediaMenu.toggleFocusTouch( el );
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Expand a menu item.
|
||||
*
|
||||
* @param {Element} - The menu item (DOM element).
|
||||
* @return {void}
|
||||
*/
|
||||
toggleItem: function( el ) {
|
||||
var parentLi = this.helper.firstAncestorMatch( el, 'li' ),
|
||||
parentUl = this.helper.firstAncestorMatch( el, 'ul' ),
|
||||
ul = parentLi.querySelector( 'ul.sub-menu' );
|
||||
|
||||
parentLi.classList.remove( 'hover' );
|
||||
|
||||
ul.setAttribute( 'tabindex', '-1' );
|
||||
this.helper.toggleClass( ul, 'active' );
|
||||
this.helper.toggleClass( el, 'active' );
|
||||
|
||||
// Go one level up in the list, and close other items that are already open.
|
||||
parentUl.querySelectorAll( 'ul.sub-menu' ).forEach( function( subMenu ) {
|
||||
var subMenuButton;
|
||||
if ( ! parentLi.contains( subMenu ) ) {
|
||||
subMenu.classList.remove( 'active' );
|
||||
subMenuButton = subMenu.parentNode.querySelector( 'button.active' );
|
||||
if ( subMenuButton ) {
|
||||
subMenuButton.classList.remove( 'active' );
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles a mobile class to elements matching our selector,
|
||||
* depending on the defined breakpoint.
|
||||
*
|
||||
* @param {string} selector - The elements where we want to toggle our mobile class.
|
||||
* @param {string} className - The class-name we want to toggle.
|
||||
* @param {int} breakpoint - The breakpoint.
|
||||
* @return {void}
|
||||
*/
|
||||
toggleMobile: function( selector, breakpoint ) {
|
||||
var self = this,
|
||||
screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
|
||||
navs = document.body.querySelectorAll( selector ),
|
||||
isMobile;
|
||||
|
||||
breakpoint = breakpoint || 720;
|
||||
isMobile = breakpoint > screenWidth;
|
||||
|
||||
if ( isMobile ) {
|
||||
navs.forEach( function( nav ) {
|
||||
if ( ! nav.classList.contains( 'mobile' ) ) {
|
||||
nav.classList.add( 'mobile' );
|
||||
self.toggleHoverEventListeners( nav );
|
||||
}
|
||||
});
|
||||
} else {
|
||||
navs.forEach( function( nav ) {
|
||||
if ( nav.classList.contains( 'mobile' ) ) {
|
||||
nav.classList.remove( 'mobile' );
|
||||
self.toggleHoverEventListeners( nav );
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a "hover" class.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
liMouseEnterEvent: function() {
|
||||
this.classList.add( 'hover' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the "hover" class.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
liMouseLeaveEvent: function() {
|
||||
this.classList.remove( 'hover' );
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Element} nav - The nav element.
|
||||
* @return {void}
|
||||
*/
|
||||
toggleHoverEventListeners: function( nav ) {
|
||||
if ( nav.classList.contains( 'mobile' ) ) {
|
||||
this.removeHoverEventListeners( nav );
|
||||
} else {
|
||||
this.addHoverEventListeners( nav );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add event-listeners for hover events.
|
||||
*
|
||||
* @param {Element} nav - The nav element.
|
||||
* @return {void}
|
||||
*/
|
||||
addHoverEventListeners: function( nav ) {
|
||||
nav.querySelectorAll( 'li' ).forEach( function( li ) {
|
||||
li.addEventListener( 'mouseenter', window.alxMediaMenu.liMouseEnterEvent );
|
||||
li.addEventListener( 'mouseleave', window.alxMediaMenu.liMouseLeaveEvent );
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove event-listeners for hover events.
|
||||
*
|
||||
* @param {Element} nav - The nav element.
|
||||
* @return {void}
|
||||
*/
|
||||
removeHoverEventListeners: function( nav ) {
|
||||
nav.querySelectorAll( 'li' ).forEach( function( li ) {
|
||||
li.removeEventListener( 'mouseenter', window.alxMediaMenu.liMouseEnterEvent );
|
||||
li.removeEventListener( 'mouseleave', window.alxMediaMenu.liMouseLeaveEvent );
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets or removes .focus class on an element.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
toggleFocus: function() {
|
||||
var self = this;
|
||||
|
||||
// Move up through the ancestors of the current link until we hit .nav-menu.
|
||||
while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
|
||||
// On li elements toggle the class .focus.
|
||||
if ( 'li' === self.tagName.toLowerCase() ) {
|
||||
if ( -1 !== self.className.indexOf( 'focus' ) ) {
|
||||
self.className = self.className.replace( ' focus', '' );
|
||||
} else {
|
||||
self.className += ' focus';
|
||||
}
|
||||
}
|
||||
|
||||
self = self.parentElement;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle focus classes to allow submenu access on tables.
|
||||
*
|
||||
* @param {Element} el - The menu element.
|
||||
* @return {void}
|
||||
*/
|
||||
toggleFocusTouch: function( el ) {
|
||||
var touchStartFn,
|
||||
parentLinks = el.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
|
||||
|
||||
if ( 'ontouchstart' in window ) {
|
||||
touchStartFn = function( e ) {
|
||||
var menuItem = this.parentNode;
|
||||
|
||||
if ( ! menuItem.classList.contains( 'focus' ) ) {
|
||||
e.preventDefault();
|
||||
menuItem.parentNode.children.forEach( function( child ) {
|
||||
if ( menuItem !== child ) {
|
||||
child.classList.remove( 'focus' );
|
||||
}
|
||||
});
|
||||
menuItem.classList.add( 'focus' );
|
||||
} else {
|
||||
menuItem.classList.remove( 'focus' );
|
||||
}
|
||||
};
|
||||
|
||||
parentLinks.forEach( function( parentLink ) {
|
||||
parentLink.addEventListener( 'touchstart', touchStartFn, false );
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper methods.
|
||||
*/
|
||||
helper: {
|
||||
|
||||
/**
|
||||
* Toggle a class to an element.
|
||||
*
|
||||
* @param {Element} el - The element.
|
||||
* @param {string} className - The class we want to toggle.
|
||||
* @return {void}
|
||||
*/
|
||||
toggleClass: function( el, className ) {
|
||||
if ( el.classList.contains( className ) ) {
|
||||
el.classList.remove( className );
|
||||
} else {
|
||||
el.classList.add( className );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the 1st ancestor of an element that matches our selector.
|
||||
*
|
||||
* @param {Element} el - The element.
|
||||
* @param {string} selector - The class we want to toggle.
|
||||
* @return {Element}
|
||||
*/
|
||||
firstAncestorMatch: function( el, selector ) {
|
||||
if ( el.parentNode.matches( selector ) ) {
|
||||
return el.parentNode;
|
||||
}
|
||||
return this.firstAncestorMatch( el.parentNode, selector );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.alxMediaMenu.init({
|
||||
selector: '.main-navigation.nav-menu',
|
||||
breakpoint: 720
|
||||
});
|
246
js/scripts.js
Normal file
246
js/scripts.js
Normal file
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
scripts.js
|
||||
|
||||
License: GNU General Public License v3.0
|
||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Copyright: (c) 2013 Alexander "Alx" Agnarson, http://alx.media
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
/* Toggle header search
|
||||
/* ------------------------------------ */
|
||||
$('.toggle-search').on('click', function() {
|
||||
$('.toggle-search').toggleClass('active');
|
||||
$('.search-expand').fadeToggle(250);
|
||||
setTimeout(function(){
|
||||
$('.search-expand input').focus();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
/* Scroll to top
|
||||
/* ------------------------------------ */
|
||||
$('a#back-to-top').on('click', function() {
|
||||
$('html, body').animate({scrollTop:0},'slow');
|
||||
return false;
|
||||
});
|
||||
|
||||
/* Tabs widget
|
||||
/* ------------------------------------ */
|
||||
(function() {
|
||||
var $tabsNav = $('.alx-tabs-nav'),
|
||||
$tabsNavLis = $tabsNav.children('li'),
|
||||
$tabsContainer = $('.alx-tabs-container');
|
||||
|
||||
$tabsNav.each(function() {
|
||||
var $this = $(this);
|
||||
$this.next().children('.alx-tab').stop(true,true).hide()
|
||||
.siblings( $this.find('a').attr('href') ).show();
|
||||
$this.children('li').first().addClass('active').stop(true,true).show();
|
||||
});
|
||||
|
||||
$tabsNavLis.on('click', function(e) {
|
||||
var $this = $(this);
|
||||
|
||||
$this.siblings().removeClass('active').end()
|
||||
.addClass('active');
|
||||
|
||||
$this.parent().next().children('.alx-tab').stop(true,true).hide()
|
||||
.siblings( $this.find('a').attr('href') ).fadeIn();
|
||||
e.preventDefault();
|
||||
}).children( window.location.hash ? 'a[href="' + window.location.hash + '"]' : 'a:first' ).trigger('click');
|
||||
|
||||
})();
|
||||
|
||||
/* Comments / pingbacks tabs
|
||||
/* ------------------------------------ */
|
||||
$('.comment-tabs li').on('click', function() {
|
||||
$('.comment-tabs li').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
$('.comment-tab').hide();
|
||||
var selected_tab = $(this).find('a').attr('href');
|
||||
$(selected_tab).fadeIn();
|
||||
return false;
|
||||
});
|
||||
|
||||
/* Table odd row class
|
||||
/* ------------------------------------ */
|
||||
$('table tr:odd').addClass('alt');
|
||||
|
||||
/* Fitvids
|
||||
/* ------------------------------------ */
|
||||
function responsiveVideo() {
|
||||
if ( $().fitVids ) {
|
||||
$('#wrapper').fitVids();
|
||||
}
|
||||
}
|
||||
|
||||
responsiveVideo();
|
||||
|
||||
/* Header Sticky
|
||||
/* ------------------------------------ */
|
||||
$('.logged-out #header-sticky').stickThis({
|
||||
top: 0,
|
||||
minscreenwidth: 1025,
|
||||
maxscreenwidth: 999999,
|
||||
zindex: 99,
|
||||
debugmode: false,
|
||||
pushup: ''
|
||||
});
|
||||
|
||||
$('.admin-bar #header-sticky').stickThis({
|
||||
top: 32,
|
||||
minscreenwidth: 1025,
|
||||
maxscreenwidth: 999999,
|
||||
zindex: 99,
|
||||
debugmode: false,
|
||||
pushup: ''
|
||||
});
|
||||
|
||||
/* Hide on scroll down
|
||||
/* ------------------------------------ */
|
||||
var scrollTimeOut = true,
|
||||
lastYPos = 0,
|
||||
yPos = 0,
|
||||
yPosDelta = 5,
|
||||
nav = $('.hide-on-scroll-down'),
|
||||
navHeight = nav.outerHeight(),
|
||||
setNavClass = function() {
|
||||
scrollTimeOut = false;
|
||||
yPos = $(window).scrollTop();
|
||||
|
||||
if(Math.abs(lastYPos - yPos) >= yPosDelta) {
|
||||
if (yPos > lastYPos && yPos > navHeight){
|
||||
nav.addClass('hide-scroll');
|
||||
} else {
|
||||
nav.removeClass('hide-scroll');
|
||||
}
|
||||
lastYPos = yPos;
|
||||
}
|
||||
};
|
||||
|
||||
$(window).scroll(function(e){
|
||||
scrollTimeOut = true;
|
||||
});
|
||||
|
||||
setInterval(function() {
|
||||
if (scrollTimeOut) {
|
||||
setNavClass();
|
||||
}
|
||||
|
||||
}, 250);
|
||||
|
||||
/* Slick featured posts
|
||||
/* ------------------------------------ */
|
||||
$.fn.randomize = function (selector) {
|
||||
var $elems = selector ? $(this).find(selector) : $(this).children(),
|
||||
$parents = $elems.parent();
|
||||
|
||||
$parents.each(function () {
|
||||
$(this).children(selector).sort(function (childA, childB) {
|
||||
// * Prevent last slide from being reordered
|
||||
if($(childB).index() !== $(this).children(selector).length - 0.5) {
|
||||
return Math.round(Math.random()) - 0.5;
|
||||
}
|
||||
}.bind(this)).detach().appendTo(this);
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
$(".slick-posts").randomize().slick({
|
||||
centerMode: true,
|
||||
centerPadding: '180px',
|
||||
slidesToShow: 4,
|
||||
appendArrows: '.slick-posts-nav',
|
||||
responsive: [
|
||||
{
|
||||
breakpoint: 1280,
|
||||
settings: {
|
||||
arrows: true,
|
||||
centerMode: true,
|
||||
centerPadding: '40px',
|
||||
slidesToShow: 3
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 1024,
|
||||
settings: {
|
||||
arrows: true,
|
||||
centerMode: true,
|
||||
centerPadding: '40px',
|
||||
slidesToShow: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 768,
|
||||
settings: {
|
||||
arrows: true,
|
||||
centerMode: true,
|
||||
centerPadding: '40px',
|
||||
slidesToShow: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
breakpoint: 480,
|
||||
settings: {
|
||||
arrows: true,
|
||||
centerMode: true,
|
||||
centerPadding: '40px',
|
||||
slidesToShow: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
$('.slick-posts').show();
|
||||
|
||||
/* Slick image slide
|
||||
/* ------------------------------------ */
|
||||
$('.slick-image-slide').each( function() {
|
||||
$( this ).slick( {
|
||||
dots: true,
|
||||
adaptiveHeight: true,
|
||||
appendArrows: $(this).parents('.slick-image-slide-wrapper').find('.slick-image-slide-nav'),
|
||||
appendDots: $(this).parents('.slick-image-slide-wrapper').find('.slick-image-slide-dots')
|
||||
} );
|
||||
} );
|
||||
$('.slick-image-slide-wrapper').show();
|
||||
|
||||
/* Trap focus
|
||||
/* ------------------------------------ */
|
||||
// add all the elements inside modal which you want to make focusable
|
||||
const focusableElements =
|
||||
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
||||
const modal = document.querySelector('.search-trap-focus'); // select the modal by it's id
|
||||
|
||||
if ( modal ) {
|
||||
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
|
||||
const focusableContent = modal.querySelectorAll(focusableElements);
|
||||
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
|
||||
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
|
||||
|
||||
if (!isTabPressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey) { // if shift key pressed for shift + tab combination
|
||||
if (document.activeElement === firstFocusableElement) {
|
||||
lastFocusableElement.focus(); // add focus for the last focusable element
|
||||
e.preventDefault();
|
||||
}
|
||||
} else { // if tab key is pressed
|
||||
if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab
|
||||
firstFocusableElement.focus(); // add focus for the first focusable element
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
3037
js/slick.js
Normal file
3037
js/slick.js
Normal file
File diff suppressed because it is too large
Load diff
18
js/slick.min.js
vendored
Normal file
18
js/slick.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue