Commit graph

345 commits

Author SHA1 Message Date
jenkins-bot
80fd6be5f4 Merge "mediawiki.Title: Generalise filename-matching in newFromImg" 2013-10-28 09:53:31 +00:00
jarry1250
d3c64655dc mediawiki.Title: Generalise filename-matching in newFromImg
Both core and extensions can (and do) modify the thumbnail string
e.g. to add page numbers, languages, etc.

As bawolff notes in the commentary to bug 55963, the assumption
that the filename itself appears twice is likely to be violated
from time to time, but for the moment it suffices to fix the
apparent regression described in that bug report.

Also includes some additional test cases.

Bug: 55963
Change-Id: I9bb29a24f9bf50924699b913e31f44689906c525
2013-10-28 09:42:13 +00:00
Timo Tijhof
0bd19ecfc7 jquery.localize: Fix incorrect use of void tag for <html:msg>
Follows-up 55dac1f which errounously changed a few <html:msg />
to <html:msg> while trying to fix up <span/></span>.

Bug: 40598
Change-Id: I987fa288cc1b97a8a5fb367aae2626d7d0b48238
2013-10-21 19:27:07 +02:00
Max Semenik
983d5a89b6 Blacklist Nokia's Ovi Browser from ResourceLoader
It runs scripts proxy-side much like Opera Mini does, resulting in nothing
resembling a real JS engine. This causes problems and the browser is popular
enough to warrant a block.

Bug: 55600

Change-Id: I2c1ee78828c2b9cead4f82ef795972a4c28140b4
2013-10-11 20:29:05 +00:00
Mark Holmquist
165373d799 Add file-link "parser" to mw.Title from commons
Rillke has been amazing and provided us with a first pass at a file URL
parser for MediaWiki:

https://commons.wikimedia.org/wiki/MediaWiki:Gadget-libUtil.js

Hoping to use this for Extension:MultimediaViewer and others in the near
future - potentially replacing patchset Ib69d1ffdfd3b58c2e8e3314940a2cad311b85533

Also tests.

Change-Id: Ie31e6df376bda087e92ec889d54df3374ba96b5e
2013-10-08 11:55:07 -07:00
jenkins-bot
72388938ca Merge "mw.Title: Rewrite from scratch (porting logic from Title.php)" 2013-10-04 03:23:58 +00:00
Timo Tijhof
4894793ab6 mw.Title: Rewrite from scratch (porting logic from Title.php)
Changes:

* Add support for fragments.

* Use wgLegalTitleChars instead of the old clean() method
  that stripped out characters instead of throwing an exception.

* Implemented various other parts of Title.php to make it more
  strict like Title.php. It is still slightly looser, but it
  now takes care of the following that Title.php did already:
  - Directory patterns ("../" etc.)
  - Extra initial colons
  - Titles in NS_TALK that don't round-trip to NS_MAIN
  - 3 or more consecutive tildes
  - Limited title size (255 bytes)

* Extracted parsing logic into a private static #parse method
  and introduced mw.Title.newFromText (a constructor that returns
  null|Title instead of throwing an exception).

* Extended test suite to cover the added features and fixed bugs.

* Since the PHP test suite was lacking these, added them there
  as well.

Bug fixes:

* Fragments are now excluded from the title instead of causing
  the input to be invalid or malformed (e.g. "Foo#bar" was being
  normalised to "Foo_bar").

* ".com" now parses and round-trips properly. The extension and
  rest of title are still separated, but only at the very end
  after all other processing, so though title cannot be empty,
  since we only do a lazy split afterwards, it will split into
  title="", ext="com" internally and join back together when
  needed (bug 38081).

* "Example.js " (trailing space after extension) was previously
  incorrectly parsed as title=Example.js,ext=null.

* "Foo    bar" (multiple consecutive spaces) was transformed
  into 1 space correctly, but "Foo___bar" was not. This has been
  fixed to match the PHP implementation (it merges underscores
  and whitespace of any kind).

Clean up:

* Removed various redundant private helper methods.

* Removed fixNsId as getNsIdByName uses wgNamespaceIds which
  always yields a valid value. The fixNsId was verifying
  something that was already valid.

