Skip to content

Commit 022fbe2

Browse files
committed
Toggle UI controls
1 parent 3fd8a59 commit 022fbe2

File tree

5 files changed

+66
-33
lines changed

5 files changed

+66
-33
lines changed

django_large_image/static/django_large_image/styles/style.css

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
margin: 0;
2020
opacity: 0.75;
2121
z-index: 15;
22-
bottom: 5px;
22+
bottom: 25px;
2323
right: 5px;
2424
}
25+
26+
.collapsible {
27+
background-color: #DCDCDC;
28+
cursor: pointer;
29+
padding: 2px;
30+
border: none;
31+
text-align: left;
32+
outline: none;
33+
}
34+
35+
/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
36+
.collapsible:hover {
37+
background-color: #D3D3D3;
38+
}

django_large_image/templates/django_large_image/_include/base.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,25 @@
4545
for (const [option, value] of Object.entries(windowSearchParams)) {
4646
updateTileUrlOption(option, value);
4747
}
48+
49+
function addToggleListener(uiToggle, uiContent, callback = null) {
50+
uiToggle.addEventListener('click', function() {
51+
this.classList.toggle('active');
52+
var state = null;
53+
if (uiContent.style.display === 'block') {
54+
uiContent.style.display = 'none';
55+
state = false;
56+
} else {
57+
uiContent.style.display = 'block';
58+
state = true;
59+
}
60+
// Call the custom callback if given
61+
if (callback != null) {
62+
callback(state);
63+
}
64+
});
65+
// Hide by default
66+
uiContent.style.display = 'none';
67+
}
4868
</script>
4969
{% endblock %}

django_large_image/templates/django_large_image/_include/cesium.html

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@
2121
<!-- Load the script to initialize the viewer -->
2222
<script src="{% static 'django_large_image/js/cesium.js' %}"></script>
2323

24-
25-
<div class="slidecontainer" id="opacityTool">
26-
<label for="rasterOpacityRange">Raster Layer Opacity: </label>
27-
<input type="range" min="1" max="100" value="100" class="overlay" id="rasterOpacityRange" onChange="updateTilesOpacity(event, value)" onInput="updateTilesOpacity(event, value)" style="top: 5px; left: 5px;">
28-
<br />
29-
{% include 'django_large_image/_include/colors.html' %}
30-
</div>
31-
24+
{% include 'django_large_image/_include/colors.html' %}
3225

3326
<script>
3427
var tileProvider;

django_large_image/templates/django_large_image/_include/colors.html

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
11
{% block colormaps %}
22

3-
<label for="bandChoice">Choose a band:</label>
4-
<select id="bandChoice" onChange='bandChange();'>
5-
<option>-- none --</option>
6-
</select>
7-
<br />
8-
<div id='colorsSubGroup' style="display: none;">
9-
<label for="colors">Choose a colormap:</label>
10-
<select id="colors" onChange='changeColors();'>
11-
<option>-- none --</option>
12-
</select>
13-
<br />
14-
<input id="mincolor" type="number" step="0.01" onChange='changeColors();'>
15-
<input id="maxcolor" type="number" step="0.01" onChange='changeColors();'>
16-
</div>
17-
<div>
18-
<img id="thumbnail" />
3+
<div class="slidecontainer">
4+
<button type="button" class="collapsible" id="displayControlsToggle">Toggle Controls</button>
5+
<div id="displayControls">
6+
<label for="rasterOpacityRange">Raster Layer Opacity: </label>
7+
<input type="range" min="1" max="100" value="100" class="overlay" id="rasterOpacityRange" onChange="updateTilesOpacity(event, value)" onInput="updateTilesOpacity(event, value)" style="top: 5px; left: 5px;">
8+
<br />
9+
<label for="bandChoice">Choose a band:</label>
10+
<select id="bandChoice" onChange='bandChange();'>
11+
<option>-- none --</option>
12+
</select>
13+
<br />
14+
<div id='colorsSubGroup' style="display: none;">
15+
<label for="colors">Choose a colormap:</label>
16+
<select id="colors" onChange='changeColors();'>
17+
<option>-- none --</option>
18+
</select>
19+
<br />
20+
<input id="mincolor" type="number" step="0.01" onChange='changeColors();'>
21+
<input id="maxcolor" type="number" step="0.01" onChange='changeColors();'>
22+
</div>
23+
<div>
24+
<img id="thumbnail" />
25+
</div>
26+
</div>
1927
</div>
2028
<script>
29+
const displayControlsToggle = document.getElementById('displayControlsToggle');
30+
const displayControls = document.getElementById('displayControls');
31+
addToggleListener(displayControlsToggle, displayControls);
32+
2133
var colorsSubGroup = document.getElementById('colorsSubGroup');
2234
var colorsDropdown = document.getElementById('colors');
2335
var bandDropdown = document.getElementById('bandChoice');
@@ -52,7 +64,6 @@
5264
});
5365
})
5466

55-
5667
fetch(`${host}/api/large-image/colormaps`)
5768
.then(response => response.json())
5869
.then(data => {

django_large_image/templates/django_large_image/_include/geojs.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55

66
<div id="imageViewer" style="width: 100%; height: 100%; z-index: 10;"></div>
77

8-
<div class="slidecontainer" id="opacityTool">
9-
<label for="rasterOpacityRange">Raster Layer Opacity: </label>
10-
<input type="range" min="1" max="100" value="100" class="overlay" id="rasterOpacityRange" onChange="updateTilesOpacity(event, value)" onInput="updateTilesOpacity(event, value)" style="top: 5px; left: 5px;">
11-
<br />
12-
{% include 'django_large_image/_include/colors.html' %}
13-
</div>
8+
{% include 'django_large_image/_include/colors.html' %}
149

1510
<script>
16-
var containerRef = document.getElementById('imageViewer')
11+
const containerRef = document.getElementById('imageViewer')
1712
var imageLayer;
1813
var viewer;
1914

0 commit comments

Comments
 (0)