Commit graph

122 commits

Author SHA1 Message Date
WMDE-Fisch f77502f526 Move tooltip events to the tooltip creation
Change-Id: I0de2aa4fabde1d4a063373de26336ccf6c8bda5e
2023-11-09 09:10:37 +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 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 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
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 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
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
WMDE-Fisch cd90d01977 Append tooltip to focused pointer to allow tabbing into it
When the user uses the keyboard to interact with the slider, the
revisions can changed by moving the pointers with the arrorw keys.

In that case the pointers have keyboard focus. To allow tabbing
into the popup from that position, the tooltip needs to follow the
pointer in the DOM. That's what's done in this patch.

Bug: T341872
Change-Id: I75ef7c32fb105526552eac387ff5a5bda8eefe1b
2023-08-25 14:45:24 +00:00
jenkins-bot 72ef3975c7 Merge "Drop wikitext comment in favor of parsedcomment" 2023-08-25 13:54:56 +00:00
WMDE-Fisch 8c4b9b963a Don't re-create tooltip when it's already there
It took me a while to come up with a solution for this, but there
are several things that seem to trigger the showTooltip method a
bit to often.

Tooltips can be triggered either by the handlers that deal with
mouseenter and mouseleave events that also trigger revision high-
lighling. But tooltips can also be triggered when you use the
keyboard or the mouse while dragging sliders.

The mechanics on what's highlighted and what's triggering a popup
are a bit weiridly setup and there could probably be a major re-
factoring done to make things clear ( for example the show popup
method also highlights the revision but the highlight revision
mehtod does not ). I had a quick approach to fix that, but it's
not too easy.

Another issue is, that some events fire off a delayed popup close
mechanism. So the solution here reads like:

If you are triggered to show a popup, and that popup exists
already, stop the delayed popup close mechanism and bail out.

Bug: T341872
Change-Id: I2646a69cccd549af902d57fdf4ff6fb0e94cbe64
2023-08-25 15:35:06 +02:00
thiemowmde 3d93003dcc Drop wikitext comment in favor of parsedcomment
The plain wikitext comment is apparently not used for anything,
anywhere. It was for some reason used for an "is empty" check. But
we can do the same with the `parsedcomment`. I checked and an empty
comment doesn't result in something non-empty like `<div></div>`, but
stays as an empty string.

Change-Id: Iedc5898b7b0f82231328ab3e0e46b1461ca845b1
2023-08-25 14:42:32 +02:00
jenkins-bot 03235ac917 Merge "Remove unused hasNoTags helper method" 2023-08-25 07:20:45 +00:00
thiemowmde dd9e9e25b4 Remove some self = this indirections that are not needed
Change-Id: I2c267e036a1b8ad395019b1aa3dcb29c21b9b251
2023-08-24 11:36:15 +00:00
thiemowmde a045c78b3d Remove unused hasNoTags helper method
Change-Id: I31b08328d8582bd75c6e972cfbfac7b555455015
2023-08-24 11:29:18 +02:00
Adam Wight b900446572 Migrate JS to ES6
Reintroduces IIFE closures in test files because variables were
declared in the global namespace, and "const" now causes hard errors.

Bug: T339323
Change-Id: I69e9d7a29591137f185f3e5ab02dea590ec4dff6
2023-06-23 08:01:31 +02:00
Fomafix 65d1dfefbf Use document.body instead of 'body' as jQuery selector
Change-Id: I2e74d31b61f5f46d1bbb1a0283a7468af9c4e856
2023-04-21 08:52:25 +00:00
Fomafix c86df62861 Use mw.msg( ... ) instead of mw.message( ... ).text()
Change-Id: If954018fdfa5a3609bf48e92de9013b05c485f93
2023-04-21 06:36:08 +00:00
Ed Sanders dcf19784eb Define documentable types in eslintrc instead of inline
Change-Id: I20e805839a13697ffea8d4a2f92b1c3a4b023175
2021-10-17 15:35:14 +01:00
Ed Sanders 64effa6e42 Move var declarations inline
Change-Id: If1256b01f6ac8237c79b5ba62f20ad65f1dc7691
2021-10-07 14:55:44 +01:00
Thiemo Kreuz a2bd859b29 Simplify/reformat code pieces with a lot of duplication
Change-Id: I7f933bb0d5c82858e5ab1831f9021f67e373ff69
2021-07-01 09:16:34 +02:00
Thiemo Kreuz c8ddf3c9b9 Fix jQuery.offset() calculation possibly failing
It turns out the jQuery documentation is incomplete:

  $( '<a>' ).offset() → { top: 0, left: 0 }
  $( '<a>' ).parent().offset() → undefined

The difference is that the jQuery set in the second example is
empty.

Bug: T282067
Change-Id: I7c19162f1a39bd529e0a74a6cc0c1ac987f33657
2021-06-21 15:35:21 +02:00
Adam Wight ebd9985afc Migrate RevisionList to packageFiles
Change-Id: I3299d3a4bc66a3b85d0d0f7d8a49edbf8f6329c3
2020-11-19 08:54:10 +00:00
Thiemo Kreuz 4ac1ff57f1 Remove closure wrappers from all JavaScript code
These are not needed any more, because the code runs in a
seperate scope anyway.