* Yoda conditional in Title.php, got rid of.

* Use newFromText in jquery.byteLimit.test. It was previously
  using a very basic invalid test (=== '') and no try-catch.
  Since we're getting more strict, typing 'User:' results in
  an invalid title, which should result in the same behaviour
  as it previously did for the lazy === '' check.

Bug: 38081
Change-Id: Ief1c11dabadc2f822065c40be91e04d655933e4f
2013-10-01 23:38:53 +02:00
Timo Tijhof
81fd2fc17c Fix comma errors in various js files (new jshint warning)
We're about to upgrade to JSHint 2.x. Among various improvements
it now properly detects incorrect use of the comma operator.

This helped uncover two mistakes that could solve a bug, though
in this case the difference was purely in the semantics. The
endresult is unchanged.

Incorrect use of the comma operator can lead to assigning the
wrong value to a variable or causing an implied global variable.


> $ jshint --version
> jshint v2.1.11
> $ jshint .
> resources/jquery/jquery.textSelection.js: line 298, col 71, Expected an assignment or function call and instead saw an expression.
>
> tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js: line 99, col 44, Expected an assignment or function call and instead saw an expression.
>
> 2 errors

Change-Id: I6fdae5f66ef69b6526121cd7b1b2fbb0d9df7a62
2013-09-30 15:05:08 +00:00
kaldari
b84b14195d Adding support for query string params to mw.util.wikiGetlink
This will enable us to easily migrate MobileFrontend from
using M.pageApi.getPageUrl (mobile custom version) to
mw.util.wikiGetlink.

Includes a unit test.

Change-Id: I5224a0910a822f1c3b1b34f505dbcdf879052b39
2013-09-11 13:48:52 -07:00
jenkins-bot
20ce9ccbd5 Merge "jquery.byteLength: Improve documentation and tests" 2013-09-07 10:40:58 +00:00
David Chan
e1ed8a7b89 jquery.byteLength: Improve documentation and tests
Change-Id: I6793487b7cd9f58b23554bc29c853bd3f02da49c
2013-09-06 18:23:35 -07:00
MatmaRex
68053542c7 jquery.makeCollapsible: Tests for collapsible <table>, <ul>, <ol>
Also expanded basic tests for <div>.

Change-Id: I33b067a70f8ea9a788c687c793fbf561db083a34
2013-09-04 16:56:25 +02:00
TheDJ
7aa4bcd629 Merge "jquery.makeCollapsible: Some low-level tests" 2013-08-06 15:52:18 +00:00
jenkins-bot
1694dcc0da Merge "Add getId to mw.user, returning wgUserId (or 0 for anons)." 2013-08-03 02:02:58 +00:00
Matthew Flaschen
164bcc780e Add getId to mw.user, returning wgUserId (or 0 for anons).
This is equivalent to how User->getId works on the server.

Small formatting update to another documentation block.

Change-Id: I31906398f572dd4f62d89b53dfd05a362bf6d5a5
2013-08-02 21:58:14 -04:00
Mark Holmquist
8d62955152 mediawiki.util: Fix addPortletLink to allow jQuery objects
The docs already say jQuery is a supported type for nextnode, it just
wasn't yet checking for it in the function.

Change-Id: I0bdc7dacd24aac720b70c6fc0ca3154ceccd0ebb
2013-08-02 01:31:53 +02:00
MatmaRex
5ecb2e1e68 jquery.makeCollapsible: Some low-level tests
* mw-made-collapsible data added
* mw-collapsible added when missing
* mw-collapsed added when missing

Change-Id: If88c57403464aca053c7babfad8802742640fcfa
2013-07-26 18:52:28 +00:00
MatmaRex
1fd1c5bb6a jquery.makeCollapsible: Consistency in test names
Mention which part of the code is being tested in parentheses in test
names. Some actions can be triggered inmore than one way or in more
than one context: this gives a clearer image of what has tests already
and what hasn't.

Change-Id: I48dcf831f6a622f08061b29ca90fb0614e4cbab6
2013-07-26 18:52:19 +00:00
MatmaRex
0fc0049a54 jquery.makeCollapsible: Tests for collapse and expand text
Provided via data- attributes (data-collapsetext, data-expandtext)
and via options (options.collapseText, options.expandText).

