Commit Graph

852 Commits

Author SHA1 Message Date
Sam Smith
3b9134f8ac launchULS: Add context to interface.language.change hook
Now that the interface.language.change hook is fired when the user
switches language using the Compact Language Switcher, we should provide
additional context to the UniversalLanguageSelector instrument.

Bug: T280770
Change-Id: I6c4ddf9738e527ac42581c9fb4924ed1d12748b4
2021-06-21 21:25:31 +00:00
jdlrobson
09a2b33bd6 Restore compact languages button user preference
The compact languages button user preference will be applied to
any compact language button provided by the skin, this allows users
to opt out of the feature as before.

This will be used immediately in Vector in
I436554d9d51470d277d59c2c71e08124735e12fd

Bug: T282149
Change-Id: I726c61d4c6895a28b999781752535e0ddc961744
2021-06-14 15:24:53 +00:00
Sam Smith
bc14f8fa40 Fire language change hook
As of Id345e933, we fire the language change hook when the user switches
language by clicking on a link in the languages list. In order to
compare the user switching language in the scenario above with the user
switching language via the CLS and/or Vector's language switcher, ensure
that we fire language change hook in all treatments.

Bug: T280770
Change-Id: I4a74254612557c287b16f4f086077a2637de9a2e
2021-06-10 11:11:37 +00:00
Sam Smith
49924e9ec5 Pass context to compact_language_links.open hook
Following on from I6fa966c2, fire the mw.uls.compact_language_links.open
hook with the $trigger parameter as context for clients to be able to
able to distinguish which treatment is visible to the user.

Supporting changes:

- Note that the hook is unstable next to its callsite

Bug: T280770
Change-Id: Ie4bbfea4dc5e36401df587550f466aeae5c8fdcc
2021-06-01 18:11:30 +00:00
Timo Tijhof
977e6c68c2 ext.uls.interface: remove some needless uses of jQuery
* $(node).prop(foo) -> node.foo

* For objects only expected to represent a single element,
  use native querySelector() and its natural null return
  fallback, instead of `$(), $.length, $()` etc.

* Fix a few minor non-voting eslint warnings that were in the CI
  output about line length and unknown type "bool".

* Remove presumed outdated comment about Vector splitting,
  per T234907.

* Rename ulsPosition to configPosition to be more clearly
  different from ulsPopupPosition.

* Remove various 'uls' prefixes of local variables,
  since this is ULS code in the ULS repository.

Change-Id: I1c617bf48283f47dc948550111c515faf173d1eb
2021-05-20 18:57:09 +00:00
Santhosh Thottingal
7b2338cef5 Replace BabelStoneTibetan with its variant with suitable type metrics
Due to the nature of the script, Tiben usually has high ascent and descent
values. Use a variant of BabelStoneTibetan to have lesser ascent, descent
values for modern, frequently used Tibetan

Bug: T283122
Change-Id: I902af894b0e4d6f375981f13548be49405fb3602
2021-05-19 14:35:33 +05:30
Santhosh Thottingal
96ec65ac8e Replace Jomolhari with BabelStone for Tibetan
Jomolhari is inactive upstream for years and BabelStone is an active
fork with improvement for better script support.

Bug: T197596
Change-Id: I5c3c1ce5ad2a80c78e93304d4023342a66382942
2021-05-17 13:39:09 +00:00
Sam Smith
8e85f0d611 Fire hook when compact language links are opened
Following on from Icc64044d, we fire the
mw.uls.compact_language_links.open hook whenever that treatment is
opened (and not only the first time that the triggering element is
clicked).

Bug: T281928
Change-Id: I6fa966c22c738ca12bcbeb0225c03f3f8394ecee
2021-05-11 12:48:10 +01:00
Sam Smith
c914a7d0ab Fire hook when user clicks language button
This allows us to correctly instrument (via the
UniversalLanguageSelector instrument) this action so interaction rates
between treatments can be compared.

Bug: T273232
Bug: T273928
Change-Id: Icc64044d51c567482d4f286637366cefb7beeb3e
2021-05-10 20:46:37 +00:00
jdlrobson
5278a672fe Restore suggested languages to compact languages button
The filterForCommonLanguagesForUser method checks if commonInterlanguageList
is null, but it can never be null unless it is first initialized that
way.

