Commit graph

440 commits

Author SHA1 Message Date
Fomafix bc81b04ecd 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: I14ac680eb67d892618bbc13be9298ec9b8e0e2e9
2024-11-07 08:39:58 -08:00
Ebrahim Byagowi 4c5bbc34ba Remove initial animation of watch star
It moves watchStar.less from .scripts to .base as star is
visible also when JavaScript isn't enabled so the right
time to apply styles to it isn't after scripts are added
but right from beginning to avoid initial animations.

It also limits minerva-animations-ready to transition
as that's the only style that needs page load to actually
happen and otherwise the styles will be limited to
JavaScript clients which isn't intended here.

Bug: T376872
Bug: T376559
Change-Id: I394d21689cae01822cf8791b361cd450771f5c31
2024-10-10 13:25:59 +00:00
jenkins-bot dadcab3f32 Merge "Fixes Watchstar display when clicked" 2024-10-07 13:52:39 +00:00
Jon Robson fa7c131470 Page issues overlay should not show bulleted list icons
Seen on [[en:The_Black_Stork]] when clicking the page issue banner
while testing the links patch.

Change-Id: Ic9417dbe6f08bd4ada8a882b55646e76ae6c5589
2024-10-05 00:13:01 +00:00
Jon Robson 3bf80a62ef Fixes Watchstar display when clicked
Bug: T376359
Change-Id: Iaeda67b6ef063596a9c4ba43084aa6bc2472e0e7
2024-10-04 19:52:18 +00:00
bwang ca85c75536 Add minerva__tab-text class
Bug: T376363
Change-Id: I3aad38dac8029692556faebab4795784c776881f
2024-10-03 12:50:54 -05:00
ksarabia 5ef5694fbf Update Minerva skin to use Codex icons
- Define icon size variables in icons.less
- Update icon classes to use
  .cdx-mixin-css-icon()
- Remove temporary fixes in icons.less
- Add 'codex.styles' dependency in skin.json
- Set 'useMaskImage' to true in skin.json