Change-Id: I939a06102f194a0c98021accb2f62be73dd0562f
2020-11-18 11:16:04 +01:00
jenkins-bot df52b15efb Merge "Get rid of all var … = function () {} declarations" 2020-11-16 15:15:32 +00:00
Thiemo Kreuz c57fe0f2b6 Get rid of all var … = function () {} declarations
… and replace them with more trivial `function …() {}`. I
believe this does not make any difference. But I feel this
makes the code a little more straightforward.

The motivation for this patch is because a few other patches
change some of these function declarations, leaving a (in my
opinion) confusing mixture of styles behind.

Change-Id: Ib8928c4176a963afcf1fee1c785dd7bdc86c9706
2020-11-12 19:23:40 +00:00
WMDE-Fisch 9386cb6f65 Improve some JSDoc blocks
- mostly fine graining Event objects referenced
- removing one obsolete parameter doc

Change-Id: I1270c4b8100da647ca0739f7f3571bd48d484137
2020-11-12 15:48:27 +01:00
Ed Sanders eaa7966710 build: Update eslint-config-wikimedia to 0.16.1
Mostly documentation style fixes

Change-Id: I75262aead377f7f41931de44c5208b7b7d06930d
2020-06-16 15:13:36 +01:00
Thiemo Kreuz 7f38c9c579 Improve discoverability of JS code with @class tags
In my PHPStorm IDE, this makes it possible to follow all methods and
properties in these classes, even these that are later defined.
Otherwise only the empty stub of each class is found.

This might be different in other IDEs.

Basically: PHPStorm does not understand the meaning of the $.extend()
syntax from jQuery without these hints.

Change-Id: I4aa76db183122f6669dc72561441f46f0056d793
2020-01-24 17:21:23 +01:00
WMDE-Fisch 7c47e6e981 Apply user highlighting for all revisions in DOM
This only solves part of the issue. Highlighting is applied for more
elements since they are retrieved from the DOM. The problem still exists
since highlighting depends on the RevisionList chunk on which is it applied.

To fix the issue completely highlighing should be managed somehow globally
on the global list.

Bug: T207781
Change-Id: Idda930f3d0dd64e767c68dade2ca8759bc636898
2019-05-19 11:27:59 +02:00
WMDE-Fisch 9e73c7d2c1 Fix re-highlighting of revisions
This was broken for obvious reasons. Also adding a test.

Change-Id: Ib6e8988884ff84472928758d4112574e17fa48be
2019-04-25 11:15:14 +02:00
WMDE-Fisch 98c33c4731 Extract reapplication of saved filter state
Change-Id: If770e0cb52034a5f52bc8bb3639c9dccdf64b683
2019-04-12 19:15:18 +00:00
WMDE-Fisch d4a3ec243e Use switch statement for filter events
Change-Id: I0f564e33744d3806682534267c4b922edd5e9b3c
2019-04-12 19:15:12 +00:00
WMDE-Fisch bd38ccaf98 Early exit filter events
Change-Id: I72fd4a1496f6c0247a9166ba54ce3de2918bc310
2019-04-12 19:15:05 +00:00
WMDE-Fisch 32cf219c4e Extract code that resets/removes highlighting
The next iterration on avoiding code duplication. I
still stuggle a bit merging these methods in a sane
way.

Change-Id: I8d95acc06da7f83a6133e55becabdf03b26a97af
2019-04-12 19:13:20 +00:00
WMDE-Fisch a49cb0c466 General code reduction in the highlight event handlers
- make use of toggelCSS()
- use more general jQuery selectors ro reset the line and bubble highlight
- get rid of ~= when selecting revision ids

Change-Id: I123e263bb379107a561fe8a2ffed476da9032b88
2019-04-12 19:12:44 +00:00
WMDE-Fisch f4c64b744e Put event setup for user line highlighting in own method
This is mainly a copy of what's done for the tag lines to set the events.
In the next steps I'll try to avoid code duplication here be extracting
common code.

Change-Id: I29df109de30c538cc206d445abff8464baf45378
2019-04-12 19:09:50 +00:00
WMDE-Fisch a2ca2c031e Add node selenium tests for revision highlight feature
The patch adds a first package of node selenium tests including
test for the user and tag filters.

The classes for user- and tag-rows were re-added to have better
access via selectors.

Change-Id: I8c53d9c923820e177d83ee900cee08e93cd3f65b
2019-04-11 17:58:53 +02:00
WMDE-Fisch a96b079e8f Unify highlighting CSS classes
Change-Id: Iceb094075d1fb1bd4aca53c120dbc3c6ccd39eb6
2019-03-25 17:30:47 +01:00
WMDE-Fisch 55c558169b Retrieve revision list in highlighting method
This moves the retrieval of the revisions into the method setting the
highlighting. The check for undefined did not to much since the rev
var would still remain undefined.

Change-Id: I1acf540f135af4c16fb80d633b3690473ada7833
2019-03-25 17:21:03 +01:00
srish 6ee7f910b7 Add filters for tags
* Uses the existing implementation of highlighting revisions from the same user
* Shows bubble next to tags in Tooltip
* When you hover on a bubble, tag row is circled, and revisions with a specific tag gets highlighted. When hovering ends, highlighting ends. But, if there is an active filter available, all previous states are restored accordingly.
* When you click on a bubble, in addition to highlighting revisions and tag row, any previous tag or user filter is removed.

Bug: T203581
Change-Id: I824a027a7f542eb7227545870553e58ec23542bb
2019-03-25 16:57:57 +01:00