From a58285fd06c8113c45377c655dd43cef6337e815 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 11 Jan 2007 19:06:07 +0000 Subject: Aktualisierung auf MediaWiki 1.9.0 --- skins/common/ajax.js | 11 +- skins/common/ajaxwatch.js | 127 +++++++++ skins/common/cologneblue.css | 8 +- skins/common/common.css | 99 ++++--- skins/common/commonPrint.css | 22 +- skins/common/common_rtl.css | 13 + skins/common/images/sort_down.gif | Bin 0 -> 879 bytes skins/common/images/sort_none.gif | Bin 0 -> 877 bytes skins/common/images/sort_up.gif | Bin 0 -> 881 bytes skins/common/nostalgia.css | 1 - skins/common/sorttable.js | 359 ++++++++++++++++++++++++++ skins/common/wikibits.js | 524 ++++++++++++++++++++++++-------------- skins/common/wikistandard.css | 8 +- 13 files changed, 931 insertions(+), 241 deletions(-) create mode 100644 skins/common/ajaxwatch.js create mode 100644 skins/common/images/sort_down.gif create mode 100644 skins/common/images/sort_none.gif create mode 100644 skins/common/images/sort_up.gif create mode 100644 skins/common/sorttable.js (limited to 'skins/common') diff --git a/skins/common/ajax.js b/skins/common/ajax.js index 6cc652b3..40065593 100644 --- a/skins/common/ajax.js +++ b/skins/common/ajax.js @@ -75,7 +75,7 @@ function sajax_do_call(func_name, args, target) { var i, x, n; var uri; var post_data; - uri = wgServer + "/" + wgScriptPath + "/index.php?action=ajax"; + uri = wgServer + wgScriptPath + "/index.php?action=ajax"; if (sajax_request_type == "GET") { if (uri.indexOf("?") == -1) uri = uri + "?rs=" + encodeURIComponent(func_name); @@ -96,7 +96,14 @@ function sajax_do_call(func_name, args, target) { return false; } - x.open(sajax_request_type, uri, true); + try { + x.open(sajax_request_type, uri, true); + } catch (e) { + if (window.location.hostname == "localhost") { + alert("Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing."); + } + throw e; + } if (sajax_request_type == "POST") { x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1"); x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); diff --git a/skins/common/ajaxwatch.js b/skins/common/ajaxwatch.js new file mode 100644 index 00000000..16e4fdc4 --- /dev/null +++ b/skins/common/ajaxwatch.js @@ -0,0 +1,127 @@ +// dependencies: +// * ajax.js: + /*extern sajax_init_object, sajax_do_call */ +// * wikibits.js: + /*extern changeText, akeytt, hookEvent */ + +// These should have been initialized in the generated js +/*extern wgAjaxWatch, wgArticleId */ + +if(typeof wgAjaxWatch === "undefined" || !wgAjaxWatch) { + var wgAjaxWatch = { + watchMsg: "Watch", + unwatchMsg: "Unwatch", + watchingMsg: "Watching...", + unwatchingMsg: "Unwatching..." + }; +} + +wgAjaxWatch.supported = true; // supported on current page and by browser +wgAjaxWatch.watching = false; // currently watching page +wgAjaxWatch.inprogress = false; // ajax request in progress +wgAjaxWatch.timeoutID = null; // see wgAjaxWatch.ajaxCall +wgAjaxWatch.watchLink1 = null; // "watch"/"unwatch" link +wgAjaxWatch.watchLink2 = null; // second one, for (some?) non-Monobook-based +wgAjaxWatch.oldHref = null; // url for action=watch/action=unwatch + +wgAjaxWatch.setLinkText = function(newText) { + changeText(wgAjaxWatch.watchLink1, newText); + if (wgAjaxWatch.watchLink2) { + changeText(wgAjaxWatch.watchLink2, newText); + } +}; + +wgAjaxWatch.setLinkID = function(newId) { + wgAjaxWatch.watchLink1.id = newId; + akeytt(newId); // update tooltips for Monobook +}; + +wgAjaxWatch.ajaxCall = function() { + if(!wgAjaxWatch.supported || wgAjaxWatch.inprogress) { + return; + } + wgAjaxWatch.inprogress = true; + wgAjaxWatch.setLinkText(wgAjaxWatch.watching ? wgAjaxWatch.unwatchingMsg : wgAjaxWatch.watchingMsg); + sajax_do_call("wfAjaxWatch", [wgArticleId, (wgAjaxWatch.watching ? "u" : "w")], wgAjaxWatch.processResult); + // if the request isn't done in 10 seconds, allow user to try again + wgAjaxWatch.timeoutID = window.setTimeout(function() { wgAjaxWatch.inprogress = false; }, 10000); + return; +}; + +wgAjaxWatch.processResult = function(request) { + if(!wgAjaxWatch.supported) { + return; + } + var response = request.responseText; + if(response == "") { + window.location.href = wgAjaxWatch.oldHref; + return; + } else if(response == "") { + wgAjaxWatch.watching = true; + wgAjaxWatch.setLinkText(wgAjaxWatch.unwatchMsg); + wgAjaxWatch.setLinkID("ca-unwatch"); + wgAjaxWatch.oldHref = wgAjaxWatch.oldHref.replace(/action=watch/, "action=unwatch"); + } else if(response == "") { + wgAjaxWatch.watching = false; + wgAjaxWatch.setLinkText(wgAjaxWatch.watchMsg); + wgAjaxWatch.setLinkID("ca-watch"); + wgAjaxWatch.oldHref = wgAjaxWatch.oldHref.replace(/action=unwatch/, "action=watch"); + } + wgAjaxWatch.inprogress = false; + if(wgAjaxWatch.timeoutID) { + window.clearTimeout(wgAjaxWatch.timeoutID); + } + return; +}; + +wgAjaxWatch.onLoad = function() { + var el1 = document.getElementById("ca-unwatch"); + var el2 = null; + if (!el1) { + el1 = document.getElementById("mw-unwatch-link1"); + el2 = document.getElementById("mw-unwatch-link2"); + } + if(el1) { + wgAjaxWatch.watching = true; + } else { + wgAjaxWatch.watching = false; + el1 = document.getElementById("ca-watch"); + if (!el1) { + el1 = document.getElementById("mw-watch-link1"); + el2 = document.getElementById("mw-watch-link2"); + } + if(!el1) { + wgAjaxWatch.supported = false; + return; + } + } + + if(!wfSupportsAjax()) { + wgAjaxWatch.supported = false; + return; + } + + // The id can be either for the parent (Monobook-based) or the element + // itself (non-Monobook) + wgAjaxWatch.watchLink1 = el1.tagName.toLowerCase() == "a" ? el1 : el1.firstChild; + wgAjaxWatch.watchLink2 = el2 ? el2 : null; + + wgAjaxWatch.oldHref = wgAjaxWatch.watchLink1.getAttribute("href"); + wgAjaxWatch.watchLink1.setAttribute("href", "javascript:wgAjaxWatch.ajaxCall()"); + if (wgAjaxWatch.watchLink2) { + wgAjaxWatch.watchLink2.setAttribute("href", "javascript:wgAjaxWatch.ajaxCall()"); + } + return; +}; + +hookEvent("load", wgAjaxWatch.onLoad); + +/** + * @return boolean whether the browser supports XMLHttpRequest + */ +function wfSupportsAjax() { + var request = sajax_init_object(); + var supportsAjax = request ? true : false; + delete request; + return supportsAjax; +} \ No newline at end of file diff --git a/skins/common/cologneblue.css b/skins/common/cologneblue.css index 33c12abb..5b6e5bca 100644 --- a/skins/common/cologneblue.css +++ b/skins/common/cologneblue.css @@ -1,5 +1,3 @@ -@import url("common.css?2"); - body { margin: 0px; padding: 0px; color: black; } #specialform { display: inline; } #content { top: 0; margin: 0; padding: 0; } @@ -78,8 +76,9 @@ td.bottom { h1 { color: #666666; font-family: Verdana, Arial, sans-serif; - font-size: 18pt; font-weight: bold; line-height: 21pt; + font-size: 180%; line-height: 21pt; } +h1 .editsection { font-size: 55.6%; } h1.pagetitle { padding-bottom: 0; margin-bottom: 0; } #article p.subtitle { color: #666666; font-size: 11pt; font-weight: bold; @@ -93,4 +92,5 @@ a.printable { text-decoration: underline; } a.stub, #quickbar a.stub { color:#772233; text-decoration:none; } a.new, #quickbar a.new { color: #CC2200; } h2, h3, h4, h5, h6 { margin-bottom: 0; } -small { font-size: 75%; } \ No newline at end of file +small { font-size: 75%; } +input.mw-searchInput { width: 106px; } \ No newline at end of file diff --git a/skins/common/common.css b/skins/common/common.css index e630b77e..f3e5b574 100644 --- a/skins/common/common.css +++ b/skins/common/common.css @@ -2,11 +2,36 @@ * common.css * This file contains CSS settings common to Wikistandard, Nostalgia and CologneBlue */ + +/* For clarity, explicitly state some recommendations from to make sure the editsection links scale right */ + +h1 { font-size: 2em; } +h2 { font-size: 1.5em; } +h3 { font-size: 1.17em; } +h5 { font-size: .83em; } +h6 { font-size: .75em; } +h1, h2, h3, h4, h5, h6 { font-weight: bolder } + +/* Now the custom parts */ + +/* Make edit sections (which are inside h# tags) normal-sized */ +.editsection { + font-weight: normal; + float: right; + margin-left: 5px; +} +h1 .editsection { font-size: 50% } +h2 .editsection { font-size: 66.7% } +h3 .editsection { font-size: 85.5% } +h5 .editsection { font-size: 120% } +h6 .editsection { font-size: 133% } + #footer { clear: both } /* images */ -div.floatright { float: right; margin: 0 0 1em 1em; } +div.floatright { float: right; clear: right; margin: 0 0 1em 1em; } div.floatright p { font-style: italic; } -div.floatleft { float: left; margin: 0.3em 0.5em 0.5em 0; } +div.floatleft { float: left; clear: left; margin: 0.3em 0.5em 0.5em 0; } div.floatleft p { font-style: italic; } @@ -26,43 +51,49 @@ table.rimage { /* thumbnails */ div.thumb { - margin: 10px; - text-align: center; - width: auto; -} -div.thumb div { - border: 1px solid #8888aa; - background-color: #f7f8ff; - padding: 2px; - font-size: 94%; - text-align: center; - overflow: hidden; + margin-bottom: .5em; + border-style: solid; + border-color: white; + width: auto; +} +div.thumbinner { + border: 1px solid #ccc; + padding: 3px !important; + background-color: #f9f9f9; + font-size: 94%; + text-align: center; + overflow: hidden; } -div.thumb div * { - border: none; - background: none; +html .thumbimage { + border: 1px solid #ccc; } -div.thumb img { - border:1px solid #8888AA; - margin-bottom:3px; - background:#FFFFFF; +html .thumbcaption { + border: none; + text-align: left; + line-height: 1.4em; + padding: 3px !important; + font-size: 94%; } -div.thumbcaption, -div.thumbcaption * { - border: none !important; - background: none !important; +div.magnify { + float: right; + border: none !important; + background: none !important; } -div.thumbcaption { - padding: 0.2em 0 0.2em 0 !important; - text-align: left !important; +div.magnify a, div.magnify img { + display: block; + border: none !important; + background: none !important; } div.tright { - float: right; - margin-left:0.5em; + clear: right; + float: right; + border-width: .5em 0 .8em 1.4em; } div.tleft { - float: left; - margin-right:0.5em; + float: left; + clear: left; + margin-right: .5em; + border-width: .5em 1.4em .8em 0; } /* Page history styling */ @@ -314,7 +345,6 @@ li span.deleted { font-style: italic; } - /* Classes for EXIF data display */ table.mw_metadata { margin-left: 0.5em; @@ -430,3 +460,8 @@ table.multipageimage td { .imagelist .TablePager_col_img_description { white-space: normal } .imagelist th.TablePager_sort { background-color: #ccccff } +.templatesUsed { margin-top: 1em; } + +#toolbar { clear: both; } + +.mw-plusminus-null { color: #aaa; } \ No newline at end of file diff --git a/skins/common/commonPrint.css b/skins/common/commonPrint.css index 7dcb5700..992ac4db 100644 --- a/skins/common/commonPrint.css +++ b/skins/common/commonPrint.css @@ -22,13 +22,11 @@ a.new{ color:#ba0000; text-decoration:none; } .tocline { margin-bottom: 0px; } -.toctoggle, .editsection { - font-size: smaller; -} /* images */ div.floatright { - float: right; + float: right; + clear: right; margin: 0; position:relative; border: 0.5em solid White; @@ -67,6 +65,7 @@ div.thumb div div.thumbcaption { div.magnify { display: none; } div.tright { float: right; + clear: right; border-width: 0.5em 0 0.8em 1.4em; } div.tleft { @@ -103,10 +102,10 @@ div#column-one, .tochidden, div#f-poweredbyico, div#f-copyrightico, -li#f-viewcount, -li#f-about, -li#f-disclaimer, -li#f-privacy { +li#viewcount, +li#about, +li#disclaimer, +li#privacy { /* Hides all the elements irrelevant for printing */ display: none; } @@ -130,12 +129,12 @@ ul { h1, h2, h3, h4, h5, h6 { - font-weight: bold; + font-weight: bold; } p, .documentDescription { margin: 1em 0 ! important; - line-height: 1.2em; + line-height: 1.2em; } .tocindent p { @@ -160,7 +159,8 @@ table.listing td { a { color: Black !important; - padding: 0 !important + background: none !important; + padding: 0 !important; } a:link, a:visited { diff --git a/skins/common/common_rtl.css b/skins/common/common_rtl.css index 8f50b2ab..54186bb8 100644 --- a/skins/common/common_rtl.css +++ b/skins/common/common_rtl.css @@ -1,3 +1,6 @@ +/* This CSS file is called from absolutely every wiki that's RTL: unlike + * common.css, it's actually common to all skins. */ + /* js pref toc */ #preftoc { float: right; } /* workaround for moz bug, displayed bullets on left side */ @@ -13,3 +16,13 @@ fieldset.operaprefsection { margin-right: 1.4em; margin-left: 0.4em; } +.editsection { + float: left; + margin-right: 5px; +} +div.tright, div.floatright { + clear: none; +} +div.tleft, div.floatleft { + clear: left; +} \ No newline at end of file diff --git a/skins/common/images/sort_down.gif b/skins/common/images/sort_down.gif new file mode 100644 index 00000000..5ff08160 Binary files /dev/null and b/skins/common/images/sort_down.gif differ diff --git a/skins/common/images/sort_none.gif b/skins/common/images/sort_none.gif new file mode 100644 index 00000000..6bb02824 Binary files /dev/null and b/skins/common/images/sort_none.gif differ diff --git a/skins/common/images/sort_up.gif b/skins/common/images/sort_up.gif new file mode 100644 index 00000000..53002968 Binary files /dev/null and b/skins/common/images/sort_up.gif differ diff --git a/skins/common/nostalgia.css b/skins/common/nostalgia.css index cc427bc9..c9b36a70 100644 --- a/skins/common/nostalgia.css +++ b/skins/common/nostalgia.css @@ -1,4 +1,3 @@ -@import url("common.css?1"); body { /* Background color is set separately on page type */ color: black; diff --git a/skins/common/sorttable.js b/skins/common/sorttable.js new file mode 100644 index 00000000..24877865 --- /dev/null +++ b/skins/common/sorttable.js @@ -0,0 +1,359 @@ +/* + * Table sorting script by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/. + * Based on a script from http://www.kryogenix.org/code/browser/sorttable/. + * Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html . + * + * Copyright (c) 1997-2006 Stuart Langridge, Joost de Valk. + * + * @todo don't break on colspans/rowspans (bug 8028) + * @todo language-specific digit grouping/decimals (bug 8063) + * @todo support all accepted date formats (bug 8226) + */ + +var image_path = stylepath+"/common/images/"; +var image_up = "sort_up.gif"; +var image_down = "sort_down.gif"; +var image_none = "sort_none.gif"; +var europeandate = wgContentLanguage != "en"; // The non-American-inclined can change to "true" + +var alternate_row_colors = true; + + +hookEvent( "load", sortables_init); + +var SORT_COLUMN_INDEX; +var thead = false; + +function sortables_init() { + var idnum = 0; + // Find all tables with class sortable and make them sortable + if (!document.getElementsByTagName) return; + tbls = document.getElementsByTagName("table"); + for (ti=0;ti 0) { + if (table.tHead && table.tHead.rows.length > 0) { + var firstRow = table.tHead.rows[table.tHead.rows.length-1]; + thead = true; + } else { + var firstRow = table.rows[0]; + } + } + if (!firstRow) return; + + // We have a first row: assume it's the header, and make its contents clickable links + for (var i=0;i↓'; + } + } + if (alternate_row_colors) { + alternate(table); + } +} + +function ts_getInnerText(el) { + if (typeof el == "string") return el; + if (typeof el == "undefined") { return el }; + if (el.innerText) return el.innerText; //Not needed but it is faster + var str = ""; + + var cs = el.childNodes; + var l = cs.length; + for (var i = 0; i < l; i++) { + switch (cs[i].nodeType) { + case 1: //ELEMENT_NODE + str += ts_getInnerText(cs[i]); + break; + case 3: //TEXT_NODE + str += cs[i].nodeValue; + break; + } + } + return str; +} + +function ts_resortTable(lnk) { + // get the span + var span; + for (var ci=0;ci)*$/); i++) { + var itm = ts_getInnerText(table.tBodies[0].rows[i].cells[column]); + itm = trim(itm); + } + sortfn = ts_sort_caseinsensitive; + if (itm.match(/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/)) sortfn = ts_sort_date; + if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/)) sortfn = ts_sort_date; + if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d$/)) sortfn = ts_sort_date; + if (itm.match(/^[£$€Û¢´]/)) sortfn = ts_sort_currency; + if (itm.match(/^[\d.,]+\%?$/)) sortfn = ts_sort_numeric; + SORT_COLUMN_INDEX = column; + var firstRow = new Array(); + var newRows = new Array(); + + for (k=0;k'; + newRows.reverse(); + span.setAttribute('sortdir','up'); + } else { + ARROW = '↑'; + span.setAttribute('sortdir','down'); + } + + // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones + // don't do sortbottom rows + for (i=0; i'; + } + } + } + + span.innerHTML = ARROW; + alternate(table); +} + +function getParent(el, pTagName) { + if (el == null) { + return null; + } else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) { // Gecko bug, supposed to be uppercase + return el; + } else { + return getParent(el.parentNode, pTagName); + } +} + +function sort_date(date) { + // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX + dt = "00000000"; + if (date.length == 11) { + monthstr = date.substr(3,3); + monthstr = monthstr.toLowerCase(); + switch(monthstr) { + case "jan": var month = "01"; break; + case "feb": var month = "02"; break; + case "mar": var month = "03"; break; + case "apr": var month = "04"; break; + case "may": var month = "05"; break; + case "jun": var month = "06"; break; + case "jul": var month = "07"; break; + case "aug": var month = "08"; break; + case "sep": var month = "09"; break; + case "oct": var month = "10"; break; + case "nov": var month = "11"; break; + case "dec": var month = "12"; break; + // default: var month = "00"; + } + dt = date.substr(7,4)+month+date.substr(0,2); + return dt; + } else if (date.length == 10) { + if (europeandate == false) { + dt = date.substr(6,4)+date.substr(0,2)+date.substr(3,2); + return dt; + } else { + dt = date.substr(6,4)+date.substr(3,2)+date.substr(0,2); + return dt; + } + } else if (date.length == 8) { + yr = date.substr(6,2); + if (parseInt(yr) < 50) { + yr = '20'+yr; + } else { + yr = '19'+yr; + } + if (europeandate == true) { + dt = yr+date.substr(3,2)+date.substr(0,2); + return dt; + } else { + dt = yr+date.substr(0,2)+date.substr(3,2); + return dt; + } + } + return dt; +} + +function ts_sort_date(a,b) { + dt1 = sort_date(ts_getInnerText(a.cells[SORT_COLUMN_INDEX])); + dt2 = sort_date(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); + + if (dt1==dt2) { + return 0; + } + if (dt1)*/, "").replace(/([ \t]|\n|\ |)*$/, ""); +} + +function alternate(table) { + // Take object table and get all it's tbodies. + var tableBodies = table.getElementsByTagName("tbody"); + // Loop through these tbodies + for (var i = 0; i < tableBodies.length; i++) { + // Take the tbody, and get all it's rows + var tableRows = tableBodies[i].getElementsByTagName("tr"); + // Loop through these rows + // Start at 1 because we want to leave the heading row untouched + for (var j = 0; j < tableRows.length; j++) { + // Check if j is even, and apply classes for both possible results + if ( (j % 2) == 0 ) { + if ( !(tableRows[j].className.indexOf('odd') == -1) ) { + tableRows[j].className = replace(tableRows[j].className, 'odd', 'even'); + } else { + if ( tableRows[j].className.indexOf('even') == -1 ) { + tableRows[j].className += " even"; + } + } + } else { + if ( !(tableRows[j].className.indexOf('even') == -1) ) { + tableRows[j].className = replace(tableRows[j].className, 'even', 'odd'); + } else { + if ( tableRows[j].className.indexOf('odd') == -1 ) { + tableRows[j].className += " odd"; + } + } + } + } + } +} 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(''); } } -// 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 -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 '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'); + } } -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); diff --git a/skins/common/wikistandard.css b/skins/common/wikistandard.css index 3985f1d9..532e4fdc 100644 --- a/skins/common/wikistandard.css +++ b/skins/common/wikistandard.css @@ -1,5 +1,3 @@ -@import url("common.css?1"); - #article { padding: 4px; } #content { margin: 0; padding: 0; } #footer { padding: 4px;font-size:95%;clear: both; } @@ -29,12 +27,18 @@ textarea { overflow: auto; } h1.pagetitle { padding-top: 0; margin-top: 0; padding-bottom: 0; margin-bottom: 0; font-size:150%; } +h1.pagetitle .editsection { font-size: 66.7%; } h2 { font-size: 120%; } +h2 .editsection { font-size: 83.3%; } h2, h3, h4, h5, h6 { margin-bottom: 0;} h3 { font-size: 106.25%; } +h3 .editsection { font-size: 94.1%; } h4 { font-size: 103.125%; } +h4 .editsection { font-size: 97.0%; } h5 { font-size: 100%; } +h5 .editsection { font-size: 100%; } h6 { font-size: 95%; } +h6 .editsection { font-size: 105.3%; } hr.sep { color:gray;height:1px;background-color:gray;} p.subpages { font-size:small;} p.subtitle { padding-top: 0; margin-top: 0;} -- cgit v1.2.2