collapsible elements
Tag: Reverted
fix maybe
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
// I wasn't totally satisfied with MediaWiki's built-in way to make collapsible elements, so here is an alternative implementation I made.
// I wasn't totally satisfied with MediaWiki's built-in way to make collapsible elements, so here is an alternative implementation I made.
function customcollapseShow(jQueryObj) {
function customcollapseShow(jQueryObj) {
let container = $(jQueryObj).parents(".customcollapse");
var container = $(jQueryObj).parents(".customcollapse");
container.find(".customcollapse-content").show();
container.find(".customcollapse-content").show();
container.find(".customcollapse-show").hide().removeAttr("aria-expanded");
container.find(".customcollapse-show").hide().removeAttr("aria-expanded");
Line 15: Line 15:


function customcollapseHide(jQueryObj) {
function customcollapseHide(jQueryObj) {
let container = $(jQueryObj).parents(".customcollapse");
var container = $(jQueryObj).parents(".customcollapse");
container.find(".customcollapse-content").hide();
container.find(".customcollapse-content").hide();
container.find(".customcollapse-hide").hide().removeAttr("aria-expanded");
container.find(".customcollapse-hide").hide().removeAttr("aria-expanded");
Line 46: Line 46:
// For toggles, changing the element to a <button>. This necessitates removing the element and adding it back again
// For toggles, changing the element to a <button>. This necessitates removing the element and adding it back again
$(this).addClass("plainbutton");
$(this).addClass("plainbutton");
let innerHtml = this.innerHTML;
var innerHtml = this.innerHTML;
let attributes = this.attributes;
var attributes = this.attributes;
let btn = document.createElement("button");
var btn = document.createElement("button");
btn.innerHTML = innerHtml;
btn.innerHTML = innerHtml;
for (let attr of attributes) {
for (var i = 0; i < attributes.length; i++) {
btn.attributes.setNamedItem(attr.cloneNode());
btn.attributes.setNamedItem(attributes[i].cloneNode());
}
}
$(this).replaceWith(btn);
$(this).replaceWith(btn);