Commit graph

817 commits

Author SHA1 Message Date
madd
3fc8c9a8d5 jquery.tablesorter: Improve detection and handling of isoDate
* Detect years 0...99 correct.
* Short forms possible: JJJJ, JJJJ-MM, JJJJMM, JJJJMMTT
  QUnit Test sorts now with parser 'isoDate' (because of 2009 former test sorts with parser 'text')
* Prefix and postfix allowed.
* Between date and time a 'T' or 'any white space' is allowed (Bug: T126886)

Bug: T126886
Change-Id: I664b4cc9d5fb472ea0bc0e36a3c209f04048e769
2017-08-13 13:40:41 -04:00
WMDE-Fisch
6df9ed1ad6 update mediawiki-codesniffer to 0.11.0 and fix issues
- mostly auto fixes
- some too long lines fixed
- ignore amp space in one case  passing by reference

Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
2017-08-11 22:27:51 +02:00
Max Semenik
fd6e9ef2d4 Human-readable section ID support
It adds the ability to replace the current section ID escaping
schema (.C0.DE) with a HTML5-compliant escaping schema that is
displayed as Unicode in many modern browsers.

See the linked bug for discussion of various options that were
considered before the implementation. A few remarks:
* Because Sanitizer::escapeId() is used in a bunch of places without
  escaping, I'm deprecating it without altering its behavior.
* The bug described in comments for Parser::guessLegacySectionNameFromWikiText()
  is still there in some Edge versions that display mojibake.

Bug: T152540
Change-Id: Id304010a0342efbb7ef2d56c5b8b244f2e4fb2c5
2017-08-01 20:32:20 -07:00
Moriel Schottlender
155d1f91d1 RCFilters: Create a sticky preference for days/limit groups
- Add sticky preference for groups and the operation behind
  it.
- Allow normalization from the UriProcessor
- Backwards-compatibility for saved queries
- Allow saved queries to load regardless of sticky params
  and to be compared correctly without the sticky params.
- Add days/limit preferences and update those on change
- Update the preference even if we received a new value
  from the URL.

Bug: T171514
Bug: T171368
Change-Id: I5232f3372f0e5c981332d152faf0ab47cc470b56
2017-07-28 16:06:30 -07:00
Timo Tijhof
5656c571ee jquery.tablesorter: Make tests QUnit 2 compatible (remove testCount)
Follows-up 6418c54c4, 5e602c6132. Missed these because they didn't
match my search pattern previously (I didn't account for the test
name being a variable instead of a string literal.)

Change-Id: Ieae82acc80719041712c8c18b8ddffe387ebe8cf
2017-07-25 19:02:16 -07:00
Timo Tijhof
2454f51b27 Upgrade QUnit from v1.23.1 to v2.4.0
Source
 https://code.jquery.com/qunit/qunit-2.4.0.js
 https://code.jquery.com/qunit/qunit-2.4.0.css

Changelog
 https://github.com/qunitjs/qunit/blob/2.4.0/History.md

This release makes 'moduleStack' private, which means we can no
longer use it to detect nested modules. Change the method of
detection to be a local 'nested' variable that we toggle in
a wrapped version of any 'executeNow' callback, in which nesting
happens.

Bug: T170515
Change-Id: Ib4ed386990125a6c713cb4351408c8f7ae7c070f
2017-07-25 22:14:09 +00:00
jenkins-bot
be00e4c0bb Merge "RCFilters: Add 'boolean' group" 2017-07-22 00:29:34 +00:00
Moriel Schottlender
dab88cde22 RCFilters: Add 'boolean' group
The group allows filters to be represented 'directly' with their
selected values corresponding to their parameter "1" or "0" value.

Change-Id: I56e9b52ff79a46227de71c905b2ecd97a3823624
2017-07-21 16:09:53 -07:00
Timo Tijhof
43dc5c1539 qunit: Prepare testrunner for QUnit 2
* Nested modules:
  - Support for Sinon extension was fixed by Ib17bbbef45b2bd.
  - Support for Fixture extension was still broken, masked by the use
    of a local variable that made the handler not fail when setup ran twice
    in a row. Fixed using the same moduleStack.length check.
  - Add regression test.

