<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cobblemon.com/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-site.js</id>
	<title>MediaWiki:Gadget-site.js - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cobblemon.com/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-site.js"/>
	<link rel="alternate" type="text/html" href="https://wiki.cobblemon.com/index.php?title=MediaWiki:Gadget-site.js&amp;action=history"/>
	<updated>2026-05-27T20:12:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.10</generator>
	<entry>
		<id>https://wiki.cobblemon.com/index.php?title=MediaWiki:Gadget-site.js&amp;diff=4920&amp;oldid=prev</id>
		<title>Blob: Created page with &quot;/**  * Collapsible elements  *  * Add the &quot;collapsible&quot; class to an element and the child element with class &quot;collapsible-content&quot;  * (or everything but the header row if a table) will be hidden when the element is collapsed.  *  * * Add the class &quot;collapsed&quot; to the element to make it start out collapsed.  * * Add either &quot;collapsetoggle-left&quot; or &quot;collapsetoggle-inline&quot; to the element to choose the collapse  *   toggle alignment (defaults to right).  * * Add an ID in the...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.cobblemon.com/index.php?title=MediaWiki:Gadget-site.js&amp;diff=4920&amp;oldid=prev"/>
		<updated>2024-07-22T06:54:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;/**  * Collapsible elements  *  * Add the &amp;quot;collapsible&amp;quot; class to an element and the child element with class &amp;quot;collapsible-content&amp;quot;  * (or everything but the header row if a table) will be hidden when the element is collapsed.  *  * * Add the class &amp;quot;collapsed&amp;quot; to the element to make it start out collapsed.  * * Add either &amp;quot;collapsetoggle-left&amp;quot; or &amp;quot;collapsetoggle-inline&amp;quot; to the element to choose the collapse  *   toggle alignment (defaults to right).  * * Add an ID in the...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;/**&lt;br /&gt;
 * Collapsible elements&lt;br /&gt;
 *&lt;br /&gt;
 * Add the &amp;quot;collapsible&amp;quot; class to an element and the child element with class &amp;quot;collapsible-content&amp;quot;&lt;br /&gt;
 * (or everything but the header row if a table) will be hidden when the element is collapsed.&lt;br /&gt;
 *&lt;br /&gt;
 * * Add the class &amp;quot;collapsed&amp;quot; to the element to make it start out collapsed.&lt;br /&gt;
 * * Add either &amp;quot;collapsetoggle-left&amp;quot; or &amp;quot;collapsetoggle-inline&amp;quot; to the element to choose the collapse&lt;br /&gt;
 *   toggle alignment (defaults to right).&lt;br /&gt;
 * * Add an ID in the format of &amp;quot;collapsible-&amp;lt;x&amp;gt;&amp;quot; to the element to make any element with the class&lt;br /&gt;
 *  &amp;quot;collapsetoggle-custom&amp;quot; and a matching class in the format of &amp;quot;collapsible-&amp;lt;x&amp;gt;-toggle&amp;quot; control&lt;br /&gt;
 *   the collapsing instead of the standard button.&lt;br /&gt;
 *   If the custom toggle contains an element with the &amp;quot;jslink&amp;quot; class, only that will be clickable.&lt;br /&gt;
 */&lt;br /&gt;
