Index: trunk/extensions/WikiLove/WikiLove.hooks.php |
— | — | @@ -43,34 +43,33 @@ |
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | | - * Adds the required module and edit token JS if we are on a user (talk) page. |
| 47 | + * Adds the required module if we are on a user (talk) page. |
48 | 48 | * |
49 | 49 | * @param $output |
50 | 50 | * @param $skin Skin |
51 | 51 | */ |
52 | 52 | public static function beforePageDisplay( $out, $skin ) { |
53 | 53 | global $wgWikiLoveGlobal, $wgUser; |
54 | | - if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) return true; |
| 54 | + if ( !$wgWikiLoveGlobal && !$wgUser->getOption( 'wikilove-enabled' ) ) { |
| 55 | + return true; |
| 56 | + } |
55 | 57 | |
56 | 58 | $title = self::getUserTalkPage( $skin->getTitle() ); |
57 | 59 | if ( !is_null( $title ) ) { |
58 | 60 | $out->addModules( 'ext.wikiLove.icon' ); |
59 | 61 | $out->addModules( 'ext.wikiLove.init' ); |
60 | 62 | self::$recipient = $title->getText(); |
61 | | - $out->addInlineScript( |
62 | | - 'jQuery( document ).ready( function() { |
63 | | - jQuery.wikiLove.editToken = ' . FormatJson::encode( $wgUser->edittoken() ) . '; |
64 | | - } );' |
65 | | - ); |
66 | 63 | } |
67 | 64 | return true; |
68 | 65 | } |
69 | 66 | |
70 | 67 | /** |
71 | | - * Exports wikilove-recipient variable to JS |
| 68 | + * Exports wikilove-recipient and edittoken variables to JS |
72 | 69 | */ |
73 | 70 | public static function makeGlobalVariablesScript( &$vars ) { |
| 71 | + global $wgUser; |
74 | 72 | $vars['wikilove-recipient'] = self::$recipient; |
| 73 | + $vars['wikilove-edittoken'] = $wgUser->edittoken(); |
75 | 74 | return true; |
76 | 75 | } |
77 | 76 | |
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js |
— | — | @@ -7,7 +7,6 @@ |
8 | 8 | currentSubtypeId = null, // id of the currently selected subtype (e.g. 'original' or 'special') |
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 | | - editToken = '', // edit token used for the final AJAX call (deprecated after 1.17) |
12 | 11 | emailable = false, |
13 | 12 | gallery = {}; |
14 | 13 | |
— | — | @@ -385,7 +384,7 @@ |
386 | 385 | 'text': wikitext, |
387 | 386 | 'message': message, |
388 | 387 | 'subject': subject, |
389 | | - 'token': $.wikiLove.editToken // after 1.17 this can become mw.user.tokens.get( 'editToken' ) |
| 388 | + 'token': mw.config.get( 'wikilove-edittoken' ) // after 1.17 this can become mw.user.tokens.get( 'editToken' ) |
390 | 389 | }; |
391 | 390 | |
392 | 391 | if ( email ) { |