Change-Id: I8922b80ee9aff149a56c9ca44edc247033fc6d6a
2013-07-22 11:15:39 +00:00
Derk-Jan Hartman
3864b0b69e Tablesorter: Add testcase for unsortable column
Change-Id: I64ea3c7301a8be6c4b7b9b462d0e81b89a525f9e
2013-07-21 17:10:40 +02:00
Santhosh Thottingal
710d3bba38 Support explicit plural forms at client side l10n
Adds support for explicit plural forms like n=form

Example:
message: There {{plural:$1|is one car|are $1 cars|0=are no cars|12=are a dozen
cars}}

with $1=12, this gives: There are a dozen cars

Includes qunit tests.

Bug: 51284
Change-Id: I82b906769ccdd9907d2d8022a689232f496c033e
2013-07-16 10:12:32 +05:30
MatmaRex
92f06b4afb jquery.client: Detect Internet Explorer 11
It only admits it's using Trident, the browser name is not in the UA.

Side-effects: detects Trident's version for IE10 as well, detect WOW64
as Windows.

Also minor code consistency changes.

Bug: 50873
Change-Id: I79d65548e90d2c98c4e1d3253ac432801f48b4ba
2013-07-10 20:10:25 +00:00
MatmaRex
ce3e67e1ab jquery.client: Add detection for Opera 15
Opera 15 pretends to be Chrome, Safari, Gecko, Mozilla, *and* KHTML.
I don't even.

Also fixed some typos in comments and done minor code cleanup.

Change-Id: I200def556c3891864235ba0f8f2f29278263e030
2013-07-10 03:30:51 +02:00
Derk-Jan Hartman
1e8ff6213d colSpan: do proper accessing of the property/attribute colSpan
Change-Id: I192a95d2eeca40265156f7a05893ab3006f65ace
2013-07-06 13:15:25 +02:00
MatmaRex
bb9aaa6e04 Remove unnecessary h5 selectors
They were only here for backwards-compatibility due to HTML caching
(see bug 42452).

Also change one JS test that still used <h5> (the tag used doesn't
matter in it anyway).

Change-Id: Ibdf248d9779ded03444fe68f3149d6531fc7b154
2013-07-05 23:07:05 +02:00
MatmaRex
435491fb25 skin: Convert table of contents from <table> to <div>
It makes no sense semantically; it was only used to make the TOC not
span full width of the page, which is easily achieved with CSS.

Bug: 658
Change-Id: I4ecd0659d1f955a9b593d281a3fef0a81c218a52
2013-07-02 01:08:45 +02:00
Derk-Jan Hartman
a106c12e5c jquery.tablesorter: Support sortable column headers with rowspans
Bug: 38911
Change-Id: I172c3a610b28498334f80a7808663bab7fb0466c
2013-07-01 17:38:27 +02:00
jenkins-bot
536cf1d6a3 Merge "jquery.client: Fix profile of some UAs and add exactMatchOnly param" 2013-06-05 12:31:24 +00:00
Ed Sanders
148cbece3b jquery.client: Fix profile of some UAs and add exactMatchOnly param
Fix detection of Iceweasel (add to wildUserAgents), Safari (make
comma after KHTML optional) and Android (add to versionPrefixes
and names).

Add 'exactMatchOnly' parameter to test function which triggers
a return value of false if the browser is not found (previously
was always true). Also making ltr/rtl splitting in support map
optional.

Change-Id: I541a6c134e9668f6bf5af49d4508a82d4f546bb6
2013-06-05 14:26:43 +02:00
jenkins-bot
7636bea2bf Merge "jquery.tablesorter: Reset unaffected columns' sort counts when sorting" 2013-06-05 11:48:07 +00:00
jenkins-bot
660019e71a Merge "jquery.byteLimit: Fix infinite loop if text is longer than max" 2013-05-24 09:34:23 +00:00
jenkins-bot
be8b80b551 Merge "jquery.byteLimit: Improve unit tests" 2013-05-24 09:29:33 +00:00
umherirrender
e7cd380dee jquery.byteLimit: Fix infinite loop if text is longer than max
When the length of the returned text of the callback is longer than the
max, the slicing of the input text, should not go into a endless loop.

