diff --git a/public/leaflet-fullscreen/control/control-added-listener.js b/public/leaflet-fullscreen/control/control-added-listener.js deleted file mode 100644 index bab5e9b..0000000 --- a/public/leaflet-fullscreen/control/control-added-listener.js +++ /dev/null @@ -1,28 +0,0 @@ -import { DomEvent } from '../../leaflet/leaflet-src.esm.js' - -import { setControlTitle } from './set-control-title.js' - -export function controlAddedListener({ - container, - getFullscreenState, - onLinkClick, - ...titleOptions -}) { - return function handleControlAdded(map) { - setControlTitle({ - fullscreen: getFullscreenState(), - ...titleOptions, - }) - - onLinkClick(async function handleLinkClick(e) { - DomEvent.stopPropagation(e) - DomEvent.preventDefault(e) - - await (getFullscreenState() - ? document?.exitFullscreen() - : map.getContainer()?.requestFullscreen()) - }) - - return container - } -} diff --git a/public/leaflet-fullscreen/control/set-control-title.js b/public/leaflet-fullscreen/control/set-control-title.js deleted file mode 100644 index 2c48900..0000000 --- a/public/leaflet-fullscreen/control/set-control-title.js +++ /dev/null @@ -1,3 +0,0 @@ -export function setControlTitle({ fullscreen, linkAssign, title }) { - linkAssign({ title: title[fullscreen] }) -} diff --git a/public/leaflet-fullscreen/dom-node-class/join-class-names.js b/public/leaflet-fullscreen/dom-node-class/join-class-names.js deleted file mode 100644 index cbaccb6..0000000 --- a/public/leaflet-fullscreen/dom-node-class/join-class-names.js +++ /dev/null @@ -1,3 +0,0 @@ -export function joinClassNames(classNames) { - return classNames.join(' ') -} diff --git a/public/leaflet-fullscreen/fullscreen-map.js b/public/leaflet-fullscreen/fullscreen-map.js deleted file mode 100644 index c85b6e5..0000000 --- a/public/leaflet-fullscreen/fullscreen-map.js +++ /dev/null @@ -1,75 +0,0 @@ -import { - control as leafletControl, - DomUtil, - map as leafletMap, -} from '../leaflet/leaflet-src.esm.js' - -import { controlAddedListener } from './control/control-added-listener.js' -import { joinClassNames } from './dom-node-class/join-class-names.js' -import { mapLifecycleListener } from './map/map-lifecycle-listener.js' -import { useBoolean } from './state/use-boolean.js' -import { useLink } from './state/use-link.js' - -export function fullscreenMap({ - fullscreenOptions: { - classNames: { - container: containerClassNames, - link: linkClassNames, - mapFullscreen: mapFullscreenClassName, - }, - control: { position, title }, - } = { - classNames: { - container: [ - 'leaflet-bar', - 'leaflet-control', - 'leaflet-control-fullscreen', - ], - link: ['leaflet-bar-part', 'leaflet-control-fullscreen-button'], - mapFullscreen: 'leaflet-fullscreen-on', - }, - control: { - position: 'topleft', - title: { - false: 'View Fullscreen', - true: 'Exit Fullscreen', - }, - }, - }, - id, - ...mapOptions -}) { - const { get: getFullscreenState, toggle: toggleFullscreenState } = - useBoolean(false), - container = DomUtil.create('div', joinClassNames(containerClassNames)), - { assign: linkAssign, onClick: onLinkClick } = useLink({ - element: DomUtil.create('a', joinClassNames(linkClassNames), container), - initialProps: { href: '#' }, - }), - control = leafletControl({ position }), - map = leafletMap(id, mapOptions), - handleMapLifecycleChange = (documentFirstReady) => - mapLifecycleListener({ - documentFirstReady, - getFullscreenState, - linkAssign, - map, - mapFullscreenClassName, - title, - toggleFullscreenState, - }) - - control.onAdd = controlAddedListener({ - container, - getFullscreenState, - linkAssign, - onLinkClick, - title, - }) - control.addTo(map) - - map.whenReady(handleMapLifecycleChange(true)) - map.on('unload', handleMapLifecycleChange(false)) - - return map -} diff --git a/public/leaflet-fullscreen/map/map-lifecycle-listener.js b/public/leaflet-fullscreen/map/map-lifecycle-listener.js deleted file mode 100644 index dbc3c2d..0000000 --- a/public/leaflet-fullscreen/map/map-lifecycle-listener.js +++ /dev/null @@ -1,33 +0,0 @@ -import { DomEvent, DomUtil } from '../../leaflet/leaflet-src.esm.js' -import { setControlTitle } from '../control/set-control-title.js' - -export function mapLifecycleListener({ - documentFirstReady, - getFullscreenState, - linkAssign, - map, - mapFullscreenClassName, - title, - toggleFullscreenState, -}) { - return function handleFullscreenMapLifecycleEvent() { - DomEvent[documentFirstReady ? 'on' : 'off']( - document, - 'fullscreenchange', - function handleFullscreenMapChange() { - ;(getFullscreenState() ? DomUtil.removeClass : DomUtil.addClass)( - map.getContainer(), - mapFullscreenClassName, - ) - - map.invalidateSize() - toggleFullscreenState() - setControlTitle({ - fullscreen: getFullscreenState(), - linkAssign, - title, - }) - }, - ) - } -} diff --git a/public/leaflet-fullscreen/state/use-boolean.js b/public/leaflet-fullscreen/state/use-boolean.js deleted file mode 100644 index 52c909a..0000000 --- a/public/leaflet-fullscreen/state/use-boolean.js +++ /dev/null @@ -1,11 +0,0 @@ -export function useBoolean(initialValue) { - let state = initialValue - return { - get() { - return state - }, - toggle() { - state = !state - }, - } -} diff --git a/public/leaflet-fullscreen/state/use-link.js b/public/leaflet-fullscreen/state/use-link.js deleted file mode 100644 index fd0e4a7..0000000 --- a/public/leaflet-fullscreen/state/use-link.js +++ /dev/null @@ -1,16 +0,0 @@ -import { DomEvent } from '../../leaflet/leaflet-src.esm.js' - -export function useLink({ element, initialProps }) { - function assign(props) { - Object.assign(element, props) - } - - assign(initialProps) - - return { - assign, - onClick(handler) { - DomEvent.on(element, 'click', handler) - }, - } -} diff --git a/public/tutorial/accessibility/script/fullscreen.js b/public/tutorial/accessibility/script/fullscreen.js deleted file mode 100644 index e08e95e..0000000 --- a/public/tutorial/accessibility/script/fullscreen.js +++ /dev/null @@ -1,25 +0,0 @@ -import { attributionOsm, urlTemplateOsm } from '../../../script/base-layers.js' -import { marker } from '../../../leaflet-adapter/marker.js' -import { tileLayer } from '../../../leaflet-adapter/tile-layer/tile-layer.js' -import { fullscreenMap } from '../../../leaflet-fullscreen/fullscreen-map.js' - -const altText = 'Kyiv', - map = fullscreenMap({ - center: [50.4501, 30.5234], - id: 'map', - zoom: 4, - }) - -marker({ - altText, - latitudeLongitude: [50.4501, 30.5234], - map, - popupContent: `${altText}, Ukraine is the birthplace of Leaflet!`, -}) - -tileLayer({ - attribution: attributionOsm, - map, - urlTemplate: urlTemplateOsm, - zoomMax: 19, -})