Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Click actions cleanup

Taylor Gunnoeda9aaaa6cc5b
diff --git a/web/js/date/wv.date.timeline.data.js b/web/js/date/wv.date.timeline.data.js
index 36b8d2d2d..48e8581f5 100644
--- a/web/js/date/wv.date.timeline.data.js
+++ b/web/js/date/wv.date.timeline.data.js
@@ -37,7 +37,9 @@ wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {
.setUTCDate(wv.util.today()
.getUTCDate()+1));
};
-
+ self.set = function(){
+
+ };
var init = function(){
tl.axisZoom
.xExtent([self.start(),self.end()]);
diff --git a/web/js/date/wv.date.timeline.js b/web/js/date/wv.date.timeline.js
index 674f8b819..425659a80 100644
--- a/web/js/date/wv.date.timeline.js
+++ b/web/js/date/wv.date.timeline.js
@@ -21,6 +21,7 @@ wv.date = wv.date || {};
*/
wv.date.timeline = wv.date.timeline || function(models, config, ui) {
var self = {};
+ var model = models.date;
self.margin = {
top: 0,
diff --git a/web/js/date/wv.date.timeline.ticks.js b/web/js/date/wv.date.timeline.ticks.js
index ee9fd88bd..4fd347ece 100644
--- a/web/js/date/wv.date.timeline.ticks.js
+++ b/web/js/date/wv.date.timeline.ticks.js
@@ -28,6 +28,14 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
var self = {};
+ var cancelClick;
+ var clicked = true;
+ var notClickDelay = 200;
+
+ var notClick = function(){
+ clicked = false;
+ };
+
self.setAll = function(){
self.all = d3.selectAll('.x.axis>g.tick');
self.firstDate = self.all.data()[0];
@@ -37,9 +45,6 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
};
self.normal = {
- set: function(){
- self.normal.background = self.all.selectAll('rect.normaltick-background');
- },
setEnds: function(){
//FIXME: this is actually the ends of all ticks,
//not just the normal ticks.
@@ -72,8 +77,11 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
.attr("width",nWidth);
});
},
+ set: function(){
+ self.normal.background = self.all.selectAll('rect.normaltick-background');
+ },
bind: function(){
- console.log(self.normal.background);
+
self.normal.background
.on('mouseenter',function(){
d = d3.select(this.parentNode).data()[0];
@@ -87,7 +95,7 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
clearTimeout(cancelClick);
if(clicked){
d = d3.select(this.parentNode).data()[0];
- clickNormalTick.call(this,d);
+ self.normal.click.call(this,d);
}
clicked = true;
});
@@ -103,10 +111,6 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
};
self.boundary = {
- set: function(){
- self.boundary.background = self.boundary.all
- .selectAll('rect.boundarytick-foreground');
- },
update: function(){
},
@@ -168,7 +172,38 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
.attr('x',7)
.attr('style','text-anchor:left;');
+ },
+ set: function(){
+ self.boundary.background = self.boundary.all
+ .selectAll('rect.boundarytick-foreground');
+ },
+ bind: function(){
+ self.boundary.background
+ .on('mouseenter',function(){
+ d = d3.select(this.parentNode).data()[0];
+ self.boundary.hover.call(this,d);
+ })
+ .on('mouseleave',self.label.remove)
+ .on('mousedown',function(){
+ cancelClick = setTimeout(notClick,notClickDelay);
+ })
+ .on('mouseup',function(){
+ clearTimeout(cancelClick);
+ if(clicked){
+ d = d3.select(this.parentNode).data()[0];
+ clickBoundaryTick.call(this,d);
+ }
+ clicked = true;
+ });
+ },
+ hover: function(d){
+ var label = tl.zoom.current.ticks.boundary.label(d);
+ self.label.show.call(this,label);
+ },
+ click: function(d){
+
}
+
};
self.compare = function(proto, end){
if(self.firstDate > tl.data.start()){
@@ -205,7 +240,6 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
self.click = {
//clickNormalTick()
};
-
self.label = { //TODO: Update, this is just copied over
show: function(d){
var tick = this.parentNode;
@@ -262,68 +296,3 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
init();
return self;
};
-
-/**
- * Loaded after setting up wv.date.timeline.zoom
- *
- * @class wv.date.timeline.ticks
- */
-/*
-wv.date.timeline.ticks.update = function(models, config, ui, current) {
- var tl = ui.timeline;
-
- var self = {};
- console.log(current.ticks.normal);
- var update = function(){
- 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){
- var first = tl.ticks.firstDate;
- var last = tl.ticks.lastDate;
- var proto = new Date(Date.UTC(first.getUTCFullYear(),
- first.getUTCMonth(),
- first.getUTCDate()-1));
- var end = new Date(Date.UTC(last.getUTCFullYear(),
- last.getUTCMonth(),
- last.getUTCDate()+1));
- tl.ticks.compare(proto, end);
- }
- //set normal ticks
- current.ticks.normal.all();
-
- //FIXME: Section below is terrible {
- //For determining needed boundary ticks
- if($(tl.ticks.normal.firstElem).is(':nth-child(2)')){
- var first = tl.ticks.normal.firstDate;
- var 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')){
- var last = tl.ticks.normal.lastDate;
- var end = new Date(Date.UTC(last.getUTCFullYear()+1,
- last.getUTCMonth()+1,
- 1));
- tl.ticks.add(end, 'path.domain');
- }
- // } End terrible
-
- //update boundary ticks
- current.ticks.boundary.all();
- tl.ticks.boundary.all.classed('tick-labeled',true);
-
- tl.ticks.boundary.init();
- console.log('ttt');
-
- };
-
- update();
-};
-
-*/
diff --git a/web/js/date/wv.date.timeline.zoom.js b/web/js/date/wv.date.timeline.zoom.js
index cf61507d3..2918bc853 100644
--- a/web/js/date/wv.date.timeline.zoom.js
+++ b/web/js/date/wv.date.timeline.zoom.js
@@ -100,6 +100,7 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
wv.date.timeline.zoom.lvl = wv.date.timeline.zoom.lvl || 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){
@@ -185,6 +186,9 @@ wv.date.timeline.zoom.lvl = wv.date.timeline.zoom.lvl || function(models, config
tl.zoom.current.ticks.normal.clickDate = function(d){
return new Date(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate());
};
+ tl.zoom.current.ticks.boundary.label = function(d){
+ return new Date(d.getUTCFullYear(),d.getUTCMonth(),model.selected.getUTCDate());
+ };
self.update();
@@ -237,12 +241,16 @@ wv.date.timeline.zoom.lvl = wv.date.timeline.zoom.lvl || function(models, config
tl.ticks.boundary.init();
tl.ticks.normal.init();
- tl.ticks.normal.set();
+ 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();
};