diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2020-06-08 17:43:43 +0100 |
---|---|---|
committer | Timo Tijhof <krinklemail@gmail.com> | 2020-06-08 17:45:18 +0100 |
commit | d6f0cd0643d3a66e66c38d35e64c311c6ef1e6e0 (patch) | |
tree | bdc355ad59166174b959e66657cdb3d912b3c773 /resources/src/mediawiki.misc-authed-pref | |
parent | 26095750d5369b424b13906dffdde01aea26c25e (diff) | |
download | mediawikicore-d6f0cd0643d3a66e66c38d35e64c311c6ef1e6e0.tar.gz mediawikicore-d6f0cd0643d3a66e66c38d35e64c311c6ef1e6e0.zip |
mediawiki.misc-authed-pref: Limit dblClickEdit to 'view' action
Follows-up c656980498, which led to this also being loaded when
the rightClickEdit feature is loaded (which is loaded on all actions).
It's a tiny opt-in script so no issue there, but we do need to make
sure it's self-contained in terms of what it is meant to do, and not
rely purely on when it is included in a bundle send to the client.
Change-Id: Ie13a4de90c0ef3cc6673bd352bc25d1e02df8dc4
Diffstat (limited to 'resources/src/mediawiki.misc-authed-pref')
-rw-r--r-- | resources/src/mediawiki.misc-authed-pref/dblClickEdit.js | 9 | ||||
-rw-r--r-- | resources/src/mediawiki.misc-authed-pref/rightClickEdit.js | 3 |
2 files changed, 10 insertions, 2 deletions
diff --git a/resources/src/mediawiki.misc-authed-pref/dblClickEdit.js b/resources/src/mediawiki.misc-authed-pref/dblClickEdit.js index 6815433af689..7943a11ac712 100644 --- a/resources/src/mediawiki.misc-authed-pref/dblClickEdit.js +++ b/resources/src/mediawiki.misc-authed-pref/dblClickEdit.js @@ -2,9 +2,16 @@ * Enable double-click-to-edit functionality. */ ( function () { - if ( !parseInt( mw.user.options.get( 'editondblclick' ), 10 ) ) { + if ( Number( mw.user.options.get( 'editondblclick' ) ) !== 1 ) { + // Support both 1 or "1" (T54542) return; } + + if ( mw.config.get( 'wgAction' ) !== 'view' ) { + // Only trigger during view action. + return; + } + $( function () { $( '#mw-content-text' ).on( 'dblclick', function ( e ) { // Trigger native HTMLElement click instead of opening URL (T45052) diff --git a/resources/src/mediawiki.misc-authed-pref/rightClickEdit.js b/resources/src/mediawiki.misc-authed-pref/rightClickEdit.js index 8c936eb39cd6..fd3a611e188b 100644 --- a/resources/src/mediawiki.misc-authed-pref/rightClickEdit.js +++ b/resources/src/mediawiki.misc-authed-pref/rightClickEdit.js @@ -5,7 +5,8 @@ * edit section link. */ ( function () { - if ( !parseInt( mw.user.options.get( 'editsectiononrightclick' ), 10 ) ) { + if ( Number( mw.user.options.get( 'editsectiononrightclick' ) ) !== 1 ) { + // Support both 1 or "1" (T54542) return; } |