Commit graph

65 commits

Author SHA1 Message Date
Piotr Miazga 211f1d1658 Disable Page Previews preferences when NavPopups are enabled
Changes:
 - introduced PopupsGadgetsIntegration class handles all checks
 - show help message on Preferences page when NavPopups is enabled
 - unit test everything

Bug: T151058
Change-Id: Ia474b1b30378efe84dedf3ad47c1f833e88d69b5
2017-01-11 01:06:48 +01:00
Piotr Miazga 05eccb31c1 Hygiene: use UserGetDefaultOptions instead of ExtensionRegistration
Changes:
 - removed onExtensionRegistration and related TODOs
 - introduced onUserGetDefaultOptions hook

Change-Id: I6648802c19d90df36a211d6494033aca30c078ca
2017-01-10 18:34:43 +01:00
Piotr Miazga c3cfcbe0e0 Inject preference option directly after skin select
Per #Design's mocks, the "Reading preferences" section should appear
immediately beneath the Skin section, if it's present.

Changes:
 - onGetPreferences will try to inject PagePreviews option after
skin section or on the end of section when skin select is not available
 - unit tests for new behaviour

Bug: T146889
Change-Id: Id14c0774aee917b7e949ab3ba5968a038b3ca933
2016-12-21 16:53:33 +00:00
Piotr Miazga c587a9785b Hygiene: Improve code quality by reaching 100% coverage
Changes:
 - added missing unit tests
 - introduced PopupsContextTestWrapper, removed all unit-tests logic
   from Hooks/Context classes
 - removed getModule() from Popups.hooks.php, it's hooks responsibility
   to keep single context instance
 - removed class_exists calls, use ExtensionRegistry instead
 - pass ExtensionRegistry as a dependency so it's easy to mock
 - reach 100% code coverage
 - introduce PoupsContext::isBetaOn() as it was used in many places

Change-Id: Id014efe72edf24628539c76968e53eb3e06709f4
2016-12-21 16:03:33 +01:00
Piotr Miazga 959bf40d9b Implement necessary wiring for preferences
Changes:
 - introduce unit tests
 - don't send module for anonymous users
 - renamed Module to Context
 - remove Config dependency from Popups.hooks.php

Bug: T146889
Change-Id: I3cbcdc1303411b28b613afa6dd1a00b410891471
2016-12-20 16:54:33 +01:00
Sam Smith 6bd082920f Hygiene: Remove experiment-related code
Changes:
* Remove $wgPopupsExperiment and $wgPopupsExperimentConfig config
  variables.
* Remove $wgPopupsExperimentIsBetaFeatureEnabled client-side config
  variable.
* Remove MakeGlobalVariablesScript hook handler as it's redundant.

Bug: T152687
Change-Id: Id25cd7c16da14b7ce9bad502565de9ff6d29434e
2016-12-16 10:59:47 +00:00
Piotr Miazga f597e341af Introduce Opt-In option on user preferences page
This changes introduces new option on Special:Preferences page that
allows users to enable/disable Page Previews feature.
By default feature is disabled. Temporarily option in Preferences
page is smoke and mirrors as switching logic is still WIP.

Bug: T146889
Change-Id: Ifdd17ce265d2d4c7583433ed4991443c563f1fe3
2016-12-16 01:06:59 +01:00
Sam Smith 71b97cd089 Hygiene: Organise change listeners
Move all of the change listeners into
resources/ext.popups/changeListeners and remove the ChangeListener
suffix. Also, do the above for the associated tests.

Bug: T152225
Change-Id: I90ada465ea291d601f8f1c5c6e775148a2100319
2016-12-12 13:06:07 +00:00
Sam Smith 1ea31cc003 Hygiene: Extract shared stub user object
Changes:
* Extract the various shapes of stub user object into the shared
  mw.popups.tests.stubs#createStubUser factory method.
* Register the ext.popups.tests.stubs module in
  PopupsHooks#onResourceLoaderTestModules and make the test suite depend
  on it.

Bug: T152225
Change-Id: I893b11461d8484bcaabfd950c2fa0dc672454a9d
2016-12-12 13:01:44 +00:00
Sam Smith 722bfe12a5 Add gateway
Supporting changes:
* Automatically register JavaScript files in the
  tests/qunit/ext.popups/ directory.

Additional changes:
* Fix a grammatical error in the docblock for
  mw.popups.createExperiment.

Change-Id: Ieb00709e353f0b960375fdaa0ca0dcdf950f2eb9
2016-11-11 18:59:44 +00:00
Sam Smith 9611d3b2db Add LINK_DWELL and LINK_ABANDON actions
Supporting changes:
* Add mw.popups.processLinks.
* Extract the existing unit tests for mw.popups.selectPopupElements and
  mw.popups.getTitle.
* Fix Grunt QUnit timeout.

