Port 'editondblclick' js to ResourceLoader.
authorKrinkle <krinkle@users.mediawiki.org>
Mon, 1 Aug 2011 22:13:32 +0000 (22:13 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Mon, 1 Aug 2011 22:13:32 +0000 (22:13 +0000)
- Fixes (bug 27894) Move 'editondblclick' event listener down from body to
  div#bodyContent
- Patch by Nik <niknyby@gmail.com>
- Changes since patch:
  * Moved from OutputPage->headElement (where the bodyAttr-hack used to be) to addDefaultModules where other additions live
  * Added dependency on 'mediawiki.util', it must be initialized before mw.util.$content can be used
  * Whitespace conventions

CREDITS
RELEASE-NOTES-1.19
includes/OutputPage.php
resources/Resources.php
resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js [new file with mode: 0644]

diff --git a/CREDITS b/CREDITS
index 5ea87f8..66a2367 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -134,6 +134,7 @@ following names for their contribution to the product.
 * Nakon
 * Nathan Larson
 * nephele
+* Nik
 * Nikolaos S. Karastathis
 * Olaf Lenz
 * Paul Copperman
index 4d2e622..f1f758b 100644 (file)
@@ -28,7 +28,9 @@ production.
 * $wgUploadNavigationUrl should be used for file redlinks if
   $wgUploadMissingFileUrl is not set. The first was used for this
   until the second was introduced in 1.17.
-* (bug 25355) Parser generates edit section links for special pages
+* (bug 25355) Parser generates edit section links for special pages.
+* (bug 27894) Move 'editondblclick' event listener down from body to
+  div#bodyContent.
 
 === API changes in 1.19 ===
 * (bug 19838) siprop=interwikimap can now use the interwiki cache.
index e1b4ff6..892b4f5 100644 (file)
@@ -2250,13 +2250,6 @@ $templates
 
                $bodyAttrs = array();
 
-               # Crazy edit-on-double-click stuff
-               if ( $this->isArticle() && $this->getUser()->getOption( 'editondblclick' ) ) {
-                       $editUrl = $this->getTitle()->getLocalUrl( $sk->editUrlOptions() );
-                       $bodyAttrs['ondblclick'] = "document.location = '" .
-                               Xml::escapeJsString( $editUrl ) . "'";
-               }
-
                # Classes for LTR/RTL directionality support
                $bodyAttrs['class'] = "mediawiki $userdir sitedir-$sitedir";
 
@@ -2312,6 +2305,11 @@ $templates
                        $this->addModules( 'mediawiki.action.view.rightClickEdit' );
                }
 
+               # Crazy edit-on-double-click stuff
+               if ( $this->isArticle() && $this->getUser()->getOption( 'editondblclick' ) ) {
+                       $this->addModules( 'mediawiki.action.view.dblClickEdit' );
+               }
+
                if ( $wgUseAJAXCategories ) {
                        global $wgAJAXCategoriesNamespaces;
 
index f5c1ba7..c7ba181 100644 (file)
@@ -479,6 +479,10 @@ return array(
                'styles' => 'resources/mediawiki.action/mediawiki.action.history.diff.css',
                'group' => 'mediawiki.action.history',
        ),
+       'mediawiki.action.view.dblClickEdit' => array(
+               'scripts' => 'resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js',
+               'dependencies' => 'mediawiki.util',
+       ),
        'mediawiki.action.view.metadata' => array(
                'scripts' => 'resources/mediawiki.action/mediawiki.action.view.metadata.js',
                'messages' => array(
diff --git a/resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js b/resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js
new file mode 100644 (file)
index 0000000..b1d906f
--- /dev/null
@@ -0,0 +1,12 @@
+/**
+ * This module enables double-click-to-edit functionality
+ */
+jQuery( document ).ready( function( $ ) {
+       var url = $( '#ca-edit a' ).attr( 'href' );
+       if ( url ) {
+               mw.util.$content.dblclick( function( e ) {
+                       e.preventDefault();
+                       window.location = url;
+               } );
+       }
+} );