User:PerfektesChaos/js/catTreeToggling

arrow downwardsarrow upwards

JavaScript gadget – toggle all branches of all CategoryTree elements in current page.

Usage

edit
  • If your project has registered this as a gadget, just activate on your Preferences page.
  • Otherwise include the following line into your common.js, global.js etc.:
mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/catTreeToggling/r.js&action=raw&maxage=86400&ctype=text/javascript" );

If you want to avoid unnecessary JavaScript execution you may limit loading to category pages only:

if ( mw.config.get( "wgNamespaceNumber" ) === 14 ) {
   mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/catTreeToggling/r.js&action=raw&maxage=86400&ctype=text/javascript" );
}

Please note that there is also Special:CategoryTree which is excluded by this rule as well.

Functionality

edit

Every CategoryTree can be expanded at various stages, or collapsed interactively.

  • If you loose track, you may want to close all trees immediately since you have opened too many.
  • If you want to explore sub-categories, it may be helpful to open all (first) sub-categories at once.

On pages with a CategoryTree element and activated catTreeToggling the toolbox will appear in the upper right corner (as demonstrated on this page). Just click a triangle.

Symbols
  Open all currently visible branches (expand).

The next sub-category level of each branch will be expanded. If that one has been expanded somewhen before, it will expand its children.

  Collapse all currently visible branches.

All visible sub-category levels will be collapsed as well. On reopening, they start collapsed.

Internationalization

edit

A translation of this page may be offered.

Codes

edit
Source code
ResourceLoader
Namespaces all
Actions view edit submit
mw.libs catTreeToggling (reserved, but currently unused)
mw.hook
  • catTreeToggling.ready
    When code has been loaded.
    Tells implementation metadata.
MediaWiki MW 1.22
JavaScript 1.5 (2000)