Change-Id: I325bcb15abc6e0b745d78b7308a346a034ab2988
2016-11-10 11:47:55 +00:00
Sam Smith 16adb1d738 Remove optional survey link
Change-Id: If545873bb97b1da8ea5001dce575b1ef512903fb
2016-11-09 14:41:03 +00:00
Sam Smith 19349c0108 Add BOOT action
Changes:
* Make grunt:qunit run all QUnit tests in those modules whose names
  being with "ext.popups".
* Add ext.popups/index.js, which initialises the mw.popups namespace.
* Add ext.popups/userSettings.js, which contains the code that deals
  with interacting with the User Agent's storage.
* Add ext.popups/experiment.js, which contains the code that that
  decides whether or not the user is in the experiment condition.
* Add tests for both units, converting existing tests where appropriate.
* Remove the associated code from ext.popups.core/ext.popups.core.js.
* Finally, dispatch the BOOT action against the store in
  ext.popups/boot.js.

Change-Id: I697207677304bd49c7cfe1d37bb0a4af7810f387
2016-11-09 10:40:59 +00:00
Sam Smith 3bf0f8ab8b Remove ResourceLoaderRegisterModules hook handler
We should endeavour to define Resource Loader modules in one place,
extension.json. Adding them to the output, however...

Changes:
* Remove ResourceLoaderRegisterModules hook handler.
* Move all dependencies, messages, templates, and styles into "empty" RL
  module definitions in extension.json so that they don't have to be
  looked up later.

Change-Id: I7ec963e3296de8f411e90079ab13b97c6eba4916
2016-11-08 14:14:16 -05:00
jhobs 046d12f51b Update linting and enable command line QUnit
You can use `grunt watch` now!

Changes:
 * Re-enable QUnit (but ignore legacy tests)
 * Add a sample QUnit test
 * Add ability to run QUnit via `grunt watch` or `grunt test`
 * Move linting to `grunt lint` task
 * Add Redux to globals in linter

Change-Id: Ie4a65a8a66773d6472b3d73257267d18027ff3c3
2016-11-08 13:56:17 -05:00
Sam Smith 89975c4942 Remove mobile support
Note well that mobile support is a consideration in the refactoring
effort (see T149801).

Change-Id: I82adc1550b66d0a456aa299ad6c8d2d097fbb7ae
2016-11-08 09:32:04 +00:00
Sam Smith f64c6ea509 Disable QUnit and acceptance tests
Change-Id: Icee115520ec559f8e107de2946224ac1fe65154d
2016-11-08 09:31:51 +00:00
jdlrobson 7dfad14da1 Directory structure should reflect the ResourceLoader definitions
Given we currently have modules defined in extension.json and in hooks
it can be really confusing understanding how the code fits together.

This change hopefully makes this a little clearer by using folder names
that are named after the resource loader modules - this is also consistent
with how we do things in our other extensions.

A images folder is added to the route so that it is clearer that the images
are not used in ResourceLoader module definitions and are only used to illustrate
the beta feature.

Change-Id: Ia650ec03e3a6d3069165441ddfa069d390be4d10
2016-10-19 20:52:40 +00:00
Sam Smith 0b2961c318 Merge mw.popups.experiment into mw.popups.core
ext.popups.experiment depends on .core as it initialized the mw.popups
namespace and .core depends on .experiments for
mw.popups#getEnabledState.

By merging the experiment module into core, we can eliminate any
circular dependencies.

Changes:
* Move ext.popups.experiment.js code into ext.popups.core.js
* Remove mw.popups.experiment module and any references to it

Note: ext.popups.experiment.test.js was left in its own file for cleaner
QUnit module setups and easier removal later. I'm not entirely happy
with doing it this way, but I'm not sure changing the mw.config within
the mw.popups.core QUnit module is worth merging the files.

Bug: T146035
Change-Id: I1f024567010acaa61c1d613c6e59c998198a5976
2016-09-21 16:43:49 -04:00
Volker E 0282b9648f Hovercards: Improve layout of settings dialog to design spec
Improving Hovercards' settings dialog to fulfill design specification.
Also fixing HTML structure by removing invalid `radiogroup` element and
adding missing `</div>` element, fixing related QUnit test.

Changes:
 * Add close icon instead of using text
 * Style header as a table for alignment
 * Remove redundant "OK" button and have it replace "Save" instead
 * Update text of "OK" button to "Done"
 * Fix description for translation of "Done" button
 * Fix qunit and selenium tests
 * Remove unnecessary markup and less
 * Add mediawiki-ui-button and mediawiki-ui-icon dependencies
 * Shrink dialog width some per design spec
 * Fix dialog horizontal position calculation to remove hard-coded value

