r61431 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61430‎ | r61431 | r61432 >
Date:20:11, 23 January 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Part 2 at solving conflict with vector and js edit

Add OutputPage::includeJQuery() for loading the jQuery currently shipped
with core. Extension can use this function to avoid loading it multiple
times. No support for plugins etc.

Changes Translate extension to use that function, restored compatability
with 1.15 for at least this part of code.
Modified paths:
  • /trunk/extensions/Translate/utils/MessageTable.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -47,6 +47,11 @@
4848 */
4949 var $styles = array();
5050
 51+ /**
 52+ * Whether to load jQuery core.
 53+ */
 54+ protected $mIncludeJQuery = false;
 55+
5156 private $mIndexPolicy = 'index';
5257 private $mFollowPolicy = 'follow';
5358 private $mVaryHeader = array( 'Accept-Encoding' => array('list-contains=gzip'),
@@ -2103,4 +2108,22 @@
21042109 }
21052110 $this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) );
21062111 }
 2112+
 2113+ /**
 2114+ * Include jQuery core. Use this to avoid loading it multiple times
 2115+ * before we get usable script loader.
 2116+ */
 2117+ public function includeJQuery() {
 2118+ if ( $this->mIncludeJQuery ) return;
 2119+ $this->mIncludeJQuery = true;
 2120+
 2121+ global $wgScriptPath, $wgStyleVersion, $wgJsMimeType;
 2122+
 2123+ $params = array(
 2124+ 'type' => $wgJsMimeType,
 2125+ 'src' => "$wgScriptPath/js2/js2stopgap.min.js?$wgStyleVersion",
 2126+ );
 2127+ $this->mScripts = Html::element( 'script', $params ) . "\n" . $this->mScripts;
 2128+ }
 2129+
21072130 }
Index: trunk/extensions/Translate/utils/MessageTable.php
@@ -54,10 +54,17 @@
5555 $prefix = "$wgExtensionAssetsPath/Translate/js";
5656 // Our class
5757 $wgOut->addScriptFile( "$prefix/quickedit.js" );
 58+
5859 // Core jQuery
59 - $wgOut->addScriptFile( "$wgScriptPath/js2/js2stopgap.min.js" );
60 - // Additional jQuery
61 - $wgOut->addScriptFile( "$prefix/jquery-ui-1.7.2.custom.min.js" );
 60+ if ( method_exists( $wgOut, 'includeJQuery' ) ) {
 61+ $wgOut->includeJQuery();
 62+ $wgOut->addScriptFile( "$prefix/jquery-ui-1.7.2.custom.min.js" );
 63+ } else {
 64+ // MW 1.15 and older
 65+ $wgOut->addScriptFile( "$prefix/js2stopgap.js" );
 66+ }
 67+
 68+ // Additional jQuery stuff
6269 $wgOut->addScriptFile( "$prefix/jquery.form.js" );
6370 $wgOut->addExtensionStyle( "$prefix/base/custom-theme/jquery-ui-1.7.2.custom.css" );
6471 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r61608wmf-deployment: Merge (parts of) r59780, r61431, r61489, r61557, r61558, r615...catrope21:59, 27 January 2010

Status & tagging log