1 function setupRightClickEdit() {
2 if (document
.getElementsByTagName
) {
3 var spans
= document
.getElementsByTagName('span');
4 for (var i
= 0; i
< spans
.length
; i
++) {
6 if(el
.className
== 'editsection') {
7 addRightClickEditHandler(el
);
13 function addRightClickEditHandler(el
) {
14 for (var i
= 0; i
< el
.childNodes
.length
; i
++) {
15 var link
= el
.childNodes
[i
];
16 if (link
.nodeType
== 1 && link
.nodeName
.toLowerCase() == 'a') {
17 var editHref
= link
.getAttribute('href');
18 // find the enclosing (parent) header
19 var prev
= el
.parentNode
;
20 if (prev
&& prev
.nodeType
== 1 &&
21 prev
.nodeName
.match(/^[Hh][1-6]$/)) {
22 prev
.oncontextmenu = function(e
) {
23 if (!e
) { e
= window
.event
; }
24 // e is now the event in all browsers
26 if (e
.target
) { targ
= e
.target
; }
27 else if (e
.srcElement
) { targ
= e
.srcElement
; }
28 if (targ
.nodeType
== 3) { // defeat Safari bug
29 targ
= targ
.parentNode
;
31 // targ is now the target element
33 // We don't want to deprive the noble reader of a context menu
34 // for the section edit link, do we? (Might want to extend this
36 if (targ
.nodeName
.toLowerCase() != 'a'
37 || targ
.parentNode
.className
!= 'editsection') {
38 document
.location
= editHref
;
48 hookEvent("load", setupRightClickEdit
);