PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.3.2
Adminify – White Label, Admin Menu Editor, Login Customizer v4.3.2
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
adminify / assets / admin / js / wp-adminify-admin-bar-switcher.js

wp-adminify-admin-bar-switcher.js in Adminify – White Label, Admin Menu Editor, Login Customizer 4.3.2, at assets/admin/js/wp-adminify-admin-bar-switcher.js

32 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3 * This devtool is neither made for production nor for readable output files.
4 * It uses "eval()" calls to create a separate source file in the browser devtools.
5 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6 * or disable the default devtool with "devtool: false".
7 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8 */
9 /******/ (() => { // webpackBootstrap
10 /******/ var __webpack_modules__ = ({
11
12 /***/ "./dev/admin/admin-bar-switcher.js":
13 /*!*****************************************!*\
14 !*** ./dev/admin/admin-bar-switcher.js ***!
15 \*****************************************/
16 /***/ (() => {
17
18 eval("/**\n * Admin bar Light/Dark/System switcher - standalone build.\n *\n * `wp-adminify.js` drives this widget everywhere Adminify's main bundle loads,\n * but that bundle is skipped on customize.php by design\n * (Assets::should_skip_adminify_scripts). WordPress 7.1 renders the admin bar\n * there, so the switcher node arrives without the code behind it. This is the\n * same widget with no dependencies: no jQuery, and no Adminify globals beyond\n * the dark-mode bundle and the localized ajax data.\n */\n(function () {\n var MODES = [\"light\", \"dark\", \"system\"];\n var prefersDark = function prefersDark() {\n return !!window.matchMedia && window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n };\n\n /**\n * The dark-mode bundle only ships up front to users already in dark mode, so\n * switching to dark from a light page may have to fetch it first.\n * `PXLBSADMINIFYDarkMode` (printed by Assets::header_scripts) handles that\n * and is a no-op once the bundle is loaded; `AdminifyDarkMode` is the bundle\n * itself, which needs the brightness passed in.\n */\n var paintDarkMode = function paintDarkMode(enable) {\n document.body.classList.toggle(\"adminify-dark-mode\", enable);\n document.body.classList.toggle(\"adminify-light-mode\", !enable);\n if (window.PXLBSADMINIFYDarkMode) {\n if (enable) {\n window.PXLBSADMINIFYDarkMode.enable();\n } else {\n window.PXLBSADMINIFYDarkMode.disable();\n }\n return;\n }\n if (window.AdminifyDarkMode) {\n if (enable) {\n window.AdminifyDarkMode.enable({\n brightness: 120\n });\n } else {\n window.AdminifyDarkMode.disable();\n }\n }\n };\n\n // Same endpoint and payload as WP_Adminify.ToggleSwitcher(), over fetch so\n // the widget does not drag jQuery onto a screen that may not have it.\n var persistMode = function persistMode(mode) {\n var data = window.PXLBSADMINIFY_ADMINBAR;\n if (!data || !data.ajax_url) return;\n window.fetch(data.ajax_url, {\n method: \"POST\",\n credentials: \"same-origin\",\n body: new URLSearchParams({\n action: \"pxlbsadminify_color_mode\",\n security: data.security_nonce || \"\",\n key: \"color_mode\",\n value: mode\n })\n });\n };\n var init = function init() {\n var wrapper = document.getElementById(\"wp-adminify-color-mode-wrapper\");\n if (!wrapper) return;\n var modeIcon = wrapper.querySelector(\".mode-icon\");\n var dropdown = wrapper.querySelector(\".light-dark-dropdown\");\n if (!modeIcon || !dropdown) return;\n var openDropdown = function openDropdown() {\n dropdown.style.visibility = \"visible\";\n dropdown.style.opacity = \"0.9999\";\n dropdown.style.transform = \"none\";\n };\n\n // Back to the stylesheet's hidden state - the rules carry the transition.\n var closeDropdown = function closeDropdown() {\n return dropdown.removeAttribute(\"style\");\n };\n var setMode = function setMode(mode) {\n persistMode(mode);\n paintDarkMode(mode === \"system\" ? prefersDark() : mode === \"dark\");\n\n // The active-mode class is what decides which of the three glyphs\n // shows, exactly as AdminBar::dark_mode_switcher_dom() prints it.\n modeIcon.className = \"mode-icon adminify-color-mode-\" + mode + \"-active\";\n closeDropdown();\n };\n modeIcon.addEventListener(\"click\", function (event) {\n event.stopPropagation();\n openDropdown();\n });\n MODES.forEach(function (mode) {\n var button = dropdown.querySelector(\".\" + mode);\n if (button) button.addEventListener(\"click\", function () {\n return setMode(mode);\n });\n });\n document.addEventListener(\"click\", function (event) {\n if (!wrapper.contains(event.target)) closeDropdown();\n });\n };\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", init);\n } else {\n init();\n }\n})();\n\n//# sourceURL=webpack://adminify/./dev/admin/admin-bar-switcher.js?");
19
20 /***/ })
21
22 /******/ });
23 /************************************************************************/
24 /******/
25 /******/ // startup
26 /******/ // Load entry module and return exports
27 /******/ // This entry module can't be inlined because the eval devtool is used.
28 /******/ var __webpack_exports__ = {};
29 /******/ __webpack_modules__["./dev/admin/admin-bar-switcher.js"]();
30 /******/
31 /******/ })()
32 ;