MediaWiki:CharacterTable.js

Revision as of 07:37, 24 January 2023 by Electricsheep (talk | contribs) (Created page with "$( document ).ready(function() { $(".charactertable-controls > .controls > span").on("click", function(){characterTableToggle($(this));}); }); function characterTableToggle (toggleItem){ //console.log('toggling '+toggleItem.attr('data-toggle')); toggleItem = (typeof toggleItem !== 'undefined') ? toggleItem : false; //default false, ES5 does not support function defaults if (toggleItem) { (toggleItem.hasClass("inactive")) ? toggleItem.addClass('active').removeClas...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$( document ).ready(function() {
	$(".charactertable-controls > .controls > span").on("click", function(){characterTableToggle($(this));});
});

function characterTableToggle (toggleItem){
	//console.log('toggling '+toggleItem.attr('data-toggle'));
	toggleItem = (typeof toggleItem !== 'undefined') ? toggleItem : false; //default false, ES5 does not support function defaults

	if (toggleItem) {
		(toggleItem.hasClass("inactive")) ? toggleItem.addClass('active').removeClass('inactive') : toggleItem.addClass('inactive').removeClass('active');

		$(".charactertable tr."+toggleItem.attr('data-toggle')).each(function (element){
			($(this).hasClass("hidden")) ? $(this).addClass('visible').removeClass('hidden') : $(this).addClass('hidden').removeClass('visible');
		});

	}
}