MediaWiki:Gadget-TemplateScript.js: Difference between revisions

MediaWiki interface page
(Undo revision 9359 by Timothy (talk))
Tag: Undo
No edit summary
Tag: Reverted
Line 11: Line 11:
forActions: '*',
forActions: '*',
script: function myFunction() {
script: function myFunction() {
  var x = document.getElementsByClassName("ts-inner");
var toggleWidth = containers[0].style.maxWidth === "none" ? "15em" : "none";
  for (i in x) {
 
  if (x[i].style.maxWidth === "none") {
     sessionStorage.setItem("setToggleWidth", toggleWidth);
     x[i].style.maxWidth = "115em";
    
   } else {
  for (let container of containers) {
    x[i].style.maxWidth = "none";
      container.style.maxWidth = toggleWidth;  
  }
  }
}
 
}
}
});
});
});
});
// </nowiki>
// </nowiki>

Revision as of 14:11, 14 July 2023

/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @update-token [[File:Pathoschild/templatescript.js]]
 */
// <nowiki>
mw.config.set('userjs-templatescript', { regexEditor: false });
$.ajax('//themidnight.wiki/templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add({
	name:'Toggle width',
	forActions: '*',
	script: function myFunction() {
var toggleWidth = containers[0].style.maxWidth === "none" ? "15em" : "none";
  
    sessionStorage.setItem("setToggleWidth", toggleWidth);
  
   for (let container of containers) {
      container.style.maxWidth = toggleWidth; 
   }

}
});
});
// </nowiki>