欢迎来到奇葩栖息地!欢迎加入Discord服务器:XfrfHCzfbW。请先至特殊:参数设置验证邮箱后再进行编辑。在特殊:参数设置挑选自己想要使用的小工具!不会编辑?请至这里学习Wikitext语法。
MediaWiki:Common.js:修订间差异
来自奇葩栖息地
添加的内容 删除的内容
SkyEye FAST(讨论 | 贡献) (建立内容为“→这里的任何JavaScript将为所有用户在每次页面载入时加载。: /** * Set minimum height for animations to prevent moving the page if the fra…”的新页面) |
SkyEye FAST(讨论 | 贡献) (// Edit via InPageEdit) |
||
第39行: | 第39行: | ||
} ).removeClass( 'animated-visible' ); |
} ).removeClass( 'animated-visible' ); |
||
}() ); |
}() ); |
||
⚫ | |||
/** |
|||
/** 顶部公告 **/ |
|||
* Animated Site Announcement |
|||
/* From wjghj.cn under CC BY-NC-SA 4.0*/ |
|||
* |
|||
function siteNoticeScroll(obj,interval) { |
|||
* To show mutiple announcements. |
|||
$(obj).animate({ |
|||
⚫ | |||
height: 'show', |
|||
⚫ | |||
paddingTop: 'show', |
|||
var $content = $( '#localNotice' ); |
|||
marginTop: 'show', |
|||
var advanceFrame = function( parentElem, parentSelector ) { |
|||
paddingBottom: 'show', |
|||
var curFrame = parentElem.querySelector( parentSelector + ' > .animated-active' ); |
|||
marginBottom: 'show', |
|||
$( curFrame ).removeClass( 'animated-active' ); |
|||
}); |
|||
var $nextFrame = $( curFrame && curFrame.nextElementSibling || parentElem.firstElementChild ); |
|||
⚫ | |||
return $nextFrame.addClass( 'animated-active' ); |
|||
$(obj).find('ul:first').animate({ |
|||
}; |
|||
marginTop: '-25px' |
|||
⚫ | |||
}, |
|||
$content.find( '.animated' ).each( function() { |
|||
300, |
|||
var $nextFrame = advanceFrame( this, '.animated' ); |
|||
⚫ | |||
if ( $nextFrame.hasClass( 'animated-subframe' ) ) { |
|||
$(this).css({ |
|||
advanceFrame( $nextFrame[0], '.animated-subframe' ); |
|||
marginTop: '0px', |
|||
} |
|||
}).find('li:first').appendTo(this); |
|||
} ); |
|||
}, 2000 ); |
|||
}, |
|||
}() ); |
|||
interval); |
|||
} |
|||
siteNoticeScroll('.siteNoticeScroll',5000); |
|||
/* [[Template:Tabs]] */ |
/* [[Template:Tabs]] */ |
2021年6月6日 (日) 16:03的版本
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
/**
* Set minimum height for animations to prevent moving the page if the frames
* differ in height
*/
/*
( function() {
// Set frames to be visible for measuring height
var $animated = $wikipageContent.find( '.animated' ).addClass( 'animated-visible' );
// Group frames per animation
var animateds = [];
$animated.each( function() {
animateds.push( {
$: $( this ).find( '> .animated-subframe' ).addBack()
.find( '> *:not(.animated-subframe)' ),
} );
} );
// Get highest frame for each animation (if heights differ)
$.each( animateds, function() {
var minHeight = 0, differentHeights;
this.$.each( function() {
var height = this.offsetHeight;
differentHeights = differentHeights || minHeight && height !== minHeight;
minHeight = Math.max( height, minHeight );
} );
if ( differentHeights ) {
this.height = minHeight;
}
} );
// Set animation to be at least as tall as the tallest frame,
// and set the non-active frames to be hidden again
$animated.each( function( i ) {
$( this ).css( 'min-height', animateds[i].height );
} ).removeClass( 'animated-visible' );
}() );
/**
* Animated Site Announcement
*
* To show mutiple announcements.
*/
( function() {
var $content = $( '#localNotice' );
var advanceFrame = function( parentElem, parentSelector ) {
var curFrame = parentElem.querySelector( parentSelector + ' > .animated-active' );
$( curFrame ).removeClass( 'animated-active' );
var $nextFrame = $( curFrame && curFrame.nextElementSibling || parentElem.firstElementChild );
return $nextFrame.addClass( 'animated-active' );
};
setInterval( function() {
$content.find( '.animated' ).each( function() {
var $nextFrame = advanceFrame( this, '.animated' );
if ( $nextFrame.hasClass( 'animated-subframe' ) ) {
advanceFrame( $nextFrame[0], '.animated-subframe' );
}
} );
}, 2000 );
}() );
/* [[Template:Tabs]] */
$(".tabtable").each(function(i, e) {
var $table = $(e);
var $nav = $table.find(".tabtable-nav");
$table.find(".tabtable-cell").each(function(i, e) {
var $cell = $(e);
var $tab = $("<div class='tabtable-tab'><span>" + $cell.attr("data-title") +"</span></div>");
$nav.append($tab);
$tab.click(function() {
$table.find(".tabtable-cell").removeClass("active");
$cell.addClass("active");
$nav.find(".tabtable-tab").removeClass("active");
$tab.addClass("active");
});
});
$table.find(".tabtable-cell").first().addClass("active");
$nav.find(".tabtable-tab").first().addClass("active");
});
/* debug */
console.info('Common.js has been successfully loaded.');