r75795 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75794‎ | r75795 | r75796 >
Date:15:32, 1 November 2010
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
Follow-up r75762
Modified paths:
  • /trunk/phase3/resources/mediawiki.advanced/mediawiki.advanced.rightclickedit.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.advanced/mediawiki.advanced.rightclickedit.js
@@ -1,19 +1,22 @@
22 /*
33 * JavaScript to enable right click edit functionality
44 */
 5+$( function() {
56
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 ) {
89
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' );
1112
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+ }
1920
 21+ });
 22+
2023 });
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75762Adding mediawiki.advanced.rightclickedit.js...krinkle23:42, 31 October 2010

Comments

#Comment by Siebrand (talk | contribs)   15:42, 1 November 2010

If you follow up a rev, or address CR comments from another rev, can you please also note in the commit summary what it is you did to the code? Thanks.

#Comment by Krinkle (talk | contribs)   15:50, 1 November 2010

Sure Siebrand, my bad.

This is a follow up on r75762 CR comments.

  • Changed binding to live() to support dynamically added headings.
  • Wrapped code to not execute untill document ready

Status & tagging log