User:Jack who built the house/Gadget-referenceTooltips.js: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
(18 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 = {
};
// 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 = {
'mouseleave.rt': onEndEvent
};
}
this.$element.on(
▲ { 'click.rt': onStartEvent } :
▲ { 'mouseenter.rt': onStartEvent, 'mouseleave.rt': onEndEvent }
▲ );
this.hideRef = function ( immediately ) {
Line 183 ⟶ 201:
if ( window.pg ) {
disableRt();
return;
}
if ( this.tooltip && !this.tooltip.$content.length ) {
return;
}
Line 554 ⟶ 576:
this.id = 'rt-' + this.te.$originalElement.attr( 'id' );
this.$content = this.te.$ref
.
.
var $this = $( this );
return this.nodeType === Node.TEXT_NODE ||
!( $this.is( '.mw-cite-backlink' ) ||
( i === 0 &&
// Template:Cnote, Template:Note
( $this.is( 'b' ) ||
// Template:Note_label
$this.is( 'a' ) &&
$this.attr( 'href' ).indexOf( '#ref' ) === 0
)
)
);
} )
.clone( true );
break;
Line 590 ⟶ 625:
.parent()
.addClass( 'rt-tooltipContent' )
.addClass( 'mw-parser-output' )
.appendTo( this.$element );
|