1
0
Fork 0
mirror of https://github.com/Findus23/RainbowRoad.git synced 2024-09-19 16:03:52 +02:00

fix accept-all

This commit is contained in:
Lukas Winkler 2024-05-12 23:34:08 +02:00
parent 843a7dd00c
commit 4b6e3e9702
Signed by: lukas
GPG key ID: 54DE4D798D244853
4 changed files with 23 additions and 11 deletions

View file

@ -6,4 +6,6 @@ But I didn't like the thought of linking an external script and wanted to slight
So I took the [banner-2024.js](https://github.com/accept-all/cdn/blob/8a09bf0d978ef6feb443a28c173bbbd86230f0fd/banner-2024.js) and manually reversed the minified code, slightly tweaked the code and adapted it to TypeScript.
And just as I was finished, I realized that the [wf-onclick-banner.js](https://github.com/accept-all/cdn/blob/8a09bf0d978ef6feb443a28c173bbbd86230f0fd/wf-onclick-banner.js) contains the unminified source code...
All credit for the creation of this module goes to [kraftwerk Agentur für neue Kommunikation](https://www.kraftwerk.co.at/) and I hope they are fine with me using a variant of their code here.

View file

@ -1,3 +1,6 @@
/*!
Please check https://github.com/Findus23/RainbowRoad/tree/main/src/accept-all for information about the Accept All modal by https://www.kraftwerk.co.at/
*/
:root {
--paddingBorderFrom: 14px;
--paddingBorderTo: 10px;

View file

@ -1,5 +1,5 @@
/*!
Please check https://github.com/Findus23/RainbowRoad/tree/main/src/accept-all for information about the Accept All modal by https://www.kraftwerk.co.at/
*/
import "./accept-all.css"
import MicroModal, {MicroModalConfig} from "micromodal";
@ -13,7 +13,7 @@ interface Translation {
text: string
}
const colors = ["#ec1d23", "#f59121", "#fddb0f", "#029246", "#242262", "#804194", "#60cdf5", "#fff", "#f7a9b8", "#000", "#785121"]
const columnColors = ["#ec1d23", "#f59121", "#fddb0f", "#029246", "#242262", "#804194", "#60cdf5", "#fff", "#f7a9b8", "#000", "#785121"]
const translations: Translation[] = [{
language: "de",
buttonText: "Alle Akzeptieren",
@ -273,7 +273,7 @@ export class AcceptAll {
this.cookieBackground.id = "kwAcceptAllcookieBackground";
const bgImageDiv = document.createElement("div");
bgImageDiv.id = "kwAcceptAllbgImage"
colors.forEach((color, index) => {
columnColors.forEach((color, index) => {
const bgImageBar = createBgImageBar(color, index);
bgImageDiv.appendChild(bgImageBar)
})
@ -376,9 +376,9 @@ export class AcceptAll {
return
}
const o = this.showOnlyOnce ? 24 * 60 * 60 * 1000 : 1
const t = Date.now();
localStorage.setItem("kwAcceptAll_popup", `${t + o}`)
const maxAge = this.showOnlyOnce ? 24 * 60 * 60 * 1000 : 1
const now = Date.now();
localStorage.setItem("kwAcceptAll_popup", `${now + maxAge}`)
this.cookieBackground.classList.remove("kwAcceptAllTranslateIn")
this.cookieBackground.classList.add("kwAcceptAllTranslateOut");
@ -408,6 +408,13 @@ export class AcceptAll {
close() {
MicroModal.close(this.cookiePopupId)
}
dispose() {
if (this.cookiePopup) {
this.cookiePopup.remove();
this.cookiePopup = undefined;
}
}
}
export function immediateInit() {

View file

@ -2,7 +2,7 @@ import {Control} from "ol/control";
import {Options} from "ol/control/Control";
import {createElement} from "./domutils";
import {router} from "./router";
import {AcceptAll} from "./accept-all/accept-all";
import type {AcceptAll} from "./accept-all/accept-all";
interface CustomOptions extends Options {
buttonLetter: string
@ -86,7 +86,7 @@ export class BasemapControl extends MapButton {
}
export class AcceptAllControl extends MapButton {
private acceptall: any;
private acceptall: AcceptAll | undefined;
constructor() {
super({
@ -97,10 +97,10 @@ export class AcceptAllControl extends MapButton {
handleToggle() {
import("./accept-all/accept-all").then(module => {
if (typeof this.acceptall === "undefined") {
console.log("sfdds")
this.acceptall = new module.AcceptAll()
if (typeof this.acceptall !== "undefined") {
this.acceptall.dispose()
}
this.acceptall = new module.AcceptAll()
this.acceptall.show();
})
}