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.

32 lines
126 KiB

/*!
13 years ago
TimelineJS
Designed and built by Zach Wise at VéritéCo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
http://www.gnu.org/licenses/
*//***********************************************
Begin VMM.js
***********************************************//* Verite
* Verite JS Master
* Version: 0.6
* Date: April 26, 2012
* Copyright 2012 Verite unless part of Verite Timeline,
* if part of Timeline then it inherits Timeline's license.
* Designed and built by Zach Wise digitalartwork.net
* ----------------------------------------------------- *//* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
================================================== */function trace(a){VMM.debug&&(window.console?console.log(a):typeof jsTrace!="undefined"&&jsTrace.send(a))}function onYouTubePlayerAPIReady(){trace("GLOBAL YOUTUBE API CALLED");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.debug=!0;VMM.master_config={init:function(){return this},sizes:{api:{width:0,height:0}},vp:"Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo",api_keys_master:{flickr:"RAIvxHY4hE/Elm5cieh4X5ptMyDpj7MYIxziGxi0WGCcy1s+yr7rKQ==",google:"jwNGnYw4hE9lmAez4ll0QD+jo6SKBJFknkopLS4FrSAuGfIwyj57AusuR0s8dAo=",twitter:""},flickr:{active:!1,array:[],api_loaded:!1,que:[]},youtube:{active:!1,array:[],api_loaded:!1,que:[]},vimeo:{active:!1,array:[],api_loaded:!1,que:[]},googlemaps:{active:!1,map_active:!1,places_active:!1,array:[],api_loaded:!1,que:[]},googledocs:{active:!1,array:[],api_loaded:!1,que:[]},googleplus:{active:!1,array:[],api_loaded:!1,que:[]},wikipedia:{active:!1,array:[],api_loaded:!1,que:[]},soundcloud:{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+=" style='"+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.hideUrlBar=function(){var a=window,b=a.document;if(!location.hash||!a.addEventListener){window.scrollTo(0,1);var c=1,d=setInterval(function(){if(b.body){clearInterval(d);c="scrollTop"in b.body?b.body.scrollTop:1;a.scrollTo(0,c===1?0:1)}},15);a.addEventListener("load",function(){setTimeout(function(){a.scrollTo(0,c===1?0:1)},0)},!1)}}}Date.prototype.getWeek=function(){var a=new Date(this.getFullYear(),0,1);return Math.ceil(((this-a)/864e5+a.getDay()+1)/7)};Date.prototype.getDayOfYear=function(){var a=new Date(this.getFullYear(),0,1);return Math.ceil((this-a)/864e5)};var is={Null:function(a){return a===null},Undefined:function(a){return a===undefined},nt:function(a){return a===null||a===undefined},Function:function(a){return typeof a=="function"?a.constructor.toString().match(/Function/)!==null:!1},String:function(a){return typeof a=="string"?!0:typeof a=="object"?a.constructor.toString().match(/string/i)!==null:!1},Array:function(a){return typeof a=="object"?a.constructor.toString().match(/array/i)!==null||a.length!==undefined:!1},Boolean:function(a){return typeof a=="boolean"?!0:typeof a=="object"?a.constructor.toString().match(/boolean/i)!==null:!1},Date:function(a){return typeof a=="date"?!0:typeof a=="object"?a.constructor.toString().match(/date/i)!==null:!1},HTML:function(a){return typeof a=="object"?a.constructor.toString().match(/html/i)!==null:!1},Number:function(a){return typeof a=="number"?!0:typeof a=="object"?a.constructor.toString().match(/Number/)!==null:!1},Object:function(a){return typeof a=="object"?a.constructor.toString().match(/object/i)!==null:!1},RegExp:function(a){return typeof a=="function"?a.constructor.toString().match(/regexp/i)!==null:!1}},type={of:function(a){for(var b in is)if(is[b](a))return b.toLowerCase()}};if(typeof VMM!="undefined"){VMM.attachElement=function(a,b){typeof jQuery!="undefined"&&jQuery(a).html(b)};VMM.appendElement=function(a,b){ty
("TWITTER JSON ERROR TIMEOUT "+a);VMM.attachElement("#twitter_"+a,"<span class='messege'><p>Error loading tweet: "+a+"</p></span>");VMM.getJSON("http://api.twitter.com/1/account/rate_limit_status.json",function(b){trace("REMAINING TWITTER API CALLS "+b.remaining_hits);trace("TWITTER RATE LIMIT WILL RESET AT "+b.reset_time);var c="";if(b.remaining_hits==0){c="<p>You've reached the maximum number of tweets you can load in an hour.</p>";c+="<p>You can view tweets again starting at: <br/>"+b.reset_time+"</p>"}else c="<p>Tweet "+a+" was not found.</p>";VMM.attachElement("#twitter_"+a,"<span class='messege'>"+c+"</span>")})},formatJSON:function(a){var b=a.id_str,c="<blockquote><p>",d=VMM.Util.linkify_with_twitter(a.text,"_blank");c+=d;c+="</p></blockquote>";c+="<div class='vcard author'>";c+="<a class='screen-name url' href='https://twitter.com/"+a.user.screen_name+"' data-screen-name='"+a.user.screen_name+"' target='_blank'>";c+="<span class='avatar'><img src=' "+a.user.profile_image_url+"' alt=''></span>";c+="<span class='fn'>"+a.user.name+"</span>";c+="<span class='nickname'>@"+a.user.screen_name+"<span class='thumbnail-inline'></span></span>";c+="</a>";c+="</div>";typeof a.entities.media!="undefined"&&a.entities.media[0].type=="photo"&&(c+="<img src=' "+a.entities.media[0].media_url+"' alt=''>");VMM.attachElement("#twitter_"+b.toString(),c);VMM.attachElement("#text_thumb_"+b.toString(),a.text)}},googlemaps:{get:function(a,b){var c,d,e;e=VMM.Util.getUrlVars(a);VMM.master_config.Timeline.api_keys.google!=""?d=VMM.master_config.Timeline.api_keys.google:d=Aes.Ctr.decrypt(VMM.master_config.api_keys_master.google,VMM.master_config.vp,256);var f="http://maps.googleapis.com/maps/api/js?key="+d+"&libraries=places&sensor=false&callback=VMM.ExternalAPI.googlemaps.onMapAPIReady",g={url:a,vars:e,id:b};if(VMM.master_config.googlemaps.active)VMM.master_config.googlemaps.que.push(g);else{VMM.master_config.googlemaps.que.push(g);VMM.master_config.googlemaps.api_loaded||VMM.LoadLib.js(f,function(){trace("Google Maps API Library Loaded")})}},create:function(a){function e(a){if(a in VMM.ExternalAPI.googlemaps.map_providers){b=VMM.ExternalAPI.googlemaps.map_attribution[VMM.ExternalAPI.googlemaps.map_providers[a].attribution];return VMM.ExternalAPI.googlemaps.map_providers[a]}if(VMM.ExternalAPI.googlemaps.defaultType(a)){trace("GOOGLE MAP DEFAULT TYPE");return google.maps.MapTypeId[a.toUpperCase()]}trace("Not a maptype: "+a)}function o(){var b=a.url+"&output=kml";b=b.replace("&output=embed","");var c=new google.maps.KmlLayer(b,{preserveViewport:!0}),e=new google.maps.InfoWindow;c.setMap(d);google.maps.event.addListenerOnce(c,"defaultviewport_changed",function(){d.fitBounds(c.getDefaultViewport());i&&d.panTo(f);j&&d.setZoom(h)});google.maps.event.addListener(c,"click",function(a){function c(a){e.setContent(a);e.open(d)}var b=a.featureData.description;c(b)})}var b="",c,d;google.maps.VeriteMapType=function(a){if(VMM.ExternalAPI.googlemaps.defaultType(a))return google.maps.MapTypeId[a.toUpperCase()];var b=e(a);return google.maps.ImageMapType.call(this,{getTileUrl:function(a,c){var d=(c+a.x+a.y)%VMM.ExternalAPI.googlemaps.map_subdomains.length;return[b.url.replace("{S}",VMM.ExternalAPI.googlemaps.map_subdomains[d]).replace("{Z}",c).replace("{X}",a.x).replace("{Y}",a.y).replace("{z}",c).replace("{x}",a.x).replace("{y}",a.y)]},tileSize:new google.maps.Size(256,256),name:a,minZoom:b.minZoom,maxZoom:b.maxZoom})};google.maps.VeriteMapType.prototype=new google.maps.ImageMapType("_");type.of(VMM.master_config.Timeline.maptype)=="string"?VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)?c=google.maps.MapTypeId[VMM.master_config.Timeline.maptype.toUpperCase()]:c=VMM.master_config.Timeline.maptype:c="toner";var f=new google.maps.LatLng(41.875696,-87.624207),g,h=11,i=!1,j=!1,k;if(type.of(VMM.Util.getUrlVars(a.url)["ll"])=="string"){i=!0;g=VMM.Util.getUrlVars(a.url).ll.split(",");f=new google.maps.LatLng(parseFloat(g[0]),parseFloat(g[1]))}else if(type.of(VMM.Util.getUrlVars(a.url)["sll"])=="string"){g=VMM.Util.getUrlVars(a.url).sll.s
m;VMM.fireEvent(r,"UPDATE")}var c={},d,e,f,g,h,i=[],j=[],k=[],l="",m=0,n=960,o={move:!1,x:10,y:0,off:0,dampen:48},p="",q=!1,r=a,s={nextBtn:"",prevBtn:"",nextDate:"",prevDate:"",nextTitle:"",prevTitle:""},t;typeof VMM.Timeline!="undefined"?d=VMM.Timeline.Config:d={preload:4,current_slide:0,interval:10,something:0,width:720,height:400,ease:"easeInOutExpo",duration:1e3,timeline:!1,spacing:15,slider:{width:720,height:400,content:{width:720,height:400,padding:130},nav:{width:100,height:200}}};this.ver="0.6";d.slider.width=d.width;d.slider.height=d.height;this.init=function(a){j=[];k=[];typeof a!="undefined"?this.setData(a):trace("WAITING ON DATA")};this.width=function(a){if(a==null||a=="")return d.slider.width;d.slider.width=a;v()};this.height=function(a){if(a==null||a=="")return d.slider.height;d.slider.height=a;v()};this.setData=function(a){if(typeof a!="undefined"){i=a;L()}else trace("NO DATA")};this.getData=function(){return i};this.setConfig=function(a){typeof a!="undefined"?d=a:trace("NO CONFIG DATA")};this.getConfig=function(){return d};this.setSize=function(a,b){a!=null&&(d.slider.width=a);b!=null&&(d.slider.height=b);q&&v()};this.active=function(){return q};this.getCurrentNumber=function(){return m};this.setSlide=function(a){J(a)};var B=function(a){i=a},C=function(a){VMM.attachElement(h,"");j=[];for(var b=0;b<a.length;b++){var c=new VMM.Slider.Slide(a[b],h);j.push(c)}},D=function(a){if(a)E();else{for(var b=0;b<j.length;b++)j[b].clearTimers();t=setTimeout(E,d.duration)}},E=function(){for(var a=0;a<j.length;a++)j[a].enqueue=!0;for(var b=0;b<d.preload;b++){if(!(m+b>j.length-1)){j[m+b].show();j[m+b].enqueue=!1}if(!(m-b<0)){j[m-b].show();j[m-b].enqueue=!1}}if(j.length>50)for(var c=0;c<j.length;c++)j[c].enqueue&&j[c].hide();G()},F=function(a){},G=function(){var a=".slider-item .layout-text-media .media .media-container ",b=".slider-item .layout-media .media .media-container ",c=".slider-item .media .media-container",e={text_media:{width:d.slider.content.width/100*60,height:d.slider.height-60,video:{width:0,height:0},text:{width:d.slider.content.width/100*40-30,height:d.slider.height}},media:{width:d.slider.content.width,height:d.slider.height-110,video:{width:0,height:0}}};VMM.master_config.sizes.api.width=e.media.width;VMM.master_config.sizes.api.height=e.media.height;e.text_media.video=VMM.Util.ratio.fit(e.text_media.width,e.text_media.height,16,9);e.media.video=VMM.Util.ratio.fit(e.media.width,e.media.height,16,9);VMM.Lib.css(".slider-item","width",d.slider.content.width);VMM.Lib.height(".slider-item",d.slider.height);var f=!1;n<=640?f=!0:VMM.Browser.device=="mobile"&&VMM.Browser.orientation=="portrait"?f=!0:VMM.Browser.device!="tablet"||VMM.Browser.orientation!="portrait";if(f){e.text_media.width=d.slider.content.width;e.text_media.height=d.slider.height/100*50-50;e.media.height=d.slider.height/100*70-40;e.text_media.video=VMM.Util.ratio.fit(e.text_media.width,e.text_media.height,16,9);e.media.video=VMM.Util.ratio.fit(e.media.width,e.media.height,16,9);VMM.Lib.css(".slider-item .layout-text-media .text","width","100%");VMM.Lib.css(".slider-item .layout-text-media .text","display","block");VMM.Lib.css(".slider-item .layout-text-media .text .container","display","block");VMM.Lib.css(".slider-item .layout-text-media .text .container","width",d.slider.content.width);VMM.Lib.css(".slider-item .layout-text-media .media","float","none");VMM.Lib.addClass(".slider-item .content-container","pad-top");VMM.Lib.css(".slider-item .media blockquote p","line-height","18px");VMM.Lib.css(".slider-item .media blockquote p","font-size","16px");VMM.Lib.css(".slider-item","overflow-y","auto")}else{VMM.Lib.css(".slider-item .layout-text-media .text","width","40%");VMM.Lib.css(".slider-item .layout-text-media .text","display","table-cell");VMM.Lib.css(".slider-item .layout-text-media .text .container","display","table-cell");VMM.Lib.css(".slider-item .layout-text-media .text .container","width","auto");VMM.Lib.css(".slider-item .layout-text-media .text .container .start","width",e.text_media.text.width);VMM.Lib.removeClass(".slider-item .con
(b.startdate);b.asset=m.date[a].asset;b.fulldate=b.startdate.getTime();b.text=m.date[a].text;b.content="";b.tag=m.date[a].tag;b.slug=m.date[a].slug;b.uniqueid=VMM.Util.unique_ID(7);n.push(b)}}m.type!="storify"&&n.sort(function(a,b){return a.fulldate-b.fulldate});if(m.headline!=null&&m.headline!=""&&m.text!=null&&m.text!=""){trace("HAS STARTPAGE");var b={},c=0,d;d=n[0].startdate;b.startdate=new Date(n[0].startdate);d.getMonth()===0&&d.getDate()==1&&d.getHours()===0&&d.getMinutes()===0?b.startdate.setFullYear(d.getFullYear()-1):d.getDate()<=1&&d.getHours()===0&&d.getMinutes()===0?b.startdate.setMonth(d.getMonth()-1):d.getHours()===0&&d.getMinutes()===0?b.startdate.setDate(d.getDate()-1):d.getMinutes()===0?b.startdate.setHours(d.getHours()-1):b.startdate.setMinutes(d.getMinutes()-1);b.uniqueid=VMM.Util.unique_ID(7);b.enddate=b.startdate;b.title=m.headline;b.headline=m.headline;b.text=m.text;b.type="start";b.date=VMM.Date.prettyDate(m.startDate);b.asset=m.asset;b.slug=!1;b.needs_slug=!1;b.fulldate=b.startdate.getTime();o.embed&&VMM.fireEvent(global,o.events.headline,b.headline);n.unshift(b)}m.type!="storify"&&n.sort(function(a,b){return a.fulldate-b.fulldate});x()}};VMM.Timeline.Config={}}typeof VMM.Timeline!="undefined"&&typeof VMM.Timeline.TimeNav=="undefined"&&(VMM.Timeline.TimeNav=function(a,b,c){function N(){trace("onConfigSet")}function O(a){VMM.Lib.css(G,"left",Math.round(M.width/2)+2);VMM.Lib.css(H,"left",Math.round(M.width/2)-8);W(M.current_slide,M.ease,M.duration,!0,a)}function P(){VMM.fireEvent(f,"UPDATE")}function Q(){VMM.DragSlider.cancelSlide();if(M.nav.multiplier.current>M.nav.multiplier.min){M.nav.multiplier.current<=1?M.nav.multiplier.current=M.nav.multiplier.current-.25:M.nav.multiplier.current>5?M.nav.multiplier.current>16?M.nav.multiplier.current=Math.round(M.nav.multiplier.current-10):M.nav.multiplier.current=Math.round(M.nav.multiplier.current-4):M.nav.multiplier.current=Math.round(M.nav.multiplier.current-1);M.nav.multiplier.current<=0&&(M.nav.multiplier.current=M.nav.multiplier.min);T()}}function R(){VMM.DragSlider.cancelSlide();if(M.nav.multiplier.current<M.nav.multiplier.max){M.nav.multiplier.current>4?M.nav.multiplier.current>16?M.nav.multiplier.current=Math.round(M.nav.multiplier.current+10):M.nav.multiplier.current=Math.round(M.nav.multiplier.current+4):M.nav.multiplier.current=Math.round(M.nav.multiplier.current+1);M.nav.multiplier.current>=M.nav.multiplier.max&&(M.nav.multiplier.current=M.nav.multiplier.max);T()}}function S(a){VMM.DragSlider.cancelSlide();W(0);P()}function U(a){VMM.DragSlider.cancelSlide();W(a.data.number);P()}function V(a){VMM.Lib.toggleClass(a.data.elem,"zFront")}function X(a,b){VMM.Lib.animate(y,b.time/2,M.ease,{left:b.left})}trace("VMM.Timeline.TimeNav");var d={},e={},f=a,g={interval_position:""},h=[],i=[],j=[],k=[],l=[],m,n,o=[],p={left:"",visible:{left:"",right:""}},q=0,r=!1,s={day:24,month:12,year:10,hour:60,minute:60,second:1e3,decade:10,century:100,millenium:1e3,age:1e6,epoch:1e7,era:1e8,eon:5e8,week:4.34812141,days_in_month:30.4368499,days_in_week:7,weeks_in_month:4.34812141,weeks_in_year:52.177457,days_in_year:365.242199,hours_in_day:24},t={day:864e5,week:7,month:30.4166666667,year:12,hour:24,minute:1440,second:86400,decade:10,century:100,millenium:1e3,age:1e6,epoch:1e7,era:1e8,eon:5e8},u={type:"year",number:10,first:1970,last:2011,multiplier:100,classname:"_idd",interval_type:"interval"},v={type:"year",number:10,first:1970,last:2011,multiplier:100,classname:"major",interval_type:"interval major"},w={type:"year",number:10,first:1970,last:2011,multiplier:100,classname:"_dd_minor",interval_type:"interval minor"},x={day:{},month:{},year:{},hour:{},minute:{},second:{},decade:{},century:{},millenium:{},week:{},age:{},epoch:{},era:{},eon:{}},y,z,A,B,C,D,E,F,G,H,I,J,K,L,M=VMM.Timeline.Config;M.nav.rows=[1,M.nav.marker.height,M.nav.marker.height*2];b!=null&&b!=""&&(M.nav.width=b);c!=null&&c!=""&&(M.nav.height=c);this.init=function(a,b){trace("VMM.Timeline.TimeNav init");typeof a!="undefined"?this.setData(a,b):trace("WAITING ON DATA")};this.setData=function(a,b){if(typeof a!