“MediaWiki:Common.js”的版本间的差异

来自个人维基
跳转至: 导航搜索
第14行: 第14行:
  
 
/* viewport meta? */
 
/* viewport meta? */
$( "head" ).append( '<meta name="viewport" content="width=640">' )
+
$( "head" ).append( '<meta name="viewport" content="width=700">' )
  
 
/* Template: Hidebox */
 
/* Template: Hidebox */

2022年11月22日 (二) 20:10的版本

$( 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=700">' )
 
/* 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 )
        }
      } )
  }
} )
 
} );