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.

14 lines
102 KiB

/* 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},vp:"Pellentesque nibh felis, eleifend id, commodo in, interdum vitae, leo",keys:{flickr:"RAIvxHY4hE/Elm5cieh4X5ptMyDpj7MYIxziGxi0WGCcy1s+yr7rKQ==",google:"jwNGnYw4hE9lmAez4ll0QD+jo6SKBJFknkopLS4FrSAuGfIwyj57AusuR0s8dAo="},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:[]},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()}};!function(a){"use strict";var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b;this.$element=a(c);this.options=this.getOptions(d);this.enabled=!0;if(this.options.trigger!="manual"){e=this.options.trigger=="hover"?"mouseenter":"focus";f=this.options.trigger=="hover"?"mouseleave":"blur";this.$element.on(e,this.options.selector,a.proxy(this.enter,
);trace(a);var b=a.id_str,c="<blockquote><p>",d=VMM.Util.linkify_with_twitter(a.text,"_blank");c+=d;c+="</p></blockquote>";c+=" <a href='https://twitter.com/"+a.user.screen_name+"/status/"+a.id+"' target='_blank' alt='link to original tweet' title='link to original tweet'>"+"<span class='created-at'></span>"+" </a>";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>";c+="</a>";c+="</div>";VMM.attachElement("#twitter_"+b.toString(),c)}},googlemaps:{get:function(a,b){var c,d=VMM.Util.getUrlVars(a);trace(d);var e="http://maps.googleapis.com/maps/api/js?key="+Aes.Ctr.decrypt(VMM.master_config.keys.google,VMM.master_config.vp,256)+"&libraries=places&sensor=false&callback=VMM.ExternalAPI.googlemaps.onMapAPIReady",f={url:a,vars:d,id:b};trace(f);if(VMM.master_config.googlemaps.active)VMM.master_config.googlemaps.que.push(f);else{VMM.master_config.googlemaps.que.push(f);VMM.master_config.googlemaps.api_loaded||VMM.LoadLib.js(e,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.split(",");f=new google.maps.LatLng(parseFloat(g[0]),parseFloat(g[1]))}if(type.of(VMM.Util.getUrlVars(a.url)["z"])=="string"){j=!0;h=parseFloat(VMM.Util.getUrlVars(a.url).z)}var l={zoom:h,disableDefaultUI:!0,mapTypeControl:!1,zoomControl:!0,zoomControlOptions:{style:google.maps.ZoomControlStyle.SMALL,position:google.maps.ControlPosition.TOP_RIGHT},center:f,mapTypeId:c,mapTypeControlOptions:{mapTypeIds:[c]}},m=a.id.toString()+"_gmap";VMM.attachElement("#"+a.id,"<div class='google-map' id='"+m+"' style='width=100%;height=100%;'></div>");var d=new google.maps.Map(document.getElementById(m),l);if(!VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)){d.mapTypes.set(c,new google.maps.VeriteMapType(c));var n="<div class='map-attribution'><
,f='$1$4$7$10$13<a href="$2$5$8$11$14" class="hyphenate">$2$5$8$11$14</a>$3$6$9$12',g=/(^|[^\/])(www\.[\S]+(\b|$))/gim,i=/(([a-zA-Z0-9_\-\.]+)@[a-zA-Z_]+?(?:\.[a-zA-Z]{2,6}))+/gim,j=/(@([\w]+))/g,k=/(#([\w]+))/g;return a.replace(e,f).replace(g,"$1<a target='_blank' class='hyphenate' onclick='void(0)' href='http://$2'>$2</a>").replace(i,"<a target='_blank' onclick='void(0)' href='mailto:$1'>$1</a>").replace(j,"<a href='http://twitter.com/$2' target='_blank' onclick='void(0)'>$1</a>").replace(k,"<a href='http://twitter.com/#search?q=%23$2' target='_blank' 'void(0)'>$1</a>")},unlinkify:function(a){if(!a)return a;a=a.replace(/<a\b[^>]*>/i,"");a=a.replace(/<\/a>/i,"");return a},nl2br:function(a){return a.replace(/(\r\n|[\r\n]|\\n|\\r)/g,"<br/>")},unique_ID:function(a){var b=function(a){return Math.floor(Math.random()*a)},c=function(){var a="abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ";return a.substr(b(62),1)},d=function(a){var b="";for(var d=0;d<a;d++)b+=c();return b};return d(a)},isEven:function(a){return a%2===0?!0:!1},getUrlVars:function(a){var b=a.toString();b.match("&#038;")?b=b.replace("&#038;","&"):b.match("&#38;")?b=b.replace("&#38;","&"):b.match("&amp;")&&(b=b.replace("&amp;","&"));var c=[],d,e=b.slice(b.indexOf("?")+1).split("&");for(var f=0;f<e.length;f++){d=e[f].split("=");c.push(d[0]);c[d[0]]=d[1]}return c},toHTML:function(a){a=this.nl2br(a);a=this.linkify(a);return a.replace(/\s\s/g,"&nbsp;&nbsp;")},toCamelCase:function(a,b){b!==!1&&(b=!0);var c=(b?a.toLowerCase():a).split(" ");for(var d=0;d<c.length;d++)c[d]=c[d].substr(0,1).toUpperCase()+c[d].substr(1);return c.join(" ")},properQuotes:function(a){return a.replace(/\"([^\"]*)\"/gi,"&#8220;$1&#8221;")},niceNumber:function(a){var b=String(Math.abs(Number(a))),c=b.split(/\./g)[0],d=b.split(/\./g)[1],e="",f=c.toArray();f.reverse();for(var g=1;g<=f.length;g++)g%3==0&&g<f.length?e=","+f[g-1]+e:e=f[g-1]+e;return d!=null&&d!=""&&d!=undefined?e+"."+d:e},toTitleCase:function(a){var b={__smallWords:["a","an","and","as","at","but","by","en","for","if","in","of","on","or","the","to","v[.]?","via","vs[.]?"],init:function(){this.__smallRE=this.__smallWords.join("|");this.__lowerCaseWordsRE=new RegExp("\\b("+this.__smallRE+")\\b","gi");this.__firstWordRE=new RegExp("^([^a-zA-Z0-9 \\r\\n\\t]*)("+this.__smallRE+")\\b","gi");this.__lastWordRE=new RegExp("\\b("+this.__smallRE+")([^a-zA-Z0-9 \\r\\n\\t]*)$","gi")},toTitleCase:function(a){var b="",c=a.split(/([:.;?!][ ]|(?:[ ]|^)["“])/);for(var d=0;d<c.length;++d){var e=c[d];e=e.replace(/\b([a-zA-Z][a-z.'’]*)\b/g,this.__titleCaseDottedWordReplacer);e=e.replace(this.__lowerCaseWordsRE,this.__lowerReplacer);e=e.replace(this.__firstWordRE,this.__firstToUpperCase);e=e.replace(this.__lastWordRE,this.__firstToUpperCase);b+=e}b=b.replace(/ V(s?)\. /g," v$1. ");b=b.replace(/(['’])S\b/g,"$1s");b=b.replace(/\b(AT&T|Q&A)\b/ig,this.__upperReplacer);return b},__titleCaseDottedWordReplacer:function(a){return a.match(/[a-zA-Z][.][a-zA-Z]/)?a:b.__firstToUpperCase(a)},__lowerReplacer:function(a){return a.toLowerCase()},__upperReplacer:function(a){return a.toUpperCase()},__firstToUpperCase:function(a){var b=a.split(/(^[^a-zA-Z0-9]*[a-zA-Z0-9])(.*)$/);b[1]=b[1].toUpperCase();return b.join("")}};b.init();a=a.replace(/_/g," ");a=b.toTitleCase(a);return a}}.init();String.linkify||(String.prototype.linkify=function(){var a=/\b(?:https?|ftp):\/\/[a-z0-9-+&@#\/%?=~_|!:,.;]*[a-z0-9-+&@#\/%=~_|]/gim,b=/(^|[^\/])(www\.[\S]+(\b|$))/gim,c=/(([a-zA-Z0-9_\-\.]+)@[a-zA-Z_]+?(?:\.[a-zA-Z]{2,6}))+/gim,d=/(@([\w]+))/g,e=/(#([\w]+))/g;return this.replace(a,'<a target="_blank" href="$&">$&</a>').replace(b,'$1<a target="_blank" href="http://$2">$2</a>').replace(c,'<a target="_blank" href="mailto:$1">$1</a>').replace(d,"<a href='http://twitter.com/$2' target='_blank'>$1</a>").replace(e,"<a href='http://twitter.com/#search?q=%23$2' target='_blank'>$1</a>")});var dateFormat=function(){var a=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,b=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Ti
);trace("WARNING: THIS IS STILL ALPHA AND WILL NOT WORK WITH ID's other than #timeline");var b=VMM.Timeline.DataObj.data_template_obj;if(VMM.Lib.find("#timeline section","time")[0]){b.timeline.startDate=VMM.Lib.html(VMM.Lib.find("#timeline section","time")[0]);b.timeline.headline=VMM.Lib.html(VMM.Lib.find("#timeline section","h2"));b.timeline.text=VMM.Lib.html(VMM.Lib.find("#timeline section","article"));var c=!1;if(VMM.Lib.find("#timeline section","figure img").length!=0){c=!0;b.timeline.asset.media=VMM.Lib.attr(VMM.Lib.find("#timeline section","figure img"),"src")}else if(VMM.Lib.find("#timeline section","figure a").length!=0){c=!0;b.timeline.asset.media=VMM.Lib.attr(VMM.Lib.find("#timeline section","figure a"),"href")}if(c){VMM.Lib.find("#timeline section","cite").length!=0&&(b.timeline.asset.credit=VMM.Lib.html(VMM.Lib.find("#timeline section","cite")));VMM.Lib.find(this,"figcaption").length!=0&&(b.timeline.asset.caption=VMM.Lib.html(VMM.Lib.find("#timeline section","figcaption")))}}VMM.Lib.each("#timeline li",function(a,c){var d=!1,e={type:"default",startDate:"",headline:"",text:"",asset:{media:"",credit:"",caption:""},tags:"Optional"};if(VMM.Lib.find(this,"time")!=0){d=!0;e.startDate=VMM.Lib.html(VMM.Lib.find(this,"time")[0]);VMM.Lib.find(this,"time")[1]&&(e.endDate=VMM.Lib.html(VMM.Lib.find(this,"time")[0]));e.headline=VMM.Lib.html(VMM.Lib.find(this,"h3"));e.text=VMM.Lib.html(VMM.Lib.find(this,"article"));var f=!1;if(VMM.Lib.find(this,"figure img").length!=0){f=!0;e.asset.media=VMM.Lib.attr(VMM.Lib.find(this,"figure img"),"src")}else if(VMM.Lib.find(this,"figure a").length!=0){f=!0;e.asset.media=VMM.Lib.attr(VMM.Lib.find(this,"figure a"),"href")}if(f){VMM.Lib.find(this,"cite").length!=0&&(e.asset.credit=VMM.Lib.html(VMM.Lib.find(this,"cite")));VMM.Lib.find(this,"figcaption").length!=0&&(e.asset.caption=VMM.Lib.html(VMM.Lib.find(this,"figcaption")))}trace(e);b.timeline.date.push(e)}});VMM.fireEvent(global,"DATAREADY",b)},parseJSON:function(a){if(a.timeline.type=="default"){trace("DATA SOURCE: JSON STANDARD TIMELINE");VMM.fireEvent(global,"DATAREADY",a)}else if(a.timeline.type=="twitter"){trace("DATA SOURCE: JSON TWEETS");VMM.Timeline.DataObj.model_Tweets.buildData(a)}else{trace("DATA SOURCE: UNKNOWN JSON");trace(type.of(a.timeline))}},model_Tweets:{type:"twitter",buildData:function(a){VMM.bindEvent(global,VMM.Timeline.DataObj.model_Tweets.onTwitterDataReady,"TWEETSLOADED");VMM.ExternalAPI.twitter.getTweets(a.timeline.tweets)},getData:function(a){VMM.bindEvent(global,VMM.Timeline.DataObj.model_Tweets.onTwitterDataReady,"TWEETSLOADED");VMM.ExternalAPI.twitter.getTweetSearch(a)},onTwitterDataReady:function(a,b){var c=VMM.Timeline.DataObj.data_template_obj;for(var d=0;d<b.tweetdata.length;d++){var e={type:"tweets",startDate:"",headline:"",text:"",asset:{media:"",credit:"",caption:""},tags:"Optional"};e.startDate=b.tweetdata[d].raw.created_at;type.of(b.tweetdata[d].raw.from_user_name)?e.headline=b.tweetdata[d].raw.from_user_name+" (<a href='https://twitter.com/"+b.tweetdata[d].raw.from_user+"'>"+"@"+b.tweetdata[d].raw.from_user+"</a>)":e.headline=b.tweetdata[d].raw.user.name+" (<a href='https://twitter.com/"+b.tweetdata[d].raw.user.screen_name+"'>"+"@"+b.tweetdata[d].raw.user.screen_name+"</a>)";e.asset.media=b.tweetdata[d].content;c.timeline.date.push(e)}VMM.fireEvent(global,"DATAREADY",c)}},model_GoogleSpreadsheet:{type:"google spreadsheet",getData:function(a){var b=VMM.Util.getUrlVars(a).key,c="https://spreadsheets.google.com/feeds/list/"+b+"/od6/public/values?alt=json";VMM.getJSON(c,VMM.Timeline.DataObj.model_GoogleSpreadsheet.buildData)},buildData:function(a){VMM.fireEvent(global,"MESSEGE","Parsing Data");var b=VMM.Timeline.DataObj.data_template_obj;for(var c=0;c<a.feed.entry.length;c++){var d=a.feed.entry[c];if(d.gsx$titleslide.$t.match("start")){b.timeline.startDate=d.gsx$startdate.$t;b.timeline.headline=d.gsx$headline.$t;b.timeline.asset.media=d.gsx$media.$t;b.timeline.asset.caption=d.gsx$mediacaption.$t;b.timeline.asset.credit=d.gsx$mediacredit.$t;b.timeline.text=d.gsx$text.$t;b.timeline.type="google spreadshe