Commit graph

65 commits

Author SHA1 Message Date
MatmaRex
c1104c2dbd (bug 42607) $.tablesorter: require separators when detecting dates
$.tablesorter allowed no separators in DMY- or MDY-formatted dates,
where M is a month taken from the wgMonthNames and wgMonthNamesShort
variables. This was probably intended to capture dates like
'1Dec2012'.

Unfortunately, for example the Czech language uses no short month
names, and the variable simply contains numbers from 1 to 12. This
caused the datection to break horribly and consider all numbers to be
dates.

With this patch, detection requires a space or one of the other
defined separators between month and day or year.

Change-Id: I3a37acf1985eddf922e69e2c2a1cf541fc00e97e
2013-03-23 22:29:51 +01:00
Brad Jorsch
4cc5048ce1 jquery.tablesorter: Fix explodeRowspans
$.tablesorter's explodeRowspans works ok for simple tables, but row
headers or unusual spanning structures will confuse it.

This rewrite makes it more robust.

Bug: 41889
Change-Id: Icb674f7eece053435ca9525d45709579df14cc74
2013-03-17 20:58:12 -07:00
Brad Jorsch
e203fdfc74 jquery.tablesorter: Fix broken getElementSortKey()
Change I3e9898f3 introduced changes to
getElementText()/getElementSortKey() that broke certain behavior with
respect to tables having colspanned cells. Restore the old behavior for
these cases.

Change-Id: I18be2e6c1f0ab926ff4c795530600b52bc6488c0
2013-03-18 03:45:10 +00:00
MatmaRex
b9e9407ffb $.tablesorter: remove and inline getTextFromRowAndCellIndex()
It introduced unnecessary indirection and was only called once.

Change-Id: I519cc1f04a581d41aa23229182c55466ed7757c8
2013-03-15 15:56:33 +00:00
MatmaRex
39d1f3967b (bug 40044) make $.tablesorter treat alt attribute like text
Now images in cells will not be ignored when sorting; instead, their alt
attribute will be used for the sort key.

Internal interface changes:
* renamed getElementText() to getElementSortKey() with changes

Change-Id: I3e9898f3424a995507095384e80c8b570da118f0
2013-01-25 19:07:26 +00:00
MatmaRex
99a53dd8e4 (bug 41886) make $.tablesorter support headers with colspan
Previously, if a header had colspan set, all headers after it would sort
wrong columns (shifted by the cumulating colspans). This fixes the issue,
from now on every header sorts on all columns it spans over (using the
multi-column sorting funcitonality already present in $.tablesorter).

Change-Id: I89766c9640b83ca38f41d698d1ef052a9e3f68d3
2012-11-24 18:19:29 +01:00
Timo Tijhof
1f92fd42d6 Lint: Pass jquery.tablesorter.
Added tolerance for "onevar" (hard to dissect, many out-of-scope
usage, probably better to be done by someone who knows this code
better).

Errors:
* Strings must use singlequote
* '$cell' is defined but never used.
* 's' is defined but never used.
* Unnecessary semicolon.
* '$document' is defined but never used.
* 'sortOrder' is defined but never used.
* 'shiftDown' is defined but never used.
* 'table' is defined but never used.
* 'table' is defined but never used.

Change-Id: I2e0abc41a79922a1810519705237ae3bd60ed679
2012-11-19 19:50:15 +01:00
Anomie
a752f35fb6 Merge "(bug 42097) $.tablesorter fix when wgDefaultDateFormat is unrecognized" 2012-11-14 20:59:03 +00:00
MatmaRex
a158c63171 (bug 42097) $.tablesorter fix when wgDefaultDateFormat is unrecognized
The 'date' parser assumed all wikis use wgDefaultDateFormat that is
either 'mdy' or 'dmy', but this is not the case; for example
fi.wikipedia uses 'fi normal'. Therefore the correct value was not set,
a string was not changed to an array, and a loop that assumed an array
would be present hanged forever.

