打开主菜单

少前百科GFwiki β

更改

MediaWiki:Common.js

添加2,905字节2021年8月2日 (一) 00:30
fix bug
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
/* AspectRatio change */
!function(){var t=document.querySelectorAll(".reAspectRatio");if(0!=t.length)for(var e=0;e<t.length;e++){var l=t[e].dataset.aspectRatio;if(null!=l||0!=l.split(":").length){var i=t[e].querySelector("img");i.height=i.width*l.split(":")[1]/l.split(":")[0]}}}();
RLQ.push(function(){
/* 返回顶部按钮 */
RLQ.push(function(){
$(function() {
var txt = " ",
}).scroll();
});
})
/* goTop END */
});
//collapse 折叠2
$(function(){
$(".gfCollapse").click(function(e){
if($(this).next().prop("nodeName") == "P" && !($(this).next().html())){
var nextElement = $(this).next().next();
$(this).next().css("display", "none");
}else var nextElement = $(this).next();
if($(this).attr("status") == "none"){
$(this).attr("status", "visible");
var signElement = $(this).children().children(".gfCollapseSign");
signElement.html(signElement.attr("data-visible"));
nextElement.slideDown("fast");}
else{
$(this).attr("status", "none");
var signElement = $(this).children().children(".gfCollapseSign");
signElement.html(signElement.attr("data-none"));
nextElement.slideUp("fast");}
});
});
 
window.addEventListener("resize", function() {
$(".gfCollapse").children().css("max-width", parseInt(Number($(".gfCollapse").parent().width()) -40));});
window.addEventListener("load", function() {
$(".gfCollapse").children().css("max-width", parseInt(Number($(".gfCollapse").parent().width()) -40));});
/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton( $content ) {
//滚动公告
/* autoScroll("#scrollDiv"); */
 
//该部分代码复制自Wikipedia
//阅读更多:https://en.wikipedia.org/wiki/MediaWiki:Common.js
//文字内容遵守【知识共享 署名-非商业性使用-相同方式共享 3.0】协议。
mw.loader.using( 'mediawiki.util', function () {
/**
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
*
* Maintainers: TheDJ
*/
function mwCollapsibleSetup( $collapsibleContent ) {
var $element,
$toggle,
autoCollapseThreshold = 2;
$.each( $collapsibleContent, function ( index, element ) {
$element = $( element );
if ( $element.hasClass( 'collapsible' ) ) {
$element.find( 'tr:first > th:first' ).prepend( $element.find( 'tr:first > * > .mw-collapsible-toggle' ) );
}
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
$element.data( 'mw-collapsible' ).collapse();
} else if ( $element.hasClass( 'innercollapse' ) ) {
if ( $element.parents( '.outercollapse' ).length > 0 ) {
$element.data( 'mw-collapsible' ).collapse();
}
}
// because of colored backgrounds, style the link in the text color
// to ensure accessible contrast
$toggle = $element.find( '.mw-collapsible-toggle' );
if ( $toggle.length ) {
// Make the toggle inherit text color
if ( $toggle.parent()[ 0 ].style.color ) {
$toggle.find( 'a' ).css( 'color', 'inherit' );
}
}
} );
}
 
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
});
24,691
个编辑