Interactive interface for browsing global, full-resolution satellite imagery
Added ability to create padding for timeline
Taylor Gunnoee9bd80b8a173
diff --git a/web/js/date/wv.date.model.js b/web/js/date/wv.date.model.jsindex 104edc998..a3da315c5 100644--- a/web/js/date/wv.date.model.js+++ b/web/js/date/wv.date.model.js@@ -20,6 +20,9 @@ wv.date.model = wv.date.model || function(config, spec) {self.events = wv.util.events();self.selected = null;+ self.monthAbbr = [ "JAN", "FEB", "MAR", "APR", "MAY", "JUN",+ "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];+var init = function() {var initial = spec.initial || wv.util.today();self.select(initial);@@ -90,8 +93,6 @@ wv.date.model = wv.date.model || function(config, spec) {self.select(state.t);}};- self.monthAbbr = [ "JAN", "FEB", "MAR", "APR", "MAY", "JUN",- "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];init();return self;diff --git a/web/js/date/wv.date.timeline.config.js b/web/js/date/wv.date.timeline.config.jsindex 12d47ec45..b6d66f2c2 100644--- a/web/js/date/wv.date.timeline.config.js+++ b/web/js/date/wv.date.timeline.config.js@@ -11,425 +11,447 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, uivar self = {};var tl = ui.timeline;var model = models.date;- self.level1 = function(){- var altEnd, fNormData;- //format of the label- var labelFormat = d3.time.format.utc("%Y");- //printed type of tick- var dateInterval = d3.time.year.utc;- //step of the ticks- var dateStep = 1;- //number of ticks total of data range, in days- var tickCount = tl.data.end().getUTCFullYear() - tl.data.start().getUTCFullYear();-- var tickCountMax;- //width in pixels of each tick- var tickWidth = 15;- //Max number of ticks able to be shown on this resolution- tickCountMax = Math.ceil(tl.width/tickWidth);+ self.zoom = function(level, event){- //end tick date if tickCount is less than tickCountMax- altEnd = new Date(tl.data.start().getUTCFullYear() + tickCountMax,- tl.data.start().getUTCMonth(),- tl.data.start().getUTCDate());-- tl.zoom.drawTicks(tickCount,- tickCountMax,- altEnd,- tickWidth,- dateInterval,- dateStep,- labelFormat);--- //Filters ticks for nonboundaries for this zoom level- tl.zoom.current.ticks.normal.all = function(){- tl.ticks.normal.all = tl.ticks.all.filter(function(d){- return d.getUTCFullYear() % 10 !== 0;- });- tl.ticks.normal.setEnds();- };-- //Filters ticks for boundaries for this zoom level- tl.zoom.current.ticks.boundary.all = function(){- tl.ticks.boundary.all = tl.ticks.all.filter(function(d){- return d.getUTCFullYear() % 10 === 0;- });- };-- //Calculated next boundary tick by date- tl.zoom.current.ticks.boundary.next = function(current){- var next = new Date(current);- return new Date(next.setUTCFullYear(next.getUTCFullYear()+10));- };-- //Calculated next normal tick by date- tl.zoom.current.ticks.normal.next = function(current){- var next = new Date(current);- return new Date(next.setUTCFullYear(next.getUTCFullYear()+1));- };-- //Date of first printed boundary interval of this zoom level- tl.zoom.current.ticks.boundary.first = function(){- var first = tl.ticks.normal.firstDate;- return new Date(Date.UTC(Math.floor(first.getUTCFullYear()/10)*10,- 0,- 1));- };-- //Date of last printed boundary interval of this zoom level- tl.zoom.current.ticks.boundary.last = function(){- var last = tl.ticks.normal.lastDate;- return new Date(Date.UTC(Math.ceil(last.getUTCFullYear()/10)*10,- 0,- 1));- };-- //Value for hovered normal label- tl.zoom.current.ticks.normal.hover = function(d){- //No modifications to date obj at this zoom level- return new Date(d.getUTCFullYear(),- model.selected.getUTCMonth(),- model.selected.getUTCDate());- };-- //Value for clicked normal tick- tl.zoom.current.ticks.normal.clickDate = function(d){- return new Date(d.getUTCFullYear(),- model.selected.getUTCMonth(),- model.selected.getUTCDate());- };-- //Value for hovered boundary tick- tl.zoom.current.ticks.boundary.hover = function(d){- var yearOffset = model.selected.getUTCFullYear() -- Math.ceil(new Date(model.selected.getUTCFullYear()/10)*10);-- return new Date(d.getUTCFullYear() + yearOffset,- model.selected.getUTCMonth(),- model.selected.getUTCDate());- };-- //Displayed default label- tl.zoom.current.ticks.boundary.label = function(d){- return d.getUTCFullYear();- };-- //Displayed default sub-label (if any)- tl.zoom.current.ticks.boundary.subLabel = function(d){- return null;- };-- //Value for clicked boundary tick, FIXME: This is exactly the same as hover value- tl.zoom.current.ticks.boundary.clickDate = function(d){- var yearOffset = model.selected.getUTCFullYear() -- Math.ceil(new Date(model.selected.getUTCFullYear()/10)*10);-- return new Date(d.getUTCFullYear() + yearOffset,- model.selected.getUTCMonth(),- model.selected.getUTCDate());- };-- //When the date updates while dragging the pick forward- tl.zoom.current.pick.nextChange = function(d){- return new Date(Date.UTC(d.getUTCFullYear() + 1,- model.selected.getUTCMonth(),- model.selected.getUTCDate()));- };-- //When the date updates while dragging the pick backward- tl.zoom.current.pick.prevChange = function(d){- return new Date(Date.UTC(d.getUTCFullYear(),- model.selected.getUTCMonth(),- model.selected.getUTCDate()));- };-- tl.zoom.current.pick.hoverTick = function(newDate){- tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')- .filter(function(d){- return d.getUTCFullYear() === newDate.getUTCFullYear();- });- };-- tl.ticks.check();- initTicks();- /*- tl.ticks.normalTicks = tl.ticks.all.filter(function(d){- return d.getUTCFullYear() % 10 !== 0;- });-- tl.ticks.boundaryTicks = tl.ticks.all.filter(function(d){- return d.getUTCFullYear() % 10 === 0;- });-- tl.ticks.refresh('year','decade');- */- };- self.level2 = function(){- var altEnd, fNormData;//format of the label- var labelFormat = d3.time.format.utc("%Y");+ var labelFormat;//printed type of tick- var dateInterval = d3.time.month.utc;- //step of the ticks+ var dateInterval;+ //step of the ticks, here difference between ticks is always 1var dateStep = 1;//number of ticks total of data range, in days- var tickCount = (tl.data.end().getUTCFullYear() - tl.data.start().getUTCFullYear()) * 12 +- tl.data.end().getUTCMonth() + 1 - tl.data.start().getUTCMonth();-+ var tickCount;+ //Calculated max number of ticks based on tickCountvar tickCountMax;//width in pixels of each tick- var tickWidth = 11;-+ var tickWidth;//Max number of ticks able to be shown on this resolution- tickCountMax = Math.ceil(tl.width/tickWidth);-+ var tickCountMax;//end tick date if tickCount is less than tickCountMax- altEnd = new Date(tl.data.start().getUTCFullYear(),- tl.data.start().getUTCMonth() + tickCountMax,- tl.data.start().getUTCDate());-- tl.zoom.drawTicks(tickCount,- tickCountMax,- altEnd,- tickWidth,- dateInterval,- dateStep,- labelFormat);--- //Filters ticks for nonboundaries for this zoom level- tl.zoom.current.ticks.normal.all = function(){- tl.ticks.normal.all = tl.ticks.all.filter(function(d){- return d.getUTCMonth() !== 0;- });- tl.ticks.normal.setEnds();- };-- //Filters ticks for boundaries for this zoom level- tl.zoom.current.ticks.boundary.all = function(){- tl.ticks.boundary.all = tl.ticks.all.filter(function(d){- return d.getUTCMonth() === 0;- });- };-- //Calculated next boundary tick by date- tl.zoom.current.ticks.boundary.next = function(current){- var next = new Date(current);- return new Date(next.setUTCFullYear(next.getUTCFullYear()+1));- };-- //Calculated next normal tick by date- tl.zoom.current.ticks.normal.next = function(current){- var next = new Date(current);- return new Date(next.setUTCMonth(next.getUTCMonth()+1));- };-- //Date of first printed boundary interval of this zoom level- tl.zoom.current.ticks.boundary.first = function(){- var first = tl.ticks.normal.firstDate;- return new Date(Date.UTC(first.getUTCFullYear(),- 0,- 1));- };-- //Date of last printed boundary interval of this zoom level- tl.zoom.current.ticks.boundary.last = function(){- var last = tl.ticks.normal.lastDate;- return new Date(Date.UTC(last.getUTCFullYear()+1,- 0,- 1));- };-- //Value for hovered normal label- tl.zoom.current.ticks.normal.hover = function(d){- //No modifications to date obj at this zoom level- return new Date(d.getUTCFullYear(),d.getUTCMonth(),model.selected.getUTCDate());- };-- //Value for clicked normal tick- tl.zoom.current.ticks.normal.clickDate = function(d){- return new Date(d.getUTCFullYear(),d.getUTCMonth(),model.selected.getUTCDate());- };-- //Value for hovered boundary tick- tl.zoom.current.ticks.boundary.hover = function(d){- return new Date(d.getUTCFullYear(),model.selected.getUTCMonth(),model.selected.getUTCDate());- };-- //Displayed default label- tl.zoom.current.ticks.boundary.label = function(d){- return d.getUTCFullYear();- };-- //Displayed default sub-label (if any)- tl.zoom.current.ticks.boundary.subLabel = function(d){- return null;- };-- //Value for clicked boundary tick- tl.zoom.current.ticks.boundary.clickDate = function(d){- return new Date(d.getUTCFullYear(),model.selected.getUTCMonth(),model.selected.getUTCDate());- };-- //When the date updates while dragging the pick forward- tl.zoom.current.pick.nextChange = function(d){- return new Date(Date.UTC(d.getUTCFullYear(),d.getUTCMonth()+1,model.selected.getUTCDate()));- };-- //When the date updates while dragging the pick backward- tl.zoom.current.pick.prevChange = function(d){- return new Date(Date.UTC(d.getUTCFullYear(),d.getUTCMonth(),model.selected.getUTCDate()));- };-- tl.zoom.current.pick.hoverTick = function(newDate){- tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')- .filter(function(d){- return (d.getUTCFullYear() === newDate.getUTCFullYear()) &&- (d.getUTCMonth() === newDate.getUTCMonth());+ var altEnd;++ switch(level){+ case 1:+ labelFormat = d3.time.format.utc("%Y");+ dateInterval = d3.time.year.utc;+ tickCount = tl.data.end().getUTCFullYear() - tl.data.start().getUTCFullYear();+ tickWidth = 15;+ tickCountMax = Math.ceil(tl.width/tickWidth);++ altEnd = new Date(tl.data.start().getUTCFullYear() + tickCountMax,+ tl.data.start().getUTCMonth(),+ tl.data.start().getUTCDate());++ tl.zoom.drawTicks(tickCount,+ tickCountMax,+ altEnd,+ tickWidth,+ dateInterval,+ dateStep,+ labelFormat,+ event);++ //Filters ticks for nonboundaries for this zoom level+ tl.zoom.current.ticks.normal.all = function(){+ tl.ticks.normal.all = tl.ticks.all.filter(function(d){+ return d.getUTCFullYear() % 10 !== 0;});- };-- tl.ticks.check();- initTicks();- /*+ tl.ticks.normal.setEnds();+ };- var protoData = new Date(Date.UTC(tl.ticks.all.data[0].getUTCFullYear(),- tl.ticks.all.data[0].getUTCMonth()-1,- 1));+ //Filters ticks for boundaries for this zoom level+ tl.zoom.current.ticks.boundary.all = function(){+ tl.ticks.boundary.all = tl.ticks.all.filter(function(d){+ return d.getUTCFullYear() % 10 === 0;+ });+ };++ //Calculated next boundary tick by date+ tl.zoom.current.ticks.boundary.next = function(current){+ var next = new Date(current);+ return new Date(next.setUTCFullYear(next.getUTCFullYear()+10));+ };++ //Calculated next normal tick by date+ tl.zoom.current.ticks.normal.next = function(current){+ var next = new Date(current);+ return new Date(next.setUTCFullYear(next.getUTCFullYear()+1));+ };++ //Date of first printed boundary interval of this zoom level+ tl.zoom.current.ticks.boundary.first = function(){+ var first = tl.ticks.normal.firstDate;+ return new Date(Date.UTC(Math.floor(first.getUTCFullYear()/10)*10,+ 0,+ 1));+ };++ //Date of last printed boundary interval of this zoom level+ tl.zoom.current.ticks.boundary.last = function(){+ var last = tl.ticks.normal.lastDate;+ return new Date(Date.UTC(Math.ceil(last.getUTCFullYear()/10)*10,+ 0,+ 1));+ };++ //Value for hovered normal label+ tl.zoom.current.ticks.normal.hover = function(d){+ //No modifications to date obj at this zoom level+ return new Date(d.getUTCFullYear(),+ model.selected.getUTCMonth(),+ model.selected.getUTCDate());+ };++ //Value for clicked normal tick+ tl.zoom.current.ticks.normal.clickDate = function(d){+ return new Date(d.getUTCFullYear(),+ model.selected.getUTCMonth(),+ model.selected.getUTCDate());+ };++ //Value for hovered boundary tick+ tl.zoom.current.ticks.boundary.hover = function(d){+ var yearOffset = model.selected.getUTCFullYear() -+ Math.ceil(new Date(model.selected.getUTCFullYear()/10)*10);++ return new Date(d.getUTCFullYear() + yearOffset,+ model.selected.getUTCMonth(),+ model.selected.getUTCDate());+ };++ //Displayed default label+ tl.zoom.current.ticks.boundary.label = function(d){+ return d.getUTCFullYear();+ };++ //Displayed default sub-label (if any)+ tl.zoom.current.ticks.boundary.subLabel = function(d){+ return null;+ };++ //Value for clicked boundary tick, FIXME: This is exactly the same as hover value+ tl.zoom.current.ticks.boundary.clickDate = function(d){+ var yearOffset = model.selected.getUTCFullYear() -+ Math.ceil(new Date(model.selected.getUTCFullYear()/10)*10);++ return new Date(d.getUTCFullYear() + yearOffset,+ model.selected.getUTCMonth(),+ model.selected.getUTCDate());+ };++ //When the date updates while dragging the pick forward+ tl.zoom.current.pick.nextChange = function(d){+ return new Date(Date.UTC(d.getUTCFullYear() + 1,+ model.selected.getUTCMonth(),+ model.selected.getUTCDate()));+ };++ //When the date updates while dragging the pick backward+ tl.zoom.current.pick.prevChange = function(d){+ return new Date(Date.UTC(d.getUTCFullYear(),+ model.selected.getUTCMonth(),+ model.selected.getUTCDate()));+ };++ tl.zoom.current.pick.hoverTick = function(newDate){+ tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')+ .filter(function(d){+ return d.getUTCFullYear() === newDate.getUTCFullYear();+ });+ };++++ //Update placement of zoom buttons+ $('.zoom-btn').removeClass(function (index, css) {+ return (css.match (/(^|\s)depth-\S+/g) || []).join(' ');+ }).css("margin","").css("font-size","");+ $('#zoom-years').addClass("depth-1").css("font-size","1.7em");+ $('#zoom-months').addClass("depth-2").css("font-size","1.2em");+ $('#zoom-days').addClass("depth-3").css("margin","-3px 0 5px 0");++ self.currentZoom = 1;+ break;+ case 2:+ labelFormat = d3.time.format.utc("%Y");+ dateInterval = d3.time.month.utc;++ tickCount = (tl.data.end().getUTCFullYear() -+ tl.data.start().getUTCFullYear()) * 12 ++ tl.data.end().getUTCMonth() + 1 -+ tl.data.start().getUTCMonth();- tl.ticks.refresh('month','year');-- */- };- self.level3 = function(){- var altEnd,- fNormData,- //format of the label- labelFormat = d3.time.format.utc("%b"),- //printed type of tick- dateInterval = d3.time.day.utc,- //step of the ticks- dateStep = 1,- //number of ticks total of data range, in days- tickCount = (tl.data.end() - tl.data.start())/1000/60/60/24,- tickCountMax,- //width in pixels of each ticktickWidth = 11;+ tickCountMax = Math.ceil(tl.width/tickWidth);++ altEnd = new Date(tl.data.start().getUTCFullYear(),+ tl.data.start().getUTCMonth() + tickCountMax,+ tl.data.start().getUTCDate());++ tl.zoom.drawTicks(tickCount,+ tickCountMax,+ altEnd,+ tickWidth,+ dateInterval,+ dateStep,+ labelFormat,+ event);++ //Filters ticks for nonboundaries for this zoom level+ tl.zoom.current.ticks.normal.all = function(){+ tl.ticks.normal.all = tl.ticks.all.filter(function(d){+ return d.getUTCMonth() !== 0;+ });+ tl.ticks.normal.setEnds();+ };- //Max number of ticks able to be shown on this resolution- tickCountMax = Math.ceil(tl.width/tickWidth);-- //end tick date if tickCount is less than tickCountMax- altEnd = new Date(tl.data.start().getUTCFullYear(),- tl.data.start().getUTCMonth(),- tl.data.start().getUTCDate() + tickCountMax);-- tl.zoom.drawTicks(tickCount,- tickCountMax,- altEnd,- tickWidth,- dateInterval,- dateStep,- labelFormat);-- //Filters ticks for nonboundaries that have the following attribute- tl.zoom.current.ticks.normal.all = function(){- tl.ticks.normal.all = tl.ticks.all.filter(function(d){- return d.getUTCDate() !== 1;- });- tl.ticks.normal.setEnds();- };-- //Filters ticks for boundaries that have the following attribute- tl.zoom.current.ticks.boundary.all = function(){- tl.ticks.boundary.all = tl.ticks.all.filter(function(d){- return d.getUTCDate() === 1;- });- };-- //Calculated next boundary tick by date- tl.zoom.current.ticks.boundary.next = function(current){- var next = new Date(current);- return new Date(next.setUTCMonth(next.getUTCMonth()+1));- };-- //Calculated next normal tick by date- tl.zoom.current.ticks.normal.next = function(current){- var next = new Date(current);- return new Date(next.setUTCDate(next.getUTCDate()+1));- };-- //Date of first printed boundary interval of this zoom level- tl.zoom.current.ticks.boundary.first = function(){- var first = tl.ticks.normal.firstDate;- return new Date(Date.UTC(first.getUTCFullYear(),- first.getUTCMonth(),- 1));- };-- //Date of last printed boundary interval of this zoom level- tl.zoom.current.ticks.boundary.last = function(){- var last = tl.ticks.normal.lastDate;- return new Date(Date.UTC(last.getUTCFullYear(),- last.getUTCMonth()+1,- 1));- };-- //Value for hovered normal label- tl.zoom.current.ticks.normal.hover = function(d){- //No modifications to date obj at this zoom level- return d;- };-- //Value for clicked normal tick- tl.zoom.current.ticks.normal.clickDate = function(d){- return new Date(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate());- };-- //Value for hovered boundary tick- tl.zoom.current.ticks.boundary.hover = function(d){- return new Date(d.getUTCFullYear(),d.getUTCMonth(),model.selected.getUTCDate());- };-- //Displayed default label- tl.zoom.current.ticks.boundary.label = function(d){- return model.monthAbbr[d.getUTCMonth()];- };-- //Displayed default sub-label (if any)- tl.zoom.current.ticks.boundary.subLabel = function(d){- return d.getUTCFullYear();- };-- //Value for clicked boundary tick- tl.zoom.current.ticks.boundary.clickDate = function(d){- return new Date(d.getUTCFullYear(),d.getUTCMonth(),model.selected.getUTCDate());- };-- //When the date updates while dragging the pick forward- tl.zoom.current.pick.nextChange = function(d){- return new Date(Date.UTC(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()+1));- };-- //When the date updates while dragging the pick backward- tl.zoom.current.pick.prevChange = function(d){- return new Date(Date.UTC(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()));- };-- tl.zoom.current.pick.hoverTick = function(newDate){- tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')- .filter(function(d){- return (d.getUTCFullYear() === newDate.getUTCFullYear()) &&- (d.getUTCMonth() === newDate.getUTCMonth() &&- (d.getUTCDate() === newDate.getUTCDate()));+ //Filters ticks for boundaries for this zoom level+ tl.zoom.current.ticks.boundary.all = function(){+ tl.ticks.boundary.all = tl.ticks.all.filter(function(d){+ return d.getUTCMonth() === 0;});- };+ };++ //Calculated next boundary tick by date+ tl.zoom.current.ticks.boundary.next = function(current){+ var next = new Date(current);+ return new Date(next.setUTCFullYear(next.getUTCFullYear()+1));+ };++ //Calculated next normal tick by date+ tl.zoom.current.ticks.normal.next = function(current){+ var next = new Date(current);+ return new Date(next.setUTCMonth(next.getUTCMonth()+1));+ };++ //Date of first printed boundary interval of this zoom level+ tl.zoom.current.ticks.boundary.first = function(){+ var first = tl.ticks.normal.firstDate;+ return new Date(Date.UTC(first.getUTCFullYear(),+ 0,+ 1));+ };++ //Date of last printed boundary interval of this zoom level+ tl.zoom.current.ticks.boundary.last = function(){+ var last = tl.ticks.normal.lastDate;+ return new Date(Date.UTC(last.getUTCFullYear()+1,+ 0,+ 1));+ };++ //Value for hovered normal label+ tl.zoom.current.ticks.normal.hover = function(d){+ //No modifications to date obj at this zoom level+ return new Date(d.getUTCFullYear(),d.getUTCMonth(),model.selected.getUTCDate());+ };++ //Value for clicked normal tick+ tl.zoom.current.ticks.normal.clickDate = function(d){+ return new Date(d.getUTCFullYear(),d.getUTCMonth(),model.selected.getUTCDate());+ };++ //Value for hovered boundary tick+ tl.zoom.current.ticks.boundary.hover = function(d){+ return new Date(d.getUTCFullYear(),+ model.selected.getUTCMonth(),+ model.selected.getUTCDate());+ };++ //Displayed default label+ tl.zoom.current.ticks.boundary.label = function(d){+ return d.getUTCFullYear();+ };++ //Displayed default sub-label (if any)+ tl.zoom.current.ticks.boundary.subLabel = function(d){+ return null;+ };++ //Value for clicked boundary tick+ tl.zoom.current.ticks.boundary.clickDate = function(d){+ return new Date(d.getUTCFullYear(),+ model.selected.getUTCMonth(),+ model.selected.getUTCDate());+ };++ //When the date updates while dragging the pick forward+ tl.zoom.current.pick.nextChange = function(d){+ return new Date(Date.UTC(d.getUTCFullYear(),+ d.getUTCMonth()+1,+ model.selected.getUTCDate()));+ };++ //When the date updates while dragging the pick backward+ tl.zoom.current.pick.prevChange = function(d){+ return new Date(Date.UTC(d.getUTCFullYear(),+ d.getUTCMonth(),+ model.selected.getUTCDate()));+ };++ tl.zoom.current.pick.hoverTick = function(newDate){+ tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')+ .filter(function(d){+ return (d.getUTCFullYear() === newDate.getUTCFullYear()) &&+ (d.getUTCMonth() === newDate.getUTCMonth());+ });+ };++ //Update placement of zoom buttons+ $('.zoom-btn').removeClass(function (index, css) {+ return (css.match (/(^|\s)depth-\S+/g) || []).join(' ');+ }).css("margin","").css("font-size","");+ $('#zoom-days').addClass("depth-2").css("margin","5px 0 0 0");+ $('#zoom-years').addClass("depth-2");+ $('#zoom-months').addClass("depth-1").css("font-size","1.7em");++ self.currentZoom = 2;+ break;+ case 3:+ labelFormat = d3.time.format.utc("%b");+ dateInterval = d3.time.day.utc;+ tickCount = (tl.data.end() - tl.data.start())/1000/60/60/24;+ tickWidth = 11;+ tickCountMax = Math.ceil(tl.width/tickWidth);++ altEnd = new Date(tl.data.start().getUTCFullYear(),+ tl.data.start().getUTCMonth(),+ tl.data.start().getUTCDate() + tickCountMax);++ tl.zoom.drawTicks(tickCount,+ tickCountMax,+ altEnd,+ tickWidth,+ dateInterval,+ dateStep,+ labelFormat,+ event);++ //Filters ticks for nonboundaries that have the following attribute+ tl.zoom.current.ticks.normal.all = function(){+ tl.ticks.normal.all = tl.ticks.all.filter(function(d){+ return d.getUTCDate() !== 1;+ });+ tl.ticks.normal.setEnds();+ };+ //Filters ticks for boundaries that have the following attribute+ tl.zoom.current.ticks.boundary.all = function(){+ tl.ticks.boundary.all = tl.ticks.all.filter(function(d){+ return d.getUTCDate() === 1;+ });+ };++ //Calculated next boundary tick by date+ tl.zoom.current.ticks.boundary.next = function(current){+ var next = new Date(current);+ return new Date(next.setUTCMonth(next.getUTCMonth()+1));+ };++ //Calculated next normal tick by date+ tl.zoom.current.ticks.normal.next = function(current){+ var next = new Date(current);+ return new Date(next.setUTCDate(next.getUTCDate()+1));+ };++ //Date of first printed boundary interval of this zoom level+ tl.zoom.current.ticks.boundary.first = function(){+ var first = tl.ticks.normal.firstDate;+ return new Date(Date.UTC(first.getUTCFullYear(),+ first.getUTCMonth(),+ 1));+ };++ //Date of last printed boundary interval of this zoom level+ tl.zoom.current.ticks.boundary.last = function(){+ var last = tl.ticks.normal.lastDate;+ return new Date(Date.UTC(last.getUTCFullYear(),+ last.getUTCMonth()+1,+ 1));+ };++ //Value for hovered normal label+ tl.zoom.current.ticks.normal.hover = function(d){+ //No modifications to date obj at this zoom level+ return d;+ };++ //Value for clicked normal tick+ tl.zoom.current.ticks.normal.clickDate = function(d){+ return new Date(d.getUTCFullYear(),+ d.getUTCMonth(),+ d.getUTCDate());+ };++ //Value for hovered boundary tick+ tl.zoom.current.ticks.boundary.hover = function(d){+ return new Date(d.getUTCFullYear(),+ d.getUTCMonth(),+ model.selected.getUTCDate());+ };++ //Displayed default label+ tl.zoom.current.ticks.boundary.label = function(d){+ return model.monthAbbr[d.getUTCMonth()];+ };++ //Displayed default sub-label (if any)+ tl.zoom.current.ticks.boundary.subLabel = function(d){+ return d.getUTCFullYear();+ };++ //Value for clicked boundary tick+ tl.zoom.current.ticks.boundary.clickDate = function(d){+ return new Date(d.getUTCFullYear(),+ d.getUTCMonth(),+ model.selected.getUTCDate());+ };++ //When the date updates while dragging the pick forward+ tl.zoom.current.pick.nextChange = function(d){+ return new Date(Date.UTC(d.getUTCFullYear(),+ d.getUTCMonth(),+ d.getUTCDate()+1));+ };++ //When the date updates while dragging the pick backward+ tl.zoom.current.pick.prevChange = function(d){+ return new Date(Date.UTC(d.getUTCFullYear(),+ d.getUTCMonth(),+ d.getUTCDate()));+ };++ tl.zoom.current.pick.hoverTick = function(newDate){+ tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')+ .filter(function(d){+ return (d.getUTCFullYear() === newDate.getUTCFullYear()) &&+ (d.getUTCMonth() === newDate.getUTCMonth() &&+ (d.getUTCDate() === newDate.getUTCDate()));+ });+ };++ //Update placement of zoom buttons+ $('.zoom-btn').removeClass(function (index, css) {+ return (css.match (/(^|\s)depth-\S+/g) || []).join(' ');+ }).css("margin","").css("font-size","");+ $('#zoom-years').addClass("depth-3").css("margin","6px 0 0 0");+ $('#zoom-months').addClass("depth-2");+ $('#zoom-days').addClass("depth-1")+ .css("margin", "8px 0 0 0")+ .css('font-size','1.8em');++ self.currentZoom = 3;+ break;++ default:+ console.log('Invalid Zoom level');+ }tl.ticks.check();initTicks();+ tl.pick.update();+ tl.pick.checkLocation();};//Draw ticks based on zoom level@@ -444,8 +466,24 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, uivar init = function(){+ d3.select("#zoom-years").on("click",function(d){+ $('.zoom-btn').removeClass("zoom-btn-selected");+ $(this).addClass("zoom-btn-selected");+ self.zoom(1);+ });+ d3.select("#zoom-months").on("click",function(d){+ $('.zoom-btn').removeClass("zoom-btn-selected");+ $(this).addClass("zoom-btn-selected");+ self.zoom(2);+ });+ d3.select("#zoom-days").on("click",function(d){+ $('.zoom-btn').removeClass("zoom-btn-selected");+ $(this).addClass("zoom-btn-selected");+ self.zoom(3);++ });//Default zoom- self.level2();+ self.zoom(2);};init();diff --git a/web/js/date/wv.date.timeline.data.js b/web/js/date/wv.date.timeline.data.jsindex 0a1928fc2..fa6e24511 100644--- a/web/js/date/wv.date.timeline.data.js+++ b/web/js/date/wv.date.timeline.data.js@@ -24,6 +24,7 @@ wv.date.timeline = wv.date.timeline || {};wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {var tl = ui.timeline;+ var model = models.date;var self = {};@@ -37,12 +38,91 @@ wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {.setUTCDate( wv.util.today().getUTCDate() + 1 ) );};++ self.addPadding = function(){+ var buffer = tl.padding;+ self.paddedStart = tl.x.invert(-buffer);+ self.paddedEnd = tl.x.invert(tl.width + buffer);+ };+self.set = function(){-++ var activeLayers = models.layers.get();+ var activeLayersDynamic = activeLayers.filter(function(al){+ return al.startDate;+ });+ /* var activeLayersInvisible = activeLayers.filter(function(al){+ return al.visible === false;+ });*/+ var activeLayersTitles = [];+ var layerCount = activeLayersDynamic.length;++ tl.dataBars.selectAll('rect').remove();++ $(activeLayersDynamic).each(function(i){+ activeLayersTitles[i] = this.id;+ });++ tl.y = d3.scale.ordinal()+ .domain(activeLayersTitles)+ .rangeBands([5,tl.height-12]);++ tl.yAxis = d3.svg.axis()+ .scale(tl.y)+ .orient("left")+ .ticks(layerCount);++ $(activeLayersDynamic).each(function(al){+ var layerStart,layerEnd,layerXY;+ var layerVisible = true;+ var staticLayer = true;+ var layerId = this.id;++ if( this.startDate ) {+ layerStart = new Date( this.startDate );+ staticLayer = false;+ }+ else{+ layerStart = self.start();+ }+ if( this.inactive === true ) {+ layerEnd = new Date( this.endDate );+ }+ else{+ layerEnd = self.end();+ }++ var currentDB = tl.dataBars.append("svg:rect")+ .attr( 'x', tl.x( layerStart ) )+ .attr( 'width', tl.x( layerEnd ) - tl.x( layerStart ) )+ //.attr('height',2)+ .attr( 'y', tl.y( layerId ) - 2.5 )+ .attr( 'rx', 4 )+ .attr( 'ry', 4 )+ .attr( 'data-layer', layerId )+ .attr( "class", "data-bar" );+// .attr("d", selection);+ if( !staticLayer ){+ currentDB.classed( 'data-bar-dyn', true );+ }+ if( this.visible === false ) {+ layerVisible = false;+ currentDB.classed( 'data-bar-invisible', true );+ }++ });+ tl.dataBars.selectAll( 'rect' )+ .attr( 'height', ( tl.height - 22 ) / layerCount );++ if( tl.verticalAxis ) {+ tl.verticalAxis.call( tl.yAxis );+ }};+var init = function(){tl.axisZoom.xExtent( [self.start(), self.end()] );+};init();diff --git a/web/js/date/wv.date.timeline.input.js b/web/js/date/wv.date.timeline.input.jsindex ca708fb02..da5e1ae98 100644--- a/web/js/date/wv.date.timeline.input.js+++ b/web/js/date/wv.date.timeline.input.js@@ -373,15 +373,6 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)$('.button-input-group').prop('disabled', true);}- model.events.on("select", function(){- self.update();- tl.pick.shiftView();- });-- models.layers.events.on("change",function(){- //setData();- });-self.update();};diff --git a/web/js/date/wv.date.timeline.js b/web/js/date/wv.date.timeline.jsindex 69904ccb9..0113d2ab7 100644--- a/web/js/date/wv.date.timeline.js+++ b/web/js/date/wv.date.timeline.js@@ -32,12 +32,18 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {left: 30};+ self.getPadding = function(){+ self.padding = self.width/4;+ return self.padding;+ };+self.getWidth = function(){self.width = $(window).outerWidth(true) -$("#timeline-header").outerWidth(true) -$("#timeline-zoom").outerWidth(true) -$("#timeline-hide").outerWidth(true) -- self.margin.left - self.margin.right - 22;+ self.margin.left - self.margin.right - 22;+return self.width;};@@ -96,7 +102,7 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {self.collapse(true);};- var resize = function(){+ self.resize = function(){var small = wv.util.browser.small || wv.util.browser.constrained;if ( self.enabled && small ) {self.enabled = false;@@ -121,7 +127,6 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {self.axis.select("line:first-child").attr("x2", self.width);- //tl.zoom.refresh();}};@@ -193,8 +198,7 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {.scale(1).scaleExtent([1,1]);- resize();- $(window).resize(resize);+ self.resize();if ( wv.util.browser.localStorage ) {if ( localStorage.getItem("timesliderState") === "collapsed" ) {@@ -204,6 +208,20 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {$('#timeline-hide').click(function() { self.toggle(); });+ $(window).resize(function(){+ self.resize();+ self.zoom.refresh();+ });++ model.events.on("select", function(){+ self.input.update();+ self.pick.shiftView();+ });++ models.layers.events.on("change",function(){+ self.data.set();+ });+};init();diff --git a/web/js/date/wv.date.timeline.pan.js b/web/js/date/wv.date.timeline.pan.jsindex 1fc3f61a7..4cbb95e09 100644--- a/web/js/date/wv.date.timeline.pan.js+++ b/web/js/date/wv.date.timeline.pan.js@@ -36,11 +36,9 @@ wv.date.timeline.pan = wv.date.timeline.pan || function(models, config, ui) {var evt = event.sourceEvent || event;var delX = evt.deltaX;if((evt.type === "wheel") && ((evt.deltaX < 0) || (evt.deltaX > 0))){- tl.axisZoom.translate([self.xPosition-delX,0]);- self.xPosition = tl.axisZoom.translate()[0];+ update(self.xPosition-delX,0);}- }- else{+ } else {self.xPosition = tl.axisZoom.translate()[0];}tl.axis.call(tl.xAxis);@@ -52,18 +50,35 @@ wv.date.timeline.pan = wv.date.timeline.pan || function(models, config, ui) {tl.pick.update();tl.pick.checkLocation();++ tl.data.set();+ };++ var update = function(x, y){+ tl.axisZoom.translate([x, y]);+ self.xPosition = tl.axisZoom.translate()[0];};self.toSelection = function(){- tl.axisZoom.translate([-tl.x(model.selected) +- (tl.width -- tl.margin.left -- tl.margin.right) /- 2,0]);+ var x = -tl.x(model.selected) ++ (tl.width - tl.margin.left -+ tl.margin.right) / 2;- self.xPosition = tl.axisZoom.translate()[0];+ update(x, 0);++ tl.data.set();++ };+ self.toCursor = function(mousePos, mouseOffset){++ var x = -tl.x(mousePos) ++ (tl.width - tl.margin.left -+ tl.margin.right) / 2 - mouseOffset;++ update(x, 0);+ tl.data.set();};var init = function(){diff --git a/web/js/date/wv.date.timeline.ticks.js b/web/js/date/wv.date.timeline.ticks.jsindex 7a1fad09d..d01835a34 100644--- a/web/js/date/wv.date.timeline.ticks.js+++ b/web/js/date/wv.date.timeline.ticks.js@@ -293,16 +293,13 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)// compare the first and last ticks with the first and last// dates of data range, if they exceed it, add these ticksself.compare = function(proto, end){- console.log(self.firstDate);- console.log(' > ' + tl.data.start());+ //TODO: Finish for !isCroppedif(self.firstDate > tl.data.start()){//the data and what element to insert it before//probably a better way of doing this- console.log('first yep');//self.add(proto, 'g.tick');}if(self.lastDate <= wv.util.today()){- console.log('yep');//self.add(end, 'path.domain');}};diff --git a/web/js/date/wv.date.timeline.zoom.js b/web/js/date/wv.date.timeline.zoom.jsindex ab428c5a2..473f47b06 100644--- a/web/js/date/wv.date.timeline.zoom.js+++ b/web/js/date/wv.date.timeline.zoom.js@@ -43,22 +43,22 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {};self.change = function(amount, event) {- //console.log('changing zoom!');- //TODO: Below- /*- zoomLvl += -amount;- if ( zoomLvl < 0 ) {- zoomLvl = 0;++ var zoom = tl.config.currentZoom;++ zoom += -amount;+ if ( zoom < 1 ) {+ zoom = 1;}- if ( zoomLvl > 2 ) {- zoomLvl = 2;+ if ( zoom > 3 ) {+ zoom = 3;}- setZoom.call(this, zoomLvl, event);- */+ tl.config.zoom.call(this, zoom, event);+};- self.drawTicks = function(count, max, aEnd, w, i, s, f){+ self.drawTicks = function(count, max, aEnd, w, i, s, f, e){var d1 = tl.data.start(),d2,r1 = (tl.width/2)-((count*w)/2),@@ -77,13 +77,23 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {r2 = tl.width;}- update(d1, d2, r1, r2, i, s, f);+ update(d1, d2, r1, r2, i, s, f, e);+ };++ self.refresh = function(){+ tl.config.zoom(tl.config.currentZoom);};- var update = function(d1, d2, r1, r2, i, s, f){+ var update = function(d1, d2, r1, r2, i, s, f, e){+ if(e){+ var relX = e.offsetX ||+ (e.clientX - $('#timeline-footer').offset().left);+ var mousePos = tl.x.invert(relX);+ var mouseOffset = (tl.width-tl.margin.left-tl.margin.right)/2 - relX;+ console.log(mousePos);+ }-tl.x.domain([d1,d2]).range([r1,r2]);@@ -98,9 +108,12 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {tl.svg.call(tl.axisZoom);- tl.pan.toSelection();+ if(e){+ tl.pan.toCursor(mousePos, mouseOffset);+ } else {+ tl.pan.toSelection();+ }- //??need to remove first?tl.axis.selectAll('.tick').remove();tl.axis.call(tl.xAxis);@@ -109,7 +122,6 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {var init = function(){- //self.level3();};init();