Commit graph

541 commits

Author SHA1 Message Date
WMDE-Fisch fc4cef8c8d Add RevisionClickHandler only to new elements
When expanding the slider to newer or older revisions the handler
for revision clicks should only be added to the new revisions.

Change-Id: If590996d27dc75cbdfc931e9649418f875c3869d
2023-11-07 13:08:46 +01:00
jenkins-bot a4f6201e3b Merge "Remove redundant checks for .offset() !== undefined" 2023-11-07 11:32:53 +00:00
jenkins-bot 0debea3f8b Merge "Consolidate highlights and tooltip creation" 2023-11-07 10:00:04 +00:00
thiemowmde d2b03abe43 Remove redundant checks for .offset() !== undefined
We added this more as an experiment because we couldn't reliably
figure out what makes later .offset() calls fail. After looking into
the actual jQuery source code I realized the only way .offset() can
return undefined is when .length is zero. Which means the two checks
are redundant and one can be removed.

In case an element is not attached to the document an object with
{ top: 0, left: 0 } is returned.

Bug: T342556
Change-Id: I6265fd27b3102a9cfe853a9c0e11063b76cf0b7b
2023-11-06 22:14:58 +01:00
WMDE-Fisch 56b886a76b Don't try to draw lines when the slider is not fully loaded
Bug: T342556
Change-Id: Ibacc149214c23310f70b8efec19d6693a4d79c06
2023-11-03 11:11:30 +01:00
WMDE-Fisch 08fe283ba7 Give this context to removeColoredColumnBorders
Otherwise the `this` to call addColoredColumnBorders() inside of
that function is unkown when triggering the callback.

Can be verified working when collapsing the slider on master vs
this patch.

Regression introduced in Icffe9551d633470ccec1b63ea570e138db48dee8

Change-Id: I653db133688d7678d0cb3b80936c7e9a7ebebd1f
2023-11-03 10:34:42 +01:00
WMDE-Fisch 5550fc74da Consolidate highlights and tooltip creation
This is a first step in restructuring and consolidating the
highlight and tooltip creation. I use revision focus to communicate
the state when a revision is highlighted and shows a tooltip.

There's still stuff to untangle but I want to keep the diffs small.

Change-Id: I0b169042837a2c3bb825c23368e7e8a485694eb5
2023-10-26 20:37:54 +02:00
jenkins-bot 68a6403052 Merge "Mark private methods with @private tags" 2023-10-26 12:22:38 +00:00
jenkins-bot ff56357289 Merge "Partly drop dependency from RevisionListView to RevisionList" 2023-10-26 12:21:38 +00:00
thiemowmde 2c0532033e Mark private methods with @private tags
I might have missed some. These are easy to validate and I wanted to
start somewhere.

Change-Id: I8e4c2de884439f3793738a5270749ff663bbda1f
2023-10-26 14:05:12 +02:00
jenkins-bot e5919d1da6 Merge "Cleanup minor code duplication/complication in various places" 2023-10-26 12:01:11 +00:00
jenkins-bot 43b185fdbe Merge "Drop custom forEach loop in favor of native Array.find()" 2023-10-26 12:01:09 +00:00
thiemowmde 0d8158de5c Partly drop dependency from RevisionListView to RevisionList
It turns out the view class doesn't really do anything with the
RevisionList object. All it does it manually iterating the array of
revisions. But it doesn't call anything from the RevisionList class.
With a single exception.

Warning: This doesn't mean the RevisionList class is pointless. It's
critical because this is where the relativeSize fields are calculated.

Bug: T224971
Change-Id: I06b8af815bb6f931355d68aa511070fb34b08156
2023-10-26 13:58:59 +02:00
thiemowmde 3f0aae5e73 Cleanup minor code duplication/complication in various places
Change-Id: Icffe9551d633470ccec1b63ea570e138db48dee8
2023-10-26 13:46:16 +02:00
thiemowmde 3a9abded84 Clamp slider position when using the browser's back button
Steps to reproduce:
* Make the browser window very narrow so that RevisionSlider can't
  show the maximum number of gray bars.
* Go to a page with many revisions, open the RevisionSlider, and pin
  it.
* Click the "Older edit" navigation link.
* Now make the browser window larger. Note how RevisionSlider will
  have more space to show more gray bars.
* Use the browser's back button.

The pointer positions will jump to a random position.

The problematic code is in DiffPage.initOnPopState() where a "state"
object from the browser history is used to not only restore the
position of the blue and yellow pointers, but also the relative
starting position of the slider (the position you can manually change
with the large left/right arrow buttons). The way this relative
position is calculated depends on the number of revisions that fit
on a screen, which depends on the the available screen width. The
problem is that these numbers change after the state was recorded in
the browser history.

