forked from Snck3rs/contao-leaflet-libraries
Update leaflet loading plugin.
This commit is contained in:
@@ -16,7 +16,8 @@ This package contains following packages:
|
||||
- [Leaflet-providers 1.0.12](http://leaflet-extras.github.io/leaflet-providers)
|
||||
- [Leaflet.markercluster 0.4.0](https://github.com/Leaflet/Leaflet.markercluster)
|
||||
- [Leaflet-omnivore 0.3.2](https://github.com/mapbox/leaflet-omnivore)
|
||||
- [Leaflet.loading 0.1.13](https://github.com/ebrelsford/Leaflet.loading)
|
||||
- [Leaflet.loading 0.1.15](https://github.com/ebrelsford/Leaflet.loading)
|
||||
- [Leaflet.Control.FullScreen 1.1.4](https://github.com/brunob/leaflet.fullscreen)
|
||||
- [Leaflet Control Geocoder 1.0.0](https://github.com/perliedman/leaflet-control-geocoder)
|
||||
- [spin.js 2.0.2](http://fgnass.github.io/spin.js)
|
||||
|
||||
|
||||
@@ -58,6 +58,10 @@
|
||||
container = this.zoomControl._container;
|
||||
// These classes are no longer used as of Leaflet 0.6
|
||||
classes += ' leaflet-bar-part-bottom leaflet-bar-part last';
|
||||
|
||||
// Loading control will be added to the zoom control. So the visible last element is not the
|
||||
// last dom element anymore. So add the part-bottom class.
|
||||
L.DomUtil.addClass(this._getLastControlButton(), 'leaflet-bar-part-bottom');
|
||||
}
|
||||
else {
|
||||
// Otherwise, create a container for the indicator
|
||||
@@ -130,7 +134,7 @@
|
||||
// If zoomControl exists, make the zoom-out button not last
|
||||
if (!this.options.separate) {
|
||||
if (this.zoomControl instanceof L.Control.Zoom) {
|
||||
L.DomUtil.removeClass(this.zoomControl._zoomOutButton, 'leaflet-bar-part-bottom');
|
||||
L.DomUtil.removeClass(this._getLastControlButton(), 'leaflet-bar-part-bottom');
|
||||
}
|
||||
else if (typeof L.Control.Zoomslider === 'function' && this.zoomControl instanceof L.Control.Zoomslider) {
|
||||
L.DomUtil.removeClass(this.zoomControl._ui.zoomOut, 'leaflet-bar-part-bottom');
|
||||
@@ -145,7 +149,7 @@
|
||||
// If zoomControl exists, make the zoom-out button last
|
||||
if (!this.options.separate) {
|
||||
if (this.zoomControl instanceof L.Control.Zoom) {
|
||||
L.DomUtil.addClass(this.zoomControl._zoomOutButton, 'leaflet-bar-part-bottom');
|
||||
L.DomUtil.addClass(this._getLastControlButton(), 'leaflet-bar-part-bottom');
|
||||
}
|
||||
else if (typeof L.Control.Zoomslider === 'function' && this.zoomControl instanceof L.Control.Zoomslider) {
|
||||
L.DomUtil.addClass(this.zoomControl._ui.zoomOut, 'leaflet-bar-part-bottom');
|
||||
@@ -153,6 +157,23 @@
|
||||
}
|
||||
},
|
||||
|
||||
_getLastControlButton: function() {
|
||||
var container = this.zoomControl._container,
|
||||
index = container.children.length - 1;
|
||||
|
||||
// Find the last visible control button that is not our loading
|
||||
// indicator
|
||||
while (index > 0) {
|
||||
var button = container.children[index];
|
||||
if (!(this._indicator === button || button.offsetWidth === 0 || button.offsetHeight === 0)) {
|
||||
break;
|
||||
}
|
||||
index--;
|
||||
}
|
||||
|
||||
return container.children[index];
|
||||
},
|
||||
|
||||
_handleLoading: function(e) {
|
||||
this.addLoader(this.getEventId(e));
|
||||
},
|
||||
|
||||
@@ -1 +1 @@
|
||||
!function(){function o(o){o.Control.Loading=o.Control.extend({options:{position:"topleft",separate:!1,zoomControl:null,spinjs:!1,spin:{lines:7,length:3,width:3,radius:5,rotate:13,top:"83%"}},initialize:function(t){o.setOptions(this,t),this._dataLoaders={},null!==this.options.zoomControl&&(this.zoomControl=this.options.zoomControl)},onAdd:function(t){if(this.options.spinjs&&"function"!=typeof Spinner)return console.error("Leaflet.loading cannot load because you didn't load spin.js (http://fgnass.github.io/spin.js/), even though you set it in options.");this._addLayerListeners(t),this._addMapListeners(t),this.options.separate||this.zoomControl||(t.zoomControl?this.zoomControl=t.zoomControl:t.zoomsliderControl&&(this.zoomControl=t.zoomsliderControl));var n,i="leaflet-control-loading";return this.zoomControl&&!this.options.separate?(n=this.zoomControl._container,i+=" leaflet-bar-part-bottom leaflet-bar-part last"):n=o.DomUtil.create("div","leaflet-control-zoom leaflet-bar"),this._indicator=o.DomUtil.create("a",i,n),this.options.spinjs&&(this._spinner=new Spinner(this.options.spin).spin(),this._indicator.appendChild(this._spinner.el)),n},onRemove:function(o){this._removeLayerListeners(o),this._removeMapListeners(o)},removeFrom:function(t){return this.zoomControl&&!this.options.separate?(this._container.removeChild(this._indicator),this._map=null,this.onRemove(t),this):o.Control.prototype.removeFrom.call(this,t)},addLoader:function(o){this._dataLoaders[o]=!0,this.updateIndicator()},removeLoader:function(o){delete this._dataLoaders[o],this.updateIndicator()},updateIndicator:function(){this.isLoading()?this._showIndicator():this._hideIndicator()},isLoading:function(){return this._countLoaders()>0},_countLoaders:function(){var o,t=0;for(o in this._dataLoaders)this._dataLoaders.hasOwnProperty(o)&&t++;return t},_showIndicator:function(){o.DomUtil.addClass(this._indicator,"is-loading"),this.options.separate||(this.zoomControl instanceof o.Control.Zoom?o.DomUtil.removeClass(this.zoomControl._zoomOutButton,"leaflet-bar-part-bottom"):"function"==typeof o.Control.Zoomslider&&this.zoomControl instanceof o.Control.Zoomslider&&o.DomUtil.removeClass(this.zoomControl._ui.zoomOut,"leaflet-bar-part-bottom"))},_hideIndicator:function(){o.DomUtil.removeClass(this._indicator,"is-loading"),this.options.separate||(this.zoomControl instanceof o.Control.Zoom?o.DomUtil.addClass(this.zoomControl._zoomOutButton,"leaflet-bar-part-bottom"):"function"==typeof o.Control.Zoomslider&&this.zoomControl instanceof o.Control.Zoomslider&&o.DomUtil.addClass(this.zoomControl._ui.zoomOut,"leaflet-bar-part-bottom"))},_handleLoading:function(o){this.addLoader(this.getEventId(o))},_handleLoad:function(o){this.removeLoader(this.getEventId(o))},getEventId:function(o){return o.id?o.id:o.layer?o.layer._leaflet_id:o.target._leaflet_id},_layerAdd:function(o){if(o.layer&&o.layer.on)try{o.layer.on({loading:this._handleLoading,load:this._handleLoad},this)}catch(t){console.warn("L.Control.Loading: Tried and failed to add event handlers to layer",o.layer),console.warn("L.Control.Loading: Full details",t)}},_addLayerListeners:function(o){o.eachLayer(function(o){o.on&&o.on({loading:this._handleLoading,load:this._handleLoad},this)},this),o.on("layeradd",this._layerAdd,this)},_removeLayerListeners:function(o){o.eachLayer(function(o){o.off&&o.off({loading:this._handleLoading,load:this._handleLoad},this)},this),o.off("layeradd",this._layerAdd,this)},_addMapListeners:function(o){o.on({dataloading:this._handleLoading,dataload:this._handleLoad,layerremove:this._handleLoad},this)},_removeMapListeners:function(o){o.off({dataloading:this._handleLoading,dataload:this._handleLoad,layerremove:this._handleLoad},this)}}),o.Map.addInitHook(function(){this.options.loadingControl&&(this.loadingControl=new o.Control.Loading,this.addControl(this.loadingControl))}),o.Control.loading=function(t){return new o.Control.Loading(t)}}"function"==typeof define&&define.amd?define(["leaflet"],function(t){o(t)}):o(L)}();
|
||||
!function(){function o(o){o.Control.Loading=o.Control.extend({options:{position:"topleft",separate:!1,zoomControl:null,spinjs:!1,spin:{lines:7,length:3,width:3,radius:5,rotate:13,top:"83%"}},initialize:function(t){o.setOptions(this,t),this._dataLoaders={},null!==this.options.zoomControl&&(this.zoomControl=this.options.zoomControl)},onAdd:function(t){if(this.options.spinjs&&"function"!=typeof Spinner)return console.error("Leaflet.loading cannot load because you didn't load spin.js (http://fgnass.github.io/spin.js/), even though you set it in options.");this._addLayerListeners(t),this._addMapListeners(t),this.options.separate||this.zoomControl||(t.zoomControl?this.zoomControl=t.zoomControl:t.zoomsliderControl&&(this.zoomControl=t.zoomsliderControl));var n,i="leaflet-control-loading";return this.zoomControl&&!this.options.separate?(n=this.zoomControl._container,i+=" leaflet-bar-part-bottom leaflet-bar-part last",o.DomUtil.addClass(this._getLastControlButton(),"leaflet-bar-part-bottom")):n=o.DomUtil.create("div","leaflet-control-zoom leaflet-bar"),this._indicator=o.DomUtil.create("a",i,n),this.options.spinjs&&(this._spinner=new Spinner(this.options.spin).spin(),this._indicator.appendChild(this._spinner.el)),n},onRemove:function(o){this._removeLayerListeners(o),this._removeMapListeners(o)},removeFrom:function(t){return this.zoomControl&&!this.options.separate?(this._container.removeChild(this._indicator),this._map=null,this.onRemove(t),this):o.Control.prototype.removeFrom.call(this,t)},addLoader:function(o){this._dataLoaders[o]=!0,this.updateIndicator()},removeLoader:function(o){delete this._dataLoaders[o],this.updateIndicator()},updateIndicator:function(){this.isLoading()?this._showIndicator():this._hideIndicator()},isLoading:function(){return this._countLoaders()>0},_countLoaders:function(){var o,t=0;for(o in this._dataLoaders)this._dataLoaders.hasOwnProperty(o)&&t++;return t},_showIndicator:function(){o.DomUtil.addClass(this._indicator,"is-loading"),this.options.separate||(this.zoomControl instanceof o.Control.Zoom?o.DomUtil.removeClass(this._getLastControlButton(),"leaflet-bar-part-bottom"):"function"==typeof o.Control.Zoomslider&&this.zoomControl instanceof o.Control.Zoomslider&&o.DomUtil.removeClass(this.zoomControl._ui.zoomOut,"leaflet-bar-part-bottom"))},_hideIndicator:function(){o.DomUtil.removeClass(this._indicator,"is-loading"),this.options.separate||(this.zoomControl instanceof o.Control.Zoom?o.DomUtil.addClass(this._getLastControlButton(),"leaflet-bar-part-bottom"):"function"==typeof o.Control.Zoomslider&&this.zoomControl instanceof o.Control.Zoomslider&&o.DomUtil.addClass(this.zoomControl._ui.zoomOut,"leaflet-bar-part-bottom"))},_getLastControlButton:function(){for(var o=this.zoomControl._container,t=o.children.length-1;t>0;){var n=o.children[t];if(this._indicator!==n&&0!==n.offsetWidth&&0!==n.offsetHeight)break;t--}return o.children[t]},_handleLoading:function(o){this.addLoader(this.getEventId(o))},_handleLoad:function(o){this.removeLoader(this.getEventId(o))},getEventId:function(o){return o.id?o.id:o.layer?o.layer._leaflet_id:o.target._leaflet_id},_layerAdd:function(o){if(o.layer&&o.layer.on)try{o.layer.on({loading:this._handleLoading,load:this._handleLoad},this)}catch(t){console.warn("L.Control.Loading: Tried and failed to add event handlers to layer",o.layer),console.warn("L.Control.Loading: Full details",t)}},_addLayerListeners:function(o){o.eachLayer(function(o){o.on&&o.on({loading:this._handleLoading,load:this._handleLoad},this)},this),o.on("layeradd",this._layerAdd,this)},_removeLayerListeners:function(o){o.eachLayer(function(o){o.off&&o.off({loading:this._handleLoading,load:this._handleLoad},this)},this),o.off("layeradd",this._layerAdd,this)},_addMapListeners:function(o){o.on({dataloading:this._handleLoading,dataload:this._handleLoad,layerremove:this._handleLoad},this)},_removeMapListeners:function(o){o.off({dataloading:this._handleLoading,dataload:this._handleLoad,layerremove:this._handleLoad},this)}}),o.Map.addInitHook(function(){this.options.loadingControl&&(this.loadingControl=new o.Control.Loading,this.addControl(this.loadingControl))}),o.Control.loading=function(t){return new o.Control.Loading(t)}}"function"==typeof define&&define.amd?define(["leaflet"],function(t){o(t)}):o(L)}();
|
||||
@@ -71,6 +71,7 @@ See Leaflet.loading in action (zoom or pan to make tiles load):
|
||||
- With the loading indicator and zoom control on the [top right][topright] of
|
||||
the map.
|
||||
- The [simplest example using spin.js](http://ebrelsford.github.io/Leaflet.loading/spinjs.html) instead of an image
|
||||
- Combined with a [fullscreen control][combined] (e.g. [https://github.com/brunob/leaflet.fullscreen]).
|
||||
|
||||
|
||||
## License
|
||||
@@ -84,3 +85,4 @@ License.
|
||||
[simple]: http://ebrelsford.github.io/Leaflet.loading/simple.html
|
||||
[separate]: http://ebrelsford.github.io/Leaflet.loading/separate.html
|
||||
[topright]: http://ebrelsford.github.io/Leaflet.loading/topright.html
|
||||
[combined]: http://ebrelsford.github.io/Leaflet.loading/combined.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "leaflet.loading",
|
||||
"version": "0.1.14",
|
||||
"version": "0.1.15",
|
||||
"homepage": "https://github.com/ebrelsford/leaflet.loading",
|
||||
"authors": [
|
||||
"Eric Brelsford <ebrelsford@gmail.com>"
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
@@ -55,7 +55,7 @@ $GLOBALS['LEAFLET_LIBRARIES']['leaflet-markercluster'] = array
|
||||
$GLOBALS['LEAFLET_LIBRARIES']['leaflet-loading'] = array
|
||||
(
|
||||
'name' => 'Leaflet.loading',
|
||||
'version' => '0.1.14',
|
||||
'version' => '0.1.15',
|
||||
'license' => '<a href="https://github.com/ebrelsford/Leaflet.loading/blob/master/LICENSE" target="_blank">MIT</a>',
|
||||
'homepage' => 'https://github.com/ebrelsford/Leaflet.loading',
|
||||
'css' => 'assets/leaflet/libs/leaflet-loading/Control.Loading.min.css',
|
||||
|
||||
Reference in New Issue
Block a user