Without this change, the added unit tests would fail as a result of
the infinite loop.

Bug: 41450
Change-Id: Iad84522659ab160e18828cbfc463db83bc7e4795
2013-05-24 09:26:47 +00:00
Timo Tijhof
4caa8528ca jquery.byteLimit: Improve unit tests
* Update outdated documentation
* Remove hasLimit and limit properties of the test helper
  function. These just repeated data already provided
  (hasLimit if input != output, limit == expected.length)
* Add tests for a filter that increases the length
  (currently only a decreasing filter was tested).

Change-Id: Ib4c19f4d49ed9d19117bbbaccedb0fccaeb34719
2013-05-24 09:20:47 +00:00
Timo Tijhof
beb1c4a0ec phpcs: More require/include is not a function
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.

Also updated usage in text in documentation and the
installer LocalSettingsGenerator.

Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;

Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
2013-05-21 23:26:28 +02:00
umherirrender
2efe85ca53 jquery.tablesorter.test: Reset transform tables in mw.config
Having $wgLanguageCode set to "de" will pre-populate the transform tables
in mw.config for German, but the English transform tables are expected
(which are empty) for the jquery.tablesorter tests to pass.

Change-Id: Ief16ff9d0767c6c9332bc4e56c96be3d7d4f6ac8
2013-05-13 18:36:46 +00:00
Timo Tijhof
50e7985d4d phpcs: Fix WhiteSpace.LanguageConstructSpacing warnings
Squiz.WhiteSpace.LanguageConstructSpacing:
   Language constructs must be followed by a single space;
   expected "require_once expression" but found
   "require_once(expression)"

It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.

Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.

It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.

Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
2013-05-09 05:56:26 +02:00
Timo Tijhof
05f6edc903 qunit: Use jQuery.getScript instead of document.write
TestSwarm jobs were breaking because this runs after the
document is ready, thus causing the page to be blanked by
document.write.

Change-Id: I5e1c331d72ac364c9cd970a9b085f0b986b26a14
2013-05-07 01:36:19 +00:00
Timo Tijhof
2e970257de mw.hook: Implement callback framework
We have various interface components that are extended, enhanced
or manipulated in some other way by extensions, gadgets and even
in core itself.

This framework helps streamlining the timing of when these other
code paths fire their plugins (instead of using document-ready,
which can and should be limited to firing only once).

Features like navigating to other wiki pages, previewing an edit
and editing itself – without a refresh – can then retrigger these
hooks accordingly to ensure everything still works as expected.

For the server side this has been possible already, but for the
client side we've been limited to running only once on the
original page load.

Further documentation and examples are in the code documentation.

Bug: 23580
Bug: 30713
Change-Id: Ic73a3efe53d6fb731e7f1e531d5f51530cd7e4fe
2013-05-03 22:33:55 +02:00
jenkins-bot
4ba162a1e0 Merge "jquery.makeCollapsible: Enable passthru for links in premade toggle" 2013-05-03 14:09:25 +00:00
MatmaRex
9857630a64 jquery.makeCollapsible: Enable passthru for links in premade toggle
Clicking on a regular link inside a premande toggle is supposed
to follow the link instead of collapsing/expanding the
appropriate element.

Broken during a rewrite in Id3f457a8 (2638b16c) - the comment
reflected the intended behavior, but the code was wrong.

Regression test included.

Bug: 46848
Change-Id: Id571f8d612e5131845d381121604c2b1116a077f
2013-05-03 16:02:23 +02:00
Max Semenik
f9be946857 Completely blacklist Opera Mobile from RL
While initially it was believed that allowing it in does no harm,
practice proves otherwise, see the dependencies of bug 47572.

Bug: 47572
Bug: 47570
Bug: 47567
Bug: 47568
Bug: 47569
Change-Id: I32c082d3cca1af4ce97da08f28beb4926ae97ac3
2013-05-01 22:44:47 +00:00
Timo Tijhof
54d25a7e24 mediawiki.util: Fix roundtripping of tooltip in portlet links
In 558985f72a ctrl-option- for Chrome on Mac was added, but it
didn't add "option-" to the regex. Since then the tooltip in
Chrome on Mac (and later when we started referring to option
instead of alt on all Mac browsers) was never detected by this
regex, sometimes resulting in double tooltips (when adding) or
outdated tooltips (when updating).

