MediaWiki:TemplateCard.js

蓮花祖泉讨论 | 贡献2024年3月1日 (五) 23:18的版本 (创建页面,内容为“→‎* * This script interacts with [[Template:Card]] * [[Category:Template script pages]]:​ var TemplateCard = { init: function () { $( '#mw-content-text' ).find( '.card-content' ).each( TemplateCard.trimList ); }, →‎* * Trim lists of more than 10 items * Example: [[Appropedia:Admin panel]]:​ trimList: function ( event ) { var $button = $( '<span>more</span>' ).css( 'cursor', 'pointer' ).on( 'click', function () { $( this ).hide().sibling…”

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
/**
 * This script interacts with [[Template:Card]]
 * [[Category:Template script pages]]
 */

var TemplateCard = {

	init: function () {
		$( '#mw-content-text' ).find( '.card-content' ).each( TemplateCard.trimList );
	},

	/**
	 * Trim lists of more than 10 items
	 * Example: [[Appropedia:Admin panel]]
	 */
	trimList: function ( event ) {
		var $button = $( '<span>more</span>' ).css( 'cursor', 'pointer' ).on( 'click', function () {
			$( this ).hide().siblings().show();
		} );
		$( this ).find( 'li' ).eq( 10 ).nextAll().hide().last().after( $button );
	}
};

$( TemplateCard.init );