MediaWiki:Common.js/User:Bawolff/sandbox/alt citations

From Wikinews, the free news source you can write!
Jump to: navigation, search

/* See User:Bawolff/sandbox/alt citations Basically converts inline ref style citations, to non-inline wikinews citations one hit button in sidebar Depends on MediaWiki:Common.css/User:Bawolff/sandbox/alt citations

  • /

//

 1 //Function that switches source style
 2 function toggleSources() {
 3     var container = document.getElementById("no-source-toggle");
 4     if (!container || !container.className) {
 5         throw new Error("Can't find the container div for the inline source toggle");
 6     }
 7     if (container.className === "no-inline-sources") {
 8         container.className = "show-inline-sources";
 9     } else if (container.className === "show-inline-sources") {
10         container.className = "no-inline-sources";
11     } else {
12         throw new Error("inline source toggle container has invalid class");
13     }
14     return (void 0);
15 }
16 
17 //Add toggle button to toolbar if container div detected
18 toggleSources.init = function() {
19     if (document.getElementById("no-source-toggle")) {
20         addPortletLink("p-tb", "javascript:toggleSources();", "Toggle inline sources", "t-toggle-inline-source-button", "Show or hide inline source information");
21     }
22 
23 }
24 addOnloadHook(toggleSources.init);
25 //