Now we always look for an accesskey hint in the tooltip and
strip it it's there.

Also fixed a bug where an undefined error can occur if accesskey
is given but tooltip not (the method unconditinally appended
text to the tooltip varible which might be undefined causing
a tooltip like "undefined[a]").

Change-Id: I0bde1a228983c58b20cad0c09a8e5efe8225ea23
2013-04-22 21:57:34 +02:00
Henning Snater
fb775d6cdf jquery.tablesorter: Reset unaffected columns' sort counts when sorting
The column sort count (which is used to determine the sort order when
clicking a table header cell) was not reset on table columns unaffected
by the sorting. Sorting a column in ascending order, then sorting another
column and finally sorting the first column again would cause that column
to be sorted in descending order although it should be ordered in the
default (ascending) order again (see test added).

Change-Id: I3dd49bab07f9a02d9e1d531f1397396025fe77e0
2013-04-15 17:00:51 +02:00
Timo Tijhof
ceaa7ddada startup: Lower blacklist for Firefox from 4 to 3.
Though Firefox is 3.6 is both unsupported by Mozilla, by jQuery
and by MediaWiki JS, it is not known to have fatal errors in
javascript run time execution so moving from Grade B (blacklist)
to Grade X (unsupported but given Grade A source code at own risk).

This is done following a thread in English Wikipedia's Village
pump requesting to get the Grade A resources again.

Follows-up 02fe025e63.

Change-Id: Ia54dd738b3ce0995fab6aae7a2729cc7b1a0dcb1
2013-04-10 09:37:19 +02:00
jenkins-bot
e2a7aac1fd Merge "mediawiki.jqueryMsg: Implement HTML support and improve HTML escaping." 2013-04-09 22:14:40 +00:00
Max Semenik
c46fc745a9 startup: Blacklist incompatible mobile browsers
These user agents have been blacklisted on the mobile site for some time.

They have been re-reviewed alongside the A grade phones supported by
jQuery mobile [1] and jQuery [2]

[1] http://jquerymobile.com/gbs/
[2] http://jquery.com/browser-support/

Change-Id: If7743c476e95002174763514428c17dfcbe7da4c
2013-04-09 00:28:33 +00:00
Matthew Flaschen
473a27e32e mediawiki.jqueryMsg: Implement HTML support and improve HTML escaping.
* Whitelisted elements.
* Whitelisted attributes allowed on all elements, and additional ones
  per element.
* Currently, only b (bold) and i (italics) and the common attributes are
  implemented, but more can be added.
* Treat error message as text
* Implement appendWithoutParsing as an extra safeguard to ensure
  jQuery never implicitly parses HTML.  Reuse this where a similar
  case was handled one-off.
* Rename some of the link functions and variables to be clearer about
  relationships.

Bug: 44525
Change-Id: Id8902af9568092d0318d0ac9d1ca6c9c195d36fe
2013-04-08 16:22:43 -04:00
Timo Tijhof
97c2c66cc1 mw.loader: Fix regression that caused CSS load after scripts.
Follows-up 705d50c which introduced cssText buffer (yielding
one tick of the event queue to reduce the number of forced
repaints).

However since that made CSS loading asynchronoous (be it only for
a split second) it caused some nasty side-effects.

This was also reflected in the unit tests that had to resort
to doing setTimeout from within the mw.loader implemented script
to assert the styles. This is now sane again: Scripts execute
after styles are inserted.

Bug: 46401
Change-Id: Ib54a3e78710b7f798c6730d3f540d3284001e2de
2013-04-08 12:23:19 -07:00
Hashar
902f5779af Revert "mw.loader: Fix regression that caused CSS load after scripts."
Broke master tests since it causes a JSDuck issue. See bug 47018.

This reverts commit be5f73b595

Change-Id: I2d945b7ffb7cfbcc5024a1c3bdcf0c9506b0cf76
2013-04-08 19:13:18 +00:00