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 |
1 | 26 | + native |