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
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
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
'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
Since we added .i18n() call to upstream, it started overwriting
our text from the default data-i18n. Change data-i18n instead.
Bug: T188860
Change-Id: Ib7e9fb9590ace9c2a4ce2e2afb5a740ae4346be6
SPDX released version 3 of their license list (<https://spdx.org/licenses/>),
which changed the FSF licenses to explicitly end in -only or -or-later
instead of relying on an easy to miss + symbol.
Bug: T183858
Change-Id: Id75a37eab27282ca7797fa3e6ceb92750c59477f
The tooltips include the title of the target article
and the name of the language in the user's language.
Bug: T160976
Change-Id: If3dd416e4a6f13b7b1366d30a1a3807a505346cb
when appearing on right side of screen
Languageselect was mostly fixed in 354378, but I forgot the
settings ones, so the triangle just disappears when
switching dialogs currently. This follows up on that and
properly fixes it.
Sidebar callouts now appear toward content regardless of
where they're appearing from, or the language
directionality. Triangles are now consistently alligned to
the top of the callout (same position in languageselect and
compact language links) to avoid issues with it appearing
over a scrollbar.
Sideways callout triangles (carets) are consolidated into a
single rendering approach and mixin across compact language
links and toolbox language selector.
Bug: T161586
Change-Id: I7717e26525ac527ede486796f49083ed40ee7d4f
Depends on the core change in 1.28, which adds the
interlanguage-link-target class to the <a> elements:
I06c80945af785477be52096022c8493e7f82c298
Includes backwards compatibility code so that ULS compact links
would be usable on core versions that don't have this change.
Bug: T135378
Change-Id: I2909ce31e19087358d194e0e108e1ba038e7273e
Depends-On: I06c80945af785477be52096022c8493e7f82c298
Create a function for this purpose and use it everywhere where
language code is read from an attribute.
Bug: T143867
Change-Id: I01b6f04dd9185a9f4ab565e96ca5a6a34e4ea14a
Consistently with getInterlanguageList(). Without this 'nds-NL'
will be handled incorrectly when the article in it is featured.
Bug: T143527
Change-Id: Ie7fe5a270cb3030899b6034512351d5d66d7be06
This is just a simple search for elements with lang attribute.
This will be executed only when previous languages, geo-IP based languages,
browser, UI, content languages etc. are not filling the defined compact size.
Bug: T70077
Change-Id: I77d1efa5e29deeaaf595753fb5519c8b70c7f2b5
Not outputting language codes with proper casing should
be solved upstream in jquery.uls.
Bug: T139795
Change-Id: Ide81c76135b23a031f1f09a33462e767e57a50b0
We were executing all compacting strategies even when we have
more than enough items as candidates. If the strategy is expensive,
(performance wise) this is a problem.
In this commit, we execute them one by one and stop when we have enough
candidates.
The methods in CompactInterlanguageList class also arranged as
individual function declarations than comma seperated method list.
Change-Id: Idce6489387d139852125f4448d0e192f6a7e1353
This is already expected by the callers. Added addPreviousLanguage
to make updating the list easier.
Change-Id: Ie4f888235ea4de4a2ce6bf5a9f24955e423e8c48