Merge pull request #1669 from jfirebaugh/closeOnClick
Popup-specific closeOnClick option
This commit is contained in:
commit
3d3e2cd12d
@ -1,15 +1,51 @@
|
|||||||
describe('Popup', function() {
|
describe('Popup', function() {
|
||||||
|
|
||||||
var map;
|
var c, map;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var c = document.createElement('div');
|
c = document.createElement('div');
|
||||||
c.style.width = '400px';
|
c.style.width = '400px';
|
||||||
c.style.height = '400px';
|
c.style.height = '400px';
|
||||||
map = new L.Map(c);
|
map = new L.Map(c);
|
||||||
map.setView(new L.LatLng(55.8, 37.6), 6);
|
map.setView(new L.LatLng(55.8, 37.6), 6);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("closes on map click when map has closePopupOnClick option", function() {
|
||||||
|
map.options.closePopupOnClick = true;
|
||||||
|
|
||||||
|
var popup = new L.Popup()
|
||||||
|
.setLatLng(new L.LatLng(55.8, 37.6))
|
||||||
|
.openOn(map);
|
||||||
|
|
||||||
|
happen.click(c);
|
||||||
|
|
||||||
|
expect(map.hasLayer(popup)).to.be(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("closes on map click when popup has closeOnClick option", function() {
|
||||||
|
map.options.closePopupOnClick = false;
|
||||||
|
|
||||||
|
var popup = new L.Popup({closeOnClick: true})
|
||||||
|
.setLatLng(new L.LatLng(55.8, 37.6))
|
||||||
|
.openOn(map);
|
||||||
|
|
||||||
|
happen.click(c);
|
||||||
|
|
||||||
|
expect(map.hasLayer(popup)).to.be(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not close on map click when popup has closeOnClick: false option", function() {
|
||||||
|
map.options.closePopupOnClick = true;
|
||||||
|
|
||||||
|
var popup = new L.Popup({closeOnClick: false})
|
||||||
|
.setLatLng(new L.LatLng(55.8, 37.6))
|
||||||
|
.openOn(map);
|
||||||
|
|
||||||
|
happen.click(c);
|
||||||
|
|
||||||
|
expect(map.hasLayer(popup)).to.be(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("should trigger popupopen on marker when popup opens", function() {
|
it("should trigger popupopen on marker when popup opens", function() {
|
||||||
var marker1 = new L.Marker(new L.LatLng(55.8, 37.6));
|
var marker1 = new L.Marker(new L.LatLng(55.8, 37.6));
|
||||||
var marker2 = new L.Marker(new L.LatLng(57.123076977278, 44.861962891635));
|
var marker2 = new L.Marker(new L.LatLng(57.123076977278, 44.861962891635));
|
||||||
|
@ -113,7 +113,7 @@ L.Popup = L.Class.extend({
|
|||||||
if (this._animated) {
|
if (this._animated) {
|
||||||
events.zoomanim = this._zoomAnimation;
|
events.zoomanim = this._zoomAnimation;
|
||||||
}
|
}
|
||||||
if (this._map.options.closePopupOnClick) {
|
if ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) {
|
||||||
events.preclick = this._close;
|
events.preclick = this._close;
|
||||||
}
|
}
|
||||||
if (this.options.keepInView) {
|
if (this.options.keepInView) {
|
||||||
|
Loading…
Reference in New Issue
Block a user