Add a simple hide/show goodie for the TOC in JavaScript.
TODO: toggle the display of 'hide/show' button, save info in cookie.
This commit is contained in:
parent
cf58e51e10
commit
707d559c42
2 changed files with 28 additions and 1 deletions
|
|
@ -1694,7 +1694,9 @@ class Skin {
|
|||
return
|
||||
"<table border=\"0\" bgcolor=\"#8888aa\" cellpadding=\"0\" cellspacing=\"1\"><tr><td>\n" .
|
||||
"<table border=\"0\" bgcolor=\"#f3f3ff\" CELLPADDING=5><tr><td>\n".
|
||||
"<b>".wfMsg("toc")."</b><p>\n".
|
||||
"<b>".wfMsg("toc")."</b>" .
|
||||
" <script type='text/javascript'>showTocToggle(\"" . wfMsg("showtoc") . "\",\"" . wfMsg("hidetoc") . "\")</script>" .
|
||||
"</td></tr><tr id='tocinside'><td>\n".
|
||||
$toc."</td></tr></table></td></tr></table><P>\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ function checkTimezone( tz, msg ) {
|
|||
// in [-][H]H format...
|
||||
// won't yet work with non-even tzs
|
||||
function fetchTimezone() {
|
||||
// FIXME: work around Safari bug
|
||||
var localclock = new Date();
|
||||
// returns negative offset from GMT in minutes
|
||||
var tzRaw = localclock.getTimezoneOffset();
|
||||
|
|
@ -45,3 +46,27 @@ function fetchTimezone() {
|
|||
function guessTimezone(box) {
|
||||
document.preferences.wpHourDiff.value = fetchTimezone();
|
||||
}
|
||||
|
||||
var tocShow, tocHide;
|
||||
function showTocToggle(show,hide) {
|
||||
if(document.getElementById) {
|
||||
document.writeln('<small>[<a href="javascript:toggleToc()" id="toctoggle">' +
|
||||
hide + '/' + show + '</a>]</small>');
|
||||
tocShow = show;
|
||||
tocHide = hide;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleToc() {
|
||||
var toc = document.getElementById('tocinside');
|
||||
var tog = document.getElementById('toctoggle');
|
||||
if(toc.style.display == 'none') {
|
||||
toc.style.display = tocWas;
|
||||
// tog.innerHtml = tocHide;
|
||||
} else {
|
||||
tocWas = toc.style.display;
|
||||
toc.style.display = 'none';
|
||||
// tog.innerHtml = tocShow;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue