mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-20 14:34:38 +00:00
Merge pull request #5087 from Leaflet/layers-collapse-alt
Always create L.Control.Layers as collapsed; expand if collapse option not set
This commit is contained in:
@ -128,4 +128,16 @@ describe("Control.Layers", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("is created with an expand link", function () {
|
||||||
|
it("when collapsed", function () {
|
||||||
|
var layersCtrl = L.control.layers(null, null, {collapsed: true}).addTo(map);
|
||||||
|
expect(map._container.querySelector('.leaflet-control-layers-toggle')).to.be.ok();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("when not collapsed", function () {
|
||||||
|
var layersCtrl = L.control.layers(null, null, {collapsed: false}).addTo(map);
|
||||||
|
expect(map._container.querySelector('.leaflet-control-layers-toggle')).to.be.ok();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -153,34 +153,34 @@ L.Control.Layers = L.Control.extend({
|
|||||||
|
|
||||||
var form = this._form = L.DomUtil.create('form', className + '-list');
|
var form = this._form = L.DomUtil.create('form', className + '-list');
|
||||||
|
|
||||||
if (this.options.collapsed) {
|
if (!L.Browser.android) {
|
||||||
if (!L.Browser.android) {
|
L.DomEvent.on(container, {
|
||||||
L.DomEvent.on(container, {
|
mouseenter: this.expand,
|
||||||
mouseenter: this.expand,
|
mouseleave: this.collapse
|
||||||
mouseleave: this.collapse
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
|
|
||||||
link.href = '#';
|
|
||||||
link.title = 'Layers';
|
|
||||||
|
|
||||||
if (L.Browser.touch) {
|
|
||||||
L.DomEvent
|
|
||||||
.on(link, 'click', L.DomEvent.stop)
|
|
||||||
.on(link, 'click', this.expand, this);
|
|
||||||
} else {
|
|
||||||
L.DomEvent.on(link, 'focus', this.expand, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// work around for Firefox Android issue https://github.com/Leaflet/Leaflet/issues/2033
|
|
||||||
L.DomEvent.on(form, 'click', function () {
|
|
||||||
setTimeout(L.bind(this._onInputClick, this), 0);
|
|
||||||
}, this);
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
this._map.on('click', this.collapse, this);
|
var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
|
||||||
// TODO keyboard accessibility
|
link.href = '#';
|
||||||
|
link.title = 'Layers';
|
||||||
|
|
||||||
|
if (L.Browser.touch) {
|
||||||
|
L.DomEvent
|
||||||
|
.on(link, 'click', L.DomEvent.stop)
|
||||||
|
.on(link, 'click', this.expand, this);
|
||||||
} else {
|
} else {
|
||||||
|
L.DomEvent.on(link, 'focus', this.expand, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// work around for Firefox Android issue https://github.com/Leaflet/Leaflet/issues/2033
|
||||||
|
L.DomEvent.on(form, 'click', function () {
|
||||||
|
setTimeout(L.bind(this._onInputClick, this), 0);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this._map.on('click', this.collapse, this);
|
||||||
|
// TODO keyboard accessibility
|
||||||
|
|
||||||
|
if (!this.options.collapsed) {
|
||||||
this.expand();
|
this.expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user