Commit graph

74 commits

Author SHA1 Message Date
Ebrahim Byagowi 77b047b12b Remove page href from arrows
As having href causes arrows to be clickable before JavaScript
handler be loaded.

And since that disables visited logic, let's remove it.

Change-Id: Ice4c979d020342890fffd587bb5bee88fcc2a1ae
2024-11-05 13:06:36 +03:30
Fomafix a62550b687 Get mode from data-ct-options instead of data-ct-mode
The attribute data-ct-options already contains the mode and attribute
data-ct-mode is just redundant. The attribute data-ct-mode is now not
needed anymore and removed from the rendered HTML.

Change-Id: If261f3cdab6c55243e80dc2ef3caa884538b02bc
2024-11-04 12:08:22 +00:00
jenkins-bot bb50f5e006 Merge "Remove redundant closure for all modules with packageFiles" 2024-10-10 15:53:44 +00:00
jenkins-bot a6eb9c0e57 Merge "Use ES6 features" 2024-10-10 15:53:42 +00:00
jenkins-bot 77c080c761 Merge "Use margin-inline mixin to simplify direction specific styles" 2024-10-06 09:53:08 +00:00
Ebrahim Byagowi bd4efc18ee Define a variable to reuse a value
Change-Id: I2d9c62f5920bf82f564bd01a38a213e7a95b0205
2024-10-06 12:34:27 +03:30
Ebrahim Byagowi 6f8049b2ed Use margin-inline mixin to simplify direction specific styles
Bug: T371265
Change-Id: Iffc9c8ad36ae53b36c9135c206d1c1e02d67b6e2
2024-10-06 11:52:27 +03:30
jenkins-bot 3684f26994 Merge "Make CategoryTree arrow expansion work outside mw-content-{ltr,rtl}" 2024-10-06 06:18:58 +00:00
Ebrahim Byagowi b66d6a38c4 Make disabled arrow more distinguishable
Change-Id: I2b70195ce5135dc181ef8b80af1aead0304a9cfc
2024-10-06 00:03:30 +03:30
Ebrahim Byagowi be7320b4fc Make CategoryTree arrow expansion work outside mw-content-{ltr,rtl}
The old code relies on CSS Janus to transform the default case outside
mw-content-{ltr,rtl} which can't be applied here so let's consider
this case also by relying only on dir attributes, the same direction
as T371265.

In future we can use &:dir( ltr ) and &:dir( rtl ) as we do in new
codes but as that isn't supported on all browsers we support.

Change-Id: Icf6b8e184ce981e6e8f16dafa9e14a19154ff0e3
2024-10-05 16:59:46 +03:30
Fomafix 9c5ccf4b74 Remove redundant closure for all modules with packageFiles
Modules loaded with packageFiles are always executed in module scope
(with a closure), even in debug mode.

The behaviour of non-packageFiles debug mode is the only reason files
have closures.

https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript#Closure

Change-Id: I7ea2057029a63148a96333af7ff09a7885d2daa8
2024-10-05 06:49:13 +00:00
Fomafix 0eb9b7d86c Use ES6 features
Bug: T334853
Change-Id: I48eef3424f4b4028f4ac668a12692af95d79c288
2024-10-05 06:49:00 +00:00
jenkins-bot 5ba10fcef7 Merge "Make category links arrow link to actual categories" 2024-10-04 23:12:32 +00:00
Ebrahim Byagowi fcc3334125 Make category links arrow link to actual categories
I believe having arrows linked to the actual pages can
be much more useful than linking to '#' of the same
page. Linking to the correct page makes user to notice
if the page is already visited also using color of
the arrow.

If we didn't like link visited logic to be not used we
could've used a different link rather than color of links
and going makes us able to :visited logic of
If8b2b45b24351ee5c8fc9ee1380563f5d5b88678 also.

Personally however I'm in believe that having a useful
link that can be opened on a different tab using
Ctrl (or long click on phones) is always more useful.

Change-Id: Ib56fad0b711853d67b2d55617b36deff56141c74
2024-10-05 00:48:31 +03:30
Ebrahim Byagowi 451aeceba1 Use Codex provided arrow icons for the tree
It also adds an animation for the arrow matching other
recently Codex provided arrow icons adopted animations.

Change-Id: If8b2b45b24351ee5c8fc9ee1380563f5d5b88678
2024-10-05 00:07:05 +03:30
Nardog fb6d6c42b0 Remove obsolete styles for bullets
The toggle is now a link element, so we can let the skin choose its
color.

cursor and text-decoration had no effect because the triangle is
rendered by borders and the element itself is empty.

speak is deprecated, and since the toggle is reachable by keyboard now,
it's no longer appropriate.

Change-Id: Id522b78d185d951b0739758ad20bb5b3dbbc546e
2024-02-15 23:11:34 +00:00
Nardog 08a23b5c26 Make the toggle reachable by keyboard
Bug: T355636
Change-Id: Ie765cddd664933fa07638c661874bef80782dd45
2024-02-05 06:53:05 +00:00
Fomafix 3f38eb6cd1 Use .css() instead of .show() and .hide()
jQuery's .show() and .hide() make some actions which are not needed here.

