MediaWiki:Common.js: Difference between revisions
Jump to navigation
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
/ * Any JavaScript here will be loaded for all users on every page load. * / | |||
document.write ("<script src='/index.php?title=Global.js&action=raw&smaxage=0&ctype=text/javascript' type='text/javascript'> </ script>"); | |||
importScript_ = import script | |||
/ / Makes the sidebar foldable (by Menidan) | / / Makes the sidebar foldable (by Menidan) | ||
sidebar_settings var = JSON.parse (localStorage.getItem ("sidebar_settings")) | | {}; | sidebar_settings var = JSON.parse (localStorage.getItem ("sidebar_settings")) | | {}; |
Revision as of 12:24, 1 November 2013
/ * Any JavaScript here will be loaded for all users on every page load. * / document.write ("<script src='/index.php?title=Global.js&action=raw&smaxage=0&ctype=text/javascript' type='text/javascript'> </ script>"); importScript_ = import script / / Makes the sidebar foldable (by Menidan) sidebar_settings var = JSON.parse (localStorage.getItem ("sidebar_settings")) | | {}; save_sidebar function () { localStorage.setItem ("sidebar_settings", JSON.stringify (sidebar_settings)); } set_sidebar function (id, folded) { if (document.getElementById (id). parentElement.id! = "column-one") return; if (folded) sidebar_settings [id] = true; else sidebar_settings delete [id]; save_sidebar (); } var fold = "http://wiki.de.grepolis.com/images/7/7e/Einklappen.png"; unfold var = "http://wiki.de.grepolis.com/images/0/06/Ausklappen.png"; sidebar_click function (node) { var content = $ (node.parentElement.lastElementChild); if (content.css ("display") == "none") { content.css ("display", "block"); node.firstElementChild.alt = "[-]"; node.firstElementChild.src = fold; set_sidebar (node.parentElement.id, false); Else {} content.css ("display", "none"); node.firstElementChild.alt = "[+]"; node.firstElementChild.src = unfold; set_sidebar (node.parentElement.id, true); } return false; } sidebar_links var = $ ("# column-one. generated sidebar.portlet-h5"). Slice (1). replaceWith (function () { if (sidebar_settings [this.parentElement.id]) return $ ('<a href="#" style="text-align:center"> <img src="' + fold +'" style="float:left" alt="[-]" /> <h5 > '+ this.innerHTML +' </ h5> </ a> '). click (function () { sidebar_click return (this); }); . $ (This.nextElementSibling) css ("display", "none"); return $ ('<a href="#" style="text-align:center"> <img src="' + unfold +'" style="float:left" alt="[+]" /> <h5 > '+ this.innerHTML +' </ h5> </ a> '). click (function () { sidebar_click return (this); }); }); console.log ("sidebar ready");