From 35929524bb637310c8d0a4c94c479aaeb6689d3c Mon Sep 17 00:00:00 2001 From: David Molineus Date: Fri, 23 Jan 2015 15:59:27 +0100 Subject: [PATCH] Update leaflet loading plugin. --- README.md | 3 ++- assets/leaflet-loading/Control.Loading.js | 25 ++++++++++++++++-- assets/leaflet-loading/Control.Loading.min.js | 2 +- assets/leaflet-loading/README.md | 2 ++ assets/leaflet-loading/bower.json | 2 +- assets/leaflet-loading/loading.gif | Bin 1840 -> 0 bytes module/config/config.php | 2 +- 7 files changed, 30 insertions(+), 6 deletions(-) delete mode 100644 assets/leaflet-loading/loading.gif diff --git a/README.md b/README.md index 876ec6b..1b50c5e 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/assets/leaflet-loading/Control.Loading.js b/assets/leaflet-loading/Control.Loading.js index 16683d2..f7515fd 100644 --- a/assets/leaflet-loading/Control.Loading.js +++ b/assets/leaflet-loading/Control.Loading.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)); }, diff --git a/assets/leaflet-loading/Control.Loading.min.js b/assets/leaflet-loading/Control.Loading.min.js index be57194..921dc15 100644 --- a/assets/leaflet-loading/Control.Loading.min.js +++ b/assets/leaflet-loading/Control.Loading.min.js @@ -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)}(); \ No newline at end of file +!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)}(); \ No newline at end of file diff --git a/assets/leaflet-loading/README.md b/assets/leaflet-loading/README.md index a9f9f71..a7cbef3 100644 --- a/assets/leaflet-loading/README.md +++ b/assets/leaflet-loading/README.md @@ -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 diff --git a/assets/leaflet-loading/bower.json b/assets/leaflet-loading/bower.json index 889a55e..a3c6268 100644 --- a/assets/leaflet-loading/bower.json +++ b/assets/leaflet-loading/bower.json @@ -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 " diff --git a/assets/leaflet-loading/loading.gif b/assets/leaflet-loading/loading.gif deleted file mode 100644 index ed65b705afeaac6b9a13edf8d2efe503ccd7e5b1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1840 zcma*mdr(tX9tZI2z31lM+(&YVKtrTX2#F>kG2s=WSobD?L10;+3gxvVVpv0=1}ef9 zMDjpL_)TTNG>oAJcYA#K?@c9b1_?yVGqugB^B9Tel0l?Nn#lx(PG8vwvh~ z_WXIy@67qk_ji7lT|13iZ4iOTHwg0d=~DzjR#sO0e*e- zsX!nQ6B9EwHiqMPMn;Ci;Rv1n|104M;8UUUgdZhY&34;C`#x!_8M-_q^i zl<4ve+cfrCwmS&_%1M8IE!y<(g~vlhEyChxg5{s?4)@=$pwGMT{6f z@X@vux#SSW0ZQJXNd-chVu8CR5hZyDyAO1w177MW8U1oPP1_TYf8+nlawu$ZaQ3YO z*(UNm6YQJyFRacBqI8pSR_A`XxIfFL;G}rpt%uIs3nY04PPfhNL|ws_=Y7%8v#u?% z8)pFsZn^%s_h@-^-9Qv5Kxm(}QeM^Kilk^9`8`OU5j zQ*&g@S}vcYg)rU(GIv$>fm$@UfxcTjsN*~{y;=bjxzf5Iz;9k~!Zbl&Nz!-kYDL7^ z2Une!$lI@57mJi94W#G(xigZLJ-Y9ue3DjcfL8@DWsc$YIX9La51rSX8N25L$h}<(>&lP5#XYRfqwcDHX z=q{X#eIw@UrWh!BF#fk0`>V{Cdk*BM)Ra~H0wLRS*ek0g2;5fa&@n_c!KhUI zT7pCh>gf>+66=!-ieYj-oGojO90}nQxz&H^g0_bB{kUNx_4=SB%8i%QLm3Bh>}gUJjf@k zgixhYG6Y7ve559C2=wl#sS*&I1(wDPvQHjavo_Fc8dR-0CRHw|1Iq8s>6M~n@w!>* z?<;0M-eudLz_XmXXm1n0GW#e`-)p~am=AKL9eXBmu$uPHwd}^(ZiQTM=Qm$D#SF!- zB5(_Wwek7vVT4Np9e`m_A@N)iMI@il@^ftIXoD)UWi1)i*z&}yn@wZ+7mmNV^yhxf zZ?F9z04IDoRmuj>*o94*>C*lsm@dlpEyQ){A8fpw>b6bkwW4D&Lszx&g2iXg&x=RE zz)g=cH!T|CrF^Jh9TkHKK8Ow6 zS--rf*P#OzLzmW%#X62jlc|%5q?8#bLR!8}Jj+(D%MkNE?Uv3g_r@CEzS3Zps?Vn-F zI<@fKVe6uX&-9%9c3iA^v;#vSFOy=8C578HG}aBbC+`-*Y931cx)uzd+RQe+D5tov GCi7qYbq=Qh diff --git a/module/config/config.php b/module/config/config.php index c2fec44..c4e9a08 100644 --- a/module/config/config.php +++ b/module/config/config.php @@ -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' => 'MIT', 'homepage' => 'https://github.com/ebrelsford/Leaflet.loading', 'css' => 'assets/leaflet/libs/leaflet-loading/Control.Loading.min.css',