Change-Id: I606430fa1922841f9974d7334f646fcedbf03173
2021-09-17 06:47:58 +00:00
Fomafix 6c36a1a3d7 Simplify JavaScript
Change-Id: Idfbb623c23a1b202869293e0b89cb83e6d41f4ad
2021-09-17 06:47:45 +00:00
Fomafix 5e61b40ee0 Restore support for modes for subcategories in Special:CategoryTree
This feature was lost in c839756b.

Before c839756b on Special:CategoryTree the mode was transfered via the
individual global JavaScript variable wgCategoryTreePageCategoryOptions.
c839756b removed the possibility to set the global JavaScript variable
to a page individual value.

Now Special:CategoryTree uses the HTML attribute to transfer the
individual options to JavaScript like at a <categorytree> tag.

Bug: T289997
Change-Id: I706c0ca89d84e3583eeee27a411f734c6969a8b7
2021-09-09 17:20:02 +00:00
Fomafix f37cd36f13 Step 2 of move bullets from HTML to CSS
This change is a follow-up to Ibfb0cb28f0086fb1b7d0997be2246bc120eea85e.

Do not deploy this change before the HTML caches have expired or purged.

Bug: T288910
Change-Id: Ia9b7b1a6d46029acfeb407a0933ffeec203d12b2
2021-09-08 18:49:23 +00:00
jenkins-bot 0d28bbe1b0 Merge "Remove @noflip workaround for T288943" 2021-08-28 19:14:05 +00:00
Fomafix d1af686a0d Remove eslint exception rule 'no-shadow' and rename variable
Also fix JSDoc warnings.

Change-Id: Idb2f15bd9ce134b17381bde1303a2e427c3056fb
2021-08-28 19:05:52 +00:00
Fomafix 107d03af53 Remove @noflip workaround for T288943
This change requires CSSJanus version 2.0.0 included in core by
I0528443e4eae0338f5a37491352db03944c6bd4c since MediaWiki 1.37.

Bug: T288943
Depends-On: I0528443e4eae0338f5a37491352db03944c6bd4c
Change-Id: I38c08b2073e10e7d56b286b1ae75b400578ce2dd
2021-08-21 14:53:53 +00:00
Fomafix 629e0509b8 Use CSS instead of Unicode to create triangles
The Unicode characters have a different shape based on the font.

Bug: T184792
Change-Id: Ia5e506f25067558cb9f879c7d1dca707ea795603
2021-08-21 14:53:12 +00:00
Fomafix 0bfff67aac Move bullets from HTML to CSS
This allows better to style the buttons.

The complicated CSS selector for the direction supports a categorytree
in the user interface language like in the sidebar or on
Special:CategoryTree and in the content language like on category pages
and with <categorytree> in the content.

The CSS selector :dir( rtl ) would be a short version for this but it is
currently only supported by Firefox:
https://developer.mozilla.org/en-US/docs/Web/CSS/:dir

Bug: T288910
Change-Id: Ibfb0cb28f0086fb1b7d0997be2246bc120eea85e
2021-08-21 14:50:15 +00:00
Fomafix 00dd5b2bce Use text direction based on the context
A categorytree can be part of the user interface (in the sidebar) or
part of the content. The user interface and the content can have a
different text direction.

This change use the usual way to of bidi flipping based on the user
interface language direction and on the content direction like the class
mw-editsection in core.

The direction of the bullets in mixed directions will be fixed in
Ibfb0cb28f0086fb1b7d0997be2246bc120eea85e.

Bug: T288910
Change-Id: Ia420ef120cf4aa66a1e63c9cf3aa2438cc68da52
2021-08-21 13:06:27 +00:00
Volker E abd233f2f0 Unify list-style CSS
`list-style: none none` was a workaround for an IE 6 & 7 rendering issue.
Same goes for `list-style-image: none; list-style-type: none;` combination.
Let's unify to shorthand `list-style: none` for any non-ancient browser.

Change-Id: If091ad82c7f73dbae826aeddc6c65c56ea92c73d
2021-05-03 01:48:51 -07:00
libraryupgrader 44998a759a build: Updating mediawiki/mediawiki-codesniffer to 32.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic
* MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage

Additional changes:
* Dropped .inc files from .phpcs.xml (T200956).
* Added the `wikimedia/mediawiki` profile in .eslintrc.json (T262222).
* Added the `wikimedia/jquery` profile in .eslintrc.json (T262222).
* Removed global `$`, included in the `wikimedia/jquery` profile (T262222).
* Removed global `mw`, included via `wikimedia/mediawiki` profile (T262222).
* Dropped the emtpy global definition in .eslintrc.json.

Change-Id: Ib5a3697712078a4ed22195c274eae9c82ddd7227
2020-10-29 07:51:57 +00:00
Volker E 7feedb1fd2 Remove unnecessary, overqualified element parts of class selectors
Those combinations origin from a time when these were seen as faster
to be rendered (at least dating back to 2011). Not only is this
reason no longer true, it also holds us back to start using semantic
HTML5 sectioning elements like `nav` for `.portal`.