Bug: T138612
Change-Id: I7395e3438836149becdd576942bdaf6f21b4163f
2016-08-10 14:01:36 -04:00
jdlrobson c1cb976ba2 Tweaks to settings page
* Change labels in English for settings options
* Update description for enable option
* Remove description for disable option

Bug: T138233
Change-Id: Id23dcc7b7e655f7939bb2e455b8680ed5a2c6331
2016-07-07 10:02:08 -07:00
jdlrobson feb0c76381 Render settings via template
This improves readability and separates the HTML from the
JavaScript

Change-Id: Ib765d78890b9aeb05940df00160790b01751a36b
2016-05-30 10:49:17 -07:00
Baha 017cb24d4a Disable Popups when the Navigation Popups gadget is enabled
Bug: T135628
Change-Id: I788932d169d6940e8f9d5112f973b24c76fa856b
2016-05-27 09:16:54 -04:00
Baha aba43fd560 Switch to Schema:Popups revid 15597282
Bug: T131315
Change-Id: I2ed18e00afb3e355327b417e68e5930b46d49086
2016-05-24 14:26:46 -07:00
Sam Smith 41dc6d396a Conditionally enable Popups
Changes:
* Disable the desktop target by default
* If the user is in the experiment condition, then enable the desktop
  target
* Add PopupsExperiment config var, which, if set to true, causes: the
  experiment config to be added to the output as config vars, as well as
  the ext.popups.desktop Resource Loader module

Bug: T132604
Change-Id: Ia71ca924c3e2ec2ee0b0191ea2573fa7ff5e8a7e
2016-05-19 23:47:02 +00:00
jenkins-bot 31430aefd8 Merge "Add ext.popups.experiment module" 2016-05-18 19:06:29 +00:00
Jdlrobson eff7dc95e6 Revert "Add properties that will be logged with each EL request"
Breaks EventLogging as the old schema is not compatible with these
new properties. We will reapply the patch later when in a better state.
My bad for merging.

This reverts commit ca20031a0e.

Change-Id: Ia961e0f99339f9045af9d0a4653599a48518cc95
2016-05-18 18:47:16 +00:00
Sam Smith 3f03d681c9 Add ext.popups.experiment module
Changes:
* Add the ext.popups.experiment module
* Add the mw.popups.experiment.isUserInCondition function, which
  returns a promise that resolves with true if the user is in the
  experimental condition, otherwise false
* If the experiment isn't configured, i.e. wgPopupsExperimentConfig is
  null or undefined, then the user isn't entered into the experiment,
  providing a kill switch

Bug: T132604
Change-Id: I49597494273e3862711a32e4951c8598e6c8bf59
2016-05-18 17:28:46 +01:00
jenkins-bot 85b27d8de8 Merge "Do not directly manipulate the cached object" 2016-05-18 09:28:41 +00:00
Baha ca20031a0e Add properties that will be logged with each EL request
Bug: T131315
Change-Id: I16f5f8170174200bb20c6bcc2835efd136d752ff
2016-05-16 16:39:07 -07:00
Baha cda1ffe425 Use mw.eventLog.Schema to log EventLogging events
This change is an intermediate step in our transition
to logging a variety of events easily.

Also:
  * Some events may need sendBeacon support and may not be
    logged if the navigator does not support sendBeacon.
  * Do not load schema code if EventLogging is not available.

Bug: T131315
Change-Id: Iff939577f65f1c6c71701dd6967939445385fb70
2016-05-16 17:29:48 -04:00
jdlrobson 7f3be6dcd4 Do not directly manipulate the cached object
Popups currently makes use of a render cache. Using a cache in this
way without protection causes problems (I will look at cleaning this up)

The hack below it
`mw.popups.$popup.html( mw.popups.$popup.html() );`
will lead to the html of the cached object being wiped out on IE9 meaning
future loads will show an empty popup.

Add a unit test (which previously would fail in IE9) to protect against this
in future.

Bug: T68496
Change-Id: Icef784fb389b0ab1856e2ba7464c9423ebcd62ab
2016-05-12 16:56:19 -07:00
jdlrobson 27d811a173 Rewrite createPopup with template for better readability
Change-Id: If646623ba4ebf5dfac2a94c73b6f053131739767
2016-05-12 16:19:13 -07:00
Baha 72dd872781 Add QUnit test for ext.popups.settings
Test pieces that make sense, everything else is already
covered in cucumber tests. See the following commit for more
info: I55f311b6b8845e6ebf4cc5698758afd1f9042a45.

Bug: T133025
Change-Id: I474c1569494601ae5865dcfba22ea728220ff8df
2016-04-28 16:13:20 -04:00
Baha 06b49dc6b8 Add QUnit tests for ext.popups.logger
Bug: T133024
Depends-On: Icb1e6ddc8f95da5e4b4de2916d292694c11ba731
Change-Id: I73fee2e3351de357f8f60bf6287a876e245117df
2016-04-20 18:33:53 +00:00
Florian c93047666e Add link preview feature to mobile beta mode
Linkpreview will try to fetch a text extract using the api and, if this
doesn't fail, show the extract as a drawer with a button "Continue to
article". If the query fails, it will redirect the user to the article
directly.

