* Re-order the functions to be defined before their first use.
* The one exception is loadChildren() which is also toggled
indirectly from a click handle, and is thus intentionally
recursive in nature:
load content > attach handler > click > expand content
> load content.
Fix this by declaring 'loadChildren' specifically ahead of time
and assigning it last. This declares it to be safe for use in
any function, knowing it is only triggered indirectly from
event handlers and not during setup.
Change-Id: If2d49e2ff5d25e330165a2d3f0860f611fc3bdb5
Follows-up 680cdd688a, which accessed the data attribute
using data() instead of attr(), making it thus be parsed as JSON,
only to be re-encoded with JSON.stringify().
I considered to instead change the 'wgCategoryTreePageCategoryOptions'
mw.config var to not be double-encoded as JSON, but concluded
it actually makes sense the way it is. Right now the options are,
from the client-side perspective, considered to be a blackbox string
set on either a link attribute, or in an mw.config key, and are
to be passed as-is (in whatever format) to the 'options' parameter
of the API module.
At least until we need these values on the client (which we don't right now)
it makes more sense not to have any js for decoding and re-coding.
Change-Id: I1e1e02a13d7a5293c9ae2e0ec61575ddb7a1f286
The href="#" shows a status line and allows to open a new tab on middle
click.
Add tabindex="0" and role="button" instead to still allow to focus the
element with the keyboard.
Add JavaScript event handler for the return key of the keyboard to still
allow to trigger the event with the keyboard.
Change-Id: I3f4c14d335f3a06bc67f148558e5b9a1534671bf
The tooltips are not right while loading and for clients with disabled
JavaScript.
Add the title attribute with JavaScript instead of PHP.
Centralize attaching in new function attachHandler.
Change-Id: I2a1b29ca204b61b5fec1d3244528e3f3d8ed6ad7
* Hide toggle buttons for clients without JavaScript via CSS.
* This also avoids rerendering while loading for clients with JavaScript.
* Hide CategoryTreeEmptyBullet for clients without JavaScript.
* Show the normal bullets for clients without JavaScript.
* Add cursor:pointer only when JavaScript handler is attached.
* Avoid selecting the buttons as selection.
Bug: T168770
Change-Id: I42678b87af84dee49ca06d950d8beddcc3b7a9f4
The extension CT_* defines are replaced by class constants.
We currently keep the former defines in CategoryTree.php,
to help to set the default configuration. When the code
will be migrated to use the extension registration, we'll
remove the defines.
Bug: T87888
Change-Id: I59e6b9319fd5130c51a23f21ea81d4dbf3f28b8e
The JavaScript side injection of message 'categorytree-expand' was introduced in 026cc407.
The intent of not initializing $wgLang does not work anymore, because
there are some other wfMessage() calls in the same request.
Change-Id: Idf0815654e1e095acccbe10afe0726bc8766f8ae
Load the subtree in the current user interface settings set by the
URL parameters debug, uselang and useskin.
Change-Id: I11c58e62b641c926a9965efb01d776851807e651
* Trim trailing whitespace on lines.
* Remove css that has been commented for 5 years (63e25672).
* Remove comment about $wgCategoryTreeVersion which was
removed 2 years ago (e77ae54).
* Add missing spaces in CSS and JS.
Change-Id: Icb28293b445880246f2b4273daab2fb21c2638df
* 0 is falsy, cover for that case
* Add comments explaining the numbers, these come from PHP constants, via $wgCategoryTreePageCategoryOptions end up in data- attributes
* Follow-up r112849
* Use dashes versions of data attributes to make it easier to find them (now the data attributes as found in PHP where no where to be found in any JS file, appeared to be bogus)
* Don't create a new <div> element ($parentTag) only to store a single string in it's data object, using local variables for ctTitle, ctMode and ctOptions instead.
There's a couple of WTF moments in the code, this is really due to some issues with the PHP side of stuff. It really needs some TLC but for right now it works, I'll come back to it before 1.19 and clean it up.