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 prevents a wrong position of the dialog when there is a different
scroll position like on an URL with fragment, for example
Special:Version?setlang=de#Installed_software
Change-Id: Ic10c6b13461a259d87fd43a718acdd1421193b6c
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
Putting icon on link label baseline as good as possible cross-browser
and unify code with Vector skin's code. With one improvement,
putting icon in `:before` selector in order to be able to specifically
change icon independent from link, which opens up `opacity` or state
changes.
Also cleaning up CSS by
- reducing specificity
- changing to `stylelint-disable-line` only on specific selectors
- removing initial value `transparent`
Bug: T207075
Change-Id: Ib5d446434263441eb85aa2e96a0e4dbde1034c1c
Depends-on: I92acb9851a3c0acdbc40a4a4528a91c7332c9293
To match how MediaWiki core expands the .background-image-svg() mixin
function. According to Codesearch, this is the only repo with a match
for `-webkit-linear-gradient.*url\(`.
Bug: T121730
Change-Id: Ide4fc6eef81de76b4b0043cd88ecdf8ed2e3e736
>>! Performance Inspector
> Source: ext.uls.common
> Used selectors: 0.00% (0 of 10)
> Used embeds: 0.00% (0 of 1)
> ----
> .uls-icon-back {
> background-image: .., url("data:image/svg+xml..
It seems the entire module isn't used, but that can be fixed
separately. The icon is used by ext.uls.inputsettings and
ext.uls.displaysettings as part of a click-triggered dialog,
which means it can never appear on a page directly.
Bug: T121730
Change-Id: I36831beeb764e6893c331b20b90102a5ceb0d21a
Instead of background-size:containing to the relative font size, but with
fixed horizontal space for it due to the padding, set both the padding and
background-size to use ems instead of px so both scale properly.
Tested in modern, cologneblue, monobook, and vector with no visible issues.
Resolves issue with icon being too large on timeless. Does not appear to
affect minerva, as that just handles it all another way.
Change-Id: Ibcea827fe15ee50c947e9c0de1e6cf053e299033
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
* No status line with URL and "#".
* No new tab on middle click.
tabindex="0" ensures to have the normal tab order.
role="button" according to
https://www.mediawiki.org/wiki/Accessibility_guide_for_developers
Change-Id: I82f1923b3905f111ce7719c03a3919633271720a
Only store reference to the element, where they can easily be read
when needed.
Also removed one unnecessary use of `self` as an alias.
Change-Id: I39fa897002037a6d6478a3fb1f40ac60833e392e
Follows-up 2ac8a0a4b6, which removed this method. In checking
Codesearch, I somehow missed this one call among the false positive
results for Datepicker and TMH-related calls to a different method
also called "setDefaults".
Bug: T206588
Bug: T187207
Change-Id: I4f94ce6f8f1b85c192b69c5b50c3f090f7b4bfd2
Add potential items directly to a single array with two indexOf
checks.
Previously, potential items were first put in a new temporary array,
then that array was filtered with indexOf checks into another temporary
array, and then the result of that combined with the previous results
into another temporary filtered array, and then the previous results
array replaced with the new one. This eliminates 2*2N filter+concat
calls an their overhead from calling functions, creating arrays,
copying arrays and the memory for those arrays. (Where N is the number
of language-list strategies). It also reduces the total number of
indexOf calls.
Below is a comparison of time spent in createCompactList() during
page load process, compared to master without this and the previous
commit. Measured on localhost with Vector, EventLogging, Interwiki,
and ULS installed; on a page that is a copy of en.wikipedia.org/Messier_87
and its 51 interlanguage links. This page was a featured article
last week. Its count of links seems average compared to other
featured and/or most-viewed articles last week (the other ones
I checked had 23, 43, 52, and 76 langlinks respectively).
|--------------|----------|--------|
| | Before | After |
|--------------|----------|--------|
| Chrome 69 | 77.5ms | 41.4ms |
| MacBook Pro | 57.7ms | 44.4ms |
| CPU 1/6th | 63.8ms | 45.3ms |
|--------------|----------|--------|
| Firefox 61 | 12ms | 10ms |
| | 10ms | 9ms |
| | 11ms | 8ms |
|--------------|----------|--------|
| Safari 11 | 3.5ms | 2.7ms |
| | 3.3ms | 2.6ms |
| | 3.4ms | 2.8ms |
|--------------|----------|--------|
Bug: T127328
Change-Id: I56052e7c01c6a667500773e12c755a7a5f5d9cd0
The createCompactList() function runs synchronously during the
module execution burst. Due to it visually changing the page, I
won't defer it with rIC for the time being, although that should
be considered for the future. For this commit, I'm trying to make
it fit the budget of <50ms because ULS is currently usually taking
80ms-180ms on desktop (MacBook/Chrome CPU/4), and that's during
batch execution with other modules as well, thus freezing the
UI thread for much longer than that.
constructor:
* Remove needless clone of jQuery object.
Use $foo instead of $( $foo ).
* Remove creation of 'interlanguageList' and 'compactList' objects
that are immediately removed and re-created by init().
init/getInterlanguageList:
* Use the HTMLElement.lang and HTMLAnchorElement.href properties
directly instead of the DOM getAttribute().
This means stores a full url instead of a relative url, which
should help avoid other bugs in the future.
* Remove needless jQuery() constructor and jQuery.text() call.
Use Node.textContent directly instead.
* Use HTMLElement#querySelectorAll instead of jQuery#find().
init/getCompactList/../filterByLangsInText:
* Avoid jQuery() constructor and jQuery.attr(),
use the HTMLElement.lang property directly.
* Avoid jQuery() selector, call querySelectorAll directly.
init/getCompactList/../getCommonLanguages/../getFrequentLanguageList:
* Avoid temporary array copies from concat() and function overhead
with forEach() and filter().
Instead, keep only a single array, and iterate it once.
init/getCompactList/../filterByBadges (~10m -> ~0.5ms):
* Use one query via $(), instead of two queries $()+find().
* Use $.map() directly instead of map()+fakejQueryObject+toArray().
* Use querySelector(One) for the child instead of $()+find().
* Use HTMLElement.lang property directly.
init/hideOriginal (~5m -> ~0.8ms):
* Use querySelectorAll() directly instead of jQuery find().
* Set HTMLElement.style directly instead of jQuery() css().
init/render/addTrigger:
* Use createElement() and direct properties instead of $(), addClass(),
prop() and text().
* The mw.msg() calls use text() and jqueryMsg#parser which is
expensive.
Use plain() for 'ext-uls-compact-link-info', which doesn't need parsing.
Keep text() for the other message, and document why.
init/listen:
* Use async Deferred#then() instead of sometimes-sync Deferred#done().
Bug: T127328
Change-Id: I424c34fb82c8e95407f7b934e6d42019becbf909
Rather than building the link in JS, which is delayed until the JS
code loads, we build it in PHP and hide it from no-JS users with CSS.
Change-Id: If0c3a4dc137d8bf6cf24957dd063bd0a39791d2e
'mw' are '$' are globals, always have been, and aren't going
anywhere. They're every bit as real as their longer versions.
If anything, the longer ones are less "real" or 'stable" because
they're not used internally by RL and easier to accidentally
replace or override. For anecdotes and history, see 91f950d6b0.
Change-Id: I526fb8c961d9477992d88f2780a0ff4cbdc51923
It is created, unconditionally fired only once (right after creation),
and then used only with add(), which becomes a synchronous
self-call.
I've searched in Wikimedia Git and Codesearch, and found no uses
of `logEventQueue` or `mw.uls.eventlogger` outside this file.
Change-Id: I3832bcb409fc919c2078e583d50e20413dede163