r76973 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76972‎ | r76973 | r76974 >
Date:22:03, 18 November 2010
Author:tparscal
Status:ok
Tags:
Comment:
Cleaned up the code a bit, and added a return false to prevent other bindings from being fired.
Modified paths:
  • /trunk/phase3/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js (added) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js
@@ -0,0 +1,24 @@
 2+/*
 3+ * JavaScript to enable right click edit functionality
 4+ */
 5+$( function() {
 6+ // Select all h1-h6 elements that contain editsection links
 7+ $( 'h1:has(.editsection a), ' +
 8+ 'h2:has(.editsection a), ' +
 9+ 'h3:has(.editsection a), ' +
 10+ 'h4:has(.editsection a), ' +
 11+ 'h5:has(.editsection a), ' +
 12+ 'h6:has(.editsection a)'
 13+ ).live( 'contextmenu', function( e ) {
 14+ // Get href of the [edit] link
 15+ var href = $(this).find( '.editsection a' ).attr( 'href' );
 16+ // Check if target is the anchor link itself. If so, don't suppress the context menu; this
 17+ // way the reader can still do things like copy URL, open in new tab etc.
 18+ $target = $( e.target );
 19+ if ( !$target.is( 'a' ) && !$target.parent().is( '.editsection' ) ){
 20+ window.location = href;
 21+ e.preventDefault();
 22+ return false;
 23+ }
 24+ } );
 25+} );
Property changes on: trunk/phase3/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js
___________________________________________________________________
Added: svn:eol-style
126 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r77643Followup r76973: keep $target variable localcatrope12:46, 3 December 2010

Status & tagging log