Change-Id: Iba17bc6b44d6a2fff491b7462d7a5457f85d19c5
2012-11-14 12:56:01 -08:00
Brad Jorsch
b30c3a3de9 (bug 41886) jquery.tablesorter should not explode rowspans until sorted
jquery.tablesorter should not explode rowspans until the table is
actually sorted.

Also adds a testcase to verify this behavior, and updates another test
case that was depending on the broken behavior.

Change-Id: Ibe4cc7e92de6cc8e370c5912c9eda062b466c538
2012-11-14 20:16:08 +01:00
Henning Snater
c934766061 sort method for jquery.tablesorter
the sort method allows programmatic sorting as well as instantly sorting
the table when initialising the tablesorter; furthermore, the method can
be used to reset sorting (e.g. if rows have been added later via JS);
sortEnd event may be used to reapply alternating table row colours or other purposes

patch set 2: fixed mentioned issues and added another test
patch set 3: addressed all further issues, introduced more obvious way to
specify sorting
patch set 4: implemented sort method instead of using an event; reprashed whole commit message; introduced 'sortEnd' event
patch set 5: fixed white space error
patch set 6: Add release notes and rebase

Change-Id: Id14862100cd27ebd6980c48dcf497db229c4301f
2012-10-17 21:13:50 +02:00
Derk-Jan Hartman
34db074bf0 Fix an issue with the data-sort-type retrieval.
The treatment of attributes with embedded dashes was changed in jQuery
1.6 to conform to the W3C HTML5 specification. Hyphenated names become
camel-cased.

Change-Id: I4ac2ebdc1ba8350b9696e516f62ba803fa8fb46b
2012-10-08 01:54:44 +02:00
Derk-Jan Hartman
6fe1f2c755 (bug 39284) Improve the tablesorter for currency.
* Make the detector for currency not trigger on cells
  starting with "." or "?".
* Make it trigger on values ending with a currency symbol.
* Add the Yen sign.
* Add a basic unit test.

Change-Id: I3c1fdf41db04ea0726ba7613fa5e1365f8fb8493
2012-08-24 17:23:48 +02:00
Brad Jorsch
20d098cfb3 (bug 39296) Fix broken table sorting
Javascript's Array.sort wants -1, 0, or 1. Not false, true, or 0.

Change-Id: I2cb73668793092b53be0c1c6f7ffc647a88bf30a
2012-08-13 12:58:57 -07:00
Brad Jorsch
fda9110f5a (bug 35526) Make jquery.tablesorter use a stable sort
In r86337, jquery.tablesorter was changed from using the standard
Javascript Array.sort to a custom merge sort, with the justification
that it eliminates an eval and merge sort is stable. However, the
implementation used is not, in fact, stable, and making an in-place
merge sort stable reportedly kills performance.

Instead, let's just go back to using Array.sort, but with a closure
(basically the same comparison function used by the merge sort) rather
than an eval and using the already-calculated "position" as a tiebreaker
when two rows are otherwise equal to make it stable.

