Commit graph

132 commits

Author SHA1 Message Date
WMDE-Fisch 58f820009e Use flags to represent settings
To reduce size of code added to the <head> and increase performance.
The increased bundlesize is still less than the size spared bytes in
ResourceLoaderGetConfigVars. - But nevertheless the main gain is loading
less in the <head> anyways.

To avoid further complexity in the code, the bitmask is converted to
the according config setting early on instead of adding checks on the
bitmask all over the place.

Tests will be added in follow ups.

Bug: T276716
Change-Id: Ib4f82bed58295b25f0a41cb37e36244e45f16317
2021-03-11 13:38:06 +01:00
Svantje Lilienthal 1962372a44 Add cogwheel to disable ReferencePreviews
I added the common styling for the setting icon to the popup.less
and removed the now empty pagePreview.less.

Bug: T234205
Change-Id: I2a82831bc71a4208c4b66c18e2a4613127c43e1f
2021-02-16 15:39:43 +01:00
Bartosz Dziewoński c8b8ba7f5f Revert "Remove title attributes at init"
This reverts commit 6bc2077ed5.

The change causes issues with various popular gadgets on Wikimedia
wikis. The 'title' attributes have been the easiest way to determine
the target pages of links, and many gadgets have come to rely on that.

Bug: T269297
Bug: T269873
Change-Id: I49d315a13c327a1c5af51d3de887c0c17642e9fe
2020-12-11 16:53:17 +00:00
Noam Rosenthal 497eb631d1 Parse template HTML only once, as HTML parsing is expensive
When creating a popup, clone the previously created DOM element
and populate the attributes and content.

Ideally this would be done with a template element, but since IE11
is still supported this is not possible.

Change-Id: I347615cf1f613d97d767d60627b13b6b3ff9c762
Bug: T269338
2020-12-07 23:01:26 +00:00
Vedmaka ff2ba9ebf5 Adds "$wgPopupsTextExtractsIntroOnly" option to control "intro" parameters for TextExtracts API request
Change-Id: I84f91ab0752bbd4a5b1ee159b7cbe1388f942f24
2020-12-07 15:00:29 -08:00
Thiemo Kreuz c6ea149d34 Wrap long words in reference preview popups
Bug: T266859
Change-Id: I874d60246a0337577c0f411d0d24f237c1ceebf2
2020-10-30 20:14:39 +01:00
Adam Wight 877c2f3e12 Clicking on a reference should behave normally
We no longer intercept reference clicks, now clicking on a reference
label will scroll to the reference definition in the same way as when
reference previews is disabled.

Metrics about clicking on the label are collected by the Cite
extension, are are unaffected by this change.

Bug: T265482
Change-Id: I2929a86b6a09f3b72e5e2f4151cb13f52446897d
2020-10-30 10:57:41 +01:00
Thiemo Kreuz 1cf721e2a2 Handle collapsible & sortable elements in reference popups
Elements that are marked as collapsible (often tables, but can
actually be anything) are most certainly marked as such because
they are big and don't fit in a popup.

Another plugin makes tables sortable.

In both cases non-functional UI elements appear in the popup.
We decided:
* Hide collapsible elements (no matter if currently collapsed
  or not), and show a placeholder text instead.
* Remove sortable arrows.

This is a baseline patch that solves everything, except the
(i) icon is missing. This will be added in the next patch.

Bug: T220208
Change-Id: I58f3036bf4988d0ebe5716b0a54506446fca10c3
2020-10-28 17:23:12 +01:00
Umherirrender 3d179775b9 build: Update eslint-config-wikimedia
Fixed the jsdoc issues

Change-Id: Ib6acf224ea5527e5c6a14212cb95b49018241764
2020-09-30 00:46:58 +02:00
Umherirrender 23b6332a5b Avoid shadowed variables in javascript
The rule no-shadow gets enabled in the version eslint-config-wikimedia
0.17.0.
In prepration for the automatic update with libup this needs to be done
in a separate patch set due to T262450

