diff --git a/dist/leaflet-geocoder-ban.js b/dist/leaflet-geocoder-ban.js new file mode 100644 index 0000000..9f2502e --- /dev/null +++ b/dist/leaflet-geocoder-ban.js @@ -0,0 +1,5 @@ +'use strict';/* global define, XMLHttpRequest */var f=function(a,b){// Universal Module Definition +if('function'==typeof define&&define.amd)define(['leaflet'],a);else if('undefined'!=typeof module)// Node/CommonJS +module.exports=a(require('leaflet'));else{// Browser globals +if('undefined'==typeof b.L)throw new Error('Leaflet must be loaded first');a(b.L)}},factory=function(b){b.GeocoderBAN=b.Control.extend({options:{position:'topleft',style:'control',placeholder:'adresse',resultsNumber:7,collapsed:!0,serviceUrl:'https://api-adresse.data.gouv.fr/search/',minIntervalBetweenRequests:250,defaultMarkgeocode:!0,autofocus:!0},includes:b.Evented.prototype||b.Mixin.Events,initialize:function c(a){b.Util.setOptions(this,a)},onRemove:function b(a){a.off('click',this.collapseHack,this)},onAdd:function h(a){var c,d=this.container=b.DomUtil.create('div','leaflet-control-geocoder-ban leaflet-bar'),e=this.icon=b.DomUtil.create('button','leaflet-control-geocoder-ban-icon',d),f=this.form=b.DomUtil.create('div','leaflet-control-geocoder-ban-form',d);if(a.on('click',this.collapseHack,this),e.innerHTML=' ',e.type='button',c=this.input=b.DomUtil.create('input','',f),c.type='text',c.placeholder=this.options.placeholder,this.alts=b.DomUtil.create('ul','leaflet-control-geocoder-ban-alternatives leaflet-control-geocoder-ban-alternatives-minimized',d),b.DomEvent.on(e,'click',function(a){this.toggle(),b.DomEvent.preventDefault(a)},this),b.DomEvent.addListener(c,'keyup',this.keyup,this),b.DomEvent.disableScrollPropagation(d),b.DomEvent.disableClickPropagation(d),this.options.collapsed||(this.expand(),this.options.autofocus&&setTimeout(function(){c.focus()},250)),'searchBar'===this.options.style){b.DomUtil.addClass(d,'searchBar');var g=document.getElementsByClassName('leaflet-control-container')[0];return g.appendChild(d),b.DomUtil.create('div','hidden')}return d},minimizeControl:function a(){'control'===this.options.style?this.collapse():b.DomUtil.addClass(this.alts,'leaflet-control-geocoder-ban-alternatives-minimized')},toggle:function a(){'searchBar'!=this.style&&(b.DomUtil.hasClass(this.container,'leaflet-control-geocoder-ban-expanded')?this.collapse():this.expand())},expand:function a(){b.DomUtil.addClass(this.container,'leaflet-control-geocoder-ban-expanded'),this.geocodeMarker&&this._map.removeLayer(this.geocodeMarker),this.input.select()},collapse:function a(){b.DomUtil.removeClass(this.container,'leaflet-control-geocoder-ban-expanded'),b.DomUtil.addClass(this.alts,'leaflet-control-geocoder-ban-alternatives-minimized'),this.input.blur()},collapseHack:function b(a){a.originalEvent instanceof MouseEvent&&this.minimizeControl()},moveSelection:function f(a){var c,d=document.getElementsByClassName('leaflet-control-geocoder-ban-selected');if(!d.length)c=this.alts[0>a?'firstChild':'lastChild'],b.DomUtil.addClass(c,'leaflet-control-geocoder-ban-selected');else{var e=d[0];b.DomUtil.removeClass(e,'leaflet-control-geocoder-ban-selected'),c=0'+c.properties.label+', '+c.properties.context,e.geocodedFeatures=c;return b.DomEvent.on(e,'click',function a(){this.minimizeControl(),this.geocodeResult(c)},this),b.DomEvent.on(e,'mouseover',function c(){var a=document.getElementsByClassName('leaflet-control-geocoder-ban-selected');a.length&&b.DomUtil.removeClass(a[0],'leaflet-control-geocoder-ban-selected'),b.DomUtil.addClass(e,'leaflet-control-geocoder-ban-selected')},this),b.DomEvent.on(e,'mouseout',function a(){b.DomUtil.removeClass(e,'leaflet-control-geocoder-ban-selected')},this),e},geocodeResult:function b(a){this.minimizeControl(),this.markGeocode(a)},markGeocode:function d(a){var c=[a.geometry.coordinates[1],a.geometry.coordinates[0]];this._map.setView(c,14),this.geocodeMarker=new b.Marker(c).bindPopup(a.properties.label).addTo(this._map).openPopup()}});var a=function(a,c,d){var e=new XMLHttpRequest;e.onreadystatechange=function(){4!==e.readyState||200!==e.status&&304!==e.status||d(JSON.parse(e.response))},e.open('GET',a+b.Util.getParamString(c),!0),e.setRequestHeader('Accept','application/json'),e.send(null)};return b.geocoderBAN=function(a){return new b.GeocoderBAN(a)},b.GeocoderBAN};f(factory,window); \ No newline at end of file diff --git a/dist/leaflet-geocoder-ban.min.css b/dist/leaflet-geocoder-ban.min.css new file mode 100644 index 0000000..cde102a --- /dev/null +++ b/dist/leaflet-geocoder-ban.min.css @@ -0,0 +1 @@ +.leaflet-control-geocoder-ban{border-radius:4px;background:#fff;min-width:26px;min-height:26px}.leaflet-touch .leaflet-control-geocoder-ban{min-width:30px;min-height:30px}.leaflet-control-geocoder-ban-icon{border-radius:4px;width:26px;height:26px;border:none;background-color:#fff;background-image:url(../images/geocoder.png);background-repeat:no-repeat;background-position:center}.leaflet-control-geocoder-ban-icon:focus{outline:None}.leaflet-touch .leaflet-control-geocoder-ban-icon{width:30px;height:30px}.leaflet-control-geocoder-ban-form{display:none;vertical-align:middle}.leaflet-control-geocoder-ban-expanded{margin-right:10px}.leaflet-control-geocoder-ban-expanded .leaflet-control-geocoder-ban-form{display:inline-block}.leaflet-control-geocoder-ban-form input{font-size:120%;border:0;background-color:transparent;width:246px}.leaflet-control-geocoder-ban-form input:focus{outline:None}.leaflet-control-geocoder-ban-alternatives{display:block;width:inherit;max-height:400px;list-style:none;padding:0;margin:0;overflow:auto}@media screen and (max-width:480px){.leaflet-control-geocoder-ban-alternatives{max-height:150px}}.leaflet-control-geocoder-ban-alternatives-minimized{display:none;height:0}.leaflet-control-geocoder-ban .leaflet-control-geocoder-ban-alternatives a{width:inherit;height:inherit;line-height:inherit;background-color:transparent;text-align:left;padding:3px 6px 3px 6px}.leaflet-control-geocoder-ban .leaflet-control-geocoder-ban-alternatives li{width:inherit;cursor:pointer;border-top:1px solid #d0d0d0}.leaflet-control-geocoder-ban-selected{background-color:rgba(0,0,255,.2)}.hidden{display:none}.searchBar{z-index:1000;position:relative;max-width:400px;margin:10px auto 0} \ No newline at end of file