From: Krinkle Date: Mon, 1 Aug 2011 22:13:32 +0000 (+0000) Subject: Port 'editondblclick' js to ResourceLoader. X-Git-Tag: 1.31.0-rc.0~28510 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27votes%27%2C%20votes=%27waiting%27%29%20%7D%7D?a=commitdiff_plain;h=f84bd991428f3d03ee49b02502cd1c8362fb9543;p=lhc%2Fweb%2Fwiklou.git Port 'editondblclick' js to ResourceLoader. - Fixes (bug 27894) Move 'editondblclick' event listener down from body to div#bodyContent - Patch by Nik - 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 --- diff --git a/CREDITS b/CREDITS index 5ea87f8441..66a2367471 100644 --- 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 diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 4d2e622768..f1f758bf07 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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. diff --git a/includes/OutputPage.php b/includes/OutputPage.php index e1b4ff60ef..892b4f5e4f 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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; diff --git a/resources/Resources.php b/resources/Resources.php index f5c1ba7277..c7ba181ef1 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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 index 0000000000..b1d906f67d --- /dev/null +++ b/resources/mediawiki.action/mediawiki.action.view.dblClickEdit.js @@ -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; + } ); + } +} );