Index: trunk/extensions/CodeReview/CodeReview.php |
— | — | @@ -149,6 +149,11 @@ |
150 | 150 | 'scripts' => 'ext.codereview.loaddiff.js' |
151 | 151 | ) + $commonModuleInfo; |
152 | 152 | |
| 153 | +// Revision tooltips CodeRevisionView: |
| 154 | +$wgResourceModules['ext.codereview.tooltips'] = array( |
| 155 | + 'scripts' => 'ext.codereview.tooltips.js' |
| 156 | +) + $commonModuleInfo; |
| 157 | + |
153 | 158 | // If you are running a closed svn, fill the following two lines with the username and password |
154 | 159 | // of a user allowed to access it. Otherwise, leave it false. |
155 | 160 | // This is only necessary if using the shell method to access Subversion |
Index: trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js |
— | — | @@ -0,0 +1,53 @@ |
| 2 | +var CodeTooltipsInit = function() { |
| 3 | + $( 'a[href]' ).each( function() { |
| 4 | + var link = this.getAttribute( 'href' ); |
| 5 | + if ( !link ) { |
| 6 | + return; |
| 7 | + } |
| 8 | + var matches = link.match( /^\/.*\/Special:Code\/([-A-Za-z\d_]*?)\/(\d+)$/ ); |
| 9 | + if ( !matches ) { |
| 10 | + return; |
| 11 | + } |
| 12 | + $( this ).mouseenter( function( e ) { |
| 13 | + var $el = $( this ); |
| 14 | + if ( $el.data('codeTooltip') ) { |
| 15 | + return; // already processed |
| 16 | + } |
| 17 | + var reqData = { |
| 18 | + format: 'json', |
| 19 | + action: 'query', |
| 20 | + list: 'coderevisions', |
| 21 | + crprop: 'revid|message|status|author', |
| 22 | + crrepo: matches[1], |
| 23 | + crrevs: matches[2], |
| 24 | + crlimit: '1' |
| 25 | + }; |
| 26 | + $el.tipsy( { fade: true, gravity: 'sw', html:true } ); |
| 27 | + $.getJSON( |
| 28 | + mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' ), |
| 29 | + reqData, |
| 30 | + function( data ) { |
| 31 | + if ( !data || !data.query || !data.query.coderevisions ) { |
| 32 | + return; |
| 33 | + } |
| 34 | + var rev = data.query.coderevisions[0]; |
| 35 | + var text = rev['*'].length > 82 ? rev['*'].substr(0,80) + '...' : rev['*']; |
| 36 | + |
| 37 | + var tip = '<div class="mw-codereview-status-' + rev.status + '" style="padding:5px 8px 4px; margin:-5px -8px -4px;">' |
| 38 | + + 'r' + matches[2] |
| 39 | + + ' [' + rev.status + '] by ' |
| 40 | + + rev.author |
| 41 | + + ( rev['*'] ? ' - ' + text : '' ) |
| 42 | + + '</div>'; |
| 43 | + $el.attr( 'title', tip ); |
| 44 | + $el.data( 'codeTooltip', true ); |
| 45 | + $el.tipsy( 'show' ); |
| 46 | + } |
| 47 | + ); |
| 48 | + }); |
| 49 | + }); |
| 50 | +}; |
| 51 | + |
| 52 | +mw.loader.using( 'jquery.tipsy', function(){ |
| 53 | + $( document ).ready( CodeTooltipsInit ); |
| 54 | +}); |
Property changes on: trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 55 | + native |
Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | global $wgRequest; |
18 | 18 | |
19 | 19 | $path = $wgRequest->getVal( 'path' ); |
20 | | - |
| 20 | + |
21 | 21 | if ( $path != '' ) { |
22 | 22 | $this->mPath = array_map( array( $this, 'preparePaths' ), explode( '|', $path ) ); |
23 | 23 | } else { |
— | — | @@ -78,6 +78,8 @@ |
79 | 79 | |
80 | 80 | $navBar = $pager->getNavigationBar(); |
81 | 81 | |
| 82 | + $wgOut->addModules( 'ext.codereview.tooltips' ); |
| 83 | + |
82 | 84 | $wgOut->addHTML( $pathForm ); |
83 | 85 | |
84 | 86 | $wgOut->addHTML( |