-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
main.min.js
6 lines (6 loc) · 11.3 KB
/
main.min.js
1
2
3
4
5
6
/*!
* So Simple Jekyll Theme 3.2.0 by Michael Rose
* Copyright 2013-2019 Michael Rose - mademistakes.com | @mmistakes
* Licensed under MIT
*/
function showToc(e){var t=function(){e.style.display="block";var t=e.scrollHeight+"px";return e.style.disply="",t}();e.classList.add("js-toc-is-open"),e.style.height=t,window.setTimeout(function(){e.style.height=""},350)}function hideToc(e){e.style.height=e.scrollHeight+"px",window.setTimeout(function(){e.style.height="0"},1),window.setTimeout(function(){e.classList.remove("js-toc-is-open")},350)}function toggleToc(e){if(tocToggle.classList.toggle("js-toc-is-open"),e.classList.contains("js-toc-is-open"))return void hideToc(e);showToc(e)}!function(e,t){"function"==typeof define&&define.amd?define(["jquery"],function(n){return t(e,n)}):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(e,require("jquery")):e.lity=t(e,e.jQuery||e.Zepto)}("undefined"!=typeof window?window:this,function(e,t){"use strict";function n(e){var t=O();return M&&e.length?(e.one(M,t.resolve),setTimeout(t.resolve,500)):t.resolve(),t.promise()}function o(e,n,o){if(1===arguments.length)return t.extend({},e);if("string"==typeof n){if(void 0===o)return void 0===e[n]?null:e[n];e[n]=o}else t.extend(e,n);return this}function i(e){var t=e.indexOf("?");t>-1&&(e=e.substr(t+1));for(var n,o=decodeURI(e.split("#")[0]).split("&"),i={},l=0,r=o.length;l<r;l++)o[l]&&(n=o[l].split("="),i[n[0]]=n[1]);return i}function l(e,n){if(!n)return e;if("string"===t.type(n)&&(n=i(n)),e.indexOf("?")>-1){var o=e.split("?");e=o.shift(),n=t.extend({},i(o[0]),n)}return e+"?"+t.param(n)}function r(e,t){var n=e.indexOf("#");return-1===n?t:(n>0&&(e=e.substr(n)),t+e)}function s(e,t,n,o){return t&&t.element().addClass("lity-iframe"),n&&(e=l(e,n)),o&&(e=r(o,e)),'<div class="lity-iframe-container"><iframe frameborder="0" allowfullscreen src="'+e+'"/></div>'}function a(e){return t('<span class="lity-error"/>').append(e)}function c(e,n){var o=n.opener()&&n.opener().data("lity-desc")||"Image with no description",i=t('<img src="'+e+'" alt="'+o+'"/>'),l=O(),r=function(){l.reject(a("Failed loading image"))};return i.on("load",function(){if(0===this.naturalWidth)return r();l.resolve(i)}).on("error",r),l.promise()}function d(e,n){var o,i,l;try{o=t(e)}catch(e){return!1}return!!o.length&&(i=t('<i style="display:none !important"/>'),l=o.hasClass("lity-hide"),n.element().one("lity:remove",function(){i.before(o).remove(),l&&!o.closest(".lity-content").length&&o.addClass("lity-hide")}),o.removeClass("lity-hide").after(i))}function u(e,t){var n=H.exec(e);return!!n&&s("https://www.youtube"+(n[2]||"")+".com/embed/"+n[4]+"?autoplay=1",t,n[5],e)}function f(e,t){var n=P.exec(e);return!!n&&s("https://player.vimeo.com/video/"+n[3]+"?autoplay=1",t,n[4],e)}function h(e,t){var n=F.exec(e);return!!n&&(0!==e.indexOf("http")&&(e="https:"+e),s("https://www.facebook.com/plugins/video.php?href="+e+"&autoplay=1",t,n[4],e))}function m(e,t){var n=W.exec(e);return!!n&&s("https://www.google."+n[3]+"/maps?"+n[6],t,{output:n[6].indexOf("layer=c")>0?"svembed":"embed"},e)}function p(e,t){return s(e,t)}function v(){return j.documentElement.clientHeight?j.documentElement.clientHeight:Math.round(C.height())}function g(e){var t=T();t&&(27===e.keyCode&&t.options("esc")&&t.close(),9===e.keyCode&&y(e,t))}function y(e,t){var n=t.element().find(B),o=n.index(j.activeElement);e.shiftKey&&o<=0?(n.get(n.length-1).focus(),e.preventDefault()):e.shiftKey||o!==n.length-1||(n.get(0).focus(),e.preventDefault())}function x(){t.each($,function(e,t){t.resize()})}function b(e){1===$.unshift(e)&&(D.addClass("lity-active"),C.on({resize:x,keydown:g})),t("body > *").not(e.element()).addClass("lity-hidden").each(function(){var e=t(this);void 0===e.data(z)&&e.data(z,e.attr(L)||null)}).attr(L,"true")}function w(e){var n;e.element().attr(L,"true"),1===$.length&&(D.removeClass("lity-active"),C.off({resize:x,keydown:g})),$=t.grep($,function(t){return e!==t}),n=$.length?$[0].element():t(".lity-hidden"),n.removeClass("lity-hidden").each(function(){var e=t(this),n=e.data(z);n?e.attr(L,n):e.removeAttr(L),e.removeData(z)})}function T(){return 0===$.length?null:$[0]}function k(e,n,o,i){var l,r="inline",s=t.extend({},o);return i&&s[i]?(l=s[i](e,n),r=i):(t.each(["inline","iframe"],function(e,t){delete s[t],s[t]=o[t]}),t.each(s,function(t,o){return!o||(!(!o.test||o.test(e,n))||(l=o(e,n),!1!==l?(r=t,!1):void 0))})),{handler:r,content:l||""}}function E(e,i,l,r){function s(e){d=t(e).css("max-height",v()+"px"),c.find(".lity-loader").each(function(){var e=t(this);n(e).always(function(){e.remove()})}),c.removeClass("lity-loading").find(".lity-content").empty().append(d),f=!0,d.trigger("lity:ready",[u])}var a,c,d,u=this,f=!1,h=!1;i=t.extend({},I,i),c=t(i.template),u.element=function(){return c},u.opener=function(){return l},u.content=function(){return d},u.options=t.proxy(o,u,i),u.handlers=t.proxy(o,u,i.handlers),u.resize=function(){f&&!h&&d.css("max-height",v()+"px").trigger("lity:resize",[u])},u.close=function(){if(f&&!h){h=!0,w(u);var e=O();if(r&&(j.activeElement===c[0]||t.contains(c[0],j.activeElement)))try{r.focus()}catch(e){}return d.trigger("lity:close",[u]),c.removeClass("lity-opened").addClass("lity-closed"),n(d.add(c)).always(function(){d.trigger("lity:remove",[u]),c.remove(),c=void 0,e.resolve()}),e.promise()}},a=k(e,u,i.handlers,i.handler),c.attr(L,"false").addClass("lity-loading lity-opened lity-"+a.handler).appendTo("body").focus().on("click","[data-lity-close]",function(e){t(e.target).is("[data-lity-close]")&&u.close()}).trigger("lity:open",[u]),b(u),t.when(a.content).always(s)}function S(e,n,o){e.preventDefault?(e.preventDefault(),o=t(this),e=o.data("lity-target")||o.attr("href")||o.attr("src")):o=t(o);var i=new E(e,t.extend({},o.data("lity-options")||o.data("lity"),n),o,j.activeElement);if(!e.preventDefault)return i}var j=e.document,C=t(e),O=t.Deferred,D=t("html"),$=[],L="aria-hidden",z="lity-"+L,B='a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,[contenteditable],[tabindex]:not([tabindex^="-"])',I={esc:!0,handler:null,handlers:{image:c,inline:d,youtube:u,vimeo:f,googlemaps:m,facebookvideo:h,iframe:p},template:'<div class="lity" role="dialog" aria-label="Dialog Window (Press escape to close)" tabindex="-1"><div class="lity-wrap" data-lity-close role="document"><div class="lity-loader" aria-hidden="true">Loading...</div><div class="lity-container"><div class="lity-content"></div><button class="lity-close" type="button" aria-label="Close (Press escape to close)" data-lity-close>×</button></div></div></div>'},q=/(^data:image\/)|(\.(png|jpe?g|gif|svg|webp|bmp|ico|tiff?)(\?\S*)?$)/i,H=/(youtube(-nocookie)?\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?([\w-]{11})(.*)?/i,P=/(vimeo(pro)?\.com)\/(?:[^\d]+)?(\d+)\??(.*)?$/,W=/((maps|www)\.)?google\.([^\/\?]+)\/?((maps\/?)?\?)(.*)/i,F=/(facebook\.com)\/([a-z0-9_-]*)\/videos\/([0-9]*)(.*)?$/i,M=function(){var e=j.createElement("div"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var n in t)if(void 0!==e.style[n])return t[n];return!1}();return c.test=function(e){return q.test(e)},S.version="3.0.0-dev",S.options=t.proxy(o,S,I),S.handlers=t.proxy(o,S,I.handlers),S.current=T,S.iframe=s,t(j).on("click.lity","[data-lity]",S),S}),function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof module&&module.exports?require("jquery"):jQuery)}(function(e){var t={},n={exclude:[],excludeWithin:[],offset:0,direction:"top",delegateSelector:null,scrollElement:null,scrollTarget:null,autoFocus:!1,beforeScroll:function(){},afterScroll:function(){},easing:"swing",speed:400,autoCoefficient:2,preventDefault:!0},o=function(t){var n=[],o=!1,i=t.dir&&"left"===t.dir?"scrollLeft":"scrollTop";return this.each(function(){var t=e(this);if(this!==document&&this!==window)return!document.scrollingElement||this!==document.documentElement&&this!==document.body?void(t[i]()>0?n.push(this):(t[i](1),o=t[i]()>0,o&&n.push(this),t[i](0))):(n.push(document.scrollingElement),!1)}),n.length||this.each(function(){this===document.documentElement&&"smooth"===e(this).css("scrollBehavior")&&(n=[this]),n.length||"BODY"!==this.nodeName||(n=[this])}),"first"===t.el&&n.length>1&&(n=[n[0]]),n},i=/^([\-\+]=)(\d+)/;e.fn.extend({scrollable:function(e){var t=o.call(this,{dir:e});return this.pushStack(t)},firstScrollable:function(e){var t=o.call(this,{el:"first",dir:e});return this.pushStack(t)},smoothScroll:function(t,n){if("options"===(t=t||{}))return n?this.each(function(){var t=e(this),o=e.extend(t.data("ssOpts")||{},n);e(this).data("ssOpts",o)}):this.first().data("ssOpts");var o=e.extend({},e.fn.smoothScroll.defaults,t),i=function(t){var n=function(e){return e.replace(/(:|\.|\/)/g,"\\$1")},i=this,l=e(this),r=e.extend({},o,l.data("ssOpts")||{}),s=o.exclude,a=r.excludeWithin,c=0,d=0,u=!0,f={},h=e.smoothScroll.filterPath(location.pathname),m=e.smoothScroll.filterPath(i.pathname),p=location.hostname===i.hostname||!i.hostname,v=r.scrollTarget||m===h,g=n(i.hash);if(g&&!e(g).length&&(u=!1),r.scrollTarget||p&&v&&g){for(;u&&c<s.length;)l.is(n(s[c++]))&&(u=!1);for(;u&&d<a.length;)l.closest(a[d++]).length&&(u=!1)}else u=!1;u&&(r.preventDefault&&t.preventDefault(),e.extend(f,r,{scrollTarget:r.scrollTarget||g,link:i}),e.smoothScroll(f))};return null!==t.delegateSelector?this.off("click.smoothscroll",t.delegateSelector).on("click.smoothscroll",t.delegateSelector,i):this.off("click.smoothscroll").on("click.smoothscroll",i),this}});var l=function(e){var t={relative:""},n="string"==typeof e&&i.exec(e);return"number"==typeof e?t.px=e:n&&(t.relative=n[1],t.px=parseFloat(n[2])||0),t},r=function(t){var n=e(t.scrollTarget);t.autoFocus&&n.length&&(n[0].focus(),n.is(document.activeElement)||(n.prop({tabIndex:-1}),n[0].focus())),t.afterScroll.call(t.link,t)};e.smoothScroll=function(n,o){if("options"===n&&"object"==typeof o)return e.extend(t,o);var i,s,a,c,d=l(n),u={},f=0,h="offset",m="scrollTop",p={},v={};d.px?i=e.extend({link:null},e.fn.smoothScroll.defaults,t):(i=e.extend({link:null},e.fn.smoothScroll.defaults,n||{},t),i.scrollElement&&(h="position","static"===i.scrollElement.css("position")&&i.scrollElement.css("position","relative")),o&&(d=l(o))),m="left"===i.direction?"scrollLeft":m,i.scrollElement?(s=i.scrollElement,d.px||/^(?:HTML|BODY)$/.test(s[0].nodeName)||(f=s[m]())):s=e("html, body").firstScrollable(i.direction),i.beforeScroll.call(s,i),u=d.px?d:{relative:"",px:e(i.scrollTarget)[h]()&&e(i.scrollTarget)[h]()[i.direction]||0},p[m]=u.relative+(u.px+f+i.offset),a=i.speed,"auto"===a&&(c=Math.abs(p[m]-s[m]()),a=c/i.autoCoefficient),v={duration:a,easing:i.easing,complete:function(){r(i)}},i.step&&(v.step=i.step),s.length?s.stop().animate(p,v):r(i)},e.smoothScroll.version="2.2.0",e.smoothScroll.filterPath=function(e){return e=e||"",e.replace(/^\//,"").replace(/(?:index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")},e.fn.smoothScroll.defaults=n});var tocToggle=document.getElementById("toc-toggle"),tableOfContents=document.getElementById("markdown-toc");tocToggle&&tocToggle.addEventListener("click",function(e){toggleToc(tableOfContents)}),$(document).ready(function(){var e=document.getElementById("menu-toggle"),t=document.getElementById("primary-nav");e&&t&&e.addEventListener("click",function(){t.classList.toggle("js-menu-is-open")}),$("a").smoothScroll({offset:-20}),$("a[href$='.jpg'], a[href$='.png'], a[href$='.gif']").attr("data-lity","")});