It might be that this patch still does not solve the issue in all
possible situations. But it already makes it behave much better.

Bug: T349208
Change-Id: If8e89457232061698c3821cae2d0aab3f7778b26
2023-10-25 15:03:44 +02:00
jenkins-bot cdf7a4af52 Merge "Replace loop with native Array.indexOf() in RevisionListView" 2023-10-24 10:54:50 +00:00
thiemowmde 48173f59af Replace loop with native Array.indexOf() in RevisionListView
According to my tests this behaves the same as before.

Change-Id: I659146232b0237f6098960b53acb91e12c9e9647
2023-10-24 12:35:18 +02:00
WMDE-Fisch b5feef80a6 Only draw lines connecting the diff when it's availible
The offsetNotAvailable method is part of the class ever since it was
created in Iadf7793. It always only checked one of the two columns.
This confuses me, to be honest. The PointerLine class is meant to have
exactly two instances: One for the left (yellow) and one for the
right (blue) lines. There should be no reason the left reaches into
the right, and vice versa.

Bug: T342556
Change-Id: I31117b3a6bb73c397f7702cb3b162276de1a77ca
2023-10-24 12:09:45 +02:00
jenkins-bot 362ba6d890 Merge "Merge two jQuery calls in RevisionListView class" 2023-10-23 21:29:06 +00:00
jenkins-bot 0eaf05f33a Merge "Fix docs and avoid duplication in PointerView class" 2023-10-23 16:53:15 +00:00
thiemowmde 6178ba7936 Fix docs and avoid duplication in PointerView class
Change-Id: I82395995dadd3c7f7f8d7973c5e51cc367e11b5a
2023-10-23 18:38:18 +02:00
jenkins-bot 132a6bb0e8 Merge "Make .less code a little more compact" 2023-10-23 13:07:00 +00:00
thiemowmde cead74416e Merge two jQuery calls in RevisionListView class
I'm sure this does the same as before. Note that we don't care how
many elements are found. Only if at least one element is found.
Whichever is found first, we can stop searching then.

This is especially relevant when the first jQuery search doesn't
find anything. It scans the entire DOM tree (upwards) then.
Combining the two means the search can stop earlier.

Change-Id: I0903c58f87fb133135a7b0de273460ff80fb45ff
2023-10-23 14:48:50 +02:00
thiemowmde 69f6410916 Make .less code a little more compact
The idea is to visually group things together that belong together.
This reduces duplication and hopefully makes the code easier to
read.

Change-Id: I609ee0eb5644de9c32984a3b2535652504e0e940
2023-10-23 14:31:09 +02:00
thiemowmde 990a9cc828 Fix certain history events being triggered multiple times
See T349208 for an explanation. It looks like the SliderView.render
function was written with the assumption that it's only triggered
once on construction time. But since T139101 it's triggered again
for every window resize event. This adds the same event handlers
over and over again to existing elements that aren't affected by
the SliderView.render function.

This will probably become even worse with I49878fd (T336729).

Please test this carefully. I'm not 100% sure this is the best
possible fix.

Bug: T349208
Change-Id: Iba22924b660f2709c0680aa6fbeb0feba92cfa76
2023-10-18 15:38:04 +02:00
thiemowmde d85496a2a8 Drop custom forEach loop in favor of native Array.find()
Plus a few minor code cleanups in the RevisionListView class.

Change-Id: I828eb92936e3a36a3794b38eac80ba50399ffaef
2023-09-30 11:52:20 +02:00
thiemowmde 6ad0647543 Fix bad use of jQuery.append with a text message
Calling .append() with a text message means jQuery will happily parse
it as HTML if it looks like HTML.

Found with the new x-xss debug feature.

Change-Id: I916f4dd8f530a8e88d34918a24fdfd28a86708f2
2023-09-30 11:45:51 +02:00
jenkins-bot ea267c7240 Merge "Simplify tooltip and hover effect removal" 2023-09-05 16:24:31 +00:00
WMDE-Fisch 3140576347 Simplify tooltip and hover effect removal
There's no need and probably just minimal gain to use these methods
with a revision as input. We could always just cleanup all tooltips
or wrapper highlighting before we set a new one. Makes the code
much simpler.

Change-Id: I34594843ccafa83372c796ff8cca68c4d6b58e06
2023-09-05 17:19:35 +02:00
WMDE-Fisch de99612520 Rename tag/user highlighting to free up the term
While working on renaming and consolidating some methods I found
it puzzeling, that the generic "highlight" word is already taken
by the filter mechanism. So I made these things more specific.

I checked the global wiki search if any user referes to these to
override CSS. It seems nobody does, so the change should be save.

