User:Splarka/popupmenu.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
// <nowiki> var ns6 = document.getElementById&&!document.all var isMenu = false ; var menuSelObj = null ; var overpopupmenu = false; // add new talk page macros here, somewhat intuitive, Keep it all in the div tag, ('\<br\>') for new lines. document.writeln('<div class="pBody" id="menudiv" style="position:absolute; display:none; top:0px; left:0px;z-index:10000;">'); document.write('<a OnClick="javascript:hidepop();" href="javascript:addtem(\'{{User:Bookofjude/block}}\')">Default</a> '); document.write('<a OnClick="javascript:hidepop();" href="javascript:addtem(\'{{User:Bookofjude/block|x=ind}}\')">Indefinitely!</a> '); document.writeln('\<br\>'); document.write('<a OnClick="javascript:hidepop();" href="javascript:addtem(\'{{User:Bookofjude/block|r=v}}\')">For vandalism</a> '); document.writeln('</div>'); function mainpop() { addmacros(); } function addmacros() { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlilink(tabs, 'javascript:function() {}', 'block template', 'ca-macro'); document.getElementById('ca-macro').onclick=showpop; } function addlilink(tabs, url, name, id) { var na = document.createElement('a'); na.href = url; na.id = id; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); tabs.appendChild(li); return li; } function showpop(e) { var posx = 0; var posy = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft; posy = e.clientY + document.body.scrollTop; } var obj = ns6 ? e.target.parentNode : event.srcElement.parentElement; menuSelObj = obj ; if (ns6) { document.getElementById('menudiv').style.left = posx +"px"; document.getElementById('menudiv').style.top = posy +"px"; } else { document.getElementById('menudiv').style.pixelLeft = posx +"px"; document.getElementById('menudiv').style.pixelTop = posy +"px"; } document.getElementById('menudiv').style.display = ""; document.getElementById('menudiv').style.backgroundColor='#FFFFFF'; } function hidepop() { document.getElementById('menudiv').style.display = "none"; document.getElementById('menudiv').style.backgroundColor='#000000'; } function addtem(blocktemplate) { document.editform.wpSummary.value = '+blocktemplate'; document.editform.wpTextbox1.value += "\n" + blocktemplate; } window.addEventListener("load", mainpop, false); // </nowiki>