MediaWiki:TemplateCard.js: Difference between revisions

From Regenerate Willamette Valley
Appropedia>Sophivorus
No edit summary
 
m 1 revision imported
 
(No difference)

Latest revision as of 14:01, 9 December 2024

/**
 * 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 );