-
Notifications
You must be signed in to change notification settings - Fork 16
Malvoz attribution control #815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
prushforth
merged 16 commits into
Maps4HTML:main
from
prushforth:malvoz-attribution-control
Apr 17, 2023
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
018cc9e
Collapse attribution behind a button
Malvoz 8472318
Update attribution
Malvoz f3cacc2
Change the attribution control SVG to dark on light
Malvoz 17f4b92
attribution control
Jacky0299 c76a965
tests fix
Jacky0299 f021c8b
Aliyan suggested changes
Jacky0299 70f6730
deleted comments
Jacky0299 1708d8b
Merge branch 'main' into malvoz-attribution-control
Jacky0299 7c6f34e
test fix
Jacky0299 35187a6
Merge branch 'malvoz-attribution-control' of https://github.com/prush…
Jacky0299 61f52c1
one flaky test
Jacky0299 4d123e3
Restore and fix old test
b08d6eb
Peter suggested changes
Jacky0299 e2dcef3
string localized
Jacky0299 9e9f79c
Get rid of unused file, formatting
prushforth 6db7922
Make sure aria-label has localized string, get rid of title to eliminate
prushforth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| export var AttributionButton = L.Control.Attribution.extend({ | ||
| options: { | ||
| prefix: '<a href="https://www.w3.org/community/maps4html/">Maps for HTML Community Group</a> | <img src="data:image/svg+xml;base64,PHN2ZyBhcmlhLWhpZGRlbj0idHJ1ZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTIiIGhlaWdodD0iOCI+PHBhdGggZmlsbD0iIzRDN0JFMSIgZD0iTTAgMGgxMnY0SDB6Ii8+PHBhdGggZmlsbD0iI0ZGRDUwMCIgZD0iTTAgNGgxMnYzSDB6Ii8+PHBhdGggZmlsbD0iI0UwQkMwMCIgZD0iTTAgN2gxMnYxSDB6Ii8+PC9zdmc+" style="padding-right: 0.3em;" alt="Slava Ukraini"> <a href="https://leafletjs.com" title="A JS library for interactive maps">Leaflet</a> ' | ||
| }, | ||
|
|
||
| onAdd: function (map) { | ||
| map.attributionControl = this; | ||
| this._container = L.DomUtil.create('details', 'leaflet-control-attribution'); | ||
| L.DomEvent.disableClickPropagation(this._container); | ||
|
|
||
| for (var i in map._layers) { | ||
| if (map._layers[i].getAttribution) { | ||
| this.addAttribution(map._layers[i].getAttribution()); | ||
| } | ||
| } | ||
|
|
||
| this._update(); | ||
|
|
||
| map.on('layeradd', this._addAttribution, this); | ||
|
|
||
| let dialog = document.createElement("dialog"); | ||
| dialog.setAttribute("class", "shortcuts-dialog"); | ||
| dialog.setAttribute("autofocus", ""); | ||
| dialog.onclick = function (e) { | ||
| e.stopPropagation(); | ||
| }; | ||
| dialog.innerHTML = `<b>${M.options.locale.kbdShortcuts} </b><button aria-label="Close" onclick='this.parentElement.close()'>X</button>` + | ||
| `<ul><b>${M.options.locale.kbdMovement}</b><li><kbd>↑</kbd> ${M.options.locale.kbdPanUp}</li><li><kbd>↓</kbd> ${M.options.locale.kbdPanDown}</li><li><kbd>←</kbd> ${M.options.locale.kbdPanLeft}</li><li><kbd>→</kbd> ${M.options.locale.kbdPanRight}</li><li><kbd>+</kbd> ${M.options.locale.btnZoomIn}</li><li><kbd>-</kbd> ${M.options.locale.btnZoomOut}</li><li><kbd>shift</kbd> + <kbd>←/↑/→/↓</kbd> 3x ${M.options.locale.kbdPanIncrement}</li><li><kbd>ctrl</kbd> + <kbd>←/↑/→/↓</kbd> 0.2x ${M.options.locale.kbdPanIncrement}</li><li><kbd>shift</kbd> + <kbd>+/-</kbd> ${M.options.locale.kbdZoom}</li></ul>` + | ||
| `<ul><b>${M.options.locale.kbdFeature}</b><li><kbd>←/↑</kbd> ${M.options.locale.kbdPrevFeature}</li><li><kbd>→/↓</kbd> ${M.options.locale.kbdNextFeature}</li></ul>`; | ||
| map._container.appendChild(dialog); | ||
|
|
||
| return this._container; | ||
| }, | ||
|
|
||
| _update: function () { | ||
| if (!this._map) { return; } | ||
|
|
||
| var attribs = []; | ||
|
|
||
| for (var i in this._attributions) { | ||
| if (this._attributions[i]) { | ||
| attribs.push(i); | ||
| } | ||
| } | ||
|
|
||
| var prefixAndAttribs = []; | ||
|
|
||
| if (this.options.prefix) { | ||
| prefixAndAttribs.push(this.options.prefix); | ||
| } | ||
| if (attribs.length) { | ||
| prefixAndAttribs.push(attribs.join(', ')); | ||
| } | ||
| this._container.innerHTML = `<summary><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="30px" viewBox="0 0 24 24" width="30px" fill="currentColor"><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path></svg></summary>` + '<div class="mapml-attribution-container">' + `<button onclick="this.closest(\'.leaflet-container\').querySelector(\'.shortcuts-dialog\').showModal()" class="shortcuts-button mapml-button">${M.options.locale.kbdShortcuts}</button> | ` + prefixAndAttribs.join(' <span aria-hidden="true">|</span> ') + '</div>'; | ||
| this._container.setAttribute("role","group"); | ||
| this._container.setAttribute("aria-label",`${M.options.locale.btnAttribution}`); | ||
| } | ||
| }); | ||
|
|
||
| L.Map.mergeOptions({ | ||
| attributionControl: false, | ||
| toggleableAttributionControl: true | ||
| }); | ||
|
|
||
| L.Map.addInitHook(function () { | ||
| if (this.options.toggleableAttributionControl) { | ||
| new AttributionButton().addTo(this); | ||
| } | ||
| }); | ||
|
|
||
| export var attributionButton = function (options) { | ||
| return new AttributionButton(options); | ||
| }; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.