Beautifully crafted timelines that are easy and intuitive to use. http://timeline.knightlab.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
73 KiB

/* Verite
* Verite JS Master
* Version: 0.1
* Date: December 12, 2011
* Copyright 2011 Verite
* Designed and built by Zach Wise digitalartwork.net
* ----------------------------------------------------- *//* CodeKit Import
================================================== *//* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
================================================== */function trace(a){window.console?console.log(a):typeof jsTrace!="undefined"&&jsTrace.send(a)}function onYouTubePlayerAPIReady(){VMM.ExternalAPI.youtube.onAPIReady()}(function(){var a=!1,b=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(c){function g(){!a&&this.init&&this.init.apply(this,arguments)}var d=this.prototype;a=!0;var e=new this;a=!1;for(var f in c)e[f]=typeof c[f]=="function"&&typeof d[f]=="function"&&b.test(c[f])?function(a,b){return function(){var c=this._super;this._super=d[a];var e=b.apply(this,arguments);this._super=c;return e}}(f,c[f]):c[f];g.prototype=e;g.prototype.constructor=g;g.extend=arguments.callee;return g}})();var global=function(){return this||(1,eval)("this")}();if(typeof VMM=="undefined"){var VMM=Class.extend({});VMM.master_config={init:function(){return this},youtube:{active:!1,array:[],api_loaded:!1}}.init();VMM.master_config={init:function(){return this},youtube:{active:!1,array:[],api_loaded:!1,que:[]}}.init();VMM.createElement=function(a,b,c,d,e){var f="";if(a!=null&&a!=""){f+="<"+a;c!=null&&c!=""&&(f+=" class='"+c+"'");d!=null&&d!=""&&(f+=" "+d);e!=null&&e!=""&&(f+=" "+e);f+=">";b!=null&&b!=""&&(f+=b);f=f+"</"+a+">"}return f};VMM.createMediaElement=function(a,b,c){var d="",e=!1;d+="<div class='media'>";if(a!=null&&a!=""){valid=!0;d+="<img src='"+a+"'>";c!=null&&c!=""&&(d+=VMM.createElement("div",c,"credit"));b!=null&&b!=""&&(d+=VMM.createElement("div",b,"caption"))}d+="</div>";return d};VMM.attachElement=function(a,b){typeof jQuery!="undefined"&&$(a).html(b)};VMM.appendElement=function(a,b){typeof jQuery!="undefined"&&$(a).append(b)};VMM.getHTML=function(a){var b;if(typeof jQuery!="undefined"){b=$(a).html();return b}};VMM.getElement=function(a,b){var c;if(typeof jQuery!="undefined"){b?c=$(a).parent().get(0):c=$(a).get(0);return c}};VMM.bindEvent=function(a,b,c,d){var e,f="click",g={};c!=null&&c!=""&&(f=c);g!=null&&g!=""&&(g=d);typeof jQuery!="undefined"&&$(a).bind(f,g,b)};VMM.unbindEvent=function(a,b,c){var d,e="click",f={};c!=null&&c!=""&&(e=c);typeof jQuery!="undefined"&&$(a).unbind(e,b)};VMM.fireEvent=function(a,b,c){var d,e="click",f=[];b!=null&&b!=""&&(e=b);c!=null&&c!=""&&(f=c);typeof jQuery!="undefined"&&$(a).trigger(e,f)};VMM.getJSON=function(a,b){typeof jQuery!="undefined"&&$.getJSON(a,b)};VMM.appendAndGetElement=function(a,b,c,d){var e,f="<div>",g="",h="";b!=null&&b!=""&&(f=b);c!=null&&c!=""&&(g=c);d!=null&&d!=""&&(h=d);if(typeof jQuery!="undefined"){e=$(b);e.addClass(g);e.html(h);$(a).append(e)}return e};VMM.Element={init:function(){return this},hide:function(a,b){b!=null&&b!=""?typeof jQuery!="undefined"&&$(a).hide(b):typeof jQuery!="undefined"&&$(a).hide()},remove:function(a){typeof jQuery!="undefined"&&$(a).remove()},detach:function(a){typeof jQuery!="undefined"&&$(a).detach()},append:function(a,b){typeof jQuery!="undefined"&&$(a).append(b)},show:function(a,b){b!=null&&b!=""?typeof jQuery!="undefined"&&$(a).show(b):typeof jQuery!="undefined"&&$(a).show()},load:function(a,b,c){var d={elem:a};d!=null&&d!=""&&(d=c);typeof jQuery!="undefined"&&$(a).load(d,b)},addClass:function(a,b){typeof jQuery!="undefined"&&$(a).addClass(b)},removeClass:function(a,b){typeof jQuery!="undefined"&&$(a).removeClass(b)},attr:function(a,b,c){if(c!=null&&c!="")typeof jQuery!="undefined"&&$(a).attr(b,c);else if(typeof jQuery!="undefined")return $(a).attr(b)},prop:function(a,b,c){typeof jQuery=="undefined"||!/[1-9]\.[3-9].[1-9]/.test($.fn.jquery)?VMM.Element.attribute(a,b,c):$(a).prop(b,c)},attribute:function(a,b,c){if(c!=null&&c!="")typeof jQuery!="undefined"&&$(a).attr(b,c);else if(typeof jQuery!="undefined")return $(a).attr(b)},visible:function(a,b){if(b!=null)typeof jQuery!="undefined"&&(b?$(a).show(0):$(a).hide(0));else if(typeof jQuery!="undefined")return $(a).is(":visible")?!0:!1},css:function(a,b,c){if(c!=null&&c!="")typeof jQuery!="undefined"&&$(a).css(b,c);else if(typeof jQuery!="undefined")return $(a).css(b)},cssmultiple:function(a,b){if(typeof jQuery!="undefined")return $(a).css(b)},offset:fun
,"max-height",o.height-50);VMM.Element.css(".slider-item .layout-media .media .media-container img","max-height",o.height-150);VMM.Element.css(".slider-item .media .media-container .soundcloud","max-height",168);var a=Math.round(o.height)-160,b=Math.round(a/9*16),c=o.content_width/100*60,d=Math.round(c/16*9)+25;VMM.Element.height(".slider-item .media .media-container .media-frame",d);VMM.Element.width(".slider-item .media .media-container .media-frame",c);VMM.Element.height(".slider-item .layout-media .media .media-container .media-frame",a);VMM.Element.width(".slider-item .layout-media .media .media-container .media-frame",b);VMM.Element.height(".slider-item .layout-media .media .media-container .soundcloud",o.height-150);VMM.Element.width(".slider-item .layout-media .media .media-container .soundcloud",o.content_width);VMM.Element.width(".slider-item .layout-text-media .media .media-container .soundcloud",c);VMM.Element.height(".slider-item .media .media-container .map",a);VMM.Element.css(".slider-item .layout-text-media .media .media-container .media-frame","max-width",o.content_width);var e=0;for(var f=0;f<i.length;f++){e=f*(o.width+o.spacing);VMM.Element.css(i[f],"left",e)}},H=function(a){var b="linear";for(var c=0;c<i.length;c++)c==k?VMM.Element.animate(i[c],o.duration,b,{opacity:1}):c==k-1?VMM.Element.animate(i[c],o.duration,b,{opacity:.1}):c==k+1?VMM.Element.animate(i[c],o.duration,b,{opacity:.1}):VMM.Element.css(i[c],"opacity",a)},I=function(a,b,c,d,e){VMM.ExternalAPI.youtube.stopPlayers();k=a;var f=o.ease,h=o.duration,j=!1,l=!1;k==0&&(l=!0);k+1==i.length&&(j=!0);b!=null&&b!=""&&(f=b);c!=null&&c!=""&&(h=c);var m=VMM.Element.position(i[k]);if(l)VMM.Element.visible(w.prevBtn,!1);else{VMM.Element.visible(w.prevBtn,!0);o.timeline&&VMM.attachElement(w.prevDate,g[k-1].date);VMM.attachElement(w.prevTitle,VMM.Util.unlinkify(g[k-1].title))}if(j)VMM.Element.visible(w.nextBtn,!1);else{VMM.Element.visible(w.nextBtn,!0);o.timeline&&VMM.attachElement(w.nextDate,g[k+1].date);VMM.attachElement(w.nextTitle,VMM.Util.unlinkify(g[k+1].title))}if(d)VMM.Element.css(u,"left",-(m.left-o.content_padding));else{VMM.Element.stop(u);VMM.Element.animate(u,h,f,{left:-(m.left-o.content_padding)})}e&&VMM.fireEvent(x,"LOADED");if(VMM.Element.height(i[k])>o.height)VMM.Element.css(".slider","overflow-y","scroll");else{VMM.Element.css(x,"overflow-y","hidden");VMM.Element.animate(x,h,f,{scrollTop:VMM.Element.prop(x,"scrollHeight")-VMM.Element.height(x)})}},J=function(){var a="<div class='icon'>&nbsp;</div>";w.nextBtn=VMM.appendAndGetElement(s,"<div>","nav-next");w.prevBtn=VMM.appendAndGetElement(s,"<div>","nav-previous");w.nextBtnContainer=VMM.appendAndGetElement(w.nextBtn,"<div>","nav-container",a);w.prevBtnContainer=VMM.appendAndGetElement(w.prevBtn,"<div>","nav-container",a);if(o.timeline){w.nextDate=VMM.appendAndGetElement(w.nextBtnContainer,"<div>","date","1957");w.prevDate=VMM.appendAndGetElement(w.prevBtnContainer,"<div>","date","1957")}w.nextTitle=VMM.appendAndGetElement(w.nextBtnContainer,"<div>","title","Title Goes Here");w.prevTitle=VMM.appendAndGetElement(w.prevBtnContainer,"<div>","title","Title Goes Here");VMM.bindEvent(".nav-next",A);VMM.bindEvent(".nav-previous",B)},K=function(){VMM.attachElement(x,"");s=VMM.getElement("div.slider");t=VMM.appendAndGetElement(s,"<div>","slider-container-mask");u=VMM.appendAndGetElement(t,"<div>","slider-container");v=VMM.appendAndGetElement(u,"<div>","slider-item-container");J();F(g);var a=3e3;if(VMM.Browser.device=="tablet"||VMM.Browser.device=="mobile"){o.duration=500;a=1e3;VMM.TouchSlider.createPanel(u,u,VMM.Element.width(i[0]),o.spacing,!0);VMM.bindEvent(u,C,"TOUCHUPDATE")}else VMM.Browser.device!="mobile";z(!1,!0);VMM.Element.visible(w.prevBtn,!1);I(0,"easeOutExpo",a,!0,!0);r=!0}});typeof VMM!="undefined"&&typeof VMM.Util=="undefined"&&(VMM.Util={init:function(){return this},randomBetween:function(a,b){return Math.floor(Math.random()*(b-a+1)+a)},customSort:function(a,b){var c=a,d=b;return c==d?0:c>d?1:-1},number2money:function(a,b,c){var b=b!==null?b:!0,c=c!==null?c:!1,d=VMM.Math2.floatPrecisio
($interval_date,i);VMM.Element.css($interval_date,"left",k);VMM.Element.css($interval_date,"left",k);VMM.Element.css($interval_date,"text-indent",-(VMM.Element.width($interval_date)/2));c&&(_major_first_pos=k);c=!1;g=k;_major_last_pos=k}VMM.Element.width(u,o.number*(r.interval_width/r.multiplier));_minor_pos_offset=50;var l=_major_last_pos-_major_first_pos+_minor_pos_offset*6,m=f+_minor_pos_offset*6;l<m?VMM.Element.width(C,m):VMM.Element.width(C,l);VMM.Element.css(C,"left",_major_first_pos-_minor_pos_offset);r.timeline_width=VMM.Element.width(x)},X=function(){j=U(e[e.length-1].enddate-e[0].startdate,!0);V();if(j.milleniums>e.length/r.density)o=q.millenium;else if(j.centuries>e.length/r.density)o=Math.ceil(q.century);else if(j.decades>e.length/r.density)o=q.decade;else if(j.years>e.length/r.density)o=q.year;else if(j.months>e.length/r.density)o=q.month;else if(j.days>e.length/r.density)o=q.day;else if(j.hours>e.length/r.density)o=q.hour;else if(j.minutes>e.length/r.density)o=q.minute;else if(j.seconds>e.length/r.density)o=q.second;else{trace("NO FUCKING IDEA WHAT THE TYPE SHOULD BE");o.type="unknown"}if(j.milleniums>=1)p=q.millenium;else if(j.centuries>=1)p=q.century;else if(j.decades>=1)p=q.decade;else if(j.years>=1)p=q.year;else if(j.months>1)p=q.month;else if(j.weeks>1)p=q.month;else if(j.days>1)p=q.day;else if(j.hours>1)p=q.hour;else if(j.minutes>1)p=q.minute;else if(j.seconds>1)p=q.minute;else{trace("NO FUCKING IDEA WHAT THE TYPE SHOULD BE");p.type="unknown"}C=VMM.appendAndGetElement(w,"<div>","minor");W()},Y=function(a,b,c,d,e){k=a;var f=r.ease,g=r.duration,i=!1,j=!1;k==0&&(j=!0);k+1==h.length&&(i=!0);b!=null&&b!=""&&(f=b);c!=null&&c!=""&&(g=c);var l=VMM.Element.position(h[k].marker);for(var m=0;m<h.length;m++)VMM.Element.removeClass(h[m].marker,"active");if(r.has_start_page&&h[k].type=="start"){VMM.Element.visible(h[k].marker,!1);VMM.Element.addClass(h[k].marker,"start")}VMM.Element.addClass(h[k].marker,"active");!j;!i;VMM.Element.stop(t);VMM.Element.animate(t,g,f,{left:r.width/2-l.left})},Z=function(){VMM.attachElement(H,"");t=VMM.appendAndGetElement(H,"<div>","timenav");u=VMM.appendAndGetElement(t,"<div>","content");v=VMM.appendAndGetElement(t,"<div>","time");w=VMM.appendAndGetElement(v,"<div>","time-interval-minor");y=VMM.appendAndGetElement(v,"<div>","time-interval-major");x=VMM.appendAndGetElement(v,"<div>","time-interval");z=VMM.appendAndGetElement(H,"<div>","timenav-background");B=VMM.appendAndGetElement(z,"<div>","timenav-line");A=VMM.appendAndGetElement(z,"<div>","timenav-interval-background","<div class='top-highlight'></div>");X();R();J(!0);VMM.fireEvent(H,"LOADED");D=VMM.appendAndGetElement(H,"<div>","toolbar");if(r.has_start_page){$backhome=VMM.appendAndGetElement(D,"<div>","back-home","<div class='icon'></div>");VMM.bindEvent(".back-home",N,"click");VMM.Element.css(D,"top",27)}E=VMM.appendAndGetElement(D,"<div>","zoom-in","<div class='icon'></div>");F=VMM.appendAndGetElement(D,"<div>","zoom-out","<div class='icon'></div>");VMM.Element.attribute($backhome,"title","Return to Title");VMM.Element.attribute($backhome,"rel","tooltip");VMM.Element.attribute(E,"title","Expand Timeline");VMM.Element.attribute(E,"rel","tooltip");VMM.Element.attribute(F,"title","Contract Timeline");VMM.Element.attribute(F,"rel","tooltip");VMM.bindEvent(".zoom-in",L,"click");VMM.bindEvent(".zoom-out",M,"click");D.tooltip({selector:"div[rel=tooltip]",placement:"right"});if(VMM.Browser.device=="mobile"||VMM.Browser.device=="tablet"){VMM.TouchSlider.createPanel(z,t,r.width,r.spacing,!1);VMM.bindEvent(t,Q,"TOUCHUPDATE")}else VMM.DragSlider.createPanel(H,t,r.width,r.spacing,!1);l=!0},$=function(){W();T(!0)}};VMM.Timeline.DataObj={data_obj:{},model_array:[],getData:function(a){data=VMM.Timeline.DataObj.data_obj;if(type.of(a)!="string"){trace("DATA SOURCE: NOT JSON");trace("TRYING HTML PARSE");VMM.Timeline.DataObj.parseHTML(a)}else if(a.match("%23")){trace("DATA SOURCE: TWITTER SEARCH");VMM.Timeline.DataObj.model_Tweets.getData("%23medill")}else if(a.match("spreadsheet")){trace("DATA SOURCE: GOOGLE SPREADSHEET");VMM.Timeline.DataObj.mo