scripts.js 93 KB

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