Commit graph

59 commits

Author SHA1 Message Date
WMDE-Fisch c52c657516 Introduce alternate SliderView
Adding a new class for an alternative slider view with
one slider for each pointer. The new class will be used
when the extension is installed as a beta feature.

Each pointer has now its own pointer container visualized
with a thin line. Pointers can not change places anymore
and methods doing so where overwritten in the patch.

Selected revisions are not colored atm to better distinguish
between pointers and bars. Poiner lines are now shown above
the bars. ( as from feedback in the last PM session )

Some issues with the design might remain. But since we plan
the deployment anyway next week this could be merged if reviewed. 

Bug: T160410
Change-Id: If00c31e30f8a01f3525b191c70605b9c9381671d
2017-04-06 07:29:19 +00:00
WMDE-Fisch fbac5c69a4 Refactor usage of OOjs UI tooltips
This patch changes the way OOjs UI tooltips are constructed.
Until now we did not use the full potential of the widget.

Some strange behaviour remains and it seems we can not use
'horizontalPosition' here. Therefore the direction is passed
down to the RevisionsListView to center the tooltip manually
and margins are set for the help and arrow tooltips.

Bug: T159428
Change-Id: I0a67340da4d94f2f6b29e507f94fc695b44b71f9
2017-03-03 14:31:07 +00:00
Andrew-WMDE 37ea49b326 All connector-lines should be contained within the RevisionSlider
Bug: T151450
Change-Id: I317a2fc81a85d20cf07b1e45d5501cadaaa0b727
2017-01-13 12:18:22 +01:00
addshore 2cf768f7b7 Lazy load most of the JS
With the parent of this commit (current master)
Loading the RevisionSlider JS without it expanded increases
the request size by roughly 767KB on first request and 242KB
on subsequent requests.
The large size of the first request is mainly down the to
dependancies of the slider.

This lazy loading patch means the RevisionSlider JS
only causes an increase of 184 KB per request.

If the user has the bar expand by default the main JS will
be loaded straight away (and the lazy JS will not be).

This patch also means that when only the bar is loaded the
pin button to set auto expand will not be shown.
This will be added once the RevsionSlider is loaded.

Bug: T151668
Change-Id: I054a82e9ea2aa89326464632e744497239f7adba
2016-11-30 11:59:16 +01:00
addshore 17caad54ca Use mw.Map#get instead of mw.Map#values
Change-Id: Ifbc7f3e40190f678d6d9dad41fc161334b9b12c2
2016-11-23 00:31:53 +00:00
Ed Sanders 1c3ef546ad eslint: Remove old jshint/jscs refs, fix exceptions
Change-Id: I56b9f037405d0f93f82dc81dad1cc1b111be338e
2016-11-19 13:37:20 +00:00
addshore ccc6905a05 Fix / Change autoexpand metric name
.'s in a metric name can essentially be thought of
as directories.

When building graphs from this data an * can be used to
match everything in a directory, for example:
MediaWiki.RevisionSlider.event.*

As these 2 events held another . in their name they
would ont be matched by the abov wild card, so instead use
a _ so that they will!

Change-Id: I1dce9253eb9d4ccb99516683897564e14bb9a577
2016-11-17 11:02:26 +00:00
addshore fc213c8880 Flip toggle button in 2 missing cases
- The first case is when the slider is collapsed and the auto
   expand is switched on, the slider expands and now the toggle
   switches.
 - The second case is when the slider is loaded expanded, the toggle
   now loads in the correct direction

Bug: T150846
Change-Id: I75610308c9f169fb926953a12dc5108e0fba23bf
2016-11-17 10:59:40 +00:00
WMDE-Fisch f17850d6e6 Clean up logging in code
Change-Id: Iad9f6846f9a80e7c6e82d930f643a92c8f42cab6
2016-11-16 15:42:04 +01:00
James D. Forrester 3269f791f5 build: Bump eslint-config-wikimedia to v0.3.0 and make pass
Change-Id: I774e05c4393eca8b4719f335a124efcb3d2a6dd5
2016-11-15 16:48:38 -08:00
WMDE-Fisch df9d94ca60 Draw lines between pointers and related columns
Introducing a new class that draws lines between the pointers
and the related diff columns. Lines are redrawn when pointers
were moved. A colored border is added to the diff columns and
readded when the diff changes.

Bug: T149175
Change-Id: Iadf779368c58da7779c769bda8e9bd3fc5afcffa
2016-11-08 13:46:14 +01:00
WMDE-Fisch 300c552334 Store settings for anonymous users
Introducing the Settings class handling settings for all users.
Use hidden user prefs for logged-in users and localStorage or
cookies for anonymous users.

