mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
fix another js error on small screens and use const instead of let where applicable
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
* redbasic theme specific JavaScript
|
||||
*/
|
||||
|
||||
let redbasic_dark_mode = localStorage.getItem('redbasic_dark_mode');
|
||||
let redbasic_theme_color = localStorage.getItem('redbasic_theme_color');
|
||||
const redbasic_dark_mode = localStorage.getItem('redbasic_dark_mode');
|
||||
const redbasic_theme_color = localStorage.getItem('redbasic_theme_color');
|
||||
|
||||
if (redbasic_dark_mode == 1) {
|
||||
document.documentElement.setAttribute('data-bs-theme', 'dark');
|
||||
@@ -41,14 +41,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
darkElements.forEach(el => el.setAttribute('data-bs-theme', 'light'));
|
||||
}
|
||||
|
||||
let navBackgroundColor = document.querySelector('nav').style.backgroundColor;
|
||||
const navBackgroundColor = document.querySelector('nav').style.backgroundColor;
|
||||
if (redbasic_theme_color !== navBackgroundColor) {
|
||||
document.querySelector('meta[name=theme-color]').setAttribute('content', navBackgroundColor);
|
||||
localStorage.setItem('redbasic_theme_color', navBackgroundColor);
|
||||
}
|
||||
|
||||
// CSS3 calc() fallback (for unsupported browsers)
|
||||
let testElem = document.createElement('div');
|
||||
const testElem = document.createElement('div');
|
||||
testElem.style.width = 'calc(10px + 10px)';
|
||||
testElem.style.display = 'none';
|
||||
testElem.id = 'css3-calc';
|
||||
@@ -66,12 +66,15 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
testElem.remove(); // Remove the test element
|
||||
|
||||
if (window.innerWidth < 1200) {
|
||||
let rightAsideWrapper = document.getElementById("right_aside_wrapper");
|
||||
let leftAsideWrapper = document.getElementById("left_aside_wrapper");
|
||||
let notificationsWrapper = document.getElementById("notifications_wrapper");
|
||||
const rightAsideWrapper = document.getElementById("right_aside_wrapper");
|
||||
const leftAsideWrapper = document.getElementById("left_aside_wrapper");
|
||||
const notificationsWrapper = document.getElementById("notifications_wrapper");
|
||||
|
||||
if (rightAsideWrapper.children.length) {
|
||||
leftAsideWrapper.appendChild(...rightAsideWrapper.children);
|
||||
if (leftAsideWrapper && rightAsideWrapper) {
|
||||
const children = rightAsideWrapper.children;
|
||||
if (children.length) {
|
||||
leftAsideWrapper.append(...children);
|
||||
}
|
||||
}
|
||||
|
||||
if (notificationsWrapper) {
|
||||
@@ -99,7 +102,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
});
|
||||
|
||||
document.getElementById('theme-switch').addEventListener('click', function () {
|
||||
let html = document.documentElement;
|
||||
const html = document.documentElement;
|
||||
if (html.getAttribute('data-bs-theme') === 'dark') {
|
||||
let nav = document.querySelector('nav');
|
||||
if (nav.dataset.bsTheme === 'dark') {
|
||||
@@ -125,7 +128,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
});
|
||||
|
||||
document.getElementById('menu-btn').addEventListener('click', function () {
|
||||
let navCollapse = document.getElementById('navbar-collapse-1');
|
||||
const navCollapse = document.getElementById('navbar-collapse-1');
|
||||
if (navCollapse && navCollapse.classList.contains('show')) {
|
||||
navCollapse.classList.remove('show');
|
||||
}
|
||||
@@ -153,7 +156,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
});
|
||||
});
|
||||
|
||||
let doctitle = document.title;
|
||||
const doctitle = document.title;
|
||||
function checkNotify() {
|
||||
let notifyUpdateElem = document.getElementById('notify-update');
|
||||
if (notifyUpdateElem && notifyUpdateElem.innerHTML !== '') {
|
||||
@@ -166,7 +169,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
setInterval(checkNotify, 10 * 1000);
|
||||
|
||||
let touch_start = null;
|
||||
let touch_max = window.innerWidth / 10;
|
||||
const touch_max = window.innerWidth / 10;
|
||||
|
||||
window.addEventListener('touchstart', function (e) {
|
||||
if (e.touches.length === 1) {
|
||||
@@ -197,7 +200,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
});
|
||||
|
||||
function setStyle(element, cssProperty) {
|
||||
for (var property in cssProperty) {
|
||||
for (let property in cssProperty) {
|
||||
element.style[property] = cssProperty[property];
|
||||
}
|
||||
}
|
||||
@@ -211,8 +214,8 @@ function stickyScroll(sticky, stickyTop, container, topOffset, bottomOffset) {
|
||||
}
|
||||
|
||||
let stickyHeight = stickyElement.getBoundingClientRect().height;
|
||||
let stickyTopElement = document.querySelector(stickyTop);
|
||||
let content = document.querySelector(container);
|
||||
const stickyTopElement = document.querySelector(stickyTop);
|
||||
const content = document.querySelector(container);
|
||||
let diff = window.innerHeight - stickyHeight;
|
||||
|
||||
let h = 0;
|
||||
|
||||
Reference in New Issue
Block a user