From bddadbe22aa627799bf8d845905ccb53d8ec895d Mon Sep 17 00:00:00 2001 From: David Molineus Date: Fri, 18 Dec 2020 10:44:16 +0100 Subject: [PATCH] Update Leaflet.Control.FullScreen to version 1.6.0 --- README.md | 2 +- .../leaflet-fullscreen/Control.FullScreen.js | 48 ++++++++++++++----- assets/leaflet-fullscreen/README.md | 3 ++ assets/leaflet-fullscreen/bower.json | 33 ------------- assets/leaflet-fullscreen/index.html | 19 ++++---- assets/leaflet-fullscreen/package.json | 4 +- module/config/config.php | 2 +- 7 files changed, 54 insertions(+), 57 deletions(-) delete mode 100644 assets/leaflet-fullscreen/bower.json diff --git a/README.md b/README.md index 9cc2154..176db3f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This package contains following packages: - [Leaflet.markercluster 1.4.1](https://github.com/Leaflet/Leaflet.markercluster) - [Leaflet-omnivore 0.3.4](https://github.com/mapbox/leaflet-omnivore) - [Leaflet.loading 0.1.24](https://github.com/ebrelsford/Leaflet.loading) - - [Leaflet.Control.FullScreen 1.4.5](https://github.com/brunob/leaflet.fullscreen) + - [Leaflet.Control.FullScreen 1.6.0](https://github.com/brunob/leaflet.fullscreen) - [Leaflet Control Geocoder 1.13.0](https://github.com/perliedman/leaflet-control-geocoder) - [Leaflet.ExtraMarkers 1.0.8](https://github.com/coryasilva/Leaflet.ExtraMarkers) - [leaflet.pm 0.25.0](https://github.com/codeofsumit/leaflet.pm) diff --git a/assets/leaflet-fullscreen/Control.FullScreen.js b/assets/leaflet-fullscreen/Control.FullScreen.js index 91f535a..44da9a1 100644 --- a/assets/leaflet-fullscreen/Control.FullScreen.js +++ b/assets/leaflet-fullscreen/Control.FullScreen.js @@ -26,32 +26,53 @@ L.Control.FullScreen = L.Control.extend({ } this._createButton(this.options.title, className, content, container, this.toggleFullScreen, this); + this._map.fullscreenControl = this; this._map.on('enterFullscreen exitFullscreen', this._toggleTitle, this); return container; }, + onRemove: function (map) { + L.DomEvent + .off(this.link, 'click', L.DomEvent.stopPropagation) + .off(this.link, 'click', L.DomEvent.preventDefault) + .off(this.link, 'click', this.toggleFullScreen, this); + + L.DomEvent + .off(this._container, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation) + .off(this._container, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault) + .off(this._container, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, this); + + L.DomEvent + .off(document, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation) + .off(document, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault) + .off(document, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, this); + }, + _createButton: function (title, className, content, container, fn, context) { this.link = L.DomUtil.create('a', className, container); this.link.href = '#'; this.link.title = title; this.link.innerHTML = content; + this.link.setAttribute('role', 'button'); + this.link.setAttribute('aria-label', title); + L.DomEvent - .addListener(this.link, 'click', L.DomEvent.stopPropagation) - .addListener(this.link, 'click', L.DomEvent.preventDefault) - .addListener(this.link, 'click', fn, context); + .on(this.link, 'click', L.DomEvent.stopPropagation) + .on(this.link, 'click', L.DomEvent.preventDefault) + .on(this.link, 'click', fn, context); L.DomEvent - .addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation) - .addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault) - .addListener(container, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, context); + .on(container, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation) + .on(container, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault) + .on(container, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, context); L.DomEvent - .addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation) - .addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault) - .addListener(document, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, context); + .on(document, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation) + .on(document, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault) + .on(document, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, context); return this.link; }, @@ -95,10 +116,15 @@ L.Control.FullScreen = L.Control.extend({ } }); +L.Map.include({ + toggleFullscreen: function () { + this.fullscreenControl.toggleFullScreen(); + } +}); + L.Map.addInitHook(function () { if (this.options.fullscreenControl) { - this.fullscreenControl = L.control.fullscreen(this.options.fullscreenControlOptions); - this.addControl(this.fullscreenControl); + this.addControl(L.control.fullscreen(this.options.fullscreenControlOptions)); } }); diff --git a/assets/leaflet-fullscreen/README.md b/assets/leaflet-fullscreen/README.md index 06b9189..58cfa31 100644 --- a/assets/leaflet-fullscreen/README.md +++ b/assets/leaflet-fullscreen/README.md @@ -61,6 +61,9 @@ map.on('enterFullscreen', function(){ map.on('exitFullscreen', function(){ console.log('exited fullscreen'); }); + +// you can also toggle fullscreen from map object +map.toggleFullScreen(); ``` Where ? diff --git a/assets/leaflet-fullscreen/bower.json b/assets/leaflet-fullscreen/bower.json deleted file mode 100644 index b2fee80..0000000 --- a/assets/leaflet-fullscreen/bower.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "leaflet.fullscreen", - "version": "1.4.5", - "homepage": "https://github.com/brunob/leaflet.fullscreen", - "license": "MIT", - "authors": [ - "brunob " - ], - "description": "Leaflet.Control.FullScreen for Leaflet", - "main": [ - "Control.FullScreen.js", - "Control.FullScreen.css", - "icon-fullscreen.png", - "icon-fullscreen-2x.png" - ], - "devDependencies": { - "eslint": "2.3.0" - }, - "keywords": [ - "leaflet", - "plugins", - "maps", - "fullscreen" - ], - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests", - "index.html" - ] -} diff --git a/assets/leaflet-fullscreen/index.html b/assets/leaflet-fullscreen/index.html index 5fb1b2b..0540909 100644 --- a/assets/leaflet-fullscreen/index.html +++ b/assets/leaflet-fullscreen/index.html @@ -3,18 +3,19 @@ Leaflet.Control.FullScreen Demo - + - + @@ -22,13 +23,13 @@