mirror of
https://github.com/ascribe/wp-theme
synced 2024-12-23 01:30:09 +01:00
11 lines
7.7 KiB
JavaScript
11 lines
7.7 KiB
JavaScript
/**
|
|
** ascribe v0.0.1
|
|
** The best WordPress theme ever made!
|
|
** http://ascribe.io
|
|
**
|
|
** Territorial <us@territorial.ca>
|
|
**
|
|
**
|
|
** https://github.com/ascribe/wp-theme.git
|
|
**/
|
|
function _dntEnabled(t,e){"use strict";var o=t||navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack,i=e||navigator.userAgent,n=["Windows NT 6.1","Windows NT 6.2","Windows NT 6.3"],s=i.match(/Firefox\/(\d+)/),a=/MSIE|Trident/i,f=a.test(i),r=i.match(/Windows.+?(?=;)/g);return f&&"function"!=typeof Array.prototype.indexOf?!1:(o=s&&parseInt(s[1],10)<32?"Unspecified":f&&r&&-1!==n.indexOf(r.toString())?"Unspecified":{0:"Disabled",1:"Enabled"}[o]||"Unspecified","Enabled"===o)}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 d=Math.abs(offsets[l]-o);s>d&&(a=l,s=d)}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"))}),d=t("<li/>").addClass(n.itemClass(i,s,a,n.prefix)).append(r);o.append(d)}),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.$element.removeClass(o.RESET).addClass("affix");var t=this.$target.scrollTop(),e=this.$element.offset();return this.pinnedOffset=e.top-t},o.prototype.checkPositionWithEventLoop=function(){setTimeout(t.proxy(this.checkPosition,this),1)},o.prototype.checkPosition=function(){if(this.$element.is(":visible")){var e=this.$element.height(),i=this.options.offset,n=i.top,s=i.bottom,a=Math.max(t(document).height(),t(document.body).height());"object"!=typeof i&&(s=n=i),"function"==typeof n&&(n=i.top(this.$element)),"function"==typeof s&&(s=i.bottom(this.$element));var f=this.getState(a,e,n,s);if(this.affixed!=f){null!=this.unpin&&this.$element.css("top","");var r="affix"+(f?"-"+f:""),l=t.Event(r+".bs.affix");if(this.$element.trigger(l),l.isDefaultPrevented())return;this.affixed=f,this.unpin="bottom"==f?this.getPinnedOffset():null,this.$element.removeClass(o.RESET).addClass(r).trigger(r.replace("affix","affixed")+".bs.affix")}"bottom"==f&&this.$element.offset({top:a-e-s})}};var i=t.fn.affix;t.fn.affix=e,t.fn.affix.Constructor=o,t.fn.affix.noConflict=function(){return t.fn.affix=i,this},t(window).on("load",function(){t('[data-spy="affix"]').each(function(){var o=t(this),i=o.data();i.offset=i.offset||{},null!=i.offsetBottom&&(i.offset.bottom=i.offsetBottom),null!=i.offsetTop&&(i.offset.top=i.offsetTop),e.call(o,i)})})}(jQuery);var Faq=function(t,e,o){"use strict";var i,n,s;return s={faqQuestion:o(".faq__question"),faqAnswer:o(".faq__answer"),faqTitle:o(".faq__title"),faqTocColumn:o(".grid__col--toc"),faqToc:o("#toc"),minWidth:768},n={faqToggle:function(){s.faqQuestion.click(function(){o(this).toggleClass("open"),o(this).next(s.faqAnswer).toggleClass("open")})},faqTocInit:function(){s.faqToc.toc({selectors:s.faqTitle,container:"body",highlightOffset:100})},faqTocSticky:function(){var t=o(window);t.on("load resize",function(t){n.isWide()&&s.faqToc.affix({offset:{top:s.faqTocColumn.offset().top+20,bottom:o(".section-faq:last-child").outerHeight(!0)+40}})})},isWide:function(){return o(window).width()>=s.minWidth}},i={init:function(){n.faqToggle(),n.faqTocInit(),n.faqTocSticky()}}}(window,document,jQuery);$(document).ready(function(){function t(){$("body").hasClass("page-template-template-tour")&&$(".tour-switcher .menu").prepend($(".tour-switcher .current-menu-item")),$(".current-menu-item a").click(function(t){t.preventDefault(),$("#menu-landing-page-menu").toggleClass("active")})}function e(){$(".case-study:gt(0)").addClass("hidden"),$(".slider-action").click(function(){var t=$(this).attr("id");"back"===t?($(".case-study").addClass("hidden"),$(".case-study").last().prependTo(".slide-container").removeClass("hidden")):(displayed=$(".case-study").first(),displayed.addClass("hidden"),$(".case-study").eq(1).removeClass("hidden"),displayed.appendTo(".slide-container"))})}function o(){$(".top-tab").click(function(){$(".top-tab").removeClass("active"),$(this).addClass("active");var t=$(this).data("tab");$(".marketplace-info").removeClass("active"),$("#"+t).addClass("active")})}$(".subtemplate--faq").length&&Faq.init(),e(),o(),t(),mobileNav(),stickyNav()}); |