Change-Id: Idc50127d3bfec2b1727f397a9780b359fd56055e
2012-08-02 16:01:25 -04:00
Timo Tijhof
089c58d232 jshint: resources/jquery/*
* .jshintrc: Updated to include more strict options that match
  our code conventions.
  Also separated into 3 groups:
  - stricter (curly, eqeqeq etc.)
  - laxer (smarttabs, laxbreak)
  - envrionment (browser)

* .jshintignore: Updated to include more third-party/upstream files
   that should not be linted.

* Most of it is just routine cleanup, a few notable points:

 - jquery.autoEllipsis: Removed unused variable $protectedText.

 - jquery.arrowSteps.js: Remove <!-- --> and language="javascript"
   that hasn't been needed for almost a decade.

 - jquery.byteLimit: Use dashToCamel key for .data(), this already
   happens internally in jQuery data(), since data storage should use
   keys that are usable as identifiers. The dashed versions are to
   populate these from data-attribute-names, which then becomes
   data.attributeNames. jQuery data() takes both forms as
   convenience.

 - jquery.client.js: To avoid a rewrite of it, allowing unexpected
   assignments (boss) and eval (evil) in the functions that use that.
   Left as it is for now, could use a rewrite later.

 - jquery.color.js: Tolerate unexpected assignment for now (boss).
   Left as it is for now, should perhaps be refactored later.
   Also re-ordered per jshint/jslint to put definition before
   invocation. This option can be disabled, but then it doesn't
   warn for invoking undefined functions (or typos) at all.

 - jquery.expandableField.js: Remove empty switch/case.

 - jquery.localize.js: Alias mw global.

 - jquery.suggestions.js: Use e.which; jQuery.Event normalizes
   e.keyCode etc.

 - jquery.tablesorter.js: Alias mw global.

 - jquery.textSelection.js: Fix leakage of variable in global scope
   of var "i" and "j".

 - mediawiki.util.test.js: Fixed implied global `pCustom`.

* Review with -w for your own sanity.

Change-Id: Ia972f79539a96a38357ec4e92b0b6e38cc301681
2012-07-15 11:13:20 -04:00
Timo Tijhof
1f83a2e791 (bug 38152) jquery.tablesorter: Use .data() instead of .attr()
* .data() is faster when looking up repeatedly

* .data() will return the latest value, even if it has changed over
   time, whereas .attr() only gives the value as it was when the page
   was generated. Much like the difference between attr() and prop()
   when it comes to value, checked, disabled etc.

* Moved buildCache() call outside `if ( firstTime )`.
  Tests show that this is fast enough to do on the fly. Left inline
  comment with proposal on how to make this more elaborate in the
  future would it become necessary.

* jquery.tablesorter.test.js:
 - Add tests for bug 38152
 - Clean up double quotes
 - Use more descriptive id (prefix with mw-bug-)

Change-Id: Ie4f801c5b1f93617fd3fd173d2eaaf173a7604e9
2012-07-04 23:11:11 +02:00
Brad Jorsch
3516944806 (bug 36991) Fix jquery.tablesorter date sorting
jquery.tablesorter should extract date sort format from date string
instead of global config. Dates like "April 1 2012" and "1 April 2012" now sort correctly regardless of the content language's
DefaultDateFormat setting (exposed as wgDefaultDateFormat in
mw.config).

Previously jquery.tablesorter sorted dates like "1 Apr 2012" (DMY) or
"Apr 1 2012" (MDY) incorrectly. It just converted it to "1 4 2012"
and "4 1 2012", respectively, and then assumes MDY or DMY order based
on the global wiki configuration.

This patch fixes that.

Change-Id: I8061b1a7892633e34be4d4a0273a4dd5045fd2ee
2012-07-03 19:05:01 +02:00
Antoine Musso
13b1e66dab rv table sorting of IP and fraction
I am reverting, for now, two recent additions made to the table sorting:
 - r111884 fractions
 - r111829 IP addresses

Both need to be polished a bit more before landing in trunk. Please reapply
in a branch then once reviewed we can merge it in trunk, that will avoid
us a lot of "spam".
2012-03-06 10:17:46 +00:00
Derk-Jan Hartman
4c8e201755 Add support for sorting fractions in jquery.tablesorter
Fixes bug 15404
2012-02-19 19:56:56 +00:00
Derk-Jan Hartman
9427b08d08 Add support to tablesorter to handle IP/CIDR notation
This fixes bug 34475
2012-02-18 14:35:14 +00:00
Mark A. Hershberger
c8b8f3a303 re r102301 — apply Krinkle's suggested fix. 2012-01-04 19:09:03 +00:00
Rob Moen
178af33e21 fix tablesorter unit test in ie7. Add semicolon to end of statement in tablesorter class 2011-12-30 21:30:17 +00:00
Derk-Jan Hartman
934b01c67e Fix issue with sortable headers when nesting a table INSIDE a table header cell ?
Who comes up with these usecases ? :D

Fixes bug 32888
2011-12-09 22:39:04 +00:00
Mark A. Hershberger
5ce9371f30 Fix Bug #32047: in table with class="sortable", thead is before
caption

Apply fomafix's patch for jquery.tablesorter.js (also reported upstream:
https://forum.jquery.com/topic/in-table-with-class-sortable-thead-is-before-caption
(currently in moderation)
2011-11-07 17:33:13 +00:00
Krinkle
7553ecf2f6 jquery.tablesorter: More selector fixes
* Limit to rowSpans (td or th) within tableRows that are a direct child of this table's tBody
* Follows-up r99092, r101417
2011-10-31 22:20:25 +00:00
Krinkle
57faa93023 jquery.tablesorter: Selector fixes
* Various fixes to limit the selector to the current table and avoid selecting similar elements from other, nested, tables.
* Should fix bug 32049
* Follows-up r97150 and likely some other refactoring commits
2011-10-31 22:12:26 +00:00
Roan Kattouw
d4e2a4bf57 (bug 31514) Followup r99031: allow clicking of links in table headers in a different way that doesn't break expand/collapse links. 2011-10-25 14:41:58 +00:00
Krinkle
238c103636 Fix broken test by r99321 2011-10-16 22:33:04 +00:00
Derk-Jan Hartman
6a706e93c2 Check if there is a prexisting tfoot, before creating a new one.
Follow up to r98669, though this was a problem that also could surface without tfoot emulation.
2011-10-08 19:28:10 +00:00
Roan Kattouw
08d90ea002 (bug 31420) Fix weird tablesorter bug where headers spanning multiple rows would get screwed up. Thanks to TheDJ for essentially telling me exactly how to fix this, he was spot on. 2011-10-06 12:52:26 +00:00
Roan Kattouw
28dc1840f5 Fix the bug reported on w:en:WP:VP/T where clicking on links in sortable table headers sorts the table rather than following the link 2011-10-05 19:27:55 +00:00
Derk-Jan Hartman
11da46af78 Add tfoot emulation to tablesorter. Fixes part of the complaints in bug 31060 2011-10-02 11:58:46 +00:00
Derk-Jan Hartman
3277c2bc29 Add the class jquery-tablesorter to all tables that are made sortable.
Use this classname to raise the specificity of the sortHeader, so that it is more difficult to accidently override with local css. Followup to r98069

Move the css into a seperate file and move the images for it to the jquery directory.
2011-10-02 11:08:12 +00:00
Roan Kattouw
02fead5840 Followup to r97150 per CR: use .children() instead of .find(), more efficient and prevents potential issues with nested tables. 2011-09-17 15:52:45 +00:00
Roan Kattouw
33e19958bf Update jquery.tablesorter for r97145: emulate <thead> if there is no <thead> in the HTML, by walking down the table starting at the first row and moving rows to the <thead> as long as all of its cells are <th>s (or the row is empty). Also fix and simplify the sortbottom code, which was incorrectly creating multiple <tfoot> elements if there were multiple sortbottom rows. 2011-09-15 13:15:06 +00:00
Brion Vibber
a496d501af Followup to r86108, r86854, r96384: table sorter fetch of 'data-sort-value' attribute failed on IE 6/7 due to directly using DOM methods not available in those browsers.
hasAttribute and getAttribute don't appear until IE 8 in Microsoft-land; switching to jQuery's .attr() resolves this nicely.
2011-09-07 22:03:16 +00:00
Krinkle
3c3d81a185 Add comments and fix whitespace for r90657, r86305 2011-08-24 19:35:18 +00:00
Krinkle
0e82a6cfd0 Applying whitespace conventions in core JS files.
* Mostly whitespace in callers: $('foo').bar(baz,quux) => $( 'foo' ).bar( baz, quux )
* Also several occurrences of mixes spaces and tabs in the indention in front of a line, converted to tabs.
* And double spaces -> single spaces at random.
2011-08-12 21:48:10 +00:00
Krinkle
a046427547 Revert r90678 per CR 2011-07-04 23:36:54 +00:00
Leo Koppelkamm
05135e2303 r86088: Adding legacy support for .sortbottom & a test for it per CR 2011-06-30 19:40:19 +00:00
Krinkle
65c2c5cd6c Review and clean up of jquery.tablesorter.js + applying code conventions
* Dropping redundant "new function(){}" construction, instead using the closure we already have for the local scope.
* Adding more function documentation
* Whitespace contentions
* Passing jQuery object to the $.tablesorter.construct and creating jQuery plugin function in $.fn.tablesorter (per jQuery convention, this allows $.tablesorter.construct to be used directly without having to use .apply() to get the this-context right).
* Making use of the arguments that jQuery.fn.each passes by default in $.tablesorter.construct (this/that => table)
* Renaming a few single-letter variables to something more descriptive (c => $row, r => regex etc.)
* Changed order of local functions in order of calling and dependancy (fixed JSHint potential implied globals). Also makes reading/understanding them easier.
* Removed commented out code
* Added more line breaks to separate blocks
* Merge var-statements together
* Declare 'ts' shortcut on top of the local scope, define 'ts' shortcut directly after definition of $.tablesorter
* Adding public member placeholders, populated by private functions, to the initial object instead of inside the functions. This way the members can be seen centrally (dateRegex, monthNames)


* Syntax/JSHint fixes (Passes 100% now; Globals: mw, jQuery)
- 'list' used out of scope. In function buildParserCache: "var list" was defined under an if-condition, but returned outside of it, this fails in the 'else' case. Moved var list outside the if-condition
- Strict === comparison to 0, null, undefined, false, true, '' etc.
- Require curly braces around all blocks


* Performance improvements (see also http://www.mediawiki.org/wiki/JSPERF)
- Using dot notation (obj.member = {}), instead of $.extend(obj, { member: .. }) for single additions. No need for $.extend
- Object literal {foo}, instead of new function(){ this.foo }
- Strict/fast comparison to undefined, without typeof and/or string evaluation
- cacheRegexs() is uselses if if re-creates the cache every time. Using static cache instead (which was likely the intention)
2011-06-26 04:36:02 +00:00
Krinkle
b79f2ca398 Removing console.log and other ad-hoc debugging code 2011-06-26 02:05:34 +00:00
Derk-Jan Hartman
6f225a6c16 Switch jquery.sortable to use mw-sortable and mw-unsortable classes, to be in line with makeCollapsible. Support for legacy .sortable remains.
Follow up to r86088
2011-06-23 21:26:21 +00:00
Derk-Jan Hartman
9763099ca1 Fix global var leaking that was making collationsort fail on Safari 5
Followup to r86088.
2011-06-23 17:12:36 +00:00
Leo Koppelkamm
21d8e6d2ff Adding rowspan tests to tablesorting & make it more stable 2011-06-23 08:31:00 +00:00
Leo Koppelkamm
4f28b0435d Adding a collation test to tablesorter, fixing var ref from r90630 2011-06-23 07:39:56 +00:00
Brion Vibber
f2ff5d901a Followup r86088: test cases and a correction for bug 17141 (IPv4 address sorting)
Test lists 8 randomly generated IPv4 addresses and attempts to sort them both forward and back.
Turned up a bug where single-digit octets (eg a .1 or .9) were not expanded in the sort key, causing them to mis-sort.
2011-06-23 00:37:23 +00:00
Leo Koppelkamm
debf5bcc4a Revert accidental change from r90630 2011-06-22 23:22:12 +00:00
Brion Vibber
ec84480c18 Followup r86088, r87244, r90612: fix jquery.tablesorter for null collation table on IE
Attempt to build a regex from an empty list failed when calling new RegEx('[]', 'ig') on IE 6/7/8.
Now allowing null for the object, and also not trying to create the regex even if we have an empty object just in case.
2011-06-22 23:19:00 +00:00