Make mediawiki.action.view.dblClickEdit recheck preference
authorAlex Monk <krenair@wikimedia.org>
Tue, 29 Jul 2014 18:51:09 +0000 (19:51 +0100)
committerAlex Monk <krenair@wikimedia.org>
Thu, 25 Sep 2014 16:37:02 +0000 (17:37 +0100)
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
resources/src/mediawiki.action/mediawiki.action.view.dblClickEdit.js

index 49f62b4..42c5b26 100644 (file)
@@ -1027,6 +1027,7 @@ return array(
                'dependencies' => array(
                        'mediawiki.util',
                        'mediawiki.page.startup',
+                       'user.options',
                ),
        ),
        'mediawiki.action.view.metadata' => array(
index 2ded40c..3c22851 100644 (file)
@@ -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 ) );