scripts.js 121 KB

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