hopefully kinda fix weirdness with the key and overlay thingies

This commit is contained in:
Gwendolyn 2024-12-16 20:08:29 +01:00
parent 7586f5f196
commit 55b90f235c

View file

@ -792,6 +792,7 @@ c3nav = {
c3nav._maybe_load_site_update(e.state); c3nav._maybe_load_site_update(e.state);
}, },
load_state: function (state, nofly) { load_state: function (state, nofly) {
console.log(window.location);
if (state.modal) { if (state.modal) {
history.back(); history.back();
return; return;
@ -2512,18 +2513,14 @@ KeyControl = L.Control.extend({
_keys: [], _keys: [],
onAdd: function () { onAdd: function () {
const pinned = JSON.parse(localStorage.getItem('c3nav.key.pinned') ?? 'false'); this._pinned = JSON.parse(localStorage.getItem('c3nav.key.pinned') ?? 'false');
this._container = L.DomUtil.create('div', 'leaflet-control-key ' + this.options.addClasses); this._container = L.DomUtil.create('div', 'leaflet-control-key ' + this.options.addClasses);
this._container.classList.toggle('leaflet-control-key-expanded', pinned);
this._content = L.DomUtil.create('div', 'content', this._container); this._content = L.DomUtil.create('div', 'content', this._container);
this._pin = L.DomUtil.create('div', 'pin-toggle material-symbols', this._container); this._pin = L.DomUtil.create('div', 'pin-toggle material-symbols', this._container);
this._pin.classList.toggle('active', pinned);
this._pin.innerText = 'push_pin'; this._pin.innerText = 'push_pin';
this._collapsed = L.DomUtil.create('a', 'collapsed-toggle', this._container); this._collapsed = L.DomUtil.create('a', 'collapsed-toggle', this._container);
this._collapsed.href = '#'; this._collapsed.href = '#';
this._expanded = pinned;
this._pinned = pinned;
if (!L.Browser.android) { if (!L.Browser.android) {
L.DomEvent.on(this._container, { L.DomEvent.on(this._container, {
@ -2532,9 +2529,11 @@ KeyControl = L.Control.extend({
}, this); }, this);
} }
if (L.Browser.mobile) {
this._pinned = false;
}
if (L.Browser.touch) { if (L.Browser.touch) {
this._pinned = false;
$(this._collapsed).click((e) => { $(this._collapsed).click((e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -2548,6 +2547,10 @@ KeyControl = L.Control.extend({
L.DomEvent.on(this._container, 'blur', this.collapse, this); L.DomEvent.on(this._container, 'blur', this.collapse, this);
} }
this._expanded = this._pinned;
this._container.classList.toggle('leaflet-control-key-expanded', this._expanded);
this._pin.classList.toggle('active', this._pinned);
this.render(); this.render();
$(this._container).on('click', 'div.pin-toggle', e => { $(this._container).on('click', 'div.pin-toggle', e => {
@ -2633,19 +2636,15 @@ OverlayControl = L.Control.extend({
onAdd: function () { onAdd: function () {
this._initialActiveOverlays = JSON.parse(localStorage.getItem('c3nav.overlays.active-overlays') ?? '[]'); this._initialActiveOverlays = JSON.parse(localStorage.getItem('c3nav.overlays.active-overlays') ?? '[]');
this._initialCollapsedGroups = JSON.parse(localStorage.getItem('c3nav.overlays.collapsed-groups') ?? '[]'); this._initialCollapsedGroups = JSON.parse(localStorage.getItem('c3nav.overlays.collapsed-groups') ?? '[]');
const pinned = JSON.parse(localStorage.getItem('c3nav.overlays.pinned') ?? 'false'); this._pinned = JSON.parse(localStorage.getItem('c3nav.overlays.pinned') ?? 'false');
this._container = L.DomUtil.create('div', 'leaflet-control-overlays ' + this.options.addClasses); this._container = L.DomUtil.create('div', 'leaflet-control-overlays ' + this.options.addClasses);
this._container.classList.toggle('leaflet-control-overlays-expanded', pinned);
this._content = L.DomUtil.create('div', 'content'); this._content = L.DomUtil.create('div', 'content');
this._collapsed = L.DomUtil.create('a', 'collapsed-toggle'); this._collapsed = L.DomUtil.create('a', 'collapsed-toggle');
this._collapsed.href = '#'; this._collapsed.href = '#';
this._pin = L.DomUtil.create('div', 'pin-toggle material-symbols'); this._pin = L.DomUtil.create('div', 'pin-toggle material-symbols');
this._pin.classList.toggle('active', pinned);
this._pin.innerText = 'push_pin'; this._pin.innerText = 'push_pin';
this._container.append(this._pin, this._content, this._collapsed); this._container.append(this._pin, this._content, this._collapsed);
this._expanded = pinned;
this._pinned = pinned;
if (!L.Browser.android) { if (!L.Browser.android) {
L.DomEvent.on(this._container, { L.DomEvent.on(this._container, {
@ -2654,9 +2653,11 @@ OverlayControl = L.Control.extend({
}, this); }, this);
} }
if (L.Browser.mobile) {
this._pinned = false;
}
if (L.Browser.touch) { if (L.Browser.touch) {
this._pinned = false;
$(this._collapsed).click((e) => { $(this._collapsed).click((e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -2675,6 +2676,11 @@ OverlayControl = L.Control.extend({
L.DomEvent.on(this._container, 'blur', this.collapse, this); L.DomEvent.on(this._container, 'blur', this.collapse, this);
} }
this._expanded = this._pinned;
this._container.classList.toggle('leaflet-control-overlays-expanded', this._expanded)
this._pin.classList.toggle('active', this._pinned);
for (const overlay of this._initialActiveOverlays) { for (const overlay of this._initialActiveOverlays) {
if (overlay in this._overlays) { if (overlay in this._overlays) {
this._overlays[overlay].visible = true; this._overlays[overlay].visible = true;