MediaWiki:Gadget-noteTAvector.js:修订间差异
外观
删除的内容 添加的内容
Fixes https://zh.wikipedia.org/wiki/Wikipedia:%E4%BA%92%E5%8A%A9%E5%AE%A2%E6%A0%88/%E5%85%B6%E4%BB%96#Resolving_technical_issues #1 |
|||
第1行: | 第1行: | ||
noteTAvector = |
var noteTAvector = ( function() { |
||
var associatedPages = document.getElementById( 'p-associated-pages' ); |
|||
⚫ | |||
var useLegacyMode = !associatedPages; |
|||
⚫ | |||
var makeSpan = function () { |
|||
.addClass( 'vector-menu-tabs' ) |
|||
⚫ | |||
//.addClass( 'vectorTabs' ) |
|||
⚫ | |||
.addClass( 'vector-menu-tabs-legacy' ) |
|||
var mapIndicatorLegacy = function() { |
|||
$( '<a href="#">' ).html( makeSpan() ) |
|||
.click( function( e ) { |
|||
⚫ | |||
} ) |
|||
.wrap( '<ul><li><span></span></li></ul>' ) |
|||
.parent().parent().parent().appendTo( this ); |
|||
}; |
|||
var mapIndicator = function () { |
|||
makeSpan().appendTo( this ); |
|||
}; |
|||
var $node = $( 'body.skin-vector-legacy,body.skin-vector-2022' ) |
|||
⚫ | |||
.removeAttr( 'style' ) |
.removeAttr( 'style' ) |
||
. |
.removeClass( 'mw-indicator') |
||
.empty() |
.empty() |
||
.each( |
.each( useLegacyMode ? mapIndicatorLegacy : mapIndicator ); |
||
⚫ | |||
if ( useLegacyMode ) { |
|||
⚫ | |||
⚫ | |||
.addClass( 'vector-menu-tabs' ) |
|||
.addClass( 'vector-menu-tabs-legacy' ) |
|||
.css( 'float', 'left' ) |
|||
.insertAfter( '#p-variants' ); |
|||
} else { |
|||
.insertAfter( '#p-variants' ); |
|||
if ( $node.length ) { |
|||
⚫ | |||
var plink = mw.util.addPortletLink('p-associated-pages', '#', '' ); |
|||
var plinkAnchor = plink.querySelector( 'a' ); |
|||
plink.style.maxHeight = '32px'; |
|||
if ( plinkAnchor ) { |
|||
$node.appendTo( plinkAnchor ); |
|||
} |
|||
} |
|||
} |
|||
} ); |
|||
mw.hook('wikipage.content').add( function ( |
mw.hook('wikipage.content').add( function () { |
||
//if ( $( '#p-variants' ).next().hasClass('vectorTabs') ) return; |
//if ( $( '#p-variants' ).next().hasClass('vectorTabs') ) return; |
||
$( '#p-variants' ).next().remove(); // Will blink duing load preview, but this will avoid the icon won't removed if the TA template is removed, and avoid repeated click event listener from noteTAViewer. |
$( '#p-variants' ).next().remove(); // Will blink duing load preview, but this will avoid the icon won't removed if the TA template is removed, and avoid repeated click event listener from noteTAViewer. |
||
$( function () { |
|||
setTimeout(noteTAvector, 1); |
|||
} ); |
|||
}); |
}); |
2023年6月15日 (四) 19:11的版本
var noteTAvector = ( function() {
var associatedPages = document.getElementById( 'p-associated-pages' );
var useLegacyMode = !associatedPages;
var makeSpan = function () {
return $( '<span style="padding:1px 3px; background: #d3e3f4; color:#000000;height:85%;">汉</span><span style="padding:1px 3px; background: #e9e9e9; color:#434343;height:85%;">漢</span>' );
};
var mapIndicatorLegacy = function() {
$( '<a href="#">' ).html( makeSpan() )
.click( function( e ) {
e.preventDefault();
} )
.wrap( '<ul><li><span></span></li></ul>' )
.parent().parent().parent().appendTo( this );
};
var mapIndicator = function () {
makeSpan().appendTo( this );
};
var $node = $( 'body.skin-vector-legacy,body.skin-vector-2022' )
.find( '.mw-indicator[id^=mw-indicator-noteTA-]' )
.removeAttr( 'style' )
.removeClass( 'mw-indicator')
.empty()
.each( useLegacyMode ? mapIndicatorLegacy : mapIndicator );
if ( useLegacyMode ) {
$node.addClass( 'vector-menu' )
.addClass( 'vector-menu-tabs' )
.addClass( 'vector-menu-tabs-legacy' )
.css( 'float', 'left' )
.insertAfter( '#p-variants' );
} else {
if ( $node.length ) {
var plink = mw.util.addPortletLink('p-associated-pages', '#', '' );
var plinkAnchor = plink.querySelector( 'a' );
plink.style.maxHeight = '32px';
if ( plinkAnchor ) {
$node.appendTo( plinkAnchor );
}
}
}
} );
mw.hook('wikipage.content').add( function () {
//if ( $( '#p-variants' ).next().hasClass('vectorTabs') ) return;
$( '#p-variants' ).next().remove(); // Will blink duing load preview, but this will avoid the icon won't removed if the TA template is removed, and avoid repeated click event listener from noteTAViewer.
$( function () {
setTimeout(noteTAvector, 1);
} );
});