123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611 |
- !function($){
- "use strict";
- var Typed = function(el, options){
-
- this.el = $(el);
-
- this.options = $.extend({}, $.fn.typed.defaults, options);
-
- this.baseText = this.el.text() || this.el.attr('placeholder') || '';
-
- this.typeSpeed = this.options.typeSpeed;
-
- this.startDelay = this.options.startDelay;
-
- this.backSpeed = this.options.backSpeed;
-
- this.backDelay = this.options.backDelay;
-
- this.strings = this.options.strings;
-
- this.strPos = 0;
-
- this.arrayPos = 0;
-
-
-
- this.stopNum = 0;
-
- this.loop = this.options.loop;
- this.loopCount = this.options.loopCount;
- this.curLoop = 0;
-
- this.stop = false;
-
- this.showCursor = this.isInput ? false : this.options.showCursor;
-
- this.cursorChar = this.options.cursorChar;
-
- this.isInput = this.el.is('input');
- this.attr = this.options.attr || (this.isInput ? 'placeholder' : null);
-
- this.build();
- };
- Typed.prototype = {
- constructor: Typed
- , init: function(){
-
-
- var self = this;
- self.timeout = setTimeout(function() {
-
- self.typewrite(self.strings[self.arrayPos], self.strPos);
- }, self.startDelay);
- }
- , build: function(){
-
- if (this.showCursor === true){
- this.cursor = $("<span class=\"typed-cursor\">" + this.cursorChar + "</span>");
- this.el.after(this.cursor);
- }
- this.init();
- }
-
- , typewrite: function(curString, curStrPos){
-
- if(this.stop === true)
- return;
-
-
- var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;
- var self = this;
-
-
-
-
-
-
-
-
- self.timeout = setTimeout(function() {
-
-
-
- var charPause = 0;
- var substr = curString.substr(curStrPos);
- if (substr.charAt(0) === '^') {
- var skip = 1;
- if(/^\^\d+/.test(substr)) {
- substr = /\d+/.exec(substr)[0];
- skip += substr.length;
- charPause = parseInt(substr);
- }
-
- curString = curString.substring(0,curStrPos)+curString.substring(curStrPos+skip);
- }
-
- self.timeout = setTimeout(function() {
- if(curStrPos === curString.length) {
-
- self.options.onStringTyped(self.arrayPos);
-
- if(self.arrayPos === self.strings.length-1) {
-
- self.options.callback();
- self.curLoop++;
-
- if(self.loop === false || self.curLoop === self.loopCount)
- return;
- }
- self.timeout = setTimeout(function(){
- self.backspace(curString, curStrPos);
- }, self.backDelay);
- } else {
-
- if(curStrPos === 0)
- self.options.preStringTyped(self.arrayPos);
-
-
- var nextString = self.baseText + curString.substr(0, curStrPos+1);
- if (self.attr) {
- self.el.attr(self.attr, nextString);
- } else {
- self.el.text(nextString);
- }
-
- curStrPos++;
-
- self.typewrite(curString, curStrPos);
- }
-
- }, charPause);
-
- }, humanize);
- }
- , backspace: function(curString, curStrPos){
-
- if (this.stop === true) {
- return;
- }
-
-
- var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed;
- var self = this;
- self.timeout = setTimeout(function() {
-
-
-
-
-
- if (self.arrayPos == 1) {
- self.stopNum = 17;
- self.backDelay = 500;
- }
- else if (self.arrayPos == 2) {
- self.stopNum = 54;
- }
- else{self.stopNum = 0;}
-
-
- var nextString = self.baseText + curString.substr(0, curStrPos);
- if (self.attr) {
- self.el.attr(self.attr, nextString);
- } else {
- self.el.text(nextString);
- }
-
-
- if (curStrPos > self.stopNum){
-
- curStrPos--;
-
- self.backspace(curString, curStrPos);
- }
-
-
- else if (curStrPos <= self.stopNum) {
- self.arrayPos++;
- if(self.arrayPos === self.strings.length) {
- self.arrayPos = 0;
- self.init();
- } else
- self.typewrite(self.strings[self.arrayPos], curStrPos);
- }
-
- }, humanize);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- , reset: function(){
- var self = this;
- clearInterval(self.timeout);
- var id = this.el.attr('id');
- this.el.after('<span id="' + id + '"/>')
- this.el.remove();
- this.cursor.remove();
-
- self.options.resetCallback();
- }
- };
- $.fn.typed = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('typed')
- , options = typeof option == 'object' && option;
- if (!data) $this.data('typed', (data = new Typed(this, options)));
- if (typeof option == 'string') data[option]();
- });
- };
- $.fn.typed.defaults = {
- strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
-
- typeSpeed: 0,
-
- startDelay: 0,
-
- backSpeed: 0,
-
- backDelay: 500,
-
- loop: false,
-
- loopCount: false,
-
- showCursor: true,
-
- cursorChar: "|",
-
- attr: null,
-
- callback: function() {},
-
- preStringTyped: function() {},
-
- onStringTyped: function() {},
-
- resetCallback: function() {}
- };
- }(window.jQuery);
- (function (name, context, definition) {
- if (typeof module != 'undefined' && module.exports) module.exports = definition();
- else if (typeof define == 'function' && define.amd) define(definition);
- else context[name] = definition();
- })('jquery-scrollto', this, function(){
-
- var jQuery, $, ScrollTo;
- jQuery = $ = window.jQuery || require('jquery');
-
- $.propHooks.scrollTop = $.propHooks.scrollLeft = {
- get: function(elem,prop) {
- var result = null;
- if ( elem.tagName === 'HTML' || elem.tagName === 'BODY' ) {
- if ( prop === 'scrollLeft' ) {
- result = window.scrollX;
- } else if ( prop === 'scrollTop' ) {
- result = window.scrollY;
- }
- }
- if ( result == null ) {
- result = elem[prop];
- }
- return result;
- }
- };
- $.Tween.propHooks.scrollTop = $.Tween.propHooks.scrollLeft = {
- get: function(tween) {
- return $.propHooks.scrollTop.get(tween.elem, tween.prop);
- },
- set: function(tween) {
-
- if ( tween.elem.tagName === 'HTML' || tween.elem.tagName === 'BODY' ) {
-
- tween.options.bodyScrollLeft = (tween.options.bodyScrollLeft || window.scrollX);
- tween.options.bodyScrollTop = (tween.options.bodyScrollTop || window.scrollY);
-
- if ( tween.prop === 'scrollLeft' ) {
- tween.options.bodyScrollLeft = Math.round(tween.now);
- }
- else if ( tween.prop === 'scrollTop' ) {
- tween.options.bodyScrollTop = Math.round(tween.now);
- }
-
- window.scrollTo(tween.options.bodyScrollLeft, tween.options.bodyScrollTop);
- }
-
- else if ( tween.elem.nodeType && tween.elem.parentNode ) {
- tween.elem[ tween.prop ] = tween.now;
- }
- }
- };
-
- ScrollTo = {
-
- config: {
- duration: 400,
- easing: 'swing',
- callback: undefined,
- durationMode: 'each',
- offsetTop: 0,
- offsetLeft: 0
- },
-
- configure: function(options){
-
- $.extend(ScrollTo.config, options||{});
-
- return this;
- },
-
-
-
- scroll: function(collections, config){
-
- var collection, $container, container, $target, $inline, position, containerTagName,
- containerScrollTop, containerScrollLeft,
- containerScrollTopEnd, containerScrollLeftEnd,
- startOffsetTop, targetOffsetTop, targetOffsetTopAdjusted,
- startOffsetLeft, targetOffsetLeft, targetOffsetLeftAdjusted,
- scrollOptions,
- callback;
-
- collection = collections.pop();
- $container = collection.$container;
- $target = collection.$target;
- containerTagName = $container.prop('tagName');
-
- $inline = $('<span/>').css({
- 'position': 'absolute',
- 'top': '0px',
- 'left': '0px'
- });
- position = $container.css('position');
-
- $container.css({position:'relative'});
- $inline.appendTo($container);
-
- startOffsetTop = $inline.offset().top;
- targetOffsetTop = $target.offset().top;
- targetOffsetTopAdjusted = targetOffsetTop - startOffsetTop - parseInt(config.offsetTop,10);
-
- startOffsetLeft = $inline.offset().left;
- targetOffsetLeft = $target.offset().left;
- targetOffsetLeftAdjusted = targetOffsetLeft - startOffsetLeft - parseInt(config.offsetLeft,10);
-
- containerScrollTop = $container.prop('scrollTop');
- containerScrollLeft = $container.prop('scrollLeft');
-
- $inline.remove();
- $container.css({position:position});
-
- scrollOptions = {};
-
- callback = function(event){
-
- if ( collections.length === 0 ) {
-
- if ( typeof config.callback === 'function' ) {
- config.callback();
- }
- }
- else {
-
- ScrollTo.scroll(collections,config);
- }
-
- return true;
- };
-
- if ( config.onlyIfOutside ) {
-
- containerScrollTopEnd = containerScrollTop + $container.height();
- containerScrollLeftEnd = containerScrollLeft + $container.width();
-
- if ( containerScrollTop < targetOffsetTopAdjusted && targetOffsetTopAdjusted < containerScrollTopEnd ) {
- targetOffsetTopAdjusted = containerScrollTop;
- }
- if ( containerScrollLeft < targetOffsetLeftAdjusted && targetOffsetLeftAdjusted < containerScrollLeftEnd ) {
- targetOffsetLeftAdjusted = containerScrollLeft;
- }
- }
-
- if ( targetOffsetTopAdjusted !== containerScrollTop ) {
- scrollOptions.scrollTop = targetOffsetTopAdjusted;
- }
- if ( targetOffsetLeftAdjusted !== containerScrollLeft ) {
- scrollOptions.scrollLeft = targetOffsetLeftAdjusted;
- }
-
- if ( $container.prop('scrollHeight') === $container.width() ) {
- delete scrollOptions.scrollTop;
- }
- if ( $container.prop('scrollWidth') === $container.width() ) {
- delete scrollOptions.scrollLeft;
- }
-
- if ( scrollOptions.scrollTop != null || scrollOptions.scrollLeft != null ) {
- $container.animate(scrollOptions, {
- duration: config.duration,
- easing: config.easing,
- complete: callback
- });
- }
- else {
- callback();
- }
-
- return true;
- },
-
- fn: function(options){
-
- var collections, config, $container, container;
- collections = [];
-
- var $target = $(this);
- if ( $target.length === 0 ) {
-
- return this;
- }
-
- config = $.extend({},ScrollTo.config,options);
-
- $container = $target.parent();
- container = $container.get(0);
-
- while ( ($container.length === 1) && (container !== document.body) && (container !== document) ) {
-
- var containerScrollTop, containerScrollLeft;
- containerScrollTop = $container.css('overflow-y') !== 'visible' && container.scrollHeight !== container.clientHeight;
- containerScrollLeft = $container.css('overflow-x') !== 'visible' && container.scrollWidth !== container.clientWidth;
- if ( containerScrollTop || containerScrollLeft ) {
-
- collections.push({
- '$container': $container,
- '$target': $target
- });
-
- $target = $container;
- }
-
- $container = $container.parent();
- container = $container.get(0);
- }
-
- collections.push({
- '$container': $('html'),
-
-
- '$target': $target
- });
-
- if ( config.durationMode === 'all' ) {
- config.duration /= collections.length;
- }
-
- ScrollTo.scroll(collections,config);
-
- return this;
- }
- };
-
- $.ScrollTo = $.ScrollTo || ScrollTo;
- $.fn.ScrollTo = $.fn.ScrollTo || ScrollTo.fn;
-
- return ScrollTo;
- });
- (function() {
- var MutationObserver, Util, WeakMap, getComputedStyle, getComputedStyleRX,
- __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
- Util = (function() {
- function Util() {}
- Util.prototype.extend = function(custom, defaults) {
- var key, value;
- for (key in defaults) {
- value = defaults[key];
- if (custom[key] == null) {
- custom[key] = value;
- }
- }
- return custom;
- };
- Util.prototype.isMobile = function(agent) {
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(agent);
- };
- Util.prototype.addEvent = function(elem, event, fn) {
- if (elem.addEventListener != null) {
- return elem.addEventListener(event, fn, false);
- } else if (elem.attachEvent != null) {
- return elem.attachEvent("on" + event, fn);
- } else {
- return elem[event] = fn;
- }
- };
- Util.prototype.removeEvent = function(elem, event, fn) {
- if (elem.removeEventListener != null) {
- return elem.removeEventListener(event, fn, false);
- } else if (elem.detachEvent != null) {
- return elem.detachEvent("on" + event, fn);
- } else {
- return delete elem[event];
- }
- };
- Util.prototype.innerHeight = function() {
- if ('innerHeight' in window) {
- return window.innerHeight;
- } else {
- return document.documentElement.clientHeight;
- }
- };
- return Util;
- })();
- WeakMap = this.WeakMap || this.MozWeakMap || (WeakMap = (function() {
- function WeakMap() {
- this.keys = [];
- this.values = [];
- }
- WeakMap.prototype.get = function(key) {
- var i, item, _i, _len, _ref;
- _ref = this.keys;
- for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
- item = _ref[i];
- if (item === key) {
- return this.values[i];
- }
- }
- };
- WeakMap.prototype.set = function(key, value) {
- var i, item, _i, _len, _ref;
- _ref = this.keys;
- for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
- item = _ref[i];
- if (item === key) {
- this.values[i] = value;
- return;
- }
- }
- this.keys.push(key);
- return this.values.push(value);
- };
- return WeakMap;
- })());
- MutationObserver = this.MutationObserver || this.WebkitMutationObserver || this.MozMutationObserver || (MutationObserver = (function() {
- function MutationObserver() {
- if (typeof console !== "undefined" && console !== null) {
- console.warn('MutationObserver is not supported by your browser.');
- }
- if (typeof console !== "undefined" && console !== null) {
- console.warn('WOW.js cannot detect dom mutations, please call .sync() after loading new content.');
- }
- }
- MutationObserver.notSupported = true;
- MutationObserver.prototype.observe = function() {};
- return MutationObserver;
- })());
- getComputedStyle = this.getComputedStyle || function(el, pseudo) {
- this.getPropertyValue = function(prop) {
- var _ref;
- if (prop === 'float') {
- prop = 'styleFloat';
- }
- if (getComputedStyleRX.test(prop)) {
- prop.replace(getComputedStyleRX, function(_, char) {
- return char.toUpperCase();
- });
- }
- return ((_ref = el.currentStyle) != null ? _ref[prop] : void 0) || null;
- };
- return this;
- };
- getComputedStyleRX = /(\-([a-z]){1})/g;
- this.WOW = (function() {
- WOW.prototype.defaults = {
- boxClass: 'wow',
- animateClass: 'animated',
- offset: 0,
- mobile: true,
- live: true
- };
- function WOW(options) {
- if (options == null) {
- options = {};
- }
- this.scrollCallback = __bind(this.scrollCallback, this);
- this.scrollHandler = __bind(this.scrollHandler, this);
- this.start = __bind(this.start, this);
- this.scrolled = true;
- this.config = this.util().extend(options, this.defaults);
- this.animationNameCache = new WeakMap();
- }
- WOW.prototype.init = function() {
- var _ref;
- this.element = window.document.documentElement;
- if ((_ref = document.readyState) === "interactive" || _ref === "complete") {
- this.start();
- } else {
- this.util().addEvent(document, 'DOMContentLoaded', this.start);
- }
- return this.finished = [];
- };
- WOW.prototype.start = function() {
- var box, _i, _len, _ref;
- this.stopped = false;
- this.boxes = (function() {
- var _i, _len, _ref, _results;
- _ref = this.element.querySelectorAll("." + this.config.boxClass);
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- box = _ref[_i];
- _results.push(box);
- }
- return _results;
- }).call(this);
- this.all = (function() {
- var _i, _len, _ref, _results;
- _ref = this.boxes;
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- box = _ref[_i];
- _results.push(box);
- }
- return _results;
- }).call(this);
- if (this.boxes.length) {
- if (this.disabled()) {
- this.resetStyle();
- } else {
- _ref = this.boxes;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- box = _ref[_i];
- this.applyStyle(box, true);
- }
- this.util().addEvent(window, 'scroll', this.scrollHandler);
- this.util().addEvent(window, 'resize', this.scrollHandler);
- this.interval = setInterval(this.scrollCallback, 50);
- }
- }
- if (this.config.live) {
- return new MutationObserver((function(_this) {
- return function(records) {
- var node, record, _j, _len1, _results;
- _results = [];
- for (_j = 0, _len1 = records.length; _j < _len1; _j++) {
- record = records[_j];
- _results.push((function() {
- var _k, _len2, _ref1, _results1;
- _ref1 = record.addedNodes || [];
- _results1 = [];
- for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
- node = _ref1[_k];
- _results1.push(this.doSync(node));
- }
- return _results1;
- }).call(_this));
- }
- return _results;
- };
- })(this)).observe(document.body, {
- childList: true,
- subtree: true
- });
- }
- };
- WOW.prototype.stop = function() {
- this.stopped = true;
- this.util().removeEvent(window, 'scroll', this.scrollHandler);
- this.util().removeEvent(window, 'resize', this.scrollHandler);
- if (this.interval != null) {
- return clearInterval(this.interval);
- }
- };
- WOW.prototype.sync = function(element) {
- if (MutationObserver.notSupported) {
- return this.doSync(this.element);
- }
- };
- WOW.prototype.doSync = function(element) {
- var box, _i, _len, _ref, _results;
- if (element == null) {
- element = this.element;
- }
- if (element.nodeType !== 1) {
- return;
- }
- element = element.parentNode || element;
- _ref = element.querySelectorAll("." + this.config.boxClass);
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- box = _ref[_i];
- if (__indexOf.call(this.all, box) < 0) {
- this.boxes.push(box);
- this.all.push(box);
- if (this.stopped || this.disabled()) {
- this.resetStyle();
- } else {
- this.applyStyle(box, true);
- }
- _results.push(this.scrolled = true);
- } else {
- _results.push(void 0);
- }
- }
- return _results;
- };
- WOW.prototype.show = function(box) {
- this.applyStyle(box);
- return box.className = "" + box.className + " " + this.config.animateClass;
- };
- WOW.prototype.applyStyle = function(box, hidden) {
- var delay, duration, iteration;
- duration = box.getAttribute('data-wow-duration');
- delay = box.getAttribute('data-wow-delay');
- iteration = box.getAttribute('data-wow-iteration');
- return this.animate((function(_this) {
- return function() {
- return _this.customStyle(box, hidden, duration, delay, iteration);
- };
- })(this));
- };
- WOW.prototype.animate = (function() {
- if ('requestAnimationFrame' in window) {
- return function(callback) {
- return window.requestAnimationFrame(callback);
- };
- } else {
- return function(callback) {
- return callback();
- };
- }
- })();
- WOW.prototype.resetStyle = function() {
- var box, _i, _len, _ref, _results;
- _ref = this.boxes;
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- box = _ref[_i];
- _results.push(box.style.visibility = 'visible');
- }
- return _results;
- };
- WOW.prototype.customStyle = function(box, hidden, duration, delay, iteration) {
- if (hidden) {
- this.cacheAnimationName(box);
- }
- box.style.visibility = hidden ? 'hidden' : 'visible';
- if (duration) {
- this.vendorSet(box.style, {
- animationDuration: duration
- });
- }
- if (delay) {
- this.vendorSet(box.style, {
- animationDelay: delay
- });
- }
- if (iteration) {
- this.vendorSet(box.style, {
- animationIterationCount: iteration
- });
- }
- this.vendorSet(box.style, {
- animationName: hidden ? 'none' : this.cachedAnimationName(box)
- });
- return box;
- };
- WOW.prototype.vendors = ["moz", "webkit"];
- WOW.prototype.vendorSet = function(elem, properties) {
- var name, value, vendor, _results;
- _results = [];
- for (name in properties) {
- value = properties[name];
- elem["" + name] = value;
- _results.push((function() {
- var _i, _len, _ref, _results1;
- _ref = this.vendors;
- _results1 = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- vendor = _ref[_i];
- _results1.push(elem["" + vendor + (name.charAt(0).toUpperCase()) + (name.substr(1))] = value);
- }
- return _results1;
- }).call(this));
- }
- return _results;
- };
- WOW.prototype.vendorCSS = function(elem, property) {
- var result, style, vendor, _i, _len, _ref;
- style = getComputedStyle(elem);
- result = style.getPropertyCSSValue(property);
- _ref = this.vendors;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- vendor = _ref[_i];
- result = result || style.getPropertyCSSValue("-" + vendor + "-" + property);
- }
- return result;
- };
- WOW.prototype.animationName = function(box) {
- var animationName;
- try {
- animationName = this.vendorCSS(box, 'animation-name').cssText;
- } catch (_error) {
- animationName = getComputedStyle(box).getPropertyValue('animation-name');
- }
- if (animationName === 'none') {
- return '';
- } else {
- return animationName;
- }
- };
- WOW.prototype.cacheAnimationName = function(box) {
- return this.animationNameCache.set(box, this.animationName(box));
- };
- WOW.prototype.cachedAnimationName = function(box) {
- return this.animationNameCache.get(box);
- };
- WOW.prototype.scrollHandler = function() {
- return this.scrolled = true;
- };
- WOW.prototype.scrollCallback = function() {
- var box;
- if (this.scrolled) {
- this.scrolled = false;
- this.boxes = (function() {
- var _i, _len, _ref, _results;
- _ref = this.boxes;
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- box = _ref[_i];
- if (!(box)) {
- continue;
- }
- if (this.isVisible(box)) {
- this.show(box);
- continue;
- }
- _results.push(box);
- }
- return _results;
- }).call(this);
- if (!(this.boxes.length || this.config.live)) {
- return this.stop();
- }
- }
- };
- WOW.prototype.offsetTop = function(element) {
- var top;
- while (element.offsetTop === void 0) {
- element = element.parentNode;
- }
- top = element.offsetTop;
- while (element = element.offsetParent) {
- top += element.offsetTop;
- }
- return top;
- };
- WOW.prototype.isVisible = function(box) {
- var bottom, offset, top, viewBottom, viewTop;
- offset = box.getAttribute('data-wow-offset') || this.config.offset;
- viewTop = window.pageYOffset;
- viewBottom = viewTop + Math.min(this.element.clientHeight, this.util().innerHeight()) - offset;
- top = this.offsetTop(box);
- bottom = top + box.clientHeight;
- return top <= viewBottom && bottom >= viewTop;
- };
- WOW.prototype.util = function() {
- return this._util != null ? this._util : this._util = new Util();
- };
- WOW.prototype.disabled = function() {
- return !this.config.mobile && this.util().isMobile(navigator.userAgent);
- };
- return WOW;
- })();
- }).call(this);
- ;(function ( $, window, document, undefined ) {
- "use strict";
- var
-
- $body = $("html, body"),
-
-
- consl = (window.console || false),
-
-
- defaults = {
-
- anchors : "a",
-
- prefetch : false,
-
-
- blacklist : ".no-smoothstate, [target]",
-
-
- development : false,
-
-
- pageCacheSize : 0,
-
-
- alterRequestUrl : function (url) {
- return url;
- },
-
-
- onStart : {
- duration: 0,
- render: function (url, $container) {
- $body.scrollTop(0);
- }
- },
-
- onProgress : {
- duration: 0,
- render: function (url, $container) {
- $body.css("cursor", "wait");
- $body.find("a").css("cursor", "wait");
- }
- },
-
- onEnd : {
- duration: 0,
- render: function (url, $container, $content) {
- $body.css("cursor", "auto");
- $body.find("a").css("cursor", "auto");
- $container.html($content);
- }
- },
-
- callback : function(url, $container, $content) {
- }
- },
-
-
- utility = {
-
- isExternal: function (url) {
- var match = url.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);
- if (typeof match[1] === "string" && match[1].length > 0 && match[1].toLowerCase() !== window.location.protocol) {
- return true;
- }
- if (typeof match[2] === "string" && match[2].length > 0 && match[2].replace(new RegExp(":(" + {"http:": 80, "https:": 443}[window.location.protocol] + ")?$"), "") !== window.location.host) {
- return true;
- }
- return false;
- },
-
- isHash: function (url) {
- var hasPathname = (url.indexOf(window.location.pathname) > 0) ? true : false,
- hasHash = (url.indexOf("#") > 0) ? true : false;
- return (hasPathname && hasHash) ? true : false;
- },
-
- shouldLoad: function ($anchor, blacklist) {
- var url = $anchor.prop("href");
-
- return (!utility.isExternal(url) && !utility.isHash(url) && !$anchor.is(blacklist));
- },
-
- htmlDoc: function (html) {
- var parent,
- elems = $(),
- matchTag = /<(\/?)(html|head|body|title|base|meta)(\s+[^>]*)?>/ig,
- prefix = "ss" + Math.round(Math.random() * 100000),
- htmlParsed = html.replace(matchTag, function(tag, slash, name, attrs) {
- var obj = {};
- if (!slash) {
- elems = elems.add("<" + name + "/>");
- if (attrs) {
- $.each($("<div" + attrs + "/>")[0].attributes, function(i, attr) {
- obj[attr.name] = attr.value;
- });
- }
- elems.eq(-1).attr(obj);
- }
- return "<" + slash + "div" + (slash ? "" : " id='" + prefix + (elems.length - 1) + "'") + ">";
- });
-
-
- if (!elems.length) {
- return $(html);
- }
-
- if (!parent) {
- parent = $("<div/>");
- }
-
- parent.html(htmlParsed);
-
-
- $.each(elems, function(i) {
- var elem = parent.find("#" + prefix + i).before(elems[i]);
- elems.eq(i).html(elem.contents());
- elem.remove();
- });
- return parent.children().unwrap();
- },
-
- clearIfOverCapacity: function (obj, cap) {
-
- if (!Object.keys) {
- Object.keys = function (obj) {
- var keys = [],
- k;
- for (k in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, k)) {
- keys.push(k);
- }
- }
- return keys;
- };
- }
- if (Object.keys(obj).length > cap) {
- obj = {};
- }
- return obj;
- },
-
- getContentById: function (id, $html) {
- $html = ($html instanceof jQuery) ? $html : utility.htmlDoc($html);
- var $insideElem = $html.find(id),
- updatedContainer = ($insideElem.length) ? $.trim($insideElem.html()) : $html.filter(id).html(),
- newContent = (updatedContainer.length) ? $(updatedContainer) : null;
- return newContent;
- },
-
- storePageIn: function (object, url, $html) {
- $html = ($html instanceof jQuery) ? $html : utility.htmlDoc($html);
- object[url] = {
- status: "loaded",
- title: $html.find("title").text(),
- html: $html
- };
- return object;
- },
-
- triggerAllAnimationEndEvent: function ($element, resetOn) {
- resetOn = " " + resetOn || "";
- var animationCount = 0,
- animationstart = "animationstart webkitAnimationStart oanimationstart MSAnimationStart",
- animationend = "animationend webkitAnimationEnd oanimationend MSAnimationEnd",
- eventname = "allanimationend",
- onAnimationStart = function (e) {
- if ($(e.delegateTarget).is($element)) {
- e.stopPropagation();
- animationCount ++;
- }
- },
- onAnimationEnd = function (e) {
- if ($(e.delegateTarget).is($element)) {
- e.stopPropagation();
- animationCount --;
- if(animationCount === 0) {
- $element.trigger(eventname);
- }
- }
- };
- $element.on(animationstart, onAnimationStart);
- $element.on(animationend, onAnimationEnd);
- $element.on("allanimationend" + resetOn, function(){
- animationCount = 0;
- utility.redraw($element);
- });
- },
-
- redraw: function ($element) {
- $element.height(0);
- setTimeout(function(){$element.height("auto");}, 0);
- }
- },
-
- onPopState = function ( e ) {
- if(e.state !== null) {
- var url = window.location.href,
- $page = $("#" + e.state.id),
- page = $page.data("smoothState");
-
- if(page.href !== url && !utility.isHash(url)) {
- page.load(url, true);
- }
- }
- },
-
- SmoothState = function ( element, options ) {
- var
-
- $container = $(element),
-
-
- cache = {},
-
-
- currentHref = window.location.href,
-
- load = function (url, isPopped) {
-
-
- isPopped = isPopped || false;
- var
-
- hasRunCallback = false,
- callbBackEnded = false,
-
-
- responses = {
-
- loaded: function() {
- var eventName = hasRunCallback ? "ss.onProgressEnd" : "ss.onStartEnd";
- if(!callbBackEnded || !hasRunCallback) {
- $container.one(eventName, function(){
- updateContent(url);
- });
- } else if(callbBackEnded) {
- updateContent(url);
- }
- if(!isPopped) {
- window.history.pushState({ id: $container.prop("id") }, cache[url].title, url);
- }
- },
-
- fetching: function() {
-
- if(!hasRunCallback) {
-
- hasRunCallback = true;
-
-
- $container.one("ss.onStartEnd", function(){
- options.onProgress.render(url, $container, null);
-
- setTimeout(function(){
- $container.trigger("ss.onProgressEnd");
- callbBackEnded = true;
- }, options.onStart.duration);
-
- });
- }
-
- setTimeout(function () {
-
- if(cache.hasOwnProperty(url)){
- responses[cache[url].status]();
- }
- }, 10);
- },
-
- error: function(){
- window.location = url;
- }
- };
-
- if (!cache.hasOwnProperty(url)) {
- fetch(url);
- }
-
-
- options.onStart.render(url, $container, null);
- setTimeout(function(){
- $container.trigger("ss.onStartEnd");
- }, options.onStart.duration);
-
- responses[cache[url].status]();
- },
-
- updateContent = function (url) {
-
- var containerId = "#" + $container.prop("id"),
- $content = cache[url] ? utility.getContentById(containerId, cache[url].html) : null;
- if($content) {
- document.title = cache[url].title;
- $container.data("smoothState").href = url;
-
-
- options.onEnd.render(url, $container, $content);
- $container.one("ss.onEndEnd", function(){
- options.callback(url, $container, $content);
- });
- setTimeout(function(){
- $container.trigger("ss.onEndEnd");
- }, options.onEnd.duration);
- } else if (!$content && options.development && consl) {
-
- consl.warn("No element with an id of " + containerId + " in response from " + url + " in " + cache);
- } else {
-
- window.location = url;
- }
- },
-
- fetch = function (url) {
-
- if(cache.hasOwnProperty(url)) {
- return;
- }
- cache = utility.clearIfOverCapacity(cache, options.pageCacheSize);
-
- cache[url] = { status: "fetching" };
- var requestUrl = options.alterRequestUrl(url) || url,
- request = $.ajax(requestUrl);
-
- request.success(function (html) {
-
- utility.storePageIn(cache, url, html);
- $container.data("smoothState").cache = cache;
- });
-
- request.error(function () {
- cache[url].status = "error";
- });
- },
-
- hoverAnchor = function (event) {
- var $anchor = $(event.currentTarget),
- url = $anchor.prop("href");
- if (utility.shouldLoad($anchor, options.blacklist)) {
- event.stopPropagation();
- fetch(url);
- }
- },
-
- clickAnchor = function (event) {
- var $anchor = $(event.currentTarget),
- url = $anchor.prop("href");
-
- if (!event.metaKey && !event.ctrlKey && utility.shouldLoad($anchor, options.blacklist)) {
-
- event.stopPropagation();
- event.preventDefault();
- load(url);
- }
- },
-
- bindEventHandlers = function ($element) {
-
- $element.on("click", options.anchors, clickAnchor);
- if (options.prefetch) {
- $element.on("mouseover touchstart", options.anchors, hoverAnchor);
- }
- },
-
- toggleAnimationClass = function (classname) {
- var classes = $container.addClass(classname).prop("class");
-
- $container.removeClass(classes);
-
- setTimeout(function(){
- $container.addClass(classes);
- },0);
- $container.one("ss.onStartEnd ss.onProgressEnd ss.onEndEnd", function(){
- $container.removeClass(classname);
- });
-
- };
-
- options = $.extend(defaults, options);
-
- if(window.history.state === null) {
- window.history.replaceState({ id: $container.prop("id") }, document.title, currentHref);
- }
-
- utility.storePageIn(cache, currentHref, document.documentElement.outerHTML);
-
- utility.triggerAllAnimationEndEvent($container, "ss.onStartEnd ss.onProgressEnd ss.onEndEnd");
-
- bindEventHandlers($container);
-
- return {
- href: currentHref,
- cache: cache,
- load: load,
- fetch: fetch,
- toggleAnimationClass: toggleAnimationClass
- };
- },
-
- declareSmoothState = function ( options ) {
- return this.each(function () {
-
- if(this.id && !$.data(this, "smoothState")) {
-
- $.data(this, "smoothState", new SmoothState(this, options));
- } else if (!this.id && consl) {
-
- consl.warn("Every smoothState container needs an id but the following one does not have one:", this);
- }
- });
- };
-
- window.onpopstate = onPopState;
-
- $.smoothStateUtility = utility;
-
- $.fn.smoothState = declareSmoothState;
- })(jQuery, window, document);
|