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
106 KiB
32 lines
106 KiB
13 years ago
|
/*!
|
||
|
Timeline
|
||
|
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
|
||
13 years ago
|
* Verite JS Master
|
||
13 years ago
|
* Version: 0.6
|
||
|
* Date: April 26, 2012
|
||
13 years ago
|
* 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
|
||
13 years ago
|
* ----------------------------------------------------- *//* Simple JavaScript Inheritance
|
||
13 years ago
|
* By John Resig http://ejohn.org/
|
||
|
* MIT Licensed.
|
||
13 years ago
|
================================================== */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},vp:"Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo",api_keys_master:{flickr:"RAIvxHY4hE/Elm5cieh4X5ptMyDpj7MYIxziGxi0WGCcy1s+yr7rKQ==",google:"jwNGnYw4hE9lmAez4ll0QD+jo6SKBJFknkopLS4FrSAuGfIwyj57AusuR0s8dAo=",twitter:""},youtube:{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:[]},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+=" "+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){typeof jQuery!="undefined"&&jQuery(a).append(b)};VMM.getHTML=function(a){var b;if(typeof jQuery!="undefined"){b=jQuery(a).html();return b}};VMM.getElement=function(a,b){var c;if(typeof jQuery!="
|
||
|
a.url+"&format=js&callback=?";VMM.getJSON(b,function(b){VMM.attachElement("#"+a.id,b.html)})},pushQue:function(){for(var a=0;a<VMM.master_config.soundcloud.que.length;a++)VMM.ExternalAPI.soundcloud.create(VMM.master_config.soundcloud.que[a]);VMM.master_config.soundcloud.que=[]}},wikipedia:{get:function(a,b){trace("WIKIPEDIA GET");var c={url:a,id:b};VMM.master_config.wikipedia.que.push(c);VMM.master_config.wikipedia.active=!0},create:function(a){var b="http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles="+a.url+"&format=json&exintro=1&callback=?";VMM.getJSON(b,function(b){var c=VMM.Util.getObjectAttributeByIndex(b.query.pages,0).extract,d=VMM.Util.getObjectAttributeByIndex(b.query.pages,0).title,e="",f="",g=c.split("<p>"),h=2;for(var i=0;i<g.length;i++)i+1<=h&&i+1<g.length&&(f+="<p>"+g[i+1]);e="<h4>"+d+"</h4>";e+="<div class='wiki-source'>From Wikipedia, the free encyclopedia</span>";e+=VMM.Util.linkify_wikipedia(f);c.match("REDIRECT")||VMM.attachElement("#"+a.id,e)})},pushQue:function(){trace("WIKIPEDIA PUSH QUE");for(var a=0;a<VMM.master_config.wikipedia.que.length;a++)VMM.ExternalAPI.wikipedia.create(VMM.master_config.wikipedia.que[a]);VMM.master_config.wikipedia.que=[]}},youtube:{get:function(a){if(VMM.master_config.youtube.active)VMM.master_config.youtube.que.push(a);else{VMM.master_config.youtube.que.push(a);VMM.master_config.youtube.api_loaded||VMM.LoadLib.js("http://www.youtube.com/player_api",function(){trace("YouTube API Library Loaded")})}},create:function(a){var b={active:!1,player:{},name:"youtube_"+a,playing:!1};b.player["youtube_"+a]=new YT.Player("youtube_"+a,{height:"390",width:"640",playerVars:{enablejsapi:1,color:"white",showinfo:0,theme:"light",rel:0},videoId:a,events:{onReady:VMM.ExternalAPI.youtube.onPlayerReady,onStateChange:VMM.ExternalAPI.youtube.onStateChange}});VMM.master_config.youtube.array.push(b)},pushQue:function(){for(var a=0;a<VMM.master_config.youtube.que.length;a++)VMM.ExternalAPI.youtube.create(VMM.master_config.youtube.que[a]);VMM.master_config.youtube.que=[]},onAPIReady:function(){VMM.master_config.youtube.active=!0;VMM.ExternalAPI.youtube.pushQue()},stopPlayers:function(){for(var a=0;a<VMM.master_config.youtube.array.length;a++)if(VMM.master_config.youtube.array[a].playing){var b=VMM.master_config.youtube.array[a].name;VMM.master_config.youtube.array[a].player[b].stopVideo()}},onStateChange:function(a){for(var b=0;b<VMM.master_config.youtube.array.length;b++){var c=VMM.master_config.youtube.array[b].name;VMM.master_config.youtube.array[b].player[c]==a.target&&a.data==YT.PlayerState.PLAYING&&(VMM.master_config.youtube.array[b].playing=!0)}},onPlayerReady:function(a){}}});typeof VMM!="undefined"&&typeof VMM.TouchSlider=="undefined"&&(VMM.TouchSlider={createPanel:function(a,b,c,d,e,f){VMM.TouchSlider.vertical=!1;VMM.TouchSlider.vertical=e;var g=d;VMM.TouchSlider.width=c;VMM.TouchSlider.height=f;VMM.TouchSlider.makeTouchable(a,b)},removePanel:function(a){VMM.unbindEvent(a,VMM.TouchSlider.onTouchStart,"touchstart");VMM.unbindEvent(a,VMM.TouchSlider.onTouchMove,"touchmove");VMM.unbindEvent(a,VMM.TouchSlider.onTouchEnd,"touchend")},makeTouchable:function(a,b){VMM.bindEvent(a,VMM.TouchSlider.onTouchStart,"touchstart",{element:b});VMM.bindEvent(a,VMM.TouchSlider.onTouchMove,"touchmove",{element:b});VMM.bindEvent(a,VMM.TouchSlider.onTouchEnd,"touchend",{element:b})},onTouchStart:function(a){VMM.TouchSlider.touchStart(a.data.element,a);a.stopPropagation();return!0},onTouchEnd:function(a){a.stopPropagation();if(VMM.TouchSlider.sliding){VMM.TouchSlider.sliding=!1;VMM.TouchSlider.touchEnd(a.data.element,a);return!1}return!0},onTouchMove:function(a){VMM.TouchSlider.touchMove(a.data.element,a);a.preventDefault();a.stopPropagation();return!1},getLeft:function(a){return parseInt(VMM.Lib.css(a,"left").substring(0,VMM.Lib.css(a,"left").length-2),10)},getTop:function(a){return parseInt(VMM.Lib.css(a,"top").substring(0,VMM.Lib.css(a,"top").length-2),10)},touchStart:function(a,b){VMM.Lib.css(a,"-webkit-transition-duration","0");VMM.TouchSlider.startX=b.originalEvent.touches[0].screenX;VMM
|
||
13 years ago
|
,shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};dateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};Date.prototype.format=function(a,b){return dateFormat(this,a,b)}}window.loadedJS=[];typeof VMM!="undefined"&&typeof VMM.LoadLib=="undefined"&&(VMM.LoadLib=function(a){function i(a){var b=!1;for(var c=0;c<h.length;c++)h[c]==a&&(b=!0);b||h.push(a);return b}function j(b,c){var d=a.createElement(b),e;for(e in c)c.hasOwnProperty(e)&&d.setAttribute(e,c[e]);return d}function k(a){var b=d[a],c,g;if(b){c=b.callback;g=b.urls;g.shift();e=0;if(!g.length){c&&c.call(b.context,b.obj);d[a]=null;f[a].length&&m(a)}}}function l(){var c=navigator.userAgent;b={async:a.createElement("script").async===!0};(b.webkit=/AppleWebKit\//.test(c))||(b.ie=/MSIE/.test(c))||(b.opera=/Opera/.test(c))||(b.gecko=/Gecko\//.test(c))||(b.unknown=!0)}function m(e,g,h,i,m){var p=function(){k(e)},q=e==="css",r=[],s,t,u,v,w,x;b||l();if(g){g=typeof g=="string"?[g]:g.concat();if(q||b.async||b.gecko||b.opera)f[e].push({urls:g,callback:h,obj:i,context:m});else for(s=0,t=g.length;s<t;++s)f[e].push({urls:[g[s]],callback:s===t-1?h:null,obj:i,context:m})}if(d[e]||!(v=d[e]=f[e].shift()))return;c||(c=a.head||a.getElementsByTagName("head")[0]);w=v.urls;for(s=0,t=w.length;s<t;++s){x=w[s];if(q)u=b.gecko?j("style"):j("link",{href:x,rel:"stylesheet"});else{u=j("script",{src:x});u.async=!1}u.className="lazyload";u.setAttribute("charset","utf-8");if(b.ie&&!q)u.onreadystatechange=function(){if(/loaded|complete/.test(u.readyState)){u.onreadystatechange=null;p()}};else if(q&&(b.gecko||b.webkit))if(b.webkit){v.urls[s]=u.href;o()}else{u.innerHTML='@import "'+x+'";';n(u)}else u.onload=u.onerror=p;r.push(u)}for(s=0,t=r.length;s<t;++s)c.appendChild(r[s])}function n(a){var b;try{b=!!a.sheet.cssRules}catch(c){e+=1;e<200?setTimeout(function(){n(a)},50):b&&k("css");return}k("css")}function o(){var a=d.css,b;if(a){b=g.length;while(--b>=0)if(g[b].href===a.urls[0]){k("css");break}e+=1;a&&(e<200?setTimeout(o,50):k("css"))}}var b,c,d={},e=0,f={css:[],js:[]},g=a.styleSheets,h=[];return{css:function(a,b,c,d){if(i(a))return b;m("css",a,b,c,d)},js:function(a,b,c,d){if(i(a))return b;m("js",a,b,c,d)}}}(this.document));typeof VMM!="undefined"&&typeof VMM.Language=="undefined"&&(VMM.Language={date:{month:["January","February","March","April","May","June","July","August","September","October","November","December"],month_abbr:["Jan.","Feb.","March","April","May","June","July","Aug.","Sept.","Oct.","Nov.","Dec."],day:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],day_abbr:["Sun.","Mon.","Tues.","Wed.","Thurs.","Fri.","Sat."]},dateformats:{year:"yyyy",month_short:"mmm",month:"mmmm yyyy",full_short:"mmm d",full:"mmmm d',' yyyy",time_no_seconds_short:"h:MM TT",time_no_seconds_small_date:"h:MM TT'<br/><small>'mmmm d',' yyyy'</small>'",full_long:"mmm d',' yyyy 'at' hh:MM TT",full_long_small_date:"hh:MM TT'<br/><small>mmm d',' yyyy'</small>'"},messages:{loading_timeline:"Loading Timeline... ",return_to_title:"Return to Title",expand_timeline:"Expand Timeline",contract_timeline:"Contract Timeline"}});var Aes={};Aes.cipher=function(a,b){var c=4,d=b.length/c-1,e=[[],[],[],[]];for(var f=0;f<4*c;f++)e[f%4][Math.floor(f/4)]=a[f];e=Aes.addRoundKey(e,b,0,c);for(var g=1;g<d;g++){e=Aes.subBytes(e,c);e=Aes.shiftRows(e,c);e=Aes.mixColumns(e,c);e=Aes.addRoundKey(e,b,g,c)}e=Aes.subBytes(e,c);e=Aes.shiftRows(e,c);e=Aes.addRoundKey(e,b,d,c);var h=new Array(4*c);for(var f=0;f<4*c;f++)h[f]=e[f%4][Math.floor(f/4)];return h};Aes.keyExpansion=function(a){var b=4,c=a.length/4,d=c+6,e=new Array(b*(d+1)),f=new Array(4);for(var g=0;g<c;g++){var h=[a[4*g],a[4*g+1],a[4*g+2],a[4*g+3]];e[g]=h}for
|
||
|
);z=VMM.appendAndGetElement(x,"<div>","time-interval");B=VMM.appendAndGetElement(f,"<div>","timenav-background");D=VMM.appendAndGetElement(B,"<div>","timenav-line");C=VMM.appendAndGetElement(B,"<div>","timenav-interval-background","<div class='top-highlight'></div>");F=VMM.appendAndGetElement(f,"<div>","toolbar");cb();db();W();$();_(j,!1,!0);_(k);if(I.start_page){$backhome=VMM.appendAndGetElement(F,"<div>","back-home","<div class='icon'></div>");VMM.bindEvent(".back-home",O,"click");VMM.Lib.css(F,"top",27);VMM.Lib.attribute($backhome,"title",VMM.Timeline.Config.language.messages.return_to_title);VMM.Lib.attribute($backhome,"rel","tooltip")}G=VMM.appendAndGetElement(F,"<div>","zoom-in","<div class='icon'></div>");H=VMM.appendAndGetElement(F,"<div>","zoom-out","<div class='icon'></div>");VMM.Lib.attribute(G,"title",VMM.Timeline.Config.language.messages.expand_timeline);VMM.Lib.attribute(G,"rel","tooltip");VMM.Lib.attribute(H,"title",VMM.Timeline.Config.language.messages.contract_timeline);VMM.Lib.attribute(H,"rel","tooltip");F.tooltip({selector:"div[rel=tooltip]",placement:"right"});if(VMM.Browser.device=="mobile"||VMM.Browser.device=="tablet"){VMM.TouchSlider.createPanel(B,v,I.width,I.spacing,!1);VMM.bindEvent(v,T,"TOUCHUPDATE")}else VMM.DragSlider.createPanel(f,v,I.width,I.spacing,!1);VMM.bindEvent(".zoom-in",M,"click");VMM.bindEvent(".zoom-out",N,"click");VMM.fireEvent(f,"LOADED");o=!0;K(!0)},cb=function(){e=Y(g[g.length-1].enddate-g[0].startdate,!0);trace(e);X();if(e.centuries>g.length/I.nav.density){r=u.century;s=u.millenium;t=u.decade}else if(e.decades>g.length/I.nav.density){r=u.decade;s=u.century;t=u.year}else if(e.years>g.length/I.nav.density){r=u.year;s=u.decade;t=u.month}else if(e.months>g.length/I.nav.density){r=u.month;s=u.year;t=u.day}else if(e.days>g.length/I.nav.density){r=u.day;s=u.month;t=u.hour}else if(e.hours>g.length/I.nav.density){r=u.hour;s=u.day;t=u.minute}else if(e.minutes>g.length/I.nav.density){r=u.minute;s=u.hour;t=u.second}else if(e.seconds>g.length/I.nav.density){r=u.second;s=u.minute;t=u.second}else{trace("NO IDEA WHAT THE TYPE SHOULD BE");r=u.day;s=u.month;t=u.hour}trace("INTERVAL TYPE: "+r.type);trace("INTERVAL MAJOR TYPE: "+s.type);ab(r,j,z);ab(s,k,A)},db=function(){var a=2,b=0,c=0;i=[];h=[];for(var d=0;d<g.length;d++){var e,f,j,k,m,n;e=VMM.appendAndGetElement(w,"<div>","marker");f=VMM.appendAndGetElement(e,"<div>","flag");j=VMM.appendAndGetElement(f,"<div>","flag-content");k=VMM.appendAndGetElement(e,"<div>","dot");m=VMM.appendAndGetElement(e,"<div>","line");n=VMM.appendAndGetElement(m,"<div>","event-line");g[d].asset!=null&&g[d].asset!=""?VMM.appendElement(j,VMM.MediaElement.thumbnail(g[d].asset,24,24)):VMM.appendElement(j,"<div style='margin-right:7px;height:50px;width:2px;float:left;'></div>");VMM.appendElement(j,"<h3>"+VMM.Util.unlinkify(g[d].title)+"</h3><h4>"+g[d].date+"</h4>");VMM.Lib.attr(e,"id",g[d].uniqueid.toString());VMM.bindEvent(f,Q,"",{number:d});VMM.bindEvent(f,R,"mouseenter mouseleave",{number:d,elem:f});var o={marker:e,flag:f,lineevent:n,type:"marker"};if(g[d].type=="start"){trace("BUILD MARKER HAS START PAGE");I.start_page=!0;o.type="start"}i.push(o)}for(var p=0;p<l.length;p++){var q={content:VMM.appendAndGetElement(w,"<div>","era"),startdate:VMM.Util.parseDate(l[p].startDate),enddate:VMM.Util.parseDate(l[p].endDate),title:l[p].headline,uniqueid:VMM.Util.unique_ID(4),color:l[p].color};VMM.Lib.attr(q.content,"id",q.uniqueid);VMM.Lib.css(q.content,"background",q.color);VMM.appendElement(q.content,"<h3>"+VMM.Util.unlinkify(q.title)+"</h3>");h.push(q)}}});typeof VMM.Timeline!="undefined"&&typeof VMM.Timeline.DataObj=="undefined"&&(VMM.Timeline.DataObj={data_obj:{},model_array:[],getData:function(a){data=VMM.Timeline.DataObj.data_obj;if(type.of(a)=="object"){trace("DATA SOURCE: JSON OBJECT");VMM.Timeline.DataObj.parseJSON(a)}else if(type.of(a)=="string")if(a.match("%23")){trace("DATA SOURCE: TWITTER SEARCH");VMM.Timeline.DataObj.model_Tweets.getData("%23medill")}else if(a.match("spreadsheet")){VMM.fireEvent(global,"MESSEGE",VMM.Timeline.Config.language.messages.loading_time
|