r76508 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76507‎ | r76508 | r76509 >
Date:06:14, 11 November 2010
Author:werdna
Status:deferred
Tags:
Comment:
LiquidThreads: Include all resources in the output for threadaction=inlineEditForm
Modified paths:
  • /trunk/extensions/LiquidThreads/api/ApiThreadAction.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -1224,30 +1224,52 @@
12251225
12261226 global $wgOut;
12271227 global $wgStyleVersion;
1228 - global $wgLiquidThreadsExtensionPath;
12291228
12301229 LqtHooks::$scriptVariables['wgLqtMessages'] = self::exportJSLocalisation();
12311230
12321231 if ( method_exists( $wgOut, 'includeJQuery' ) ) {
12331232 $wgOut->includeJQuery();
1234 - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/plugins.js" );
1235 - } else {
1236 - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/js2.combined.js" );
12371233 }
12381234
1239 - $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery-ui-1.7.2.css" );
1240 - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/jquery.autogrow.js" );
 1235+ $output = self::getJSAndCSS();
12411236
1242 - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/lqt.js" );
1243 - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/js/lqt.toolbar.js" );
1244 - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/jquery.thread_collapse.js" );
1245 - $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery.thread_collapse.css" );
1246 -
1247 - $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/lqt.css?{$wgStyleVersion}" );
 1237+ foreach( $output['scripts'] as $script ) {
 1238+ $wgOut->addScriptFile( "$script?$wgStyleVersion" );
 1239+ }
12481240
 1241+ foreach( $output['styles'] as $style ) {
 1242+ $wgOut->addExtensionStyle( "$style?$wgStyleVersion" );
 1243+ }
 1244+
12491245 self::$stylesAndScriptsDone = true;
12501246 }
12511247
 1248+ static function getJSAndCSS() {
 1249+ global $wgLiquidThreadsExtensionPath, $wgOut;
 1250+ // Returns an associative array, with the keys: styles, scripts
 1251+
 1252+ $styles = array(
 1253+ "$wgLiquidThreadsExtensionPath/jquery/jquery-ui-1.7.2.css",
 1254+ "$wgLiquidThreadsExtensionPath/jquery/jquery.thread_collapse.css",
 1255+ "$wgLiquidThreadsExtensionPath/lqt.css",
 1256+ );
 1257+
 1258+ $scripts = array(
 1259+ "$wgLiquidThreadsExtensionPath/lqt.js",
 1260+ "$wgLiquidThreadsExtensionPath/js/lqt.toolbar.js",
 1261+ "$wgLiquidThreadsExtensionPath/jquery/jquery.thread_collapse.js",
 1262+ "$wgLiquidThreadsExtensionPath/jquery/jquery.autogrow.js"
 1263+ );
 1264+
 1265+ if ( method_exists( $wgOut, 'includeJQuery' ) ) {
 1266+ $scripts[] = "$wgLiquidThreadsExtensionPath/jquery/plugins.js";
 1267+ } else {
 1268+ $scripts[] = "$wgLiquidThreadsExtensionPath/jquery/js2.combined.js";
 1269+ }
 1270+
 1271+ return array( 'scripts' => $scripts, 'styles' => $styles );
 1272+ }
 1273+
12521274 static function exportJSLocalisation() {
12531275 $messages = array(
12541276 'lqt-quote-intro',
Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php
@@ -799,6 +799,9 @@
800800 $output = LqtView::getInlineEditForm( $talkpage, $method, $operand );
801801
802802 $result = array( 'inlineeditform' => array( 'html' => $output ) );
 803+
 804+ $result['resources'] = LqtView::getJSandCSS();
 805+ $result['resources']['messages'] = LqtView::exportJSLocalisation();
803806
804807 $this->getResult()->addValue( null, 'threadaction', $result );
805808 }
Index: trunk/extensions/LiquidThreads/lqt.js
@@ -1,7 +1,18 @@
22 // Prototype in string.trim on browsers that haven't yet implemented
33 if ( typeof String.prototype.trim !== "function" )
44 String.prototype.trim = function() { return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); };
 5+
56 var wgWikiEditorIconVersion = 0;
 7+
 8+jQuery.getCSS = function( url, media ) {
 9+ jQuery( document.createElement('link') ).attr({
 10+ href: url,
 11+ media: media || 'screen',
 12+ type: 'text/css',
 13+ rel: 'stylesheet'
 14+ }).appendTo('head');
 15+};
 16+
617 var liquidThreads = {
718 currentReplyThread : null,
819 currentToolbar : null,
@@ -215,6 +226,22 @@
216227 function(result) {
217228 var content = $j(result.threadaction.inlineeditform.html);
218229 $j(container).empty().append(content);
 230+
 231+ // Add resources if necessary
 232+ if ( typeof wgLqtMessages == 'undefined' || !wgLqtMessages ) {
 233+ wgLqtMessages = result.threadaction.resources.messages;
 234+
 235+ $j.each( result.threadaction.resources.scripts,
 236+ function(index,value) {
 237+ $j.getScript( value );
 238+ } );
 239+
 240+ $j.each( result.threadaction.resources.styles,
 241+ function(index,value) {
 242+ $j.getCSS( value );
 243+ } );
 244+ }
 245+
219246 callback();
220247 } );
221248 },

Follow-up revisions

RevisionCommit summaryAuthorDate
r76509Merging from r76432 trhu r76508 of trunkawjrichards06:24, 11 November 2010

Status & tagging log