Change-Id: I47c149978b0527c2d9e91709ef9d704526d56101
2023-09-05 12:01:02 +00:00
jenkins-bot 23b2f811a2 Merge "Don't trigger hover or tooltips from a tooltip" 2023-09-04 09:35:43 +00:00
jenkins-bot 77792dfc12 Merge "Close popup when clicking enter" 2023-08-31 13:56:34 +00:00
jenkins-bot 122964ed7d Merge "Close tooltip when the focus moves away" 2023-08-31 08:56:18 +00:00
jenkins-bot e66f2f370b Merge "Remove grab cursor workarounds for older browsers" 2023-08-30 18:11:13 +00:00
WMDE-Fisch 41cb479b45 Remove grab cursor workarounds for older browsers
According to the compatiblity standards to give Grade A support
for modern browser versions not older than 3 years, we do not need
these workarounds anymore.

Change-Id: Ib1c42594b2c4077cabb010b8830a04ab10938a17
2023-08-30 18:05:10 +02:00
thiemowmde e65e19aa56 Make use of Codex LESS tokens where possible
Mostly motivated by the confusing border-radius.

Change-Id: I87c0fd6fbe86df765a41047a04a8d2a3c6516403
2023-08-30 17:54:59 +02:00
WMDE-Fisch 45b68b2942 Don't trigger hover or tooltips from a tooltip
Mousemove events seem to bubble up and can trigger unwanted hover
effects when the tooltip is appended to the pointer container.

This regression was introduced in the patch that supports tabbing
into the tooltips in I75ef7c32fb105526552eac387ff5a5bda8eefe1b

Bug: T341872
Change-Id: I975cc054a760f2da1d8ea37d10d9a5bf00bf3ae2
2023-08-30 14:40:13 +02:00
WMDE-Fisch e2bb3741e6 Close tooltip when the focus moves away
Adds two handlers to make sure the popup is closed when the focus
moves away from either the pointers or contents of the a popup.

Bug: T341874
Change-Id: Ia68fc5ffbb63b4a534c84987879499e06cd60238
2023-08-30 08:56:06 +02:00
jenkins-bot 3dcd9c3756 Merge "Remove obsolete per-skin CSS" 2023-08-29 15:47:18 +00:00
jenkins-bot 3b6eeb0be8 Merge "Restore highlightable-row CSS we accidentally removed" 2023-08-29 15:46:40 +00:00
thiemowmde 10931b6210 Remove obsolete per-skin CSS
This is obsolete since I75ef7c3 where we had to replace the
`font-size: 0.8em` with a fixed 13px.

Bug: T341872
Change-Id: I81603536dd930c6faee38c63aabe848203c42715
2023-08-29 17:29:20 +02:00
thiemowmde 6455955ea1 Restore highlightable-row CSS we accidentally removed
This was removed in I75ef7c3. Turns out it's needed for the
highlightable elements in the popups (e.g. when highlighting all
edits made by the same user). The text row in the popup gets a thin
gray border. This border needs some padding on the left.

The solution is to make the CSS selector more specific so it can
win over the problematic selector in Vector.

Bug: T341872
Change-Id: Ia029b92b5e049c60279b55177a62e03919dc55d8
2023-08-29 17:23:31 +02:00
thiemowmde 98e5730835 Remove more duplicate code in SliderView class
Change-Id: I4580047617cfadba04339c1f58d896507927ee73
2023-08-29 17:07:47 +02:00
Svantje Lilienthal 143dee9a1d Close popup when clicking enter
Bug: T341874
Change-Id: I8cafbc93a87d168a428b2e9e46a60ea812ae584c
2023-08-29 16:13:33 +02:00
jenkins-bot 24ca67ff10 Merge "Trigger popup creation on pointer focus" 2023-08-28 12:58:07 +00:00
jenkins-bot 89b7d1fcc2 Merge "Append tooltip to focused pointer to allow tabbing into it" 2023-08-28 12:50:16 +00:00
jenkins-bot b0efa18399 Merge "Generalize revision click handlers" 2023-08-28 12:50:14 +00:00
WMDE-Fisch cc37621ab9 Generalize revision click handlers
The pointer click and revision click handlers did almost the same
and the former was able to handle events from the latter. I merged
them and could then shortcut some code.

Change-Id: Id224b8d8da653110134cce0385da3a18cd073ecf
2023-08-28 11:47:21 +02:00
jenkins-bot b77b5dcbf8 Merge "Dramatically simplify duplicate code in the PointerLine class" 2023-08-28 06:45:23 +00:00
jenkins-bot 2e173563f8 Merge "Don't add keypress handler when not needed" 2023-08-28 06:21:01 +00:00