User:Jack who built the house/Gadget-referenceTooltips.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 1:
// See [[mw:Reference Tooltips]]
// Source https://en.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.js
 
( function () {
Line 105 ⟶ 106:
function TooltippedElement( $element ) {
var tooltip,
events,
te = this;
 
Line 110 ⟶ 112:
var showRefArgs;
 
if ( activatedByClick && te.type !== 'commentedText' && e.type !== 'contextmenu' ) {
e.preventDefault();
}
Line 149 ⟶ 151:
}
this.$element.addClass('rt-commentedText');
);}
if ( activatedByClick ) {
events = {
{ 'click.rt': onStartEvent } :
};
// Adds an ability to see tooltips for links
if ( this.type === 'commentedText' &&
( this.$element.closest( 'a' ).length ||
this.$element.has( 'a' ).length
)
) {
events[ 'contextmenu.rt' ] = onStartEvent;
}
} else {
events = {
{ 'mouseenter.rt': onStartEvent, 'mouseleave.rt': onEndEvent }
'mouseleave.rt': onEndEvent
};
}
 
this.$element.on( activatedByClickevents ?);
{ 'click.rt': onStartEvent } :
{ 'mouseenter.rt': onStartEvent, 'mouseleave.rt': onEndEvent }
);
 
this.hideRef = function ( immediately ) {
Line 560 ⟶ 578:
.contents()
.filter( function ( i ) {
var $this = $( this );
return this.nodeType === Node.TEXT_NODE ||
!( !$( this ).is( '.mw-cite-backlink, .mw-cite-up-arrow, .mw-cite-up-arrow-backlink, .mw-cite-targeted-backlink' ) &&||
!( i === 10 && $( this.is( 'b' ) ) )
// Template:Cnote, Template:Note
( $this.is( 'b' ) ||
// Template:Note_label
$this.is( 'a' ) &&
$this.attr( 'href' ).indexOf( '#ref' ) === 0
)
)
);
} )
Line 599 ⟶ 625:
.parent()
.addClass( 'rt-tooltipContent' )
.addClass( 'mw-parser-output' )
.appendTo( this.$element );