Change-Id: I66d405aef6d2b777e9a7f63734f2b5a5649d2080
2020-09-21 20:31:44 +00:00
jenkins-bot fc413f3ad6 Merge "Selenium: Update to WebdriverIO v6" 2020-08-25 10:32:18 +00:00
vidhi-mody bd7b4c87cc Selenium: Update to WebdriverIO v6
Update NPM packages: @wdio/* and webdriverio.

Bug: T258620
Change-Id: I63e6812e5cfd0e29444765b4b956a9a63711dfdb
2020-08-25 15:10:40 +05:30
Ed Sanders 56d87d6795 Disable popups inside VE surfaces
This was already accidentally the case for the main VE article
editor as it doesn't live inside #mw-content-text, however other
VE surfaces (e.g. DiscussionTools') don't live inside #mw-content-text.

Bug: T259889
Change-Id: I48bdee6f62af33cad7512128b5465d474a6dfebb
2020-08-08 12:53:03 +01:00
jenkins-bot 88fa9c0131 Merge "Disable Reference Previews in the (mobile) Minerva skin" 2020-07-24 14:53:33 +00:00
vidhi-mody 17a3e59a1e Selenium: Update to WebdriverIO v5
Update NPM packages: webdriverio, wdio-mediawiki.

Replace NPM packages:
- wdio-mocha-framework with @wdio/mocha-framework.
- wdio-spec-reporter with @wdio/spec-reporter.
- wdio-junit-reporter with @wdio/junit-reporter.

New NPM packages: @wdio/cli, @wdio/local-runner, @wdio/sync.

Commands that return data no longer wrapped in `{ value: … }`.
Values are now returned directly.

Replace:
- `browser.element` with `$`.
- `chromeOptions` with `'goog:chromeOptions'`.
- `password` with `mwPwd`.
- `username` with `mwUser`.
- `moveToObject()` with `moveTo()`.
- `isVisible()` with `isDisplayed()`.

Bug: T258620
Change-Id: If339ff08b5e87c91905a65927ccd7e1b72b9f8e4
2020-07-24 17:17:01 +05:30
Thiemo Kreuz 5da88be420 Disable Reference Previews in the (mobile) Minerva skin
Bug: T243822
Change-Id: I6de02243301184bce8ff53a56b13752880ecfbe6
2020-07-24 13:01:47 +02:00
James D. Forrester e37ce8ef80 build: Upgrade grunt to 1.1.0
Change-Id: I2196e88f40a9cbd57c33e157e699a74870778efa
2020-06-26 17:35:18 +01:00
James D. Forrester eb0347135a build: Upgrade grunt-banana-checker to 0.9.0
Change-Id: I6532248f8384d1a818598ac30c75d01d3350ae88
2020-06-26 17:33:41 +01:00
James D. Forrester 5452af11e6 build: Upgrade stylelint-config-wikimedia to 0.10.1
Change-Id: I05f987be2d5925ec65e2862cfb47a70972bc4f28
2020-06-26 17:12:10 +01:00
Ed Sanders 536470c01d build: Update eslint-config-wikimedia to 0.16.2
Change-Id: Icb65074fe64993314bbb28f690ce3ce0f89fb57c
2020-06-26 17:05:56 +01:00
Ed Sanders 85fc18d38d eslint: Cleanup linting of /dist
* Move eslintrc.es5.json to /dist to avoid extra Grunt config
* Upgrade clean-webpack-plugin and exclude dist/.eslintrc.js
  from cleaning
* Set root:true and just enable wikimedia/language/not-es5 instead
  of disabling dozens of rules
* Remove getOwnPropertySymbols rule as webpack uses this.

Change-Id: I802138a8a591dd4c3cb0cc637112e383570286df
2020-04-27 20:45:42 +01:00
Ed Sanders 957e81747b eslint: Update to 0.15.3
Change-Id: Ide2bdfac7838408c39e1d26ea7662b90a6e3ddfd
2020-04-25 22:32:53 +01:00
jenkins-bot 992f73ebab Merge "build: Upgrade jquery to version used in MediaWiki" 2020-02-04 09:21:14 +00:00
jdlrobson 62af052bf6 build: Upgrade jquery to version used in MediaWiki
Change-Id: Ied35038ad5c86cad847d9f5fc3d395d7a087124c
2020-02-04 17:04:25 +08:00
jenkins-bot ee6c902702 Merge "build: Upgrade nyc from 13.1.0 to 15.0.0" 2020-02-04 08:04:18 +00:00
jdlrobson 2337c84a78 build: Upgrade nyc from 13.1.0 to 15.0.0
Bug: T243790
Change-Id: Ib8cc7041d792bed0a19d18e14506627099a69bea
2020-02-04 15:35:29 +08:00
James D. Forrester 23bb1c1796 build: Upgrade tap-mocha-reporter from 3.0.7 to 5.0.1 for npm audit issue
Change-Id: I1c51725ec66df14b112937e830dd697a576bfeaa
2020-01-06 16:13:12 -08:00
jdlrobson 24666442d5 Storybook: Copy over static files
Follow up to  I58493db15b27f148fcc1cf42ab0b0148ee291eb6

Bug: T236589
Change-Id: I706107f80048a14a8122df503f53eb6936b95395
2019-12-12 13:08:22 -08:00
jdlrobson 189b386a13 Publish storybook now we are using more modern node
Breaking change - I was having issues getting the knobs feature
to work so it has been removed for the time being.

Bug: T236589
Depends-On: I8505d2dad69aefed5f8ed1f599b3ca1b7e79acf5
Change-Id: I42fbf37124477e2d950b4bca15acf77703cd3f5d
2019-12-11 15:16:13 -08:00
Adam Wight 07aa0f3ae9 Don't record Popups actions on non-content pages
We found that Popups was overcounted approximately 2.5x relative to Cite.
This patch attempts to nearly match the circumstances under which Cite
(and its tracking) is loaded.

Bug: T214493
Change-Id: Ib31df3c33879f4ea63d9808ffd260861069a8977
2019-11-14 16:52:05 +01:00
jdlrobson 01fc2db19f Use 6.1.0 of @wikimedia/mw-node-qunit
Bug: T203137
Change-Id: I9fd701cc9575ad250c919d88bf1fe74898b690eb
2019-10-22 10:42:49 -07:00
Thiemo Kreuz 76e02fae98 Remove obsolete mediaWiki and jQuery aliases
Notice how this actually reduces the size of the final, compiled index.js.
It's not much, but still.

One issue I noticed is that the coverage reports for the JS code stopped
working. I have no idea why.

Bug: T208951
Change-Id: I2fe92579574b3b1ba4d2dd064899eee944045a96
2019-10-22 09:30:46 +02:00
jdlrobson 7d6a903d69 Upgrade Popups mw-node-qunit version
Bug: T203137
Change-Id: I0cf856d04eacf5bf7764c58db55eeae04811e973
2019-10-15 15:36:54 -07:00
Ed Sanders af07b4214e build: Update linters
Change-Id: I4170001345e511cc47ebe77977433488b6f1b523
2019-10-07 16:32:01 +01:00
Adam Wight 76a34618c3 Tracking for Reference Previews interactions
Logs events to the ReferencePreviewsPopups EventLogging schema, in
order to understand whether Reference Previews is helpful for
end-users.

This will be removed along with the older tracking, as soon as our analysis
phase is finished.

Incidentally disables a lint rule for the generated JS, it's about
readability so irrelevant to the minified code.

Bug: T214493
Change-Id: I2638611ba67b785338f7e98a1c4b08a5e829812d
2019-10-07 11:22:00 +02:00
Ed Sanders 9b3029e0ee Build: Update linters
Change-Id: Ia2a833a01e1bb05d6be3923dd452b1851afd7655
2019-09-17 12:47:25 +01:00
libraryupgrader ca30a90a70 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 24.0.0 → 26.0.0

npm:
* set-value: 2.0.0 → 2.0.1
  * https://npmjs.com/advisories/1012
  * CVE-2019-10747
* union-value: 1.0.0 → 1.0.1
  * https://npmjs.com/advisories/1012
  * CVE-2019-10747
* mixin-deep: 1.3.1 → 1.3.2
  * https://npmjs.com/advisories/1013
  * CVE-2019-10746
* lodash: 4.17.11 → 4.17.15
  * https://npmjs.com/advisories/1065
  * CVE-2019-10744
* wdio-mediawiki: 0.2.0 → 0.4.0

Change-Id: I6d8d0e35f5dd0eb19d42cc57547ede5e38e1fa68
2019-08-15 19:40:36 +00:00
Ed Sanders a17be78b3d build: Update linters
Change-Id: I9b32f412e7e75918a59bdb239d3a42670177be70
2019-08-15 09:55:57 +02:00
WMDE-Fisch 7d7317da10 build: bump dependencies and make tests pass
Change-Id: I5fb80d19c7a0423648053c66fd9c2b7680f30426
2019-08-14 17:09:18 +02:00
James D. Forrester 4fb6120fc9 Upgrade from node 6 to node 10, now that CI is running that
Change-Id: I8830cc39c8f5c5d22299d3c3cc90b308f50fb08a
2019-06-03 14:51:51 -07:00
WMDE-Fisch 1879a4d59e Show referencePreviews on click
Introducing the REFERENCE_CLICK action that will fetch and show the
preview for the clicked reference right away without any delay.

The main goal of the new chain of events introduced with the reference
click is showing the reference preview right away. The actions triggered
by the dwelling include delays in multiple parts of the process.

If there's a dwell action-chain in progress when the click action is
executed, the related promise ( that might still include steps with
delays ) and the reference preview is retrieved and shown right away
re-using the token. 

In the case where there's no dwell action running ( e.g. when the click
was triggered via touch ) we create a new token and start from scratch.

In either case we want to avoid, that multiple clicks trigger multiple
actions and abort early when there's already a click action in progress.

Bug: T218765
Change-Id: I073a93be2d17a21178aebe12267765f60a2811b9
2019-04-29 17:46:49 +00:00
WMDE-Fisch d72ef0fa65 Avoid fade-out above horizontal scrollbars
The changes in the patch check if a horizontal scrollbar is present
and move the absolute positioned fade overlay above that scrollbar.

Since we cannot change the CSS of the :after element via JS a new div
element was introduced.

Bug: T220200
Change-Id: Ia69c9be0facaf3ecebdb9f76d36f7cb3412c0816
2019-04-26 18:02:06 +02:00
Andrew Kostka 522829c43a Add a fade out to reference content
This will only be applied when the height of the content exceeds four
lines of text.

Bug: T217139
Change-Id: If15952c9886c23827873812bb63e8e3127776709
2019-03-25 13:30:52 +01:00
Ed Sanders 1627dadcab build: Update eslint-config-wikimedia to 0.11.0
Change-Id: I80e2707d9954f8549aa0241f4c7f64eb2644ec93
2019-03-18 15:48:01 -06:00
Stephen Niedzielski b3dd38c8aa Build: synchronize Webpack config with MobileFrontend
Minimize the difference between MobileFrontend and Popup's
configuration where possible. No build delta was generated so the change
is expected to be nonfunctional.

- Set the Webpack configuration file's ESLint environment to Node.js
  instead of manually specifying Node.js globals.

- Directly export the configuration as a function instead of persisting
  a local and assigning it to module.exports at the end.

- Export the configuration as a function and replace Node.js variables
  with Shell compatible parameters. This required inlining a couple
  single-use variables. See
  I83e507fad1ee2f477bb95c2987d0b24f082b2165.

- Reorder configuration and update comments to match MobileFrontend.

Change-Id: I24545da2d029d08b0ea0e1330b6bb71ce423e6b7
2019-03-07 13:37:59 -07:00
Thiemo Kreuz 90acf2a778 Fix pointer mask and CSS offsets for flipped popups
I tested this with all 16 possible combinations:
* The pointer can show up in all 4 corners.
* The popup can contain a thumbnail or not. The code for the pointer
  is very different then, because the SVG masks are only relevant in
  this scenario.
* The thumbnail can be tall or not.
* I even tested tall popups without a thumbnail. This is a combination
  that is impossible in production scenarios.

I found 3 issues. This patch fixes 2 of them:
* The pointer is misplaced in the bottom-right corner when the popup
  does not have a thumbnail (as reported in T215194).
* The pointer is misplaced in the upper-right corner when the popup
  shows a thumbnail.
* The pointer in the upper-right corner is gray instead of white when
  the popup is tall, but does not show a thumbnail. As this is not
  relevant in production, I did not fixed it.

It seems both misplacements are because of the same reason: For some
reason, calculations are done based on the assumption the popup would
be 300px wide, but it is 320px wide.

Note I did not just added 20 everywhere, but manually alligned the
pointer triangles so they are placed exactly the same distance from
the corner as in the three other corners.

Note I did not tested this (yet) in RTL scenarios.

Bug: T215194
Change-Id: If0ca63d4d4b6e8083c7de1517fe32f49671a40e6
2019-02-13 13:48:51 +01:00
Stephen Niedzielski e2cce6883a Hygiene: improve jQuery JSDoc type checking
Add jQuery types. The JSDocs use TypeScript-compatible typing but tools
such as Visual Studio Code and WebStorm requires the definitions be
supplied. Popups will require these definitions to enable any future
automated type checking too.

Change-Id: I27b5cb052c5ad353322181b0f0ffa4fa56ac1d9f
2019-02-11 15:02:10 -07:00
Ed Sanders e1c4e94b23 build: Update eslint-config-wikimedia to 0.10.0
Also enable jquery ruleset.

Change-Id: Ie1f43d0335ea2aad1e2dd5d86b775316105c3d90
2019-01-31 11:05:33 +01:00
Stephen Niedzielski 6859d6f828 Hygiene: rename NPM test:node to test:unit
Rename the NPM test:node script to test:unit for consistency with
MobileFrontend.

Change-Id: I7329592ab5b375d816cd36a28a04cbe1d8f044a5
2019-01-24 08:29:27 -07:00
Thiemo Kreuz 671c39ef4a Add reference preview type
This adds support for preview popups on reference/footnotes from
the Cite extension. For that a new preview type was introduced and
integrated into the existing structures.

The essential starting points were this code comes into action are
added behind the feature flag introduced in the previous patches.

Bug: T213415
Change-Id: Ie0ccb03117bd654373d0f458b62cc52018361c67
2019-01-23 12:12:36 +01:00