Action changes:
* Add the PREVIEW_SHOW action.
Reducer changes:
* Increment the user's preview count in the eventLogging reducer.
Changes:
* Dispatch the PREVIEW_SHOW action when the preview has been shown.
* Add the previewCount change listener, which is responsible for
persisting the user's preview count to storage when it changes.
* Call the change listener factories individually in
#registerChangeListeners as their signatures aren't consistent.
Bug: T152225
Change-Id: Ifb493c5bff66712a25614ebb905251e43375420a
Action changes:
* Include the user's preview count in the user property of the action.
Reducer changes:
* Make the eventLogging reducer add the bucketed user's preview count to
the state tree.
Changes:
* Extract mw.popups.UserSettings#getPreviewCount and #setPreviewCount
and associated tests from the ext.popups.core module.
Bug: T152225
Change-Id: I6b7afef31311be8fede685deb536f577845cb9cf
Action changes:
* Group user-related data in the user property, rather than repeating
"isUser" and "user" prefixes.
* Include user's edit count in the user property of the action.
Reducer changes:
* Make the preview reducer handle the action's new shape.
* Make the eventLogging reducer add the bucketed user's edit count to
the state tree.
Bug: T152225
Change-Id: I8fae9e2d0f6889ffdd30bb5192513d194f791967
Action changes:
* Include whether the user is logged in/out and information about the
current page in the BOOT action.
* Add the EVENT_LOGGED action, which represents the eventLoggined change
listener logging the queued event.
Reducer changes:
* Move all tokens and timing information from the preview reducer to the
eventLogging reducer.
* Make the eventLogging reducer reset the state.
Changes:
* Add the mw.popups.createSchema function, which constructs an instance
of the mw.eventLog.Schema object that can be used to log Popups
events.
* Add the eventLogging change listener, which logs the queued event.
* Add hand-crafted, artisanal documentation.
Bug: T152225
Change-Id: I8a3f58358b211cc55417dcda7e796fe538e3d910
This reverts commit 047bccfac1.
It created merge conflicts with a bunch of patches that were days old and about to be merged. Instead of rebasing 10 patches, let's revert this one, finish merging the other ones and just rebase and fix this one. I'll re-introduce the patch in a bit.
Change-Id: Ib495755b0ab4bfa5fdf5590b1271792862a47d4b
Since the state was cloned into an empty object with $.extend, undefined
properties were being deleted from it, not actually preserving those
keys. So:
nextState({hi: undefined, ho: 1}, {ho: 2})
//> {ho: 2}
It seems like a more consistent behavior would be to not lose any own
keys on the state as we do with the updates too, so that:
nextState({hi: undefined, ho: 1}, {ho: 2})
//> {hi: undefined, ho: 2}
Which is what this commit does by not using $.extend to clone the state
and instead just manually copy the keys to the new object, even the
undefined ones.
Change-Id: If4f2a3b0d25bb5ef34cfbc1f2c9c0b5479aeee9b
Changes:
* Make the gateway handle missing pages, which are characterised by the
MediaWiki API response having both the missing property set to truthy
and the page not having any revisions.
* Add the preview-empty template and associated "mwe-popups-is-empty"
CSS class, which describe what an empty preview contains and how it
should look.
Supporting changes:
* Move the original preview template into the ext.popups module.
Bug: T151054
Change-Id: Ife75bf9c6bafdfe0a6cc3e20eea853b4ac8f951b
The preview reducer would treat the LINK_ABANDON_END and
PREVIEW_ABANDON_END actions as the PREVIEW_DWELL action. Fortunately,
this was a NOOP as they would only fall through if the preview was being
dwelled upon.
HT Joaquin Hernandez.
Change-Id: I01ff47de34ac41f1e6aa46aa5baccc2a27013f1b
Per T150814#2833030.
Changes:
* Round the preview's border.
* Adjust the shadow cast by the preview.
* Make both fade-in and -out animations last 200 ms.
Bug: T150814
Change-Id: I55c728680ebb208e7cd1bd4c99a8453ae9915f2e
It would seem that nextState should be $.extend({}, state, updates), but
as it was noted in the commit message that introduced the function
$.extend doesn't copy undefined|null values and that's why we iterate
manually over updates to copy any prop that exists over. That way we can
override properties to null|undefined in the state.
This commit expands the comment to explain so, and why OO.copy couldn't
be used.
Change-Id: If6c7119a4713328bb23c8f77042500510d515049
Instead of defaulting the config to the global mw.config when the param
is not defined, always pass it in (it is called just once in application
code), that way there's no need to test for the optional argument
behavior and the function is pure.
Change-Id: Ib1addb3060826f58dce2d6f928252ce1888a4293
Given this UI elements are going to change this comment would get
outdated really soon. Instead refer to generic interaction.
Change-Id: Icf56a864c47847bdef23985e9afd702ccb0de3b7
I59ac2e32 removed support for non-SVG capable UAs but didn't remove all
of the associated styles.
Additional changes:
* Give the inner container a name, "mwe-popups-container", so that it
can be styled with reduced specificity.
Supporting changes:
* Move the "core" styles into the ext.popups module.
Bug: T151054
Change-Id: I8deb6e76daf6f33fcb6f496129e6baf9e6793231
I14b437e7 introduced a regression where neither the preview's thumbnail
nor extract linked to the page.
Change-Id: I51793640d882aec711af8683ffbea794fad1b047
Action creator changes:
* Make the linkAbandon action creator asynchronous by splitting it into
two distinct actions, LINK_ABANDON_START and _END, the latter of which
is dispatched after a 300 ms delay.
* Introduce the previewDwell and previewAbandon action creators. The
latter is an asynchronous action that mirrors the linkAbandon action.
Reducer changes:
* Make the LINK_DWELL, LINK_ABANDON_END, and PREVIEW_ABANDON_END action
hide a preview, if one has been shown.
* Make the LINK_ABANDON_END action NOOP if:
* The user has interacted with another link, or
* The user is interacting with the preview.
Supporting changes:
* Update the mw.popups.reducers#preview and #renderer unit tests to use
an empty previous state so that the tests are more resilient to
modifications of the state tree.
Change-Id: I2ecf575bbb59bb64772f75da9b5a29c071b46a8d
I14b437e7 introduced a regression where the `moment`ed last modified
timestamp wasn't rendered.
Additional changes:
* Remove the HTML comments from the preview template.
Change-Id: I78047dd0f8acc6292e0592887e128e6046119212
If the user abandons the link after the API request delay (500 ms) but
before the it resolves (~10e3 ms), then the preview shouldn't be
rendered.
Changes:
* actions: Include the link in the FETCH_START, FETCH_FAILED, and
FETCH_END actions.
* reducers: If the active link has changed, then FETCH_END is a NOOP.
Supporting changes:
* reducers: Signal that a preview should be rendered and shown with
preview.shouldShow.
Change-Id: I3dd1c0c566ec63de515174c14845d7927583ce93
The QUnit test suite now completes in ~10e2 ms rather than ~10e3 ms.
Changes:
* Make mw.popups.actions#linkDwell to use mw.popups.wait.
* Make the tests for mw.popups.actions#linkDwell complete faster, but
still asynchronously, by stubbing mw.popups.wait.
Change-Id: I5cbef0ea69bc860f75cac27c1adea3d419c1ffad
Changes:
* Reduce the fade-in animation delay to 200 ms.
* Truncate a long extract by fading it out gradually.
* Increase the depth of the shadow cast by a preview and remove its
border.
Bug: T150814
Change-Id: I2ec0c0472bc24767bbf1f4db000cc9d690454629
Extract core rendering functionality from the mw.popups.renderer and
mw.popups.renderer.article objects.
For now, render and show the preview when the user dwells on and
abandons a link respectively.
Supporting changes:
* Add mw.popups.wait, which is sugar around window.setTimeout.
* action.response -> action.result in the FETCH_END case of the preview
reducer.
Change-Id: I14b437e7c2f55b988837fcb2800dd61a23c29a01
Supporting changes:
* Remove the preview.previousActiveLink property from the state tree as
it's unnecessary.
Change-Id: I657decf9425a7a9e2b27a798ed60b162569661d8
OO.copy doesn't copy Element instances, whereas $.extend does. However,
OO.copy does copy properties whose values are undefined or null, whereas
$.extend doesn't.
Since the state tree contains an Element instance - the
preview.activeLink property - we need to use $.extend.
Add the nextState helper function which copies the current state tree
with $.extend and mixes in all updates manually.
Change-Id: Ie8edd9fa0cc3a62a792ed60b49288f85b3ca73e9
If the user has abandoned the link or dwelled on a different link, then
don't make the API request.
Changes:
* Fix a bug in the linkDwell reducer where the activeLink was always
being set to undefined.
* Add the private fetch action creator.
* Make the linkDwell action dispatch the result of the fetch action
creator after 500ms.
Supporting changes:
* Make the link* action creators take DOM elements rather than jQuery
instances so that:
1. Testing whether the state tree has changed is an identity
comparison.
2. jQuery instances are constructed only when required.
* Document the ext.popups.Gateway type.
* Document the Redux.Store type.
* Rename the "previews-page-title" data attribute to
"page-previews-title" to avoid confusion.
Change-Id: I0b1cf3337a6f8d6450ad2bd127cb292ebb73af4f
Supporting changes:
* Add mw.popups.registerChangeListener, which registers a change
listener that will only be called when the state in the store has
changed.
Change-Id: Ibe6934058327c7f02f7d8092e74a667a5a1c600a
Changes:
* Add sessionToken and pageToken properties to the BOOT action and
update the preview reducer.
Supporting changes:
* Move the mw.popups.createActions to ext.popups/boot.js so that Redux
is used in one file and the actions can be tested in isolation more
easily.
Change-Id: Icd61bf1aeb466899e047432bf9798e2574652830
Reducers as a whole are a WIP, but this implements a baseline from which
to add more.
Changes:
* Create ext.popups.reducers to house all reducers
* Create reducers for preview and renderer state manipulation
* Create rootReducer by combining preview and renderer reducers
* Add QUnit tests for reducers
* Move action types into ext.popups.actionTypes
* Extract rootReducer from boot.js
Change-Id: I8a2296c6846cd4b0552a485e671af1d974944195
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
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
Also, fix a bug introduced in Ib7168217 wherein the non-existent
Redux.thunk was referenced rather than ReduxThunk.default.
Change-Id: Ia4cc28b16b17442de69ed84bb8e8c88a6a9f201d
Changes:
* Create the ext.popups.lib module, which contains redux@3.6.0 and
redux-thunk@2.1.0.
* Rely on the Resource Loader's minification and mangling (?)
mechanisms.
* Create an asynchronous bootstrap script, which creates a Redux store
when the User Agent is idle.
Change-Id: Ib7168217a5673bb2a8378eb30d6aa45043c66e62