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.

33 lines
129 KiB

/*!
13 years ago
TimelineJS
Version 1.65
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
***********************************************//* VéritéCo JS Master
Version: 0.6
Date: June 19, 2012
Copyright 2012 VéritéCo unless part of TimelineJS,
if part of TimelineJS then it inherits TimelineJS's license.
Designed and built by Zach Wise digitalartwork.net
================================================== *//* Simple JavaScript Inheritance
By John Resig http://ejohn.org/
MIT Licensed.
================================================== */function trace(e){VMM.debug&&(window.console?console.log(e):typeof jsTrace!="undefined"&&jsTrace.send(e))}function onYouTubePlayerAPIReady(){trace("GLOBAL YOUTUBE API CALLED");VMM.ExternalAPI.youtube.onAPIReady()}(function(){var e=!1,t=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(n){function o(){!e&&this.init&&this.init.apply(this,arguments)}var r=this.prototype;e=!0;var i=new this;e=!1;for(var s in n)i[s]=typeof n[s]=="function"&&typeof r[s]=="function"&&t.test(n[s])?function(e,t){return function(){var n=this._super;this._super=r[e];var i=t.apply(this,arguments);this._super=n;return i}}(s,n[s]):n[s];o.prototype=i;o.prototype.constructor=o;o.extend=arguments.callee;return o}})();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:""},timers:{api:7e3},api:{pushques:[]},twitter:{active:!1,array:[],api_loaded:!1,que:[]},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:[],tries:0},soundcloud:{active:!1,array:[],api_loaded:!1,que:[]}}.init();VMM.createElement=function(e,t,n,r,i){var s="";if(e!=null&&e!=""){s+="<"+e;n!=null&&n!=""&&(s+=" class='"+n+"'");r!=null&&r!=""&&(s+=" "+r);i!=null&&i!=""&&(s+=" style='"+i+"'");s+=">";t!=null&&t!=""&&(s+=t);s=s+"</"+e+">"}return s};VMM.createMediaElement=function(e,t,n){var r="",i=!1;r+="<div class='media'>";if(e!=null&&e!=""){valid=!0;r+="<img src='"+e+"'>";n!=null&&n!=""&&(r+=VMM.createElement("div",n,"credit"));t!=null&&t!=""&&(r+=VMM.createElement("div",t,"caption"))}r+="</div>";return r};VMM.hideUrlBar=function(){var e=window,t=e.document;if(!location.hash||!e.addEventListener){window.scrollTo(0,1);var n=1,r=setInterval(function(){if(t.body){clearInterval(r);n="scrollTop"in t.body?t.body.scrollTop:1;e.scrollTo(0,n===1?0:1)}},15);e.addEventListener("load",function(){setTimeout(function(){e.scrollTo(0,n===1?0:1)},0)},!1)}}}Array.prototype.remove=function(e,t){var n=this.slice((t||e)+1||this.length);this.length=e<0?this.length+e:e;return this.push.apply(this,n)};Date.prototype.getWeek=function(){var e=new Date(this.getFullYear(),0,1);return Math.ceil(((this-e)/864e5+e.getDay()+1)/7)};Date.prototype.getDayOfYear=function(){var e=new Date(this.getFullYear(),0,1);return Math.ceil((this-e)/864e5)};var is={Null:function(e){return e===null},Undefined:function(e){return e===undefined},nt:function(e){return e===null||e===undefined},Function:function(e){return typeof e=="function"?e.constructor.toString().match(/Function/)!==null:!1},String:function(e){return typeof e=="string"?!0:typeof e=="object"?e.constructor.toString().match(/string/i)!==null:!1},Array:function(e){return typeof e=="object"?e.constructor.toString().match(/array/i)!==null||e.length!==undefined:!1},Boolean:function(e){return typeof e=="boolean"?!0:typeof e=="object"?e.constructor.toString().match(/boolean/i)!==null:!1},Date:function(e){return typeof e=="date"?!0:typeof e=="object"?e.constructor.toString().match(/date/i)!==null:!1},HTML:function(e){return typeof e=="object"?e.constructor.toString().match(/html/i)!==null:!1},Number:function(e){return typeof e=="number"?!0:typeof e=="object"?e.constructor.toString().match(/Number/)!==null:!1},Object:function(e){return typeof e=="object"?e.constructor.toString().match(/object/i)!==null:!1},RegExp:function(e){return typeof e=="function"?e.constructor.toString().match(/reg
;if(t.remaining_hits==0){n="<p>You've reached the maximum number of tweets you can load in an hour.</p>";n+="<p>You can view tweets again starting at: <br/>"+t.reset_time+"</p>"}else n="<p>Still waiting on Twitter. "+e.mid+"</p>";VMM.attachElement("#"+e.id.toString(),VMM.MediaElement.loadingmessage(n))})},pushQue:function(){if(VMM.master_config.twitter.que.length>0){VMM.ExternalAPI.twitter.create(VMM.master_config.twitter.que[0],VMM.ExternalAPI.twitter.pushQue);VMM.master_config.twitter.que.remove(0)}},getHTML:function(e){var t="http://api.twitter.com/1/statuses/oembed.json?id="+e+"&callback=?";VMM.getJSON(t,VMM.ExternalAPI.twitter.onJSONLoaded)},onJSONLoaded:function(e){trace("TWITTER JSON LOADED");var t=e.id;VMM.attachElement("#"+t,VMM.Util.linkify_with_twitter(e.html))},parseTwitterDate:function(e){var t=new Date(Date.parse(e));return t},prettyParseTwitterDate:function(e){var t=new Date(Date.parse(e));return VMM.Date.prettyDate(t,!0)},getTweets:function(e){var t=[],n=e.length;for(var r=0;r<e.length;r++){var i="";e[r].tweet.match("status/")?i=e[r].tweet.split("status/")[1]:e[r].tweet.match("statuses/")?i=e[r].tweet.split("statuses/")[1]:i="";var s="http://api.twitter.com/1/statuses/show.json?id="+i+"&include_entities=true&callback=?";VMM.getJSON(s,function(e){var r={},i="<div class='twitter'><blockquote><p>",s=VMM.Util.linkify_with_twitter(e.text,"_blank");i+=s;i+="</p>";i+="— "+e.user.name+" (<a href='https://twitter.com/"+e.user.screen_name+"'>@"+e.user.screen_name+"</a>) <a href='https://twitter.com/"+e.user.screen_name+"/status/"+e.id+"'>"+VMM.ExternalAPI.twitter.prettyParseTwitterDate(e.created_at)+" </a></blockquote></div>";r.content=i;r.raw=e;t.push(r);if(t.length==n){var o={tweetdata:t};VMM.fireEvent(global,"TWEETSLOADED",o)}}).success(function(){trace("second success")}).error(function(){trace("error")}).complete(function(){trace("complete")})}},getTweetSearch:function(e,t){var n=40;t!=null&&t!=""&&(n=t);var r="http://search.twitter.com/search.json?q="+e+"&rpp="+n+"&include_entities=true&result_type=mixed",i=[];VMM.getJSON(r,function(e){for(var t=0;t<e.results.length;t++){var n={},r="<div class='twitter'><blockquote><p>",s=VMM.Util.linkify_with_twitter(e.results[t].text,"_blank");r+=s;r+="</p>";r+="— "+e.results[t].from_user_name+" (<a href='https://twitter.com/"+e.results[t].from_user+"'>@"+e.results[t].from_user+"</a>) <a href='https://twitter.com/"+e.results[t].from_user+"/status/"+e.id+"'>"+VMM.ExternalAPI.twitter.prettyParseTwitterDate(e.results[t].created_at)+" </a></blockquote></div>";n.content=r;n.raw=e.results[t];i.push(n)}var o={tweetdata:i};VMM.fireEvent(global,"TWEETSLOADED",o)})},prettyHTML:function(e,t){var e=e.toString(),n={twitterid:e},r="http://api.twitter.com/1/statuses/show.json?id="+e+"&include_entities=true&callback=?",i=setTimeout(VMM.ExternalAPI.twitter.errorTimeOut,VMM.master_config.timers.api,e);VMM.getJSON(r,VMM.ExternalAPI.twitter.formatJSON).error(function(t,n,r){trace("TWITTER error");trace("TWITTER ERROR: "+n+" "+t.responseText);VMM.attachElement("#twitter_"+e,"<p>ERROR LOADING TWEET "+e+"</p>")}).success(function(e){clearTimeout(i);t&&VMM.ExternalAPI.twitter.secondaryMedia(e)})},formatJSON:function(e){var t=e.id_str,n="<blockquote><p>",r=VMM.Util.linkify_with_twitter(e.text,"_blank");n+=r;n+="</p></blockquote>";n+="<div class='vcard author'>";n+="<a class='screen-name url' href='https://twitter.com/"+e.user.screen_name+"' data-screen-name='"+e.user.screen_name+"' target='_blank'>";n+="<span class='avatar'><img src=' "+e.user.profile_image_url+"' alt=''></span>";n+="<span class='fn'>"+e.user.name+"</span>";n+="<span class='nickname'>@"+e.user.screen_name+"<span class='thumbnail-inline'></span></span>";n+="</a>";n+="</div>";typeof e.entities.media!="undefined"&&e.entities.media[0].type=="photo"&&(n+="<img src=' "+e.entities.media[0].media_url+"' alt=''>");VMM.attachElement("#twitter_"+t.toString(),n);VMM.attachElement("#text_thumb_"+t.toString(),e.text)}},googlemaps:{get:function(e,t){var n,r,i;i=VMM.Util.getUrlVars(e);VMM.master_config.Timeline.api_keys.google!=""?r=VMM.mas
.time=5e3)}VMM.fireEvent(t,"DRAGUPDATE",[r]);r.time>0&&(e.touch?VMM.Lib.animate(t,r.time,"easeOutCirc",{left:r.left}):VMM.Lib.animate(t,r.time,e.ease,{left:r.left}))},p=function(e){return parseInt(VMM.Lib.css(e,"left").substring(0,VMM.Lib.css(e,"left").length-2),10)}});typeof VMM!="undefined"&&typeof VMM.Slider=="undefined"&&(VMM.Slider=function(e,t){function w(){trace("onConfigSet")}function E(e,t){var n=!0,i=!1;e!=null&&(n=e);t!=null&&(i=t);p=r.slider.width;r.slider.nav.height=VMM.Lib.height(y.prevBtnContainer);r.slider.content.width=p-r.slider.content.padding*2;VMM.Lib.width(u,f.length*r.slider.content.width);if(i){var a=f[h].leftpos();VMM.Lib.css(o,"left",a)}_();D();VMM.Lib.css(y.nextBtn,"left",p-r.slider.nav.width);VMM.Lib.height(y.prevBtn,r.slider.height);VMM.Lib.height(y.nextBtn,r.slider.height);VMM.Lib.css(y.nextBtnContainer,"top",r.slider.height/2-r.slider.nav.height/2+10);VMM.Lib.css(y.prevBtnContainer,"top",r.slider.height/2-r.slider.nav.height/2+10);VMM.Lib.height(s,r.slider.height);VMM.Lib.width(s,p);n&&H(h,"linear",1);h==0&&VMM.Lib.visible(y.prevBtn,!1)}function S(e){if(h==f.length-1)VMM.Lib.animate(o,r.duration,r.ease,{left:-f[h].leftpos()});else{H(h+1);C()}}function x(e){if(h==0)H(h);else{H(h-1);C()}}function T(e){switch(e.keyCode){case 39:S(e);break;case 37:x(e)}}function N(e,t){if(l.length==0)for(var n=0;n<f.length;n++)l.push(f[n].leftpos());if(typeof t.left=="number"){var i=t.left,s=-f[h].leftpos();i<s-r.slider_width/3?S():i>s+r.slider_width/3?x():VMM.Lib.animate(o,r.duration,r.ease,{left:s})}else VMM.Lib.animate(o,r.duration,r.ease,{left:s});typeof t.top=="number"&&VMM.Lib.animate(o,r.duration,r.ease,{top:-t.top})}function C(){r.current_slide=h;VMM.fireEvent(g,"UPDATE")}var n={},r,i,s,o,u,a=[],f=[],l=[],c="",h=0,p=960,d={move:!1,x:10,y:0,off:0,dampen:48},v="",m=!1,g=e,y={nextBtn:"",prevBtn:"",nextDate:"",prevDate:"",nextTitle:"",prevTitle:""},b;typeof VMM.Timeline!="undefined"?r=VMM.Timeline.Config:r={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";r.slider.width=r.width;r.slider.height=r.height;this.init=function(e){f=[];l=[];typeof e!="undefined"?this.setData(e):trace("WAITING ON DATA")};this.width=function(e){if(e==null||e=="")return r.slider.width;r.slider.width=e;E()};this.height=function(e){if(e==null||e=="")return r.slider.height;r.slider.height=e;E()};this.setData=function(e){if(typeof e!="undefined"){a=e;j()}else trace("NO DATA")};this.getData=function(){return a};this.setConfig=function(e){typeof e!="undefined"?r=e:trace("NO CONFIG DATA")};this.getConfig=function(){return r};this.setSize=function(e,t){e!=null&&(r.slider.width=e);t!=null&&(r.slider.height=t);m&&E()};this.active=function(){return m};this.getCurrentNumber=function(){return h};this.setSlide=function(e){H(e)};var k=function(e){a=e},L=function(e){VMM.attachElement(u,"");f=[];for(var t=0;t<e.length;t++){var n=new VMM.Slider.Slide(e[t],u);f.push(n)}},A=function(e){if(e)O();else{for(var t=0;t<f.length;t++)f[t].clearTimers();b=setTimeout(O,r.duration)}},O=function(){for(var e=0;e<f.length;e++)f[e].enqueue=!0;for(var t=0;t<r.preload;t++){if(!(h+t>f.length-1)){f[h+t].show();f[h+t].enqueue=!1}if(!(h-t<0)){f[h-t].show();f[h-t].enqueue=!1}}if(f.length>50)for(var n=0;n<f.length;n++)f[n].enqueue&&f[n].hide();_()},M=function(e){},_=function(){var e=".slider-item .layout-text-media .media .media-container ",t=".slider-item .layout-media .media .media-container ",n=".slider-item .media .media-container",i=".slider-item .media .media-container .media-shadow .caption",s={text_media:{width:r.slider.content.width/100*60,height:r.slider.height-60,video:{width:0,height:0},text:{width:r.slider.content.width/100*40-30,height:r.slider.height}},media:{width:r.slider.content.width,height:r.slider.height-110,video:{width:0,height:0}}};VMM.master_config.sizes.api.width=s.media.width;VMM.master_config.sizes.api.height=s.media.height;s.text_media.video=VMM.Util.rati
Timeline.TimeNav=="undefined"&&(VMM.Timeline.TimeNav=function(e,t,n){function R(){trace("onConfigSet")}function U(e){I.nav.constraint.left=I.width/2;I.nav.constraint.right=I.nav.constraint.right_min-I.width/2;_.updateConstraint(I.nav.constraint);VMM.Lib.css(C,"left",Math.round(I.width/2)+2);VMM.Lib.css(k,"left",Math.round(I.width/2)-8);G(I.current_slide,I.ease,I.duration,!0,e)}function z(){VMM.fireEvent(s,"UPDATE")}function W(){_.cancelSlide();if(I.nav.multiplier.current>I.nav.multiplier.min){I.nav.multiplier.current<=1?I.nav.multiplier.current=I.nav.multiplier.current-.25:I.nav.multiplier.current>5?I.nav.multiplier.current>16?I.nav.multiplier.current=Math.round(I.nav.multiplier.current-10):I.nav.multiplier.current=Math.round(I.nav.multiplier.current-4):I.nav.multiplier.current=Math.round(I.nav.multiplier.current-1);I.nav.multiplier.current<=0&&(I.nav.multiplier.current=I.nav.multiplier.min);J()}}function X(){_.cancelSlide();if(I.nav.multiplier.current<I.nav.multiplier.max){I.nav.multiplier.current>4?I.nav.multiplier.current>16?I.nav.multiplier.current=Math.round(I.nav.multiplier.current+10):I.nav.multiplier.current=Math.round(I.nav.multiplier.current+4):I.nav.multiplier.current=Math.round(I.nav.multiplier.current+1);I.nav.multiplier.current>=I.nav.multiplier.max&&(I.nav.multiplier.current=I.nav.multiplier.max);J()}}function V(e){_.cancelSlide();G(0);z()}function $(e){var t=0,n=0;e||(e=window.event);e.originalEvent&&(e=e.originalEvent);e.wheelDelta?t=e.wheelDelta/6:e.detail&&(t=-e.detail*12);if(t){e.preventDefault&&e.preventDefault();e.returnValue=!1}if(typeof e.wheelDeltaX!="undefined"){t=e.wheelDeltaY/6;Math.abs(e.wheelDeltaX)>Math.abs(e.wheelDeltaY)?t=e.wheelDeltaX/6:t=e.wheelDeltaY/6}n=VMM.Lib.position(y).left+t;n>I.nav.constraint.left?n=I.width/2:n<I.nav.constraint.right&&(n=I.nav.constraint.right);VMM.Lib.stop(y);VMM.Lib.css(y,"left",n)}function K(e){_.cancelSlide();G(e.data.number);z()}function Q(e){VMM.Lib.toggleClass(e.data.elem,"zFront")}function Y(e,t){VMM.Lib.animate(y,t.time/2,I.ease,{left:t.left})}trace("VMM.Timeline.TimeNav");var r={},i={},s=e,o=[],u=[],a=[],f=[],l=[],c=[],h=0,p=!1,d,v,m={interval_position:""},g={left:"",visible:{left:"",right:""}},y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D={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},P={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},H={type:"year",number:10,first:1970,last:2011,multiplier:100,classname:"_idd",interval_type:"interval"},B={type:"year",number:10,first:1970,last:2011,multiplier:100,classname:"major",interval_type:"interval major"},j={type:"year",number:10,first:1970,last:2011,multiplier:100,classname:"_dd_minor",interval_type:"interval minor"},F={day:{},month:{},year:{},hour:{},minute:{},second:{},decade:{},century:{},millenium:{},week:{},age:{},epoch:{},era:{},eon:{}},I=VMM.Timeline.Config,q=I.nav.marker.height/2;I.nav.rows={full:[1,q*2,q*4],half:[1,q,q*2,q*3,q*4,q*5],current:[]};t!=null&&t!=""&&(I.nav.width=t);n!=null&&n!=""&&(I.nav.height=n);this.init=function(e,t){trace("VMM.Timeline.TimeNav init");typeof e!="undefined"?this.setData(e,t):trace("WAITING ON DATA")};this.setData=function(e,t){if(typeof e!="undefined"){o={};o=e;d=t;lt()}else trace("NO DATA")};this.setSize=function(e,t){e!=null&&(I.width=e);t!=null&&(I.height=t);p&&U()};this.setMarker=function(e,t,n,r){G(e,t,n)};this.getCurrentNumber=function(){return h};var J=function(){trace("config.nav.multiplier "+I.nav.multiplier.current);ot(!0);ut(!0);at(S,f,!0,!0);at(x,l,!0);I.nav.constraint.left=I.width/2;I.nav.constraint.right=I.nav.constraint.right_min-I.width/2;_.updateConstraint(I.nav.constraint)},G=function(e,t,n,r,i){var s=I.ease,o=I.duration,u=!1,f=!1;h=e;g.left=I.width/2-VMM.Lib.position(a[h].marker).left;g.visible.left=Math.abs(g.left)-100;g.visible.right=Math.abs(
t.tweetdata[r].raw.from_user+"</a>)":i.headline=t.tweetdata[r].raw.user.name+" (<a href='https://twitter.com/"+t.tweetdata[r].raw.user.screen_name+"'>"+"@"+t.tweetdata[r].raw.user.screen_name+"</a>)";i.asset.media=t.tweetdata[r].content;n.timeline.date.push(i)}VMM.fireEvent(global,VMM.Timeline.Config.events.data_ready,n)}}},data_template_obj:{timeline:{headline:"",description:"",asset:{media:"",credit:"",caption:""},date:[],era:[]}},date_obj:{startDate:"2012,2,2,11,30",headline:"",text:"",asset:{media:"http://youtu.be/vjVfu8-Wp6s",credit:"",caption:""},tags:"Optional"}});VMM.debug=!1;