wp-theme/assets/dist/js/ascribe.min.js

11 lines
7.2 KiB
JavaScript
Raw Normal View History

2016-01-16 21:26:38 +01:00
/**
** ascribe v0.0.1
** The best WordPress theme ever made!
** http://ascribe.io
**
** Territorial <us@territorial.ca>
**
**
** https://github.com/ascribe/wp-theme.git
**/
2016-03-12 20:51:08 +01:00
function stickyNav(){var t=$(".sticky");$(window).on("load resize scroll",function(){$(window).width()>768&&($(window).scrollTop()>100?t.addClass("stuck"):t.removeClass("stuck"))})}function mobileNav(){var t=$(".hamburger"),e=$(".mobile-nav");t.click(function(o){o.preventDefault(),e.toggleClass("active"),t.toggleClass("open"),$(document).bind("click.hidepopup",function(){e.removeClass("active"),t.removeClass("open"),$(document).unbind("click.hidepopup")}),e.on("click",function(t){t.stopPropagation()}),o.stopPropagation()})}!function(t){t.fn.smoothScroller=function(e){e=t.extend({},t.fn.smoothScroller.defaults,e);var o=t(this);return t(e.scrollEl).animate({scrollTop:o.offset().top-t(e.scrollEl).offset().top-e.offset},e.speed,e.ease,function(){var t=o.attr("id");t.length&&(document.location.hash=t),o.trigger("smoothScrollerComplete")}),this},t.fn.smoothScroller.defaults={speed:400,ease:"swing",scrollEl:"body,html",offset:0},t("body").on("click","[data-smoothscroller]",function(e){e.preventDefault();var o=t(this).attr("href");0===o.indexOf("#")&&t(o).smoothScroller()})}(jQuery),function(t){var e={};t.fn.toc=function(e){var o,i=this,n=t.extend({},jQuery.fn.toc.defaults,e),s=t(n.container),a=t(n.selectors,s),f=n.activeClass,r=function(){var e=[];return a.each(function(o,i){var s=t(i);e.push(s.offset().top-n.highlightOffset)}),e},l=function(e,o){if(n.smoothScrolling&&"function"==typeof n.smoothScrolling){e.preventDefault();var s=t(e.target).attr("href");n.smoothScrolling(s,n,o)}t("li",i).removeClass(f),t(e.target).parent().addClass(f)},c=function(e){o&&clearTimeout(o),o=setTimeout(function(){var e,o=t(window).scrollTop(),s=Number.MAX_VALUE,a=0;offsets=r();for(var l=0,c=offsets.length;c>l;l++){var h=Math.abs(offsets[l]-o);s>h&&(a=l,s=h)}t("li",i).removeClass(f),e=t("li:eq("+a+")",i).addClass(f),n.onHighlight(e)},50)};return n.highlightOnScroll&&(t(window).bind("scroll",c),c()),this.each(function(){var e=t(this),o=t(n.listType);a.each(function(i,s){var a=t(s),f=n.anchorName(i,s,n.prefix);if(s.id!==f){t("<span/>").attr("id",f).insertBefore(a)}var r=t("<a/>").text(n.headerText(i,s,a)).attr("href","#"+f).bind("click",function(o){t(window).unbind("scroll",c),l(o,function(){t(window).bind("scroll",c)}),e.trigger("selected",t(this).attr("href"))}),h=t("<li/>").addClass(n.itemClass(i,s,a,n.prefix)).append(r);o.append(h)}),e.html(o)})},jQuery.fn.toc.defaults={container:"body",listType:"<ul/>",selectors:"h1,h2,h3",smoothScrolling:function(e,o,i){t(e).smoothScroller({offset:o.scrollToOffset}).on("smoothScrollerComplete",function(){i()})},scrollToOffset:0,prefix:"toc",activeClass:"toc-active",onHighlight:function(){},highlightOnScroll:!0,highlightOffset:100,anchorName:function(o,i,n){if(i.id.length)return i.id;var s=t(i).text().replace(/[^a-z0-9]/gi," ").replace(/\s+/g,"-").toLowerCase();if(e[s]){for(var a=2;e[s+a];)a++;s=s+"-"+a}return e[s]=!0,n+"-"+s},headerText:function(t,e,o){return o.text()},itemClass:function(t,e,o,i){return i+"-"+o[0].tagName.toLowerCase()}}}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var i=t(this),n=i.data("bs.affix"),s="object"==typeof e&&e;n||i.data("bs.affix",n=new o(this,s)),"string"==typeof e&&n[e]()})}var o=function(e,i){this.options=t.extend({},o.DEFAULTS,i),this.$target=t(this.options.target).on("scroll.bs.affix.data-api",t.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",t.proxy(this.checkPositionWithEventLoop,this)),this.$element=t(e),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};o.VERSION="3.3.6",o.RESET="affix affix-top affix-bottom",o.DEFAULTS={offset:0,target:window},o.prototype.getState=function(t,e,o,i){var n=this.$target.scrollTop(),s=this.$element.offset(),a=this.$target.height();if(null!=o&&"top"==this.affixed)return o>n?"top":!1;if("bottom"==this.affixed)return null!=o?n+this.unpin<=s.top?!1:"bottom":t-i>=n+a?!1:"bottom";var f=null==this.affixed,r=f?n:s.top,l=f?a:e;return null!=o&&o>=n?"top":null!=i&&r+l>=t-i?"bottom":!1},o.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$elemen