r34559 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34558‎ | r34559 | r34560 >
Date:09:40, 10 May 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Partly revert 34542, broke my section editing
Modified paths:
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -461,6 +461,53 @@
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+
465512 var checkboxes;
466513 var lastCheckbox;
467514

Follow-up revisions

RevisionCommit summaryAuthorDate
r34697Revert r34559 and fix r34542 -- include rightclickedit.js for 'edit on right ...brion23:37, 12 May 2008

Status & tagging log