Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -461,53 +461,6 @@ |
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | | -function setupRightClickEdit() { |
466 | | - if (document.getElementsByTagName) { |
467 | | - var spans = document.getElementsByTagName('span'); |
468 | | - for (var i = 0; i < spans.length; i++) { |
469 | | - var el = spans[i]; |
470 | | - if(el.className == 'editsection') { |
471 | | - addRightClickEditHandler(el); |
472 | | - } |
473 | | - } |
474 | | - } |
475 | | -} |
476 | | - |
477 | | -function addRightClickEditHandler(el) { |
478 | | - for (var i = 0; i < el.childNodes.length; i++) { |
479 | | - var link = el.childNodes[i]; |
480 | | - if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { |
481 | | - var editHref = link.getAttribute('href'); |
482 | | - // find the enclosing (parent) header |
483 | | - var prev = el.parentNode; |
484 | | - if (prev && prev.nodeType == 1 && |
485 | | - prev.nodeName.match(/^[Hh][1-6]$/)) { |
486 | | - prev.oncontextmenu = function(e) { |
487 | | - if (!e) { e = window.event; } |
488 | | - // e is now the event in all browsers |
489 | | - var targ; |
490 | | - if (e.target) { targ = e.target; } |
491 | | - else if (e.srcElement) { targ = e.srcElement; } |
492 | | - if (targ.nodeType == 3) { // defeat Safari bug |
493 | | - targ = targ.parentNode; |
494 | | - } |
495 | | - // targ is now the target element |
496 | | - |
497 | | - // We don't want to deprive the noble reader of a context menu |
498 | | - // for the section edit link, do we? (Might want to extend this |
499 | | - // to all <a>'s?) |
500 | | - if (targ.nodeName.toLowerCase() != 'a' |
501 | | - || targ.parentNode.className != 'editsection') { |
502 | | - document.location = editHref; |
503 | | - return false; |
504 | | - } |
505 | | - return true; |
506 | | - }; |
507 | | - } |
508 | | - } |
509 | | - } |
510 | | -} |
511 | | - |
512 | 465 | var checkboxes; |
513 | 466 | var lastCheckbox; |
514 | 467 | |
Index: trunk/phase3/skins/common/rightclickedit.js |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +function setupRightClickEdit() { |
| 3 | + if (document.getElementsByTagName) { |
| 4 | + var spans = document.getElementsByTagName('span'); |
| 5 | + for (var i = 0; i < spans.length; i++) { |
| 6 | + var el = spans[i]; |
| 7 | + if(el.className == 'editsection') { |
| 8 | + addRightClickEditHandler(el); |
| 9 | + } |
| 10 | + } |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +function addRightClickEditHandler(el) { |
| 15 | + for (var i = 0; i < el.childNodes.length; i++) { |
| 16 | + var link = el.childNodes[i]; |
| 17 | + if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { |
| 18 | + var editHref = link.getAttribute('href'); |
| 19 | + // find the enclosing (parent) header |
| 20 | + var prev = el.parentNode; |
| 21 | + if (prev && prev.nodeType == 1 && |
| 22 | + prev.nodeName.match(/^[Hh][1-6]$/)) { |
| 23 | + prev.oncontextmenu = function(e) { |
| 24 | + if (!e) { e = window.event; } |
| 25 | + // e is now the event in all browsers |
| 26 | + var targ; |
| 27 | + if (e.target) { targ = e.target; } |
| 28 | + else if (e.srcElement) { targ = e.srcElement; } |
| 29 | + if (targ.nodeType == 3) { // defeat Safari bug |
| 30 | + targ = targ.parentNode; |
| 31 | + } |
| 32 | + // targ is now the target element |
| 33 | + |
| 34 | + // We don't want to deprive the noble reader of a context menu |
| 35 | + // for the section edit link, do we? (Might want to extend this |
| 36 | + // to all <a>'s?) |
| 37 | + if (targ.nodeName.toLowerCase() != 'a' |
| 38 | + || targ.parentNode.className != 'editsection') { |
| 39 | + document.location = editHref; |
| 40 | + return false; |
| 41 | + } |
| 42 | + return true; |
| 43 | + }; |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +hookEvent("load", setupRightClickEdit); |
Property changes on: trunk/phase3/skins/common/rightclickedit.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 50 | + native |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -794,6 +794,10 @@ |
795 | 795 | $this->addScriptFile( 'mwsuggest.js' ); |
796 | 796 | } |
797 | 797 | } |
| 798 | + |
| 799 | + if( $wgUser->getBoolOption( 'editsectiononrightclick' ) ) { |
| 800 | + $this->addScriptFile( 'rightclickedit.js' ); |
| 801 | + } |
798 | 802 | |
799 | 803 | |
800 | 804 | # Buffer output; final headers may depend on later processing |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -436,11 +436,7 @@ |
437 | 437 | } else { |
438 | 438 | $tpl->set('body_ondblclick', false); |
439 | 439 | } |
440 | | - if( $this->iseditable && $wgUser->getOption( 'editsectiononrightclick' ) ) { |
441 | | - $tpl->set( 'body_onload', 'setupRightClickEdit()' ); |
442 | | - } else { |
443 | | - $tpl->set( 'body_onload', false ); |
444 | | - } |
| 440 | + $tpl->set( 'body_onload', false ); |
445 | 441 | $tpl->set( 'sidebar', $this->buildSidebar() ); |
446 | 442 | $tpl->set( 'nav_urls', $this->buildNavUrls() ); |
447 | 443 | |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -544,12 +544,6 @@ |
545 | 545 | |
546 | 546 | } |
547 | 547 | $a['onload'] = $wgOut->getOnloadHandler(); |
548 | | - if( $wgUser->getOption( 'editsectiononrightclick' ) ) { |
549 | | - if( $a['onload'] != '' ) { |
550 | | - $a['onload'] .= ';'; |
551 | | - } |
552 | | - $a['onload'] .= 'setupRightClickEdit()'; |
553 | | - } |
554 | 548 | $a['class'] = |
555 | 549 | 'mediawiki ns-'.$wgTitle->getNamespace(). |
556 | 550 | ' '.($wgContLang->isRTL() ? "rtl" : "ltr"). |