MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 113: Line 113:
   document.getElementById(col_name).value="hide";
   document.getElementById(col_name).value="hide";
  }
  }
}
/* ======================================= Template:Drawer ======================================= */
for (i = 1; i < 100; i++) {
if (document.getElementById('drawer'+i)) {
document.getElementById('drawer'+i).addEventListener('click', function(){ drawerExpand(i); } );
}
}
function drawerExpand(x) {
  var y = "drawer-"+x; //outputs something like "drawer-1"
  var z = document.getElementById(y); //outputs something like document.getElementById("drawer-1")
  var a = "drawer-button-"+x; //outputs something like "drawer-button-1"
  var b = document.getElementById(a); //outputs something like document.getElementById("drawer-button-1")
  if (z.style.display === "block") {
    z.style.display = "none";
b.innerHTML = "Expand";
  } else {
    z.style.display = "block";
    b.innerHTML = "Collapse";
  }
}
}