v1.0.0.0
StocketBase
- document.addEventListener('DOMContentLoaded', function () {
- document.querySelectorAll('.js-reject-btn').forEach(function (button) {
- button.addEventListener('click', function () {
- var row = document.getElementById('reject-row-' + this.dataset.productId);
- if (row) {
- row.style.display = row.style.display === 'none' ? 'table-row' : 'none';
- }
- });
- });
-
- var THEME_KEY = 'stocketbase_dashboard_theme';
-
- function applyTheme(theme) {
- document.body.setAttribute('data-theme', theme);
- }
-
- var stored = localStorage.getItem(THEME_KEY);
- if (stored === 'dark' || stored === 'light') {
- applyTheme(stored);
- } else {
- var prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
- applyTheme(prefersDark ? 'dark' : 'light');
- }
-
- var toggleBtns = document.querySelectorAll('#dash-theme-toggle-btn, .dash-theme-toggle');
- toggleBtns.forEach(function (btn) {
- btn.addEventListener('click', function () {
- var current = document.body.getAttribute('data-theme') || 'dark';
- var next = current === 'dark' ? 'light' : 'dark';
- applyTheme(next);
- localStorage.setItem(THEME_KEY, next);
- });
- });
-
- var nav = document.querySelector('.dash-nav');
- var sidebar = document.querySelector('.dash-sidebar');
- if (nav && sidebar) {
- var MAX_VISIBLE = 4;
- var navLinks = Array.prototype.slice.call(nav.querySelectorAll('a'));
-
- var moreBtn = null;
- var sheetBackdrop = null;
- var sheet = null;
-
- function buildOverflow() {
- if (navLinks.length <= MAX_VISIBLE) {
- return;
- }
-
- var overflowLinks = navLinks.slice(MAX_VISIBLE - 1);
- overflowLinks.forEach(function (a) {
- a.classList.add('dash-nav-overflow-item');
- });
- nav.classList.add('has-overflow');
-
- moreBtn = document.createElement('button');
- moreBtn.type = 'button';
- moreBtn.className = 'dash-nav-more-btn';
- moreBtn.innerHTML = '<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="5" cy="12" r="1.5"/><circle cx="12" cy="12" r="1.5"/><circle cx="19" cy="12" r="1.5"/></svg><span>More</span>';
- nav.appendChild(moreBtn);
-
- sheetBackdrop = document.createElement('div');
- sheetBackdrop.className = 'dash-nav-sheet-backdrop';
-
- sheet = document.createElement('div');
- sheet.className = 'dash-nav-sheet';
- var handle = document.createElement('div');
- handle.className = 'dash-nav-sheet-handle';
- sheet.appendChild(handle);
-
- overflowLinks.forEach(function (a) {
- sheet.appendChild(a.cloneNode(true));
- });
-
- document.body.appendChild(sheetBackdrop);
- document.body.appendChild(sheet);
-
- function openSheet() {
- sheetBackdrop.classList.add('open');
- sheet.classList.add('open');
- moreBtn.classList.add('open');
- }
-
- function closeSheet() {
- sheetBackdrop.classList.remove('open');
- sheet.classList.remove('open');
- moreBtn.classList.remove('open');
- }
-
- moreBtn.addEventListener('click', function () {
- if (sheetBackdrop.classList.contains('open')) {
- closeSheet();
- } else {
- openSheet();
- }
- });
-
- sheetBackdrop.addEventListener('click', closeSheet);
- }
-
- buildOverflow();
- }
- });
-
- (function (global) {
- 'use strict';
-
- var SIDEBAR_KEY = 'stocketbase_dashboard_sidebar_scale';
- var MAIN_KEY = 'stocketbase_dashboard_main_scale';
- var VALID_SCALES = [80, 90, 100, 110, 120, 130, 140, 150];
-
- function loadScale(key) {
- var stored = parseInt(global.localStorage.getItem(key), 10);
- return VALID_SCALES.indexOf(stored) !== -1 ? stored : 100;
- }
-
- function supportsZoom() {
- return typeof document.body.style.zoom !== 'undefined';
- }
-
- function applyScaleTo(el, scale) {
- if (!el) {
- return;
- }
- if (scale === 100) {
- el.style.zoom = '';
- el.style.transform = '';
- el.style.width = '';
- return;
- }
- if (supportsZoom()) {
- el.style.zoom = (scale / 100).toString();
- el.style.transform = '';
- el.style.width = '';
- } else {
- var factor = scale / 100;
- el.style.transform = 'scale(' + factor + ')';
- el.style.transformOrigin = 'top left';
- el.style.width = (100 / factor) + '%';
- }
- }
-
- var UI_FONT_KEY = 'stocketbase_dashboard_ui_font';
- var CONTENT_FONT_KEY = 'stocketbase_dashboard_content_font';
-
- function applyFonts() {
- var root = document.documentElement.style;
- var uiFont = global.localStorage.getItem(UI_FONT_KEY);
- var contentFont = global.localStorage.getItem(CONTENT_FONT_KEY);
-
- if (uiFont) {
- root.setProperty('--dash-font-ui', '"' + uiFont + '"');
- } else {
- root.removeProperty('--dash-font-ui');
- }
-
- if (contentFont) {
- root.setProperty('--dash-font-content', '"' + contentFont + '"');
- } else {
- root.removeProperty('--dash-font-content');
- }
- }
-
- var GLASS_KEY = 'stocketbase_dashboard_glass';
-
- var MINIMAL_KEY = 'stocketbase_dashboard_minimal';
-
- function applyGlass() {
- var minimal = global.localStorage.getItem(MINIMAL_KEY) === '1';
- document.body.classList.toggle('dash-minimal', minimal);
- document.body.classList.toggle('dash-no-glass', minimal || global.localStorage.getItem(GLASS_KEY) === '0');
- }
-
- function apply() {
- try {
- applyGlass();
- applyScaleTo(document.querySelector('.dash-sidebar'), loadScale(SIDEBAR_KEY));
- applyScaleTo(document.querySelector('.dash-main'), loadScale(MAIN_KEY));
- applyFonts();
- } catch (error) {
- }
- }
-
- global.StocketBaseAppearance = {
- apply: apply,
- };
-
- document.addEventListener('DOMContentLoaded', apply);
- })(window);
-