旧站的内容可能已过时。您可以前往“真魂”分站查看本页面,那里的内容将会定期同步。
“MediaWiki:Common.js”的版本间的差异
来自个人维基
小 (尝试修复在一些浏览器中hidebox折叠时三角指示器不归位的问题) |
小 (撤销版本99714) |
||
第54行: | 第54行: | ||
height: "" | height: "" | ||
} ) | } ) | ||
− | |||
.removeAttr( "data-lnnblog-hidebox-state" ) | .removeAttr( "data-lnnblog-hidebox-state" ) | ||
} | } | ||
第84行: | 第83行: | ||
height: "" | height: "" | ||
} ) | } ) | ||
− | |||
.removeAttr( "data-lnnblog-hidebox-state" ) | .removeAttr( "data-lnnblog-hidebox-state" ) | ||
.prop( "open", false ) | .prop( "open", false ) |
2022年11月22日 (二) 13:34的版本
$( function () { /* 缺省将内容 lang 设置成简体中文 */ if ( !document.getElementById( "lnnblog-setlang" ) ) { $( "mw-content-text" ).attr( "lang", "zh-cmn-Hans" ); $( "firstHeading" ).attr( "lang", "zh-cmn-Hans" ); } /* 评论框内联 CSS 修正 */ $( "#addComment" ).css( "width", "" ).css( "max-width", "500px" ); $( "#addComment textarea" ).css( "width", "100%" ).css( "box-sizing", "border-box" ); $( "#addComment form .greyTiny" ).css( "padding-left", "" ); $( "#addComment textarea+div" ).css( "text-align", "right" ); /* viewport meta? */ $( "head" ).append( '<meta name="viewport" content="width=720">' ) /* Template: Hidebox */ var animationDuration = 250 $( "#bodyContent" ).on( "click", ".lnnblog-hidebox-heading", function ( event ) { var $this = $( this ) var $parent = $this.parent() var $body = $this.nextAll( ".lnnblog-hidebox-body" ) var open = $parent.prop( "open" ) var state = $parent.attr( "data-lnnblog-hidebox-state" ) if ( !open || state === "shrink" ) { event.preventDefault() var currentWidth = $parent.width() var currentHeight = $parent.height() $parent.stop( true, true ).prop( "open", true ) var targetWidth = $parent.width() var targetHeight = $parent.height() $body.outerWidth( targetWidth + 1 ) $parent .attr( "data-lnnblog-hidebox-state", "expand" ) .width( currentWidth ) .height( currentHeight ) $parent.animate( { width: targetWidth, height: targetHeight }, { duration: animationDuration, done: function () { $body.css( "width", "" ) $parent .css( { width: "", height: "" } ) .removeAttr( "data-lnnblog-hidebox-state" ) } } ) } else if ( open || state === "expand" ) { event.preventDefault() var currentWidth = $parent.width() var currentHeight = $parent.height() $parent.stop( true, true ).prop( "open", false ) var targetWidth = $parent.width() var targetHeight = $parent.height() state === "expand" || $body.outerWidth( currentWidth + 1 ) $parent .attr( "data-lnnblog-hidebox-state", "shrink" ) .width( currentWidth ) .height( currentHeight ) .prop( "open", true ) .animate( { width: targetWidth, height: targetHeight }, { duration: animationDuration, done: function () { $body.css( "width", "" ) $parent .css( { width: "", height: "" } ) .removeAttr( "data-lnnblog-hidebox-state" ) .prop( "open", false ) } } ) } } ) } );