Interactive interface for browsing global, full-resolution satellite imagery
Move configuration to its own file, fixed resize
Taylor Gunnoe5b6446ebf01c
diff --git a/web/index.html b/web/index.htmlindex 1c91287c7..0444c801c 100644--- a/web/index.html+++ b/web/index.html@@ -161,6 +161,7 @@<!-- link.dev --> <script type="text/javascript" src="js/date/wv.date.timeline.pick.js"></script><!-- link.dev --> <script type="text/javascript" src="js/date/wv.date.timeline.pan.js"></script><!-- link.dev --> <script type="text/javascript" src="js/date/wv.date.timeline.input.js"></script>+ <!-- link.dev --> <script type="text/javascript" src="js/date/wv.date.timeline.configure.js"></script><!-- link.dev --> <script type="text/javascript" src="js/date/wv.date.wheels.js"></script>diff --git a/web/js/date/wv.date.timeline.config.js b/web/js/date/wv.date.timeline.config.jsnew file mode 100644index 000000000..72ba18985--- /dev/null+++ b/web/js/date/wv.date.timeline.config.js@@ -0,0 +1,174 @@+/**+ * Modify zoom levels here. Maybe this isnt the best way to do this.+ * It could be called just level without the zoom part instead.+ *+ * When the zoom level is changed, this re renders everything of the timeline.+ *+ * @class wv.date.timeline.config+ */++wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui) {+ var self = {};+ var tl = ui.timeline;+ var model = models.date;+ self.level1 = function(){+/*+ 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(){+/*+ tl.ticks.normalTicks = tl.ticks.all.filter(function(d){+ return d.getUTCMonth() !== 0;+ });++ tl.ticks.boundaryTicks = tl.ticks.all.filter(function(d){+ return d.getUTCMonth() === 0;+ });++ var protoData = new Date(Date.UTC(tl.ticks.all.data[0].getUTCFullYear(),+ tl.ticks.all.data[0].getUTCMonth()-1,+ 1));++ 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 tick+ tickWidth = 11;++ //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));+ };++ //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()));+ });+ };++ tl.ticks.check();+ initTicks();++ };++ //Draw ticks based on zoom level+ var initTicks = function(){+ tl.ticks.boundary.init();+ tl.ticks.normal.init();+ tl.ticks.normal.set(); //could probably combine set and bind+ tl.ticks.normal.bind();+ tl.ticks.boundary.set();+ tl.ticks.boundary.bind();+ };++ var init = function(){++ //Default zoom+ self.level3();+ };++ init();+ return self;+};diff --git a/web/js/date/wv.date.timeline.js b/web/js/date/wv.date.timeline.jsindex d42d7cf16..291589afc 100644--- a/web/js/date/wv.date.timeline.js+++ b/web/js/date/wv.date.timeline.js@@ -45,7 +45,7 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {self.isCropped = true;- self.toggle = function(){+ self.toggle = function(now){var tl = $('#timeline-footer');var tlz = $('#timeline-zoom');var tlg = self.boundary;@@ -73,7 +73,7 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {}};- self.expand = function(){+ self.expand = function(now){now = now || false;var tl = $('#timeline-footer, #timeline-zoom');if (tl.is(":hidden")){@@ -85,13 +85,17 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {self.expand(true);};- self.collapse = function(){+ self.collapse = function(now){var tl = $('#timeline-footer, #timeline-zoom');if (!tl.is(":hidden")){- self.toggle();+ self.toggle(now);}};+ self.collapseNow = function() {+ self.collapse(true);+ };+var resize = function(){var small = wv.util.browser.small || wv.util.browser.constrained;if ( self.enabled && small ) {@@ -101,19 +105,25 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {self.enabled = true;$("#timeline").show();}- //TODO: Below- /*+if ( self.enabled ) {- getTimelineWidth();- d3.select('#timeline-footer svg')- .attr('width', width);// + margin.left + margin.right);- d3.select('#timeline-boundary rect').attr('width',width);//+margin.left+margin.right);- d3.select('#guitarpick-boundary rect').attr('width',width+margin.left+margin.right);//+margin.left+margin.right);- timeline.select(".x.axis line:first-child").attr("x2",width);//+margin.left+margin.right);-- setZoom(zoomLvl);+ self.getWidth();++ self.svg.attr('width', self.width);++ d3.select('#timeline-boundary rect').attr( 'width', self.width);++ d3.select('#guitarpick-boundary rect')+ .attr('width', self.width+ + self.margin.left+ + self.margin.right );++ self.axis.select("line:first-child")+ .attr("x2", self.width);++ //tl.zoom.refresh();}- */+};var drawContainers = function(){@@ -184,6 +194,7 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {.scaleExtent([1,1]);resize();+ $(window).resize(resize);if ( wv.util.browser.localStorage ) {if ( localStorage.getItem("timesliderState") === "collapsed" ) {@@ -191,6 +202,8 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {}}+ $('#timeline-hide').click(function() { self.toggle(); });+};init();diff --git a/web/js/date/wv.date.timeline.pan.js b/web/js/date/wv.date.timeline.pan.jsindex 2f95d7d3c..1fc3f61a7 100644--- a/web/js/date/wv.date.timeline.pan.js+++ b/web/js/date/wv.date.timeline.pan.js@@ -45,7 +45,7 @@ wv.date.timeline.pan = wv.date.timeline.pan || function(models, config, ui) {}tl.axis.call(tl.xAxis);- tl.zoom.lvl.configure();+ tl.ticks.check();tl.ticks.boundary.update();tl.ticks.normal.update();diff --git a/web/js/date/wv.date.timeline.ticks.js b/web/js/date/wv.date.timeline.ticks.jsindex a87e407da..3ea41f614 100644--- a/web/js/date/wv.date.timeline.ticks.js+++ b/web/js/date/wv.date.timeline.ticks.js@@ -373,8 +373,59 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)}};- var init = function(){+ self.check = function(){+ var first, last, proto, end;+ tl.ticks.setAll();++ //Checks to see if all of the ticks fit onto the timeline space+ //and if so check to see that first and last major ticks are printed+ if(!tl.isCropped){+ first = tl.ticks.firstDate;+ last = tl.ticks.lastDate;+ proto = new Date(Date.UTC(first.getUTCFullYear(),+ first.getUTCMonth(),+ first.getUTCDate()-1));+ end = new Date(Date.UTC(last.getUTCFullYear(),+ last.getUTCMonth(),+ last.getUTCDate()+1));+ tl.ticks.compare(proto, end);+ }+ //set normal ticks+ tl.zoom.current.ticks.normal.all();++ //FIXME: Section below is terrible {+ //For determining needed boundary ticks+ if($(tl.ticks.normal.firstElem).is(':nth-child(2)')){+ first = tl.ticks.normal.firstDate;+ proto = new Date(Date.UTC(first.getUTCFullYear(),+ first.getUTCMonth(),+ 1));+ tl.ticks.add(proto, 'g.tick');+ }++ //FIXME: Passing from d3 to jQuery to d3 in order to check if its the last tick elem. WAT.+ if(d3.select($(tl.ticks.normal.lastElem)+ .next()[0]).classed('domain')){+ last = tl.ticks.normal.lastDate;+ end = new Date(Date.UTC(last.getUTCFullYear()+1,+ last.getUTCMonth()+1,+ 1));+ tl.ticks.add(end, 'path.domain');+ }+ // } End terrible++ tl.ticks.setAll();+ //update boundary ticks+ tl.zoom.current.ticks.boundary.all();++ tl.ticks.boundary.all.classed('tick-labeled',true);++ };+++ var init = function(){+};init();diff --git a/web/js/wv.main.js b/web/js/wv.main.jsindex 1461eadc0..27816142f 100644--- a/web/js/wv.main.js+++ b/web/js/wv.main.js@@ -159,7 +159,7 @@ $(function() {ui.timeline.ticks = wv.date.timeline.ticks(models, config, ui);ui.timeline.pick = wv.date.timeline.pick(models, config, ui);ui.timeline.pan = wv.date.timeline.pan(models, config, ui);- ui.timeline.zoom.lvl = wv.date.timeline.zoom.lvl(models, config, ui);+ ui.timeline.configure = wv.date.timeline.zoom.lvl(models, config, ui);ui.timeline.input = wv.date.timeline.input(models, config, ui);ui.dateLabel = wv.date.label(models);ui.dateWheels = wv.date.wheels(models, config);