Bug: T145494
Change-Id: I8676873c87d5656c55365706f1ccefa604caae4d
2016-10-24 16:46:42 +02:00
Ed Sanders 79c0305b09 Throttle the window resize event handler
Drag-resizing a window results in hundreds of events being fired,
so limit this to one event every 250ms.

Change-Id: Ie3ace9001cd840a5d790cd269c4ae3c77649079a
2016-10-14 08:25:35 +00:00
jenkins-bot a79bccf2ea Merge "Close HelpDialouge when clicking away from it" 2016-09-15 10:14:33 +00:00
addshore 22556fcf16 Close HelpDialouge when clicking away from it
Bug: T145525
Change-Id: Ia21d5163f561ede4f327eec3a4aaf7c34d103094
2016-09-15 12:01:08 +02:00
Tobi Gritschacher a3244e1805 Expand Revision Slider when user activates pin button
Bug: T145068
Change-Id: I26bd6d3cbd2e0da6e3d537431a45ef8193906c40
2016-09-13 16:05:01 +02:00
addshore c8cd4c5fb4 Only show pin button to logged in users
When the extension is used without the BetaFeatures
extension it is possible to use while not logged in.

Anon users can not have a user preference set.
Thus anon users should not be shown the pin icon.

It may be an idea to add a cookie for anon users
later down the line.

Change-Id: Iafeacf6ae9e24b3134f1c180d390cfad4245719a
2016-09-12 12:45:35 +02:00
Leszek Manicki 8e7fe2434d Add eslint, to be used instead of jscs and/or jshint
First I jumped on replacing both jscs and jshint with eslint but
it might be premature decision. Although linting with eslint
is possible (like in there is wikimedia config for eslint)
it is still not clear should it

But in case the change happens we will be ready.

Apart from config stuff this changes few bits spotted by eslint:
improves some indentation, removes weird spaces, completes some
doc blocks, changes IIFE forms in tests. These changes do not
seem controversial.

Change-Id: I9f8bf0f5745da8e662685f4cd879ea4baa609c01
2016-09-05 09:47:11 +02:00
Leszek Manicki 6502728184 Add button to have revision slider expanded automatically
This adds a button which allows a user to make revision slider
automatically expand on each diff page (disabled by default).
User's choice is stored as a hidden user preference.

This is a bit hacky as it squeezes a button on top
of another button (100% wide expand/collapse button).
This also adjusts styles of ToggleButtonWidget so
the button looks more like a frameless button, although
it is created as a framed one (to have inverted behaviour
when button is in its "on" state).

The button only gets visible when Resource Loader finishes
loading JS and CSS to avoid button jumping around the top
of slider window before "right" styles are applied.

Bug: T142196
Change-Id: Id561485344cba9b136666fe31b086151467de19e
2016-08-30 13:57:12 +02:00
Jakob Warkotsch 4d6233f842 Resize revision slider when resizing the browser window.
Bug: T139101
Change-Id: I57c7d9e553f02c2e8eaa76ee729f85ec4ae2ec3b
2016-08-16 16:08:44 +02:00
Ed Sanders 6997f135db Abort pending requests
Ensure all requests are abortable promises, and abort if
a new, conflicting request is made.

Change-Id: Ie05142f6da8cba6dde4f73c1b22960b726af4764
2016-08-15 11:19:15 -07:00
Ed Sanders f6a44f43fe Convert the few instances of IDs to classes
Makes for more modular code.

Change-Id: Ic71d7421aea548e5b4a9c4841cd4af49a3d385a5
2016-08-10 15:32:12 -07:00
Leszek Manicki e243ca2746 Do not load RevisionSlider initially, add a button to show/hide it
Instead of loading RevisionSlider only add a little button
to expand RevisionSlider on top of the diff page.

This makes RevisionSlider only steal a bit of space over the
diff, and only inserts quite a big slider to users that want
to have it visible for the particular diff.

API calls are only made once RevisionSlider has been expanded.

This is re-submit of b0f229d75f
that was reverted in I26427faaa00b38c2aa1377a66224c9062dcca302.

Bug: T141871
Change-Id: I879de5774b2cce7b908e73cbbe869fd48d6afa23
2016-08-10 16:26:54 +02:00
WMDE-Fisch c5690ba763 Revert "Do not load RevisionSlider initially, add button to load it"
This reverts commit b0f229d75f.