Bug: T113243
Depends-On: I6d8c5b80e70c3d8d1a92a70cc91e1b90d598cb0f
Change-Id: Idbaae9fe2decd89b73e623a25fbd39464c316fb2
2016-03-05 18:22:30 +01:00
Florian bbe958bb5d Prepare Popups for adding of mobile specific Popups implementation
For the work on T113243, the Popups extension should be structured in a
more flexible way. This is achieved with this change.

Following has changed:
 * The main/core logic of Popups now lives in ext.popups.core to be shareable
   between implementations
 * The desktop specific logic lives in ext.popups.desktop now, the frontend init
   code in ext.popups.desktopTarget and the desktop renderer in
   ext.popups.renderer.desktopRenderer

This change doesn't change the functionality of Popups.

Change-Id: I72121e0a1e4b2952f85dc1bc8cf59d06b8d22f47
2016-01-30 23:09:55 +01:00
Kunal Mehta 131563a68c Move EventLogging schema registration into extension.json
Change-Id: I9dea6584d5e811d761542f207a5f63357479d644
Depends-On: I01aa2887a9b98c2ef52cacc3a892390a72b4a3ba
2015-12-22 16:50:39 -08:00
Kunal Mehta 1dc7725389 Use ExtensionRegistry to determine whether TextExtracts is installed
Bug: T121777
Change-Id: Ic017615993b7d1ba746424ce6b576b71ba72b25f
2015-12-19 22:59:31 +00:00
Brion Vibber d90c492275 Hi-DPI/Retina support for hovercard images
Requires core changeset Ic9cb1654 for $.bracketedDevicePixelRatio()

Bug: T97935
Change-Id: I452b87a90769463328840c6c7e46b583e6148439
2015-09-09 15:40:33 +02:00
Prateek Saxena 947f644991 Move all images to resources/images
Change-Id: Iac712668baf8cefedf036c4d479687e3f5da5a46
2015-07-18 22:27:18 +00:00
Fomafix 7713e343fe Replace 'jquery.mwExtension' by 'mediawiki.RegExp'
Replace $.escapeRE from 'jquery.mwExtension' by
mw.RegExp.escape from 'mediawiki.RegExp'.

Bug: T103610
Change-Id: I1d23e4c02d92828291b98a52b4e8050fbebc06d9
2015-06-26 07:48:18 +00:00
Andrew Garrett c7e057946d Act as a beta feature if so configured
Add a configuration key, 'PopupsBetaFeature'. If true, Popups will act as a
beta-feature, and will depend on the BetaFeatures extension. Set to false by
default.

Bug: T88917
Bug: T88164
Change-Id: Ie4cc455fa6379dbc8ef700e4773bedfb49fcf813
2015-04-16 18:06:46 -07:00
jenkins-bot a5d4bec8fd Merge "Use href attribute to calculate titles" 2015-04-07 10:04:55 +00:00
wctaiwan 642bdf013e Use href attribute to calculate titles
This is needed for wikis that use LanguageConverter, since the title
attribute is converted to the user's variant, and the canonical title is
needed for the API unless converttitles is specified.

For filtering, instead of comparing linkHref and expectedHref, filter
out links that have other query parameters or aren't in content
namespaces.

Bug: T93605
Change-Id: I5534753307ed5e1d4b27c52c616fd143b2a397e1
2015-04-06 05:55:25 -04:00
jenkins-bot 0ff656a892 Merge "Implement the new schema for when the popups are enabled" 2015-04-06 09:18:16 +00:00
jenkins-bot 7fe8f5d45f Merge "Add icon and link to qualtric survey if $wgPopupsSurveyLink is defined" 2015-04-06 09:03:26 +00:00
Prateek Saxena 8fbacb9040 Add icon and link to qualtric survey if $wgPopupsSurveyLink is defined
The link to the survey is added in Ic445732197e6abeba459b40b1416d8a71bc23bd6

Bug: T1005
Change-Id: I24bfd5fd622d1afc4372dbd4bfca3879927b0c17
2015-04-02 15:29:15 +05:30
Prateek Saxena 2971d90831 Implement the new schema for when the popups are enabled
Bug: T88167
Change-Id: I38c9e474e0ec7da45af8338a458430e5d7427463
2015-03-26 11:42:39 +05:30
Prateek Saxena d49cfb9b65 Rename popups.eventLogging to popups.logger
...and eventLogging.logEvent to logger.log

Change-Id: I9af697a56c2248069a32ac586f5b78b55095460e
2015-03-26 04:56:29 +05:30