MediaWiki

Group-Grouse.js: Difference between revisions

From Grouse House Wiki

No edit summary
No edit summary
Line 125: Line 125:
/* Testing */
/* Testing */


$(function() {
/* style the expandable's button */
   const headings = document.querySelectorAll('h2');
[data-expandable] {
    
   display: block;
   Array.prototype.forEach.call(headings, h => {
  width: 100%;
    let btn = h.querySelector('button');
  text-align: left;
    let target = h.nextElementSibling;
  background: #293352;
   
  border: 0;
    btn.onclick = () => {
   color: #fff;
      let expanded = btn.getAttribute('aria-expanded') === 'true';
   padding: 0.25em 0.5em;
     
  margin-bottom: 0.25em;
      btn.setAttribute('aria-expanded', !expanded);
}
      target.hidden = expanded;
 
    }
/* make sure there is a focus style for keyboard accessibility */
  });
[data-expandable]:focus {
})()
  outline: 2px solid #005C9C;
  outline-offset: 1px;
}
 
/* the arrow using pseudo-content and unicode */
[data-expandable][aria-expanded="false"]::before {
  content: '\25b8\0020';
}
/* the arrow for the expanded state using pseudo-content and unicode */
[data-expandable][aria-expanded="true"]::before {
  content: '\25bE\0020';
}
 
/* pair visual appearance with accessible state  */
.expandable[aria-hidden="true"] {
  display: none;
}
 
h3 {
font-size: 1em !important;
}

Revision as of 22:25, 18 February 2024


$(function() {
    $('h2.c-header.active span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

        var $secondheader = "#" + $headernameu + "_2";

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h2.c-header.hidden span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

        var $secondheader = "#" + $headernameu + "_2";

        var $editsection = $( $secondheader ).next().children('a').attr("href");
        
        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        $("a[href='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h2.h-static span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

        var $secondheader = "#" + $headernameu + "_2";

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        var $pagename = $('h1#firstHeading').html();
        $pagenameu = $pagename.split(' ').join('_');
        
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h3.c-header.active span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

        var $secondheader = "#" + $headernameu + "_2";

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h3.c-header.hidden span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

        var $secondheader = "#" + $headernameu + "_2";

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        var $pagename = $('h1#firstHeading').html();
        $pagenameu = $pagename.split(' ').join('_');
        
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

$(function() {
    $('h3.h-static span.mw-headline').each(function () {
        var $header = $(this);
        var $headername = $header.html();
        $headernameu = $headername.split(' ').join('_');
$headernameu = $headernameu.replace("'", "\\'").replace("?", "\\?").replace("!", "\\!");

        var $secondheader = "#" + $headernameu + "_2";

        var $editsection = $( $secondheader ).next().children('a').attr("href");

        $header.after('[Edit]');
        $header.next().css( 'font-size', '0.6em').css( 'margin-left', '1em');

        var $pagename = $('h1#firstHeading').html();
        $pagenameu = $pagename.split(' ').join('_');
        
        $toclink = "https://grousehouse.wiki/" + $pagenameu + $secondheader;

        $("a[href*='" + $secondheader + "']").hide();
    });
 });

/* Testing */

/* style the expandable's button */
[data-expandable] {
  display: block;
  width: 100%;
  text-align: left;
  background: #293352;
  border: 0;
  color: #fff;
  padding: 0.25em 0.5em;
  margin-bottom: 0.25em;
}

/* make sure there is a focus style for keyboard accessibility */
[data-expandable]:focus {
  outline: 2px solid #005C9C;
  outline-offset: 1px;
}

/* the arrow using pseudo-content and unicode */
[data-expandable][aria-expanded="false"]::before {
  content: '\25b8\0020';
}
/* the arrow for the expanded state using pseudo-content and unicode */
[data-expandable][aria-expanded="true"]::before {
  content: '\25bE\0020';
}

/* pair visual appearance with accessible state  */
.expandable[aria-hidden="true"] {
  display: none;
}

h3 {
font-size: 1em !important;
}