Add user.css, minified files, and unit tests for AssetMinifier
Co-authored-by: jmiller-moko <230051081+jmiller-moko@users.noreply.github.com>
This commit is contained in:
1
src/media/js/darkmode-toggle.min.js
vendored
Normal file
1
src/media/js/darkmode-toggle.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(){'use strict';var STORAGE_KEY='theme';var docEl=document.documentElement;var mql=window.matchMedia('(prefers-color-scheme: dark)');function getStored(){try{return localStorage.getItem(STORAGE_KEY);}catch(e){return null;}}function setStored(v){try{localStorage.setItem(STORAGE_KEY,v);}catch(e){}}function clearStored(){try{localStorage.removeItem(STORAGE_KEY);}catch(e){}}function systemTheme(){return mql.matches ? 'dark' : 'light';}function applyTheme(theme){docEl.setAttribute('data-bs-theme',theme);docEl.setAttribute('data-aria-theme',theme);var meta=document.querySelector('meta[name="theme-color"]');if(meta){meta.setAttribute('content',theme==='dark' ? '#0f1115' : '#ffffff');}var sw=document.getElementById('mokoThemeSwitch');if(sw){sw.setAttribute('aria-checked',theme==='dark' ? 'true' : 'false');}}function initTheme(){var stored=getStored();applyTheme(stored ? stored : systemTheme());}function posClassFromBody(){var pos=(document.body.getAttribute('data-theme-fab-pos')||'br').toLowerCase();if(!/^(br|bl|tr|tl)$/.test(pos))pos='br';return 'pos-'+pos;}function buildToggle(){if(document.getElementById('mokoThemeFab'))return;var wrap=document.createElement('div');wrap.id='mokoThemeFab';wrap.className=posClassFromBody();var lblL=document.createElement('span');lblL.className='label';lblL.textContent='Light';var switchWrap=document.createElement('button');switchWrap.id='mokoThemeSwitch';switchWrap.type='button';switchWrap.setAttribute('role','switch');switchWrap.setAttribute('aria-label','Toggle dark mode');switchWrap.setAttribute('aria-checked','false');var track=document.createElement('span');track.className='switch';var knob=document.createElement('span');knob.className='knob';track.appendChild(knob);switchWrap.appendChild(track);var lblD=document.createElement('span');lblD.className='label';lblD.textContent='Dark';var auto=document.createElement('button');auto.id='mokoThemeAuto';auto.type='button';auto.className='btn btn-sm btn-link text-decoration-none px-2';auto.setAttribute('aria-label','Follow system theme');auto.textContent='Auto';switchWrap.addEventListener('click',function(){var current=(docEl.getAttribute('data-bs-theme')||'light').toLowerCase();var next=current==='dark' ? 'light' : 'dark';applyTheme(next);setStored(next);});auto.addEventListener('click',function(){clearStored();applyTheme(systemTheme());});var onMql=function(){if(!getStored())applyTheme(systemTheme());};if(typeof mql.addEventListener==='function')mql.addEventListener('change',onMql);else if(typeof mql.addListener==='function')mql.addListener(onMql);var initial=getStored()||systemTheme();switchWrap.setAttribute('aria-checked',initial==='dark' ? 'true' : 'false');wrap.appendChild(lblL);wrap.appendChild(switchWrap);wrap.appendChild(lblD);wrap.appendChild(auto);document.body.appendChild(wrap);window.mokoThemeFabStatus=function(){var el=document.getElementById('mokoThemeFab');if(!el)return{mounted: false};var r=el.getBoundingClientRect();return{mounted: true,rect:{top: r.top,left: r.left,width: r.width,height: r.height},zIndex: window.getComputedStyle(el).zIndex,posClass: el.className};};setTimeout(function(){var r=wrap.getBoundingClientRect();if(r.width<10||r.height<10){wrap.classList.add('debug-outline');console.warn('[moko]Theme FAB mounted but appears too small — check CSS collisions.');}},50);}function init(){initTheme();buildToggle();}if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init);}else{init();}})();
|
||||
1
src/media/js/gtm.min.js
vendored
Normal file
1
src/media/js/gtm.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
src/media/js/template.min.js
vendored
Normal file
1
src/media/js/template.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(win,doc){"use strict";function backToTop(){win.scrollTo({top: 0,behavior: "smooth"});}function handleScroll(){if(win.scrollY>50){doc.body.classList.add("scrolled");}else{doc.body.classList.remove("scrolled");}}function initTOC(){if(typeof win.Toc==="function"&&doc.querySelector("#toc")){win.Toc.init({$nav: $("#toc"),$scope: $("main")});}}function initDrawers(){var leftBtn=doc.querySelector(".drawer-toggle-left");var rightBtn=doc.querySelector(".drawer-toggle-right");if(leftBtn){leftBtn.addEventListener("click",function(){var target=doc.querySelector(leftBtn.getAttribute("data-bs-target"));if(target)new bootstrap.Offcanvas(target).show();});}if(rightBtn){rightBtn.addEventListener("click",function(){var target=doc.querySelector(rightBtn.getAttribute("data-bs-target"));if(target)new bootstrap.Offcanvas(target).show();});}}function initBackTop(){var backTop=doc.getElementById("back-top");if(backTop){backTop.addEventListener("click",function(e){e.preventDefault();backToTop();});}}function init(){handleScroll();win.addEventListener("scroll",handleScroll);initTOC();initDrawers();initBackTop();}if(doc.readyState==="loading"){doc.addEventListener("DOMContentLoaded",init);}else{init();}})(window,document);
|
||||
1
src/media/js/theme-init.min.js
vendored
Normal file
1
src/media/js/theme-init.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(win,doc){"use strict";var storageKey="theme";var mql=win.matchMedia("(prefers-color-scheme: dark)");var root=doc.documentElement;function applyTheme(theme){root.setAttribute("data-bs-theme",theme);root.setAttribute("data-aria-theme",theme);try{localStorage.setItem(storageKey,theme);}catch(e){}}function clearStored(){try{localStorage.removeItem(storageKey);}catch(e){}}function systemTheme(){return mql.matches ? "dark" : "light";}function init(){var stored=null;try{stored=localStorage.getItem(storageKey);}catch(e){}var theme=stored ? stored : systemTheme();applyTheme(theme);var onChange=function(){if(!localStorage.getItem(storageKey)){applyTheme(systemTheme());}};if(typeof mql.addEventListener==="function"){mql.addEventListener("change",onChange);}else if(typeof mql.addListener==="function"){mql.addListener(onChange);}var switchEl=doc.getElementById("themeSwitch");var autoBtn=doc.getElementById("themeAuto");if(switchEl){switchEl.checked=(theme==="dark");switchEl.addEventListener("change",function(){var choice=switchEl.checked ? "dark" : "light";applyTheme(choice);});}if(autoBtn){autoBtn.addEventListener("click",function(){clearStored();applyTheme(systemTheme());});}}if(doc.readyState==="loading"){doc.addEventListener("DOMContentLoaded",init);}else{init();}})(window,document);
|
||||
Reference in New Issue
Block a user