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
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
This is updated version of 61f1a9863a
which was reverted due to compatability issues which are no longer
present.
Change-Id: I05333ddc288171b6d867dce8a1d3efc1e1450e0a
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
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
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
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
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
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
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
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
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
These modules are always loaded together. There is no need to load
them in separate ResourceLoader modules
Change-Id: Ibdf7d1bbd9090ffed6a142055ee684ad97dd6680
This reverts commit 61f1a9863a.
Reason: mw.storage.getObject was introduced in MW 1.34. Need to
support MW 1.33 for MLEB 2020.04 release.
Change-Id: If9cd8d1f9e1ab544eba280c8fa7b36db91b64573
The main goal here is to reduce complexity. For example, the method to
remove a parameter from the current URL is never used with another
parameter. The complexity is not needed.
This is inspired by the changes I have seen in Icaf086f.
Change-Id: If22c25e84f50ac380320cd581690835ddb70f01d
Add two new options for ext.uls.dialog - afterOpen and afterClose.
These are callback function which will be triggered after the dialog
opens or closes.
Using the afterClose callback in ext.uls.setlang to remove the
setlang parameter from the URL if the dialog is closed without
pressing any button. This might happen if the user closes the dialog
by pressing Esc, or by clicking on the overlay.
Also see: Ie3215d12d9c77f15597495e21610707b272eeee9
In addition, renamed all occurrence of setlang to setLang.
Bug: T63115
Change-Id: Icaf086f947b1d91bf7ad5b36f126da0be1fc7747
Support has been added for:
* Esc: Closes the dialog
* Tab: Ensures that tabbing keeps focus on the focusable elements
in the dialog. If no overlay is not present, the focus is
allowed to flow normally.
This should not happen but if NO focusable elements are found and
overlay is displayed, focus is locked on the overlay.
Also add description and other license information for uls.dialog
& uls.setlang files.
Bug: T63115
Change-Id: Ie3215d12d9c77f15597495e21610707b272eeee9
This change allows to use the ULS language changer without getting a
dialog for restoring the old language.
This change requires that the module is also loaded in this case.
Change-Id: Ie5169e986d0362034ede122b0bc29ce7a4aa481e
This removes the URL with the URL parameter setlang from the history.
A click on history back doesn't show the URL parameter setlang anymore.
Change-Id: I0ea8c4508bedd9758a1cebbe8ecb2a7113bf8538
setlang will now display a dialog to confirm with the user that
they would like to change their interface language. The preferred
language will only be updated if the user confirms.
The dialog will be displayed if the setlang parameter is present in
the query string and,
* A user is logged in, and their preferred language is not the same
as the one passed via setlang.
* For an anonymous user if the wgULSAnonCanChangeLanguage is true,
and the current interface language is not the same as the one
passed via setlang.
Bug: T63115
Change-Id: I882297d99a594fd82fd0aec3b4664e8bfd1eac3a
This reverts commit 76551ed4a7.
Reason for revert: It seems it's breaking Serbian editing Wikidata
Bug: T217770
Bug: T121747
Change-Id: If69156400ff665a8c488a24f70d6a100e26761da
When mw.uls.getFrequentLanguageList() is requested sometimes
the language that is a redirect returned causing other codebases (like Wikibase)
to show an invalid language to the user.
Bug: T217770
Change-Id: I49c802d584081aa5992dd0ba76144059bcac56c8
This change prevents a failure when clicking on the language revert
button.
This change is a follow-up to c578db020d.
Change-Id: Ic5da1b1dcdcc07de417a6eef0189940cb5a2392f
Given the code no longer uses any EventLogging methods directly,
but rather mw.track(), this means it also doesn't need to declare
any dependencies, including for older MediaWiki versions this
will work as-is.
Change-Id: I8cdcef54321d0887c509fc3683acf132c113e628
I guess the expectation was that for browsers that don't support
Navigator.sendBeacon, the promise would wait for the 'new Image'
fallback to complete.
However, EventLogging never did that. In browsers where the Beacon API
is not supported, 'new Image' starts asynchronously and either
way the returned promise is immediately resolved.
The only purpose of the returned promise was to detect errors
in the format of the event (e.g. missing properties), which this
code is not concerned with (given that it uses "always",
not "done"). And besides, for that you'd probably want to use
the EventLogging debug mode [1] instead.
This is the last step before ULS can switch to a soft EL dependency
by using mw.track instead, which I'll do in the next commit.
Change-Id: If016b73dcd7320ddf1478c1678d2cc6371fe0fa1
Follows-up e58be7c411, 1ad0c9c819.
* The mw.uls.eventlogger property does not appear to be
used anywhere indexed by Codesearch. It was also undocumented.
Removed without deprecation. Kept exposed for debugging purpopses
via module.exports, which could be retreived in tests via require(),
or via mw.loader.require() from the browser console.
* Remove redundant $.Deferred wrapper.
Change-Id: Id081038e5d4902c7e38967353c6f551c12517311