catch SecurityError with localStorage, fixes #47
This commit is contained in:
parent
b108efae5c
commit
514cc705ef
3 changed files with 26 additions and 4 deletions
|
|
@ -7,7 +7,7 @@ BR.OpacitySlider = L.Control.extend({
|
|||
onAdd: function (map) {
|
||||
var container = L.DomUtil.create('div', 'leaflet-bar control-slider'),
|
||||
input = $('<input id="slider" type="text"/>'),
|
||||
item = localStorage.opacitySliderValue,
|
||||
item = BR.Util.localStorageAvailable() ? localStorage.opacitySliderValue : null,
|
||||
value = item ? parseInt(item) : BR.conf.defaultOpacity * 100,
|
||||
minOpacity = (BR.conf.minOpacity || 0) * 100;
|
||||
|
||||
|
|
@ -39,7 +39,9 @@ BR.OpacitySlider = L.Control.extend({
|
|||
}).on('slide slideStop', { self: this }, function (evt) {
|
||||
evt.data.self.options.callback(evt.value / 100);
|
||||
}).on('slideStop', function (evt) {
|
||||
localStorage.opacitySliderValue = evt.value;
|
||||
if (BR.Util.localStorageAvailable()) {
|
||||
localStorage.opacitySliderValue = evt.value;
|
||||
}
|
||||
|
||||
// When dragging outside slider and over map, click event after mouseup
|
||||
// adds marker when active on Chromium. So disable click (not needed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue