From: Niklas Laxström Date: Sat, 10 May 2008 09:40:26 +0000 (+0000) Subject: * Partly revert 34542, broke my section editing X-Git-Tag: 1.31.0-rc.0~47752 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=65f4e6999a235d62e41b9e64c606f73b3dccd30c;p=lhc%2Fweb%2Fwiklou.git * Partly revert 34542, broke my section editing --- diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 812710b73d..839e624523 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -461,6 +461,53 @@ function akeytt( doId ) { } } +function setupRightClickEdit() { + if (document.getElementsByTagName) { + var spans = document.getElementsByTagName('span'); + for (var i = 0; i < spans.length; i++) { + var el = spans[i]; + if(el.className == 'editsection') { + addRightClickEditHandler(el); + } + } + } +} + +function addRightClickEditHandler(el) { + for (var i = 0; i < el.childNodes.length; i++) { + var link = el.childNodes[i]; + if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { + var editHref = link.getAttribute('href'); + // find the enclosing (parent) header + var prev = el.parentNode; + if (prev && prev.nodeType == 1 && + prev.nodeName.match(/^[Hh][1-6]$/)) { + prev.oncontextmenu = function(e) { + if (!e) { e = window.event; } + // e is now the event in all browsers + var targ; + if (e.target) { targ = e.target; } + else if (e.srcElement) { targ = e.srcElement; } + if (targ.nodeType == 3) { // defeat Safari bug + targ = targ.parentNode; + } + // targ is now the target element + + // We don't want to deprive the noble reader of a context menu + // for the section edit link, do we? (Might want to extend this + // to all 's?) + if (targ.nodeName.toLowerCase() != 'a' + || targ.parentNode.className != 'editsection') { + document.location = editHref; + return false; + } + return true; + }; + } + } + } +} + var checkboxes; var lastCheckbox;