r34697 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34696‎ | r34697 | r34698 >
Date:23:37, 12 May 2008
Author:brion
Status:old
Tags:
Comment:
Revert r34559 and fix r34542 -- include rightclickedit.js for 'edit on right click' pref, must have forgot to finish it up before commit :D
Modified paths:
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/skins/common/rightclickedit.js (added) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -461,53 +461,6 @@
462462 }
463463 }
464464
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 -
512465 var checkboxes;
513466 var lastCheckbox;
514467
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
150 + native
Index: trunk/phase3/includes/OutputPage.php
@@ -794,6 +794,10 @@
795795 $this->addScriptFile( 'mwsuggest.js' );
796796 }
797797 }
 798+
 799+ if( $wgUser->getBoolOption( 'editsectiononrightclick' ) ) {
 800+ $this->addScriptFile( 'rightclickedit.js' );
 801+ }
798802
799803
800804 # Buffer output; final headers may depend on later processing
Index: trunk/phase3/includes/SkinTemplate.php
@@ -436,11 +436,7 @@
437437 } else {
438438 $tpl->set('body_ondblclick', false);
439439 }
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 );
445441 $tpl->set( 'sidebar', $this->buildSidebar() );
446442 $tpl->set( 'nav_urls', $this->buildNavUrls() );
447443
Index: trunk/phase3/includes/Skin.php
@@ -544,12 +544,6 @@
545545
546546 }
547547 $a['onload'] = $wgOut->getOnloadHandler();
548 - if( $wgUser->getOption( 'editsectiononrightclick' ) ) {
549 - if( $a['onload'] != '' ) {
550 - $a['onload'] .= ';';
551 - }
552 - $a['onload'] .= 'setupRightClickEdit()';
553 - }
554548 $a['class'] =
555549 'mediawiki ns-'.$wgTitle->getNamespace().
556550 ' '.($wgContLang->isRTL() ? "rtl" : "ltr").

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r34542Revert r34541 for the moment pending further review & discussion...brion23:52, 9 May 2008
r34559* Partly revert 34542, broke my section editingnikerabbit09:40, 10 May 2008

Status & tagging log