tupali/librerias/leaflet/js/leaflet-sidebar.min.js

1 line
6.8 KiB
JavaScript
Raw Normal View History

2019-07-29 15:18:21 +00:00
L.Control.Sidebar=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:{autopan:!1,closeButton:!0,container:null,position:"left"},initialize:function(t,e){return"string"==typeof t&&(console.warn("this syntax is deprecated. please use L.control.sidebar({ container }) now"),t={container:t}),"object"==typeof t&&t.id&&(console.warn("this syntax is deprecated. please use L.control.sidebar({ container }) now"),t.container=t.id),this._tabitems=[],this._panes=[],this._closeButtons=[],L.setOptions(this,Object.assign({},t,e)),this},onAdd:function(t){var e,i,s,n,o;for((o=this._container)||(o=this._container||"string"==typeof this.options.container?L.DomUtil.get(this.options.container):this.options.container),o||(o=L.DomUtil.create("div","leaflet-sidebar collapsed"),"string"==typeof this.options.container&&(o.id=this.options.container)),this._paneContainer=o.querySelector("div.leaflet-sidebar-content"),null===this._paneContainer&&(this._paneContainer=L.DomUtil.create("div","leaflet-sidebar-content",o)),s=o.querySelectorAll("ul.leaflet-sidebar-tabs, div.leaflet-sidebar-tabs > ul"),this._tabContainerTop=s[0]||null,this._tabContainerBottom=s[1]||null,null===this._tabContainerTop&&((n=L.DomUtil.create("div","leaflet-sidebar-tabs",o)).setAttribute("role","tablist"),this._tabContainerTop=L.DomUtil.create("ul","",n)),null===this._tabContainerBottom&&(n=this._tabContainerTop.parentNode,this._tabContainerBottom=L.DomUtil.create("ul","",n)),e=0;e<this._tabContainerTop.children.length;e++)(i=this._tabContainerTop.children[e])._sidebar=this,i._id=i.querySelector("a").hash.slice(1),this._tabitems.push(i);for(e=0;e<this._tabContainerBottom.children.length;e++)(i=this._tabContainerBottom.children[e])._sidebar=this,i._id=i.querySelector("a").hash.slice(1),this._tabitems.push(i);for(e=0;e<this._paneContainer.children.length;e++)if("DIV"===(i=this._paneContainer.children[e]).tagName&&L.DomUtil.hasClass(i,"leaflet-sidebar-pane")){this._panes.push(i);var a=i.querySelectorAll(".leaflet-sidebar-close");a.length&&(this._closeButtons.push(a[a.length-1]),this._closeClick(a[a.length-1],"on"))}for(e=0;e<this._tabitems.length;e++)this._tabClick(this._tabitems[e],"on");return o},onRemove:function(t){var e;for(this._map=null,this._tabitems=[],this._panes=[],this._closeButtons=[],e=0;e<this._tabitems.length;e++)this._tabClick(this._tabitems[e],"off");for(e=0;e<this._closeButtons.length;e++)this._closeClick(this._closeButtons[e],"off");return this},addTo:function(t){return this.onRemove(),this._map=t,this._container=this.onAdd(t),L.DomUtil.addClass(this._container,"leaflet-control"),L.DomUtil.addClass(this._container,"leaflet-sidebar-"+this.getPosition()),L.Browser.touch&&L.DomUtil.addClass(this._container,"leaflet-touch"),L.DomEvent.disableScrollPropagation(this._container),L.DomEvent.disableClickPropagation(this._container),L.DomEvent.on(this._container,"contextmenu",L.DomEvent.stopPropagation),t._container.insertBefore(this._container,t._container.firstChild),this},removeFrom:function(t){return console.warn("removeFrom() has been deprecated, please use remove() instead as support for this function will be ending soon."),this._map._container.removeChild(this._container),this.onRemove(t),this},open:function(t){var e,i,s;if(s=this._getTab(t),L.DomUtil.hasClass(s,"disabled"))return this;for(e=0;e<this._panes.length;e++)(i=this._panes[e]).id===t?L.DomUtil.addClass(i,"active"):L.DomUtil.hasClass(i,"active")&&L.DomUtil.removeClass(i,"active");for(e=0;e<this._tabitems.length;e++)(i=this._tabitems[e]).querySelector("a").hash==="#"+t?L.DomUtil.addClass(i,"active"):L.DomUtil.hasClass(i,"active")&&L.DomUtil.removeClass(i,"active");return this.fire("content",{id:t}),L.DomUtil.hasClass(this._container,"collapsed")&&(this.fire("opening"),L.DomUtil.removeClass(this._container,"collapsed"),this.options.autopan&&this._panMap("open")),this},close:function(){var t;for(t=0;t<this._tabitems.length;t++){var e=this._tabitems[t];L.DomUtil.hasClass(e,"active")&&L.DomUtil.removeClass(e,"active")}return L.DomUtil.hasClass(this._container,"collapsed")||(this.fir