Bug: T282037
Change-Id: I70c3a60349693473509d9b329764dc5138930506
2021-05-10 07:14:04 +00:00
jdlrobson
ec8edeb8ec Use ev.currentTarget not ev.target
In modern Vector, the ULS trigger button has a child node which is
a span. When clicks are received on the span, they will result
in positioning relating to the span rather than the button.

The ev.currentTarget should be read outside the asynchronous function
to avoid bubbling.

Bug: T276248
Change-Id: I6e138c88e29b335b8e0bc22cf0aa07c289a5eb74
2021-04-26 16:59:47 +00:00
Inductiveload
a2a218cce1 Update Junicode to 1.002
Bug: T173573
Change-Id: I0d8d650ea63e5391a405926ff769981a4c094403
2021-04-21 13:47:21 +00:00
Niklas Laxström
2a044e1e0a Small cleanups and typo fixes
Change-Id: I4faeb4673fd5e903d2931d6071262a893d4009f5
2021-04-21 11:48:15 +00:00
Niklas Laxström
929e707c49 Simplify undo tooltip positioning
OOUI is smart enough to handle this automatically:
https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.PopupWidget-cfg-position
https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.PopupWidget-cfg-autoFlip

Change-Id: Ib8e4ea0e900b3ea0904b34d82c874227462e342e
2021-04-21 11:48:13 +00:00
Timo Tijhof
a6e0c10c54 ext.uls.interface: remove unused "ulsPopup remove" code
The ulsPopup variable is local to the showUndoTooltip() function.
If it is called multiple times, then a previous assignment of an
OO.ui.PopupWidget object would not be found here in subsequent calls.

This check can only ever be false since it is the first statement in
the function (after variable and function declarations, which don't
do anything other than call `$()`).

Change-Id: I7020c103428d01b5e48c65be695471401f588fc4
2021-04-15 07:01:13 +00:00
Niklas Laxström
50b345c83d Avoid JavaScript errors for tipsy if no entry point on the page
Bug: T278313
Change-Id: I48011eec9f7d876b914550012cc76e2209fc783c
2021-04-14 23:41:54 +00:00
libraryupgrader
e2ab4bb1c3 build: Updating dependencies
composer:
* mediawiki/minus-x: 1.1.0 → 1.1.1

npm:
* eslint-config-wikimedia: 0.17.0 → 0.19.0
  The following rules are failing and were disabled:
  * compat/compat

Additional changes:
* Added the "composer phan" command to conveniently run phan.
* eslint: Renamed `wikimedia/client` profile to `client-es5` (T277085).

Change-Id: Ib31cbcd8c615d2e6abf9ee30f0f4d7b7baa54e2e
2021-04-07 11:10:07 +00:00
Niklas Laxström
3af22f60d4 Fix ULS dialog positioning in some cases
In development environment, ev.currentTarget is the button.
In Beta Cluster, however, once ext.uls.mediawiki is loaded,
it is now the document (the event has bubbled up). I do not
know what causes the difference, but we can use the target.

Bug: T276255
Change-Id: Ie4c425510293a6f2ce81e4bf4a353f2c8d86d412
2021-03-24 10:32:08 +01:00
Niklas Laxström
e8747a022d Avoid content language selector dialog resize shortly after opening
Small dialogs were resizing after loading when display and input
setting buttons were added to it. Now delay showing the dialog until
they are loaded.

Bug: T276248
Change-Id: I7033903737afedbd4be908c84d07656c468ce801
2021-03-22 18:21:16 +00:00
Niklas Laxström
8c835588f2 Fix positioning of input/display settings for new language selector
Unrelated behavior change: ULS language selection dialog is hidden while
display or input settings is open.

Also simplified dead code in addDisplaySettings.