Change-Id: I26427faaa00b38c2aa1377a66224c9062dcca302
2016-08-09 16:34:53 +00:00
Leszek Manicki b0f229d75f Do not load RevisionSlider initially, add button to load it
Instead of loading RevisionSlider only add a little button
to expand RevisionSlider on top of the diff page.

This makes RevisionSlider only steal a bit of space over the
diff, and only inserts quite a big slider to users that want
to have it visible for the particular diff.

API calls are only made once RevisionSlider has been expanded.

Bug: T141871
Change-Id: Ib312f6225b85b9ebdf4ac5d16e254a57d5cf6411
2016-08-09 14:54:59 +02:00
Leszek Manicki 0af4fe35d5 Make the "show help" button a OOjs ButtonWidget
This also adjusts position of the help icon so it better fits
the available space.

Bug: T139150
Change-Id: Iec7ec31a83a1a847cd68a994ecac12acf960d699
2016-08-08 13:14:31 +00:00
addshore fd61e41db8 Track the load times of RevisionSlider
Change-Id: Ibeaac111802af80d2910c1892d233b7835069148
2016-08-02 13:02:57 +01:00
Leszek Manicki dc838bc87d Fetch more revisions as the user moves back and forward
This changes the previous behaviour of fetching always up to
500 most recent revisions.

Now the extensions fetches N revisions including the newer
revision selected to diff as the most recent revision.
N is number of revisions that would fit in the current
window when rendered as bars.
When user is close to either "end" of the slider, extensions
fetches another batch of up to N older or newer revisions,
as long as user does not reach the oldest or the newest
revision of the page.

Among others, this removes the limitations of the previous
approach: showing only 500 revisions, and failing to show
anything when any of selected revisions was older than
500 recent revisions.

This change also simplifies usage of Api class.

Bug: T135005
Change-Id: Ib3f4a6ac57ff17008f9d8784c4716bd294443096
2016-07-28 12:58:35 +02:00
Leszek Manicki c7190cf97d Add support for GENDER to the username label in the tooltip
After fetching a batch of revision data, user names are extracted
and another API query is made to get gender preferences for users.

This change also moves a code responsible for MediaWiki API calls
to its own class.

Bug: T136367
Change-Id: Id11fe14e9ca37829141ae92b13b51f10f992eb96
2016-07-26 11:50:59 +02:00
Leszek Manicki 8e2365502b Make RevisionList expect list of Revision object
Despite its documentation the "constructor" of RevisionList tends
to expect array of revision data in a format returned by API instead
of array of Revision objects.
Due to different name of ID fields in Revision object and in API array,
if "real" Revision object is passed to RevisionList, its ID is lost.

This changes RevisionList so that it only accepts an array of Revision
objects. This provides better abstraction.

This is basically a revert of I147270f28381038d05f8bcfd2317e8c269b2e458
which aimed at the same problem but suggested solution doesn't seem right.

Change-Id: Ic45cdd3e7b707a8c6a19eecf0a84d4c11696cd1f
2016-07-05 00:01:46 +02:00
Ed Sanders a5f36af0f3 Prefix all classes and IDs with mw-revslider
Bug: T139105
Change-Id: Ia92396ec4f8acea39398173c81842d66257dc519
2016-07-01 11:27:23 +01:00
WMDE-leszek 200f3e1ddd Merge "Start browser tests (Initial test for beta feature switch)" 2016-06-30 14:01:29 +00:00
addshore d7caa6c1f3 Start browser tests (Initial test for beta feature switch)
This adds 1 simple browser test to make sure that the placeholder
for the revision slider loads when the beta feature is enabled and
does not load when it is disabled

More tests will follow.

Bug: T133278
Change-Id: I5be9014b6c5ac03128c034fd866141e89fd7a0ed
2016-06-30 14:46:37 +01:00
Jakob Warkotsch 80aafa27d9 Show a tooltip for the questionmark that opens the help text.
Bug: T138945
Change-Id: I6c3235bdf228d051c7039f188ff62d1137377bca
2016-06-30 15:07:18 +02:00
Leszek Manicki cd12add2cb Make a symbol on the "Show help" button translatable
Change-Id: I60ae368f59203f63fb352ec861db5d75d488f8fa
2016-06-24 15:55:03 +02:00
Jakob Warkotsch 079f5607c9 Add button to reopen the help dialog.
Bug: T137086
Change-Id: Ifef5c8451a53bf43b10418ace8e6651801480bb2
2016-06-17 13:11:38 +02:00
Jakob Warkotsch 5f6b3c8556 Show a help dialog.
- slide show dialog using OOJS UI
 - setting a user option to only show it once
 - translatable content
 - images of the slides

