feat: add geolocatoin permission denied case for some elements

This commit is contained in:
log101 2024-07-26 21:48:34 +03:00
parent 820cdc903b
commit 86cc813977
4 changed files with 27 additions and 1 deletions

View File

@ -30,6 +30,12 @@ function removeElement(elemId: string) {
else console.error("Element could not be found!"); else console.error("Element could not be found!");
} }
function addAttribute(elemId: string, attribute: string, value: string) {
const elem = document.getElementById(elemId);
if (elem) elem.setAttribute(attribute, value);
else console.error("Element could not be found!");
}
function revealContent() { function revealContent() {
incrementUnlockCounter(document.URL.slice(-12)); incrementUnlockCounter(document.URL.slice(-12));
removeClasses("content", "blur-2xl"); removeClasses("content", "blur-2xl");
@ -43,4 +49,5 @@ export {
toggleClass, toggleClass,
updateText, updateText,
revealContent, revealContent,
addAttribute,
}; };

View File

@ -1,6 +1,7 @@
import Toastify from "toastify-js"; import Toastify from "toastify-js";
import L, { type LatLngTuple } from "leaflet"; import L, { type LatLngTuple } from "leaflet";
import { import {
addAttribute,
addClasses, addClasses,
removeClasses, removeClasses,
removeElement, removeElement,
@ -72,6 +73,13 @@ function errorCallback(err: GeolocationPositionError) {
case GeolocationPositionError.PERMISSION_DENIED: case GeolocationPositionError.PERMISSION_DENIED:
errorMessage = errorMessage =
"Konum izni alınamadı, lütfen tarayıcınızın ve cihazınızın gizlilik ayarlarını kontrol edin."; "Konum izni alınamadı, lütfen tarayıcınızın ve cihazınızın gizlilik ayarlarını kontrol edin.";
updateText(
"locked-content-description",
"Konum izleme izni alınamadı. \nİçeriği görüntüleyebilmek için konum bilginiz gerekiyor."
);
addAttribute("current-location-control", "disabled", "true");
addClasses("current-location-control", "disabled-button");
removeElement("location-permission-button");
break; break;
case GeolocationPositionError.POSITION_UNAVAILABLE: case GeolocationPositionError.POSITION_UNAVAILABLE:
errorMessage = errorMessage =

View File

@ -57,6 +57,8 @@ const CurrentLocation = L.Control.extend({
locationButton.type = "button"; locationButton.type = "button";
locationButton.id = "current-location-control";
locationButton.addEventListener("click", () => { locationButton.addEventListener("click", () => {
if (currentLocationMarker) { if (currentLocationMarker) {
map.setView(currentLocationMarker.getLatLng(), 12); map.setView(currentLocationMarker.getLatLng(), 12);
@ -90,7 +92,7 @@ const GoToTargetLocation = L.Control.extend({
locationButton.classList.add("custom-map-control-button"); locationButton.classList.add("custom-map-control-button");
locationButton.addEventListener("click", () => { locationButton.addEventListener("click", () => {
if (TARGET_LOCATION) map.setView(TARGET_LOCATION, 18); if (TARGET_LOCATION) map.setView(TARGET_LOCATION, 12);
}); });
return locationButton; return locationButton;

View File

@ -14,3 +14,12 @@
.custom-map-control-button:hover { .custom-map-control-button:hover {
background: rgb(235, 235, 235); background: rgb(235, 235, 235);
} }
.disabled-button {
opacity: 0.5;
cursor: not-allowed;
}
.disabled-button:hover {
background-color: #fff;
}