r86478 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86477‎ | r86478 | r86479 >
Date:14:58, 20 April 2011
Author:catrope
Status:ok
Tags:
Comment:
CodeReview: Make revision tooltips annoy Tim less :) . Disables tooltips for the revision number column in revision lists, and adds a 250ms delay so accidentally moving the mouse over an MFT revision doesn't trigger a dozen API requests.
Modified paths:
  • /trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/modules/ext.codereview.tooltips.js
@@ -1,5 +1,9 @@
22 var CodeTooltipsInit = function() {
33 $( 'a[href]' ).each( function() {
 4+ if ( $( this ).parent().is( '.TablePager_col_cr_id' ) ) {
 5+ // Tooltips are unnecessary and annoying in revision lists
 6+ return;
 7+ }
48 var link = this.getAttribute( 'href' );
59 if ( !link ) {
610 return;
@@ -8,7 +12,8 @@
913 if ( !matches ) {
1014 return;
1115 }
12 - $( this ).mouseenter( function( e ) {
 16+
 17+ function showTooltip() {
1318 var $el = $( this );
1419 if ( $el.data('codeTooltip') ) {
1520 return; // already processed
@@ -49,11 +54,31 @@
5055 }
5156 }
5257 );
53 - });
 58+ }
 59+
 60+ // We want to avoid doing API calls just because someone accidentally moves the mouse
 61+ // over a link, so we only want to do an API call after the mouse has been on a link
 62+ // for 250ms.
 63+ $( this ).mouseenter( function( e ) {
 64+ var that = this;
 65+ var timerID = $( this ).data( 'codeTooltipTimer' );
 66+ if ( typeof timerID != 'undefined' ) {
 67+ // Clear the running timer
 68+ clearTimeout( timerID );
 69+ }
 70+ timerID = setTimeout( function() { showTooltip.apply( that ); }, 250 );
 71+ $( this ).data( 'codeTooltipTimer', timerID );
 72+ } );
5473 // take care of cases when louse leaves our link while we load stuff from API.
5574 // We shouldn't display the tooltip in such case.
5675 $( this ).mouseleave( function( e ) {
5776 var $el = $( this );
 77+ var timerID = $el.data( 'codeTooltipTimer' );
 78+ if ( typeof timerID != 'undefined' ) {
 79+ // Clear the running timer
 80+ clearTimeout( timerID );
 81+ }
 82+
5883 if ( $el.data( 'codeTooltip' ) || !$el.data( 'codeTooltipLoading' ) ) {
5984 return;
6085 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r87090MFT a few minor CR fixes (r86477, r86478, r86479, r87012)demon18:11, 28 April 2011

Status & tagging log