* beforeEach/afterEach:
  - Added in 1.16, with compat for setup/teardown.
    Our wrapper adds its own setup/teardown, and preserves any original one.
    However, it didn't account for beforeEach/afterEach, so it ends up
    sending both but only one is used.
  - Fix to support both on the incoming localEnv object, and also switch
    our wrapper to use beforeEach/afterEach in prep for QUnit 2.0.
  - Fix our wrappers to preserve return value since QUnit 2 allows beforeEach
    and afterEach hooks to be asynchronous by returning a Promise, similar
    to how one can do from QUnit.test().
  - Add regression test.

* Centralise makeSafeEnv logic
  - We always create our own env object to pass to orgModule().
    Document why this is (to avoid recursion).
  - Add regression test.

* Custom assertion methods:
  - Use this.pushResult instead of the deprecated QUnit.push() method.
    This also improves the in-browser reporting of errors by properly
    supporting 'negative' results for notHtmlEqual reporter.

Bug: T170515
Change-Id: If4141df10eae55cbe8a5ca7a26707be1cd7b9217
2017-07-20 20:45:18 +00:00
jenkins-bot
081f44fa7f Merge "RCFilters: Add range group filters - limit, days and hours" 2017-07-19 02:32:21 +00:00
Moriel Schottlender
91b2ebe834 RCFilters: Add range group filters - limit, days and hours
- Add 'hidden' groups that have base defaults but are not
  viewed in the filter drop-down.
- Add a UI for days, hours and limit selections, based on their
  group models.
- Clean up the fieldset form to remove redundant line breaks
  and empty objects.
- Add 'hours' as a subset of days, where the UI can split itself
  by picking up values >=1 and <1
- Add the ability to allow 'arbitrary' information from the URL
  values, but also make sure there is a validation method
  and a possibility to re-sort the values that are added in.

Bug: T162784
Bug: T162786
Change-Id: I8068a7cc411eef40ddb8af4eef1d4f1e5f2a2b82
2017-07-18 19:21:10 -07:00
Ed Sanders
2c03d167fa build: Upgrade grunt-eslint from 19.0.0 to 20.0.0
Most indent and escaping fixes.

Change-Id: I210e2fc3c0ce3148327ef81f824e1ce9f1e269b6
2017-07-18 16:57:03 +01:00
Timo Tijhof
5a49381406 qunit: Remove redundant conditional for sandbox teardown
Follows-up 0a208911a2, which added support for the `executeNow`
parameter to QUnit.module.

To properly support nested modules, we also need to skip registering
a second setup and teardown because nested modules already run the
beforeEach (setup), and afterEach (teardown), of their parent modules.

During setup this would needlessly create two sandboxes and override
the 'sandbox' property on the same 'this' context object. During
teardown it would fail because the inner module's teardown would
have already torn down the sandbox.

Change-Id: Ib17bbbef45b2bd0247979cf0fa8aed17800c54a0
2017-07-17 20:25:11 +00:00
Timo Tijhof
6fd5e71ef9 mediawiki.toc: Migrate test from deprecated asyncTest()
Instead, use assert.async(), or (in this case) return the Promise directly
to QUnit.test, which will naturally await it.
As bonus, it'll handle errors, too. (instead of timing out)

