From 8bcf79454b9d63f42e9bdb6318399e2f9138dfca Mon Sep 17 00:00:00 2001 From: heinrichmartin Date: Fri, 6 Apr 2018 14:14:49 +0200 Subject: [PATCH] Provide toggle() toggle() changes the open/closed state of the dialog. The implementation assigns the actual functions open and close to the internal function "pointer" _toggle. --- Leaflet.Dialog.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Leaflet.Dialog.js b/Leaflet.Dialog.js index dad4b2a..ac12e7c 100644 --- a/Leaflet.Dialog.js +++ b/Leaflet.Dialog.js @@ -34,6 +34,7 @@ L.Control.Dialog = L.Control.extend({ return; } this._container.style.visibility = ''; + this._toogle = this.close; this._map.fire('dialog:opened', this); @@ -42,11 +43,21 @@ L.Control.Dialog = L.Control.extend({ close: function(){ this._container.style.visibility = 'hidden'; + this._toogle = this.open; this._map.fire('dialog:closed', this); return this; }, + toggle: function(){ + return this._toggle(); + }, + + _toggle: function(){ + // update, open, and close change _toggle as needed + return this; + }, + destroy: function(){ if(!this._map){ return this; } @@ -171,6 +182,7 @@ L.Control.Dialog = L.Control.extend({ this._updateLayout(); this._container.style.visibility = ''; + this._toggle = this.close; this._map.fire('dialog:updated', this); },