nc-gpxedit/js/leaflet-sidebar.min.js

1 line
2.2 KiB
JavaScript
Raw Normal View History

2016-11-30 19:00:03 +00:00
L.Control.Sidebar=L.Control.extend({includes:L.Mixin.Events,initialize:function(t,s){var i,a;for(L.setOptions(this,s),this._sidebar=L.DomUtil.get(t),L.Browser.touch&&L.DomUtil.addClass(this._sidebar,"leaflet-touch"),i=this._sidebar.children.length-1;i>=0;i--)a=this._sidebar.children[i],"UL"==a.tagName&&L.DomUtil.hasClass(a,"sidebar-tabs")?this._tabs=a:"DIV"==a.tagName&&L.DomUtil.hasClass(a,"sidebar-content")&&(this._container=a);for(this._tabitems=[],i=this._tabs.children.length-1;i>=0;i--)a=this._tabs.children[i],"LI"==a.tagName&&(this._tabitems.push(a),a._sidebar=this);for(this._panes=[],i=this._container.children.length-1;i>=0;i--)a=this._container.children[i],"DIV"==a.tagName&&L.DomUtil.hasClass(a,"sidebar-pane")&&this._panes.push(a);this._hasTouchStart=L.Browser.touch&&"ontouchstart"in document.documentElement},addTo:function(t){this._map=t;for(var s=this._hasTouchStart?"touchstart":"click",i=this._tabitems.length-1;i>=0;i--){var a=this._tabitems[i];L.DomEvent.on(a.firstChild,s,this._onClick,a)}return this},removeFrom:function(){this._map=null;for(var t=this._hasTouchStart?"touchstart":"click",s=this._tabitems.length-1;s>=0;s--){var i=this._tabitems[s];L.DomEvent.off(i.firstChild,t,this._onClick)}return this},open:function(t){var s,i;for(s=this._panes.length-1;s>=0;s--)i=this._panes[s],i.id==t?L.DomUtil.addClass(i,"active"):L.DomUtil.hasClass(i,"active")&&L.DomUtil.removeClass(i,"active");for(s=this._tabitems.length-1;s>=0;s--)i=this._tabitems[s],i.firstChild.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._sidebar,"collapsed")&&(this.fire("opening"),L.DomUtil.removeClass(this._sidebar,"collapsed")),this},close:function(){for(var t=this._tabitems.length-1;t>=0;t--){var s=this._tabitems[t];L.DomUtil.hasClass(s,"active")&&L.DomUtil.removeClass(s,"active")}return L.DomUtil.hasClass(this._sidebar,"collapsed")||(this.fire("closing"),L.DomUtil.addClass(this._sidebar,"collapsed")),this},_onClick:function(){L.DomUtil.hasClass(this,"active")?this._sidebar.close():this._sidebar.open(this.firstChild.hash.slice(1))}}),L.control.sidebar=function(t,s){return new L.Control.Sidebar(t,s)};