Bug: T374145
Depends-On: Ia8f770aec365da77b39cb0258f546df7894e6ba4
Change-Id: I87b060cf98194d81679da2610944f58e8d941389
2024-09-27 21:53:55 +00:00
Jon Robson 6bd291c9f4 Fixes last modified colors
Bug: T367892
Bug: T375586
Change-Id: I55a4f17cd3fe9ab9f1a81a28a88edc12eca01ce9
2024-09-26 16:28:52 +00:00
jenkins-bot 2b77c02639 Merge "tests: Adopt private require() for skins.minerva.scripts (take 2)" 2024-08-29 23:58:39 +00:00
Timo Tijhof 4ca4febd89 tests: Adopt private require() for skins.minerva.scripts (take 2)
Resubmission of Ib68f45d93a (548e94da98), which caused an error due
to `require('../../`)` not working outside the module base directory.
This is fixed with regression test in T373065.

Further confirmed in this repo by viewing
`/wiki/Special:CreateAccount?campaign=loginCTA&useskin=minerva`
with this patch applied. Without the T373065 fix, the console warns:
> Error: Cannot require undefined file …/ToggleList.js

-------

Support for private require() in tests is available since MW 1.41:
https://mediawiki.org/wiki/RL/PKG#Private_export_and_import
https://mediawiki.org/wiki/RL/PKG#Virtual_files_in_traditional_modules

This fixes a confusing assertion in page-issues/index.test.js,
where for "insertBannersOrNotice()" it was asserting that the HTML
contain "⧼skin-minerva-issue-learn-more⧽", where the ⧼ character
indicates the message is not found (i.e. an error).

The test had to be written this way in order to pass, because
the skins.minerva.scripts module was not actually loaded, and thus
its templates and messages are not present either. This lack was
filled in by index.js for mw.templates, but not mw.messages.

By adopting private require(), these workarounds can all be removed.

== Motivation ==

In change I3a4024ccf90e505581, I'm working on improving the testrunner
config to enforce uselang=qqx on all tests. This is passing except
for GrowthExperiments and Minerva, both of which have the above
workarounds in place that caused a message to be undefined, and then
kept in the assertion expectation. When using uselang=qqx, values are
returned as (key) instead of ⧼key⧽, which exposes these message
existence errors.

By removing this workaround, the test will simply import the module
in the test as normal, thus the messages will exist, and thus it
will expect (key), and thus it will continue to pass even after
enforcing uselang=qqx.

Bug: T373482
Depends-On: I777f2c12e845a738edeac00e19818d4c939a1ef1
Change-Id: I6348e5ae00776c2c01d91fa90a431b6ffe3da25d
2024-08-29 20:34:16 +00:00
jenkins-bot 105b6fc266 Merge "Add a tag to mw.notify" 2024-08-29 16:58:11 +00:00
Jdrewniak dbe79167e5 Revert "tests: Adopt private require() for skins.minerva.scripts"
This reverts commit 548e94da98.

Reason for revert: The patch was causing the following error on pageload

    Error: Cannot require undefined file includes/Skins/ToggleList/ToggleList.js
    require startup.js:1006

Bug: T373482
Change-Id: I22751109c124795af7d2e0ad6c4104745b2d6632
2024-08-27 20:06:24 +00:00
Fomafix 8a78d01763 Add a tag to mw.notify
This prevent multiple notifications for the same message.

Change-Id: I6487852350497a48e1710fb04d3af01fc5c18116
2024-08-27 13:03:10 +00:00
Timo Tijhof 548e94da98 tests: Adopt private require() for skins.minerva.scripts
Added to MediaWiki core last year with I9fca9fdf9b7623b1.

This fixes a confusing assertion in page-issues/index.test.js,
where for "insertBannersOrNotice()" it was asserting that the HTML
contain "⧼skin-minerva-issue-learn-more⧽", where the ⧼ character
indicates the message is not found (i.e. an error).

The test had to be written this way in order to pass, because
the skins.minerva.scripts module was not actually loaded, and thus
its templates and messages are not present either. This lack was
filled in by index.js for mw.templates, but not mw.messages.

By adopting private require(), these workarounds can all be removed.

== Motivation ==

In change I3a4024ccf90e505581, I'm working on improving the testrunner
config to enforce uselang=qqx on all tests. This is passing except
for GrowthExperiments and Minerva, both of which have the above
workarounds in place that caused a message to be undefined, and then
kept in the assertion expectation. When using uselang=qqx, values are
returned as (key) instead of ⧼key⧽, which exposes these message
existence errors.

By removing this workaround, the test will simply import the module
in the test as normal, thus the messages will exist, and thus it
will expect (key), and thus it will continue to pass even after
enforcing uselang=qqx.

Change-Id: Ib68f45d93a7054ed8bd35fc5644e2852f2f90248
2024-08-23 19:04:36 +00:00
jenkins-bot bb57b22eb3 Merge "Hooks: change wikipedia is made for you warning to a notice message" 2024-08-02 17:19:51 +00:00
libraryupgrader 842a91590a build: Updating npm dependencies
* eslint-config-wikimedia: 0.27.0 → 0.28.2
  The following rules are failing and were disabled:
  * tests/selenium:
    * implicit-arrow-linebreak
    * no-mixed-spaces-and-tabs
* grunt-banana-checker: 0.11.1 → 0.13.0
* stylelint-config-wikimedia: 0.16.1 → 0.17.2
  The following rules no longer exist and were removed:
  * stylistic/selector-list-comma-newline-after
* braces: 3.0.2 → 3.0.3
  * https://github.com/advisories/GHSA-grv7-fg5c-xmjg

Change-Id: Ia94454c1da778f241085714e1601a0233d547570
2024-08-01 15:27:33 +01:00
Sergio Gimeno 73fe281d50 Hooks: change wikipedia is made for you warning to a notice message
The message box is changed from warning to
notice for the following messages:
 - mobile-frontend-generic-login-new
 - mobile-frontend-watchlist-purpose
 - mobile-frontend-watchlist-signup-action

Bug: T366127
Depends-On: I358ee59a1a0b7a5bb94e66bca9a2437517f40141
Change-Id: Ifa4418cbecda38011a6ee4d09c03db3ded7a9eb9
2024-08-01 13:22:36 +02:00
Novem Linguae 0cc0a1e16b JSDoc: fix double @ignore
Change-Id: I972019c22d18c0f276bf6240dafeb78122571fba
2024-07-01 17:15:29 +00:00
Ed Sanders 2be7b9f919 build: Update jsdoc-wmf-theme to 1.1.0
Additional changes:
* Update Minerva so that it doesn't output any APIs
to the documentation - this is intentional as Minerva does
not have any public facing APIs.

Bug: T368081
Change-Id: Ie1a3ea30cbf35663c7fdd2494c1698044882969e
2024-06-28 12:38:54 -07:00
Ed Sanders 527e018af1 Remove all use of IIFEs across Minerva codebase
These will make JSDoc easier to configure later and is
better suited to ES6 module format.
The dependency injection pattern can be retained by moving
the import to the top of the file.

Change-Id: I0fe692eb7066e52815ef3d21724c7439d82b2c5f
2024-06-28 18:54:38 +00:00
Steph Toyofuku 6f98cc6460 (Almost) no more CSS variables in minerva
Remove direct usage of CSS variables in Minerva, and replace them with
codex design tokens again.  Document this decision in the original ADR

Note: there are still a small number of CSS variables in use, including
most notably the --color-link-red fix, which broke when I removed it,
but this change takes care of all the ones that could be easily replaced

Bug: T363743
Change-Id: I7d3a9dceb908167078987de1733774c8bd4bea2f
2024-06-11 11:44:47 -07:00
Ed Sanders a6ab8d6da3 Prefer arrow callbacks (ESLint autofix)
Change-Id: I52b2feacd6216e99e04f193ba963e897b3e1a771
2024-06-04 08:01:54 -07:00
Steph Toyofuku de3f85bac7 Fix inverted text in (recently) last modified bar
Currently we are using the --color-inverted token, which is double
inverted in night mode, yielding insufficient color contrast with the
blue (progressive) background when the page has been recently modified.
Instead, use the @color-inverted-fixed token, which stays white in night
mode for backgrounds which are darker regardless of mode (additionally,
switch back to using LESS variables as this is the new recommendation)

Visual change due to bugfix

Bug: T364123
Change-Id: Ib284abffd6907272e580986fb08c2b8dee5a1a47
2024-05-17 14:15:39 -07:00
Fomafix 7f4c7d2db2 Add eslint-disable-next-line security/detect-non-literal-regexp
Change-Id: Ie85cdab8d2407fd432ae420ae46970490c2f693d
2024-05-14 12:41:50 +00:00
Fomafix 3b343d142d Get namespace ids from wgNamespaceIds
Use
	mw.config.get( 'wgNamespaceIds' ).category
instead of hard coded `14`.

Change-Id: Id54a33d45a696e958cf338e3ef93c1e078582bf1
2024-04-14 11:48:02 +00:00
Fomafix c43cdce48c Some small JavaScript/jQuery improvements
Change-Id: I33feb8bccbd870f589a01dc187e6155b7498714c
2024-04-08 19:45:22 +00:00
Jan Drewniak f9183cbc81 Follow-up to cf723c00 - Guard against undefined $container
Since `initMediaViewer()` can be invoked via
`mw.hook( 'wikipage.content' ).fire($container)` it's better
to validate that $container is in fact an HTMLElement and not
an empty jQuery collection.

Bug: T360781
Change-Id: Ib43327dd70c35918e3079c7b6b23a161383654b5
2024-04-02 14:37:23 -04:00
Fomafix effd4fe133 Use eslint rule "no-var": "error" and replace all var
Change-Id: I67acf88e1b8de55054248d7cf8ca622d5772ea6f
2024-03-29 07:40:22 +00:00
Fomafix a73e2d2d19 Add eslint rule "max-len": "error" and fix long lines
Change-Id: I079f300eea18024a6e1698b5016778fa60c74578
2024-03-29 02:05:03 +00:00
Jan Drewniak cf723c00c3 Guard against undefined $container element in initMobile.js
In order to prevent spikes in JS errors, ensure that the $container
element exists before initializing the mobile media viewer.

Bug: T360781
Change-Id: I48a57e8008e7bd90e9fcfc783f3720f6f75520a7
2024-03-25 09:38:11 -04:00
jenkins-bot 978702f3be Merge "Revert "The new class should be present alongside the old class for all page views"" 2024-03-20 16:15:18 +00:00
Jdlrobson b6ffc85cd4 Revert "The new class should be present alongside the old class for all page views"
This reverts commit bca9223bb1.

Reason for revert: This is now longer needed following the work
in Ia253de68f94236e7fe2219b736dd6084c64ce838.

Bug: T359983
Change-Id: Ibd3013169f26531a0cd879c143692e7030709808
2024-03-19 23:23:54 +00:00
Moh'd Khier Abualruz 5d6b866890 Rename the skin night mode classes to more readable classes
The classes:
- skin-night-mode-clientpref-0
- skin-night-mode-clientpref-1
- skin-night-mode-clientpref-2
is being replaced with
- skin-theme-clientpref-day
- skin-theme-clientpref-night
- skin-theme-clientpref-os
- Moved $forceNightMode to be a text parameter (dat|night|os)
- Keep adding the old classes to the html element, to give the ability of gradual deployment

The preference is renamed from minerva-night-mode to minerva-theme (a follow up to consider
migrating existing values will follow).

The query string minervanightmode continues to behave the same but now
accepts other values such as day, night and os.

Bug: T359983
Change-Id: Ia253de68f94236e7fe2219b736dd6084c64ce838
2024-03-19 23:12:59 +00:00
Jon Robson bca9223bb1 The new class should be present alongside the old class for all page views
Bug: T359983
Change-Id: Id0bcb3c9b0d37aef84886fe2efb907f8ebd1cfd9
2024-03-18 21:43:44 +00:00
Steph Toyofuku 4b3abcb1eb [VISUAL CHANGE] Update last modified bar to have an accessible color contrast
The current white text on a green background is not an accessible level
of color contrast.  We were instead recommended to use
@background-color-progressive, so let's do that

In addition, remove the previous definition of
@background-color-last-modified-bar-active as it's no longer being used

Visual change for pages on mobile that have been updated recently

Bug: T358736
Change-Id: If5b97b785e95df75645be62847cef396f6be68b6
2024-03-15 22:28:48 +00:00
lwatson 261eab0221 styles: Update color in Less from #d33 to #d73333
This patch promotes a consistent design decision across projects in
MediaWiki core, extensions, and skins. The darker red color meets the
W3C Web Content Accessibility Guidelines (WCAG) at Level AA that text
or images of text must have a contrast ratio of at least 4.5:1 (or 3:1
for large text).

Bug: T343239
Change-Id: I771fec3f567ea7ce5a25f8c63d88c956a27121ef
2024-02-28 17:10:08 -05:00
Jon Robson 145db70286 Reset: Drop p and div inside overlays
Required for proper presentation of page issues overlay
and multimedia viewer.

The div rules were unnecessary.

Bug: T205341
Change-Id: I6fea0f2013a11e5248b71619b795d794c8ed18ad
2024-02-14 22:20:43 +00:00
Jon Robson b079031b0a Send a toast notification if night mode is not available
Add a skin-night-mode-page-disabled class to the HTML element when
a page was disabled by the new MinervaNightModeOptions configuration
flag.

Bug: T356653
Change-Id: I7a6582ef8f66e78cc6f07da06bc4d2a3277cfcf0
2024-02-14 01:51:23 +00:00
Jon Robson 5e2e2142ef Diffs: Localize number in timeago
Bug: T357079
Change-Id: I6c877baa82ac88e50ae0c5e932665bda9122da70
2024-02-09 16:51:30 +00:00
Jan Drewniak 59fd0cd5dc Convert all color related Less variables to CSS custom properties
All colors used in Minerva are converted from Less variables
into CSS custom properties. A new file called CSSCustomProperties.less
is created in the skins.minerva.base.styles module to store
these custom properties and an ADR is provided on the rationale for
dropping support for browsers that don't support custom properties.

The new CSS custom properties follow Codex design token conventions
where possible (and noted when not).

Link colors are unique because their styles are defined in core,
so in that case the Less variables values are set to custom properties.
Those values are then fed back into MediaWiki core for core link
styling.

Also adds a temporary night-mode color palette under the
.skin-nightmode-1 class on the <html> element.

Bug: T356074
Change-Id: Ida1f14138f12bd3c600c264bde7b5100f9dbf4ff
2024-02-02 17:57:27 +00:00
Jan Drewniak be0b43042e Convert Less variable names from camelCase to snake-case
Converts all Less variable names from CamelCase to snake-case
per the MediaWiki coding conventions.

Removes the following unused Less variables, mostly
related to icons, since those were converted to Codex:
- @icon-touch-area-sm
- @icon-touch-area-md
- @min-size-icon (replaced with @size-icon-medium)
- @icon-glyph-size-sm
- @icon-size-sm
- @icon-padding-sm
- @icon-glyph-size-md
- @icon-size-md
- @margin-icon-md-labelled

Bug: T350581
Change-Id: I1b16e77942d9bea20dcc5636a63d64aa2325a173
2024-01-31 15:24:31 -08:00
Ed Sanders 8ef144f936 build: Update linters
Change-Id: I5aa3ab891890b52057a5fc855315e5b1b2203037
2024-01-24 22:02:12 +00:00
Jon Robson d5e6a0b4ce Do not use mw.loader.require
That method is marked as private. Instead using require (the
ResourceLoader require)

Bug: T235198
Change-Id: I6e4e5c76717808e416dc703639c15d0de1070a09
2024-01-03 10:53:48 -08:00
Steph Toyofuku 2b41416c0d Allow addPortletLink to target tabs/associated pages
Currently `mw.util.addPortletLink` cannot properly add a portlet link to
the associated pages tabs, as there is no `p-associated-pages` id on
mobile.  This change pulls the id from the page data, and adds the
necessary class for the tab to be styled correctly - since tabs do not
have corresponding icons while most portlet links do, we also branch on
this class (effectively on whether we are in the tab container) to
ensure an icon is not inserted

Finally, I added a few comments and spacing in the sections of code that
I touched to make them more readable and resolve some of the linter
warnings, but happy to hear if these are not helpful!

Bug: T340728
Change-Id: I33fc12611a6238552a3eb47f6ca37f087903a92a
2023-12-21 16:37:28 -08:00
thiemowmde e0d893c0f5 Fix broken reference popup when name contains # character
The fragment in a URL like http://example.com/foo#bar#baz doesn't end
when there is another # somewhere. That # is part of the fragment.

I'm not sure since when this issue exists. It's already in the first
version of this codebase from 2017, see Iff1f7e6.

Bug: T332007
Change-Id: I3b0726380d2f385475f5ba53aeab16932d7ccaa7
2023-12-12 15:08:55 +01:00
Jdlrobson ca28efc9c7 Drop mw.mobileFrontend references
This restores the previously reverted patchset
If5b76245bf60bfa9cf977cdbf37ee0d6bb65f9d9

Changes since original:
* Added Depends-On to MobileFrontend
* Uses OOUI classes for page issues rather than es6 classes - ES6
classes do not support modifications to class prior to running
super so MobileFrontend's View class is not compatible without
significant refactors.

Depends-On: I24ad75adf8519102ca356d64d99d765ab69180cc
Bug: T348807
Change-Id: I4ff82af0251254c846f2caee330af5af738f6029
2023-11-10 01:30:52 +00:00
Jdlrobson 2ee3e27406 Revert "Drop mw.mobileFrontend references"
This reverts commit 19ea6328b0.

Reason for revert: Breaks page issues and image overlay. I
will break this up into smaller less risky patches.

Change-Id: If5b76245bf60bfa9cf977cdbf37ee0d6bb65f9d9
2023-11-03 19:26:16 +00:00
Jon Robson 19ea6328b0 Drop mw.mobileFrontend references
Bug: T348807
Change-Id: Ib71b43005e5788d0e29917a165281faa84926414
2023-10-31 21:54:26 +00:00
Jon Robson 5170e69d3c Fixes read only mode.
When $wgReadOnly = true; in LocalSettings.php the edit icons
appear locked and when clicked should show a warning.

This also addresses deprecation warnings in the code and
tidies up the ES6 code.

Note to reviewer: Please use git diff HEAD^ -w
when reviewing this diff. Mostly whitespace changes.

Change-Id: I3fa83cc1dc4da62260fd0ef50ac14805c3e1282b
2023-10-31 00:41:29 +00:00
Jon Robson db8e3b09af Document messages and add hours and minute units
Follow up to I5a4a2588da3d701be87690038c2c9b2bc1aa0365

Change-Id: I6ea2b98bd3d03e586cc58307d3f2f0f1119059e3
2023-10-30 23:37:12 +00:00