User:YFdyh000/MediaWiki:Gadget-internalLinkHelper-redtipsy-2022.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
mw.loader.using('ext.gadget.tipsyDeprecated', function(){
( function( $, mw, window ) { $( function() {
mw.hook( 'wikipage.content' ).add( function( $content ) {
$( '.ilh-all', $content ).not( '.ilh-blue' ).on( 'internalLinkHelper-close', function( event ) {
var $this = $( this );
if ( $this.data( 'internalLinkHelper-showing' ) ) {
$( this ).removeClass( 'ilh-active' ).find( '.ilh-all a' ).tipsy( 'hide' ).end()
.data( 'internalLinkHelper-showing', false );
}
} ).each( function() {
var origTitle = $(this).text(),
$foreignSpan =$(this).data('fname'), // foreign title
$linkAnchor = $(this),
$langSpan = $(this).data('fcode'), // foreign code raw
$langName = $langSpan, // todo build with lists
$that = $( this ).data( 'internalLinkHelper-showing', false );
//debugger;
if ( !$linkAnchor.length ) {
return;
}
var timeout = null;
var maybeClearTimeout = function() {
if ( timeout !== null ) {
clearTimeout( timeout );
}
}, autoSetTimeout = function() {
maybeClearTimeout();
timeout = setTimeout.apply( null, arguments );
};
var mouseleave = function() {
autoSetTimeout( function() {
$that.trigger( 'internalLinkHelper-close' );
}, 500 );
}, mouseenter = function() {
if ( $that.data( 'internalLinkHelper-showing' ) ) {
maybeClearTimeout();
} else {
$( '.ilh-all', $content ).not( $that ).trigger( 'internalLinkHelper-close' );
$that.addClass( 'ilh-active' ).data( 'internalLinkHelper-showing', true );
var tipsy = $linkAnchor.tipsy( 'show' );
// please revise as necessary
if(tipsy) {
tipsy = tipsy.tipsy( true );
if(tipsy && tipsy.tip) {
tipsy.tip().mouseleave( mouseleave ).mouseenter( mouseenter );
}
}
}
};
$linkAnchor.tipsy( {
className: 'ilh-tipsy',
gravity: 'nw',
html: true,
trigger: 'manual',
title: function() {
return '<div>'
+ wgUVS( '条目“', '條目「' )
+ origTitle
+ wgUVS( '”尚未创建,可参考', '」尚未創建,可參考' )
+ $langName
+ wgUVS( '维基百科的对应页面:', '維基百科的對應頁面:' )
+ $('<div>').append($("<a />",{href:"https:"+mediaWiki.config.get('wgServer')+"/wiki/"+$langName+":"+$foreignSpan}).text($foreignSpan)).html()
+ '。</div>';
}
} )
.mouseleave( mouseleave ).mouseenter( mouseenter );
} );
} );
} ); } )( jQuery, mediaWiki, window );})