Bug: T248137
Change-Id: I72b180d1c8bc1b029c147483590e2fc44dd29a86
2020-03-24 10:52:20 -07:00
Timo Tijhof c839756b32 Remove 'wgCategoryTreePageCategoryOptions' export from pageview HTML
This was internal to CategoryTree JS code and only needed on very
few pages. Export it as part of the module that needs it, instead.

Given this is computed and not a plain config var, use callback
to generate the value.

Bug: T219342
Change-Id: I790a98128b0a3317e27ac0d5fda08d48aeb640dc
2019-04-05 11:31:03 -07:00
jenkins-bot e97676459c Merge "Attach event handler for categories" 2019-01-22 05:12:20 +00:00
Fomafix eebad4e3ae Attach event handler for categories
This change is restoring the functionality on categories when
wgCategoryTreeHijackPageCategories is enabled. This functionality was
lost in 69fa92ee11.

Change-Id: I5b16bfd653bf193b15a3003628bfa2bd864b9881
2019-01-22 05:06:37 +00:00
Fomafix 095040a9e6 Remove hook SkinJoinCategoryLinks
The hook `SkinJoinCategoryLinks` is not used and not triggered.

Also remove the style for the class CategoryTreeCategoryBarItem because
it is only used in skinJoinCategoryLinks::skinJoinCategoryLinks.

Change-Id: I52e4f819ff195fc1fa8a148b0bb58d95a4bf22d7
2019-01-10 20:15:28 +01:00
Fomafix 9529dbf27b Remove support for Firefox 2 and Internet Explorer 7 and older
Change-Id: I5cb8543ab2a07db9386400382913764e182c81ae
2019-01-10 18:25:54 +00:00
Fomafix 3cdb4e95f2 Move styles that only used in JavaScript to JavaScript module
Also rename the style module from 'ext.categoryTree.css' to
'ext.categoryTree.styles'.
Keep the previous module name 'ext.categoryTree.css' for compability to
cached versions.
Also move the files of the module 'ext.categoryTree' into a
subdirectory ext.categoryTree.

Change-Id: Ie5ea28acfb43e33a94ec5824baf4f26d63d8e9e6
2019-01-10 13:38:58 +01:00
Fomafix 0a1f707f2f Remove obsolete aliases from closures
Bug: T208951
Change-Id: I963db9601a597e398187644946d83dda43568069
2018-12-06 19:55:37 +01:00
Fomafix 3232eedeb3 Clarify result handling in JavaScript
Change-Id: Id79340512854cb2e86a9275239bc9be79db26728
2018-05-24 10:33:36 +02:00
jenkins-bot 616e9e5dfe Merge "Remove error message on retry" 2018-05-24 08:16:11 +00:00
Fomafix 0d681798ce Remove error message on retry
Change-Id: Icc6fdaec6cc9289347d3065c54bdc9dd61e04ed9
2018-05-24 08:33:59 +02:00
TTO 191d1f5ec8 Fix display of categories with numeric names
Bug: T44938
Change-Id: Ib84b58451475c54bc0a59d8c6b0a9747fc59345d
2018-05-09 14:05:57 +00:00
Timo Tijhof c24e5edb2f Fix eslint no-use-before-define warning
* 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
2018-04-17 01:31:23 +01:00
Fomafix dd5583f026 Fix sidebar tree support
Bug: T171778
Change-Id: I2a2498d2129e8bed03340cfb00f65281f7aa3d35
2018-04-17 01:01:33 +01:00
Kunal Mehta 50c10d1fcb Use standard GPL file header
Change-Id: Ic49d45d0a0cb640d40486735c95f13cc6e29063f
2018-04-16 22:38:06 +00:00
jenkins-bot 5c5da4ca9e Merge "Avoid href="#" for <a>" 2018-02-27 02:08:42 +00:00
Timo Tijhof c35519b5af Avoid parsing and re-encoding ct-options in categoryTree.js
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
2018-02-20 04:27:15 +00:00
James D. Forrester 120b01696b build: Bump devDependencies to latest
eslint-config-wikimedia      0.4.0  →   0.5.0
 grunt                        1.0.1  →   1.0.2
 grunt-banana-checker         0.5.0  →   0.6.0
 grunt-eslint                19.0.0  →  20.1.0
 grunt-jsonlint               1.0.8  →   1.1.0
 grunt-stylelint              0.6.0  →   0.9.0
 stylelint                    7.8.0  →   8.2.0
 stylelint-config-wikimedia   0.4.1  →   0.4.2

Change-Id: Id081b31764ae923486031255cc5f24bfd6601782
2018-02-14 09:21:40 -08:00
Fomafix e39e99b436 Avoid href="#" for <a>
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
2017-09-06 05:50:19 +02:00
Fomafix f0f7ffa6dc Add tooltips when attaching the handler
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
2017-09-05 11:28:58 +02:00
Fomafix 3b48d9af2c Improve CSS while loading and for non-JavaScript clients
* 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
2017-09-04 21:55:47 +00:00