Bug: T276248
Change-Id: Ia91a2b83e7ad4072016649230e2376b0793cbbff
2021-03-22 12:11:39 +00:00
Niklas Laxström
d3a3ac082b ULS: Avoid JS error for undo tooltip with new language button
Change-Id: Ib571152ff14754e186a3e7dd9e1c08bc22239032
2021-03-18 08:43:06 +00:00
Niklas Laxström
03547c68e3 Improve positioning for content language selector on narrow screens
Reported in
https://github.com/wikimedia/jquery.uls/pull/383#pullrequestreview-613761459

Instead of checking the left edge of the trigger, check the midpoint.
This is more reliable and does not cause the dialog to incorrectly
swap sides in narrow screens in LTR direction,

This patch does not touch the compact language links variant.

Bug: T276248
Change-Id: Ic734abb7b350852f8c5c10ced8456bf146df62d8
2021-03-17 10:29:18 +01:00
Niklas Laxström
dd8842517e Change ULS content language selector positioning
New Vector introduced a new content language selector trigger. This
code was hardcoding a behavior that works for compact language links
but is not so appropriate for other uses in the skin, which are out
of our control.

This patch aims to be a minimal change to allow other kinds of
behavior without changing the amount of tech debt. This changes
the default ULS dialog behavior to match the requirements shown
in the task. Compact language links specific behavior is retained but
only enabled for the compact language links trigger. The behavior
is chosen depending on the value of isUsingStandaloneLanguageButton().

For future changes, I propose that mw-interlanguage-selector class will
not have any styles attached to it. Whoever creates the trigger would
be in charge of styling it. Ideally that code would also define the
positioning and other behavior, but it is less clear how that can be
abstracted in a nice and decoupled way.

Bug: T276248
Change-Id: I52da6c2f5a1f25d64f322a3c8f6105da3b244b66
2021-03-16 22:36:18 +00:00
Niklas Laxström
95b1137a57 ext.uls.interface: clarify code
Changes to comments, naming and code to increase clarity of the code
and explain better what it does and why. No change in behavior.

Change-Id: I998fcfd620c2ee737618c3ab8f41fb6dfdd2c99a
2021-03-16 22:36:16 +00:00
Niklas Laxström
099f1f37c8 Add mw.uls.setLanguage
Translate's pagetranslation.uls module needs to override the action
that happens after language code is set. Currently it uses setlang
url parameter, which (no longer) works with Special:MyLanguage.

After this patch, it can use mw.uls.setLanguage and does not need
to reimplement it's functionality.

Turned mw.uls.changeLanguage into simple utility that calls
location.reload when the promise is resolved.

Change-Id: I9a648b146188dd252c239085bbe276165dc5f393
2021-03-16 10:16:06 +00:00
Sam Smith
852d72e66d Remove UniversalLanguageSelector instrument
Per T275894, Readers Web intend to increase the scope of the
UniversalLanguageSelector instrument to help them understand how
users are interacting with the Languages list in sidebar.

In order to keep the UniversalLanguageSelector extension focussed and
not overly Wikimedia-specific, it was agreed that the instrument would
be migrated to the WikimediaEvents extension, where other such
instruments are located.

Therefore, remove all code related to the UniversalLanguageSelector
instrument.

Bug: T275894
Depends-On: I2acee8ba8dc59c497dc6ba42cd5bd88dfd985c8b
Change-Id: I72b1d0ff35488521b3499e9606efee26baff8c00
2021-03-04 13:58:19 +00:00
jdlrobson
96656c5f41 Allow access to display and input settings in new vector
Light refactor of existing code into reusable method to support
this.

Use Extension attributes to allow skins to provide ULS
additional configuration.

Bug: T274396
Change-Id: I7dcd49f05fae83fbc0c15768bee8ca93eab17bcc
2021-02-22 11:02:10 +00:00
Niklas Laxström
2172c8c1b2 CompactLinks: Update performance summary
Change-Id: I310fea3dbdd8cd232a0204ffd17e3a02c6723c8a
2021-02-11 08:00:48 +00:00
Niklas Laxström
8b6d8f6898 Remove CompactInterlanguageList.prototype.getInterlanguageList
Unused since e3569d32a7

Change-Id: I2a0f74972b8f566d6462fa261231dbafe9a66665
2021-02-11 07:51:26 +00:00
Niklas Laxström
b385d58aca Remove CompactInterlanguageList.prototype.getCommonLanguages
Unused since fcfa36ac77.

