Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Run semistandard --fix

Jo Sprague83d0e75e0f9d
diff --git a/test/data/wv.data-test.js b/test/data/wv.data-test.js
index eb959b456..6d48ab260 100644
--- a/test/data/wv.data-test.js
+++ b/test/data/wv.data-test.js
@@ -1,40 +1,39 @@
-buster.testCase("wv.data", (function() {
-
+buster.testCase('wv.data', (function () {
var self = {};
var config;
var errors;
- self.setUp = function() {
+ self.setUp = function () {
config = {
products: {
- "product1": {}
+ 'product1': {}
}
};
errors = [];
};
- self["Parses state, 1.1"] = function() {
+ self['Parses state, 1.1'] = function () {
var state = {
- dataDownload: "product1"
+ dataDownload: 'product1'
};
wv.data.parse(state, errors, config);
- buster.assert.equals(state.download, "product1");
+ buster.assert.equals(state.download, 'product1');
buster.assert.equals(errors.length, 0);
};
- self["Parses state, 1.2"] = function() {
+ self['Parses state, 1.2'] = function () {
var state = {
- download: "product1"
+ download: 'product1'
};
wv.data.parse(state, errors, config);
- buster.assert.equals(state.download, "product1");
+ buster.assert.equals(state.download, 'product1');
buster.assert.equals(errors.length, 0);
};
- self["Error on an invalid product"] = function() {
+ self['Error on an invalid product'] = function () {
var state = {
- download: "productX"
+ download: 'productX'
};
wv.data.parse(state, errors, config);
buster.refute(state.download);
@@ -42,5 +41,4 @@ buster.testCase("wv.data", (function() {
};
return self;
-
}()));
diff --git a/test/data/wv.data.model-test.js b/test/data/wv.data.model-test.js
index 6325780ef..36506f3a2 100644
--- a/test/data/wv.data.model-test.js
+++ b/test/data/wv.data.model-test.js
@@ -1,20 +1,20 @@
-buster.testCase("wv.data.model", {
+buster.testCase('wv.data.model', {
config: null,
models: null,
model: null,
errors: null,
- setUp: function() {
+ setUp: function () {
this.config = {
products: {
- "product1": {}
+ 'product1': {}
},
layers: {
- "layer1": {
- id: "layer1",
- product: "product1",
- group: "overlays",
+ 'layer1': {
+ id: 'layer1',
+ product: 'product1',
+ group: 'overlays',
projections: {
geographic: {}
}
@@ -24,56 +24,56 @@ buster.testCase("wv.data.model", {
this.models = {};
this.models.proj = wv.proj.model(this.config);
this.models.proj.selected = {
- id: "geographic"
+ id: 'geographic'
};
this.models.date = wv.date.model(this.config);
this.models.layers = wv.layers.model(this.models, this.config);
- this.models.layers.add("layer1");
+ this.models.layers.add('layer1');
this.model = wv.data.model(this.models, this.config);
this.errors = [];
},
- "Doesn't save state when not active": function() {
- this.model.selectProduct("product1");
+ "Doesn't save state when not active": function () {
+ this.model.selectProduct('product1');
var state = {};
this.model.save(state);
buster.refute(state.download);
},
- "Saves state": function() {
+ 'Saves state': function () {
this.model.active = true;
- this.model.selectedProduct = "product1";
+ this.model.selectedProduct = 'product1';
var state = {};
this.model.save(state);
- buster.assert.equals(state.download, "product1");
+ buster.assert.equals(state.download, 'product1');
},
- "Subscribed for startup event when data download in load state": function() {
+ 'Subscribed for startup event when data download in load state': function () {
this.models.wv = {
events: {
on: this.stub()
}
};
var state = {
- download: "product1"
+ download: 'product1'
};
this.model.load(state, this.errors);
buster.assert.equals(this.errors.length, 0);
- buster.assert.calledWith(this.models.wv.events.on, "startup");
+ buster.assert.calledWith(this.models.wv.events.on, 'startup');
},
- "Error product is in state when no active layer is found": function() {
+ 'Error product is in state when no active layer is found': function () {
this.models.wv = {
events: {
on: this.stub()
}
};
- this.models.layers.remove("layer1");
+ this.models.layers.remove('layer1');
var state = {
- download: "product1"
+ download: 'product1'
};
this.model.load(state, this.errors);
buster.assert.equals(this.errors.length, 1);
- buster.refute.calledWith(this.models.wv.events.on, "startup");
+ buster.refute.calledWith(this.models.wv.events.on, 'startup');
}
});
diff --git a/test/date/wv.date-test.js b/test/date/wv.date-test.js
index ab84fc09b..f5f9aa3ad 100644
--- a/test/date/wv.date-test.js
+++ b/test/date/wv.date-test.js
@@ -1,60 +1,59 @@
-buster.testCase("wv.date", function() {
-
+buster.testCase('wv.date', (function () {
var self = {};
var config, models, errors;
- self.setUp = function() {
+ self.setUp = function () {
config = fixtures.config();
models = fixtures.models(config);
errors = [];
};
- self.tearDown = function() {
+ self.tearDown = function () {
wv.util.resetNow();
};
- self["1.1: Parses valid date"] = function() {
+ self['1.1: Parses valid date'] = function () {
var d = new Date(Date.UTC(2013, 0, 5));
var state = {
- time: "2013-01-05"
+ time: '2013-01-05'
};
wv.date.parse(state, errors);
buster.assert.equals(state.t, d);
buster.assert.equals(errors.length, 0);
};
- self["1.2: Parses valid date"] = function() {
+ self['1.2: Parses valid date'] = function () {
var d = new Date(Date.UTC(2013, 0, 5));
var state = {
- t: "2013-01-05"
+ t: '2013-01-05'
};
wv.date.parse(state, errors);
buster.assert.equals(state.t, d);
buster.assert.equals(errors.length, 0);
};
- self["Error added if date is invalid"] = function() {
+ self['Error added if date is invalid'] = function () {
var state = {
- time: "X"
+ time: 'X'
};
wv.date.parse(state, errors);
buster.assert.equals(errors.length, 1);
buster.refute(state.time);
};
- self["Overrides now"] = function() {
+ self['Overrides now'] = function () {
var d = new Date(Date.UTC(2013, 0, 5));
var state = {
- now: "2013-01-05"
+ now: '2013-01-05'
};
wv.date.parse(state, errors);
buster.assert.equals(wv.util.now(), d);
buster.assert.equals(errors.length, 0);
};
- self["Error added if now is invalid"] = function() {
+ self['Error added if now is invalid'] = function () {
var state = {
- now: "X"
+ now: 'X'
};
var errors = [];
wv.date.parse(state, errors);
@@ -63,5 +62,4 @@ buster.testCase("wv.date", function() {
};
return self;
-
-}());
+}()));
diff --git a/test/date/wv.date.model-test.js b/test/date/wv.date.model-test.js
index c257d3bc0..2d148a732 100644
--- a/test/date/wv.date.model-test.js
+++ b/test/date/wv.date.model-test.js
@@ -1,23 +1,22 @@
-buster.testCase("wv.date.model", function() {
-
+buster.testCase('wv.date.model', (function () {
var self = {};
var config, models, now;
- self.setUp = function() {
+ self.setUp = function () {
now = new Date(Date.UTC(2013, 0, 15));
- this.stub(wv.util, "now")
+ this.stub(wv.util, 'now')
.returns(now);
config = fixtures.config();
models = fixtures.models(config);
};
- self["Initializes to today"] = function() {
+ self['Initializes to today'] = function () {
buster.assert.equals(models.date.selected.getUTCFullYear(), 2013);
buster.assert.equals(models.date.selected.getUTCMonth(), 0);
buster.assert.equals(models.date.selected.getUTCDate(), 15);
};
- self["Initializes with a specified date"] = function() {
+ self['Initializes with a specified date'] = function () {
var initial = new Date(Date.UTC(2013, 0, 5));
var date = wv.date.model(config, {
initial: initial
@@ -25,24 +24,24 @@ buster.testCase("wv.date.model", function() {
buster.assert.equals(date.selected, initial);
};
- self["Select new date"] = function() {
+ self['Select new date'] = function () {
var d = new Date(Date.UTC(2013, 0, 5));
var listener = this.stub();
- models.date.events.on("select", listener);
+ models.date.events.on('select', listener);
models.date.select(d);
buster.assert.equals(models.date.selected, d);
buster.assert.calledWith(listener, d);
};
- self["Saves state"] = function() {
+ self['Saves state'] = function () {
var d = new Date(Date.UTC(2013, 0, 5));
models.date.select(d);
var state = {};
models.date.save(state);
- buster.assert.equals(state.t, "2013-01-05");
+ buster.assert.equals(state.t, '2013-01-05');
};
- self["Loads state"] = function() {
+ self['Loads state'] = function () {
var date = new Date(Date.UTC(2013, 0, 5));
var state = {
t: date
@@ -51,12 +50,12 @@ buster.testCase("wv.date.model", function() {
buster.assert.equals(models.date.selected, date);
};
- self["Nothing selected when missing in state"] = function() {
+ self['Nothing selected when missing in state'] = function () {
models.date.load({});
buster.assert.equals(models.date.selected, now);
};
- self["Clears time to UTC midnight when selecting"] = function() {
+ self['Clears time to UTC midnight when selecting'] = function () {
var date = new Date(Date.UTC(2012, 1, 2, 3, 4, 5));
models.date.select(date);
var selected = models.date.selected;
@@ -69,5 +68,4 @@ buster.testCase("wv.date.model", function() {
};
return self;
-
-}());
+}()));
diff --git a/test/fixtures.js b/test/fixtures.js
index baa1d8d23..3a3300354 100644
--- a/test/fixtures.js
+++ b/test/fixtures.js
@@ -1,144 +1,143 @@
// FIXME: OL3
-proj4.defs("EPSG:3413", "+title=WGS 84 / NSIDC Sea Ice Polar Stereographic North +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
-proj4.defs("EPSG:3031", "+title=WGS 84 / Antarctic Polar Stereographic +proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs");
-
+proj4.defs('EPSG:3413', '+title=WGS 84 / NSIDC Sea Ice Polar Stereographic North +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
+proj4.defs('EPSG:3031', '+title=WGS 84 / Antarctic Polar Stereographic +proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs');
var fixtures = {
- red: "ff0000ff",
- light_red: "fff0f0ff",
- dark_red: "400000ff",
- green: "00ff00ff",
- yellow: "ffff00ff",
- blue: "0000ffff",
- light_blue: "f0f0ffff",
- dark_blue: "000040"
+ red: 'ff0000ff',
+ light_red: 'fff0f0ff',
+ dark_red: '400000ff',
+ green: '00ff00ff',
+ yellow: 'ffff00ff',
+ blue: '0000ffff',
+ light_blue: 'f0f0ffff',
+ dark_blue: '000040'
};
-fixtures.config = function() {
+fixtures.config = function () {
return {
defaults: {
- projection: "geographic"
+ projection: 'geographic'
},
projections: {
geographic: {
- id: "geographic",
+ id: 'geographic',
epsg: 4326,
- crs: "EPSG:4326",
+ crs: 'EPSG:4326',
maxExtent: [-180, -90, 180, 90]
},
arctic: {
- id: "arctic",
+ id: 'arctic',
epsg: 3413,
- crs: "EPSG:3413"
+ crs: 'EPSG:3413'
},
antarctic: {
- id: "antarctic",
+ id: 'antarctic',
epsg: 3031,
- crs: "EPSG:3031"
+ crs: 'EPSG:3031'
}
},
layers: {
- "terra-cr": {
- id: "terra-cr",
- group: "baselayers",
- period: "daily",
- startDate: "2000-01-01",
+ 'terra-cr': {
+ id: 'terra-cr',
+ group: 'baselayers',
+ period: 'daily',
+ startDate: '2000-01-01',
projections: {
geographic: {},
arctic: {},
antarctic: {}
}
},
- "aqua-cr": {
- id: "aqua-cr",
- group: "baselayers",
- period: "daily",
- startDate: "2002-01-01",
+ 'aqua-cr': {
+ id: 'aqua-cr',
+ group: 'baselayers',
+ period: 'daily',
+ startDate: '2002-01-01',
projections: {
geographic: {},
arctic: {},
antarctic: {}
}
},
- "mask": {
- id: "mask",
- group: "baselayers",
+ 'mask': {
+ id: 'mask',
+ group: 'baselayers',
projections: {
geographic: {},
arctic: {},
antarctic: {}
}
},
- "terra-aod": {
- id: "terra-aod",
- group: "overlays",
- period: "daily",
- startDate: "2000-01-01",
+ 'terra-aod': {
+ id: 'terra-aod',
+ group: 'overlays',
+ period: 'daily',
+ startDate: '2000-01-01',
projections: {
geographic: {}
},
palette: {
- id: "terra-aod"
+ id: 'terra-aod'
}
},
- "aqua-aod": {
- id: "aqua-aod",
- group: "overlays",
- period: "daily",
- startDate: "2002-01-01",
+ 'aqua-aod': {
+ id: 'aqua-aod',
+ group: 'overlays',
+ period: 'daily',
+ startDate: '2002-01-01',
projections: {
geographic: {}
},
palette: {
- id: "aqua-aod"
+ id: 'aqua-aod'
}
},
- "combo-aod": {
- id: "combo-aod",
- group: "overlays",
+ 'combo-aod': {
+ id: 'combo-aod',
+ group: 'overlays',
projections: {
geographic: {}
- },
+ }
}
},
palettes: {
rendered: {
- "terra-aod": {
- id: "terra-aod",
+ 'terra-aod': {
+ id: 'terra-aod',
maps: [{
entries: {
- type: "scale",
+ type: 'scale',
colors: [fixtures.green, fixtures.yellow, fixtures.red],
values: [0, 1, 2]
},
legend: {
- tooltips: ["0", "1", "2"],
- minLabel: "0",
- maxLabel: "2"
+ tooltips: ['0', '1', '2'],
+ minLabel: '0',
+ maxLabel: '2'
}
}]
},
- "aqua-aod": {
- id: "aqua-aod",
+ 'aqua-aod': {
+ id: 'aqua-aod',
maps: [{
entries: {
- type: "scale",
+ type: 'scale',
colors: [fixtures.green, fixtures.yellow, fixtures.red],
values: [0, 1, 2]
},
legend: {
- tooltips: ["0", "1", "2"],
- minLabel: "0",
- maxLabel: "2"
+ tooltips: ['0', '1', '2'],
+ minLabel: '0',
+ maxLabel: '2'
}
}]
}
},
custom: {
- "blue-1": {
+ 'blue-1': {
colors: [fixtures.light_blue, fixtures.blue, fixtures.dark_blue]
},
- "red-1": {
+ 'red-1': {
colors: [fixtures.light_red, fixtures.red, fixtures.dark_red]
}
}
@@ -146,7 +145,7 @@ fixtures.config = function() {
};
};
-fixtures.models = function(config) {
+fixtures.models = function (config) {
var models = {};
models.date = wv.date.model(config);
diff --git a/test/layers/wv.layers-test.js b/test/layers/wv.layers-test.js
index 50652405f..85527b9ca 100644
--- a/test/layers/wv.layers-test.js
+++ b/test/layers/wv.layers-test.js
@@ -1,230 +1,228 @@
/* jshint sub: true */
-buster.testCase("wv.layers", function() {
-
+buster.testCase('wv.layers', (function () {
var self = {};
var config;
var errors;
- self.setUp = function() {
+ self.setUp = function () {
config = fixtures.config();
errors = [];
};
- self["1.1: Parses only one baselayer"] = function() {
+ self['1.1: Parses only one baselayer'] = function () {
var state = {
- products: "baselayers,terra-cr"
+ products: 'baselayers,terra-cr'
};
wv.layers.parse(state, errors, config);
- buster.assert(state.l[0].id, "terra-cr");
+ buster.assert(state.l[0].id, 'terra-cr');
buster.assert.equals(errors.length, 0);
};
- self["1.1: Parses only one overlay"] = function() {
+ self['1.1: Parses only one overlay'] = function () {
var state = {
- products: "overlays,terra-aod"
+ products: 'overlays,terra-aod'
};
wv.layers.parse(state, errors, config);
- buster.assert.equals(state.l[0].id, "terra-aod");
+ buster.assert.equals(state.l[0].id, 'terra-aod');
buster.assert.equals(errors.length, 0);
};
- self["1.2: Parses only one layer"] = function() {
+ self['1.2: Parses only one layer'] = function () {
var state = {
- l: "terra-cr"
+ l: 'terra-cr'
};
wv.layers.parse(state, errors, config);
- buster.assert(state.l[0].id, "terra-cr");
+ buster.assert(state.l[0].id, 'terra-cr');
buster.assert.equals(errors.length, 0);
};
- self["1.1: Parses multiple layers"] = function() {
+ self['1.1: Parses multiple layers'] = function () {
var state = {
- products: "baselayers,terra-cr~overlays,terra-aod,aqua-aod"
+ products: 'baselayers,terra-cr~overlays,terra-aod,aqua-aod'
};
wv.layers.parse(state, errors, config);
buster.assert(_.find(state.l, {
- id: "terra-cr"
+ id: 'terra-cr'
}));
buster.assert(_.find(state.l, {
- id: "terra-aod"
+ id: 'terra-aod'
}));
buster.assert(_.find(state.l, {
- id: "aqua-aod"
+ id: 'aqua-aod'
}));
buster.assert.equals(errors.length, 0);
};
- self["1.2: Parses multiple layers"] = function() {
+ self['1.2: Parses multiple layers'] = function () {
var state = {
- l: "terra-cr,terra-aod,aqua-aod"
+ l: 'terra-cr,terra-aod,aqua-aod'
};
wv.layers.parse(state, errors, config);
buster.assert(_.find(state.l, {
- id: "terra-cr"
+ id: 'terra-cr'
}));
buster.assert(_.find(state.l, {
- id: "terra-aod"
+ id: 'terra-aod'
}));
buster.assert(_.find(state.l, {
- id: "aqua-aod"
+ id: 'aqua-aod'
}));
buster.assert.equals(errors.length, 0);
};
- self["1.1: Empty layer list"] = function() {
+ self['1.1: Empty layer list'] = function () {
var state = {
- products: "baselayers~overlays"
+ products: 'baselayers~overlays'
};
wv.layers.parse(state, errors, config);
buster.assert.equals(state.l.length, 0);
};
- self["1.2: Empty layer list"] = function() {
+ self['1.2: Empty layer list'] = function () {
var state = {
- l: ""
+ l: ''
};
wv.layers.parse(state, errors, config);
buster.assert.equals(state.l.length, 0);
};
- self["1.0: Supports old style period delimiters"] = function() {
+ self['1.0: Supports old style period delimiters'] = function () {
var state = {
- products: "baselayers.terra-cr~overlays.terra-aod.aqua-aod"
+ products: 'baselayers.terra-cr~overlays.terra-aod.aqua-aod'
};
wv.layers.parse(state, errors, config);
buster.assert(_.find(state.l, {
- id: "terra-cr"
+ id: 'terra-cr'
}));
buster.assert(_.find(state.l, {
- id: "terra-aod"
+ id: 'terra-aod'
}));
buster.assert(_.find(state.l, {
- id: "aqua-aod"
+ id: 'aqua-aod'
}));
buster.assert.equals(errors.length, 0);
};
- self["1.1: Skips invalid layers and records an error"] = function() {
+ self['1.1: Skips invalid layers and records an error'] = function () {
var state = {
- products: "baselayers,terra-cr~overlays,layerx,aqua-aod"
+ products: 'baselayers,terra-cr~overlays,layerx,aqua-aod'
};
wv.layers.parse(state, errors, config);
buster.assert(_.find(state.l, {
- id: "terra-cr"
+ id: 'terra-cr'
}));
buster.assert(_.find(state.l, {
- id: "aqua-aod"
+ id: 'aqua-aod'
}));
buster.assert.equals(errors.length, 1);
};
- self["1.2: Skips invalid layers and records an error"] = function() {
+ self['1.2: Skips invalid layers and records an error'] = function () {
var state = {
- products: "terra-cr,layerx,aqua-aod"
+ products: 'terra-cr,layerx,aqua-aod'
};
wv.layers.parse(state, errors, config);
buster.assert(_.find(state.l, {
- id: "terra-cr"
+ id: 'terra-cr'
}));
buster.assert(_.find(state.l, {
- id: "aqua-aod"
+ id: 'aqua-aod'
}));
buster.assert.equals(errors.length, 1);
};
- self["1.1: No layers and no error if no groups found"] = function() {
+ self['1.1: No layers and no error if no groups found'] = function () {
var state = {
- products: "layerx,layery"
+ products: 'layerx,layery'
};
wv.layers.parse(state, errors, config);
buster.assert.equals(state.l.length, 0);
};
- self["1.1: Hidden layers"] = function() {
+ self['1.1: Hidden layers'] = function () {
var state = {
- products: "baselayers,!terra-cr"
+ products: 'baselayers,!terra-cr'
};
wv.layers.parse(state, errors, config);
- buster.assert.equals(state.l[0].id, "terra-cr");
- buster.assert.equals(state.l[0].attributes[0].id, "hidden");
+ buster.assert.equals(state.l[0].id, 'terra-cr');
+ buster.assert.equals(state.l[0].attributes[0].id, 'hidden');
buster.assert.equals(errors.length, 0);
};
- self["1.2: Hidden layers"] = function() {
+ self['1.2: Hidden layers'] = function () {
var state = {
- l: "terra-cr(hidden)"
+ l: 'terra-cr(hidden)'
};
wv.layers.parse(state, errors, config);
- buster.assert.equals(state.l[0].id, "terra-cr");
- buster.assert.equals(state.l[0].attributes[0].id, "hidden");
+ buster.assert.equals(state.l[0].id, 'terra-cr');
+ buster.assert.equals(state.l[0].attributes[0].id, 'hidden');
buster.assert.equals(errors.length, 0);
};
- self["Opacity"] = function() {
+ self['Opacity'] = function () {
var state = {
- l: "terra-cr(opacity=0.5)"
+ l: 'terra-cr(opacity=0.5)'
};
wv.layers.parse(state, errors, config);
- buster.assert.equals(state.l[0].id, "terra-cr");
+ buster.assert.equals(state.l[0].id, 'terra-cr');
var attr = state.l[0].attributes[0];
- buster.assert.equals(attr.id, "opacity");
- buster.assert.equals(attr.value, "0.5");
+ buster.assert.equals(attr.id, 'opacity');
+ buster.assert.equals(attr.value, '0.5');
buster.assert.equals(errors.length, 0);
};
- self["Minimum threshold"] = function() {
+ self['Minimum threshold'] = function () {
var state = {
- l: "terra-cr(min=0.5)"
+ l: 'terra-cr(min=0.5)'
};
wv.layers.parse(state, errors, config);
- buster.assert.equals(state.l[0].id, "terra-cr");
+ buster.assert.equals(state.l[0].id, 'terra-cr');
var attr = state.l[0].attributes[0];
- buster.assert.equals(attr.id, "min");
- buster.assert.equals(attr.value, "0.5");
+ buster.assert.equals(attr.id, 'min');
+ buster.assert.equals(attr.value, '0.5');
buster.assert.equals(errors.length, 0);
};
- self["Maximum threshold"] = function() {
+ self['Maximum threshold'] = function () {
var state = {
- l: "terra-cr(max=0.5)"
+ l: 'terra-cr(max=0.5)'
};
wv.layers.parse(state, errors, config);
- buster.assert.equals(state.l[0].id, "terra-cr");
+ buster.assert.equals(state.l[0].id, 'terra-cr');
var attr = state.l[0].attributes[0];
- buster.assert.equals(attr.id, "max");
- buster.assert.equals(attr.value, "0.5");
+ buster.assert.equals(attr.id, 'max');
+ buster.assert.equals(attr.value, '0.5');
buster.assert.equals(errors.length, 0);
};
- self["1.1: Layer redirects"] = function() {
+ self['1.1: Layer redirects'] = function () {
config.redirects = {
layers: {
- "terra-cr": "aqua-cr"
+ 'terra-cr': 'aqua-cr'
}
};
var state = {
- products: "baselayers,terra-cr"
+ products: 'baselayers,terra-cr'
};
wv.layers.parse(state, errors, config);
- buster.assert.equals(state.l[0].id, "aqua-cr");
+ buster.assert.equals(state.l[0].id, 'aqua-cr');
buster.assert.equals(errors.length, 0);
};
- self["1.2: Layer redirects"] = function() {
+ self['1.2: Layer redirects'] = function () {
config.redirects = {
layers: {
- "terra-cr": "aqua-cr"
+ 'terra-cr': 'aqua-cr'
}
};
var state = {
- l: "terra-cr"
+ l: 'terra-cr'
};
wv.layers.parse(state, errors, config);
- buster.assert.equals(state.l[0].id, "aqua-cr");
+ buster.assert.equals(state.l[0].id, 'aqua-cr');
buster.assert.equals(errors.length, 0);
};
return self;
-
-}());
+}()));
diff --git a/test/layers/wv.layers.model-test.js b/test/layers/wv.layers.model-test.js
index 6851a9863..7b9dbcbaf 100644
--- a/test/layers/wv.layers.model-test.js
+++ b/test/layers/wv.layers.model-test.js
@@ -1,13 +1,12 @@
-buster.testCase("wv.layers.model", function() {
-
+buster.testCase('wv.layers.model', (function () {
var self = {};
var config, models, errors, listener, changeListener;
var today;
var l;
- self.setUp = function() {
+ self.setUp = function () {
today = new Date(Date.UTC(2014, 0, 1));
- this.stub(wv.util, "now")
+ this.stub(wv.util, 'now')
.returns(today);
config = fixtures.config();
models = fixtures.models(config);
@@ -17,360 +16,360 @@ buster.testCase("wv.layers.model", function() {
changeListener = this.stub();
};
- var stack = function() {
- l.add("terra-cr");
- l.add("aqua-cr");
- l.add("terra-aod");
- l.add("aqua-aod");
+ var stack = function () {
+ l.add('terra-cr');
+ l.add('aqua-cr');
+ l.add('terra-aod');
+ l.add('aqua-aod');
};
- self["Adds base layer"] = function() {
+ self['Adds base layer'] = function () {
stack();
- l.events.on("add", listener);
- l.events.on("change", changeListener);
- l.add("mask");
- buster.assert.equals(_.pluck(l.get(), "id"), ["mask", "aqua-cr", "terra-cr", "aqua-aod", "terra-aod"]);
+ l.events.on('add', listener);
+ l.events.on('change', changeListener);
+ l.add('mask');
+ buster.assert.equals(_.pluck(l.get(), 'id'), ['mask', 'aqua-cr', 'terra-cr', 'aqua-aod', 'terra-aod']);
buster.assert.calledWith(listener, config.layers.mask);
buster.assert.called(changeListener);
};
- self["Adds overlay"] = function() {
+ self['Adds overlay'] = function () {
stack();
- l.events.on("add", listener);
- l.events.on("change", changeListener);
- l.add("combo-aod");
- buster.assert.equals(_.pluck(l.get(), "id"), ["aqua-cr", "terra-cr", "combo-aod", "aqua-aod", "terra-aod"]);
- buster.assert.calledWith(listener, config.layers["combo-aod"]);
+ l.events.on('add', listener);
+ l.events.on('change', changeListener);
+ l.add('combo-aod');
+ buster.assert.equals(_.pluck(l.get(), 'id'), ['aqua-cr', 'terra-cr', 'combo-aod', 'aqua-aod', 'terra-aod']);
+ buster.assert.calledWith(listener, config.layers['combo-aod']);
buster.assert.called(changeListener);
};
- self["Doesn't add duplicate layer"] = function() {
+ self["Doesn't add duplicate layer"] = function () {
stack();
- l.events.on("add", listener);
- l.events.on("change", changeListener);
- l.add("terra-cr");
- buster.assert.equals(_.pluck(l.get(), "id"), ["aqua-cr", "terra-cr", "aqua-aod", "terra-aod"]);
+ l.events.on('add', listener);
+ l.events.on('change', changeListener);
+ l.add('terra-cr');
+ buster.assert.equals(_.pluck(l.get(), 'id'), ['aqua-cr', 'terra-cr', 'aqua-aod', 'terra-aod']);
buster.refute.called(listener);
buster.refute.called(changeListener);
};
- self["Removes base layer"] = function() {
+ self['Removes base layer'] = function () {
stack();
- l.events.on("remove", listener);
- l.events.on("change", changeListener);
- l.remove("terra-cr");
- buster.assert.equals(_.pluck(l.get(), "id"), ["aqua-cr", "aqua-aod", "terra-aod"]);
- buster.assert.calledWith(listener, config.layers["terra-cr"]);
+ l.events.on('remove', listener);
+ l.events.on('change', changeListener);
+ l.remove('terra-cr');
+ buster.assert.equals(_.pluck(l.get(), 'id'), ['aqua-cr', 'aqua-aod', 'terra-aod']);
+ buster.assert.calledWith(listener, config.layers['terra-cr']);
buster.assert.called(changeListener);
};
- self["Does nothing on removing a non-existant layer"] = function() {
+ self['Does nothing on removing a non-existant layer'] = function () {
stack();
- l.events.on("remove", listener);
- l.events.on("change", changeListener);
- l.remove("mask");
- buster.assert.equals(_.pluck(l.get(), "id"), ["aqua-cr", "terra-cr", "aqua-aod", "terra-aod"]);
+ l.events.on('remove', listener);
+ l.events.on('change', changeListener);
+ l.remove('mask');
+ buster.assert.equals(_.pluck(l.get(), 'id'), ['aqua-cr', 'terra-cr', 'aqua-aod', 'terra-aod']);
buster.refute.called(listener);
buster.refute.called(changeListener);
};
- self["Clears all layers"] = function() {
+ self['Clears all layers'] = function () {
stack();
- l.events.on("remove", listener);
- l.events.on("change", changeListener);
+ l.events.on('remove', listener);
+ l.events.on('change', changeListener);
l.clear();
- buster.assert.equals(_.pluck(l.get(), "id"), []);
+ buster.assert.equals(_.pluck(l.get(), 'id'), []);
buster.assert.called(listener);
buster.assert.called(changeListener);
};
- self["Clears layers for projection"] = function() {
+ self['Clears layers for projection'] = function () {
stack();
- models.proj.select("arctic");
+ models.proj.select('arctic');
l.clear();
- models.proj.select("geographic");
- buster.assert.equals(_.pluck(l.get(), "id"), ["aqua-aod", "terra-aod"]);
+ models.proj.select('geographic');
+ buster.assert.equals(_.pluck(l.get(), 'id'), ['aqua-aod', 'terra-aod']);
};
- self["Resets to default layers"] = function() {
+ self['Resets to default layers'] = function () {
config.defaults.startingLayers = [
{
- id: "terra-cr"
+ id: 'terra-cr'
},
{
- id: "terra-aod"
+ id: 'terra-aod'
}
];
models = fixtures.models(config);
stack();
l.reset();
- buster.assert.equals(_.pluck(l.get(), "id"), ["terra-cr", "terra-aod"]);
+ buster.assert.equals(_.pluck(l.get(), 'id'), ['terra-cr', 'terra-aod']);
};
- self["No date range for static products"] = function() {
- l.add("mask");
+ self['No date range for static products'] = function () {
+ l.add('mask');
buster.refute(l.dateRange());
};
- self["Date range for ongoing layers"] = function() {
+ self['Date range for ongoing layers'] = function () {
stack();
var range = l.dateRange();
buster.assert.equals(range.start, new Date(Date.UTC(2000, 0, 1)));
buster.assert.equals(range.start, new Date(Date.UTC(2000, 0, 1)));
};
- self["Date range for ended layers"] = function() {
+ self['Date range for ended layers'] = function () {
config.layers.end1 = {
- id: "end1",
- group: "overlays",
+ id: 'end1',
+ group: 'overlays',
projections: {
geographic: {}
},
- startDate: "1990-01-01",
- endDate: "2005-01-01",
+ startDate: '1990-01-01',
+ endDate: '2005-01-01',
inactive: true
};
config.layers.end2 = {
- id: "end1",
- group: "overlays",
+ id: 'end1',
+ group: 'overlays',
projections: {
geographic: {}
},
- startDate: "1992-01-01",
- endDate: "2007-01-01",
+ startDate: '1992-01-01',
+ endDate: '2007-01-01',
inactive: true
};
- l.add("end1");
- l.add("end2");
+ l.add('end1');
+ l.add('end2');
var range = l.dateRange();
buster.assert.equals(range.start, new Date(Date.UTC(1990, 0, 1)));
buster.assert.equals(range.end, new Date(Date.UTC(2007, 0, 1)));
};
- self["Gets layers in reverse"] = function() {
+ self['Gets layers in reverse'] = function () {
stack();
var list = l.get({
reverse: true
});
- buster.assert.equals(_.pluck(list, "id"), ["terra-cr", "aqua-cr", "terra-aod", "aqua-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['terra-cr', 'aqua-cr', 'terra-aod', 'aqua-aod']);
};
- self["Gets baselayers"] = function() {
+ self['Gets baselayers'] = function () {
stack();
var list = l.get({
- group: "baselayers"
+ group: 'baselayers'
});
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "terra-cr"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'terra-cr']);
};
- self["Gets overlays"] = function() {
+ self['Gets overlays'] = function () {
stack();
var list = l.get({
- group: "overlays"
+ group: 'overlays'
});
- buster.assert.equals(_.pluck(list, "id"), ["aqua-aod", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-aod', 'terra-aod']);
};
- self["Gets all groups"] = function() {
+ self['Gets all groups'] = function () {
stack();
var results = l.get({
- group: "all"
+ group: 'all'
});
- buster.assert.equals(results.baselayers[0].id, "aqua-cr");
- buster.assert.equals(results.baselayers[1].id, "terra-cr");
- buster.assert.equals(results.overlays[0].id, "aqua-aod");
- buster.assert.equals(results.overlays[1].id, "terra-aod");
+ buster.assert.equals(results.baselayers[0].id, 'aqua-cr');
+ buster.assert.equals(results.baselayers[1].id, 'terra-cr');
+ buster.assert.equals(results.overlays[0].id, 'aqua-aod');
+ buster.assert.equals(results.overlays[1].id, 'terra-aod');
};
- self["Gets layers for other projection"] = function() {
+ self['Gets layers for other projection'] = function () {
stack();
var list = l.get({
- proj: "arctic"
+ proj: 'arctic'
});
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "terra-cr"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'terra-cr']);
};
- self["Obscured base layer is not renderable"] = function() {
+ self['Obscured base layer is not renderable'] = function () {
stack();
var list = l.get({
renderable: true
});
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "aqua-aod", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'aqua-aod', 'terra-aod']);
};
- self["Base layer is not obscured by a hidden layer"] = function() {
+ self['Base layer is not obscured by a hidden layer'] = function () {
stack();
- l.setVisibility("aqua-cr", false);
+ l.setVisibility('aqua-cr', false);
var list = l.get({
renderable: true
});
- buster.assert.equals(_.pluck(list, "id"), ["terra-cr", "aqua-aod", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['terra-cr', 'aqua-aod', 'terra-aod']);
};
- self["Layer with zero opacity is not renderable"] = function() {
+ self['Layer with zero opacity is not renderable'] = function () {
stack();
- l.setOpacity("aqua-aod", 0);
+ l.setOpacity('aqua-aod', 0);
var list = l.get({
renderable: true
});
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'terra-aod']);
};
- self["Layer outside date range is not renderable"] = function() {
+ self['Layer outside date range is not renderable'] = function () {
stack();
models.date.select(new Date(Date.UTC(2001, 0, 1)));
var list = l.get({
renderable: true
});
- buster.assert.equals(_.pluck(list, "id"), ["terra-cr", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['terra-cr', 'terra-aod']);
};
- self["All layers are visible"] = function() {
+ self['All layers are visible'] = function () {
stack();
var list = l.get({
visible: true
});
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "terra-cr", "aqua-aod", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'terra-cr', 'aqua-aod', 'terra-aod']);
};
- self["Only visible layers"] = function() {
+ self['Only visible layers'] = function () {
stack();
- l.setVisibility("terra-cr", false);
- l.setVisibility("terra-aod", false);
+ l.setVisibility('terra-cr', false);
+ l.setVisibility('terra-aod', false);
var list = l.get({
visible: true
});
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "aqua-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'aqua-aod']);
};
- self["Replace base layer"] = function() {
+ self['Replace base layer'] = function () {
stack();
- l.events.on("update", listener);
- l.events.on("change", changeListener);
- l.replace("aqua-cr", "mask");
+ l.events.on('update', listener);
+ l.events.on('change', changeListener);
+ l.replace('aqua-cr', 'mask');
var list = l.get();
- buster.assert.equals(_.pluck(list, "id"), ["mask", "terra-cr", "aqua-aod", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['mask', 'terra-cr', 'aqua-aod', 'terra-aod']);
buster.assert.called(listener);
buster.assert.called(changeListener);
};
- self["Replace overlay"] = function() {
+ self['Replace overlay'] = function () {
stack();
- l.events.on("update", listener);
- l.events.on("change", changeListener);
- l.replace("aqua-aod", "combo-aod");
+ l.events.on('update', listener);
+ l.events.on('change', changeListener);
+ l.replace('aqua-aod', 'combo-aod');
var list = l.get();
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "terra-cr", "combo-aod", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'terra-cr', 'combo-aod', 'terra-aod']);
buster.assert.called(listener);
buster.assert.called(changeListener);
};
- self["Push base layer to bottom"] = function() {
+ self['Push base layer to bottom'] = function () {
stack();
- l.events.on("update", listener);
- l.events.on("change", changeListener);
- l.pushToBottom("aqua-cr");
+ l.events.on('update', listener);
+ l.events.on('change', changeListener);
+ l.pushToBottom('aqua-cr');
var list = l.get();
- buster.assert.equals(_.pluck(list, "id"), ["terra-cr", "aqua-cr", "aqua-aod", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['terra-cr', 'aqua-cr', 'aqua-aod', 'terra-aod']);
buster.assert.called(listener);
buster.assert.called(changeListener);
};
- self["Push overlay to bottom"] = function() {
+ self['Push overlay to bottom'] = function () {
stack();
- l.events.on("update", listener);
- l.events.on("change", changeListener);
- l.pushToBottom("aqua-aod");
+ l.events.on('update', listener);
+ l.events.on('change', changeListener);
+ l.pushToBottom('aqua-aod');
var list = l.get();
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "terra-cr", "terra-aod", "aqua-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'terra-cr', 'terra-aod', 'aqua-aod']);
buster.assert.called(listener);
buster.assert.called(changeListener);
};
- self["Move base layer before"] = function() {
+ self['Move base layer before'] = function () {
stack();
- l.events.on("update", listener);
- l.events.on("change", changeListener);
- l.moveBefore("terra-cr", "aqua-cr");
+ l.events.on('update', listener);
+ l.events.on('change', changeListener);
+ l.moveBefore('terra-cr', 'aqua-cr');
var list = l.get();
- buster.assert.equals(_.pluck(list, "id"), ["terra-cr", "aqua-cr", "aqua-aod", "terra-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['terra-cr', 'aqua-cr', 'aqua-aod', 'terra-aod']);
buster.assert.called(listener);
buster.assert.called(changeListener);
};
- self["Move overlay before"] = function() {
+ self['Move overlay before'] = function () {
stack();
- l.events.on("update", listener);
- l.events.on("change", changeListener);
- l.moveBefore("terra-aod", "aqua-aod");
+ l.events.on('update', listener);
+ l.events.on('change', changeListener);
+ l.moveBefore('terra-aod', 'aqua-aod');
var list = l.get();
- buster.assert.equals(_.pluck(list, "id"), ["aqua-cr", "terra-cr", "terra-aod", "aqua-aod"]);
+ buster.assert.equals(_.pluck(list, 'id'), ['aqua-cr', 'terra-cr', 'terra-aod', 'aqua-aod']);
buster.assert.called(listener);
buster.assert.called(changeListener);
};
- self["Saves state"] = function() {
- l.add("terra-cr");
- l.add("terra-aod");
+ self['Saves state'] = function () {
+ l.add('terra-cr');
+ l.add('terra-aod');
var state = {};
l.save(state);
buster.assert.equals(state.l, [
{
- id: "terra-cr",
+ id: 'terra-cr',
attributes: []
},
{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: []
}
]);
};
- self["Saves state with hidden layer"] = function() {
- l.add("terra-cr");
- l.setVisibility("terra-cr", false);
+ self['Saves state with hidden layer'] = function () {
+ l.add('terra-cr');
+ l.setVisibility('terra-cr', false);
var state = {};
l.save(state);
buster.assert.equals(state.l, [
{
- id: "terra-cr",
+ id: 'terra-cr',
attributes: [{
- id: "hidden"
+ id: 'hidden'
}]
}
]);
};
- self["Loads state"] = function() {
+ self['Loads state'] = function () {
var state = {
l: [
{
- id: "terra-cr",
+ id: 'terra-cr',
attributes: []
},
{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: []
}
]
};
l.load(state, errors);
buster.assert(_.find(l.active, {
- id: "terra-aod"
+ id: 'terra-aod'
}));
buster.assert(_.find(l.active, {
- id: "terra-cr"
+ id: 'terra-cr'
}));
buster.assert.equals(errors.length, 0);
};
- self["Loads state with hidden layer"] = function() {
+ self['Loads state with hidden layer'] = function () {
var state = {
l: [
{
- id: "terra-cr",
+ id: 'terra-cr',
attributes: [{
- id: "hidden",
+ id: 'hidden',
value: true
}]
}
@@ -378,20 +377,20 @@ buster.testCase("wv.layers.model", function() {
};
l.load(state, errors);
var def = _.find(models.layers.active, {
- id: "terra-cr"
+ id: 'terra-cr'
});
buster.assert(def);
buster.refute(def.visible);
buster.assert.equals(errors.length, 0);
};
- self["Loads state with opacity"] = function() {
+ self['Loads state with opacity'] = function () {
var state = {
l: [
{
- id: "terra-cr",
+ id: 'terra-cr',
attributes: [{
- id: "opacity",
+ id: 'opacity',
value: 0.12
}]
}
@@ -399,19 +398,19 @@ buster.testCase("wv.layers.model", function() {
};
l.load(state, errors);
var def = _.find(models.layers.active, {
- id: "terra-cr"
+ id: 'terra-cr'
});
buster.assert(0.12, def.opacity);
buster.assert.equals(errors.length, 0);
};
- self["Loads state, opacity clamped at 1"] = function() {
+ self['Loads state, opacity clamped at 1'] = function () {
var state = {
l: [
{
- id: "terra-cr",
+ id: 'terra-cr',
attributes: [{
- id: "opacity",
+ id: 'opacity',
value: 5
}]
}
@@ -419,19 +418,19 @@ buster.testCase("wv.layers.model", function() {
};
l.load(state, errors);
var def = _.find(models.layers.active, {
- id: "terra-cr"
+ id: 'terra-cr'
});
buster.assert.equals(1, def.opacity);
buster.assert.equals(errors.length, 0);
};
- self["Loads state, opacity clamped at 0"] = function() {
+ self['Loads state, opacity clamped at 0'] = function () {
var state = {
l: [
{
- id: "terra-cr",
+ id: 'terra-cr',
attributes: [{
- id: "opacity",
+ id: 'opacity',
value: -5
}]
}
@@ -439,37 +438,36 @@ buster.testCase("wv.layers.model", function() {
};
l.load(state, errors);
var def = _.find(models.layers.active, {
- id: "terra-cr"
+ id: 'terra-cr'
});
buster.assert.equals(0, def.opacity);
buster.assert.equals(errors.length, 0);
};
- self["Starts with default layers when no permalink"] = function() {
+ self['Starts with default layers when no permalink'] = function () {
config.defaults.startingLayers = [
{
- id: "terra-cr"
+ id: 'terra-cr'
}
];
l = wv.layers.model(models, config);
l.load({});
- buster.assert(l.active[0].id, "terra-cr");
+ buster.assert(l.active[0].id, 'terra-cr');
buster.assert(l.active[0].visible);
};
- self["Starts with a default hidden layer"] = function() {
+ self['Starts with a default hidden layer'] = function () {
config.defaults.startingLayers = [
{
- id: "terra-cr",
+ id: 'terra-cr',
hidden: true
}
];
l = wv.layers.model(models, config);
l.load({});
- buster.assert(l.active[0].id, "terra-cr");
+ buster.assert(l.active[0].id, 'terra-cr');
buster.refute(l.active[0].visible);
};
return self;
-
-}());
+}()));
diff --git a/test/layers/wv.layers.model.dateRange-test.js b/test/layers/wv.layers.model.dateRange-test.js
index 5be218b8a..04f1137d7 100644
--- a/test/layers/wv.layers.model.dateRange-test.js
+++ b/test/layers/wv.layers.model.dateRange-test.js
@@ -1,65 +1,65 @@
-buster.testCase("wv.layers.model.dateRange", {
+buster.testCase('wv.layers.model.dateRange', {
config: null,
models: null,
model: null,
- setUp: function() {
+ setUp: function () {
this.models = {};
this.models.proj = wv.proj.model({
defaults: {
- projection: "geographic"
+ projection: 'geographic'
},
projections: {
geographic: {
- id: "geographic"
+ id: 'geographic'
}
}
});
this.models.layers = wv.layers.model(this.models, {
layers: {
- "historical_1": {
- id: "historical_1",
- startDate: "2000-01-01",
- endDate: "2002-01-01",
- group: "baselayers",
+ 'historical_1': {
+ id: 'historical_1',
+ startDate: '2000-01-01',
+ endDate: '2002-01-01',
+ group: 'baselayers',
projections: {
geographic: {}
}
},
- "historical_2": {
- id: "historical_2",
- startDate: "2001-01-01",
- endDate: "2003-01-01",
- group: "overlays",
+ 'historical_2': {
+ id: 'historical_2',
+ startDate: '2001-01-01',
+ endDate: '2003-01-01',
+ group: 'overlays',
projections: {
geographic: {}
}
},
- "active_1": {
- id: "active_1",
- startDate: "2005-01-01",
- group: "overlays",
+ 'active_1': {
+ id: 'active_1',
+ startDate: '2005-01-01',
+ group: 'overlays',
projections: {
geographic: {}
}
},
- "static": {
- id: "static",
- group: "overlays",
+ 'static': {
+ id: 'static',
+ group: 'overlays',
projections: {
geographic: {}
}
- },
+ }
}
});
this.model = this.models.layers;
- this.stub(wv.util, "now")
+ this.stub(wv.util, 'now')
.returns(new Date(Date.UTC(2010, 0, 1)));
},
- "Date range with one layer": function() {
- this.model.add("historical_1");
+ 'Date range with one layer': function () {
+ this.model.add('historical_1');
var range = this.model.dateRange();
buster.assert.equals(range.start.getTime(),
new Date(Date.UTC(2000, 0, 1))
@@ -69,9 +69,9 @@ buster.testCase("wv.layers.model.dateRange", {
.getTime());
},
- "Date range with two layers": function() {
- this.model.add("historical_1");
- this.model.add("historical_2");
+ 'Date range with two layers': function () {
+ this.model.add('historical_1');
+ this.model.add('historical_2');
var range = this.model.dateRange();
buster.assert.equals(range.start.getTime(),
new Date(Date.UTC(2000, 0, 1))
@@ -81,8 +81,8 @@ buster.testCase("wv.layers.model.dateRange", {
.getTime());
},
- "End of date range is today if no end date": function() {
- this.model.add("active_1");
+ 'End of date range is today if no end date': function () {
+ this.model.add('active_1');
var range = this.model.dateRange();
buster.assert.equals(range.start.getTime(),
new Date(Date.UTC(2005, 0, 1))
@@ -92,8 +92,8 @@ buster.testCase("wv.layers.model.dateRange", {
.getTime());
},
- "No date range with static": function() {
- this.model.add("static");
+ 'No date range with static': function () {
+ this.model.add('static');
buster.refute(this.model.dateRange());
}
diff --git a/test/link/wv.link.model-test.js b/test/link/wv.link.model-test.js
index f9df2c530..286ca5e3b 100644
--- a/test/link/wv.link.model-test.js
+++ b/test/link/wv.link.model-test.js
@@ -1,80 +1,80 @@
-buster.testCase("wv.link.model", {
+buster.testCase('wv.link.model', {
- "Query string from registered components": function() {
+ 'Query string from registered components': function () {
var c1 = {
- save: function(state) {
+ save: function (state) {
state.foo = 1;
}
};
var c2 = {
- save: function(state) {
+ save: function (state) {
state.bar = 2;
}
};
var model = wv.link.model();
model.register(c1)
.register(c2);
- buster.assert.equals(model.toQueryString(), "foo=1&bar=2");
+ buster.assert.equals(model.toQueryString(), 'foo=1&bar=2');
},
- "Values encoded": function() {
+ 'Values encoded': function () {
var c1 = {
- save: function(state) {
- state.foo = "?";
+ save: function (state) {
+ state.foo = '?';
}
};
var model = wv.link.model();
model.register(c1);
- buster.assert.equals(model.toQueryString(), "foo=%3F");
+ buster.assert.equals(model.toQueryString(), 'foo=%3F');
},
- "Exceptions not encoded": function() {
+ 'Exceptions not encoded': function () {
var c1 = {
- save: function(state) {
- state.foo = ",";
+ save: function (state) {
+ state.foo = ',';
}
};
var model = wv.link.model();
model.register(c1);
- buster.assert.equals(model.toQueryString(), "foo=,");
+ buster.assert.equals(model.toQueryString(), 'foo=,');
},
- "Shorten calls cgi script": function(done) {
+ 'Shorten calls cgi script': function (done) {
var link = wv.link.model();
- var call = this.stub(jQuery, "getJSON");
+ var call = this.stub(jQuery, 'getJSON');
call.returns(jQuery.Deferred()
.resolve({
data: {
- url: "shorten"
+ url: 'shorten'
}
}));
- var promise = link.shorten("foo");
- promise.done(function(result) {
- buster.assert.calledWith(call, "service/link/shorten.cgi?url=foo");
- buster.assert.equals(result.data.url, "shorten");
+ var promise = link.shorten('foo');
+ promise.done(function (result) {
+ buster.assert.calledWith(call, 'service/link/shorten.cgi?url=foo');
+ buster.assert.equals(result.data.url, 'shorten');
done();
});
},
- "Repeated call cached": function(done) {
+ 'Repeated call cached': function (done) {
var link = wv.link.model();
- var call = this.stub(jQuery, "getJSON");
+ var call = this.stub(jQuery, 'getJSON');
call.returns(jQuery.Deferred()
.resolve({
data: {
- url: "shorten"
+ url: 'shorten'
}
}));
- link.shorten("foo");
- var promise = link.shorten("foo");
- promise.done(function(result) {
- buster.assert.equals(result.data.url, "shorten");
+ link.shorten('foo');
+ var promise = link.shorten('foo');
+ promise.done(function (result) {
+ buster.assert.equals(result.data.url, 'shorten');
buster.assert.calledOnce(call);
done();
});
},
- "Update on any event": function() {
+ 'Update on any event': function () {
var c1 = {
events: wv.util.events()
};
@@ -85,9 +85,9 @@ buster.testCase("wv.link.model", {
link.register(c1);
link.register(c2);
var call = this.stub();
- link.events.on("update", call);
- c1.events.trigger("event");
- c2.events.trigger("event");
+ link.events.on('update', call);
+ c1.events.trigger('event');
+ c2.events.trigger('event');
buster.assert.calledTwice(call);
}
diff --git a/test/map/wv.map-test.js b/test/map/wv.map-test.js
index a1e747c29..e4225301c 100644
--- a/test/map/wv.map-test.js
+++ b/test/map/wv.map-test.js
@@ -1,32 +1,32 @@
-buster.testCase("wv.map", {
+buster.testCase('wv.map', {
errors: null,
- setUp: function() {
+ setUp: function () {
this.errors = [];
},
- "1.1: Parses state": function() {
+ '1.1: Parses state': function () {
var state = {
- map: "0,1,2,3"
+ map: '0,1,2,3'
};
wv.map.parse(state, this.errors);
buster.assert.equals(state.v, [0, 1, 2, 3]);
buster.assert.equals(this.errors.length, 0);
},
- "1.2: Parses state": function() {
+ '1.2: Parses state': function () {
var state = {
- v: "0,1,2,3"
+ v: '0,1,2,3'
};
wv.map.parse(state, this.errors);
buster.assert.equals(state.v, [0, 1, 2, 3]);
buster.assert.equals(this.errors.length, 0);
},
- "Error on invalid extent": function() {
+ 'Error on invalid extent': function () {
var state = {
- map: "0,1,x,3"
+ map: '0,1,x,3'
};
wv.map.parse(state, this.errors);
buster.refute(state.map);
diff --git a/test/map/wv.map.model-test.js b/test/map/wv.map.model-test.js
index 117a08401..ae917f7cb 100644
--- a/test/map/wv.map.model-test.js
+++ b/test/map/wv.map.model-test.js
@@ -1,10 +1,9 @@
-buster.testCase("wv.map.model", function() {
-
+buster.testCase('wv.map.model', (function () {
var self = {};
var config;
var errors;
- self.setUp = function() {
+ self.setUp = function () {
config = fixtures.config();
models = fixtures.models(config);
errors = [];
@@ -24,5 +23,4 @@ buster.testCase("wv.map.model", function() {
};
*/
return self;
-
-}());
+}()));
diff --git a/test/map/wv.map.runningdata-test.js b/test/map/wv.map.runningdata-test.js
index 49b83e23e..437444236 100644
--- a/test/map/wv.map.runningdata-test.js
+++ b/test/map/wv.map.runningdata-test.js
@@ -1,8 +1,8 @@
-buster.testCase("wv.map.runningdata", {
+buster.testCase('wv.map.runningdata', {
models: null,
errors: null,
- setUp: function() {
+ setUp: function () {
models = {
layers: {
events: {
@@ -12,16 +12,16 @@ buster.testCase("wv.map.runningdata", {
};
this.runner = new wv.map.runningdata(models);
},
- "1.0: Get Label from Palette object": function() {
+ '1.0: Get Label from Palette object': function () {
var scale = {
- colors: ["fbd1fbff", "a605b0ff", "1e00eaff"],
- tooltips: ["40 – 40.4", "40.4 – 50", "50 – 60"],
+ colors: ['fbd1fbff', 'a605b0ff', '1e00eaff'],
+ tooltips: ['40 – 40.4', '40.4 – 50', '50 – 60'],
units: 'ppb'
};
- var value = this.runner.getDataLabel(scale, "1e00eaff");
- buster.assert.equals(value.label, "50 – 60 ppb");
+ var value = this.runner.getDataLabel(scale, '1e00eaff');
+ buster.assert.equals(value.label, '50 – 60 ppb');
},
- "1.2: Removes layers that are no longer present": function() {
+ '1.2: Removes layers that are no longer present': function () {
var arra1 = ['layer1', 'layer2', 'layer3'];
var arra2 = ['layer1', 'layer2'];
diff --git a/test/palettes/wv.palettes-test.js b/test/palettes/wv.palettes-test.js
index 4a2767d8b..948dca7eb 100644
--- a/test/palettes/wv.palettes-test.js
+++ b/test/palettes/wv.palettes-test.js
@@ -1,61 +1,60 @@
-buster.testCase("wv.palettes", function() {
-
+buster.testCase('wv.palettes', (function () {
var self = {};
var config, models, errors;
- self.setUp = function() {
+ self.setUp = function () {
config = fixtures.config();
models = fixtures.models(config);
errors = [];
};
- self["Parses palette for valid layer"] = function() {
+ self['Parses palette for valid layer'] = function () {
var state = {
- l: "terra-aod(palette=blue-1)"
+ l: 'terra-aod(palette=blue-1)'
};
wv.layers.parse(state, errors, config);
var attr = state.l[0].attributes[0];
- buster.assert.equals(attr.id, "palette");
- buster.assert.equals(attr.value, "blue-1");
+ buster.assert.equals(attr.id, 'palette');
+ buster.assert.equals(attr.value, 'blue-1');
buster.assert.equals(errors.length, 0);
};
- self["1.1: Parses palette for valid layer"] = function() {
+ self['1.1: Parses palette for valid layer'] = function () {
var state = {
- l: "terra-aod",
- palettes: "terra-aod,blue-1"
+ l: 'terra-aod',
+ palettes: 'terra-aod,blue-1'
};
wv.layers.parse(state, errors, config);
wv.palettes.parse(state, errors, config);
var attr = state.l[0].attributes[0];
- buster.assert.equals(attr.id, "palette");
- buster.assert.equals(attr.value, "blue-1");
+ buster.assert.equals(attr.id, 'palette');
+ buster.assert.equals(attr.value, 'blue-1');
buster.assert.equals(errors.length, 0);
};
- self["1.1: Parses palette for two valid layers"] = function() {
+ self['1.1: Parses palette for two valid layers'] = function () {
var state = {
- l: "terra-aod,aqua-aod",
- palettes: "terra-aod,blue-1~aqua-aod,red-1"
+ l: 'terra-aod,aqua-aod',
+ palettes: 'terra-aod,blue-1~aqua-aod,red-1'
};
wv.layers.parse(state, errors, config);
wv.palettes.parse(state, errors, config);
var attr1 = state.l[0].attributes[0];
- buster.assert.equals(attr1.id, "palette");
- buster.assert.equals(attr1.value, "blue-1");
+ buster.assert.equals(attr1.id, 'palette');
+ buster.assert.equals(attr1.value, 'blue-1');
var attr2 = state.l[1].attributes[0];
- buster.assert.equals(attr2.id, "palette");
- buster.assert.equals(attr2.value, "red-1");
+ buster.assert.equals(attr2.id, 'palette');
+ buster.assert.equals(attr2.value, 'red-1');
buster.assert.equals(errors.length, 0);
};
- self["1.1: Error if palette assigned to a layer that is not active"] = function() {
+ self['1.1: Error if palette assigned to a layer that is not active'] = function () {
var state = {
- l: "terra-aod",
- palettes: "aqua-aod,red-1"
+ l: 'terra-aod',
+ palettes: 'aqua-aod,red-1'
};
wv.layers.parse(state, errors, config);
wv.palettes.parse(state, errors, config);
@@ -63,5 +62,4 @@ buster.testCase("wv.palettes", function() {
};
return self;
-
-}());
+}()));
diff --git a/test/palettes/wv.palettes.model-test.js b/test/palettes/wv.palettes.model-test.js
index 00aa1eb10..7bc51db4e 100644
--- a/test/palettes/wv.palettes.model-test.js
+++ b/test/palettes/wv.palettes.model-test.js
@@ -1,54 +1,52 @@
-buster.testCase("wv.palettes.model", function() {
-
+buster.testCase('wv.palettes.model', (function () {
var self = {};
var config, models;
- self.setUp = function() {
+ self.setUp = function () {
config = fixtures.config();
models = fixtures.models(config);
- this.stub($, "getJSON");
+ this.stub($, 'getJSON');
};
- self["Set a custom palette"] = function(done) {
- models.palettes.events.on("set-custom", function(layerId) {
+ self['Set a custom palette'] = function (done) {
+ models.palettes.events.on('set-custom', function (layerId) {
var palette = models.palettes.get(layerId);
var colors = palette.legend.colors;
var labels = palette.legend.tooltips;
buster.assert.equals(colors[0], fixtures.light_blue);
buster.assert.equals(colors[1], fixtures.blue);
buster.assert.equals(colors[2], fixtures.dark_blue);
- buster.assert.equals(labels[0], "0");
- buster.assert.equals(labels[1], "1");
- buster.assert.equals(labels[2], "2");
+ buster.assert.equals(labels[0], '0');
+ buster.assert.equals(labels[1], '1');
+ buster.assert.equals(labels[2], '2');
done();
});
- models.layers.add("terra-aod");
- models.palettes.setCustom("terra-aod", "blue-1");
+ models.layers.add('terra-aod');
+ models.palettes.setCustom('terra-aod', 'blue-1');
};
- self["Palettte compresses color range"] = function() {
- config.palettes.custom["blue-1"].colors = [
- "1", "2", "3", "4", "5", "6"
+ self['Palettte compresses color range'] = function () {
+ config.palettes.custom['blue-1'].colors = [
+ '1', '2', '3', '4', '5', '6'
];
models = fixtures.models(config);
- models.layers.add("terra-aod");
- models.palettes.setCustom("terra-aod", "blue-1");
- var palette = models.palettes.get("terra-aod");
- buster.assert.equals(palette.legend.colors[0], "1");
- buster.assert.equals(palette.legend.colors[1], "3");
- buster.assert.equals(palette.legend.colors[2], "5");
+ models.layers.add('terra-aod');
+ models.palettes.setCustom('terra-aod', 'blue-1');
+ var palette = models.palettes.get('terra-aod');
+ buster.assert.equals(palette.legend.colors[0], '1');
+ buster.assert.equals(palette.legend.colors[1], '3');
+ buster.assert.equals(palette.legend.colors[2], '5');
};
- self["Palette expands color range"] = function() {
-
- config.palettes.rendered["terra-aod"].maps[0].entries.colors = [
- "1", "2", "3", "4", "5", "6"
+ self['Palette expands color range'] = function () {
+ config.palettes.rendered['terra-aod'].maps[0].entries.colors = [
+ '1', '2', '3', '4', '5', '6'
];
models = fixtures.models(config);
- models.layers.add("terra-aod");
- models.palettes.setCustom("terra-aod", "blue-1");
- var palette = models.palettes.get("terra-aod");
+ models.layers.add('terra-aod');
+ models.palettes.setCustom('terra-aod', 'blue-1');
+ var palette = models.palettes.get('terra-aod');
var colors = palette.legend.colors;
buster.assert.equals(colors[0], fixtures.light_blue);
@@ -59,153 +57,153 @@ buster.testCase("wv.palettes.model", function() {
buster.assert.equals(colors[5], fixtures.dark_blue);
};
- self["Exception setting a custom palette when no layer exists"] = function() {
- buster.assert.exception(function() {
- models.palettes.setCustom("no-layer", "blue-1");
+ self['Exception setting a custom palette when no layer exists'] = function () {
+ buster.assert.exception(function () {
+ models.palettes.setCustom('no-layer', 'blue-1');
});
};
- self["Exception setting an invalid custom palette"] = function() {
- buster.assert.exception(function() {
- models.palettes.setCustom("terra-aod", "no-palette");
+ self['Exception setting an invalid custom palette'] = function () {
+ buster.assert.exception(function () {
+ models.palettes.setCustom('terra-aod', 'no-palette');
});
};
- self["Exception setting a custom palette on a imagery layer"] = function() {
- buster.assert.exception(function() {
- models.palettes.setCustom("terra-cr", "blue-1");
+ self['Exception setting a custom palette on a imagery layer'] = function () {
+ buster.assert.exception(function () {
+ models.palettes.setCustom('terra-cr', 'blue-1');
});
};
- self["Clear a custom palette"] = function() {
- this.stub(models.palettes.events, "trigger");
+ self['Clear a custom palette'] = function () {
+ this.stub(models.palettes.events, 'trigger');
- models.layers.add("aqua-aod");
- models.palettes.setCustom("terra-aod", "blue-1");
- models.palettes.clearCustom("terra-aod");
+ models.layers.add('aqua-aod');
+ models.palettes.setCustom('terra-aod', 'blue-1');
+ models.palettes.clearCustom('terra-aod');
- var palette = models.palettes.get("terra-aod");
+ var palette = models.palettes.get('terra-aod');
buster.assert.equals(palette.entries.colors[0], fixtures.green);
- buster.assert.equals(palette.legend.tooltips[0], "0");
+ buster.assert.equals(palette.legend.tooltips[0], '0');
- buster.assert.calledWith(models.palettes.events.trigger, "clear-custom");
- buster.assert.calledWith(models.palettes.events.trigger, "change");
+ buster.assert.calledWith(models.palettes.events.trigger, 'clear-custom');
+ buster.assert.calledWith(models.palettes.events.trigger, 'change');
};
- self["Set a minimum threshold"] = function() {
- this.stub(models.palettes.events, "trigger");
+ self['Set a minimum threshold'] = function () {
+ this.stub(models.palettes.events, 'trigger');
- models.layers.add("terra-aod");
- models.palettes.setRange("terra-aod", 1, 2);
+ models.layers.add('terra-aod');
+ models.palettes.setRange('terra-aod', 1, 2);
- var palette = models.palettes.get("terra-aod");
+ var palette = models.palettes.get('terra-aod');
buster.assert.equals(palette.min, 1);
buster.assert(_.isUndefined(palette.max));
- buster.assert.equals(palette.legend.colors[0], "00000000");
+ buster.assert.equals(palette.legend.colors[0], '00000000');
buster.assert.equals(palette.legend.colors[1], fixtures.yellow);
buster.assert.equals(palette.legend.colors[2], fixtures.red);
- buster.assert.calledWith(models.palettes.events.trigger, "range");
- buster.assert.calledWith(models.palettes.events.trigger, "change");
+ buster.assert.calledWith(models.palettes.events.trigger, 'range');
+ buster.assert.calledWith(models.palettes.events.trigger, 'change');
};
- self["Set a maximum threshold"] = function() {
- this.stub(models.palettes.events, "trigger");
+ self['Set a maximum threshold'] = function () {
+ this.stub(models.palettes.events, 'trigger');
- models.layers.add("terra-aod");
- models.palettes.setRange("terra-aod", 0, 1);
+ models.layers.add('terra-aod');
+ models.palettes.setRange('terra-aod', 0, 1);
- var palette = models.palettes.get("terra-aod");
+ var palette = models.palettes.get('terra-aod');
buster.assert.equals(palette.max, 1);
buster.assert(_.isUndefined(palette.min));
buster.assert.equals(palette.legend.colors[0], fixtures.green);
buster.assert.equals(palette.legend.colors[1], fixtures.yellow);
- buster.assert.equals(palette.legend.colors[2], "00000000");
+ buster.assert.equals(palette.legend.colors[2], '00000000');
- buster.assert.calledWith(models.palettes.events.trigger, "range");
- buster.assert.calledWith(models.palettes.events.trigger, "change");
+ buster.assert.calledWith(models.palettes.events.trigger, 'range');
+ buster.assert.calledWith(models.palettes.events.trigger, 'change');
};
- self["Save custom palette"] = function() {
- models.layers.add("aqua-aod");
- models.layers.add("terra-aod");
- models.palettes.setCustom("terra-aod", "blue-1");
- models.palettes.setCustom("aqua-aod", "red-1");
+ self['Save custom palette'] = function () {
+ models.layers.add('aqua-aod');
+ models.layers.add('terra-aod');
+ models.palettes.setCustom('terra-aod', 'blue-1');
+ models.palettes.setCustom('aqua-aod', 'red-1');
var state = {};
models.layers.save(state);
models.palettes.save(state);
buster.assert.equals(state.l, [
{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: [{
- id: "palette",
- value: "blue-1"
+ id: 'palette',
+ value: 'blue-1'
}]
},
{
- id: "aqua-aod",
+ id: 'aqua-aod',
attributes: [{
- id: "palette",
- value: "red-1"
+ id: 'palette',
+ value: 'red-1'
}]
}
]);
};
- self["Save threshold minimum"] = function() {
- models.layers.add("terra-aod");
- models.palettes.setRange("terra-aod", 1, 2);
+ self['Save threshold minimum'] = function () {
+ models.layers.add('terra-aod');
+ models.palettes.setRange('terra-aod', 1, 2);
var state = {};
models.layers.save(state);
models.palettes.save(state);
buster.assert.equals(state.l, [
{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: [{
- id: "min",
+ id: 'min',
value: 1
}]
}
]);
};
- self["Save threshold maximum"] = function() {
- models.layers.add("terra-aod");
- models.palettes.setRange("terra-aod", 0, 1);
+ self['Save threshold maximum'] = function () {
+ models.layers.add('terra-aod');
+ models.palettes.setRange('terra-aod', 0, 1);
var state = {};
models.layers.save(state);
models.palettes.save(state);
buster.assert.equals(state.l, [
{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: [{
- id: "max",
+ id: 'max',
value: 1
}]
}
]);
};
- self["Save threshold range"] = function() {
- models.layers.add("terra-aod");
- models.palettes.setRange("terra-aod", 1, 1);
+ self['Save threshold range'] = function () {
+ models.layers.add('terra-aod');
+ models.palettes.setRange('terra-aod', 1, 1);
var state = {};
models.layers.save(state);
models.palettes.save(state);
buster.assert.equals(state.l, [
{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: [
{
- id: "min",
+ id: 'min',
value: 1
},
{
- id: "max",
+ id: 'max',
value: 1
}
]
@@ -213,37 +211,37 @@ buster.testCase("wv.palettes.model", function() {
]);
};
- self["No save when not active"] = function() {
- models.layers.add("terra-aod");
+ self['No save when not active'] = function () {
+ models.layers.add('terra-aod');
var state = {};
models.layers.save(state);
models.palettes.save(state);
buster.assert.equals(state.l, [
{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: []
}
]);
};
- self["Load state"] = function() {
+ self['Load state'] = function () {
var state = {
l: [
{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: [
{
- id: "palette",
- value: "blue-1"
+ id: 'palette',
+ value: 'blue-1'
},
{
- id: "min",
- value: "1"
+ id: 'min',
+ value: '1'
},
{
- id: "max",
- value: "1"
+ id: 'max',
+ value: '1'
}
]
}
@@ -252,20 +250,20 @@ buster.testCase("wv.palettes.model", function() {
var errors = [];
models.layers.load(state, errors);
models.palettes.load(state, errors);
- var palette = models.palettes.get("terra-aod");
- buster.assert.equals(palette.custom, "blue-1");
+ var palette = models.palettes.get('terra-aod');
+ buster.assert.equals(palette.custom, 'blue-1');
buster.assert.equals(palette.min, 1);
buster.assert.equals(palette.max, 1);
buster.assert.equals(errors.length, 0);
};
- self["Error loading non-existing palette"] = function() {
+ self['Error loading non-existing palette'] = function () {
var state = {
l: [{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: [{
- id: "palette",
- value: "none"
+ id: 'palette',
+ value: 'none'
}]
}]
};
@@ -275,13 +273,13 @@ buster.testCase("wv.palettes.model", function() {
buster.assert.equals(errors.length, 1);
};
- self["Error loading invalid minimum"] = function() {
+ self['Error loading invalid minimum'] = function () {
var state = {
l: [{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: [{
- id: "min",
- value: "x"
+ id: 'min',
+ value: 'x'
}]
}]
};
@@ -291,13 +289,13 @@ buster.testCase("wv.palettes.model", function() {
buster.assert.equals(errors.length, 1);
};
- self["Error loading invalid maximum"] = function() {
+ self['Error loading invalid maximum'] = function () {
var state = {
l: [{
- id: "terra-aod",
+ id: 'terra-aod',
attributes: [{
- id: "max",
- value: "x"
+ id: 'max',
+ value: 'x'
}]
}]
};
@@ -307,29 +305,28 @@ buster.testCase("wv.palettes.model", function() {
buster.assert.equals(errors.length, 1);
};
- self["Canvas not in use"] = function() {
+ self['Canvas not in use'] = function () {
buster.refute(models.palettes.inUse());
};
- self["Canvas in use with custom palette"] = function() {
- models.layers.add("terra-aod");
- models.palettes.setCustom("terra-aod", "blue-1");
+ self['Canvas in use with custom palette'] = function () {
+ models.layers.add('terra-aod');
+ models.palettes.setCustom('terra-aod', 'blue-1');
buster.assert(models.palettes.inUse());
};
- self["Canvas in use with threshold ranges"] = function() {
- models.layers.add("terra-aod");
- models.palettes.setRange("terra-aod", 1);
+ self['Canvas in use with threshold ranges'] = function () {
+ models.layers.add('terra-aod');
+ models.palettes.setRange('terra-aod', 1);
buster.assert(models.palettes.inUse());
};
- self["Canvas not in use when not active layers have a palette"] = function() {
- models.layers.add("terra-aod");
- models.palettes.setCustom("terra-aod", "blue-1");
- models.layers.remove("terra-aod");
+ self['Canvas not in use when not active layers have a palette'] = function () {
+ models.layers.add('terra-aod');
+ models.palettes.setCustom('terra-aod', 'blue-1');
+ models.layers.remove('terra-aod');
buster.refute(models.palettes.inUse());
};
return self;
-
-}());
+}()));
diff --git a/test/proj/wv.proj-test.js b/test/proj/wv.proj-test.js
index be4e70694..554a36350 100644
--- a/test/proj/wv.proj-test.js
+++ b/test/proj/wv.proj-test.js
@@ -1,8 +1,8 @@
-buster.testCase("wv.proj", {
+buster.testCase('wv.proj', {
config: null,
- setUp: function() {
+ setUp: function () {
this.config = {
projections: {
geographic: {}
@@ -10,29 +10,29 @@ buster.testCase("wv.proj", {
};
},
- "1.1: Parses valid projection": function() {
+ '1.1: Parses valid projection': function () {
var state = {
- "switch": "geographic"
+ 'switch': 'geographic'
};
var errors = [];
wv.proj.parse(state, errors, this.config);
- buster.assert.equals(state.p, "geographic");
+ buster.assert.equals(state.p, 'geographic');
buster.assert.equals(errors.length, 0);
},
- "1.2: Parses valid projection": function() {
+ '1.2: Parses valid projection': function () {
var state = {
- "p": "geographic"
+ 'p': 'geographic'
};
var errors = [];
wv.proj.parse(state, errors, this.config);
- buster.assert.equals(state.p, "geographic");
+ buster.assert.equals(state.p, 'geographic');
buster.assert.equals(errors.length, 0);
},
- "Rejects unsupported projection": function() {
+ 'Rejects unsupported projection': function () {
var state = {
- "p": "albers"
+ 'p': 'albers'
};
var errors = [];
wv.proj.parse(state, errors, this.config);
diff --git a/test/proj/wv.proj.change-test.js b/test/proj/wv.proj.change-test.js
index 9e19eaf97..a091af05b 100644
--- a/test/proj/wv.proj.change-test.js
+++ b/test/proj/wv.proj.change-test.js
@@ -1,29 +1,29 @@
-buster.testCase("wv.proj.change", {
+buster.testCase('wv.proj.change', {
config: null,
models: null,
replace: null,
- setUp: function() {
+ setUp: function () {
this.config = {
defaults: {
- projection: "geographic",
+ projection: 'geographic'
},
projections: {
geographic: {
- id: "geographic",
- epsg: "4326",
- crs: "EPSG:4326"
+ id: 'geographic',
+ epsg: '4326',
+ crs: 'EPSG:4326'
},
arctic: {
- id: "arctic",
- epsg: "3413",
- crs: "EPSG:3413"
+ id: 'arctic',
+ epsg: '3413',
+ crs: 'EPSG:3413'
},
antarctic: {
- id: "antarctic",
- epsg: "3031",
- crs: "EPSG:3031"
+ id: 'antarctic',
+ epsg: '3031',
+ crs: 'EPSG:3031'
}
}
};
@@ -35,8 +35,8 @@ buster.testCase("wv.proj.change", {
replace: this.replace
}
};
- this.stub(wv.ui, "notify");
- this.stub(window, "$")
+ this.stub(wv.ui, 'notify');
+ this.stub(window, '$')
.returns({
on: this.stub()
});
@@ -51,107 +51,107 @@ buster.testCase("wv.proj.change", {
};
},
- "Initializes with new projection": function() {
+ 'Initializes with new projection': function () {
var model = wv.proj.change(this.models);
buster.refute(model.old);
- buster.assert.equals(model.crs, "EPSG:4326");
+ buster.assert.equals(model.crs, 'EPSG:4326');
},
- "New projection with arctic": function() {
+ 'New projection with arctic': function () {
var model = wv.proj.change(this.models);
this.models.date.select(new Date(Date.UTC(2014, 0, 1)));
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
buster.refute(model.old);
- buster.assert.equals(model.crs, "EPSG:3413");
+ buster.assert.equals(model.crs, 'EPSG:3413');
},
- "Old projection with arctic via projection change": function() {
+ 'Old projection with arctic via projection change': function () {
var model = wv.proj.change(this.models);
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
buster.assert(model.old);
- buster.assert.equals(model.crs, "EPSG:3995");
+ buster.assert.equals(model.crs, 'EPSG:3995');
},
- "Old projection with arctic via date change": function() {
+ 'Old projection with arctic via date change': function () {
var model = wv.proj.change(this.models);
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
buster.assert(model.old);
- buster.assert.equals(model.crs, "EPSG:3995");
+ buster.assert.equals(model.crs, 'EPSG:3995');
},
- "Old projection with antarctic": function() {
+ 'Old projection with antarctic': function () {
var model = wv.proj.change(this.models);
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
- this.models.proj.select("antarctic");
+ this.models.proj.select('antarctic');
buster.assert(model.old);
- buster.assert.equals(model.crs, "EPSG:3031");
+ buster.assert.equals(model.crs, 'EPSG:3031');
},
- "Changes back to new on date change": function() {
+ 'Changes back to new on date change': function () {
var model = wv.proj.change(this.models);
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
this.models.date.select(new Date(Date.UTC(2014, 0, 1)));
buster.refute(model.old);
- buster.assert.equals(model.crs, "EPSG:3413");
+ buster.assert.equals(model.crs, 'EPSG:3413');
},
- "Changes back to new on projection change": function() {
+ 'Changes back to new on projection change': function () {
var model = wv.proj.change(this.models);
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
- this.models.proj.select("arctic");
- this.models.proj.select("geographic");
+ this.models.proj.select('arctic');
+ this.models.proj.select('geographic');
buster.refute(model.old);
- buster.assert.equals(model.crs, "EPSG:4326");
+ buster.assert.equals(model.crs, 'EPSG:4326');
},
- "No notification in first new arctic projection visit": function() {
+ 'No notification in first new arctic projection visit': function () {
this.models.date.select(new Date(Date.UTC(2014, 0, 1)));
var model = wv.proj.change(this.models);
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
buster.refute.called(wv.ui.notify);
},
- "No notification in first old arctic projection visit": function() {
+ 'No notification in first old arctic projection visit': function () {
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
var model = wv.proj.change(this.models);
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
buster.refute.called(wv.ui.notify);
},
- "Notification switching from new to old projection": function() {
+ 'Notification switching from new to old projection': function () {
this.models.date.select(new Date(Date.UTC(2014, 0, 1)));
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
var model = wv.proj.change(this.models);
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
buster.assert.calledOnce(wv.ui.notify);
},
- "Notification switching from old to new projection": function() {
+ 'Notification switching from old to new projection': function () {
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
var model = wv.proj.change(this.models);
this.models.date.select(new Date(Date.UTC(2014, 0, 1)));
buster.assert.calledOnce(wv.ui.notify);
},
- "Only notified once": function() {
+ 'Only notified once': function () {
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
var model = wv.proj.change(this.models);
this.models.date.select(new Date(Date.UTC(2014, 0, 1)));
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
buster.assert.calledOnce(wv.ui.notify);
},
- "Not notified if 'Dont show again' selected": function() {
+ "Not notified if 'Dont show again' selected": function () {
this.stub(window.localStorage, 'getItem')
- .withArgs("arcticProjectionChangeNotification")
- .returns("true");
+ .withArgs('arcticProjectionChangeNotification')
+ .returns('true');
this.models.date.select(new Date(Date.UTC(2013, 0, 1)));
- this.models.proj.select("arctic");
+ this.models.proj.select('arctic');
var model = wv.proj.change(this.models);
this.models.date.select(new Date(Date.UTC(2014, 0, 1)));
buster.refute.called(wv.ui.notify);
diff --git a/test/proj/wv.proj.model-test.js b/test/proj/wv.proj.model-test.js
index fe1b74af0..a04a1b831 100644
--- a/test/proj/wv.proj.model-test.js
+++ b/test/proj/wv.proj.model-test.js
@@ -1,48 +1,48 @@
-buster.testCase("wv.proj.model", {
+buster.testCase('wv.proj.model', {
config: null,
- setUp: function() {
+ setUp: function () {
this.config = {
defaults: {
- projection: "geographic",
+ projection: 'geographic'
},
projections: {
- "geographic": {
- id: "geographic",
- epsg: "4326",
- crs: "EPSG:4326"
+ 'geographic': {
+ id: 'geographic',
+ epsg: '4326',
+ crs: 'EPSG:4326'
},
- "arctic": {
- id: "arctic",
- epsg: "3413",
- crs: "EPSG:3413"
+ 'arctic': {
+ id: 'arctic',
+ epsg: '3413',
+ crs: 'EPSG:3413'
}
}
};
},
- "Initializes with default": function() {
+ 'Initializes with default': function () {
var model = wv.proj.model(this.config);
- buster.assert.equals(model.selected.id, "geographic");
- buster.assert.equals(model.selected.crs, "EPSG:4326");
+ buster.assert.equals(model.selected.id, 'geographic');
+ buster.assert.equals(model.selected.crs, 'EPSG:4326');
},
- "Throws exception witn an invalid default": function() {
- this.config.defaults.projection = "invalid";
+ 'Throws exception witn an invalid default': function () {
+ this.config.defaults.projection = 'invalid';
var self = this;
- buster.assert.exception(function() {
+ buster.assert.exception(function () {
wv.proj.model(self.config);
});
},
- "Selects projection": function() {
+ 'Selects projection': function () {
var model = wv.proj.model(this.config);
var listener = this.stub();
- model.events.on("select", listener);
- model.select("arctic");
- buster.assert.equals(model.selected.id, "arctic");
- buster.assert.equals(model.selected.crs, "EPSG:3413");
+ model.events.on('select', listener);
+ model.select('arctic');
+ buster.assert.equals(model.selected.id, 'arctic');
+ buster.assert.equals(model.selected.crs, 'EPSG:3413');
buster.assert.calledOnce(listener);
},
@@ -54,27 +54,27 @@ buster.testCase("wv.proj.model", {
},
*/
- "Event not fired if selection does not change": function() {
+ 'Event not fired if selection does not change': function () {
var model = wv.proj.model(this.config);
var listener = this.stub();
- model.events.on("select", listener);
- model.select("geographic");
+ model.events.on('select', listener);
+ model.select('geographic');
buster.refute.called(listener);
},
- "Saves state": function() {
+ 'Saves state': function () {
var model = wv.proj.model(this.config);
var state = {};
model.save(state);
- buster.assert.equals(state.p, "geographic");
+ buster.assert.equals(state.p, 'geographic');
},
- "Loads state": function() {
+ 'Loads state': function () {
var model = wv.proj.model(this.config);
var state = {
- "p": "arctic"
+ 'p': 'arctic'
};
model.load(state);
- buster.assert.equals(model.selected.id, "arctic");
+ buster.assert.equals(model.selected.id, 'arctic');
}
});
diff --git a/test/ui/wv.ui.indicator-test.js b/test/ui/wv.ui.indicator-test.js
index 21d9ae780..6dc46ea93 100644
--- a/test/ui/wv.ui.indicator-test.js
+++ b/test/ui/wv.ui.indicator-test.js
@@ -1,17 +1,16 @@
-buster.testCase("wv.ui.indicator", function() {
-
+buster.testCase('wv.ui.indicator', (function () {
var self = {};
- self.setUp = function() {
+ self.setUp = function () {
wv.ui.indicator.active = [];
};
- self["Delayed indicator shown"] = function(done) {
- this.stub(wv.ui.indicator, "_show");
- this.stub(wv.ui.indicator, "hide");
+ self['Delayed indicator shown'] = function (done) {
+ this.stub(wv.ui.indicator, '_show');
+ this.stub(wv.ui.indicator, 'hide');
var promise = $.Deferred();
wv.ui.indicator.delayed(promise, 10);
- setTimeout(function() {
+ setTimeout(function () {
promise.resolve();
buster.assert.called(wv.ui.indicator._show);
buster.assert.called(wv.ui.indicator.hide);
@@ -19,12 +18,12 @@ buster.testCase("wv.ui.indicator", function() {
}, 50);
};
- self["Delayed indicator not shown"] = function(done) {
- this.stub(wv.ui.indicator, "_show");
- this.stub(wv.ui.indicator, "hide");
+ self['Delayed indicator not shown'] = function (done) {
+ this.stub(wv.ui.indicator, '_show');
+ this.stub(wv.ui.indicator, 'hide');
var promise = $.Deferred();
wv.ui.indicator.delayed(promise, 1000);
- setTimeout(function() {
+ setTimeout(function () {
promise.resolve();
buster.refute.called(wv.ui.indicator._show);
buster.refute.called(wv.ui.indicator.hide);
@@ -32,43 +31,42 @@ buster.testCase("wv.ui.indicator", function() {
}, 20);
};
- self["Pop message"] = function() {
- this.stub(wv.ui.indicator, "_show");
- this.stub(wv.ui.indicator, "_hide");
+ self['Pop message'] = function () {
+ this.stub(wv.ui.indicator, '_show');
+ this.stub(wv.ui.indicator, '_hide');
- wv.ui.indicator.show("Bottom");
- var id = wv.ui.indicator.show("Top");
+ wv.ui.indicator.show('Bottom');
+ var id = wv.ui.indicator.show('Top');
wv.ui.indicator.hide(id);
buster.assert.equals(1, wv.ui.indicator.active.length);
- buster.assert.equals("Bottom", wv.ui.indicator.active[0].message);
+ buster.assert.equals('Bottom', wv.ui.indicator.active[0].message);
};
- self["Remove bottom message"] = function() {
- this.stub(wv.ui.indicator, "_show");
- this.stub(wv.ui.indicator, "_hide");
+ self['Remove bottom message'] = function () {
+ this.stub(wv.ui.indicator, '_show');
+ this.stub(wv.ui.indicator, '_hide');
- var id = wv.ui.indicator.show("Bottom");
- wv.ui.indicator.show("Top");
+ var id = wv.ui.indicator.show('Bottom');
+ wv.ui.indicator.show('Top');
wv.ui.indicator.hide(id);
buster.assert.equals(1, wv.ui.indicator.active.length);
- buster.assert.equals("Top", wv.ui.indicator.active[0].message);
+ buster.assert.equals('Top', wv.ui.indicator.active[0].message);
};
- self["Hide group"] = function() {
- this.stub(wv.ui.indicator, "_show");
- this.stub(wv.ui.indicator, "_hide");
+ self['Hide group'] = function () {
+ this.stub(wv.ui.indicator, '_show');
+ this.stub(wv.ui.indicator, '_hide');
var indicators = {
two: null,
- three: null,
+ three: null
};
- wv.ui.indicator.show("One");
- indicators.two = wv.ui.indicator.show("Two");
- indicators.three = wv.ui.indicator.show("Three");
+ wv.ui.indicator.show('One');
+ indicators.two = wv.ui.indicator.show('Two');
+ indicators.three = wv.ui.indicator.show('Three');
wv.ui.indicator.hide(indicators);
buster.assert.equals(1, wv.ui.indicator.active.length);
- buster.assert.equals("One", wv.ui.indicator.active[0].message);
+ buster.assert.equals('One', wv.ui.indicator.active[0].message);
};
return self;
-
-}());
+}()));
diff --git a/test/ui/wv.ui.mouse-test.js b/test/ui/wv.ui.mouse-test.js
index 2333a568f..edc863629 100644
--- a/test/ui/wv.ui.mouse-test.js
+++ b/test/ui/wv.ui.mouse-test.js
@@ -1,20 +1,19 @@
-buster.testCase("wv.ui.mouse.click", function() {
-
+buster.testCase('wv.ui.mouse.click', (function () {
var self = {};
var element, down, up;
- self.setUp = function() {
+ self.setUp = function () {
element = {
- mousedown: function(handler) {
+ mousedown: function (handler) {
down = handler;
},
- mouseup: function(handler) {
+ mouseup: function (handler) {
up = handler;
}
};
};
- self["Within click limit"] = function() {
+ self['Within click limit'] = function () {
var callback = this.stub();
wv.ui.mouse.click(element, callback);
down({
@@ -28,7 +27,7 @@ buster.testCase("wv.ui.mouse.click", function() {
buster.assert.called(callback);
};
- self["Outside click limit"] = function() {
+ self['Outside click limit'] = function () {
var callback = this.stub();
wv.ui.mouse.click(element, callback);
down({
@@ -43,5 +42,4 @@ buster.testCase("wv.ui.mouse.click", function() {
};
return self;
-
-}());
+}()));
diff --git a/test/util/wv.util.browser-test.js b/test/util/wv.util.browser-test.js
index f3c6e034a..adfb5827b 100644
--- a/test/util/wv.util.browser-test.js
+++ b/test/util/wv.util.browser-test.js
@@ -1,97 +1,97 @@
-buster.testCase("wv.util.browser", {
+buster.testCase('wv.util.browser', {
- setUp: function() {},
+ setUp: function () {},
- "Is Safari": function() {
- this.stub(wv.util.browser.tests, "navigator")
+ 'Is Safari': function () {
+ this.stub(wv.util.browser.tests, 'navigator')
.returns({
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10"
+ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10'
});
buster.assert(wv.util.browser.tests.safari());
},
- "Is not Safari": function() {
- this.stub(wv.util.browser.tests, "navigator")
+ 'Is not Safari': function () {
+ this.stub(wv.util.browser.tests, 'navigator')
.returns({
- userAgent: "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"
+ userAgent: 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36'
});
buster.refute(wv.util.browser.tests.safari());
},
- "Safari version": function() {
- this.stub(wv.util.browser.tests, "navigator")
+ 'Safari version': function () {
+ this.stub(wv.util.browser.tests, 'navigator')
.returns({
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10"
+ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10'
});
buster.assert.equals(wv.util.browser.tests.safariVersion(), 5);
},
- "Is Internet Explorer": function() {
- this.stub(wv.util.browser.tests, "navigator")
+ 'Is Internet Explorer': function () {
+ this.stub(wv.util.browser.tests, 'navigator')
.returns({
- userAgent: "Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/5.0)"
+ userAgent: 'Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/5.0)'
});
buster.assert(wv.util.browser.tests.ie());
},
- "Is Internet Explorer 10": function() {
- this.stub(wv.util.browser.tests, "navigator")
+ 'Is Internet Explorer 10': function () {
+ this.stub(wv.util.browser.tests, 'navigator')
.returns({
- userAgent: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)"
+ userAgent: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)'
});
buster.assert(wv.util.browser.tests.ie());
},
- "Is not Internet Explorer": function() {
- this.stub(wv.util.browser.tests, "navigator")
+ 'Is not Internet Explorer': function () {
+ this.stub(wv.util.browser.tests, 'navigator')
.returns({
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0"
+ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0'
});
buster.refute(wv.util.browser.tests.ie());
},
- "Internet Explorer version": function() {
- this.stub(wv.util.browser.tests, "navigator")
+ 'Internet Explorer version': function () {
+ this.stub(wv.util.browser.tests, 'navigator')
.returns({
- userAgent: "Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/5.0)"
+ userAgent: 'Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/5.0)'
});
buster.assert.equals(wv.util.browser.tests.ieVersion(), 9);
},
- "CORS": function() {
- this.stub(wv.util.browser.tests, "safari")
+ 'CORS': function () {
+ this.stub(wv.util.browser.tests, 'safari')
.returns(true);
- this.stub(wv.util.browser.tests, "safariVersion")
+ this.stub(wv.util.browser.tests, 'safariVersion')
.returns(7);
buster.assert(wv.util.browser.tests.cors());
},
- "Non-working CORS on Safari version <= 6": function() {
- this.stub(wv.util.browser.tests, "safari")
+ 'Non-working CORS on Safari version <= 6': function () {
+ this.stub(wv.util.browser.tests, 'safari')
.returns(true);
- this.stub(wv.util.browser.tests, "safariVersion")
+ this.stub(wv.util.browser.tests, 'safariVersion')
.returns(6);
buster.refute(wv.util.browser.tests.cors());
},
- "Web workers": function() {
- this.stub(wv.util.browser.tests, "window")
+ 'Web workers': function () {
+ this.stub(wv.util.browser.tests, 'window')
.returns({});
buster.assert(wv.util.browser.tests.webWorkers());
},
- "No web workers": function() {
- this.stub(wv.util.browser.tests, "window")
+ 'No web workers': function () {
+ this.stub(wv.util.browser.tests, 'window')
.returns(undefined);
buster.refute(wv.util.browser.tests.webWorkers());
},
- "Local storage": function() {
+ 'Local storage': function () {
buster.assert(wv.util.browser.tests.localStorage);
},
- "No local storage": function() {
- this.stub(wv.util.browser.tests, "window")
+ 'No local storage': function () {
+ this.stub(wv.util.browser.tests, 'window')
.returns(undefined);
buster.refute(wv.util.browser.tests.localStorage());
},
@@ -105,8 +105,8 @@ buster.testCase("wv.util.browser", {
},
*/
- "Large device": function() {
- this.stub(window, "$")
+ 'Large device': function () {
+ this.stub(window, '$')
.returns({
width: this.stub()
.returns(1000),
@@ -117,8 +117,8 @@ buster.testCase("wv.util.browser", {
buster.refute(wv.util.browser.tests.constrained());
},
- "Small device": function() {
- this.stub(window, "$")
+ 'Small device': function () {
+ this.stub(window, '$')
.returns({
width: this.stub()
.returns(200),
@@ -128,8 +128,8 @@ buster.testCase("wv.util.browser", {
buster.assert(wv.util.browser.tests.small());
},
- "Constrained device, height": function() {
- this.stub(window, "$")
+ 'Constrained device, height': function () {
+ this.stub(window, '$')
.returns({
width: this.stub()
.returns(1000),
diff --git a/test/util/wv.util.events-test.js b/test/util/wv.util.events-test.js
index 11e2fb12f..feb34b45f 100644
--- a/test/util/wv.util.events-test.js
+++ b/test/util/wv.util.events-test.js
@@ -1,43 +1,43 @@
-buster.testCase("wv.util.events", {
+buster.testCase('wv.util.events', {
events: null,
- setUp: function() {
+ setUp: function () {
this.events = wv.util.events();
},
- "Triggers an event": function() {
+ 'Triggers an event': function () {
var listener1 = this.stub();
var listener2 = this.stub();
- this.events.on("test", listener1);
- this.events.on("test", listener2);
- this.events.trigger("test", "a", 2);
- buster.assert.calledWith(listener1, "a", 2);
- buster.assert.calledWith(listener2, "a", 2);
+ this.events.on('test', listener1);
+ this.events.on('test', listener2);
+ this.events.trigger('test', 'a', 2);
+ buster.assert.calledWith(listener1, 'a', 2);
+ buster.assert.calledWith(listener2, 'a', 2);
},
- "Exception thrown when trying to register a null listener": function() {
+ 'Exception thrown when trying to register a null listener': function () {
var self = this;
- buster.assert.exception(function() {
- self.events.on("foo");
+ buster.assert.exception(function () {
+ self.events.on('foo');
});
},
- "Removes listener": function() {
+ 'Removes listener': function () {
var listener = this.stub();
- this.events.on("test", listener);
- this.events.trigger("test");
- this.events.off("test", listener);
- this.events.trigger("test");
+ this.events.on('test', listener);
+ this.events.trigger('test');
+ this.events.off('test', listener);
+ this.events.trigger('test');
buster.assert.calledOnce(listener);
},
- "Any listener called on any event": function() {
+ 'Any listener called on any event': function () {
var listener = this.stub();
- this.events.on("event1", listener);
- this.events.on("event2", listener);
- this.events.trigger("event1");
- this.events.trigger("event2");
+ this.events.on('event1', listener);
+ this.events.on('event2', listener);
+ this.events.trigger('event1');
+ this.events.trigger('event2');
buster.assert.calledTwice(listener);
}
});
diff --git a/test/wv.brand-test.js b/test/wv.brand-test.js
index 1c95c6b3d..1f2f31364 100644
--- a/test/wv.brand-test.js
+++ b/test/wv.brand-test.js
@@ -1,21 +1,21 @@
-buster.testCase("wv.brand", {
+buster.testCase('wv.brand', {
- "Is development build": function() {
+ 'Is development build': function () {
buster.refute(wv.brand.release());
},
- "Is release build": function() {
- this.stub(wv.brand, "VERSION", "0.0.0");
+ 'Is release build': function () {
+ this.stub(wv.brand, 'VERSION', '0.0.0');
buster.assert(wv.brand.release());
},
- "URL with build nonce": function() {
- buster.assert.equals(wv.brand.url("foo"), "foo?v=@BUILD_NONCE@");
+ 'URL with build nonce': function () {
+ buster.assert.equals(wv.brand.url('foo'), 'foo?v=@BUILD_NONCE@');
},
- "URL build build nonce, existing query string": function() {
- buster.assert.equals(wv.brand.url("foo?bar=1"),
- "foo?bar=1&v=@BUILD_NONCE@");
+ 'URL build build nonce, existing query string': function () {
+ buster.assert.equals(wv.brand.url('foo?bar=1'),
+ 'foo?bar=1&v=@BUILD_NONCE@');
}
});
diff --git a/web/js/animation/wv.anim.gif.js b/web/js/animation/wv.anim.gif.js
index a58349936..0ce88d7d5 100644
--- a/web/js/animation/wv.anim.gif.js
+++ b/web/js/animation/wv.anim.gif.js
@@ -2,9 +2,9 @@ var wv = wv || {};
wv.anim = wv.anim || {};
-wv.anim.gif = wv.anim.gif || function(models, config, ui) {
+wv.anim.gif = wv.anim.gif || function (models, config, ui) {
var self = {};
- var $cropee = $("#wv-map");
+ var $cropee = $('#wv-map');
var jcropAPI = null;
var coords = null;
var animCoords = null;
@@ -13,16 +13,16 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
var $progress; // progress bar
var loader;
var showDates = true; // show date stamp
- var progressing = false; //if progress bar has started
+ var progressing = false; // if progress bar has started
var GRATICLE_WARNING =
- "The graticule layer cannot be used to take a snapshot. Would you " +
- "like to hide this layer?";
+ 'The graticule layer cannot be used to take a snapshot. Would you ' +
+ 'like to hide this layer?';
var PALETTE_WARNING =
- "One or more layers on the map have been modified (changed palette, " +
- "thresholds, etc.). These modifications cannot be used to take a " +
- "snapshot. Would you like to temporarily revert to the original " +
- "layer(s)?";
- var ROTATE_WARNING = "Image may not be downloaded when rotated. Would you like to reset rotation?";
+ 'One or more layers on the map have been modified (changed palette, ' +
+ 'thresholds, etc.). These modifications cannot be used to take a ' +
+ 'snapshot. Would you like to temporarily revert to the original ' +
+ 'layer(s)?';
+ var ROTATE_WARNING = 'Image may not be downloaded when rotated. Would you like to reset rotation?';
/*
* sets listeners
@@ -34,7 +34,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- self.init = function() {
+ self.init = function () {
models.anim.events.on('gif-click', setImageCoords);
};
@@ -49,7 +49,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- self.createGIF = function() {
+ self.createGIF = function () {
var stateObj = animModel.rangeState;
var interval = stateObj.speed;
var startDate = stateObj.startDate;
@@ -60,28 +60,28 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
var build;
loader = wv.ui.indicator.loading();
- build = function(stamp) {
- var buildProgressBar = function() {
- $progress = $("<progress />") //display progress for GIF creation
- .attr("class", "wv-gif-progress");
+ build = function (stamp) {
+ var buildProgressBar = function () {
+ $progress = $('<progress />') // display progress for GIF creation
+ .attr('class', 'wv-gif-progress');
wv.ui.getDialog()
.append($progress)
- .dialog({ //dialog for progress
- title: "Collecting Images...",
+ .dialog({ // dialog for progress
+ title: 'Collecting Images...',
width: 300,
height: 100
});
- $progress.attr("value", 0);
+ $progress.attr('value', 0);
};
- var onGifProgress = function(captureProgress) {
+ var onGifProgress = function (captureProgress) {
if (!progressing) {
buildProgressBar();
progressing = true;
wv.ui.indicator.hide(loader);
}
$progress.parent()
- .dialog("option", "title", "Creating GIF..."); //set dialog title
- $progress.attr("value", captureProgress); //before value set, it is in indeterminate state
+ .dialog('option', 'title', 'Creating GIF...'); // set dialog title
+ $progress.attr('value', captureProgress); // before value set, it is in indeterminate state
};
imageArra = getImageArray(startDate, endDate, $progress);
@@ -110,10 +110,10 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
}, onGifComplete);
};
stamp = new Image();
- stamp.onload = function() {
+ stamp.onload = function () {
build(stamp);
};
- stamp.onerror = function() {
+ stamp.onerror = function () {
build(null);
};
stamp.src = 'brand/images/wv-icon-w-shadow.png';
@@ -130,39 +130,37 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var calcRes = function(mode) { //return either multiplier or string resolution
- //geographic has 10 zoom levels from 0 to 9, polar projections have 8 from 0 to 7
- var isGeographic = models.proj.selected.id === "geographic";
+ var calcRes = function (mode) { // return either multiplier or string resolution
+ // geographic has 10 zoom levels from 0 to 9, polar projections have 8 from 0 to 7
+ var isGeographic = models.proj.selected.id === 'geographic';
- //Map the zoom level from 0-9 / 0-7 to an index from 0-4
+ // Map the zoom level from 0-9 / 0-7 to an index from 0-4
var zoom_res = [40, 20, 4, 2, 1],
str, res;
- if (isGeographic)
+ if (isGeographic) {
res = zoom_res[Math.floor(ui.map.selected.getView()
.getZoom() / 2)];
-
- else
+ } else {
res = zoom_res[Math.floor(((ui.map.selected.getView()
.getZoom() + 2) / 2))];
+ }
- if (mode === 0)
- return res;
- else {
+ if (mode === 0) { return res; } else {
switch (res) {
case 1:
- str = "250m";
+ str = '250m';
break;
case 2:
- str = "500m";
+ str = '500m';
break;
case 4:
- str = "1km";
+ str = '1km';
break;
case 20:
- str = "5km";
+ str = '5km';
break;
default:
- str = "10km";
+ str = '10km';
}
return str;
@@ -179,19 +177,19 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- self.getGif = function() {
+ self.getGif = function () {
var layers;
- //check for rotation, changed palettes, and graticule layers and ask for reset if so
+ // check for rotation, changed palettes, and graticule layers and ask for reset if so
- //ui.anim.stop(); Add this
+ // ui.anim.stop(); Add this
layers = models.layers.get({
renderable: true
});
if (models.palettes.inUse()) {
wv.ui.ask({
- header: "Notice",
+ header: 'Notice',
message: PALETTE_WARNING,
- onOk: function() {
+ onOk: function () {
previousPalettes = models.palettes.active;
models.palettes.clear();
self.getGif();
@@ -200,13 +198,13 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
return;
}
if (_.find(layers, {
- id: "Graticule"
- }) && models.proj.selected.id === "geographic") {
+ id: 'Graticule'
+ }) && models.proj.selected.id === 'geographic') {
wv.ui.ask({
- header: "Notice",
+ header: 'Notice',
message: GRATICULE_WARNING,
- onOk: function() {
- models.layers.setVisibility("Graticule", false);
+ onOk: function () {
+ models.layers.setVisibility('Graticule', false);
self.getGif(startDate, endDate, delta, interval);
}
});
@@ -215,11 +213,11 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
if (ui.map.selected.getView()
.getRotation() !== 0.0) {
wv.ui.ask({
- header: "Reset rotation?",
+ header: 'Reset rotation?',
message: ROTATE_WARNING,
- onOk: function() {
+ onOk: function () {
resetRotation();
- //Let rotation finish before reselecting can occur
+ // Let rotation finish before reselecting can occur
setImageCoords();
}
});
@@ -240,9 +238,9 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {array} array of layer ids
*
*/
- var getLayers = function(products, proj) {
+ var getLayers = function (products, proj) {
var layers = [];
- _.each(products, function(layer) {
+ _.each(products, function (layer) {
if (layer.projections[proj].layer) {
layers.push(layer.projections[proj].layer);
} else {
@@ -260,13 +258,13 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {array} array of layer objects
*
*/
- var getProducts = function(date) {
+ var getProducts = function (date) {
var layers = [];
var products = models.layers.get({
reverse: true,
renderable: true
});
- _.each(products, function(layer) {
+ _.each(products, function (layer) {
if (layer.endDate) {
if (date > new Date(layer.endDate)) return;
}
@@ -290,9 +288,9 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {array} array of opacities
*
*/
- var getOpacities = function(products) {
+ var getOpacities = function (products) {
var opacities = [];
- _.each(products, function(product) {
+ _.each(products, function (product) {
opacities.push((_.isUndefined(product.opacity)) ? 1 : product.opacity);
});
return opacities;
@@ -307,7 +305,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {array} array of coords
*
*/
- var getCoords = function() {
+ var getCoords = function () {
return [ui.map.selected.getCoordinateFromPixel([Math.floor(animCoords.x), Math.floor(animCoords.y2)]),
ui.map.selected.getCoordinateFromPixel([Math.floor(animCoords.x2), Math.floor(animCoords.y)])];
};
@@ -320,9 +318,8 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {array} array with dimensions
*
*/
- var getDimensions = function(lonlat, proj) {
-
- var conversionFactor = proj === "geographic" ? 0.002197 : 256;
+ var getDimensions = function (lonlat, proj) {
+ var conversionFactor = proj === 'geographic' ? 0.002197 : 256;
var res = calcRes(0);
return [
Math.round((Math.abs(lonlat[1][0] - lonlat[0][0]) / conversionFactor) / Number(res)), // width
@@ -340,7 +337,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {array} array of jpg urls
*
*/
- var getImageArray = function(startDate, endDate) {
+ var getImageArray = function (startDate, endDate) {
var url;
var a = [];
var fromDate = new Date(startDate);
@@ -358,7 +355,6 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
var epsg = (models.proj.change) ? models.proj.change.epsg : models.proj.selected.epsg;
var products = getProducts();
-
if (config.features.imageDownload) {
host = config.features.imageDownload.host;
path = config.parameters.imagegen || config.features.imageDownload.path;
@@ -374,7 +370,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
layers = getLayers(products, proj);
opacities = getOpacities(products);
- url = wv.util.format(host + '/' + path + "?{1}&extent={2}&epsg={3}&layers={4}&opacities={5}&worldfile=false&format=image/jpeg&width={6}&height={7}", "TIME={1}", lonlat[0][0] + "," + lonlat[0][1] + "," + lonlat[1][0] + "," + lonlat[1][1], epsg, layers.join(","), opacities.join(","), dimensions[0], dimensions[1]);
+ url = wv.util.format(host + '/' + path + '?{1}&extent={2}&epsg={3}&layers={4}&opacities={5}&worldfile=false&format=image/jpeg&width={6}&height={7}', 'TIME={1}', lonlat[0][0] + ',' + lonlat[0][1] + ',' + lonlat[1][0] + ',' + lonlat[1][1], epsg, layers.join(','), opacities.join(','), dimensions[0], dimensions[1]);
src = wv.util.format(url, strDate);
if (showDates) {
a.push({
@@ -391,7 +387,6 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
return false;
}
-
}
return a;
};
@@ -406,14 +401,14 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var showUnavailableReason = function() {
+ var showUnavailableReason = function () {
var headerMsg = "<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";
var bodyMsg = 'Too many frames were selected. Please request less than 40 frames if you would like to generate a GIF';
- callback = function() {
+ callback = function () {
$('#timeline-footer')
.toggleClass('wv-anim-active');
};
- wv.ui.notify(headerMsg + bodyMsg, "Notice", 600, callback);
+ wv.ui.notify(headerMsg + bodyMsg, 'Notice', 600, callback);
};
/*
@@ -426,7 +421,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var resetRotation = function() {
+ var resetRotation = function () {
ui.map.selected.getView()
.animate({
duration: 400,
@@ -446,126 +441,125 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var onGifComplete = function(obj) { //callback function for when image is finished
+ var onGifComplete = function (obj) { // callback function for when image is finished
if (obj.error === false) {
$progress.remove();
progressing = false;
var animatedImage = document.createElement('img');
- //Create a blob out of the image's base64 encoding because Chrome can't handle large data URIs, taken from:
- //http://stackoverflow.com/questions/16761927/aw-snap-when-data-uri-is-too-large
+ // Create a blob out of the image's base64 encoding because Chrome can't handle large data URIs, taken from:
+ // http://stackoverflow.com/questions/16761927/aw-snap-when-data-uri-is-too-large
var byteCharacters = atob(obj.image.substring(22)),
- byteArrays = []; //remove "data:image/gif;base64,"
+ byteArrays = []; // remove "data:image/gif;base64,"
for (var offset = 0; offset < byteCharacters.length; offset += 512) {
var slice = byteCharacters.slice(offset, offset + 512);
var byteNumbers = new Array(slice.length);
- for (var i = 0; i < slice.length; i++)
- byteNumbers[i] = slice.charCodeAt(i);
+ for (var i = 0; i < slice.length; i++) { byteNumbers[i] = slice.charCodeAt(i); }
var byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
var blob = new Blob(byteArrays, {
- type: "image/gif"
+ type: 'image/gif'
});
- var blobURL = URL.createObjectURL(blob); //supported in Chrome and FF
+ var blobURL = URL.createObjectURL(blob); // supported in Chrome and FF
animatedImage.src = blobURL;
- var dlURL = wv.util.format("nasa-worldview-{1}-to-{2}.gif", animModel.rangeState.startDate, animModel.rangeState.endDate);
+ var dlURL = wv.util.format('nasa-worldview-{1}-to-{2}.gif', animModel.rangeState.startDate, animModel.rangeState.endDate);
var downloadSize = (blob.size / 1024)
.toFixed();
- //Create download link and apply button CSS
- var $download = $("<a><span class=ui-button-text>Download</span></a>")
- .attr("type", "button")
- .attr("role", "button")
- .attr("download", dlURL)
- .attr("href", blobURL)
- .attr("class", "ui-button ui-widget ui-state-default ui-button-text-only")
- .hover(function() {
+ // Create download link and apply button CSS
+ var $download = $('<a><span class=ui-button-text>Download</span></a>')
+ .attr('type', 'button')
+ .attr('role', 'button')
+ .attr('download', dlURL)
+ .attr('href', blobURL)
+ .attr('class', 'ui-button ui-widget ui-state-default ui-button-text-only')
+ .hover(function () {
$(this)
- .addClass("ui-state-hover");
- }, function() {
+ .addClass('ui-state-hover');
+ }, function () {
$(this)
- .removeClass("ui-state-hover");
+ .removeClass('ui-state-hover');
})
- .click(function() {
+ .click(function () {
WVC.GA.event('Animation', 'Download', 'GIF', downloadSize);
});
var $catalog =
"<div class='gif-results-dialog' style='height: " + animCoords.h + "px; min-height: 210px;' >" +
- "<div>" +
- "<div><b>" +
- "Size: " +
- "</b></div>" +
- "<div>" +
- downloadSize + " KB" +
- "</div>" +
- "</div>" +
- "<div>" +
- "<div><b>" +
- "Speed: " +
- "</b></div>" +
- "<div>" +
- animModel.rangeState.speed + " fps" +
- "</div>" +
-
- "</div>" +
- "<div>" +
- "<div><b>" +
- "Date Range: " +
- "</b></div>" +
- "<div>" +
+ '<div>' +
+ '<div><b>' +
+ 'Size: ' +
+ '</b></div>' +
+ '<div>' +
+ downloadSize + ' KB' +
+ '</div>' +
+ '</div>' +
+ '<div>' +
+ '<div><b>' +
+ 'Speed: ' +
+ '</b></div>' +
+ '<div>' +
+ animModel.rangeState.speed + ' fps' +
+ '</div>' +
+
+ '</div>' +
+ '<div>' +
+ '<div><b>' +
+ 'Date Range: ' +
+ '</b></div>' +
+ '<div>' +
animModel.rangeState.startDate +
- "</div>" +
- "<div>" +
- " - " +
- "</div>" +
- "<div>" +
+ '</div>' +
+ '<div>' +
+ ' - ' +
+ '</div>' +
+ '<div>' +
animModel.rangeState.endDate +
- "</div>" +
- "</div>" +
- "<div>" +
- "<div><b>" +
- "Increments: " +
- "</b></div>" +
- "<div>" +
+ '</div>' +
+ '</div>' +
+ '<div>' +
+ '<div><b>' +
+ 'Increments: ' +
+ '</b></div>' +
+ '<div>' +
ui.anim.widget.getIncrements() +
- "</div>" +
+ '</div>' +
- "</div>" +
- "</div>";
- var $dialogBodyCase = $("<div></div>");
+ '</div>' +
+ '</div>';
+ var $dialogBodyCase = $('<div></div>');
$dialogBodyCase.addClass('gif-results-dialog-case');
$dialogBodyCase.css('padding', '10px 0');
$dialogBodyCase.append(animatedImage);
$dialogBodyCase.append($catalog);
- //calculate the offset of the dialog position based on image size to display it properly
- //only height needs to be adjusted to center the dialog
+ // calculate the offset of the dialog position based on image size to display it properly
+ // only height needs to be adjusted to center the dialog
var pos_width = animCoords.w * 1 / window.innerWidth,
pos_height = animCoords.h * 50 / window.innerHeight;
- var at_string = "center-" + pos_width.toFixed() + "% center-" + pos_height.toFixed() + "%";
+ var at_string = 'center-' + pos_width.toFixed() + '% center-' + pos_height.toFixed() + '%';
- //Create a dialog over the view and place the image there
+ // Create a dialog over the view and place the image there
var $imgDialog = wv.ui.getDialog()
.append($dialogBodyCase)
.append($download);
$imgDialog.dialog({
- dialogClass: "wv-panel wv-gif-results",
- title: "Your GIF",
+ dialogClass: 'wv-panel wv-gif-results',
+ title: 'Your GIF',
width: animCoords.w + 198,
resizable: false,
- close: function() {
+ close: function () {
animCoords = null;
- $imgDialog.find("img")
+ $imgDialog.find('img')
.remove();
$('#timeline-footer')
.toggleClass('wv-anim-active');
},
- position: { //based on image size
- my: "center center",
+ position: { // based on image size
+ my: 'center center',
at: at_string,
of: window
}
@@ -574,11 +568,11 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
var headerMsg = "<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";
var bodyMsg = 'One or more of the frames requested was unable to be processed';
wv.ui.indicator.hide(loader);
- callback = function() {
+ callback = function () {
$('#timeline-footer')
.toggleClass('wv-anim-active');
};
- wv.ui.notify(headerMsg + bodyMsg, "Notice", 600, callback);
+ wv.ui.notify(headerMsg + bodyMsg, 'Notice', 600, callback);
}
};
@@ -594,11 +588,11 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {number} Size of frame
*
*/
- var calcSize = function(c) {
+ var calcSize = function (c) {
var lonlat1 = ui.map.selected.getCoordinateFromPixel([Math.floor(c.x), Math.floor(c.y2)]),
lonlat2 = ui.map.selected.getCoordinateFromPixel([Math.floor(c.x2), Math.floor(c.y)]);
- var conversionFactor = models.proj.selected.id === "geographic" ? 0.002197 : 256,
+ var conversionFactor = models.proj.selected.id === 'geographic' ? 0.002197 : 256,
res = calcRes(0);
var imgWidth = Math.round((Math.abs(lonlat2[0] - lonlat1[0]) / conversionFactor) / Number(res)),
@@ -619,13 +613,12 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var removeCrop = function() {
- $("#wv-map")
- .insertAfter('#productsHolder'); //retain map element before disabling jcrop
+ var removeCrop = function () {
+ $('#wv-map')
+ .insertAfter('#productsHolder'); // retain map element before disabling jcrop
animCoords = undefined;
jcropAPI.destroy();
- if (models.proj.selected.id === "geographic")
- ui.map.events.trigger('selectiondone');
+ if (models.proj.selected.id === 'geographic') { ui.map.events.trigger('selectiondone'); }
};
/*
@@ -639,7 +632,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {JQuery} Selector diaglog element
*
*/
- self.getSelectorDialog = function(width) {
+ self.getSelectorDialog = function (width) {
var $dialogBox;
var $createButton;
var $footer;
@@ -647,28 +640,28 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
var $checkBox;
var dialog =
"<div class='content'>" +
- "Create an animation from " +
- "<b>" +
+ 'Create an animation from ' +
+ '<b>' +
animModel.rangeState.startDate +
- "</b>" +
- " to " +
- "<b>" +
+ '</b>' +
+ ' to ' +
+ '<b>' +
animModel.rangeState.endDate +
- "</b>" +
- " at a rate of " +
+ '</b>' +
+ ' at a rate of ' +
animModel.rangeState.speed +
- " frames per second" +
- "</div>";
- $createButton = $("<a><span class=ui-button-text>Create GIF</span></a>")
- .attr("type", "button")
- .attr("role", "button")
- .attr("class", "ui-button ui-widget ui-state-default ui-button-text-only")
- .hover(function() {
+ ' frames per second' +
+ '</div>';
+ $createButton = $('<a><span class=ui-button-text>Create GIF</span></a>')
+ .attr('type', 'button')
+ .attr('role', 'button')
+ .attr('class', 'ui-button ui-widget ui-state-default ui-button-text-only')
+ .hover(function () {
$(this)
- .addClass("ui-state-hover");
- }, function() {
+ .addClass('ui-state-hover');
+ }, function () {
$(this)
- .removeClass("ui-state-hover");
+ .removeClass('ui-state-hover');
});
$checkBox = $("<div class='wv-checkbox-date'><label for='checkbox-date'><input type='checkbox' title='Check box to remove dates from Animating GIF' name='checkbox-date' class='checkbox-date-input' id='checkbox-date-input'>Include Date Stamps</label></div>");
$footer = $('<div></div>');
@@ -686,30 +679,29 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
paddingBottom: '10px'
});
$dialogBox.dialog({
- dialogClass: "wv-panel wv-image",
- title: "Generate GIF",
+ dialogClass: 'wv-panel wv-image',
+ title: 'Generate GIF',
height: 'auto',
width: width,
minHeight: 40,
minWidth: 287,
resizable: false,
show: {
- effect: "slide",
- direction: "down"
+ effect: 'slide',
+ direction: 'down'
},
position: {
- my: "left top",
- at: "left bottom+10",
- of: $(".jcrop-tracker")
+ my: 'left top',
+ at: 'left bottom+10',
+ of: $('.jcrop-tracker')
},
- close: function(event) {
+ close: function (event) {
destoryCheckboxListeners($checkBox);
- $("#wv-map")
- .insertAfter('#productsHolder'); //retain map element before disabling jcrop
+ $('#wv-map')
+ .insertAfter('#productsHolder'); // retain map element before disabling jcrop
jcropAPI.destroy();
- if (models.proj.selected.id === "geographic")
- ui.map.events.trigger('selectiondone');
+ if (models.proj.selected.id === 'geographic') { ui.map.events.trigger('selectiondone'); }
}
});
return $dialogBox;
@@ -728,7 +720,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var initCheckBox = function($checkBox) {
+ var initCheckBox = function ($checkBox) {
$checkBox.iCheck({
checkboxClass: 'icheckbox_square-red'
});
@@ -748,7 +740,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var onchecked = function(e) {
+ var onchecked = function (e) {
if (e.type === 'ifUnchecked') {
showDates = false;
} else {
@@ -766,7 +758,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var destoryCheckboxListeners = function($checkBox) {
+ var destoryCheckboxListeners = function ($checkBox) {
$checkBox.off('ifChecked', onchecked);
$checkBox.off('ifUnchecked', onchecked);
};
@@ -783,7 +775,7 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var setDialogWidth = function($dialog, width) {
+ var setDialogWidth = function ($dialog, width) {
var $parent;
if (width < 287) {
width = 287;
@@ -792,9 +784,9 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
$parent = $dialog.parent();
$parent.width(width);
$parent.position({
- my: "left top",
- at: "left bottom+10",
- of: $(".jcrop-tracker")
+ my: 'left top',
+ at: 'left bottom+10',
+ of: $('.jcrop-tracker')
});
}
};
@@ -811,10 +803,9 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var setIconFontSize = function($el, width) {
+ var setIconFontSize = function ($el, width) {
var fs = Math.abs(width / 4);
- if (!$el)
- return;
+ if (!$el) { return; }
if (fs <= 30) {
fs = 30;
}
@@ -831,63 +822,60 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
* @returns {void}
*
*/
- var setImageCoords = function() {
+ var setImageCoords = function () {
var starterWidth;
var $dlButton;
var $dialog;
- //Set JCrop selection
- if (previousCoords === null || previousCoords === undefined)
+ // Set JCrop selection
+ if (previousCoords === null || previousCoords === undefined) {
previousCoords = [($(window)
.width() / 2) - 100, ($(window)
.height() / 2) - 100, ($(window)
.width() / 2) + 100, ($(window)
.height() / 2) + 100];
- else
- previousCoords = [previousCoords.x, previousCoords.y, previousCoords.x2, previousCoords.y2];
+ } else { previousCoords = [previousCoords.x, previousCoords.y, previousCoords.x2, previousCoords.y2]; }
- if (models.proj.selected.id === "geographic")
- ui.map.events.trigger('selecting');
+ if (models.proj.selected.id === 'geographic') { ui.map.events.trigger('selecting'); }
starterWidth = previousCoords[0] - previousCoords[2];
- //Start the image cropping. Show the dialog
- $("#wv-map")
+ // Start the image cropping. Show the dialog
+ $('#wv-map')
.Jcrop({
bgColor: 'black',
bgOpacity: 0.3,
fullScreen: true,
setSelect: previousCoords,
- onSelect: function(c) {
+ onSelect: function (c) {
animCoords = c;
- $("#wv-gif-width")
+ $('#wv-gif-width')
.html((c.w));
- $("#wv-gif-height")
+ $('#wv-gif-height')
.html((c.h));
},
- onChange: function(c) { //Update gif size and image size in MB
+ onChange: function (c) { // Update gif size and image size in MB
var modalLeftMargin;
animCoords = c;
- if (c.h !== 0 && c.w !== 0) //don't save coordinates if empty selection
- previousCoords = c;
+ if (c.h !== 0 && c.w !== 0) { previousCoords = c; } // don't save coordinates if empty selection
var dataSize = calcSize(c);
- //Update the gif selection dialog
- $("#wv-gif-width")
+ // Update the gif selection dialog
+ $('#wv-gif-width')
.html((c.w));
- $("#wv-gif-height")
+ $('#wv-gif-height')
.html((c.h));
- $("#wv-gif-size")
- .html(dataSize + " MB");
+ $('#wv-gif-size')
+ .html(dataSize + ' MB');
- if (dataSize > 250) { //disable GIF generation if GIF would be too large
- $("#wv-gif-button")
- .button("disable");
+ if (dataSize > 250) { // disable GIF generation if GIF would be too large
+ $('#wv-gif-button')
+ .button('disable');
} else {
- $("#wv-gif-button")
- .button("enable");
+ $('#wv-gif-button')
+ .button('enable');
}
setDialogWidth($dialog, c.w);
setIconFontSize($dlButton, c.w);
},
- onRelease: function(c) {
+ onRelease: function (c) {
removeCrop();
$('#timeline-footer')
.toggleClass('wv-anim-active');
@@ -895,12 +883,12 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
wv.ui.close();
}
}
- }, function() {
+ }, function () {
var $tracker;
$dlButton =
"<div class='wv-dl-gif-bt-case'>" +
"<i class='fa fa-download'>" +
- "</div>";
+ '</div>';
jcropAPI = this;
$('#timeline-footer')
.toggleClass('wv-anim-active');
@@ -910,8 +898,6 @@ wv.anim.gif = wv.anim.gif || function(models, config, ui) {
$dlButton = $('.wv-dl-gif-bt-case i');
setIconFontSize($dlButton, starterWidth);
$dlButton.on('click', self.getGif);
-
-
});
};
self.init();
diff --git a/web/js/animation/wv.anim.js b/web/js/animation/wv.anim.js
index 8347f717c..7934f81f4 100644
--- a/web/js/animation/wv.anim.js
+++ b/web/js/animation/wv.anim.js
@@ -1,27 +1,26 @@
var wv = wv || {};
-wv.anim = (function(self) {
-
- //Given the raw string, parse state.a into an object
- self.parse = function(state, errors) {
+wv.anim = (function (self) {
+ // Given the raw string, parse state.a into an object
+ self.parse = function (state, errors) {
if (state.a) {
var str = state.a,
astate = {
attributes: []
};
- //Get text before (
+ // Get text before (
var on = str.match(/[^\(,]+/)[0];
- if (on !== 'on') { //don't do anything if wrong format
+ if (on !== 'on') { // don't do anything if wrong format
state.a = undefined;
return;
}
- //remove (, get key value pairs
- str = str.match(/\(.*\)/)[0].replace(/[\(\)]/g, "");
- var kvps = str.split(",");
- _.each(kvps, function(kvp) {
- var parts = kvp.split("=");
+ // remove (, get key value pairs
+ str = str.match(/\(.*\)/)[0].replace(/[\(\)]/g, '');
+ var kvps = str.split(',');
+ _.each(kvps, function (kvp) {
+ var parts = kvp.split('=');
astate.attributes.push({
id: parts[0],
value: parts[1]
diff --git a/web/js/animation/wv.anim.model.js b/web/js/animation/wv.anim.model.js
index 363d35d9a..dc0c7ddb8 100644
--- a/web/js/animation/wv.anim.model.js
+++ b/web/js/animation/wv.anim.model.js
@@ -1,7 +1,7 @@
var wv = wv || {};
wv.anim = wv.anim || {};
-wv.anim.model = wv.anim.model || function(models, config) {
- //state.a is now an object, check input and set values
+wv.anim.model = wv.anim.model || function (models, config) {
+ // state.a is now an object, check input and set values
var self = {};
self.delay = 500;
self.events = wv.util.events();
@@ -25,7 +25,7 @@ wv.anim.model = wv.anim.model || function(models, config) {
* @returns {void}
*
*/
- self.load = function(state, errors) {
+ self.load = function (state, errors) {
self.rangeState = self.rangeState || {};
// self.rangeState.playing = false;
// if(state.a) {
@@ -40,7 +40,6 @@ wv.anim.model = wv.anim.model || function(models, config) {
self.rangeState.state = state.ab;
}
if (state.as && state.ae) {
-
if (state.ae.length == 10 && state.as.length == 10) {
self.rangeState.startDate = state.as;
self.rangeState.endDate = state.ae;
@@ -64,7 +63,7 @@ wv.anim.model = wv.anim.model || function(models, config) {
* @returns {void}
*
*/
- self.toggleActive = function() {
+ self.toggleActive = function () {
if (self.rangeState.state === 'off') {
self.rangeState.state = 'on';
} else {
@@ -82,7 +81,7 @@ wv.anim.model = wv.anim.model || function(models, config) {
*
*/
- self.add = function(arra) {
+ self.add = function (arra) {
// var updatedState = _.clone(self.state);
// arra.forEach(function(prop) {
// updatedState[prop.id] = prop.value;
@@ -99,7 +98,7 @@ wv.anim.model = wv.anim.model || function(models, config) {
* @returns {void}
*
*/
- self.save = function(state) {
+ self.save = function (state) {
var activeState;
var playStates;
var options;
diff --git a/web/js/animation/wv.anim.rangeselect.js b/web/js/animation/wv.anim.rangeselect.js
index 303a76e44..90fe9c6eb 100644
--- a/web/js/animation/wv.anim.rangeselect.js
+++ b/web/js/animation/wv.anim.rangeselect.js
@@ -2,7 +2,7 @@ var wv = wv || {};
wv.anim = wv.anim || {};
-wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
+wv.anim.rangeselect = wv.anim.rangeselect || function (models, config, ui) {
var self = {};
var model;
var timeline = ui.timeline;
@@ -25,7 +25,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {void}
*
*/
- self.init = function() {
+ self.init = function () {
var $animateButton = $('#animate-button');
var options;
@@ -45,7 +45,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {void}
*
*/
- self.setDefaults = function() {
+ self.setDefaults = function () {
/*
* Set some defaults
*/
@@ -67,7 +67,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {void}
*
*/
- self.render = function() {
+ self.render = function () {
var options;
var startLocation;
var EndLocation;
@@ -77,7 +77,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
.width;
var ticHeight = $('.end-tick')
.height();
- var animEndLocation = (d3.transform(pick.attr("transform"))
+ var animEndLocation = (d3.transform(pick.attr('transform'))
.translate[0] - (pickWidth / 2)); // getting guitar pick location
if (model.rangeState.startDate) {
@@ -116,10 +116,10 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {number} OffsetX
*
*/
- self.getHeaderOffset = function() {
+ self.getHeaderOffset = function () {
return $header.width() + Number($timeline.css('left')
- .replace("px", "")) + Number($footer.css('margin-left')
- .replace("px", ""));
+ .replace('px', '')) + Number($footer.css('margin-left')
+ .replace('px', ''));
};
/*
@@ -133,7 +133,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {number} OffsetX
*
*/
- self.getLocationFromStringDate = function(date) {
+ self.getLocationFromStringDate = function (date) {
return timeline.x(new Date(date));
};
@@ -147,7 +147,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {void}
*
*/
- self.update = function() { // being called from timeline.config.js
+ self.update = function () { // being called from timeline.config.js
var props = self.updateOptions();
self.reactComponent.setState(props);
};
@@ -161,7 +161,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {number} max width
*
*/
- self.getMaxWidth = function() {
+ self.getMaxWidth = function () {
var $elWidth = $footer.width();
var $dataWidth = timeline.x(timeline.data.end());
if ($elWidth > $dataWidth) {
@@ -179,7 +179,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {object} props
*
*/
- self.updateOptions = function() {
+ self.updateOptions = function () {
var max;
var state = model.rangeState;
var props = {};
@@ -203,7 +203,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {object} props
*
*/
- self.onRangeClick = function(e) {
+ self.onRangeClick = function (e) {
var headerOffset = self.getHeaderOffset();
var offsetX = (e.pageX - headerOffset);
var date = timeline.x.invert(offsetX);
@@ -223,7 +223,7 @@ wv.anim.rangeselect = wv.anim.rangeselect || function(models, config, ui) {
* @returns {object} props
*
*/
- self.updateRange = function(startLocation, EndLocation) {
+ self.updateRange = function (startLocation, EndLocation) {
var startDate = timeline.x.invert(startLocation);
var endDate = timeline.x.invert(EndLocation);
var state = model.rangeState;
diff --git a/web/js/animation/wv.anim.ui.js b/web/js/animation/wv.anim.ui.js
index 051c7f749..6cd83a852 100644
--- a/web/js/animation/wv.anim.ui.js
+++ b/web/js/animation/wv.anim.ui.js
@@ -1,6 +1,6 @@
var wv = wv || {};
wv.anim = wv.anim || {};
-wv.anim.ui = wv.anim.ui || function(models, ui) {
+wv.anim.ui = wv.anim.ui || function (models, ui) {
var self = {};
self.events = wv.util.events();
var dateModel = models.date;
@@ -26,14 +26,14 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.init = function() {
+ self.init = function () {
self.refreshState();
animModel.events.on('play', self.onPushedPlay);
animModel.events.on('gif-click', self.refreshState);
animModel.events.on('datechange', self.refreshState);
animModel.events.on('toggle-widget', self.refreshState);
if (models.proj) {
- models.proj.events.on("select", self.refreshState);
+ models.proj.events.on('select', self.refreshState);
}
if (models.palettes) {
models.palettes.events.on('update', self.refreshState);
@@ -41,12 +41,12 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
if (models.data) {
models.data.events.on('activate', self.refreshState);
models.date.events.on('zoom-change', self.refreshState);
- models.date.events.on("select", self.dateChange);
+ models.date.events.on('select', self.dateChange);
}
if (ui.map) {
ui.map.events.on('added-layer', self.refreshState);
}
- //map.on('moveend', self.refreshState);
+ // map.on('moveend', self.refreshState);
};
/*
@@ -60,7 +60,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.dateChange = function() {
+ self.dateChange = function () {
if (!self.state.playing) {
self.refreshState();
}
@@ -77,7 +77,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
*
*/
- self.refreshState = function() {
+ self.refreshState = function () {
preloadArray = [];
preload = {};
pastDates = {};
@@ -105,7 +105,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {string} ISO string Date
*
*/
- self.getStartDate = function() {
+ self.getStartDate = function () {
var state;
var endDate;
var startDate;
@@ -129,7 +129,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.onPushedPlay = function() {
+ self.onPushedPlay = function () {
self.checkQueue(queueLength, self.state.playIndex);
self.checkShouldPlay();
};
@@ -143,7 +143,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {string} Zoom increment
*
*/
- self.getInterval = function() {
+ self.getInterval = function () {
return zooms[ui.timeline.config.currentZoom - 1];
};
@@ -159,7 +159,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {object} JS Date
*
*/
- self.nextDate = function(date) {
+ self.nextDate = function (date) {
return wv.util.dateAdd(date, self.getInterval(), 1);
};
@@ -175,12 +175,12 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {object} JS Date
*
*/
- self.addDate = function(date) {
+ self.addDate = function (date) {
self.addToInQueue(date);
- queue.add(function() {
+ queue.add(function () {
return ui.map.promiseDay(date);
})
- .then(function(date) {
+ .then(function (date) {
self.addDateToCache(date);
self.shiftCache();
self.checkQueue(queueLength, self.state.playIndex);
@@ -200,7 +200,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.addToInQueue = function(date) {
+ self.addToInQueue = function (date) {
var strDate = wv.util.toISOStringDate(date);
inQueue[strDate] = date;
preloadArray.push(strDate);
@@ -219,7 +219,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.addDateToCache = function(date) {
+ self.addDateToCache = function (date) {
var strDate = wv.util.toISOStringDate(date);
preload[strDate] = date;
delete inQueue[strDate];
@@ -236,7 +236,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.shiftCache = function() {
+ self.shiftCache = function () {
var key;
if (preload[preloadArray[0]] &&
wv.util.objectLength(preload) > queueLength + (queueLength / 2) + 1 &&
@@ -262,7 +262,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {boolean}
*
*/
- self.isInToPlayGroup = function(testDate) {
+ self.isInToPlayGroup = function (testDate) {
var loop = animModel.rangeState.loop;
var i = 0;
var day = new Date(self.state.playIndex);
@@ -296,7 +296,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.clearCache = function() {
+ self.clearCache = function () {
preload = {};
preloadArray = [];
};
@@ -313,7 +313,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.checkQueue = function(bufferLength, index) {
+ self.checkQueue = function (bufferLength, index) {
var date;
var currentDate;
var startDate = wv.util.parseDateUTC(animModel.rangeState.startDate);
@@ -346,7 +346,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {boolean}
*
*/
- self.hasCustomLayers = function() {
+ self.hasCustomLayers = function () {
var layer;
var layers = models.layers.get();
@@ -373,7 +373,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.customQueuer = function(currentDate, startDate, endDate) {
+ self.customQueuer = function (currentDate, startDate, endDate) {
var nextDateStr;
var nextDate = self.nextDate(currentDate);
if (nextDate > endDate) {
@@ -402,13 +402,13 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.initialPreload = function(currentDate, startDate, endDate, lastToQueue) {
+ self.initialPreload = function (currentDate, startDate, endDate, lastToQueue) {
var day = currentDate;
queueLength = self.getQueueLength(startDate, endDate);
if (queueLength <= 1) { // if only one frame will play just move to that date
dateModel.select(startDate);
animModel.rangeState.playing = false;
- setTimeout(function() {
+ setTimeout(function () {
self.refreshState();
}, 100);
return;
@@ -443,7 +443,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {number} new buffer length
*
*/
- self.getQueueLength = function(startDate, endDate) {
+ self.getQueueLength = function (startDate, endDate) {
var day = startDate;
var i = 0;
while (i < queueLength) {
@@ -469,7 +469,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.addItemToQueue = function(currentDate, startDate, endDate) {
+ self.addItemToQueue = function (currentDate, startDate, endDate) {
var nextDate = self.getNextBufferDate(currentDate, startDate, endDate);
var nextDateStr = wv.util.toISOStringDate(nextDate);
@@ -496,7 +496,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {object} JS Date
*
*/
- self.getNextBufferDate = function(currentDate, startDate, endDate) {
+ self.getNextBufferDate = function (currentDate, startDate, endDate) {
var lastInBuffer = wv.util.parseDateUTC(preloadArray[preloadArray.length - 1]);
var nextDate = self.nextDate(lastInBuffer);
if (lastInBuffer >= endDate || self.nextDate(lastInBuffer) > endDate) {
@@ -519,7 +519,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {string} Date string
*
*/
- self.getLastBufferDateStr = function(currentDate, startDate, endDate) {
+ self.getLastBufferDateStr = function (currentDate, startDate, endDate) {
var day = currentDate;
var loop = animModel.rangeState.loop;
var i = 1;
@@ -530,7 +530,6 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
return wv.util.toISOStringDate(day);
}
day = self.setNewDate(day, startDate);
-
} else {
day = self.nextDate(day);
}
@@ -552,11 +551,11 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.checkShouldLoop = function(playIndexJSDate) {
+ self.checkShouldLoop = function (playIndexJSDate) {
if (animModel.rangeState.loop) {
self.shiftCache();
self.state.playIndex = wv.util.toISOStringDate(self.setNewDate(playIndexJSDate, new Date(animModel.rangeState.startDate)));
- setTimeout(function() {
+ setTimeout(function () {
self.checkShouldPlay();
self.checkQueue(queueLength, self.state.playIndex);
}, 1000);
@@ -578,7 +577,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.checkShouldPlay = function() {
+ self.checkShouldPlay = function () {
var currentDate = wv.util.parseDateUTC(self.state.playIndex);
var fps = 1000 / animModel.rangeState.speed;
var endDate = wv.util.parseDateUTC(animModel.rangeState.endDate);
@@ -612,12 +611,11 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.play = function(index) {
+ self.play = function (index) {
self.state.playing = true;
wv.ui.indicator.hide(loader);
wv.ui.indicator._hide(loader);
self.animate(index);
- return;
};
/*
@@ -633,7 +631,7 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.setNewDate = function(date, newDate) {
+ self.setNewDate = function (date, newDate) {
return newDate;
};
@@ -648,12 +646,12 @@ wv.anim.ui = wv.anim.ui || function(models, ui) {
* @returns {void}
*
*/
- self.animate = function(index) {
+ self.animate = function (index) {
var interval;
var playIndex = index;
var playIndexJSDate;
var endDate = wv.util.parseDateUTC(animModel.rangeState.endDate);
- var player = function() {
+ var player = function () {
self.shiftCache();
self.checkQueue(queueLength, playIndex);
diff --git a/web/js/animation/wv.anim.widget.js b/web/js/animation/wv.anim.widget.js
index c34995206..5cd0af612 100644
--- a/web/js/animation/wv.anim.widget.js
+++ b/web/js/animation/wv.anim.widget.js
@@ -2,7 +2,7 @@ var wv = wv || {};
wv.anim = wv.anim || {};
-wv.anim.widget = wv.anim.widget || function(models, config, ui) {
+wv.anim.widget = wv.anim.widget || function (models, config, ui) {
var zooms = ['yearly', 'monthly', 'daily'];
var self = {};
var timeline = ui.timeline;
@@ -21,17 +21,17 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.init = function() {
+ self.init = function () {
var speed;
var Widget;
Widget = self.initWidget();
- //mount react component
+ // mount react component
$animateButton = $('#animate-button');
self.reactComponent = ReactDOM.render(Widget, $('#wv-animation-widet-case')[0]);
$timelineFooter = $('#timeline-footer');
- $animateButton.on('click', function() {
+ $animateButton.on('click', function () {
WVC.GA.event('Animation', 'Click', 'Animation Icon');
self.toggleAnimationWidget();
});
@@ -39,7 +39,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
$timelineFooter.toggleClass('wv-anim-active');
}
$('.wv-date-selector-widget input')
- .on('keydown', function(e) {
+ .on('keydown', function (e) {
// A bit of a hack
e.stopPropagation(); // needed to correct event bubbling between react and Document
});
@@ -48,11 +48,11 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
models.date.events.on('timeline-change', self.update);
if (models.data) {
dataModel = models.data;
- dataModel.events.on('activate', function() {
+ dataModel.events.on('activate', function () {
self.toggleAnimationWidget();
self.onDataActivate();
});
- dataModel.events.on('deactivate', function() {
+ dataModel.events.on('deactivate', function () {
self.onDataDeactivate();
});
} else {
@@ -60,20 +60,20 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
dataModel.active = false;
}
- //hack for react bug https://github.com/facebook/react/issues/1920
+ // hack for react bug https://github.com/facebook/react/issues/1920
$('.wv-date-selector-widget input')
- .keydown(function(e) {
+ .keydown(function (e) {
if (e.keyCode == 13 || e.keyCode == 9) {
e.preventDefault();
}
});
// Space bar event listener
$(window)
- .keypress(function(e) {
+ .keypress(function (e) {
if ((e.keyCode == 32 ||
e.charCode == 32) && // space click
- !$("#layer-modal")
- .dialog("isOpen")) { //layer selector is not open
+ !$('#layer-modal')
+ .dialog('isOpen')) { // layer selector is not open
e.preventDefault();
self.onSpaceBar();
}
@@ -90,7 +90,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.initWidget = function() {
+ self.initWidget = function () {
var rangeState = model.rangeState;
return widgetFactory({
onPushPlay: self.onPressPlay,
@@ -122,7 +122,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.onSpaceBar = function() {
+ self.onSpaceBar = function () {
if (model.rangeState.state === 'on') {
if (model.rangeState.playing) {
self.onPressPause();
@@ -130,7 +130,6 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
}
self.onPressPlay();
self.update();
- return;
}
};
@@ -144,7 +143,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.update = function() {
+ self.update = function () {
var state = model.rangeState;
self.reactComponent.setState({
startDate: new Date(state.startDate),
@@ -164,7 +163,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {string} timeline interval
*
*/
- self.getIncrements = function() {
+ self.getIncrements = function () {
return zooms[timeline.config.currentZoom - 1];
};
@@ -182,7 +181,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {string} timeline interval
*
*/
- self.onZoomSelect = function(increment) {
+ self.onZoomSelect = function (increment) {
var zoomLevel = _.indexOf(zooms, increment);
return timeline.config.zoom(zoomLevel + 1);
};
@@ -201,7 +200,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.dateUpdate = function(startDate, endDate) {
+ self.dateUpdate = function (startDate, endDate) {
model.rangeState.startDate = wv.util.toISOStringDate(startDate) || 0;
model.rangeState.endDate = wv.util.toISOStringDate(endDate);
model.rangeState.playing = false;
@@ -219,7 +218,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.toggleAnimationWidget = function() {
+ self.toggleAnimationWidget = function () {
// If timeline is hidden, pressing
// the anim icon will open the
// timeline and the anim widget
@@ -227,12 +226,12 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
model.rangeState.state = 'off';
self.makeDateGuess();
}
- if ($timelineFooter.is(":hidden") && !dataModel.active) {
- ui.timeline.toggle(); //toggle
+ if ($timelineFooter.is(':hidden') && !dataModel.active) {
+ ui.timeline.toggle(); // toggle
if (model.rangeState.state === 'on') { // activate anim if not already
return;
}
- setTimeout(function() {
+ setTimeout(function () {
model.events.trigger('change');
model.events.trigger('toggle-widget');
}, 500);
@@ -247,7 +246,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
return $timelineFooter.toggleClass('wv-anim-active');
};
- self.makeDateGuess = function() {
+ self.makeDateGuess = function () {
var start;
var end;
var currentDate = new Date(models.date.selected);
@@ -272,7 +271,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.onPressPlay = function() {
+ self.onPressPlay = function () {
model.rangeState.playing = true;
model.events.trigger('play');
};
@@ -290,7 +289,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.onRateChange = function(speed) {
+ self.onRateChange = function (speed) {
model.rangeState.speed = speed;
model.events.trigger('change');
};
@@ -305,7 +304,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.onPressPause = function() {
+ self.onPressPause = function () {
var state = model.rangeState;
state.playing = false;
model.events.trigger('change');
@@ -322,7 +321,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.onDataActivate = function() {
+ self.onDataActivate = function () {
$animateButton.addClass('wv-disabled-button');
$animateButton.prop('title', 'Animation feature is deactivated when data download feature is active');
};
@@ -338,7 +337,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.onDataDeactivate = function() {
+ self.onDataDeactivate = function () {
$animateButton.removeClass('wv-disabled-button');
$animateButton.prop('title', 'Setup animation');
};
@@ -355,7 +354,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.onPressLoop = function(loop) {
+ self.onPressLoop = function (loop) {
var state = model.rangeState;
state.loop = loop;
model.events.trigger('change');
@@ -372,7 +371,7 @@ wv.anim.widget = wv.anim.widget || function(models, config, ui) {
* @returns {void}
*
*/
- self.onPressGIF = function() {
+ self.onPressGIF = function () {
model.events.trigger('gif-click');
};
self.init();
diff --git a/web/js/data/wv.data.cmr.js b/web/js/data/wv.data.cmr.js
index 1bf3fd116..ec8e7d23e 100644
--- a/web/js/data/wv.data.cmr.js
+++ b/web/js/data/wv.data.cmr.js
@@ -5,27 +5,26 @@ var wv = wv || {};
wv.data = wv.data || {};
wv.data.cmr = wv.data.cmr || {};
-wv.data.cmr.client = wv.data.cmr.client || function(spec) {
-
+wv.data.cmr.client = wv.data.cmr.client || function (spec) {
// Abort query after 45 seconds
var QUERY_TIMEOUT = spec.timeout || 45 * 1000;
var ns = wv.data.cmr.client;
var ajaxOptions = {
- url: "https://cmr.earthdata.nasa.gov/search/",
+ url: 'https://cmr.earthdata.nasa.gov/search/',
traditional: true,
- dataType: "json",
+ dataType: 'json',
timeout: QUERY_TIMEOUT
};
var self = {};
- var init = function() {
+ var init = function () {
ns.ajax = wv.util.ajaxCache();
};
- self.submit = function(parameters) {
+ self.submit = function (parameters) {
var queryParameters = $.extend(true, {}, ajaxOptions, parameters);
var startTimeDelta = parameters.startTimeDelta || 0;
var endTimeDelta = parameters.endTimeDelta || 0;
@@ -48,18 +47,17 @@ wv.data.cmr.client = wv.data.cmr.client || function(spec) {
startTime = startTime.toISOString();
endTime = endTime.toISOString();
queryParameters.data.temporal = startTime + ',' + endTime;
-
}
queryParameters.data.pageSize = '1000';
var deferred = $.Deferred();
- var metrics = "ev=data-download&" + $.param(queryParameters.data, true);
+ var metrics = 'ev=data-download&' + $.param(queryParameters.data, true);
wv.util.metrics(metrics);
ns.ajax.submit(queryParameters)
- .done(function(data) {
+ .done(function (data) {
deferred.resolve(data.feed.entry);
})
- .fail(function(jqXHR, textStatus, errorThrown) {
+ .fail(function (jqXHR, textStatus, errorThrown) {
deferred.reject(jqXHR, textStatus, errorThrown);
});
return deferred.promise();
@@ -67,32 +65,29 @@ wv.data.cmr.client = wv.data.cmr.client || function(spec) {
init();
return self;
-
};
-
-wv.data.cmr.geometry = function(result) {
-
+wv.data.cmr.geometry = function (result) {
var self = {};
self.polygons = [];
- var init = function() {
+ var init = function () {
if (result.polygons) {
initFromPolygons(result.polygons);
} else if (result.boxes) {
initFromBoxes(result.boxes);
} else {
- throw new Error("Unable to find spatial field");
+ throw new Error('Unable to find spatial field');
}
};
- self.toOpenLayers = function() {
+ self.toOpenLayers = function () {
olPolygons = [];
- $.each(self.polygons, function(index, polygon) {
+ $.each(self.polygons, function (index, polygon) {
var olRings = [];
- $.each(polygon, function(index, ring) {
+ $.each(polygon, function (index, ring) {
var olPoints = [];
- $.each(ring, function(index, point) {
+ $.each(ring, function (index, point) {
var p = [point.x, point.y];
olPoints.push(p);
});
@@ -103,12 +98,12 @@ wv.data.cmr.geometry = function(result) {
return olPolygons[0];
};
- var initFromPolygons = function(cmrPolygons) {
- $.each(cmrPolygons, function(index, cmrPolygon) {
+ var initFromPolygons = function (cmrPolygons) {
+ $.each(cmrPolygons, function (index, cmrPolygon) {
var rings = [];
- $.each(cmrPolygon, function(index, cmrRing) {
+ $.each(cmrPolygon, function (index, cmrRing) {
var ring = [];
- var parts = cmrRing.split(" ");
+ var parts = cmrRing.split(' ');
for (var i = 0; i < parts.length; i += 2) {
var y = parseFloat(parts[i]);
var x = parseFloat(parts[i + 1]);
@@ -123,10 +118,10 @@ wv.data.cmr.geometry = function(result) {
});
};
- var initFromBoxes = function(cmrBoxes) {
- $.each(cmrBoxes, function(index, cmrBox) {
+ var initFromBoxes = function (cmrBoxes) {
+ $.each(cmrBoxes, function (index, cmrBox) {
var ring = [];
- var fields = cmrBox.split(" ");
+ var fields = cmrBox.split(' ');
var ymin = parseFloat(fields[0]);
var xmin = parseFloat(fields[1]);
var ymax = parseFloat(fields[2]);
@@ -160,26 +155,24 @@ wv.data.cmr.geometry = function(result) {
return self;
};
-
-wv.data.cmr.mockClient = function(suffix) {
-
+wv.data.cmr.mockClient = function (suffix) {
var endpoint;
var results;
var self = {};
- var init = function() {
+ var init = function () {
if (!suffix) {
- throw new Error("No mock CMR suffix specified");
+ throw new Error('No mock CMR suffix specified');
}
- endpoint = "mock/cmr.cgi-" + suffix;
+ endpoint = 'mock/cmr.cgi-' + suffix;
};
- self.submit = function(parameters) {
- console.warn("Mocking CMR query", endpoint);
+ self.submit = function (parameters) {
+ console.warn('Mocking CMR query', endpoint);
var deferred = $.Deferred();
if (!results) {
- $.getJSON(endpoint, function(data) {
+ $.getJSON(endpoint, function (data) {
try {
results = adjustResults(parameters, data);
deferred.resolve(results.feed.entry);
@@ -187,7 +180,7 @@ wv.data.cmr.mockClient = function(suffix) {
wv.util.error(error);
}
})
- .fail(function(jqXHR, textStatus, errorThrown) {
+ .fail(function (jqXHR, textStatus, errorThrown) {
deferred.reject(jqXHR, textStatus, errorThrown);
});
} else {
@@ -196,13 +189,13 @@ wv.data.cmr.mockClient = function(suffix) {
return deferred.promise();
};
- var adjustResults = function(parameters, data) {
+ var adjustResults = function (parameters, data) {
var day = wvx.models.date.selected;
// Mock data was retrieved for Aug 6, 2013
var resultsDay = new Date(Date.UTC(2013, 7, 6));
var diffDays = (day - resultsDay) / (1000 * 60 * 60 * 24);
- $.each(data.feed.entry, function(index, entry) {
+ $.each(data.feed.entry, function (index, entry) {
var timeStart = wv.util.parseTimestampUTC(entry.time_start);
timeStart.setUTCDate(timeStart.getUTCDate() + diffDays);
entry.time_start = timeStart.toISOString();
@@ -220,12 +213,12 @@ wv.data.cmr.mockClient = function(suffix) {
return self;
};
-wv.data.cmr.REL_DATA = "http://esipfed.org/ns/fedsearch/1.1/data#";
-wv.data.cmr.REL_METADATA = "http://esipfed.org/ns/fedsearch/1.1/metadata#";
-wv.data.cmr.REL_BROWSE = "http://esipfed.org/ns/fedsearch/1.1/browse#";
-wv.data.cmr.DATA_EXTS = ["hdf", "he5", "h5", "hdf5", "nc", "bz2"];
+wv.data.cmr.REL_DATA = 'http://esipfed.org/ns/fedsearch/1.1/data#';
+wv.data.cmr.REL_METADATA = 'http://esipfed.org/ns/fedsearch/1.1/metadata#';
+wv.data.cmr.REL_BROWSE = 'http://esipfed.org/ns/fedsearch/1.1/browse#';
+wv.data.cmr.DATA_EXTS = ['hdf', 'he5', 'h5', 'hdf5', 'nc', 'bz2'];
-wv.data.cmr.roundTime = function(timeString) {
+wv.data.cmr.roundTime = function (timeString) {
var time = wv.util.parseTimestampUTC(timeString);
if (time.getUTCMilliseconds() >= 500) {
time.setUTCSeconds(time.getUTCSeconds() + 1);
diff --git a/web/js/data/wv.data.handler.js b/web/js/data/wv.data.handler.js
index 285b7b3d8..5a1646ccf 100644
--- a/web/js/data/wv.data.handler.js
+++ b/web/js/data/wv.data.handler.js
@@ -6,36 +6,35 @@ wv.data = wv.data || {};
wv.data.handler = wv.data.handler || {};
-wv.data.handler.getByName = function(name) {
+wv.data.handler.getByName = function (name) {
var map = {
- "AquaSwathMultiDay": wv.data.handler.aquaSwathMultiDay,
- "CollectionList": wv.data.handler.collectionList,
- "CollectionMix": wv.data.handler.collectionMix,
- "List": wv.data.handler.list,
- "DailyGranuleList": wv.data.handler.dailyGranuleList,
- "DailyAMSRE": wv.data.handler.dailyAMSRE,
- "MODISGrid": wv.data.handler.modisGrid,
- "MODISMix": wv.data.handler.modisMix,
- "MODISSwath": wv.data.handler.modisSwath,
- "TerraSwathMultiDay": wv.data.handler.terraSwathMultiDay,
- "HalfOrbit": wv.data.handler.halfOrbit
+ 'AquaSwathMultiDay': wv.data.handler.aquaSwathMultiDay,
+ 'CollectionList': wv.data.handler.collectionList,
+ 'CollectionMix': wv.data.handler.collectionMix,
+ 'List': wv.data.handler.list,
+ 'DailyGranuleList': wv.data.handler.dailyGranuleList,
+ 'DailyAMSRE': wv.data.handler.dailyAMSRE,
+ 'MODISGrid': wv.data.handler.modisGrid,
+ 'MODISMix': wv.data.handler.modisMix,
+ 'MODISSwath': wv.data.handler.modisSwath,
+ 'TerraSwathMultiDay': wv.data.handler.terraSwathMultiDay,
+ 'HalfOrbit': wv.data.handler.halfOrbit
};
var handler = map[name];
if (!handler) {
- throw new Error("No such handler: " + name);
+ throw new Error('No such handler: ' + name);
}
return handler;
};
-
-wv.data.handler.base = function(config, model) {
+wv.data.handler.base = function (config, model) {
var self = {};
self.events = wv.util.events();
self.cmr = null;
self.ajax = null;
- var init = function() {
+ var init = function () {
var ns = wv.data.handler.base;
if (!ns.cmr) {
if (config.parameters.mockCMR) {
@@ -55,41 +54,41 @@ wv.data.handler.base = function(config, model) {
self.ajax = ns.ajax;
self.extents = {};
- $.each(config.projections, function(key, projection) {
+ $.each(config.projections, function (key, projection) {
self.extents[projection.crs] = projection.maxExtent;
});
};
- self.submit = function() {
+ self.submit = function () {
var productConfig = config.products[model.selectedProduct].query;
var queryData = $.extend(true, {}, productConfig);
var promise = self._submit(queryData);
var queriedProduct = model.selectedProduct;
- promise.done(function(data) {
+ promise.done(function (data) {
try {
if (model.selectedProduct !== queriedProduct) {
- self.events.trigger("results", {
+ self.events.trigger('results', {
granules: [],
meta: {}
});
return;
}
var results = self._processResults(data);
- self.events.trigger("results", results);
+ self.events.trigger('results', results);
} catch (error) {
- self.events.trigger("error", "exception", error);
+ self.events.trigger('error', 'exception', error);
}
})
- .fail(function(jqXHR, textStatus, errorThrown) {
- if (textStatus === "timeout") {
- self.events.trigger("timeout");
+ .fail(function (jqXHR, textStatus, errorThrown) {
+ if (textStatus === 'timeout') {
+ self.events.trigger('timeout');
} else {
- self.events.trigger("error", textStatus, errorThrown);
+ self.events.trigger('error', textStatus, errorThrown);
}
});
- if (promise.state() === "pending") {
- self.events.trigger("query");
+ if (promise.state() === 'pending') {
+ self.events.trigger('query');
}
};
@@ -97,19 +96,18 @@ wv.data.handler.base = function(config, model) {
return self;
};
-
-wv.data.handler.modisSwathMultiDay = function(config, model, spec) {
+wv.data.handler.modisSwathMultiDay = function (config, model, spec) {
var startTimeDelta = spec.startTimeDelta || 0;
var endTimeDelta = spec.endTimeDelta || 0;
var self = wv.data.handler.base(config, model);
- var init = function() {
+ var init = function () {
self.extents[wv.map.CRS_WGS_84] =
wv.map.CRS_WGS_84_QUERY_EXTENT;
};
- self._submit = function(queryData) {
+ self._submit = function (queryData) {
var queryOptions = {
time: model.time,
startTimeDelta: startTimeDelta,
@@ -120,7 +118,7 @@ wv.data.handler.modisSwathMultiDay = function(config, model, spec) {
return self.cmr.submit(queryOptions);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var results = {
meta: {},
granules: data
@@ -160,7 +158,7 @@ wv.data.handler.modisSwathMultiDay = function(config, model, spec) {
return self;
};
-wv.data.handler.aquaSwathMultiDay = function(config, model) {
+wv.data.handler.aquaSwathMultiDay = function (config, model) {
var spec = {
startTimeDelta: -180,
endTimeDelta: 180,
@@ -173,8 +171,7 @@ wv.data.handler.aquaSwathMultiDay = function(config, model) {
return $.extend(true, self, spec);
};
-
-wv.data.handler.terraSwathMultiDay = function(config, model) {
+wv.data.handler.terraSwathMultiDay = function (config, model) {
var spec = {
startTimeDelta: -180,
endTimeDelta: 180,
@@ -187,11 +184,10 @@ wv.data.handler.terraSwathMultiDay = function(config, model) {
return $.extend(true, self, spec);
};
-
-wv.data.handler.collectionList = function(config, model, spec) {
+wv.data.handler.collectionList = function (config, model, spec) {
var self = wv.data.handler.base(config, model);
- self._submit = function(queryData) {
+ self._submit = function (queryData) {
var queryOptions = {
data: queryData,
search: 'collections.json'
@@ -200,7 +196,7 @@ wv.data.handler.collectionList = function(config, model, spec) {
return self.cmr.submit(queryOptions);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var results = {
meta: {},
granules: data
@@ -224,13 +220,12 @@ wv.data.handler.collectionList = function(config, model, spec) {
return self;
};
-wv.data.handler.collectionMix = function(config, model, spec) {
-
+wv.data.handler.collectionMix = function (config, model, spec) {
var self = wv.data.handler.base(config, model);
var nrtHandler;
var scienceHandler;
- var init = function() {
+ var init = function () {
var productConfig = config.products[model.selectedProduct];
var nrtHandlerName = productConfig.nrt.handler;
@@ -244,8 +239,7 @@ wv.data.handler.collectionMix = function(config, model, spec) {
scienceHandler = scienceHandlerFactory(config, model, spec);
};
- self._submit = function() {
-
+ self._submit = function () {
var nrtQueryOptions = {
time: model.time,
startTimeDelta: nrtHandler.startTimeDelta,
@@ -264,20 +258,20 @@ wv.data.handler.collectionMix = function(config, model, spec) {
return wv.util.ajaxJoin([
{
- item: "nrt",
+ item: 'nrt',
promise: nrt
},
{
- item: "science",
+ item: 'science',
promise: science
}
]);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var useNRT = false;
if (data.nrt.length > 0 && data.science.length > 0) {
- useNRT = (model.prefer === "nrt");
+ useNRT = (model.prefer === 'nrt');
} else {
useNRT = (data.nrt.length > 0);
}
@@ -293,11 +287,10 @@ wv.data.handler.collectionMix = function(config, model, spec) {
return self;
};
-
-wv.data.handler.list = function(config, model, spec) {
+wv.data.handler.list = function (config, model, spec) {
var self = wv.data.handler.base(config, model);
- self._submit = function(queryData) {
+ self._submit = function (queryData) {
var queryOptions = {
startTimeDelta: 1,
endTimeDelta: -1,
@@ -308,7 +301,7 @@ wv.data.handler.list = function(config, model, spec) {
return self.cmr.submit(queryOptions);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var results = {
meta: {},
granules: data
@@ -335,10 +328,10 @@ wv.data.handler.list = function(config, model, spec) {
return self;
};
-wv.data.handler.dailyGranuleList = function(config, model, spec) {
+wv.data.handler.dailyGranuleList = function (config, model, spec) {
var self = wv.data.handler.list(config, model, spec);
- self._submit = function(queryData) {
+ self._submit = function (queryData) {
var queryOptions = {
startTimeDelta: 180,
endTimeDelta: -180,
@@ -352,11 +345,10 @@ wv.data.handler.dailyGranuleList = function(config, model, spec) {
return self;
};
-wv.data.handler.dailyAMSRE = function(config, model, spec) {
-
+wv.data.handler.dailyAMSRE = function (config, model, spec) {
var self = wv.data.handler.base(config, model);
- self._submit = function(queryData) {
+ self._submit = function (queryData) {
var queryOptions = {
startTimeDelta: 180,
endTimeDelta: -180,
@@ -367,7 +359,7 @@ wv.data.handler.dailyAMSRE = function(config, model, spec) {
return self.cmr.submit(queryOptions);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var results = {
meta: {},
granules: data
@@ -390,11 +382,11 @@ wv.data.handler.dailyAMSRE = function(config, model, spec) {
return self;
};
-wv.data.handler.modisGrid = function(config, model, spec) {
+wv.data.handler.modisGrid = function (config, model, spec) {
var self = wv.data.handler.base(config, model);
- self._submit = function() {
- var crs = model.crs.replace(/:/, "_");
+ self._submit = function () {
+ var crs = model.crs.replace(/:/, '_');
var queryOptions = {
startTimeDelta: 1,
@@ -405,24 +397,24 @@ wv.data.handler.modisGrid = function(config, model, spec) {
var granules = self.cmr.submit(queryOptions);
var grid = self.ajax.submit({
- url: "data/MODIS_Grid." + crs + ".json?v=" + wv.brand.BUILD_NONCE,
- dataType: "json"
+ url: 'data/MODIS_Grid.' + crs + '.json?v=' + wv.brand.BUILD_NONCE,
+ dataType: 'json'
});
var promise = $.Deferred();
return wv.util.ajaxJoin([
{
- item: "granules",
+ item: 'granules',
promise: granules
},
{
- item: "grid",
+ item: 'grid',
promise: grid
}
]);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var productConfig = config.products[model.selectedProduct];
var results = {
meta: {
@@ -450,14 +442,12 @@ wv.data.handler.modisGrid = function(config, model, spec) {
return self;
};
-
-wv.data.handler.modisMix = function(config, model, spec) {
-
+wv.data.handler.modisMix = function (config, model, spec) {
var self = wv.data.handler.base(config, model);
var nrtHandler;
var scienceHandler;
- var init = function() {
+ var init = function () {
var productConfig = config.products[model.selectedProduct];
var nrtHandlerName = productConfig.nrt.handler;
@@ -471,8 +461,8 @@ wv.data.handler.modisMix = function(config, model, spec) {
scienceHandler = scienceHandlerFactory(config, model, spec);
};
- self._submit = function() {
- var crs = model.crs.replace(/:/, "_");
+ self._submit = function () {
+ var crs = model.crs.replace(/:/, '_');
var nrtQueryOptions = {
time: model.time,
@@ -489,30 +479,30 @@ wv.data.handler.modisMix = function(config, model, spec) {
var science = self.cmr.submit(scienceQueryOptions);
var grid = self.ajax.submit({
- url: "data/MODIS_Grid." + crs + ".json?v=" + wv.brand.BUILD_NONCE,
- dataType: "json"
+ url: 'data/MODIS_Grid.' + crs + '.json?v=' + wv.brand.BUILD_NONCE,
+ dataType: 'json'
});
return wv.util.ajaxJoin([
{
- item: "nrt",
+ item: 'nrt',
promise: nrt
},
{
- item: "science",
+ item: 'science',
promise: science
},
{
- item: "grid",
+ item: 'grid',
promise: grid
}
]);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var useNRT = false;
if (data.nrt.length > 0 && data.science.length > 0) {
- useNRT = (model.prefer === "nrt");
+ useNRT = (model.prefer === 'nrt');
} else {
useNRT = (data.nrt.length > 0);
}
@@ -531,18 +521,16 @@ wv.data.handler.modisMix = function(config, model, spec) {
return self;
};
-
-wv.data.handler.modisSwath = function(config, model, spec) {
-
+wv.data.handler.modisSwath = function (config, model, spec) {
var MAX_DISTANCE = 270;
var self = wv.data.handler.base(config, model);
- var init = function() {
+ var init = function () {
self.extents[wv.map.CRS_WGS_84] =
wv.map.CRS_WGS_84_QUERY_EXTENT;
};
- self._submit = function(queryData) {
+ self._submit = function (queryData) {
var queryOptions = {
time: model.time,
data: queryData
@@ -551,7 +539,7 @@ wv.data.handler.modisSwath = function(config, model, spec) {
return self.cmr.submit(queryOptions);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var results = {
meta: {},
granules: data
@@ -587,16 +575,15 @@ wv.data.handler.modisSwath = function(config, model, spec) {
return self;
};
-wv.data.handler.halfOrbit = function(config, model, spec) {
-
+wv.data.handler.halfOrbit = function (config, model, spec) {
var self = wv.data.handler.base(config, model);
- var init = function() {
+ var init = function () {
self.extents[wv.map.CRS_WGS_84] =
wv.map.CRS_WGS_84_QUERY_EXTENT;
};
- self._submit = function(queryData) {
+ self._submit = function (queryData) {
var queryOptions = {
time: model.time,
data: queryData
@@ -605,7 +592,7 @@ wv.data.handler.halfOrbit = function(config, model, spec) {
return self.cmr.submit(queryOptions);
};
- self._processResults = function(data) {
+ self._processResults = function (data) {
var results = {
meta: {},
granules: data
@@ -633,7 +620,7 @@ wv.data.handler.halfOrbit = function(config, model, spec) {
ns.transform(model.crs),
ns.timeLabel(model.time)
];
- console.log("before process", results);
+ console.log('before process', results);
return chain.process(results);
};
diff --git a/web/js/data/wv.data.js b/web/js/data/wv.data.js
index 133e5ac17..b21831311 100644
--- a/web/js/data/wv.data.js
+++ b/web/js/data/wv.data.js
@@ -1,8 +1,7 @@
var wv = wv || {};
-wv.data = (function(self) {
-
- self.parse = function(state, errors, config) {
+wv.data = (function (self) {
+ self.parse = function (state, errors, config) {
if (state.dataDownload) {
state.download = state.dataDownload;
delete state.dataDownload;
@@ -12,12 +11,11 @@ wv.data = (function(self) {
if (!config.products[productId]) {
delete state.download;
errors.push({
- message: "No such product: " + productId
+ message: 'No such product: ' + productId
});
}
}
};
return self;
-
})(wv.data || {});
diff --git a/web/js/data/wv.data.map.js b/web/js/data/wv.data.map.js
index 16cfd2e36..e7ff3136e 100644
--- a/web/js/data/wv.data.map.js
+++ b/web/js/data/wv.data.map.js
@@ -1,8 +1,7 @@
var wv = wv || {};
wv.data = wv.data || {};
-wv.data.map = wv.data.map || function(model, maps, config) {
-
+wv.data.map = wv.data.map || function (model, maps, config) {
var self = {};
var map = null;
@@ -15,24 +14,24 @@ wv.data.map = wv.data.map || function(model, maps, config) {
var hovering = null;
var selectedFeatures = null;
- var init = function() {
+ var init = function () {
model.events
- .on("activate", updateProjection)
- .on("query", clear)
- .on("queryResults", updateGranules)
- .on("projectionUpdate", updateProjection)
- .on("granuleSelect", selectGranule)
- .on("granuleUnselect", unselectGranule);
+ .on('activate', updateProjection)
+ .on('query', clear)
+ .on('queryResults', updateGranules)
+ .on('projectionUpdate', updateProjection)
+ .on('granuleSelect', selectGranule)
+ .on('granuleUnselect', unselectGranule);
updateProjection();
};
- var buttonStyle = function(feature) {
+ var buttonStyle = function (feature) {
var dim = getButtonDimensions();
var image;
if (model.isSelected(feature.granule)) {
- image = "images/data.minus-button.png";
+ image = 'images/data.minus-button.png';
} else {
- image = "images/data.plus-button.png";
+ image = 'images/data.plus-button.png';
}
if (feature !== hovering) {
@@ -50,13 +49,13 @@ wv.data.map = wv.data.map || function(model, maps, config) {
scale: dim.scale
}),
text: new ol.style.Text({
- font: "bold 14px ‘Lucida Sans’, Arial, Sans-Serif",
+ font: 'bold 14px ‘Lucida Sans’, Arial, Sans-Serif',
text: feature.granule.label,
fill: new ol.style.Fill({
- color: "#ffffff"
+ color: '#ffffff'
}),
stroke: new ol.style.Stroke({
- color: "rgba(0, 0, 0, .7)",
+ color: 'rgba(0, 0, 0, .7)',
width: 5
}),
offsetY: offset
@@ -65,31 +64,31 @@ wv.data.map = wv.data.map || function(model, maps, config) {
}
};
- var hoverStyle = function(feature) {
+ var hoverStyle = function (feature) {
if (!model.isSelected(feature.granule)) {
return [new ol.style.Style({
fill: new ol.style.Fill({
- color: "rgba(181, 158, 50, 0.25)"
+ color: 'rgba(181, 158, 50, 0.25)'
}),
stroke: new ol.style.Stroke({
- color: "rgb(251, 226, 109)",
+ color: 'rgb(251, 226, 109)',
width: 3
})
})];
} else {
return [new ol.style.Style({
fill: new ol.style.Fill({
- color: "rgba(242, 12, 12, 0.25)"
+ color: 'rgba(242, 12, 12, 0.25)'
}),
stroke: new ol.style.Stroke({
- color: "rgb(255, 6, 0)",
+ color: 'rgb(255, 6, 0)',
width: 3
})
})];
}
};
- var createButtonLayer = function() {
+ var createButtonLayer = function () {
buttonLayer = new ol.layer.Vector({
source: new ol.source.Vector({
wrapX: false
@@ -99,7 +98,7 @@ wv.data.map = wv.data.map || function(model, maps, config) {
map.addLayer(buttonLayer);
};
- var createHoverLayer = function() {
+ var createHoverLayer = function () {
hoverLayer = new ol.layer.Vector({
source: new ol.source.Vector({
wrapX: false
@@ -109,17 +108,17 @@ wv.data.map = wv.data.map || function(model, maps, config) {
map.addLayer(hoverLayer);
};
- var createSelectionLayer = function() {
+ var createSelectionLayer = function () {
selectionLayer = new ol.layer.Vector({
source: new ol.source.Vector({
wrapX: false
}),
style: new ol.style.Style({
fill: new ol.style.Fill({
- color: "rgba(127, 127, 127, 0.2)"
+ color: 'rgba(127, 127, 127, 0.2)'
}),
stroke: new ol.style.Stroke({
- color: "rgb(127, 127, 127)",
+ color: 'rgb(127, 127, 127)',
width: 3
}),
opacity: 0.6
@@ -128,14 +127,14 @@ wv.data.map = wv.data.map || function(model, maps, config) {
map.addLayer(selectionLayer);
};
- var createSwathLayer = function() {
+ var createSwathLayer = function () {
swathLayer = new ol.layer.Vector({
source: new ol.source.Vector({
wrapX: false
}),
style: new ol.style.Style({
stroke: new ol.style.Stroke({
- color: "rgba(195, 189, 123, 0.75)",
+ color: 'rgba(195, 189, 123, 0.75)',
width: 2
})
})
@@ -143,14 +142,14 @@ wv.data.map = wv.data.map || function(model, maps, config) {
map.addLayer(swathLayer);
};
- var createGridLayer = function() {
+ var createGridLayer = function () {
gridLayer = new ol.layer.Vector({
source: new ol.source.Vector({
wrapX: false
}),
style: new ol.style.Style({
stroke: new ol.style.Stroke({
- color: "rgba(186, 180, 152, 0.6)",
+ color: 'rgba(186, 180, 152, 0.6)',
width: 1.5
})
})
@@ -158,20 +157,19 @@ wv.data.map = wv.data.map || function(model, maps, config) {
map.addLayer(gridLayer);
};
- var create = function() {
-
+ var create = function () {
createSelectionLayer();
createGridLayer();
createSwathLayer();
createHoverLayer();
createButtonLayer();
$(maps.selected.getViewport())
- .on("mousemove", hoverCheck);
+ .on('mousemove', hoverCheck);
$(maps.selected.getViewport())
- .on("click", clickCheck);
+ .on('click', clickCheck);
};
- var dispose = function() {
+ var dispose = function () {
if (map) {
map.removeLayer(selectionLayer);
map.removeLayer(gridLayer);
@@ -181,20 +179,20 @@ wv.data.map = wv.data.map || function(model, maps, config) {
}
selectedFeatures = [];
$(maps.selected.getViewport())
- .off("mousemove", hoverCheck);
+ .off('mousemove', hoverCheck);
$(maps.selected.getViewport())
- .off("click", clickCheck);
+ .off('click', clickCheck);
};
self.dispose = dispose;
- var updateGranules = function(r) {
- //console.log("results");
+ var updateGranules = function (r) {
+ // console.log("results");
results = r;
granules = r.granules;
updateButtons();
updateSwaths();
updateGrid();
- _.each(model.selectedGranules, function(granule) {
+ _.each(model.selectedGranules, function (granule) {
if (selectedFeatures[granule.id]) {
selectionLayer.getSource()
.removeFeature(selectedFeatures[granule.id]);
@@ -204,11 +202,11 @@ wv.data.map = wv.data.map || function(model, maps, config) {
});
};
- var updateButtons = function() {
+ var updateButtons = function () {
buttonLayer.getSource()
.clear();
var features = [];
- _.each(granules, function(granule) {
+ _.each(granules, function (granule) {
if (!granule.centroid || !granule.centroid[model.crs]) {
return;
}
@@ -225,27 +223,27 @@ wv.data.map = wv.data.map || function(model, maps, config) {
.addFeatures(features);
};
- var updateSwaths = function() {
+ var updateSwaths = function () {
swathLayer.getSource()
.clear();
var swaths = results.meta.swaths;
if (!swaths) {
return;
}
- var maxDistance = (model.crs === wv.map.CRS_WGS_84) ?
- 270 : Number.POSITIVE_INFINITY;
+ var maxDistance = (model.crs === wv.map.CRS_WGS_84)
+ ? 270 : Number.POSITIVE_INFINITY;
var features = [];
- _.each(swaths, function(swath) {
+ _.each(swaths, function (swath) {
var lastGranule = null;
- _.each(swath, function(granule) {
+ _.each(swath, function (granule) {
if (!lastGranule) {
lastGranule = granule;
return;
}
var polys1 = wv.map.toPolys(lastGranule.geometry[model.crs]);
var polys2 = wv.map.toPolys(granule.geometry[model.crs]);
- _.each(polys1, function(poly1) {
- _.each(polys2, function(poly2) {
+ _.each(polys1, function (poly1) {
+ _.each(polys2, function (poly2) {
var c1 = poly1.getInteriorPoint()
.getCoordinates();
var c2 = poly2.getInteriorPoint()
@@ -264,7 +262,7 @@ wv.data.map = wv.data.map || function(model, maps, config) {
.addFeatures(features);
};
- var updateGrid = function() {
+ var updateGrid = function () {
gridLayer.getSource()
.clear();
var grid = results.meta.grid;
@@ -273,7 +271,7 @@ wv.data.map = wv.data.map || function(model, maps, config) {
}
var features = [];
var parser = new ol.format.GeoJSON();
- _.each(grid, function(cell) {
+ _.each(grid, function (cell) {
var geom = parser.readGeometry(cell.geometry);
var feature = new ol.Feature(geom);
features.push(feature);
@@ -282,39 +280,39 @@ wv.data.map = wv.data.map || function(model, maps, config) {
.addFeatures(features);
};
- var selectGranule = function(granule) {
+ var selectGranule = function (granule) {
if (!granule.feature) {
return;
}
granule.feature.changed();
var select = new ol.Feature(granule.geometry[model.crs]);
select.granule = granule;
- //granule.selectedFeature = select;
+ // granule.selectedFeature = select;
selectionLayer.getSource()
.addFeature(select);
selectedFeatures[granule.id] = select;
};
- var unselectGranule = function(granule) {
+ var unselectGranule = function (granule) {
if (!granule.feature) {
return;
}
granule.feature.changed();
- //selectionLayer.getSource().removeFeature(granule.selectedFeature);
- //delete granule.selectedFeature;
+ // selectionLayer.getSource().removeFeature(granule.selectedFeature);
+ // delete granule.selectedFeature;
selectionLayer.getSource()
.removeFeature(selectedFeatures[granule.id]);
delete selectedFeatures[granule.id];
};
- var updateProjection = function() {
+ var updateProjection = function () {
dispose();
map = maps.selected;
create();
};
- var clear = function() {
- //console.log("clear");
+ var clear = function () {
+ // console.log("clear");
if (map) {
swathLayer.getSource()
.clear();
@@ -327,10 +325,10 @@ wv.data.map = wv.data.map || function(model, maps, config) {
}
};
- var hoverCheck = function(event) {
+ var hoverCheck = function (event) {
var pixel = map.getEventPixel(event.originalEvent);
var newFeature = null;
- map.forEachFeatureAtPixel(pixel, function(feature, layer) {
+ map.forEachFeatureAtPixel(pixel, function (feature, layer) {
if (feature.button) {
newFeature = feature;
}
@@ -352,9 +350,9 @@ wv.data.map = wv.data.map || function(model, maps, config) {
hovering = newFeature;
};
- var clickCheck = function(event) {
+ var clickCheck = function (event) {
var pixel = map.getEventPixel(event.originalEvent);
- map.forEachFeatureAtPixel(pixel, function(feature, layer) {
+ map.forEachFeatureAtPixel(pixel, function (feature, layer) {
if (feature.button) {
model.toggleGranule(feature.granule);
hovering = false;
@@ -363,7 +361,7 @@ wv.data.map = wv.data.map || function(model, maps, config) {
});
};
- var hoverOver = function(feature) {
+ var hoverOver = function (feature) {
granule = feature.granule;
if (!granule.geometry) {
return;
@@ -376,12 +374,12 @@ wv.data.map = wv.data.map || function(model, maps, config) {
.addFeature(hover);
};
- var hoverOut = function() {
+ var hoverOut = function () {
hoverLayer.getSource()
.clear();
};
- var getButtonDimensions = function() {
+ var getButtonDimensions = function () {
var zoom = map.getView()
.getZoom();
// Minimum size of the button is 15 pixels
diff --git a/web/js/data/wv.data.model.js b/web/js/data/wv.data.model.js
index aa5c89663..a5b1fe244 100644
--- a/web/js/data/wv.data.model.js
+++ b/web/js/data/wv.data.model.js
@@ -9,9 +9,8 @@ wv.data = wv.data || {};
*
* @class wv.data.model
*/
-wv.data.model = wv.data.model || function(models, config) {
-
- var NO_PRODUCT_ID = "__NO_PRODUCT";
+wv.data.model = wv.data.model || function (models, config) {
+ var NO_PRODUCT_ID = '__NO_PRODUCT';
var NO_PRODUCT = {
name: "Not available for download &nbsp;&nbsp;<span class='link'>(?)</span>",
notSelectable: true
@@ -35,7 +34,7 @@ wv.data.model = wv.data.model || function(models, config) {
* @event EVENT_ACTIVATE
* @final
*/
- self.EVENT_ACTIVATE = "activate";
+ self.EVENT_ACTIVATE = 'activate';
/**
* Fired when the data download mode is deactivated.
@@ -43,17 +42,17 @@ wv.data.model = wv.data.model || function(models, config) {
* @event EVENT_ACTIVATE
* @final
*/
- self.EVENT_DEACTIVATE = "deactivate";
-
- self.EVENT_PRODUCT_SELECT = "productSelect";
- self.EVENT_LAYER_UPDATE = "layerUpdate";
- self.EVENT_QUERY = "query";
- self.EVENT_QUERY_RESULTS = "queryResults";
- self.EVENT_QUERY_CANCEL = "queryCancel";
- self.EVENT_QUERY_ERROR = "queryError";
- self.EVENT_QUERY_TIMEOUT = "queryTimeout";
- self.EVENT_GRANULE_SELECT = "granuleSelect";
- self.EVENT_GRANULE_UNSELECT = "granuleUnselect";
+ self.EVENT_DEACTIVATE = 'deactivate';
+
+ self.EVENT_PRODUCT_SELECT = 'productSelect';
+ self.EVENT_LAYER_UPDATE = 'layerUpdate';
+ self.EVENT_QUERY = 'query';
+ self.EVENT_QUERY_RESULTS = 'queryResults';
+ self.EVENT_QUERY_CANCEL = 'queryCancel';
+ self.EVENT_QUERY_ERROR = 'queryError';
+ self.EVENT_QUERY_TIMEOUT = 'queryTimeout';
+ self.EVENT_GRANULE_SELECT = 'granuleSelect';
+ self.EVENT_GRANULE_UNSELECT = 'granuleUnselect';
/**
* Indicates if data download mode is active.
@@ -75,7 +74,7 @@ wv.data.model = wv.data.model || function(models, config) {
self.selectedProduct = null;
self.selectedGranules = {};
- self.prefer = "science";
+ self.prefer = 'science';
self.granules = [];
@@ -86,10 +85,10 @@ wv.data.model = wv.data.model || function(models, config) {
self.crs = null;
self.time = null;
- var init = function() {
- models.layers.events.on("change", updateLayers);
- models.proj.events.on("select", updateProjection);
- models.date.events.on("select", updateDate);
+ var init = function () {
+ models.layers.events.on('change', updateLayers);
+ models.proj.events.on('select', updateProjection);
+ models.date.events.on('select', updateDate);
updateLayers();
updateProjection();
updateDate();
@@ -101,7 +100,7 @@ wv.data.model = wv.data.model || function(models, config) {
*
* @method activate
*/
- self.activate = function(productName) {
+ self.activate = function (productName) {
if (!self.active) {
try {
if (productName) {
@@ -132,7 +131,7 @@ wv.data.model = wv.data.model || function(models, config) {
*
* @method deactivate
*/
- self.deactivate = function() {
+ self.deactivate = function () {
if (self.active) {
self.active = false;
self.events.trigger(self.EVENT_DEACTIVATE);
@@ -145,7 +144,7 @@ wv.data.model = wv.data.model || function(models, config) {
*
* @method toggleMode
*/
- self.toggleMode = function() {
+ self.toggleMode = function () {
if (self.active) {
self.deactivate();
} else {
@@ -153,9 +152,9 @@ wv.data.model = wv.data.model || function(models, config) {
}
};
- self.groupByProducts = function() {
+ self.groupByProducts = function () {
var products = {};
- $.each(self.layers, function(index, layer) {
+ $.each(self.layers, function (index, layer) {
var productId = layer.product || NO_PRODUCT_ID;
var product = config.products[productId] || NO_PRODUCT;
if (!products[productId]) {
@@ -179,7 +178,7 @@ wv.data.model = wv.data.model || function(models, config) {
// especially for IE9. This whole function needs clean up.
var results = {};
var none = products.__NO_PRODUCT;
- _.each(products, function(product, key) {
+ _.each(products, function (product, key) {
if (key !== NO_PRODUCT_ID) {
results[key] = product;
}
@@ -190,20 +189,20 @@ wv.data.model = wv.data.model || function(models, config) {
return results;
};
- self.getProductsString = function() {
+ self.getProductsString = function () {
var parts = [];
var products = self.groupByProducts();
- $.each(products, function(key, product) {
+ $.each(products, function (key, product) {
var layers = [];
- $.each(product.items, function(index, item) {
+ $.each(product.items, function (index, item) {
layers.push(item.value);
});
- parts.push(key + "," + layers.join(","));
+ parts.push(key + ',' + layers.join(','));
});
- return parts.join("~");
+ return parts.join('~');
};
- self.selectProduct = function(productName) {
+ self.selectProduct = function (productName) {
if (self.selectedProduct === productName) {
return;
}
@@ -217,19 +216,19 @@ wv.data.model = wv.data.model || function(models, config) {
}
};
- self.selectGranule = function(granule) {
+ self.selectGranule = function (granule) {
self.selectedGranules[granule.id] = granule;
self.events.trigger(self.EVENT_GRANULE_SELECT, granule);
};
- self.unselectGranule = function(granule) {
+ self.unselectGranule = function (granule) {
if (self.selectedGranules[granule.id]) {
delete self.selectedGranules[granule.id];
self.events.trigger(self.EVENT_GRANULE_UNSELECT, granule);
}
};
- self.toggleGranule = function(granule) {
+ self.toggleGranule = function (granule) {
if (self.isSelected(granule)) {
self.unselectGranule(granule);
} else {
@@ -237,9 +236,9 @@ wv.data.model = wv.data.model || function(models, config) {
}
};
- self.isSelected = function(granule) {
+ self.isSelected = function (granule) {
var selected = false;
- $.each(self.selectedGranules, function(index, selection) {
+ $.each(self.selectedGranules, function (index, selection) {
if (granule.id === selection.id) {
selected = true;
}
@@ -247,10 +246,10 @@ wv.data.model = wv.data.model || function(models, config) {
return selected;
};
- self.getSelectionSize = function() {
+ self.getSelectionSize = function () {
var totalSize = 0;
var sizeValid = true;
- $.each(self.selectedGranules, function(index, granule) {
+ $.each(self.selectedGranules, function (index, granule) {
if (sizeValid && granule.granule_size) {
totalSize += parseFloat(granule.granule_size);
} else {
@@ -262,31 +261,31 @@ wv.data.model = wv.data.model || function(models, config) {
}
};
- self.getSelectionCounts = function() {
+ self.getSelectionCounts = function () {
counts = {};
- $.each(self.layers, function(index, layer) {
+ $.each(self.layers, function (index, layer) {
if (layer.product) {
counts[layer.product] = 0;
}
});
- $.each(self.selectedGranules, function(index, granule) {
+ $.each(self.selectedGranules, function (index, granule) {
counts[granule.product]++;
});
return counts;
};
- self.setPreference = function(preference) {
+ self.setPreference = function (preference) {
self.prefer = preference;
query();
};
- self.save = function(state) {
+ self.save = function (state) {
if (self.active) {
state.download = self.selectedProduct;
}
};
- self.load = function(state, errors) {
+ self.load = function (state, errors) {
var productId = state.download;
if (productId) {
var found = _.find(models.layers.active, {
@@ -294,18 +293,18 @@ wv.data.model = wv.data.model || function(models, config) {
});
if (!found) {
errors.push({
- message: "No active layers match product: " +
+ message: 'No active layers match product: ' +
productId
});
} else {
- models.wv.events.on("startup", function() {
+ models.wv.events.on('startup', function () {
self.activate(productId);
});
}
}
};
- var query = function() {
+ var query = function () {
if (!self.active) {
return;
}
@@ -319,15 +318,15 @@ wv.data.model = wv.data.model || function(models, config) {
var productConfig = config.products[self.selectedProduct];
if (!productConfig) {
- throw Error("Product not defined: " + self.selectedProduct);
+ throw Error('Product not defined: ' + self.selectedProduct);
}
var handlerFactory = wv.data.handler.getByName(productConfig.handler);
var handler = handlerFactory(config, self);
- handler.events.on("query", function() {
+ handler.events.on('query', function () {
self.events.trigger(self.EVENT_QUERY);
})
- .on("results", function(results) {
+ .on('results', function (results) {
queryExecuting = false;
if (self.active && !nextQuery) {
self.events.trigger(self.EVENT_QUERY_RESULTS, results);
@@ -338,14 +337,14 @@ wv.data.model = wv.data.model || function(models, config) {
executeQuery(q);
}
})
- .on("error", function(textStatus, errorThrown) {
+ .on('error', function (textStatus, errorThrown) {
queryExecuting = false;
if (self.active) {
self.events.trigger(self.EVENT_QUERY_ERROR, textStatus,
errorThrown);
}
})
- .on("timeout", function() {
+ .on('timeout', function () {
queryExecuting = false;
if (self.active) {
self.events.trigger(self.EVENT_QUERY_TIMEOUT);
@@ -354,7 +353,7 @@ wv.data.model = wv.data.model || function(models, config) {
executeQuery(handler);
};
- var executeQuery = function(handler) {
+ var executeQuery = function (handler) {
if (!queryExecuting) {
try {
queryExecuting = true;
@@ -368,10 +367,10 @@ wv.data.model = wv.data.model || function(models, config) {
}
};
- var updateLayers = function() {
+ var updateLayers = function () {
self.layers = [];
var foundSelected = false;
- _.each(models.layers.get(), function(layer) {
+ _.each(models.layers.get(), function (layer) {
var id = layer.id;
var names = models.layers.getTitles(layer.id);
var layerName = names.title;
@@ -400,7 +399,7 @@ wv.data.model = wv.data.model || function(models, config) {
// FIXME: This is a hack for now and should be cleaned up when
// everything changes to models.
var products = self.groupByProducts();
- _.each(self.selectedGranules, function(selected) {
+ _.each(self.selectedGranules, function (selected) {
if (!products[selected.product] &&
!productActive(selected.product)) {
self.unselectGranule(selected);
@@ -408,9 +407,9 @@ wv.data.model = wv.data.model || function(models, config) {
});
};
- var productActive = function(product) {
+ var productActive = function (product) {
var active = false;
- _.each(layersModel.active, function(layer) {
+ _.each(layersModel.active, function (layer) {
if (layer.product === product) {
active = true;
return false;
@@ -419,26 +418,26 @@ wv.data.model = wv.data.model || function(models, config) {
return active;
};
- var updateProjectionInfo = function() {
+ var updateProjectionInfo = function () {
self.projection = models.proj.selected.id;
self.crs = models.proj.selected.crs;
};
- var updateProjection = function() {
+ var updateProjection = function () {
updateProjectionInfo();
- self.events.trigger("projectionUpdate");
+ self.events.trigger('projectionUpdate');
updateLayers();
query();
};
// FIXME: This is a hack
self.updateProjection = updateProjection;
- var updateDate = function() {
+ var updateDate = function () {
self.time = models.date.selected;
query();
};
- var findAvailableProduct = function() {
+ var findAvailableProduct = function () {
var foundProduct = null;
var list = models.layers.get({
flat: true
@@ -453,9 +452,9 @@ wv.data.model = wv.data.model || function(models, config) {
return foundProduct;
};
- var validateProduct = function(productName) {
+ var validateProduct = function (productName) {
var found = false;
- $.each(self.layers, function(index, layer) {
+ $.each(self.layers, function (index, layer) {
var layerProduct = layer.product;
if (layerProduct === productName) {
found = true;
@@ -463,7 +462,7 @@ wv.data.model = wv.data.model || function(models, config) {
}
});
if (!found) {
- throw Error("No layer displayed for product: " + productName);
+ throw Error('No layer displayed for product: ' + productName);
}
};
diff --git a/web/js/data/wv.data.results.js b/web/js/data/wv.data.results.js
index deeee590d..f843cf1e6 100644
--- a/web/js/data/wv.data.results.js
+++ b/web/js/data/wv.data.results.js
@@ -4,15 +4,13 @@
var wv = wv || {};
wv.data = wv.data || {};
-
wv.data.results = wv.data.results || {};
-wv.data.results.antiMeridianMulti = function(maxDistance) {
-
+wv.data.results.antiMeridianMulti = function (maxDistance) {
var self = {};
- self.name = "AntiMeridianMulti";
+ self.name = 'AntiMeridianMulti';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
var geom = granule.geometry[wv.map.CRS_WGS_84];
// Semi-hack of ensuring geometry isn't a MultiPolygon since
// isPolygonValid can't handle it; addresses WV-1574
@@ -41,20 +39,18 @@ wv.data.results.antiMeridianMulti = function(maxDistance) {
return self;
};
-
-wv.data.results.chain = function() {
-
+wv.data.results.chain = function () {
var self = {};
self.processes = [];
- self.process = function(results) {
- $.each(results.granules, function(index, granule) {
+ self.process = function (results) {
+ $.each(results.granules, function (index, granule) {
delete granule.filtered;
delete granule.filteredBy;
});
- $.each(self.processes, function(index, process) {
- $.each(results.granules, function(index2, granule) {
+ $.each(self.processes, function (index, process) {
+ $.each(results.granules, function (index2, granule) {
if (!granule.filtered) {
var result = process.process(results.meta, granule);
if (!result) {
@@ -70,7 +66,7 @@ wv.data.results.chain = function() {
newGranules = [];
filteredGranules = {};
- $.each(results.granules, function(index, granule) {
+ $.each(results.granules, function (index, granule) {
if (!granule.filtered) {
newGranules.push(granule);
} else {
@@ -91,20 +87,18 @@ wv.data.results.chain = function() {
return self;
};
-
-wv.data.results.collectPreferred = function(prefer) {
-
+wv.data.results.collectPreferred = function (prefer) {
var self = {};
- self.name = "CollectPreferred";
+ self.name = 'CollectPreferred';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (!meta.preferred) {
meta.preferred = {};
}
var preferred =
- (prefer === "nrt" && granule.nrt) ||
- (prefer === "science" && !granule.nrt);
+ (prefer === 'nrt' && granule.nrt) ||
+ (prefer === 'science' && !granule.nrt);
if (preferred) {
var timeStart = wv.data.cmr.roundTime(granule.time_start);
meta.preferred[timeStart] = granule;
@@ -115,14 +109,12 @@ wv.data.results.collectPreferred = function(prefer) {
return self;
};
-
-wv.data.results.collectVersions = function() {
-
+wv.data.results.collectVersions = function () {
var self = {};
- self.name = "CollectVersions";
+ self.name = 'CollectVersions';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (!meta.versions) {
meta.versions = {};
}
@@ -138,17 +130,15 @@ wv.data.results.collectVersions = function() {
return self;
};
-
-wv.data.results.connectSwaths = function(projection) {
-
+wv.data.results.connectSwaths = function (projection) {
var MAX_DISTANCE_GEO = 270;
var startTimes = {};
var endTimes = {};
var self = {};
- self.name = "ConnectSwaths";
+ self.name = 'ConnectSwaths';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (!granule.centroid[projection]) {
return;
}
@@ -156,12 +146,12 @@ wv.data.results.connectSwaths = function(projection) {
var timeEnd = roundTime(granule.time_end);
if (startTimes[timeStart]) {
- console.warn("Discarding duplicate start time", timeStart,
+ console.warn('Discarding duplicate start time', timeStart,
granule, startTimes[timeStart]);
return;
}
if (endTimes[timeEnd]) {
- console.warn("Discarding duplicate end time", timeEnd,
+ console.warn('Discarding duplicate end time', timeEnd,
granule, endTimes[timeEnd]);
return;
}
@@ -173,20 +163,20 @@ wv.data.results.connectSwaths = function(projection) {
return granule;
};
- self.after = function(results) {
+ self.after = function (results) {
results.meta.swaths = [];
- $.each(startTimes, function(index, swath) {
+ $.each(startTimes, function (index, swath) {
if (swath.length > 1) {
results.meta.swaths.push(swath);
}
});
};
- var combineSwath = function(swath) {
+ var combineSwath = function (swath) {
var combined = false;
- var maxDistance = (projection === wv.map.CRS_WGS_84) ?
- MAX_DISTANCE_GEO : Number.POSITIVE_INFINITY;
+ var maxDistance = (projection === wv.map.CRS_WGS_84)
+ ? MAX_DISTANCE_GEO : Number.POSITIVE_INFINITY;
var thisTimeStart = roundTime(swath[0].time_start);
var thisTimeEnd = roundTime(swath[swath.length - 1].time_end);
var otherSwath = endTimes[thisTimeStart];
@@ -228,12 +218,12 @@ wv.data.results.connectSwaths = function(projection) {
// Connection is allowed as long as there is at least one path between
// centroids that is less than the max distance
- var connectionAllowed = function(g1, g2, maxDistance) {
+ var connectionAllowed = function (g1, g2, maxDistance) {
var polys1 = wv.map.toPolys(g1.geometry[projection]);
var polys2 = wv.map.toPolys(g2.geometry[projection]);
var allowed = false;
- $.each(polys1, function(index, poly1) {
- $.each(polys2, function(index, poly2) {
+ $.each(polys1, function (index, poly1) {
+ $.each(polys2, function (index, poly2) {
var x1 = poly1.getInteriorPoint()
.getCoordinates()[0];
var x2 = poly2.getInteriorPoint()
@@ -247,52 +237,45 @@ wv.data.results.connectSwaths = function(projection) {
return allowed;
};
-
- var roundTime = function(timeString) {
+ var roundTime = function (timeString) {
return wv.data.cmr.roundTime(timeString);
};
return self;
-
};
-
-wv.data.results.dateTimeLabel = function(time) {
-
+wv.data.results.dateTimeLabel = function (time) {
var self = {};
- self.name = "DateTimeLabel";
+ self.name = 'DateTimeLabel';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
var timeStart = wv.util.parseTimestampUTC(granule.time_start);
// Some granules may not have an end time
if (granule.time_end) {
var timeEnd = wv.util.parseTimestampUTC(granule.time_end);
- granule.label = wv.util.toISOStringDate(timeStart) + ": " +
- wv.util.toISOStringTimeHM(timeStart) + "-" +
- wv.util.toISOStringTimeHM(timeEnd) + " UTC";
+ granule.label = wv.util.toISOStringDate(timeStart) + ': ' +
+ wv.util.toISOStringTimeHM(timeStart) + '-' +
+ wv.util.toISOStringTimeHM(timeEnd) + ' UTC';
} else {
- granule.label = wv.util.toISOStringDate(timeStart) + ": " +
- wv.util.toISOStringTimeHM(timeStart) + " UTC";
+ granule.label = wv.util.toISOStringDate(timeStart) + ': ' +
+ wv.util.toISOStringTimeHM(timeStart) + ' UTC';
}
return granule;
};
return self;
-
};
-
-wv.data.results.densify = function() {
-
+wv.data.results.densify = function () {
var MAX_DISTANCE = 5;
var self = {};
- self.name = "Densify";
+ self.name = 'Densify';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
// There is a bug exposed here discovered when switching to OL3. Since this
// function isn't needed for any of the data that we have, just skip it
// for now and fix it later.
@@ -316,7 +299,7 @@ wv.data.results.densify = function() {
*/
};
- var densifyPolygon = function(poly) {
+ var densifyPolygon = function (poly) {
// Get the outer ring and then get an array of all the points
var ring = poly.getLinearRing(0)
.getCoordinates();
@@ -342,34 +325,33 @@ wv.data.results.densify = function() {
return self;
};
-wv.data.results.dividePolygon = function() {
-
+wv.data.results.dividePolygon = function () {
var self = {};
- self.name = "DividePolygon";
+ self.name = 'DividePolygon';
- self.process = function(meta, granule) {
- if (granule.geometry["EPSG:4326"].getPolygons) {
+ self.process = function (meta, granule) {
+ if (granule.geometry['EPSG:4326'].getPolygons) {
return granule;
}
- var ring = granule.geometry["EPSG:4326"].getLinearRing(0);
+ var ring = granule.geometry['EPSG:4326'].getLinearRing(0);
var coords = ring.getCoordinates();
var latlons = [];
- _.each(coords, function(coord) {
+ _.each(coords, function (coord) {
var latlon = new L.LatLng(coord[1], coord[0]);
latlons.push(latlon);
});
var result = L.sphericalPolygon.dividePolygon(latlons);
var newPolys = result.interiors;
var resultMultiPoly = [];
- _.each(newPolys, function(newPoly) {
+ _.each(newPolys, function (newPoly) {
var resultPoly = [];
- _.each(newPoly, function(newCoord) {
+ _.each(newPoly, function (newCoord) {
resultPoly.push([newCoord.lng, newCoord.lat]);
});
resultMultiPoly.push(resultPoly);
});
- granule.geometry["EPSG:4326"] =
+ granule.geometry['EPSG:4326'] =
new ol.geom.MultiPolygon([resultMultiPoly]);
return granule;
};
@@ -377,13 +359,12 @@ wv.data.results.dividePolygon = function() {
return self;
};
-wv.data.results.extentFilter = function(projection, extent) {
-
+wv.data.results.extentFilter = function (projection, extent) {
var self = {};
- self.name = "ExtentFilter";
+ self.name = 'ExtentFilter';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
var geom = granule.geometry[projection];
if (!geom) {
return result;
@@ -395,20 +376,18 @@ wv.data.results.extentFilter = function(projection, extent) {
};
if (!extent) {
- throw new Error("No extent");
+ throw new Error('No extent');
}
return self;
};
-
-wv.data.results.geometryFromCMR = function(densify) {
-
+wv.data.results.geometryFromCMR = function (densify) {
var self = {};
- self.name = "GeometryFromCMR";
+ self.name = 'GeometryFromCMR';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (!granule.geometry) {
granule.geometry = {};
}
@@ -429,16 +408,14 @@ wv.data.results.geometryFromCMR = function(densify) {
return self;
};
-
-wv.data.results.geometryFromMODISGrid = function(projection) {
-
+wv.data.results.geometryFromMODISGrid = function (projection) {
var parser = new ol.format.GeoJSON();
var self = {};
- self.name = "GeoemtryFromMODISGrid";
+ self.name = 'GeoemtryFromMODISGrid';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (!granule.geometry) {
granule.geometry = {};
granule.centroid = {};
@@ -465,25 +442,24 @@ wv.data.results.geometryFromMODISGrid = function(projection) {
return self;
};
-wv.data.results.modisGridIndex = function() {
-
+wv.data.results.modisGridIndex = function () {
var self = {};
- self.name = "MODISGridIndex";
+ self.name = 'MODISGridIndex';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
var id = granule.producer_granule_id;
var matches = id.match(/\.h(\d+)v(\d+)\./);
granule.h = parseInt(matches[1], 10);
granule.v = parseInt(matches[2], 10);
- granule.hv = "h" + granule.h + "v" + granule.v;
+ granule.hv = 'h' + granule.h + 'v' + granule.v;
return granule;
};
- self.after = function(results) {
+ self.after = function (results) {
results.meta.grid = {};
- $.each(results.meta.gridFetched.features, function(index, feature) {
- var key = "h" + feature.properties.H + "v" + feature.properties.V;
+ $.each(results.meta.gridFetched.features, function (index, feature) {
+ var key = 'h' + feature.properties.H + 'v' + feature.properties.V;
results.meta.grid[key] = feature;
});
};
@@ -491,20 +467,18 @@ wv.data.results.modisGridIndex = function() {
return self;
};
-
-wv.data.results.modisGridLabel = function() {
-
+wv.data.results.modisGridLabel = function () {
var self = {};
- self.name = "MODISGridLabel";
+ self.name = 'MODISGridLabel';
- self.process = function(meta, granule) {
- granule.label = "h" + granule.h + " - " + "v" + granule.v;
+ self.process = function (meta, granule) {
+ granule.label = 'h' + granule.h + ' - ' + 'v' + granule.v;
var timeStart = wv.util.parseTimestampUTC(granule.time_start);
var date = wv.util.toISOStringDate(timeStart);
- granule.downloadLabel = date + ": h" + granule.h + "-" + granule.v;
+ granule.downloadLabel = date + ': h' + granule.h + '-' + granule.v;
return granule;
};
@@ -512,13 +486,12 @@ wv.data.results.modisGridLabel = function() {
return self;
};
-wv.data.results.orbitFilter = function(spec) {
-
+wv.data.results.orbitFilter = function (spec) {
var self = {};
- self.name = "OrbitFilter";
+ self.name = 'OrbitFilter';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (spec) {
var regex = new RegExp(spec.regex);
var text = granule[spec.field];
@@ -534,20 +507,18 @@ wv.data.results.orbitFilter = function(spec) {
return self;
};
-
-wv.data.results.preferredFilter = function(prefer) {
-
+wv.data.results.preferredFilter = function (prefer) {
var self = {};
- self.name = "PreferredFilter";
+ self.name = 'PreferredFilter';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
var timeStart = wv.data.cmr.roundTime(granule.time_start);
if (meta.preferred[timeStart]) {
- if (prefer === "nrt" && !granule.nrt) {
+ if (prefer === 'nrt' && !granule.nrt) {
return;
}
- if (prefer === "science" && granule.nrt) {
+ if (prefer === 'science' && granule.nrt) {
return;
}
}
@@ -557,14 +528,12 @@ wv.data.results.preferredFilter = function(prefer) {
return self;
};
-
-wv.data.results.productLabel = function(name) {
-
+wv.data.results.productLabel = function (name) {
var self = {};
- self.name = "ProductLabel";
+ self.name = 'ProductLabel';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
granule.label = name;
return granule;
};
@@ -572,44 +541,40 @@ wv.data.results.productLabel = function(name) {
return self;
};
-
-wv.data.results.tagList = function(spec) {
-
+wv.data.results.tagList = function (spec) {
var self = {};
- self.name = "TagList";
+ self.name = 'TagList';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
return granule;
};
- self.after = function(results) {
+ self.after = function (results) {
results.meta.showList = true;
};
return self;
};
-
-wv.data.results.tagNRT = function(spec) {
-
+wv.data.results.tagNRT = function (spec) {
var self = {};
- self.name = "TagNRT";
+ self.name = 'TagNRT';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
// Exit now if this product doesn't have information about NRT
if (!spec) {
return granule;
}
var isNRT;
- if (spec.by === "value") {
+ if (spec.by === 'value') {
isNRT = granule[spec.field] === spec.value;
- } else if (spec.by === "regex") {
+ } else if (spec.by === 'regex') {
var re = new RegExp(spec.value);
isNRT = re.test(granule[spec.field]);
} else {
- throw new Error("Unknown TagNRT method: " + spec.by);
+ throw new Error('Unknown TagNRT method: ' + spec.by);
}
if (isNRT) {
granule.nrt = true;
@@ -621,44 +586,40 @@ wv.data.results.tagNRT = function(spec) {
return self;
};
-
-wv.data.results.tagProduct = function(product) {
-
+wv.data.results.tagProduct = function (product) {
var self = {};
- self.name = "TagProduct";
+ self.name = 'TagProduct';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
granule.product = product;
return granule;
};
return self;
-
};
// FIXME: Code copy and pasted from TagNRT, maybe consoldate this?
-wv.data.results.tagURS = function(spec) {
-
+wv.data.results.tagURS = function (spec) {
var self = {};
- self.name = "TagURS";
+ self.name = 'TagURS';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
// Exit now if this product doesn't have information about NRT
if (!spec) {
return granule;
}
var isURS;
- if (spec.by === "constant") {
+ if (spec.by === 'constant') {
isURS = spec.value;
- } else if (spec.by === "value") {
+ } else if (spec.by === 'value') {
isURS = granule[spec.field] === spec.value;
- } else if (spec.by === "regex") {
+ } else if (spec.by === 'regex') {
var re = new RegExp(spec.value);
isURS = re.test(granule[spec.field]);
} else {
- throw new Error("Unknown TagURS method: " + spec.by);
+ throw new Error('Unknown TagURS method: ' + spec.by);
}
granule.urs = isURS;
if (isURS) {
@@ -670,23 +631,21 @@ wv.data.results.tagURS = function(spec) {
return self;
};
-
-wv.data.results.tagVersion = function() {
-
+wv.data.results.tagVersion = function () {
var self = {};
- self.name = "TagVersion";
+ self.name = 'TagVersion';
- self.process = function(meta, granule) {
- var match = granule.dataset_id.match("V(\\d{3})(\\d*)");
+ self.process = function (meta, granule) {
+ var match = granule.dataset_id.match('V(\\d{3})(\\d*)');
if (match) {
var major = match[1];
var minor = match[2] || 0;
- granule.version = parseFloat(major + "." + minor);
+ granule.version = parseFloat(major + '.' + minor);
return granule;
}
- match = granule.dataset_id.match("V([\\d\\.]+)");
+ match = granule.dataset_id.match('V([\\d\\.]+)');
if (match) {
granule.version = parseFloat(match[1]);
return granule;
@@ -698,18 +657,16 @@ wv.data.results.tagVersion = function() {
return self;
};
-
-wv.data.results.timeFilter = function(spec) {
-
+wv.data.results.timeFilter = function (spec) {
var westZone = null;
var eastZone = null;
var maxDistance = null;
var self = {};
- self.name = "TimeFilter";
+ self.name = 'TimeFilter';
- var init = function() {
+ var init = function () {
westZone = new Date(spec.time.getTime())
.setUTCMinutes(spec.westZone);
eastZone = new Date(spec.time.getTime())
@@ -718,7 +675,7 @@ wv.data.results.timeFilter = function(spec) {
timeOffset = spec.timeOffset || 0;
};
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
var geom = granule.geometry[wv.map.CRS_WGS_84];
var time = wv.util.parseTimestampUTC(granule.time_start);
time.setUTCMinutes(time.getUTCMinutes() + timeOffset);
@@ -748,14 +705,12 @@ wv.data.results.timeFilter = function(spec) {
return self;
};
-
-wv.data.results.timeLabel = function(time) {
-
+wv.data.results.timeLabel = function (time) {
var self = {};
- self.name = "TimeLabel";
+ self.name = 'TimeLabel';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
var timeStart = wv.util.parseTimestampUTC(granule.time_start);
// Sometimes an end time is not provided by CMR
@@ -768,12 +723,12 @@ wv.data.results.timeLabel = function(time) {
(timeStart.getTime() - time.getTime()) / (1000 * 60 * 60 * 24)
);
- var suffix = "";
+ var suffix = '';
if (diff !== 0) {
if (diff < 0) {
- suffix = " (" + diff + " day)";
+ suffix = ' (' + diff + ' day)';
} else {
- suffix = " (+" + diff + " day)";
+ suffix = ' (+' + diff + ' day)';
}
}
var displayStart = wv.util.toISOStringTimeHM(timeStart);
@@ -781,12 +736,12 @@ wv.data.results.timeLabel = function(time) {
if (timeEnd) {
displayEnd = wv.util.toISOStringTimeHM(timeEnd);
} else {
- displayEnd = "?";
+ displayEnd = '?';
}
- granule.label = displayStart + " - " + displayEnd + " UTC" + suffix;
+ granule.label = displayStart + ' - ' + displayEnd + ' UTC' + suffix;
- granule.downloadLabel = wv.util.toISOStringDate(timeStart) + ": " +
- displayStart + "-" + displayEnd + " UTC";
+ granule.downloadLabel = wv.util.toISOStringDate(timeStart) + ': ' +
+ displayStart + '-' + displayEnd + ' UTC';
return granule;
};
@@ -794,14 +749,12 @@ wv.data.results.timeLabel = function(time) {
return self;
};
-
-wv.data.results.transform = function(projection) {
-
+wv.data.results.transform = function (projection) {
var self = {};
- self.name = "Transform";
+ self.name = 'Transform';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (granule.geometry[projection]) {
return granule;
}
@@ -825,14 +778,12 @@ wv.data.results.transform = function(projection) {
return self;
};
-
-wv.data.results.versionFilter = function() {
-
+wv.data.results.versionFilter = function () {
var self = {};
- self.name = "VersionFilter";
+ self.name = 'VersionFilter';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (granule.version) {
var timeStart = wv.data.cmr.roundTime(granule.time_start);
if (meta.versions[timeStart]) {
@@ -847,13 +798,12 @@ wv.data.results.versionFilter = function() {
return self;
};
-wv.data.results.versionFilterExact = function(version) {
-
+wv.data.results.versionFilterExact = function (version) {
var self = {};
- self.name = "versionFilterExact";
+ self.name = 'versionFilterExact';
- self.process = function(meta, granule) {
+ self.process = function (meta, granule) {
if (granule.version && granule.version === version) {
return granule;
}
diff --git a/web/js/data/wv.data.ui.js b/web/js/data/wv.data.ui.js
index b413cfcbd..de492f9d5 100644
--- a/web/js/data/wv.data.ui.js
+++ b/web/js/data/wv.data.ui.js
@@ -1,8 +1,7 @@
var wv = wv || {};
wv.data = wv.data || {};
-wv.data.ui = wv.data.ui || function(models, ui, config) {
-
+wv.data.ui = wv.data.ui || function (models, ui, config) {
var queryActive = false;
var model = models.data;
var mapController = null;
@@ -18,28 +17,27 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
};
var self = {};
- self.selector = "#wv-data";
- self.id = "wv-data";
-
- var init = function() {
+ self.selector = '#wv-data';
+ self.id = 'wv-data';
+ var init = function () {
model.events
- .on("activate", onActivate)
- .on("deactivate", onDeactivate)
- .on("productSelect", onProductSelect)
- .on("layerUpdate", onLayerUpdate)
- .on("query", onQuery)
- .on("queryResults", onQueryResults)
- .on("queryCancel", onQueryCancel)
- .on("queryError", onQueryError)
- .on("queryTimeout", onQueryTimeout)
- .on("granuleSelect", updateSelection)
- .on("granuleUnselect", updateSelection);
+ .on('activate', onActivate)
+ .on('deactivate', onDeactivate)
+ .on('productSelect', onProductSelect)
+ .on('layerUpdate', onLayerUpdate)
+ .on('query', onQuery)
+ .on('queryResults', onQueryResults)
+ .on('queryCancel', onQueryCancel)
+ .on('queryError', onQueryError)
+ .on('queryTimeout', onQueryTimeout)
+ .on('granuleSelect', updateSelection)
+ .on('granuleUnselect', updateSelection);
$(window)
.resize(sizeDownloadTab);
- ui.sidebar.events.on("selectTab", function(tab) {
- if (tab === "download") {
+ ui.sidebar.events.on('selectTab', function (tab) {
+ if (tab === 'download') {
sizeDownloadTab();
model.activate();
} else {
@@ -48,7 +46,7 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
});
};
- self.render = function() {
+ self.render = function () {
var $footer = $('<footer />');
var $container = $(self.selector).empty();
var $actionButton = $('<button />', {
@@ -74,67 +72,67 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
self.refresh();
};
- self.refresh = function() {
- var $content = $("#wv-datacontent");
+ self.refresh = function () {
+ var $content = $('#wv-datacontent');
- $content = $("#wv-datacontent")
+ $content = $('#wv-datacontent')
.empty();
var data = model.groupByProducts();
- $.each(data, function(key, value) {
+ $.each(data, function (key, value) {
refreshProduct($content, key, value);
});
$('.dl-group[value="__NO_PRODUCT"] h3 span')
- .click(function() {
+ .click(function () {
showUnavailableReason();
});
sizeDownloadTab();
};
- var refreshProduct = function($content, key, value) {
+ var refreshProduct = function ($content, key, value) {
var title = value.title;
- var $header = $("<h3></h3>")
- .addClass("head")
+ var $header = $('<h3></h3>')
+ .addClass('head')
.html(title);
// FIXME: Why is this needed?
var $productSelector;
if (!value.notSelectable) {
- var $selectedCount = $("<i></i>")
- .attr("id", key + "dynamictext")
- .addClass("dynamic")
- .html("0 selected");
+ var $selectedCount = $('<i></i>')
+ .attr('id', key + 'dynamictext')
+ .addClass('dynamic')
+ .html('0 selected');
$productSelector = $("<input type='radio'></input>")
- .attr("value", key)
- .attr("data-product", key);
+ .attr('value', key)
+ .attr('data-product', key);
$header.prepend($productSelector)
.append($selectedCount);
}
if (model.selectedProduct === key) {
- $productSelector.each(function() {
+ $productSelector.each(function () {
this.checked = true;
});
}
var $contentDlGroup = $("<div class='dl-group'></div>")
- .attr("value", key)
- .attr("data-product", key)
- .click(function() {
+ .attr('value', key)
+ .attr('data-product', key)
+ .click(function () {
model.selectProduct($(this)
- .find("input")
- .attr("data-product"));
- $(".dl-group")
- .removeClass("dl-group-selected");
+ .find('input')
+ .attr('data-product'));
+ $('.dl-group')
+ .removeClass('dl-group-selected');
$(this)
.addClass('dl-group-selected');
- $(".dl-group input")
- .each(function() {
+ $('.dl-group input')
+ .each(function () {
this.checked = false;
});
$(this)
- .find("input")
- .each(function() {
+ .find('input')
+ .each(function () {
this.checked = true;
});
})
@@ -142,61 +140,60 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
$content.append($contentDlGroup);
- var $products = $("<ul></ul>")
- .attr("id", self.id + key)
- .addClass(self.id + "category");
+ var $products = $('<ul></ul>')
+ .attr('id', self.id + key)
+ .addClass(self.id + 'category');
- $.each(value.items, function(index, item) {
+ $.each(value.items, function (index, item) {
refreshLayers($products, key, value, item);
});
$contentDlGroup.append($products);
};
- var refreshLayers = function($container, key, value, layer) {
- var $item = $("<li></li>")
- .attr("id", self.id + key + encodeURIComponent(layer.value))
- .addClass("item")
- .addClass("item-static");
- $item.append("<h4>" + layer.label + "</h4>");
- $item.append("<p>" + layer.sublabel + "</p>");
+ var refreshLayers = function ($container, key, value, layer) {
+ var $item = $('<li></li>')
+ .attr('id', self.id + key + encodeURIComponent(layer.value))
+ .addClass('item')
+ .addClass('item-static');
+ $item.append('<h4>' + layer.label + '</h4>');
+ $item.append('<p>' + layer.sublabel + '</p>');
$container.append($item);
};
var productsIsOverflow = false;
- var sizeDownloadTab = function() {
+ var sizeDownloadTab = function () {
var $tabPanel = $('#wv-data');
var $tabFooter = $tabPanel.find('footer');
var windowHeight = $(window).outerHeight(true);
var tabBarHeight = $('ul#productsHolder-tabs').outerHeight(true);
var footerHeight = $tabFooter.outerHeight(true);
- var distanceFromTop = $("#productsHolder").offset().top;
- var timelineHeight = $("#timeline").outerHeight(true);
+ var distanceFromTop = $('#productsHolder').offset().top;
+ var timelineHeight = $('#timeline').outerHeight(true);
- //FIXME: -10 here is the timeline's bottom position from page, fix
+ // FIXME: -10 here is the timeline's bottom position from page, fix
// after timeline markup is corrected to be loaded first
var maxHeight = windowHeight - tabBarHeight - footerHeight - distanceFromTop - timelineHeight - 10 - 5;
- $tabPanel.css("max-height", maxHeight);
+ $tabPanel.css('max-height', maxHeight);
var childrenHeight = $('#wv-datacontent').outerHeight(true);
var isTallerThanContainer = childrenHeight > maxHeight;
if (isTallerThanContainer) {
- $(".wv-datalist").css('height', maxHeight).css('padding-right', '10px');
+ $('.wv-datalist').css('height', maxHeight).css('padding-right', '10px');
if (productsIsOverflow) {
- $(".wv-datalist").perfectScrollbar('update');
+ $('.wv-datalist').perfectScrollbar('update');
} else {
- $(".wv-datalist").perfectScrollbar();
+ $('.wv-datalist').perfectScrollbar();
productsIsOverflow = true;
}
} else if (productsIsOverflow) {
- $(".wv-datalist").css('height', '').css('padding-right', '');
- $(".wv-datalist").perfectScrollbar('destroy');
+ $('.wv-datalist').css('height', '').css('padding-right', '');
+ $('.wv-datalist').perfectScrollbar('destroy');
productsIsOverflow = false;
}
-
};
- self.onViewChange = function() {
+ self.onViewChange = function () {
var map = ui.map.selected;
if (!model.active || queryActive || !lastResults) {
@@ -210,7 +207,7 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
var extent = map.getView()
.calculateExtent(map.getSize());
var crs = models.proj.selected.crs;
- _.each(lastResults.granules, function(granule) {
+ _.each(lastResults.granules, function (granule) {
if (granule.centroid && granule.centroid[crs]) {
hasCentroids = true;
if (ol.extent.intersects(extent,
@@ -223,12 +220,12 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
wv.ui.indicator.hide(indicators.noneInView);
if (hasCentroids && !inView) {
indicators.noneInView =
- wv.ui.indicator.show("Zoom out or move map");
+ wv.ui.indicator.show('Zoom out or move map');
}
};
- var onActivate = function() {
- ui.sidebar.selectTab("download");
+ var onActivate = function () {
+ ui.sidebar.selectTab('download');
if (!mapController) {
mapController = wv.data.map(model, maps, config);
}
@@ -236,7 +233,7 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
updateSelection();
};
- var onDeactivate = function() {
+ var onDeactivate = function () {
wv.ui.indicator.hide(indicators);
if (selectionListPanel) {
selectionListPanel.hide();
@@ -247,19 +244,19 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
mapController.dispose();
};
- var onProductSelect = function(product) {
+ var onProductSelect = function (product) {
$(self.selector + " input[value='" + product + "']")
- .prop("checked", "true");
+ .prop('checked', 'true');
};
- var onLayerUpdate = function() {
+ var onLayerUpdate = function () {
if (!model.active) {
return;
}
self.refresh();
};
- var onQuery = function() {
+ var onQuery = function () {
queryActive = true;
indicators.query = wv.ui.indicator.searching(indicators);
if (selectionListPanel) {
@@ -270,7 +267,7 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
}
};
- var onQueryResults = function(results) {
+ var onQueryResults = function (results) {
if (selectionListPanel) {
selectionListPanel.hide();
selectionListPanel = null;
@@ -291,61 +288,61 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
updateSelection();
};
- var onQueryCancel = function() {
+ var onQueryCancel = function () {
queryActive = false;
wv.ui.indicator.hide(indicators);
};
- var onQueryError = function(status, error) {
+ var onQueryError = function (status, error) {
queryActive = false;
wv.ui.indicator.hide(indicators);
- if (status !== "abort") {
- console.error("Unable to search", status, error);
- wv.ui.notify("Unable to search at this time.<br/><br/>Please try " +
- "again later.");
+ if (status !== 'abort') {
+ console.error('Unable to search', status, error);
+ wv.ui.notify('Unable to search at this time.<br/><br/>Please try ' +
+ 'again later.');
}
};
- var onQueryTimeout = function() {
+ var onQueryTimeout = function () {
queryActive = false;
wv.ui.indicator.hide(indicators);
wv.ui.notify(
- "No results received yet. This may be due to a " +
- "connectivity issue. Please try again later."
+ 'No results received yet. This may be due to a ' +
+ 'connectivity issue. Please try again later.'
);
};
- var updateSelection = function() {
- var $button = $("#wv-data-download-button");
+ var updateSelection = function () {
+ var $button = $('#wv-data-download-button');
var selected = _.size(model.selectedGranules);
if (selected > 0) {
- $button.button("enable");
+ $button.button('enable');
var totalSize = model.getSelectionSize();
if (totalSize) {
var formattedSize = Math.round(totalSize * 100) / 100;
- $button.find(".ui-button-text")
- .html("Download Data (" + formattedSize + " MB)");
+ $button.find('.ui-button-text')
+ .html('Download Data (' + formattedSize + ' MB)');
} else {
- $button.find(".ui-button-text")
- .html("Download Selected Data");
+ $button.find('.ui-button-text')
+ .html('Download Selected Data');
}
} else {
- $button.button("disable");
- $button.find(".ui-button-text")
- .html("No Data Selected");
+ $button.button('disable');
+ $button.find('.ui-button-text')
+ .html('No Data Selected');
}
var counts = model.getSelectionCounts();
- $.each(counts, function(productId, count) {
- $("#" + productId + "dynamictext")
- .html("" + count + " selected");
+ $.each(counts, function (productId, count) {
+ $('#' + productId + 'dynamictext')
+ .html('' + count + ' selected');
});
if (downloadListPanel && downloadListPanel.visible()) {
downloadListPanel.refresh();
}
};
- var showDownloadList = function() {
+ var showDownloadList = function () {
WVC.GA.event('Data Download', 'Click', 'Download Button');
if (selectionListPanel) {
selectionListPanel.setVisible(false);
@@ -353,7 +350,7 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
if (!downloadListPanel) {
downloadListPanel =
wv.data.ui.downloadListPanel(config, model);
- downloadListPanel.events.on("close", function() {
+ downloadListPanel.events.on('close', function () {
if (selectionListPanel) {
selectionListPanel.setVisible(true);
}
@@ -362,11 +359,11 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
downloadListPanel.show();
};
- var showUnavailableReason = function() {
+ var showUnavailableReason = function () {
var headerMsg = "<h3 class='wv-data-unavailable-header'>Why are these layers not available for downloading?</h3>";
var bodyMsg = 'Some layers in Worldview do not have corresponding source data products available for download. These include National Boundaries, Orbit Tracks, Earth at Night, and MODIS Corrected Reflectance products.<br><br>For a downloadable product similar to MODIS Corrected Reflectance, please try the MODIS Land Surface Reflectance layers available in Worldview. If you would like to generate MODIS Corrected Reflectance imagery yourself, please see the following document: <a href="https://earthdata.nasa.gov/sites/default/files/field/document/MODIS_True_Color.pdf" target="_blank">https://earthdata.nasa.gov/sites/default/files/field/document/MODIS_True_Color.pdf</a><br><br>If you would like to download only an image, please use the "camera" icon in the upper right.<br><br> Data download will not work for "Terra and Aqua" Fires, select Terra only Fires and/or Aqua only Fires to download the associated data files.';
- wv.ui.notify(headerMsg + bodyMsg, "Notice", 600);
+ wv.ui.notify(headerMsg + bodyMsg, 'Notice', 600);
};
init();
@@ -374,27 +371,27 @@ wv.data.ui = wv.data.ui || function(models, ui, config) {
};
wv.data.ui.bulkDownloadPage = wv.data.ui.bulkDownloadPage ||
- (function() {
+ (function () {
var ns = {};
var pages = {
- wget: "pages/wget.html",
- curl: "pages/curl.html"
+ wget: 'pages/wget.html',
+ curl: 'pages/curl.html'
};
- ns.show = function(selection, type) {
+ ns.show = function (selection, type) {
var nonce = Date.now();
- var page = window.open(pages[type] + "?v=" + nonce,
+ var page = window.open(pages[type] + '?v=' + nonce,
'Worldview_' + nonce);
var loaded = false;
- page.onload = function() {
+ page.onload = function () {
if (!loaded) {
fillPage(page, selection, type);
loaded = true;
}
};
var checkCount = 0;
- var timer = setInterval(function() {
+ var timer = setInterval(function () {
checkCount++;
if (loaded) {
clearInterval(timer);
@@ -411,27 +408,27 @@ wv.data.ui.bulkDownloadPage = wv.data.ui.bulkDownloadPage ||
}, 100);
};
- var fillPage = function(page, selection, type) {
+ var fillPage = function (page, selection, type) {
var downloadLinks = [];
var hosts = {};
var indirectLinks = [];
- $.each(selection, function(index, product) {
- $.each(product.list, function(index2, granule) {
- var netrc = "";
+ $.each(selection, function (index, product) {
+ $.each(product.list, function (index2, granule) {
+ var netrc = '';
if (granule.urs) {
- netrc = "--netrc ";
+ netrc = '--netrc ';
}
- $.each(granule.links, function(index2, link) {
+ $.each(granule.links, function (index2, link) {
if (!link.data) {
return;
}
if (product.noBulkDownload) {
indirectLinks.push("<li><a href='" + link.href + "'>" +
- link.href + "</a></li>");
+ link.href + '</a></li>');
return;
}
- if (type === "curl") {
- downloadLinks.push("curl --remote-name " + netrc +
+ if (type === 'curl') {
+ downloadLinks.push('curl --remote-name ' + netrc +
link.href);
} else {
downloadLinks.push(link.href);
@@ -447,43 +444,43 @@ wv.data.ui.bulkDownloadPage = wv.data.ui.bulkDownloadPage ||
});
});
});
- var links = page.document.getElementById("links");
+ var links = page.document.getElementById('links');
if (!links) return false;
- links.innerHTML = "<pre>" + downloadLinks.join("\n") + "</pre>";
+ links.innerHTML = '<pre>' + downloadLinks.join('\n') + '</pre>';
var netrcEntries = [];
var hostnames = [];
- $.each(hosts, function(host) {
- netrcEntries.push("machine " + host + " login URS_USER " +
- "password URS_PASSWORD");
+ $.each(hosts, function (host) {
+ netrcEntries.push('machine ' + host + ' login URS_USER ' +
+ 'password URS_PASSWORD');
hostnames.push(host);
});
if (netrcEntries.length > 0) {
- page.document.getElementById("netrc")
+ page.document.getElementById('netrc')
.innerHTML =
- "<pre>" + netrcEntries.join("\n") + "</pre>";
- page.document.getElementById("bulk-password-notice")
- .style.display = "block";
- page.document.getElementById("netrc-instructions")
- .style.display = "block";
+ '<pre>' + netrcEntries.join('\n') + '</pre>';
+ page.document.getElementById('bulk-password-notice')
+ .style.display = 'block';
+ page.document.getElementById('netrc-instructions')
+ .style.display = 'block';
var instructions =
- page.document.getElementById("fdm-password-instructions");
+ page.document.getElementById('fdm-password-instructions');
if (instructions) {
- instructions.style.display = "block";
+ instructions.style.display = 'block';
}
var machineNames =
- page.document.getElementById("fdm-machine-names");
+ page.document.getElementById('fdm-machine-names');
if (machineNames) {
- machineNames.innerHTML = "<pre>" + hostnames.join("\n") +
- "</pre>";
+ machineNames.innerHTML = '<pre>' + hostnames.join('\n') +
+ '</pre>';
}
}
if (indirectLinks.length > 0) {
- page.document.getElementById("indirect-instructions")
- .style.display = "block";
- page.document.getElementById("indirect")
+ page.document.getElementById('indirect-instructions')
+ .style.display = 'block';
+ page.document.getElementById('indirect')
.innerHTML =
- "<ul>" + indirectLinks.join("\n") + "</ul>";
+ '<ul>' + indirectLinks.join('\n') + '</ul>';
}
return true;
};
@@ -491,19 +488,19 @@ wv.data.ui.bulkDownloadPage = wv.data.ui.bulkDownloadPage ||
return ns;
})();
-wv.data.ui.downloadListPanel = function(config, model) {
+wv.data.ui.downloadListPanel = function (config, model) {
var cmr = wv.data.cmr;
var NOTICE =
"<div id='wv-data-selection-notice'>" +
"<i class='icon fa fa-info-circle fa-3x'></i>" +
"<p class='text'>" +
- "Some items you have selected require a profile with " +
- "Earthdata Login to download. " +
- "It is simple and free to sign up! " +
+ 'Some items you have selected require a profile with ' +
+ 'Earthdata Login to download. ' +
+ 'It is simple and free to sign up! ' +
"<a href='https://urs.earthdata.nasa.gov/users/new' target='urs'>" +
- "Click to register for a profile.</a>" +
- "</p>" +
- "</div>";
+ 'Click to register for a profile.</a>' +
+ '</p>' +
+ '</div>';
var selection;
var self = {};
@@ -512,90 +509,90 @@ wv.data.ui.downloadListPanel = function(config, model) {
self.events = wv.util.events();
- self.show = function() {
+ self.show = function () {
$dialog = wv.ui.getDialog()
- .attr("id", "wv-data-selection");
+ .attr('id', 'wv-data-selection');
$dialog.dialog({
- title: "Download Links",
+ title: 'Download Links',
width: 600,
height: 500,
autoOpen: false
});
- var $bottomPane = $("<div></div>")
- .attr("id", "wv-data-bulk-download-links")
- .addClass("ui-dialog-buttonpane")
- .addClass("ui-widget-content")
- .addClass("ui-helper-clearfix")
+ var $bottomPane = $('<div></div>')
+ .attr('id', 'wv-data-bulk-download-links')
+ .addClass('ui-dialog-buttonpane')
+ .addClass('ui-widget-content')
+ .addClass('ui-helper-clearfix')
.html(bulkDownloadText());
- $("#wv-data-selection")
+ $('#wv-data-selection')
.after($bottomPane);
- $(".ui-dialog .ui-dialog-titlebar-close")
- .attr("tabindex", -1);
+ $('.ui-dialog .ui-dialog-titlebar-close')
+ .attr('tabindex', -1);
- $dialog.dialog("open");
+ $dialog.dialog('open');
- $("a.wget")
+ $('a.wget')
.click(showWgetPage);
- $("a.curl")
+ $('a.curl')
.click(showCurlPage);
- $dialog.find(".collapse")
+ $dialog.find('.collapse')
.accordion({
collapsible: true,
active: false,
icons: {
- header: "fa fa-caret-right fa-fw",
- activeHeader: "fa fa-caret-down fa-fw"
+ header: 'fa fa-caret-right fa-fw',
+ activeHeader: 'fa fa-caret-down fa-fw'
}
});
- $dialog.on("dialogclose", function() {
- self.events.trigger("close");
+ $dialog.on('dialogclose', function () {
+ self.events.trigger('close');
});
self.refresh();
};
- self.refresh = function() {
+ self.refresh = function () {
selection = reformatSelection();
- $("#wv-data-selection")
+ $('#wv-data-selection')
.html(bodyText(selection));
var bulkVisible = isBulkDownloadable() &&
_.size(model.selectedGranules) !== 0;
if (bulkVisible) {
- $("wv-data-bulk-download-links")
+ $('wv-data-bulk-download-links')
.show();
} else {
- $("wv-data-bulk-download-links")
+ $('wv-data-bulk-download-links')
.hide();
}
- $("#wv-data-selection .remove")
+ $('#wv-data-selection .remove')
.click(removeGranule);
- $("#wv-data-selection tr")
- .on("mouseenter", onHoverOver);
- $("#wv-data-selection tr")
- .on("mouseleave", onHoverOut);
+ $('#wv-data-selection tr')
+ .on('mouseenter', onHoverOver);
+ $('#wv-data-selection tr')
+ .on('mouseleave', onHoverOut);
};
- self.hide = function() {
- var $d = $(".ui-dialog");
+ self.hide = function () {
+ var $d = $('.ui-dialog');
if ($d.length !== 0) {
$d.hide();
}
};
- self.visible = function() {
- var $d = $(".ui-dialog");
+ self.visible = function () {
+ var $d = $('.ui-dialog');
if ($d.length !== 0) {
- return $d.is(":visible");
+ return $d.is(':visible');
}
return false;
};
- var reformatSelection = function() {
+ var reformatSelection = function () {
var selection = {};
urs = false;
- $.each(model.selectedGranules, function(key, granule) {
+ $.each(model.selectedGranules, function (key, granule) {
if (granule.urs) {
urs = true;
}
@@ -605,7 +602,7 @@ wv.data.ui.downloadListPanel = function(config, model) {
name: productConfig.name,
granules: [granule],
counts: {},
- noBulkDownload: productConfig.noBulkDownload || false,
+ noBulkDownload: productConfig.noBulkDownload || false
};
} else {
selection[granule.product].granules.push(granule);
@@ -616,14 +613,14 @@ wv.data.ui.downloadListPanel = function(config, model) {
// For each link that looks like metadata, see if that link is
// repeated in all granules for that product. If so, we want to
// bump that up to product level instead of at the granule level.
- $.each(granule.links, function(index, link) {
+ $.each(granule.links, function (index, link) {
// Formerly relied on metadata being correctly marked as data
// via the cmr.REL_DATA constant; unfortunately this wasn't
// the case in practice so the following workaround was
// implemented to check the link's file extension to see if
// it looks like a data file
var hrefExt = link.href.toLowerCase()
- .split(".")
+ .split('.')
.slice(-1);
if (hrefExt && hrefExt.length > 0) {
hrefExt = hrefExt[0];
@@ -640,28 +637,28 @@ wv.data.ui.downloadListPanel = function(config, model) {
});
});
- $.each(selection, function(key, product) {
+ $.each(selection, function (key, product) {
product.links = [];
product.list = [];
// Check the first granule, and populate product level links
// where the count equals the number of granules
var granule = product.granules[0];
- $.each(granule.links, function(index, link) {
+ $.each(granule.links, function (index, link) {
var count = product.counts[link.href];
if (count % product.granules.length === 0) {
product.links.push(reformatLink(link));
}
});
- $.each(product.granules, function(index, granule) {
+ $.each(product.granules, function (index, granule) {
var item = {
id: granule.id,
label: granule.downloadLabel || granule.label,
links: [],
urs: granule.urs
};
- $.each(granule.links, function(index, link) {
+ $.each(granule.links, function (index, link) {
// Skip this link if now at the product level
var count = product.counts[link.href];
if (count % product.granules.length === 0) {
@@ -675,7 +672,7 @@ wv.data.ui.downloadListPanel = function(config, model) {
});
product.list.push(item);
});
- product.list.sort(function(a, b) {
+ product.list.sort(function (a, b) {
if (a.label > b.label) {
return 1;
}
@@ -689,9 +686,9 @@ wv.data.ui.downloadListPanel = function(config, model) {
return selection;
};
- var isBulkDownloadable = function() {
+ var isBulkDownloadable = function () {
var result = false;
- $.each(selection, function(index, product) {
+ $.each(selection, function (index, product) {
if (!product.noBulkDownload) {
result = true;
}
@@ -699,15 +696,15 @@ wv.data.ui.downloadListPanel = function(config, model) {
return result;
};
- var reformatLink = function(link) {
+ var reformatLink = function (link) {
// For title, take it if found, otherwise, use the basename of the URI
var titleVal = link.title;
if (!link.title) {
- titleVal = link.href.split("/")
+ titleVal = link.href.split('/')
.slice(-1);
// Handle special case where link is a directory which ends with /
- if (titleVal && titleVal.length && titleVal[0] === "") {
+ if (titleVal && titleVal.length && titleVal[0] === '') {
titleVal = link.href;
}
}
@@ -719,19 +716,19 @@ wv.data.ui.downloadListPanel = function(config, model) {
};
};
- var linksText = function(links) {
+ var linksText = function (links) {
var elements = [];
- elements.push("<ul>");
- $.each(links, function(index, link) {
+ elements.push('<ul>');
+ $.each(links, function (index, link) {
elements.push(
"<li class='link'><a href='" + link.href + "' target='_blank'>" +
- link.title + "</a></li>");
+ link.title + '</a></li>');
});
- elements.push("</ul>");
- return elements.join("\n");
+ elements.push('</ul>');
+ return elements.join('\n');
};
- var granuleText = function(product, granule) {
+ var granuleText = function (product, granule) {
var elements;
if (product.name !== granule.label) {
elements = [
@@ -739,9 +736,9 @@ wv.data.ui.downloadListPanel = function(config, model) {
"<td><input type='button' class='remove' " +
"data-granule='" + granule.id + "' " +
"value='X'></input></td>",
- "<td><nobr><ul><li>" + granule.label + "</li></ul></nobr></td>",
- "<td class='wv-data-granule-link'>" + linksText(granule.links) + "</td>",
- "</tr>"
+ '<td><nobr><ul><li>' + granule.label + '</li></ul></nobr></td>',
+ "<td class='wv-data-granule-link'>" + linksText(granule.links) + '</td>',
+ '</tr>'
];
} else {
elements = [
@@ -749,145 +746,144 @@ wv.data.ui.downloadListPanel = function(config, model) {
"<td><input type='button' class='remove' " +
"data-granule='" + granule.id + "' " +
"value='X'></input></td>",
- "<td colspan='2'>" + linksText(granule.links) + "</td>",
- "</tr>"
+ "<td colspan='2'>" + linksText(granule.links) + '</td>',
+ '</tr>'
];
}
- return elements.join("\n");
+ return elements.join('\n');
};
- var productText = function(product) {
+ var productText = function (product) {
var elements = [
- "<h3>" + product.name + "</h3>"
+ '<h3>' + product.name + '</h3>'
];
- elements.push("<h5>Selected Data</h5>");
- elements.push("<table>");
+ elements.push('<h5>Selected Data</h5>');
+ elements.push('<table>');
- $.each(product.list, function(index, item) {
+ $.each(product.list, function (index, item) {
elements.push(granuleText(product, item));
});
- elements.push("</table>");
+ elements.push('</table>');
if (product.links && product.links.length > 0) {
- elements.push("<h5>Data Collection Information</h5>");
+ elements.push('<h5>Data Collection Information</h5>');
elements.push("<div class='product'>");
elements.push(linksText(product.links));
- elements.push("</div>");
+ elements.push('</div>');
}
- return elements.join("\n");
+ return elements.join('\n');
};
- var bodyText = function() {
+ var bodyText = function () {
if (_.size(model.selectedGranules) === 0) {
- return "<br/><h3>Selection Empty</h3>";
+ return '<br/><h3>Selection Empty</h3>';
}
var elements = [];
if (urs) {
elements.push(NOTICE);
}
var products = [];
- $.each(selection, function(key, product) {
+ $.each(selection, function (key, product) {
products.push(productText(product));
});
- elements.push(products.join("<br/><br/><br/>"));
- var text = elements.join("");
+ elements.push(products.join('<br/><br/><br/>'));
+ var text = elements.join('');
return text;
};
- var bulkDownloadText = function() {
+ var bulkDownloadText = function () {
var bulk =
"<div class='bulk collapse'>" +
- "<h5>Bulk Download</h5>" +
+ '<h5>Bulk Download</h5>' +
"<ul class='BulkDownload'>" +
"<li><a class='wget' href='#'>List of Links</a>: " +
- "for wget or download managers that accept a list of " +
- "URLs</li>" +
+ 'for wget or download managers that accept a list of ' +
+ 'URLs</li>' +
"<li><a class='curl' href='#'>List of cURL Commands</a>: " +
- "can be copied and pasted to " +
- "a terminal window to download using cURL.</li>" +
- "</ul>" +
- "</div>";
+ 'can be copied and pasted to ' +
+ 'a terminal window to download using cURL.</li>' +
+ '</ul>' +
+ '</div>';
return bulk;
};
- var showWgetPage = function() {
- wv.data.ui.bulkDownloadPage.show(selection, "wget");
+ var showWgetPage = function () {
+ wv.data.ui.bulkDownloadPage.show(selection, 'wget');
};
- var showCurlPage = function() {
- wv.data.ui.bulkDownloadPage.show(selection, "curl");
+ var showCurlPage = function () {
+ wv.data.ui.bulkDownloadPage.show(selection, 'curl');
};
- var removeGranule = function() {
+ var removeGranule = function () {
var id = $(this)
- .attr("data-granule");
+ .attr('data-granule');
model.unselectGranule(model.selectedGranules[id]);
onHoverOut.apply(this);
};
- var onHoverOver = function() {
- model.events.trigger("hoverOver",
+ var onHoverOver = function () {
+ model.events.trigger('hoverOver',
model.selectedGranules[$(this)
- .attr("data-granule")]);
+ .attr('data-granule')]);
};
- var onHoverOut = function() {
- model.events.trigger("hoverOut",
+ var onHoverOut = function () {
+ model.events.trigger('hoverOut',
model.selectedGranules[$(this)
- .attr("data-granule")]);
+ .attr('data-granule')]);
};
return self;
};
-wv.data.ui.selectionListPanel = function(model, results) {
-
+wv.data.ui.selectionListPanel = function (model, results) {
var self = {};
var granules = {};
var $dialog;
- var init = function() {
- model.events.on("granuleUnselect", onGranuleUnselect);
+ var init = function () {
+ model.events.on('granuleUnselect', onGranuleUnselect);
};
- self.show = function() {
- $dialog = wv.ui.getDialog("wv-data-list");
+ self.show = function () {
+ $dialog = wv.ui.getDialog('wv-data-list');
$dialog
- .attr("id", "wv-data-list")
+ .attr('id', 'wv-data-list')
.html(bodyText())
.dialog({
- title: "Select data",
+ title: 'Select data',
width: 400,
height: 400
});
- $("button.ui-dialog-titlebar-close")
+ $('button.ui-dialog-titlebar-close')
.hide();
- $.each(results.granules, function(index, granule) {
+ $.each(results.granules, function (index, granule) {
granules[granule.id] = granule;
});
- $("#wv-data-list input")
- .on("click", toggleSelection);
+ $('#wv-data-list input')
+ .on('click', toggleSelection);
};
- self.hide = function() {
- var $d = $(".ui-dialog");
+ self.hide = function () {
+ var $d = $('.ui-dialog');
if ($d.length !== 0) {
$d.hide();
}
};
- self.visible = function() {
- var $d = $(".ui-dialog");
+ self.visible = function () {
+ var $d = $('.ui-dialog');
if ($d.length !== 0) {
- return $d.is(":visible");
+ return $d.is(':visible');
}
return false;
};
- self.setVisible = function(value) {
+ self.setVisible = function (value) {
if (!value) {
self.hide();
} else {
@@ -895,41 +891,41 @@ wv.data.ui.selectionListPanel = function(model, results) {
}
};
- var resultsText = function() {
+ var resultsText = function () {
var elements = [];
- $.each(results.granules, function(index, granule) {
- var selected = model.isSelected(granule) ? "checked='true'" : "";
+ $.each(results.granules, function (index, granule) {
+ var selected = model.isSelected(granule) ? "checked='true'" : '';
elements.push(
- "<tr>" +
- "<td>" +
+ '<tr>' +
+ '<td>' +
"<input type='checkbox' value='" + granule.id + "' " +
- selected + ">" +
- "</td>" +
- "<td class='label'>" + granule.label + "</td>" +
- "</tr>"
+ selected + '>' +
+ '</td>' +
+ "<td class='label'>" + granule.label + '</td>' +
+ '</tr>'
);
});
- var text = elements.join("\n");
+ var text = elements.join('\n');
return text;
};
- var bodyText = function() {
+ var bodyText = function () {
var elements = [
"<div'>",
- "<table>",
+ '<table>',
resultsText(),
- "</table>",
- "</div>"
+ '</table>',
+ '</div>'
];
- var text = elements.join("\n") + "<br/>";
+ var text = elements.join('\n') + '<br/>';
return text;
};
- var toggleSelection = function() {
+ var toggleSelection = function () {
var granule = granules[$(this)
- .attr("value")];
+ .attr('value')];
var selected = $(this)
- .prop("checked");
+ .prop('checked');
if (selected) {
model.selectGranule(granule);
} else {
@@ -937,9 +933,9 @@ wv.data.ui.selectionListPanel = function(model, results) {
}
};
- var onGranuleUnselect = function(granule) {
+ var onGranuleUnselect = function (granule) {
$("#wv-data-list input[value='" + granule.id + "']")
- .removeAttr("checked");
+ .removeAttr('checked');
};
init();
diff --git a/web/js/date/wv.date.js b/web/js/date/wv.date.js
index 2e9183edd..5be120596 100644
--- a/web/js/date/wv.date.js
+++ b/web/js/date/wv.date.js
@@ -1,8 +1,7 @@
var wv = wv || {};
-wv.date = (function(self) {
-
- self.parse = function(state, errors) {
+wv.date = (function (self) {
+ self.parse = function (state, errors) {
if (state.time) {
state.t = state.time;
delete state.time;
@@ -13,7 +12,7 @@ wv.date = (function(self) {
} catch (error) {
delete state.t;
errors.push({
- message: "Invalid date: " + state.t,
+ message: 'Invalid date: ' + state.t,
cause: error
});
}
@@ -22,14 +21,14 @@ wv.date = (function(self) {
if (state.now) {
try {
state.now = wv.util.parseDateUTC(state.now);
- wv.util.now = function() {
+ wv.util.now = function () {
return new Date(state.now.getTime());
};
- wv.util.warn("Overriding now: " + state.now.toISOString());
+ wv.util.warn('Overriding now: ' + state.now.toISOString());
} catch (error) {
delete state.now;
errors.push({
- message: "Invalid now: " + state.now,
+ message: 'Invalid now: ' + state.now,
cause: error
});
}
@@ -37,5 +36,4 @@ wv.date = (function(self) {
};
return self;
-
})(wv.date || {});
diff --git a/web/js/date/wv.date.label.js b/web/js/date/wv.date.label.js
index a43a911bb..d9faffb90 100644
--- a/web/js/date/wv.date.label.js
+++ b/web/js/date/wv.date.label.js
@@ -9,20 +9,19 @@ wv.date = wv.date || {};
*
* @class wv.date.label
*/
-wv.date.label = wv.date.label || function(models) {
-
- var id = "timedsdateHolder";
- var $container = $("#" + id);
+wv.date.label = wv.date.label || function (models) {
+ var id = 'timedsdateHolder';
+ var $container = $('#' + id);
var model = models.date;
var self = {};
- var init = function() {
- model.events.on("select", update);
+ var init = function () {
+ model.events.on('select', update);
update();
};
- var update = function() {
+ var update = function () {
$container.html(wv.util.toISOStringDate(model.selected));
};
diff --git a/web/js/date/wv.date.model.js b/web/js/date/wv.date.model.js
index e3a236e29..4a45b3b60 100644
--- a/web/js/date/wv.date.model.js
+++ b/web/js/date/wv.date.model.js
@@ -1,42 +1,41 @@
var wv = wv || {};
wv.date = wv.date || {};
-wv.date.model = wv.date.model || function(config, spec) {
-
+wv.date.model = wv.date.model || function (config, spec) {
spec = spec || {};
var self = {};
self.events = wv.util.events();
self.selected = null;
- self.monthAbbr = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN",
- "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
+ self.monthAbbr = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
+ 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
- var init = function() {
+ var init = function () {
var initial = spec.initial || wv.util.today();
self.select(initial);
};
- self.string = function() {
+ self.string = function () {
return wv.util.toISOStringDate(self.selected);
};
- self.select = function(date) {
+ self.select = function (date) {
date = self.clamp(wv.util.clearTimeUTC(date));
var updated = false;
if (!self.selected || date.getTime() !== self.selected.getTime()) {
self.selected = date;
- self.events.trigger("select", date);
+ self.events.trigger('select', date);
updated = true;
}
return updated;
};
- self.add = function(interval, amount) {
+ self.add = function (interval, amount) {
self.select(wv.util.dateAdd(self.selected, interval, amount));
};
- self.clamp = function(date) {
+ self.clamp = function (date) {
if (date > wv.util.today()) {
date = wv.util.today();
}
@@ -49,7 +48,7 @@ wv.date.model = wv.date.model || function(config, spec) {
return date;
};
- self.isValid = function(date) {
+ self.isValid = function (date) {
if (date > wv.util.today()) {
return false;
}
@@ -62,26 +61,26 @@ wv.date.model = wv.date.model || function(config, spec) {
return true;
};
- self.minDate = function() {
+ self.minDate = function () {
if (config.startDate) {
return wv.util.parseDateUTC(config.startDate);
}
return wv.util.minDate();
};
- self.maxDate = function() {
+ self.maxDate = function () {
return wv.util.today();
};
- self.save = function(state) {
+ self.save = function (state) {
state.t = self.selected.toISOString()
- .split("T")[0];
+ .split('T')[0];
if (self.selectedZoom) {
state.z = self.selectedZoom.toString();
}
};
- self.load = function(state) {
+ self.load = function (state) {
if (state.t) {
self.select(state.t);
}
@@ -91,5 +90,4 @@ wv.date.model = wv.date.model || function(config, spec) {
};
init();
return self;
-
};
diff --git a/web/js/date/wv.date.timeline.config.js b/web/js/date/wv.date.timeline.config.js
index cb57d5d94..fba6d1b6e 100644
--- a/web/js/date/wv.date.timeline.config.js
+++ b/web/js/date/wv.date.timeline.config.js
@@ -11,33 +11,32 @@ var wv = wv || {};
wv.date = wv.date || {};
wv.date.timeline = wv.date.timeline || {};
-wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui) {
+wv.date.timeline.config = wv.date.timeline.config || function (models, config, ui) {
var self = {};
var tl = ui.timeline;
var model = models.date;
var zoomLevel = model.selectedZoom || 3;
- self.zoom = function(level, event) {
-
- //format of the label
+ self.zoom = function (level, event) {
+ // format of the label
var labelFormat;
- //printed type of tick
+ // printed type of tick
var dateInterval;
- //step of the ticks, here difference between ticks is always 1
+ // step of the ticks, here difference between ticks is always 1
var dateStep = 1;
- //number of ticks total of data range, in days
+ // number of ticks total of data range, in days
var tickCount;
- //Calculated max number of ticks based on tickCount
+ // Calculated max number of ticks based on tickCount
var tickCountMax;
- //width in pixels of each tick
+ // width in pixels of each tick
var tickWidth;
- //end tick date if tickCount is less than tickCountMax
+ // end tick date if tickCount is less than tickCountMax
var altEnd;
var paddedRange;
switch (level) {
case 1:
- labelFormat = d3.time.format.utc("%Y");
+ labelFormat = d3.time.format.utc('%Y');
dateInterval = d3.time.year.utc;
tickCount = tl.data.end()
.getUTCFullYear() - tl.data.start()
@@ -45,12 +44,10 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
tickWidth = 15;
tickCountMax = Math.ceil(tl.width / tickWidth);
- paddedRange = [new Date(tl.data.start()
- .setUTCFullYear(tl.data.start()
- .getUTCFullYear() - 10)),
- new Date(tl.data.end()
- .setUTCFullYear(tl.data.end()
- .getUTCFullYear() + 10))];
+ paddedRange = [
+ new Date(tl.data.start().setUTCFullYear(tl.data.start().getUTCFullYear() - 10)),
+ new Date(tl.data.end().setUTCFullYear(tl.data.end().getUTCFullYear() + 10))
+ ];
altEnd = new Date(tl.data.start()
.getUTCFullYear() + tickCountMax,
@@ -59,8 +56,6 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
tl.data.start()
.getUTCDate());
-
-
tl.zoom.drawTicks(tickCount,
tickCountMax,
altEnd,
@@ -71,74 +66,74 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
event,
paddedRange);
- //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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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() {
+ // 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 first printed normal tick
- tl.zoom.current.ticks.normal.first = function() {
+ // Date of first printed normal tick
+ tl.zoom.current.ticks.normal.first = function () {
var first = tl.ticks.firstDate;
return new Date(Date.UTC(first.getUTCFullYear() - 1,
first.getUTCMonth(),
first.getUTCDate()));
};
- //Date of last printed boundary interval of this zoom level
- tl.zoom.current.ticks.boundary.last = function() {
+ // 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
+ // 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) {
+ // 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) {
+ // 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);
@@ -147,18 +142,18 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
model.selected.getUTCDate());
};
- //Displayed default label
- tl.zoom.current.ticks.boundary.label = function(d) {
+ // 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) {
+ // 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) {
+ // 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);
@@ -167,49 +162,49 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
model.selected.getUTCDate());
};
- //When the date updates while dragging the pick forward
- tl.zoom.current.pick.nextChange = function(d) {
+ // 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) {
+ // 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.hoverTick = function (newDate) {
tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')
- .filter(function(d) {
+ .filter(function (d) {
return d.getUTCFullYear() === newDate.getUTCFullYear();
});
};
- //Update placement of zoom buttons
+ // Update placement of zoom buttons
$('.zoom-btn')
- .removeClass(function(index, css) {
+ .removeClass(function (index, css) {
return (css.match(/(^|\s)depth-\S+/g) || [])
.join(' ');
})
- .css("margin", "")
- .css("font-size", "");
+ .css('margin', '')
+ .css('font-size', '');
$('#zoom-years')
- .addClass("depth-1")
- .css("font-size", "1.7em");
+ .addClass('depth-1')
+ .css('font-size', '1.7em');
$('#zoom-months')
- .addClass("depth-2")
- .css("font-size", "1.2em");
+ .addClass('depth-2')
+ .css('font-size', '1.2em');
$('#zoom-days')
- .addClass("depth-3")
- .css("margin", "-3px 0 5px 0");
+ .addClass('depth-3')
+ .css('margin', '-3px 0 5px 0');
self.currentZoom = 1;
break;
case 2:
- labelFormat = d3.time.format.utc("%Y");
+ labelFormat = d3.time.format.utc('%Y');
dateInterval = d3.time.month.utc;
tickCount = (tl.data.end()
@@ -224,12 +219,10 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
tickWidth = 11;
tickCountMax = Math.ceil(tl.width / tickWidth);
- paddedRange = [new Date(tl.data.start()
- .setUTCFullYear(tl.data.start()
- .getUTCFullYear() - 1)),
- new Date(tl.data.end()
- .setUTCFullYear(tl.data.end()
- .getUTCFullYear() + 1))];
+ paddedRange = [
+ new Date(tl.data.start().setUTCFullYear(tl.data.start().getUTCFullYear() - 1)),
+ new Date(tl.data.end().setUTCFullYear(tl.data.end().getUTCFullYear() + 1))
+ ];
altEnd = new Date(tl.data.start()
.getUTCFullYear(),
@@ -248,146 +241,144 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
event,
paddedRange);
- //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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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() {
+ // 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 first printed normal tick
- tl.zoom.current.ticks.normal.first = function() {
+ // Date of first printed normal tick
+ tl.zoom.current.ticks.normal.first = function () {
var first = tl.ticks.normal.firstDate;
return new Date(Date.UTC(first.getUTCFullYear(),
first.getUTCMonth() - 1,
first.getUTCDate()));
};
- //Date of last printed boundary interval of this zoom level
- tl.zoom.current.ticks.boundary.last = function() {
+ // 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
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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.hoverTick = function (newDate) {
tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')
- .filter(function(d) {
+ .filter(function (d) {
return (d.getUTCFullYear() === newDate.getUTCFullYear()) &&
(d.getUTCMonth() === newDate.getUTCMonth());
});
};
- //Update placement of zoom buttons
+ // Update placement of zoom buttons
$('.zoom-btn')
- .removeClass(function(index, css) {
+ .removeClass(function (index, css) {
return (css.match(/(^|\s)depth-\S+/g) || [])
.join(' ');
})
- .css("margin", "")
- .css("font-size", "");
+ .css('margin', '')
+ .css('font-size', '');
$('#zoom-days')
- .addClass("depth-2")
- .css("margin", "5px 0 0 0");
+ .addClass('depth-2')
+ .css('margin', '5px 0 0 0');
$('#zoom-years')
- .addClass("depth-2");
+ .addClass('depth-2');
$('#zoom-months')
- .addClass("depth-1")
- .css("font-size", "1.7em");
+ .addClass('depth-1')
+ .css('font-size', '1.7em');
self.currentZoom = 2;
break;
case 3:
- labelFormat = d3.time.format.utc("%b");
+ 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);
- paddedRange = [new Date(tl.data.start()
- .setUTCDate(tl.data.start()
- .getUTCDate() - 15)),
- new Date(tl.data.end()
- .setUTCDate(tl.data.end()
- .getUTCDate() + 15))];
+ paddedRange = [
+ new Date(tl.data.start().setUTCDate(tl.data.start().getUTCDate() - 15)),
+ new Date(tl.data.end().setUTCDate(tl.data.end().getUTCDate() + 15))
+ ];
altEnd = new Date(tl.data.start()
.getUTCFullYear(),
@@ -406,111 +397,111 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
event,
paddedRange);
- //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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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() {
+ // 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 first printed normal tick
- tl.zoom.current.ticks.normal.first = function() {
+ // Date of first printed normal tick
+ tl.zoom.current.ticks.normal.first = function () {
var first = tl.ticks.normal.firstDate;
return new Date(Date.UTC(first.getUTCFullYear(),
first.getUTCMonth(),
first.getUTCDate() - 1));
};
- //Date of last printed boundary interval of this zoom level
- tl.zoom.current.ticks.boundary.last = function() {
+ // 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
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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) {
+ // 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.hoverTick = function (newDate) {
tl.zoom.current.pick.hoveredTick = d3.selectAll('.x.axis>g.tick')
- .filter(function(d) {
+ .filter(function (d) {
return (d.getUTCFullYear() === newDate.getUTCFullYear()) &&
(d.getUTCMonth() === newDate.getUTCMonth() &&
(d.getUTCDate() === newDate.getUTCDate()));
@@ -518,7 +509,7 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
};
d3.selectAll('.x.axis > g.tick')
- .each(function() {
+ .each(function () {
var currentTick = d3.select(this);
var currentTickData = currentTick.data()[0];
if ((currentTickData.getUTCDay() === 0) &&
@@ -532,22 +523,22 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
}
});
- //Update placement of zoom buttons
+ // Update placement of zoom buttons
$('.zoom-btn')
- .removeClass(function(index, css) {
+ .removeClass(function (index, css) {
return (css.match(/(^|\s)depth-\S+/g) || [])
.join(' ');
})
- .css("margin", "")
- .css("font-size", "");
+ .css('margin', '')
+ .css('font-size', '');
$('#zoom-years')
- .addClass("depth-3")
- .css("margin", "6px 0 0 0");
+ .addClass('depth-3')
+ .css('margin', '6px 0 0 0');
$('#zoom-months')
- .addClass("depth-2");
+ .addClass('depth-2');
$('#zoom-days')
- .addClass("depth-1")
- .css("margin", "8px 0 0 0")
+ .addClass('depth-1')
+ .css('margin', '8px 0 0 0')
.css('font-size', '1.8em');
self.currentZoom = 3;
@@ -557,7 +548,7 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
console.log('Invalid Zoom level');
}
- //TODO: Maybe group check, initTicks, and removePadding
+ // TODO: Maybe group check, initTicks, and removePadding
tl.ticks.check();
initTicks();
@@ -568,46 +559,44 @@ wv.date.timeline.config = wv.date.timeline.config || function(models, config, ui
model.events.trigger('timeline-change');
};
- //Draw ticks based on zoom level
- var initTicks = function() {
+ // 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.set(); // could probably combine set and bind
tl.ticks.normal.bind();
tl.ticks.boundary.set();
tl.ticks.boundary.bind();
};
- var init = function() {
-
- d3.select("#zoom-years")
- .on("click", function(d) {
+ var init = function () {
+ d3.select('#zoom-years')
+ .on('click', function (d) {
$('.zoom-btn')
- .removeClass("zoom-btn-selected");
+ .removeClass('zoom-btn-selected');
$(this)
- .addClass("zoom-btn-selected");
+ .addClass('zoom-btn-selected');
self.zoom(1);
});
- d3.select("#zoom-months")
- .on("click", function(d) {
+ d3.select('#zoom-months')
+ .on('click', function (d) {
$('.zoom-btn')
- .removeClass("zoom-btn-selected");
+ .removeClass('zoom-btn-selected');
$(this)
- .addClass("zoom-btn-selected");
+ .addClass('zoom-btn-selected');
self.zoom(2);
-
});
- d3.select("#zoom-days")
- .on("click", function(d) {
+ d3.select('#zoom-days')
+ .on('click', function (d) {
$('.zoom-btn')
- .removeClass("zoom-btn-selected");
+ .removeClass('zoom-btn-selected');
$(this)
- .addClass("zoom-btn-selected");
+ .addClass('zoom-btn-selected');
self.zoom(3);
});
- //Default zoom
+ // Default zoom
self.zoom(zoomLevel);
- tl.setClip(); //fix for firefox svg overflow
+ tl.setClip(); // fix for firefox svg overflow
};
init();
diff --git a/web/js/date/wv.date.timeline.data.js b/web/js/date/wv.date.timeline.data.js
index f6734e734..af53ec612 100644
--- a/web/js/date/wv.date.timeline.data.js
+++ b/web/js/date/wv.date.timeline.data.js
@@ -10,33 +10,31 @@ wv.date.timeline = wv.date.timeline || {};
*
* @class wv.date.timeline.data
*/
-wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {
-
+wv.date.timeline.data = wv.date.timeline.data || function (models, config, ui) {
var tl = ui.timeline;
var model = models.date;
var self = {};
- self.start = function() {
+ self.start = function () {
return new Date(config.startDate);
};
- self.end = function() {
+ self.end = function () {
return new Date(
new Date(wv.util.today())
.setUTCDate(wv.util.today()
.getUTCDate()));
};
- self.set = function() {
-
+ self.set = function () {
var activeLayers = models.layers.get();
- var activeLayersDynamic = activeLayers.filter(function(al) {
+ 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;
@@ -44,7 +42,7 @@ wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {
.remove();
$(activeLayersDynamic)
- .each(function(i) {
+ .each(function (i) {
activeLayersTitles[i] = this.id;
});
@@ -54,11 +52,11 @@ wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {
tl.yAxis = d3.svg.axis()
.scale(tl.y)
- .orient("left")
+ .orient('left')
.ticks(layerCount);
$(activeLayersDynamic)
- .each(function(al) {
+ .each(function (al) {
var layerStart, layerEnd, layerXY;
var layerVisible = true;
var staticLayer = true;
@@ -78,15 +76,15 @@ wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {
.getUTCDate() + 1));
}
- var currentDB = tl.dataBars.append("svg:rect")
+ var currentDB = tl.dataBars.append('svg:rect')
.attr('x', tl.x(layerStart))
.attr('width', tl.x(layerEnd) - tl.x(layerStart))
- //.attr('height',2)
+ // .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('class', 'data-bar');
// .attr("d", selection);
if (!staticLayer) {
currentDB.classed('data-bar-dyn', true);
@@ -95,7 +93,6 @@ wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {
layerVisible = false;
currentDB.classed('data-bar-invisible', true);
}
-
});
tl.dataBars.selectAll('rect')
.attr('height', (tl.height - 22) / layerCount);
@@ -105,8 +102,7 @@ wv.date.timeline.data = wv.date.timeline.data || function(models, config, ui) {
}
};
- var init = function() {
-
+ var init = function () {
};
diff --git a/web/js/date/wv.date.timeline.input.js b/web/js/date/wv.date.timeline.input.js
index 86fb7c6ec..6ed761f4e 100644
--- a/web/js/date/wv.date.timeline.input.js
+++ b/web/js/date/wv.date.timeline.input.js
@@ -10,58 +10,57 @@ wv.date.timeline = wv.date.timeline || {};
*
* @class wv.date.timeline.input
*/
-wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui) {
-
+wv.date.timeline.input = wv.date.timeline.input || function (models, config, ui) {
var tl = ui.timeline;
var model = models.date;
var timer;
var self = {};
var rollingDate;
- self.direction = "forward";
- self.interval = "day";
+ self.direction = 'forward';
+ self.interval = 'day';
self.delta = 1;
self.active = false;
self.delay = 500;
- var $incrementBtn = $("#right-arrow-group");
- var $decrementBtn = $("#left-arrow-group");
+ var $incrementBtn = $('#right-arrow-group');
+ var $decrementBtn = $('#left-arrow-group');
- var forwardNextDay = function() { //FIXME: Limit animation correctly
+ var forwardNextDay = function () { // FIXME: Limit animation correctly
var nextDay = new Date(new Date(model.selected)
.setUTCDate(model.selected.getUTCDate() + 1));
if (nextDay <= wv.util.today()) {
- animateForward("day");
+ animateForward('day');
} else {
self.stop();
}
};
- self.forward = function() {
- self.play("forward");
+ self.forward = function () {
+ self.play('forward');
};
- self.reverse = function() {
- self.play("reverse");
+ self.reverse = function () {
+ self.play('reverse');
};
- self.stop = function() {
+ self.stop = function () {
if (timer) {
clearTimeout(timer);
}
timer = null;
self.active = false;
};
- var prepareFrame = function() {
+ var prepareFrame = function () {
if (!self.active) {
return;
}
- var amount = (self.direction === "forward") ?
- self.delta : -self.delta;
+ var amount = (self.direction === 'forward')
+ ? self.delta : -self.delta;
var newDate = wv.util.dateAdd(model.selected, self.interval, amount);
- timer = setTimeout(function() {
+ timer = setTimeout(function () {
advance(newDate);
}, self.delay);
};
- var advance = function(newDate) {
+ var advance = function (newDate) {
var updated = model.select(newDate);
if (!updated) {
self.stop();
@@ -69,7 +68,7 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
prepareFrame();
}
};
- self.play = function(direction) {
+ self.play = function (direction) {
if (self.active && direction !== self.direction) {
self.stop();
} else if (self.active) {
@@ -79,43 +78,43 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
self.active = true;
prepareFrame();
};
- var reversePrevDay = function() { //FIXME: Limit animation correctly
+ var reversePrevDay = function () { // FIXME: Limit animation correctly
var prevDay = new Date(new Date(model.selected)
.setUTCDate(model.selected.getUTCDate() - 1));
if (prevDay >= tl.data.start()) {
- animateReverse("day");
+ animateReverse('day');
} else {
self.stop();
}
};
- var animateForward = function(interval) {
+ var animateForward = function (interval) {
if (self.active) {
return;
}
models.date.add(interval, 1);
self.interval = interval;
- self.play("forward");
+ self.play('forward');
};
- var animateReverse = function(interval) {
+ var animateReverse = function (interval) {
if (self.active) {
return;
}
models.date.add(interval, -1);
self.interval = interval;
- self.play("reverse");
+ self.play('reverse');
};
- var roll = function(dataInterval, amt) {
+ var roll = function (dataInterval, amt) {
if (timer) {
clearTimeout(timer);
timer = null;
}
var interval = $(this)
- .attr("data-interval") || dataInterval;
+ .attr('data-interval') || dataInterval;
var amount = _.parseInt($(this)
- .attr("data-value")) || amt;
+ .attr('data-value')) || amt;
var date = rollingDate || models.date.selected;
var min = models.date.minDate();
var max = models.date.maxDate();
@@ -125,10 +124,10 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
rollingDate = newDate;
$(this)
.parent()
- .css("border-color", "");
+ .css('border-color', '');
updateDateInputs(rollingDate);
var that = this;
- timer = setTimeout(function() {
+ timer = setTimeout(function () {
model.select(rollingDate);
$(that)
.parent()
@@ -140,11 +139,11 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
}
};
- //TODO: Cleanup
- var validateInput = function(event) {
+ // TODO: Cleanup
+ var validateInput = function (event) {
var kc = event.keyCode || event.which;
var entered = (kc == 13) || (kc === 9);
- if (event.type == "focusout" || entered) {
+ if (event.type == 'focusout' || entered) {
if (entered) {
event.preventDefault();
}
@@ -155,10 +154,11 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
var selectedDateObj = null;
switch (YMDInterval) {
case 'year-input-group':
- if ((newInput > 1000) && (newInput < 9999))
+ if ((newInput > 1000) && (newInput < 9999)) {
selectedDateObj = new Date(
(new Date(model.selected))
.setUTCFullYear(newInput));
+ }
break;
case 'month-input-group':
if (($.isNumeric(newInput)) &&
@@ -222,7 +222,7 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
} else {
selected.parent()
.css('border-color', '#ff0000');
- if (event.type !== "focusout") {
+ if (event.type !== 'focusout') {
selected.select();
} else {
if (document.selection) {
@@ -233,11 +233,11 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
}
selected.parent()
.animate({
- borderColor: "rgba(40, 40, 40, .9)"
+ borderColor: 'rgba(40, 40, 40, .9)'
}, {
- complete: function() {
+ complete: function () {
selected.parent()
- .css("border-color", "");
+ .css('border-color', '');
}
});
self.update();
@@ -246,38 +246,38 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
}
};
- //TODO: Combine with self.update
- var updateDateInputs = function(date) {
+ // TODO: Combine with self.update
+ var updateDateInputs = function (date) {
date = date || models.selected.date;
- $("#year-input-group")
+ $('#year-input-group')
.val(date.getUTCFullYear());
- $("#month-input-group")
+ $('#month-input-group')
.val(model.monthAbbr[date.getUTCMonth()]);
var day = date.getUTCDate();
- $("#day-input-group")
- .val(wv.util.pad(date.getUTCDate(), 2, "0"));
+ $('#day-input-group')
+ .val(wv.util.pad(date.getUTCDate(), 2, '0'));
};
- //TODO: Cleanup
- self.update = function(date) {
+ // TODO: Cleanup
+ self.update = function (date) {
var ms = date || new Date(model.selected);
var nd = new Date(ms.setUTCDate(ms.getUTCDate() + 1));
var pd = new Date(ms.setUTCDate(ms.getUTCDate() - 1));
- //Update fields
+ // Update fields
$('#year-input-group')
.val(model.selected.getUTCFullYear());
$('#month-input-group')
.val(model.monthAbbr[model.selected.getUTCMonth()]);
if (model.selected.getUTCDate() < 10) {
$('#day-input-group')
- .val("0" + model.selected.getUTCDate());
+ .val('0' + model.selected.getUTCDate());
} else {
$('#day-input-group')
.val(model.selected.getUTCDate());
}
- //Disable arrows if nothing before/after selection
+ // Disable arrows if nothing before/after selection
if (nd > wv.util.today()) {
$incrementBtn.addClass('button-disabled');
} else {
@@ -293,18 +293,17 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
tl.pick.update();
};
- //TODO: Cleanup
- var init = function() {
-
+ // TODO: Cleanup
+ var init = function () {
$incrementBtn
- .mousedown(function(e) {
+ .mousedown(function (e) {
e.preventDefault();
forwardNextDay();
})
.mouseup(self.stop);
$decrementBtn
- .mousedown(function(e) {
+ .mousedown(function (e) {
e.preventDefault();
reversePrevDay();
})
@@ -312,23 +311,22 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
$(document)
.mouseout(self.stop)
- .keydown(function(event) {
- if (event.target.nodeName === "INPUT") {
+ .keydown(function (event) {
+ if (event.target.nodeName === 'INPUT') {
return;
}
switch (event.keyCode) {
case wv.util.key.LEFT:
- animateReverse("day");
+ animateReverse('day');
event.preventDefault();
break;
case wv.util.key.RIGHT:
- animateForward("day");
+ animateForward('day');
event.preventDefault();
break;
-
}
})
- .keyup(function(event) {
+ .keyup(function (event) {
switch (event.keyCode) {
case wv.util.key.LEFT:
case wv.util.key.RIGHT:
@@ -343,7 +341,7 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
// FIXME: Quick fix for fixing the propagation
// of events with arrow keys and input field
- $buttons.keydown(function(event) {
+ $buttons.keydown(function (event) {
var interval = $(this)
.attr('id')
.split('-')[0];
@@ -366,10 +364,9 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
.select()
.focus();
}
-
});
- $buttons.on('focus', function(e) {
+ $buttons.on('focus', function (e) {
e.preventDefault();
$buttons.siblings('.date-arrows')
.css('visibility', '');
@@ -383,7 +380,7 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
.css('visibility', 'visible');
});
- $buttons.focusout(function(e) {
+ $buttons.focusout(function (e) {
$buttons.siblings('.date-arrows')
.css('visibility', '');
$buttons.parent()
@@ -392,50 +389,50 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
var $incrementIntDate = $('.date-arrow-up');
$incrementIntDate.click(roll);
- $incrementIntDate.mousedown(function(e) {
+ $incrementIntDate.mousedown(function (e) {
e.preventDefault();
});
var $decrementIntDate = $('.date-arrow-down');
$decrementIntDate.click(roll);
- $decrementIntDate.mousedown(function(e) {
+ $decrementIntDate.mousedown(function (e) {
e.preventDefault();
});
- //select all input on focus
+ // select all input on focus
$('input')
- .focus(function(e) {
+ .focus(function (e) {
$(this)
.select();
})
- .mouseup(function(e) {
+ .mouseup(function (e) {
e.preventDefault();
});
$('.button-input-group')
.keydown(validateInput)
- .focusout(function(event) {
+ .focusout(function (event) {
if ($(this)
- .hasClass("focus")) {
+ .hasClass('focus')) {
$(this)
- .removeClass("focus");
+ .removeClass('focus');
validateInput.call(this, event);
}
})
- .focus(function() {
+ .focus(function () {
$(this)
- .addClass("focus");
+ .addClass('focus');
});
- $("#focus-guard-1")
- .on('focus', function() {
- $("#day-input-group")
+ $('#focus-guard-1')
+ .on('focus', function () {
+ $('#day-input-group')
.focus()
.select();
});
- $("#focus-guard-2")
- .on('focus', function() {
- $("#year-input-group")
+ $('#focus-guard-2')
+ .on('focus', function () {
+ $('#year-input-group')
.focus()
.select();
});
@@ -446,7 +443,6 @@ wv.date.timeline.input = wv.date.timeline.input || function(models, config, ui)
}
self.update();
-
};
init();
diff --git a/web/js/date/wv.date.timeline.js b/web/js/date/wv.date.timeline.js
index 038b05f0d..a468bacae 100644
--- a/web/js/date/wv.date.timeline.js
+++ b/web/js/date/wv.date.timeline.js
@@ -8,7 +8,7 @@ wv.date = wv.date || {};
*
* @class wv.date.timeline
*/
-wv.date.timeline = wv.date.timeline || function(models, config, ui) {
+wv.date.timeline = wv.date.timeline || function (models, config, ui) {
var self = {};
var model = models.date;
@@ -21,19 +21,19 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {
left: 30
};
- self.getPadding = function() {
+ self.getPadding = function () {
self.padding = self.width / 4;
return self.padding;
};
- self.getWidth = function() {
+ self.getWidth = function () {
self.width = $(window)
.outerWidth(true) -
- $("#timeline-header")
+ $('#timeline-header')
.outerWidth(true) -
- $("#timeline-zoom")
+ $('#timeline-zoom')
.outerWidth(true) -
- $("#timeline-hide")
+ $('#timeline-hide')
.outerWidth(true) -
self.margin.left - self.margin.right - 22;
@@ -44,18 +44,18 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {
self.isCropped = true;
- self.toggle = function(now) {
+ self.toggle = function (now) {
var tl = $('#timeline-footer');
var tlz = $('#timeline-zoom');
var tlg = self.boundary;
var gp = d3.select('#guitarpick');
if (tl.is(':hidden')) {
- var afterShow = function() {
+ var afterShow = function () {
tlz.show();
$('#timeline')
.css('right', '10px');
tlg.attr('style', 'clip-path:url("#timeline-boundary")');
- gp.attr("style", "display:block;clip-path:url(#guitarpick-boundary);");
+ gp.attr('style', 'display:block;clip-path:url(#guitarpick-boundary);');
};
if (now) {
tl.show();
@@ -65,7 +65,7 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {
}
} else {
tlg.attr('style', 'clip-path:none');
- gp.attr("style", "display:none;clip-path:none");
+ gp.attr('style', 'display:none;clip-path:none');
tlz.hide();
tl.hide('slow');
$('#timeline')
@@ -73,38 +73,38 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {
}
};
- self.expand = function(now) {
+ self.expand = function (now) {
now = now || false;
var tl = $('#timeline-footer, #timeline-zoom');
- if (tl.is(":hidden")) {
+ if (tl.is(':hidden')) {
self.toggle(now);
}
};
- self.expandNow = function() {
+ self.expandNow = function () {
self.expand(true);
};
- self.collapse = function(now) {
+ self.collapse = function (now) {
var tl = $('#timeline-footer, #timeline-zoom');
- if (!tl.is(":hidden")) {
+ if (!tl.is(':hidden')) {
self.toggle(now);
}
};
- self.collapseNow = function() {
+ self.collapseNow = function () {
self.collapse(true);
};
- self.resize = function() {
+ self.resize = function () {
var small = wv.util.browser.small || wv.util.browser.constrained;
if (self.enabled && small) {
self.enabled = false;
- $("#timeline")
+ $('#timeline')
.hide();
} else if (!self.enabled && !small) {
self.enabled = true;
- $("#timeline")
+ $('#timeline')
.show();
}
@@ -121,19 +121,17 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {
self.margin.left +
self.margin.right);
- self.axis.select("line:first-child")
- .attr("x2", self.width);
-
+ self.axis.select('line:first-child')
+ .attr('x2', self.width);
}
-
};
- self.setClip = function() { //This is a hack until Firefox fixes their svg rendering problems
+ self.setClip = function () { // This is a hack until Firefox fixes their svg rendering problems
d3.select('#timeline-footer svg > g:nth-child(2)')
.attr('visibility', 'hidden');
d3.select('#timeline-footer svg > g:nth-child(2)')
.attr('style', '');
- setTimeout(function() {
+ setTimeout(function () {
d3.select('#timeline-footer svg > g:nth-child(2)')
.attr('style', 'clip-path:url("#timeline-boundary")');
d3.select('#timeline-footer svg > g:nth-child(2)')
@@ -141,63 +139,62 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {
}, 50);
};
- var drawContainers = function() {
+ var drawContainers = function () {
self.getWidth();
self.svg = d3.select('#timeline-footer')
- .append("svg:svg")
+ .append('svg:svg')
.attr('width', self.width) // + margin.left + margin.right)
.attr('height', self.height + self.margin.top + self.margin.bottom + 16);
self.svg
- .append("svg:defs")
- .append("svg:clipPath")
- .attr("id", "timeline-boundary")
- .append("svg:rect")
+ .append('svg:defs')
+ .append('svg:clipPath')
+ .attr('id', 'timeline-boundary')
+ .append('svg:rect')
.attr('width', self.width) // + margin.left + margin.right)
.attr('height', self.height + self.margin.top + self.margin.bottom);
- d3.select("#timeline-footer svg defs")
- .append("svg:clipPath")
- .attr("id", "guitarpick-boundary")
- .append("svg:rect")
+ d3.select('#timeline-footer svg defs')
+ .append('svg:clipPath')
+ .attr('id', 'guitarpick-boundary')
+ .append('svg:rect')
.attr('width', self.width + self.margin.left + self.margin.right) // + margin.left + margin.right)
.attr('height', self.height + self.margin.top + self.margin.bottom)
- .attr("x", -self.margin.left);
+ .attr('x', -self.margin.left);
self.boundary = self.svg
- .append("svg:g")
- .attr("clip-path", "#timeline-boundary")
- .attr("style", "clip-path:url(#timeline-boundary)")
- .attr("transform", "translate(0,16)");
+ .append('svg:g')
+ .attr('clip-path', '#timeline-boundary')
+ .attr('style', 'clip-path:url(#timeline-boundary)')
+ .attr('transform', 'translate(0,16)');
- self.axis = self.boundary.append("svg:g")
- .attr("class", "x axis")
- .attr("transform", "translate(0," + self.height + ")");
+ self.axis = self.boundary.append('svg:g')
+ .attr('class', 'x axis')
+ .attr('transform', 'translate(0,' + self.height + ')');
self.axis
- .insert("line", ":first-child")
- .attr("x1", 0)
- .attr("x2", self.width); //+margin.left+margin.right);
+ .insert('line', ':first-child')
+ .attr('x1', 0)
+ .attr('x2', self.width); // +margin.left+margin.right);
- self.dataBars = self.boundary.insert("svg:g", '.x.axis')
- .attr("height", self.height)
+ self.dataBars = self.boundary.insert('svg:g', '.x.axis')
+ .attr('height', self.height)
.classed('plot', true);
- self.verticalAxis = self.boundary.append("svg:g")
- .attr("class", "y axis")
- .attr("transform", "translate(0,0)");
+ self.verticalAxis = self.boundary.append('svg:g')
+ .attr('class', 'y axis')
+ .attr('transform', 'translate(0,0)');
self.animboundary = self.svg
- .append("svg:g")
- .attr("clip-path", "#timeline-boundary")
- .attr("transform", "translate(0,16)");
+ .append('svg:g')
+ .attr('clip-path', '#timeline-boundary')
+ .attr('transform', 'translate(0,16)');
self.animboundary
.append('g')
.attr('id', 'wv-rangeselector-case');
-
};
- var init = function() {
+ var init = function () {
var $timelineFooter = $('#timeline-footer');
drawContainers();
@@ -214,7 +211,7 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {
self.x = d3.time.scale.utc();
self.xAxis = d3.svg.axis()
- .orient("bottom")
+ .orient('bottom')
.tickSize(-self.height)
.tickPadding(5);
@@ -225,32 +222,31 @@ wv.date.timeline = wv.date.timeline || function(models, config, ui) {
self.resize();
if (wv.util.browser.localStorage) {
- if (localStorage.getItem("timesliderState") === "collapsed") {
+ if (localStorage.getItem('timesliderState') === 'collapsed') {
self.collapseNow();
}
}
$('#timeline-hide')
- .click(function() {
+ .click(function () {
self.toggle();
});
$(window)
- .resize(function() {
+ .resize(function () {
self.resize();
self.zoom.refresh();
self.setClip();
});
- model.events.on("select", function() {
+ model.events.on('select', function () {
self.input.update();
self.pick.shiftView();
});
- models.layers.events.on("change", function() {
+ 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.js
index 5b40214fc..f92c21e89 100644
--- a/web/js/date/wv.date.timeline.pan.js
+++ b/web/js/date/wv.date.timeline.pan.js
@@ -10,20 +10,18 @@ wv.date.timeline = wv.date.timeline || {};
*
* @class wv.date.timeline.pan
*/
-wv.date.timeline.pan = wv.date.timeline.pan || function(models, config, ui) {
-
+wv.date.timeline.pan = wv.date.timeline.pan || function (models, config, ui) {
var tl = ui.timeline;
var model = models.date;
var self = {};
self.xPosition = tl.axisZoom.translate()[0];
- self.axis = function(event) {
-
+ self.axis = function (event) {
if (event) {
var evt = event.sourceEvent || event;
var delX = evt.deltaX;
- if ((evt.type === "wheel") && ((delX <= 0) || (delX > 0))) { // when user is panning
+ if ((evt.type === 'wheel') && ((delX <= 0) || (delX > 0))) { // when user is panning
update(self.xPosition - delX, 0);
}
} else {
@@ -41,27 +39,24 @@ wv.date.timeline.pan = wv.date.timeline.pan || function(models, config, ui) {
tl.pick.checkLocation();
model.events.trigger('timeline-change');
-
tl.data.set();
};
- var update = function(x, y) {
+ var update = function (x, y) {
tl.axisZoom.translate([x, y]);
self.xPosition = tl.axisZoom.translate()[0];
};
- self.toSelection = function() {
+ self.toSelection = function () {
var x = -tl.x(model.selected) +
(tl.width - tl.margin.left - tl.margin.right) / 2;
update(x, 0);
tl.data.set();
-
};
- self.toCursor = function(mousePos, mouseOffset) {
-
+ self.toCursor = function (mousePos, mouseOffset) {
var x = -tl.x(mousePos) +
(tl.width - tl.margin.left - tl.margin.right) / 2 - mouseOffset;
@@ -70,7 +65,7 @@ wv.date.timeline.pan = wv.date.timeline.pan || function(models, config, ui) {
tl.data.set();
};
- var init = function() {
+ var init = function () {
};
diff --git a/web/js/date/wv.date.timeline.pick.js b/web/js/date/wv.date.timeline.pick.js
index 7b6514ac8..3cf070329 100644
--- a/web/js/date/wv.date.timeline.pick.js
+++ b/web/js/date/wv.date.timeline.pick.js
@@ -10,8 +10,7 @@ wv.date.timeline = wv.date.timeline || {};
*
* @class wv.date.timeline.pick
*/
-wv.date.timeline.pick = wv.date.timeline.pick || function(models, config, ui) {
-
+wv.date.timeline.pick = wv.date.timeline.pick || function (models, config, ui) {
var tl = ui.timeline;
var model = models.date;
@@ -23,8 +22,8 @@ wv.date.timeline.pick = wv.date.timeline.pick || function(models, config, ui) {
var nextChange, prevChange;
var tipDate;
- //FIXME: Optimize a lot, this is terrible
- var dragmove = function(d) {
+ // FIXME: Optimize a lot, this is terrible
+ var dragmove = function (d) {
var tempPickOffset = Math.max(-(width / 2),
Math.min(tl.width - (width / 2), d3.event.x));
var tempPickTipOffset = tempPickOffset + (width / 2);
@@ -71,30 +70,30 @@ wv.date.timeline.pick = wv.date.timeline.pick || function(models, config, ui) {
};
var drag = d3.behavior.drag()
- .origin(function(d) {
+ .origin(function (d) {
return d;
})
- .on("dragstart", function() {
+ .on('dragstart', function () {
mousedown = true;
d3.event.sourceEvent.preventDefault();
d3.event.sourceEvent.stopPropagation();
tl.guitarPick.classed('pick-clicked', true);
})
- .on("drag", dragmove)
- .on("dragend", function() {
+ .on('drag', dragmove)
+ .on('dragend', function () {
mousedown = false;
prevChange = undefined;
nextChange = undefined;
tl.guitarPick.classed('pick-clicked', false);
});
- var change = function() {
+ var change = function () {
var d;
var newDate = tipDate;
var tick, tickBg;
tl.guitarPick
- .attr("transform", 'translate(' + self.offset + ',' + 0 + ')');
+ .attr('transform', 'translate(' + self.offset + ',' + 0 + ')');
tl.guitarPick
.data([{
@@ -106,7 +105,7 @@ wv.date.timeline.pick = wv.date.timeline.pick || function(models, config, ui) {
model.select(newDate);
self.hoverDate(newDate);
};
- self.hoverDate = function(date) {
+ self.hoverDate = function (date) {
var d;
tl.zoom.current.pick.hoverTick(date);
@@ -118,14 +117,14 @@ wv.date.timeline.pick = wv.date.timeline.pick || function(models, config, ui) {
tl.ticks.normal.hover.call(tickBg, d);
};
- var updateChanges = function(d) {
+ var updateChanges = function (d) {
prevChange = tl.zoom.current.pick.prevChange(d);
nextChange = tl.zoom.current.pick.nextChange(d);
};
// Pan the timeline if the pick is dragged off the side
// or if the date input goes outside of the shown range
- self.shiftView = function() {
+ self.shiftView = function () {
var zt = tl.pan.xPosition;
if (tl.x(model.selected) >= (tl.width - 15)) {
if (mousedown) {
@@ -153,7 +152,7 @@ wv.date.timeline.pick = wv.date.timeline.pick || function(models, config, ui) {
};
// Hide/show pick if it goes off/on the timeline
- self.checkLocation = function() {
+ self.checkLocation = function () {
if ((self.offset - width / 2) >=
(tl.width - tl.margin.left - tl.margin.right) ||
(self.offset <= -30)) {
@@ -166,8 +165,7 @@ wv.date.timeline.pick = wv.date.timeline.pick || function(models, config, ui) {
};
// Simple update the position of the pick
- self.update = function() {
-
+ self.update = function () {
if (mousedown === false) {
self.offset = tl.x(model.selected) - width / 2;
}
@@ -177,42 +175,41 @@ wv.date.timeline.pick = wv.date.timeline.pick || function(models, config, ui) {
x: self.offset,
y: 0
}])
- .attr("transform", "translate(" + self.offset + ",0)")
+ .attr('transform', 'translate(' + self.offset + ',0)')
.call(drag);
prevChange = undefined;
nextChange = undefined;
};
- var init = function() {
-
- //Draw the pick
+ var init = function () {
+ // Draw the pick
tl.guitarPick = tl.svg
- .append("svg:g")
- .attr("id", "guitarpick")
- .attr("style", "clip-path:url(#guitarpick-boundary);");
-
- tl.guitarPick.append("svg:path")
- .attr("d", "M 7.3151,0.7426 C 3.5507,0.7426 0.5,3.7926 0.5,7.5553 l 0,21.2724 14.6038,15.7112 14.6039,15.7111 14.6038,-15.7111 14.6037,-15.7112 0,-21.2724 c 0,-3.7627 -3.051,-6.8127 -6.8151,-6.8127 l -44.785,0 z");
- tl.guitarPick.append("svg:rect")
- .attr("width", "4")
- .attr("height", "20")
- .attr("x", "21")
- .attr("y", "11");
- tl.guitarPick.append("svg:rect")
- .attr("width", "4")
- .attr("height", "20")
- .attr("x", "28")
- .attr("y", "11");
- tl.guitarPick.append("svg:rect")
- .attr("width", "4")
- .attr("height", "20")
- .attr("x", "35")
- .attr("y", "11");
-
- //stop guitarpick if mouseup anywhere on document
+ .append('svg:g')
+ .attr('id', 'guitarpick')
+ .attr('style', 'clip-path:url(#guitarpick-boundary);');
+
+ tl.guitarPick.append('svg:path')
+ .attr('d', 'M 7.3151,0.7426 C 3.5507,0.7426 0.5,3.7926 0.5,7.5553 l 0,21.2724 14.6038,15.7112 14.6039,15.7111 14.6038,-15.7111 14.6037,-15.7112 0,-21.2724 c 0,-3.7627 -3.051,-6.8127 -6.8151,-6.8127 l -44.785,0 z');
+ tl.guitarPick.append('svg:rect')
+ .attr('width', '4')
+ .attr('height', '20')
+ .attr('x', '21')
+ .attr('y', '11');
+ tl.guitarPick.append('svg:rect')
+ .attr('width', '4')
+ .attr('height', '20')
+ .attr('x', '28')
+ .attr('y', '11');
+ tl.guitarPick.append('svg:rect')
+ .attr('width', '4')
+ .attr('height', '20')
+ .attr('x', '35')
+ .attr('y', '11');
+
+ // stop guitarpick if mouseup anywhere on document
d3.select(document)
- .on("mouseup", function() {
+ .on('mouseup', function () {
if (mousedown) {
mousedown = false;
tl.guitarPick.classed('pick-clicked', false);
diff --git a/web/js/date/wv.date.timeline.ticks.js b/web/js/date/wv.date.timeline.ticks.js
index 9233f610f..bab64ad80 100644
--- a/web/js/date/wv.date.timeline.ticks.js
+++ b/web/js/date/wv.date.timeline.ticks.js
@@ -10,8 +10,7 @@ wv.date.timeline = wv.date.timeline || {};
*
* @class wv.date.timeline.ticks
*/
-wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui) {
-
+wv.date.timeline.ticks = wv.date.timeline.ticks || function (models, config, ui) {
var tl = ui.timeline;
var model = models.date;
@@ -21,22 +20,21 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
var clicked = true;
var notClickDelay = 200;
- var notClick = function() {
+ var notClick = function () {
clicked = false;
};
- self.setAll = function() {
+ self.setAll = function () {
self.all = d3.selectAll('.x.axis>g.tick');
self.firstElem = self.all[0][0];
self.firstDate = self.all.data()[0];
self.lastDate = self.all.data()[self.all.data()
.length - 1];
- //remove previous classes for labels
+ // remove previous classes for labels
self.all.classed('tick-labeled', false);
-
};
self.normal = {
- setEnds: function() {
+ setEnds: function () {
var all = self.normal.all;
self.normal.all.classed('end-tick', false);
self.normal.firstDate = all.data()[0];
@@ -47,23 +45,23 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
d3.select(self.normal.lastElem)
.classed('end-tick', true);
},
- update: function() {
+ update: function () {
var ticks = self.normal.all;
- ticks.each(function() {
+ ticks.each(function () {
var current = d3.select(this);
var currentData = current.data()[0];
var nextData = tl.zoom.current.ticks.normal.next(currentData);
- //var normalTickLine = normalTick.select('line'); What's this for?
+ // var normalTickLine = normalTick.select('line'); What's this for?
- //FIXME: Calculate actual width of tick line
+ // FIXME: Calculate actual width of tick line
nWidth = tl.x(nextData) - tl.x(currentData) + 1;
if (($(this)
.find('line:first-child')
.attr('y1') !== '-2')) {
current.select('line')
- .attr("y1", "-2");
+ .attr('y1', '-2');
}
if (current.classed('end-tick')) {
if (current.select('line.tick-close')[0][0] === null) {
@@ -79,7 +77,7 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
if (($(this)
.find('text')
.length)) {
- current.select("text")
+ current.select('text')
.remove();
}
@@ -89,7 +87,7 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
self.normal.insert.rect(current, nWidth);
} else {
current.select('rect.normaltick-background')
- .attr("width", nWidth);
+ .attr('width', nWidth);
}
if (tl.config.currentZoom === 3) {
if (!$(this)
@@ -113,24 +111,24 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
self.normal.set();
self.normal.bind();
},
- init: function() {
+ init: function () {
var ticks = self.normal.all;
ticks.selectAll('line')
- .attr("y1", "-2");
+ .attr('y1', '-2');
ticks.selectAll('line.tick-week')
- .attr("y1", "0");
+ .attr('y1', '0');
- ticks.selectAll("text")
+ ticks.selectAll('text')
.remove();
- ticks.each(function() {
+ ticks.each(function () {
var current = d3.select(this);
var currentData = current.data()[0];
var nextData = tl.zoom.current.ticks.normal.next(currentData);
- //var normalTickLine = normalTick.select('line'); What's this for?
+ // var normalTickLine = normalTick.select('line'); What's this for?
- //FIXME: Calculate actual width of tick line
+ // FIXME: Calculate actual width of tick line
nWidth = tl.x(nextData) - tl.x(currentData) + 1;
self.normal.insert.rect(current, nWidth);
@@ -145,34 +143,32 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
.attr('x2', nWidth - 0.5);
}
});
-
},
insert: {
- rect: function(current, nWidth) {
- current.append("svg:rect")
- .attr("class", "normaltick-background")
- .attr("height", tl.height - 1)
- .attr("y", -tl.height)
- .attr("x", -0.5)
- .attr("width", nWidth);
+ rect: function (current, nWidth) {
+ current.append('svg:rect')
+ .attr('class', 'normaltick-background')
+ .attr('height', tl.height - 1)
+ .attr('y', -tl.height)
+ .attr('x', -0.5)
+ .attr('width', nWidth);
}
},
- set: function() {
+ set: function () {
self.normal.background = self.all.selectAll('rect.normaltick-background');
},
- bind: function() {
-
+ bind: function () {
self.normal.background
- .on('mouseenter', function() {
+ .on('mouseenter', function () {
d = d3.select(this.parentNode)
.data()[0];
self.normal.hover.call(this, d);
})
.on('mouseleave', self.label.remove)
- .on('mousedown', function() {
+ .on('mousedown', function () {
cancelClick = setTimeout(notClick, notClickDelay);
})
- .on('mouseup', function() {
+ .on('mouseup', function () {
clearTimeout(cancelClick);
if (!ui.map.mapIsbeingDragged &&
clicked) {
@@ -183,22 +179,22 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
clicked = true;
});
},
- hover: function(d) {
+ hover: function (d) {
var label = tl.zoom.current.ticks.normal.hover(d);
self.label.show.call(this, label);
},
- click: function(d) {
+ click: function (d) {
var date = tl.zoom.current.ticks.normal.clickDate(d);
model.select(date);
- },
+ }
};
self.boundary = {
- update: function() {
+ update: function () {
var ticks = self.boundary.all;
- ticks.each(function() {
- //This is a repeat, maybe fix?
+ ticks.each(function () {
+ // This is a repeat, maybe fix?
var current = d3.select(this);
var currentData = current.data()[0];
var nextData = tl.zoom.current.ticks.boundary.next(currentData);
@@ -206,14 +202,14 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
var bWidth = tl.x(nextData) - tl.x(currentData);
var nWidth = tl.x(nextNormalData) - tl.x(currentData) + 1;
var subLabel = tl.zoom.current.ticks.boundary.subLabel(currentData);
- //end repeat
+ // end repeat
if (($(this)
.find('line')
.attr('y1') !== '20')) {
current.select('line')
- .attr("y1", "20")
- .attr("y2", "-50");
+ .attr('y1', '20')
+ .attr('y2', '-50');
}
if (!$(this)
.find('text')
@@ -224,16 +220,17 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
.attr('style', 'text-anchor:left;');
if (subLabel) {
current.select('text')
- .append("tspan")
- .text(" " + subLabel)
- .attr("class", "sub-label");
+ .append('tspan')
+ .text(' ' + subLabel)
+ .attr('class', 'sub-label');
}
}
if (!$(this)
.find('circle')
- .length)
- current.insert("svg:circle", "text")
- .attr("r", "6");
+ .length) {
+ current.insert('svg:circle', 'text')
+ .attr('r', '6');
+ }
if (!$(this)
.find('rect')
@@ -241,29 +238,27 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
self.boundary.insert.rect(current, bWidth, nWidth);
} else {
current.select('rect.boundarytick-background')
- .attr("width", bWidth);
+ .attr('width', bWidth);
current.select('rect.boundarytick-foreground')
- .attr("width", bWidth);
+ .attr('width', bWidth);
current.select('rect.normaltick-background')
- .attr("width", nWidth);
+ .attr('width', nWidth);
}
});
self.boundary.set();
self.boundary.bind();
},
- init: function() {
-
+ init: function () {
var ticks = self.boundary.all;
ticks.selectAll('line')
- .attr("y1", "20")
- .attr("y2", "-50");
+ .attr('y1', '20')
+ .attr('y2', '-50');
- ticks.insert("svg:circle", "text")
- .attr("r", "6");
-
- ticks.each(function() {
+ ticks.insert('svg:circle', 'text')
+ .attr('r', '6');
+ ticks.each(function () {
var current = d3.select(this);
var currentData = current.data()[0];
var nextData = tl.zoom.current.ticks.boundary.next(currentData);
@@ -275,12 +270,12 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
if (currentData < tl.data.end()) {
self.boundary.insert.rect(current, bWidth, nWidth);
}
- //TODO: Sublabel
+ // TODO: Sublabel
if (subLabel) {
current.select('text')
- .append("tspan")
- .text(" " + subLabel)
- .attr("class", "sub-label");
+ .append('tspan')
+ .text(' ' + subLabel)
+ .attr('class', 'sub-label');
}
});
@@ -288,49 +283,48 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
.attr('class', 'tick-label')
.attr('x', 7)
.attr('style', 'text-anchor:left;');
-
},
insert: {
- rect: function(current, bWidth, nWidth) {
- current.insert("svg:rect", "text")
- .attr("x", "0")
- .attr("y", "0")
- .attr("width", bWidth)
- .attr("height", tl.height)
- .attr("class", "boundarytick-background");
-
- current.append("svg:rect")
- .attr("x", "0")
- .attr("y", "0")
- .attr("width", bWidth)
- .attr("height", tl.height)
- .attr("class", "boundarytick-foreground");
+ rect: function (current, bWidth, nWidth) {
+ current.insert('svg:rect', 'text')
+ .attr('x', '0')
+ .attr('y', '0')
+ .attr('width', bWidth)
+ .attr('height', tl.height)
+ .attr('class', 'boundarytick-background');
+
+ current.append('svg:rect')
+ .attr('x', '0')
+ .attr('y', '0')
+ .attr('width', bWidth)
+ .attr('height', tl.height)
+ .attr('class', 'boundarytick-foreground');
if (!(current.classed('label-only'))) {
- current.append("svg:rect")
- .attr("class", "normaltick-background")
- .attr("height", tl.height - 1)
- .attr("y", -tl.height)
- .attr("x", -0.5)
- .attr("width", nWidth);
+ current.append('svg:rect')
+ .attr('class', 'normaltick-background')
+ .attr('height', tl.height - 1)
+ .attr('y', -tl.height)
+ .attr('x', -0.5)
+ .attr('width', nWidth);
}
}
},
- set: function() {
+ set: function () {
self.boundary.background = self.boundary.all
.selectAll('rect.boundarytick-foreground');
},
- bind: function() {
+ bind: function () {
self.boundary.background
- .on('mouseenter', function() {
+ .on('mouseenter', function () {
d = d3.select(this.parentNode)
.data()[0];
self.boundary.hover.call(this, d);
})
.on('mouseleave', self.label.remove)
- .on('mousedown', function() {
+ .on('mousedown', function () {
cancelClick = setTimeout(notClick, notClickDelay);
})
- .on('mouseup', function() {
+ .on('mouseup', function () {
clearTimeout(cancelClick);
if (!ui.map.mapIsbeingDragged &&
clicked) {
@@ -341,26 +335,26 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
clicked = true;
});
},
- hover: function(d) {
+ hover: function (d) {
var label = tl.zoom.current.ticks.boundary.hover(d);
self.label.show.call(this, label);
},
- click: function(d) {
+ click: function (d) {
var date = tl.zoom.current.ticks.boundary.clickDate(d);
model.select(date);
},
- labelOnly: function(d) {
+ labelOnly: function (d) {
var labeled = d3.selectAll('.x.axis>g.label-only');
}
};
- self.add = function(data, elem, normal) {
+ self.add = function (data, elem, normal) {
var tick = tl.axis.insert('g', elem)
.data([data])
.attr('class', 'tick')
.attr('transform', 'translate(' + tl.x(data) + ',0)');
if (!normal) {
- tick.classed('label-only', true); //if add function is for label only
+ tick.classed('label-only', true); // if add function is for label only
}
var text = tl.zoom.current.ticks.boundary.label(data);
@@ -373,52 +367,52 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
.text(text);
};
- self.label = { //TODO: Update, this is just copied over
- show: function(d) {
+ self.label = { // TODO: Update, this is just copied over
+ show: function (d) {
var tick = this.parentNode;
var boundaryTick, boundaryTickWidth;
- //Using jquery to precise select as it's easier than d3
+ // Using jquery to precise select as it's easier than d3
if (d3.select(tick)
.classed('tick-labeled')) {
$boundaryTick = $(tick);
} else {
- //Grab Boundary Tick if it is a Normal Tick
+ // Grab Boundary Tick if it is a Normal Tick
$boundaryTick = $(tick)
.prevAll('g.tick-labeled')
.first();
}
- //get width from one boundary to the next
+ // get width from one boundary to the next
boundaryTickWidth = $boundaryTick
.find('rect.boundarytick-background')
.attr('width');
- //Convert jquery selection back to d3 selection
+ // Convert jquery selection back to d3 selection
boundaryTick = d3.select($boundaryTick[0]);
- //hide current labels
+ // hide current labels
boundaryTick
.selectAll('.tick-label, .sub-label')
.attr('visibility', 'hidden');
- //trigger hover state
+ // trigger hover state
boundaryTick.select('rect.boundarytick-background')
.classed('bg-hover', true);
- boundaryTick.append("svg:text")
- .attr("class", "hover-tick-label")
- .attr("y", "15")
- .attr("x", boundaryTickWidth / 2)
- .attr("style", "text-anchor:middle")
- .attr("width", boundaryTickWidth)
+ boundaryTick.append('svg:text')
+ .attr('class', 'hover-tick-label')
+ .attr('y', '15')
+ .attr('x', boundaryTickWidth / 2)
+ .attr('style', 'text-anchor:middle')
+ .attr('width', boundaryTickWidth)
.text(d.getUTCFullYear() +
- " " + model.monthAbbr[d.getUTCMonth()] +
- " " + d.getUTCDate()); //Add hover Label
+ ' ' + model.monthAbbr[d.getUTCMonth()] +
+ ' ' + d.getUTCDate()); // Add hover Label
},
- remove: function() { //TODO: update
+ remove: function () { // TODO: update
tl.boundary.selectAll('.tick-label, .sub-label')
- .attr("visibility", "");
+ .attr('visibility', '');
tl.boundary.selectAll('.hover-tick-label, .hover-sub-label')
.remove();
tl.boundary.selectAll('rect.boundarytick-background.bg-hover')
@@ -426,8 +420,8 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
}
};
- self.removePaddingData = function() {
- self.all.each(function() {
+ self.removePaddingData = function () {
+ self.all.each(function () {
if (((d3.select(this)
.data()[0] < tl.data.start()) ||
(d3.select(this)
@@ -445,27 +439,26 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
});
};
- self.check = function() {
+ self.check = function () {
var first, last, proto, end;
self.setAll();
tl.ticks.removePaddingData();
self.setAll();
- //Checks to see if all of the ticks fit onto the timeline space
- //and if so check to see that first normal tick is printed
+ // Checks to see if all of the ticks fit onto the timeline space
+ // and if so check to see that first normal tick is printed
if (!tl.isCropped) {
if (self.firstDate > tl.data.start()) {
protoNorm = tl.zoom.current.ticks.normal.first();
self.add(protoNorm, 'g.tick', true);
-
}
}
self.setAll();
- //set normal ticks
+ // set normal ticks
tl.zoom.current.ticks.normal.all();
- //FIXME: Section below is terrible {
- //For determining needed boundary ticks
+ // FIXME: Section below is terrible {
+ // For determining needed boundary ticks
self.all.classed('label-only', false);
if ($(self.normal.firstElem)
@@ -474,29 +467,26 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
self.add(proto, 'g.tick');
}
- //FIXME: Passing from d3 to jQuery to d3 in order to check if its the last tick elem. WAT.
- //Select element that follows last non-boundary tick
+ // FIXME: Passing from d3 to jQuery to d3 in order to check if its the last tick elem. WAT.
+ // Select element that follows last non-boundary tick
var sibElem = d3.select($(self.normal.lastElem)
.next()[0]);
if (sibElem.classed('domain')) {
end = tl.zoom.current.ticks.boundary.last();
self.add(end, 'path.domain');
-
}
// } End terrible
self.setAll();
- //update boundary ticks
+ // update boundary ticks
tl.zoom.current.ticks.boundary.all();
self.boundary.all.classed('tick-labeled', true);
-
};
-
- var init = function() {
+ var init = function () {
};
diff --git a/web/js/date/wv.date.timeline.zoom.js b/web/js/date/wv.date.timeline.zoom.js
index 9bf46c5ef..e863c180a 100644
--- a/web/js/date/wv.date.timeline.zoom.js
+++ b/web/js/date/wv.date.timeline.zoom.js
@@ -9,8 +9,7 @@ wv.date.timeline = wv.date.timeline || {};
*
* @class wv.date.timeline.zoom
*/
-wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
-
+wv.date.timeline.zoom = wv.date.timeline.zoom || function (models, config, ui) {
var tl = ui.timeline;
var model = models.date;
@@ -18,21 +17,20 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
self.current = {
ticks: {
- //Placeholders
+ // Placeholders
boundary: {
},
normal: {
- },
+ }
},
pick: {
- //Placeholder
+ // Placeholder
}
};
- self.change = function(amount, event) {
-
+ self.change = function (amount, event) {
var zoom = tl.config.currentZoom;
zoom += -amount;
@@ -44,10 +42,9 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
}
tl.config.zoom.call(this, zoom, event);
-
};
- self.drawTicks = function(count, max, aEnd, w, i, s, f, e, p) {
+ self.drawTicks = function (count, max, aEnd, w, i, s, f, e, p) {
var mouseOffset, mousePos;
if (e) {
@@ -64,13 +61,11 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
r2 = (tl.width / 2) + ((count * w) / 2);
if (max > count) {
-
tl.isCropped = false;
d2 = tl.data.end();
r1 = (tl.width / 2) - ((count * w) / 2);
r2 = (tl.width / 2) + ((count * w) / 2);
} else {
-
tl.isCropped = true;
d2 = aEnd;
r1 = 0;
@@ -110,14 +105,13 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
.remove();
tl.axis.call(tl.xAxis);
-
};
- self.refresh = function() {
+ self.refresh = function () {
tl.config.zoom(tl.config.currentZoom);
};
- var init = function() {
+ var init = function () {
};
diff --git a/web/js/date/wv.date.wheels.js b/web/js/date/wv.date.wheels.js
index e90f88d71..533e7ce1d 100644
--- a/web/js/date/wv.date.wheels.js
+++ b/web/js/date/wv.date.wheels.js
@@ -9,65 +9,64 @@ wv.date = wv.date || {};
*
* @class wv.date.wheels
*/
-wv.date.wheels = wv.date.wheels || function(models, config) {
-
- var id = "timewheels";
- var $container = $("#" + id);
+wv.date.wheels = wv.date.wheels || function (models, config) {
+ var id = 'timewheels';
+ var $container = $('#' + id);
var MSEC_TO_MIN = 1000 * 60;
var model = models.date;
var self = {};
self.enabled = false;
- var init = function() {
+ var init = function () {
render();
- model.events.on("select", update);
+ model.events.on('select', update);
$(window)
- .on("resize", resize);
+ .on('resize', resize);
updateRange();
update();
resize();
};
- var render = function() {
+ var render = function () {
$container
- .addClass("datespan")
+ .addClass('datespan')
.html("<div id='wv-date-mobile-label'></div><input type='hidden' id='linkmode' readonly>");
- $("#linkmode")
+ $('#linkmode')
.mobiscroll()
.date({
- display: "bottom",
- onChange: function(valueText) {
+ display: 'bottom',
+ onChange: function (valueText) {
var d = wv.util.parseDateUTC(valueText);
model.select(d);
},
- onShow: function() {
- $("#wv-date-mobile-label")
- .css("display", "none");
+ onShow: function () {
+ $('#wv-date-mobile-label')
+ .css('display', 'none');
},
- onClose: function() {
- $("#wv-date-mobile-label")
- .css("display", "block");
+ onClose: function () {
+ $('#wv-date-mobile-label')
+ .css('display', 'block');
},
dateFormat: 'yyyy-mm-dd',
setText: 'OK'
});
- $("#linkmode")
+ $('#linkmode')
.mobiscroll('setDate', UTCToLocal(model.selected), true);
- $("#wv-date-mobile-label")
- .click(function(e) {
- $("#linkmode")
- .mobiscroll("show");
+ $('#wv-date-mobile-label')
+ .click(function (e) {
+ $('#linkmode')
+ .mobiscroll('show');
});
};
- var UTCToLocal = function(d) {
+ var UTCToLocal = function (d) {
var timezoneOffset = d.getTimezoneOffset() * MSEC_TO_MIN;
return new Date(d.getTime() + timezoneOffset);
};
- var resize = function() {
+ var resize = function () {
if (!self.enabled && wv.util.browser.small) {
self.enabled = true;
$container.show();
@@ -77,21 +76,21 @@ wv.date.wheels = wv.date.wheels || function(models, config) {
}
};
- var updateRange = function() {
+ var updateRange = function () {
startDate = wv.util.parseDateUTC(config.startDate);
endDate = wv.util.today();
- $("#linkmode")
- .mobiscroll("option", "disabled", false);
- $("#linkmode")
- .mobiscroll("option", "minDate", UTCToLocal(startDate));
- $("#linkmode")
- .mobiscroll("option", "maxDate", UTCToLocal(endDate));
+ $('#linkmode')
+ .mobiscroll('option', 'disabled', false);
+ $('#linkmode')
+ .mobiscroll('option', 'minDate', UTCToLocal(startDate));
+ $('#linkmode')
+ .mobiscroll('option', 'maxDate', UTCToLocal(endDate));
};
- var update = function() {
- $("#wv-date-mobile-label")
+ var update = function () {
+ $('#wv-date-mobile-label')
.html(wv.util.toISOStringDate(model.selected));
- $("#linkmode")
+ $('#linkmode')
.mobiscroll('setDate', UTCToLocal(model.selected), true);
};
diff --git a/web/js/edsc.js b/web/js/edsc.js
index 3f1be0b1c..8308e288c 100644
--- a/web/js/edsc.js
+++ b/web/js/edsc.js
@@ -9,7 +9,7 @@ L.Polyline = {
};
L.Polygon = {
- extend: function() {},
+ extend: function () {},
prototype: {}
};
@@ -35,25 +35,24 @@ L.EditToolbar = {
L.Draw = {
Polygon: {
- extend: function() {}
+ extend: function () {}
}
};
L.Edit = {
Poly: {
- extend: function() {}
+ extend: function () {}
}
};
L.Util = {
- isArray: function(value) {
+ isArray: function (value) {
return value.constructor === Array;
}
};
-(function() {
-
- function LatLng(lat, lng) {
+(function () {
+ function LatLng (lat, lng) {
if (lat.lat) {
var latlng = lat;
this.lat = latlng.lat;
@@ -65,8 +64,7 @@ L.Util = {
}
L.LatLng = LatLng;
- L.latLng = function(lat, lng) {
+ L.latLng = function (lat, lng) {
return new L.LatLng(lat, lng);
};
-
})();
diff --git a/web/js/edsc/arc.js b/web/js/edsc/arc.js
index 2cb819aca..7e7df4942 100644
--- a/web/js/edsc/arc.js
+++ b/web/js/edsc/arc.js
@@ -1,16 +1,16 @@
-(function() {
+(function () {
var ns;
ns = window.edsc.map;
- ns.Arc = (function(L, Coordinate) {
+ ns.Arc = (function (L, Coordinate) {
var Arc, EPSILON, exports;
// A small number for dealing with near-0
EPSILON = 0.00000001;
// Method for dealing with operations on great circle arcs
- Arc = (function() {
- function Arc(coordA, coordB) {
+ Arc = (function () {
+ function Arc (coordA, coordB) {
var ref;
if (coordB.theta < coordA.theta) {
ref = [coordA, coordB], coordB = ref[0], coordA = ref[1];
@@ -25,7 +25,7 @@
this.normal = this.coordA.cross(this.coordB);
}
- Arc.prototype.antimeridianCrossing = function() {
+ Arc.prototype.antimeridianCrossing = function () {
var abs, x, xN, y, yA, yN, z, zN;
abs = Math.abs;
@@ -90,9 +90,7 @@
};
return Arc;
-
})();
return exports = Arc;
})(L, ns.Coordinate);
-
}).call(this);
diff --git a/web/js/edsc/coordinate.js b/web/js/edsc/coordinate.js
index d910886a1..6eb9b393d 100644
--- a/web/js/edsc/coordinate.js
+++ b/web/js/edsc/coordinate.js
@@ -1,12 +1,12 @@
-(function() {
+(function () {
var ns,
slice = [].slice;
ns = window.edsc.map;
- ns.Coordinate = (function(L) {
+ ns.Coordinate = (function (L) {
var Coordinate, DEG_TO_RAD, RAD_TO_DEG, exports;
-
+
DEG_TO_RAD = Math.PI / 180;
RAD_TO_DEG = 180 / Math.PI;
@@ -16,10 +16,10 @@
* Consider properties on this class to be immutable. Changing, say, 'x' will not
* update `phi` or `theta` and will throw normalization out of whack.
*/
- Coordinate = (function() {
- Coordinate.fromLatLng = function() {
+ Coordinate = (function () {
+ Coordinate.fromLatLng = function () {
var args, lat, lng, ref;
- args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
+ args = arguments.length >= 1 ? slice.call(arguments, 0) : [];
if (args.length === 1) {
ref = args[0], lat = ref.lat, lng = ref.lng;
} else {
@@ -28,7 +28,7 @@
return Coordinate.fromPhiTheta(lat * DEG_TO_RAD, lng * DEG_TO_RAD);
};
- Coordinate.fromPhiTheta = function(phi, theta) {
+ Coordinate.fromPhiTheta = function (phi, theta) {
var PI, cos, sin, x, y, z;
PI = Math.PI;
cos = Math.cos;
@@ -66,7 +66,7 @@
* +Y axis passes through 90 degrees longitude at the equator
* +Z axis passes through the north pole
*/
- Coordinate.fromXYZ = function(x, y, z) {
+ Coordinate.fromXYZ = function (x, y, z) {
var d, phi, scale, theta;
d = x * x + y * y + z * z;
if (d === 0) { // Should never happen, but stay safe
@@ -82,7 +82,7 @@
return new Coordinate(phi, theta, x, y, z);
};
- function Coordinate(phi1, theta1, x1, y1, z1) {
+ function Coordinate (phi1, theta1, x1, y1, z1) {
this.phi = phi1;
this.theta = theta1;
this.x = x1;
@@ -91,12 +91,12 @@
}
// Dot product
- Coordinate.prototype.dot = function(other) {
+ Coordinate.prototype.dot = function (other) {
return this.x * other.x + this.y * other.y + this.z * other.z;
};
// Normalized cross product
- Coordinate.prototype.cross = function(other) {
+ Coordinate.prototype.cross = function (other) {
var x, y, z;
x = this.y * other.z - this.z * other.y;
y = this.z * other.x - this.x * other.z;
@@ -105,28 +105,26 @@
};
// Distance to other coordinate on a unit sphere. Same as the angle between the two points at the origin.
- Coordinate.prototype.distanceTo = function(other) {
+ Coordinate.prototype.distanceTo = function (other) {
return Math.acos(this.dot(other));
};
- Coordinate.prototype.toLatLng = function() {
+ Coordinate.prototype.toLatLng = function () {
return new L.LatLng(RAD_TO_DEG * this.phi, RAD_TO_DEG * this.theta);
};
- Coordinate.prototype.toString = function() {
+ Coordinate.prototype.toString = function () {
var latlng;
latlng = this.toLatLng();
- return "(" + (latlng.lat.toFixed(3)) + ", " + (latlng.lng.toFixed(3)) + ")";
+ return '(' + (latlng.lat.toFixed(3)) + ', ' + (latlng.lng.toFixed(3)) + ')';
};
- Coordinate.prototype.toXYZString = function() {
- return "<" + (this.x.toFixed(3)) + ", " + (this.y.toFixed(3)) + ", " + (this.z.toFixed(3)) + ">";
+ Coordinate.prototype.toXYZString = function () {
+ return '<' + (this.x.toFixed(3)) + ', ' + (this.y.toFixed(3)) + ', ' + (this.z.toFixed(3)) + '>';
};
return Coordinate;
-
})();
return exports = Coordinate;
})(L);
-
}).call(this);
diff --git a/web/js/edsc/geoutil.js b/web/js/edsc/geoutil.js
index a62d7165f..e1867a9e5 100644
--- a/web/js/edsc/geoutil.js
+++ b/web/js/edsc/geoutil.js
@@ -1,11 +1,11 @@
-(function() {
+(function () {
var ns;
ns = window.edsc.map;
- ns.geoutil = (function(L, Coordinate, Arc, config) {
+ ns.geoutil = (function (L, Coordinate, Arc, config) {
var DEG_TO_RAD, EPSILON, NORTH_POLE, RAD_TO_DEG, SOUTH_POLE, _angleDelta, _course, _rotationDirection, area, containsPole, exports, gcInterpolate;
-
+
// A small number for dealing with near-0
EPSILON = 0.00000001;
NORTH_POLE = 1;
@@ -15,8 +15,8 @@
// Given two points, returns their midpoint along the shortest great circle between them. The
// two points may not be antipodal, since such a midpoint would be undefined
- gcInterpolate = function(p1, p2) {
- return (function(abs, asin, sqrt, pow, sin, cos, atan2) {
+ gcInterpolate = function (p1, p2) {
+ return (function (abs, asin, sqrt, pow, sin, cos, atan2) {
var AB, d, lat, lat1, lat2, lon, lon1, lon2, ref, ref1, x, y, z;
if ((abs(p1.lat) === (ref = abs(p2.lat)) && ref === 90)) {
return p1;
@@ -58,7 +58,7 @@
};
// Determines the initial course direction from latlng1 setting off toward latlng2
- _course = function(latlng1, latlng2) {
+ _course = function (latlng1, latlng2) {
var PI, atan2, c1, c2, cos, denom, lat1, lat2, lng1, lng2, numer, result, sin;
// http://williams.best.vwh.net/avform.htm#Crs
sin = Math.sin, cos = Math.cos, atan2 = Math.atan2, PI = Math.PI;
@@ -85,7 +85,7 @@
// Determines the difference between the given angles in the interval (-180, 180)
// See: http://www.element84.com/determining-if-a-spherical-polygon-contains-a-pole.html
- _angleDelta = function(a1, a2) {
+ _angleDelta = function (a1, a2) {
var left_turn_amount;
if (a2 < a1) {
a2 += 360;
@@ -102,12 +102,12 @@
// Returns a positive number if the angles rotate counterclockwise, a negative number
// if the angles rotate clockwise, or 0 if they do not rotate
- _rotationDirection = function(angles) {
+ _rotationDirection = function (angles) {
var a1, a2, delta, i, j, len, ref;
// Sum all adjacent angle deltas. The sum gives us the number we need to return
delta = 0;
len = angles.length;
- for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
+ for (i = j = 0, ref = len; ref >= 0 ? j < ref : j > ref; i = ref >= 0 ? ++j : --j) {
a1 = angles[i];
a2 = angles[(i + 1) % len];
delta += _angleDelta(a1, a2);
@@ -125,12 +125,12 @@
* Any Pole: containsPole(...) != 0
* Neither Pole: containsPole(...) == 0
*/
- containsPole = function(latlngs) {
+ containsPole = function (latlngs) {
var angles, delta, delta0, delta1, dir, final, i, initial, j, latlng, latlng0, latlng1, latlng2, len, prev, ref;
if (latlngs.length < 3) {
return false;
}
- latlngs = (function() {
+ latlngs = (function () {
var j, len1, results;
results = [];
for (j = 0, len1 = latlngs.length; j < len1; j++) {
@@ -142,7 +142,7 @@
// http://www.element84.com/determining-if-a-spherical-polygon-contains-a-pole.html
delta = 0;
len = latlngs.length;
- for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
+ for (i = j = 0, ref = len; ref >= 0 ? j < ref : j > ref; i = ref >= 0 ? ++j : --j) {
latlng0 = latlngs[(i - 1 + len) % len];
latlng1 = latlngs[i];
latlng2 = latlngs[(i + 1) % len];
@@ -175,7 +175,7 @@
if (delta < -360 + EPSILON) {
return NORTH_POLE | SOUTH_POLE;
} else if (delta < EPSILON) {
- angles = (function() {
+ angles = (function () {
var k, len1, results;
results = [];
for (k = 0, len1 = latlngs.length; k < len1; k++) {
@@ -191,7 +191,7 @@
return SOUTH_POLE;
} else {
if (config.debug) {
- console.warn("Rotation direction is NONE despite containing a pole");
+ console.warn('Rotation direction is NONE despite containing a pole');
}
return 0;
}
@@ -201,7 +201,7 @@
};
// Calculates the area within the given latlngs
- area = function(origLatlngs) {
+ area = function (origLatlngs) {
var PI, crossesMeridian, i, j, k, latlngA, latlngB, latlngC, latlngs, len, phiB, ref, ref1, sum, thetaA, thetaB, thetaC;
if (origLatlngs.length < 3) {
return 0;
@@ -222,7 +222,7 @@
*/
latlngs = [];
len = origLatlngs.length;
- for (i = j = 0, ref = len; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
+ for (i = j = 0, ref = len; ref >= 0 ? j < ref : j > ref; i = ref >= 0 ? ++j : --j) {
latlngA = origLatlngs[i];
latlngB = origLatlngs[(i + 1) % len];
latlngs.push(latlngA);
@@ -236,7 +236,7 @@
crossesMeridian = false;
sum = 0;
len = latlngs.length;
- for (i = k = 0, ref1 = len; 0 <= ref1 ? k < ref1 : k > ref1; i = 0 <= ref1 ? ++k : --k) {
+ for (i = k = 0, ref1 = len; ref1 >= 0 ? k < ref1 : k > ref1; i = ref1 >= 0 ? ++k : --k) {
latlngA = latlngs[i];
latlngB = latlngs[(i + 1) % len];
latlngC = latlngs[(i + 2) % len];
@@ -280,5 +280,4 @@
SOUTH_POLE: SOUTH_POLE
};
})(L, ns.Coordinate, ns.Arc, this.edsc.config);
-
}).call(this);
diff --git a/web/js/edsc/interpolation.js b/web/js/edsc/interpolation.js
index 1fc45a129..312cab271 100644
--- a/web/js/edsc/interpolation.js
+++ b/web/js/edsc/interpolation.js
@@ -5,29 +5,29 @@
* have a curved shape despite only having 4 vertices.
*/
-(function() {
+(function () {
var ns;
ns = this.edsc.map.L;
// Cartesian interpolation. Averages lat and lng
- ns.interpolation = (function(L, gcInterpolate) {
+ ns.interpolation = (function (L, gcInterpolate) {
var exports, interpolateCartesian, interpolateGeodetic, projectLatLngPath, projectLatlngs, projectPath;
-
- interpolateCartesian = function(ll0, ll1) {
+
+ interpolateCartesian = function (ll0, ll1) {
return L.latLng((ll0.lat + ll1.lat) / 2, (ll0.lng + ll1.lng) / 2);
};
// Geodetic interpolation. Finds great circle path between the given points.
// See geoutil.gcInterpolate
- interpolateGeodetic = function(ll0, ll1) {
+ interpolateGeodetic = function (ll0, ll1) {
return gcInterpolate(ll0, ll1);
};
// Given a path defined by latLngs, a projection defined by proj, and an interpolation
// function that takes two pionts and returns their midpoint, finds a set of projected
// (x, y) points defining the path between the points in the given projection
- projectLatLngPath = function(latLngs, proj, interpolateFn, tolerance, maxDepth) {
+ projectLatLngPath = function (latLngs, proj, interpolateFn, tolerance, maxDepth) {
var d, depth, depth0, depth1, interpolatedLatLngs, interpolatedPoints, ll, ll0, ll1, maxDepthReached, p, p0, p1, points, ref;
if (tolerance == null) {
tolerance = 1;
@@ -46,7 +46,7 @@
} else {
latLngs = latLngs.concat(latLngs[0]);
}
- points = (function() {
+ points = (function () {
var i, len, results;
results = [];
for (i = 0, len = latLngs.length; i < len; i++) {
@@ -93,12 +93,12 @@
}
}
if (maxDepthReached && config.debug) {
- console.log("Max interpolation depth reached.");
+ console.log('Max interpolation depth reached.');
}
return interpolatedPoints;
};
- projectPath = function(map, latlngs, holes, fn, tolerance, maxDepth) {
+ projectPath = function (map, latlngs, holes, fn, tolerance, maxDepth) {
var hole, proj, result;
if (holes == null) {
holes = [];
@@ -118,7 +118,7 @@
if (fn === 'cartesian') {
fn = interpolateCartesian;
}
- proj = function(ll) {
+ proj = function (ll) {
// Avoid weird precision problems near infinity by clamping to a high min/max pixel value
var MAX_RES, result;
MAX_RES = 10000000;
@@ -133,7 +133,7 @@
};
return result = {
boundary: projectLatLngPath(latlngs, proj, fn, tolerance, maxDepth),
- holes: (function() {
+ holes: (function () {
var i, len, ref, results;
ref = holes != null ? holes : [];
results = [];
@@ -148,7 +148,7 @@
// Overrides the default projectLatLngs in Polyline and Polygon to project and interpolate the
// path instead of just projecting it
- projectLatlngs = function() {
+ projectLatlngs = function () {
var interpolated;
interpolated = projectPath(this._map, this._latlngs, this._holes, this._interpolationFn);
this._originalPoints = interpolated.boundary;
@@ -166,5 +166,4 @@
projectPath: projectPath
};
})(L, window.edsc.map.geoutil.gcInterpolate);
-
}).call(this);
diff --git a/web/js/edsc/spherical_polygon.js b/web/js/edsc/spherical_polygon.js
index a9782281a..38d4ba22f 100644
--- a/web/js/edsc/spherical_polygon.js
+++ b/web/js/edsc/spherical_polygon.js
@@ -1,14 +1,14 @@
-(function() {
+(function () {
var ns;
ns = edsc.map;
- ns.L.sphericalPolygon = (function(L, geoutil, Arc, Coordinate) {
+ ns.L.sphericalPolygon = (function (L, geoutil, Arc, Coordinate) {
var antimeridianCrossing, convertLatLngs, dividePolygon, exports, ll2j, ll2s, makeCounterclockwise, originalRemove;
// Converts the given latlngs to L.latLng objects and ensures they're
// normalized on the expected interval, [-180, 180]
- convertLatLngs = function(latlngs) {
+ convertLatLngs = function (latlngs) {
var j, latlng, len1, original, result;
result = [];
for (j = 0, len1 = latlngs.length; j < len1; j++) {
@@ -30,7 +30,7 @@
* arc between latlng0 and latlng1 crosses the antimeridian. Will either
* return the point of the crossing or null if the arc does not cross.
*/
- antimeridianCrossing = function(latlng0, latlng1) {
+ antimeridianCrossing = function (latlng0, latlng1) {
var arc, ref;
arc = new Arc(Coordinate.fromLatLng(L.latLng(latlng0)), Coordinate.fromLatLng(L.latLng(latlng1)));
return (ref = arc.antimeridianCrossing()) != null ? ref.toLatLng() : void 0;
@@ -38,7 +38,7 @@
// Ensures that latlngs is counterclockwise around its smallest area
// This is an in-place operation modifying the original list.
- makeCounterclockwise = function(latlngs) {
+ makeCounterclockwise = function (latlngs) {
var area;
area = geoutil.area(latlngs);
if (area > 2 * Math.PI) {
@@ -49,14 +49,14 @@
// For debugging
// Prints a string of latLng objects
- ll2s = function(latlngs) {
+ ll2s = function (latlngs) {
var ll;
- return ((function() {
+ return ((function () {
var j, len1, results;
results = [];
for (j = 0, len1 = latlngs.length; j < len1; j++) {
ll = latlngs[j];
- results.push("(" + ll.lat + ", " + ll.lng + ")");
+ results.push('(' + ll.lat + ', ' + ll.lng + ')');
}
return results;
})()).join(', ');
@@ -64,15 +64,15 @@
// Prints a string of latLng objects to a format useful in Jason's visualization
// tools: http://testbed.echo.nasa.gov/spatial-viz/interactive_spherical_polygon_coverage
- ll2j = function(latlngs) {
+ ll2j = function (latlngs) {
var ll;
- return ((function() {
+ return ((function () {
var j, len1, ref, results;
ref = latlngs.concat(latlngs[0]);
results = [];
for (j = 0, len1 = ref.length; j < len1; j++) {
ll = ref[j];
- results.push(ll.lng + "," + ll.lat);
+ results.push(ll.lng + ',' + ll.lat);
}
return results;
})()).join(', ');
@@ -102,7 +102,7 @@
*
* It is, necessarily, a hack.
*/
- dividePolygon = function(latlngs) {
+ dividePolygon = function (latlngs) {
var boundaries, boundary, containedPoles, containsNorthPole, containsSouthPole, crossing, extra, extras, hasInsertions, hasPole, hole, holes, i, inc, interior, interiors, j, k, l, lat, latlng, latlng1, latlng2, len, len1, len2, len3, lng, m, maxCrossingLat, minCrossingLat, n, next, o, p, q, ref, ref1, split;
interiors = [];
boundaries = [];
@@ -142,7 +142,7 @@
*/
split = [];
len = latlngs.length;
- for (i = k = 0, ref1 = len; 0 <= ref1 ? k < ref1 : k > ref1; i = 0 <= ref1 ? ++k : --k) {
+ for (i = k = 0, ref1 = len; ref1 >= 0 ? k < ref1 : k > ref1; i = ref1 >= 0 ? ++k : --k) {
latlng1 = latlngs[i];
latlng2 = latlngs[(i + 1) % len];
crossing = antimeridianCrossing(latlng1, latlng2);
@@ -265,21 +265,21 @@
options: {
fill: true
},
- initialize: function(latlngs, options) {
+ initialize: function (latlngs, options) {
this._layers = {};
this._options = L.extend({}, this.options, options);
return this.setLatLngs(latlngs);
},
- setLatLngs: function(latlngs) {
+ setLatLngs: function (latlngs) {
var divided, latlng;
if (latlngs[0] && Array.isArray(latlngs[0]) && latlngs[0].length > 2) {
// Don't deal with holes
if (console.warn) {
- console.warn("Polygon with hole detected. Ignoring.");
+ console.warn('Polygon with hole detected. Ignoring.');
}
latlngs = latlngs[0];
}
- latlngs = (function() {
+ latlngs = (function () {
var j, len1, results;
results = [];
for (j = 0, len1 = latlngs.length; j < len1; j++) {
@@ -304,13 +304,13 @@
return this.addLayer(this._boundaries);
}
},
- getLatLngs: function() {
+ getLatLngs: function () {
return makeCounterclockwise(this._latlngs.concat());
},
- newLatLngIntersects: function(latlng, skipFirst) {
+ newLatLngIntersects: function (latlng, skipFirst) {
return false;
},
- setOptions: function(options) {
+ setOptions: function (options) {
this._options = this.options = L.extend({}, this._options, options);
L.setOptions(this._interiors, L.extend({}, this._options, {
stroke: false
@@ -320,7 +320,7 @@
}));
return this.redraw();
},
- setStyle: function(style) {
+ setStyle: function (style) {
if (this.options.previousOptions) {
this.options.previousOptions = this._options;
}
@@ -331,19 +331,19 @@
fill: false
}));
},
- redraw: function() {
+ redraw: function () {
return this.setLatLngs(this._latlngs);
}
});
- L.sphericalPolygon = function(latlngs, options) {
+ L.sphericalPolygon = function (latlngs, options) {
return new L.SphericalPolygon(latlngs, options);
};
// Monkey-patch _removeLayer. The original doesn't handle event propagation
// from FeatureGroups, and SphericalPolygons are FeatureGroups
originalRemove = L.EditToolbar.Delete.prototype._removeLayer;
- L.EditToolbar.Delete.prototype._removeLayer = function(e) {
+ L.EditToolbar.Delete.prototype._removeLayer = function (e) {
var ref;
if ((ref = e.target) != null ? ref._boundaries : void 0) {
e.layer = e.target;
@@ -353,7 +353,7 @@
L.Draw.Polygon = L.Draw.Polygon.extend({
Poly: L.SphericalPolygon,
- addHooks: function() {
+ addHooks: function () {
L.Draw.Polyline.prototype.addHooks.call(this);
if (this._map) {
return this._poly = new L.SphericalPolygon([], this.options.shapeOptions);
@@ -362,7 +362,7 @@
});
L.Edit.Poly = L.Edit.Poly.extend({
- _getMiddleLatLng: function(marker1, marker2) {
+ _getMiddleLatLng: function (marker1, marker2) {
var latlng;
return latlng = geoutil.gcInterpolate(marker1.getLatLng(), marker2.getLatLng());
}
@@ -372,5 +372,4 @@
dividePolygon: dividePolygon
};
})(L, ns.geoutil, ns.Arc, ns.Coordinate);
-
}).call(this);
diff --git a/web/js/image/wv.image.panel.js b/web/js/image/wv.image.panel.js
index 133b0f37b..7f5ab64bd 100644
--- a/web/js/image/wv.image.panel.js
+++ b/web/js/image/wv.image.panel.js
@@ -1,18 +1,17 @@
var wv = wv || {};
wv.image = wv.image || {};
-wv.image.panel = wv.image.panel || function(models, ui, config) {
-
+wv.image.panel = wv.image.panel || function (models, ui, config) {
var self = {};
var container;
var alignTo = config.alignTo;
- var containerId = "imagedownload";
+ var containerId = 'imagedownload';
var id = containerId;
var coords;
- var resolution = "1";
- var format = "image/jpeg";
- var worldfile = "false";
+ var resolution = '1';
+ var format = 'image/jpeg';
+ var worldfile = 'false';
var lastZoom = -1;
var host, path;
@@ -21,20 +20,18 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
host = config.features.imageDownload.host;
path = config.parameters.imagegen || config.features.imageDownload.path;
} else {
- host = "http://map2.vis.earthdata.nasa.gov";
- path = "imagegen/index.php";
+ host = 'http://map2.vis.earthdata.nasa.gov';
+ path = 'imagegen/index.php';
}
- url = host + "/" + path + "?";
+ url = host + '/' + path + '?';
if (config.parameters.imagegen) {
- wv.util.warn("Redirecting image download to: " + url);
-
+ wv.util.warn('Redirecting image download to: ' + url);
}
-
- var init = function() {
- ui.rubberband.events.on("update", update);
- ui.rubberband.events.on("show", show);
+ var init = function () {
+ ui.rubberband.events.on('update', update);
+ ui.rubberband.events.on('show', show);
};
/**
@@ -42,9 +39,9 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
* Display the HTML UI with UI options. *
* @this {Download}
*/
- var show = function() {
+ var show = function () {
alignTo = {
- id: "wv-image-button"
+ id: 'wv-image-button'
};
container = document.getElementById(containerId);
@@ -52,7 +49,7 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
throw new Error("Error: element '" + containerId + "' not found!");
}
- container.setAttribute("class", "imagedownload");
+ container.setAttribute('class', 'imagedownload');
setPosition();
$(window)
@@ -69,65 +66,65 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
"<option value='4'>1km</option>" +
"<option value='20'>5km</option>" +
"<option value='40'>10km</option>" +
- "</select>Resolution (per pixel)</div>" +
+ '</select>Resolution (per pixel)</div>' +
"<div class='wv-image-header'>" +
"<select id='wv-image-format'>" +
"<option value='image/jpeg'>JPEG</option>" +
"<option value='image/png'>PNG</option>" +
"<option value='image/geotiff'>GeoTIFF</option>" +
"<option value='image/kmz'>KMZ</option>" +
- "</select>Format</div>" +
+ '</select>Format</div>' +
"<div class='wv-image-header'>" +
"<select id='wv-image-worldfile' > " +
"<option value='false'>No</option>" +
"<option value='true'>Yes</option>" +
- "</select>Worldfile (.zip)</div>" +
+ '</select>Worldfile (.zip)</div>' +
"<table class='wv-image-download'>" +
- "<tr>" +
- "<th>Raw Size</th>" +
- "<th>Maximum</th>" +
- "</tr>" +
- "<tr>" +
+ '<tr>' +
+ '<th>Raw Size</th>' +
+ '<th>Maximum</th>' +
+ '</tr>' +
+ '<tr>' +
"<td id='wv-image-size' class='wv-image-size'>000.00MB</td>" +
"<td class='wv-image-size'>250 MB</td>" +
- "</tr>" +
- "<tr>" +
+ '</tr>' +
+ '<tr>' +
"<td><span id='wv-image-width'>0000</span> x <span id='wv-image-height'>0000</span> px</td>" +
"<td><button id='wv-image-download-button'>Download</button>" +
- "</tr>" +
- "</table>" +
- "</div>";
+ '</tr>' +
+ '</table>' +
+ '</div>';
var $dialog = wv.ui.getDialog()
.html(htmlElements);
$dialog.dialog({
- dialogClass: "wv-panel wv-image",
- title: "Take a snapshot",
+ dialogClass: 'wv-panel wv-image',
+ title: 'Take a snapshot',
show: {
- effect: "slide",
- direction: "up"
+ effect: 'slide',
+ direction: 'up'
},
hide: {
- effect: "slide",
- direction: "up"
+ effect: 'slide',
+ direction: 'up'
},
width: 230,
- height: "auto",
+ height: 'auto',
minHeight: 10,
draggable: false,
resizable: false,
autoOpen: false
});
- //$("#wv-image-resolution").buttonset();
- //$("#wv-image-format").buttonset();
- $("#wv-image-download-button")
+ // $("#wv-image-resolution").buttonset();
+ // $("#wv-image-format").buttonset();
+ $('#wv-image-download-button')
.button();
- $(".ui-dialog")
+ $('.ui-dialog')
.zIndex(600);
// Remove higher resolution options from polar views since no higher
// resolution polar layers currenly exist
- if (models.proj.selected.id !== "geographic") {
+ if (models.proj.selected.id !== 'geographic') {
$("#wv-image-format [value='image/kmz']")
.remove();
$("#wv-image-resolution [value='0.5']")
@@ -148,16 +145,16 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
if (curZoom != lastZoom) {
lastZoom = curZoom;
var nZoomLevels = models.proj.selected.resolutions.length;
- var curResolution = (curZoom >= nZoomLevels) ?
- models.proj.selected.resolutions[nZoomLevels - 1] :
- models.proj.selected.resolutions[curZoom];
+ var curResolution = (curZoom >= nZoomLevels)
+ ? models.proj.selected.resolutions[nZoomLevels - 1]
+ : models.proj.selected.resolutions[curZoom];
// Estimate the option value used by "wv-image-resolution"
- var resolutionEstimate = (models.proj.selected.id == "geographic") ?
- curResolution / 0.002197265625 : curResolution / 256.0;
+ var resolutionEstimate = (models.proj.selected.id == 'geographic')
+ ? curResolution / 0.002197265625 : curResolution / 256.0;
// Find the closest match of resolution within the available values
- var possibleResolutions = (models.proj.selected.id == "geographic") ? [0.125, 0.25, 0.5, 1, 2, 4, 20, 40] : [1, 2, 4, 20, 40];
+ var possibleResolutions = (models.proj.selected.id == 'geographic') ? [0.125, 0.25, 0.5, 1, 2, 4, 20, 40] : [1, 2, 4, 20, 40];
var bestDiff = Infinity;
var bestIdx = -1;
var currDiff = 0;
@@ -172,7 +169,7 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
// Bump up resolution in certain cases where default is too low
if (bestIdx > 0) {
- if (models.proj.selected.id == "geographic") {
+ if (models.proj.selected.id == 'geographic') {
switch (curZoom) {
case 3:
case 4:
@@ -192,65 +189,62 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
}
}
-
- $("#wv-image-format")
- .change(function() {
- format = $("#wv-image-format option:checked")
+ $('#wv-image-format')
+ .change(function () {
+ format = $('#wv-image-format option:checked')
.val();
update(coords);
});
-
- $("#wv-image-worldfile")
- .change(function() {
- worldfile = $("#wv-image-worldfile option:checked")
+ $('#wv-image-worldfile')
+ .change(function () {
+ worldfile = $('#wv-image-worldfile option:checked')
.val();
update(coords);
});
- $("#wv-image-resolution option")
- .removeAttr("selected");
+ $('#wv-image-resolution option')
+ .removeAttr('selected');
$("#wv-image-resolution option[value='" + resolution + "']")
- .attr("selected", "selected");
+ .attr('selected', 'selected');
- $("#wv-image-format option")
- .removeAttr("selected");
+ $('#wv-image-format option')
+ .removeAttr('selected');
$("#wv-image-format option[value='" + format + "']")
- .attr("selected", "selected");
+ .attr('selected', 'selected');
- $("#wv-image-worldfile option")
- .removeAttr("selected");
+ $('#wv-image-worldfile option')
+ .removeAttr('selected');
$("#wv-image-worldfile option[value='" + worldfile + "']")
- .attr("selected", "selected");
+ .attr('selected', 'selected');
wv.ui.positionDialog($dialog, {
- my: "left top",
- at: "left bottom+5",
- of: ("#wv-image-button"),
+ my: 'left top',
+ at: 'left bottom+5',
+ of: ('#wv-image-button')
});
- $dialog.dialog("open");
+ $dialog.dialog('open');
- $(".wv-image-coords")
+ $('.wv-image-coords')
.show();
};
- var setPosition = function() {
- var offset = $("#" + alignTo.id)
+ var setPosition = function () {
+ var offset = $('#' + alignTo.id)
.offset();
- var left = offset.left + parseInt($("#" + alignTo.id)
- .css("width")) - parseInt($("#" + id)
- .css("width"));
- $("#" + id)
- .css("left", left + "px");
+ var left = offset.left + parseInt($('#' + alignTo.id)
+ .css('width')) - parseInt($('#' + id)
+ .css('width'));
+ $('#' + id)
+ .css('left', left + 'px');
};
-
- var update = function(c) {
+ var update = function (c) {
try {
coords = c;
var map = ui.map.selected;
- //What's this for?
- //var bbox = map.getExtent();
+ // What's this for?
+ // var bbox = map.getExtent();
var time = models.date.selected;
var pixels = coords;
var s = models.proj.selected.id;
@@ -260,17 +254,17 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
});
// NOTE: This needs to be changed back to the projection model
// when the backfill removes the old projection.
- var epsg = (models.proj.change) ? models.proj.change.epsg :
- models.proj.selected.epsg;
+ var epsg = (models.proj.change) ? models.proj.change.epsg
+ : models.proj.selected.epsg;
// get layer transparencies (opacities)
var opacities = [];
_(products)
- .each(function(product) {
+ .each(function (product) {
opacities.push((_.isUndefined(product.opacity)) ? 1 : product.opacity);
});
- //console.log("EPSG: " + epsg);
+ // console.log("EPSG: " + epsg);
var px = pixels;
var x1 = px.x;
@@ -282,8 +276,8 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
var lonlat1 = map.getCoordinateFromPixel([Math.floor(x1), Math.floor(y2)]);
var lonlat2 = map.getCoordinateFromPixel([Math.floor(x2), Math.floor(y1)]);
- var geolonlat1 = ol.proj.transform(lonlat1, crs, "EPSG:4326");
- var geolonlat2 = ol.proj.transform(lonlat2, crs, "EPSG:4326");
+ var geolonlat1 = ol.proj.transform(lonlat1, crs, 'EPSG:4326');
+ var geolonlat2 = ol.proj.transform(lonlat2, crs, 'EPSG:4326');
var minLon = geolonlat1[0];
var maxLon = geolonlat2[0];
@@ -294,18 +288,18 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
var ur = wv.util.formatCoordinate([maxLon, minLat]);
if (x2 - x1 < 150) {
- ll = "";
- ur = "";
+ ll = '';
+ ur = '';
}
- $("#wv-image-top")
+ $('#wv-image-top')
.css({
left: x1 - 10,
top: y1 - 20,
width: x2 - x1
})
.html(ur);
- $("#wv-image-bottom")
+ $('#wv-image-bottom')
.css({
left: x1,
top: y2,
@@ -315,83 +309,80 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
var dlURL = url;
var conversionFactor = 256;
- if (s == "geographic") {
+ if (s == 'geographic') {
conversionFactor = 0.002197;
}
var dTime = time;
- //Julian date, padded with two zeros (to ensure the julian date is always in DDD format).
- var jStart = wv.util.parseDateUTC(dTime.getUTCFullYear() + "-01-01");
- var jDate = "00" + (1 + Math.ceil((dTime.getTime() - jStart) / 86400000));
- dlURL += "TIME=" + dTime.getUTCFullYear() + (jDate)
+ // Julian date, padded with two zeros (to ensure the julian date is always in DDD format).
+ var jStart = wv.util.parseDateUTC(dTime.getUTCFullYear() + '-01-01');
+ var jDate = '00' + (1 + Math.ceil((dTime.getTime() - jStart) / 86400000));
+ dlURL += 'TIME=' + dTime.getUTCFullYear() + (jDate)
.substr((jDate.length) - 3);
+ dlURL += '&extent=' + lonlat1[0] + ',' + lonlat1[1] + ',' + lonlat2[0] + ',' + lonlat2[1];
-
- dlURL += "&extent=" + lonlat1[0] + "," + lonlat1[1] + "," + lonlat2[0] + "," + lonlat2[1];
-
- //dlURL += "&switch="+s;
- dlURL += "&epsg=" + epsg;
+ // dlURL += "&switch="+s;
+ dlURL += '&epsg=' + epsg;
var layers = [];
- _.each(products, function(layer) {
+ _.each(products, function (layer) {
if (layer.projections[s].layer) {
layers.push(layer.projections[s].layer);
} else {
layers.push(layer.id);
}
});
- dlURL += "&layers=" + layers.join(",");
- dlURL += "&opacities=" + opacities.join(",");
+ dlURL += '&layers=' + layers.join(',');
+ dlURL += '&opacities=' + opacities.join(',');
var imgWidth = 0;
var imgHeight = 0;
var imageRes, imgFileSize, imgFormat, imgWorldfile;
- $("#wv-image-resolution")
- .unbind("change")
- .change(function() {
- imgRes = $("#wv-image-resolution option:checked")
+ $('#wv-image-resolution')
+ .unbind('change')
+ .change(function () {
+ imgRes = $('#wv-image-resolution option:checked')
.val();
resolution = imgRes;
imgWidth = Math.round((Math.abs(lonlat2[0] - lonlat1[0]) / conversionFactor) / Number(imgRes));
imgHeight = Math.round((Math.abs(lonlat2[1] - lonlat1[1]) / conversionFactor) / Number(imgRes));
imgFilesize = ((imgWidth * imgHeight * 24) / 8388608)
.toFixed(2);
- imgFormat = $("#wv-image-format option:checked")
+ imgFormat = $('#wv-image-format option:checked')
.val();
- imgWorldfile = $("#wv-image-worldfile option:checked")
+ imgWorldfile = $('#wv-image-worldfile option:checked')
.val();
var invalid = (imgFilesize > 250 || imgHeight === 0 || imgWidth === 0);
var icon;
if (invalid) {
icon = "<i class='fa fa-times fa-fw'></i>";
- $(".wv-image-size")
- .addClass("wv-image-size-invalid");
- $("#wv-image-download-button")
- .button("disable");
+ $('.wv-image-size')
+ .addClass('wv-image-size-invalid');
+ $('#wv-image-download-button')
+ .button('disable');
} else {
icon = "<i class='fa fa-check fa-fw'></i>";
- $(".wv-image-size")
- .removeClass("wv-image-size-invalid");
- $("#wv-image-download-button")
- .button("enable");
+ $('.wv-image-size')
+ .removeClass('wv-image-size-invalid');
+ $('#wv-image-download-button')
+ .button('enable');
}
- $("#wv-image-width")
+ $('#wv-image-width')
.html((imgWidth));
- $("#wv-image-height")
+ $('#wv-image-height')
.html((imgHeight));
- $("#wv-image-size")
- .html(icon + imgFilesize + " MB");
+ $('#wv-image-size')
+ .html(icon + imgFilesize + ' MB');
})
.change();
-
- $("#wv-image-download-button")
+ $('#wv-image-download-button')
.unbind('click')
- .click(function() {
+ .click(function () {
WVC.GA.event('Image Download', 'Click', 'Download');
- wv.util.metrics('lc=' + encodeURIComponent(dlURL + "&worldfile=" + imgWorldfile + "&format=" + imgFormat + "&width=" + imgWidth + "&height=" + imgHeight));
- window.open(dlURL + "&worldfile=" + imgWorldfile + "&format=" + imgFormat + "&width=" + imgWidth + "&height=" + imgHeight, "_blank");
+ wv.util.metrics('lc=' + encodeURIComponent(dlURL + '&worldfile=' + imgWorldfile + '&format=' + imgFormat + '&width=' + imgWidth + '&height=' + imgHeight));
+ window.open(dlURL + '&worldfile=' + imgWorldfile + '&format=' + imgFormat + '&width=' + imgWidth + '&height=' + imgHeight, '_blank');
});
} catch (cause) {
wv.util.error(cause);
@@ -401,5 +392,4 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
init();
return self;
-
};
diff --git a/web/js/image/wv.image.rubberband.js b/web/js/image/wv.image.rubberband.js
index 9991604c4..04980db91 100644
--- a/web/js/image/wv.image.rubberband.js
+++ b/web/js/image/wv.image.rubberband.js
@@ -1,33 +1,31 @@
var wv = wv || {};
wv.image = wv.image || {};
-wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
-
+wv.image.rubberband = wv.image.rubberband || function (models, ui, config) {
var self = {};
var PALETTE_WARNING =
- "One or more layers on the map have been modified (changed palette, " +
- "thresholds, etc.). These modifications cannot be used to take a " +
- "snapshot. Would you like to temporarily revert to the original " +
- "layer(s)?";
+ 'One or more layers on the map have been modified (changed palette, ' +
+ 'thresholds, etc.). These modifications cannot be used to take a ' +
+ 'snapshot. Would you like to temporarily revert to the original ' +
+ 'layer(s)?';
var GRATICLE_WARNING =
- "The graticule layer cannot be used to take a snapshot. Would you " +
- "like to hide this layer?";
-
- var ROTATE_WARNING = "Image may not be downloaded when rotated. Would you like to reset rotation?";
+ 'The graticule layer cannot be used to take a snapshot. Would you ' +
+ 'like to hide this layer?';
+ var ROTATE_WARNING = 'Image may not be downloaded when rotated. Would you like to reset rotation?';
- var containerId = "wv-image-button";
+ var containerId = 'wv-image-button';
var container;
- var selector = "#" + containerId;
+ var selector = '#' + containerId;
var coords = null;
var previousCoords = null;
- var icon = "images/camera.png";
- var onicon = "images/cameraon.png";
- var $cropee = $("#wv-map"); //TODO: Test on non-canvas
+ var icon = 'images/camera.png';
+ var onicon = 'images/cameraon.png';
+ var $cropee = $('#wv-map'); // TODO: Test on non-canvas
var id = containerId;
- var state = "off";
+ var state = 'off';
var jcropAPI = null;
var previousPalettes = null;
var $button;
@@ -38,22 +36,22 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
*
* @this {RubberBand}
*/
- var init = function() {
+ var init = function () {
container = document.getElementById(containerId);
if (container === null) {
throw new Error("Error: element '" + containerId + "' not found!");
}
- $button = $("<input></input>")
- .attr("type", "checkbox")
- .attr("id", "wv-image-button-check")
- .val("");
- var $label = $("<label></label>")
- .attr("for", "wv-image-button-check")
- .attr("title", "Take a snapshot");
- var $icon = $("<i></i>")
- .addClass("fa")
- .addClass("fa-camera")
- .addClass("fa-2x");
+ $button = $('<input></input>')
+ .attr('type', 'checkbox')
+ .attr('id', 'wv-image-button-check')
+ .val('');
+ var $label = $('<label></label>')
+ .attr('for', 'wv-image-button-check')
+ .attr('title', 'Take a snapshot');
+ var $icon = $('<i></i>')
+ .addClass('fa')
+ .addClass('fa-camera')
+ .addClass('fa-2x');
$label.append($icon);
$(selector)
.append($label);
@@ -65,42 +63,42 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
$button.on('click', toggle);
};
- var toolbarButtons = function(action) {
- $("#wv-info-button input")
+ var toolbarButtons = function (action) {
+ $('#wv-info-button input')
.button(action);
- $("#wv-proj-button input")
+ $('#wv-proj-button input')
.button(action);
- $("#wv-link-button input")
+ $('#wv-link-button input')
.button(action);
};
- var toggle = function() {
- var checked = $("#wv-image-button-check")
- .prop("checked");
- var geographic = models.proj.selected.id === "geographic";
- //Enables UI to select an area on the map while darkening the view
- var toggleOn = function() {
- state = "on";
- toolbarButtons("disable");
- self.events.trigger("show");
- $(".ui-dialog")
- .on("dialogclose", function() {
- if (state === "on") {
+ var toggle = function () {
+ var checked = $('#wv-image-button-check')
+ .prop('checked');
+ var geographic = models.proj.selected.id === 'geographic';
+ // Enables UI to select an area on the map while darkening the view
+ var toggleOn = function () {
+ state = 'on';
+ toolbarButtons('disable');
+ self.events.trigger('show');
+ $('.ui-dialog')
+ .on('dialogclose', function () {
+ if (state === 'on') {
toggle();
}
document.activeElement.blur();
});
draw();
};
- var resetRotation = function() {
+ var resetRotation = function () {
ui.map.selected.getView()
.animate({
rotation: 0,
- duration: 400,
+ duration: 400
});
};
- var disablePalettes = function() {
+ var disablePalettes = function () {
var map = ui.map.selected;
// Save the previous state to be restored later
previousPalettes = models.palettes.active;
@@ -108,25 +106,25 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
toggle();
};
- var disableGraticle = function() {
- models.layers.setVisibility("Graticule", false);
+ var disableGraticle = function () {
+ models.layers.setVisibility('Graticule', false);
toggle();
};
- if (state == "off") {
+ if (state == 'off') {
var layers = models.layers.get({
renderable: true
});
var on = true;
if (_.find(layers, {
- id: "Graticule"
+ id: 'Graticule'
}) && geographic) {
wv.ui.ask({
- header: "Notice",
+ header: 'Notice',
message: GRATICLE_WARNING,
onOk: disableGraticle,
- onCancel: function() {
- $button.prop("checked", false)
- .button("refresh");
+ onCancel: function () {
+ $button.prop('checked', false)
+ .button('refresh');
}
});
return;
@@ -136,45 +134,43 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
// the palettes before bringing up the crop box.
if (models.palettes.inUse()) {
wv.ui.ask({
- header: "Notice",
+ header: 'Notice',
message: PALETTE_WARNING,
onOk: disablePalettes,
- onCancel: function() {
- $button.prop("checked", false)
- .button("refresh");
+ onCancel: function () {
+ $button.prop('checked', false)
+ .button('refresh');
}
});
return;
}
- //Don't toggle area select UI for downloading image if image rotated
+ // Don't toggle area select UI for downloading image if image rotated
if (ui.map.selected.getView()
- .getRotation() === 0.0)
- toggleOn();
- else
+ .getRotation() === 0.0) { toggleOn(); } else {
wv.ui.ask({
- header: "Reset rotation?",
+ header: 'Reset rotation?',
message: ROTATE_WARNING,
- onOk: function() {
+ onOk: function () {
resetRotation();
- setTimeout(toggle, 500); //Let rotation finish before image download can occur
+ setTimeout(toggle, 500); // Let rotation finish before image download can occur
}
});
+ }
} else {
- state = "off";
- $button.prop("checked", false)
- .button("refresh");
+ state = 'off';
+ $button.prop('checked', false)
+ .button('refresh');
$cropee
.insertAfter('#productsHolder');
jcropAPI.destroy();
- if (geographic)
- ui.map.events.trigger('selectiondone'); //Should be a changed to a image event
+ if (geographic) { ui.map.events.trigger('selectiondone'); } // Should be a changed to a image event
if (previousPalettes) {
models.palettes.restore(previousPalettes);
previousPalettes = null;
}
- toolbarButtons("enable");
+ toolbarButtons('enable');
wv.ui.closeDialog();
- $(".wv-image-coords")
+ $('.wv-image-coords')
.hide();
}
};
@@ -185,10 +181,10 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
* @param {String} coordinates object of JCrop
*
*/
- var setCoords = function(c) {
+ var setCoords = function (c) {
previousCoords = coords;
coords = c;
- self.events.trigger("update", coords);
+ self.events.trigger('update', coords);
};
/**
@@ -198,19 +194,18 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
*
*
*/
- var draw = function() {
-
+ var draw = function () {
$cropee.Jcrop({
bgColor: 'black',
bgOpacity: 0.3,
- onSelect: function(c) {
+ onSelect: function (c) {
previousCoords = coords;
handleChange(c);
},
- onChange: function(c) {
+ onChange: function (c) {
handleChange(c);
},
- onRelease: function(c) {
+ onRelease: function (c) {
coords = previousCoords;
toggle();
},
@@ -218,8 +213,7 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
});
jcropAPI = $cropee.data('Jcrop');
- if (models.proj.selected.id === "geographic")
- ui.map.events.trigger('selecting'); //Should be a changed to a image event
+ if (models.proj.selected.id === 'geographic') { ui.map.events.trigger('selecting'); } // Should be a changed to a image event
if (coords) {
jcropAPI.setSelect([coords.x, coords.y, coords.x2, coords.y2]);
} else {
@@ -229,14 +223,10 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
.width() / 2) + 100, ($(window)
.height() / 2) + 100]);
}
-
};
-
- var handleChange = function(c) {
-
+ var handleChange = function (c) {
setCoords(c);
-
};
init();
diff --git a/web/js/layers/wv.layers.active.js b/web/js/layers/wv.layers.active.js
index 37f22a6bd..9bd987b06 100644
--- a/web/js/layers/wv.layers.active.js
+++ b/web/js/layers/wv.layers.active.js
@@ -7,50 +7,49 @@ wv.layers = wv.layers || {};
/**
* @class wv.layers.active
*/
-wv.layers.active = wv.layers.active || function(models, ui, config) {
-
+wv.layers.active = wv.layers.active || function (models, ui, config) {
var model = models.layers;
var groups = wv.util.LAYER_GROUPS;
var legends = {};
var self = {};
- self.id = "products";
- self.selector = "#products";
+ self.id = 'products';
+ self.selector = '#products';
- var init = function() {
+ var init = function () {
render();
model.events
- .on("add", onLayerAdded)
- .on("remove", onLayerRemoved)
- .on("update", onLayerUpdate)
- .on("visibility", onLayerVisibility);
+ .on('add', onLayerAdded)
+ .on('remove', onLayerRemoved)
+ .on('update', onLayerUpdate)
+ .on('visibility', onLayerVisibility);
models.proj.events
- .on("select", onProjectionChanged);
+ .on('select', onProjectionChanged);
models.palettes.events
- .on("set-custom", onPaletteUpdate)
- .on("clear-custom", onPaletteUpdate)
- .on("range", onPaletteUpdate)
- .on("update", onPaletteUpdateAll);
+ .on('set-custom', onPaletteUpdate)
+ .on('clear-custom', onPaletteUpdate)
+ .on('range', onPaletteUpdate)
+ .on('update', onPaletteUpdateAll);
models.date.events
- .on("select", onDateChange);
- models.wv.events.on("sidebar-expand", sizeProductsTab);
+ .on('select', onDateChange);
+ models.wv.events.on('sidebar-expand', sizeProductsTab);
$(window)
.resize(sizeProductsTab);
- ui.sidebar.events.on("selectTab", function(tab) {
- if (tab === "active") {
+ ui.sidebar.events.on('selectTab', function (tab) {
+ if (tab === 'active') {
sizeProductsTab();
}
});
ui.map.selected.getView()
- .on("change:resolution", onZoomChange);
+ .on('change:resolution', onZoomChange);
};
- var render = function() {
+ var render = function () {
legends = {};
var $container = $('<div />', {class: 'layer-container bank'});
$(self.selector).empty().append($container);
- _.eachRight(groups, function(group) {
+ _.eachRight(groups, function (group) {
renderGroup($container, group);
});
@@ -62,10 +61,10 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
}));
$('#products').append($footer);
- var $addBtn = $("#layers-add");
+ var $addBtn = $('#layers-add');
$addBtn.button();
- $addBtn.click(function(e) {
- $('#layer-modal').dialog("open");
+ $addBtn.click(function (e) {
+ $('#layer-modal').dialog('open');
});
$('.layer-container .close')
@@ -75,69 +74,68 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
$('.layer-container .close')
.on('click', removeLayer);
- $(".layer-container .hideReg")
+ $('.layer-container .hideReg')
.on('click', toggleVisibility);
- $(".layer-container ul.category")
+ $('.layer-container ul.category')
.sortable({
- items: "li:not(.head)",
- axis: "y",
- containment: "parent",
- tolerance: "pointer",
- placeholder: "state-saver"
+ items: 'li:not(.head)',
+ axis: 'y',
+ containment: 'parent',
+ tolerance: 'pointer',
+ placeholder: 'state-saver'
});
- $(".layer-container ul.category li")
+ $('.layer-container ul.category li')
.disableSelection();
- $(".layer-container ul.category")
+ $('.layer-container ul.category')
.bind('sortstop', moveLayer);
_.each(model.get({
- group: "overlays"
- }), function(layer) {
+ group: 'overlays'
+ }), function (layer) {
if (layer.palette) {
renderLegendCanvas(layer);
}
});
setTimeout(sizeProductsTab, 1000);
-
};
- var renderGroup = function($parent, group) {
- var $container = $("<ul></ul>")
- .attr("id", group.id)
- .addClass("category");
+ var renderGroup = function ($parent, group) {
+ var $container = $('<ul></ul>')
+ .attr('id', group.id)
+ .addClass('category');
- var $header = $("<h3></h3>")
- .addClass("head")
- .attr("id", group.id + '-header')
+ var $header = $('<h3></h3>')
+ .addClass('head')
+ .attr('id', group.id + '-header')
.html(group.description);
$parent.append($header);
_.each(model.get({
group: group.id
- }), function(layer) {
+ }), function (layer) {
renderLayer($container, group, layer);
});
$parent.append($container);
};
- var renderLayer = function($parent, group, layer, top) {
- var $layer = $("<li></li>")
- .attr("id", group.id + "-" + encodeURIComponent(layer.id))
- .addClass(self.id + "item")
- .addClass("item")
- .attr("data-layer", layer.id);
-
- var $visibleButton = $("<a></a>")
- .addClass("hdanchor hide hideReg bank-item-img")
- .attr("id", "hide" + encodeURIComponent(layer.id))
- .attr("data-layer", layer.id)
+ var renderLayer = function ($parent, group, layer, top) {
+ var $layer = $('<li></li>')
+ .attr('id', group.id + '-' + encodeURIComponent(layer.id))
+ .addClass(self.id + 'item')
+ .addClass('item')
+ .attr('data-layer', layer.id);
+
+ var $visibleButton = $('<a></a>')
+ .addClass('hdanchor hide hideReg bank-item-img')
+ .attr('id', 'hide' + encodeURIComponent(layer.id))
+ .attr('data-layer', layer.id)
.on('click', toggleVisibility);
- var $visibleImage = $("<i></i>")
- .on('click', function() {
+ var $visibleImage = $('<i></i>')
+ .on('click', function () {
$visibleButton.trigger('click');
});
@@ -149,7 +147,7 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
.addClass('disabled')
.addClass('layer-hidden');
$visibleButton
- .attr("title", "No data on selected date for this layer");
+ .attr('title', 'No data on selected date for this layer');
} else {
$layer
.removeClass('disabled')
@@ -157,34 +155,34 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
.removeClass('layer-hidden');
if (!layer.visible) {
$visibleButton
- .attr("title", "Show Layer")
- .attr("data-action", "show")
+ .attr('title', 'Show Layer')
+ .attr('data-action', 'show')
.parent()
- .addClass("layer-hidden");
+ .addClass('layer-hidden');
} else {
$visibleButton
- .attr("title", "Hide Layer")
- .attr("data-action", "hide")
+ .attr('title', 'Hide Layer')
+ .attr('data-action', 'hide')
.parent()
- .addClass("layer-visible");
+ .addClass('layer-visible');
}
}
- $layer.append($("<div></div>")
+ $layer.append($('<div></div>')
.addClass('zot')
.append('<b>!</b>'));
if (model.available(layer.id)) {
if (!layer.visible) {
$visibleButton
- .attr("title", "Show Layer")
- .attr("data-action", "show")
+ .attr('title', 'Show Layer')
+ .attr('data-action', 'show')
.parent()
- .addClass("layer-hidden");
+ .addClass('layer-hidden');
} else {
$visibleButton
- .attr("title", "Hide Layer")
- .attr("data-action", "hide")
+ .attr('title', 'Hide Layer')
+ .attr('data-action', 'hide')
.parent()
- .addClass("layer-visible");
+ .addClass('layer-visible');
}
}
@@ -192,24 +190,24 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
var names = models.layers.getTitles(layer.id);
- var $removeButton = $("<a></a>")
- .attr("id", "close" + group.id + encodeURIComponent(layer.id))
- .addClass("button close bank-item-img")
- .attr("data-layer", layer.id)
- .attr("title", "Remove Layer")
+ var $removeButton = $('<a></a>')
+ .attr('id', 'close' + group.id + encodeURIComponent(layer.id))
+ .addClass('button close bank-item-img')
+ .attr('data-layer', layer.id)
+ .attr('title', 'Remove Layer')
.on('click', removeLayer);
- var $removeImage = $("<i></i>");
+ var $removeImage = $('<i></i>');
$removeButton.append($removeImage);
- var $infoButton = $("<a></a>")
- .attr("data-layer", layer.id)
- .attr("title", "Layer description for " + names.title)
- .addClass("wv-layers-info");
+ var $infoButton = $('<a></a>')
+ .attr('data-layer', layer.id)
+ .attr('title', 'Layer description for ' + names.title)
+ .addClass('wv-layers-info');
if (!layer.description) {
$infoButton
- .addClass("disabled")
- .attr("title", "No layer description");
+ .addClass('disabled')
+ .attr('title', 'No layer description');
} else {
$infoButton.on('click', toggleInfoPanel);
}
@@ -217,39 +215,38 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
$infoButton.hide();
}
- var $infoIcon = $("<i></i>")
- .addClass("fa fa-info wv-layers-info-icon");
+ var $infoIcon = $('<i></i>')
+ .addClass('fa fa-info wv-layers-info-icon');
$infoButton.append($infoIcon);
- var $editButton = $("<a></a>")
- .attr("data-layer", layer.id)
- .attr("title", "Layer options for " + names.title)
- .addClass("wv-layers-options");
+ var $editButton = $('<a></a>')
+ .attr('data-layer', layer.id)
+ .attr('title', 'Layer options for ' + names.title)
+ .addClass('wv-layers-options');
$editButton.on('click', toggleOptionsPanel);
if (wv.util.browser.small) {
$editButton.hide();
}
- var $gearIcon = $("<i></i>")
- .addClass("wv-layers-options-icon");
+ var $gearIcon = $('<i></i>')
+ .addClass('wv-layers-options-icon');
$editButton.append($gearIcon);
var $mainLayerDiv = $('<div></div>')
.addClass('layer-main')
- .attr("data-layer", layer.id)
+ .attr('data-layer', layer.id)
.append($('<h4></h4>')
.html(names.title)
.attr('title', names.title))
.append($('<p></p>')
.html(names.subtitle));
- $layer.hover(function() {
+ $layer.hover(function () {
d3.select('#timeline-footer svg g.plot rect[data-layer="' + layer.id + '"]')
.classed('data-bar-hovered', true);
-
- }, function() {
+ }, function () {
d3.select('#timeline-footer svg g.plot rect[data-layer="' + layer.id + '"]')
.classed('data-bar-hovered', false);
});
@@ -269,16 +266,16 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
}
};
- var toggleInfoPanel = function(e) {
+ var toggleInfoPanel = function (e) {
e.stopPropagation();
- var $i = $("#wv-layers-info-dialog");
+ var $i = $('#wv-layers-info-dialog');
var thisLayerId = $(this)
- .attr("data-layer");
+ .attr('data-layer');
var thisLayer = config.layers[thisLayerId];
if ($i.length === 0) {
wv.layers.info(config, models, thisLayer);
- } else if ($i.attr("data-layer") !== thisLayerId) {
+ } else if ($i.attr('data-layer') !== thisLayerId) {
wv.ui.closeDialog();
wv.layers.info(config, models, thisLayer);
} else {
@@ -286,15 +283,15 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
}
};
- var toggleOptionsPanel = function(e) {
+ var toggleOptionsPanel = function (e) {
e.stopPropagation();
- var $d = $("#wv-layers-options-dialog");
+ var $d = $('#wv-layers-options-dialog');
var thisLayerId = $(this)
- .attr("data-layer");
+ .attr('data-layer');
var thisLayer = config.layers[thisLayerId];
if ($d.length === 0) {
wv.layers.options(config, models, thisLayer);
- } else if ($d.attr("data-layer") !== thisLayerId) {
+ } else if ($d.attr('data-layer') !== thisLayerId) {
wv.ui.closeDialog();
wv.layers.options(config, models, thisLayer);
} else {
@@ -302,14 +299,14 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
}
};
- var renderLegend = function($parent, group, layer) {
- var $container = $("<div></div>")
- .addClass("wv-palette")
- .attr("data-layer", encodeURIComponent(layer.id));
+ var renderLegend = function ($parent, group, layer) {
+ var $container = $('<div></div>')
+ .addClass('wv-palette')
+ .attr('data-layer', encodeURIComponent(layer.id));
$parent.append($container);
};
- var renderLegendCanvas = function(layer) {
+ var renderLegendCanvas = function (layer) {
var selector = ".wv-palette[data-layer='" +
wv.util.jqueryEscape(layer.id) + "']";
legends[layer.id] = wv.palettes.legend({
@@ -321,13 +318,13 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
});
};
var productsIsOverflow = false;
- var sizeProductsTab = function() {
+ var sizeProductsTab = function () {
var $tabPanel = $('#products');
var $tabFooter = $tabPanel.find('footer');
var windowHeight = $(window).outerHeight(true);
- var tabBarHeight = $("#productsHolder-tabs").outerHeight(true);
+ var tabBarHeight = $('#productsHolder-tabs').outerHeight(true);
var footerHeight = $tabFooter.outerHeight(true);
- var distanceFromTop = $("#productsHolder").offset().top;
+ var distanceFromTop = $('#productsHolder').offset().top;
var overlaysHeight = $('#overlays').outerHeight(true);
var baseLayersHeight = $('#baselayers').outerHeight(true);
var layerGroupHeight = 26; // Height of layer group titles
@@ -336,32 +333,32 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
// If on a mobile device, use the native scroll bars
if (!wv.util.browser.small) {
- $(".wv-layers-options").show();
- $(".wv-layers-info").show();
+ $('.wv-layers-options').show();
+ $('.wv-layers-info').show();
} else {
- $(".wv-layers-options").hide();
- $(".wv-layers-info").hide();
+ $('.wv-layers-options').hide();
+ $('.wv-layers-info').hide();
wv.ui.closeDialog();
}
- //FIXME: -10 here is the timeline's bottom position from page, fix
+ // FIXME: -10 here is the timeline's bottom position from page, fix
// after timeline markup is corrected to be loaded first
if (wv.util.browser.small) {
maxHeight = windowHeight - tabBarHeight - footerHeight - distanceFromTop - 10 - 5;
} else {
- //FIXME: Hack, the timeline sometimes renders twice as large of a height and
- //creates a miscalculation here for timelineHeight
- maxHeight = windowHeight - tabBarHeight - footerHeight - distanceFromTop - /*timelineHeight*/ 67 - 10 - 5;
+ // FIXME: Hack, the timeline sometimes renders twice as large of a height and
+ // creates a miscalculation here for timelineHeight
+ maxHeight = windowHeight - tabBarHeight - footerHeight - distanceFromTop - /* timelineHeight */ 67 - 10 - 5;
}
- $tabPanel.css("max-height", maxHeight);
+ $tabPanel.css('max-height', maxHeight);
if ((maxHeight <= contentHeight)) {
- $(".layer-container").css('height', maxHeight).css('padding-right', '10px');
+ $('.layer-container').css('height', maxHeight).css('padding-right', '10px');
$('.layer-container').perfectScrollbar();
if (productsIsOverflow === false) productsIsOverflow = true;
} else {
- $(".layer-container").css('height', '').css('padding-right', '');
+ $('.layer-container').css('height', '').css('padding-right', '');
if (productsIsOverflow) {
$('.layer-container').perfectScrollbar('destroy');
productsIsOverflow = false;
@@ -369,16 +366,16 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
}
};
- var removeLayer = function(event) {
+ var removeLayer = function (event) {
var layerId = $(event.target)
- .attr("data-layer");
- setTimeout(function() {
+ .attr('data-layer');
+ setTimeout(function () {
model.remove(layerId);
}, 50);
};
- var onLayerRemoved = function(layer) {
- var layerSelector = "#" + layer.group + "-" +
+ var onLayerRemoved = function (layer) {
+ var layerSelector = '#' + layer.group + '-' +
wv.util.jqueryEscape(layer.id);
$(layerSelector)
.remove();
@@ -388,59 +385,57 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
sizeProductsTab();
};
- var onLayerAdded = function(layer) {
- var $container = $("#" + layer.group);
+ var onLayerAdded = function (layer) {
+ var $container = $('#' + layer.group);
- renderLayer($container, groups[layer.group], layer, "top");
+ renderLayer($container, groups[layer.group], layer, 'top');
if (layer.palette) {
renderLegendCanvas(layer);
}
sizeProductsTab();
};
- var toggleVisibility = function() {
+ var toggleVisibility = function () {
if ($(this)
.parent()
- .hasClass('disabled'))
- return;
+ .hasClass('disabled')) { return; }
if ($(this)
- .attr("data-action") === "show") {
+ .attr('data-action') === 'show') {
model.setVisibility($(this)
- .attr("data-layer"), true);
+ .attr('data-layer'), true);
} else {
model.setVisibility($(this)
- .attr("data-layer"), false);
+ .attr('data-layer'), false);
}
};
- var moveLayer = function(event, ui) {
-
+ var moveLayer = function (event, ui) {
var $target = ui.item;
var $next = $target.next();
if ($next.length) {
- model.moveBefore($target.attr("data-layer"),
- $next.attr("data-layer"));
+ model.moveBefore($target.attr('data-layer'),
+ $next.attr('data-layer'));
} else {
- model.pushToBottom($target.attr("data-layer"));
+ model.pushToBottom($target.attr('data-layer'));
}
};
- var onLayerUpdate = function() {
+ var onLayerUpdate = function () {
// Timeout prevents redraw artifacts
setTimeout(render, 1);
};
- var onLayerVisibility = function(layer, visible) {
+ var onLayerVisibility = function (layer, visible) {
var $element = $(".hideReg[data-layer='" + layer.id + "']");
if (visible) {
- $element.attr("data-action", "hide")
- .attr("title", 'Hide Layer')
+ $element.attr('data-action', 'hide')
+ .attr('title', 'Hide Layer')
.parent()
.removeClass('layer-hidden')
.addClass('layer-visible');
} else {
- $element.attr("data-action", "show")
- .attr("title", "Show Layer")
+ $element.attr('data-action', 'show')
+ .attr('title', 'Show Layer')
.parent()
.removeClass('layer-visible')
.addClass('layer-hidden');
@@ -448,44 +443,43 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
onZoomChange();
};
- var onPaletteUpdate = function(layerId) {
+ var onPaletteUpdate = function (layerId) {
if (legends[layerId]) {
legends[layerId].update();
}
};
- var onPaletteUpdateAll = function() {
- _.each(legends, function(legend) {
+ var onPaletteUpdateAll = function () {
+ _.each(legends, function (legend) {
legend.update();
});
};
- var onProjectionChanged = function() {
+ var onProjectionChanged = function () {
// Timeout prevents redraw artifacts
ui.map.selected.getView()
- .on("change:resolution", onZoomChange);
+ .on('change:resolution', onZoomChange);
setTimeout(render, 1);
};
- var onZoomChange = function() {
-
- _.each(groups, function(group) {
+ var onZoomChange = function () {
+ _.each(groups, function (group) {
_.each(model.get({
group: group.id
- }), function(layer) {
+ }), function (layer) {
var $layer = $('#products li.productsitem[data-layer="' +
layer.id + '"]');
checkZots($layer, layer);
});
});
};
- var onDateChange = function() {
- _.each(groups, function(group) {
+ var onDateChange = function () {
+ _.each(groups, function (group) {
_.each(model.get({
group: group.id
- }), function(layer) {
- var $layer = $('#' + group.id + "-" + encodeURIComponent(layer.id));
+ }), function (layer) {
+ var $layer = $('#' + group.id + '-' + encodeURIComponent(layer.id));
- var $visibleButton = $('#' + "hide" + encodeURIComponent(layer.id));
+ var $visibleButton = $('#' + 'hide' + encodeURIComponent(layer.id));
if (!model.available(layer.id)) {
$layer
@@ -494,7 +488,7 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
.addClass('disabled')
.addClass('layer-hidden');
$visibleButton
- .attr("title", "No data on selected date for this layer");
+ .attr('title', 'No data on selected date for this layer');
} else {
$layer
.removeClass('layer-visible')
@@ -503,16 +497,16 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
.removeClass('layer-hidden');
if (!layer.visible) {
$visibleButton
- .attr("title", "Show Layer")
- .attr("data-action", "show")
+ .attr('title', 'Show Layer')
+ .attr('data-action', 'show')
.parent()
- .addClass("layer-hidden");
+ .addClass('layer-hidden');
} else {
$visibleButton
- .attr("title", "Hide Layer")
- .attr("data-action", "hide")
+ .attr('title', 'Hide Layer')
+ .attr('data-action', 'hide')
.parent()
- .addClass("layer-visible");
+ .addClass('layer-visible');
}
}
checkZots($layer, layer);
@@ -520,7 +514,7 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
});
};
- var checkZots = function($layer, layer) {
+ var checkZots = function ($layer, layer) {
var map = ui.map;
var zoom = map.selected.getView()
.getZoom();
@@ -529,11 +523,10 @@ wv.layers.active = wv.layers.active || function(models, ui, config) {
// Account for offset between the map's top zoom level and the
// lowest-resolution TileMatrix in polar layers
- var zoomOffset = ((proj == "arctic") || (proj == "antarctic")) ? 1 : 0;
+ var zoomOffset = ((proj == 'arctic') || (proj == 'antarctic')) ? 1 : 0;
var matrixSet = layer.projections[proj].matrixSet;
-
if (matrixSet !== undefined) {
var source = layer.projections[proj].source;
var zoomLimit = sources[source]
diff --git a/web/js/layers/wv.layers.add.js b/web/js/layers/wv.layers.add.js
index 43469b20e..75fc9c516 100644
--- a/web/js/layers/wv.layers.add.js
+++ b/web/js/layers/wv.layers.add.js
@@ -7,20 +7,19 @@ wv.layers = wv.layers || {};
/**
* @class wv.layers.add
*/
-wv.layers.add = wv.layers.add || function(models, ui, config) {
-
+wv.layers.add = wv.layers.add || function (models, ui, config) {
var jsp = null;
var model = models.layers;
var self = {};
- self.selector = "#selectorbox";
- self.id = "selectorbox";
+ self.selector = '#selectorbox';
+ self.id = 'selectorbox';
var visible = {};
- var init = function() {
- _.each(config.layers, function(layer) {
+ var init = function () {
+ _.each(config.layers, function (layer) {
visible[layer.id] = true;
});
@@ -28,30 +27,30 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
.resize(resize);
model.events
- .on("add", onLayerAdded)
- .on("remove", onLayerRemoved);
- models.proj.events.on("select", onProjectionChange);
- models.wv.events.on("sidebar-expand", resize);
- ui.sidebar.events.on("selectTab", function(tab) {
- if (tab === "add") {
+ .on('add', onLayerAdded)
+ .on('remove', onLayerRemoved);
+ models.proj.events.on('select', onProjectionChange);
+ models.wv.events.on('sidebar-expand', resize);
+ ui.sidebar.events.on('selectTab', function (tab) {
+ if (tab === 'add') {
resize();
}
});
// Rendering all the layers can take a half second or so. Place
// in a timeout to make startup look fast. This should all be
// replaced in the next version.
- setTimeout(function() {
+ setTimeout(function () {
render();
filter();
resize();
}, 1);
};
- var render = function() {
+ var render = function () {
$(self.selector)
.empty();
- var tabs_height = $(".ui-tabs-nav")
+ var tabs_height = $('.ui-tabs-nav')
.outerHeight(true);
$(self.selector)
.addClass('selector');
@@ -63,48 +62,48 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
.outerHeight() - tabs_height
);
- var $form = $("<div></div>")
- .attr("id", self.id + "facetedSearch")
- .addClass("facetedSearch");
+ var $form = $('<div></div>')
+ .attr('id', self.id + 'facetedSearch')
+ .addClass('facetedSearch');
if (config.aoi) {
- var $select = $("<select></select>")
- .attr("id", self.id + "select")
- .addClass("select");
+ var $select = $('<select></select>')
+ .attr('id', self.id + 'select')
+ .addClass('select');
$form.append($select);
}
- var $search = $("<input>")
- .attr("id", self.id + "search")
- .addClass("search")
- .attr("type", "text")
- .attr("name", "search")
- .attr("placeholder", 'Search ("aqua", "fire")')
- .attr("autocomplete", "off");
+ var $search = $('<input>')
+ .attr('id', self.id + 'search')
+ .addClass('search')
+ .attr('type', 'text')
+ .attr('name', 'search')
+ .attr('placeholder', 'Search ("aqua", "fire")')
+ .attr('autocomplete', 'off');
$form.append($search);
$(self.selector)
.append($form);
- var $content = $("<div></div>")
- .attr("id", self.id + "content");
+ var $content = $('<div></div>')
+ .attr('id', self.id + 'content');
- renderType($content, "baselayers", "Base Layers", "BaseLayers");
- renderType($content, "overlays", "Overlays", "Overlays");
+ renderType($content, 'baselayers', 'Base Layers', 'BaseLayers');
+ renderType($content, 'overlays', 'Overlays', 'Overlays');
$(self.selector)
.append($content);
- $(self.selector + " .selectorItem, " + self.selector +
- " .selectorItem input")
+ $(self.selector + ' .selectorItem, ' + self.selector +
+ ' .selectorItem input')
.on('ifChecked', addLayer);
- $(self.selector + " .selectorItem, " + self.selector +
- " .selectorItem input")
+ $(self.selector + ' .selectorItem, ' + self.selector +
+ ' .selectorItem input')
.on('ifUnchecked', removeLayer);
- $(self.selector + "select")
+ $(self.selector + 'select')
.on('change', filter);
- $(self.selector + "search")
+ $(self.selector + 'search')
.on('keyup', filter);
- $(self.selector + "search")
+ $(self.selector + 'search')
.focus();
$(self.selector)
@@ -116,25 +115,25 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
setTimeout(resize, 1);
};
- var renderType = function($parent, group, header, camelCase) {
- var $container = $("<div></div>")
- .attr("id", self.id + camelCase)
- .addClass("categoryContainer");
+ var renderType = function ($parent, group, header, camelCase) {
+ var $container = $('<div></div>')
+ .attr('id', self.id + camelCase)
+ .addClass('categoryContainer');
- var $header = $("<h3></h3>")
- .addClass("head")
+ var $header = $('<h3></h3>')
+ .addClass('head')
.html(header);
- var $element = $("<ul></ul>")
- .attr("id", self.id + group)
- .addClass(self.id + "category")
- .addClass("category")
- .addClass("scroll-pane");
+ var $element = $('<ul></ul>')
+ .attr('id', self.id + group)
+ .addClass(self.id + 'category')
+ .addClass('category')
+ .addClass('scroll-pane');
- _.each(config.layerOrder, function(layerId) {
+ _.each(config.layerOrder, function (layerId) {
var layer = config.layers[layerId];
if (!layer) {
- console.warn("In layer order but not defined", layerId);
+ console.warn('In layer order but not defined', layerId);
} else if (layer.group === group) {
renderLayer($element, group, layerId);
}
@@ -145,49 +144,49 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
$parent.append($container);
};
- var renderLayer = function($parent, group, layerId) {
+ var renderLayer = function ($parent, group, layerId) {
var layer = config.layers[layerId];
if (!layer) {
- console.warn("Skipping unknown layer", layerId);
+ console.warn('Skipping unknown layer', layerId);
return;
}
- var $label = $("<label></label>")
- .attr("data-layer", encodeURIComponent(layer.id));
- var $element = $("<li></li>")
- .addClass("selectorItem")
- .attr("data-layer", encodeURIComponent(layer.id))
- .addClass("item");
+ var $label = $('<label></label>')
+ .attr('data-layer', encodeURIComponent(layer.id));
+ var $element = $('<li></li>')
+ .addClass('selectorItem')
+ .attr('data-layer', encodeURIComponent(layer.id))
+ .addClass('item');
var names = models.layers.getTitles(layer.id);
- var $name = $("<h4></h4>")
- .addClass("title")
+ var $name = $('<h4></h4>')
+ .addClass('title')
.html(names.title);
if (config.parameters.markPalettes) {
if (layer.palette) {
- $name.addClass("mark");
+ $name.addClass('mark');
}
}
if (config.parameters.markDownloads) {
if (layer.product) {
- $name.addClass("mark");
+ $name.addClass('mark');
}
}
- var $description = $("<p></p>")
- .addClass("subtitle")
+ var $description = $('<p></p>')
+ .addClass('subtitle')
.html(names.subtitle);
- var $checkbox = $("<input></input>")
- .attr("id", encodeURIComponent(layer.id))
- .attr("value", layer.id)
- .attr("type", "checkbox")
- .attr("data-layer", layer.id);
- if (group === "baselayers") {
- $checkbox.attr("name", group);
+ var $checkbox = $('<input></input>')
+ .attr('id', encodeURIComponent(layer.id))
+ .attr('value', layer.id)
+ .attr('type', 'checkbox')
+ .attr('data-layer', layer.id);
+ if (group === 'baselayers') {
+ $checkbox.attr('name', group);
}
if (_.find(model.active, {
id: layer.id
})) {
- $checkbox.attr("checked", "checked");
+ $checkbox.attr('checked', 'checked');
}
$element.append($checkbox);
@@ -198,31 +197,31 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
$parent.append($label);
};
- var adjustCategoryHeights = function() {
+ var adjustCategoryHeights = function () {
var heights = [];
var facets_height =
- $(self.selector + "facetedSearch")
+ $(self.selector + 'facetedSearch')
.outerHeight(true);
var container_height =
$(self.selector)
.outerHeight(true) - facets_height;
- $(self.selector + "content")
+ $(self.selector + 'content')
.height(container_height);
var labelHeight = 0;
$(self.selector + 'content .head')
- .each(function() {
+ .each(function () {
labelHeight += $(this)
.outerHeight(true);
});
container_height -= labelHeight;
- $.each(["baselayers", "overlays"], function(i, group) {
+ $.each(['baselayers', 'overlays'], function (i, group) {
var actual_height = 0;
var count = 0;
$(self.selector + group + ' li')
- .each(function() {
+ .each(function () {
var layerId = decodeURIComponent($(this)
- .attr("data-layer"));
+ .attr('data-layer'));
if (visible[layerId]) {
actual_height += $(this)
.outerHeight(true);
@@ -243,16 +242,16 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
}
heights[1].height = container_height - heights[0].height;
}
- $("#" + heights[0].name)
- .css("height", heights[0].height + "px");
- $("#" + heights[1].name)
- .css("height", heights[1].height + "px");
+ $('#' + heights[0].name)
+ .css('height', heights[0].height + 'px');
+ $('#' + heights[1].name)
+ .css('height', heights[1].height + 'px');
reinitializeScrollbars();
};
- var reinitializeScrollbars = function() {
- $("." + self.id + "category")
- .each(function() {
+ var reinitializeScrollbars = function () {
+ $('.' + self.id + 'category')
+ .each(function () {
var api = $(this)
.data('jsp');
if (api) {
@@ -261,9 +260,8 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
});
};
- var resize = function() {
-
- var tabs_height = $(".ui-tabs-nav")
+ var resize = function () {
+ var tabs_height = $('.ui-tabs-nav')
.outerHeight(true);
$(self.selector)
.height($(self.selector)
@@ -277,7 +275,7 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
}
}
if (wv.util.browser.ie) {
- jsp = $("." + self.id + "category")
+ jsp = $('.' + self.id + 'category')
.jScrollPane({
verticalDragMinHeight: 20,
autoReinitialise: false,
@@ -285,7 +283,7 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
mouseWheelSpeed: 60
});
} else {
- jsp = $("." + self.id + "category")
+ jsp = $('.' + self.id + 'category')
.jScrollPane({
verticalDragMinHeight: 20,
autoReinitialise: false,
@@ -295,37 +293,36 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
adjustCategoryHeights();
};
- var addLayer = function() {
+ var addLayer = function () {
model.add(decodeURIComponent($(this)
- .attr("data-layer")));
-
+ .attr('data-layer')));
};
- var removeLayer = function() {
+ var removeLayer = function () {
model.remove(decodeURIComponent($(this)
- .attr("data-layer")));
+ .attr('data-layer')));
};
- var onLayerAdded = function(layer) {
+ var onLayerAdded = function (layer) {
var $element = $("#selectorbox [data-layer='" +
wv.util.jqueryEscape(layer.id) + "']");
- $element.iCheck("check");
+ $element.iCheck('check');
};
- var onLayerRemoved = function(layer) {
+ var onLayerRemoved = function (layer) {
var $element = $("#selectorbox [data-layer='" +
wv.util.jqueryEscape(layer.id) + "']");
- $element.iCheck("uncheck");
+ $element.iCheck('uncheck');
};
- var onProjectionChange = function() {
+ var onProjectionChange = function () {
adjustTitles();
updateAreasOfInterest();
filter();
};
- var adjustTitles = function() {
- _.each(config.layers, function(def) {
+ var adjustTitles = function () {
+ _.each(config.layers, function (def) {
var names = models.layers.getTitles(def.id);
$("#selectorbox [data-layer='" + encodeURIComponent(def.id) +
"'] .title")
@@ -336,22 +333,22 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
});
};
- var updateAreasOfInterest = function() {
+ var updateAreasOfInterest = function () {
if (!config.aoi) {
return;
}
- var $select = $("#" + self.id + "select");
- var previous = $(self.selector + "select")
+ var $select = $('#' + self.id + 'select');
+ var previous = $(self.selector + 'select')
.val();
$select.empty();
- var $option = $("<option></option>")
- .attr("value", "All")
- .html("All");
+ var $option = $('<option></option>')
+ .attr('value', 'All')
+ .html('All');
$select.append($option);
var aois = [];
- $.each(config.aoi, function(name, info) {
+ $.each(config.aoi, function (name, info) {
if ($.inArray(models.proj.selected.id,
info.projections) >= 0) {
if (info.index === 0 || info.index) {
@@ -362,39 +359,39 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
}
});
- $.each(aois, function(index, name) {
- var $option = $("<option></option>")
- .attr("value", name)
+ $.each(aois, function (index, name) {
+ var $option = $('<option></option>')
+ .attr('value', name)
.html(name);
if (previous === name) {
- $option.attr("selected", "selected");
+ $option.attr('selected', 'selected');
}
$select.append($option);
});
filter();
};
- var searchTerms = function() {
- var search = $(self.selector + "search")
+ var searchTerms = function () {
+ var search = $(self.selector + 'search')
.val()
.toLowerCase();
var terms = search.split(/ +/);
return terms;
};
- var filterProjection = function(layer) {
+ var filterProjection = function (layer) {
return !layer.projections[models.proj.selected.id];
};
- var filterSearch = function(layer, terms) {
- var search = $(self.selector + "search")
+ var filterSearch = function (layer, terms) {
+ var search = $(self.selector + 'search')
.val();
- if (search === "") {
+ if (search === '') {
return false;
}
var filtered = false;
var names = models.layers.getTitles(layer.id);
- $.each(terms, function(index, term) {
+ $.each(terms, function (index, term) {
filtered = !names.title.toLowerCase()
.contains(term) &&
!names.subtitle.toLowerCase()
@@ -408,17 +405,17 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {
return filtered;
};
- var filter = _.throttle(function() {
+ var filter = _.throttle(function () {
var search = searchTerms();
- $.each(config.layers, function(layerId, layer) {
+ $.each(config.layers, function (layerId, layer) {
var fproj = filterProjection(layer);
var fterms = filterSearch(layer, search);
var filtered = fproj || fterms;
- var display = filtered ? "none" : "block";
+ var display = filtered ? 'none' : 'block';
var selector = "#selectorbox li[data-layer='" +
wv.util.jqueryEscape(layerId) + "']";
$(selector)
- .css("display", display);
+ .css('display', display);
visible[layer.id] = !filtered;
});
adjustCategoryHeights();
diff --git a/web/js/layers/wv.layers.info.js b/web/js/layers/wv.layers.info.js
index e5a901011..7e60560e4 100644
--- a/web/js/layers/wv.layers.info.js
+++ b/web/js/layers/wv.layers.info.js
@@ -1,31 +1,30 @@
var wv = wv || {};
wv.layers = wv.layers || {};
-wv.layers.info = wv.layers.info || function(config, models, layer) {
-
+wv.layers.info = wv.layers.info || function (config, models, layer) {
var $dialog;
var self = {};
- var init = function() {
+ var init = function () {
loaded();
};
- var loaded = function(custom) {
+ var loaded = function (custom) {
var names;
$dialog = wv.ui.getDialog();
$dialog
- .attr("id", "wv-layers-info-dialog")
- .attr("data-layer", layer.id);
+ .attr('id', 'wv-layers-info-dialog')
+ .attr('data-layer', layer.id);
renderDescription($dialog);
names = models.layers.getTitles(layer.id);
$dialog.dialog({
- dialogClass: "wv-panel",
+ dialogClass: 'wv-panel',
title: names.title,
show: {
- effect: "slide",
- direction: "left"
+ effect: 'slide',
+ direction: 'left'
},
width: 450,
minHeight: 150,
@@ -33,32 +32,32 @@ wv.layers.info = wv.layers.info || function(config, models, layer) {
resizable: false,
draggable: false,
position: {
- my: "left top",
- at: "right+5 top",
- of: $("#products")
+ my: 'left top',
+ at: 'right+5 top',
+ of: $('#products')
},
// Wait for the dialog box to load, then force scroll to top
- open: function() {
+ open: function () {
$(this)
.parent()
.promise()
- .done(function() {
+ .done(function () {
$('.ui-dialog-content')
.scrollTop('0');
});
},
close: dispose
});
- $("#wv-layers-info-dialog")
+ $('#wv-layers-info-dialog')
.perfectScrollbar();
};
- var dispose = function() {
+ var dispose = function () {
$dialog = null;
wv.ui.closeDialog();
};
- var renderDescription = function($dialog) {
+ var renderDescription = function ($dialog) {
var $layerMeta = $('<div></div>')
.addClass('layer-metadata source-metadata');
var $layerMetaTitle = $('<a>Layer Description</a>')
@@ -66,7 +65,7 @@ wv.layers.info = wv.layers.info || function(config, models, layer) {
if (layer.description) {
$.get('config/metadata/' + layer.description + '.html')
- .success(function(data) {
+ .success(function (data) {
$layerMeta.html(data);
$dialog.append($layerMeta);
$layerMeta.find('a')
@@ -75,13 +74,12 @@ wv.layers.info = wv.layers.info || function(config, models, layer) {
}
};
- var onLayerRemoved = function(removedLayer) {
+ var onLayerRemoved = function (removedLayer) {
if (layer.id === removedLayer.id && $dialog) {
- $dialog.dialog("close");
+ $dialog.dialog('close');
}
};
init();
return self;
-
};
diff --git a/web/js/layers/wv.layers.js b/web/js/layers/wv.layers.js
index 20f80020f..af3edaab9 100644
--- a/web/js/layers/wv.layers.js
+++ b/web/js/layers/wv.layers.js
@@ -1,8 +1,7 @@
var wv = wv || {};
-wv.layers = (function(self) {
-
- self.parse = function(state, errors, config) {
+wv.layers = (function (self) {
+ self.parse = function (state, errors, config) {
if (state.l) {
parse12(state, errors, config);
}
@@ -12,17 +11,17 @@ wv.layers = (function(self) {
};
// Permalink versions 1.0 and 1.1
- var parse11 = function(state, errors, config) {
+ var parse11 = function (state, errors, config) {
var str = state.products;
var layers = [];
var hidden = {};
var ids = str.split(/[~,\.]/);
- _.each(ids, function(id) {
- if (id === "baselayers" || id == "overlays") {
+ _.each(ids, function (id) {
+ if (id === 'baselayers' || id == 'overlays') {
return;
}
var visible = true;
- if (id.startsWith("!")) {
+ if (id.startsWith('!')) {
visible = false;
id = id.substring(1);
}
@@ -31,7 +30,7 @@ wv.layers = (function(self) {
}
if (!config.layers[id]) {
errors.push({
- message: "No such layer: " + id
+ message: 'No such layer: ' + id
});
return;
}
@@ -41,7 +40,7 @@ wv.layers = (function(self) {
};
if (!visible) {
lstate.attributes.push({
- id: "hidden",
+ id: 'hidden',
value: true
});
}
@@ -51,12 +50,12 @@ wv.layers = (function(self) {
};
// Permalink version 1.2
- var parse12 = function(state, errors, config) {
+ var parse12 = function (state, errors, config) {
var str = state.l;
// Split by layer definitions (commas not in parens)
var layerDefs = str.match(/[^\(,]+(\([^\)]*\))?,?/g);
var lstates = [];
- _.each(layerDefs, function(layerDef) {
+ _.each(layerDefs, function (layerDef) {
// Get the text before any paren or comma
var layerId = layerDef.match(/[^\(,]+/)[0];
if (config.redirects && config.redirects.layers) {
@@ -70,11 +69,11 @@ wv.layers = (function(self) {
var arrayAttr = layerDef.match(/\(.*\)/);
if (arrayAttr) {
// Get single match and remove parens
- var strAttr = arrayAttr[0].replace(/[\(\)]/g, "");
+ var strAttr = arrayAttr[0].replace(/[\(\)]/g, '');
// Key value pairs
- var kvps = strAttr.split(",");
- _.each(kvps, function(kvp) {
- parts = kvp.split("=");
+ var kvps = strAttr.split(',');
+ _.each(kvps, function (kvp) {
+ parts = kvp.split('=');
if (parts.length === 1) {
lstate.attributes.push({
id: parts[0],
@@ -93,43 +92,40 @@ wv.layers = (function(self) {
state.l = lstates;
};
- self.validate = function(errors, config) {
- var error = function(layerId, cause) {
+ self.validate = function (errors, config) {
+ var error = function (layerId, cause) {
errors.push({
- message: "Invalid layer: " + layerId,
+ message: 'Invalid layer: ' + layerId,
cause: cause,
layerRemoved: true
});
delete config.layers[layerId];
- _.remove(config.layerOrder.baselayers, function(e) {
+ _.remove(config.layerOrder.baselayers, function (e) {
return e === layerId;
});
- _.remove(config.layerOrder.overlays, function(e) {
+ _.remove(config.layerOrder.overlays, function (e) {
return e === layerId;
});
};
var layers = _.cloneDeep(config.layers);
- _.each(layers, function(layer) {
+ _.each(layers, function (layer) {
if (!layer.group) {
- error(layer.id, "No group defined");
+ error(layer.id, 'No group defined');
return;
}
if (!layer.projections) {
- error(layer.id, "No projections defined");
- return;
+ error(layer.id, 'No projections defined');
}
});
var orders = _.cloneDeep(config.layerOrder);
- _.each(orders, function(layerId) {
+ _.each(orders, function (layerId) {
if (!config.layers[layerId]) {
- error(layerId, "No configuration");
- return;
+ error(layerId, 'No configuration');
}
});
};
return self;
-
})(wv.layers || {});
diff --git a/web/js/layers/wv.layers.modal.js b/web/js/layers/wv.layers.modal.js
index f78d3a57c..dac79595b 100644
--- a/web/js/layers/wv.layers.modal.js
+++ b/web/js/layers/wv.layers.modal.js
@@ -7,8 +7,7 @@ wv.layers = wv.layers || {};
/**
* @class wv.layers.modal
*/
-wv.layers.modal = wv.layers.modal || function(models, ui, config) {
-
+wv.layers.modal = wv.layers.modal || function (models, ui, config) {
var model = models.layers;
var self = {};
self.selector = '#layer-modal';
@@ -17,20 +16,20 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
var $header = $(self.selector + ' header');
var $categories = $(' #layer-categories ');
- var $selectedCategory = $(self.selector + " #selected-category");
- var $allLayers = $(self.selector + " #layers-all");
- var gridItemWidth = 320; //with of grid item + spacing
+ var $selectedCategory = $(self.selector + ' #selected-category');
+ var $allLayers = $(self.selector + ' #layers-all');
+ var gridItemWidth = 320; // with of grid item + spacing
var modalHeight;
var modalWidth;
var sizeMultiplier;
var searchBool;
var hasMeasurement;
- var getLayersForProjection = function(projection) {
- var filteredLayers = Object.values(config.layers).filter(function(layer){
+ var getLayersForProjection = function (projection) {
+ var filteredLayers = Object.values(config.layers).filter(function (layer) {
// Only use the layers for the active projection
return layer.projections[projection];
- }).map(function(layer){
+ }).map(function (layer) {
// If there is metadata for the current projection, use that
var projectionMeta = layer.projections[projection];
if (projectionMeta.title) layer.title = projectionMeta.title;
@@ -39,26 +38,26 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
if (layer.subtitle) layer.subtitle = decodeHtml(layer.subtitle);
return layer;
});
- return _.sortBy(filteredLayers, function(layer) {
+ return _.sortBy(filteredLayers, function (layer) {
return _.indexOf(config.layerOrder, layer.id);
});
};
- var decodeHtml = function(html) {
- var txt = document.createElement("textarea");
+ var decodeHtml = function (html) {
+ var txt = document.createElement('textarea');
txt.innerHTML = html;
return txt.value;
};
var allLayers = getLayersForProjection(models.proj.selected.id);
- var init = function() {
+ var init = function () {
model.events
// FIXME: on "add" needs to be present without trying to add a product
// multiple times
- //.on("add", onLayerAdded)
- .on("remove", onLayerRemoved);
- models.proj.events.on("select", drawDefaultPage);
+ // .on("add", onLayerAdded)
+ .on('remove', onLayerRemoved);
+ models.proj.events.on('select', drawDefaultPage);
// Create tiles
render();
@@ -86,16 +85,16 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* @return {boolean} Return true if the source contains settings.
*
*/
- var hasMeasurementSetting = function(current, source) {
+ var hasMeasurementSetting = function (current, source) {
var projection = models.proj.selected.id;
var hasSetting;
- Object.values(source.settings).forEach(function(setting) {
+ Object.values(source.settings).forEach(function (setting) {
var layer = config.layers[setting];
- if(layer) {
+ if (layer) {
var proj = layer.projections;
- if(layer.id == setting && Object.keys(proj).indexOf(projection) > -1) {
- if (layer.layergroup && layer.layergroup.indexOf("reference_orbits") !== -1) {
- if(current.id === "orbital-track") {
+ if (layer.id == setting && Object.keys(proj).indexOf(projection) > -1) {
+ if (layer.layergroup && layer.layergroup.indexOf('reference_orbits') !== -1) {
+ if (current.id === 'orbital-track') {
hasSetting = true;
}
// Don't output sources with only orbit tracks
@@ -118,9 +117,9 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* @return {boolean} Return true if the measurement has sources with settings.
*/
- var hasMeasurementSource = function(current) {
+ var hasMeasurementSource = function (current) {
var hasSource;
- Object.values(current.sources).forEach(function(source) {
+ Object.values(current.sources).forEach(function (source) {
if (hasMeasurementSetting(current, source)) {
hasSource = true;
hasMeasurement = true;
@@ -129,81 +128,78 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
return hasSource;
};
-
/**
* var checkModalView - If modalView is set, then output a console message describing
* which layer is being shown.
*
* @return {string} Returns a console warn message.
*/
- var checkModalView = function() {
+ var checkModalView = function () {
var modalView = config.parameters.modalView;
- switch(modalView) {
- case('categories'):
+ switch (modalView) {
+ case ('categories'):
console.warn("'Add Layers' view changed to Categories");
break;
- case('measurements'):
+ case ('measurements'):
console.warn("'Add Layers' view changed to Measurements");
break;
- case('layers'):
+ case ('layers'):
console.warn("'Add Layers' view changed to Layers");
break;
case undefined:
break;
default:
- console.warn("Invalid parameter; showing Categories view");
+ console.warn('Invalid parameter; showing Categories view');
}
};
- var setModalSize = function() {
+ var setModalSize = function () {
var availableWidth = $(window).width() - ($(window).width() * 0.15);
sizeMultiplier = Math.floor(availableWidth / gridItemWidth);
- if (sizeMultiplier < 1)
- sizeMultiplier = 1;
- if (sizeMultiplier > 3)
- sizeMultiplier = 3;
+ if (sizeMultiplier < 1) { sizeMultiplier = 1; }
+ if (sizeMultiplier > 3) { sizeMultiplier = 3; }
modalHeight = $(window).height() - 100;
modalWidth = gridItemWidth * sizeMultiplier + 10;
};
- $.fn.hasScrollBar = function() {
+ $.fn.hasScrollBar = function () {
return this.get(0).scrollHeight > this.height();
};
- //Update modal size
- var redo = function() {
+ // Update modal size
+ var redo = function () {
setModalSize();
- $(self.selector).dialog("option", {
+ $(self.selector).dialog('option', {
height: modalHeight,
width: modalWidth
});
- $( '#layers-all' ).css( 'height', modalHeight - 70); // 40 search box height + 30 breadcrub height
+ $('#layers-all').css('height', modalHeight - 70); // 40 search box height + 30 breadcrub height
$('#layer-modal-main').css('height', modalHeight - 40).perfectScrollbar('update');
};
- var redoScrollbar = function() {
+ var redoScrollbar = function () {
$('#layer-modal-main').perfectScrollbar('update');
};
// This draws the default page, depending on projection
// and hides the breadcrumb, and sets the search back to normal
// and updates the scrollbar.
- var removeSearch = function(){
+ var removeSearch = function () {
$selectedCategory.hide();
$breadcrumb.hide();
searchBool = false;
- if(self.reactList){
+ if (self.reactList) {
$('#layer-modal-main').perfectScrollbar();
}
- $( '#layers-search-input' ).val('');
- $( '#layer-search label.search-icon' ).removeClass('search-on').off('click');
+ $('#layers-search-input').val('');
+ $('#layer-search label.search-icon').removeClass('search-on').off('click');
};
- var resize = function(){
- if( $( self.selector ).dialog( "isOpen" ) ) {
+ var resize = function () {
+ if ($(self.selector).dialog('isOpen')) {
redo();
}
};
- var drawDefaultPage = function() {
+ var drawDefaultPage = function () {
removeSearch();
drawModal();
redoScrollbar();
@@ -217,21 +213,21 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* @return {void} Calls the categories, measurements, or layers view functions
* to which renders the html. Also sets the breadcrumb text based on the view.
*/
- var drawModal = function() {
+ var drawModal = function () {
var projection = models.proj.selected.id;
var modalView = config.parameters.modalView;
// If URL parameter is set, draw that type of modal view.
- switch(modalView) {
- case('categories'):
+ switch (modalView) {
+ case ('categories'):
crumbText = 'Categories';
drawCategories();
break;
- case('measurements'):
+ case ('measurements'):
crumbText = 'Measurements';
drawAllMeasurements();
break;
- case('layers'):
+ case ('layers'):
crumbText = 'Layers';
drawAllLayers();
break;
@@ -261,23 +257,22 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* @return {HTMLElement} Returns html to output measurements grouped by categories with
* categories grouped by interest.
*/
- var drawCategories = function() {
+ var drawCategories = function () {
$categories.empty();
- if( $categories.data('isotope') ) {
+ if ($categories.data('isotope')) {
$categories.isotope('destroy');
}
$allLayers.hide();
$nav.empty();
- Object.keys(config.categories).forEach(function(metaCategoryName) {
-
- Object.values(config.categories[metaCategoryName]).forEach(function(category) {
+ Object.keys(config.categories).forEach(function (metaCategoryName) {
+ Object.values(config.categories[metaCategoryName]).forEach(function (category) {
var sortNumber = 2;
var $i = 0;
// Check if categories have settings with the same projection.
hasMeasurement = false;
- Object.values(category.measurements).forEach(function(measurement) {
+ Object.values(category.measurements).forEach(function (measurement) {
hasMeasurementSource(config.measurements[measurement]);
});
@@ -310,7 +305,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
text: category.title,
'class': 'layer-category-name',
'alt': category.title
- }).click(function(e) {
+ }).click(function (e) {
drawMeasurements(category);
});
@@ -319,11 +314,11 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
var $measurements = $('<ul />');
- Object.values(category.measurements).forEach(function(measurement, index) {
+ Object.values(category.measurements).forEach(function (measurement, index) {
var projection = models.proj.selected.id;
var current = config.measurements[measurement];
// Check if measurements have settings with the same projection.
- if(hasMeasurementSource(current)) {
+ if (hasMeasurementSource(current)) {
$i++;
if ($i > 6) {
@@ -331,7 +326,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
}
if (config.measurements[measurement] === undefined) {
- throw new Error("Error: Measurement '" + measurement + "' stated in category '" + category.title + "' does not exist " + "in measurement list!");
+ throw new Error("Error: Measurement '" + measurement + "' stated in category '" + category.title + "' does not exist " + 'in measurement list!');
}
var $measurement = $('<a />', {
@@ -342,7 +337,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
'title': category.title + ' - ' + current.title
});
- $measurement.click(function(e) {
+ $measurement.click(function (e) {
drawMeasurements(category, current.id, index);
});
@@ -361,9 +356,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
});
$breadcrumb.show();
-
}
-
});
$categories.show();
@@ -373,12 +366,12 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
id: 'button-filter-' + interestCssName(metaCategoryName),
'data-filter': interestCssName(metaCategoryName),
'type': 'radio'
- }).click(function(e) {
+ }).click(function (e) {
$categories.isotope({
filter: '.layer-category-' + interestCssName(metaCategoryName)
});
$nav.find('.ui-button').removeClass('nav-selected');
- $("label[for=" + $(this).attr("id") + "]").addClass('nav-selected');
+ $('label[for=' + $(this).attr('id') + ']').addClass('nav-selected');
});
var $label = $('<label />', {
@@ -395,7 +388,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$categories.isotope({
itemSelector: '.layer-category',
- //stamp: '.stamp',
+ // stamp: '.stamp',
getSortData: {
name: '.layer-category-name', // text from querySelector
order: '[data-sort]'
@@ -426,7 +419,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* sources which contain settings. Each source has a description. Layers
* can be added to the map using a checkbox.
*/
- var drawMeasurements = function(category, selectedMeasurement, selectedIndex) {
+ var drawMeasurements = function (category, selectedMeasurement, selectedIndex) {
var projection = models.proj.selected.id;
var tabIndex;
var currentTab = -1;
@@ -437,10 +430,10 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
id: category.id + '-list'
});
// Begin Measurement Level
- Object.values(category.measurements).forEach(function(measurement) {
+ Object.values(category.measurements).forEach(function (measurement) {
var current = config.measurements[measurement];
// Check if measurements have settings with the same projection.
- if(hasMeasurementSource(current)) {
+ if (hasMeasurementSource(current)) {
currentTab++;
if (selectedMeasurement == current.id) {
tabIndex = currentTab;
@@ -465,9 +458,9 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$measurementContent.append($sourceTabs);
// Begin source level
- Object.values(current.sources).forEach(function(source) {
+ Object.values(current.sources).forEach(function (source) {
// Check if sources have settings with the same projection.
- if(hasMeasurementSetting(current, source)) {
+ if (hasMeasurementSetting(current, source)) {
var $sourceTab = $('<li />');
var $sourceLink = $('<a />', {
@@ -498,11 +491,11 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$showMore.append($moreElps);
- $showMore.toggle(function(e) {
+ $showMore.toggle(function (e) {
$sourceMeta.removeClass('overflow');
$moreElps.text('^').addClass('up');
redoScrollbar();
- }, function(e) {
+ }, function (e) {
$sourceMeta.addClass('overflow');
$moreElps.text('...').removeClass('up');
redoScrollbar();
@@ -510,7 +503,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
// Simple test to see if theres a link to some metadata
if (source.description) {
- $.get('config/metadata/' + source.description + '.html').success(function(data) {
+ $.get('config/metadata/' + source.description + '.html').success(function (data) {
$sourceMeta.html(data);
$sourceContent.append($sourceMeta);
@@ -531,11 +524,10 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
'class': 'source-orbit-tracks'
});
- Object.values(source.settings).forEach(function(setting) {
+ Object.values(source.settings).forEach(function (setting) {
var layer = config.layers[setting];
// If a setting matches the current projection, then output it.
if (layer && layer.id == setting && Object.keys(layer.projections).indexOf(projection) > -1) {
-
var $wrapper = $('<li />', {
'class': 'measurement-settings-item',
'data-layer': encodeURIComponent(layer.id),
@@ -552,7 +544,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
.on('ifUnchecked', removeLayer);
if (_.find(model.active, {id: layer.id})) {
- $setting.attr("checked", "checked");
+ $setting.attr('checked', 'checked');
}
var $label = $('<label />', {
@@ -563,10 +555,10 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$wrapper.append($setting).append($label);
// If this is an orbit track.... put it in the orbit track list
- if (layer.layergroup && layer.layergroup.indexOf("reference_orbits") !== -1) {
+ if (layer.layergroup && layer.layergroup.indexOf('reference_orbits') !== -1) {
var orbitTitle;
if (layer.daynight && layer.track) {
- orbitTitle = _.startCase(layer.track) + "/" + _.startCase(layer.daynight);
+ orbitTitle = _.startCase(layer.track) + '/' + _.startCase(layer.daynight);
}
$label.empty()
@@ -578,8 +570,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* set doesn't have the layergroup parameter set then use the
* layer title to determine if it is a Orbital Track.
*/
- } else if (layer.title.indexOf("Orbital Track") !== -1) {
-
+ } else if (layer.title.indexOf('Orbital Track') !== -1) {
// The following complex if statement is a placeholder
// for truncating the layer names, until the rest of
// the interface is implemented
@@ -594,7 +585,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
} else {
$sourceSettings.append($wrapper);
}
- $wrapper.click(function(e) {
+ $wrapper.click(function (e) {
e.stopPropagation();
var $checkbox = $(this).find('input#setting-' + layer.id);
@@ -615,7 +606,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$sourceContent.append($sourceOrbits);
}
- //$sourceContent.append( $addButton, $removeButton );
+ // $sourceContent.append( $addButton, $removeButton );
$measurementContent.append($sourceContent);
}
});
@@ -633,16 +624,16 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$categoryList.accordion({
collapsible: true,
- heightStyle: "content",
+ heightStyle: 'content',
animate: false,
active: false,
- activate: function(event, ui) {
+ activate: function (event, ui) {
redoScrollbar();
}
});
if (selectedMeasurement) {
- $categoryList.accordion("option", "active", tabIndex);
+ $categoryList.accordion('option', 'active', tabIndex);
}
$selectedCategory.append($categoryList);
@@ -667,7 +658,6 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$selectedCategory.show();
redoScrollbar();
$selectedCategory.iCheck({checkboxClass: 'icheckbox_square-red'});
-
};
/**
@@ -677,10 +667,10 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* @return {void} Returns a list of measurements with a dropdown containing
* sources which contain settings. Each source has a description.
*/
- var drawAllMeasurements = function() {
- Object.keys(config.categories).forEach(function(metaCategoryName) {
- Object.values(config.categories[metaCategoryName]).forEach(function(category) {
- if (category.id == "legacy-all") {
+ var drawAllMeasurements = function () {
+ Object.keys(config.categories).forEach(function (metaCategoryName) {
+ Object.values(config.categories[metaCategoryName]).forEach(function (category) {
+ if (category.id == 'legacy-all') {
drawMeasurements(category);
}
});
@@ -694,12 +684,12 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* @return {HTMLElement} Returns html with title, substitle, description and option to
* add layer to the map.
*/
- var drawAllLayers = function() {
+ var drawAllLayers = function () {
var projection = models.proj.selected.id;
- //Remove perfectScrollbar for the search list window
+ // Remove perfectScrollbar for the search list window
$('#layer-modal-main').perfectScrollbar('destroy');
- var props = {
+ var props = {
addLayer: model.add,
removeLayer: model.remove,
activeLayers: model.active,
@@ -707,7 +697,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
filteredLayers: getLayersForProjection(projection)
};
self.reactList = ReactDOM.render(
- React.createElement(WVC.LayerList , props),
+ React.createElement(WVC.LayerList, props),
$allLayers[0]
);
@@ -720,7 +710,6 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$breadcrumb.empty();
if (searchBool) {
-
var $homeCrumb = $('<a />', {
text: crumbText,
'alt': crumbText,
@@ -739,7 +728,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
}
};
- var interestCssName = function(name) {
+ var interestCssName = function (name) {
if (name === 'hazards and disasters') {
return 'legacy';
} else {
@@ -747,7 +736,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
}
};
- var interestLabelName = function(name) {
+ var interestLabelName = function (name) {
if (name === 'scientific') {
return 'science disciplines';
} else {
@@ -762,7 +751,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
* @param {string} $measurements The measurements contained within the category.
* @return {HTMLElement} Returns html to add the ellipsis to the category list.
*/
- var setCategoryOverflow = function(category, $measurements) {
+ var setCategoryOverflow = function (category, $measurements) {
var $dotContinueItem = $('<li />', {
'class': 'layer-category-item'
});
@@ -772,7 +761,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
'data-category': category.id
});
- $dotContinueLink.click(function(e) {
+ $dotContinueLink.click(function (e) {
drawMeasurements(category);
});
@@ -780,27 +769,27 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
$measurements.append($dotContinueItem);
};
- var addLayer = function(event) {
+ var addLayer = function (event) {
event.stopPropagation();
model.add(decodeURIComponent($(this).val()));
};
- var removeLayer = function(event) {
+ var removeLayer = function (event) {
event.stopPropagation();
model.remove(decodeURIComponent($(this).val()));
};
- var onLayerAdded = function(layer) {
+ var onLayerAdded = function (layer) {
var $element = $(self.selector + " [data-layer='" + wv.util.jqueryEscape(layer.id) + "']");
- $element.iCheck("check");
+ $element.iCheck('check');
};
- var onLayerRemoved = function(layer) {
+ var onLayerRemoved = function (layer) {
var $element = $(self.selector + " [data-layer='" + wv.util.jqueryEscape(layer.id) + "']");
- $element.iCheck("uncheck");
+ $element.iCheck('uncheck');
};
- var unfocusInput = function() {
+ var unfocusInput = function () {
if (!wv.util.browser.small) {
$('#layers-search-input').focus();
} else {
@@ -809,7 +798,7 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
}
};
- var render = function() {
+ var render = function () {
checkModalView();
setModalSize();
@@ -826,23 +815,23 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
var $searchBtn = $('<label />', {
'class': 'search-icon'
- }).click(function(e) {
+ }).click(function (e) {
var that = this;
- //TODO: Click for search icon
- }).append("<i />");
+ // TODO: Click for search icon
+ }).append('<i />');
- $search.append( $searchBtn )
- .append( $searchInput );
+ $search.append($searchBtn)
+ .append($searchInput);
- $header.append( $search );
+ $header.append($search);
var $closeButton = $('<div />', {
'id': 'layers-modal-close'
- }).click( function() {
- $( self.selector ).dialog( "close" );
+ }).click(function () {
+ $(self.selector).dialog('close');
}).append('<i></i>');
- $header.append ( $closeButton );
+ $header.append($closeButton);
$(self.selector).dialog({
autoOpen: false,
@@ -850,18 +839,18 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
height: modalHeight,
width: modalWidth,
modal: true,
- dialogClass: "layer-modal no-titlebar",
+ dialogClass: 'layer-modal no-titlebar',
draggable: false,
- title: "Layer Picker",
+ title: 'Layer Picker',
show: {
- effect: "fade",
+ effect: 'fade',
duration: 400
},
hide: {
- effect: "fade",
+ effect: 'fade',
duration: 200
},
- open: function(event, ui) {
+ open: function (event, ui) {
redo();
if ($categories.data('isotope')) {
$categories.isotope();
@@ -869,67 +858,66 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
redoScrollbar();
- $(".ui-widget-overlay").click(function(e) {
- $(self.selector).dialog("close");
+ $('.ui-widget-overlay').click(function (e) {
+ $(self.selector).dialog('close');
});
- //fade in time for show is 400 above, so after that
+ // fade in time for show is 400 above, so after that
setTimeout(unfocusInput, 410);
-
},
- close: function( event, ui ) {
- $( ".ui-widget-overlay" ).unbind( "click" );
+ close: function (event, ui) {
+ $('.ui-widget-overlay').unbind('click');
}
});
- //$(self.selector + "select").on('change', filter);
- $searchInput.keyup( filter );
+ // $(self.selector + "select").on('change', filter);
+ $searchInput.keyup(filter);
drawDefaultPage();
};
- //returns each term from search field
- var searchTerms = function() {
- var search = $("#layers-search-input").val().toLowerCase();
+ // returns each term from search field
+ var searchTerms = function () {
+ var search = $('#layers-search-input').val().toLowerCase();
var terms = search.split(/ +/);
return terms;
};
- var filterAreaOfInterest = function(layerId) {
- if ( !config.aoi ) {
+ var filterAreaOfInterest = function (layerId) {
+ if (!config.aoi) {
return false;
}
- var aoi = $(self.selector + "select").val();
- if ( aoi === "All" ) {
+ var aoi = $(self.selector + 'select').val();
+ if (aoi === 'All') {
return false;
}
return $.inArray(layerId, config.aoi[aoi].baselayers) < 0 &&
$.inArray(layerId, config.aoi[aoi].overlays) < 0;
};
- var filterProjections = function(layer) {
+ var filterProjections = function (layer) {
return !layer.projections[models.proj.selected.id];
};
- //Takes the terms and returns true if the layer isnt part of search
- var filterSearch = function(layer, terms) {
- var search = $(self.selector + "search").val();
- if ( search === '' ) return false;
+ // Takes the terms and returns true if the layer isnt part of search
+ var filterSearch = function (layer, terms) {
+ var search = $(self.selector + 'search').val();
+ if (search === '') return false;
var filtered = false;
var names = models.layers.getTitles(layer.id);
- $.each(terms, function(index, term) {
+ $.each(terms, function (index, term) {
filtered = !names.title.toLowerCase().contains(term) &&
!names.subtitle.toLowerCase().contains(term) &&
!names.tags.toLowerCase().contains(term) &&
!config.layers[layer.id].id.toLowerCase().contains(term);
- if ( filtered ) return false;
+ if (filtered) return false;
});
return filtered;
};
- var runSearch = function() {
+ var runSearch = function () {
var search = searchTerms();
- var filteredLayers = allLayers.filter(function(layer){
+ var filteredLayers = allLayers.filter(function (layer) {
return !(filterProjections(layer) || filterSearch(layer, search));
});
self.reactList.setState({
@@ -937,11 +925,10 @@ wv.layers.modal = wv.layers.modal || function(models, ui, config) {
});
};
- var filter = function(e) {
+ var filter = function (e) {
if ($('#layers-search-input').val().length !== 0) {
searchBool = true;
- }
- else{
+ } else {
searchBool = false;
drawModal();
removeSearch();
diff --git a/web/js/layers/wv.layers.model.js b/web/js/layers/wv.layers.model.js
index 0bd13389f..7fdcb3a10 100644
--- a/web/js/layers/wv.layers.model.js
+++ b/web/js/layers/wv.layers.model.js
@@ -7,8 +7,7 @@ wv.layers = wv.layers || {};
/**
* @class wv.layers.model
*/
-wv.layers.model = wv.layers.model || function(models, config) {
-
+wv.layers.model = wv.layers.model || function (models, config) {
var self = {};
var split = 0;
@@ -16,42 +15,42 @@ wv.layers.model = wv.layers.model || function(models, config) {
self.active = [];
- var init = function() {
+ var init = function () {
self.reset();
};
- self.reset = function() {
+ self.reset = function () {
self.clear();
if (config.defaults && config.defaults.startingLayers) {
- _.each(config.defaults.startingLayers, function(start) {
+ _.each(config.defaults.startingLayers, function (start) {
self.add(start.id, start);
});
}
};
- self.get = function(spec) {
+ self.get = function (spec) {
spec = spec || {};
- var baselayers = forGroup("baselayers", spec);
- var overlays = forGroup("overlays", spec);
- if (spec.group === "baselayers") {
+ var baselayers = forGroup('baselayers', spec);
+ var overlays = forGroup('overlays', spec);
+ if (spec.group === 'baselayers') {
return baselayers;
}
- if (spec.group === "overlays") {
+ if (spec.group === 'overlays') {
return overlays;
}
- if (spec.group === "all") {
+ if (spec.group === 'all') {
return {
baselayers: baselayers,
overlays: overlays
};
}
if (spec.group) {
- throw new Error("Invalid layer group: " + spec.group);
+ throw new Error('Invalid layer group: ' + spec.group);
}
return baselayers.concat(overlays);
};
- self.getTitles = function(layerId, proj) {
+ self.getTitles = function (layerId, proj) {
proj = proj || models.proj.selected.id;
var title, subtitle;
if (config.layers[layerId].projections[proj]) {
@@ -61,9 +60,9 @@ wv.layers.model = wv.layers.model || function(models, config) {
tags = forProj.tags;
}
var forLayer = config.layers[layerId];
- title = title || forLayer.title || "[" + layerId + "]";
- subtitle = subtitle || forLayer.subtitle || "";
- tags = tags || forLayer.tags || "";
+ title = title || forLayer.title || '[' + layerId + ']';
+ subtitle = subtitle || forLayer.subtitle || '';
+ tags = tags || forLayer.tags || '';
return {
title: title,
subtitle: subtitle,
@@ -71,7 +70,7 @@ wv.layers.model = wv.layers.model || function(models, config) {
};
};
- self.available = function(id) {
+ self.available = function (id) {
var range = self.dateRange({
layer: id
});
@@ -86,24 +85,23 @@ wv.layers.model = wv.layers.model || function(models, config) {
// Takes a layer id and returns a true or false value
// if the layer exists in the active layer list
- self.exists = function(layer) {
+ self.exists = function (layer) {
var found = false;
- _.each(self.active, function(current) {
+ _.each(self.active, function (current) {
if (layer === current.id) {
found = true;
- return;
}
});
return found;
};
- self.dateRange = function(spec) {
+ self.dateRange = function (spec) {
spec = spec || {};
var projId = spec.projId || models.proj.selected.id;
var layers = (spec.layer) ? [_.find(self.active, {
id: spec.layer
- })] :
- self.active;
+ })]
+ : self.active;
var ignoreRange =
config.parameters &&
(config.parameters.debugGIBS || config.parameters.ignoreDateRange);
@@ -116,7 +114,7 @@ wv.layers.model = wv.layers.model || function(models, config) {
var min = Number.MAX_VALUE;
var max = 0;
var range = false;
- _.each(layers, function(def) {
+ _.each(layers, function (def) {
if (def.startDate) {
range = true;
var start = wv.util.parseDateUTC(def.startDate)
@@ -155,7 +153,7 @@ wv.layers.model = wv.layers.model || function(models, config) {
}
};
- self.add = function(id, spec) {
+ self.add = function (id, spec) {
if (_.find(self.active, {
id: id
})) {
@@ -164,7 +162,7 @@ wv.layers.model = wv.layers.model || function(models, config) {
spec = spec || {};
var def = config.layers[id];
if (!def) {
- throw new Error("No such layer: " + id);
+ throw new Error('No such layer: ' + id);
}
def.visible = true;
if (!_.isUndefined(spec.visible)) {
@@ -173,17 +171,17 @@ wv.layers.model = wv.layers.model || function(models, config) {
def.visible = !spec.hidden;
}
def.opacity = (_.isUndefined(spec.opacity)) ? 1.0 : spec.opacity;
- if (def.group === "overlays") {
+ if (def.group === 'overlays') {
self.active.unshift(def);
split += 1;
} else {
self.active.splice(split, 0, def);
}
- self.events.trigger("add", def);
- self.events.trigger("change");
+ self.events.trigger('add', def);
+ self.events.trigger('change');
};
- self.remove = function(id) {
+ self.remove = function (id) {
var index = _.findIndex(self.active, {
id: id
});
@@ -193,12 +191,12 @@ wv.layers.model = wv.layers.model || function(models, config) {
if (index < split) {
split -= 1;
}
- self.events.trigger("remove", def);
- self.events.trigger("change");
+ self.events.trigger('remove', def);
+ self.events.trigger('change');
}
};
- self.replace = function(idOld, idNew) {
+ self.replace = function (idOld, idNew) {
var index = _.findIndex(self.active, {
id: idOld
});
@@ -210,44 +208,44 @@ wv.layers.model = wv.layers.model || function(models, config) {
newDef.visible = true;
newDef.opacity = 1.0;
self.active[index] = newDef;
- self.events.trigger("update");
- self.events.trigger("change");
+ self.events.trigger('update');
+ self.events.trigger('change');
};
- self.clear = function(projId) {
+ self.clear = function (projId) {
projId = projId || models.proj.selected.id;
var defs = self.active.slice(0);
- _.each(defs, function(def) {
+ _.each(defs, function (def) {
if (projId && def.projections[projId]) {
self.remove(def.id);
}
});
};
- self.pushToBottom = function(id) {
+ self.pushToBottom = function (id) {
var oldIndex = _.findIndex(self.active, {
id: id
});
if (oldIndex < 0) {
- throw new Error("Layer is not active: " + id);
+ throw new Error('Layer is not active: ' + id);
}
var def = self.active[oldIndex];
self.active.splice(oldIndex, 1);
- if (def.group === "baselayers") {
+ if (def.group === 'baselayers') {
self.active.push(def);
} else {
self.active.splice(split - 1, 0, def);
}
- self.events.trigger("update");
- self.events.trigger("change");
+ self.events.trigger('update');
+ self.events.trigger('change');
};
- self.moveBefore = function(sourceId, targetId) {
+ self.moveBefore = function (sourceId, targetId) {
var sourceIndex = _.findIndex(self.active, {
id: sourceId
});
if (sourceIndex < 0) {
- throw new Error("Layer is not active: " + source);
+ throw new Error('Layer is not active: ' + source);
}
var sourceDef = self.active[sourceIndex];
@@ -255,7 +253,7 @@ wv.layers.model = wv.layers.model || function(models, config) {
id: targetId
});
if (targetIndex < 0) {
- throw new Error("Layer is not active: " + target);
+ throw new Error('Layer is not active: ' + target);
}
self.active.splice(targetIndex, 0, sourceDef);
@@ -263,33 +261,33 @@ wv.layers.model = wv.layers.model || function(models, config) {
sourceIndex++;
}
self.active.splice(sourceIndex, 1);
- self.events.trigger("update", sourceDef, targetIndex);
- self.events.trigger("change");
+ self.events.trigger('update', sourceDef, targetIndex);
+ self.events.trigger('change');
};
- self.setVisibility = function(id, visible) {
+ self.setVisibility = function (id, visible) {
var def = _.find(self.active, {
id: id
});
if (def.visible !== visible) {
def.visible = visible;
- self.events.trigger("visibility", def, visible);
- self.events.trigger("change");
+ self.events.trigger('visibility', def, visible);
+ self.events.trigger('change');
}
};
- self.setOpacity = function(id, opacity) {
+ self.setOpacity = function (id, opacity) {
var def = _.find(self.active, {
id: id
});
if (def.opacity !== opacity) {
def.opacity = opacity;
- self.events.trigger("opacity", def, opacity);
- self.events.trigger("change");
+ self.events.trigger('opacity', def, opacity);
+ self.events.trigger('change');
}
};
- self.isRenderable = function(id) {
+ self.isRenderable = function (id) {
var def = _.find(self.active, {
id: id
});
@@ -302,13 +300,13 @@ wv.layers.model = wv.layers.model || function(models, config) {
if (!def.visible || def.opacity === 0) {
return false;
}
- if (def.group === "overlays") {
+ if (def.group === 'overlays') {
return true;
}
var obscured = false;
_.each(self.get({
- group: "baselayers"
- }), function(otherDef) {
+ group: 'baselayers'
+ }), function (otherDef) {
if (otherDef.id === def.id) {
return false;
}
@@ -321,10 +319,10 @@ wv.layers.model = wv.layers.model || function(models, config) {
return !obscured;
};
- self.save = function(state) {
+ self.save = function (state) {
var defs = self.get();
state.l = state.l || [];
- _.each(self.get(), function(def) {
+ _.each(self.get(), function (def) {
var lstate = _.find(state.l, {
id: def.id
});
@@ -339,37 +337,37 @@ wv.layers.model = wv.layers.model || function(models, config) {
}
if (!def.visible) {
lstate.attributes.push({
- id: "hidden"
+ id: 'hidden'
});
}
if (def.opacity < 1) {
lstate.attributes.push({
- id: "opacity",
+ id: 'opacity',
value: def.opacity
});
}
});
};
- self.load = function(state, errors) {
+ self.load = function (state, errors) {
if (!_.isUndefined(state.l)) {
self.clear(models.proj.selected.id);
- _.eachRight(state.l, function(layerDef) {
+ _.eachRight(state.l, function (layerDef) {
if (!config.layers[layerDef.id]) {
errors.push({
- message: "No such layer: " + layerDef.id
+ message: 'No such layer: ' + layerDef.id
});
return;
}
var hidden = false;
var opacity = 1.0;
- _.each(layerDef.attributes, function(attr) {
- if (attr.id === "hidden") {
+ _.each(layerDef.attributes, function (attr) {
+ if (attr.id === 'hidden') {
hidden = true;
}
- if (attr.id === "opacity") {
+ if (attr.id === 'opacity') {
opacity = wv.util.clamp(parseFloat(attr.value), 0, 1);
- if (isNaN(opacity)) opacity = 0; //"opacity=0.0" is opacity in URL, resulting in NaN
+ if (isNaN(opacity)) opacity = 0; // "opacity=0.0" is opacity in URL, resulting in NaN
}
});
self.add(layerDef.id, {
@@ -380,19 +378,19 @@ wv.layers.model = wv.layers.model || function(models, config) {
}
};
- var forGroup = function(group, spec) {
+ var forGroup = function (group, spec) {
spec = spec || {};
var projId = spec.proj || models.proj.selected.id;
var results = [];
var defs = _.filter(self.active, {
group: group
});
- _.each(defs, function(def) {
+ _.each(defs, function (def) {
// Skip if this layer isn't available for the selected projection
if (!def.projections[projId]) {
return;
}
- if (spec.dynamic && def.period !== "daily") {
+ if (spec.dynamic && def.period !== 'daily') {
return;
}
if (spec.renderable && !self.isRenderable(def.id)) {
@@ -411,5 +409,4 @@ wv.layers.model = wv.layers.model || function(models, config) {
init();
return self;
-
};
diff --git a/web/js/layers/wv.layers.options.js b/web/js/layers/wv.layers.options.js
index 7bf9e3b82..59f02089d 100644
--- a/web/js/layers/wv.layers.options.js
+++ b/web/js/layers/wv.layers.options.js
@@ -1,9 +1,8 @@
var wv = wv || {};
wv.layers = wv.layers || {};
-wv.layers.options = wv.layers.options || function(config, models, layer) {
-
- var alignTo = "#products";
+wv.layers.options = wv.layers.options || function (config, models, layer) {
+ var alignTo = '#products';
var $dialog;
var $opacity;
var $range;
@@ -13,8 +12,8 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
var palettes;
var index = 0;
- var init = function() {
- canvas = document.createElement("canvas");
+ var init = function () {
+ canvas = document.createElement('canvas');
canvas.width = 120;
canvas.height = 10;
if (config.features.customPalettes) {
@@ -25,31 +24,31 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
}
};
- var loaded = function(custom) {
+ var loaded = function (custom) {
$dialog = wv.ui.getDialog();
$dialog
- .attr("id", "wv-layers-options-dialog")
- .attr("data-layer", layer.id);
+ .attr('id', 'wv-layers-options-dialog')
+ .attr('data-layer', layer.id);
renderOpacity($dialog);
if (config.features.customPalettes) {
if (models.palettes.allowed(layer.id) &&
(models.palettes.getLegends(layer.id)
.length < 2)) {
- //TODO: Dual Colormap options
- /*if ( models.palettes.getLegends(layer.id).length > 1 ) {
+ // TODO: Dual Colormap options
+ /* if ( models.palettes.getLegends(layer.id).length > 1 ) {
renderLegendButtons($dialog);
- }*/
+ } */
var legend = models.palettes.getLegend(layer.id, index);
- if ((legend.type === "continuous") ||
- (legend.type === "discrete")) {
+ if ((legend.type === 'continuous') ||
+ (legend.type === 'discrete')) {
renderRange($dialog);
- if (config.layers[layer.id].type !== "wms") {
+ if (config.layers[layer.id].type !== 'wms') {
renderPaletteSelector($dialog);
}
} else if (models.palettes.getDefaultLegend(layer.id, index)
.colors.length === 1) {
- if (config.layers[layer.id].type !== "wms") {
+ if (config.layers[layer.id].type !== 'wms') {
renderPaletteSelector($dialog);
}
}
@@ -57,45 +56,45 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
}
var names = models.layers.getTitles(layer.id);
$dialog.dialog({
- dialogClass: "wv-panel",
+ dialogClass: 'wv-panel',
title: names.title,
show: {
- effect: "slide",
- direction: "left"
+ effect: 'slide',
+ direction: 'left'
},
width: 300,
- height: "auto",
+ height: 'auto',
resizable: false,
draggable: false,
position: {
- my: "left top",
- at: "right+5 top",
- of: $("#products")
+ my: 'left top',
+ at: 'right+5 top',
+ of: $('#products')
},
close: dispose
});
- $("#wv-squash-button-check")
- .addClass("custom-check");
- $("#wv-palette-selector")
- .addClass("custom-check");
- $("#wv-layers-options-dialog .custom-check")
+ $('#wv-squash-button-check')
+ .addClass('custom-check');
+ $('#wv-palette-selector')
+ .addClass('custom-check');
+ $('#wv-layers-options-dialog .custom-check')
.iCheck({
radioClass: 'iradio_square-grey',
checkboxClass: 'icheckbox_square-grey'
});
- $("#wv-layers-options-dialog #wv-palette-selector")
- .each(function() {
+ $('#wv-layers-options-dialog #wv-palette-selector')
+ .each(function () {
$(this)
.perfectScrollbar('update');
});
- $("#wv-squash-button-check")
- .on("ifChanged", function() {
- var squash = $("#wv-squash-button-check")
- .prop("checked");
- //var $slider = $("#wv-range-slider");
+ $('#wv-squash-button-check')
+ .on('ifChanged', function () {
+ var squash = $('#wv-squash-button-check')
+ .prop('checked');
+ // var $slider = $("#wv-range-slider");
var $slider = $range;
models.palettes.setRange(layer.id,
parseFloat($slider.val()[0]),
@@ -105,44 +104,44 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
});
models.layers.events
- .on("remove", onLayerRemoved)
- .on("opacity", onOpacityUpdate);
+ .on('remove', onLayerRemoved)
+ .on('opacity', onOpacityUpdate);
models.palettes.events
- .on("range", onRangeUpdate)
- .on("update", onPaletteUpdateAll);
+ .on('range', onRangeUpdate)
+ .on('update', onPaletteUpdateAll);
};
- var dispose = function() {
+ var dispose = function () {
models.layers.events
- .off("remove", onLayerRemoved)
- .off("opacity", onOpacityUpdate);
+ .off('remove', onLayerRemoved)
+ .off('opacity', onOpacityUpdate);
models.palettes.events
- .off("range", onRangeUpdate)
- .off("update", onPaletteUpdateAll);
+ .off('range', onRangeUpdate)
+ .off('update', onPaletteUpdateAll);
$dialog = null;
wv.ui.closeDialog();
};
- var renderOpacity = function($dialog) {
- var $header = $("<div></div>")
- .html("Opacity")
- .addClass("wv-header");
- var $slider = $("<div></div>")
+ var renderOpacity = function ($dialog) {
+ var $header = $('<div></div>')
+ .html('Opacity')
+ .addClass('wv-header');
+ var $slider = $('<div></div>')
.noUiSlider({
start: layer.opacity,
step: 0.01,
range: {
min: 0,
max: 1
- },
+ }
})
- .on("slide", function() {
+ .on('slide', function () {
models.layers.setOpacity(layer.id, parseFloat($(this)
.val()));
});
- var $label = $("<div></div>")
- .addClass("wv-label")
- .addClass("wv-label-opacity");
+ var $label = $('<div></div>')
+ .addClass('wv-label')
+ .addClass('wv-label-opacity');
$dialog.append($header);
$dialog.append($slider);
$dialog.append($label);
@@ -150,36 +149,35 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
onOpacityUpdate(layer, layer.opacity);
};
- var onOpacityUpdate = function(def, opacity) {
+ var onOpacityUpdate = function (def, opacity) {
if (def.id !== layer.id) {
return;
}
var label = (opacity * 100)
- .toFixed(0) + "%";
- $("#wv-layers-options-dialog .wv-label-opacity")
+ .toFixed(0) + '%';
+ $('#wv-layers-options-dialog .wv-label-opacity')
.html(label);
if ($opacity.val() !== opacity) {
$opacity.val(opacity);
}
};
- var renderLegendButtons = function($dialog) {
- var $panel = $("<div></div>")
- .addClass("wv-legend-buttons");
+ var renderLegendButtons = function ($dialog) {
+ var $panel = $('<div></div>')
+ .addClass('wv-legend-buttons');
var legends = models.palettes.getLegends(layer.id);
- _.each(legends, function(legend, index) {
-
- id = "wv-legend-" + index;
+ _.each(legends, function (legend, index) {
+ id = 'wv-legend-' + index;
$panel.append("<input type='radio' id='" + id + "' " +
"name='legend' value='" + index + "'>" +
- "<label for='" + id + "'>" + legend.title + "</label>");
+ "<label for='" + id + "'>" + legend.title + '</label>');
});
$panel.buttonset();
$dialog.append($panel);
$(".wv-legend-buttons input[type='radio']")
- .change(function() {
+ .change(function () {
index = _.parseInt($(this)
.val());
rerenderRange();
@@ -187,39 +185,39 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
});
};
- var renderRange = function() {
- var $header = $("<div></div>")
- .html("Thresholds")
- .addClass("wv-header");
-
- var $squash = $("<div></div>")
- .addClass("wv-palette-squash");
- var $squashButton = $("<input></input>")
- .attr("type", "checkbox")
- .attr("id", "wv-squash-button-check");
- var $squashLabel = $("<label></label>")
- .attr("for", "wv-squash-button-check")
- .attr("title", "Squash Palette")
- .html("Squash Palette");
+ var renderRange = function () {
+ var $header = $('<div></div>')
+ .html('Thresholds')
+ .addClass('wv-header');
+
+ var $squash = $('<div></div>')
+ .addClass('wv-palette-squash');
+ var $squashButton = $('<input></input>')
+ .attr('type', 'checkbox')
+ .attr('id', 'wv-squash-button-check');
+ var $squashLabel = $('<label></label>')
+ .attr('for', 'wv-squash-button-check')
+ .attr('title', 'Squash Palette')
+ .html('Squash Palette');
$squash.append($squashButton)
.append($squashLabel);
- var $panel = $("<div></div>")
- .addClass("wv-layer-options-threshold");
+ var $panel = $('<div></div>')
+ .addClass('wv-layer-options-threshold');
$dialog.append($header);
$dialog.append($squash);
$dialog.append($panel);
rerenderRange();
};
- var rerenderRange = function() {
+ var rerenderRange = function () {
var legend = models.palettes.get(layer.id, index);
var max = legend.entries.values.length - 1;
var startMin = legend.min || 0;
var startMax = legend.max || max;
- var $slider = $("<div></div>")
+ var $slider = $('<div></div>')
.noUiSlider({
start: [startMin, startMax],
step: 1,
@@ -228,9 +226,9 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
max: max
}
})
- .on("set", function() {
- var squash = $("#wv-squash-button-check")
- .prop("checked");
+ .on('set', function () {
+ var squash = $('#wv-squash-button-check')
+ .prop('checked');
models.palettes.setRange(layer.id,
parseFloat($(this)
.val()[0]),
@@ -239,21 +237,21 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
squash,
index);
})
- .on("slide", function() {
+ .on('slide', function () {
updateRangeLabels(
parseFloat($(this)
.val()[0]),
parseFloat($(this)
.val()[1]));
});
- var $label = $("<div>&nbsp;</div>")
- .addClass("wv-label");
- $label.append($("<span></span>")
- .addClass("wv-label-range-min"));
- $label.append($("<span></span>")
- .addClass("wv-label-range-max"));
-
- $(".wv-layer-options-threshold")
+ var $label = $('<div>&nbsp;</div>')
+ .addClass('wv-label');
+ $label.append($('<span></span>')
+ .addClass('wv-label-range-min'));
+ $label.append($('<span></span>')
+ .addClass('wv-label-range-max'));
+
+ $('.wv-layer-options-threshold')
.empty()
.append($slider)
.append($label);
@@ -263,69 +261,69 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
onRangeUpdate();
};
- var onRangeUpdate = function() {
+ var onRangeUpdate = function () {
updateRangeLabels();
var palette = models.palettes.get(layer.id, index);
var imin = (_.isUndefined(palette.min)) ? 0 : palette.min;
- var imax = (_.isUndefined(palette.max)) ?
- palette.legend.tooltips.length - 1 : palette.max;
+ var imax = (_.isUndefined(palette.max))
+ ? palette.legend.tooltips.length - 1 : palette.max;
current = [parseFloat($range.val()[0]), parseFloat($range.val()[1])];
if (!_.isEqual(current, [imin, imax])) {
$range.val([imin, imax]);
}
if (palette.squash) {
- $("#wv-squash-button-check")
- .iCheck("check");
+ $('#wv-squash-button-check')
+ .iCheck('check');
} else {
- $("#wv-squash-button-check")
- .iCheck("uncheck");
+ $('#wv-squash-button-check')
+ .iCheck('uncheck');
}
};
- var updateRangeLabels = function(min, max) {
+ var updateRangeLabels = function (min, max) {
var palette = models.palettes.get(layer.id, index);
var legend = models.palettes.getLegend(layer.id, index);
min = min || palette.min || 0;
max = max || palette.max || legend.tooltips.length - 1;
- var minLabel = (legend.units) ? legend.tooltips[min] + " " + legend.units : legend.tooltips[min];
- var maxLabel = (legend.units) ? legend.tooltips[max] + " " + legend.units : legend.tooltips[max];
- $("#wv-layers-options-dialog .wv-label-range-min")
+ var minLabel = (legend.units) ? legend.tooltips[min] + ' ' + legend.units : legend.tooltips[min];
+ var maxLabel = (legend.units) ? legend.tooltips[max] + ' ' + legend.units : legend.tooltips[max];
+ $('#wv-layers-options-dialog .wv-label-range-min')
.html(minLabel);
- $("#wv-layers-options-dialog .wv-label-range-max")
+ $('#wv-layers-options-dialog .wv-label-range-max')
.html(maxLabel);
};
- var onPaletteUpdateAll = function() {
+ var onPaletteUpdateAll = function () {
onRangeUpdate();
onPaletteUpdate();
};
- var renderPaletteSelector = function($dialog) {
- var $header = $("<div></div>")
- .addClass("wv-header")
- .addClass("wv-color-palette-label")
- .html("Color Palette");
- var $pane = $("<div></div>")
- .attr("id", "wv-palette-selector");
+ var renderPaletteSelector = function ($dialog) {
+ var $header = $('<div></div>')
+ .addClass('wv-header')
+ .addClass('wv-color-palette-label')
+ .html('Color Palette');
+ var $pane = $('<div></div>')
+ .attr('id', 'wv-palette-selector');
$dialog.append($header)
.append($pane);
rerenderPaletteSelector(true);
};
- var rerenderPaletteSelector = function(firstTime) {
- var $pane = $("#wv-palette-selector")
+ var rerenderPaletteSelector = function (firstTime) {
+ var $pane = $('#wv-palette-selector')
.empty();
$pane.append(defaultLegend());
var recommended = layer.palette.recommended || [];
- _.each(recommended, function(id) {
+ _.each(recommended, function (id) {
var item = customLegend(id);
if (item) {
$pane.append(item);
}
});
- _.each(config.paletteOrder, function(id) {
+ _.each(config.paletteOrder, function (id) {
if (_.indexOf(recommended, id) < 0) {
var item = customLegend(id);
if (item) {
@@ -340,19 +338,19 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
if (palette.custom) {
$(".wv-palette-selector-row input[data-palette='" +
palette.custom + "']")
- .iCheck("check");
+ .iCheck('check');
} else {
$(".wv-palette-selector-row input[data-palette='__default']")
- .iCheck("check");
+ .iCheck('check');
}
- $("#wv-palette-selector input")
- .on("ifChecked", function() {
+ $('#wv-palette-selector input')
+ .on('ifChecked', function () {
var that = this;
- setTimeout(function() {
+ setTimeout(function () {
var id = $(that)
- .attr("data-palette");
- if (id === "__default") {
+ .attr('data-palette');
+ if (id === '__default') {
models.palettes.clearCustom(layer.id, index);
} else {
models.palettes.setCustom(layer.id, id, index);
@@ -361,41 +359,41 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
});
if (!firstTime) {
- $("#wv-palette-selector")
+ $('#wv-palette-selector')
.iCheck({
radioClass: 'iradio_square-grey'
});
}
};
- var onPaletteUpdate = function() {
+ var onPaletteUpdate = function () {
var palette = models.palettes.get(layer.id, index);
if (palette.custom) {
$("#wv-palette-selector input[data-palette='" + palette.custom + "']")
- .iCheck("check");
+ .iCheck('check');
} else {
$("#wv-palette-selector input[data-palette='__default']")
- .iCheck("check");
+ .iCheck('check');
}
};
- var selectorItemScale = function(palette, id, description) {
+ var selectorItemScale = function (palette, id, description) {
wv.palettes.colorbar(canvas, palette);
- var $row = $("<div></div>")
- .addClass("wv-palette-selector-row");
- var $radio = $("<input></input>")
- .attr("type", "radio")
- .attr("id", "wv-palette-radio-" + id)
- .attr("name", "wv-palette-radio")
- .attr("data-palette", id);
-
- var $label = $("<label></label>")
- .attr("for", "wv-palette-radio-" + id);
- var $image = $("<img></img>")
- .attr("src", canvas.toDataURL("image/png"));
- var $description = $("<span></span>")
- .addClass("wv-palette-label")
+ var $row = $('<div></div>')
+ .addClass('wv-palette-selector-row');
+ var $radio = $('<input></input>')
+ .attr('type', 'radio')
+ .attr('id', 'wv-palette-radio-' + id)
+ .attr('name', 'wv-palette-radio')
+ .attr('data-palette', id);
+
+ var $label = $('<label></label>')
+ .attr('for', 'wv-palette-radio-' + id);
+ var $image = $('<img></img>')
+ .attr('src', canvas.toDataURL('image/png'));
+ var $description = $('<span></span>')
+ .addClass('wv-palette-label')
.html(description);
$label.append($image);
$label.append($description);
@@ -406,25 +404,25 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
return $row;
};
- var selectorItemSingle = function(palette, id, description) {
- var $row = $("<div></div>")
- .addClass("wv-palette-selector-row");
- var $radio = $("<input></input>")
- .attr("type", "radio")
- .attr("id", "wv-palette-radio-" + id)
- .attr("name", "wv-palette-radio")
- .attr("data-palette", id);
+ var selectorItemSingle = function (palette, id, description) {
+ var $row = $('<div></div>')
+ .addClass('wv-palette-selector-row');
+ var $radio = $('<input></input>')
+ .attr('type', 'radio')
+ .attr('id', 'wv-palette-radio-' + id)
+ .attr('name', 'wv-palette-radio')
+ .attr('data-palette', id);
var color = (palette.classes) ? palette.classes.colors[0] : palette.colors[0];
- var $label = $("<label></label>")
- .attr("for", "wv-palette-radio-" + id);
- var $image = $("<span></span>")
- .addClass("wv-palettes-class")
- .css("background-color", wv.util.hexToRGB(color))
- .html("&nbsp;");
- var $description = $("<span></span>")
+ var $label = $('<label></label>')
+ .attr('for', 'wv-palette-radio-' + id);
+ var $image = $('<span></span>')
+ .addClass('wv-palettes-class')
+ .css('background-color', wv.util.hexToRGB(color))
+ .html('&nbsp;');
+ var $description = $('<span></span>')
.html(description)
- .addClass("wv-palette-label");
+ .addClass('wv-palette-label');
$label.append($image);
$label.append($description);
@@ -434,38 +432,37 @@ wv.layers.options = wv.layers.options || function(config, models, layer) {
return $row;
};
- var defaultLegend = function() {
+ var defaultLegend = function () {
var legend = models.palettes.getDefaultLegend(layer.id, index);
- if ((legend.type === "continuous") || (legend.type === "discrete")) {
- return selectorItemScale(legend.colors, "__default", "Default");
+ if ((legend.type === 'continuous') || (legend.type === 'discrete')) {
+ return selectorItemScale(legend.colors, '__default', 'Default');
} else {
- return selectorItemSingle(legend, "__default", "Default");
+ return selectorItemSingle(legend, '__default', 'Default');
}
};
- var customLegend = function(id) {
+ var customLegend = function (id) {
var source = models.palettes.getDefaultLegend(layer.id, index);
var target = models.palettes.getCustom(id);
- var targetType = (target.colors.length === 1) ? "classification" : "continuous";
+ var targetType = (target.colors.length === 1) ? 'classification' : 'continuous';
- if ((source.type === "continuous" && targetType === "continuous") ||
- (source.type === "discrete" && targetType === "continuous")) {
+ if ((source.type === 'continuous' && targetType === 'continuous') ||
+ (source.type === 'discrete' && targetType === 'continuous')) {
var translated = wv.palettes.translate(source.colors,
target.colors);
return selectorItemScale(translated, id, target.name);
}
- if (source.type === "classification" && targetType === "classification") {
+ if (source.type === 'classification' && targetType === 'classification') {
return selectorItemSingle(target, id, target.name);
}
};
- var onLayerRemoved = function(removedLayer) {
+ var onLayerRemoved = function (removedLayer) {
if (layer.id === removedLayer.id && $dialog) {
- $dialog.dialog("close");
+ $dialog.dialog('close');
}
};
init();
return self;
-
};
diff --git a/web/js/layers/wv.layers.sidebar.js b/web/js/layers/wv.layers.sidebar.js
index 86e363959..2b0859031 100644
--- a/web/js/layers/wv.layers.sidebar.js
+++ b/web/js/layers/wv.layers.sidebar.js
@@ -7,50 +7,48 @@ wv.layers = wv.layers || {};
/**
* @class wv.layers.sidebar
*/
-wv.layers.sidebar = wv.layers.sidebar || function(models, config) {
-
+wv.layers.sidebar = wv.layers.sidebar || function (models, config) {
var collapsed = false;
var collapseRequested = false;
var productsIsOverflow = false;
var mobile = false;
var self = {};
- self.id = "productsHolder";
- self.selector = "#productsHolder";
+ self.id = 'productsHolder';
+ self.selector = '#productsHolder';
self.events = wv.util.events();
- var init = function() {
+ var init = function () {
render();
$(window)
.resize(resize);
- models.proj.events.on("select", onProjectionChange);
+ models.proj.events.on('select', onProjectionChange);
resize();
if (wv.util.browser.localStorage) {
- if (localStorage.getItem("sidebarState") === "collapsed") {
+ if (localStorage.getItem('sidebarState') === 'collapsed') {
self.collapseNow();
collapseRequested = true;
}
}
};
- self.selectTab = function(tabName) {
-
- if (tabName === "active") {
+ self.selectTab = function (tabName) {
+ if (tabName === 'active') {
$(self.selector)
- .tabs("option", "active", 0);
- } else if (tabName === "events") {
+ .tabs('option', 'active', 0);
+ } else if (tabName === 'events') {
$(self.selector)
- .tabs("option", "active", 1);
- } else if (tabName === "download") {
+ .tabs('option', 'active', 1);
+ } else if (tabName === 'download') {
$(self.selector)
- .tabs("option", "active", 2);
+ .tabs('option', 'active', 2);
} else {
- throw new Error("Invalid tab: " + tabName);
+ throw new Error('Invalid tab: ' + tabName);
}
};
- self.collapse = function(now) {
+ self.collapse = function (now) {
if (collapsed) {
return;
}
@@ -61,27 +59,27 @@ wv.layers.sidebar = wv.layers.sidebar || function(models, config) {
.removeClass('arrow')
.addClass('staticLayers');
$('.accordionToggler')
- .attr("title", "Show Layer Selector");
+ .attr('title', 'Show Layer Selector');
$('.accordionToggler')
- .html("Layers (" + models.layers.get()
- .length + ")");
+ .html('Layers (' + models.layers.get()
+ .length + ')');
- var speed = (now) ? undefined : "fast";
+ var speed = (now) ? undefined : 'fast';
$('.products')
.hide(speed);
- $("#" + self.id)
+ $('#' + self.id)
.after($('.accordionToggler'));
if (wv.util.browser.localStorage) {
- localStorage.setItem("sidebarState", "collapsed");
+ localStorage.setItem('sidebarState', 'collapsed');
}
};
- self.collapseNow = function() {
+ self.collapseNow = function () {
self.collapse(true);
};
- self.expand = function(now) {
+ self.expand = function (now) {
if (!collapsed) {
return;
}
@@ -92,31 +90,31 @@ wv.layers.sidebar = wv.layers.sidebar || function(models, config) {
.removeClass('staticLayers dateHolder')
.addClass('arrow');
$('.accordionToggler')
- .attr("title", "Hide Layer Selector");
+ .attr('title', 'Hide Layer Selector');
$('.accordionToggler')
.empty();
- var speed = (now) ? undefined : "fast";
+ var speed = (now) ? undefined : 'fast';
$('.products')
- .show(speed, function() {
- models.wv.events.trigger("sidebar-expand");
+ .show(speed, function () {
+ models.wv.events.trigger('sidebar-expand');
});
$('.accordionToggler')
- .appendTo("#" + self.id + "toggleButtonHolder");
+ .appendTo('#' + self.id + 'toggleButtonHolder');
if (wv.util.browser.localStorage) {
- localStorage.setItem("sidebarState", "expanded");
+ localStorage.setItem('sidebarState', 'expanded');
}
// Resize after browser repaints
- setTimeout(function(){
+ setTimeout(function () {
self.sizeEventsTab();
}, 100);
};
- self.expandNow = function() {
+ self.expandNow = function () {
self.expand(true);
};
- self.toggle = function() {
+ self.toggle = function () {
if (collapsed) {
self.expand();
collapseRequested = false;
@@ -126,7 +124,7 @@ wv.layers.sidebar = wv.layers.sidebar || function(models, config) {
}
};
- self.sizeEventsTab = function() {
+ self.sizeEventsTab = function () {
var $tabPanel = $('#wv-events');
var $tabFooter = $tabPanel.find('footer');
var footerIsVisible = $tabFooter.css('display') === 'block';
@@ -138,7 +136,7 @@ wv.layers.sidebar = wv.layers.sidebar || function(models, config) {
$tabPanel.css('padding-bottom', footerHeight);
var tabPadding = $tabPanel.outerHeight(true) - $tabPanel.height();
- //FIXME: -10 here is the timeline's bottom position from page, fix
+ // FIXME: -10 here is the timeline's bottom position from page, fix
// after timeline markup is corrected to be loaded first
var maxHeight = windowHeight - tabBarHeight - distanceFromTop - tabPadding;
if (!wv.util.browser.small) {
@@ -166,60 +164,59 @@ wv.layers.sidebar = wv.layers.sidebar || function(models, config) {
}
};
- var render = function() {
-
+ var render = function () {
var $container = $(self.selector);
- $container.addClass("products");
+ $container.addClass('products');
- var $tabs = $("ul#productsHolder-tabs");
+ var $tabs = $('ul#productsHolder-tabs');
- var $activeTab = $("<li></li>")
- .addClass("layerPicker")
- .addClass("first")
- .attr("data-tab", "active");
+ var $activeTab = $('<li></li>')
+ .addClass('layerPicker')
+ .addClass('first')
+ .attr('data-tab', 'active');
- var $activeLink = $("<a></a>")
- .attr("href", "#products")
- .addClass("activetab")
- .addClass("tab")
+ var $activeLink = $('<a></a>')
+ .attr('href', '#products')
+ .addClass('activetab')
+ .addClass('tab')
.html("<i class='productsIcon selected icon-layers' title='Layers'></i> Layers");
$activeTab.append($activeLink);
$tabs.append($activeTab);
if (config.features.naturalEvents) {
- var $eventsTab = $("<li></li>")
- .addClass("layerPicker")
- .addClass("second")
- .attr("data-tab", "events");
- var $eventsLink = $("<a></a>")
- .attr("href", "#wv-events")
- .addClass("tab")
+ var $eventsTab = $('<li></li>')
+ .addClass('layerPicker')
+ .addClass('second')
+ .attr('data-tab', 'events');
+ var $eventsLink = $('<a></a>')
+ .attr('href', '#wv-events')
+ .addClass('tab')
.html("<i class='productsIcon selected icon-events' title='Events'></i> Events");
$eventsTab.append($eventsLink);
$tabs.append($eventsTab);
}
if (config.features.dataDownload) {
- var $downloadTab = $("<li></li>")
- .addClass("layerPicker")
- .addClass("third")
- .attr("data-tab", "download");
- var $downloadLink = $("<a></a>")
- .attr("href", "#wv-data")
- .addClass("tab")
+ var $downloadTab = $('<li></li>')
+ .addClass('layerPicker')
+ .addClass('third')
+ .attr('data-tab', 'download');
+ var $downloadLink = $('<a></a>')
+ .attr('href', '#wv-data')
+ .addClass('tab')
.html("<i class='productsIcon selected icon-download' title='Data'></i> Data");
$downloadTab.append($downloadLink);
$tabs.append($downloadTab);
}
- var $collapseContainer = $("div#productsHoldertoggleButtonHolder")
- .addClass("toggleButtonHolder");
+ var $collapseContainer = $('div#productsHoldertoggleButtonHolder')
+ .addClass('toggleButtonHolder');
- var $collapseButton = $("<a></a>")
- .addClass("accordionToggler")
- .addClass("atcollapse")
- .addClass("arrow")
- .attr("title", "Hide");
+ var $collapseButton = $('<a></a>')
+ .addClass('accordionToggler')
+ .addClass('atcollapse')
+ .addClass('arrow')
+ .attr('title', 'Hide');
$collapseContainer.append($collapseButton);
@@ -232,36 +229,36 @@ wv.layers.sidebar = wv.layers.sidebar || function(models, config) {
.bind('click', self.toggle);
};
- var onTabChange = function(e, ui) {
- var tab = ui.newTab.attr("data-tab");
- if (tab === "events" || tab === "download") {
- $("#wv-layers-options-dialog")
- .dialog("close");
+ var onTabChange = function (e, ui) {
+ var tab = ui.newTab.attr('data-tab');
+ if (tab === 'events' || tab === 'download') {
+ $('#wv-layers-options-dialog')
+ .dialog('close');
}
- self.events.trigger('selectTab', ui.newTab.attr("data-tab"));
+ self.events.trigger('selectTab', ui.newTab.attr('data-tab'));
if (e.currentTarget) {
e.currentTarget.blur();
}
};
- var onBeforeTabChange = function(e, ui) {
- var tab = ui.newTab.attr("data-tab");
- $('.ui-tabs-nav li.second').removeClass("ui-state-active");
- if (tab === "active") {
- $('.ui-tabs-nav li.first').addClass("ui-state-active");
- } else if (tab === "events") {
+ var onBeforeTabChange = function (e, ui) {
+ var tab = ui.newTab.attr('data-tab');
+ $('.ui-tabs-nav li.second').removeClass('ui-state-active');
+ if (tab === 'active') {
+ $('.ui-tabs-nav li.first').addClass('ui-state-active');
+ } else if (tab === 'events') {
WVC.GA.event('Natural Events', 'Click', 'Events Tab');
- $('.ui-tabs-nav li.second').addClass("ui-state-active");
- } else if (tab === "download") {
- $('.ui-tabs-nav li.third').addClass("ui-state-active");
+ $('.ui-tabs-nav li.second').addClass('ui-state-active');
+ } else if (tab === 'download') {
+ $('.ui-tabs-nav li.third').addClass('ui-state-active');
} else {
- throw new Error("Invalid tab index: " + ui.index);
+ throw new Error('Invalid tab index: ' + ui.index);
}
- self.events.trigger("before-select", tab);
+ self.events.trigger('before-select', tab);
return true;
};
- var resize = function() {
+ var resize = function () {
if (!mobile && wv.util.browser.small) {
self.collapseNow();
mobile = true;
@@ -271,11 +268,11 @@ wv.layers.sidebar = wv.layers.sidebar || function(models, config) {
}
};
- var onProjectionChange = function() {
+ var onProjectionChange = function () {
if (collapsed) {
$('.accordionToggler')
- .html("Layers (" + models.layers.get()
- .length + ")");
+ .html('Layers (' + models.layers.get()
+ .length + ')');
}
};
diff --git a/web/js/link/wv.link.model.js b/web/js/link/wv.link.model.js
index 8c08b2e47..da4b7cdda 100644
--- a/web/js/link/wv.link.model.js
+++ b/web/js/link/wv.link.model.js
@@ -1,90 +1,89 @@
var wv = wv || {};
wv.link = wv.link || {};
-wv.link.model = wv.link.model || function(config) {
-
+wv.link.model = wv.link.model || function (config) {
var self = {};
- var DEBUG_SHORTEN_LINK = "http://go.nasa.gov/1iKIZ4j";
+ var DEBUG_SHORTEN_LINK = 'http://go.nasa.gov/1iKIZ4j';
var ENCODING_EXCEPTIONS = [
{
- match: new RegExp("%2C", "g"),
- replace: ","
+ match: new RegExp('%2C', 'g'),
+ replace: ','
}, {
- match: new RegExp("%3B", "g"),
- replace: ";"
+ match: new RegExp('%3B', 'g'),
+ replace: ';'
}, {
- match: new RegExp("%3D", "g"),
- replace: "="
+ match: new RegExp('%3D', 'g'),
+ replace: '='
}
];
var shortenCache = new Cache(10);
- var mock = "";
+ var mock = '';
var components = [];
self.events = wv.util.events();
- var init = function() {
+ var init = function () {
if (config && config.parameters && config.parameters.shorten) {
- mock = "-" + config.parameters.shorten;
+ mock = '-' + config.parameters.shorten;
}
};
- self.register = function(component) {
+ self.register = function (component) {
components.push(component);
if (component.events) {
- component.events.any(function() {
- self.events.trigger("update");
+ component.events.any(function () {
+ self.events.trigger('update');
});
}
return self;
};
- //Returns a serialized string containing information of the current session
- self.toQueryString = function() {
+ // Returns a serialized string containing information of the current session
+ self.toQueryString = function () {
var state = {};
- _.each(components, function(component) {
+ _.each(components, function (component) {
component.save(state);
});
- var strings = _.map(state, function(value, key) {
+ var strings = _.map(state, function (value, key) {
if (_.isArray(value)) {
var parts = [];
- _.each(value, function(item) {
- var part = "";
+ _.each(value, function (item) {
+ var part = '';
if (_.isObject(item)) {
part = item.id;
if (item.attributes && item.attributes.length > 0) {
var attributes = [];
- _.each(item.attributes, function(attribute) {
+ _.each(item.attributes, function (attribute) {
if (attribute.value) {
- attributes.push(attribute.id + "=" + attribute.value);
+ attributes.push(attribute.id + '=' + attribute.value);
} else {
attributes.push(attribute.id);
}
});
- part += "(" + attributes.join(",") + ")";
+ part += '(' + attributes.join(',') + ')';
}
} else {
part = item;
}
parts.push(part);
});
- value = parts.join(",");
+ value = parts.join(',');
}
- return key + "=" + encode(value);
+ return key + '=' + encode(value);
});
- return strings.join("&");
+ return strings.join('&');
};
- self.get = function() {
+ self.get = function () {
var queryString = self.toQueryString();
var url = window.location.href;
- var prefix = url.split("?")[0];
+ var prefix = url.split('?')[0];
prefix = (prefix !== null && prefix !== undefined) ? prefix : url;
- return prefix + "?" + queryString;
+ return prefix + '?' + queryString;
};
- self.shorten = function(link) {
+ self.shorten = function (link) {
if (!link) {
link = self.get();
}
@@ -99,23 +98,23 @@ wv.link.model = wv.link.model || function(config) {
}
});
}
- var promise = $.getJSON("service/link/shorten.cgi" + mock + "?url=" + encodeURIComponent(link));
- promise.done(function(result) {
+ var promise = $.getJSON('service/link/shorten.cgi' + mock + '?url=' + encodeURIComponent(link));
+ promise.done(function (result) {
shortenCache[link] = result;
});
return promise;
};
- self.load = function(state, errors) {
+ self.load = function (state, errors) {
errors = errors || [];
- _.each(components, function(component) {
+ _.each(components, function (component) {
component.load(state, errors);
});
};
- var encode = function(value) {
+ var encode = function (value) {
var encoded = encodeURIComponent(value);
- _.each(ENCODING_EXCEPTIONS, function(exception) {
+ _.each(ENCODING_EXCEPTIONS, function (exception) {
encoded = encoded.replace(exception.match, exception.replace);
});
return encoded;
diff --git a/web/js/link/wv.link.ui.js b/web/js/link/wv.link.ui.js
index 8b7b4d237..adfa795ab 100644
--- a/web/js/link/wv.link.ui.js
+++ b/web/js/link/wv.link.ui.js
@@ -1,24 +1,23 @@
var wv = wv || {};
wv.link = wv.link || {};
-wv.link.ui = wv.link.ui || function(models, config) {
-
+wv.link.ui = wv.link.ui || function (models, config) {
var self = {};
- var id = "wv-link-button";
- var selector = "#" + id;
+ var id = 'wv-link-button';
+ var selector = '#' + id;
var $button, $label;
var widgetFactory = React.createFactory(WVC.Share);
var clipboard = new Clipboard('.copy-btn');
- var init = function() {
- $button = $("<input></input>")
- .attr("type", "checkbox")
- .attr("id", "wv-link-button-check");
- $label = $("<label></label>")
- .attr("for", "wv-link-button-check")
- .attr("title", "Share this map");
- var $icon = $("<i></i>")
- .addClass("fa fa-share-square-o fa-2x");
+ var init = function () {
+ $button = $('<input></input>')
+ .attr('type', 'checkbox')
+ .attr('id', 'wv-link-button-check');
+ $label = $('<label></label>')
+ .attr('for', 'wv-link-button-check')
+ .attr('title', 'Share this map');
+ var $icon = $('<i></i>')
+ .addClass('fa fa-share-square-o fa-2x');
$label.append($icon);
$(selector)
.append($label);
@@ -27,9 +26,9 @@ wv.link.ui = wv.link.ui || function(models, config) {
$button.button({
text: false
})
- .click(function() {
- var checked = $("#wv-link-button-check")
- .prop("checked");
+ .click(function () {
+ var checked = $('#wv-link-button-check')
+ .prop('checked');
WVC.GA.event('Link', 'Click', 'Share link Button');
if (checked) {
self.show();
@@ -37,13 +36,13 @@ wv.link.ui = wv.link.ui || function(models, config) {
wv.ui.closeDialog();
}
});
- models.link.events.on("update", replaceHistoryState);
+ models.link.events.on('update', replaceHistoryState);
};
- //Calls toQueryString to fetch updated state and returns URL
- var replaceHistoryState = _.throttle(function() {
+ // Calls toQueryString to fetch updated state and returns URL
+ var replaceHistoryState = _.throttle(function () {
if (wv.util.browser.history) {
- window.history.replaceState("", "@OFFICIAL_NAME@", "?" + models.link.toQueryString());
+ window.history.replaceState('', '@OFFICIAL_NAME@', '?' + models.link.toQueryString());
}
}, 2000, {
leading: true,
@@ -51,29 +50,29 @@ wv.link.ui = wv.link.ui || function(models, config) {
});
// Facebook: https://developers.facebook.com/docs/sharing/reference/share-dialog#redirect
- var facebookUrlParams = function(appId, href, redirectUri, display) {
- return "https://www.facebook.com/dialog/share?" + "app_id=" + encodeURIComponent(appId) + "&href=" + encodeURIComponent(href) + "&redirect_uri=" + encodeURIComponent(redirectUri) + "&display=" + encodeURIComponent(display);
+ var facebookUrlParams = function (appId, href, redirectUri, display) {
+ return 'https://www.facebook.com/dialog/share?' + 'app_id=' + encodeURIComponent(appId) + '&href=' + encodeURIComponent(href) + '&redirect_uri=' + encodeURIComponent(redirectUri) + '&display=' + encodeURIComponent(display);
};
// Twitter: https://dev.twitter.com/web/tweet-button/parameters#web-intent-example
- var twitterUrlParams = function(url, text) {
- return "https://twitter.com/intent/tweet?" + "url=" + encodeURIComponent(url) + "&text=" + encodeURIComponent(text);
+ var twitterUrlParams = function (url, text) {
+ return 'https://twitter.com/intent/tweet?' + 'url=' + encodeURIComponent(url) + '&text=' + encodeURIComponent(text);
};
// Reddit: https://www.reddit.com/r/nasa/submit?url=[URL]&title=[TITLE]
- var redditUrlParams = function(url, title) {
- return "https://www.reddit.com/r/nasa/submit?" + "url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title);
+ var redditUrlParams = function (url, title) {
+ return 'https://www.reddit.com/r/nasa/submit?' + 'url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title);
};
// Email: mailto:?subject=[SUBJECT]&body=[BODY]
- var emailUrlParams = function(subject, body) {
- return "mailto:?" + "subject=" + encodeURIComponent(subject) + "&body=" + encodeURIComponent(body);
+ var emailUrlParams = function (subject, body) {
+ return 'mailto:?' + 'subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body);
};
- var getSharelink = function(type, url) {
+ var getSharelink = function (type, url) {
var shareMessage = 'Check out what I found in NASA Worldview!';
var twMessage = 'Check out what I found in #NASAWorldview -';
- var emailBody = shareMessage + " - " + url;
+ var emailBody = shareMessage + ' - ' + url;
switch (type) {
case 'twitter':
@@ -87,10 +86,10 @@ wv.link.ui = wv.link.ui || function(models, config) {
}
return undefined;
};
- var openPromisedSocial = function(url, win) {
+ var openPromisedSocial = function (url, win) {
win.location.assign(url);
};
- var clickFunction = function(type) {
+ var clickFunction = function (type) {
var href, win;
var shareLink = models.link.get();
var promise = models.link.shorten();
@@ -101,16 +100,16 @@ wv.link.ui = wv.link.ui || function(models, config) {
if (type === 'twitter') {
win = window.open('', '_blank');
}
- promise.done(function(result) {
+ promise.done(function (result) {
if (result.status_code === 200) {
href = getSharelink(type, result.data.url);
openPromisedSocial(href, win);
}
})
- .fail(function() {
+ .fail(function () {
href = getSharelink(type, shareLink);
openPromisedSocial(href, win);
- console.warn("Unable to shorten URL, full link generated.");
+ console.warn('Unable to shorten URL, full link generated.');
});
} else {
href = getSharelink(type, shareLink);
@@ -118,22 +117,22 @@ wv.link.ui = wv.link.ui || function(models, config) {
}
};
- self.show = function() {
+ self.show = function () {
var $dialog = wv.ui.getDialog();
var item = "<div id='wv-link' class='wv-link'>" +
"<div class='input-group'>" +
"<input type='text' value='' name='permalink_content' id='permalink_content' readonly/>" +
"<span class='input-group-button hide-icon' data-balloon-visible data-tooltip='Copied!' data-tooltip-pos='up' data-tooltip-length='xsmall'>" +
"<button title='Copy to clipboard' class='copy-btn' data-clipboard-target='#permalink_content'>COPY</button>" +
- "</span>" +
- "</div>";
+ '</span>' +
+ '</div>';
if (config.features.urlShortening) {
item += "<span autofocus></span><div id='wv-link-shorten'>" +
"<input type='checkbox' value='' id='wv-link-shorten-check' />" +
"<label id='wv-link-shorten-label' for='wv-link-shorten-check'>Shorten link</label>" +
- "</div>";
+ '</div>';
}
- item += "</div>";
+ item += '</div>';
var dialogWidth = '300';
if (wv.util.browser.small) {
@@ -147,73 +146,73 @@ wv.link.ui = wv.link.ui || function(models, config) {
// If selected during the animation, the cursor will go to the
// end of the input box
- var updateLink = function() {
+ var updateLink = function () {
$('#permalink_content')
.val(models.link.get());
- $("#wv-link-shorten-check")
- .iCheck("uncheck");
+ $('#wv-link-shorten-check')
+ .iCheck('uncheck');
$('#permalink_content')
.focus();
$('#permalink_content')
.select();
};
- models.link.events.on("update", updateLink);
+ models.link.events.on('update', updateLink);
$dialog.dialog({
- dialogClass: "wv-panel wv-link-panel",
- title: "Copy link to share:",
+ dialogClass: 'wv-panel wv-link-panel',
+ title: 'Copy link to share:',
show: {
- effect: "slide",
- direction: "up"
+ effect: 'slide',
+ direction: 'up'
},
width: dialogWidth,
- height: "auto",
+ height: 'auto',
minHeight: 10,
draggable: false,
resizable: false,
autoOpen: false
})
- .on("dialogcreate",
+ .on('dialogcreate',
$dialog.prepend(item)
)
- .on("dialogclose", function() {
- $("#wv-link-button-check")
- .prop("checked", false);
- $button.button("refresh");
- models.link.events.off("update", updateLink);
+ .on('dialogclose', function () {
+ $('#wv-link-button-check')
+ .prop('checked', false);
+ $button.button('refresh');
+ models.link.events.off('update', updateLink);
});
if (wv.util.browser.small) {
wv.ui.positionDialog($dialog, {
- my: "left top",
- at: "left+58 bottom+5",
- of: "#wv-toolbar"
+ my: 'left top',
+ at: 'left+58 bottom+5',
+ of: '#wv-toolbar'
});
} else {
wv.ui.positionDialog($dialog, {
- my: "left top",
- at: "left bottom+5",
+ my: 'left top',
+ at: 'left bottom+5',
of: $label
});
}
- $(".ui-dialog")
+ $('.ui-dialog')
.zIndex(600);
$('#permalink_content')
.val(models.link.get());
- $dialog.dialog("open");
+ $dialog.dialog('open');
setTimeout(updateLink, 500);
- $("#wv-link-shorten-check")
- .on("change", function() {
- var checked = $("#wv-link-shorten-check")
- .prop("checked");
+ $('#wv-link-shorten-check')
+ .on('change', function () {
+ var checked = $('#wv-link-shorten-check')
+ .prop('checked');
if (checked) {
var promise = models.link.shorten();
WVC.GA.event('Link', 'Check', 'Shorten');
- $("#permalink_content")
- .val("Please wait...");
- promise.done(function(result) {
+ $('#permalink_content')
+ .val('Please wait...');
+ promise.done(function (result) {
if (result.status_code === 200) {
$('#permalink_content')
.val(result.data.url);
@@ -221,7 +220,7 @@ wv.link.ui = wv.link.ui || function(models, config) {
error(result.status_code, result.status_txt);
}
})
- .fail(function(jqXHR, textStatus, errorThrown) {
+ .fail(function (jqXHR, textStatus, errorThrown) {
error(textStatus, errorThrown);
});
} else {
@@ -235,36 +234,36 @@ wv.link.ui = wv.link.ui || function(models, config) {
.select();
});
- var error = function() {
- console.warn("Unable to shorten URL");
+ var error = function () {
+ console.warn('Unable to shorten URL');
console.warn.apply(console, arguments);
- wv.ui.notify("Unable to shorten the permalink at this time. " +
- "Please try again later.");
+ wv.ui.notify('Unable to shorten the permalink at this time. ' +
+ 'Please try again later.');
};
- $("#wv-link-shorten-check")
- .prop("checked", false);
+ $('#wv-link-shorten-check')
+ .prop('checked', false);
- clipboard.on('success', function(e) {
+ clipboard.on('success', function (e) {
e.clearSelection();
$('.wv-link .input-group-button')
.removeClass('hide-icon');
- setTimeout(function(){
+ setTimeout(function () {
$('.wv-link .input-group-button')
.addClass('hide-icon');
}, 1000);
});
- clipboard.on('error', function(e) {
+ clipboard.on('error', function (e) {
console.error('Link could not be copied!');
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
};
- self.initWidget = function() {
+ self.initWidget = function () {
return widgetFactory({
clickFunction: clickFunction,
fbLink: '#',
@@ -276,5 +275,4 @@ wv.link.ui = wv.link.ui || function(models, config) {
init();
return self;
-
};
diff --git a/web/js/map/wv.map.animate.js b/web/js/map/wv.map.animate.js
index 4677da062..3c318b7ec 100644
--- a/web/js/map/wv.map.animate.js
+++ b/web/js/map/wv.map.animate.js
@@ -1,7 +1,6 @@
var wv = wv || {};
wv.map = wv.map || {};
-wv.map.animate = wv.map.animate || function(models, config, ui) {
-
+wv.map.animate = wv.map.animate || function (models, config, ui) {
var self = {};
/**
@@ -11,7 +10,7 @@ wv.map.animate = wv.map.animate || function(models, config, ui) {
* @param {integer} endZoom Ending Zoom Level
* @return {Promise} Promise that is fulfilled when animation completes
*/
- self.fly = function(endPoint, endZoom) {
+ self.fly = function (endPoint, endZoom) {
var view = ui.map.selected.getView();
view.cancelAnimations();
var startPoint = view.getCenter();
@@ -22,16 +21,16 @@ wv.map.animate = wv.map.animate || function(models, config, ui) {
var hasEndInView = ol.extent.containsCoordinate(extent, endPoint);
var line = new ol.geom.LineString([startPoint, endPoint]);
var distance = line.getLength(); // In map units, which is usually degrees
- var duration = (distance * 20)+1000; // 4.6 seconds to go 360 degrees
- var animationPromise = function() {
+ var duration = (distance * 20) + 1000; // 4.6 seconds to go 360 degrees
+ var animationPromise = function () {
var args = Array.prototype.slice.call(arguments);
- return new Promise(function(resolve, reject){
- args.push(function(complete){
+ return new Promise(function (resolve, reject) {
+ args.push(function (complete) {
if (complete) resolve();
if (!complete) reject(new Error('Animation interrupted!'));
});
view.animate.apply(view, args);
- }).catch(function(){});
+ }).catch(function () {});
};
if (hasEndInView) {
// If the event is already visible, don't zoom out
@@ -44,8 +43,8 @@ wv.map.animate = wv.map.animate || function(models, config, ui) {
return Promise.all([
animationPromise({center: endPoint, duration: duration}),
animationPromise(
- {zoom: getBestZoom(distance, startZoom, endZoom, view), duration: duration/2},
- {zoom: endZoom, duration: duration/2}
+ {zoom: getBestZoom(distance, startZoom, endZoom, view), duration: duration / 2},
+ {zoom: endZoom, duration: duration / 2}
)
]);
};
@@ -59,18 +58,18 @@ wv.map.animate = wv.map.animate || function(models, config, ui) {
* @param {object} view map view
* @return {integer} best zoom level for flight animation
*/
- var getBestZoom = function(distance, start, end, view) {
+ var getBestZoom = function (distance, start, end, view) {
var idealLength = 1500;
- var lines = [2,3,4,5,6,7,8].map(function(zoom){
+ var lines = [2, 3, 4, 5, 6, 7, 8].map(function (zoom) {
return {
zoom: zoom,
- pixels: distance/view.getResolutionForZoom(zoom)
+ pixels: distance / view.getResolutionForZoom(zoom)
};
});
- var bestFit = lines.sort(function(a, b) {
+ var bestFit = lines.sort(function (a, b) {
return Math.abs(idealLength - a.pixels) - Math.abs(idealLength - b.pixels);
})[0];
- return Math.max(2, Math.min(bestFit.zoom, start-1, end-1));
+ return Math.max(2, Math.min(bestFit.zoom, start - 1, end - 1));
};
return self;
diff --git a/web/js/map/wv.map.datelinebuilder.js b/web/js/map/wv.map.datelinebuilder.js
index d75cc6128..80f87405c 100644
--- a/web/js/map/wv.map.datelinebuilder.js
+++ b/web/js/map/wv.map.datelinebuilder.js
@@ -4,7 +4,7 @@ wv.map = wv.map || {};
/*
* @Class
*/
-wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
+wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
var self = {};
var map, overlay1, overlay2, textFactory, lineFactory, textOverlay1, textOverlay2,
lineLeft, lineRight, textLeft, textRight, proj;
@@ -21,7 +21,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {object} React Component
*/
- self.init = function(Parent, olMap, date) {
+ self.init = function (Parent, olMap, date) {
var dimensions;
map = olMap;
lineFactory = React.createFactory(WVC.DateLine);
@@ -29,31 +29,28 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
drawDatelines(map, date);
proj = models.proj.selected.id;
- Parent.events.on('moveend', function() {
- if (!isGeoProjection())
- return;
+ Parent.events.on('moveend', function () {
+ if (!isGeoProjection()) { return; }
updateLineVisibility(true);
dimensions = position(map);
update(dimensions);
});
- Parent.events.on('drag', function() {
- if (!isGeoProjection())
- return;
+ Parent.events.on('drag', function () {
+ if (!isGeoProjection()) { return; }
updateLineVisibility(false);
});
- Parent.events.on('movestart', function() {
- if (!isGeoProjection())
- return;
+ Parent.events.on('movestart', function () {
+ if (!isGeoProjection()) { return; }
updateLineVisibility(false);
});
- models.date.events.on('select', function() {
+ models.date.events.on('select', function () {
updateDate(models.date.selected);
});
- models.proj.events.on('select', function() {
+ models.proj.events.on('select', function () {
proj = models.proj.selected.id;
});
};
- var isGeoProjection = function() {
+ var isGeoProjection = function () {
if (proj === 'geographic') {
return true;
}
@@ -75,7 +72,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {object} React Component
*/
- var setLineDefaults = function(Factory, height, lineX, overlay, reactCase, tooltip) {
+ var setLineDefaults = function (Factory, height, lineX, overlay, reactCase, tooltip) {
var props = {
height: height,
lineOver: onHover,
@@ -100,7 +97,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {object} React Component
*/
- var setTextDefaults = function(Factory, reactCase, date) {
+ var setTextDefaults = function (Factory, reactCase, date) {
var props = {
dateLeft: wv.util.toISOStringDate(wv.util.dateAdd(date, 'day', 1)),
dateRight: wv.util.toISOStringDate(date)
@@ -119,7 +116,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {object} React Component
*/
- var initWidget = function(Factory, props) {
+ var initWidget = function (Factory, props) {
return Factory(props);
};
@@ -133,7 +130,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {void}
*/
- var updateLineVisibility = function(boo) {
+ var updateLineVisibility = function (boo) {
var state = {
active: boo
};
@@ -151,13 +148,13 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {void}
*/
- var drawDatelines = function(map, date) {
+ var drawDatelines = function (map, date) {
var height, leftLineCase, rightLineCase, leftTextCase, rightTextCase;
- leftLineCase = document.createElement("div");
- rightLineCase = document.createElement("div");
- leftTextCase = document.createElement("div");
- rightTextCase = document.createElement("div");
+ leftLineCase = document.createElement('div');
+ rightLineCase = document.createElement('div');
+ leftTextCase = document.createElement('div');
+ rightTextCase = document.createElement('div');
height = 0;
overlay1 = drawOverlay([-180, 90], leftLineCase);
@@ -189,7 +186,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {void}
*/
- var onHover = function(pixels, overlay, lineX, tooltip) {
+ var onHover = function (pixels, overlay, lineX, tooltip) {
var coords;
coords = map.getCoordinateFromPixel(pixels);
overlay.setPosition([lineX, coords[1]]);
@@ -209,7 +206,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {void}
*/
- var onMouseOut = function(tooltip) {
+ var onMouseOut = function (tooltip) {
tooltip.setState({
active: false
});
@@ -225,7 +222,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {void}
*/
- var updateDate = function(date) {
+ var updateDate = function (date) {
var leftState, rightState;
leftState = {
dateLeft: wv.util.toISOStringDate(wv.util.dateAdd(date, 'day', 1)),
@@ -237,7 +234,6 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
};
textLeft.setState(leftState);
textRight.setState(rightState);
-
};
/*
@@ -250,7 +246,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {void}
*/
- var position = function(map) {
+ var position = function (map) {
var extent, top, topY, bottomY, bottom, height, startY, topExtent, bottomExtent;
if (map.getSize()[0] === 0) {
@@ -291,7 +287,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {void}
*/
- var update = function(dimensions) {
+ var update = function (dimensions) {
var state = {
height: dimensions[0]
};
@@ -312,7 +308,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function(models, config) {
*
* @returns {void}
*/
- var drawOverlay = function(coordinate, el) {
+ var drawOverlay = function (coordinate, el) {
var overlay = new ol.Overlay({
element: el,
stopEvent: false
diff --git a/web/js/map/wv.map.js b/web/js/map/wv.map.js
index 20e4b3101..ccf4f87db 100644
--- a/web/js/map/wv.map.js
+++ b/web/js/map/wv.map.js
@@ -4,9 +4,8 @@ wv.map = wv.map || {};
/*
* @Class
*/
-wv.map = (function(self) {
-
- self.CRS_WGS_84 = "EPSG:4326";
+wv.map = (function (self) {
+ self.CRS_WGS_84 = 'EPSG:4326';
self.CRS_WGS_84_QUERY_EXTENT = [-180, -60, 180, 60];
@@ -26,20 +25,20 @@ wv.map = (function(self) {
*
* @todo would benefit by returning the array instead of attaching it to a global var
*/
- self.parse = function(state, errors) {
+ self.parse = function (state, errors) {
// 1.1 support
if (state.map) {
state.v = state.map;
delete state.map;
}
if (state.v) {
- var extent = _.map(state.v.split(","), function(str) {
+ var extent = _.map(state.v.split(','), function (str) {
return parseFloat(str);
});
var valid = wv.map.isExtentValid(extent);
if (!valid) {
errors.push({
- message: "Invalid extent: " + state.v
+ message: 'Invalid extent: ' + state.v
});
delete state.v;
} else {
@@ -59,7 +58,7 @@ wv.map = (function(self) {
* @return {boolean} False if any of the values is NaN, otherwise returns
* true.
*/
- self.isExtentValid = function(extent) {
+ self.isExtentValid = function (extent) {
if (_.isUndefined(extent)) {
return false;
}
@@ -67,7 +66,7 @@ wv.map = (function(self) {
if (extent.toArray) {
extent = extent.toArray();
}
- _.each(extent, function(value) {
+ _.each(extent, function (value) {
if (isNaN(value)) {
valid = false;
return false;
@@ -83,10 +82,10 @@ wv.map = (function(self) {
* @static
* @readOnly
*/
- self.tileScheduler = _.once(function() {
+ self.tileScheduler = _.once(function () {
if (wv.util.browser.webWorkers) {
return wv.map.palette.scheduler({
- script: "js/map/wv.map.tileworker.js?v=" + wv.brand.BUILD_NONCE,
+ script: 'js/map/wv.map.tileworker.js?v=' + wv.brand.BUILD_NONCE,
max: 4
});
}
@@ -103,14 +102,14 @@ wv.map = (function(self) {
* @param layer {OpenLayers.Layer} The layer to set the opacity
* @param opacity {float} A value from 0 (transparent) to 1 (opaque).
*/
- self.setOpacity = function(layer, opacity) {
+ self.setOpacity = function (layer, opacity) {
layer.setOpacity(opacity);
if (opacity === 1) {
- var effect = layer.originalTransitionEffect || "resize";
+ var effect = layer.originalTransitionEffect || 'resize';
layer.transitionEffect = effect;
} else {
layer.originalTransitionEffect = layer.transitionEffect;
- layer.transitionEffect = "none";
+ layer.transitionEffect = 'none';
}
};
@@ -130,7 +129,7 @@ wv.map = (function(self) {
* @param opacity {float} The opacity that this layer should be if it
* is visible. A value from 0 (transparent) to 1 (opaque).
*/
- self.setVisibility = function(layer, visible, opacity) {
+ self.setVisibility = function (layer, visible, opacity) {
if (layer.isControl) {
layer.setVisibility(visible);
} else {
@@ -155,11 +154,11 @@ wv.map = (function(self) {
* @return {obj} Layer object
*
*/
- self.getLayerByName = function(map, name) {
+ self.getLayerByName = function (map, name) {
var layers = map.getLayers()
.getArray();
return _.find(layers, {
- "wvname": name
+ 'wvname': name
});
};
@@ -178,7 +177,7 @@ wv.map = (function(self) {
* @todo relocate this utility function
*
*/
- self.isPolygonValid = function(polygon, maxDistance) {
+ self.isPolygonValid = function (polygon, maxDistance) {
var outerRing = polygon.getLinearRing(0);
var points = outerRing.getCoordinates();
for (var i = 0; i < points.length - 1; i++) {
@@ -211,7 +210,7 @@ wv.map = (function(self) {
*
* @todo relocate this utility function
*/
- self.adjustAntiMeridian = function(polygon, adjustSign) {
+ self.adjustAntiMeridian = function (polygon, adjustSign) {
var outerRing = polygon.getLinearRing(0);
var points = outerRing.getCoordinates()
.slice();
@@ -242,7 +241,7 @@ wv.map = (function(self) {
* @todo relocate this utility function
*
*/
- self.distance2D = function(p1, p2) {
+ self.distance2D = function (p1, p2) {
return Math.sqrt(Math.pow(p1[0] - p2[0], 2) +
(Math.pow(p1[1] - p2[1], 2)));
};
@@ -262,7 +261,7 @@ wv.map = (function(self) {
* @todo relocate this utility function
*
*/
- self.distanceX = function(p1, p2) {
+ self.distanceX = function (p1, p2) {
return Math.abs(p2 - p1);
};
@@ -281,7 +280,7 @@ wv.map = (function(self) {
* @todo relocate this utility function
*
*/
- self.interpolate2D = function(p1, p2, amount) {
+ self.interpolate2D = function (p1, p2, amount) {
var distX = p2[0] - p1[0];
var distY = p2[1] - p1[1];
@@ -305,7 +304,7 @@ wv.map = (function(self) {
* @todo relocate this utility function
*
*/
- self.toPolys = function(geom) {
+ self.toPolys = function (geom) {
if (geom.getPolygons) {
return geom.getPolygons();
}
@@ -313,7 +312,6 @@ wv.map = (function(self) {
};
return self;
-
})(wv.map || {});
/* FIXME OL3
diff --git a/web/js/map/wv.map.layerbuilder.js b/web/js/map/wv.map.layerbuilder.js
index 1f23a9f3c..0469f6fde 100644
--- a/web/js/map/wv.map.layerbuilder.js
+++ b/web/js/map/wv.map.layerbuilder.js
@@ -4,10 +4,10 @@ wv.map = wv.map || {};
/*
* @Class
*/
-wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Parent) {
+wv.map.layerbuilder = wv.map.layerbuilder || function (models, config, cache, Parent) {
var self = {};
var map;
- self.init = function(Parent) {
+ self.init = function (Parent) {
self.extentLayers = [];
Parent.events.on('selecting', hideWrap);
Parent.events.on('selectiondone', showWrap);
@@ -25,7 +25,7 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
*
* @returns {object} OpenLayers layer
*/
- self.createLayer = function(def, options) {
+ self.createLayer = function (def, options) {
var date, key, proj, layer, layerNext, layerPrior, group, attributes;
group = null;
@@ -44,7 +44,7 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
};
def = _.cloneDeep(def);
_.merge(def, def.projections[proj.id]);
- if (def.type === "wmts") {
+ if (def.type === 'wmts') {
layer = createLayerWMTS(def, options);
if (proj.id === 'geographic' && def.wrapadjacentdays === true) {
layerNext = createLayerWMTS(def, options, 1);
@@ -58,11 +58,9 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
layers: [layer, layerNext, layerPrior]
});
}
-
- } else if (def.type === "wms") {
+ } else if (def.type === 'wms') {
layer = createLayerWMS(def, options);
if (proj.id === 'geographic' && def.wrapadjacentdays === true) {
-
layerNext = createLayerWMS(def, options, 1);
layerPrior = createLayerWMS(def, options, -1);
@@ -75,7 +73,7 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
});
}
} else {
- throw new Error("Unknown layer type: " + def.type);
+ throw new Error('Unknown layer type: ' + def.type);
}
layer.wv = attributes;
cache.setItem(key, layer);
@@ -96,7 +94,7 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
*
* @returns {object} layer key Object
*/
- self.layerKey = function(def, options) {
+ self.layerKey = function (def, options) {
var layerId = def.id;
var projId = models.proj.selected.id;
var date;
@@ -105,12 +103,12 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
} else {
date = wv.util.toISOStringDate(models.date.selected);
}
- var dateId = (def.period === "daily") ? date : "";
- var palette = "";
+ var dateId = (def.period === 'daily') ? date : '';
+ var palette = '';
if (models.palettes.isActive(def.id)) {
palette = models.palettes.key(def.id);
}
- return [layerId, projId, dateId, palette].join(":");
+ return [layerId, projId, dateId, palette].join(':');
};
/*
* Create a new WMTS Layer
@@ -125,7 +123,7 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
*
* @returns {object} OpenLayers WMTS layer
*/
- var createLayerWMTS = function(def, options, day) {
+ var createLayerWMTS = function (def, options, day) {
var proj, source, matrixSet, matrixIds, extra,
date, extent, start;
proj = models.proj.selected;
@@ -133,22 +131,22 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
extent = proj.maxExtent;
start = [proj.maxExtent[0], proj.maxExtent[3]];
if (!source) {
- throw new Error(def.id + ": Invalid source: " + def.source);
+ throw new Error(def.id + ': Invalid source: ' + def.source);
}
matrixSet = source.matrixSets[def.matrixSet];
if (!matrixSet) {
- throw new Error(def.id + ": Undefined matrix set: " + def.matrixSet);
+ throw new Error(def.id + ': Undefined matrix set: ' + def.matrixSet);
}
- if ("undefined" === typeof def.matrixIds) {
+ if (typeof def.matrixIds === 'undefined') {
matrixIds = [];
- _.each(matrixSet.resolutions, function(resolution, index) {
+ _.each(matrixSet.resolutions, function (resolution, index) {
matrixIds.push(index);
});
} else {
matrixIds = def.matrixIds;
}
- extra = "";
+ extra = '';
if (day) {
if (day === 1) {
@@ -160,17 +158,17 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
}
}
- if (def.period === "daily") {
+ if (def.period === 'daily') {
date = options.date || models.date.selected;
if (day) {
date = wv.util.dateAdd(date, 'day', day);
}
- extra = "?TIME=" + wv.util.toISOStringDate(date);
+ extra = '?TIME=' + wv.util.toISOStringDate(date);
}
var sourceOptions = {
url: source.url + extra,
layer: def.layer || def.id,
- crossOrigin: "anonymous",
+ crossOrigin: 'anonymous',
format: def.format,
matrixSet: matrixSet.id,
tileGrid: new ol.tilegrid.WMTS({
@@ -180,7 +178,7 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
tileSize: matrixSet.tileSize[0]
}),
wrapX: false,
- style: "undefined" === typeof def.style ? 'default' : def.style
+ style: typeof def.style === 'undefined' ? 'default' : def.style
};
if (models.palettes.isActive(def.id)) {
var lookup = models.palettes.getLookup(def.id);
@@ -206,7 +204,7 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
*
* @returns {object} OpenLayers WMS layer
*/
- var createLayerWMS = function(def, options, day) {
+ var createLayerWMS = function (def, options, day) {
var proj, source, matrixSet, matrixIds, extra, transparent,
date, extent, start, bbox, res;
proj = models.proj.selected;
@@ -214,11 +212,10 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
extent = proj.maxExtent;
start = [proj.maxExtent[0], proj.maxExtent[3]];
res = proj.resolutions;
- if (!source)
- throw new Error(def.id + ": Invalid source: " + def.source);
+ if (!source) { throw new Error(def.id + ': Invalid source: ' + def.source); }
- transparent = (def.format === "image/png");
- if (proj.id === "geographic") {
+ transparent = (def.format === 'image/png');
+ if (proj.id === 'geographic') {
res = [0.28125, 0.140625, 0.0703125, 0.03515625, 0.017578125, 0.0087890625, 0.00439453125,
0.002197265625, 0.0010986328125, 0.00054931640625, 0.00027465820313];
}
@@ -235,25 +232,24 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
LAYERS: def.layer || def.id,
FORMAT: def.format,
TRANSPARENT: transparent,
- VERSION: "1.1.1"
+ VERSION: '1.1.1'
};
- if (def.styles)
- parameters.STYLES = def.styles;
+ if (def.styles) { parameters.STYLES = def.styles; }
- extra = "";
+ extra = '';
- if (def.period === "daily") {
+ if (def.period === 'daily') {
date = options.date || models.date.selected;
if (day) {
date = wv.util.dateAdd(date, 'day', day);
}
- extra = "?TIME=" + wv.util.toISOStringDate(date);
+ extra = '?TIME=' + wv.util.toISOStringDate(date);
}
var sourceOptions = {
url: source.url + extra,
wrapX: true,
style: 'default',
- crossOrigin: "anonymous",
+ crossOrigin: 'anonymous',
params: parameters,
tileGrid: new ol.tilegrid.TileGrid({
origin: start,
@@ -271,7 +267,7 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
});
return layer;
};
- var hideWrap = function() {
+ var hideWrap = function () {
var layer;
var key;
var layers;
@@ -289,14 +285,13 @@ wv.map.layerbuilder = wv.map.layerbuilder || function(models, config, cache, Par
}
}
};
- var showWrap = function() {
+ var showWrap = function () {
var layer;
var layers;
var key;
layers = models.layers.active;
for (var i = 0, len = layers.length; i < len; i++) {
-
layer = layers[i];
if (layer.wrapadjacentdays && layer.visible) {
key = self.layerKey(layer, {
diff --git a/web/js/map/wv.map.model.js b/web/js/map/wv.map.model.js
index 281106573..3c73ff9f9 100644
--- a/web/js/map/wv.map.model.js
+++ b/web/js/map/wv.map.model.js
@@ -6,8 +6,7 @@ wv.map = wv.map || {};
/*
* @Class
*/
-wv.map.model = wv.map.model || function(models, config) {
-
+wv.map.model = wv.map.model || function (models, config) {
var self = {};
self.extent = null;
@@ -23,9 +22,9 @@ wv.map.model = wv.map.model || function(models, config) {
*
* @returns {void}
*/
- self.update = function(extent) {
+ self.update = function (extent) {
self.extent = extent;
- self.events.trigger("update", extent);
+ self.events.trigger('update', extent);
};
/*
@@ -40,13 +39,13 @@ wv.map.model = wv.map.model || function(models, config) {
*
* @returns {void}
*/
- self.load = function(state, errors) {
+ self.load = function (state, errors) {
if (state.v) {
var proj = models.proj.selected;
var extent = state.v;
var maxExtent = proj.maxExtent;
- if (proj.id === "geographic") {
+ if (proj.id === 'geographic') {
proj.wrapExtent = maxExtent = [-250, -90, 250, 90];
}
if (ol.extent.intersects(extent, maxExtent)) {
@@ -54,14 +53,14 @@ wv.map.model = wv.map.model || function(models, config) {
} else {
self.extent = _.clone(proj.maxExtent);
errors.push({
- message: "Extent outside of range"
+ message: 'Extent outside of range'
});
}
}
- //get rotation if it exists
- if (state.p === 'arctic' || state.p === 'antarctic')
- if (!isNaN(state.r)) //convert to radians here
- self.rotation = state.r * (Math.PI / 180.0);
+ // get rotation if it exists
+ if (state.p === 'arctic' || state.p === 'antarctic') {
+ if (!isNaN(state.r)) { self.rotation = state.r * (Math.PI / 180.0); } // convert to radians
+ }
};
/*
@@ -76,11 +75,12 @@ wv.map.model = wv.map.model || function(models, config) {
*
* @returns {void}
*/
- self.save = function(state) {
+ self.save = function (state) {
state.v = _.clone(self.extent);
- if (self.rotation !== 0.0 && self.rotation !== 0 && models.proj.selected.id !== 'geographic')
+ if (self.rotation !== 0.0 && self.rotation !== 0 && models.proj.selected.id !== 'geographic') {
state.r = (self.rotation * (180.0 / Math.PI))
- .toPrecision(6); //convert from radians to degrees
+ .toPrecision(6);
+ } // convert from radians to degrees
};
/*
@@ -98,7 +98,7 @@ wv.map.model = wv.map.model || function(models, config) {
*
* @returns {object} Extent Array
*/
- self.getLeadingExtent = function() {
+ self.getLeadingExtent = function () {
var curHour = wv.util.now()
.getUTCHours();
diff --git a/web/js/map/wv.map.precachetile.js b/web/js/map/wv.map.precachetile.js
index 43031d7b6..67904eed8 100644
--- a/web/js/map/wv.map.precachetile.js
+++ b/web/js/map/wv.map.precachetile.js
@@ -4,7 +4,7 @@ wv.map = wv.map || {};
/*
* @Class
*/
-wv.map.precachetile = wv.map.precachetile || function(models, config, cache, parent) {
+wv.map.precachetile = wv.map.precachetile || function (models, config, cache, parent) {
/*
* Loaded the layers that are needed for any one date.
* Checks the cache to see if a layer has already
@@ -18,7 +18,7 @@ wv.map.precachetile = wv.map.precachetile || function(models, config, cache, par
*
* @returns {object} Promise.all
*/
- self.promiseDay = function(date) {
+ self.promiseDay = function (date) {
var viewState;
var currentZ;
var frameState;
@@ -29,13 +29,12 @@ wv.map.precachetile = wv.map.precachetile || function(models, config, cache, par
var promiseArray;
var projExtent;
-
layers = getActiveLayersWithData(date);
map = parent.selected;
frameState = parent.selected.frameState_;
pixelRatio = frameState.pixelRatio;
viewState = frameState.viewState;
- promiseArray = layers.map(function(def) {
+ promiseArray = layers.map(function (def) {
var key;
var layer;
var renderer;
@@ -54,18 +53,18 @@ wv.map.precachetile = wv.map.precachetile || function(models, config, cache, par
});
return promiseLayerGroup(layer, extent, viewState, pixelRatio, map);
});
- return new Promise(function(resolve) {
+ return new Promise(function (resolve) {
Promise.all(promiseArray)
- .then(function(yo) {
+ .then(function (yo) {
resolve(date);
});
});
};
- var getActiveLayersWithData = function(date) {
+ var getActiveLayersWithData = function (date) {
var layers;
var arra = [];
layers = models.layers.get();
- _.each(layers, function(layer) {
+ _.each(layers, function (layer) {
if (layer.visible && new Date(layer.startDate > date)) {
arra.push(layer);
}
@@ -73,7 +72,7 @@ wv.map.precachetile = wv.map.precachetile || function(models, config, cache, par
return arra;
};
- var calculateExtent = function(extent, viewportExtent) {
+ var calculateExtent = function (extent, viewportExtent) {
if (extent[1] < -180) {
extent = getExtent(viewportExtent, extent);
extent[1] = extent[1] + 360;
@@ -90,11 +89,11 @@ wv.map.precachetile = wv.map.precachetile || function(models, config, cache, par
}
return extent;
};
- var getExtent = function(extent1, extent2) {
+ var getExtent = function (extent1, extent2) {
return ol.extent.getIntersection(extent1, extent2);
};
- var promiseLayerGroup = function(layer, extent, viewState, pixelRatio, map) {
- return new Promise(function(resolve, reject) {
+ var promiseLayerGroup = function (layer, extent, viewState, pixelRatio, map) {
+ return new Promise(function (resolve, reject) {
var layers, layerPromiseArray;
layers = layer.values_.layers;
if (layer.values_.layers) {
@@ -103,21 +102,21 @@ wv.map.precachetile = wv.map.precachetile || function(models, config, cache, par
} else {
layers = [layer];
}
- layerPromiseArray = layers.map(function(layer) {
+ layerPromiseArray = layers.map(function (layer) {
extent = calculateExtent(layer.getExtent(), map.getView()
.calculateExtent(map.getSize()));
return promiseTileLayer(layer, extent, viewState, pixelRatio);
});
Promise.all(layerPromiseArray)
- .then(function(yo) {
+ .then(function (yo) {
resolve('reslove layer group');
});
});
};
- var promiseTileLayer = function(layer, extent, viewState, pixelRatio) {
+ var promiseTileLayer = function (layer, extent, viewState, pixelRatio) {
var renderer, tileSource, currentZ, i, tileGrid, projection;
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
if (!extent) {
resolve('reslove tile layer');
}
@@ -127,11 +126,11 @@ wv.map.precachetile = wv.map.precachetile || function(models, config, cache, par
tileSource = layer.getSource();
tileGrid = tileSource.getTileGridForProjection(projection);
currentZ = tileGrid.getZForResolution(viewState.resolution, renderer.zDirection);
- tileGrid.forEachTileCoord(extent, currentZ, function(tileCoord) {
+ tileGrid.forEachTileCoord(extent, currentZ, function (tileCoord) {
var tile;
tile = tileSource.getTile(tileCoord[0], tileCoord[1], tileCoord[2], pixelRatio, projection);
tile.load();
- var loader = function(e) {
+ var loader = function (e) {
if (e.type === 'tileloadend') {
--i;
if (i === 0) {
@@ -139,7 +138,7 @@ wv.map.precachetile = wv.map.precachetile || function(models, config, cache, par
}
} else {
reject(new Error('No response at this URL'));
- //resolve();// some gibs data is not accurate and rejecting this will break the animation if tile doesn't exist
+ // resolve();// some gibs data is not accurate and rejecting this will break the animation if tile doesn't exist
}
this.un('tileloadend', loader); // remove event listeners from memory
this.un('tileloaderror', loader);
diff --git a/web/js/map/wv.map.rotate.js b/web/js/map/wv.map.rotate.js
index 145610d1f..5005c5620 100644
--- a/web/js/map/wv.map.rotate.js
+++ b/web/js/map/wv.map.rotate.js
@@ -4,7 +4,7 @@ wv.map = wv.map || {};
/*
* @Class
*/
-wv.map.rotate = wv.map.rotate || function(ui, models, map) {
+wv.map.rotate = wv.map.rotate || function (ui, models, map) {
this.evts = wv.util.events();
var model = models.map;
this.intervalId = null;
@@ -22,7 +22,7 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {
*
* @returns {void}
*/
- this.init = function(map, id) {
+ this.init = function (map, id) {
this.buildRotationWidget(map);
this.setRotationEvents(map, id);
};
@@ -36,24 +36,24 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {
*
* @returns {void}
*/
- this.buildRotationWidget = function(map) {
- var $map = $("#" + map.getTarget());
- var $rotateLeftButton = $("<button></button>")
- .addClass("wv-map-rotate-left wv-map-zoom")
- .attr("title", "You may also rotate by holding Alt and dragging the mouse");
- var $lefticon = $("<i></i>")
- .addClass("fa fa-undo");
-
- var $rotateRightButton = $("<button></button>")
- .addClass("wv-map-rotate-right wv-map-zoom")
- .attr("title", "You may also rotate by holding Alt and dragging the mouse");
- var $righticon = $("<i></i>")
- .addClass("fa fa-repeat");
-
- var $resetButton = $("<button></button>")
- .addClass("wv-map-reset-rotation wv-map-zoom")
- .attr("title", "Click to reset")
- .attr("style", "width: 43px");
+ this.buildRotationWidget = function (map) {
+ var $map = $('#' + map.getTarget());
+ var $rotateLeftButton = $('<button></button>')
+ .addClass('wv-map-rotate-left wv-map-zoom')
+ .attr('title', 'You may also rotate by holding Alt and dragging the mouse');
+ var $lefticon = $('<i></i>')
+ .addClass('fa fa-undo');
+
+ var $rotateRightButton = $('<button></button>')
+ .addClass('wv-map-rotate-right wv-map-zoom')
+ .attr('title', 'You may also rotate by holding Alt and dragging the mouse');
+ var $righticon = $('<i></i>')
+ .addClass('fa fa-repeat');
+
+ var $resetButton = $('<button></button>')
+ .addClass('wv-map-reset-rotation wv-map-zoom')
+ .attr('title', 'Click to reset')
+ .attr('style', 'width: 43px');
$rotateLeftButton.append($lefticon);
$rotateRightButton.append($righticon);
@@ -73,38 +73,36 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {
*
* @returns {void}
*/
- this.setRotationEvents = function(map, id) {
+ this.setRotationEvents = function (map, id) {
var dur = 500;
var $leftButton = $('#wv-map-' + id + ' .wv-map-rotate-left');
var $rightButton = $('#wv-map-' + id + ' .wv-map-rotate-right');
var $resetButton = $('#wv-map-' + id + ' .wv-map-reset-rotation');
- //Set buttons to animate rotation by 18 degrees. use setInterval to repeat the rotation when mouse button is held
+ // Set buttons to animate rotation by 18 degrees. use setInterval to repeat the rotation when mouse button is held
$leftButton.button({
text: false
})
- .mousedown(function() {
- self.intervalId = setInterval(function() {
+ .mousedown(function () {
+ self.intervalId = setInterval(function () {
self.rotate(10, dur, map);
}, dur);
self.rotate(10, dur, map);
-
})
- .mouseup(function() {
+ .mouseup(function () {
clearInterval(self.intervalId);
});
$rightButton.button({
text: false
})
- .mousedown(function() {
- self.intervalId = setInterval(function() {
+ .mousedown(function () {
+ self.intervalId = setInterval(function () {
self.rotate(-10, dur, map);
}, dur);
self.rotate(-10, dur, map);
-
})
- .mouseup(function() {
+ .mouseup(function () {
clearInterval(self.intervalId);
});
@@ -112,15 +110,15 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {
label: Number(models.map.rotation * (180 / Math.PI))
.toFixed()
})
- .mousedown(function() { //reset rotation
- clearInterval(self.intervalId); //stop repeating rotation on mobile
+ .mousedown(function () { // reset rotation
+ clearInterval(self.intervalId); // stop repeating rotation on mobile
map.getView()
.animate({
duration: 500,
rotation: 0
});
- $resetButton.button("option", "label", "0");
+ $resetButton.button('option', 'label', '0');
});
};
@@ -133,7 +131,7 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {
* This ensures the maximum degrees never exceeds +/- 360.
* The current view is then set to this new value.
*/
- this.saveRotation = function(currentDeg, currentView) {
+ this.saveRotation = function (currentDeg, currentView) {
if (Math.abs(currentDeg) === 360) {
currentView.setRotation(0);
} else if (Math.abs(currentDeg) >= 360) {
@@ -154,7 +152,7 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {
*
* @returns {void}
*/
- this.updateRotation = function() {
+ this.updateRotation = function () {
var deg,
radians,
currentView,
@@ -180,28 +178,28 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {
*
* @returns {void}
*/
- this.setResetButton = function(radians) {
- var button = $(".wv-map-reset-rotation");
+ this.setResetButton = function (radians) {
+ var button = $('.wv-map-reset-rotation');
var deg = radians * (180.0 / Math.PI);
- //Set reset button content
- button.button("option", "label", Number(deg % 360)
+ // Set reset button content
+ button.button('option', 'label', Number(deg % 360)
.toFixed());
switch (true) {
case (deg >= 100.0):
- button.find("span")
- .attr("style", "padding-left: 9px");
+ button.find('span')
+ .attr('style', 'padding-left: 9px');
break;
case (deg <= -100.0):
- button.find("span")
- .attr("style", "padding-left: 6px");
+ button.find('span')
+ .attr('style', 'padding-left: 6px');
break;
case (deg <= -10.0):
- button.find("span")
- .attr("style", "padding-left: 10px");
+ button.find('span')
+ .attr('style', 'padding-left: 10px');
break;
default:
- button.find("span")
- .attr("style", "padding-left: 14px");
+ button.find('span')
+ .attr('style', 'padding-left: 14px');
break;
}
};
@@ -220,8 +218,7 @@ wv.map.rotate = wv.map.rotate || function(ui, models, map) {
*
* @returns {void}
*/
- this.rotate = function(amount, duration, map) {
-
+ this.rotate = function (amount, duration, map) {
var currentDeg = (map.getView()
.getRotation() * (180.0 / Math.PI));
diff --git a/web/js/map/wv.map.runningdata.js b/web/js/map/wv.map.runningdata.js
index 14974698a..5e88fdbeb 100644
--- a/web/js/map/wv.map.runningdata.js
+++ b/web/js/map/wv.map.runningdata.js
@@ -1,7 +1,7 @@
var wv = wv || {};
wv.map = wv.map || {};
-wv.map.runningdata = wv.map.runningdata || function(models) {
+wv.map.runningdata = wv.map.runningdata || function (models) {
var self;
var $productsBox;
var productsBoxHeight;
@@ -10,21 +10,19 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
self = this;
-
self.layers = [];
self.prePixelData = [];
self.pixel = null;
self.oldLayers = [];
-
- self.init = function() {
+ self.init = function () {
$productsBox = $('#products');
productsBoxHeight = $productsBox.height();
productsBoxTop = $productsBox.scrollTop();
productsBoxBottom = productsBoxTop + productsBoxHeight;
- models.layers.events.on('change', function() { //when layers are added or removed
- //hacky timeout that allows onchange changes to render
- setTimeout(function() {
+ models.layers.events.on('change', function () { // when layers are added or removed
+ // hacky timeout that allows onchange changes to render
+ setTimeout(function () {
productsBoxHeight = $productsBox.height();
productsBoxBottom = productsBoxTop + productsBoxHeight;
}, 300);
@@ -34,10 +32,9 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* A scroll event listener that updates
* the location of scroller
*/
- $productsBox.on('scroll', function() {
+ $productsBox.on('scroll', function () {
productsBoxTop = $productsBox.scrollTop();
productsBoxBottom = productsBoxTop + productsBoxHeight;
-
});
};
@@ -57,7 +54,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
*
* @return {object}
*/
- self.getDataLabel = function(legend, hex) {
+ self.getDataLabel = function (legend, hex) {
var units = legend.units || '';
// for(var i = 0, len = legend.colors.length; i < len; i++) {
// if(legend.colors[i] === hex) {
@@ -96,7 +93,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {number} margin-left value of label
*
*/
- self.getLabelMarginLeft = function(labelWidth, caseWidth, location) {
+ self.getLabelMarginLeft = function (labelWidth, caseWidth, location) {
if (location + (labelWidth / 2) > caseWidth) {
return (caseWidth - labelWidth) - 5;
} else if (location - (labelWidth / 2) < 0) {
@@ -116,7 +113,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Boolean} legend is visible
*
*/
- var layerIsInView = function(layerID) {
+ var layerIsInView = function (layerID) {
var elTop;
var elBottom;
var $case = $(".productsitem[data-layer='" + layerID + "']");
@@ -142,7 +139,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Object} Jquery palette dom object
*
*/
- self.getPalette = function(id) {
+ self.getPalette = function (id) {
return $(document.getElementById(id));
};
@@ -160,7 +157,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* palette.scale.colors array
*
*/
- self.getPercent = function(len, index, caseWidth) {
+ self.getPercent = function (len, index, caseWidth) {
var segmentWidth;
var location;
if (len < 250) {
@@ -186,7 +183,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Array} Array of layers to remove
*
*/
- self.LayersToRemove = function(oldArray, newArray) {
+ self.LayersToRemove = function (oldArray, newArray) {
return _.difference(oldArray, newArray);
};
@@ -203,9 +200,9 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Void}
*
*/
- self.newPoint = function(coords, map) {
+ self.newPoint = function (coords, map) {
self.activeLayers = [];
- map.forEachLayerAtPixel(coords, function(layer, data) {
+ map.forEachLayerAtPixel(coords, function (layer, data) {
var hex;
var palette;
var legend;
@@ -222,10 +219,9 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
legends = models.palettes.getLegends(layerId);
hex = wv.util.rgbaToHex(data[0], data[1], data[2], data[3]);
- _.each(legends, function(legend) {
+ _.each(legends, function (legend) {
if (legend) {
self.createRunnerFromLegend(legend, hex);
-
}
});
}
@@ -241,12 +237,11 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Void}
*
*/
- self.update = function() {
+ self.update = function () {
if (self.oldLayers.length) {
self.updateRunners(self.LayersToRemove(self.oldLayers, self.activeLayers));
}
self.oldLayers = self.activeLayers;
-
};
/*
* Initiates new legend
@@ -260,7 +255,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Void}
*
*/
- self.newLegend = function(legends, hex) {
+ self.newLegend = function (legends, hex) {
self.activeLayers = [legends.id];
$productsBox.addClass('active-lengend');
self.createRunnerFromLegend(legends, hex);
@@ -280,7 +275,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Void}
*
*/
- self.createRunnerFromLegend = function(legend, hex) {
+ self.createRunnerFromLegend = function (legend, hex) {
var paletteInfo;
if (legend.type === 'continuous' || legend.type === 'discrete') {
@@ -309,13 +304,13 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Void}
*
*/
- self.remove = function(id) {
+ self.remove = function (id) {
var $palette = $('#' + id);
var $paletteCase = $palette.parent();
$paletteCase.removeClass('wv-running');
$palette.removeClass('wv-running');
};
- self.clearAll = function() {
+ self.clearAll = function () {
$productsBox.removeClass('active-lengend');
$('.wv-running')
.removeClass('wv-running');
@@ -335,7 +330,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Void}
*
*/
- self.setCategoryValue = function(id, data) {
+ self.setCategoryValue = function (id, data) {
var $categoryPaletteCase;
var $caseWidth;
var $labelWidth;
@@ -383,7 +378,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Void}
*
*/
- self.setLayerValue = function(id, data) {
+ self.setLayerValue = function (id, data) {
var $palette;
var $paletteCase;
var $paletteWidth;
@@ -423,7 +418,7 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
* @return {Void}
*
*/
- self.updateRunners = function(layers) {
+ self.updateRunners = function (layers) {
if (layers.length) {
for (var i = 0, len = layers.length; i < len; i++) {
self.remove(layers[i]);
diff --git a/web/js/map/wv.map.ui.js b/web/js/map/wv.map.ui.js
index dc3b9cb55..bc9bddb8b 100644
--- a/web/js/map/wv.map.ui.js
+++ b/web/js/map/wv.map.ui.js
@@ -4,9 +4,9 @@ wv.map = wv.map || {};
/*
* @Class
*/
-wv.map.ui = wv.map.ui || function(models, config, components) {
- var id = "wv-map";
- var selector = "#" + id;
+wv.map.ui = wv.map.ui || function (models, config, components) {
+ var id = 'wv-map';
+ var selector = '#' + id;
var cache = new Cache(400); // Save layers from days visited
var animationDuration = 250;
var self = {};
@@ -39,34 +39,34 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var init = function() {
+ var init = function () {
if (config.parameters.mockMap) {
return;
}
// NOTE: iOS sometimes bombs if this is _.each instead. In that case,
// it is possible that config.projections somehow becomes array-like.
- _.forOwn(config.projections, function(proj) {
+ _.forOwn(config.projections, function (proj) {
var map = createMap(proj);
self.proj[proj.id] = map;
});
- models.proj.events.on("select", function() {
+ models.proj.events.on('select', function () {
updateProjection();
});
models.layers.events
- .on("add", addLayer)
- .on("remove", removeLayer)
- .on("visibility", updateLayerVisibilities)
- .on("opacity", updateOpacity)
- .on("update", updateLayerOrder);
- models.date.events.on("select", updateDate);
+ .on('add', addLayer)
+ .on('remove', removeLayer)
+ .on('visibility', updateLayerVisibilities)
+ .on('opacity', updateOpacity)
+ .on('update', updateLayerOrder);
+ models.date.events.on('select', updateDate);
models.palettes.events
- .on("set-custom", updateLookup)
- .on("clear-custom", updateLookup)
- .on("range", updateLookup)
- .on("update", updateLookup);
+ .on('set-custom', updateLookup)
+ .on('clear-custom', updateLookup)
+ .on('range', updateLookup)
+ .on('update', updateLookup);
$(window)
- .on("resize", onResize);
+ .on('resize', onResize);
updateProjection(true);
};
/*
@@ -79,7 +79,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var updateProjection = function(start) {
+ var updateProjection = function (start) {
if (self.selected) {
// Keep track of center point on projection switch
self.selected.previousCenter = self.selected.center;
@@ -89,9 +89,8 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
var map = self.selected;
reloadLayers();
- //Update the rotation buttons if polar projection to display correct value
- if (models.proj.selected.id !== "geographic")
- rotation.setResetButton(models.map.rotation);
+ // Update the rotation buttons if polar projection to display correct value
+ if (models.proj.selected.id !== 'geographic') { rotation.setResetButton(models.map.rotation); }
// If the browser was resized, the inactive map was not notified of
// the event. Force the update no matter what and reposition the center
@@ -109,7 +108,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
var extent = null;
if (models.map.extent) {
extent = models.map.extent;
- } else if (!models.map.extent && projId === "geographic") {
+ } else if (!models.map.extent && projId === 'geographic') {
extent = models.map.getLeadingExtent();
}
if (extent) {
@@ -130,7 +129,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var onResize = function() {
+ var onResize = function () {
var map = self.selected;
if (map.small !== wv.util.browser.small) {
if (wv.util.browser.small) {
@@ -156,8 +155,8 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var hideMap = function(map) {
- $("#" + map.getTarget())
+ var hideMap = function (map) {
+ $('#' + map.getTarget())
.hide();
};
/*
@@ -170,8 +169,8 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var showMap = function(map) {
- $("#" + map.getTarget())
+ var showMap = function (map) {
+ $('#' + map.getTarget())
.show();
};
/*
@@ -184,11 +183,11 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var clearLayers = function(map) {
+ var clearLayers = function (map) {
var activeLayers = map.getLayers()
.getArray()
.slice(0);
- _.each(activeLayers, function(mapLayer) {
+ _.each(activeLayers, function (mapLayer) {
if (mapLayer.wv) {
map.removeLayer(mapLayer);
}
@@ -207,14 +206,14 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var reloadLayers = function(map) {
+ var reloadLayers = function (map) {
map = map || self.selected;
clearLayers(map);
var defs = models.layers.get({
reverse: true
});
- _.each(defs, function(def) {
+ _.each(defs, function (def) {
if (isGraticule(def)) {
addGraticule();
} else {
@@ -232,16 +231,16 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var updateLayerVisibilities = function() {
+ var updateLayerVisibilities = function () {
var layers = self.selected.getLayers();
- layers.forEach(function(layer) {
+ layers.forEach(function (layer) {
if (layer.wv) {
var renderable = models.layers.isRenderable(layer.wv.id);
layer.setVisible(renderable);
}
});
var defs = models.layers.get();
- _.each(defs, function(def) {
+ _.each(defs, function (def) {
if (isGraticule(def)) {
var renderable = models.layers.isRenderable(def.id);
if (renderable) {
@@ -264,7 +263,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var updateOpacity = function(def, value) {
+ var updateOpacity = function (def, value) {
var layer = findLayer(def);
layer.setOpacity(value);
updateLayerVisibilities();
@@ -280,7 +279,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
* @returns {void}
*/
- var addLayer = function(def) {
+ var addLayer = function (def) {
var mapIndex = _.findIndex(models.layers.get({
reverse: true
}), {
@@ -305,7 +304,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var removeLayer = function(def) {
+ var removeLayer = function (def) {
if (isGraticule(def)) {
removeGraticule();
} else {
@@ -324,7 +323,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var updateLayerOrder = function() {
+ var updateLayerOrder = function () {
reloadLayers();
};
@@ -337,10 +336,10 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var updateDate = function() {
+ var updateDate = function () {
var defs = models.layers.get();
- _.each(defs, function(def) {
- if (def.period !== "daily") {
+ _.each(defs, function (def) {
+ if (def.period !== 'daily') {
return;
}
var index = findLayerIndex(def);
@@ -360,12 +359,12 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var updateLookup = function(layerId) {
+ var updateLookup = function (layerId) {
// If the lookup changes, all layers in the cache are now stale
// since the tiles need to be rerendered. Remove from cache.
var selectedDate = wv.util.toISOStringDate(models.date.selected);
var selectedProj = models.proj.selected.id;
- cache.removeWhere(function(key, mapLayer) {
+ cache.removeWhere(function (key, mapLayer) {
if (mapLayer.wvid === layerId &&
mapLayer.wvproj === selectedProj &&
mapLayer.wvdate !== selectedDate &&
@@ -376,7 +375,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
});
reloadLayers();
};
- self.getCustomLayerTimeout = function(layer) {
+ self.getCustomLayerTimeout = function (layer) {
if (models.palettes.isActive(layer.id)) {
return 200;
}
@@ -393,7 +392,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {object} Layer object
*/
- var findLayer = function(def) {
+ var findLayer = function (def) {
var layers = self.selected.getLayers()
.getArray();
var layer = _.find(layers, {
@@ -415,7 +414,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {number} Index of layer in OpenLayers layer array
*/
- var findLayerIndex = function(def) {
+ var findLayerIndex = function (def) {
var layers = self.selected.getLayers()
.getArray();
var layer = _.findIndex(layers, {
@@ -439,10 +438,10 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {boolean}
*/
- var isGraticule = function(def) {
+ var isGraticule = function (def) {
var proj = models.proj.selected.id;
- return (def.projections[proj].type === "graticule" ||
- def.type === "graticule");
+ return (def.projections[proj].type === 'graticule' ||
+ def.type === 'graticule');
};
/*
@@ -456,9 +455,8 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var addGraticule = function() {
- if (self.selected.graticule)
- return;
+ var addGraticule = function () {
+ if (self.selected.graticule) { return; }
self.selected.graticule = new ol.Graticule({
map: self.selected,
@@ -480,15 +478,14 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var removeGraticule = function() {
- if (self.selected.graticule)
- self.selected.graticule.setMap(null);
+ var removeGraticule = function () {
+ if (self.selected.graticule) { self.selected.graticule.setMap(null); }
self.selected.graticule = null;
};
- var triggerExtent = _.throttle(function() {
- self.events.trigger("extent");
+ var triggerExtent = _.throttle(function () {
+ self.events.trigger('extent');
}, 500, {
trailing: true
});
@@ -502,7 +499,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var updateExtent = function() {
+ var updateExtent = function () {
var map = self.selected;
models.map.update(map.getView()
.calculateExtent(map.getSize()));
@@ -520,27 +517,27 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {object} OpenLayers Map Object
*/
- var createMap = function(proj) {
+ var createMap = function (proj) {
var id, $map, scaleMetric, scaleImperial, rotateInteraction,
map, mobileRotation, lineSvgs, resolution;
- id = "wv-map-" + proj.id;
- $map = $("<div></div>")
- .attr("id", id)
- .attr("data-proj", proj.id)
- .addClass("wv-map")
+ id = 'wv-map-' + proj.id;
+ $map = $('<div></div>')
+ .attr('id', id)
+ .attr('data-proj', proj.id)
+ .addClass('wv-map')
.hide();
$(selector)
.append($map);
- //Create two specific controls
+ // Create two specific controls
scaleMetric = new ol.control.ScaleLine({
- className: "wv-map-scale-metric",
- units: "metric"
+ className: 'wv-map-scale-metric',
+ units: 'metric'
});
scaleImperial = new ol.control.ScaleLine({
- className: "wv-map-scale-imperial",
- units: "imperial"
+ className: 'wv-map-scale-imperial',
+ units: 'imperial'
});
rotateInteraction = new ol.interaction.DragRotate({
@@ -555,14 +552,14 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
maxResolution: proj.resolutions[0],
projection: ol.proj.get(proj.crs),
center: proj.startCenter,
- rotation: proj.id === "geographic" ? 0.0 : models.map.rotation,
+ rotation: proj.id === 'geographic' ? 0.0 : models.map.rotation,
zoom: proj.startZoom,
maxZoom: proj.numZoomLevels,
enableRotation: true,
- extent: proj.id === "geographic" ? [-250, -90, 250, 90] : proj.maxExtent,
+ extent: proj.id === 'geographic' ? [-250, -90, 250, 90] : proj.maxExtent
}),
target: id,
- renderer: ["canvas"],
+ renderer: ['canvas'],
logo: false,
controls: [
scaleMetric,
@@ -595,7 +592,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
createZoomButtons(map, proj);
createMousePosSel(map, proj);
- //allow rotation by dragging for polar projections
+ // allow rotation by dragging for polar projections
if (proj.id !== 'geographic') {
rotation.init(map, proj.id);
map.addInteraction(rotateInteraction);
@@ -606,26 +603,26 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
// Set event listeners for changes on the map view (when rotated, zoomed, panned)
map.getView()
- .on("change:center", updateExtent);
+ .on('change:center', updateExtent);
map.getView()
- .on("change:resolution", updateExtent);
+ .on('change:resolution', updateExtent);
map.getView()
- .on("change:rotation", _.throttle(onRotate, 300));
- map.on('pointerdrag', function() {
+ .on('change:rotation', _.throttle(onRotate, 300));
+ map.on('pointerdrag', function () {
self.mapIsbeingDragged = true;
self.events.trigger('drag');
});
map.getView()
- .on('propertychange', function(e) {
+ .on('propertychange', function (e) {
switch (e.key) {
case 'resolution':
self.mapIsbeingZoomed = true;
break;
}
});
- map.on('moveend', function(e) {
+ map.on('moveend', function (e) {
self.events.trigger('moveend');
- setTimeout(function() {
+ setTimeout(function () {
self.mapIsbeingDragged = false;
self.mapIsbeingZoomed = false;
}, 200);
@@ -646,16 +643,16 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var createZoomButtons = function(map, proj) {
- var $map = $("#" + map.getTarget());
-
- var $zoomOut = $("<button></button>")
- .addClass("wv-map-zoom-out")
- .addClass("wv-map-zoom");
- var $outIcon = $("<i></i>")
- .addClass("fa")
- .addClass("fa-minus")
- .addClass("fa-1x");
+ var createZoomButtons = function (map, proj) {
+ var $map = $('#' + map.getTarget());
+
+ var $zoomOut = $('<button></button>')
+ .addClass('wv-map-zoom-out')
+ .addClass('wv-map-zoom');
+ var $outIcon = $('<i></i>')
+ .addClass('fa')
+ .addClass('fa-minus')
+ .addClass('fa-1x');
$zoomOut.append($outIcon);
$map.append($zoomOut);
$zoomOut.button({
@@ -663,13 +660,13 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
});
$zoomOut.click(zoomAction(map, -1));
- var $zoomIn = $("<button></button>")
- .addClass("wv-map-zoom-in")
- .addClass("wv-map-zoom");
- var $inIcon = $("<i></i>")
- .addClass("fa")
- .addClass("fa-plus")
- .addClass("fa-1x");
+ var $zoomIn = $('<button></button>')
+ .addClass('wv-map-zoom-in')
+ .addClass('wv-map-zoom');
+ var $inIcon = $('<i></i>')
+ .addClass('fa')
+ .addClass('fa-plus')
+ .addClass('fa-1x');
$zoomIn.append($inIcon);
$map.append($zoomIn);
$zoomIn.button({
@@ -687,30 +684,30 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
* @returns {void}
*
*/
- var onZoomChange = function() {
+ var onZoomChange = function () {
var maxZoom = proj.resolutions.length;
var zoom = map.getView()
.getZoom();
if (zoom === 0) {
- $zoomIn.button("enable");
- $zoomOut.button("disable");
+ $zoomIn.button('enable');
+ $zoomOut.button('disable');
} else if (zoom === maxZoom) {
- $zoomIn.button("disable");
- $zoomOut.button("enable");
+ $zoomIn.button('disable');
+ $zoomOut.button('enable');
} else {
- $zoomIn.button("enable");
- $zoomOut.button("enable");
+ $zoomIn.button('enable');
+ $zoomOut.button('enable');
}
};
map.getView()
- .on("change:resolution", function() {
+ .on('change:resolution', function () {
onZoomChange();
self.events.trigger('movestart');
});
onZoomChange();
};
- var onRotate = function() {
+ var onRotate = function () {
rotation.updateRotation();
updateExtent();
};
@@ -730,7 +727,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @todo move this component to another Location
*/
- var createMousePosSel = function(map, proj) {
+ var createMousePosSel = function (map, proj) {
var $map;
var mapId;
var $mousePosition;
@@ -742,18 +739,17 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
var hoverThrottle;
var extent;
-
// var timer = null;
// var isIntervalSet = false;
- $map = $("#" + map.getTarget());
+ $map = $('#' + map.getTarget());
map = map || self.selected;
mapId = 'coords-' + proj.id;
extent = proj.maxExtent;
$mousePosition = $('<div></div>')
- .attr("id", mapId)
- .addClass("wv-coords-map wv-coords-map-btn");
+ .attr('id', mapId)
+ .addClass('wv-coords-map wv-coords-map-btn');
/*
* Creates map events based on mouse position
@@ -766,31 +762,29 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- coordinateFormat = function(source, format, outsideExtent) {
-
+ coordinateFormat = function (source, format, outsideExtent) {
var target, crs;
- crs = (models.proj.change) ? models.proj.change.crs :
- models.proj.selected.crs;
+ crs = (models.proj.change) ? models.proj.change.crs
+ : models.proj.selected.crs;
if (outsideExtent) {
return crs;
}
- target = ol.proj.transform(source, proj.crs, "EPSG:4326");
- return wv.util.formatCoordinate(target, format) + " " + crs;
+ target = ol.proj.transform(source, proj.crs, 'EPSG:4326');
+ return wv.util.formatCoordinate(target, format) + ' ' + crs;
};
$map.append($mousePosition);
- $latlonDD = $("<span></span>")
+ $latlonDD = $('<span></span>')
.attr('id', mapId + '-latlon-dd')
.attr('data-format', 'latlon-dd')
.addClass('map-coord');
- $latlonDMS = $("<span></span>")
+ $latlonDMS = $('<span></span>')
.attr('id', mapId + '-latlon-dms')
.attr('data-format', 'latlon-dms')
.addClass('map-coord');
-
- if (wv.util.getCoordinateFormat() === "latlon-dd") {
+ if (wv.util.getCoordinateFormat() === 'latlon-dd') {
$('div.map-coord')
.removeClass('latlon-selected');
$latlonDD.addClass('latlon-selected');
@@ -799,10 +793,10 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
.removeClass('latlon-selected');
$latlonDMS.addClass('latlon-selected');
}
- $coordBtn = $("<i></i>")
+ $coordBtn = $('<i></i>')
.addClass('coord-switch');
- $coordWrapper = $("<div></div>")
+ $coordWrapper = $('<div></div>')
.addClass('coord-btn');
$coordWrapper.append($coordBtn);
@@ -811,11 +805,11 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
.append($latlonDD)
.append($latlonDMS)
.append($coordWrapper)
- .click(function() {
+ .click(function () {
var $format = $(this)
- .find(".latlon-selected");
+ .find('.latlon-selected');
- if ($format.attr("data-format") === "latlon-dd") {
+ if ($format.attr('data-format') === 'latlon-dd') {
$('span.map-coord')
.removeClass('latlon-selected');
$('span.map-coord[data-format="latlon-dms"]')
@@ -828,10 +822,9 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
.addClass('latlon-selected');
wv.util.setCoordinateFormat('latlon-dd');
}
-
});
- function onMouseMove(e) {
+ function onMouseMove (e) {
var coords;
var pixels;
var outside;
@@ -864,7 +857,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
$('#' + mapId)
.show();
$('#' + mapId + ' span.map-coord')
- .each(function() {
+ .each(function () {
var format = $(this)
.attr('data-format');
$(this)
@@ -875,8 +868,8 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
if (self.mapIsbeingDragged || wv.util.browser.small) {
return;
}
- if (typeof models.naturalEvents == 'undefined' ||
- typeof models.data == 'undefined' ||
+ if (typeof models.naturalEvents === 'undefined' ||
+ typeof models.data === 'undefined' ||
models.naturalEvents.active || models.data.active) {
return;
}
@@ -888,7 +881,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
dataRunner.newPoint(pixels, map);
}
$(map.getViewport())
- .mouseover(function(e) {
+ .mouseover(function (e) {
if ($(e.relatedTarget)
.hasClass('map-coord') ||
$(e.relatedTarget)
@@ -898,7 +891,7 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
$('#' + mapId)
.show();
})
- .mouseout(function(e) {
+ .mouseout(function (e) {
if ($(e.relatedTarget)
.hasClass('map-coord') ||
$(e.relatedTarget)
@@ -925,8 +918,8 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
*
* @returns {void}
*/
- var zoomAction = function(map, amount) {
- return function() {
+ var zoomAction = function (map, amount) {
+ return function () {
var view = map.getView();
var zoom = view.getZoom();
view.animate({
@@ -938,5 +931,4 @@ wv.map.ui = wv.map.ui || function(models, config, components) {
init();
return self;
-
};
diff --git a/web/js/naturalEvents/wv.naturalEvents.markers.js b/web/js/naturalEvents/wv.naturalEvents.markers.js
index c730325ed..e34fff2df 100644
--- a/web/js/naturalEvents/wv.naturalEvents.markers.js
+++ b/web/js/naturalEvents/wv.naturalEvents.markers.js
@@ -1,15 +1,15 @@
var wv = wv || {};
wv.naturalEvents = wv.naturalEvents || {};
-wv.naturalEvents.markers = wv.naturalEvents.markers || function(models, ui) {
+wv.naturalEvents.markers = wv.naturalEvents.markers || function (models, ui) {
var self = {}, map;
map = map || ui.map.selected;
var olViewport = map.getViewport();
- self.draw = function() {
+ self.draw = function () {
if (!(models.naturalEvents && models.naturalEvents.data)) return null;
var events = models.naturalEvents.data.events;
if (!events) return null;
- var markers = events.map(function(event){
+ var markers = events.map(function (event) {
var marker = {};
var selected = ui.naturalEvents.selected;
var isSelected = event.id === selected.id;
@@ -19,7 +19,7 @@ wv.naturalEvents.markers = wv.naturalEvents.markers || function(models, ui) {
date = selected.date;
}
- var geometry = _.find(event.geometries, function(geom){
+ var geometry = _.find(event.geometries, function (geom) {
return geom.date.split('T')[0] === date;
}) || event.geometries[0];
@@ -29,16 +29,16 @@ wv.naturalEvents.markers = wv.naturalEvents.markers || function(models, ui) {
var category = event.categories[0];
// Assign a default category if we don't have an icon
var icons = [
- "Dust and Haze",
- "Icebergs",
- "Manmade",
- "Sea and Lake Ice",
- "Severe Storms",
- "Snow",
- "Temperature Extremes",
- "Volcanoes",
- "Water Color",
- "Wildfires"
+ 'Dust and Haze',
+ 'Icebergs',
+ 'Manmade',
+ 'Sea and Lake Ice',
+ 'Severe Storms',
+ 'Snow',
+ 'Temperature Extremes',
+ 'Volcanoes',
+ 'Water Color',
+ 'Wildfires'
];
category = icons.includes(category.title)
? category
@@ -61,30 +61,40 @@ wv.naturalEvents.markers = wv.naturalEvents.markers || function(models, ui) {
var willSelect = true;
var moveCount = 0;
var pinEl = marker.pin.element_;
- ['pointerdown', 'mousedown', 'touchstart'].forEach(function(type){
- pinEl.addEventListener(type, function(e){
+
+ ['pointerdown', 'mousedown', 'touchstart'].forEach(function (type) {
+ pinEl.addEventListener(type, function (e) {
willSelect = true;
moveCount = 0;
passEventToTarget(e, olViewport);
});
});
- ['pointermove', 'wheel', 'pointerdrag',
- 'pointerup', 'mousemove', 'touchmove'].forEach(function(type){
- pinEl.addEventListener(type, function(e){
+
+ [
+ 'pointermove',
+ 'wheel',
+ 'pointerdrag',
+ 'pointerup',
+ 'mousemove',
+ 'touchmove'
+ ].forEach(function (type) {
+ pinEl.addEventListener(type, function (e) {
passEventToTarget(e, olViewport);
});
});
- ['pointermove', 'mousemove'].forEach(function(type){
- pinEl.addEventListener(type, function(e){
+
+ ['pointermove', 'mousemove'].forEach(function (type) {
+ pinEl.addEventListener(type, function (e) {
moveCount++;
if (moveCount > 2) {
willSelect = false;
}
});
});
- pinEl.addEventListener('click', function(e){
+
+ pinEl.addEventListener('click', function (e) {
if (willSelect && !isSelected) {
- ui.naturalEvents.selectEvent(event.id,date);
+ ui.naturalEvents.selectEvent(event.id, date);
} else {
passEventToTarget(e, olViewport);
}
@@ -95,16 +105,16 @@ wv.naturalEvents.markers = wv.naturalEvents.markers || function(models, ui) {
return markers;
};
- self.remove = function(markers) {
+ self.remove = function (markers) {
markers = markers || [];
- if (markers.length<1) return;
- markers.forEach(function(marker){
+ if (markers.length < 1) return;
+ markers.forEach(function (marker) {
if (marker.boundingBox) map.removeLayer(marker.boundingBox);
if (marker.pin) map.removeOverlay(marker.pin);
});
};
- var passEventToTarget = function(event, target) {
+ var passEventToTarget = function (event, target) {
try {
var eventCopy = new event.constructor(event.type, event);
target.dispatchEvent(eventCopy);
@@ -113,7 +123,7 @@ wv.naturalEvents.markers = wv.naturalEvents.markers || function(models, ui) {
}
};
- var createPin = function(id, category, isSelected){
+ var createPin = function (id, category, isSelected) {
var overlayEl = document.createElement('div');
var icon = document.createElement('i');
overlayEl.className = 'marker';
@@ -128,12 +138,12 @@ wv.naturalEvents.markers = wv.naturalEvents.markers || function(models, ui) {
});
};
- var createBoundingBox = function(coordinates){
+ var createBoundingBox = function (coordinates) {
var lightStroke = new ol.style.Style({
stroke: new ol.style.Stroke({
color: [255, 255, 255, 0.6],
width: 2,
- lineDash: [4,8],
+ lineDash: [4, 8],
lineDashOffset: 6
})
});
@@ -141,7 +151,7 @@ wv.naturalEvents.markers = wv.naturalEvents.markers || function(models, ui) {
stroke: new ol.style.Stroke({
color: [0, 0, 0, 0.6],
width: 2,
- lineDash: [4,8]
+ lineDash: [4, 8]
})
});
return new ol.layer.Vector({
diff --git a/web/js/naturalEvents/wv.naturalEvents.model.js b/web/js/naturalEvents/wv.naturalEvents.model.js
index c5be2a159..f7c017ad5 100644
--- a/web/js/naturalEvents/wv.naturalEvents.model.js
+++ b/web/js/naturalEvents/wv.naturalEvents.model.js
@@ -7,8 +7,7 @@ wv.naturalEvents = wv.naturalEvents || {};
/**
* @class wv.naturalEvents.model
*/
-wv.naturalEvents.model = wv.naturalEvents.model || function(models, config, ui) {
-
+wv.naturalEvents.model = wv.naturalEvents.model || function (models, config, ui) {
var self = {};
self.selected = null;
self.active = false;
@@ -23,18 +22,18 @@ wv.naturalEvents.model = wv.naturalEvents.model || function(models, config, ui)
*/
self.events = wv.util.events();
- self.save = function(state) {
+ self.save = function (state) {
if (self.active) {
var id = ui.naturalEvents.selected.id;
var date = ui.naturalEvents.selected.date;
- var value = id?date?[id, date].join(','):id:true;
+ var value = id ? date ? [id, date].join(',') : id : true;
state.e = value;
}
};
- self.load = function(state) {
+ self.load = function (state) {
if (!state.e) return;
- models.wv.events.on('startup', function() {
+ models.wv.events.on('startup', function () {
ui.sidebar.selectTab('events');
});
var values = state.e.split(',');
@@ -43,7 +42,7 @@ wv.naturalEvents.model = wv.naturalEvents.model || function(models, config, ui)
id = id.match(/^EONET_[0-9]+/i) ? values[0] : null;
date = date.match(/\d{4}-\d{2}-\d{2}/) ? values[1] : null;
if (id) {
- self.events.on('hasData', function() {
+ self.events.on('hasData', function () {
ui.naturalEvents.selectEvent(id, date);
});
}
diff --git a/web/js/naturalEvents/wv.naturalEvents.request.js b/web/js/naturalEvents/wv.naturalEvents.request.js
index 4c241de2d..3e84015aa 100644
--- a/web/js/naturalEvents/wv.naturalEvents.request.js
+++ b/web/js/naturalEvents/wv.naturalEvents.request.js
@@ -3,12 +3,12 @@ wv.naturalEvents = wv.naturalEvents || {};
/**
* @module wv.naturalEvents.request
*/
-wv.naturalEvents.request = wv.naturalEvents.request || function(models, ui, config) {
+wv.naturalEvents.request = wv.naturalEvents.request || function (models, ui, config) {
var self = {};
self.events = wv.util.events();
- self.EVENT_QUERY_RESULTS = "queryResults";
- self.EVENT_SELECT = "select";
+ self.EVENT_QUERY_RESULTS = 'queryResults';
+ self.EVENT_SELECT = 'select';
self.apiURL = config.features.naturalEvents.host;
var querySuccessFlag = false;
@@ -16,17 +16,17 @@ wv.naturalEvents.request = wv.naturalEvents.request || function(models, ui, conf
self.ignored = config.naturalEvents.skip || [];
model.data = {};
- var init = function() {
- self.events.on("queryResults", onQueryResults);
+ var init = function () {
+ self.events.on('queryResults', onQueryResults);
self.query();
};
- var onQueryResults = function() {
+ var onQueryResults = function () {
if (model.data.sources && model.data.types && model.data.events) {
querySuccessFlag = true;
// Remove types and events for ignored event categories
- var removeIgnoredItems = function(item){
+ var removeIgnoredItems = function (item) {
if (item.categories) {
var category = Array.isArray(item.categories)
? item.categories[0]
@@ -42,10 +42,10 @@ wv.naturalEvents.request = wv.naturalEvents.request || function(models, ui, conf
model.data.types = model.data.types.filter(removeIgnoredItems);
// Sort event geometries by descending date
- model.data.events = model.data.events.map(function(e){
+ model.data.events = model.data.events.map(function (e) {
e.geometries = _.orderBy(e.geometries, 'date', 'desc');
// Discard duplicate geometry dates
- e.geometries = _.uniqBy(e.geometries, function(g){
+ e.geometries = _.uniqBy(e.geometries, function (g) {
return g.date.split('T')[0];
});
return e;
@@ -60,51 +60,51 @@ wv.naturalEvents.request = wv.naturalEvents.request || function(models, ui, conf
}
};
- var queryEvents = function() {
- return new Promise(function(resolve) {
- var url = self.apiURL + "/events";
+ var queryEvents = function () {
+ return new Promise(function (resolve) {
+ var url = self.apiURL + '/events';
if (config.parameters.mockEvents) {
- console.warn("Using mock events data: " + config.parameters.mockEvents);
- url = "mock/events_data.json-" + config.parameters.mockEvents;
+ console.warn('Using mock events data: ' + config.parameters.mockEvents);
+ url = 'mock/events_data.json-' + config.parameters.mockEvents;
}
- $.getJSON(url, function(data) {
+ $.getJSON(url, function (data) {
resolve(data);
});
});
};
- var queryTypes = function() {
- return new Promise(function(resolve) {
- var url = self.apiURL + "/categories";
+ var queryTypes = function () {
+ return new Promise(function (resolve) {
+ var url = self.apiURL + '/categories';
if (config.parameters.mockCategories) {
- console.warn("Using mock categories data: " + config.parameters.mockEvents);
- url = "mock/categories_data.json-" + config.parameters.mockCategories;
+ console.warn('Using mock categories data: ' + config.parameters.mockEvents);
+ url = 'mock/categories_data.json-' + config.parameters.mockCategories;
}
- $.getJSON(url, function(data) {
+ $.getJSON(url, function (data) {
resolve(data);
});
});
};
- var querySources = function() {
- return new Promise(function(resolve) {
- var url = self.apiURL + "/sources";
+ var querySources = function () {
+ return new Promise(function (resolve) {
+ var url = self.apiURL + '/sources';
if (config.parameters.mockSources) {
- console.warn("Using mock sources data: " + config.parameters.mockEvents);
- url = "mock/sources_data.json-" + config.parameters.mockSources;
+ console.warn('Using mock sources data: ' + config.parameters.mockEvents);
+ url = 'mock/sources_data.json-' + config.parameters.mockSources;
}
- $.getJSON(url, function(data) {
+ $.getJSON(url, function (data) {
resolve(data);
});
});
};
- self.query = function() {
+ self.query = function () {
Promise.all([
queryTypes(),
queryEvents(),
querySources()
- ]).then(function(res) {
+ ]).then(function (res) {
model.data.types = res[0].categories;
model.data.events = res[1].events;
model.data.sources = res[2].sources;
diff --git a/web/js/naturalEvents/wv.naturalEvents.ui.js b/web/js/naturalEvents/wv.naturalEvents.ui.js
index bd79fc473..2982a9aad 100644
--- a/web/js/naturalEvents/wv.naturalEvents.ui.js
+++ b/web/js/naturalEvents/wv.naturalEvents.ui.js
@@ -1,19 +1,17 @@
var wv = wv || {};
wv.naturalEvents = wv.naturalEvents || {};
-wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, request) {
-
+wv.naturalEvents.ui = wv.naturalEvents.ui || function (models, ui, config, request) {
var self = {}, eventVisibilityAlert, $footer, view;
var model = models.naturalEvents;
self.markers = [];
self.selected = {};
var naturalEventMarkers = wv.naturalEvents.markers(models, ui, config);
- var init = function() {
-
+ var init = function () {
view = ui.map.selected.getView();
- request.events.on('queryResults', function() {
+ request.events.on('queryResults', function () {
if (!(model.data.events || model.data.sources)) return;
createEventList();
var isZoomed = Math.floor(view.getZoom()) >= 3;
@@ -25,9 +23,9 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
self.markers = naturalEventMarkers.draw();
}
- ui.map.selected.on('moveend', function(e) {
+ ui.map.selected.on('moveend', function (e) {
var isZoomed = Math.floor(view.getZoom()) >= 3;
- if (isZoomed){
+ if (isZoomed) {
self.filterEventList();
} else {
$('.map-item-list .item').show();
@@ -38,14 +36,14 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
// Reselect previously selected event
if (self.selected.id) {
- self.selectEvent(self.selected.id, self.selected.date||null);
+ self.selectEvent(self.selected.id, self.selected.date || null);
}
ui.sidebar.sizeEventsTab();
$(window).resize(ui.sidebar.sizeEventsTab);
});
- ui.sidebar.events.on('selectTab', function(tab) {
+ ui.sidebar.events.on('selectTab', function (tab) {
if (tab === 'events') {
model.active = true;
@@ -68,7 +66,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
});
};
- self.selectEvent = function(id, date) {
+ self.selectEvent = function (id, date) {
var isIdChange = (!self.selected || self.selected.id !== id);
var prevId = self.selected.id ? self.selected.id : false;
var prevEvent = prevId ? getEventById(prevId) : false;
@@ -98,7 +96,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
naturalEventMarkers.remove(self.markers);
// Store markers so the can be referenced later
self.markers = naturalEventMarkers.draw();
- zoomToEvent(event, date).then(function(){
+ zoomToEvent(event, date).then(function () {
if (isIdChange && !isSameCategory) {
activateLayersForCategory(event.categories[0].title);
}
@@ -111,7 +109,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
if (event.categories[0].title === 'Wildfires') {
var now = new Date();
var today = now.toISOString().split('T')[0];
- var yesterday = new Date(now.setDate(now.getDate()-1)).toISOString().split('T')[0];
+ var yesterday = new Date(now.setDate(now.getDate() - 1)).toISOString().split('T')[0];
if (date !== today || date !== yesterday) {
models.date.select(wv.util.dateAdd(wv.util.parseDateUTC(date), 'day', 1));
}
@@ -124,7 +122,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
'Events may not be visible at all times.',
800,
'warning',
- function() {
+ function () {
if (wv.util.browser.localStorage) localStorage.setItem('dismissedEventVisibilityAlert', true);
eventVisibilityAlert.dialog('close');
}
@@ -136,7 +134,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
});
};
- self.deselectEvent = function() {
+ self.deselectEvent = function () {
self.selected = {};
naturalEventMarkers.remove(self.markers);
self.markers = naturalEventMarkers.draw();
@@ -144,7 +142,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
model.events.trigger('change');
};
- self.getDefaultEventDate = function(event) {
+ self.getDefaultEventDate = function (event) {
date = new Date(event.geometries[0].date).toISOString().split('T')[0];
if (event.geometries.length < 2) return date;
var category = event.categories.title || event.categories[0].title;
@@ -156,26 +154,26 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
return date;
};
- self.filterEventList = function(){
+ self.filterEventList = function () {
if (!model.data.events) return;
var extent = view.calculateExtent();
- model.data.events.forEach(function(naturalEvent){
+ model.data.events.forEach(function (naturalEvent) {
var date = self.getDefaultEventDate(naturalEvent);
if (self.selected && self.selected.date) {
date = self.selected.date;
}
- var geometry = _.find(naturalEvent.geometries, function(geometry){
+ var geometry = _.find(naturalEvent.geometries, function (geometry) {
return geometry.date.split('T')[0] == date;
}) || naturalEvent.geometries[0];
var coordinates = geometry.coordinates;
if (geometry.type == 'Polygon') {
var geomExtent = ol.extent.boundingExtent(geometry.coordinates[0]);
- coordinates = ol.extent.getCenter(geomExtent);
+ coordinates = ol.extent.getCenter(geomExtent);
}
var isVisible = ol.extent.containsCoordinate(extent, coordinates);
- var $thisItem = $('.map-item-list .item[data-id='+naturalEvent.id+']');
+ var $thisItem = $('.map-item-list .item[data-id=' + naturalEvent.id + ']');
if (isVisible) {
$thisItem.show();
} else {
@@ -186,13 +184,13 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
ui.sidebar.sizeEventsTab();
};
- var getEventById = function(id) {
- return _.find(model.data.events, function(e){
+ var getEventById = function (id) {
+ return _.find(model.data.events, function (e) {
return e.id === id;
});
};
- var createEventList = function() {
+ var createEventList = function () {
var $panels = $('<div />', {class: 'wv-eventslist bank'});
$('#wv-events').empty().append($panels);
var $list = $('<ul></ul>').attr('id', 'wv-eventscontent').addClass('content').addClass('map-item-list');
@@ -200,7 +198,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
$panels.append($list);
$panels.append($detailContainer);
var $content = $('#wv-eventscontent').empty();
- _.each(model.data.events, function(event) {
+ _.each(model.data.events, function (event) {
$content.append(createEventElement($content, event));
});
@@ -212,7 +210,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
class: 'action',
id: 'show-all-events',
text: 'List All',
- click: function(){
+ click: function () {
$('.map-item-list .item').show();
$footer.hide();
ui.sidebar.sizeEventsTab();
@@ -225,7 +223,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
$footer.hide();
};
- var createEventElement = function($content, event) {
+ var createEventElement = function ($content, event) {
var eventCategoryID = event.categories[0].id || null;
eventDate = wv.util.parseDateUTC(event.geometries[0].date);
dateString = wv.util.giveWeekDay(eventDate) + ', ' +
@@ -253,7 +251,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
if (event.geometries.length > 1) {
var eventIndex = 0;
- _.each(event.geometries, function(geometry) {
+ _.each(event.geometries, function (geometry) {
eventIndex++;
var date = geometry.date.split('T')[0];
var todayDateISOString = wv.util.toISOStringDate(wv.util.today());
@@ -263,7 +261,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
'data-id': event.id,
'data-date': date,
html: date,
- click: function(e) {
+ click: function (e) {
e.stopPropagation();
self.selectEvent(event.id, date);
}
@@ -274,10 +272,10 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
}
$item.append($eventIcon).append($title).append($subtitle).append($dates);
- var references = Array.isArray(event.sources)?event.sources:[event.sources];
+ var references = Array.isArray(event.sources) ? event.sources : [event.sources];
if (references.length > 0) {
items = [];
- _.each(references, function(reference) {
+ _.each(references, function (reference) {
var source = _.find(model.data.sources, {
id: reference.id
});
@@ -291,11 +289,11 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
});
$subtitle.append(items.join(' '));
}
- $('.natural-event-link').click(function(e) {
+ $('.natural-event-link').click(function (e) {
e.stopPropagation();
});
- $item.on('click', function() {
+ $item.on('click', function () {
var isSelected = self.selected && self.selected.id && (self.selected.id === event.id);
if (isSelected) {
self.deselectEvent();
@@ -307,7 +305,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
return $item;
};
- var highlightEventInList = function(id, date) {
+ var highlightEventInList = function (id, date) {
// Undo previous highlights
$('#wv-eventscontent .subtitle').hide();
$('#wv-eventscontent .dates').hide();
@@ -326,19 +324,18 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
ui.sidebar.sizeEventsTab();
};
- var activateLayersForCategory = function(category){
-
+ var activateLayersForCategory = function (category) {
category = category || 'Default';
// Turn on the relevant layers for the event type
layers = model.layers[category];
if (!layers) layers = model.layers.Default;
// Turn off all layers in list first
- _.each(models.layers.active, function(layer) {
+ _.each(models.layers.active, function (layer) {
models.layers.setVisibility(layer.id, false);
});
// Turn on or add new layers
- _.each(layers, function(layer) {
+ _.each(layers, function (layer) {
var id = layer[0];
var visible = layer[1];
if (models.layers.exists(id)) {
@@ -351,9 +348,9 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
});
};
- var zoomToEvent = function(event, date) {
+ var zoomToEvent = function (event, date) {
var category = event.categories[0].title;
- var geometry = _.find(event.geometries, function(geom){
+ var geometry = _.find(event.geometries, function (geom) {
return geom.date.split('T')[0] === date;
});
var coordinates = (geometry.type === 'Polygon') ? ol.extent.boundingExtent(geometry.coordinates[0]) : geometry.coordinates;
diff --git a/web/js/notifications/wv.notifications.ui.js b/web/js/notifications/wv.notifications.ui.js
index d9d6334b4..f097c9158 100644
--- a/web/js/notifications/wv.notifications.ui.js
+++ b/web/js/notifications/wv.notifications.ui.js
@@ -4,7 +4,7 @@ wv.notifications = wv.notifications || {};
/*
* @Class
*/
-wv.notifications.ui = wv.notifications.ui || function(models, config) {
+wv.notifications.ui = wv.notifications.ui || function (models, config) {
var self = {};
var mainNotification;
var mainIcon;
@@ -18,7 +18,6 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
var alertBlockExists;
var messageBlockExists;
-
url = config.features.alert.url;
messageBlockExists = false;
alertBlockExists = false;
@@ -42,22 +41,22 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var init = function() {
+ var init = function () {
var reactComponent, options, p, alertUser;
- if(!wv.util.browser.localStorage) {
+ if (!wv.util.browser.localStorage) {
return;
}
mainIcon = $('#wv-info-button')[0];
mainIconLabel = $('#wv-info-button label')[0];
p = wv.util.get(url);
- p.then(function(response) {
+ p.then(function (response) {
var obj, notifications, alert;
obj = JSON.parse(response);
notifications = obj.notifications;
sortedNotifications = separateByType(notifications);
update(sortedNotifications);
- }, function(error) {
+ }, function (error) {
console.warn(error);
});
};
@@ -72,7 +71,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var getPriority = function(sortedNotifications) {
+ var getPriority = function (sortedNotifications) {
var priority, message, outage, alert;
priority = null;
message = sortedNotifications.messages[0];
@@ -101,7 +100,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
}
return priority;
};
- var getCounts = function() {
+ var getCounts = function () {
var outageCount, messageCount, alertsAndOutages;
messageCount = getNumberOfTypeNotseen('message', sortedNotifications.messages);
@@ -119,7 +118,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
/**
* @return {void}
*/
- var update = function() {
+ var update = function () {
var alertCount, messageCount, counts, priority;
counts = getCounts();
alertCount = counts.alertCount;
@@ -141,7 +140,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
* @returns {Number} count - number of unseen messages
* in LocalStorage
*/
- var getNumberOfTypeNotseen = function(type, arra) {
+ var getNumberOfTypeNotseen = function (type, arra) {
var storageItem = localStorage.getItem(type);
var count, len;
@@ -171,7 +170,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var objectAlreadySeen = function(obj) {
+ var objectAlreadySeen = function (obj) {
var fieldExists, fieldValueMatches, type, idString;
type = obj.notification_type;
@@ -194,7 +193,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var separateByType = function(obj) {
+ var separateByType = function (obj) {
var messages = [],
alerts = [],
outages = [],
@@ -228,8 +227,8 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var orderByDate = function(obj) {
- obj.sort(function(a, b) {
+ var orderByDate = function (obj) {
+ obj.sort(function (a, b) {
return new Date(b.created_at) - new Date(a.created_at);
});
return obj;
@@ -243,7 +242,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var updateMainIcon = function(type, numberOfAlerts) {
+ var updateMainIcon = function (type, numberOfAlerts) {
mainIconLabel.setAttribute('data-content', numberOfAlerts);
if (type) {
mainIcon.className = 'wv-toolbar-button wv-status-' + type;
@@ -260,7 +259,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {object} a jquery element
*/
- self.getMessages = function() {
+ self.getMessages = function () {
var $message, messageNumber, messages, hide;
hide = '';
messages = sortedNotifications.messages;
@@ -293,7 +292,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {object} a jquery element
*/
- self.getAlert = function() {
+ self.getAlert = function () {
var $notifyMenuItem, alertsNumber, outageNumber, count, hide;
if (!_.isEmpty(activeNotifications)) {
@@ -329,7 +328,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var deactivateMessage = function(e) {
+ var deactivateMessage = function (e) {
var messages;
this.className = 'ui-icon fa fa-fw fa-gift';
self.messageIconActive = false;
@@ -357,14 +356,14 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var notify = function(e) {
+ var notify = function (e) {
this.className = 'ui-icon fa fa-fw fa-bolt';
self.infoIconActive = false;
self.notifyIconActive = false;
mainNotification = null;
createNotifyDialog();
- if (activeNotifications.outage ) {
+ if (activeNotifications.outage) {
localStorage.setItem('outage', activeNotifications.outage);
}
if (activeNotifications.alert) {
@@ -387,7 +386,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var createNotifyDialog = function() {
+ var createNotifyDialog = function () {
var $dialog, dimensions;
var $notifyContent = $('<div class="wv-notify-modal"></div>');
if (!sortedNotifications.alerts && !sortedNotifications.outages) {
@@ -401,15 +400,15 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
.append($notifyContent);
$dialog.dialog({
- title: "Notifications",
+ title: 'Notifications',
width: dimensions[0],
height: dimensions[1],
maxHeight: 525,
show: {
- effect: "fade"
+ effect: 'fade'
},
hide: {
- effect: "fade"
+ effect: 'fade'
}
});
};
@@ -422,11 +421,11 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {Object} Dimension array
*/
- var getModalDimensions = function() {
+ var getModalDimensions = function () {
var width, height;
width = 625;
- height = "auto";
+ height = 'auto';
if (wv.util.browser.small || wv.util.browser.touchDevice) {
width = $(window)
.width();
@@ -447,7 +446,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {Object} Jquery ul element
*/
- var create$block = function(arra, title) {
+ var create$block = function (arra, title) {
var $li, date, numNotSeen, activeClass, $ul = $('<ul></ul>');
numNotSeen = getNumberOfTypeNotseen(title, sortedNotifications[title + 's']);
@@ -458,8 +457,8 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
activeClass = title;
}
date = new Date(arra[i].created_at);
- date = date.getDate() + " " + wv.util.giveMonth(date) + " " + date.getFullYear();
- $li = $("<li><div class='" + activeClass + "'><h2> <i class='fa fa-" + classes[title] + "'/> " + title + "<span> Posted " + date + "</span></h2><p>" + arra[i].message + "</p></div></li>");
+ date = date.getDate() + ' ' + wv.util.giveMonth(date) + ' ' + date.getFullYear();
+ $li = $("<li><div class='" + activeClass + "'><h2> <i class='fa fa-" + classes[title] + "'/> " + title + '<span> Posted ' + date + '</span></h2><p>' + arra[i].message + '</p></div></li>');
$ul.append($li);
}
return $ul;
@@ -476,7 +475,7 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {Boolean}
*/
- var localStorageValueMatches = function(property, value) {
+ var localStorageValueMatches = function (property, value) {
var oldValue = localStorage.getItem(property);
return new Date(value) <= new Date(oldValue);
};
@@ -492,14 +491,14 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
*
* @returns {void}
*/
- var create$whatsNew = function(obj, title) {
+ var create$whatsNew = function (obj, title) {
var $dialog, width, height, $notifyContent, releasePageUrl, date, dimensions;
date = new Date(obj.created_at);
- date = date.getDate() + " " + wv.util.giveMonth(date) + " " + date.getFullYear();
- releasePageUrl = config.features.alert.releases || "https://github.com/nasa-gibs/worldview/releases";
+ date = date.getDate() + ' ' + wv.util.giveMonth(date) + ' ' + date.getFullYear();
+ releasePageUrl = config.features.alert.releases || 'https://github.com/nasa-gibs/worldview/releases';
dimensions = getModalDimensions();
- $notifyContent = $("<div class='wv-notify-modal'><div><h2>" + title + "<span> Posted " + date + "</span></h2><p>" + obj.message + "</p></div></div>");
+ $notifyContent = $("<div class='wv-notify-modal'><div><h2>" + title + '<span> Posted ' + date + '</span></h2><p>' + obj.message + '</p></div></div>');
$footer = $('<div class="wv-notify-footer"><p> Check out our <a target="_blank" href="' + releasePageUrl + '">release notes</a> for a complete list of new additions.</p></div>');
$notifyContent.append($footer);
$dialog = wv.ui.getDialog()
@@ -510,10 +509,10 @@ wv.notifications.ui = wv.notifications.ui || function(models, config) {
height: dimensions[1],
maxHeight: 525,
show: {
- effect: "fade"
+ effect: 'fade'
},
hide: {
- effect: "fade"
+ effect: 'fade'
}
});
};
diff --git a/web/js/ol.wv/ol.wv.lookupimagetile.js b/web/js/ol.wv/ol.wv.lookupimagetile.js
index e8182fe14..3c876cdde 100644
--- a/web/js/ol.wv/ol.wv.lookupimagetile.js
+++ b/web/js/ol.wv/ol.wv.lookupimagetile.js
@@ -3,9 +3,8 @@ ol.wv = {};
* @constructor
* @extends {ol.ImageTile}
*/
-ol.wv.LookupImageTile = function(lookup, tileCoord, state, src, crossOrigin, tileLoadFunction) {
-
- goog.base(this, tileCoord, state, src, "anonymous", tileLoadFunction);
+ol.wv.LookupImageTile = function (lookup, tileCoord, state, src, crossOrigin, tileLoadFunction) {
+ goog.base(this, tileCoord, state, src, 'anonymous', tileLoadFunction);
/**
* @private
@@ -22,30 +21,29 @@ goog.inherits(ol.wv.LookupImageTile, ol.ImageTile);
/**
* @return (HTMLCanvasElement|HTMLImageElement|HTMLVideoElement|null)
*/
-ol.wv.LookupImageTile.prototype.getImage = function(opt_context) {
+ol.wv.LookupImageTile.prototype.getImage = function (opt_context) {
return this.canvas_;
};
-ol.wv.LookupImageTile.prototype.load = function() {
-
+ol.wv.LookupImageTile.prototype.load = function () {
if (this.state === ol.TileState.IDLE) {
this.state = ol.TileState.LOADING;
var that = this;
- var onImageLoad = function(e) {
- that.canvas_ = document.createElement("canvas");
+ var onImageLoad = function (e) {
+ that.canvas_ = document.createElement('canvas');
that.canvas_.width = that.image_.width;
that.canvas_.height = that.image_.height;
var octets = that.canvas_.width * that.canvas_.height * 4;
- var g = that.canvas_.getContext("2d");
+ var g = that.canvas_.getContext('2d');
g.drawImage(that.image_, 0, 0);
var imageData = g.getImageData(0, 0, that.canvas_.width,
that.canvas_.height);
var pixels = imageData.data;
for (var i = 0; i < octets; i += 4) {
- var source = pixels[i + 0] + "," +
- pixels[i + 1] + "," +
- pixels[i + 2] + "," +
+ var source = pixels[i + 0] + ',' +
+ pixels[i + 1] + ',' +
+ pixels[i + 2] + ',' +
pixels[i + 3];
var target = that.lookup_[source];
@@ -59,18 +57,18 @@ ol.wv.LookupImageTile.prototype.load = function() {
g.putImageData(imageData, 0, 0);
that.state = ol.TileState.LOADED;
that.changed();
- that.image_.removeEventListener("load", onImageLoad);
+ that.image_.removeEventListener('load', onImageLoad);
};
this.image_.src = this.src_;
- this.image_.addEventListener("load", onImageLoad);
+ this.image_.addEventListener('load', onImageLoad);
}
};
/**
* @api
*/
-ol.wv.LookupImageTile.factory = function(lookup) {
- return function(tileCoord, state, src, crossOrigin, tileLoadFunction) {
+ol.wv.LookupImageTile.factory = function (lookup) {
+ return function (tileCoord, state, src, crossOrigin, tileLoadFunction) {
return new ol.wv.LookupImageTile(lookup, tileCoord, state, src,
crossOrigin, tileLoadFunction);
};
diff --git a/web/js/palettes/wv.palettes.js b/web/js/palettes/wv.palettes.js
index 868baca16..81b64ba3c 100644
--- a/web/js/palettes/wv.palettes.js
+++ b/web/js/palettes/wv.palettes.js
@@ -3,13 +3,12 @@
*/
var wv = wv || {};
-wv.palettes = (function(self) {
-
+wv.palettes = (function (self) {
var checkerboard;
self.supported = true;
- var init = function() {
+ var init = function () {
var browser = wv.util.browser;
if (browser.ie || !browser.webWorkers || !browser.cors) {
self.supported = false;
@@ -18,7 +17,7 @@ wv.palettes = (function(self) {
}
};
- self.colorbar = function(target, colors) {
+ self.colorbar = function (target, colors) {
var canvas;
if (target.length) {
canvas = $(target)
@@ -29,7 +28,7 @@ wv.palettes = (function(self) {
if (!canvas) {
return;
}
- var g = canvas.getContext("2d");
+ var g = canvas.getContext('2d');
g.fillStyle = checkerboard;
g.fillRect(0, 0, canvas.width, canvas.height);
@@ -37,7 +36,7 @@ wv.palettes = (function(self) {
var bins = colors.length;
var binWidth = canvas.width / bins;
var drawWidth = Math.ceil(binWidth);
- _.each(colors, function(color, i) {
+ _.each(colors, function (color, i) {
g.fillStyle = wv.util.hexToRGBA(color);
g.fillRect(Math.floor(binWidth * i), 0, drawWidth,
canvas.height);
@@ -45,31 +44,31 @@ wv.palettes = (function(self) {
}
};
- var drawCheckerboard = function() {
+ var drawCheckerboard = function () {
var size = 2;
- var canvas = document.createElement("canvas");
+ var canvas = document.createElement('canvas');
canvas.width = size * 2;
canvas.height = size * 2;
- var g = canvas.getContext("2d");
+ var g = canvas.getContext('2d');
- //g.fillStyle = "rgb(102, 102, 102)";
- g.fillStyle = "rgb(200, 200, 200)";
+ // g.fillStyle = "rgb(102, 102, 102)";
+ g.fillStyle = 'rgb(200, 200, 200)';
g.fillRect(0, 0, size, size);
g.fillRect(size, size, size, size);
- //g.fillStyle = "rgb(153, 153, 153)";
- g.fillStyle = "rgb(240, 240, 240)";
+ // g.fillStyle = "rgb(153, 153, 153)";
+ g.fillStyle = 'rgb(240, 240, 240)';
g.fillRect(0, size, size, size);
g.fillRect(size, 0, size, size);
- checkerboard = g.createPattern(canvas, "repeat");
+ checkerboard = g.createPattern(canvas, 'repeat');
};
- self.translate = function(source, target) {
+ self.translate = function (source, target) {
var translation = [];
- _.each(source, function(color, index) {
+ _.each(source, function (color, index) {
var sourcePercent = index / source.length;
var targetIndex = Math.floor(sourcePercent * target.length);
translation.push(target[targetIndex]);
@@ -77,14 +76,14 @@ wv.palettes = (function(self) {
return translation;
};
- self.lookup = function(sourcePalette, targetPalette) {
+ self.lookup = function (sourcePalette, targetPalette) {
var lookup = {};
- _.each(sourcePalette.colors, function(sourceColor, index) {
+ _.each(sourcePalette.colors, function (sourceColor, index) {
var source =
- parseInt(sourceColor.substring(0, 2), 16) + "," +
- parseInt(sourceColor.substring(2, 4), 16) + "," +
- parseInt(sourceColor.substring(4, 6), 16) + "," +
- "255";
+ parseInt(sourceColor.substring(0, 2), 16) + ',' +
+ parseInt(sourceColor.substring(2, 4), 16) + ',' +
+ parseInt(sourceColor.substring(4, 6), 16) + ',' +
+ '255';
var targetColor = targetPalette.colors[index];
var target = {
r: parseInt(targetColor.substring(0, 2), 16),
@@ -97,30 +96,30 @@ wv.palettes = (function(self) {
return lookup;
};
- self.loadCustom = function(config) {
+ self.loadCustom = function (config) {
return wv.util.load.config(config.palettes,
- "custom", "config/palettes-custom.json");
+ 'custom', 'config/palettes-custom.json');
};
- self.loadRendered = function(config, layerId) {
+ self.loadRendered = function (config, layerId) {
var layer = config.layers[layerId];
return wv.util.load.config(config.palettes.rendered,
- layer.palette.id, "config/palettes/" + layer.palette.id + ".json");
+ layer.palette.id, 'config/palettes/' + layer.palette.id + '.json');
};
- self.requirements = function(state, config) {
+ self.requirements = function (state, config) {
var promises = [];
config.palettes = {
rendered: {},
custom: {}
};
- _.each(state.l, function(qsLayer) {
+ _.each(state.l, function (qsLayer) {
var layerId = qsLayer.id;
if (config.layers[layerId] && config.layers[layerId].palette) {
promises.push(self.loadRendered(config, layerId));
}
var custom = _.find(qsLayer.attributes, {
- id: "palette"
+ id: 'palette'
});
if (custom) {
promises.push(self.loadCustom(config));
@@ -136,30 +135,30 @@ wv.palettes = (function(self) {
};
// Only for permalink 1.1 support
- self.parse = function(state, errors, config) {
+ self.parse = function (state, errors, config) {
if (state.palettes) {
if (!wv.palettes.supported) {
// FIXME: This should go in errors
delete state.palettes;
- wv.ui.notify("The custom palette feature is not supported " +
- "with your web browser. Upgrade or try again in a " +
- "different browser");
+ wv.ui.notify('The custom palette feature is not supported ' +
+ 'with your web browser. Upgrade or try again in a ' +
+ 'different browser');
return;
}
- var parts = state.palettes.split("~");
- _.each(parts, function(part) {
- var items = part.split(",");
+ var parts = state.palettes.split('~');
+ _.each(parts, function (part) {
+ var items = part.split(',');
var layerId = items[0];
var paletteId = items[1];
if (!config.layers[layerId]) {
errors.push({
- message: "Invalid layer for palette " +
- paletteId + ": " + layerId
+ message: 'Invalid layer for palette ' +
+ paletteId + ': ' + layerId
});
} else if (!config.layers[layerId].palette) {
errors.push({
- message: "Layer " + layerId + " does not " +
- "support palettes"
+ message: 'Layer ' + layerId + ' does not ' +
+ 'support palettes'
});
} else {
var layer = _.find(state.l, {
@@ -167,13 +166,13 @@ wv.palettes = (function(self) {
});
if (layer) {
layer.attributes.push({
- id: "palette",
+ id: 'palette',
value: paletteId
});
} else {
errors.push({
- message: "Layer " + layerId + " is not " +
- "active"
+ message: 'Layer ' + layerId + ' is not ' +
+ 'active'
});
}
}
@@ -184,5 +183,4 @@ wv.palettes = (function(self) {
init();
return self;
-
})(wv.palettes || {});
diff --git a/web/js/palettes/wv.palettes.legend.js b/web/js/palettes/wv.palettes.legend.js
index 853971070..d125b4028 100644
--- a/web/js/palettes/wv.palettes.legend.js
+++ b/web/js/palettes/wv.palettes.legend.js
@@ -4,8 +4,7 @@
var wv = wv || {};
wv.palettes = wv.palettes || {};
-wv.palettes.legend = wv.palettes.legend || function(spec) {
-
+wv.palettes.legend = wv.palettes.legend || function (spec) {
var selector = spec.selector;
var config = spec.config;
var models = spec.models;
@@ -17,14 +16,14 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {
var self = {};
- var init = function() {
+ var init = function () {
var paletteId = layer.palette.id;
if (config.palettes.rendered[paletteId]) {
loaded = true;
render();
} else {
wv.palettes.loadRendered(config, layer.id)
- .done(function() {
+ .done(function () {
if (!loaded) {
loaded = true;
render();
@@ -36,56 +35,55 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {
}
};
- var render = function() {
+ var render = function () {
var $parent = $(selector);
var paletteId = layer.palette.id;
var palette = config.palettes.rendered[paletteId];
- var $legendPanel = $("<div></div>")
- .addClass("wv-palettes-panel")
- .attr("data-layer", layer.id);
+ var $legendPanel = $('<div></div>')
+ .addClass('wv-palettes-panel')
+ .attr('data-layer', layer.id);
$parent.append($legendPanel);
var legends = model.getLegends(layer.id);
- _.each(legends, function(legend, index) {
- if ((legend.type === "continuous") ||
- (legend.type === "discrete")) {
+ _.each(legends, function (legend, index) {
+ if ((legend.type === 'continuous') ||
+ (legend.type === 'discrete')) {
renderScale($legendPanel, legend, index, layer.id);
}
- if (legend.type === "classification") {
+ if (legend.type === 'classification') {
renderClasses($legendPanel, legend, index);
}
});
self.update();
};
- var renderScale = function($legendPanel, legend, index, layerId) {
- $container = $("<div></div>")
- .addClass("wv-palettes-legend")
- .attr("data-index", index);
- $colorbar = $("<canvas></canvas>")
- .addClass("wv-palettes-colorbar")
- .attr("id", legend.id)
- .attr("data-index", index);
- //set fixed canvas dimensions
+ var renderScale = function ($legendPanel, legend, index, layerId) {
+ $container = $('<div></div>')
+ .addClass('wv-palettes-legend')
+ .attr('data-index', index);
+ $colorbar = $('<canvas></canvas>')
+ .addClass('wv-palettes-colorbar')
+ .attr('id', legend.id)
+ .attr('data-index', index);
+ // set fixed canvas dimensions
$colorbar[0].width = 235;
$colorbar[0].height = 12;
$container.append($colorbar);
- var $runningDataPointBar = $("<div></div>")
- .addClass("wv-running-bar");
- var $runningDataPointLabel = $("<span></span>")
- .addClass("wv-running-label");
-
+ var $runningDataPointBar = $('<div></div>')
+ .addClass('wv-running-bar');
+ var $runningDataPointLabel = $('<span></span>')
+ .addClass('wv-running-label');
- var $ranges = $("<div></div>")
- .addClass("wv-palettes-ranges");
- var $min = $("<div></div>")
- .addClass("wv-palettes-min");
- var $max = $("<div></div>")
- .addClass("wv-palettes-max");
- var $title = $("<div></div>")
- .addClass("wv-palettes-title");
+ var $ranges = $('<div></div>')
+ .addClass('wv-palettes-ranges');
+ var $min = $('<div></div>')
+ .addClass('wv-palettes-min');
+ var $max = $('<div></div>')
+ .addClass('wv-palettes-max');
+ var $title = $('<div></div>')
+ .addClass('wv-palettes-title');
$container.prepend($title);
$ranges
.append($min)
@@ -95,66 +93,65 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {
.append($ranges)
.append($runningDataPointBar);
- $colorbar.on("mousemove", function(e) {
+ $colorbar.on('mousemove', function (e) {
showUnitHover(e, index);
});
- $colorbar.on("mouseout", hideUnitsOnMouseOut);
+ $colorbar.on('mouseout', hideUnitsOnMouseOut);
$legendPanel.append($container);
- wv.palettes.colorbar(selector + " " +
+ wv.palettes.colorbar(selector + ' ' +
"[data-index='" + index + "'] canvas", legend.colors);
};
- var renderClasses = function($legendPanel, legend, index) {
+ var renderClasses = function ($legendPanel, legend, index) {
// var $runningDataPointLabel = $("<span></span>")
// .addClass("wv-running-category-label");
- var $panel = $("<div></div>")
- .addClass("wv-palettes-legend")
- .addClass("wv-palettes-classes")
- //.append($runningDataPointLabel)
- .attr("data-index", index);
+ var $panel = $('<div></div>')
+ .addClass('wv-palettes-legend')
+ .addClass('wv-palettes-classes')
+ // .append($runningDataPointLabel)
+ .attr('data-index', index);
$legendPanel
- .attr("id", legend.id)
+ .attr('id', legend.id)
.append($panel);
-
};
- var updateClasses = function(legend, index) {
+ var updateClasses = function (legend, index) {
var $panel = $(selector + " [data-index='" + index + "']");
$panel.empty();
- _.each(legend.colors, function(color, classIndex) {
+ _.each(legend.colors, function (color, classIndex) {
var $colorBox;
- var $runningDataPointLabel = $("<span></span>")
- .addClass("wv-running-category-label");
- $colorBox = $("<span></span>")
- .attr("data-index", index)
- .attr("data-class-index", classIndex)
- .attr("data-hex", color)
- .addClass("wv-palettes-class")
- .html("&nbsp;")
- .css("background-color", wv.util.hexToRGB(color))
+ var $runningDataPointLabel = $('<span></span>')
+ .addClass('wv-running-category-label');
+ $colorBox = $('<span></span>')
+ .attr('data-index', index)
+ .attr('data-class-index', classIndex)
+ .attr('data-hex', color)
+ .addClass('wv-palettes-class')
+ .html('&nbsp;')
+ .css('background-color', wv.util.hexToRGB(color))
.hover(highlightClass, unhighlightClass);
$panel.append($colorBox);
$panel.append($runningDataPointLabel);
- //Calls running data
+ // Calls running data
$colorBox.on('mouseenter', showClassUnitHover);
$colorBox.on('mouseout', hideUnitsOnMouseOut);
});
- var $detailPanel = $("<div></div>");
- _.each(legend.colors, function(color, classIndex) {
+ var $detailPanel = $('<div></div>');
+ _.each(legend.colors, function (color, classIndex) {
var label = legend.tooltips[classIndex];
- label = (legend.units) ? label + " " + legend.units : label;
- var $row = $("<div></div>")
- .addClass("wv-palettes-class-detail")
- .attr("data-class-index", classIndex);
+ label = (legend.units) ? label + ' ' + legend.units : label;
+ var $row = $('<div></div>')
+ .addClass('wv-palettes-class-detail')
+ .attr('data-class-index', classIndex);
$colorBox =
$row.append(
- $("<span></span>")
- .addClass("wv-palettes-class")
- .html("&nbsp;")
- .css("background-color", wv.util.hexToRGB(color)))
- .append($("<span></span>")
- .addClass("wv-palettes-class-label")
- .attr("data-index", index)
- .attr("data-class-index", classIndex)
+ $('<span></span>')
+ .addClass('wv-palettes-class')
+ .html('&nbsp;')
+ .css('background-color', wv.util.hexToRGB(color)))
+ .append($('<span></span>')
+ .addClass('wv-palettes-class-label')
+ .attr('data-index', index)
+ .attr('data-class-index', classIndex)
.html(label));
$detailPanel.append($row);
});
@@ -163,40 +160,40 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {
}
};
- self.update = function() {
+ self.update = function () {
if (!loaded) {
return;
}
var legends = model.getLegends(layer.id);
- _.each(legends, function(legend, index) {
- if ((legend.type === "continuous") ||
- (legend.type === "discrete")) {
- wv.palettes.colorbar(selector + " " +
+ _.each(legends, function (legend, index) {
+ if ((legend.type === 'continuous') ||
+ (legend.type === 'discrete')) {
+ wv.palettes.colorbar(selector + ' ' +
"[data-index='" + index + "'] canvas", legend.colors);
showUnitRange(index);
- } else if (legend.type === "classification") {
+ } else if (legend.type === 'classification') {
updateClasses(legend, index);
}
});
};
- var showUnitRange = function(index) {
+ var showUnitRange = function (index) {
if (!loaded) {
return;
}
var legends = model.getLegends(layer.id, index);
var entries = model.get(layer.id, index)
.entries;
- _.each(legends, function(legend, index) {
+ _.each(legends, function (legend, index) {
var min = legend.minLabel || _.first(legend.tooltips);
var max = legend.maxLabel || _.last(legend.tooltips);
- min = (legend.units) ? min + " " + legend.units : min;
- max = (legend.units) ? max + " " + legend.units : max;
+ min = (legend.units) ? min + ' ' + legend.units : min;
+ max = (legend.units) ? max + ' ' + legend.units : max;
$(selector + " [data-index='" + index + "'] .wv-palettes-min")
.html(min);
$(selector + " [data-index='" + index + "'] .wv-palettes-max")
.html(max);
- var title = legend.title || "&nbsp;";
+ var title = legend.title || '&nbsp;';
if (legends.length === 1) {
$(selector + " [data-index='" + index + "'] .wv-palettes-title")
.hide();
@@ -215,7 +212,7 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {
* @param {MouseEvent} e
* @return {void}
*/
- var showUnitHover = function(e, index) {
+ var showUnitHover = function (e, index) {
var rgba;
var pos;
var x;
@@ -245,7 +242,7 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {
* @param {MouseEvent} e
* @return {void}
*/
- var showClassUnitHover = function(e) {
+ var showClassUnitHover = function (e) {
var hex = $(this)
.data('hex');
var legends = model.getLegends(layer.id)[0];
@@ -262,32 +259,30 @@ wv.palettes.legend = wv.palettes.legend || function(spec) {
* @param {MouseEvent} e
* @return {void}
*/
- var hideUnitsOnMouseOut = function() {
+ var hideUnitsOnMouseOut = function () {
ui.map.runningdata.clearAll();
};
-
- var highlightClass = function() {
+ var highlightClass = function () {
legendIndex = $(this)
- .attr("data-index");
+ .attr('data-index');
classIndex = $(this)
- .attr("data-class-index");
+ .attr('data-class-index');
$(".wv-palettes-class-label[data-index='" + legendIndex + "']" +
"[data-class-index='" + classIndex + "']")
- .addClass("wv-palettes-class-highlight");
+ .addClass('wv-palettes-class-highlight');
};
- var unhighlightClass = function() {
+ var unhighlightClass = function () {
legendIndex = $(this)
- .attr("data-index");
+ .attr('data-index');
classIndex = $(this)
- .attr("data-class-index");
+ .attr('data-class-index');
$(".wv-palettes-class-label[data-index='" + legendIndex + "']" +
"[data-class-index='" + classIndex + "']")
- .removeClass("wv-palettes-class-highlight");
+ .removeClass('wv-palettes-class-highlight');
};
-
init();
return self;
};
diff --git a/web/js/palettes/wv.palettes.model.js b/web/js/palettes/wv.palettes.model.js
index 1a68c89d8..b7e0c15ed 100644
--- a/web/js/palettes/wv.palettes.model.js
+++ b/web/js/palettes/wv.palettes.model.js
@@ -7,8 +7,7 @@ wv.palettes = wv.palettes || {};
/**
* @class wv.palette.model
*/
-wv.palettes.model = wv.palettes.model || function(models, config) {
-
+wv.palettes.model = wv.palettes.model || function (models, config) {
config.palettes = config.palettes || {
rendered: {},
custom: {}
@@ -18,7 +17,7 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
self.events = wv.util.events();
self.active = {};
- self.getRendered = function(layerId, index) {
+ self.getRendered = function (layerId, index) {
var name = config.layers[layerId].palette.id;
var palette = config.palettes.rendered[name];
if (!_.isUndefined(index)) {
@@ -27,37 +26,37 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
return palette;
};
- self.getCustom = function(paletteId) {
+ self.getCustom = function (paletteId) {
palette = config.palettes.custom[paletteId];
if (!palette) {
- throw new Error("Invalid palette: " + paletteId);
+ throw new Error('Invalid palette: ' + paletteId);
}
return palette;
};
- var prepare = function(layerId) {
+ var prepare = function (layerId) {
self.active[layerId] = self.active[layerId] || {};
var active = self.active[layerId];
active.maps = active.maps || [];
_.each(self.getRendered(layerId)
.maps,
- function(palette, index) {
+ function (palette, index) {
if (!active.maps[index]) {
active.maps[index] = _.cloneDeep(palette);
}
});
};
- self.allowed = function(layerId) {
+ self.allowed = function (layerId) {
if (!wv.palettes.supported) {
return false;
}
return config.layers[layerId].palette;
};
- self.setCustom = function(layerId, paletteId, index) {
+ self.setCustom = function (layerId, paletteId, index) {
if (!config.layers[layerId]) {
- throw new Error("Invalid layer: " + layerId);
+ throw new Error('Invalid layer: ' + layerId);
}
prepare(layerId);
index = (_.isUndefined(index)) ? 0 : index;
@@ -68,11 +67,11 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
}
palette.custom = paletteId;
updateLookup(layerId);
- self.events.trigger("set-custom", layerId, active);
- self.events.trigger("change");
+ self.events.trigger('set-custom', layerId, active);
+ self.events.trigger('change');
};
- self.clearCustom = function(layerId, index) {
+ self.clearCustom = function (layerId, index) {
index = (_.isUndefined(index)) ? 0 : index;
var active = self.active[layerId];
if (!active) {
@@ -84,11 +83,11 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
}
delete palette.custom;
updateLookup(layerId);
- self.events.trigger("clear-custom", layerId);
- self.events.trigger("change");
+ self.events.trigger('clear-custom', layerId);
+ self.events.trigger('change');
};
- self.setRange = function(layerId, min, max, squash, index) {
+ self.setRange = function (layerId, min, max, squash, index) {
prepare(layerId);
index = (_.isUndefined(index)) ? 0 : index;
var palette = self.active[layerId].maps[index];
@@ -103,11 +102,11 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
palette.max = max;
palette.squash = squash;
updateLookup(layerId);
- self.events.trigger("range", layerId, palette.min, palette.max);
- self.events.trigger("change");
+ self.events.trigger('range', layerId, palette.min, palette.max);
+ self.events.trigger('change');
};
- self.getCount = function(layerId) {
+ self.getCount = function (layerId) {
return self.getRendered(layerId)
.maps.length;
};
@@ -122,7 +121,7 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
* object.
* @return {object} object including the entries and legend
*/
- self.get = function(layerId, index) {
+ self.get = function (layerId, index) {
index = (_.isUndefined(index)) ? 0 : index;
if (self.active[layerId]) {
return self.active[layerId].maps[index];
@@ -140,7 +139,7 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
* object.
* @return {object} object of the legend
*/
- self.getLegend = function(layerId, index) {
+ self.getLegend = function (layerId, index) {
var value = self.get(layerId, index);
return value.legend || value.entries;
};
@@ -155,12 +154,12 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
* object.
* @return {object} object of the legend
*/
- self.getDefaultLegend = function(layerId, index) {
+ self.getDefaultLegend = function (layerId, index) {
var palette = self.getRendered(layerId, index);
return palette.legend || palette.entries;
};
- self.getLegends = function(layerId) {
+ self.getLegends = function (layerId) {
var legends = [];
var count = self.getCount(layerId);
for (var i = 0; i < count; i++) {
@@ -170,38 +169,38 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
};
// Is a canvas required?
- self.isActive = function(layerId) {
+ self.isActive = function (layerId) {
return self.active[layerId];
};
// Looks up options/colormaps/layer.xml colormap entry
- self.getLookup = function(layerId) {
+ self.getLookup = function (layerId) {
return self.active[layerId].lookup;
};
- self.clear = function() {
+ self.clear = function () {
self.active = {};
- self.events.trigger("update");
+ self.events.trigger('update');
};
- self.restore = function(active) {
+ self.restore = function (active) {
self.active = active;
- self.events.trigger("update");
+ self.events.trigger('update');
};
- var getMinValue = function(v) {
+ var getMinValue = function (v) {
return (v.length) ? v[0] : v;
};
- var getMaxValue = function(v) {
+ var getMaxValue = function (v) {
return (v.length) ? v[v.length - 1] : v;
};
- self.save = function(state) {
+ self.save = function (state) {
if (self.inUse() && !state.l) {
- throw new Error("No layers in state");
+ throw new Error('No layers in state');
}
- _.each(self.active, function(def, layerId) {
+ _.each(self.active, function (def, layerId) {
if (!_.find(models.layers.get(), {
id: layerId
})) {
@@ -215,7 +214,7 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
});
};
- self.saveSingle = function(state, layerId) {
+ self.saveSingle = function (state, layerId) {
var attr = _.find(state.l, {
id: layerId
})
@@ -223,32 +222,32 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
var def = self.get(layerId);
if (def.custom) {
attr.push({
- id: "palette",
+ id: 'palette',
value: def.custom
});
}
if (def.min) {
var minValue = def.entries.values[def.min];
attr.push({
- id: "min",
+ id: 'min',
value: minValue
});
}
if (def.max) {
var maxValue = def.entries.values[def.max];
attr.push({
- id: "max",
+ id: 'max',
value: maxValue
});
}
if (def.squash) {
attr.push({
- id: "squash"
+ id: 'squash'
});
}
};
- self.saveMulti = function(state, layerId) {
+ self.saveMulti = function (state, layerId) {
var palettes = [],
hasPalettes = false;
var min = [],
@@ -264,28 +263,28 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
palettes.push(def.custom);
hasPalettes = true;
} else {
- palettes.push("");
+ palettes.push('');
}
if (def.min) {
min.push(getMinValue(def.entries.values[def.min]));
hasMin = true;
} else {
- min.push("");
+ min.push('');
}
if (def.max) {
max.push(getMaxValue(def.entries.values[def.max]));
hasMax = true;
} else {
- max.push("");
+ max.push('');
}
if (def.squash) {
squash.push(def.squash);
hasSquash = true;
} else {
- squash.push("");
+ squash.push('');
}
}
@@ -295,115 +294,115 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
.attributes;
if (hasPalettes) {
attr.push({
- id: "palette",
- value: palettes.join(";")
+ id: 'palette',
+ value: palettes.join(';')
});
}
if (hasMin) {
attr.push({
- id: "min",
- value: min.join(";")
+ id: 'min',
+ value: min.join(';')
});
}
if (hasMax) {
attr.push({
- id: "max",
- value: max.join(";")
+ id: 'max',
+ value: max.join(';')
});
}
if (hasSquash) {
attr.push({
- id: "squash",
- value: squash.join(";")
+ id: 'squash',
+ value: squash.join(';')
});
}
};
- self.key = function(layerId) {
+ self.key = function (layerId) {
if (!self.isActive(layerId)) {
- return "";
+ return '';
}
var def = self.get(layerId);
var keys = [];
if (def.custom) {
- keys.push("palette=" + def.custom);
+ keys.push('palette=' + def.custom);
}
if (def.min) {
- keys.push("min=" + def.min);
+ keys.push('min=' + def.min);
}
if (def.max) {
- keys.push("max=" + def.max);
+ keys.push('max=' + def.max);
}
if (def.squash) {
- keys.push("squash");
+ keys.push('squash');
}
- return keys.join(",");
+ return keys.join(',');
};
- self.load = function(state, errors) {
+ self.load = function (state, errors) {
if (!wv.palettes.supported) {
return;
}
- _.each(state.l, function(layerDef) {
+ _.each(state.l, function (layerDef) {
var layerId = layerDef.id;
var minValue, maxValue;
var min = [],
max = [];
var squash = [];
var count = 0;
- _.each(layerDef.attributes, function(attr) {
- if (attr.id === "palette") {
+ _.each(layerDef.attributes, function (attr) {
+ if (attr.id === 'palette') {
count = self.getCount(layerId);
- values = wv.util.toArray(attr.value.split(";"));
- _.each(values, function(value, index) {
+ values = wv.util.toArray(attr.value.split(';'));
+ _.each(values, function (value, index) {
try {
self.setCustom(layerId, value, index);
} catch (error) {
- errors.push("Invalid palette: " + value);
+ errors.push('Invalid palette: ' + value);
}
});
}
- if (attr.id === "min") {
+ if (attr.id === 'min') {
count = self.getCount(layerId);
- values = wv.util.toArray(attr.value.split(";"));
- _.each(values, function(value, index) {
- if (value === "") {
+ values = wv.util.toArray(attr.value.split(';'));
+ _.each(values, function (value, index) {
+ if (value === '') {
min.push(undefined);
return;
}
minValue = parseFloat(value);
if (_.isNaN(minValue)) {
- errors.push("Invalid min value: " + value);
+ errors.push('Invalid min value: ' + value);
} else {
- min.push(findIndex(layerId, "min", minValue, index));
+ min.push(findIndex(layerId, 'min', minValue, index));
}
});
}
- if (attr.id === "max") {
+ if (attr.id === 'max') {
count = self.getCount(layerId);
- values = wv.util.toArray(attr.value.split(";"));
- _.each(values, function(value, index) {
- if (value === "") {
+ values = wv.util.toArray(attr.value.split(';'));
+ _.each(values, function (value, index) {
+ if (value === '') {
max.push(undefined);
return;
}
maxValue = parseFloat(value);
if (_.isNaN(maxValue)) {
- errors.push("Invalid max value: " + value);
+ errors.push('Invalid max value: ' + value);
} else {
- max.push(findIndex(layerId, "max", maxValue, index));
+ max.push(findIndex(layerId, 'max', maxValue, index));
}
});
}
- if (attr.id === "squash") {
+ if (attr.id === 'squash') {
count = self.getCount(layerId);
if (attr.value === true) {
squash[0] = true;
} else {
- values = wv.util.toArray(attr.value.split(";"));
- _.each(values, function(value) {
- squash.push(value === "true");
+ values = wv.util.toArray(attr.value.split(';'));
+ _.each(values, function (value) {
+ squash.push(value === 'true');
});
}
}
@@ -419,19 +418,19 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
});
};
- var findIndex = function(layerId, type, value, index) {
+ var findIndex = function (layerId, type, value, index) {
index = index || 0;
var values = self.get(layerId, index)
.entries.values;
var result;
- _.each(values, function(check, index) {
+ _.each(values, function (check, index) {
var min = getMinValue(check);
var max = getMaxValue(check);
- if (type === "min" && value === min) {
+ if (type === 'min' && value === min) {
result = index;
return false;
}
- if (type === "max" && value === max) {
+ if (type === 'max' && value === max) {
result = index;
return false;
}
@@ -441,10 +440,10 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
// If any custom rendering is being used, image download must turn it
// off
- self.inUse = function() {
+ self.inUse = function () {
var layers = models.layers.get();
var found = false;
- _.each(layers, function(layer) {
+ _.each(layers, function (layer) {
if (self.active[layer.id]) {
found = true;
return false;
@@ -453,11 +452,11 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
return found;
};
- var useLookup = function(layerId) {
+ var useLookup = function (layerId) {
var use = false;
var active = self.active[layerId].maps;
- _.each(active, function(palette, index) {
+ _.each(active, function (palette, index) {
if (palette.custom) {
use = true;
return false;
@@ -479,14 +478,14 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
return use;
};
- var updateLookup = function(layerId) {
+ var updateLookup = function (layerId) {
if (!useLookup(layerId)) {
delete self.active[layerId];
return;
}
var active = self.active[layerId].maps;
var lookup = {};
- _.each(active, function(palette, index) {
+ _.each(active, function (palette, index) {
oldLegend = palette.legend;
entries = palette.entries;
legend = {
@@ -501,8 +500,8 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
};
var source = entries.colors;
var values = entries.values;
- var target = (palette.custom) ?
- self.getCustom(palette.custom)
+ var target = (palette.custom)
+ ? self.getCustom(palette.custom)
.colors : source;
var min = palette.min || 0;
@@ -512,10 +511,10 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
var targetCount = target.length;
var indexCount = max - min;
- _.each(source, function(color, index) {
+ _.each(source, function (color, index) {
var newColor;
if (index < min || index > max) {
- targetColor = "00000000";
+ targetColor = '00000000';
} else {
var sourcePercent, targetIndex;
if (palette.squash) {
@@ -535,9 +534,9 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
}
legend.colors.push(targetColor);
var lookupSource =
- _.parseInt(color.substring(0, 2), 16) + "," +
- _.parseInt(color.substring(2, 4), 16) + "," +
- _.parseInt(color.substring(4, 6), 16) + "," +
+ _.parseInt(color.substring(0, 2), 16) + ',' +
+ _.parseInt(color.substring(2, 4), 16) + ',' +
+ _.parseInt(color.substring(4, 6), 16) + ',' +
_.parseInt(color.substring(6, 8), 16);
var lookupTarget = {
r: _.parseInt(targetColor.substring(0, 2), 16),
@@ -553,5 +552,4 @@ wv.palettes.model = wv.palettes.model || function(models, config) {
};
return self;
-
};
diff --git a/web/js/proj/wv.proj.change.js b/web/js/proj/wv.proj.change.js
index 95d572fc6..a8349426e 100644
--- a/web/js/proj/wv.proj.change.js
+++ b/web/js/proj/wv.proj.change.js
@@ -7,11 +7,10 @@ wv.proj = wv.proj || {};
/**
* @class wv.proj.change
*/
-wv.proj.change = wv.proj.change || function(models) {
-
+wv.proj.change = wv.proj.change || function (models) {
var PROJECTION_CHANGE_DATE = new Date(Date.UTC(2013, 5, 6));
var EARLIEST_CHANGE_DATE = new Date(Date.UTC(2012, 11, 31));
- var DO_NOT_SHOW_AGAIN = "arcticProjectionChangeNotification";
+ var DO_NOT_SHOW_AGAIN = 'arcticProjectionChangeNotification';
var notified = false;
var polarVisited = 0;
var self = {};
@@ -21,21 +20,21 @@ wv.proj.change = wv.proj.change || function(models) {
self.crs = null;
self.epsg = null;
- var init = function() {
- models.proj.register("EPSG:3995",
- "+title=WGS 84 / Arctic Polar Stereographic +proj=stere " +
- "lat_0=90 +lat_ts=71 +lon_0=0 +k=1 +x_0=0 +y_0=0 " +
- "+datum=WGS84 +units=m +no_def");
- models.proj.events.on("select", onChange);
- models.date.events.on("select", onChange);
+ var init = function () {
+ models.proj.register('EPSG:3995',
+ '+title=WGS 84 / Arctic Polar Stereographic +proj=stere ' +
+ 'lat_0=90 +lat_ts=71 +lon_0=0 +k=1 +x_0=0 +y_0=0 ' +
+ '+datum=WGS84 +units=m +no_def');
+ models.proj.events.on('select', onChange);
+ models.date.events.on('select', onChange);
update();
};
- var update = function() {
+ var update = function () {
var proj = models.proj.selected;
self.old = false;
- if (proj.id === "arctic" || proj.id === "antarctic") {
+ if (proj.id === 'arctic' || proj.id === 'antarctic') {
polarVisited = polarVisited + 1;
var day = models.date.selected.getTime();
var change = PROJECTION_CHANGE_DATE.getTime();
@@ -43,8 +42,8 @@ wv.proj.change = wv.proj.change || function(models) {
self.old = day < change && day > earliest;
}
- if (proj.id === "arctic" && self.old) {
- self.crs = "EPSG:3995";
+ if (proj.id === 'arctic' && self.old) {
+ self.crs = 'EPSG:3995';
self.epsg = 3995;
} else {
self.crs = proj.crs;
@@ -52,22 +51,22 @@ wv.proj.change = wv.proj.change || function(models) {
}
};
- var onChange = function() {
+ var onChange = function () {
var wasOld = self.old;
update();
- self.events.trigger("select", self);
+ self.events.trigger('select', self);
if (polarVisited > 1 && wasOld !== self.old) {
checkNotify();
}
};
- var checkNotify = function() {
+ var checkNotify = function () {
// If the flag cannot be stored in local storage, do not notify
// the user which will constantly annoy them.
if (!wv.util.browser.localStorage) {
return;
}
- if (localStorage.getItem(DO_NOT_SHOW_AGAIN) === "true") {
+ if (localStorage.getItem(DO_NOT_SHOW_AGAIN) === 'true') {
return;
}
if (notified) {
@@ -76,54 +75,53 @@ wv.proj.change = wv.proj.change || function(models) {
notify();
};
- var notify = function() {
+ var notify = function () {
notified = true;
var message = [
- "From 2013-01-01 to 2013-06-05, imagery in the polar projections",
- " are different than the other dates as follows:",
- "<br/><br/>",
- "The <b>Arctic projection</b> is in Arctic Polar ",
- "Stereographic (EPSG:3995, \"Greenwich down\") rather than NSIDC ",
- " Polar Stereographic North (EPSG:3413, \"Greenland down\"). ",
- "Coastlines and Graticule for this time range ",
- "can be found in the Add Layer tab by searching for ",
- " \"EPSG:3995\". Note that the image snapshot tool will not work ",
- "for Arctic imagery during this time range.",
- "<br/><br/>" +
-
- "The <b>Antarctic projection</b> is a sphere with radius of ",
- "6371007.181 meters during these dates rather than being ",
- "projected onto the WGS84 ",
- " ellipsoid. For all other dates, the projection is now the ",
- "correct Antarctic Polar Stereographic (EPSG:3031). This change ",
- "results in a shift of the imagery that ranges up to tens of ",
- "kilometers, depending on the location.",
- "<br/><br/>",
-
- "Imagery during this time range will be reprocessed during winter ",
- "2017-18 to be made consistent with all other imagery. In the ",
- "meantime, imagery will continue to be back-processed to the ",
- "start of the Terra and Aqua missions in 2000 and 2002, ",
- "respectively.",
- "<br/><br/>",
-
- "Thanks for your patience as we improve and expand our ",
- "imagery archive.",
- "<br/><br/>",
+ 'From 2013-01-01 to 2013-06-05, imagery in the polar projections',
+ ' are different than the other dates as follows:',
+ '<br/><br/>',
+ 'The <b>Arctic projection</b> is in Arctic Polar ',
+ 'Stereographic (EPSG:3995, "Greenwich down") rather than NSIDC ',
+ ' Polar Stereographic North (EPSG:3413, "Greenland down"). ',
+ 'Coastlines and Graticule for this time range ',
+ 'can be found in the Add Layer tab by searching for ',
+ ' "EPSG:3995". Note that the image snapshot tool will not work ',
+ 'for Arctic imagery during this time range.',
+ '<br/><br/>' +
+
+ 'The <b>Antarctic projection</b> is a sphere with radius of ',
+ '6371007.181 meters during these dates rather than being ',
+ 'projected onto the WGS84 ',
+ ' ellipsoid. For all other dates, the projection is now the ',
+ 'correct Antarctic Polar Stereographic (EPSG:3031). This change ',
+ 'results in a shift of the imagery that ranges up to tens of ',
+ 'kilometers, depending on the location.',
+ '<br/><br/>',
+
+ 'Imagery during this time range will be reprocessed during winter ',
+ '2017-18 to be made consistent with all other imagery. In the ',
+ 'meantime, imagery will continue to be back-processed to the ',
+ 'start of the Terra and Aqua missions in 2000 and 2002, ',
+ 'respectively.',
+ '<br/><br/>',
+
+ 'Thanks for your patience as we improve and expand our ',
+ 'imagery archive.',
+ '<br/><br/>',
"<input id='arcticChangeNoticeDontShowAgain' value='false' ",
"type='checkbox'>Do not show again"
- ].join("");
- wv.ui.notify(message, "Notice", 400);
- var $check = $("#arcticChangeNoticeDontShowAgain");
- $check.on("click", function() {
- if ($check.is(":checked") && wv.util.browser.localStorage) {
- localStorage.setItem(DO_NOT_SHOW_AGAIN, "true");
+ ].join('');
+ wv.ui.notify(message, 'Notice', 400);
+ var $check = $('#arcticChangeNoticeDontShowAgain');
+ $check.on('click', function () {
+ if ($check.is(':checked') && wv.util.browser.localStorage) {
+ localStorage.setItem(DO_NOT_SHOW_AGAIN, 'true');
}
});
};
-
init();
return self;
};
diff --git a/web/js/proj/wv.proj.js b/web/js/proj/wv.proj.js
index 4f43b7d2e..ad788f326 100644
--- a/web/js/proj/wv.proj.js
+++ b/web/js/proj/wv.proj.js
@@ -1,24 +1,22 @@
var wv = wv || {};
-wv.proj = (function(self) {
-
- self.parse = function(state, errors, config) {
+wv.proj = (function (self) {
+ self.parse = function (state, errors, config) {
// Permalink version 1.0 - 1.1
- if (state["switch"]) {
- state.p = state["switch"];
- delete state["switch"];
+ if (state['switch']) {
+ state.p = state['switch'];
+ delete state['switch'];
}
var projId = state.p;
if (projId) {
if (!config.projections[projId]) {
delete state.p;
errors.push({
- message: "Unsupported projection: " + projId
+ message: 'Unsupported projection: ' + projId
});
}
}
};
return self;
-
})(wv.proj || {});
diff --git a/web/js/proj/wv.proj.model.js b/web/js/proj/wv.proj.model.js
index 2e7a5aca1..bf4057c32 100644
--- a/web/js/proj/wv.proj.model.js
+++ b/web/js/proj/wv.proj.model.js
@@ -7,15 +7,14 @@ wv.proj = wv.proj || {};
/**
* @class wv.proj.model
*/
-wv.proj.model = wv.proj.model || function(config) {
-
+wv.proj.model = wv.proj.model || function (config) {
var self = {};
self.selected = null;
self.events = wv.util.events();
- var init = function() {
+ var init = function () {
self.selectDefault();
- _.each(config.projections, function(proj) {
+ _.each(config.projections, function (proj) {
if (proj.crs && proj.proj4) {
self.register(proj.crs, proj.proj4);
ol.proj.get(proj.crs)
@@ -24,37 +23,37 @@ wv.proj.model = wv.proj.model || function(config) {
});
};
- self.select = function(id) {
+ self.select = function (id) {
var proj = config.projections[id];
if (!proj) {
- throw new Error("Invalid projection: " + id);
+ throw new Error('Invalid projection: ' + id);
}
var updated = false;
if (!self.selected || self.selected.id !== id) {
self.selected = proj;
- self.events.trigger("select", proj);
+ self.events.trigger('select', proj);
}
return updated;
};
- self.selectDefault = function() {
+ self.selectDefault = function () {
if (config.defaults && config.defaults.projection) {
self.select(config.defaults.projection);
}
};
- self.save = function(state) {
+ self.save = function (state) {
state.p = self.selected.id;
};
- self.load = function(state) {
+ self.load = function (state) {
var projId = state.p;
if (projId) {
self.select(projId);
}
};
- self.register = function(crs, def) {
+ self.register = function (crs, def) {
if (def && window.proj4) {
proj4.defs(crs, def);
}
diff --git a/web/js/proj/wv.proj.ui.js b/web/js/proj/wv.proj.ui.js
index f906982e8..4bc3f32b9 100644
--- a/web/js/proj/wv.proj.ui.js
+++ b/web/js/proj/wv.proj.ui.js
@@ -9,8 +9,7 @@ wv.proj = wv.proj || {};
*
* @class wv.proj.ui
*/
-wv.proj.ui = wv.proj.ui || function(models, config) {
-
+wv.proj.ui = wv.proj.ui || function (models, config) {
var model = models.proj;
var self = {};
@@ -18,26 +17,26 @@ wv.proj.ui = wv.proj.ui || function(models, config) {
var $label;
var $menuItems;
- var selector = "#wv-proj-button";
- var id = "wv-proj-button";
+ var selector = '#wv-proj-button';
+ var id = 'wv-proj-button';
- var init = function() {
+ var init = function () {
if (config.ui && config.ui.projections) {
render();
}
};
- var render = function() {
- $button = $("<input></input>")
- .attr("type", "checkbox")
- .attr("id", "wv-proj-button-check");
- $label = $("<label></label>")
- .attr("for", "wv-proj-button-check")
- .attr("title", "Switch projection");
- var $icon = $("<i></i>")
- .addClass("fa")
- .addClass("fa-globe")
- .addClass("fa-2x");
+ var render = function () {
+ $button = $('<input></input>')
+ .attr('type', 'checkbox')
+ .attr('id', 'wv-proj-button-check');
+ $label = $('<label></label>')
+ .attr('for', 'wv-proj-button-check')
+ .attr('title', 'Switch projection');
+ var $icon = $('<i></i>')
+ .addClass('fa')
+ .addClass('fa-globe')
+ .addClass('fa-2x');
$label.append($icon);
$(selector)
.append($label);
@@ -47,78 +46,77 @@ wv.proj.ui = wv.proj.ui || function(models, config) {
text: false
});
- $button.click(function(event) {
+ $button.click(function (event) {
event.stopPropagation();
wv.ui.close();
- var checked = $("#wv-proj-button-check")
- .prop("checked");
+ var checked = $('#wv-proj-button-check')
+ .prop('checked');
if (checked) {
show();
}
});
};
- var show = function() {
+ var show = function () {
var $menu = wv.ui.getMenu()
- .attr("id", "wv-proj-menu");
- $menuItems = $("<ul></ul>");
+ .attr('id', 'wv-proj-menu');
+ $menuItems = $('<ul></ul>');
- _.each(config.ui.projections, function(ui) {
+ _.each(config.ui.projections, function (ui) {
var $item = $(
"<li data-proj='" + ui.id + "'>" +
"<a data-proj='" + ui.id + "'>" +
"<i class='ui-icon icon-large " + ui.style + "'>" +
- "</i>" + ui.name + "</a></li>");
+ '</i>' + ui.name + '</a></li>');
$menuItems.append($item);
- $item.click(function() {
+ $item.click(function () {
models.proj.select(ui.id);
- $("#wv-proj-button-check")
- .prop("checked", false);
- $button.button("refresh");
+ $('#wv-proj-button-check')
+ .prop('checked', false);
+ $button.button('refresh');
});
});
$menu.append($menuItems);
$menuItems.menu();
wv.ui.positionMenu($menuItems, {
- my: "left top",
- at: "left bottom+5",
+ my: 'left top',
+ at: 'left bottom+5',
of: $label
});
$menuItems.hide();
- $menuItems.show("slide", {
- direction: "up"
+ $menuItems.show('slide', {
+ direction: 'up'
});
- $("#wv-proj-menu li")
- .removeClass("wv-menu-item-selected");
+ $('#wv-proj-menu li')
+ .removeClass('wv-menu-item-selected');
$("#wv-proj-menu li[data-proj='" + models.proj.selected.id + "']")
- .addClass("wv-menu-item-selected");
+ .addClass('wv-menu-item-selected');
- var clickOut = function(event) {
+ var clickOut = function (event) {
if ($button.parent()
.has(event.target)
.length > 0) {
return;
}
$menuItems.hide();
- $("#wv-proj-button-check")
- .prop("checked", false);
- $("#wv-proj-button label")
- .removeClass("ui-state-hover");
- $button.button("refresh");
- $("body")
- .off("click", clickOut)
- .off("touchstart", clickOut);
+ $('#wv-proj-button-check')
+ .prop('checked', false);
+ $('#wv-proj-button label')
+ .removeClass('ui-state-hover');
+ $button.button('refresh');
+ $('body')
+ .off('click', clickOut)
+ .off('touchstart', clickOut);
};
- $menuItems.on("touchstart", function(event) {
+ $menuItems.on('touchstart', function (event) {
event.stopPropagation();
});
- $("body")
- .one("click", clickOut)
- .one("touchstart", clickOut);
+ $('body')
+ .one('click', clickOut)
+ .one('touchstart', clickOut);
};
init();
return self;
-
};
diff --git a/web/js/ui/wv.ui.indicator.js b/web/js/ui/wv.ui.indicator.js
index eab5de984..cbe495a24 100644
--- a/web/js/ui/wv.ui.indicator.js
+++ b/web/js/ui/wv.ui.indicator.js
@@ -1,7 +1,6 @@
var wv = wv || {};
wv.ui = wv.ui || {};
-wv.ui.indicator = wv.ui.indicator || (function() {
-
+wv.ui.indicator = wv.ui.indicator || (function () {
var self = {};
var $indicator;
@@ -10,20 +9,20 @@ wv.ui.indicator = wv.ui.indicator || (function() {
self.active = [];
- var init = function() {
- $indicator = $("<div></div>")
- .attr("id", "indicator");
- $icon = $("<img />");
- $message = $("<span></span>");
+ var init = function () {
+ $indicator = $('<div></div>')
+ .attr('id', 'indicator');
+ $icon = $('<img />');
+ $message = $('<span></span>');
$indicator.append($icon)
.append($message)
.hide();
- $("body")
+ $('body')
.append($indicator);
};
- self.show = function(message, icon) {
+ self.show = function (message, icon) {
self._show(message, icon);
var id = _.uniqueId();
self.active.push({
@@ -34,11 +33,11 @@ wv.ui.indicator = wv.ui.indicator || (function() {
return id;
};
- self.hide = function(hides) {
+ self.hide = function (hides) {
if (_.isString(hides)) {
hides = [hides];
}
- _.each(hides, function(id) {
+ _.each(hides, function (id) {
_.remove(self.active, {
id: id
});
@@ -51,62 +50,62 @@ wv.ui.indicator = wv.ui.indicator || (function() {
}
};
- self.replace = function(hides, message, icon) {
+ self.replace = function (hides, message, icon) {
self.hide(hides);
return self.show(message, icon);
};
- self._show = function(message, icon) {
+ self._show = function (message, icon) {
if (!$indicator) {
init();
}
if (icon) {
- $indicator.removeClass("message");
- $icon.attr("src", icon)
+ $indicator.removeClass('message');
+ $icon.attr('src', icon)
.show();
} else {
- $indicator.addClass("message");
- $icon.removeAttr("src")
+ $indicator.addClass('message');
+ $icon.removeAttr('src')
.hide();
}
$message.html(message);
$indicator.show();
};
- self._hide = function() {
+ self._hide = function () {
if ($indicator) {
$indicator.hide();
}
};
- self.searching = function(hides) {
+ self.searching = function (hides) {
if (hides) {
self.hide(hides);
}
- return self.show("Searching for Data", "images/activity.gif");
+ return self.show('Searching for Data', 'images/activity.gif');
};
- self.loading = function(hides) {
+ self.loading = function (hides) {
if (hides) {
self.hide(hides);
}
- return self.show("Loading", "images/activity.gif");
+ return self.show('Loading', 'images/activity.gif');
};
- self.noData = function(hides) {
+ self.noData = function (hides) {
if (hides) {
self.hide(hides);
}
- return self.show("No Data Available", "images/red-x.svg");
+ return self.show('No Data Available', 'images/red-x.svg');
};
- self.delayed = function(promise, delay) {
+ self.delayed = function (promise, delay) {
delay = delay || 1000;
var id;
- var timeout = setTimeout(function() {
+ var timeout = setTimeout(function () {
id = self.loading();
}, delay);
- promise.always(function() {
+ promise.always(function () {
clearTimeout(timeout);
if (id) {
self.hide(id);
@@ -115,5 +114,4 @@ wv.ui.indicator = wv.ui.indicator || (function() {
};
return self;
-
})();
diff --git a/web/js/ui/wv.ui.info.js b/web/js/ui/wv.ui.info.js
index 01aaca02f..abc77480d 100644
--- a/web/js/ui/wv.ui.info.js
+++ b/web/js/ui/wv.ui.info.js
@@ -4,19 +4,18 @@
var wv = wv || {};
wv.ui = wv.ui || {};
-wv.ui.info = wv.ui.info || (function(ui, config) {
-
- var selector = "#wv-info-button";
- var $button = $("<input />")
- .attr("type", "checkbox")
- .attr("id", "wv-info-button-check");
- var $label = $("<label></label>")
- .attr("for", "wv-info-button-check")
- .attr("title", "Information");
- var $icon = $("<i></i>")
- .addClass("fa")
- .addClass("fa-info-circle")
- .addClass("fa-2x");
+wv.ui.info = wv.ui.info || function (ui, config) {
+ var selector = '#wv-info-button';
+ var $button = $('<input />')
+ .attr('type', 'checkbox')
+ .attr('id', 'wv-info-button-check');
+ var $label = $('<label></label>')
+ .attr('for', 'wv-info-button-check')
+ .attr('title', 'Information');
+ var $icon = $('<i></i>')
+ .addClass('fa')
+ .addClass('fa-info-circle')
+ .addClass('fa-2x');
$label.append($icon);
$(selector)
.append($label);
@@ -27,22 +26,22 @@ wv.ui.info = wv.ui.info || (function(ui, config) {
text: false
});
- $button.click(function(event) {
+ $button.click(function (event) {
event.stopPropagation();
wv.ui.close();
- var checked = $("#wv-info-button-check")
- .prop("checked");
+ var checked = $('#wv-info-button-check')
+ .prop('checked');
if (checked) {
show();
}
});
- var show = function() {
+ var show = function () {
var $menu = wv.ui.getMenu()
.attr('id', 'wv-info-menu');
var $alerts, $new;
- var whatsNewUrl = "https://github.com/nasa-gibs/worldview/releases";
- var $menuItems = $("<ul></ul>");
+ var whatsNewUrl = 'https://github.com/nasa-gibs/worldview/releases';
+ var $menuItems = $('<ul></ul>');
var $feedback = $("<li><a class='feedback'><i class='ui-icon fa fa-envelope fa-fw'></i>Send Feedback</a></li>");
var $tour = $("<li><a><i class='ui-icon fa fa-truck fa-fw'></i>Start Tour</a></li>");
var $about = $("<li><a><i class='ui-icon fa fa-file fa-fw'></i>About</a></li>");
@@ -77,73 +76,72 @@ wv.ui.info = wv.ui.info || (function(ui, config) {
$menuItems.menu();
wv.ui.positionMenu($menuItems, {
- my: "left top",
- at: "left bottom + 5",
+ my: 'left top',
+ at: 'left bottom + 5',
of: $label
});
$menuItems.hide();
- $about.click(function() {
+ $about.click(function () {
if (wv.util.browser.small || wv.util.browser.touchDevice) {
- window.open("brand/pages/about.html?v=@BUILD_NONCE@", "_blank");
+ window.open('brand/pages/about.html?v=@BUILD_NONCE@', '_blank');
} else {
wv.ui.getDialog()
.dialog({
- title: "About",
+ title: 'About',
width: 625,
height: 525,
show: {
- effect: "fade"
+ effect: 'fade'
},
hide: {
- effect: "fade"
+ effect: 'fade'
}
})
- .load("brand/pages/about.html?v=@BUILD_NONCE@ #page")
- .addClass("wv-opaque");
+ .load('brand/pages/about.html?v=@BUILD_NONCE@ #page')
+ .addClass('wv-opaque');
}
});
- $source.click(function(e) {
- window.open("https://github.com/nasa-gibs/worldview", "_blank");
+ $source.click(function (e) {
+ window.open('https://github.com/nasa-gibs/worldview', '_blank');
});
- wv.feedback.decorate($feedback.find("a"));
+ wv.feedback.decorate($feedback.find('a'));
- $tour.click(function() {
+ $tour.click(function () {
ui.tour.start();
});
- $("#wv-toolbar")
- .find("input:not(#wv-info-button-check)")
- .prop("checked", false)
- .button("refresh");
- $menuItems.show("slide", {
- direction: "up"
+ $('#wv-toolbar')
+ .find('input:not(#wv-info-button-check)')
+ .prop('checked', false)
+ .button('refresh');
+ $menuItems.show('slide', {
+ direction: 'up'
});
- var clickOut = function(event) {
+ var clickOut = function (event) {
if ($button.parent()
.has(event.target)
.length > 0) {
return;
}
$menuItems.hide();
- $("#wv-info-button-check")
- .prop("checked", false);
- $("#wv-info-button")
- .find("label")
- .removeClass("ui-state-hover");
- $button.button("refresh");
- $("body")
- .off("click", clickOut)
- .off("touchstart", clickOut);
+ $('#wv-info-button-check')
+ .prop('checked', false);
+ $('#wv-info-button')
+ .find('label')
+ .removeClass('ui-state-hover');
+ $button.button('refresh');
+ $('body')
+ .off('click', clickOut)
+ .off('touchstart', clickOut);
};
- $menuItems.on("touchstart", function(event) {
+ $menuItems.on('touchstart', function (event) {
event.stopPropagation();
});
- $("html")
- .one("click", clickOut)
- .one("touchstart", clickOut);
+ $('html')
+ .one('click', clickOut)
+ .one('touchstart', clickOut);
};
-
-});
+};
diff --git a/web/js/ui/wv.ui.js b/web/js/ui/wv.ui.js
index 8b3669d8f..5c01f6dc1 100644
--- a/web/js/ui/wv.ui.js
+++ b/web/js/ui/wv.ui.js
@@ -9,8 +9,7 @@ var wv = wv || {};
* @class wv.ui
* @static
*/
-wv.ui = (function(self) {
-
+wv.ui = (function (self) {
/**
* General error handler.
*
@@ -22,19 +21,19 @@ wv.ui = (function(self) {
*
* @param {Exception} cause The exception object that caused the error
*/
- self.error = function() {
+ self.error = function () {
console.error.apply(console, arguments);
self.notify(
"<div class='error-header'>" +
"<i class='error-icon fa fa-exclamation-triangle fa-3x'></i>" +
- "An unexpected error has occurred" +
- "</div>" +
+ 'An unexpected error has occurred' +
+ '</div>' +
"<div class='error-body'>Please reload the page and try " +
- "again. If you continue to have problems, contact us at " +
+ 'again. If you continue to have problems, contact us at ' +
"<a href='mailto:@MAIL@'>" +
- "@MAIL@</a>" +
- "</div>", "Error"
+ '@MAIL@</a>' +
+ '</div>', 'Error'
);
};
@@ -48,26 +47,26 @@ wv.ui = (function(self) {
*
* @param [title="Notice"] {string} Title for the dialog box.
*/
- self.notify = function(message, title, width, callback) {
+ self.notify = function (message, title, width, callback) {
var $dialog = self.getDialog();
- title = title || "Notice";
+ title = title || 'Notice';
width = width || 300;
$dialog.html(message)
.dialog({
title: title,
width: width,
minHeight: 1,
- height: "auto",
+ height: 'auto',
show: {
- effect: "fade",
+ effect: 'fade',
duration: 400
},
hide: {
- effect: "fade",
+ effect: 'fade',
duration: 200
}
})
- .on('dialogclose', function() {
+ .on('dialogclose', function () {
$(this)
.off('dialogclose');
if (callback) {
@@ -76,10 +75,10 @@ wv.ui = (function(self) {
});
};
- self.alert = function(body, title, size, glyph, closeFn) {
+ self.alert = function (body, title, size, glyph, closeFn) {
var $message = $('<span/>', {class: 'notify-message'});
var $icon = $('<i/>', { class: 'fa fa-' + glyph + ' fa-1x', title: title });
- var $messageWrapper = $('<div/>').click(function() {
+ var $messageWrapper = $('<div/>').click(function () {
self.notify(body, title, size);
}).append($icon).append($message);
var $close = $('<i/>', {class: 'fa fa-times fa-1x'}).click(closeFn);
@@ -126,33 +125,33 @@ wv.ui = (function(self) {
* @parma [spec.onCancel] {function} Function to execute when the Cancel
* button is pressed. If not specified, the dialog box simply closes.
*/
- self.ask = function(spec) {
- var $dialog = self.getDialog("wv-dialog-ask");
- var cancelText = spec.cancelButton || "Cancel";
- var okText = spec.okButton || "OK";
+ self.ask = function (spec) {
+ var $dialog = self.getDialog('wv-dialog-ask');
+ var cancelText = spec.cancelButton || 'Cancel';
+ var okText = spec.okButton || 'OK';
var buttons = {};
- buttons[cancelText] = function() {
+ buttons[cancelText] = function () {
$(this)
- .dialog("close");
+ .dialog('close');
if (spec.onCancel) {
spec.onCancel();
}
};
- buttons[okText] = function() {
+ buttons[okText] = function () {
$(this)
- .dialog("close");
+ .dialog('close');
if (spec.onOk) {
spec.onOk();
}
};
$dialog.dialog({
- title: spec.header || "Notice",
+ title: spec.header || 'Notice',
resizable: false,
modal: true,
buttons: buttons
})
.html(spec.message)
- .on("dialogclose", function() {
+ .on('dialogclose', function () {
if (spec.onCancel) {
spec.onCancel();
}
@@ -170,94 +169,93 @@ wv.ui = (function(self) {
* "The <featureName> feature is not supported...". Otherwise it will
* state "This feature..."
*/
- self.unsupported = function(featureName) {
+ self.unsupported = function (featureName) {
var prefix;
if (!featureName) {
- prefix = "This feature";
+ prefix = 'This feature';
} else {
- prefix = "The " + featureName + " feature";
+ prefix = 'The ' + featureName + ' feature';
}
- wv.ui.notify(prefix + " is not supported with your web " +
- "browser. Upgrade or try again in a different browser.");
+ wv.ui.notify(prefix + ' is not supported with your web ' +
+ 'browser. Upgrade or try again in a different browser.');
};
- var getComponent = function(marker) {
- var $element = $("<div></div>")
+ var getComponent = function (marker) {
+ var $element = $('<div></div>')
.addClass(marker);
- $("body")
+ $('body')
.append($element);
return $element;
};
- var closeComponent = function(marker, fnClose) {
- var selector = "." + marker;
+ var closeComponent = function (marker, fnClose) {
+ var selector = '.' + marker;
var $element = $(selector);
if ($element.length !== 0) {
fnClose($element);
}
};
- var closeDialog = function($element) {
+ var closeDialog = function ($element) {
if ($element.length !== 0) {
if ($element.dialog) {
- $element.dialog("close");
+ $element.dialog('close');
}
$element.remove();
}
};
- var closeMenu = function($element) {
+ var closeMenu = function ($element) {
if ($element.length !== 0) {
$element.remove();
}
};
- self.close = function() {
- closeComponent("wv-dialog", closeDialog);
- closeComponent("wv-menu", closeMenu);
+ self.close = function () {
+ closeComponent('wv-dialog', closeDialog);
+ closeComponent('wv-menu', closeMenu);
};
- self.getDialog = function(marker) {
+ self.getDialog = function (marker) {
self.close(marker);
- return getComponent(marker || "wv-dialog", closeDialog);
+ return getComponent(marker || 'wv-dialog', closeDialog);
};
- self.getMenu = function(marker) {
+ self.getMenu = function (marker) {
self.close();
- return getComponent(marker || "wv-menu", closeMenu);
+ return getComponent(marker || 'wv-menu', closeMenu);
};
- self.closeDialog = function() {
+ self.closeDialog = function () {
self.close();
};
- self.positionMenu = function($menuItems, pos) {
- var position = function() {
+ self.positionMenu = function ($menuItems, pos) {
+ var position = function () {
$menuItems.menu()
.position(pos);
};
position();
$(window)
.resize(position);
- $menuItems.on("hide", function() {
+ $menuItems.on('hide', function () {
$(window)
- .off("resize", position);
+ .off('resize', position);
});
};
- self.positionDialog = function($dialog, pos) {
- var position = function() {
- $dialog.dialog("option", "position", pos);
+ self.positionDialog = function ($dialog, pos) {
+ var position = function () {
+ $dialog.dialog('option', 'position', pos);
};
position();
$(window)
.resize(position);
- $dialog.on("dialogclose", function() {
+ $dialog.on('dialogclose', function () {
$(window)
- .off("resize", position);
+ .off('resize', position);
});
};
return self;
-
})(wv.ui = wv.ui || {});
diff --git a/web/js/ui/wv.ui.mouse.js b/web/js/ui/wv.ui.mouse.js
index 36a9a48cc..38a3c72c0 100644
--- a/web/js/ui/wv.ui.mouse.js
+++ b/web/js/ui/wv.ui.mouse.js
@@ -2,30 +2,29 @@ var wv = wv || {};
wv.ui = wv.ui || {};
wv.ui.mouse = wv.ui.mouse || {};
-wv.ui.mouse.click = wv.ui.mouse.click || function($element, callback) {
-
+wv.ui.mouse.click = wv.ui.mouse.click || function ($element, callback) {
var self = {};
self.sensitivity = 5; // pixels
var startX, startY;
- var init = function() {
+ var init = function () {
$element.mousedown(mousedown);
$element.mouseup(mouseup);
};
- var mousedown = function(event) {
+ var mousedown = function (event) {
startX = event.clientX;
startY = event.clientY;
};
- var mouseup = function(event) {
+ var mouseup = function (event) {
if (withinClickDistance(event)) {
callback.call(this);
}
};
- var withinClickDistance = function(event) {
+ var withinClickDistance = function (event) {
var targetX = event.clientX;
var targetY = event.clientY;
var distance = Math.sqrt(Math.pow(startX - targetX, 2) +
@@ -35,10 +34,9 @@ wv.ui.mouse.click = wv.ui.mouse.click || function($element, callback) {
init();
return self;
-
};
-wv.ui.mouse.wheel = wv.ui.mouse.wheel || function(element, ui, options) {
+wv.ui.mouse.wheel = wv.ui.mouse.wheel || function (element, ui, options) {
options = options || {};
var self = {};
@@ -52,16 +50,16 @@ wv.ui.mouse.wheel = wv.ui.mouse.wheel || function(element, ui, options) {
var timeout = false;
var lastEvent = null;
- var init = function() {
- element.on("zoom", wheel);
+ var init = function () {
+ element.on('zoom', wheel);
};
- self.change = function(listener) {
- self.events.on("change", listener);
+ self.change = function (listener) {
+ self.events.on('change', listener);
return self;
};
- var wheel = function() {
+ var wheel = function () {
var evt = d3.event.sourceEvent;
if ((Math.abs(evt.deltaX) <= Math.abs(evt.deltaY)) && timeout === false) {
lastEvent = evt;
@@ -77,7 +75,7 @@ wv.ui.mouse.wheel = wv.ui.mouse.wheel || function(element, ui, options) {
ui.timeline.pan.axis(d3.event);
timeout = true;
clearTimeout(timer);
- timer = setTimeout(function() {
+ timer = setTimeout(function () {
timeout = false;
}, 500);
}
@@ -88,21 +86,21 @@ wv.ui.mouse.wheel = wv.ui.mouse.wheel || function(element, ui, options) {
}
};
- var update = function(event) {
+ var update = function (event) {
var change = Math.floor(Math.abs(delta) / self.threshold);
if (change >= 1) {
var sign = delta ? delta < 0 ? -1 : 1 : 0;
- self.events.trigger("change", sign * change, event);
+ self.events.trigger('change', sign * change, event);
delta = delta % self.threshold;
zoomed = true;
}
};
- var end = function() {
+ var end = function () {
timer = null;
if (!zoomed) {
var sign = delta ? delta < 0 ? -1 : 1 : 0;
- self.events.trigger("change", sign, lastEvent);
+ self.events.trigger('change', sign, lastEvent);
}
lastEvent = null;
delta = 0;
@@ -111,5 +109,4 @@ wv.ui.mouse.wheel = wv.ui.mouse.wheel || function(element, ui, options) {
init();
return self;
-
};
diff --git a/web/js/util/wv.util.browser.js b/web/js/util/wv.util.browser.js
index 1c8c0fc8a..bb57f4e54 100644
--- a/web/js/util/wv.util.browser.js
+++ b/web/js/util/wv.util.browser.js
@@ -13,8 +13,7 @@ wv.util = wv.util || {};
* @class wv.util.browser
* @static
*/
-wv.util.browser = wv.util.browser || (function() {
-
+wv.util.browser = wv.util.browser || (function () {
var self = {};
/**
@@ -87,7 +86,7 @@ wv.util.browser = wv.util.browser || (function() {
self.mobileWidth = 740;
self.constrainedHeight = 320;
- var init = function() {
+ var init = function () {
var tests = self.tests;
if (tests.safari()) {
@@ -107,13 +106,13 @@ wv.util.browser = wv.util.browser || (function() {
self.history = tests.history();
self.touchDevice = tests.touchDevice();
- var onResize = function() {
+ var onResize = function () {
self.small = tests.small();
self.constrained = tests.constrained();
};
$(window)
- .on("resize", onResize);
- $(function() {
+ .on('resize', onResize);
+ $(function () {
onResize();
});
};
@@ -122,11 +121,11 @@ wv.util.browser = wv.util.browser || (function() {
// set in the init function. These functions are useful for testing.
self.tests = {};
- self.tests.navigator = function() {
+ self.tests.navigator = function () {
return navigator;
};
- self.tests.window = function(property) {
+ self.tests.window = function (property) {
// Some browsers throw an error when attempting to access restricted Window objects
try {
return window[property];
@@ -135,7 +134,7 @@ wv.util.browser = wv.util.browser || (function() {
}
};
- self.tests.safari = function() {
+ self.tests.safari = function () {
var navigator = self.tests.navigator();
if (/ Chrome\//.test(navigator.userAgent)) {
return false;
@@ -144,55 +143,55 @@ wv.util.browser = wv.util.browser || (function() {
.test(navigator.userAgent);
};
- self.tests.safariVersion = function() {
+ self.tests.safariVersion = function () {
var navigator = self.tests.navigator();
var version = navigator.userAgent.match(/ Version\/([^ ]+)/);
if (version) {
- return parseInt(version[1].split(".")[0]);
+ return parseInt(version[1].split('.')[0]);
}
};
- self.tests.ie = function() {
+ self.tests.ie = function () {
var navigator = self.tests.navigator();
if (/MSIE /.test(navigator.userAgent)) {
return true;
}
// IE 11
- return navigator.appName === "Netscape" && /Trident/.test(navigator.userAgent);
+ return navigator.appName === 'Netscape' && /Trident/.test(navigator.userAgent);
};
- self.tests.firefox = function() {
+ self.tests.firefox = function () {
return navigator.userAgent.toLowerCase()
- .indexOf("firefox") > -1;
+ .indexOf('firefox') > -1;
};
- self.tests.touchDevice = function() {
+ self.tests.touchDevice = function () {
var el = document.createElement('div');
el.setAttribute('ontouchstart', 'return;');
- return typeof el.ontouchstart === "function";
+ return typeof el.ontouchstart === 'function';
};
- self.tests.ieVersion = function() {
+ self.tests.ieVersion = function () {
var navigator = self.tests.navigator();
var version = navigator.userAgent.match(/MSIE ([\d\.]+)/);
if (version) {
- return parseInt(version[1].split(".")[0]);
+ return parseInt(version[1].split('.')[0]);
}
};
- self.tests.cors = function() {
+ self.tests.cors = function () {
if (self.tests.safari() && self.tests.safariVersion() <= 6) {
return false;
}
return !self.tests.ie();
};
- self.tests.webWorkers = function() {
- return self.tests.window("Worker");
+ self.tests.webWorkers = function () {
+ return self.tests.window('Worker');
};
- self.tests.localStorage = function() {
- if (!self.tests.window("localStorage")) {
+ self.tests.localStorage = function () {
+ if (!self.tests.window('localStorage')) {
return false;
}
try {
@@ -207,23 +206,22 @@ wv.util.browser = wv.util.browser || (function() {
}
};
- self.tests.small = function() {
+ self.tests.small = function () {
return $(window)
.width() < self.mobileWidth;
};
- self.tests.constrained = function() {
+ self.tests.constrained = function () {
return $(window)
.height() < self.constrainedHeight;
};
- self.tests.history = function() {
+ self.tests.history = function () {
return window.history && window.history.replaceState;
};
init();
return self;
-
})();
// ===========================================================================
@@ -236,16 +234,15 @@ wv.util.browser = wv.util.browser || (function() {
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
*/
if (!Date.prototype.toISOString) {
- (function() {
-
- function pad(number) {
+ (function () {
+ function pad (number) {
if (number < 10) {
return '0' + number;
}
return number;
}
- Date.prototype.toISOString = function() {
+ Date.prototype.toISOString = function () {
return this.getUTCFullYear() +
'-' + pad(this.getUTCMonth() + 1) +
'-' + pad(this.getUTCDate()) +
@@ -264,12 +261,12 @@ if (!Date.prototype.toISOString) {
* console
*/
if (!window.console) {
- (function() {
+ (function () {
window.console = {
- log: function() {},
- warn: function() {},
- info: function() {},
- error: function() {}
+ log: function () {},
+ warn: function () {},
+ info: function () {},
+ error: function () {}
};
})();
}
@@ -277,8 +274,8 @@ if (!window.console) {
/*
* Get rid of address bar on iphone/ipod
*/
-(function() {
- var execute = function() {
+(function () {
+ var execute = function () {
window.scrollTo(0, 0);
if (document.body) {
document.body.style.height = '100%';
@@ -296,7 +293,7 @@ if (!window.console) {
/*
* Hide the URL bar
*/
-(function() {
+(function () {
window.scrollTo(0, 0);
})();
@@ -307,23 +304,22 @@ if (!window.console) {
* https://developer.mozilla.org/en-US/docs/Web/API/Window.setTimeout
*/
if (wv.util.browser.ie && wv.util.browser.version <= 9) {
- (function() {
-
+ (function () {
var __nativeST__ = window.setTimeout,
__nativeSI__ = window.setInterval;
- window.setTimeout = function(vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */ ) {
+ window.setTimeout = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
var oThis = this,
aArgs = Array.prototype.slice.call(arguments, 2);
- return __nativeST__(vCallback instanceof Function ? function() {
+ return __nativeST__(vCallback instanceof Function ? function () {
vCallback.apply(oThis, aArgs);
} : vCallback, nDelay);
};
- window.setInterval = function(vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */ ) {
+ window.setInterval = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
var oThis = this,
aArgs = Array.prototype.slice.call(arguments, 2);
- return __nativeSI__(vCallback instanceof Function ? function() {
+ return __nativeSI__(vCallback instanceof Function ? function () {
vCallback.apply(oThis, aArgs);
} : vCallback, nDelay);
};
@@ -336,10 +332,10 @@ if (wv.util.browser.ie && wv.util.browser.version <= 9) {
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/contains
*/
if (!('contains' in String.prototype)) {
- (function() {
- String.prototype.contains = function(str, startIndex) {
- return -1 !== String.prototype.indexOf.call(this, str,
- startIndex);
+ (function () {
+ String.prototype.contains = function (str, startIndex) {
+ return String.prototype.indexOf.call(this, str,
+ startIndex) !== -1;
};
})();
}
@@ -350,12 +346,12 @@ if (!('contains' in String.prototype)) {
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
*/
if (!String.prototype.startsWith) {
- (function() {
+ (function () {
Object.defineProperty(String.prototype, 'startsWith', {
enumerable: false,
configurable: false,
writable: false,
- value: function(searchString, position) {
+ value: function (searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
}
@@ -369,12 +365,12 @@ if (!String.prototype.startsWith) {
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
*/
if (!String.prototype.endsWith) {
- (function() {
+ (function () {
Object.defineProperty(String.prototype, 'endsWith', {
enumerable: false,
configurable: false,
writable: false,
- value: function(searchString, position) {
+ value: function (searchString, position) {
position = position || this.length;
position = position - searchString.length;
var lastIndex = this.lastIndexOf(searchString);
@@ -387,7 +383,7 @@ if (!String.prototype.endsWith) {
/*
* Mobile device quirks. This section is mostly overwriting things that jquery.mobile is adding
*/
-(function() {
+(function () {
if (navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
@@ -402,31 +398,30 @@ if (!String.prototype.endsWith) {
}
}
-
if (navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('Android') != -1) {
// In Safari, the true version is after "Safari"
if (navigator.userAgent.indexOf('Safari') != -1) {
// Set a variable to use later
mobileSafari = true;
}
- addEventListener("load", function() {
+ addEventListener('load', function () {
if (mobile) {
$(".layerPicker a[href='#DataDownload']")
.hide();
}
setHeight();
window.scrollTo(0, 1);
- $("#app, .ui-mobile, .ui-mobile .ui-page")
- .css("min-height", 0);
+ $('#app, .ui-mobile, .ui-mobile .ui-page')
+ .css('min-height', 0);
}, false);
- addEventListener("orientationchange", function() {
+ addEventListener('orientationchange', function () {
window.scrollTo(0, 1);
setHeight();
}, false);
}
// Set the div height
- function setHeight($body) {
+ function setHeight ($body) {
if (navigator.userAgent.match(/(iPad|iPhone|iPod touch);.*CPU.*OS 6_\d/i)) {
var new_height = $(window)
.height();
@@ -436,9 +431,8 @@ if (!String.prototype.endsWith) {
.css('min-height', 0)
.css('height', new_height);
} else {
- $("#app, .ui-mobile, .ui-mobile .ui-page")
- .css("min-height", 0);
+ $('#app, .ui-mobile, .ui-mobile .ui-page')
+ .css('min-height', 0);
}
}
-
})();
diff --git a/web/js/util/wv.util.events.js b/web/js/util/wv.util.events.js
index ae36e7753..3ea4fc0ba 100644
--- a/web/js/util/wv.util.events.js
+++ b/web/js/util/wv.util.events.js
@@ -1,17 +1,16 @@
var wv = wv || {};
wv.util = wv.util || {};
-wv.util.events = wv.util.events || function() {
-
+wv.util.events = wv.util.events || function () {
var self = {};
// Object of event types. Each event type is an array of listeners.
var events = {};
var allListeners = [];
- self.on = function(event, callback) {
+ self.on = function (event, callback) {
if (!callback) {
- throw new Error("No listener specified");
+ throw new Error('No listener specified');
}
var listeners = events[event];
if (!listeners) {
@@ -22,7 +21,7 @@ wv.util.events = wv.util.events || function() {
return self;
};
- self.off = function(event, callback) {
+ self.off = function (event, callback) {
var listeners = events[event];
if (listeners) {
_.pull(listeners, callback);
@@ -30,23 +29,23 @@ wv.util.events = wv.util.events || function() {
return self;
};
- self.any = function(callback) {
+ self.any = function (callback) {
if (!callback) {
- throw new Error("No listener specified");
+ throw new Error('No listener specified');
}
allListeners.push(callback);
};
- self.trigger = function(event) {
+ self.trigger = function (event) {
var listeners = events[event];
if (!listeners && !allListeners) {
return;
}
var eventArguments = Array.prototype.slice.call(arguments, 1);
- _.each(events[event], function(listener) {
+ _.each(events[event], function (listener) {
listener.apply(self, eventArguments);
});
- _.each(allListeners, function(listener) {
+ _.each(allListeners, function (listener) {
listener.apply(self, eventArguments);
});
return self;
diff --git a/web/js/util/wv.util.js b/web/js/util/wv.util.js
index 3db8aca3f..e82f0f170 100644
--- a/web/js/util/wv.util.js
+++ b/web/js/util/wv.util.js
@@ -9,32 +9,32 @@ var wv = wv || {};
* @class wv.util
* @static
*/
-wv.util = (function(self) {
+wv.util = (function (self) {
var canvas = null;
// Needed anymore?
self.LAYER_GROUPS = {
baselayers: {
- id: "baselayers",
- camel: "BaseLayers",
- description: "Base Layers"
+ id: 'baselayers',
+ camel: 'BaseLayers',
+ description: 'Base Layers'
},
overlays: {
- id: "overlays",
- camel: "Overlays",
- description: "Overlays"
+ id: 'overlays',
+ camel: 'Overlays',
+ description: 'Overlays'
}
};
- self.repeat = function(value, length) {
- var result = "";
+ self.repeat = function (value, length) {
+ var result = '';
for (var i = 0; i < length; i++) {
result += value;
}
return result;
};
- self.pad = function(value, width, padding) {
- value = "" + value;
+ self.pad = function (value, width, padding) {
+ value = '' + value;
if (value.length < width) {
var add = width - value.length;
value = self.repeat(padding, add) + value;
@@ -62,17 +62,17 @@ wv.util = (function(self) {
* object.
* @return {object} object representation of the query string.
*/
- self.fromQueryString = function(queryString) {
+ self.fromQueryString = function (queryString) {
if (!queryString) {
return {};
}
- if (queryString[0] === "?") {
+ if (queryString[0] === '?') {
queryString = queryString.substring(1);
}
- var parameters = queryString.split("&");
+ var parameters = queryString.split('&');
var result = {};
for (var i = 0; i < parameters.length; i++) {
- var index = parameters[i].indexOf("=");
+ var index = parameters[i].indexOf('=');
var key = parameters[i].substring(0, index);
var value = parameters[i].substring(index + 1);
result[key] = decodeURIComponent(value);
@@ -101,22 +101,22 @@ wv.util = (function(self) {
* "format=image/png"
* @return {String} converted query string
*/
- self.toQueryString = function(kvps, exceptions) {
+ self.toQueryString = function (kvps, exceptions) {
exceptions = exceptions || {};
var parts = [];
- _.each(kvps, function(value, key) {
- var part = key + "=" + encodeURIComponent(value);
- _.each(exceptions, function(exception) {
- var regexp = new RegExp(exception, "ig");
+ _.each(kvps, function (value, key) {
+ var part = key + '=' + encodeURIComponent(value);
+ _.each(exceptions, function (exception) {
+ var regexp = new RegExp(exception, 'ig');
var decoded = decodeURIComponent(exception);
part = part.replace(regexp, decoded);
});
parts.push(part);
});
if (parts.length === 0) {
- return "";
+ return '';
}
- return "?" + parts.join("&");
+ return '?' + parts.join('&');
};
/**
@@ -130,7 +130,7 @@ wv.util = (function(self) {
* @return {Date} converted string as a datetime object, throws an
* exception if the string is invalid.
*/
- self.parseTimestampUTC = function(str) {
+ self.parseTimestampUTC = function (str) {
return self.parseDateUTC(str);
};
/**
@@ -143,8 +143,8 @@ wv.util = (function(self) {
* @return y {Number} Y value on canvas
* @return {Object} Canvas image data.
*/
- self.getCanvasPixelData = function(canvas, x, y) {
- var context = canvas.getContext("2d");
+ self.getCanvasPixelData = function (canvas, x, y) {
+ var context = canvas.getContext('2d');
return context.getImageData(x, y, 1, 1)
.data;
};
@@ -158,10 +158,10 @@ wv.util = (function(self) {
* the string is invalid
*/
// NOTE: Older Safari doesn't like Date.parse
- self.parseDateUTC = function(dateAsString) {
+ self.parseDateUTC = function (dateAsString) {
var dateTimeArr = dateAsString.split(/T/);
- var yyyymmdd = dateTimeArr[0].split("-");
+ var yyyymmdd = dateTimeArr[0].split('-');
// Parse elements of date and time
var year = yyyymmdd[0];
@@ -184,7 +184,7 @@ wv.util = (function(self) {
var date = new Date(Date.UTC(year, month, day, hour, minute, second,
millisecond));
if (isNaN(date.getTime())) {
- throw new Error("Invalid date: " + dateAsString);
+ throw new Error('Invalid date: ' + dateAsString);
}
return date;
};
@@ -196,10 +196,10 @@ wv.util = (function(self) {
*
* @see http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393
*/
- self.getTextWidth = function(text, font) {
+ self.getTextWidth = function (text, font) {
// re-use canvas object for better performance
- canvas = canvas || document.createElement("canvas");
- var context = canvas.getContext("2d");
+ canvas = canvas || document.createElement('canvas');
+ var context = canvas.getContext('2d');
context.font = font;
var metrics = context.measureText(text);
return metrics.width;
@@ -212,9 +212,9 @@ wv.util = (function(self) {
* @param date {Date} the date to convert
* @return {string} ISO string in the form of ``YYYY-MM-DD``.
*/
- self.toISOStringDate = function(date) {
+ self.toISOStringDate = function (date) {
return date.toISOString()
- .split("T")[0];
+ .split('T')[0];
};
/**
@@ -225,11 +225,11 @@ wv.util = (function(self) {
* @param date {Date} the date to convert
* @return {string} ISO string in the form of ``HH:MM``.
*/
- self.toISOStringTimeHM = function(date) {
+ self.toISOStringTimeHM = function (date) {
var time = date.toISOString()
- .split("T")[1];
- var parts = time.split(".")[0].split(":");
- return parts[0] + ":" + parts[1];
+ .split('T')[1];
+ var parts = time.split('.')[0].split(':');
+ return parts[0] + ':' + parts[1];
};
/**
* Calculates percent of date between two other dates
@@ -241,7 +241,7 @@ wv.util = (function(self) {
* @param end {Date} end date
* @return {number} decimal percent
*/
- self.getDatePercent = function(current, start, end) {
+ self.getDatePercent = function (current, start, end) {
return Math.round((current - start) / (end - start));
};
/**
@@ -253,7 +253,7 @@ wv.util = (function(self) {
* to zero.
* @return {Date} the date object
*/
- self.clearTimeUTC = function(date) {
+ self.clearTimeUTC = function (date) {
date.setUTCHours(0);
date.setUTCMinutes(0);
date.setUTCSeconds(0);
@@ -261,14 +261,14 @@ wv.util = (function(self) {
return date;
};
- self.dateAdd = function(date, interval, amount) {
+ self.dateAdd = function (date, interval, amount) {
var month, maxDay, year;
var newDate = new Date(date.getTime());
switch (interval) {
- case "day":
+ case 'day':
newDate.setUTCDate(newDate.getUTCDate() + amount);
break;
- case "month":
+ case 'month':
year = newDate.getUTCFullYear();
month = newDate.getUTCMonth();
maxDay = new Date(year, month + amount + 1, 0)
@@ -278,15 +278,15 @@ wv.util = (function(self) {
}
newDate.setUTCMonth(month + amount);
break;
- case "year":
+ case 'year':
newDate.setUTCFullYear(newDate.getUTCFullYear() + amount);
break;
default:
- throw new Error("[dateAdd] Invalid interval: " + interval);
+ throw new Error('[dateAdd] Invalid interval: ' + interval);
}
return newDate;
};
- self.daysInMonth = function(d) {
+ self.daysInMonth = function (d) {
var y;
var m;
if (d.getUTCFullYear) {
@@ -299,7 +299,7 @@ wv.util = (function(self) {
var lastDay = new Date(Date.UTC(y, m + 1, 0));
return lastDay.getUTCDate();
};
- self.objectLength = function(obj) {
+ self.objectLength = function (obj) {
return Object.keys(obj)
.length;
};
@@ -312,15 +312,15 @@ wv.util = (function(self) {
* @param date {Date} date object of which to determine week day
* @return {String} the full name of the day of the week
*/
- self.giveWeekDay = function(d) {
+ self.giveWeekDay = function (d) {
var day = [
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday",
+ 'Sunday',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
+ 'Saturday'
];
return day[d.getUTCDay()];
@@ -333,26 +333,26 @@ wv.util = (function(self) {
* @param date {Date} date object of which to determine the Month name
* @return {String} the full name of the month
*/
- self.giveMonth = function(d) {
+ self.giveMonth = function (d) {
var month = [
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"
+ 'January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ 'August',
+ 'September',
+ 'October',
+ 'November',
+ 'December'
];
return month[d.getUTCMonth()];
};
- self.clamp = function(val, min, max) {
+ self.clamp = function (val, min, max) {
if (val < min) {
return min;
}
@@ -362,7 +362,7 @@ wv.util = (function(self) {
return val;
};
- self.roll = function(val, min, max) {
+ self.roll = function (val, min, max) {
if (val < min) {
return max - (min - val) + 1;
}
@@ -372,20 +372,20 @@ wv.util = (function(self) {
return val;
};
- self.minDate = function() {
+ self.minDate = function () {
return new Date(Date.UTC(1000, 0, 1));
};
- self.maxDate = function() {
+ self.maxDate = function () {
return new Date(Date.UTC(3000, 11, 31));
};
- self.rollRange = function(date, interval, minDate, maxDate) {
+ self.rollRange = function (date, interval, minDate, maxDate) {
var y = date.getUTCFullYear();
var m = date.getUTCMonth();
var first, last;
switch (interval) {
- case "day":
+ case 'day':
var firstDay = new Date(Date.UTC(y, m, 1));
var lastDay = new Date(Date.UTC(y, m, self.daysInMonth(date)));
first = new Date(Math.max(firstDay, minDate))
@@ -393,7 +393,7 @@ wv.util = (function(self) {
last = new Date(Math.min(lastDay, maxDate))
.getUTCDate();
break;
- case "month":
+ case 'month':
var firstMonth = new Date(Date.UTC(y, 0, 1));
var lastMonth = new Date(Date.UTC(y, 11, 31));
first = new Date(Math.max(firstMonth, minDate))
@@ -401,7 +401,7 @@ wv.util = (function(self) {
last = new Date(Math.min(lastMonth, maxDate))
.getUTCMonth();
break;
- case "year":
+ case 'year':
var firstYear = self.minDate();
var lastYear = self.maxDate();
first = new Date(Math.max(firstYear, minDate))
@@ -416,7 +416,7 @@ wv.util = (function(self) {
};
};
- self.rollDate = function(date, interval, amount, minDate, maxDate) {
+ self.rollDate = function (date, interval, amount, minDate, maxDate) {
minDate = minDate || self.minDate();
maxDate = maxDate || self.maxDate();
var range = self.rollRange(date, interval, minDate, maxDate);
@@ -426,17 +426,17 @@ wv.util = (function(self) {
var month = date.getUTCMonth();
var year = date.getUTCFullYear();
switch (interval) {
- case "day":
+ case 'day':
day = self.roll(day + amount, min, max);
break;
- case "month":
+ case 'month':
month = self.roll(month + amount, min, max);
break;
- case "year":
+ case 'year':
year = self.roll(year + amount, min, max);
break;
default:
- throw new Error("[rollDate] Invalid interval: " + interval);
+ throw new Error('[rollDate] Invalid interval: ' + interval);
}
var daysInMonth = self.daysInMonth({
year: year,
@@ -459,9 +459,9 @@ wv.util = (function(self) {
* @return {String} string representation in the form of
* ``YYYYMMDDHHMMSSsss``
*/
- self.toCompactTimestamp = function(date) {
+ self.toCompactTimestamp = function (date) {
return date.toISOString()
- .replace(/[-:TZ\.]/g, "");
+ .replace(/[-:TZ\.]/g, '');
};
/**
@@ -473,10 +473,10 @@ wv.util = (function(self) {
* ``YYYYMMDDHHMMSSsss``.
* @return {Date} the converted date object.
*/
- self.fromCompactTimestamp = function(str) {
+ self.fromCompactTimestamp = function (str) {
var v = str.match(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{3})/);
if (_.isNull(v)) {
- throw new Error("Invalid timestamp:" + str);
+ throw new Error('Invalid timestamp:' + str);
}
return new Date(Date.UTC(
parseInt(v[1], 10),
@@ -496,11 +496,11 @@ wv.util = (function(self) {
* @static
* @return {Date} The current time or an overriden value.
*/
- var now = function() {
+ var now = function () {
return new Date();
};
self.now = now;
- self.resetNow = function() {
+ self.resetNow = function () {
self.now = now;
};
@@ -513,7 +513,7 @@ wv.util = (function(self) {
* @return {Date} The current time with the UTC hours, minutes, and seconds
* fields set to zero or an overriden value.
*/
- self.today = function() {
+ self.today = function () {
return self.clearTimeUTC(self.now());
};
@@ -529,7 +529,7 @@ wv.util = (function(self) {
* @param {string} message Message to display to the end user.
* @param {Exception} cause The exception object that caused the error
*/
- self.error = function(message, cause) {
+ self.error = function (message, cause) {
wv.ui.error(message, cause);
};
@@ -542,32 +542,31 @@ wv.util = (function(self) {
* @static
* @param {object*} messages Messages to display to the end user.
*/
- self.warn = (console && console.warn && console.warn.bind) ?
- console.warn.bind(console) : function() {};
+ self.warn = (console && console.warn && console.warn.bind)
+ ? console.warn.bind(console) : function () {};
-
- self.hexToRGB = function(str) {
- return "rgb(" +
- parseInt(str.substring(0, 2), 16) + "," +
- parseInt(str.substring(2, 4), 16) + "," +
- parseInt(str.substring(4, 6), 16) + ")";
+ self.hexToRGB = function (str) {
+ return 'rgb(' +
+ parseInt(str.substring(0, 2), 16) + ',' +
+ parseInt(str.substring(2, 4), 16) + ',' +
+ parseInt(str.substring(4, 6), 16) + ')';
};
- self.hexToRGBA = function(str) {
- return "rgba(" +
- parseInt(str.substring(0, 2), 16) + "," +
- parseInt(str.substring(2, 4), 16) + "," +
- parseInt(str.substring(4, 6), 16) + "," +
- parseInt(str.substring(6, 8), 16) + ")";
+ self.hexToRGBA = function (str) {
+ return 'rgba(' +
+ parseInt(str.substring(0, 2), 16) + ',' +
+ parseInt(str.substring(2, 4), 16) + ',' +
+ parseInt(str.substring(4, 6), 16) + ',' +
+ parseInt(str.substring(6, 8), 16) + ')';
};
- self.rgbaToHex = function(r, g, b) {
- function hex(c) {
+ self.rgbaToHex = function (r, g, b) {
+ function hex (c) {
var strHex = c.toString(16);
- return strHex.length == 1 ? "0" + strHex : strHex;
+ return strHex.length == 1 ? '0' + strHex : strHex;
}
return hex(r) + hex(g) + hex(b) + 'ff';
};
- self.hexColorDelta = function(hex1, hex2) {
+ self.hexColorDelta = function (hex1, hex2) {
var r1 = parseInt(hex1.substring(0, 2), 16);
var g1 = parseInt(hex1.substring(2, 4), 16);
var b1 = parseInt(hex1.substring(4, 6), 16);
@@ -587,7 +586,7 @@ wv.util = (function(self) {
* @param {Object} [spec.options] options to pass to jscache on setItem.
*
*/
- self.ajaxCache = function(spec) {
+ self.ajaxCache = function (spec) {
spec = spec || {};
var size = spec.size || null;
var options = spec.options || {};
@@ -605,10 +604,10 @@ wv.util = (function(self) {
* when the query returns, or resolves immedately if the results
* are cached.
*/
- submit: function(parameters) {
- var key = "url=" + parameters.url;
+ submit: function (parameters) {
+ var key = 'url=' + parameters.url;
if (parameters.data) {
- key += "&query=" + $.param(parameters.data, true);
+ key += '&query=' + $.param(parameters.data, true);
}
var results = cache.getItem(key);
@@ -618,7 +617,7 @@ wv.util = (function(self) {
.promise();
} else {
var promise = $.ajax(parameters);
- promise.done(function(results) {
+ promise.done(function (results) {
cache.setItem(key, results, options);
});
return promise;
@@ -634,8 +633,8 @@ wv.util = (function(self) {
* @param {function} func the function to wrap
* @return the function wrapped in a try/catch block.
*/
- self.wrap = function(func) {
- return function() {
+ self.wrap = function (func) {
+ return function () {
try {
return func.apply(func, arguments);
} catch (error) {
@@ -651,14 +650,14 @@ wv.util = (function(self) {
* @param {url} func the function to wrap
* @return {object} Promise
*/
- self.get = function(url) {
+ self.get = function (url) {
// Return a new promise.
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
- req.onload = function() {
+ req.onload = function () {
// This is called even on 404 etc
// so check the status
if (req.status == 200) {
@@ -671,29 +670,28 @@ wv.util = (function(self) {
}
};
// Handle network errors
- req.onerror = function() {
- reject(Error("Network Error"));
+ req.onerror = function () {
+ reject(Error('Network Error'));
};
// Make the request
req.send();
});
};
// FIXME: Should be replaced with $.when
- self.ajaxJoin = function(calls) {
-
+ self.ajaxJoin = function (calls) {
var completed = 0;
var result = {};
var deferred = $.Deferred();
- $.each(calls, function(index, call) {
- call.promise.done(function(data) {
+ $.each(calls, function (index, call) {
+ call.promise.done(function (data) {
result[call.item] = data;
completed += 1;
if (completed == calls.length) {
deferred.resolve(result);
}
})
- .fail(function(jqXHR, textStatus, errorThrown) {
+ .fail(function (jqXHR, textStatus, errorThrown) {
deferred.reject(jqXHR, textStatus, errorThrown);
});
});
@@ -702,16 +700,16 @@ wv.util = (function(self) {
};
// http://totaldev.com/content/escaping-characters-get-valid-jquery-id
- self.jqueryEscape = function(str) {
+ self.jqueryEscape = function (str) {
return encodeURIComponent(str)
.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
};
- self.metrics = function() {
+ self.metrics = function () {
if (window.ntptEventTag) {
ntptEventTag.apply(null, arguments);
} else {
- console.log("no metrics");
+ console.log('no metrics');
}
};
@@ -722,14 +720,14 @@ wv.util = (function(self) {
DOWN: 40
};
- self.formatDMS = function(value, type) {
+ self.formatDMS = function (value, type) {
var width, signs;
- if (type === "longitude") {
+ if (type === 'longitude') {
width = 3;
- signs = "EW";
+ signs = 'EW';
} else {
width = 2;
- signs = "NS";
+ signs = 'NS';
}
var sign = (value >= 0) ? signs[0] : signs[1];
value = Math.abs(value);
@@ -737,39 +735,39 @@ wv.util = (function(self) {
var minutes = Math.floor((value * 60) - (degrees * 60));
var seconds = Math.floor((value * 3600) - (degrees * 3600) - (minutes * 60));
- var sdegrees = self.pad(degrees, width, " ");
- var sminutes = self.pad(minutes, 2, "0");
- var sseconds = self.pad(seconds, 2, "0");
- return sdegrees + "&deg;" + sminutes + "'" + sseconds + '"' + sign;
+ var sdegrees = self.pad(degrees, width, ' ');
+ var sminutes = self.pad(minutes, 2, '0');
+ var sseconds = self.pad(seconds, 2, '0');
+ return sdegrees + '&deg;' + sminutes + "'" + sseconds + '"' + sign;
};
- self.setCoordinateFormat = function(type) {
+ self.setCoordinateFormat = function (type) {
if (!wv.util.browser.localStorage) return;
- if (type !== "latlon-dd" && type !== "latlon-dms") {
- throw new Error("Invalid coordinate format: " + type);
+ if (type !== 'latlon-dd' && type !== 'latlon-dms') {
+ throw new Error('Invalid coordinate format: ' + type);
}
localStorage.setItem('coordinateFormat', type);
};
- self.getCoordinateFormat = function() {
+ self.getCoordinateFormat = function () {
if (!wv.util.browser.localStorage) return 'latlon-dd';
- return localStorage.getItem("coordinateFormat") || "latlon-dd";
+ return localStorage.getItem('coordinateFormat') || 'latlon-dd';
};
- self.formatCoordinate = function(coord, format) {
+ self.formatCoordinate = function (coord, format) {
var type = format || self.getCoordinateFormat();
- if (type === "latlon-dms") {
- return self.formatDMS(coord[1], "latitude") + ", " +
- self.formatDMS(coord[0], "longitude");
+ if (type === 'latlon-dms') {
+ return self.formatDMS(coord[1], 'latitude') + ', ' +
+ self.formatDMS(coord[0], 'longitude');
} else {
- return coord[1].toFixed(4) + "&deg;, " +
- coord[0].toFixed(4) + "&deg;";
+ return coord[1].toFixed(4) + '&deg;, ' +
+ coord[0].toFixed(4) + '&deg;';
}
};
- //allows simple printf functionality with strings
- //arguments array contains all args passed. String must be formatted so that first replacement starts with "{1}"
- //usage example: wv.util.format("{1}{2}",'World','view')
- self.format = function() {
+ // allows simple printf functionality with strings
+ // arguments array contains all args passed. String must be formatted so that first replacement starts with "{1}"
+ // usage example: wv.util.format("{1}{2}",'World','view')
+ self.format = function () {
var formatted = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var regexp = new RegExp('\\{' + i + '\\}', 'gi');
@@ -777,7 +775,7 @@ wv.util = (function(self) {
}
return formatted;
};
- self.toArray = function(value) {
+ self.toArray = function (value) {
if (!value) {
return [];
}
@@ -788,5 +786,4 @@ wv.util = (function(self) {
};
return self;
-
})(wv.util || {});
diff --git a/web/js/util/wv.util.load.js b/web/js/util/wv.util.load.js
index 0bf5f11b8..e78f9bdad 100644
--- a/web/js/util/wv.util.load.js
+++ b/web/js/util/wv.util.load.js
@@ -1,15 +1,14 @@
var wv = wv || {};
wv.util = wv.util || {};
-wv.util.load = wv.util.load || (function() {
-
+wv.util.load = wv.util.load || (function () {
var self = {};
var configPromises = {};
var loading = 0;
var indicatorTimeout = null;
var indicatorId = null;
- self.config = function(root, attr, url) {
+ self.config = function (root, attr, url) {
var promise = $.Deferred();
// If a request is already outstanding, chain to that one
if (configPromises[url]) {
@@ -23,14 +22,14 @@ wv.util.load = wv.util.load || (function() {
loading += 1;
promise = $.getJSON(wv.brand.url(url));
if (loading === 1) {
- indicatorTimeout = setTimeout(function() {
+ indicatorTimeout = setTimeout(function () {
indicatorId = wv.ui.indicator.loading();
}, 2000);
}
- promise.done(function(result) {
+ promise.done(function (result) {
root[attr] = result;
})
- .always(function() {
+ .always(function () {
delete configPromises[url];
loading -= 1;
if (loading === 0) {
@@ -47,5 +46,4 @@ wv.util.load = wv.util.load || (function() {
};
return self;
-
})();
diff --git a/web/js/wv.brand.js b/web/js/wv.brand.js
index b0a02c2e4..f39fbe3a5 100644
--- a/web/js/wv.brand.js
+++ b/web/js/wv.brand.js
@@ -7,8 +7,7 @@ var wv = wv || {};
* @class wv.brand
* @static
*/
-wv.brand = wv.brand || (function() {
-
+wv.brand = wv.brand || (function () {
var self = {};
/**
@@ -18,7 +17,7 @@ wv.brand = wv.brand || (function() {
* @type String
* @static
*/
- self.NAME = "@LONG_NAME@";
+ self.NAME = '@LONG_NAME@';
/**
* Release version string. This value is filled in during the build
@@ -28,7 +27,7 @@ wv.brand = wv.brand || (function() {
* @type String
* @static
*/
- self.VERSION = "@BUILD_VERSION@";
+ self.VERSION = '@BUILD_VERSION@';
/**
* Date and time Worldview was built. This value is filled in during the
@@ -38,7 +37,7 @@ wv.brand = wv.brand || (function() {
* @type string
* @static
*/
- self.BUILD_TIMESTAMP = "@BUILD_TIMESTAMP@";
+ self.BUILD_TIMESTAMP = '@BUILD_TIMESTAMP@';
/**
* The value of the timestamp in numeric form that can be used as
@@ -49,7 +48,7 @@ wv.brand = wv.brand || (function() {
* @type String
* @static
*/
- self.BUILD_NONCE = "@BUILD_NONCE@";
+ self.BUILD_NONCE = '@BUILD_NONCE@';
/**
* Determines if this is a release build.
@@ -59,15 +58,14 @@ wv.brand = wv.brand || (function() {
* @return true if the build script has populated the VERSION field,
* otherwise returns false.
*/
- self.release = function() {
- return self.VERSION[0] !== "@";
+ self.release = function () {
+ return self.VERSION[0] !== '@';
};
- self.url = function(base) {
- var joiner = (_.indexOf(base, "?") < 0) ? "?" : "&";
- return base + joiner + "v=" + self.BUILD_NONCE;
+ self.url = function (base) {
+ var joiner = (_.indexOf(base, '?') < 0) ? '?' : '&';
+ return base + joiner + 'v=' + self.BUILD_NONCE;
};
return self;
-
})();
diff --git a/web/js/wv.debug.js b/web/js/wv.debug.js
index 20cce2db8..9e8228731 100644
--- a/web/js/wv.debug.js
+++ b/web/js/wv.debug.js
@@ -2,34 +2,33 @@
* @module wv.debug
*/
var wv = wv || {};
-wv.debug = wv.debug || (function() {
-
+wv.debug = wv.debug || (function () {
var parameters = wv.util.fromQueryString(location.search);
var self = {};
- var init = function() {
+ var init = function () {
if (parameters.loadDelay) {
var delay;
try {
delay = parseInt(parameters.loadDelay);
self.loadDelay(delay);
} catch (error) {
- console.warn("Invalid load delay: " + delay);
+ console.warn('Invalid load delay: ' + delay);
return;
}
}
if (parameters.showError) {
- $(function() {
+ $(function () {
wv.util.error();
});
}
};
- var delayedCallback = function(jqXHR, wrap, delay) {
- return function(fn) {
- wrap(function() {
+ var delayedCallback = function (jqXHR, wrap, delay) {
+ return function (fn) {
+ wrap(function () {
var args = arguments;
- setTimeout(function() {
+ setTimeout(function () {
if (fn) {
fn.apply(jqXHR, args);
}
@@ -39,23 +38,23 @@ wv.debug = wv.debug || (function() {
};
};
- self.loadDelay = function(delay) {
+ self.loadDelay = function (delay) {
var ajax = $.ajax;
- $.ajax = function() {
+ $.ajax = function () {
var ajaxArgs = arguments;
- console.log("delay", delay, ajaxArgs);
+ console.log('delay', delay, ajaxArgs);
var jqXHR = ajax.apply($, arguments);
var done = jqXHR.done;
jqXHR.done = delayedCallback(jqXHR, done, delay);
- jqXHR.done(function() {
- console.log("done", ajaxArgs);
+ jqXHR.done(function () {
+ console.log('done', ajaxArgs);
});
var fail = jqXHR.fail;
jqXHR.fail = delayedCallback(jqXHR, fail, delay);
- jqXHR.fail(function() {
- console.log("fail", ajaxArgs);
+ jqXHR.fail(function () {
+ console.log('fail', ajaxArgs);
});
var always = jqXHR.always;
@@ -67,71 +66,69 @@ wv.debug = wv.debug || (function() {
init();
return self;
-
})();
-wv.debug.config = wv.debug.config || function(config) {
- if (config.parameters.debug === "tiles") {
+wv.debug.config = wv.debug.config || function (config) {
+ if (config.parameters.debug === 'tiles') {
var tileSize = _.parseInt(config.parameters.tileSize);
if (_.isNaN(tileSize)) {
- throw new Error("No tileSize specified");
+ throw new Error('No tileSize specified');
}
- console.log("Debugging tiles with size", tileSize);
+ console.log('Debugging tiles with size', tileSize);
config.layers.debug_tile = {
- id: "debug_tile",
- title: "Debug Tiles",
- subtitle: "Worldview",
- tags: "debug",
- group: "overlays",
- format: "image/svg",
- type: "wmts",
- noTransition: "true",
+ id: 'debug_tile',
+ title: 'Debug Tiles',
+ subtitle: 'Worldview',
+ tags: 'debug',
+ group: 'overlays',
+ format: 'image/svg',
+ type: 'wmts',
+ noTransition: 'true',
projections: {}
};
- _.each(config.projections, function(proj) {
+ _.each(config.projections, function (proj) {
config.layers.debug_tile.projections[proj.id] = {
- "source": "debug_tile",
- "matrixSet": tileSize
+ 'source': 'debug_tile',
+ 'matrixSet': tileSize
};
});
config.sources.debug_tile = {
- url: "service/debug_tile.cgi",
+ url: 'service/debug_tile.cgi',
matrixSets: {}
};
config.sources.debug_tile.matrixSets[tileSize] = {
id: tileSize,
tileSize: [tileSize, tileSize]
};
- config.layerOrder.push("debug_tile");
+ config.layerOrder.push('debug_tile');
config.defaults.startingLayers.push({
- id: "debug_tile"
+ id: 'debug_tile'
});
}
};
-wv.debug.layers = wv.debug.layers || function(ui, models, config) {
-
+wv.debug.layers = wv.debug.layers || function (ui, models, config) {
var type;
var selectedLayer;
var useDebugPanel = {
- "gibs": true,
- "layers": true,
- "palettes": true,
- "dataDownload": true
+ 'gibs': true,
+ 'layers': true,
+ 'palettes': true,
+ 'dataDownload': true
};
- var init = function() {
+ var init = function () {
type = config.parameters.debug;
if (config.parameters.debugGIBS) {
- type = "gibs";
+ type = 'gibs';
}
- if (type === "gibs") {
+ if (type === 'gibs') {
ui.sidebar.collapse();
- //ui.dateSliders.collapse();
+ // ui.dateSliders.collapse();
}
if (useDebugPanel[type]) {
- if (type === "palettes") {
+ if (type === 'palettes') {
wv.palettes.loadCustom(config)
.done(render);
} else {
@@ -140,92 +137,92 @@ wv.debug.layers = wv.debug.layers || function(ui, models, config) {
}
};
- var render = function(type) {
+ var render = function (type) {
var $div = $(
"<div id='wv-debug-gibs'>" +
"<div class='wv-debug-gibs-layer'>" +
"<button class='wv-debug-gibs-previous-layer'>-</button>" +
"<button class='wv-debug-gibs-next-layer'>+</button>" +
"<select class='wv-debug-gibs-layerlist'></select>" +
- "</div>" +
+ '</div>' +
"<div class='wv-debug-gibs-date'>" +
"<button class='wv-debug-gibs-previous-date'>-</button>" +
"<button class='wv-debug-gibs-next-date'>+</button>" +
"<span class='wv-debug-gibs-date-label'>Date</span>" +
- "</div>" +
- "</div>");
- $("body")
+ '</div>' +
+ '</div>');
+ $('body')
.append($div);
initLayers();
- var $select = $(".wv-debug-gibs-layerlist");
- $select.on("change", updateLayers);
- models.date.events.on("select", updateDate);
- models.proj.events.on("select", initLayers);
+ var $select = $('.wv-debug-gibs-layerlist');
+ $select.on('change', updateLayers);
+ models.date.events.on('select', updateDate);
+ models.proj.events.on('select', initLayers);
- $(".wv-debug-gibs-next-layer")
+ $('.wv-debug-gibs-next-layer')
.click(nextLayer);
- $(".wv-debug-gibs-previous-layer")
+ $('.wv-debug-gibs-previous-layer')
.click(previousLayer);
- $(".wv-debug-gibs-next-date")
+ $('.wv-debug-gibs-next-date')
.click(nextDate);
- $(".wv-debug-gibs-previous-date")
+ $('.wv-debug-gibs-previous-date')
.click(previousDate);
updateDate();
};
- var acceptLayer = function(layer) {
+ var acceptLayer = function (layer) {
var proj = models.proj.selected.id;
if (!layer.projections[proj]) {
return false;
}
- if (layer.id === "Land_Water_Map" || layer.id === "Land_Mask") {
+ if (layer.id === 'Land_Water_Map' || layer.id === 'Land_Mask') {
return false;
}
- if (type === "gibs" && layer.period === "daily" && layer.type === "wmts") {
+ if (type === 'gibs' && layer.period === 'daily' && layer.type === 'wmts') {
return true;
}
- if (type === "palettes" && layer.palette && !layer.palette.immutable) {
+ if (type === 'palettes' && layer.palette && !layer.palette.immutable) {
return true;
}
- if (type === "dataDownload" && layer.product) {
+ if (type === 'dataDownload' && layer.product) {
return true;
}
- return type === "layers";
+ return type === 'layers';
};
- var initLayers = function() {
- var $select = $(".wv-debug-gibs-layerlist");
+ var initLayers = function () {
+ var $select = $('.wv-debug-gibs-layerlist');
$select.empty();
var proj = models.proj.selected.id;
- var sortedLayers = _.sortBy(config.layers, ["title", "subtitle"]);
- _.each(sortedLayers, function(layer) {
+ var sortedLayers = _.sortBy(config.layers, ['title', 'subtitle']);
+ _.each(sortedLayers, function (layer) {
if (acceptLayer(layer)) {
var names = models.layers.getTitles(layer.id);
- var text = names.title + "; " + names.subtitle;
+ var text = names.title + '; ' + names.subtitle;
if (text.length > 65) {
- text = text.substr(0, 65) + "...";
+ text = text.substr(0, 65) + '...';
}
console.log(layer.id);
- var $option = $("<option></option>")
+ var $option = $('<option></option>')
.val(encodeURIComponent(layer.id))
.html(text);
$select.append($option);
}
});
models.layers.clear();
- if (type !== "gibs" && config.layers.Land_Water_Map) {
- models.layers.add("Land_Water_Map");
+ if (type !== 'gibs' && config.layers.Land_Water_Map) {
+ models.layers.add('Land_Water_Map');
}
updateLayers.apply($select);
- if (type === "dataDownload") {
+ if (type === 'dataDownload') {
models.data.activate();
}
};
- var updateLayers = function() {
+ var updateLayers = function () {
if (!$(this)
.val()) {
return;
@@ -233,13 +230,13 @@ wv.debug.layers = wv.debug.layers || function(ui, models, config) {
var layerId = decodeURIComponent($(this)
.val());
var names = models.layers.getTitles(layerId);
- console.log(names.title + "; " + names.subtitle);
+ console.log(names.title + '; ' + names.subtitle);
if (selectedLayer) {
models.layers.remove(selectedLayer);
models.palettes.clearCustom(selectedLayer);
}
models.layers.add(layerId);
- if (type !== "gibs") {
+ if (type !== 'gibs') {
var range = models.layers.dateRange();
if (range && (config.parameters && !config.parameters.ignoreRange)) {
range.end.setUTCDate(range.end.getUTCDate() - 1);
@@ -247,51 +244,51 @@ wv.debug.layers = wv.debug.layers || function(ui, models, config) {
}
}
selectedLayer = layerId;
- if (type === "palettes") {
+ if (type === 'palettes') {
wv.palettes.loadRendered(config, layerId)
- .done(function() {
+ .done(function () {
var layer = config.layers[layerId];
var palette = config.palettes.rendered[layerId];
if (layer.palette.recommended) {
models.palettes.setCustom(layerId, layer.palette.recommended[0]);
} else {
if (palette.scale) {
- models.palettes.setCustom(layerId, "rainbow_2");
+ models.palettes.setCustom(layerId, 'rainbow_2');
} else {
- models.palettes.setCustom(layerId, "blue_light");
+ models.palettes.setCustom(layerId, 'blue_light');
}
}
});
}
};
- var nextLayer = function() {
- $(".wv-debug-gibs-layerlist option:selected")
+ var nextLayer = function () {
+ $('.wv-debug-gibs-layerlist option:selected')
.next()
- .attr("selected", "selected");
- updateLayers.apply($(".wv-debug-gibs-layerlist"));
+ .attr('selected', 'selected');
+ updateLayers.apply($('.wv-debug-gibs-layerlist'));
};
- var previousLayer = function() {
- $(".wv-debug-gibs-layerlist option:selected")
+ var previousLayer = function () {
+ $('.wv-debug-gibs-layerlist option:selected')
.prev()
- .attr("selected", "selected");
- updateLayers.apply($(".wv-debug-gibs-layerlist"));
+ .attr('selected', 'selected');
+ updateLayers.apply($('.wv-debug-gibs-layerlist'));
};
- var updateDate = function() {
- $(".wv-debug-gibs-date-label")
+ var updateDate = function () {
+ $('.wv-debug-gibs-date-label')
.html(
wv.util.toISOStringDate(models.date.selected));
};
- var nextDate = function() {
+ var nextDate = function () {
var d = new Date(models.date.selected.getTime());
d.setUTCDate(d.getUTCDate() + 1);
models.date.select(d);
};
- var previousDate = function() {
+ var previousDate = function () {
var d = new Date(models.date.selected.getTime());
d.setUTCDate(d.getUTCDate() - 1);
models.date.select(d);
diff --git a/web/js/wv.feedback.js b/web/js/wv.feedback.js
index 22a6ffe6f..b5bb6c1d4 100644
--- a/web/js/wv.feedback.js
+++ b/web/js/wv.feedback.js
@@ -1,14 +1,13 @@
var wv = wv || {};
-wv.feedback = wv.feedback || (function() {
-
+wv.feedback = wv.feedback || (function () {
var self = {};
var feedbackInit = false;
- self.decorate = function($element) {
- $element.attr("href",
- "mailto:@MAIL@?subject=Feedback for @LONG_NAME@ tool");
+ self.decorate = function ($element) {
+ $element.attr('href',
+ 'mailto:@MAIL@?subject=Feedback for @LONG_NAME@ tool');
- $element.click(function(event) {
+ $element.click(function (event) {
if (!wv.util.browser.small && window.feedback) {
event.preventDefault();
if (!feedbackInit) {
@@ -23,5 +22,4 @@ wv.feedback = wv.feedback || (function() {
};
return self;
-
})();
diff --git a/web/js/wv.main.js b/web/js/wv.main.js
index 432f05b93..455e035e3 100644
--- a/web/js/wv.main.js
+++ b/web/js/wv.main.js
@@ -1,22 +1,21 @@
var wvx = wvx || {};
// Document ready function
-$(function() {
-
+$(function () {
var config;
var state = wv.util.fromQueryString(location.search);
var parameters = wv.util.fromQueryString(location.search);
var errors = [];
var startTime;
- var main = function() {
+ var main = function () {
if (parameters.elapsed) {
startTime = new Date()
.getTime();
} else {
- elapsed = function() {};
+ elapsed = function () {};
}
- elapsed("start");
+ elapsed('start');
/* May be included in next version
yepnope({
test: parameters.debug,
@@ -27,9 +26,9 @@ $(function() {
loadConfig();
};
- var loadConfig = function() {
- elapsed("loading config");
- var configURI = wv.brand.url("config/wv.json");
+ var loadConfig = function () {
+ elapsed('loading config');
+ var configURI = wv.brand.url('config/wv.json');
var promise = $.getJSON(configURI);
promise
.done(wv.util.wrap(onConfigLoaded))
@@ -37,8 +36,8 @@ $(function() {
wv.ui.indicator.delayed(promise, 1000);
};
- var onConfigLoaded = function(data) {
- elapsed("config loaded");
+ var onConfigLoaded = function (data) {
+ elapsed('config loaded');
config = data;
config.parameters = parameters;
@@ -49,7 +48,7 @@ $(function() {
// Load any additional scripts as needed
if (config.scripts) {
- _.each(config.scripts, function(script) {
+ _.each(config.scripts, function (script) {
$.getScript(script);
});
}
@@ -69,7 +68,7 @@ $(function() {
if (config.features.animation) {
parsers.push(wv.anim.parse);
}
- _.each(parsers, function(parser) {
+ _.each(parsers, function (parser) {
parser(state, errors, config);
});
requirements = [
@@ -81,8 +80,8 @@ $(function() {
.fail(wv.util.error);
};
- var init = function() {
- elapsed("init");
+ var init = function () {
+ elapsed('init');
// If at the beginning of the day, wait on the previous day until GIBS
// catches up (about three hours)
var initialDate;
@@ -157,15 +156,14 @@ $(function() {
models.proj.change = wv.proj.change(models, config);
}
- elapsed("ui");
+ elapsed('ui');
// Create widgets
ui.proj = wv.proj.ui(models, config);
ui.sidebar = wv.layers.sidebar(models, config);
ui.activeLayers = wv.layers.active(models, ui, config);
ui.addModal = wv.layers.modal(models, ui, config);
-
- function timelineInit() {
+ function timelineInit () {
ui.timeline = wv.date.timeline(models, config, ui);
ui.timeline.data = wv.date.timeline.data(models, config, ui);
ui.timeline.zoom = wv.date.timeline.zoom(models, config, ui);
@@ -208,9 +206,9 @@ $(function() {
ui.alert = wv.notifications.ui(ui, config);
}
- //FIXME: Old hack
+ // FIXME: Old hack
$(window)
- .resize(function() {
+ .resize(function () {
if (wv.util.browser.small) {
$('#productsHoldertabs li.first a')
.trigger('click');
@@ -221,67 +219,67 @@ $(function() {
});
document.activeElement.blur();
- $("input")
+ $('input')
.blur();
- $("#eventsHolder")
+ $('#eventsHolder')
.hide();
if (config.features.dataDownload) {
models.data.events
- .on("activate", function() {
- ui.sidebar.selectTab("download");
+ .on('activate', function () {
+ ui.sidebar.selectTab('download');
})
- .on("queryResults", function() {
+ .on('queryResults', function () {
ui.data.onViewChange();
});
- ui.map.events.on("extent", function() {
+ ui.map.events.on('extent', function () {
ui.data.onViewChange();
});
// FIXME: This is a hack
- models.map.events.on("projection", models.data.updateProjection);
+ models.map.events.on('projection', models.data.updateProjection);
}
// Sink all focus on inputs if click unhandled
$(document)
- .click(function(event) {
- if (event.target.nodeName !== "INPUT") {
- $("input")
+ .click(function (event) {
+ if (event.target.nodeName !== 'INPUT') {
+ $('input')
.blur();
}
});
// Console notifications
if (wv.brand.release()) {
- console.info(wv.brand.NAME + " - Version " + wv.brand.VERSION +
- " - " + wv.brand.BUILD_TIMESTAMP);
+ console.info(wv.brand.NAME + ' - Version ' + wv.brand.VERSION +
+ ' - ' + wv.brand.BUILD_TIMESTAMP);
} else {
- console.warn("Development version");
+ console.warn('Development version');
}
wv.debug.layers(ui, models, config);
errorReport();
- //wv.debug.error(parameters);
+ // wv.debug.error(parameters);
- models.wv.events.trigger("startup");
- elapsed("done");
+ models.wv.events.trigger('startup');
+ elapsed('done');
// Reset Worldview when clicking on logo
- $(document).click(function(e) {
- if (e.target.id == "wv-logo") resetWorldview(e);
+ $(document).click(function (e) {
+ if (e.target.id == 'wv-logo') resetWorldview(e);
});
};
- var resetWorldview = function(e){
+ var resetWorldview = function (e) {
e.preventDefault();
- if (window.location.search === "") return; // Nothing to reset
- var msg = "Do you want to reset Worldview to its defaults? You will lose your current state.";
- if (confirm(msg)) document.location.href = "/";
+ if (window.location.search === '') return; // Nothing to reset
+ var msg = 'Do you want to reset Worldview to its defaults? You will lose your current state.';
+ if (confirm(msg)) document.location.href = '/';
};
- var errorReport = function() {
+ var errorReport = function () {
var layersRemoved = 0;
- _.each(errors, function(error) {
- var cause = (error.cause) ? ": " + error.cause : "";
+ _.each(errors, function (error) {
+ var cause = (error.cause) ? ': ' + error.cause : '';
wv.util.warn(error.message + cause);
if (error.layerRemoved) {
layersRemoved = layersRemoved + 1;
@@ -301,7 +299,7 @@ $(function() {
}
};
- var elapsed = function(message) {
+ var elapsed = function (message) {
if (!parameters.elapsed) return;
var t = new Date()
.getTime() - startTime;
@@ -330,5 +328,4 @@ $(function() {
*/
wv.util.wrap(main)();
-
});
diff --git a/web/js/wv.tour.js b/web/js/wv.tour.js
index bc3a3b0ec..7224bc231 100644
--- a/web/js/wv.tour.js
+++ b/web/js/wv.tour.js
@@ -1,21 +1,20 @@
var wv = wv || {};
-wv.tour = wv.tour || function(models, ui, config) {
-
+wv.tour = wv.tour || function (models, ui, config) {
var self = {};
var conclusionPanel = null;
var splashOverlay = null;
- var init = function() {
- $("#wv-tour")
- .click(function() {
+ var init = function () {
+ $('#wv-tour')
+ .click(function () {
self.start();
});
self.introduction();
};
- self.introduction = function() {
+ self.introduction = function () {
if (!config.features.tour) {
return;
}
@@ -36,7 +35,7 @@ wv.tour = wv.tour || function(models, ui, config) {
}
// Don't show tour if the user has opted out
- if (localStorage.getItem("hideSplash")) {
+ if (localStorage.getItem('hideSplash')) {
return;
}
@@ -51,21 +50,21 @@ wv.tour = wv.tour || function(models, ui, config) {
/**
* Create the splash screen and tour panels and control iteration over them.
*/
- self.start = function(introduction) {
+ self.start = function (introduction) {
if (wv.util.browser.ie && wv.util.browser.version <= 9) {
- wv.ui.unsupported("tour");
+ wv.ui.unsupported('tour');
return;
}
if (!validScreenSize()) {
- wv.ui.notify("Unfortunately the @NAME@ tour can only be viewed in larger web browser windows.");
+ wv.ui.notify('Unfortunately the @NAME@ tour can only be viewed in larger web browser windows.');
return;
}
- $content = $("#wv-tour-content");
+ $content = $('#wv-tour-content');
if ($content.children()
.length === 0) {
- $content.load("pages/tour.html", function() {
+ $content.load('pages/tour.html', function () {
onLoad(introduction);
});
} else {
@@ -73,68 +72,68 @@ wv.tour = wv.tour || function(models, ui, config) {
}
};
- var onLoad = function(introduction) {
+ var onLoad = function (introduction) {
var padding = 15; // padding - used for all of the tour windows
var pos, width, height, xval, yval; // helpful calculation vars
wv.ui.close();
- var $startDialog = $("#wv-tour-intro");
+ var $startDialog = $('#wv-tour-intro');
$startDialog
.dialog({
- title: "Welcome to @NAME@!",
- dialogClass: "tour",
+ title: 'Welcome to @NAME@!',
+ dialogClass: 'tour',
modal: true,
width: 700,
- height: "auto",
+ height: 'auto',
draggable: false,
resizable: false
});
if (introduction) {
- $("#wv-tour-skip")
+ $('#wv-tour-skip')
.show();
} else {
- $("#wv-tour-skip")
+ $('#wv-tour-skip')
.hide();
}
- var mapAnchor = document.getElementById("mapPanelTourAnchor");
+ var mapAnchor = document.getElementById('mapPanelTourAnchor');
if (!mapAnchor) {
- //console.log("creating mapanchor");
- var owner = document.getElementById("wv-map");
- mapAnchor = document.createElement("div");
- mapAnchor.setAttribute("id", "mapPanelTourAnchor");
- mapAnchor.setAttribute("style", "float:right; height:68px; right:14px; top:90px; width:36px; position:relative; z-index:-1");
+ // console.log("creating mapanchor");
+ var owner = document.getElementById('wv-map');
+ mapAnchor = document.createElement('div');
+ mapAnchor.setAttribute('id', 'mapPanelTourAnchor');
+ mapAnchor.setAttribute('style', 'float:right; height:68px; right:14px; top:90px; width:36px; position:relative; z-index:-1');
owner.appendChild(mapAnchor);
}
- var endTour = function() {
+ var endTour = function () {
wv.ui.close();
- $dialog = $("#wv-tour-end");
+ $dialog = $('#wv-tour-end');
$dialog
.dialog({
- title: "Finished!",
- dialogClass: "tour",
+ title: 'Finished!',
+ dialogClass: 'tour',
modal: true,
width: 600,
- height: "auto",
+ height: 'auto',
draggable: false,
resizable: false
});
- wv.feedback.decorate($dialog.find(".feedback"));
- $("#repeat")
+ wv.feedback.decorate($dialog.find('.feedback'));
+ $('#repeat')
.click(repeatTour);
- $("#done")
+ $('#done')
.click(handleDone);
};
/*
* Restart the tour at the beginning.
*/
- var repeatTour = function(e) {
+ var repeatTour = function (e) {
e.stopPropagation();
- $(".ui-dialog-content")
- .dialog("close");
+ $('.ui-dialog-content')
+ .dialog('close');
$('#joyRideTipContent')
.joyride({
adjustForPhone: false,
@@ -143,7 +142,7 @@ wv.tour = wv.tour || function(models, ui, config) {
template: {
'link': '<a href="#" class="joyride-close-tip">X</a>'
},
- postStepCallback: function(index, tip) {
+ postStepCallback: function (index, tip) {
if (index == 5) {
endTour();
}
@@ -154,25 +153,25 @@ wv.tour = wv.tour || function(models, ui, config) {
/*
* Hide the tour.
*/
- var handleDone = function(e) {
+ var handleDone = function (e) {
e.stopPropagation();
- $(".ui-dialog-content")
- .dialog("close");
+ $('.ui-dialog-content')
+ .dialog('close');
};
/*
* Close the splash and go straight to worldview.
*/
- var handleSkipTour = function() {
- $(".ui-dialog-content")
- .dialog("close");
+ var handleSkipTour = function () {
+ $('.ui-dialog-content')
+ .dialog('close');
};
- var onStop = function(index, tip, button) {
- //console.log(index, tip, button);
+ var onStop = function (index, tip, button) {
+ // console.log(index, tip, button);
setTourState();
WVC.GA.event('Tour', 'Click', 'Post Tour View', index + 1);
- if (index == 5 && button !== "previous") {
+ if (index == 5 && button !== 'previous') {
endTour();
}
};
@@ -180,10 +179,10 @@ wv.tour = wv.tour || function(models, ui, config) {
/*
* Close the splash and start the tour.
*/
- var handleTakeTour = function(e) {
+ var handleTakeTour = function (e) {
e.stopPropagation();
- $(".ui-dialog-content")
- .dialog("close");
+ $('.ui-dialog-content')
+ .dialog('close');
initTourState();
WVC.GA.event('Tour', 'Click', 'Take Tour');
$('#joyRideTipContent')
@@ -201,23 +200,22 @@ wv.tour = wv.tour || function(models, ui, config) {
/*
* Toggle the value of the "hideSplash" flag.
*/
- var setDoNotShow = function() {
+ var setDoNotShow = function () {
if (!wv.util.browser.localStorage) return;
var hideSplash = localStorage.getItem('hideSplash');
localStorage.setItem('hideSplash', !hideSplash);
};
// assign events and start
- $("#takeTour")
+ $('#takeTour')
.click(handleTakeTour);
- $("#skipTour")
+ $('#skipTour')
.click(handleSkipTour);
- $("#dontShowAgain")
+ $('#dontShowAgain')
.click(setDoNotShow);
-
};
- var initTourState = function() {
+ var initTourState = function () {
var map = ui.map.selected;
models.proj.selectDefault();
models.date.select(wv.util.today());
@@ -228,14 +226,14 @@ wv.tour = wv.tour || function(models, ui, config) {
setTourState();
};
- var setTourState = function() {
+ var setTourState = function () {
ui.sidebar.expandNow();
- ui.sidebar.selectTab("active");
+ ui.sidebar.selectTab('active');
ui.timeline.expandNow();
models.proj.selectDefault();
};
- var validScreenSize = function() {
+ var validScreenSize = function () {
var viewWidth = $(window)
.width();
var viewHeight = $(window)