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

Revision: 84594
Author:   reedy
Date:     2011-03-23 14:24:22 +0000 (Wed, 23 Mar 2011)
Log Message:
-----------
Per mailing list, import MaxSems tooltip gadget from 
http://www.mediawiki.org/wiki/MediaWiki:Gadget-CodeTooltips.js

All credit to MaxSem

Modified Paths:
--------------
    trunk/extensions/CodeReview/CodeReview.php
    trunk/extensions/CodeReview/ui/CodeRevisionListView.php

Added Paths:
-----------
    trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js

Modified: trunk/extensions/CodeReview/CodeReview.php
===================================================================
--- trunk/extensions/CodeReview/CodeReview.php  2011-03-23 12:14:46 UTC (rev 
84593)
+++ trunk/extensions/CodeReview/CodeReview.php  2011-03-23 14:24:22 UTC (rev 
84594)
@@ -149,6 +149,11 @@
        'scripts' => 'ext.codereview.loaddiff.js'
 ) + $commonModuleInfo;
 
+// Revision tooltips CodeRevisionView:
+$wgResourceModules['ext.codereview.tooltips'] = array(
+       'scripts' => 'ext.codereview.tooltips.js'
+) + $commonModuleInfo;
+
 // If you are running a closed svn, fill the following two lines with the 
username and password
 // of a user allowed to access it. Otherwise, leave it false.
 // This is only necessary if using the shell method to access Subversion

Added: trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js
===================================================================
--- trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js              
                (rev 0)
+++ trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js      
2011-03-23 14:24:22 UTC (rev 84594)
@@ -0,0 +1,53 @@
+var CodeTooltipsInit = function() {
+       $( 'a[href]' ).each( function() {
+               var link = this.getAttribute( 'href' );
+               if ( !link ) {
+                       return;
+               }
+               var matches = link.match( 
/^\/.*\/Special:Code\/([-A-Za-z\d_]*?)\/(\d+)$/ );
+               if ( !matches ) {
+                       return;
+               }
+               $( this ).mouseenter( function( e ) {
+                       var $el = $( this );
+                       if ( $el.data('codeTooltip') ) {
+                               return; // already processed
+                       }
+                       var reqData = {
+                               format: 'json',
+                               action: 'query',
+                               list: 'coderevisions',
+                               crprop: 'revid|message|status|author',
+                               crrepo: matches[1],
+                               crrevs: matches[2],
+                               crlimit: '1'
+                       };
+                       $el.tipsy( { fade: true, gravity: 'sw', html:true } );
+                       $.getJSON(
+                               mw.config.get( 'wgScriptPath' ) + '/api' + 
mw.config.get( 'wgScriptExtension' ),
+                               reqData,
+                               function( data ) {
+                                       if ( !data || !data.query || 
!data.query.coderevisions ) {
+                                               return;
+                                       }
+                                       var rev = data.query.coderevisions[0];
+                                       var text = rev['*'].length > 82 ? 
rev['*'].substr(0,80) + '...' : rev['*'];
+
+                                       var tip = '<div 
class="mw-codereview-status-' + rev.status + '" style="padding:5px 8px 4px; 
margin:-5px -8px -4px;">'
+                                               + 'r' + matches[2]
+                                               + ' [' + rev.status + '] by '
+                                               + rev.author
+                                               + ( rev['*'] ? ' - ' + text : 
'' )
+                                               + '</div>';
+                                       $el.attr( 'title', tip );
+                                       $el.data( 'codeTooltip', true );
+                                       $el.tipsy( 'show' );
+                               }
+                       );
+               });
+       });
+};
+
+mw.loader.using( 'jquery.tipsy', function(){
+       $( document ).ready( CodeTooltipsInit );
+});


Property changes on: 
trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/extensions/CodeReview/ui/CodeRevisionListView.php
===================================================================
--- trunk/extensions/CodeReview/ui/CodeRevisionListView.php     2011-03-23 
12:14:46 UTC (rev 84593)
+++ trunk/extensions/CodeReview/ui/CodeRevisionListView.php     2011-03-23 
14:24:22 UTC (rev 84594)
@@ -16,7 +16,7 @@
                global $wgRequest;
 
                $path = $wgRequest->getVal( 'path' );
-               
+
                if ( $path != '' ) {
                        $this->mPath = array_map( array( $this, 'preparePaths' 
), explode( '|', $path ) );
                } else {
@@ -78,6 +78,8 @@
 
                $navBar = $pager->getNavigationBar();
 
+               $wgOut->addModules( 'ext.codereview.tooltips' );
+
                $wgOut->addHTML( $pathForm );
 
                $wgOut->addHTML(


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

Reply via email to