terra/terra.demo.min.js

2 lines
32 KiB
JavaScript
Raw Normal View History

2014-08-24 06:40:44 +00:00
Function.prototype.bind||(Function.prototype.bind=function(e){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this;return fNOP=function(){},fBound=function(){return n.apply(this instanceof fNOP&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))},fNOP.prototype=this.prototype,fBound.prototype=new fNOP,fBound}),!function(e,t){"function"==typeof define&&define.amd?define("smoothScroll",t(e)):"object"==typeof exports?module.exports=t(e):e.smoothScroll=t(e)}(this,function(e){"use strict";var t,n={},r=!!document.querySelector&&!!e.addEventListener,o={speed:500,easing:"easeInOutCubic",offset:0,updateURL:!0,callbackBefore:function(){},callbackAfter:function(){}},i=function(e,t,n){if("[object Object]"===Object.prototype.toString.call(e))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(n,e[r],r,e);else for(var o=0,i=e.length;i>o;o++)t.call(n,e[o],o,e)},a=function(e,t){var n={};return i(e,function(t,r){n[r]=e[r]}),i(t,function(e,r){n[r]=t[r]}),n},u=function(e){for(var t,n=String(e),r=n.length,o=-1,i="",a=n.charCodeAt(0);++o<r;){if(t=n.charCodeAt(o),0===t)throw new InvalidCharacterError("Invalid character: the input contains U+0000.");i+=t>=1&&31>=t||127==t||0===o&&t>=48&&57>=t||1===o&&t>=48&&57>=t&&45===a?"\\"+t.toString(16)+" ":t>=128||45===t||95===t||t>=48&&57>=t||t>=65&&90>=t||t>=97&&122>=t?n.charAt(o):"\\"+n.charAt(o)}return i},c=function(e,t){var n;return"easeInQuad"===e&&(n=t*t),"easeOutQuad"===e&&(n=t*(2-t)),"easeInOutQuad"===e&&(n=.5>t?2*t*t:-1+(4-2*t)*t),"easeInCubic"===e&&(n=t*t*t),"easeOutCubic"===e&&(n=--t*t*t+1),"easeInOutCubic"===e&&(n=.5>t?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1),"easeInQuart"===e&&(n=t*t*t*t),"easeOutQuart"===e&&(n=1- --t*t*t*t),"easeInOutQuart"===e&&(n=.5>t?8*t*t*t*t:1-8*--t*t*t*t),"easeInQuint"===e&&(n=t*t*t*t*t),"easeOutQuint"===e&&(n=1+--t*t*t*t*t),"easeInOutQuint"===e&&(n=.5>t?16*t*t*t*t*t:1+16*--t*t*t*t*t),n||t},s=function(e,t,n){var r=0;if(e.offsetParent)do r+=e.offsetTop,e=e.offsetParent;while(e);return r=r-t-n,r>=0?r:0},l=function(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},f=function(e){return e&&"object"==typeof JSON&&"function"==typeof JSON.parse?JSON.parse(e):{}},p=function(e,t){history.pushState&&(t||"true"===t)&&history.pushState({pos:e.id},"",window.location.pathname+e)};return n.animateScroll=function(t,n,r,i){var g=a(g||o,r||{}),d=f(t?t.getAttribute("data-options"):null);g=a(g,d),n="#"+u(n.substr(1));var h,y,m,v=document.querySelector("[data-scroll-header]"),b=null===v?0:v.offsetHeight+v.offsetTop,w=e.pageYOffset,x=s(document.querySelector(n),b,parseInt(g.offset,10)),E=x-w,j=l(),k=0;t&&"a"===t.tagName.toLowerCase()&&i&&i.preventDefault(),p(n,g.updateURL);var O=function(r,o,i){var a=e.pageYOffset;(r==o||a==o||e.innerHeight+a>=j)&&(clearInterval(i),g.callbackAfter(t,n))},S=function(){k+=16,y=k/parseInt(g.speed,10),y=y>1?1:y,m=w+E*c(g.easing,y),e.scrollTo(0,Math.floor(m)),O(m,x,h)},A=function(){g.callbackBefore(t,n),h=setInterval(S,16)};0===e.pageYOffset&&e.scrollTo(0,0),A()},n.init=function(e){if(r){t=a(o,e||{});var u=document.querySelectorAll("[data-scroll]");i(u,function(e){e.addEventListener("click",n.animateScroll.bind(null,e,e.hash,t),!1)})}},n}),self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content)):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var r={};for(var o in e)e.hasOwnProperty(o)&&(r[o]=t.util.clone(e[o]));return r;case"Array":return
}:function(e){return e=e[i],a===e&&(0!==a||1/a==1/e)}},a.filter=w,a.forEach=x,a.forIn=Pt,a.forOwn=Ct,a.keys=kt,a.map=E,a.property=C,a.collect=E,a.each=x,a.extend=At,a.select=w,a.clone=function(e,t,n,r){return"boolean"!=typeof t&&null!=t&&(r=n,n=t,t=!1),c(e,t,"function"==typeof n&&l(n,r,1))},a.identity=A,a.isArguments=y,a.isArray=Et,a.isFunction=m,a.isObject=v,a.isString=b,a.noop=P,a.random=function(e,t,n){var r=null==e,o=null==t;return null==n&&("boolean"==typeof e&&o?(n=e,e=1):o||"boolean"!=typeof t||(n=t,o=!0)),r&&o&&(t=1),e=+e||0,o?(t=e,e=0):t=+t||0,n||e%1||t%1?(n=mt(),yt(e+n*(t-e+parseFloat("1e-"+((n+"").length-1))),t)):e+at(mt()*(t-e+1))},a.reduce=j,a.some=O,a.any=O,a.foldl=j,a.inject=j,a.VERSION="2.4.1",V&&Z&&(V._=a)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]);