scripts.js 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984
  1. // ------------- JQUERY Wallpaper------------------------------------------- //
  2. // ============ https://github.com/Formstone/Wallpaper ===================== //
  3. // ------------------------------------------------------------------------- //
  4. !function(a,b){"use strict";function c(b){var c=a.extend({},F,b);t=a("body"),u=s(),v=u!==!1,v||(u="transitionend.wallpaper");for(var e=a(this),f=0,g=e.length;g>f;f++)d.apply(e.eq(f),[a.extend({},c)]);return t.hasClass("wallpaper-inititalized")||(t.addClass("wallpaper-inititalized"),x.on("resize.wallpaper",c,l)),e}function d(b){var c=a(this);if(!c.hasClass("wallpaper")){a.extend(b,c.data("wallpaper-options")),c.addClass("wallpaper").append('<div class="wallpaper-container"></div>'),b.guid="wallpaper-"+A++,b.youTubeGuid=0,b.$target=c,b.$container=b.$target.find(".wallpaper-container"),b.$target.data("wallpaper",b).on("resize.wallpaper",b,k);var d=b.source;b.source=null,e(d,b,!0),b.onReady.call()}}function e(a,c,d){if(a!==c.source){if(c.source=a,c.isYouTube=!1,"object"==typeof a&&"string"==typeof a.video){var e=a.video.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i);e&&e.length>=1&&(c.isYouTube=!0,c.videoId=e[1])}if(c.isYouTube)c.playing=!1,c.playerReady=!1,c.posterLoaded=!1,h(a,c,d);else if("object"!=typeof a||a.hasOwnProperty("fallback")){if(c.responsiveSource)for(var i in c.responsiveSource)c.responsiveSource.hasOwnProperty(i)&&c.responsiveSource[i].mq.removeListener(m);if(c.responsive=!1,c.responsiveSource=null,"object"==typeof a){var j,k=[];for(var l in a)if(a.hasOwnProperty(l)){var n="fallback"===l?"(min-width: 0px)":l;if(n){var o=b.matchMedia(n.replace(1/0,"100000px"));o.addListener(m),k.push({mq:o,source:a[l]}),o.matches&&(j=a[l])}}c.responsive=!0,c.responsiveSource=k,a=j}f(a,c,!1,d)}else g(a,c,d)}else c.$target.trigger("wallpaper.loaded"),c.onLoad.call(c.$target)}function f(b,c,d,e){var f=a('<div class="wallpaper-media wallpaper-image'+(e!==!0?" animated":"")+'"><img /></div>'),g=f.find("img"),h=b;g.one("load.wallpaper",function(){z&&f.addClass("native").css({backgroundImage:"url('"+h+"')"}),f.on(u,function(b){r(b),a(b.target).is(f)&&(f.off(u),d||i(c))}),setTimeout(function(){f.css({opacity:1}),c.responsive&&e&&i(c)},0),k({data:c}),(!d||e)&&(c.$target.trigger("wallpaper.loaded"),c.onLoad.call(c.$target)),y=a(".wallpaper-responsive")}).attr("src",h),c.responsive&&f.addClass("wallpaper-responsive"),c.$container.append(f),(g[0].complete||4===g[0].readyState)&&g.trigger("load.wallpaper")}function g(b,c,d){if(c.source.poster&&(f(c.source.poster,c,!0,!0),d=!1),!E){var e='<div class="wallpaper-media wallpaper-video'+(d!==!0?" animated":"")+'">';e+="<video",c.loop&&(e+=" loop"),c.mute&&(e+=" muted"),e+=">",c.source.webm&&(e+='<source src="'+c.source.webm+'" type="video/webm" />'),c.source.mp4&&(e+='<source src="'+c.source.mp4+'" type="video/mp4" />'),c.source.ogg&&(e+='<source src="'+c.source.ogg+'" type="video/ogg" />'),e+="</video>",e+="</div>";var g=a(e),h=g.find("video");h.one("loadedmetadata.wallpaper",function(){g.on(u,function(b){r(b),a(b.target).is(g)&&(g.off(u),i(c))}),setTimeout(function(){g.css({opacity:1})},0),k({data:c}),c.$target.trigger("wallpaper.loaded"),c.onLoad.call(c.$target),c.hoverPlay?c.$target.on("mouseover.boxer",G.play).on("mouseout.boxer",G.pause):c.autoPlay&&this.play()}),c.$container.append(g)}}function h(c,d,e){if(!d.videoId){var g=c.match(/^.*(?:youtu.be\/|v\/|e\/|u\/\w+\/|embed\/|v=)([^#\&\?]*).*/);d.videoId=g[1]}if(d.posterLoaded||(d.source.poster||(d.source.poster="http://img.youtube.com/vi/"+d.videoId+"/0.jpg"),d.posterLoaded=!0,f(d.source.poster,d,!0,e),e=!1),!E)if(a("script[src*='youtube.com/iframe_api']").length||a("head").append('<script src="//www.youtube.com/iframe_api"></script>'),B){var h=d.guid+"_"+d.youTubeGuid++,j="";j+='<div class="wallpaper-media wallpaper-embed'+(e!==!0?" animated":"")+'">',j+='<div id="'+h+'"></div>',j+="</div>";var l=a(j);d.$container.append(l),d.player&&(d.oldPlayer=d.player,d.player=null),d.player=new b.YT.Player(h,{videoId:d.videoId,playerVars:{controls:0,rel:0,showinfo:0,wmode:"transparent",enablejsapi:1,version:3,playerapiid:h,loop:d.loop?1:0,autoplay:1,origin:b.location.protocol+"//"+b.location.host},events:{onReady:function(){d.playerReady=!0,d.mute&&d.player.mute(),d.hoverPlay?d.$target.on("mouseover.boxer",G.play).on("mouseout.boxer",G.pause):d.autoPlay&&d.player.playVideo()},onStateChange:function(c){d.playing||c.data!==b.YT.PlayerState.PLAYING?d.loop&&d.playing&&c.data===b.YT.PlayerState.ENDED&&d.player.playVideo():(d.playing=!0,(d.hoverPlay||!d.autoPlay)&&d.player.pauseVideo(),d.$target.trigger("wallpaper.loaded"),d.onLoad.call(d.$target),l.on(u,function(b){r(b),a(b.target).is(l)&&(l.off(u),i(d))}),l.css({opacity:1})),d.$target.find(".wallpaper-embed").addClass("ready")},onPlaybackQualityChange:function(){},onPlaybackRateChange:function(){},onError:function(){},onApiChange:function(){}}}),k({data:d})}else C.push({source:c,data:d})}function i(b){var c=b.$container.find(".wallpaper-media");c.length>=1&&(c.not(":last").remove(),b.oldPlayer=null),y=a(".wallpaper-responsive")}function j(b){var c=b.$container.find(".wallpaper-media");c.length>=1&&c.on(u,function(d){r(d),a(d.target).is(c)&&(a(this).remove(),delete b.source)}).css({opacity:0})}function k(a){r(a);for(var b=a.data,c=b.$container.find(".wallpaper-media"),d=0,e=c.length;e>d;d++){var f=c.eq(d),g=b.isYouTube?"iframe":f.find("video").length?"video":"img",h=f.find(g);if(h.length&&("img"!==g||!b.nativeSupport)){var i=b.$target.outerWidth(),j=b.$target.outerHeight(),k=q(b,h);b.width=k.naturalWidth,b.height=k.naturalHeight,b.left=0,b.top=0;var l=b.isYouTube?b.embedRatio:b.width/b.height;b.height=j,b.width=b.height*l,b.width<i&&(b.width=i,b.height=b.width/l),b.left=-(b.width-i)/2,b.top=-(b.height-j)/2,f.css({height:b.height,width:b.width,left:b.left,top:b.top})}}}function l(){a(".wallpaper").each(function(){var b=a(this).data("wallpaper");k({data:b})})}function m(){w=o(w,5,n)}function n(){p(w),y.each(function(){for(var b=a(this),c=(b.find("img"),b.parents(".wallpaper").data("wallpaper")),d=c.responsiveSource,e=0,g=0,h=d.length;h>g;g++)if(d.hasOwnProperty(g)){var i=d[g].mq;i&&i.matches&&(e=g)}f(d[e].source,c,!1,!0),b.trigger("change.wallpaper")})}function o(a,b,c,d){return p(a,d),setTimeout(c,b)}function p(a){null!==a&&(clearInterval(a),a=null)}function q(a,b){if(a.isYouTube)return{naturalHeight:500,naturalWidth:500/a.embedRatio};if(b.is("img")){var c=b[0];if("undefined"!=typeof c.naturalHeight)return{naturalHeight:c.naturalHeight,naturalWidth:c.naturalWidth};var d=new Image;return d.src=c.src,{naturalHeight:d.height,naturalWidth:d.width}}return{naturalHeight:b[0].videoHeight,naturalWidth:b[0].videoWidth}}function r(a){a.preventDefault&&(a.stopPropagation(),a.preventDefault())}function s(){var a={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",transition:"transitionend"},b=document.createElement("div");for(var c in a)if(a.hasOwnProperty(c)&&c in b.style)return a[c]+".wallpaper";return!1}var t,u,v,w,x=a(b),y=null,z="backgroundSize"in document.documentElement.style,A=0,B=!1,C=[],D=b.navigator.userAgent||b.navigator.vendor||b.opera,E=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(D),F=(D.toLowerCase().indexOf("safari")>=0&&D.toLowerCase().indexOf("chrome")<0,{autoPlay:!0,embedRatio:1.777777,hoverPlay:!1,loop:!0,mute:!0,onLoad:a.noop,onReady:a.noop,source:null}),G={defaults:function(b){return F=a.extend(F,b||{}),"object"==typeof this?a(this):!0},destroy:function(){var b=a(this).each(function(){var b=a(this).data("wallpaper");b&&(b.$container.remove(),b.$target.removeClass("wallpaper").off(".boxer").data("wallpaper",null))});return"undefined"!=typeof t&&"undefined"!=typeof x&&a(".wallpaper").length<1&&(t.removeClass("wallpaper-inititalized"),x.off(".wallpaper")),b},load:function(b){return a(this).each(function(){var c=a(this).data("wallpaper");c&&e(b,c)})},pause:function(){return a(this).each(function(){var b=a(this).data("wallpaper");if(b)if(b.isYouTube&&b.playerReady)b.player.pauseVideo();else{var c=b.$container.find("video");c.length&&c[0].pause()}})},play:function(){return a(this).each(function(){var b=a(this).data("wallpaper");if(b)if(b.isYouTube&&b.playerReady)b.player.playVideo();else{var c=b.$container.find("video");c.length&&c[0].play()}})},stop:function(){G.pause.apply(this)},unload:function(){return a(this).each(function(){var b=a(this).data("wallpaper");b&&j(b)})}};b.onYouTubeIframeAPIReady=function(){B=!0;for(var a in C)C.hasOwnProperty(a)&&h(C[a].source,C[a].data);C=[]},a.fn.wallpaper=function(a){return G[a]?G[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:c.apply(this,arguments)},a.wallpaper=function(a){"defaults"===a&&G.defaults.apply(this,Array.prototype.slice.call(arguments,1))}}(jQuery,window);
  5. // ------------- JQUERY APPEAR ---------------------------------------------- //
  6. // ============ https://github.com/morr/jquery.appear ====================== //
  7. // -------------------------------------------------------------------------- //
  8. (function($) {
  9. var selectors = [];
  10. var check_binded = false;
  11. var check_lock = false;
  12. var defaults = {
  13. interval: 250,
  14. force_process: false
  15. }
  16. var $window = $(window);
  17. var $prior_appeared;
  18. function process() {
  19. check_lock = false;
  20. for (var index = 0, selectorsLength = selectors.length; index < selectorsLength; index++) {
  21. var $appeared = $(selectors[index]).filter(function() {
  22. return $(this).is(':appeared');
  23. });
  24. $appeared.trigger('appear', [$appeared]);
  25. if ($prior_appeared) {
  26. var $disappeared = $prior_appeared.not($appeared);
  27. $disappeared.trigger('disappear', [$disappeared]);
  28. }
  29. $prior_appeared = $appeared;
  30. }
  31. }
  32. // "appeared" custom filter
  33. $.expr[':']['appeared'] = function(element) {
  34. var $element = $(element);
  35. if (!$element.is(':visible')) {
  36. return false;
  37. }
  38. var window_left = $window.scrollLeft();
  39. var window_top = $window.scrollTop();
  40. var offset = $element.offset();
  41. var left = offset.left;
  42. var top = offset.top;
  43. if (top + $element.height() >= window_top &&
  44. top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() &&
  45. left + $element.width() >= window_left &&
  46. left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) {
  47. return true;
  48. } else {
  49. return false;
  50. }
  51. }
  52. $.fn.extend({
  53. // watching for element's appearance in browser viewport
  54. appear: function(options) {
  55. var opts = $.extend({}, defaults, options || {});
  56. var selector = this.selector || this;
  57. if (!check_binded) {
  58. var on_check = function() {
  59. if (check_lock) {
  60. return;
  61. }
  62. check_lock = true;
  63. setTimeout(process, opts.interval);
  64. };
  65. $(window).scroll(on_check).resize(on_check);
  66. check_binded = true;
  67. }
  68. if (opts.force_process) {
  69. setTimeout(process, opts.interval);
  70. }
  71. selectors.push(selector);
  72. return $(selector);
  73. }
  74. });
  75. $.extend({
  76. // force elements's appearance check
  77. force_appear: function() {
  78. if (check_binded) {
  79. process();
  80. return true;
  81. };
  82. return false;
  83. }
  84. });
  85. })(jQuery);
  86. // ------------- DRAW FILL SVG ---------------------------------------------- //
  87. // ============ https://github.com/callmenick/Draw-Fill-SVG ================= //
  88. // -------------------------------------------------------------------------- //
  89. (function( window ){
  90. 'use strict';
  91. /**
  92. * Cross browser transition end events
  93. *
  94. * Use modernizr to detect cross browser transition end events. Make sure
  95. * to include Modernizr in your doc and have "Modernizr.prefixed()" checked
  96. * off in the extensibility section.
  97. */
  98. var transEndEventNames = {
  99. "WebkitTransition" : "webkitTransitionEnd",
  100. "MozTransition" : "transitionend",
  101. "OTransition" : "oTransitionEnd",
  102. "msTransition" : "MSTransitionEnd",
  103. "transition" : "transitionend"
  104. },
  105. transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ];
  106. /**
  107. * Extend obj function
  108. *
  109. */
  110. function extend( a, b ) {
  111. for( var key in b ) {
  112. if( b.hasOwnProperty( key ) ) {
  113. a[key] = b[key];
  114. }
  115. }
  116. return a;
  117. }
  118. /**
  119. * DrawFillSVG constructor
  120. *
  121. */
  122. function DrawFillSVG( options ) {
  123. this.options = extend( {}, this.options );
  124. extend( this.options, options );
  125. this._init();
  126. }
  127. /**
  128. * DrawFillSVG options
  129. *
  130. * Available options:
  131. * elementId - the ID of the element to draw
  132. */
  133. DrawFillSVG.prototype.options = {
  134. elementId : "svg"
  135. }
  136. /**
  137. * DrawFillSVG _init
  138. *
  139. * Initialise DrawFillSVG
  140. */
  141. DrawFillSVG.prototype._init = function() {
  142. this.svg = document.getElementById(this.options.elementId);
  143. this.paths = this.svg.querySelectorAll("path");
  144. this._initAnimation();
  145. }
  146. /**
  147. * DrawFillSVG _initAnimation()
  148. *
  149. * Reset some style properties on our paths, add some transitions, set the
  150. * stroke-dasharray to the length of the path, and the stroke-dashoffset to
  151. * the length of the path pushing it out of view initially. Then, set the
  152. * stroke-dashoffset to 0, animating the strokes in a drawing manner. Then,
  153. * run the path filler sequence.
  154. */
  155. DrawFillSVG.prototype._initAnimation = function() {
  156. for ( var i = 0; i < this.paths.length; i++ ) {
  157. var path = this.paths[i];
  158. var length = path.getTotalLength();
  159. // reset opacities
  160. path.style.fillOpacity = 0;
  161. path.style.strokeOpacity = 1;
  162. // reset transitions
  163. path.style.transition = path.style.WebkitTransition = "none";
  164. // reset stroke dash array and stroke dash offset
  165. path.style.strokeDasharray = length + " " + length;
  166. path.style.strokeDashoffset = length;
  167. path.getBoundingClientRect();
  168. // apply new transitions
  169. path.style.transition = path.style.WebkitTransition = "stroke-dashoffset 2s ease-in-out";
  170. // go baby go
  171. path.style.strokeDashoffset = 0;
  172. // fill the path
  173. this._fillPath( path );
  174. }
  175. }
  176. /**
  177. * DrawFillSVG _fillPath()
  178. *
  179. * Resets the transition props, then fills the path and fades out the stroke
  180. * by updating the styles.
  181. */
  182. DrawFillSVG.prototype._fillPath = function( path ) {
  183. path.addEventListener( transEndEventName, function() {
  184. // reset transitions
  185. path.style.transition = path.style.WebkitTransition = "none";
  186. path.style.transition = path.style.WebkitTransition = "fill-opacity 1s ease-in-out, stroke-opacity 1s ease-in-out";
  187. // edit props
  188. path.style.fillOpacity = 1;
  189. path.style.strokeOpacity = 0;
  190. } );
  191. }
  192. /**
  193. * DrawFillSVG replay
  194. *
  195. * A public function that allows you to replay the animation if you want. For
  196. * example, click a button, and replay the animation.
  197. */
  198. DrawFillSVG.prototype.replay = function() {
  199. this._initAnimation();
  200. }
  201. /**
  202. * Add to global namespace
  203. */
  204. window.DrawFillSVG = DrawFillSVG;
  205. })( window );
  206. // ------------- JQUERY TYPED.JS -------------------------------------------- //
  207. // ============ https://github.com/mattboldt/typed.js/ ====================== //
  208. // -------------------------------------------------------------------------- //
  209. !function($){
  210. "use strict";
  211. var Typed = function(el, options){
  212. // chosen element to manipulate text
  213. this.el = $(el);
  214. // options
  215. this.options = $.extend({}, $.fn.typed.defaults, options);
  216. // text content of element
  217. this.baseText = this.el.text() || this.el.attr('placeholder') || '';
  218. // typing speed
  219. this.typeSpeed = this.options.typeSpeed;
  220. // add a delay before typing starts
  221. this.startDelay = this.options.startDelay;
  222. // backspacing speed
  223. this.backSpeed = this.options.backSpeed;
  224. // amount of time to wait before backspacing
  225. this.backDelay = this.options.backDelay;
  226. // input strings of text
  227. this.strings = this.options.strings;
  228. // character number position of current string
  229. this.strPos = 0;
  230. // current array position
  231. this.arrayPos = 0;
  232. // number to stop backspacing on.
  233. // default 0, can change depending on how many chars
  234. // you want to remove at the time
  235. this.stopNum = 0;
  236. // Looping logic
  237. this.loop = this.options.loop;
  238. this.loopCount = this.options.loopCount;
  239. this.curLoop = 0;
  240. // for stopping
  241. this.stop = false;
  242. // show cursor
  243. this.showCursor = this.isInput ? false : this.options.showCursor;
  244. // custom cursor
  245. this.cursorChar = this.options.cursorChar;
  246. // attribute to type
  247. this.isInput = this.el.is('input');
  248. this.attr = this.options.attr || (this.isInput ? 'placeholder' : null);
  249. // All systems go!
  250. this.build();
  251. };
  252. Typed.prototype = {
  253. constructor: Typed
  254. , init: function(){
  255. // begin the loop w/ first current string (global self.string)
  256. // current string will be passed as an argument each time after this
  257. var self = this;
  258. self.timeout = setTimeout(function() {
  259. // Start typing
  260. self.typewrite(self.strings[self.arrayPos], self.strPos);
  261. }, self.startDelay);
  262. }
  263. , build: function(){
  264. // Insert cursor
  265. if (this.showCursor === true){
  266. this.cursor = $("<span class=\"typed-cursor\">" + this.cursorChar + "</span>");
  267. this.el.after(this.cursor);
  268. }
  269. this.init();
  270. }
  271. // pass current string state to each function, types 1 char per call
  272. , typewrite: function(curString, curStrPos){
  273. // exit when stopped
  274. if(this.stop === true)
  275. return;
  276. // varying values for setTimeout during typing
  277. // can't be global since number changes each time loop is executed
  278. var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;
  279. var self = this;
  280. // ------------- optional ------------- //
  281. // backpaces a certain string faster
  282. // ------------------------------------ //
  283. // if (self.arrayPos == 1){
  284. // self.backDelay = 50;
  285. // }
  286. // else{ self.backDelay = 500; }
  287. // contain typing function in a timeout humanize'd delay
  288. self.timeout = setTimeout(function() {
  289. // check for an escape character before a pause value
  290. // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
  291. // single ^ are removed from string
  292. var charPause = 0;
  293. var substr = curString.substr(curStrPos);
  294. if (substr.charAt(0) === '^') {
  295. var skip = 1; // skip atleast 1
  296. if(/^\^\d+/.test(substr)) {
  297. substr = /\d+/.exec(substr)[0];
  298. skip += substr.length;
  299. charPause = parseInt(substr);
  300. }
  301. // strip out the escape character and pause value so they're not printed
  302. curString = curString.substring(0,curStrPos)+curString.substring(curStrPos+skip);
  303. }
  304. // timeout for any pause after a character
  305. self.timeout = setTimeout(function() {
  306. if(curStrPos === curString.length) {
  307. // fires callback function
  308. self.options.onStringTyped(self.arrayPos);
  309. // is this the final string
  310. if(self.arrayPos === self.strings.length-1) {
  311. // animation that occurs on the last typed string
  312. self.options.callback();
  313. self.curLoop++;
  314. // quit if we wont loop back
  315. if(self.loop === false || self.curLoop === self.loopCount)
  316. return;
  317. }
  318. self.timeout = setTimeout(function(){
  319. self.backspace(curString, curStrPos);
  320. }, self.backDelay);
  321. } else {
  322. /* call before functions if applicable */
  323. if(curStrPos === 0)
  324. self.options.preStringTyped(self.arrayPos);
  325. // start typing each new char into existing string
  326. // curString: arg, self.baseText: original text inside element
  327. var nextString = self.baseText + curString.substr(0, curStrPos+1);
  328. if (self.attr) {
  329. self.el.attr(self.attr, nextString);
  330. } else {
  331. self.el.text(nextString);
  332. }
  333. // add characters one by one
  334. curStrPos++;
  335. // loop the function
  336. self.typewrite(curString, curStrPos);
  337. }
  338. // end of character pause
  339. }, charPause);
  340. // humanized value for typing
  341. }, humanize);
  342. }
  343. , backspace: function(curString, curStrPos){
  344. // exit when stopped
  345. if (this.stop === true) {
  346. return;
  347. }
  348. // varying values for setTimeout during typing
  349. // can't be global since number changes each time loop is executed
  350. var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed;
  351. var self = this;
  352. self.timeout = setTimeout(function() {
  353. // ----- this part is optional ----- //
  354. // check string array position
  355. // on the first string, only delete one word
  356. // the stopNum actually represents the amount of chars to
  357. // ------------- CUSTOM OPTIONS --------------------------------------------- //
  358. // ========================================================================== //
  359. // -------------------------------------------------------------------------- //
  360. if (self.arrayPos == 1) {
  361. self.stopNum = 17;
  362. self.backDelay = 500;
  363. }
  364. else if (self.arrayPos == 2) {
  365. self.stopNum = 54;
  366. }
  367. else{self.stopNum = 0;}
  368. // ----- continue important stuff ----- //
  369. // replace text with base text + typed characters
  370. var nextString = self.baseText + curString.substr(0, curStrPos);
  371. if (self.attr) {
  372. self.el.attr(self.attr, nextString);
  373. } else {
  374. self.el.text(nextString);
  375. }
  376. // if the number (id of character in current string) is
  377. // less than the stop number, keep going
  378. if (curStrPos > self.stopNum){
  379. // subtract characters one by one
  380. curStrPos--;
  381. // loop the function
  382. self.backspace(curString, curStrPos);
  383. }
  384. // if the stop number has been reached, increase
  385. // array position to next string
  386. else if (curStrPos <= self.stopNum) {
  387. self.arrayPos++;
  388. if(self.arrayPos === self.strings.length) {
  389. self.arrayPos = 0;
  390. self.init();
  391. } else
  392. self.typewrite(self.strings[self.arrayPos], curStrPos);
  393. }
  394. // humanized value for typing
  395. }, humanize);
  396. }
  397. // Start & Stop currently not working
  398. // , stop: function() {
  399. // var self = this;
  400. // self.stop = true;
  401. // clearInterval(self.timeout);
  402. // }
  403. // , start: function() {
  404. // var self = this;
  405. // if(self.stop === false)
  406. // return;
  407. // this.stop = false;
  408. // this.init();
  409. // }
  410. // Reset and rebuild the element
  411. , reset: function(){
  412. var self = this;
  413. clearInterval(self.timeout);
  414. var id = this.el.attr('id');
  415. this.el.after('<span id="' + id + '"/>')
  416. this.el.remove();
  417. this.cursor.remove();
  418. // Send the callback
  419. self.options.resetCallback();
  420. }
  421. };
  422. $.fn.typed = function (option) {
  423. return this.each(function () {
  424. var $this = $(this)
  425. , data = $this.data('typed')
  426. , options = typeof option == 'object' && option;
  427. if (!data) $this.data('typed', (data = new Typed(this, options)));
  428. if (typeof option == 'string') data[option]();
  429. });
  430. };
  431. $.fn.typed.defaults = {
  432. strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
  433. // typing speed
  434. typeSpeed: 0,
  435. // time before typing starts
  436. startDelay: 0,
  437. // backspacing speed
  438. backSpeed: 0,
  439. // time before backspacing
  440. backDelay: 500,
  441. // loop
  442. loop: false,
  443. // false = infinite
  444. loopCount: false,
  445. // show cursor
  446. showCursor: true,
  447. // character for cursor
  448. cursorChar: "|",
  449. // attribute to type (null == text)
  450. attr: null,
  451. // call when done callback function
  452. callback: function() {},
  453. // starting callback function before each string
  454. preStringTyped: function() {},
  455. //callback for every typed string
  456. onStringTyped: function() {},
  457. // callback for reset
  458. resetCallback: function() {}
  459. };
  460. }(window.jQuery);
  461. // ------------- JQUERY SCROLLTO--------------------------------------------- //
  462. // ============ https://github.com/balupton/jquery-scrollto ================= //
  463. // -------------------------------------------------------------------------- //
  464. /*global define:false require:false */
  465. (function (name, context, definition) {
  466. if (typeof module != 'undefined' && module.exports) module.exports = definition();
  467. else if (typeof define == 'function' && define.amd) define(definition);
  468. else context[name] = definition();
  469. })('jquery-scrollto', this, function(){
  470. // Prepare
  471. var jQuery, $, ScrollTo;
  472. jQuery = $ = window.jQuery || require('jquery');
  473. // Fix scrolling animations on html/body on safari
  474. $.propHooks.scrollTop = $.propHooks.scrollLeft = {
  475. get: function(elem,prop) {
  476. var result = null;
  477. if ( elem.tagName === 'HTML' || elem.tagName === 'BODY' ) {
  478. if ( prop === 'scrollLeft' ) {
  479. result = window.scrollX;
  480. } else if ( prop === 'scrollTop' ) {
  481. result = window.scrollY;
  482. }
  483. }
  484. if ( result == null ) {
  485. result = elem[prop];
  486. }
  487. return result;
  488. }
  489. };
  490. $.Tween.propHooks.scrollTop = $.Tween.propHooks.scrollLeft = {
  491. get: function(tween) {
  492. return $.propHooks.scrollTop.get(tween.elem, tween.prop);
  493. },
  494. set: function(tween) {
  495. // Our safari fix
  496. if ( tween.elem.tagName === 'HTML' || tween.elem.tagName === 'BODY' ) {
  497. // Defaults
  498. tween.options.bodyScrollLeft = (tween.options.bodyScrollLeft || window.scrollX);
  499. tween.options.bodyScrollTop = (tween.options.bodyScrollTop || window.scrollY);
  500. // Apply
  501. if ( tween.prop === 'scrollLeft' ) {
  502. tween.options.bodyScrollLeft = Math.round(tween.now);
  503. }
  504. else if ( tween.prop === 'scrollTop' ) {
  505. tween.options.bodyScrollTop = Math.round(tween.now);
  506. }
  507. // Apply
  508. window.scrollTo(tween.options.bodyScrollLeft, tween.options.bodyScrollTop);
  509. }
  510. // jQuery's IE8 Fix
  511. else if ( tween.elem.nodeType && tween.elem.parentNode ) {
  512. tween.elem[ tween.prop ] = tween.now;
  513. }
  514. }
  515. };
  516. // jQuery ScrollTo
  517. ScrollTo = {
  518. // Configuration
  519. config: {
  520. duration: 400,
  521. easing: 'swing',
  522. callback: undefined,
  523. durationMode: 'each',
  524. offsetTop: 0,
  525. offsetLeft: 0
  526. },
  527. // Set Configuration
  528. configure: function(options){
  529. // Apply Options to Config
  530. $.extend(ScrollTo.config, options||{});
  531. // Chain
  532. return this;
  533. },
  534. // Perform the Scroll Animation for the Collections
  535. // We use $inline here, so we can determine the actual offset start for each overflow:scroll item
  536. // Each collection is for each overflow:scroll item
  537. scroll: function(collections, config){
  538. // Prepare
  539. var collection, $container, container, $target, $inline, position, containerTagName,
  540. containerScrollTop, containerScrollLeft,
  541. containerScrollTopEnd, containerScrollLeftEnd,
  542. startOffsetTop, targetOffsetTop, targetOffsetTopAdjusted,
  543. startOffsetLeft, targetOffsetLeft, targetOffsetLeftAdjusted,
  544. scrollOptions,
  545. callback;
  546. // Determine the Scroll
  547. collection = collections.pop();
  548. $container = collection.$container;
  549. $target = collection.$target;
  550. containerTagName = $container.prop('tagName');
  551. // Prepare the Inline Element of the Container
  552. $inline = $('<span/>').css({
  553. 'position': 'absolute',
  554. 'top': '0px',
  555. 'left': '0px'
  556. });
  557. position = $container.css('position');
  558. // Insert the Inline Element of the Container
  559. $container.css({position:'relative'});
  560. $inline.appendTo($container);
  561. // Determine the top offset
  562. startOffsetTop = $inline.offset().top;
  563. targetOffsetTop = $target.offset().top;
  564. targetOffsetTopAdjusted = targetOffsetTop - startOffsetTop - parseInt(config.offsetTop,10);
  565. // Determine the left offset
  566. startOffsetLeft = $inline.offset().left;
  567. targetOffsetLeft = $target.offset().left;
  568. targetOffsetLeftAdjusted = targetOffsetLeft - startOffsetLeft - parseInt(config.offsetLeft,10);
  569. // Determine current scroll positions
  570. containerScrollTop = $container.prop('scrollTop');
  571. containerScrollLeft = $container.prop('scrollLeft');
  572. // Reset the Inline Element of the Container
  573. $inline.remove();
  574. $container.css({position:position});
  575. // Prepare the scroll options
  576. scrollOptions = {};
  577. // Prepare the callback
  578. callback = function(event){
  579. // Check
  580. if ( collections.length === 0 ) {
  581. // Callback
  582. if ( typeof config.callback === 'function' ) {
  583. config.callback();
  584. }
  585. }
  586. else {
  587. // Recurse
  588. ScrollTo.scroll(collections,config);
  589. }
  590. // Return true
  591. return true;
  592. };
  593. // Handle if we only want to scroll if we are outside the viewport
  594. if ( config.onlyIfOutside ) {
  595. // Determine current scroll positions
  596. containerScrollTopEnd = containerScrollTop + $container.height();
  597. containerScrollLeftEnd = containerScrollLeft + $container.width();
  598. // Check if we are in the range of the visible area of the container
  599. if ( containerScrollTop < targetOffsetTopAdjusted && targetOffsetTopAdjusted < containerScrollTopEnd ) {
  600. targetOffsetTopAdjusted = containerScrollTop;
  601. }
  602. if ( containerScrollLeft < targetOffsetLeftAdjusted && targetOffsetLeftAdjusted < containerScrollLeftEnd ) {
  603. targetOffsetLeftAdjusted = containerScrollLeft;
  604. }
  605. }
  606. // Determine the scroll options
  607. if ( targetOffsetTopAdjusted !== containerScrollTop ) {
  608. scrollOptions.scrollTop = targetOffsetTopAdjusted;
  609. }
  610. if ( targetOffsetLeftAdjusted !== containerScrollLeft ) {
  611. scrollOptions.scrollLeft = targetOffsetLeftAdjusted;
  612. }
  613. // Check to see if the scroll is necessary
  614. if ( $container.prop('scrollHeight') === $container.width() ) {
  615. delete scrollOptions.scrollTop;
  616. }
  617. if ( $container.prop('scrollWidth') === $container.width() ) {
  618. delete scrollOptions.scrollLeft;
  619. }
  620. // Perform the scroll
  621. if ( scrollOptions.scrollTop != null || scrollOptions.scrollLeft != null ) {
  622. $container.animate(scrollOptions, {
  623. duration: config.duration,
  624. easing: config.easing,
  625. complete: callback
  626. });
  627. }
  628. else {
  629. callback();
  630. }
  631. // Return true
  632. return true;
  633. },
  634. // ScrollTo the Element using the Options
  635. fn: function(options){
  636. // Prepare
  637. var collections, config, $container, container;
  638. collections = [];
  639. // Prepare
  640. var $target = $(this);
  641. if ( $target.length === 0 ) {
  642. // Chain
  643. return this;
  644. }
  645. // Handle Options
  646. config = $.extend({},ScrollTo.config,options);
  647. // Fetch
  648. $container = $target.parent();
  649. container = $container.get(0);
  650. // Cycle through the containers
  651. while ( ($container.length === 1) && (container !== document.body) && (container !== document) ) {
  652. // Check Container for scroll differences
  653. var containerScrollTop, containerScrollLeft;
  654. containerScrollTop = $container.css('overflow-y') !== 'visible' && container.scrollHeight !== container.clientHeight;
  655. containerScrollLeft = $container.css('overflow-x') !== 'visible' && container.scrollWidth !== container.clientWidth;
  656. if ( containerScrollTop || containerScrollLeft ) {
  657. // Push the Collection
  658. collections.push({
  659. '$container': $container,
  660. '$target': $target
  661. });
  662. // Update the Target
  663. $target = $container;
  664. }
  665. // Update the Container
  666. $container = $container.parent();
  667. container = $container.get(0);
  668. }
  669. // Add the final collection
  670. collections.push({
  671. '$container': $('html'),
  672. // document.body doesn't work in firefox, html works for all
  673. // internet explorer starts at the beggining
  674. '$target': $target
  675. });
  676. // Adjust the Config
  677. if ( config.durationMode === 'all' ) {
  678. config.duration /= collections.length;
  679. }
  680. // Handle
  681. ScrollTo.scroll(collections,config);
  682. // Chain
  683. return this;
  684. }
  685. };
  686. // Apply our extensions to jQuery
  687. $.ScrollTo = $.ScrollTo || ScrollTo;
  688. $.fn.ScrollTo = $.fn.ScrollTo || ScrollTo.fn;
  689. // Export
  690. return ScrollTo;
  691. });
  692. // ------------- WOW ANIMATE ------------------------------------------------ //
  693. // ==============https://github.com/matthieua/WOW =========================== //
  694. // -------------------------------------------------------------------------- //
  695. (function() {
  696. var MutationObserver, Util, WeakMap, getComputedStyle, getComputedStyleRX,
  697. __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  698. __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; };
  699. Util = (function() {
  700. function Util() {}
  701. Util.prototype.extend = function(custom, defaults) {
  702. var key, value;
  703. for (key in defaults) {
  704. value = defaults[key];
  705. if (custom[key] == null) {
  706. custom[key] = value;
  707. }
  708. }
  709. return custom;
  710. };
  711. Util.prototype.isMobile = function(agent) {
  712. return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(agent);
  713. };
  714. Util.prototype.addEvent = function(elem, event, fn) {
  715. if (elem.addEventListener != null) {
  716. return elem.addEventListener(event, fn, false);
  717. } else if (elem.attachEvent != null) {
  718. return elem.attachEvent("on" + event, fn);
  719. } else {
  720. return elem[event] = fn;
  721. }
  722. };
  723. Util.prototype.removeEvent = function(elem, event, fn) {
  724. if (elem.removeEventListener != null) {
  725. return elem.removeEventListener(event, fn, false);
  726. } else if (elem.detachEvent != null) {
  727. return elem.detachEvent("on" + event, fn);
  728. } else {
  729. return delete elem[event];
  730. }
  731. };
  732. Util.prototype.innerHeight = function() {
  733. if ('innerHeight' in window) {
  734. return window.innerHeight;
  735. } else {
  736. return document.documentElement.clientHeight;
  737. }
  738. };
  739. return Util;
  740. })();
  741. WeakMap = this.WeakMap || this.MozWeakMap || (WeakMap = (function() {
  742. function WeakMap() {
  743. this.keys = [];
  744. this.values = [];
  745. }
  746. WeakMap.prototype.get = function(key) {
  747. var i, item, _i, _len, _ref;
  748. _ref = this.keys;
  749. for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
  750. item = _ref[i];
  751. if (item === key) {
  752. return this.values[i];
  753. }
  754. }
  755. };
  756. WeakMap.prototype.set = function(key, value) {
  757. var i, item, _i, _len, _ref;
  758. _ref = this.keys;
  759. for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
  760. item = _ref[i];
  761. if (item === key) {
  762. this.values[i] = value;
  763. return;
  764. }
  765. }
  766. this.keys.push(key);
  767. return this.values.push(value);
  768. };
  769. return WeakMap;
  770. })());
  771. MutationObserver = this.MutationObserver || this.WebkitMutationObserver || this.MozMutationObserver || (MutationObserver = (function() {
  772. function MutationObserver() {
  773. if (typeof console !== "undefined" && console !== null) {
  774. console.warn('MutationObserver is not supported by your browser.');
  775. }
  776. if (typeof console !== "undefined" && console !== null) {
  777. console.warn('WOW.js cannot detect dom mutations, please call .sync() after loading new content.');
  778. }
  779. }
  780. MutationObserver.notSupported = true;
  781. MutationObserver.prototype.observe = function() {};
  782. return MutationObserver;
  783. })());
  784. getComputedStyle = this.getComputedStyle || function(el, pseudo) {
  785. this.getPropertyValue = function(prop) {
  786. var _ref;
  787. if (prop === 'float') {
  788. prop = 'styleFloat';
  789. }
  790. if (getComputedStyleRX.test(prop)) {
  791. prop.replace(getComputedStyleRX, function(_, char) {
  792. return char.toUpperCase();
  793. });
  794. }
  795. return ((_ref = el.currentStyle) != null ? _ref[prop] : void 0) || null;
  796. };
  797. return this;
  798. };
  799. getComputedStyleRX = /(\-([a-z]){1})/g;
  800. this.WOW = (function() {
  801. WOW.prototype.defaults = {
  802. boxClass: 'wow',
  803. animateClass: 'animated',
  804. offset: 0,
  805. mobile: true,
  806. live: true
  807. };
  808. function WOW(options) {
  809. if (options == null) {
  810. options = {};
  811. }
  812. this.scrollCallback = __bind(this.scrollCallback, this);
  813. this.scrollHandler = __bind(this.scrollHandler, this);
  814. this.start = __bind(this.start, this);
  815. this.scrolled = true;
  816. this.config = this.util().extend(options, this.defaults);
  817. this.animationNameCache = new WeakMap();
  818. }
  819. WOW.prototype.init = function() {
  820. var _ref;
  821. this.element = window.document.documentElement;
  822. if ((_ref = document.readyState) === "interactive" || _ref === "complete") {
  823. this.start();
  824. } else {
  825. this.util().addEvent(document, 'DOMContentLoaded', this.start);
  826. }
  827. return this.finished = [];
  828. };
  829. WOW.prototype.start = function() {
  830. var box, _i, _len, _ref;
  831. this.stopped = false;
  832. this.boxes = (function() {
  833. var _i, _len, _ref, _results;
  834. _ref = this.element.querySelectorAll("." + this.config.boxClass);
  835. _results = [];
  836. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  837. box = _ref[_i];
  838. _results.push(box);
  839. }
  840. return _results;
  841. }).call(this);
  842. this.all = (function() {
  843. var _i, _len, _ref, _results;
  844. _ref = this.boxes;
  845. _results = [];
  846. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  847. box = _ref[_i];
  848. _results.push(box);
  849. }
  850. return _results;
  851. }).call(this);
  852. if (this.boxes.length) {
  853. if (this.disabled()) {
  854. this.resetStyle();
  855. } else {
  856. _ref = this.boxes;
  857. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  858. box = _ref[_i];
  859. this.applyStyle(box, true);
  860. }
  861. this.util().addEvent(window, 'scroll', this.scrollHandler);
  862. this.util().addEvent(window, 'resize', this.scrollHandler);
  863. this.interval = setInterval(this.scrollCallback, 50);
  864. }
  865. }
  866. if (this.config.live) {
  867. return new MutationObserver((function(_this) {
  868. return function(records) {
  869. var node, record, _j, _len1, _results;
  870. _results = [];
  871. for (_j = 0, _len1 = records.length; _j < _len1; _j++) {
  872. record = records[_j];
  873. _results.push((function() {
  874. var _k, _len2, _ref1, _results1;
  875. _ref1 = record.addedNodes || [];
  876. _results1 = [];
  877. for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
  878. node = _ref1[_k];
  879. _results1.push(this.doSync(node));
  880. }
  881. return _results1;
  882. }).call(_this));
  883. }
  884. return _results;
  885. };
  886. })(this)).observe(document.body, {
  887. childList: true,
  888. subtree: true
  889. });
  890. }
  891. };
  892. WOW.prototype.stop = function() {
  893. this.stopped = true;
  894. this.util().removeEvent(window, 'scroll', this.scrollHandler);
  895. this.util().removeEvent(window, 'resize', this.scrollHandler);
  896. if (this.interval != null) {
  897. return clearInterval(this.interval);
  898. }
  899. };
  900. WOW.prototype.sync = function(element) {
  901. if (MutationObserver.notSupported) {
  902. return this.doSync(this.element);
  903. }
  904. };
  905. WOW.prototype.doSync = function(element) {
  906. var box, _i, _len, _ref, _results;
  907. if (element == null) {
  908. element = this.element;
  909. }
  910. if (element.nodeType !== 1) {
  911. return;
  912. }
  913. element = element.parentNode || element;
  914. _ref = element.querySelectorAll("." + this.config.boxClass);
  915. _results = [];
  916. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  917. box = _ref[_i];
  918. if (__indexOf.call(this.all, box) < 0) {
  919. this.boxes.push(box);
  920. this.all.push(box);
  921. if (this.stopped || this.disabled()) {
  922. this.resetStyle();
  923. } else {
  924. this.applyStyle(box, true);
  925. }
  926. _results.push(this.scrolled = true);
  927. } else {
  928. _results.push(void 0);
  929. }
  930. }
  931. return _results;
  932. };
  933. WOW.prototype.show = function(box) {
  934. this.applyStyle(box);
  935. return box.className = "" + box.className + " " + this.config.animateClass;
  936. };
  937. WOW.prototype.applyStyle = function(box, hidden) {
  938. var delay, duration, iteration;
  939. duration = box.getAttribute('data-wow-duration');
  940. delay = box.getAttribute('data-wow-delay');
  941. iteration = box.getAttribute('data-wow-iteration');
  942. return this.animate((function(_this) {
  943. return function() {
  944. return _this.customStyle(box, hidden, duration, delay, iteration);
  945. };
  946. })(this));
  947. };
  948. WOW.prototype.animate = (function() {
  949. if ('requestAnimationFrame' in window) {
  950. return function(callback) {
  951. return window.requestAnimationFrame(callback);
  952. };
  953. } else {
  954. return function(callback) {
  955. return callback();
  956. };
  957. }
  958. })();
  959. WOW.prototype.resetStyle = function() {
  960. var box, _i, _len, _ref, _results;
  961. _ref = this.boxes;
  962. _results = [];
  963. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  964. box = _ref[_i];
  965. _results.push(box.style.visibility = 'visible');
  966. }
  967. return _results;
  968. };
  969. WOW.prototype.customStyle = function(box, hidden, duration, delay, iteration) {
  970. if (hidden) {
  971. this.cacheAnimationName(box);
  972. }
  973. box.style.visibility = hidden ? 'hidden' : 'visible';
  974. if (duration) {
  975. this.vendorSet(box.style, {
  976. animationDuration: duration
  977. });
  978. }
  979. if (delay) {
  980. this.vendorSet(box.style, {
  981. animationDelay: delay
  982. });
  983. }
  984. if (iteration) {
  985. this.vendorSet(box.style, {
  986. animationIterationCount: iteration
  987. });
  988. }
  989. this.vendorSet(box.style, {
  990. animationName: hidden ? 'none' : this.cachedAnimationName(box)
  991. });
  992. return box;
  993. };
  994. WOW.prototype.vendors = ["moz", "webkit"];
  995. WOW.prototype.vendorSet = function(elem, properties) {
  996. var name, value, vendor, _results;
  997. _results = [];
  998. for (name in properties) {
  999. value = properties[name];
  1000. elem["" + name] = value;
  1001. _results.push((function() {
  1002. var _i, _len, _ref, _results1;
  1003. _ref = this.vendors;
  1004. _results1 = [];
  1005. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1006. vendor = _ref[_i];
  1007. _results1.push(elem["" + vendor + (name.charAt(0).toUpperCase()) + (name.substr(1))] = value);
  1008. }
  1009. return _results1;
  1010. }).call(this));
  1011. }
  1012. return _results;
  1013. };
  1014. WOW.prototype.vendorCSS = function(elem, property) {
  1015. var result, style, vendor, _i, _len, _ref;
  1016. style = getComputedStyle(elem);
  1017. result = style.getPropertyCSSValue(property);
  1018. _ref = this.vendors;
  1019. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1020. vendor = _ref[_i];
  1021. result = result || style.getPropertyCSSValue("-" + vendor + "-" + property);
  1022. }
  1023. return result;
  1024. };
  1025. WOW.prototype.animationName = function(box) {
  1026. var animationName;
  1027. try {
  1028. animationName = this.vendorCSS(box, 'animation-name').cssText;
  1029. } catch (_error) {
  1030. animationName = getComputedStyle(box).getPropertyValue('animation-name');
  1031. }
  1032. if (animationName === 'none') {
  1033. return '';
  1034. } else {
  1035. return animationName;
  1036. }
  1037. };
  1038. WOW.prototype.cacheAnimationName = function(box) {
  1039. return this.animationNameCache.set(box, this.animationName(box));
  1040. };
  1041. WOW.prototype.cachedAnimationName = function(box) {
  1042. return this.animationNameCache.get(box);
  1043. };
  1044. WOW.prototype.scrollHandler = function() {
  1045. return this.scrolled = true;
  1046. };
  1047. WOW.prototype.scrollCallback = function() {
  1048. var box;
  1049. if (this.scrolled) {
  1050. this.scrolled = false;
  1051. this.boxes = (function() {
  1052. var _i, _len, _ref, _results;
  1053. _ref = this.boxes;
  1054. _results = [];
  1055. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1056. box = _ref[_i];
  1057. if (!(box)) {
  1058. continue;
  1059. }
  1060. if (this.isVisible(box)) {
  1061. this.show(box);
  1062. continue;
  1063. }
  1064. _results.push(box);
  1065. }
  1066. return _results;
  1067. }).call(this);
  1068. if (!(this.boxes.length || this.config.live)) {
  1069. return this.stop();
  1070. }
  1071. }
  1072. };
  1073. WOW.prototype.offsetTop = function(element) {
  1074. var top;
  1075. while (element.offsetTop === void 0) {
  1076. element = element.parentNode;
  1077. }
  1078. top = element.offsetTop;
  1079. while (element = element.offsetParent) {
  1080. top += element.offsetTop;
  1081. }
  1082. return top;
  1083. };
  1084. WOW.prototype.isVisible = function(box) {
  1085. var bottom, offset, top, viewBottom, viewTop;
  1086. offset = box.getAttribute('data-wow-offset') || this.config.offset;
  1087. viewTop = window.pageYOffset;
  1088. viewBottom = viewTop + Math.min(this.element.clientHeight, this.util().innerHeight()) - offset;
  1089. top = this.offsetTop(box);
  1090. bottom = top + box.clientHeight;
  1091. return top <= viewBottom && bottom >= viewTop;
  1092. };
  1093. WOW.prototype.util = function() {
  1094. return this._util != null ? this._util : this._util = new Util();
  1095. };
  1096. WOW.prototype.disabled = function() {
  1097. return !this.config.mobile && this.util().isMobile(navigator.userAgent);
  1098. };
  1099. return WOW;
  1100. })();
  1101. }).call(this);
  1102. // ------------- JQUERY SMOOTHSTATE ----------------------------------------- //
  1103. // ============ https://github.com/miguel-perez/jquery.smoothState.js ======= //
  1104. // -------------------------------------------------------------------------- //
  1105. ;(function ( $, window, document, undefined ) {
  1106. "use strict";
  1107. var
  1108. /** Used later to scroll page to the top */
  1109. $body = $("html, body"),
  1110. /** Used in development mode to console out useful warnings */
  1111. consl = (window.console || false),
  1112. /** Plugin default options */
  1113. defaults = {
  1114. /** jquery element string to specify which anchors smoothstate should bind to */
  1115. anchors : "a",
  1116. /** If set to true, smoothState will prefetch a link's contents on hover */
  1117. prefetch : false,
  1118. /** A selecor that deinfes with links should be ignored by smoothState */
  1119. blacklist : ".no-smoothstate, [target]",
  1120. /** If set to true, smoothState will log useful debug information instead of aborting */
  1121. development : false,
  1122. /** The number of pages smoothState will try to store in memory and not request again */
  1123. pageCacheSize : 0,
  1124. /** A function that can be used to alter urls before they are used to request content */
  1125. alterRequestUrl : function (url) {
  1126. return url;
  1127. },
  1128. /** Run when a link has been activated */
  1129. onStart : {
  1130. duration: 0,
  1131. render: function (url, $container) {
  1132. $body.scrollTop(0);
  1133. }
  1134. },
  1135. /** Run if the page request is still pending and onStart has finished animating */
  1136. onProgress : {
  1137. duration: 0,
  1138. render: function (url, $container) {
  1139. $body.css("cursor", "wait");
  1140. $body.find("a").css("cursor", "wait");
  1141. }
  1142. },
  1143. /** Run when requested content is ready to be injected into the page */
  1144. onEnd : {
  1145. duration: 0,
  1146. render: function (url, $container, $content) {
  1147. $body.css("cursor", "auto");
  1148. $body.find("a").css("cursor", "auto");
  1149. $container.html($content);
  1150. }
  1151. },
  1152. /** Run when content has been injected and all animations are complete */
  1153. callback : function(url, $container, $content) {
  1154. }
  1155. },
  1156. /** Utility functions that are decoupled from SmoothState */
  1157. utility = {
  1158. /**
  1159. * Checks to see if the url is external
  1160. * @param {string} url - url being evaluated
  1161. * @see http://stackoverflow.com/questions/6238351/fastest-way-to-detect-external-urls
  1162. *
  1163. */
  1164. isExternal: function (url) {
  1165. var match = url.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);
  1166. if (typeof match[1] === "string" && match[1].length > 0 && match[1].toLowerCase() !== window.location.protocol) {
  1167. return true;
  1168. }
  1169. if (typeof match[2] === "string" && match[2].length > 0 && match[2].replace(new RegExp(":(" + {"http:": 80, "https:": 443}[window.location.protocol] + ")?$"), "") !== window.location.host) {
  1170. return true;
  1171. }
  1172. return false;
  1173. },
  1174. /**
  1175. * Checks to see if the url is an internal hash
  1176. * @param {string} url - url being evaluated
  1177. *
  1178. */
  1179. isHash: function (url) {
  1180. var hasPathname = (url.indexOf(window.location.pathname) > 0) ? true : false,
  1181. hasHash = (url.indexOf("#") > 0) ? true : false;
  1182. return (hasPathname && hasHash) ? true : false;
  1183. },
  1184. /**
  1185. * Checks to see if we should be loading this URL
  1186. * @param {string} url - url being evaluated
  1187. * @param {string} blacklist - jquery selector
  1188. *
  1189. */
  1190. shouldLoad: function ($anchor, blacklist) {
  1191. var url = $anchor.prop("href");
  1192. // URL will only be loaded if it"s not an external link, hash, or blacklisted
  1193. return (!utility.isExternal(url) && !utility.isHash(url) && !$anchor.is(blacklist));
  1194. },
  1195. /**
  1196. * Prevents jQuery from stripping elements from $(html)
  1197. * @param {string} url - url being evaluated
  1198. * @author Ben Alman http://benalman.com/
  1199. * @see https://gist.github.com/cowboy/742952
  1200. *
  1201. */
  1202. htmlDoc: function (html) {
  1203. var parent,
  1204. elems = $(),
  1205. matchTag = /<(\/?)(html|head|body|title|base|meta)(\s+[^>]*)?>/ig,
  1206. prefix = "ss" + Math.round(Math.random() * 100000),
  1207. htmlParsed = html.replace(matchTag, function(tag, slash, name, attrs) {
  1208. var obj = {};
  1209. if (!slash) {
  1210. elems = elems.add("<" + name + "/>");
  1211. if (attrs) {
  1212. $.each($("<div" + attrs + "/>")[0].attributes, function(i, attr) {
  1213. obj[attr.name] = attr.value;
  1214. });
  1215. }
  1216. elems.eq(-1).attr(obj);
  1217. }
  1218. return "<" + slash + "div" + (slash ? "" : " id='" + prefix + (elems.length - 1) + "'") + ">";
  1219. });
  1220. // If no placeholder elements were necessary, just return normal
  1221. // jQuery-parsed HTML.
  1222. if (!elems.length) {
  1223. return $(html);
  1224. }
  1225. // Create parent node if it hasn"t been created yet.
  1226. if (!parent) {
  1227. parent = $("<div/>");
  1228. }
  1229. // Create the parent node and append the parsed, place-held HTML.
  1230. parent.html(htmlParsed);
  1231. // Replace each placeholder element with its intended element.
  1232. $.each(elems, function(i) {
  1233. var elem = parent.find("#" + prefix + i).before(elems[i]);
  1234. elems.eq(i).html(elem.contents());
  1235. elem.remove();
  1236. });
  1237. return parent.children().unwrap();
  1238. },
  1239. /**
  1240. * Resets an object if it has too many properties
  1241. *
  1242. * This is used to clear the "cache" object that stores
  1243. * all of the html. This would prevent the client from
  1244. * running out of memory and allow the user to hit the
  1245. * server for a fresh copy of the content.
  1246. *
  1247. * @param {object} obj
  1248. * @param {number} cap
  1249. *
  1250. */
  1251. clearIfOverCapacity: function (obj, cap) {
  1252. // Polyfill Object.keys if it doesn"t exist
  1253. if (!Object.keys) {
  1254. Object.keys = function (obj) {
  1255. var keys = [],
  1256. k;
  1257. for (k in obj) {
  1258. if (Object.prototype.hasOwnProperty.call(obj, k)) {
  1259. keys.push(k);
  1260. }
  1261. }
  1262. return keys;
  1263. };
  1264. }
  1265. if (Object.keys(obj).length > cap) {
  1266. obj = {};
  1267. }
  1268. return obj;
  1269. },
  1270. /**
  1271. * Finds the inner content of an element, by an ID, from a jQuery object
  1272. * @param {string} id
  1273. * @param {object} $html
  1274. *
  1275. */
  1276. getContentById: function (id, $html) {
  1277. $html = ($html instanceof jQuery) ? $html : utility.htmlDoc($html);
  1278. var $insideElem = $html.find(id),
  1279. updatedContainer = ($insideElem.length) ? $.trim($insideElem.html()) : $html.filter(id).html(),
  1280. newContent = (updatedContainer.length) ? $(updatedContainer) : null;
  1281. return newContent;
  1282. },
  1283. /**
  1284. * Stores html content as jquery object in given object
  1285. * @param {object} object - object contents will be stored into
  1286. * @param {string} url - url to be used as the prop
  1287. * @param {jquery} html - contents to store
  1288. *
  1289. */
  1290. storePageIn: function (object, url, $html) {
  1291. $html = ($html instanceof jQuery) ? $html : utility.htmlDoc($html);
  1292. object[url] = { // Content is indexed by the url
  1293. status: "loaded",
  1294. title: $html.find("title").text(), // Stores the title of the page
  1295. html: $html // Stores the contents of the page
  1296. };
  1297. return object;
  1298. },
  1299. /**
  1300. * Triggers an "allanimationend" event when all animations are complete
  1301. * @param {object} $element - jQuery object that should trigger event
  1302. * @param {string} resetOn - which other events to trigger allanimationend on
  1303. *
  1304. */
  1305. triggerAllAnimationEndEvent: function ($element, resetOn) {
  1306. resetOn = " " + resetOn || "";
  1307. var animationCount = 0,
  1308. animationstart = "animationstart webkitAnimationStart oanimationstart MSAnimationStart",
  1309. animationend = "animationend webkitAnimationEnd oanimationend MSAnimationEnd",
  1310. eventname = "allanimationend",
  1311. onAnimationStart = function (e) {
  1312. if ($(e.delegateTarget).is($element)) {
  1313. e.stopPropagation();
  1314. animationCount ++;
  1315. }
  1316. },
  1317. onAnimationEnd = function (e) {
  1318. if ($(e.delegateTarget).is($element)) {
  1319. e.stopPropagation();
  1320. animationCount --;
  1321. if(animationCount === 0) {
  1322. $element.trigger(eventname);
  1323. }
  1324. }
  1325. };
  1326. $element.on(animationstart, onAnimationStart);
  1327. $element.on(animationend, onAnimationEnd);
  1328. $element.on("allanimationend" + resetOn, function(){
  1329. animationCount = 0;
  1330. utility.redraw($element);
  1331. });
  1332. },
  1333. /** Forces browser to redraw elements */
  1334. redraw: function ($element) {
  1335. $element.height(0);
  1336. setTimeout(function(){$element.height("auto");}, 0);
  1337. }
  1338. },
  1339. /** Handles the popstate event, like when the user hits "back" */
  1340. onPopState = function ( e ) {
  1341. if(e.state !== null) {
  1342. var url = window.location.href,
  1343. $page = $("#" + e.state.id),
  1344. page = $page.data("smoothState");
  1345. if(page.href !== url && !utility.isHash(url)) {
  1346. page.load(url, true);
  1347. }
  1348. }
  1349. },
  1350. /** Constructor function */
  1351. SmoothState = function ( element, options ) {
  1352. var
  1353. /** Container element smoothState is run on */
  1354. $container = $(element),
  1355. /** Variable that stores pages after they are requested */
  1356. cache = {},
  1357. /** Url of the content that is currently displayed */
  1358. currentHref = window.location.href,
  1359. /**
  1360. * Loads the contents of a url into our container
  1361. *
  1362. * @param {string} url
  1363. * @param {bool} isPopped - used to determine if whe should
  1364. * add a new item into the history object
  1365. *
  1366. */
  1367. load = function (url, isPopped) {
  1368. /** Makes this an optional variable by setting a default */
  1369. isPopped = isPopped || false;
  1370. var
  1371. /** Used to check if the onProgress function has been run */
  1372. hasRunCallback = false,
  1373. callbBackEnded = false,
  1374. /** List of responses for the states of the page request */
  1375. responses = {
  1376. /** Page is ready, update the content */
  1377. loaded: function() {
  1378. var eventName = hasRunCallback ? "ss.onProgressEnd" : "ss.onStartEnd";
  1379. if(!callbBackEnded || !hasRunCallback) {
  1380. $container.one(eventName, function(){
  1381. updateContent(url);
  1382. });
  1383. } else if(callbBackEnded) {
  1384. updateContent(url);
  1385. }
  1386. if(!isPopped) {
  1387. window.history.pushState({ id: $container.prop("id") }, cache[url].title, url);
  1388. }
  1389. },
  1390. /** Loading, wait 10 ms and check again */
  1391. fetching: function() {
  1392. if(!hasRunCallback) {
  1393. hasRunCallback = true;
  1394. // Run the onProgress callback and set trigger
  1395. $container.one("ss.onStartEnd", function(){
  1396. options.onProgress.render(url, $container, null);
  1397. setTimeout(function(){
  1398. $container.trigger("ss.onProgressEnd");
  1399. callbBackEnded = true;
  1400. }, options.onStart.duration);
  1401. });
  1402. }
  1403. setTimeout(function () {
  1404. // Might of been canceled, better check!
  1405. if(cache.hasOwnProperty(url)){
  1406. responses[cache[url].status]();
  1407. }
  1408. }, 10);
  1409. },
  1410. /** Error, abort and redirect */
  1411. error: function(){
  1412. window.location = url;
  1413. }
  1414. };
  1415. if (!cache.hasOwnProperty(url)) {
  1416. fetch(url);
  1417. }
  1418. // Run the onStart callback and set trigger
  1419. options.onStart.render(url, $container, null);
  1420. setTimeout(function(){
  1421. $container.trigger("ss.onStartEnd");
  1422. }, options.onStart.duration);
  1423. // Start checking for the status of content
  1424. responses[cache[url].status]();
  1425. },
  1426. /** Updates the contents from cache[url] */
  1427. updateContent = function (url) {
  1428. // If the content has been requested and is done:
  1429. var containerId = "#" + $container.prop("id"),
  1430. $content = cache[url] ? utility.getContentById(containerId, cache[url].html) : null;
  1431. if($content) {
  1432. document.title = cache[url].title;
  1433. $container.data("smoothState").href = url;
  1434. // Call the onEnd callback and set trigger
  1435. options.onEnd.render(url, $container, $content);
  1436. $container.one("ss.onEndEnd", function(){
  1437. options.callback(url, $container, $content);
  1438. });
  1439. setTimeout(function(){
  1440. $container.trigger("ss.onEndEnd");
  1441. }, options.onEnd.duration);
  1442. } else if (!$content && options.development && consl) {
  1443. // Throw warning to help debug in development mode
  1444. consl.warn("No element with an id of " + containerId + " in response from " + url + " in " + cache);
  1445. } else {
  1446. // No content availble to update with, aborting...
  1447. window.location = url;
  1448. }
  1449. },
  1450. /**
  1451. * Fetches the contents of a url and stores it in the "cache" varible
  1452. * @param {string} url
  1453. *
  1454. */
  1455. fetch = function (url) {
  1456. // Don"t fetch we have the content already
  1457. if(cache.hasOwnProperty(url)) {
  1458. return;
  1459. }
  1460. cache = utility.clearIfOverCapacity(cache, options.pageCacheSize);
  1461. cache[url] = { status: "fetching" };
  1462. var requestUrl = options.alterRequestUrl(url) || url,
  1463. request = $.ajax(requestUrl);
  1464. // Store contents in cache variable if successful
  1465. request.success(function (html) {
  1466. // Clear cache varible if it"s getting too big
  1467. utility.storePageIn(cache, url, html);
  1468. $container.data("smoothState").cache = cache;
  1469. });
  1470. // Mark as error
  1471. request.error(function () {
  1472. cache[url].status = "error";
  1473. });
  1474. },
  1475. /**
  1476. * Binds to the hover event of a link, used for prefetching content
  1477. *
  1478. * @param {object} event
  1479. *
  1480. */
  1481. hoverAnchor = function (event) {
  1482. var $anchor = $(event.currentTarget),
  1483. url = $anchor.prop("href");
  1484. if (utility.shouldLoad($anchor, options.blacklist)) {
  1485. event.stopPropagation();
  1486. fetch(url);
  1487. }
  1488. },
  1489. /**
  1490. * Binds to the click event of a link, used to show the content
  1491. *
  1492. * @param {object} event
  1493. *
  1494. */
  1495. clickAnchor = function (event) {
  1496. var $anchor = $(event.currentTarget),
  1497. url = $anchor.prop("href");
  1498. // Ctrl (or Cmd) + click must open a new tab
  1499. if (!event.metaKey && !event.ctrlKey && utility.shouldLoad($anchor, options.blacklist)) {
  1500. // stopPropagation so that event doesn"t fire on parent containers.
  1501. event.stopPropagation();
  1502. event.preventDefault();
  1503. load(url);
  1504. }
  1505. },
  1506. /**
  1507. * Binds all events and inits functionality
  1508. *
  1509. * @param {object} event
  1510. *
  1511. */
  1512. bindEventHandlers = function ($element) {
  1513. //@todo: Handle form submissions
  1514. $element.on("click", options.anchors, clickAnchor);
  1515. if (options.prefetch) {
  1516. $element.on("mouseover touchstart", options.anchors, hoverAnchor);
  1517. }
  1518. },
  1519. /** Used to restart css animations with a class */
  1520. toggleAnimationClass = function (classname) {
  1521. var classes = $container.addClass(classname).prop("class");
  1522. $container.removeClass(classes);
  1523. setTimeout(function(){
  1524. $container.addClass(classes);
  1525. },0);
  1526. $container.one("ss.onStartEnd ss.onProgressEnd ss.onEndEnd", function(){
  1527. $container.removeClass(classname);
  1528. });
  1529. };
  1530. /** Override defaults with options passed in */
  1531. options = $.extend(defaults, options);
  1532. /** Sets a default state */
  1533. if(window.history.state === null) {
  1534. window.history.replaceState({ id: $container.prop("id") }, document.title, currentHref);
  1535. }
  1536. /** Stores the current page in cache variable */
  1537. utility.storePageIn(cache, currentHref, document.documentElement.outerHTML);
  1538. /** Bind all of the event handlers on the container, not anchors */
  1539. utility.triggerAllAnimationEndEvent($container, "ss.onStartEnd ss.onProgressEnd ss.onEndEnd");
  1540. /** Bind all of the event handlers on the container, not anchors */
  1541. bindEventHandlers($container);
  1542. /** Public methods */
  1543. return {
  1544. href: currentHref,
  1545. cache: cache,
  1546. load: load,
  1547. fetch: fetch,
  1548. toggleAnimationClass: toggleAnimationClass
  1549. };
  1550. },
  1551. /** Returns elements with SmoothState attached to it */
  1552. declareSmoothState = function ( options ) {
  1553. return this.each(function () {
  1554. // Checks to make sure the smoothState element has an id and isn"t already bound
  1555. if(this.id && !$.data(this, "smoothState")) {
  1556. // Makes public methods available via $("element").data("smoothState");
  1557. $.data(this, "smoothState", new SmoothState(this, options));
  1558. } else if (!this.id && consl) {
  1559. // Throw warning if in development mode
  1560. consl.warn("Every smoothState container needs an id but the following one does not have one:", this);
  1561. }
  1562. });
  1563. };
  1564. /** Sets the popstate function */
  1565. window.onpopstate = onPopState;
  1566. /** Makes utility functions public for unit tests */
  1567. $.smoothStateUtility = utility;
  1568. /** Defines the smoothState plugin */
  1569. $.fn.smoothState = declareSmoothState;
  1570. })(jQuery, window, document);
  1571. // ------------- jQuery Cookie Plugin v1.4.1 -------------------------------- //
  1572. // ============ https://github.com/carhartl/jquery-cookie =================== //
  1573. // -------------------------------------------------------------------------- //
  1574. (function (factory) {
  1575. if (typeof define === 'function' && define.amd) {
  1576. // AMD
  1577. define(['jquery'], factory);
  1578. } else if (typeof exports === 'object') {
  1579. // CommonJS
  1580. factory(require('jquery'));
  1581. } else {
  1582. // Browser globals
  1583. factory(jQuery);
  1584. }
  1585. }(function ($) {
  1586. var pluses = /\+/g;
  1587. function encode(s) {
  1588. return config.raw ? s : encodeURIComponent(s);
  1589. }
  1590. function decode(s) {
  1591. return config.raw ? s : decodeURIComponent(s);
  1592. }
  1593. function stringifyCookieValue(value) {
  1594. return encode(config.json ? JSON.stringify(value) : String(value));
  1595. }
  1596. function parseCookieValue(s) {
  1597. if (s.indexOf('"') === 0) {
  1598. // This is a quoted cookie as according to RFC2068, unescape...
  1599. s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  1600. }
  1601. try {
  1602. // Replace server-side written pluses with spaces.
  1603. // If we can't decode the cookie, ignore it, it's unusable.
  1604. // If we can't parse the cookie, ignore it, it's unusable.
  1605. s = decodeURIComponent(s.replace(pluses, ' '));
  1606. return config.json ? JSON.parse(s) : s;
  1607. } catch(e) {}
  1608. }
  1609. function read(s, converter) {
  1610. var value = config.raw ? s : parseCookieValue(s);
  1611. return $.isFunction(converter) ? converter(value) : value;
  1612. }
  1613. var config = $.cookie = function (key, value, options) {
  1614. // Write
  1615. if (arguments.length > 1 && !$.isFunction(value)) {
  1616. options = $.extend({}, config.defaults, options);
  1617. if (typeof options.expires === 'number') {
  1618. var days = options.expires, t = options.expires = new Date();
  1619. t.setTime(+t + days * 864e+5);
  1620. }
  1621. return (document.cookie = [
  1622. encode(key), '=', stringifyCookieValue(value),
  1623. options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  1624. options.path ? '; path=' + options.path : '',
  1625. options.domain ? '; domain=' + options.domain : '',
  1626. options.secure ? '; secure' : ''
  1627. ].join(''));
  1628. }
  1629. // Read
  1630. var result = key ? undefined : {};
  1631. // To prevent the for loop in the first place assign an empty array
  1632. // in case there are no cookies at all. Also prevents odd result when
  1633. // calling $.cookie().
  1634. var cookies = document.cookie ? document.cookie.split('; ') : [];
  1635. for (var i = 0, l = cookies.length; i < l; i++) {
  1636. var parts = cookies[i].split('=');
  1637. var name = decode(parts.shift());
  1638. var cookie = parts.join('=');
  1639. if (key && key === name) {
  1640. // If second argument (value) is a function it's a converter...
  1641. result = read(cookie, value);
  1642. break;
  1643. }
  1644. // Prevent storing a cookie that we couldn't decode.
  1645. if (!key && (cookie = read(cookie)) !== undefined) {
  1646. result[name] = cookie;
  1647. }
  1648. }
  1649. return result;
  1650. };
  1651. config.defaults = {};
  1652. $.removeCookie = function (key, options) {
  1653. if ($.cookie(key) === undefined) {
  1654. return false;
  1655. }
  1656. // Must not alter options, thus extending a fresh object...
  1657. $.cookie(key, '', $.extend({}, options, { expires: -1 }));
  1658. return !$.cookie(key);
  1659. };
  1660. }));