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

来自个人维基
跳转至: 导航搜索
第15行: 第15行:
 
/* viewport meta? */
 
/* viewport meta? */
 
var wide = window.outerWidth > 720
 
var wide = window.outerWidth > 720
var viewportMeta = $( '<meta name="viewport" content="width=' + (wide ? "device-width" : "700") + ">' )
+
var viewportMeta = $( '<meta name="viewport" content="width=' + (wide ? "device-width" : "700") + '">' )
 
$( "head" ).append(viewportMeta)
 
$( "head" ).append(viewportMeta)
 
$( window ).on( "resize", function () {
 
$( window ).on( "resize", function () {

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

$( 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? */
var wide = window.outerWidth > 720
var viewportMeta = $( '<meta name="viewport" content="width=' + (wide ? "device-width" : "700") + '">' )
$( "head" ).append(viewportMeta)
$( window ).on( "resize", function () {
	var wide_ = window.outerWidth > 720
	if (wide_ === wide) return
	wide = wide_
	viewportMeta.attr( "content", "width=" + (wide ? "device-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 )
        }
      } )
  }
} )
 
} );