Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -1224,30 +1224,52 @@ |
1225 | 1225 | |
1226 | 1226 | global $wgOut; |
1227 | 1227 | global $wgStyleVersion; |
1228 | | - global $wgLiquidThreadsExtensionPath; |
1229 | 1228 | |
1230 | 1229 | LqtHooks::$scriptVariables['wgLqtMessages'] = self::exportJSLocalisation(); |
1231 | 1230 | |
1232 | 1231 | if ( method_exists( $wgOut, 'includeJQuery' ) ) { |
1233 | 1232 | $wgOut->includeJQuery(); |
1234 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/plugins.js" ); |
1235 | | - } else { |
1236 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/js2.combined.js" ); |
1237 | 1233 | } |
1238 | 1234 | |
1239 | | - $wgOut->addExtensionStyle( "$wgLiquidThreadsExtensionPath/jquery/jquery-ui-1.7.2.css" ); |
1240 | | - $wgOut->addScriptFile( "$wgLiquidThreadsExtensionPath/jquery/jquery.autogrow.js" ); |
| 1235 | + $output = self::getJSAndCSS(); |
1241 | 1236 | |
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 | + } |
1248 | 1240 | |
| 1241 | + foreach( $output['styles'] as $style ) { |
| 1242 | + $wgOut->addExtensionStyle( "$style?$wgStyleVersion" ); |
| 1243 | + } |
| 1244 | + |
1249 | 1245 | self::$stylesAndScriptsDone = true; |
1250 | 1246 | } |
1251 | 1247 | |
| 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 | + |
1252 | 1274 | static function exportJSLocalisation() { |
1253 | 1275 | $messages = array( |
1254 | 1276 | 'lqt-quote-intro', |
Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php |
— | — | @@ -799,6 +799,9 @@ |
800 | 800 | $output = LqtView::getInlineEditForm( $talkpage, $method, $operand ); |
801 | 801 | |
802 | 802 | $result = array( 'inlineeditform' => array( 'html' => $output ) ); |
| 803 | + |
| 804 | + $result['resources'] = LqtView::getJSandCSS(); |
| 805 | + $result['resources']['messages'] = LqtView::exportJSLocalisation(); |
803 | 806 | |
804 | 807 | $this->getResult()->addValue( null, 'threadaction', $result ); |
805 | 808 | } |
Index: trunk/extensions/LiquidThreads/lqt.js |
— | — | @@ -1,7 +1,18 @@ |
2 | 2 | // Prototype in string.trim on browsers that haven't yet implemented |
3 | 3 | if ( typeof String.prototype.trim !== "function" ) |
4 | 4 | String.prototype.trim = function() { return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }; |
| 5 | + |
5 | 6 | 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 | + |
6 | 17 | var liquidThreads = { |
7 | 18 | currentReplyThread : null, |
8 | 19 | currentToolbar : null, |
— | — | @@ -215,6 +226,22 @@ |
216 | 227 | function(result) { |
217 | 228 | var content = $j(result.threadaction.inlineeditform.html); |
218 | 229 | $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 | + |
219 | 246 | callback(); |
220 | 247 | } ); |
221 | 248 | }, |