diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2007-01-11 19:06:07 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2007-01-11 19:06:07 +0000 |
commit | a58285fd06c8113c45377c655dd43cef6337e815 (patch) | |
tree | dfe31d3d12652352fe44890b4811eda0728faefb /skins/common/wikibits.js | |
parent | 20194986f6638233732ba1fc3e838f117d3cc9ea (diff) |
Aktualisierung auf MediaWiki 1.9.0
Diffstat (limited to 'skins/common/wikibits.js')
-rw-r--r-- | skins/common/wikibits.js | 524 |
1 files changed, 335 insertions, 189 deletions
diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 3a8fd6c6..eabdcbb4 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -5,54 +5,38 @@ var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')= && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1)); var is_safari = ((clientPC.indexOf('applewebkit')!=-1) && (clientPC.indexOf('spoofer')==-1)); var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled )); +// For accesskeys +var is_ff2_win = (clientPC.indexOf('firefox/2')!=-1 || clientPC.indexOf('minefield/3')!=-1) && clientPC.indexOf('windows')!=-1; +var is_ff2_x11 = (clientPC.indexOf('firefox/2')!=-1 || clientPC.indexOf('minefield/3')!=-1) && clientPC.indexOf('x11')!=-1; if (clientPC.indexOf('opera') != -1) { var is_opera = true; var is_opera_preseven = (window.opera && !document.childNodes); var is_opera_seven = (window.opera && document.childNodes); } -// add any onload functions in this hook (please don't hard-code any events in the xhtml source) +// Global external objects used by this script. +/*extern ta, stylepath, skin */ +// add any onload functions in this hook (please don't hard-code any events in the xhtml source) var doneOnloadHook; -if (!window.onloadFuncts) +if (!window.onloadFuncts) { var onloadFuncts = []; +} function addOnloadHook(hookFunct) { // Allows add-on scripts to add onload functions onloadFuncts[onloadFuncts.length] = hookFunct; } -function runOnloadHook() { - // don't run anything below this for non-dom browsers - if (doneOnloadHook || !(document.getElementById && document.getElementsByTagName)) - return; - - histrowinit(); - unhidetzbutton(); - tabbedprefs(); - akeytt(); - scrollEditBox(); - setupCheckboxShiftClick(); - - // Run any added-on functions - for (var i = 0; i < onloadFuncts.length; i++) - onloadFuncts[i](); - - doneOnloadHook = true; -} - function hookEvent(hookName, hookFunct) { - if (window.addEventListener) - addEventListener(hookName, hookFunct, false); - else if (window.attachEvent) - attachEvent("on" + hookName, hookFunct); + if (window.addEventListener) { + window.addEventListener(hookName, hookFunct, false); + } else if (window.attachEvent) { + window.attachEvent("on" + hookName, hookFunct); + } } -//note: all skins shoud call runOnloadHook() at the end of html output, -// so the below should be redundant. It's there just in case. -hookEvent("load", runOnloadHook); - // document.write special stylesheet links if (typeof stylepath != 'undefined' && typeof skin != 'undefined') { if (is_opera_preseven) { @@ -63,9 +47,13 @@ if (typeof stylepath != 'undefined' && typeof skin != 'undefined') { document.write('<link rel="stylesheet" type="text/css" href="'+stylepath+'/'+skin+'/KHTMLFixes.css">'); } } -// Un-trap us from framesets -if (window.top != window) - window.top.location = window.location; + +if (wgBreakFrames) { + // Un-trap us from framesets + if (window.top != window) { + window.top.location = window.location; + } +} // for enhanced RecentChanges function toggleVisibility(_levelId, _otherId, _linkId) { @@ -83,29 +71,13 @@ function toggleVisibility(_levelId, _otherId, _linkId) { } } -// page history stuff -// attach event handlers to the input elements on history page -function histrowinit() { - var hf = document.getElementById('pagehistory'); - if (!hf) - return; - var lis = hf.getElementsByTagName('li'); - for (var i = 0; i < lis.length; i++) { - var inputs = historyRadios(lis[i]); - if (inputs[0] && inputs[1]) { - inputs[0].onclick = diffcheck; - inputs[1].onclick = diffcheck; - } - } - diffcheck(); -} - function historyRadios(parent) { var inputs = parent.getElementsByTagName('input'); var radios = []; for (var i = 0; i < inputs.length; i++) { - if (inputs[i].name == "diff" || inputs[i].name == "oldid") + if (inputs[i].name == "diff" || inputs[i].name == "oldid") { radios[radios.length] = inputs[i]; + } } return radios; } @@ -115,15 +87,17 @@ function diffcheck() { var dli = false; // the li where the diff radio is checked var oli = false; // the li where the oldid radio is checked var hf = document.getElementById('pagehistory'); - if (!hf) + if (!hf) { return true; + } var lis = hf.getElementsByTagName('li'); - for (i=0;i<lis.length;i++) { + for (var i=0;i<lis.length;i++) { var inputs = historyRadios(lis[i]); if (inputs[1] && inputs[0]) { if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button - if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value) + if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value) { return false; + } if (oli) { // it's the second checked radio if (inputs[1].checked) { oli.className = "selected"; @@ -132,23 +106,28 @@ function diffcheck() { } else if (inputs[0].checked) { return false; } - if (inputs[0].checked) + if (inputs[0].checked) { dli = lis[i]; - if (!oli) + } + if (!oli) { inputs[0].style.visibility = 'hidden'; - if (dli) + } + if (dli) { inputs[1].style.visibility = 'hidden'; + } lis[i].className = "selected"; oli = lis[i]; } else { // no radio is checked in this row - if (!oli) + if (!oli) { inputs[0].style.visibility = 'hidden'; - else + } else { inputs[0].style.visibility = 'visible'; - if (dli) + } + if (dli) { inputs[1].style.visibility = 'hidden'; - else + } else { inputs[1].style.visibility = 'visible'; + } lis[i].className = ""; } } @@ -156,38 +135,61 @@ function diffcheck() { return true; } +// page history stuff +// attach event handlers to the input elements on history page +function histrowinit() { + var hf = document.getElementById('pagehistory'); + if (!hf) { + return; + } + var lis = hf.getElementsByTagName('li'); + for (var i = 0; i < lis.length; i++) { + var inputs = historyRadios(lis[i]); + if (inputs[0] && inputs[1]) { + inputs[0].onclick = diffcheck; + inputs[1].onclick = diffcheck; + } + } + diffcheck(); +} + // generate toc from prefs form, fold sections // XXX: needs testing on IE/Mac and safari // more comments to follow function tabbedprefs() { var prefform = document.getElementById('preferences'); - if (!prefform || !document.createElement) + if (!prefform || !document.createElement) { return; - if (prefform.nodeName.toLowerCase() == 'a') + } + if (prefform.nodeName.toLowerCase() == 'a') { return; // Occasional IE problem + } prefform.className = prefform.className + 'jsprefs'; - var sections = new Array(); + var sections = []; var children = prefform.childNodes; var seci = 0; for (var i = 0; i < children.length; i++) { if (children[i].nodeName.toLowerCase() == 'fieldset') { children[i].id = 'prefsection-' + seci; children[i].className = 'prefsection'; - if (is_opera || is_khtml) + if (is_opera || is_khtml) { children[i].className = 'prefsection operaprefsection'; + } var legends = children[i].getElementsByTagName('legend'); - sections[seci] = new Object(); + sections[seci] = {}; legends[0].className = 'mainLegend'; - if (legends[0] && legends[0].firstChild.nodeValue) + if (legends[0] && legends[0].firstChild.nodeValue) { sections[seci].text = legends[0].firstChild.nodeValue; - else + } else { sections[seci].text = '# ' + seci; + } sections[seci].secid = children[i].id; seci++; - if (sections.length != 1) + if (sections.length != 1) { children[i].style.display = 'none'; - else + } else { var selectedid = children[i].id; + } } } var toc = document.createElement('ul'); @@ -195,8 +197,9 @@ function tabbedprefs() { toc.selectedid = selectedid; for (i = 0; i < sections.length; i++) { var li = document.createElement('li'); - if (i == 0) + if (i === 0) { li.className = 'selected'; + } var a = document.createElement('a'); a.href = '#' + sections[i].secid; a.onmousedown = a.onclick = uncoversection; @@ -243,8 +246,9 @@ function checkTimezone(tz, msg) { function unhidetzbutton() { var tzb = document.getElementById('guesstimezonebutton'); - if (tzb) + if (tzb) { tzb.style.display = 'inline'; + } } // in [-]HH:MM format... @@ -269,9 +273,10 @@ function showTocToggle() { if (document.createTextNode) { // Uses DOM calls to avoid document.write + XHTML issues - var linkHolder = document.getElementById('toctitle') - if (!linkHolder) + var linkHolder = document.getElementById('toctitle'); + if (!linkHolder) { return; + } var outerSpan = document.createElement('span'); outerSpan.className = 'toctoggle'; @@ -290,22 +295,24 @@ function showTocToggle() { linkHolder.appendChild(outerSpan); var cookiePos = document.cookie.indexOf("hidetoc="); - if (cookiePos > -1 && document.cookie.charAt(cookiePos + 8) == 1) + if (cookiePos > -1 && document.cookie.charAt(cookiePos + 8) == 1) { toggleToc(); + } } } function changeText(el, newText) { // Safari work around - if (el.innerText) + if (el.innerText) { el.innerText = newText; - else if (el.firstChild && el.firstChild.nodeValue) + } else if (el.firstChild && el.firstChild.nodeValue) { el.firstChild.nodeValue = newText; + } } function toggleToc() { var toc = document.getElementById('toc').getElementsByTagName('ul')[0]; - var toggleLink = document.getElementById('togglelink') + var toggleLink = document.getElementById('togglelink'); if (toc && toggleLink && toc.style.display == 'none') { changeText(toggleLink, tocHideText); @@ -348,7 +355,7 @@ function mwInsertEditButton(parent, item) { image.onclick = function() { insertTags(item.tagOpen, item.tagClose, item.sampleText); return false; - } + }; parent.appendChild(image); return true; @@ -356,20 +363,21 @@ function mwInsertEditButton(parent, item) { function mwSetupToolbar() { var toolbar = document.getElementById('toolbar'); - if (!toolbar) return false; + if (!toolbar) { return false; } var textbox = document.getElementById('wpTextbox1'); - if (!textbox) return false; + if (!textbox) { return false; } // Don't generate buttons for browsers which don't fully // support it. - if (!document.selection && textbox.selectionStart == null) + if (!document.selection && textbox.selectionStart === null) { return false; + } for (var i in mwEditButtons) { mwInsertEditButton(toolbar, mwEditButtons[i]); } - for (var i in mwCustomEditButtons) { + for (i in mwCustomEditButtons) { mwInsertEditButton(toolbar, mwCustomEditButtons[i]); } return true; @@ -386,11 +394,11 @@ function escapeQuotes(text) { function escapeQuotesHTML(text) { var re = new RegExp('&',"g"); text = text.replace(re,"&"); - var re = new RegExp('"',"g"); + re = new RegExp('"',"g"); text = text.replace(re,"""); - var re = new RegExp('<',"g"); + re = new RegExp('<',"g"); text = text.replace(re,"<"); - var re = new RegExp('>',"g"); + re = new RegExp('>',"g"); text = text.replace(re,">"); return text; } @@ -399,19 +407,21 @@ function escapeQuotesHTML(text) { // use sampleText instead of selection if there is none // copied and adapted from phpBB function insertTags(tagOpen, tagClose, sampleText) { - if (document.editform) - var txtarea = document.editform.wpTextbox1; - else { + var txtarea; + if (document.editform) { + txtarea = document.editform.wpTextbox1; + } else { // some alternate form? take the first one we can find var areas = document.getElementsByTagName('textarea'); - var txtarea = areas[0]; + txtarea = areas[0]; } // IE if (document.selection && !is_gecko) { var theSelection = document.selection.createRange().text; - if (!theSelection) + if (!theSelection) { theSelection=sampleText; + } txtarea.focus(); if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any theSelection = theSelection.substring(0, theSelection.length - 1); @@ -425,12 +435,15 @@ function insertTags(tagOpen, tagClose, sampleText) { var replaced = false; var startPos = txtarea.selectionStart; var endPos = txtarea.selectionEnd; - if (endPos-startPos) + if (endPos-startPos) { replaced = true; + } var scrollTop = txtarea.scrollTop; var myText = (txtarea.value).substring(startPos, endPos); - if (!myText) + if (!myText) { myText=sampleText; + } + var subst; if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " "; } else { @@ -455,19 +468,38 @@ function insertTags(tagOpen, tagClose, sampleText) { // bar, but that caused more problems than it solved. } // reposition cursor if possible - if (txtarea.createTextRange) + if (txtarea.createTextRange) { txtarea.caretPos = document.selection.createRange().duplicate(); + } } -function akeytt() { - if (typeof ta == "undefined" || !ta) +/** + * Set up accesskeys/tooltips. If doId is specified, only set up for that id. + * + * @param mixed doId string or null + */ +function akeytt( doId ) { + if (typeof ta == "undefined" || !ta) { return; - var pref = 'alt-'; + } + + var pref; if (is_safari || navigator.userAgent.toLowerCase().indexOf('mac') + 1 - || navigator.userAgent.toLowerCase().indexOf('konqueror') + 1 ) + || navigator.userAgent.toLowerCase().indexOf('konqueror') + 1 ) { pref = 'control-'; - if (is_opera) + } else if (is_opera) { pref = 'shift-esc-'; + } else if (is_ff2_x11) { + pref = 'ctrl-shift-'; + } else if (is_ff2_win) { + pref = 'alt-shift-'; + } else { + pref = 'alt-'; + } + + if ( doId ) { + ta = [ta[doId]]; + } for (var id in ta) { var n = document.getElementById(id); @@ -483,8 +515,10 @@ function akeytt() { } else { a = n.childNodes[0]; } - - if (a) { + // Don't add an accesskey for the watch tab if the watch + // checkbox is also available. + if (a && ((id != 'ca-watch' && id != 'ca-unwatch') || + !(window.location.search.match(/[\?&](action=edit|action=submit)/i)))) { a.accessKey = ta[id][0]; ak = ' ['+pref+ta[id][0]+']'; } @@ -503,9 +537,9 @@ function akeytt() { function setupRightClickEdit() { if (document.getElementsByTagName) { - var divs = document.getElementsByTagName('div'); - for (var i = 0; i < divs.length; i++) { - var el = divs[i]; + var spans = document.getElementsByTagName('span'); + for (var i = 0; i < spans.length; i++) { + var el = spans[i]; if(el.className == 'editsection') { addRightClickEditHandler(el); } @@ -518,23 +552,31 @@ function addRightClickEditHandler(el) { var link = el.childNodes[i]; if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { var editHref = link.getAttribute('href'); - - // find the following a - var next = el.nextSibling; - while (next.nodeType != 1) - next = next.nextSibling; - - // find the following header - next = next.nextSibling; - while (next.nodeType != 1) - next = next.nextSibling; - - if (next && next.nodeType == 1 && - next.nodeName.match(/^[Hh][1-6]$/)) { - next.oncontextmenu = function() { - document.location = editHref; - return false; - } + // find the enclosing (parent) header + var prev = el.parentNode; + if (prev && prev.nodeType == 1 && + prev.nodeName.match(/^[Hh][1-6]$/)) { + prev.oncontextmenu = function(e) { + if (!e) { e = window.event; } + // e is now the event in all browsers + var targ; + if (e.target) { targ = e.target; } + else if (e.srcElement) { targ = e.srcElement; } + if (targ.nodeType == 3) { // defeat Safari bug + targ = targ.parentNode; + } + // targ is now the target element + + // We don't want to deprive the noble reader of a context menu + // for the section edit link, do we? (Might want to extend this + // to all <a>'s?) + if (targ.nodeName.toLowerCase() != 'a' + || targ.parentNode.className != 'editsection') { + document.location = editHref; + return false; + } + return true; + }; } } } @@ -613,22 +655,25 @@ function checkboxMouseupHandler(e) { } function toggle_element_activation(ida,idb) { - if (!document.getElementById) + if (!document.getElementById) { return; + } document.getElementById(ida).disabled=true; document.getElementById(idb).disabled=false; } function toggle_element_check(ida,idb) { - if (!document.getElementById) + if (!document.getElementById) { return; + } document.getElementById(ida).checked=true; document.getElementById(idb).checked=false; } function fillDestFilename(id) { - if (!document.getElementById) + if (!document.getElementById) { return; + } var path = document.getElementById(id).value; // Find trailing part var slash = path.lastIndexOf('/'); @@ -647,25 +692,30 @@ function fillDestFilename(id) { // Output result var destFile = document.getElementById('wpDestFile'); - if (destFile) + if (destFile) { destFile.value = fname; + } } function considerChangingExpiryFocus() { - if (!document.getElementById) + if (!document.getElementById) { return; + } var drop = document.getElementById('wpBlockExpiry'); - if (!drop) + if (!drop) { return; + } var field = document.getElementById('wpBlockOther'); - if (!field) + if (!field) { return; + } var opt = drop.value; - if (opt == 'other') + if (opt == 'other') { field.style.display = ''; - else + } else { field.style.display = 'none'; + } } function scrollEditBox() { @@ -674,91 +724,187 @@ function scrollEditBox() { var editFormEl = document.getElementById("editform"); if (editBoxEl && scrollTopEl) { - if (scrollTopEl.value) editBoxEl.scrollTop = scrollTopEl.value; + if (scrollTopEl.value) { editBoxEl.scrollTop = scrollTopEl.value; } editFormEl.onsubmit = function() { document.getElementById("wpScrolltop").value = document.getElementById("wpTextbox1").scrollTop; - } + }; } } hookEvent("load", scrollEditBox); +var allmessages_nodelist = false; +var allmessages_modified = false; +var allmessages_timeout = false; +var allmessages_running = false; + +function allmessagesmodified() { + allmessages_modified = !allmessages_modified; + allmessagesfilter(); +} + function allmessagesfilter() { - text = document.getElementById('allmessagesinput').value; - k = document.getElementById('allmessagestable'); - if (!k) { return;} + if ( allmessages_timeout ) + window.clearTimeout( allmessages_timeout ); - var items = k.getElementsByTagName('span'); + if ( !allmessages_running ) + allmessages_timeout = window.setTimeout( 'allmessagesfilter_do();', 500 ); +} - if ( text.length > allmessages_prev.length ) { - for (var i = items.length-1, j = 0; i >= 0; i--) { - j = allmessagesforeach(items, i, j); - } - } else { - for (var i = 0, j = 0; i < items.length; i++) { - j = allmessagesforeach(items, i, j); - } +function allmessagesfilter_do() { + if ( !allmessages_nodelist ) + return; + + var text = document.getElementById('allmessagesinput').value; + var nodef = allmessages_modified; + + allmessages_running = true; + + for ( var name in allmessages_nodelist ) { + var nodes = allmessages_nodelist[name]; + var display = ( name.indexOf( text ) == -1 ? 'none' : '' ); + + for ( var i = 0; i < nodes.length; i++) + nodes[i].style.display = + ( nodes[i].className == "def" && nodef + ? 'none' : display ); } - allmessages_prev = text; + + if ( text != document.getElementById('allmessagesinput').value || + nodef != allmessages_modified ) + allmessagesfilter_do(); // repeat + + allmessages_running = false; } -function allmessagesforeach(items, i, j) { - var hItem = items[i].getAttribute('id'); - if (hItem.substring(0,17) == 'sp-allmessages-i-') { - if (items[i].firstChild && items[i].firstChild.nodeName == '#text' && items[i].firstChild.nodeValue.indexOf(text) != -1) { - var itemA = document.getElementById( hItem.replace('i', 'r1') ); - var itemB = document.getElementById( hItem.replace('i', 'r2') ); - if ( itemA.style.display != '' ) { - var s = "allmessageshider(\"" + hItem.replace('i', 'r1') + "\", \"" + hItem.replace('i', 'r2') + "\", '')"; - var k = window.setTimeout(s,j++*5); - } - } else { - var itemA = document.getElementById( hItem.replace('i', 'r1') ); - var itemB = document.getElementById( hItem.replace('i', 'r2') ); - if ( itemA.style.display != 'none' ) { - var s = "allmessageshider(\"" + hItem.replace('i', 'r1') + "\", \"" + hItem.replace('i', 'r2') + "\", 'none')"; - var k = window.setTimeout(s,j++*5); +function allmessagesfilter_init() { + if ( allmessages_nodelist ) + return; + + var nodelist = new Array(); + var templist = new Array(); + + var table = document.getElementById('allmessagestable'); + if ( !table ) return; + + var rows = document.getElementsByTagName('tr'); + for ( var i = 0; i < rows.length; i++ ) { + var id = rows[i].getAttribute('id') + if ( id && id.substring(0,16) != 'sp-allmessages-r' ) continue; + templist[ id ] = rows[i]; + } + + var spans = table.getElementsByTagName('span'); + for ( var i = 0; i < spans.length; i++ ) { + var id = spans[i].getAttribute('id') + if ( id && id.substring(0,17) != 'sp-allmessages-i-' ) continue; + if ( !spans[i].firstChild || spans[i].firstChild.nodeType != 3 ) continue; + + var nodes = new Array(); + var row1 = templist[ id.replace('i', 'r1') ]; + var row2 = templist[ id.replace('i', 'r2') ]; + + if ( row1 ) nodes[nodes.length] = row1; + if ( row2 ) nodes[nodes.length] = row2; + nodelist[ spans[i].firstChild.nodeValue ] = nodes; + } + + var k = document.getElementById('allmessagesfilter'); + if (k) { k.style.display = ''; } + + allmessages_nodelist = nodelist; +} + +hookEvent( "load", allmessagesfilter_init ); + +/* + Written by Jonathan Snook, http://www.snook.ca/jonathan + Add-ons by Robert Nyman, http://www.robertnyman.com + Author says "The credit comment is all it takes, no license. Go crazy with it!:-)" + From http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ +*/ +function getElementsByClassName(oElm, strTagName, oClassNames){ + var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); + var arrReturnElements = new Array(); + var arrRegExpClassNames = new Array(); + if(typeof oClassNames == "object"){ + for(var i=0; i<oClassNames.length; i++){ + arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)")); + } + } + else{ + arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)")); + } + var oElement; + var bMatchesAll; + for(var j=0; j<arrElements.length; j++){ + oElement = arrElements[j]; + bMatchesAll = true; + for(var k=0; k<arrRegExpClassNames.length; k++){ + if(!arrRegExpClassNames[k].test(oElement.className)){ + bMatchesAll = false; + break; } } + if(bMatchesAll){ + arrReturnElements.push(oElement); + } } - return j; + return (arrReturnElements) } - -function allmessageshider(idA, idB, cstyle) { - var itemA = document.getElementById( idA ); - var itemB = document.getElementById( idB ); - if (itemA) { itemA.style.display = cstyle; } - if (itemB) { itemB.style.display = cstyle; } +function sortableTables() { + if (getElementsByClassName(document, "table", "sortable").length != 0) { + document.write('<script type="text/javascript" src="'+stylepath+'/common/sorttable.js"></script>'); + } } -function allmessagesmodified() { - allmessages_modified = !allmessages_modified; - k = document.getElementById('allmessagestable'); - if (!k) { return;} - var items = k.getElementsByTagName('tr'); - for (var i = 0, j = 0; i< items.length; i++) { - if (!allmessages_modified ) { - if ( items[i].style.display != '' ) { - var s = "allmessageshider(\"" + items[i].getAttribute('id') + "\", null, '')"; - var k = window.setTimeout(s,j++*5); - } - } else if (items[i].getAttribute('class') == 'def' && allmessages_modified) { - if ( items[i].style.display != 'none' ) { - var s = "allmessageshider(\"" + items[i].getAttribute('id') + "\", null, 'none')"; - var k = window.setTimeout(s,j++*5); - } +function redirectToFragment(fragment) { + var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/); + if (match) { + var webKitVersion = parseInt(match[1]); + if (webKitVersion < 420) { + // Released Safari w/ WebKit 418.9.1 messes up horribly + // Nightlies of 420+ are ok + return; } } + if (is_gecko) { + // Mozilla needs to wait until after load, otherwise the window doesn't scroll + addOnloadHook(function () { + if (window.location.hash == "") + window.location.hash = fragment; + }); + } else { + if (window.location.hash == "") + window.location.hash = fragment; + } } -function allmessagesshow() { - k = document.getElementById('allmessagesfilter'); - if (k) { k.style.display = ''; } +function runOnloadHook() { + // don't run anything below this for non-dom browsers + if (doneOnloadHook || !(document.getElementById && document.getElementsByTagName)) { + return; + } + + histrowinit(); + unhidetzbutton(); + tabbedprefs(); + akeytt( null ); + scrollEditBox(); + setupCheckboxShiftClick(); + sortableTables(); - allmessages_prev = ''; - allmessages_modified = false; + // Run any added-on functions + for (var i = 0; i < onloadFuncts.length; i++) { + onloadFuncts[i](); + } + + doneOnloadHook = true; } -hookEvent("load", allmessagesshow); +//note: all skins should call runOnloadHook() at the end of html output, +// so the below should be redundant. It's there just in case. +hookEvent("load", runOnloadHook); + hookEvent("load", mwSetupToolbar); |