PageSourceSearch

https://framacarte.org/static/umap/vendors/iconlayers/iconLayers.73b220e72069.js

js framacarte.org collected 2026-10-02 05:11:30 UTC 6,925 bytes, 22 lines download raw bytes

vendor: 6,925 bytes, lines 1-22
1(function(factory){if(typeof module!=='undefined'&&module.exports){module.exports=factory(require('leaflet'));}else{window.L.control.iconLayers=factory(window.L);window.L.Control.IconLayers=window.L.control.iconLayers.Constructor;}})(function(L){function each(o,cb){for(var p in o){if(o.hasOwnProperty(p)){cb(o[p],p,o);}}}
2function find(ar,cb){if(ar.length){for(var i=0;i<ar.length;i++){if(cb(ar[i])){return ar[i];}}}else{for(var p in ar){if(ar.hasOwnProperty(p)&&cb(ar[p])){return ar[p];}}}}
3function first(o){for(var p in o){if(o.hasOwnProperty(p)){return o[p];}}}
4function length(o){var length=0;for(var p in o){if(o.hasOwnProperty(p)){length++;}}
5return length;}
6function prepend(parent,el){if(parent.children.length){parent.insertBefore(el,parent.children[0]);}else{parent.appendChild(el);}}
7var IconLayers=L.Control.extend({includes:L.Mixin.Events,_getActiveLayer:function(){if(this._activeLayerId){return this._layers[this._activeLayerId];}else if(length(this._layers)){return first(this._layers);}else{return null;}},_getPreviousLayer:function(){var activeLayer=this._getActiveLayer();if(!activeLayer){return null;}else if(this._previousLayerId){return this._layers[this._previousLayerId];}else{return find(this._layers,function(l){return l.id!==activeLayer.id;}.bind(this))||null;}},_getInactiveLayers:function(){var ar=[];var activeLayerId=this._getActiveLayer()?this._getActiveLayer().id:null;var previousLayerId=this._getPreviousLayer()?this._getPreviousLayer().id:null;each(this._layers,function(l){if((l.id!==activeLayerId)&&(l.id!==previousLayerId)){ar.push(l);}});return ar;},_arrangeLayers:function(){var behaviors={};behaviors.previous=function(){var layers=this._getInactiveLayers();if(this._getActiveLayer()){layers.unshift(this._getActiveLayer());}
8if(this._getPreviousLayer()){layers.unshift(this._getPreviousLayer());}
9return layers;};return behaviors[this.options.behavior].apply(this,arguments);},_getLayerCellByLayerId:function(id){var els=this._container.getElementsByClassName('leaflet-iconLayers-layerCell');for(var i=0;i<els.length;i++){if(els[i].getAttribute('data-layerid')==id){return els[i];}}},_createLayerElement:function(layerObj){var el=L.DomUtil.create('div','leaflet-iconLayers-layer');if(layerObj.title){var titleContainerEl=L.DomUtil.create('div','leaflet-iconLayers-layerTitleContainer');var titleEl=L.DomUtil.create('div','leaflet-iconLayers-layerTitle');var checkIconEl=L.DomUtil.create('div','leaflet-iconLayers-layerCheckIcon');titleEl.innerHTML=layerObj.title;titleContainerEl.appendChild(titleEl);el.appendChild(titleContainerEl);el.appendChild(checkIconEl);}
10if(layerObj.icon){el.setAttribute('style','background-image: url(\''+layerObj.icon+'\')');}
11return el;},_createLayerElements:function(){var currentRow,layerCell;var layers=this._arrangeLayers();var activeLayerId=this._getActiveLayer()&&this._getActiveLayer().id;for(var i=0;i<layers.length;i++){if(i%this.options.maxLayersInRow===0){currentRow=L.DomUtil.create('div','leaflet-iconLayers-layersRow');if(this.options.position.indexOf('bottom')===-1){this._container.appendChild(currentRow);}else{prepend(this._container,currentRow);}}
12layerCell=L.DomUtil.create('div','leaflet-iconLayers-layerCell');layerCell.setAttribute('data-layerid',layers[i].id);if(i!==0){L.DomUtil.addClass(layerCell,'leaflet-iconLayers-layerCell_hidden');}
13if(layers[i].id===activeLayerId){L.DomUtil.addClass(layerCell,'leaflet-iconLayers-layerCell_active');}
14if(this._expandDirection==='left'){L.DomUtil.addClass(layerCell,'leaflet-iconLayers-layerCell_expandLeft');}else{L.DomUtil.addClass(layerCell,'leaflet-iconLayers-layerCell_expandRight');}
15layerCell.appendChild(this._createLayerElement(layers[i]));if(this.options.position.indexOf('right')===-1){currentRow.appendChild(layerCell);}else{prepend(currentRow,layerCell);}}},_onLayerClick:function(e){e.stopPropagation();var layerId=e.currentTarget.getAttribute('data-layerid');var layer=this._layers[layerId];this.setActiveLayer(layer.layer);this.expand();},_attachEvents:function(){each(this._layers,function(l){var e=this._getLayerCellByLayerId(l.id);if(e){e.addEventListener('click',this._onLayerClick.bind(this));}}.bind(this));var layersRowCollection=this._container.getElementsByClassName('leaflet-iconLayers-layersRow');var onMouseEnter=function(e){e.stopPropagation();this.expand();}.bind(this);var onMouseLeave=function(e){e.stopPropagation();this.collapse();}.bind(this);var stopPropagation=function(e){e.stopPropagation();};for(var i=0;i<layersRowCollection.length;i++){var el=layersRowCollection[i];el.addEventListener('mouseenter',onMouseEnter);el.addEventListener('mouseleave',onMouseLeave);el.addEventListener('mousemove',stopPropagation);}},_render:function(){this._container.innerHTML='';this._createLayerElements();this._attachEvents();},_switchMapLayers:function(){if(!this._map){return;}
16var activeLayer=this._getActiveLayer();var previousLayer=this._getPreviousLayer();if(previousLayer){this._map.removeLayer(previousLayer.layer);}else{each(this._layers,function(layerObject){var layer=layerObject.layer;this._map.removeLayer(layer);}.bind(this));}
17if(activeLayer){this._map.addLayer(activeLayer.layer);}},options:{position:'bottomleft',behavior:'previous',expand:'horizontal',autoZIndex:true,maxLayersInRow:5,manageLayers:true},initialize:function(layers,options){if(!L.Util.isArray(arguments[0])){options=layers;layers=[];}
18L.setOptions(this,options);this._expandDirection=(this.options.position.indexOf('left')!=-1)?'right':'left';if(this.options.manageLayers){this.on('activelayerchange',this._switchMapLayers,this);}
19this.setLayers(layers);},onAdd:function(map){this._container=L.DomUtil.create('div','leaflet-iconLayers');L.DomUtil.addClass(this._container,'leaflet-iconLayers_'+this.options.position);this._render();map.on('click',this.collapse,this);if(this.options.manageLayers){this._switchMapLayers();}
20return this._container;},onRemove:function(map){map.off('click',this.collapse,this);},setLayers:function(layers){this._layers={};layers.map(function(layer){var id=L.stamp(layer.layer);this._layers[id]=L.extend(layer,{id:id});}.bind(this));if(this._container){this._render();}},setActiveLayer:function(layer){var l=layer&&this._layers[L.stamp(layer)];if(!l||l.id===this._activeLayerId){return;}
21this._previousLayerId=this._activeLayerId;this._activeLayerId=l.id;if(this._container){this._render();}
22this.fire('activelayerchange',{layer:layer});},expand:function(){this._arrangeLayers().slice(1).map(function(l){var el=this._getLayerCellByLayerId(l.id);L.DomUtil.removeClass(el,'leaflet-iconLayers-layerCell_hidden');}.bind(this));},collapse:function(){this._arrangeLayers().slice(1).map(function(l){var el=this._getLayerCellByLayerId(l.id);L.DomUtil.addClass(el,'leaflet-iconLayers-layerCell_hidden');}.bind(this));}});var iconLayers=function(layers,options){return new IconLayers(layers,options);};iconLayers.Constructor=IconLayers;return iconLayers;});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.