(function(e,i){var m=window.TimelineSetter=(window.TimelineSetter||{});var s=function(E){E.bind=function(I,F){var G=(this._callbacks=this._callbacks||{});var H=(G[I]=G[I]||[]);H.push(F)};E.trigger=function(H){if(!this._callbacks){return}var G=this._callbacks[H];if(!G){return}for(var F=0;F0&&N<=250?"doubletap":"tap";G={x:M.touches[0].pageX};H=K;I.el.trigger(e.Event(L))});I.el.bind("touchmove",F);I.el.bind("touchend",J)}};var o=/WebKit\/533/.test(navigator.userAgent);var y=function(F){function E(H){H.preventDefault();var I=(H.wheelDelta||-H.detail);if(o){var G=I<0?-1:1;I=Math.log(Math.abs(I))*G*2}H.type="scrolled";H.deltaX=I;F.el.trigger(H)}F.el.bind("mousewheel DOMMouseScroll",E)};var w=function(){this.min=+Infinity;this.max=-Infinity};w.prototype.extend=function(E){this.min=Math.min(E,this.min);this.max=Math.max(E,this.max)};w.prototype.width=function(){return this.max-this.min};w.prototype.project=function(F,E){return(F-this.min)/this.width()*E};var h=function(G,E){this.max=G.max;this.min=G.min;if(!E||!this.INTERVALS[E]){var F=this.computeMaxInterval();this.maxInterval=this.INTERVAL_ORDER[F];this.idx=F}else{this.maxInterval=E;this.idx=_.indexOf(this.INTERVAL_ORDER,E)}};h.dateFormats=function(H){var J=new Date(H);var I={};var F=["Jan.","Feb.","March","April","May","June","July","Aug.","Sept.","Oct.","Nov.","Dec."];var G=J.getHours()>12;var E=J.getHours()>=12;I.month=F[J.getMonth()];I.year=J.getFullYear();I.date=I.month+" "+J.getDate()+", "+I.year;I.hourWithMinutes=(G?J.getHours()-12:(J.getHours()>0?J.getHours():"12"))+":"+z(J.getMinutes())+" "+(E?"p.m.":"a.m.");I.hourWithMinutesAndSeconds=I.hourWithMinutes+":"+z(J.getSeconds());return h.formatter(J,I)||I};h.dateStr=function(F,E){var G=new h.dateFormats(F);switch(E){case"Decade":return G.year;case"Lustrum":return G.year;case"FullYear":return G.year;case"Month":return G.month+", "+G.year;case"Week":return G.date;case"Date":return G.date;case"Hours":return G.hourWithMinutes;case"Minutes":return G.hourWithMinutes;case"Seconds":return G.hourWithMinutesAndSeconds}};h.prototype={INTERVALS:{Decade:315360000000,Lustrum:157680000000,FullYear:31536000000,Month:2592000000,Week:604800000,Date:86400000,Hours:3600000,Minutes:60000,Seconds:1000},INTERVAL_ORDER:["Seconds","Minutes","Hours","Date","Week","Month","FullYear","Lustrum","Decade"],isAtLeastA:function(E){return((this.max-this.min)>this.INTERVALS[E])},computeMaxInterval:function(){for(var E=0;E_.indexOf(this.INTERVAL_ORDER,"FullYear")?_.indexOf(this.INTERVAL_ORDER,"FullYear"):E;switch(H){case"Decade":F.setFullYear(this.getDecade(F));break;case"Lustrum":F.setFullYear(this.getLustrum(F));break;case"Week":F.setDate(this.getWeekFloor(F).getDate());E=_.indexOf(this.INTERVAL_ORDER,"Week")}while(E--){H=this.INTERVAL_ORDER[E];if(H!=="Week"){F["set"+H](H==="Date"?1:0)}}return F.getTime()},ceil:function(F){var E=new Date(this.floor(F));var G=this.INTERVAL_ORDER[this.idx];switch(G){case"Decade":E.setFullYear(this.getDecade(E)+10);break;case"Lustrum":E.setFullYear(this.getLustrum(E)+5);break;case"Week":E.setTime(this.getWeekCeil(E).getTime());break;default:E["set"+G](E["get"+G]()+1)}return E.getTime()},span:function(E){return this.ceil(E)-this.floor(E)},getRanges:function(){if(this.intervals){return this.intervals}this.intervals=[];for(var E=this.floor(this.min);E<=this.ceil(this.max);E+=this.span(E)){this.intervals.push({human:h.dateStr(E,this.maxInterval),timestamp:E})}return this.intervals}};var n=function(E,G){var F=Array.prototype.slice.call(arguments,2);_.each(F,function(H){E.bind(H,function(){G[H].apply(G,arguments)})})};var v=function(E){return parseInt(E.replace(/^[^+\-\d]?([+\-]?\d+)?.*$/,"$1"),10)};var z=function(E){return(E<10?"0":"")+E};var t=/^#*/;var r={get:function(){return window.location.hash.replace(t,"")},set:function(E){window.location.hash=E}};var x=1;var u=function(){var E;if(x<10){E=x;x+=1}else{E="default"}return E};var j=m.Timeline=function(F,E){_.bindAll(this,"render");this.data=F.sort(function(H,G){return H.timestamp-G.timestamp});this.bySid={};this.cards=[];this.series=[];this.config=E;this.config.container=this.config.container||"#timeline";h.formatter=this.config.formatter||function(H,G){return G}};s(j.prototype);j.prototype=_.extend(j.prototype,{render:function(){var F=this;c(this,this.config.container);e(this.config.container).html(JST.timeline());this.bounds=new w();this.bar=new b(this);this.cardCont=new q(this);this.createSeries(this.data);var E=new h(this.bounds,this.config.interval);this.intervals=E.getRanges();this.bounds.extend(this.bounds.min-E.getMaxInterval()/2);this.bounds.extend(this.bounds.max+E.getMaxInterval()/2);this.bar.render();n(this.bar,this.cardCont,"move","zoom");this.trigger("render");new f("in",this);new f("out",this);this.chooseNext=new C("next",this);this.choosePrev=new C("prev",this);if(!this.$(".TS-card_active").is("*")){this.chooseNext.click()}e(this.config.container).bind("click",_.bind(this.setGlobalCurrentTimeline,this));this.trigger("load")},setGlobalCurrentTimeline:function(){m.currentTimeline=this},createSeries:function(F){for(var E=0;EF){H.deltaX=F-I}this.trigger("move",H);this.timeline.trigger("move",H);this.move("move",H)},doZoom:function(J,F){var G=this;var E=this.timeline.$(".TS-notch_active");var I=function(){return E.length>0?E.position().left:0};var H=I();this.el.animate({width:F+"%"},{step:function(M,K){var L=e.Event("dragging");var N=H-I();L.deltaX=N;G.moving(L);H=I();L=e.Event("zoom");L.width=M+"%";G.trigger("zoom",L)}})},render:function(){var G=this.timeline.intervals;var H=this.timeline.bounds;for(var F=0;F0?u():"default";this.cards=[];_.bindAll(this,"render","showNotches","hideNotches");this.timeline.bind("render",this.render)};s(l.prototype);l.prototype=_.extend(l.prototype,{add:function(E){var F=new k(E,this);this.cards.push(F)},_comparator:function(E){return E.timestamp},hideNotches:function(E){E.preventDefault();this.el.addClass("TS-series_legend_item_inactive");this.trigger("hideNotch")},showNotches:function(E){E.preventDefault();this.el.removeClass("TS-series_legend_item_inactive");this.trigger("showNotch")},render:function(E){if(this.name.length===0){return}this.el=e(JST.series_legend(this));this.timeline.$(".TS-series_nav_container").append(this.el);this.el.toggle(this.hideNotches,this.showNotches)}});_(["min","max"]).each(function(E){l.prototype[E]=function(){return _[E].call(_,this.cards,this._comparator).get("timestamp")}});var k=function(E,F){this.series=F;this.timeline=this.series.timeline;E=_.clone(E);this.timestamp=E.timestamp;this.attributes=E;this.attributes.topcolor=F.color;_.bindAll(this,"render","activate","flip","setPermalink","toggleNotch");this.series.bind("hideNotch",this.toggleNotch);this.series.bind("showNotch",this.toggleNotch);this.timeline.bind("render",this.render);this.timeline.bar.bind("flip",this.flip);this.id=[this.get("timestamp"),this.get("description").split(/ /)[0].replace(/[^a-zA-Z\-]/g,"")].join("-");this.timeline.cards.push(this)};k.prototype=_.extend(k.prototype,{get:function(E){return this.attributes[E]},render:function(){this.offset=this.timeline.bounds.project(this.timestamp,100);var E=JST.notch(this.attributes);this.notch=e(E).css({left:this.offset+"%"});this.timeline.$(".TS-notchbar").append(this.notch);this.notch.click(this.activate);if(r.get()===this.id){this.activate()}},flip:function(){if(!this.el||!this.el.is(":visible")){return}var E=this.$(".TS-item").offset().left+this.$(".TS-item").width();var I=this.timeline.$(".timeline_setter").offset().left+this.timeline.$(".timeline_setter").width();var H=this.el.css("margin-left")===this.originalMargin;var G=this.$(".TS-item").width()this.$(".TS-item_year").width()){this.$(".TS-item_label").css("width",this.$(E).width())}else{this.$(".TS-item_label").css("width",this.$(".TS-item_year").width())}},move:function(){var F=e.Event("moving");var G=this.$(".TS-item").offset();var E=this.timeline.$(".timeline_setter").offset();if(G.leftE.left+this.timeline.$(".timeline_setter").width()){F.deltaX=E.left+this.timeline.$(".timeline_setter").width()-(G.left+this.$(".TS-item").outerWidth());this.timeline.bar.moving(F)}}},setPermalink:function(){r.set(this.id)},hideActiveCard:function(){this.timeline.$(".TS-card_active").removeClass("TS-card_active").hide();this.timeline.$(".TS-notch_active").removeClass("TS-notch_active")},toggleNotch:function(E){switch(E){case"hideNotch":this.notch.hide().removeClass("TS-notch_active").addClass("TS-series_inactive");if(this.el){this.el.hide()}return;case"showNotch":this.notch.removeClass("TS-series_inactive").show()}}});var g=function(){};var p=function(F,E){g.prototype=E.prototype;F.prototype=new g();F.prototype.constructor=F};var D=function(G,F){this.timeline=F;this.direction=G;this.el=this.timeline.$(this.prefix+G);var E=this;this.el.bind("click",function(H){H.preventDefault();E.click(H)})};var a=100;var f=function(F,E){D.apply(this,arguments)};p(f,D);f.prototype=_.extend(f.prototype,{prefix:".TS-zoom_",click:function(){a+=(this.direction==="in"?+100:-100);if(a>=100){this.timeline.$(".TS-notchbar").trigger("doZoom",[a])}else{a=100}}});var C=function(F,E){D.apply(this,arguments);this.notches=this.timeline.$(".TS-notch")};p(C,D);C.prototype=_.extend(D.prototype,{prefix:".TS-choose_",click:function(I){var F;var H=this.notches.not(".TS-series_inactive");var E=H.index(this.timeline.$(".TS-notch_active"));var G=H.length;if(this.direction==="next"){F=(E0?H.eq(E-1):false)}if(!F){return}F.trigger("click")}});m.Api=function(E){this.timeline=E};m.Api.prototype=_.extend(m.Api.prototype,{onLoad:function(E){this.timeline.bind("load",E)},onCardAdd:function(E){this.timeline.bind("cardAdd",E)},onCardActivate:function(E){this.timeline.bind("cardActivate",E)},onBarMove:function(E){this.timeline.bind("move",E)},activateCard:function(E){_(this.timeline.cards).detect(function(F){return F.timestamp===E}).activate()}});m.bindKeydowns=function(){e(document).bind("keydown",function(E){if(m.currentTimeline&&E.keyCode===39){m.currentTimeline.chooseNext.click()}else{if(m.currentTimeline&&E.keyCode===37){m.currentTimeline.choosePrev.click()}else{return}}})};j.boot=function(H,E){var G=m.timeline=new j(H,E||{});var F=new m.Api(G);if(!m.pageTimelines){m.currentTimeline=G;m.bindKeydowns()}m.pageTimelines=m.pageTimelines?m.pageTimelines+=1:1;e(G.render);return{timeline:G,api:F}}})(jQuery);(function(){window.JST=window.JST||{};var a=function(c){var b=new Function("obj","var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+c.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/<%=([\s\S]+?)%>/g,function(d,e){return"',"+e.replace(/\\'/g,"'")+",'"}).replace(/<%([\s\S]+?)%>/g,function(d,e){return"');"+e.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');");return b};window.JST.card=a('
">\n
">
\n
" data-timestamp="<%= card.get("timestamp") %>">\n
\n <% if (!_.isEmpty(card.get("html"))){ %>\n
\n <%= card.get("html") %>\n
\n <% } %>\n <%= card.get("description") %>\n
\n <% if (!_.isEmpty(card.get("link"))){ %>\n ">Read More\n <% } %>\n\n
\n <%= (card.get("display_date") || "").length > 0 ? card.get("display_date") : card.get("date") %>\n \n
\n
\n
');window.JST.notch=a('
TS-notch_color_<%= topcolor %>">
\n');window.JST.series_legend=a('
">\n   <%= name %>\n
\n');window.JST.timeline=a('
\n
\n
\n + \n - \n      \n « Previous \n Next »\n
\n
\n
\n\n
\n
\n
\n
\n
\n
\n
\n
');window.JST.year_notch=a('
\n <%= human %>\n
\n')})();