mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 09:10:17 +01:00
Replaced checkbox with toggle button to start automatic updates.
This commit is contained in:
parent
f708a7c44b
commit
7413221341
@ -95,8 +95,8 @@ L.control.coordinates({
|
|||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
var manualUpdateControl;
|
var manualUpdateControl;
|
||||||
L.autoUpdate('autoUpdate', function(e) {
|
L.autoUpdate('autoUpdate', function(pressed) {
|
||||||
if (e.target.checked) {
|
if (pressed) {
|
||||||
manualUpdateControl.getContainer().style = 'visibility: hidden';
|
manualUpdateControl.getContainer().style = 'visibility: hidden';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3,23 +3,31 @@ L.Control.AutoUpdate = L.Control.extend({
|
|||||||
position: 'topleft',
|
position: 'topleft',
|
||||||
label: 'Automatic update'
|
label: 'Automatic update'
|
||||||
},
|
},
|
||||||
|
pressed: true,
|
||||||
|
|
||||||
onAdd: function() {
|
onAdd: function() {
|
||||||
var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control');
|
var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control');
|
||||||
container.innerHTML = '<form><input id="autoUpdateCb" type="checkbox"/>'
|
this.link = L.DomUtil.create('a', 'leaflet-bar-part', container);
|
||||||
+ this.options.label + '</form>';
|
this.iconStart = L.DomUtil.create('i', 'fa fa-play', this.link);
|
||||||
L.DomEvent.on(container, 'click', this.cbClick, this);
|
this.link.href = '#';
|
||||||
|
L.DomEvent.on(this.link, 'click', this.cbClick, this);
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
|
|
||||||
cbClick: function (e) {
|
cbClick: function (e) {
|
||||||
L.DomEvent.stopPropagation(e);
|
L.DomEvent.stopPropagation(e);
|
||||||
this.intendedFunction(e);
|
this.intendedFunction(this.pressed);
|
||||||
if (e.target.checked) {
|
if (this.pressed) {
|
||||||
|
this.pressed = false;
|
||||||
|
this.iconStart.setAttribute('class', 'fa fa-pause');
|
||||||
this.autoUpdate();
|
this.autoUpdate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!e.target.checked) {
|
if (!this.pressed) {
|
||||||
|
this.pressed = true;
|
||||||
|
this.iconStart.setAttribute('class', 'fa fa-play');
|
||||||
this.stopUpdate();
|
this.stopUpdate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user