( function() {&lt;br /&gt;
	var $collapsibles = $wikipageContent.find( &amp;#039;.collapsible&amp;#039; );&lt;br /&gt;
	if ( !$collapsibles.length ) {&lt;br /&gt;
		return;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	var $toggleTemplate = $( &amp;#039;&amp;lt;span&amp;gt;&amp;#039; ).addClass( &amp;#039;collapsetoggle&amp;#039; ).append(&lt;br /&gt;
		&amp;#039;[&amp;#039;, $( &amp;#039;&amp;lt;span&amp;gt;&amp;#039; ).addClass( &amp;#039;jslink&amp;#039; ), &amp;#039;]&amp;#039;&lt;br /&gt;
	);&lt;br /&gt;
	$collapsibles.each( function() {&lt;br /&gt;
		var $collapsible = $( this );&lt;br /&gt;
		if ( $collapsible.data( &amp;#039;made-collapsible&amp;#039; ) ) {&lt;br /&gt;
			return true;&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		var $children = $collapsible.children();&lt;br /&gt;
		var showText = $collapsible.data( &amp;#039;expandtext&amp;#039; ) || i18n.showText;&lt;br /&gt;
		var hideText = $collapsible.data( &amp;#039;collapsetext&amp;#039; ) || i18n.hideText;&lt;br /&gt;
		&lt;br /&gt;
		// If there is no content area, add it&lt;br /&gt;
		if ( !$collapsible.is( &amp;#039;table&amp;#039; ) &amp;amp;&amp;amp; !$children.filter( &amp;#039;.collapsible-content&amp;#039; ).length ) {&lt;br /&gt;
			if ( $collapsible.is( &amp;#039;tr.collapsible-rows&amp;#039; ) ) {&lt;br /&gt;
				var $collapsibleRows = $collapsible.nextUntil( &amp;#039;.collapsible-rows&amp;#039; );&lt;br /&gt;
				if ( $collapsibleRows.hasClass( &amp;#039;collapsible-row&amp;#039; ) ) {&lt;br /&gt;
					$collapsibleRows = $collapsibleRows.filter( &amp;#039;collapsible-row&amp;#039; );&lt;br /&gt;
				} else {&lt;br /&gt;
					$collapsibleRows.addClass( &amp;#039;collapsible-row&amp;#039; );&lt;br /&gt;
				}&lt;br /&gt;
				if ( $collapsible.hasClass( &amp;#039;collapsed&amp;#039; ) &amp;amp;&amp;amp; !$collapsibleRows.hasClass( &amp;#039;collapsed&amp;#039; ) ) {&lt;br /&gt;
					$collapsibleRows.addClass( &amp;#039;collapsed&amp;#039; );&lt;br /&gt;
				}&lt;br /&gt;
				$collapsible = $collapsible.add( $collapsibleRows );&lt;br /&gt;
			} else if ( $collapsible.is( &amp;#039;tr&amp;#039; ) ) {&lt;br /&gt;
				$children.addClass( &amp;#039;collapsible-content&amp;#039; );&lt;br /&gt;
			} else {&lt;br /&gt;
				$collapsible.wrapInner( &amp;#039;&amp;lt;div class=&amp;quot;collapsible-content&amp;quot;&amp;gt;&amp;#039; );&lt;br /&gt;
				$children = $collapsible.children();&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		var $toggle;&lt;br /&gt;
		var id = $collapsible.attr( &amp;#039;id&amp;#039; );&lt;br /&gt;
		if ( id &amp;amp;&amp;amp; id.match( /^collapsible-./ ) ) {&lt;br /&gt;
			$toggle = $( $wikipageContent[0].getElementsByClassName( id + &amp;#039;-toggle&amp;#039; ) )&lt;br /&gt;
				.filter( &amp;#039;.collapsetoggle-custom&amp;#039; ).css( &amp;#039;visibility&amp;#039;, &amp;#039;visible&amp;#039; );&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Create and insert the toggle button if there is no custom one&lt;br /&gt;
		if ( !$toggle || !$toggle.length ) {&lt;br /&gt;
			var $toggleContainer;&lt;br /&gt;
			if ( $collapsible.is( &amp;#039;table&amp;#039; ) ) {&lt;br /&gt;
				var $rows = $children.filter( &amp;#039;thead&amp;#039; ).children();&lt;br /&gt;
				if ( !$rows.length ) {&lt;br /&gt;
					$rows = $children.filter( &amp;#039;tbody&amp;#039; ).first().children();&lt;br /&gt;
					if ( !$rows.length ) {&lt;br /&gt;
						$rows = $children.filter( &amp;#039;tr&amp;#039; );&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
				$toggleContainer = $rows.first().children().last();&lt;br /&gt;
			} else {&lt;br /&gt;
				$toggleContainer = $children.first();&lt;br /&gt;
				if ( $toggleContainer.hasClass( &amp;#039;collapsible-content&amp;#039; ) ) {&lt;br /&gt;
					$toggleContainer = $collapsible;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			$toggle = $toggleTemplate.clone();&lt;br /&gt;
			if (&lt;br /&gt;
				$toggleContainer !== $collapsible &amp;amp;&amp;amp; (&lt;br /&gt;
				$collapsible.hasClass( &amp;#039;collapsetoggle-inline&amp;#039; ) ||&lt;br /&gt;
				$collapsible.hasClass( &amp;#039;collapse-button-none&amp;#039; )&lt;br /&gt;
			) ) {&lt;br /&gt;
				$toggleContainer.append( $toggle );&lt;br /&gt;
			} else {&lt;br /&gt;
				$toggleContainer.prepend( $toggle );&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		var $toggleLink = $toggle.find( &amp;#039;.jslink&amp;#039; );&lt;br /&gt;
		if ( !$toggleLink.length ) {&lt;br /&gt;
			$toggleLink = $toggle;&lt;br /&gt;
		}&lt;br /&gt;
		$toggleLink.attr( &amp;#039;tabindex&amp;#039;, 0 ).text( hideText );&lt;br /&gt;
		&lt;br /&gt;
		// Find max toggle size, and set its min-width to it&lt;br /&gt;
		var hideWidth = $toggle.width();&lt;br /&gt;
		$toggleLink.text( showText );&lt;br /&gt;
		var showWidth = $toggle.width();&lt;br /&gt;
		if ( hideWidth !== showWidth ) {&lt;br /&gt;
			$toggle.css( &amp;#039;min-width&amp;#039;, hideWidth &amp;gt; showWidth ? hideWidth : showWidth );&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		// Set the text back to hide if it&amp;#039;s not collapsed to begin with&lt;br /&gt;
		if ( !$collapsible.first().hasClass( &amp;#039;collapsed&amp;#039; ) ) {&lt;br /&gt;
			$toggleLink.text( hideText );&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		$toggleLink.on( &amp;#039;click keydown&amp;#039;, function( e ) {&lt;br /&gt;
			// Only trigger on enter press&lt;br /&gt;
			if ( e.keyCode &amp;amp;&amp;amp; e.keyCode !== 13 ) {&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			// Don&amp;#039;t toggle when clicking buttons or links inside the toggle&lt;br /&gt;
			var $target = $( e.target );&lt;br /&gt;
			if ( $target.is( &amp;#039;button&amp;#039; ) || $target.is( &amp;#039;a&amp;#039; ) ) {&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			$collapsible.toggleClass( &amp;#039;collapsed&amp;#039; );&lt;br /&gt;
			if ( $collapsible.first().hasClass( &amp;#039;collapsed&amp;#039; ) ) {&lt;br /&gt;
				$toggleLink.text( showText );&lt;br /&gt;
			} else {&lt;br /&gt;
				$toggleLink.text( hideText );&lt;br /&gt;
			}&lt;br /&gt;
			&lt;br /&gt;
			// Stop table sorting activating when clicking the link&lt;br /&gt;
			e.stopPropagation();&lt;br /&gt;
		} );&lt;br /&gt;
		&lt;br /&gt;
		$collapsible.data( &amp;#039;made-collapsible&amp;#039;, true );&lt;br /&gt;
	} );&lt;br /&gt;
}() );&lt;/div&gt;</summary>
		<author><name>Blob</name></author>
	</entry>
</feed>