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
* jquery.autoEllipsis didn't return 'this', which means whenever it
was used in a chain, it would return undefined.
So in mediawiki.searchSuggest append( ... autoEllipsis() ) would
apply it to a detached node that stays detached because it
isn't passed to append.
* Remove redundant passing of this in jQuery context to $().
On jQuery.prototype, 'this' is obviously a jQuery object. In
jquery.highlightText, which is called from jquery.autoEllipsis.
* Remove redundant .empty() call before calling .text( .. ),
.text() replaces all content and naturally is forced to empty
the element first.
* Merge use of $el and $container in jquery.autoEllipsis.js. They
were both pointing to the same object, having two names was only
confusing.
* Spaces.
Change-Id: I4649ec0c89d38c4d79d1dceec28227902cd48d32
* adds $wgResponsiveImages setting, defaulting to true, to enable the feature
* adds 'srcset' attribute with 1.5x and 2x URLs to image links and image thumbs
* adds jquery.hidpi plugin to check pixel density and implement partial 'srcset' polyfill
** $.devicePixelRatio() returns window.devicePixelRatio, with compat fallback for IE 10
** $().hidpi() performs a 'srcset' polyfill for browsers with no native 'srcset' support
* adds mediawiki.hidpi RL script to trigger hidpi loads after main images load
Note that this is a work in progress. There will be places where this doesn't yet work which output their imgs differently. If moving from a low to high-DPI screen on a MacBook Pro Retina display, you won't see images load until you reload.
Confirmed basic images and thumbs in wikitext appear to work in Safari 6, Chrome 21, Firefox 18 nightly on MacBook Pro Retina display, and IE 10 in Windows 8 at 150% zoom, 200% zoom, and 140% and 180%-ratio Metro tablet sizes.
Internally this is still a bit of a hack; Linker::makeImageLink and Linker::makeThumbLink explicitly ask for 1.5x and 2x scaled versions and insert their URLs, if different, into the original thumbnail object which (in default handler) outputs the srcset. This means that a number of places that handle images differently won't see the higher-resolution versions, such as <gallery> and the large thumbnail on the File: description page.
At some point we may wish to redo some of how the MediaHandler stuff works so that requesting a single thumbnail automatically produces the extra sizes in all circumstances. We might also consider outputting a 'srcset' or multiple src sizes in 'imageinfo' API requests, which would make ApiForeignRepo/InstantCommons more efficient. (Currently it has to make three requests for each image to get the three sizes.)
Change-Id: Id80ebd07a1a9f401a2c2bfeb21aae987e5aa863b
Several optimisations:
* Re-using the same $collapsible jQuery object instead of
re-creation of $(this).
* Use .data instead of dom manipulation (className property).
* Use $.nodeName( HTMLElement, tag ) to check something is <a>,
instead of using creating a jQuery object and calling
"is.('a')", which goes through a lot of selector stuff.
- Fix bug where it says it does instantHide but actually still
triggers the event that causes initial animations.
Thanks to Lupo for most of these ideas, based on this patch:
* https://bugzilla.wikimedia.org/attachment.cgi?id=10200
Verified that these test cases all still work:
https://test.wikipedia.org/wiki/User:Krinkle/CollapsingTestpageMw
(copy wikitext to localhost)
Change-Id: Idb9ca00c03ec7d70903ed7fd79e427efa270ace4
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
It used to be fairly simply and that seemed good enough. Listen
on keypress, get current value, add character from key code in
event object, and calculate the byteLength. If it is too long,
preventDefault().
However there were so many edge cases (too many of them to be
considered edge cases) where this failed whereas the native
maxLength handling was fine.
For example:
- Cut and paste
- Selecting text and replacing or removing it (by any of the
methods on this list)
- Custom javascript input methods (e.g. Narayam)
- Spelling suggestions and corrections
- Drag and drop
- etc.
Now it acts on changes after the fact.
I considered building in a timeout loop in addition to this so
that when javascript gadgets change the input value it would
detect it, however I'd like to hold that off for now. We can
add that later if needed. For now scripts are expected to fire
the 'change' event if they change it, which seems reasonable.
The only challenge that it creates, however, is the need for
basic history reconstruction. Figure out what was already there
and what is new, and cut down the new part until the total sum
satisfies the limit.
This is the same behavior that WebKit browsers (and others) have.
e.g. of "barbaz" is pasted between "f" and "o" in "foo" with a
maxLength of 5, then the resulting string will be "fbaoo".
Also fixed bug 38158 while at it. Filed an upstream bug against
webkit/Chrome but was wont fixed. Either way, we'd have to be
compatible for a little while with old WebKit builds out there
(iOS 3, Safari 5, etc.).
http://code.google.com/p/chromium/issues/detail?id=136004
Use removeAttribute('maxlength') to let the browser internally
reset the maxLength property. Resetting it directly (to undefined
or with `delete el.maxLength') does not work and casts it to 0,
which blocks the input field entirely.
Updated unit tests, and also removed the "type=text" code
afterwards which that doesn't work in IE (Internet Explorer does
not support dynamic changing of input types), needs to be in the
HTML directly. So far it was passing in IE because 'text' is the
default. Tests now use attr('maxlength') everywhere for
consistency, though properties work the same. Browsers
synchronize these things (just like the "class" attribute and
"className" property).
References:
* Fixes bug 38158: Unexpected 0 maxLength.
* Fixes bug 38163: Incorrect limiting of input when using input
methods other than basic per-char typing.
* Follows-up: 39cb0c19
* Supersedes: I70d09aae
Change-Id: I9c204243d0bdf7158aa86a62b591ce717a36fe27
The module has been broken for a while now, but nobody noticed
because in plain core it is disabled by default, and in the
bundle we ship with Extension:Vector (and its SimpleSearch).
This commit removed the mediawiki.legacy.mwsuggest module (and
related components that become obsolete with its deletion) and
replaces it with the new mediawiki.searchSuggest module, which is
based on SimpleSearch from Extension:Vector (where it will be
removed soon).
The following and all references to it in core have been removed,
I also made sure that they weren't used in any of extensions/*.
Only matches in extensions/Settings and some file that dumped the startup module, and in extensions/Vector which are addressed in
I1d5bf81a8a0266c51c99d41eefacc0f4b3ae4b76.
Had to make a few updates to jquery.suggestions to make it work
in other skins. So far it was only used in Vector, but now that
it is used in mediawiki.searchSuggest, I noticed several issues
in other skins. Most importantly the fact that it assumed the
default offset was from the right corner, which isn't the case in
Monobook where the search bar is on the left (in the sidebar).
It now detects the appropiate origin corner automatically, and
also takes directionality of the page into account.
It also uses the correct font-size automatically. Previously it
used font-size: 0.8; but that only works in Vector. Every skin
seems to have its own way of making a sane font-size. In Monobook
the <body> has an extra small font-size which is then fixed in
div#globalWrapper, and in Vector it is extra large, which is then
fixed as well deeper in the document. Either way, the size on
<body> can't be used, and since this suggestions box is appended
to the <body> (it is a generic jQuery plugin without knowledge of
the document, and even if we could give it knowledge inside
the configuration, it'd have to be per-skin). So I removed the
Vector specific font-size and let it handle it automatically.
This was needed because it is now used in all skins.
Removed modules:
* mediawiki.legacy.mwsuggest:
> Replaced with mediawiki.searchSuggest.
Removed messages:
* search-mwsuggest-enabled
* search-mwsuggest-disabled
> No longer used.
Removed mw.config.values:
* wgMWSuggestTemplate
> Obsolete.
* wgSearchNamespaces
> Obsolete.
Removed server-side settings:
* $wgEnableMWSuggest
> Suggestions are now enabled by default and can be disabled
through the user preference `disablesuggest` still.
They can be disabled by default site-wide or hidden from
prefs through the standard mechanisms for that.
* $wgMWSuggestTemplate
> Obsolete.
Removed methods
* SearchEngine::getMWSuggestTemplate()
> Obsolete.
Filters:
$ ack mwsuggest -i -Q --ignore-dir=languages/messages
$ ack wgSearchNamespaces -Q
Message changes:
* vector-simplesearch-preference
> It was wrong, it didn't activate search suggestions, that
was handled by the Vector extension. This preference in
MediaWiki core controls whether the SimpleSearch bar HTML
and CSS will be used (e.g. the rectangle search box with
the magnifying class instead of the browser-default input
field with the plain submit buttons).
* searchsuggest-search
* searchsuggest-containing
These come from Extension:Vector message and should be imported
by translatewiki:
- vector-simplesearch-search
- vector-simplesearch-containing
Change-Id: Icd721011b40bb8d2c20aefa8b359a3e45413a07f
Replaced single `id` argument to $.createSpinner with an options object.
The options allow one to set the id (as before), spinner size (small or
large), and its display mode (inline or block). Analogic change was made
to $.fn.injectSpinner.
Default options are kept the same as they used to be, and old-style calls
still work. However, the definition of .mw-spinner CSS class has been
changed (although, with a bit of hairy code, it could be kept
compatible...).
These changes should be enough to allow us to replace old usages of
.mw-small-spinner and .mw-ajax-loader classes, as defined in shared.css.
This is a reimplementation of the idea described in Ie55ffb6b.
Copied spinner.gif and ajax-loader.gif from /skins/common/images/.
Change-Id: I0ff71ba1eef299e0e699df84c68f1be1c20492f7
* (bug 39959) Right click to edit section causing browser hangs
The :has() selector has gotten significantly slower in
jQuery 1.8.1 however the reason it affected us so much is
partly because of the very inefficient way we used it.
Namely duplicated 6 times and evaluated from a live() binding
In order words, on every instance of the event.
Optimizing by
- only select headings, do the :has implicitly by checking
for the result of .find().
- document.on(.., selector) instead of .live()
- remove redundant and overkill 'return false'
Results in Firefox 15/Chrome 21:
- up to 130x (one hundred and thirty) faster!
* /resources/* (except for third party libs)
- Use .on() instead of bind, delegate or live
- Use .off() instead of unbind, undelegate or die
- Use document.getElementById instead of $('#' + variable)
not for performance but for predictability/security.
(e.g. rel="foo.bar" should select id="foo.bar" not
id="foo" class="bar")
- Fix some minor whitespace and code conventions.
Change-Id: I2fefb5376d0de40f4997a3a1763eee23fcd3e7fa
Notes:
* JSHint stuff
* Code conventions
* jQuery best practices
* mediawiki.debug:
- Append a text node instead of html. Though .append()
does check if it looks "like" not-html and creates a text
node, this is not more a sanity/security thing than a
reliable documented feature. http://api.jquery.com/append/ :
"HTML string, DOM element(s) or jQuery object".
While at it:
* Update .jshintignore to also cover:
- resources/mediawiki.libs/CLDRPluralRuleParser.js
* Update .jshintrc to set onevar back to true (was set to false
temporarily but not removed).
* Fix files in resources/mediawiki and resources/jquery as well.
These dirs where already covered, perhaps these were missed or
recently introduced, again.
* Add missing dependencies:
jquery.highlightText -> jquery.mwExtension ($.escapeRE)
jquery.tablesorter -> jquery.mwExtension ($.escapeRE)
mediawiki.page.watch.ajax -> jquery.mwExtension ($.escapeRE)
Change-Id: I30a55717d0963ce23e51cef1f1df9e549e4c232e
- Support for multiple messages instead of just one is included.
- Persistent messages are also supported.
- Tagged message replacement is supported so that only one message of a type will show up at once.
- A light flood protection is included to stop all the notifications from disappearing at once.
- Watchlist uses it's own tag now.
- Legacy jsMessage messages still replace each other by using a tag: 'legacy' option
- #mw-js-message was an old id used for something with a completely different style. So rather than re-using it that id is being dropped. Skins can now style the new notifications.
- Core is no longer using messageBox and no extension uses it so instead of making a compatibility layer for it that module is just being dropped.
This is a follow up to I41c70d78.
Change-Id: I2b3d9cbce6d1514d754b4403ec878d89ea6af29d
jQuery 1.8.0 has regression issues where selections with class and id
returned wrong elements (aka: $('#ca-talk.new a'). This patch upgrade
jQuery to 1.8.1 from upstream.
Change-Id: I9db28a52341eef0862aac7e1ae5e4f4e4637fd91
This reverts commit 4dd2c82ff4
As mentioned (on bug 39572) in the mean time, this was not related to the jQuery update. The problems were related to abuse of jsMsg to prepend arbitrary content to the top of the page.
Adding jStorage from http://www.jstorage.info/ to MediaWiki
It's MIT-style licensed and useful for local caching of data.
Adding to .jshintignore since it is a third party library.
Change-Id: I2343744304191d5846cf346e4ac6ca083a6414b3
* 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
to distinguish from attributes i've reversed the order e.g. instead of
html-msg i've used msg-html
i've added the data prefix to allow for html validation.
this is important as an OPTION tag cannot have any children so currently
there is no way to localize it. This provides a route.
Documentation needed.
Change-Id: Iefdbbf0e55ab3c6c6a9564b568980a7319bc4453
* .jshintrc
- Update properties to reflect our conventions more
* Re-pass resources/jquery/*
* Pass resources/mediawiki/*
- Trailing whitespace
- Whitelist the one usage of document.write with
a local /*jshint evil:true */ in the function that
we allow to use it.
- Get rid of dangling _ in var names and undescriptive
instances of '_this'.
- More code conventions
* Add a few documentation comments while at it
Change-Id: Ic4f2b5d473a440667a40e4d5f12f40877386b02f
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
* Added examples of all options (prefix, keys and params)
* Added example of raw attribute being used to bypass escaping
* Added documentation to code where it seemed clarification was needed
* Reduce duplication and simplified some unnecessarily complex statements
* Added test for new placeholder-msg attribute support
* Made adding more attributes in the future easier
* Moved message wrapper function out of the localize function so we aren't defining it each time localize is used
Change-Id: I77593acf4c1b3974d502a1a8382cca9267af2d41
* Upstream https://github.com/jquery/qunit.git
- tag: v1.9.0
- tree: https://github.com/jquery/qunit/tree/v1.9.0
- commit: e36f17de98
* Also update our testrunner.js since the format of
QUnit.config.urlConfig has changed (it is still backwards
compatible, but we might as well use the new format right away,
as it makes the checkboxes look better).
Change-Id: Ia5a9eb7a40a438c126879497ec0dbecbb72e0edb
* .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
* Previously it was hooking into the keypress event, this meant
that it had to do all sorts of calculation to figure out what
the string length would be *after* the to-be-pressed key
is allowed to be pressed. This sounds trivial, but is quite the
contrary. First of all are control, alt, shift etc. those were
covered.
What wasn't covered and imho can't be realistically covered
without bugs is: copy/paste, drag/drop, text selection and
replacing or removing more at once. Or even a combination of the
above. And then there is custom insert methods such as Narayam,
where the character will not be literally inserted at all.
Therefore I've changed it to instead listen to *after* the insert.
and if necessary undo the last (one or more) characters until the
byteLimit is satisfied. This works much more stable. Still very
fast and not noticeable to the user.
This also fixes the bug where when the limit is reached, you
select all and type something else, you couldn't because it would
prevent the keypress since the limit is reached.
* Updated documentation comments.
* Updated unit tests to simulate onkeyup instead of onkeypress.
- hasLimit option in byteLimitTest() was redundant, using limit
directly, instead of duplicating it twice.
- Added more comments and better test names. Tests themselves
have not changed.
- Removed redundant tests at the bottom that no longer make sense
in the new version (and were broken) since the property is
now always unset instead of just if there is a callback.
The native limit must not interfere.
Change-Id: I9ace3ab79f488d24ad13baace32118c151c06347
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