Index: trunk/phase3/resources/mediawiki.advanced/mediawiki.advanced.rightclickedit.js |
— | — | @@ -1,19 +1,22 @@ |
2 | 2 | /* |
3 | 3 | * JavaScript to enable right click edit functionality |
4 | 4 | */ |
| 5 | +$( function() { |
5 | 6 | |
6 | | -// Select all h1-h6 elements that contain editsection links |
7 | | -$('h1, h2, h3, h4, h5, h6').filter( ':has(.editsection a)' ).bind( 'contextmenu', function( e ) { |
| 7 | + // Select all h1-h6 elements that contain editsection links |
| 8 | + $('h1:has(.editsection a), h2:has(.editsection a), h3:has(.editsection a), h4:has(.editsection a), h5:has(.editsection a), h6:has(.editsection a)').live( 'contextmenu', function( e ) { |
8 | 9 | |
9 | | - // Get href of the [edit] link |
10 | | - var href = $(this).find( '.editsection a' ).attr( 'href' ); |
| 10 | + // Get href of the [edit] link |
| 11 | + var href = $(this).find( '.editsection a' ).attr( 'href' ); |
11 | 12 | |
12 | | - // Check if target is the anchor link itself. If so, dont supress the contextmenu |
13 | | - // So that the reader can still do things like copy url, open in new tab etc. |
14 | | - $target = $( e.target ); |
15 | | - if( !$target.is( 'a' ) && !$target.parent().is( '.editsection' ) ){ |
16 | | - window.location = href; |
17 | | - e.preventDefault(); |
18 | | - } |
| 13 | + // Check if target is the anchor link itself. If so, dont supress the contextmenu |
| 14 | + // So that the reader can still do things like copy url, open in new tab etc. |
| 15 | + $target = $( e.target ); |
| 16 | + if( !$target.is( 'a' ) && !$target.parent().is( '.editsection' ) ){ |
| 17 | + window.location = href; |
| 18 | + e.preventDefault(); |
| 19 | + } |
19 | 20 | |
| 21 | + }); |
| 22 | + |
20 | 23 | }); |
\ No newline at end of file |