Index: trunk/extensions/WikiLove/WikiLove.php |
— | — | @@ -67,6 +67,7 @@ |
68 | 68 | $wgHooks['SkinTemplateTabs'][] = 'WikiLoveHooks::skinTemplateTabs'; |
69 | 69 | $wgHooks['BeforePageDisplay'][] = 'WikiLoveHooks::beforePageDisplay'; |
70 | 70 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'WikiLoveHooks::loadExtensionSchemaUpdates'; |
| 71 | +$wgHooks['MakeGlobalVariablesScript'][] = 'WikiLoveHooks::makeGlobalVariablesScript'; |
71 | 72 | |
72 | 73 | // api modules |
73 | 74 | $wgAPIModules['wikilove'] = 'WikiLoveApi'; |
Index: trunk/extensions/WikiLove/WikiLove.hooks.php |
— | — | @@ -7,6 +7,8 @@ |
8 | 8 | */ |
9 | 9 | |
10 | 10 | class WikiLoveHooks { |
| 11 | + private static $recipient = ''; |
| 12 | + |
11 | 13 | /** |
12 | 14 | * LoadExtensionSchemaUpdates hook |
13 | 15 | * |
— | — | @@ -56,16 +58,20 @@ |
57 | 59 | if ( !is_null( $title ) ) { |
58 | 60 | $out->addModules( 'ext.wikiLove.icon' ); |
59 | 61 | $out->addModules( 'ext.wikiLove.init' ); |
60 | | - $out->addInlineScript( |
61 | | - 'jQuery( document ).ready( function() { |
62 | | - jQuery.wikiLove.setUsername( ' . FormatJson::encode( $title->getText() ) . ' ); |
63 | | - } );' |
64 | | - ); |
| 62 | + self::$recipient = $title->getText(); |
65 | 63 | } |
66 | 64 | return true; |
67 | 65 | } |
68 | 66 | |
69 | 67 | /** |
| 68 | + * Exports wikilove-recipient variable to JS |
| 69 | + */ |
| 70 | + public static function makeGlobalVariablesScript( &$vars ) { |
| 71 | + $vars['wikilove-recipient'] = self::$recipient; |
| 72 | + return true; |
| 73 | + } |
| 74 | + |
| 75 | + /** |
70 | 76 | * Adds a tab the old way (before MW 1.18) |
71 | 77 | */ |
72 | 78 | public static function skinTemplateTabs( $skin, &$contentActions ) { |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -8,8 +8,7 @@ |
9 | 9 | currentTypeOrSubtype = null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.) |
10 | 10 | previewData = null, // data of the currently previewed thing is set here |
11 | 11 | emailable = false, |
12 | | - gallery = {}, |
13 | | - username = ''; |
| 12 | + gallery = {}; |
14 | 13 | |
15 | 14 | return { |
16 | 15 | optionsHook: function() { return {}; }, // hook that can be overridden by the user to modify options |
— | — | @@ -331,7 +330,7 @@ |
332 | 331 | msg = msg.replace( '$5', myBackgroundColor ); // replace the background color |
333 | 332 | msg = msg.replace( '$6', myBorderColor ); // replace the border color |
334 | 333 | |
335 | | - msg = msg.replace( '$7', username ); // replace the username we're sending to |
| 334 | + msg = msg.replace( '$7', mw.config.get( 'wikilove-recipient' ) ); // replace the username we're sending to |
336 | 335 | |
337 | 336 | return msg; |
338 | 337 | }, |
— | — | @@ -516,13 +515,6 @@ |
517 | 516 | $.wikiLove.openDialog(); |
518 | 517 | e.preventDefault(); |
519 | 518 | }); |
520 | | - }, |
521 | | - |
522 | | - /* |
523 | | - * Public function to set the username by finding the base title server-side. |
524 | | - */ |
525 | | - setUsername: function( name ) { |
526 | | - username = name; |
527 | 519 | } |
528 | 520 | |
529 | 521 | /* |