MediaWiki:Common.css: Difference between revisions

From Bose Portable PA Knowledge
Jump to navigation Jump to search
mNo edit summary
Tag: Manual revert
mNo edit summary
Tag: Reverted
Line 1: Line 1:
/** CSS placed here will be applied to all skins */
/* MediaWiki:Common.js
 
  Lightweight fallback mobile menu
@font-face {
  Activates only when Minerva/native mobile menu is not present
    font-family:"Gotham-Black";
*/
    src:url("/styles/Gotham-Black.otf")
}
 
@font-face {
    font-family:"Gotham-BlackItalic";
    src:url("/styles/Gotham-BlackItalic.otf")
}
 
@font-face {
    font-family:"Gotham-Bold";
    src:url("/styles/Gotham-Bold.otf")
}
@font-face {
    font-family:"Gotham-BoldItalic";
    src:url("/styles/Gotham-BoldItalic.otf")
}
 
@font-face {
    font-family:"Gotham-Book";
    src:url("/styles/Gotham-Book.otf")
}
 
@font-face {
    font-family:"Gotham-BookItalic";
    src:url("/styles/Gotham-BookItalic.otf")
}
h1, h2, h3, h4, h5, h6 { font-family:Gotham-Book;
                        /* text-transform: uppercase; */
}
body {font-family:Gotham-Book;Montserrat}