Change-Id: Ifae139d989fb6cb21fc3e19006306ed597d058e6
2021-02-10 14:39:25 +01:00
jdlrobson
64aeedfb17 Modern Vector should be compatible with ULS
Without the following changes the language button shows the
wrong label and opens a dialog with zero languages.

* Don't apply heading change to modern Vector
* Look for the element .mw-portlet-lang as well as #p-lang

Bug: T273232
Bug: T273928
Change-Id: Ic201b1983a17cc37fd1ff7c507aab656ea25f370
2021-02-09 18:07:11 +00:00
Nikerabbit
3ac9853220 Simplify ext.uls.preferences module
This is updated version of 61f1a9863a
which was reverted due to compatability issues which are no longer
present.

Change-Id: I05333ddc288171b6d867dce8a1d3efc1e1450e0a
2021-01-21 08:08:15 +00:00
Niklas Laxström
4fc7bc9200 Handle corrupted values in input preferences
Bug: T246370
Change-Id: I13c730a6d584ad2f73807e11d5ceadfcb16a6040
2021-01-19 08:45:05 +00:00
Amir Aharoni
7a0d559dc0 Add the Boyo Gagrai for the Ho language in the Warang Citi script
Bug: T233301
Change-Id: Iad328485531b97428f795b154f8181e71947a5fd
2020-11-30 15:31:31 +00:00
jdlrobson
d69d5773e5 Compact language links module is loaded via server side
This provides an alternative mechanism to
I0518ecdf402ebf5eb6bad2c430f6462322c0d8e1 for loading the compact
language link module. Instead of relying on the client, the HTML
is inspected.

Bug: T264824
Change-Id: I977a998388b3e70f7fe4d97fa05be3c1ac1bf676
2020-11-18 17:07:59 +00:00
jdlrobson
ab6decae11 Allow skins to register their own button and disable compact
Example usage:
Iabd4688c6081b4de391b9655b92a16f3a414e018

We will skip loading the compact link if we don't need
to compact the languages.

Note special handling is known for Timeless which stops
propagation of events. This will be fixed in Timeless at a
later date.

Bug: T264824
Change-Id: I0518ecdf402ebf5eb6bad2c430f6462322c0d8e1
2020-11-18 17:06:40 +00:00
Amir Aharoni
077a3ac844 Make a more specific CSS selector in getLangsWithBadges
This should avoid problems with elements that are not real
interlanguage links, which may be added by other code,
for example user scripts.

Bug: T267887
Change-Id: I3f9c618b417363f667a31e9dad335c1aec15b055
2020-11-17 10:25:43 +02:00
Niklas Laxström
4387bb9d61 CompactLinks: Better handling of opening links to new tab/window
* Check for any of Shift, Ctrl or Meta
* Only do it for links
* Support both mouse and keyboard

Change-Id: I0b331b802e1d96ae0e0511746d6b42663db924b1
2020-11-16 14:51:47 +00:00
jdlrobson
e3569d32a7 Separate compacting of language list from launching of dialog
This refactor will allow us to separate these two functions so that
the modernized version of Vector can avoid loading the compact
language list.

Changes:
* `options` is now optional to the CompactInterlanguageList constructor
The max value is already defined in
CompactInterlanguageList.prototype.init
* this.interlanguageList is now initialized inside the constructor
Previously calling CompactInterlanguageList.prototype.createSelector
or getCompactList before calling init would throw an exception.
This will be important in I0518ecdf402ebf5eb6bad2c430f6462322c0d8e1 when
the responsibilities of wiring up the button and compacting the languages
is separated.

Bug: T264824
Change-Id: I9606df30a050d0cdaf7add2deff849cd5b895bab
2020-11-05 08:44:06 +00:00
Niklas Laxström
79a038f166 Handle Apply button little bit more sanely
Change-Id: I55d48de703662f139549d764bf7c1f235111d5ab
2020-11-02 11:08:25 +00:00
Niklas Laxström
5cb2aec0a1 Fix language switching using the undo tooltip
Introduced in I740600d18859422b2f98a5ef92d0321f6e9615a2.

