MediaWiki:Gadget-HoverPopTools.js

/** * HoverPopTools * @author Krinkle * @version 1.1 **/ // jquery.hoverIntent makes sure the list doesn't dissapear right away.

(function ( $, mw ) {	"use strict";

if ( mw.config.get( 'skin' ) !== 'vector' ) { return; }

$( 'document' ).ready( function {		$( '.mw-usertoollinks' ).each( function  { var	$that = $( this ), pos = {}, $mwUserlink = $that.prev('.mw-userlink'); if ( $mwUserlink.size ) { // Hide the original tools $that.hide; // Active the CSS classes for the list $mwUserlink.addClass( 'mw-hoverpoptools' ); // Create the new dropdown list var $list = $( '' ); // Append each link to the list as a list-item $that.find( '> a' ).each( function {					$list.append( $( this ) .click( function( e ) {							// In Firefox 3.6 on Mac (perhaps other versions too) the parent  is (also or only) triggered							// And hijacks the click action. In order for this click to actually do what we want we need to							// navigate to the href location manually							e.preventDefault;							window.location.href = this.href;							return false; // stops bubbling and other handlers							} ) .wrap( '' ) .parent );				} );				// Remove the original tools and put the new list inside the mw-userlink //$that.remove; $list = $list.wrap( ' ' ).parent; $list.appendTo( $mwUserlink ); // Make it into a dropdown $mwUserlink.hoverIntent( {					timeout: 350,					over: function {						var addW = $mwUserlink.width - 5;						pos = $mwUserlink.position;						$(this).addClass( 'mw-hoverpoptools-hover' );						$list.css( { left: pos.left + addW, top: pos.top-1 } );					},					out: function {						$(this).removeClass( 'mw-hoverpoptools-hover' );					}				} ); }		} );	} ); } )( jQuery, mediaWiki );