mediawiki.special.preferences: Support Back/Forward navigation
authorJoan Creus <joan.creus.c@gmail.com>
Sat, 14 Apr 2012 06:45:06 +0000 (08:45 +0200)
committerTimo Tijhof <ttijhof@wikimedia.org>
Fri, 29 Jun 2012 02:05:49 +0000 (04:05 +0200)
commit317bbf8c4b5109aa8ed5924a588d92507ce22bf8
tree7b8cda0856a2ac6c03372f2e74671cec3bf1fe82
parent26eae98f7f7fc543088c2a36d070687571ab89b6
mediawiki.special.preferences: Support Back/Forward navigation

The current preferences tabbed dialog already uses hashes to identify
different tab sections, but using the browser's Back or Forward
button had no effect.

Added an event listener to the browser 'hashchange' event, so
that when the hash changes (as a result of using Back/Forward), the
display switched to the desired section.

If on the 'hashchange' event the hash is empty, it opens up the first
tab (just like the default when loading plain Special:Preferences
without a hash).

If the hash does not correspond to any section, nothing happens (this
can happen when the user follows an old hash-link to an tab that no
longer exists, in that case we need not do anything as the first tab
is visible by default). Another thing that can cause this is when the
page is already opened and some other component is using the hashes
for something. So we don't want to force a switch to the first tab
either.

Removed duplication of code by introducing function switchPrefTab().

Tested:
- Loading to a hash value
- Switching tabs
- Pressing Back/Forward
in:
* Chrome 19: OK
* Safari 5.1: OK
* Firefox 12: OK
* Opera 11.1: OK
* Opera 11.5: OK
* Opera 11.6: OK

Change-Id: Ic51c3954884680496f76814eed3fe65c9d0daacc
resources/mediawiki.special/mediawiki.special.preferences.js