跳转到内容

MediaWiki:Gadget-noteTAvector.js:修订间差异

维基百科,自由的百科全书
删除的内容 添加的内容
回退到由Shizhao讨论)做出的修订版本72830958:Rv
标签TW 撤销
Jon (WMF)留言 | 贡献
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 = ( function() { $( function() {
var noteTAvector = ( function() {
var associatedPages = document.getElementById( 'p-associated-pages' );
$( 'body.skin-vector .mw-indicator[id^=mw-indicator-noteTA-]' )
var useLegacyMode = !associatedPages;
.addClass( 'vector-menu' )
var makeSpan = function () {
.addClass( 'vector-menu-tabs' )
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>' );
//.addClass( 'vectorTabs' )
};
.addClass( 'vector-menu-tabs-legacy' )
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' )
.removeAttr( 'style' )
.css( 'float', 'left' )
.removeClass( 'mw-indicator')
.empty()
.empty()
.each( function() {
.each( useLegacyMode ? mapIndicatorLegacy : mapIndicator );

$( '<a href="#"><span style="padding:1px 3px; background: #d3e3f4; color:#000000;height:85%;">汉</span><span style="padding:1px 3px; background: #e9e9e9; color:#434343;height:85%;">漢</span></a>' )
.click( function( e ) {
if ( useLegacyMode ) {
$node.addClass( 'vector-menu' )
e.preventDefault();
} )
.addClass( 'vector-menu-tabs' )
.wrap( '<ul><li><span></span></li></ul>' )
.addClass( 'vector-menu-tabs-legacy' )
.parent().parent().parent().appendTo( this );
.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 ( $content ) {
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.
setTimeout("noteTAvector();", 1);
$( 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);
    } );
});