-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Minor tweaks to new altitude slider
* File formatting * Added cursor and title text hover
- Loading branch information
Showing
3 changed files
with
55 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,67 @@ | ||
"use strict"; | ||
var AltitudeSlider = function AltitudeSlider() { | ||
this.initialValue = 260; | ||
this.handle = null; | ||
this.altitudeLayer = null; | ||
//on document load | ||
var that = this; | ||
$(function() { | ||
that.sliderObject = $( "#altitude-slider" ); | ||
that.altitudeDisplay = $("#altitude-slider > div"); | ||
var updateSliderValue = function (event, logVal) { | ||
that.handle = that.handle || $(".ui-slider-handle", that.sliderObject); | ||
that.altitudeDisplay.text((parseInt(logVal) || that.initialValue) + "m") | ||
.css(that.handle.position()); | ||
}; | ||
this.initialValue = 260; | ||
this.handle = null; | ||
this.altitudeLayer = null; | ||
|
||
//on document load | ||
var that = this; | ||
$(function() { | ||
that.sliderObject = $("#altitude-slider"); | ||
that.altitudeDisplay = $("#altitude-slider > div"); | ||
|
||
var updateSliderValue = function(event, logVal) { | ||
that.handle = that.handle || $(".ui-slider-handle", that.sliderObject); | ||
that.altitudeDisplay.text((parseInt(logVal) || that.initialValue) + "m") | ||
.css(that.handle.position()); | ||
}; | ||
|
||
that.sliderObject.slider({ | ||
orientation: "vertical", | ||
value: that.initialValue, | ||
min: 33, | ||
max: 114, | ||
step: 1, | ||
animate: "fast", | ||
create: updateSliderValue, | ||
slide: function( event, ui ) { | ||
var dataLayer = activeEarthTimeLayers[activeEarthTimeLayers.length-1]; //TODO: debug this line with use of this.altitudeLayer | ||
var logVal = Math.round(Math.pow(1.05,ui.value)); | ||
csvFileLayers.updateLayerData(dataLayer, {options: {"maxElevation" : logVal}}, false, false) | ||
updateSliderValue(event,logVal); | ||
} | ||
}); | ||
}); | ||
that.sliderObject.slider({ | ||
orientation: "vertical", | ||
value: that.initialValue, | ||
min: 33, | ||
max: 114, | ||
step: 1, | ||
animate: "fast", | ||
create: updateSliderValue, | ||
slide: function(event, ui) { | ||
var dataLayer = activeEarthTimeLayers[activeEarthTimeLayers.length - 1]; //TODO: debug this line with use of this.altitudeLayer | ||
var logVal = Math.round(Math.pow(1.05, ui.value)); | ||
csvFileLayers.updateLayerData(dataLayer, { | ||
options: { | ||
"maxElevation": logVal | ||
} | ||
}, false, false) | ||
updateSliderValue(event, logVal); | ||
} | ||
}).attr("title", "Drag to change the max elevation being drawn"); | ||
}); | ||
}; | ||
|
||
// Update altitude layer stored in AltitudeSlider object | ||
AltitudeSlider.prototype.checkAltitudeLayer = function checkAltitudeLayer(layerList){ | ||
AltitudeSlider.prototype.checkAltitudeLayer = function checkAltitudeLayer(layerList) { | ||
layerList = layerList || activeEarthTimeLayers; | ||
this.altitudeLayer = null; | ||
for (var i=0; i< layerList.length; i++){ | ||
for (var i = 0; i < layerList.length; i++) { | ||
var layer = getLayer(layerList[i]); | ||
if(layer && layer.setDataOptions && layer.setDataOptions.hasAltitude){ | ||
if (layer && layer.setDataOptions && layer.setDataOptions.hasAltitude) { | ||
this.altitudeLayer = layer; | ||
break; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
// Handle slider from page load or new layer added/removed (from data library) | ||
AltitudeSlider.prototype.handleAltitudeLayers = function handleAltitudeLayers(fromShareLink,layers){ | ||
AltitudeSlider.prototype.handleAltitudeLayers = function handleAltitudeLayers(fromShareLink, layers) { | ||
this.checkAltitudeLayer(); //uses activeEarthTimeLayers if layers undefined | ||
updateAltitudeSlider(this); // hide/show calendar | ||
|
||
|
||
function updateAltitudeSlider(that){ | ||
if (that.altitudeLayer == null){ //hide button if no altitude layers | ||
function updateAltitudeSlider(that) { | ||
if (that.altitudeLayer == null) { //hide button if no altitude layers | ||
$("#altitude-slider").hide(); | ||
} | ||
else{ | ||
} else { | ||
$("#altitude-slider").show(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters