/* sequence.js (http://www.sequencejs.com) version: 0.8.1 beta author: ian lunn @ianlunn author url: http://www.ianlunn.co.uk/ github: https://github.com/ianlunn/sequence this is a free script and is available under a mit license: http://www.opensource.org/licenses/mit-license.php sequence.js and its dependencies are (c) ian lunn design 2012 unless otherwise stated. sequence also relies on the following open source scripts: - jquery imagesloaded 2.1.0 (http://github.com/desandro/imagesloaded) paul irish et al available under a mit license: http://www.opensource.org/licenses/mit-license.php - jquery touchwipe 1.1.1 (http://www.netcu.de/jquery-touchwipe-iphone-ipad-library) andreas waltl, netcu internetagentur (http://www.netcu.de) available under a mit license: http://www.opensource.org/licenses/mit-license.php - modernizr 2.6.1 custom build (http://modernizr.com/) copyright (c) faruk ates, paul irish, alex sexton available under the bsd and mit licenses: www.modernizr.com/license/ */(function(e){function t(t,n,r,i){function f(){s.afterloaded();s.settings.hideframesuntilpreloaded&&s.settings.preloader&&s.sequence.children("li").show();if(s.settings.preloader)if(s.settings.hidepreloaderusingcss&&s.transitionssupported){s.prependpreloadingcompleteto=s.settings.prependpreloadingcomplete==1?s.settings.preloader:e(s.settings.prependpreloadingcomplete);s.prependpreloadingcompleteto.addclass("preloading-complete");settimeout(y,s.settings.hidepreloaderdelay)}else s.settings.preloader.fadeout(s.settings.hidepreloaderdelay,function(){clearinterval(s.defaultpreloader);y()});else y()}function g(t,n){function l(){var t=e(a),s=e(f);i&&(f.length?i.reject(o,t,s):i.resolve(o));e.isfunction(n)&&n.call(r,o,t,s)}function c(t,n){if(t.src===blank||e.inarray(t,u)!==-1)return;u.push(t);n?f.push(t):a.push(t);e.data(t,"imagesloaded",{isbroken:n,src:t.src});s&&i.notifywith(e(t),[n,o,e(a),e(f)]);if(o.length===u.length){settimeout(l);o.unbind(".imagesloaded")}}blank="data:image/gif;base64,r0lgodlhaqabaiaaaaaaap///ywaaaaaaqabaaacauwaow==";var r=t,i=e.isfunction(e.deferred)?e.deferred():0,s=e.isfunction(i.notify),o=r.find("img").add(r.filter("img")),u=[],a=[],f=[];e.isplainobject(n)&&e.each(n,function(e,t){e==="callback"?n=t:i&&i[e](t)});o.length?o.bind("load.imagesloaded error.imagesloaded",function(e){c(e.target,e.type==="error")}).each(function(t,n){var r=n.src,i=e.data(n,"imagesloaded");if(i&&i.src===r){c(n,i.isbroken);return}if(n.complete&&n.naturalwidth!==undefined){c(n,n.naturalwidth===0||n.naturalheight===0);return}if(n.readystate||n.complete){n.src=blank;n.src=r}}):l()}function y(){e(s.settings.preloader).remove();s.nextbutton=s.init.uielements(s.settings.nextbutton,".next");s.prevbutton=s.init.uielements(s.settings.prevbutton,".prev");s.pausebutton=s.init.uielements(s.settings.pausebutton,".pause");s.nextbutton!==undefined&&s.nextbutton!==!1&&s.settings.shownextbuttononinit&&s.nextbutton.show();s.prevbutton!==undefined&&s.prevbutton!==!1&&s.settings.showprevbuttononinit&&s.prevbutton.show();s.pausebutton!==undefined&&s.pausebutton!==!1&&s.pausebutton.show();if(s.settings.pauseicon!==!1){s.pauseicon=s.init.uielements(s.settings.pauseicon,".pause-icon");s.pauseicon!==undefined&&s.pauseicon.hide()}else s.pauseicon=undefined;s.nextframeid=s.settings.startingframeid;if(s.settings.hashtags){s.sequence.children("li").each(function(){s.framehashid.push(e(this).attr(s.gethashtagfrom))});s.currenthashtag=location.hash.replace("#","");if(s.currenthashtag===undefined||s.currenthashtag==="")s.nextframeid=s.settings.startingframeid;else{s.framehashindex=e.inarray(s.currenthashtag,s.framehashid);s.framehashindex!==-1?s.nextframeid=s.framehashindex+1:s.nextframeid=s.settings.startingframeid}}s.nextframe=s.sequence.children("li:nth-child("+s.nextframeid+")");s.nextframechildren=s.nextframe.children();s.sequence.css({width:"100%",height:"100%",position:"relative"});s.sequence.children("li").css({width:"100%",height:"100%",position:"absolute","z-index":1});if(s.transitionssupported)if(!s.settings.animatestartingframein){s.currentframeid=s.nextframeid;s.settings.moveactiveframetotop&&s.nextframe.css("z-index",s.numberofframes);s.modifyelements(s.nextframechildren,"0s");s.nextframe.addclass("animate-in");if(s.settings.hashtags&&s.settings.hashchangesonfirstframe){s.currenthashtag=s.nextframe.attr(s.gethashtagfrom);document.location.hash="#"+s.currenthashtag}settimeout(function(){s.modifyelements(s.nextframechildren,"")},100);s.resetautoplay(!0,s.settings.autoplaydelay)}else if(s.settings.reverseanimationswhennavigatingbackwards&&s.settings.autoplaydirection-1&&s.settings.animatestartingframein){s.modifyelements(s.nextframechildren,"0s");s.nextframe.addclass("animate-out");s.goto(s.nextframeid,-1)}else s.goto(s.nextframeid,1);else{s.container.addclass("sequence-fallback");s.beforenextframeanimatesin();s.afternextframeanimatesin();if(s.settings.hashtags&&s.settings.hashchangesonfirstframe){s.currenthashtag=s.nextframe.attr(s.gethashtagfrom);document.location.hash="#"+s.currenthashtag}s.currentframeid=s.nextframeid;s.sequence.children("li").addclass("animate-in");s.sequence.children(":not(li:nth-child("+s.nextframeid+"))").css({display:"none",opacity:0});s.resetautoplay(!0,s.settings.autoplaydelay)}s.nextbutton!==undefined&&s.nextbutton.click(function(){s.next()});s.prevbutton!==undefined&&s.prevbutton.click(function(){s.prev()});s.pausebutton!==undefined&&s.pausebutton.click(function(){s.pause(!0)});if(s.settings.keynavigation){var t={left:37,right:39};function n(e,n){var r;for(keycodes in n){keycodes==="left"||keycodes==="right"?r=t[keycodes]:r=keycodes;e===parsefloat(r)&&s.initcustomkeyevent(n[keycodes])}}e(document).keydown(function(e){var t=string.fromcharcode(e.keycode);if(t>0&&t<=s.numberofframes&&s.settings.numerickeysgotoframes){s.nextframeid=t;s.goto(s.nextframeid)}n(e.keycode,s.settings.keyevents);n(e.keycode,s.settings.customkeyevents)})}s.settings.pauseonhover&&s.settings.autoplay&&!s.hastouch&&s.sequence.on({mouseenter:function(){s.mouseover=!0;s.ishardpaused||s.pause()},mouseleave:function(){s.mouseover=!1;s.ishardpaused||s.unpause()}});s.settings.hashtags&&e(window).hashchange(function(){newtag=location.hash.replace("#","");if(s.currenthashtag!==newtag){s.currenthashtag=newtag;s.framehashindex=e.inarray(s.currenthashtag,s.framehashid);if(s.framehashindex!==-1){s.nextframeid=s.framehashindex+1;s.goto(s.nextframeid)}}});if(s.settings.swipenavigation&&s.hastouch){var r,i,o=!1;function u(){s.sequence.on("touchmove",a);r=null;o=!1}function a(e){s.settings.swipepreventsdefault&&e.preventdefault();if(o){var t=e.originalevent.touches[0].pagex,n=e.originalevent.touches[0].pagey,a=r-t,f=i-n;if(math.abs(a)>=s.settings.swipethreshold){u();a>0?s.initcustomkeyevent(s.settings.swipeevents.left):s.initcustomkeyevent(s.settings.swipeevents.right)}else if(math.abs(f)>=s.settings.swipethreshold){u();f>0?s.initcustomkeyevent(s.settings.swipeevents.down):s.initcustomkeyevent(s.settings.swipeevents.up)}}}function f(e){if(e.originalevent.touches.length==1){r=e.originalevent.touches[0].pagex;i=e.originalevent.touches[0].pagey;o=!0;s.sequence.on("touchmove",a)}}s.sequence.on("touchstart",f)}}var s=this;s.container=e(t),s.sequence=s.container.children("ul");try{modernizr.prefixed;if(modernizr.prefixed===undefined)throw"undefined"}catch(o){i.modernizr()}var u={webkittransition:"-webkit-",moztransition:"-moz-",otransition:"-o-",mstransition:"-ms-",transition:""},a={webkittransition:"webkittransitionend webkitanimationend",moztransition:"transitionend animationend",otransition:"otransitionend oanimationend",mstransition:"mstransitionend msanimationend",transition:"transitionend animationend"};s.prefix=u[modernizr.prefixed("transition")],s.transitionend=a[modernizr.prefixed("transition")],s.transitionproperties={},s.numberofframes=s.sequence.children("li").length,s.transitionssupported=s.prefix!==undefined?!0:!1,s.hastouch="ontouchstart"in window?!0:!1,s.active,s.navigationskipthresholdactive=!1,s.autoplaytimer,s.ispaused=!1,s.ishardpaused=!1,s.mouseover=!1,s.defaultpreloader,s.nextbutton,s.prevbutton,s.pausebutton,s.pauseicon,s.delayunpause,s.init={uielements:function(t,n){switch(t){case!1:return undefined;case!0:n===".sequence-preloader"&&i.defaultpreloader(s.container,s.transitionssupported,s.prefix);return e(n);default:return e(t)}}};s.paused=function(){},s.unpaused=function(){},s.beforenextframeanimatesin=function(){},s.afternextframeanimatesin=function(){},s.beforecurrentframeanimatesout=function(){},s.aftercurrentframeanimatesout=function(){},s.beforefirstframeanimatesin=function(){},s.afterfirstframeanimatesin=function(){},s.beforelastframeanimatesin=function(){},s.afterlastframeanimatesin=function(){},s.afterloaded=function(){};s.settings=e.extend({},r,n);s.settings.preloader=s.init.uielements(s.settings.preloader,".sequence-preloader");s.firstframe=s.settings.animatestartingframein?!0:!1;s.settings.unpausedelay=s.settings.unpausedelay===null?s.settings.autoplaydelay:s.settings.unpausedelay;s.currenthashtag;s.gethashtagfrom=s.settings.hashdataattribute?"data-sequence-hashtag":"id";s.framehashid=[];s.direction=s.settings.autoplaydirection;s.settings.hideframesuntilpreloaded&&s.settings.preloader&&s.sequence.children("li").hide();s.prefix==="-o-"&&(s.transitionssupported=i.operatest());s.modifyelements(s.sequence.children("li"),"0s");s.sequence.children("li").removeclass("animate-in");var l=s.settings.preloadtheseframes.length,c=s.settings.preloadtheseimages.length;if(!s.settings.preloader||l===0&&c===0)e(window).bind("load",function(){f();e(this).unbind("load")});else{function h(t,n){var r=[];if(!n)for(var i=t;i>0;i--)s.sequence.children("li:nth-child("+s.settings.preloadtheseframes[i-1]+")").find("img").each(function(){r.push(e(this)[0])});else for(var i=t;i>0;i--)r.push(e("body").find('img[src="'+s.settings.preloadtheseimages[i-1]+'"]')[0]);return r}var p=h(l),d=h(c,!0),v=e(p.concat(d)),m=v.length;g(v,f)}}t.prototype={initcustomkeyevent:function(e){var t=this;switch(e){case"next":t.next();break;case"prev":t.prev();break;case"pause":t.pause(!0)}},modifyelements:function(e,t){var n=this;e.css(n.prefixcss(n.prefix,{"transition-duration":t,"transition-delay":t}))},prefixcss:function(e,t){var n={};for(property in t)n[e+property]=t[property];return n},settransitionproperties:function(t){var n=this;t.each(function(){n.transitionproperties["transition-duration"]=e(this).css(n.prefix+"transition-duration");n.transitionproperties["transition-delay"]=e(this).css(n.prefix+"transition-delay");e(this).css(n.prefixcss(n.prefix,n.transitionproperties))})},startautoplay:function(e){var t=this,e=e===undefined?t.settings.autoplaydelay:e;t.unpause();t.resetautoplay();t.autoplaytimer=settimeout(function(){t.settings.autoplaydirection===1?t.next():t.prev()},e)},stopautoplay:function(){var e=this;e.pause(!0);cleartimeout(e.autoplaytimer)},resetautoplay:function(e,t){var n=this;if(e===!0){if(n.settings.autoplay&&!n.ispaused){cleartimeout(n.autoplaytimer);n.autoplaytimer=settimeout(function(){n.settings.autoplaydirection===1?n.next():n.prev()},t)}}else cleartimeout(n.autoplaytimer)},pause:function(e){var t=this;if(!t.ispaused){if(t.pausebutton!==undefined){t.pausebutton.addclass("paused");t.pauseicon!==undefined&&t.pauseicon.show()}t.paused();t.ispaused=!0;t.ishardpaused=e?!0:!1;t.resetautoplay()}else t.unpause()},unpause:function(e){var t=this;if(t.pausebutton!==undefined){t.pausebutton.removeclass("paused");t.pauseicon!==undefined&&t.pauseicon.hide()}t.ispaused=!1;t.ishardpaused=!1;if(!t.active){e!==!1&&t.unpaused();t.resetautoplay(!0,t.settings.unpausedelay)}else t.delayunpause=!0},next:function(){var e=this;e.nextframeid=e.currentframeid!==e.numberofframes?e.currentframeid+1:1;e.goto(e.nextframeid,1)},prev:function(){var e=this;e.nextframeid=e.currentframeid===1?e.numberofframes:e.currentframeid-1;e.goto(e.nextframeid,-1)},goto:function(e,t){var n=this,e=parsefloat(e);if(e===n.currentframeid||n.settings.navigationskip&&n.navigationskipthresholdactive||!n.settings.navigationskip&&n.active||!n.transitionssupported&&n.active||!n.settings.cycle&&t===1&&n.currentframeid===n.numberofframes||!n.settings.cycle&&t===-1&&n.currentframeid===1||n.settings.preventreverseskipping&&n.direction!==t&&n.active)return!1;if(n.settings.navigationskip&&n.active){n.navigationskipthresholdactive=!0;n.settings.fadeframewhenskipped&&n.nextframe.stop().animate({opacity:0},n.settings.fadeframetime);navigationskipthresholdtimer=settimeout(function(){n.navigationskipthresholdactive=!1},n.settings.navigationskipthreshold)}if(!n.active||n.settings.navigationskip){n.active=!0;n.resetautoplay();e===n.numberofframes?n.beforelastframeanimatesin():e===1&&n.beforefirstframeanimatesin();t===undefined?n.direction=e>n.currentframeid?1:-1:n.direction=t;n.currentframe=n.sequence.children(".animate-in");n.nextframe=n.sequence.children("li:nth-child("+e+")");n.framechildren=n.currentframe.children();n.nextframechildren=n.nextframe.children();if(n.transitionssupported){if(n.currentframe.length!==undefined){n.beforecurrentframeanimatesout();n.settings.moveactiveframetotop&&n.currentframe.css("z-index",1);n.modifyelements(n.nextframechildren,"0s");if(!n.settings.reverseanimationswhennavigatingbackwards||n.direction===1){n.nextframe.removeclass("animate-out");n.modifyelements(n.framechildren,"")}else if(n.settings.reverseanimationswhennavigatingbackwards&&n.direction===-1){n.nextframe.addclass("animate-out");n.settransitionproperties(n.framechildren)}}else n.firstframe=!1;n.active=!0;n.currentframe.unbind(n.transitionend);n.nextframe.unbind(n.transitionend);n.settings.fadeframewhenskipped&&n.nextframe.css("opacity",1);n.beforenextframeanimatesin();n.settings.moveactiveframetotop&&n.nextframe.css({"z-index":n.numberofframes});!n.settings.reverseanimationswhennavigatingbackwards||n.direction===1?settimeout(function(){n.modifyelements(n.nextframechildren,"");n.waitforanimationstocomplete(n.nextframe,n.nextframechildren,"in");n.aftercurrentframeanimatesout!=="function () {}"&&n.waitforanimationstocomplete(n.currentframe,n.framechildren,"out")},50):n.settings.reverseanimationswhennavigatingbackwards&&n.direction===-1&&settimeout(function(){n.modifyelements(n.nextframechildren,"");n.settransitionproperties(n.framechildren);n.waitforanimationstocomplete(n.nextframe,n.nextframechildren,"in");n.aftercurrentframeanimatesout!="function () {}"&&n.waitforanimationstocomplete(n.currentframe,n.framechildren,"out")},50);!n.settings.reverseanimationswhennavigatingbackwards||n.direction===1?settimeout(function(){n.currentframe.toggleclass("animate-out animate-in");n.nextframe.addclass("animate-in")},50):n.settings.reverseanimationswhennavigatingbackwards&&n.direction===-1&&settimeout(function(){n.nextframe.toggleclass("animate-out animate-in");n.currentframe.removeclass("animate-in")},50)}else{function r(){n.sethashtag();n.active=!1;n.resetautoplay(!0,n.settings.autoplaydelay)}n.beforecurrentframeanimatesout();switch(n.settings.fallback.theme){case"fade":n.sequence.children("li").css({position:"relative"});n.currentframe.animate({opacity:0},n.settings.fallback.speed,function(){n.currentframe.css({display:"none","z-index":"1"});n.beforenextframeanimatesin();n.nextframe.css({display:"block","z-index":n.numberofframes}).animate({opacity:1},500,function(){n.afternextframeanimatesin()});r()});n.sequence.children("li").css({position:"relative"});break;case"slide":default:var i={},s={},o={};if(n.direction===1){i.left="-100%";s.left="100%"}else{i.left="100%";s.left="-100%"}o.left="0";o.opacity=1;n.currentframe=n.sequence.children("li:nth-child("+n.currentframeid+")");n.currentframe.animate(i,n.settings.fallback.speed);n.beforenextframeanimatesin();n.nextframe.show().css(s);settimeout(function(){n.nextframe.animate(o,n.settings.fallback.speed,function(){r();n.afternextframeanimatesin()})},50)}}n.currentframeid=e}},waitforanimationstocomplete:function(t,n,r){var i=this;if(r==="out")var s=function(){i.aftercurrentframeanimatesout()};else if(r==="in")var s=function(){i.afternextframeanimatesin();i.sethashtag();i.currentframeid===i.numberofframes?i.afterlastframeanimatesin():i.currentframeid===1&&i.afterfirstframeanimatesin();i.active=!1;if(!i.ishardpaused&&!i.mouseover)if(!i.delayunpause)i.unpause(!1);else{i.delayunpause=!1;i.unpause()}};n.data("animationended",!1);t.bind(i.transitionend,function(r){e(r.target).data("animationended",!0);var o=!0;n.each(function(){if(e(this).data("animationended")===!1){o=!1;return!1}});if(o){t.unbind(i.transitionend);s()}})},sethashtag:function(){var t=this;if(t.settings.hashtags){t.currenthashtag=t.nextframe.attr(t.gethashtagfrom);t.framehashindex=e.inarray(t.currenthashtag,t.framehashid);if(t.framehashindex!==-1&&(t.settings.hashchangesonfirstframe||!t.firstframe||!t.transitionssupported)){t.nextframeid=t.framehashindex+1;document.location.hash="#"+t.currenthashtag}else{t.nextframeid=t.settings.startingframeid;t.firstframe=!1}}}};e.fn.sequence=function(i){var s=this;return s.each(function(){var s=new t(e(this),i,r,n);e(this).data("sequence",s)})};var n={modernizr:function(){window.modernizr=function(e,t,n){function r(e){v.csstext=e}function i(e,t){return r(prefixes.join(e+";")+(t||""))}function s(e,t){return typeof e===t}function o(e,t){return!!~(""+e).indexof(t)}function u(e,t){for(var r in e){var i=e[r];if(!o(i,"-")&&v[i]!==n)return t=="pfx"?i:!0}return!1}function a(e,t,r){for(var i in e){var o=t[e[i]];if(o!==n)return r===!1?e[i]:s(o,"function")?o.bind(r||t):o}return!1}function f(e,t,n){var r=e.charat(0).touppercase()+e.slice(1),i=(e+" "+b.join(r+" ")+r).split(" ");return s(t,"string")||s(t,"undefined")?u(i,t):(i=(e+" "+w.join(r+" ")+r).split(" "),a(i,t,n))}var l="2.6.1",c={},h=t.documentelement,p="modernizr",d=t.createelement(p),v=d.style,m,g={}.tostring,y="webkit moz o ms",b=y.split(" "),w=y.tolowercase().split(" "),e={svg:"http://www.w3.org/2000/svg"},s={},x={},t={},n=[],c=n.slice,k,l={}.hasownproperty,a;!s(l,"undefined")&&!s(l.call,"undefined")?a=function(e,t){return l.call(e,t)}:a=function(e,t){return t in e&&s(e.constructor.prototype[t],"undefined")},function.prototype.bind||(function.prototype.bind=function(e){var t=self;if(typeof t!="function")throw new typeerror;var n=c.call(arguments,1),r=function(){if(self instanceof r){var i=function(){};i.prototype=t.prototype;var s=new i,o=t.apply(s,n.concat(c.call(arguments)));return object(o)===o?o:s}return t.apply(e,n.concat(c.call(arguments)))};return r}),s.svg=function(){return!!t.createelementns&&!!t.createelementns(e.svg,"svg").createsvgrect};for(var o in s)a(s,o)&&(k=o.tolowercase(),c[k]=s[o](),n.push((c[k]?"":"no-")+k));return c.addtest=function(e,t){if(typeof e=="object")for(var r in e)a(e,r)&&c.addtest(r,e[r]);else{e=e.tolowercase();if(c[e]!==n)return c;t=typeof t=="function"?t():t,enableclasses&&(h.classname+=" "+(t?"":"no-")+e),c[e]=t}return c},r(""),d=m=null,c._version=l,c._domprefixes=w,c._cssomprefixes=b,c.testprop=function(e){return u([e])},c.testallprops=f,c.prefixed=function(e,t,n){return t?f(e,t,n):f(e,"pfx")},c}(self,self.document)},defaultpreloader:function(t,n,r){var i='
';e("head").append("");t.prepend(i);if(!modernizr.svg&&!n){e(".sequence-preloader").prepend('
');setinterval(function(){e(".sequence-preloader .circle").fadetoggle(500)},500)}else n||setinterval(function(){e(".sequence-preloader").fadetoggle(500)},500)},operatest:function(){e("body").append('');var t=e("#sequence-opera-test");t.css("-o-transition","1s");return t.css("-o-transition")!="1s"?!1:!0}},r={startingframeid:1,cycle:!0,animatestartingframein:!1,reverseanimationswhennavigatingbackwards:!0,moveactiveframetotop:!0,autoplay:!0,autoplaydirection:1,autoplaydelay:5e3,navigationskip:!0,navigationskipthreshold:250,fadeframewhenskipped:!0,fadeframetime:150,preventreverseskipping:!1,nextbutton:!1,shownextbuttononinit:!0,prevbutton:!1,showprevbuttononinit:!0,pausebutton:!1,unpausedelay:null,pauseonhover:!0,pauseicon:!1,preloader:!1,preloadtheseframes:[1],preloadtheseimages:[],hideframesuntilpreloaded:!0,prependpreloadingcomplete:!0,hidepreloaderusingcss:!0,hidepreloaderdelay:0,keynavigation:!0,numerickeysgotoframes:!0,keyevents:{left:"prev",right:"next"},customkeyevents:{},swipenavigation:!0,swipethreshold:20,swipepreventsdefault:!1,swipeevents:{left:"prev",right:"next",up:!1,down:!1},hashtags:!1,hashdataattribute:!1,hashchangesonfirstframe:!1,fallback:{theme:"slide",speed:500}}})(jquery);