$.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
$.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
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
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
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
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
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
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
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
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
* 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
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
* .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
* .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
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
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".
* 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
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.
* 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.
* 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)
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.
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.