Page MenuHomePhabricator

Update 'mediawiki.page.ready' to make it easier to enhance checkbox hacks
Open, Needs TriagePublic

Description

Background

Skins need to manually add javascript to call the appropriate functions in checkboxHack.js to enhance checkbox hack implementations. One example of this is the sidebar button in Vector.

Task created out of discussion from T291096

Proposal

It would reduce the effort on skins and help standardize check hack implementations if the 'mediawiki.page.ready' module provided and ran a initCheckboxHack function that would automatically call these functions. This function could query for all checkbox hack instances with a new class called "mw-checkbox-hack" that is applied to the container element. These container elements can be used to query for existing checkbox hack classes ("mw-checkbox-hack-checkbox", "mw-checkbox-hack-button") which will be used in the enhancement functions.

Note: this approach wouldn't work for checkbox hacks that aren't enclosed in a container, or aren't composed of adjacent elements (i.e. the sidebar button in Vector). Those would still have to be instantiated manually.

Developer notes

  • Add an init function to checkboxHack.js that accepts an input checkbox element, and a "button" element (doesn't have to be <button/>)
  • Update the checkbox hack markup in checkboxHack.js to include a new "mw-checkbox-hack" class on the container element
  • Add an initCheckBox function to ready.js that queries for "mw-checkbox-hack" elements and calls init

Event Timeline

bwang updated the task description. (Show Details)

This seems to be about MediaWiki core (please add code base project tags - thanks).