http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89034

Revision: 89034
Author:   janpaul123
Date:     2011-05-28 11:46:55 +0000 (Sat, 28 May 2011)
Log Message:
-----------
Fixed inline JS based on comment in 
http://www.mediawiki.org/wiki/User:Catrope/Extension_review/WikiLove

Modified Paths:
--------------
    trunk/extensions/WikiLove/WikiLove.hooks.php
    trunk/extensions/WikiLove/WikiLove.php
    trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js

Modified: trunk/extensions/WikiLove/WikiLove.hooks.php
===================================================================
--- trunk/extensions/WikiLove/WikiLove.hooks.php        2011-05-28 11:30:29 UTC 
(rev 89033)
+++ trunk/extensions/WikiLove/WikiLove.hooks.php        2011-05-28 11:46:55 UTC 
(rev 89034)
@@ -7,6 +7,8 @@
  */
 
 class WikiLoveHooks {
+       private static $recipient = '';
+       
        /**
         * LoadExtensionSchemaUpdates hook
         *
@@ -56,16 +58,20 @@
                if ( !is_null( $title ) ) {
                        $out->addModules( 'ext.wikiLove.icon' );
                        $out->addModules( 'ext.wikiLove.init' );
-                       $out->addInlineScript(
-                               'jQuery( document ).ready( function() {
-                                       jQuery.wikiLove.setUsername( ' . 
FormatJson::encode( $title->getText() ) . ' );
-                               } );'
-                       );
+                       self::$recipient = $title->getText();
                }
                return true;
        }
        
        /**
+        * Exports wikilove-recipient variable to JS
+        */
+       public static function makeGlobalVariablesScript( &$vars ) {
+               $vars['wikilove-recipient'] = self::$recipient;
+               return true;
+       }
+       
+       /**
         * Adds a tab the old way (before MW 1.18)
         */
        public static function skinTemplateTabs( $skin, &$contentActions ) {

Modified: trunk/extensions/WikiLove/WikiLove.php
===================================================================
--- trunk/extensions/WikiLove/WikiLove.php      2011-05-28 11:30:29 UTC (rev 
89033)
+++ trunk/extensions/WikiLove/WikiLove.php      2011-05-28 11:46:55 UTC (rev 
89034)
@@ -67,6 +67,7 @@
 $wgHooks['SkinTemplateTabs'][]                    = 
'WikiLoveHooks::skinTemplateTabs';
 $wgHooks['BeforePageDisplay'][]                   = 
'WikiLoveHooks::beforePageDisplay';
 $wgHooks['LoadExtensionSchemaUpdates'][]          = 
'WikiLoveHooks::loadExtensionSchemaUpdates';
+$wgHooks['MakeGlobalVariablesScript'][]           = 
'WikiLoveHooks::makeGlobalVariablesScript';
 
 // api modules
 $wgAPIModules['wikilove'] = 'WikiLoveApi';

Modified: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
===================================================================
--- trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js 
2011-05-28 11:30:29 UTC (rev 89033)
+++ trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js 
2011-05-28 11:46:55 UTC (rev 89034)
@@ -8,8 +8,7 @@
        currentTypeOrSubtype = null, // content of the current (sub)type (i.e. 
an object with title, descr, text, etc.)
        previewData = null, // data of the currently previewed thing is set here
        emailable = false,
-       gallery = {},
-       username = '';
+       gallery = {};
        
 return {
        optionsHook: function() { return {}; }, // hook that can be overridden 
by the user to modify options
@@ -331,7 +330,7 @@
                msg = msg.replace( '$5', myBackgroundColor ); // replace the 
background color
                msg = msg.replace( '$6', myBorderColor ); // replace the border 
color
                
-               msg = msg.replace( '$7', username ); // replace the username 
we're sending to
+               msg = msg.replace( '$7', mw.config.get( 'wikilove-recipient' ) 
); // replace the username we're sending to
                
                return msg;
        },
@@ -516,13 +515,6 @@
                        $.wikiLove.openDialog();
                        e.preventDefault();
                });
-       },
-       
-       /*
-        * Public function to set the username by finding the base title 
server-side.
-        */
-       setUsername: function( name ) {
-               username = name;
        }
        
        /*


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to