.mw-body h1,.mw-body h2,.mw-body h3, .mw-body h4,.mw-body h5 {font-family:Gotham-Book,Montserrat}
mw.hook('wikipage.content').add(function () {
  // Only run on narrow screens
  if (window.innerWidth > 800) return;


  // If native Minerva menu exists, do nothing
  if (document.querySelector('.minerva-menu-button, .minerva-hamburger, .mw-mobile-menu')) return;


  // Avoid injecting twice
  if (document.querySelector('.fallback-mobile-hamburger')) return;


.mw-headline
  // Create hamburger button
{
  var btn = document.createElement('button');
font-family: "Gotham-Bold","Gotham-Book" , Montserrat, sans-serif;
  btn.className = 'fallback-mobile-hamburger';
/*font-size: 14px; */
  btn.type = 'button';
/*font-weight: bold;*/
  btn.setAttribute('aria-label', 'Open menu');
/*color: #008080;*/
  btn.setAttribute('aria-expanded', 'false');
background:#ffffff;
  btn.innerHTML = '☰';
//background:#cef2e0;
// background-color: #CCFFCC;
// border-radius: 5px;
//border: 1px outset #008080;
padding: 2px;
width: 300px;
}
.structuredData {display:none}


td {vertical-align:top}
  // Insert into header area (best-effort)
  var header = document.querySelector('.minerva-header') || document.querySelector('#mw-head') || document.body;
  try {
    header.insertBefore(btn, header.firstChild);
  } catch (e) {
    document.body.appendChild(btn);
  }


body {
  // Create overlay and panel
max-width:1366px;  
  var overlay = document.createElement('div');
}
  overlay.className = 'fallback-mobile-overlay';
  overlay.setAttribute('role', 'dialog');
  overlay.setAttribute('aria-modal', 'true');
  overlay.style.display = 'none';


/* max-width of text on page
  var panel = document.createElement('nav');
body {max-width:1366px;}
  panel.className = 'fallback-mobile-panel';
html {max-width:1366px;}
  panel.setAttribute('aria-label', 'Mobile menu');
.mw-body-content {max-width:1366px;}
  panel.setAttribute('role', 'menu');
*/


  overlay.appendChild(panel);


/* ****************** NO TITLE ON MAINPAGE *************** */
  // Close control
body.page-The_Bose_Professional_Portable_PA_Encyclopedia_FAQ_Wiki.action-view h1.firstHeading, body.page-The_Bose_Professional_Portable_PA_Encyclopedia_FAQ_Wiki.action-submit h1.firstHeading { display: none; }
  var close = document.createElement('div');
  close.className = 'fallback-mobile-close';
  close.innerHTML = '<a href="#" aria-label="Close menu">✕</a>';
  panel.appendChild(close);


  // Menu links — mirror typical Mobile-menu entries
  var links = [
    { href: mw.util.getUrl('Main_Page'), label: 'Home' },
    { href: mw.util.getUrl('Special:Search'), label: 'Search' },
    { href: mw.util.getUrl('Recentchanges'), label: 'Recent changes' },
    { href: mw.util.getUrl('Special:Random'), label: 'Random page' },
    { href: mw.util.getUrl('Special:AllPages'), label: 'All pages' },
    { href: mw.util.getUrl('Special:Categories'), label: 'Categories' },
    { href: mw.util.getUrl('Special:Upload'), label: 'Upload file' }
  ];


  links.forEach(function (lnk) {
    var a = document.createElement('a');
    a.href = lnk.href;
    a.textContent = lnk.label;
    a.setAttribute('role', 'menuitem');
    a.tabIndex = 0;
    panel.appendChild(a);
  });


/* responsive image sizing */
   document.body.appendChild(overlay);
img {
   max-width: 100%;
  height: auto;
}


/* responsive table of contents with introduction https://medium.freecodecamp.org/how-to-make-your-html-responsive-by-adding-a-single-line-of-css-2a62de81e431 */
  // Focus management helpers
    .tocdiv {
  function trapFocus(container) {
     max-width: 1366px;
     var focusable = container.querySelectorAll('a, button, [tabindex]:not([tabindex="-1"])');
    display: grid;
     if (!focusable.length) return null;
    grid-gap: 15px;
     var first = focusable[0];
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
     var last = focusable[focusable.length - 1];
     grid-template-columns: repeat(auto-fit, minmax(300px, 4fr));
     grid-template-rows: repeat(2, 300px);
     grid-template-rows: repeat(auto-fit, minmax(300px, 1fr));


 
    function handleTab(e) {
/*  responsive iframe for youtube videos */
      if (e.key !== 'Tab') return;
@media screen and (max-width: 750px) {
      if (e.shiftKey && document.activeElement === first) {
    iframe {
        e.preventDefault();
         max-width: 100% !important;
         last.focus();
         width: auto !important;
      } else if (!e.shiftKey && document.activeElement === last) {
         height: auto !important;
         e.preventDefault();
         first.focus();
      }
     }
     }
}
    document.addEventListener('keydown', handleTab);
    return function remove() { document.removeEventListener('keydown', handleTab); };
  }


/* Power Characters */
  var removeTrap = null;
@font-face {
    font-family: 'power_symbols';
    src: url('https://toonz.ca/fonts/unicode/Unicode_IEC_symbol.ttf') format('ttf'),
        url('https://toonz.ca/fonts/unicode/Unicode_IEC_symbol.woff2') format('woff2'),
        url('https://toonz.ca/fonts/unicode/Unicode_IEC_symbol.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}


.power{
  function openMenu() {
  font-family: 'power_symbols';
    overlay.style.display = 'flex';
  font-style: normal;
    document.body.style.overflow = 'hidden';
}
    btn.setAttribute('aria-expanded', 'true');
    // focus first link
    var firstLink = panel.querySelector('a');
    if (firstLink) firstLink.focus();
    removeTrap = trapFocus(panel);
  }


/* standard link colors */
  function closeMenu() {
.mw-body-content a:link { color: #0000FF; } /* normal unvisited links */
    overlay.style.display = 'none';
.mw-body-content a:link:visited { color: #0B0080; } /* visited links */
    document.body.style.overflow = '';
.mw-body-content a:link:active { color: #FF0000; } /* active links */
    btn.setAttribute('aria-expanded', 'false');
.mw-body-content a:link.new { color: #FF0000; } /* new links */
    if (removeTrap) { removeTrap(); removeTrap = null; }
.mw-body-content a:link.extiw { color: #3366BB; } /* interwiki links */
    btn.focus();
.mw-body-content a:link.external { color: #3366BB; } /* external links */
  }
.mw-body-content a:link.stub { color: #772233; } /* hovered links */


.mw-body-content a:link {color: #FF0000}
  // Event listeners
.mw-body-content a:visited {color: #00FF00}
  btn.addEventListener('click', function (e) {
.mw-body-content a:hover {color: #FF00FF}
    e.preventDefault();
.mw-body-content a:active {color: #0000FF}
    openMenu();
  });


// no right click
  overlay.addEventListener('click', function (e) {
img {
    if (e.target === overlay) closeMenu();
  -webkit-touch-callout: none;
   });
   -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}


// l1 comparison table
  close.addEventListener('click', function (e) {
    e.preventDefault();
    closeMenu();
  });


/* === L1 comparison table scroll container === */
  // Close on Escape
.mw-parser-output .l1-compare-wrap {
  document.addEventListener('keydown', function (e) {
  display: block;
    if (e.key === 'Escape' && overlay.style.display === 'flex') {
  overflow-x: auto;
      closeMenu();
   overflow-y: visible;
    }
  width: 100%;
   });
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
}


/* === CRITICAL OVERRIDE: defeat Vector/Minerva table width clamp === */
  // If viewport is resized to desktop, remove fallback elements
.mw-parser-output .l1-compare-wrap table.l1-compare {
   window.addEventListener('resize', function () {
  white-space: nowrap;
    if (window.innerWidth > 800) {
  width: max-content;
      if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
  min-width: 1400px;
      if (btn.parentNode) btn.parentNode.removeChild(btn);
  max-width: none !important;  /* ← THIS is the blocker you were hitting */
      document.body.style.overflow = '';
   border-collapse: separate;
    }
  border-spacing: 0;
   });
}
});
 
/* === Sticky header row === */
.mw-parser-output .l1-compare-wrap table.l1-compare th {
  position: sticky;
  top: 0;
  background: #f8f9fa;
  color: #202122;
  z-index: 10;
}
 
/* === Sticky first column === */
.mw-parser-output .l1-compare-wrap table.l1-compare th:first-child,
.mw-parser-output .l1-compare-wrap table.l1-compare td:first-child {
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 9;
  border-right: 1px solid #a2a9b1;
}
 
/* === Image display on hover over text === */
 
.hover-image-wrapper {
  position: relative;
  display: inline-block;
  cursor: help;
}
 
.hover-image-popup {
  position: absolute;
  top: 1.2em;
  left: 0;
  z-index: 9999;
 
  background: #fff;
  padding: 4px;
  border: 1px solid #ccc;
 
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
 
  transition: opacity 0.15s ease-in-out;
}
 
.hover-image-wrapper:hover .hover-image-popup {
  visibility: visible !important;
  opacity: 1 !important;
   pointer-events: auto !important;
}
 
body { outline: 5px solid red !important; }

Revision as of 23:21, 31 March 2026

/* MediaWiki:Common.js
   Lightweight fallback mobile menu
   Activates only when Minerva/native mobile menu is not present
*/

mw.hook('wikipage.content').add(function () {
  // Only run on narrow screens
  if (window.innerWidth > 800) return;

  // If native Minerva menu exists, do nothing
  if (document.querySelector('.minerva-menu-button, .minerva-hamburger, .mw-mobile-menu')) return;

  // Avoid injecting twice
  if (document.querySelector('.fallback-mobile-hamburger')) return;

  // Create hamburger button
  var btn = document.createElement('button');
  btn.className = 'fallback-mobile-hamburger';
  btn.type = 'button';
  btn.setAttribute('aria-label', 'Open menu');
  btn.setAttribute('aria-expanded', 'false');
  btn.innerHTML = '&#9776;';

  // Insert into header area (best-effort)
  var header = document.querySelector('.minerva-header') || document.querySelector('#mw-head') || document.body;
  try {
    header.insertBefore(btn, header.firstChild);
  } catch (e) {
    document.body.appendChild(btn);
  }

  // Create overlay and panel
  var overlay = document.createElement('div');
  overlay.className = 'fallback-mobile-overlay';
  overlay.setAttribute('role', 'dialog');
  overlay.setAttribute('aria-modal', 'true');
  overlay.style.display = 'none';

  var panel = document.createElement('nav');
  panel.className = 'fallback-mobile-panel';
  panel.setAttribute('aria-label', 'Mobile menu');
  panel.setAttribute('role', 'menu');

  overlay.appendChild(panel);

  // Close control
  var close = document.createElement('div');
  close.className = 'fallback-mobile-close';
  close.innerHTML = '<a href="#" aria-label="Close menu">✕</a>';
  panel.appendChild(close);

  // Menu links  mirror typical Mobile-menu entries
  var links = [
    { href: mw.util.getUrl('Main_Page'), label: 'Home' },
    { href: mw.util.getUrl('Special:Search'), label: 'Search' },
    { href: mw.util.getUrl('Recentchanges'), label: 'Recent changes' },
    { href: mw.util.getUrl('Special:Random'), label: 'Random page' },
    { href: mw.util.getUrl('Special:AllPages'), label: 'All pages' },
    { href: mw.util.getUrl('Special:Categories'), label: 'Categories' },
    { href: mw.util.getUrl('Special:Upload'), label: 'Upload file' }
  ];

  links.forEach(function (lnk) {
    var a = document.createElement('a');
    a.href = lnk.href;
    a.textContent = lnk.label;
    a.setAttribute('role', 'menuitem');
    a.tabIndex = 0;
    panel.appendChild(a);
  });

  document.body.appendChild(overlay);

  // Focus management helpers
  function trapFocus(container) {
    var focusable = container.querySelectorAll('a, button, [tabindex]:not([tabindex="-1"])');
    if (!focusable.length) return null;
    var first = focusable[0];
    var last = focusable[focusable.length - 1];

    function handleTab(e) {
      if (e.key !== 'Tab') return;
      if (e.shiftKey && document.activeElement === first) {
        e.preventDefault();
        last.focus();
      } else if (!e.shiftKey && document.activeElement === last) {
        e.preventDefault();
        first.focus();
      }
    }
    document.addEventListener('keydown', handleTab);
    return function remove() { document.removeEventListener('keydown', handleTab); };
  }

  var removeTrap = null;

  function openMenu() {
    overlay.style.display = 'flex';
    document.body.style.overflow = 'hidden';
    btn.setAttribute('aria-expanded', 'true');
    // focus first link
    var firstLink = panel.querySelector('a');
    if (firstLink) firstLink.focus();
    removeTrap = trapFocus(panel);
  }

  function closeMenu() {
    overlay.style.display = 'none';
    document.body.style.overflow = '';
    btn.setAttribute('aria-expanded', 'false');
    if (removeTrap) { removeTrap(); removeTrap = null; }
    btn.focus();
  }

  // Event listeners
  btn.addEventListener('click', function (e) {
    e.preventDefault();
    openMenu();
  });

  overlay.addEventListener('click', function (e) {
    if (e.target === overlay) closeMenu();
  });

  close.addEventListener('click', function (e) {
    e.preventDefault();
    closeMenu();
  });

  // Close on Escape
  document.addEventListener('keydown', function (e) {
    if (e.key === 'Escape' && overlay.style.display === 'flex') {
      closeMenu();
    }
  });

  // If viewport is resized to desktop, remove fallback elements
  window.addEventListener('resize', function () {
    if (window.innerWidth > 800) {
      if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
      if (btn.parentNode) btn.parentNode.removeChild(btn);
      document.body.style.overflow = '';
    }
  });
});