From d31afa8147b7662bfcd09031312b8c41442732a5 Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Tue, 29 Jul 2014 19:51:09 +0100 Subject: [PATCH] Make mediawiki.action.view.dblClickEdit recheck preference There's a preference which makes the browser go to action=edit when double clicking on the content. In VE we want to disable this while the editor is open. With this check in place, we can turn it off by falsifying the value of the preference (and then restoring the original value when VE closes). Bug: 53058 Change-Id: I0f6225b25ad279755548361f82b855727758da2b --- resources/Resources.php | 1 + .../mediawiki.action.view.dblClickEdit.js | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/Resources.php b/resources/Resources.php index 49f62b48d5..42c5b265e5 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1027,6 +1027,7 @@ return array( 'dependencies' => array( 'mediawiki.util', 'mediawiki.page.startup', + 'user.options', ), ), 'mediawiki.action.view.metadata' => array( diff --git a/resources/src/mediawiki.action/mediawiki.action.view.dblClickEdit.js b/resources/src/mediawiki.action/mediawiki.action.view.dblClickEdit.js index 2ded40cf2f..3c22851e37 100644 --- a/resources/src/mediawiki.action/mediawiki.action.view.dblClickEdit.js +++ b/resources/src/mediawiki.action/mediawiki.action.view.dblClickEdit.js @@ -4,9 +4,12 @@ ( function ( mw, $ ) { $( function () { mw.util.$content.dblclick( function ( e ) { - e.preventDefault(); - // Trigger native HTMLElement click instead of opening URL (bug 43052) - $( '#ca-edit a' ).get( 0 ).click(); + // Recheck preference so extensions can do a hack to disable this code. + if ( parseInt( mw.user.options.get( 'editondblclick' ), 10 ) ) { + e.preventDefault(); + // Trigger native HTMLElement click instead of opening URL (bug 43052) + $( '#ca-edit a' ).get( 0 ).click(); + } } ); } ); }( mediaWiki, jQuery ) ); -- 2.20.1