Change-Id: I94ee0bf72a3d8ac2e588cd75cbe0787b5001d5b4
2017-07-15 04:10:18 +00:00
jenkins-bot
8dfa5aa74d Merge "mw.loader: Avoid use of deprecated QUnit.asyncTest/QUnit.start" 2017-07-15 00:27:30 +00:00
Timo Tijhof
6418c54c4a mw.loader: Avoid use of deprecated QUnit.asyncTest/QUnit.start
Deprecated since QUnit 1.16, removed in QUnit 2.0. (We're on 1.23 currently.)

Migrate to assert.async().

This is a fairly atypical use of QUnit.start(), because it functions here
as a cross-script callback, where lexical scope cannot be used to share
the async() callback directly.

Other mw.loader tests already solved this by using a static callback instead
which inherits the lexical scope from the test to call done(). The old
'qunitOkCall' script is no longer used after this and thus removed.

Change-Id: I430df14b35a69c71df8685494d1379e22af0d6df
2017-07-13 04:44:43 +00:00
Timo Tijhof
12cca1c68e mw.loader: Log unknown modules in load() to console
Follows-up If8ff31b530dfbd882. Now that we have resolveStubbornly,
we don't need to filter out unknown modules ahead of time.

Aside from removing the needless filter condition, it also has
the benefit of causing a message to be logged to the console,
which can help discover problems. Previously these were silently
ignored.

Change-Id: I700db4931dfd0a412a8eca66c4a74b8831ab0086
2017-07-11 15:40:54 +00:00
Timo Tijhof
37df741514 mw.loader: Skip modules in load() with unknown dependencies
We already skip unknown modules at the top-level, but dependencies
still cause a run-time exception from sortDependencies, resulting
in the entire queue not being loaded.

Bug: T36853
Change-Id: If8ff31b530dfbd8823c47ffd827fcdba807c05b3
2017-07-08 22:53:03 +00:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Moriel Schottlender
5ed72ed54c RCFilters: Add 'single_option' group type
Group type that only allows a single option to be selected
from its range of items.

Bonus: Add the ability to have a view that is hidden from
the menus

Bug: T162784
Bug: T162786
Change-Id: Ide93491a49c1405926ac171c7924a469e94c0e0a
2017-06-27 00:16:46 +00:00
Moriel Schottlender
08703ee29f RCFilters: Unify reading filters by views and adjust unit tests
- Have the initialization method read filters by views and treat
  all filters, regardless of their views, the exact same, including
  evaluating their subsets and conflicts.
- Clean up unit test file and make pass with the new initialization.

Change-Id: I200720ffde8ad8ff7a63d0cd82615d358e74949a
2017-06-23 11:17:37 -07:00
Moriel Schottlender
11d7c69377 RCFilters: Have the model accept multiple views
Organize the way we create and process multiple views, to stop
hard-coding namespaces and tags.

Change-Id: Ib28c166052781b23a3b35c1b7b0af7d26f102e3f
2017-06-22 11:31:57 -07:00
jenkins-bot
3458091bfe Merge "Ability to create tests with nested modules" 2017-06-22 14:11:21 +00:00
Moriel Schottlender
51ce88abb9 RCFilters: Add 'views' concept and a namespace view to RCFilters
Enhanced RCFilters: Add the ability to filter by namespaces to RCFilters.
	🎉	🎁	🎊

- Add the ability to separate groups of filters by 'views'
- Add the first views as 'default' (for predefined filters)
  and 'namespace' as the list of namespaces.
- Add 'nsinvert' to namespace group
- Allow highlighting namespaces
- Allow searching on either view, depending on prefix
- Add a way to switch views by typing prefix, clicking the
  'Namespaces' button or clicking a tag (either namespace
  or filter tag, changes the view accordingly, and adds
  or removes the prefix from the input to stay consistent)
- Add an optional wrapper text for tags, so we can represent
  them with their respective prefixes and (if needed) with
  a special message for inverted state.
- Add unit tests and make pass
- Bonus: Fix issue with URL not updating (and not being updated)
  the inverted and highlight enabled states.

Bug: T159942
Bug: T163521
Bug: T164130
Change-Id: I7e83f0800cbeb289dfd3461c1c5a197c053147ca
2017-06-14 12:57:13 -07:00
Moriel Schottlender
85876bbc71 RCFilters: Make frontend URL follow backend rules and add 'urlversion=2'
The backend always merges the query with wiki/user defaults before
it gives us data. The frontend, though, initially assumed that the
state is given strictly by the URL parameters (especially after the
URL shorening commit). This made it so that the frontend state is
incompatible with backend state.

However, always merging frontend state with user/wiki defaults can
produce inconsistencies between URLs in the same wiki, preventing
users from sharing them -- and making it potentially break if ever
a wiki default changes.

The solution is to add 'urlversion=2' to all RCFilters-generated
URLs and have the backend recognize this parameter as 'do not
merge with defaults'.

When RCFilters frontend loads, it checks whether the parameter
exists; if it doesn't, it merges whatever it sees with the defaults
just like the backend, then it transforms the URL to represent the
correct full state, and adds 'urlversion=2' to the URL parameters,
making it consistent across accounts and through time for the
next time it will load.

This means several new behaviors over the 'short url' commit:
- Accessing Special:RecentChanges directly (no query) will result
  in one of two things:
  -- If there is a saved query that's set to default:
     The system will load that saved query "straight forward" (as
     if the user clicked that option from the menu) causing, also,
     an ajax re-request from the server (since the server does not
     yet know about saved queries or their potential for being
     the default state.)
  -- If there is no saved query default: The system will load
     user/wiki defaults (like the backend does) and then fix the
     url to represent this state fully (with parameters showing the
     actual state of the filters.
  -- Both cases will also result in adding 'urlversion=2' to
     the end result URL.
- Accessing Special:RecentChanges?urlversion=2 (without any other
  parameters) will result in loading a completely empty filter set
  in RCFilters. We assume that 'urlversion=2' does not load defaults
  even if it is the only parameter in the URL.
- Accessing Special:RecentChanges?hideX=1 (parameter set without
  urlversion=2) will result in the front end taking the requested
  parameters, merging them with user/wiki default (reproducing what
  the backend does) and then adding urlversion=2 to the URL.

In all cases except for the default-saved-query-load case, the initial
load will **not** re-request data from the backend. The backend needs
to adjust to respect urlversion=2 as well (will come in an upcoming
commit) so the state and expectation of both the front- and back-end
are the same.

This commit also factors out URL handing to a separate class (UriProcessor)
and adds unit tests for it.

Bug: T166907
Bug: T166972
Bug: T166974
Change-Id: I0eed3bc0d4fa4810b6301b535c75b6bfbc8b4a5b
2017-06-14 10:50:49 -07:00
Fomafix
fbf939cdda Remove id selector for toctitle
In 1bf5a652 the id selector was changed to a class selector for toctitle.
The cached HTML has been expired now and the id selector is not necessary
anymore.

Also remove the id selector #toc.tochidden for print style. This is not
necessary because the tochidden gets only added to .toc and not to #toc.

Change-Id: I43cfffdb0807e8ed8f6b7b8732ba857b709bee80
2017-06-08 10:05:00 +02:00
Aleksey Bekh-Ivanov (WMDE)
0a208911a2 Ability to create tests with nested modules
Change-Id: Ie0bf2dcfb63e7dc53cd5afe411e2fbb8d1bbfd73
2017-06-02 11:28:48 +00:00
jenkins-bot
e166ba2abd Merge "RCFilters: Minimize url string" 2017-05-30 22:46:08 +00:00
Moriel Schottlender
2dea830ecc RCFilters: Minimize url string
In order to minimize the URL query, we use a base representation of the
parameters as if they were all '0' or '' and internally expand on it.

- Only display parameters with a value that is not empty or '0' in the
  URI. Any parameter that is missing from the URI is presumed to have
  an empty value.
- Stop pushing defaultParameters everywhere. Default parameters should
  only be considered either on load (when/if needed) or when the user
  actively requests for them.
- Minimize parameters to the URL, and expand when reading into the model.

Similar to using base filters, we can use a representation of base
parameters to make the URL small but the representation all-encompassing.

Bug: T165445
Change-Id: I1d21c38137fde51fcd561e2de24592722bf532c6
2017-05-28 12:05:59 +03:00
Timo Tijhof
15b88fc280 jquery.makeCollapsible: Restore considering empty <a> as part of toggle
Before 2d95d36a8e, clicks on links inside toggles with non-empty
targets that are not '#', were ignored ("pass through") since they
are not intended for the toggle.

In 2d95d36a8e, this was simplified to ignoring clicks from all <a>
elements inside toggles. However this ignored too much as links
without 'href' attribute are also sometimes used inside toggles
to look like links and have no href-target, which means clicking
them does nothing and is in fact meant to toggle the element.

Restore previous behaviour and restore previous test + add a new
test for this specific case.

Bug: T166298
Change-Id: Ia3a0648f809f94be0977a83b469fbd184aa72aff
2017-05-25 21:23:17 +00:00
Moritz Oberhauser
2d95d36a8e Allow more customization on the default toggle system
The naming convention remains unchainched. Default toggles are added if no mw-collapsible-toggle child element is present. Premade toggles have already one ore more mw-collapsible-toggle elements defined.

Default and premade toggles (mw-collapsible-toggle) still cannot be mixed/combined with remote toggles (mw-customtoggle).

* The default toggle got less rigid by removing dependency on <a> elements.
* Support for multiple premade toggles was introduced.
* The expand/collapse messages can be used by premade toggles via mw-collapsible-text.
* Removed the linksPassthru option. This step allowed merging premadeToggleHandler into actionHandler.
* The pass through functionality is now applied to all <a> elements since the default toggle does no longer depends on those.
* Removed mw-collapsible-bracket because it was not used and is deprecated by mw-collapsible-text.
* The test suite was adapted to reflect the latest changes.

Change-Id: Ic8627c4c185e8e4175e6fef1c8e1c2190e54edaa
2017-05-20 15:27:53 +02:00
Moriel Schottlender
ee5397eaa0 RCFilters: Fix getFilterRepresentation to consider '0' as false
Because '0' is a string, it's true, but for our purposes, it's
supposed to be false. Thanks JavaScript.

This bug was actually pretty horrific, it meant that when you refresh
the representation is all wrong (all items in the group were considered
true if the group was 'send_unselected_if_any' which meant that most
of those (that are full coverage) 'corrected themselves' to be all-false
which meant you lost filters when refreshing, even though the parameters
appeared in the URL (the url helpfully corrects itself based on the model
but the model was wrong.)

How did this pass unit tests, one might ask. Well, the unit tests were
treating parameter values as numbers, rather than strings, a fact that
is promptly fixed in this commit.

Also, for consistency and proper data validation, all parameters are
now always stored and handled as strings, in the model.

Bug: T165230
Change-Id: I16d8d95be067b3e48e557ef25f8eb6a49736aa4e
2017-05-13 13:22:58 -07:00
Moriel Schottlender
c1bd4b7d27 Refactor filter-specific logic into group models
Make the view model more generic and ready to accept other types
of filtering, like namespaces and tags, by handing off the responsibility
and logic of the parameterizing and filter relationships to the groups.

Change-Id: I9c333719e89088d96d044d72ddb9c39feeeb68ca
2017-05-12 15:06:20 +00:00
jenkins-bot
841e78dfbc Merge "RCFilters UI: Add a 'saved queries' quick filters feature" 2017-05-08 23:47:54 +00:00
Moriel Schottlender
8936e6455a RCFilters UI: Add a 'saved queries' quick filters feature
Bug: T151994
Bug: T164128
Change-Id: I5cede87633147736d3b4ee5b8ea178ae21bd441f
2017-05-08 16:20:44 -07:00
jenkins-bot
f72f4b7595 Merge "RCFilter UI: allow getParametersFromFilters to accept filter list" 2017-05-05 15:16:59 +00:00
Ed Sanders
ee3d5a014f build: Update eslint to 0.4.0 and make pass
Change-Id: Ib230392f332268ac801cf668f399fcefb1cb1cc5
2017-05-04 22:38:03 +00:00
Moriel Schottlender
25c2ad91f2 RCFilter UI: allow getParametersFromFilters to accept filter list
Up until now we assumed that this method should output the parameters
from the state of the system, which meant that even if it accepted an
external list, it required that it be the format of this.groups.

Instead, allow the method to accept a "flat" list of filter name/values
and translate that to a parameter state without changing the model state.

Change-Id: Ib41da620a16d874326fe73220ae7a0114c555639
2017-05-02 15:31:41 -07:00
Ed Sanders
9e002ecb55 Spread and indent string-concatenations
Avoids single lint string concatenations and multi-line strings.

Change-Id: Iada91c1019cda87d48b13bdcff963d1950b54874
2017-05-01 14:56:04 +01:00
Timo Tijhof
1073b75139 qunit: Also clear $.timers when stopping unfinished animations
Stopping the animation is essentially the same as pausing, it remains in the
animation registry and will continue to fail all subsequent tests until one
of those later tests starts the animation queue again and also happens to
wait long enough for this unrelated animation to finish.

Fix the testrunner to actually fully stop the pre-existing animations, which
requires clearing $.timers as well. This matches the logic we have for
pending ajax requests.

Bug: T163211
Change-Id: Ic7d848187bc3c800e8347e0650093b2ffce6dddc
2017-04-18 16:52:41 -07:00
Fomafix
115fca376e Use .toc instead of #toc as selector for TOC
Since 1bf5a652 multiple TOCs are supported.

In CSS the selector #toc is kept for backward compatibility for uses in the
content.

Change-Id: I07036c0d5782420fc127781a15c675fc7e6fafaf
2017-04-18 01:26:26 +00:00
Timo Tijhof
d8af25c706 qunit: Improve testrunner logging for pending ajax
* Move `restoreWarnings()` in tearDown() to the mirrored location
  of related code in setUp().

* Ensure that accidentally calling `suppressWarnings()` twice will
  not wipe out the original reference indefinitely. If it was
  already set, subsequent calls should do nothing instead of
  overwriting them again so that recovery is still possible.

* Log all ajax requests logged during the test, not just the
  one currently still pending. This should avoid situations
  where we throw "Pending ajax requests" but no information
  is logged about which requests those might be.

Change-Id: I900ad98c4c8520bdd6ae00a24ac82272f3becfee
2017-04-14 17:23:16 -07:00
Timo Tijhof
560f7ef7f9 jquery.tablesorter: Disable a flaky isoDate test case
This one varies by local timezone. To be fixed up later.

Change-Id: I42f3684b721d4c8a9a687adbaf0b4f770c1f057d
2017-04-13 14:19:40 -07:00
Timo Tijhof
74432560be qunit: Remove test for deprecated jquery.placeholder
It's not very useful and needlessly emits deprecation warnings
which unfortunately cannot be surpressed at runtime.

The test just asserts that a no-op function exists.

Change-Id: I2768ba40191a3c0cc7be6202ffa5bed529eabfee
2017-04-13 14:00:24 -07:00
jenkins-bot
dc1632d58e Merge "RC Filters: correctly read default value for 'string_options' filters" 2017-04-10 18:46:29 +00:00
Ed Sanders
1bf5a652d6 Use classes instead of IDs for TOC collapsing
One may way to have multiple TOC's on the page (e.g. in VisualEditor).

Change-Id: I19701c4037b653b2944e407752e50f444861f883
2017-04-10 17:00:03 +00:00
jenkins-bot
3150aa2436 Merge "Replace deprecated jQuery.isArray by Array.isArray" 2017-04-04 21:27:55 +00:00
Fomafix
93aafce974 Replace deprecated jQuery.isArray by Array.isArray
jQuery.isArray gets deprecated in jQuery 3.2.0. [1]

Array.isArray is supported since the following browser versions: [2]
* Chrome 5
* Firefox (Gecko) 4.0 (2.0)
* Internet Explorer 9
* Opera 10.5
* Safari 5

Performed using:
find resources/src tests -type f -name \*.js -exec sed -i -e 's/\$\.isArray/Array.isArray/g' {} \;

[1] https://blog.jquery.com/2017/03/16/jquery-3-2-0-is-out/
[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray#Browser_compatibility

Bug: T160953
Change-Id: I1f5fe19d247ec420810e1c4a6db779425b69de23
2017-04-03 19:55:07 -07:00
Timo Tijhof
edd4985b72 Remove support for jquery.placeholder shim
Browser support according to MDN:
* input placeholder:
  - Chrome 10
  - Firefox 4
  - IE 10
  - Opera 11.00
  - Safari 5.0

* textarea placeholder:
  - Chrome
  - Firefox 4
  - IE 10
  - Opera 11.50
  - Safari 5.0

<https://developer.mozilla.org/en/docs/Web/HTML/Element/input>
<https://developer.mozilla.org/en/docs/Web/HTML/Element/textarea>

Bug: T159911
Change-Id: I388e99c5760681049abbe8d9c173b83af9121b02
2017-04-04 02:52:30 +00:00
James D. Forrester
09fcee6110 startup: Drop JavaScript support for ES3-only browsers
Bug: T128115
Change-Id: I95400637d1b85d2c607cd91bcb39ce21733295c8
2017-04-03 19:04:08 -07:00