We need to prevent the default action (navigating a link) so that
our custom code has a chance to run. Before it was synchronous so
it called location.href before default action had a chance to execute.
When it was made asynchronous, the default action got executed before
our custom code.

Change-Id: I292f99aa5f5ff536d8197174c317018462685866
2020-10-28 11:44:33 +00:00
Niklas Laxström
094c30bc1c Fix language selection using [...] button
Introduced in I740600d18859422b2f98a5ef92d0321f6e9615a2.

When onSelect was called for the new language, it set dirty to true.
Then the, now delayed, render function reset the dirty status to false.

There is no need to set dirty to false on render, so moved it to the
constructor.

Change-Id: Ibfa23f545c9d358e7e03fb299c238182ea449d7c
2020-10-28 09:29:47 +01:00
Timo Tijhof
09862cffec ext.uls.eventlogger: Remove more obsolete deferred complexity
Follows-up c578db02 and ea671b1f, which I thought removed
all code relating to the old async EventLogging method.
I didn't notice this UI code at the time, because I only took a
single pass over the code to find dead code. Now that that code
is gone, it is clear that the UI code is also redundant.

The mw.track() and logEvent() methods don't track the Beacon API's
async fetches, which also isn't needed, since the loss of browser
context upon navigation doesn't abort background beacons.

The loading of the EL library itself is already ensured via a
dependency so we already know there won't be an async fetch for
that.

What that leaves is some portion of older browsers in which a
EventLogging falls back to 'new Image'. This is basically just
IE 11 per <https://caniuse.com/beacon>, and for those some portion
of events will have been lost since EventLogging removed support
two+ years ago for tracking those fallback fetches via a Promise
(because of the perf issues caused by what the removed code here
was able to do).

Change-Id: Idf4378f983b6ba0e755ebadb97aa6d87cf95f7a5
2020-10-22 23:45:52 +00:00
jdlrobson
f8fde38197 Use require to clarify ext.uls.preferences
ext.uls.preferences only depended on ext.uls.common because of its
use of the uls global. This is unnecessary, and made clearer by using
require and module.exports to access it.

Change-Id: Ied2a1b560d19a18529fd766ced778c912199fa2f
2020-10-20 16:08:59 +00:00
jdlrobson
5cd10ce862 Reduce JS loaded on critical path
As a precursor to incorporating a new language switcher in the new
version of Vector I'd like to improve the performance of loading
the switcher.

It seems most code can be deferred until the language selector
button is clicked.

This shaves around 30kb of resources off the critical path for
most users. There's potential here for a positive performance
impact so we should follow up the deployment by checking the
associated performance graphs to see if there's improvement.

Note, if the compact personal links feature is enabled
there is no performance saving for now. This will be addressed in follow
ups.

Bug: T153844
Bug: T153845
Bug: T237061
Change-Id: I740600d18859422b2f98a5ef92d0321f6e9615a2
2020-10-20 13:40:49 +00:00
jdlrobson
a1963ce12d Merge ext.uls.inputsettings into ext.uls.displaysettings
These modules are always loaded together. There is no need to load
them in separate ResourceLoader modules

Change-Id: Ibdf7d1bbd9090ffed6a142055ee684ad97dd6680
2020-10-14 21:11:03 +00:00
Reedy
99937ba18b Add GochiHand font
Bug: T258839
Change-Id: I38eacbfbc3293c7b7a2a6bf4f680b2f70f1a43ad
2020-09-16 05:20:07 +00:00
David Kamholz
dc4937eb1f update Bali fonts to fix spacing issue
Change-Id: I221e9c2db3373ffc14a9f764e5de311e980a93a6
2020-07-27 14:29:15 -07:00
Ed Sanders
e128c51356 build: Update eslint-config-wikimedia to 0.16.2
Change-Id: Iea4b73bdceb66e113b7f9c9244ae6b37a3ce205f
2020-07-09 16:40:05 +01:00
Seb35
54ff8272ab Remove jQuery 3 migration warnings
Bug: T175236
Change-Id: Ibbeec40bd46523c14ba53da1441f46fc9cdfbc10
2020-05-08 11:48:58 +00:00