Bug: T136830
Change-Id: Ia820aecb20aa6b239f1a64dd328683639baf399e
2016-06-16 18:05:10 +02:00
Moriel Schottlender 7b75c1ebf2 Use momentjs to display internationalized timestamps
MediaWiki uses the momentJS module to display standard timestamps;
this means you can avoid calculating the user offset, but also, it
means that all timestamps are internationalized and translated, and
use the standard view that MW uses in its interfaces.

We can store the user's offset in a RevisionSlider variable so we can
refer to it in timestamp construction, as well as manipulate it in
tests without touching any global user options that may affect other
tests.

Bug: T136825
Change-Id: I67d9859b8f33ab8a217128822e246e7ab67f6511
2016-06-03 13:20:35 +00:00
WMDE-Fisch 1a8a4312de Move dependencies to extension.json
Also removed unused dependency.

Bug: T135198
Change-Id: I1ee53ec9d7e123bdca84701b9557aeeeade815ff
2016-06-02 18:16:23 +02:00
Brian Wolff 39d8d9229a Make files not executable
I know it doesn't matter, but it was kind of bothering me.

Change-Id: Iae9f8b17a3fb5ced362dc2da95e67e20db8af5a5
2016-06-02 13:48:09 +00:00
Leszek Manicki a2774984c4 Make JavaScript code and CSS follow the style guide.
Changes include:
 - not passing in HTML attributes when creating tag elements,
 - creating HTML elements instead of appending hand-crafted HTML,
 - single append() calls instead of multiple consecutie appends,
 - not using raw HTML messages when not needed,
 - prefixing all CSS classes and IDs with "mw-" to avoid potential
   name conflicts.

Change-Id: I164538bbaf44d46a4c66659f56e07ec7225d7fa9
2016-05-31 14:57:14 +02:00
addshore 91759f25bd Show useful error if either rev is not in our range
Bug: T135119
Change-Id: I48f3316f2285b987d1a7e4c4a622eb1291de6357
2016-05-12 16:44:34 +01:00
addshore f9471bcfbc If the slider fails to load then fail nicely!
If something goes wrong with the initial api rquest the
slider would either load in a broken state or say that
it is loading forever.

Now a message will be displayed to the user as well
as the error logged to the console.

Change-Id: Id763f31432feb7bd0e9ecbbeb2dd40f7ca6acaaf
2016-05-12 09:46:39 +01:00
addshore b1f6a1df56 add events to history
This allows using browser back and forward buttons
once users have started heading between revisions.

This also updates the URL so that the page can be
reloaded at any time and the same state will be held.
(This also removes a commented out block of code that
I think was left for updating the URL)

Change-Id: I4cfe38f76eeb9e090f0a8a42e22e75cf84014d60
2016-05-12 08:36:28 +00:00
addshore 4835195da9 Add basic usage tracking
Change-Id: I4bde95492ef6483cfd4e4f3c29b1ab7eaeccbc10
2016-05-12 08:36:23 +00:00
addshore be036e757c Re add section legend as a module
Change-Id: I6ad89e2b15435ef35cc1ebddde0f92584ffd9ecf
2016-05-10 19:11:59 +01:00
Jakob Warkotsch 980f2ca917 Create Slider module.
* threw out most of the things from init.js
* turned Slider + View into respective modules
* pointers should remember position (except on page load) and correctly
  slide back to their position/to the side

Some things still need testing and refactoring.

Addshore: - CS fixes and comment out current failing tests

Bug: T134395
Change-Id: I78a7095e1d9902314163b1443448f47ef0484d4e
2016-05-10 17:38:46 +01:00
addshore 3eb7e87879 Add data-revid to all slider elements
Change-Id: I1ae5a98d40342cd581dca5a19caaae283472e2da
2016-05-06 14:59:59 +01:00
Jakob Warkotsch 54720944a0 Create Pointer module.
This creates a module for the draggable pointers for the RevisionSlider
mainly to encapsulate both the pointers' state and their HTML code.

Some animation methods such as slideToSide and slideToPosition
that are still flying around in init.js weren't added to the
module since I thought they should be part of the not yet existing
Slider module.

Change-Id: I1292bfb0bbd68f8d2de04b3b5e5f3133ec6363b8
2016-05-06 12:37:01 +00:00
jenkins-bot 8140114a53 Merge "Add localizable placeholder message while loading" 2016-05-04 10:14:01 +00:00