From: Timo Tijhof Date: Thu, 13 Dec 2012 06:17:31 +0000 (+0100) Subject: (bug 43052) dblClickEdit/rightClickEdit: Trigger ca-edit click. X-Git-Tag: 1.31.0-rc.0~21031^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=c407aa09b174dc64b54ffadbdf9146f9c9709bb8;p=lhc%2Fweb%2Fwiklou.git (bug 43052) dblClickEdit/rightClickEdit: Trigger ca-edit click. To test, enable these preferences under "Editing": * Enable section editing by right clicking on section titles * Edit pages on double click Change-Id: Ie8a35700bc9e74b24f234ea682ad25375e18bda4 --- diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index e5e5c6880e..556f0fa10a 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -1,4 +1,3 @@ - Security reminder: MediaWiki does not require PHP's register_globals. If you have it on, turn it '''off''' if you can. @@ -133,6 +132,8 @@ production. * (bug 39062) Special:Contributions will display changes that don't have a parent id instead of just an empty bullet item. * wfMerge() now works if $wgDiff3 contains spaces +* (bug 43052) mediawiki.action.view.dblClickEdit.dblClickEdit should trigger + ca-edit click instead opening URL directly. === API changes in 1.21 === * prop=revisions can now report the contentmodel and contentformat. diff --git a/resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js b/resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js index 7a9ceee577..c15fa0d90c 100644 --- a/resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js +++ b/resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js @@ -2,13 +2,9 @@ * This module enables double-click-to-edit functionality */ ( function ( mw, $ ) { - $( function () { - var url = $( '#ca-edit a' ).attr( 'href' ); - if ( url ) { - mw.util.$content.dblclick( function ( e ) { - e.preventDefault(); - window.location = url; - } ); - } + mw.util.$content.dblclick( function ( e ) { + e.preventDefault(); + // Trigger native HTMLElement click instead of opening URL (bug 43052) + $( '#ca-edit a' ).get( 0 ).click(); } ); }( mediaWiki, jQuery ) ); diff --git a/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js b/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js index d02d43273e..61d9d15031 100644 --- a/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js +++ b/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js @@ -1,4 +1,4 @@ -/* +/** * JavaScript to enable right click edit functionality. * When the user right-clicks in a heading, it will open the * edit screen. @@ -8,23 +8,19 @@ jQuery( function ( $ ) { // Don't use the ":has:(.editsection a)" selector because it performs very bad. // http://jsperf.com/jq-1-7-2-vs-jq-1-8-1-performance-of-mw-has/2 $( document ).on( 'contextmenu', 'h1, h2, h3, h4, h5, h6', function ( e ) { - var $edit, href; - - $edit = $( this ).find( '.editsection a' ); + var $edit = $( this ).find( '.editsection a' ); if ( !$edit.length ) { return; } - // Get href of the editsection link - href = $edit.prop( 'href' ); - // Headings can contain rich text. // Make sure to not block contextmenu events on (other) anchor tags // inside the heading (e.g. to do things like copy URL, open in new tab, ..). // e.target can be the heading, but it can also be anything inside the heading. - if ( href && e.target.nodeName.toLowerCase() !== 'a' ) { - window.location = href; + if ( e.target.nodeName.toLowerCase() !== 'a' ) { + // Trigger native HTMLElement click instead of opening URL (bug 43052) e.preventDefault(); + $edit.get( 0 ).click(); } } ); } );