From 370e83bb0dfd0c70de268c93bf07ad5ee0897192 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 15 Aug 2008 01:29:47 +0200 Subject: Update auf 1.13.0 --- skins/common/allmessages.js | 83 +++ skins/common/commonPrint.css | 25 - skins/common/common_rtl.css | 16 +- skins/common/diff.css | 2 + skins/common/edit.js | 156 +++++ skins/common/history.js | 83 +++ skins/common/images/ar/button_bold.png | Bin 0 -> 741 bytes skins/common/images/ar/button_headline.png | Bin 0 -> 629 bytes skins/common/images/ar/button_italic.png | Bin 0 -> 692 bytes skins/common/images/ar/button_link.png | Bin 0 -> 741 bytes skins/common/images/ar/button_nowiki.png | Bin 0 -> 1185 bytes skins/common/images/be-tarask/button_bold.png | Bin 0 -> 575 bytes skins/common/images/be-tarask/button_italic.png | Bin 0 -> 638 bytes skins/common/images/be-tarask/button_link.png | Bin 0 -> 550 bytes skins/common/images/cyrl/LICENSE | 17 + skins/common/images/cyrl/button_bold.png | Bin 0 -> 275 bytes skins/common/images/cyrl/button_italic.png | Bin 0 -> 461 bytes skins/common/images/cyrl/button_link.png | Bin 0 -> 353 bytes skins/common/images/spinner.gif | Bin 2285 -> 586 bytes skins/common/mwsuggest.js | 775 ++++++++++++++++++++++++ skins/common/oldshared.css | 41 -- skins/common/prefs.js | 119 ++++ skins/common/preview.js | 3 +- skins/common/rightclickedit.js | 48 ++ skins/common/shared.css | 170 ++++++ skins/common/upload.js | 14 + skins/common/wikibits.js | 606 +++--------------- skins/common/wikistandard.css | 2 +- 28 files changed, 1568 insertions(+), 592 deletions(-) create mode 100644 skins/common/allmessages.js create mode 100644 skins/common/edit.js create mode 100644 skins/common/history.js create mode 100644 skins/common/images/ar/button_bold.png create mode 100644 skins/common/images/ar/button_headline.png create mode 100644 skins/common/images/ar/button_italic.png create mode 100644 skins/common/images/ar/button_link.png create mode 100644 skins/common/images/ar/button_nowiki.png create mode 100644 skins/common/images/be-tarask/button_bold.png create mode 100644 skins/common/images/be-tarask/button_italic.png create mode 100644 skins/common/images/be-tarask/button_link.png create mode 100644 skins/common/images/cyrl/LICENSE create mode 100644 skins/common/images/cyrl/button_bold.png create mode 100644 skins/common/images/cyrl/button_italic.png create mode 100644 skins/common/images/cyrl/button_link.png create mode 100644 skins/common/mwsuggest.js create mode 100644 skins/common/prefs.js create mode 100644 skins/common/rightclickedit.js (limited to 'skins/common') diff --git a/skins/common/allmessages.js b/skins/common/allmessages.js new file mode 100644 index 00000000..9f07a481 --- /dev/null +++ b/skins/common/allmessages.js @@ -0,0 +1,83 @@ +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() { + if ( allmessages_timeout ) + window.clearTimeout( allmessages_timeout ); + + if ( !allmessages_running ) + allmessages_timeout = window.setTimeout( 'allmessagesfilter_do();', 500 ); +} + +function allmessagesfilter_do() { + if ( !allmessages_nodelist ) + return; + + var text = document.getElementById('allmessagesinput').value.toLowerCase(); + var nodef = allmessages_modified; + + allmessages_running = true; + + for ( var name in allmessages_nodelist ) { + var nodes = allmessages_nodelist[name]; + var display = ( name.toLowerCase().indexOf( text ) == -1 ? 'none' : '' ); + + for ( var i = 0; i < nodes.length; i++) + nodes[i].style.display = + ( nodes[i].className == "def" && nodef + ? 'none' : display ); + } + + if ( text != document.getElementById('allmessagesinput').value.toLowerCase() || + nodef != allmessages_modified ) + allmessagesfilter_do(); // repeat + + allmessages_running = false; +} + +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 ); diff --git a/skins/common/commonPrint.css b/skins/common/commonPrint.css index b0aad3d1..ecf146de 100644 --- a/skins/common/commonPrint.css +++ b/skins/common/commonPrint.css @@ -209,31 +209,6 @@ img { border: none; } img.tex { vertical-align: middle; } span.texhtml { font-family: serif; } -div.townBox { - position:relative; - float:right; - background:White; - margin-left:1em; - border: 1px solid gray; - padding:0.3em; - width: 200px; - overflow: hidden; - clear: right; -} -div.townBox dl { - padding: 0; - margin: 0 0 0.3em 0; - font-size: 96%; -} -div.townBox dl dt { - background: none; - margin: 0.4em 0 0 0; -} -div.townBox dl dd { - margin: 0.1em 0 0 1.1em; - background-color: #f3f3f3; -} - #siteNotice { display: none; } table.gallery { diff --git a/skins/common/common_rtl.css b/skins/common/common_rtl.css index d26acc13..cda3835d 100644 --- a/skins/common/common_rtl.css +++ b/skins/common/common_rtl.css @@ -14,7 +14,7 @@ fieldset.operaprefsection { margin-right: 18em; } /* page history */ -#pagehistory span.user { +#pagehistory .history-user { margin-right: 1.4em; margin-left: 0.4em; } @@ -28,10 +28,20 @@ div.tright, div.floatright { div.tleft, div.floatleft { clear: left; } -/* Unblock and Ipblocklist links of Special:Blockip */ -p.mw-ipb-conveniencelinks { +/* Convenience links to edit block and delete reasons */ +p.mw-ipb-conveniencelinks, p.mw-filedelete-editreasons, p.mw-delete-editreasons { float: left; } table.filehistory th { text-align: right; } + +/** + * Lists: + * The following lines don't have a visible effect on non-Gecko browsers + * They fix a problem ith Gecko browsers rendering lists to the right of + * left-floated objects in an RTL layout. + */ +html > body div#article ul { + display: table; +} diff --git a/skins/common/diff.css b/skins/common/diff.css index 6a1f23b5..b262222a 100644 --- a/skins/common/diff.css +++ b/skins/common/diff.css @@ -33,6 +33,8 @@ td.diff-context { color: red; font-weight: bold; text-decoration: none; + white-space: pre-wrap; + white-space: -moz-pre-wrap; } table.diff { diff --git a/skins/common/edit.js b/skins/common/edit.js new file mode 100644 index 00000000..945059e0 --- /dev/null +++ b/skins/common/edit.js @@ -0,0 +1,156 @@ +// this function generates the actual toolbar buttons with localized text +// we use it to avoid creating the toolbar where javascript is not enabled +function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { + // Don't generate buttons for browsers which don't fully + // support it. + mwEditButtons[mwEditButtons.length] = + {"imageId": imageId, + "imageFile": imageFile, + "speedTip": speedTip, + "tagOpen": tagOpen, + "tagClose": tagClose, + "sampleText": sampleText}; +} + +// this function generates the actual toolbar buttons with localized text +// we use it to avoid creating the toolbar where javascript is not enabled +function mwInsertEditButton(parent, item) { + var image = document.createElement("img"); + image.width = 23; + image.height = 22; + image.className = "mw-toolbar-editbutton"; + if (item.imageId) image.id = item.imageId; + image.src = item.imageFile; + image.border = 0; + image.alt = item.speedTip; + image.title = item.speedTip; + image.style.cursor = "pointer"; + image.onclick = function() { + insertTags(item.tagOpen, item.tagClose, item.sampleText); + return false; + }; + + parent.appendChild(image); + return true; +} + +function mwSetupToolbar() { + var toolbar = document.getElementById('toolbar'); + if (!toolbar) { return false; } + + var textbox = document.getElementById('wpTextbox1'); + if (!textbox) { return false; } + + // Don't generate buttons for browsers which don't fully + // support it. + if (!(document.selection && document.selection.createRange) + && textbox.selectionStart === null) { + return false; + } + + for (var i = 0; i < mwEditButtons.length; i++) { + mwInsertEditButton(toolbar, mwEditButtons[i]); + } + for (var i = 0; i < mwCustomEditButtons.length; i++) { + mwInsertEditButton(toolbar, mwCustomEditButtons[i]); + } + return true; +} + +// apply tagOpen/tagClose to selection in textarea, +// use sampleText instead of selection if there is none +function insertTags(tagOpen, tagClose, sampleText) { + 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'); + txtarea = areas[0]; + } + var selText, isSample = false; + + if (document.selection && document.selection.createRange) { // IE/Opera + + //save window scroll position + if (document.documentElement && document.documentElement.scrollTop) + var winScroll = document.documentElement.scrollTop + else if (document.body) + var winScroll = document.body.scrollTop; + //get current selection + txtarea.focus(); + var range = document.selection.createRange(); + selText = range.text; + //insert tags + checkSelectedText(); + range.text = tagOpen + selText + tagClose; + //mark sample text as selected + if (isSample && range.moveStart) { + if (window.opera) + tagClose = tagClose.replace(/\n/g,''); + range.moveStart('character', - tagClose.length - selText.length); + range.moveEnd('character', - tagClose.length); + } + range.select(); + //restore window scroll position + if (document.documentElement && document.documentElement.scrollTop) + document.documentElement.scrollTop = winScroll + else if (document.body) + document.body.scrollTop = winScroll; + + } else if (txtarea.selectionStart || txtarea.selectionStart == '0') { // Mozilla + + //save textarea scroll position + var textScroll = txtarea.scrollTop; + //get current selection + txtarea.focus(); + var startPos = txtarea.selectionStart; + var endPos = txtarea.selectionEnd; + selText = txtarea.value.substring(startPos, endPos); + //insert tags + checkSelectedText(); + txtarea.value = txtarea.value.substring(0, startPos) + + tagOpen + selText + tagClose + + txtarea.value.substring(endPos, txtarea.value.length); + //set new selection + if (isSample) { + txtarea.selectionStart = startPos + tagOpen.length; + txtarea.selectionEnd = startPos + tagOpen.length + selText.length; + } else { + txtarea.selectionStart = startPos + tagOpen.length + selText.length + tagClose.length; + txtarea.selectionEnd = txtarea.selectionStart; + } + //restore textarea scroll position + txtarea.scrollTop = textScroll; + } + + function checkSelectedText(){ + if (!selText) { + selText = sampleText; + isSample = true; + } else if (selText.charAt(selText.length - 1) == ' ') { //exclude ending space char + selText = selText.substring(0, selText.length - 1); + tagClose += ' ' + } + } + +} + +/** + * Restore the edit box scroll state following a preview operation, + * and set up a form submission handler to remember this state + */ +function scrollEditBox() { + var editBox = document.getElementById( 'wpTextbox1' ); + var scrollTop = document.getElementById( 'wpScrolltop' ); + var editForm = document.getElementById( 'editform' ); + if( editBox && scrollTop ) { + if( scrollTop.value ) + editBox.scrollTop = scrollTop.value; + addHandler( editForm, 'submit', function() { + document.getElementById( 'wpScrolltop' ).value = document.getElementById( 'wpTextbox1' ).scrollTop; + } ); + } +} +hookEvent( 'load', scrollEditBox ); +hookEvent( 'load', mwSetupToolbar ); diff --git a/skins/common/history.js b/skins/common/history.js new file mode 100644 index 00000000..57e61849 --- /dev/null +++ b/skins/common/history.js @@ -0,0 +1,83 @@ +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") { + radios[radios.length] = inputs[i]; + } + } + return radios; +} + +// check selection and tweak visibility/class onclick +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) { + return true; + } + var lis = hf.getElementsByTagName('li'); + for (var i=0;i Results object +var os_map = {}; +// cached data, url -> json_text +var os_cache = {}; +// global variables for suggest_keypress +var os_cur_keypressed = 0; +var os_last_keypress = 0; +var os_keypressed_count = 0; +// type: Timer +var os_timer = null; +// tie mousedown/up events +var os_mouse_pressed = false; +var os_mouse_num = -1; +// if true, the last change was made by mouse (and not keyboard) +var os_mouse_moved = false; +// delay between keypress and suggestion (in ms) +var os_search_timeout = 250; +// these pairs of inputs/forms will be autoloaded at startup +var os_autoload_inputs = new Array('searchInput', 'searchInput2', 'powerSearchText', 'searchText'); +var os_autoload_forms = new Array('searchform', 'searchform2', 'powersearch', 'search' ); +// if we stopped the service +var os_is_stopped = false; +// max lines to show in suggest table +var os_max_lines_per_suggest = 7; + +/** Timeout timer class that will fetch the results */ +function os_Timer(id,r,query){ + this.id = id; + this.r = r; + this.query = query; +} + +/** Property class for single search box */ +function os_Results(name, formname){ + this.searchform = formname; // id of the searchform + this.searchbox = name; // id of the searchbox + this.container = name+"Suggest"; // div that holds results + this.resultTable = name+"Result"; // id base for the result table (+num = table row) + this.resultText = name+"ResultText"; // id base for the spans within result tables (+num) + this.toggle = name+"Toggle"; // div that has the toggle (enable/disable) link + this.query = null; // last processed query + this.results = null; // parsed titles + this.resultCount = 0; // number of results + this.original = null; // query that user entered + this.selected = -1; // which result is selected + this.containerCount = 0; // number of results visible in container + this.containerRow = 0; // height of result field in the container + this.containerTotal = 0; // total height of the container will all results + this.visible = false; // if container is visible +} + +/** Hide results div */ +function os_hideResults(r){ + var c = document.getElementById(r.container); + if(c != null) + c.style.visibility = "hidden"; + r.visible = false; + r.selected = -1; +} + +/** Show results div */ +function os_showResults(r){ + if(os_is_stopped) + return; + os_fitContainer(r); + var c = document.getElementById(r.container); + r.selected = -1; + if(c != null){ + c.scrollTop = 0; + c.style.visibility = "visible"; + r.visible = true; + } +} + +function os_operaWidthFix(x){ + // TODO: better css2 incompatibility detection here + if(is_opera || is_khtml || navigator.userAgent.toLowerCase().indexOf('firefox/1')!=-1){ + return x - 30; // opera&konqueror & old firefox don't understand overflow-x, estimate scrollbar width + } + return x; +} + +function os_encodeQuery(value){ + if (encodeURIComponent) { + return encodeURIComponent(value); + } + if(escape) { + return escape(value); + } + return null; +} +function os_decodeValue(value){ + if (decodeURIComponent) { + return decodeURIComponent(value); + } + if(unescape){ + return unescape(value); + } + return null; +} + +/** Brower-dependent functions to find window inner size, and scroll status */ +function f_clientWidth() { + return f_filterResults ( + window.innerWidth ? window.innerWidth : 0, + document.documentElement ? document.documentElement.clientWidth : 0, + document.body ? document.body.clientWidth : 0 + ); +} +function f_clientHeight() { + return f_filterResults ( + window.innerHeight ? window.innerHeight : 0, + document.documentElement ? document.documentElement.clientHeight : 0, + document.body ? document.body.clientHeight : 0 + ); +} +function f_scrollLeft() { + return f_filterResults ( + window.pageXOffset ? window.pageXOffset : 0, + document.documentElement ? document.documentElement.scrollLeft : 0, + document.body ? document.body.scrollLeft : 0 + ); +} +function f_scrollTop() { + return f_filterResults ( + window.pageYOffset ? window.pageYOffset : 0, + document.documentElement ? document.documentElement.scrollTop : 0, + document.body ? document.body.scrollTop : 0 + ); +} +function f_filterResults(n_win, n_docel, n_body) { + var n_result = n_win ? n_win : 0; + if (n_docel && (!n_result || (n_result > n_docel))) + n_result = n_docel; + return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; +} + +/** Get the height available for the results container */ +function os_availableHeight(r){ + var absTop = document.getElementById(r.container).style.top; + var px = absTop.lastIndexOf("px"); + if(px > 0) + absTop = absTop.substring(0,px); + return f_clientHeight() - (absTop - f_scrollTop()); +} + + +/** Get element absolute position {left,top} */ +function os_getElementPosition(elemID){ + var offsetTrail = document.getElementById(elemID); + var offsetLeft = 0; + var offsetTop = 0; + while (offsetTrail){ + offsetLeft += offsetTrail.offsetLeft; + offsetTop += offsetTrail.offsetTop; + offsetTrail = offsetTrail.offsetParent; + } + if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){ + offsetLeft += document.body.leftMargin; + offsetTop += document.body.topMargin; + } + return {left:offsetLeft,top:offsetTop}; +} + +/** Create the container div that will hold the suggested titles */ +function os_createContainer(r){ + var c = document.createElement("div"); + var s = document.getElementById(r.searchbox); + var pos = os_getElementPosition(r.searchbox); + var left = pos.left; + var top = pos.top + s.offsetHeight; + c.className = "os-suggest"; + c.setAttribute("id", r.container); + document.body.appendChild(c); + + // dynamically generated style params + // IE workaround, cannot explicitely set "style" attribute + c = document.getElementById(r.container); + c.style.top = top+"px"; + c.style.left = left+"px"; + c.style.width = s.offsetWidth+"px"; + + // mouse event handlers + c.onmouseover = function(event) { os_eventMouseover(r.searchbox, event); }; + c.onmousemove = function(event) { os_eventMousemove(r.searchbox, event); }; + c.onmousedown = function(event) { return os_eventMousedown(r.searchbox, event); }; + c.onmouseup = function(event) { os_eventMouseup(r.searchbox, event); }; + return c; +} + +/** change container height to fit to screen */ +function os_fitContainer(r){ + var c = document.getElementById(r.container); + var h = os_availableHeight(r) - 20; + var inc = r.containerRow; + h = parseInt(h/inc) * inc; + if(h < (2 * inc) && r.resultCount > 1) // min: two results + h = 2 * inc; + if((h/inc) > os_max_lines_per_suggest ) + h = inc * os_max_lines_per_suggest; + if(h < r.containerTotal){ + c.style.height = h +"px"; + r.containerCount = parseInt(Math.round(h/inc)); + } else{ + c.style.height = r.containerTotal+"px"; + r.containerCount = r.resultCount; + } +} +/** If some entries are longer than the box, replace text with "..." */ +function os_trimResultText(r){ + var w = document.getElementById(r.container).offsetWidth; + if(r.containerCount < r.resultCount){ + w -= 20; // give 20px for scrollbar + } else + w = os_operaWidthFix(w); + if(w < 10) + return; + for(var i=0;i w && (e.offsetWidth < lastW || iteration<2)){ + changedText = true; + lastW = e.offsetWidth; + var l = e.innerHTML; + e.innerHTML = l.substring(0,l.length-replace)+"..."; + iteration++; + replace = 4; // how many chars to replace + } + if(changedText){ + // show hint for trimmed titles + document.getElementById(r.resultTable+i).setAttribute("title",r.results[i]); + } + } +} + +/** Handles data from XMLHttpRequest, and updates the suggest results */ +function os_updateResults(r, query, text, cacheKey){ + os_cache[cacheKey] = text; + r.query = query; + r.original = query; + if(text == ""){ + r.results = null; + r.resultCount = 0; + os_hideResults(r); + } else{ + try { + var p = eval('('+text+')'); // simple json parse, could do a safer one + if(p.length<2 || p[1].length == 0){ + r.results = null; + r.resultCount = 0; + os_hideResults(r); + return; + } + var c = document.getElementById(r.container); + if(c == null) + c = os_createContainer(r); + c.innerHTML = os_createResultTable(r,p[1]); + // init container table sizes + var t = document.getElementById(r.resultTable); + r.containerTotal = t.offsetHeight; + r.containerRow = t.offsetHeight / r.resultCount; + os_trimResultText(r); + os_showResults(r); + } catch(e){ + // bad response from server or such + os_hideResults(r); + os_cache[cacheKey] = null; + } + } +} + +/** Create the result table to be placed in the container div */ +function os_createResultTable(r, results){ + var c = document.getElementById(r.container); + var width = os_operaWidthFix(c.offsetWidth); + var html = ""; + r.results = new Array(); + r.resultCount = results.length; + for(i=0;i"+title+""; + } + html+="
" + return html; +} + +/** Fetch namespaces from checkboxes or hidden fields in the search form, + if none defined use wgSearchNamespaces global */ +function os_getNamespaces(r){ + var namespaces = ""; + var elements = document.forms[r.searchform].elements; + for(i=0; i < elements.length; i++){ + var name = elements[i].name; + if(typeof name != 'undefined' && name.length > 2 + && name[0]=='n' && name[1]=='s' + && ((elements[i].type=='checkbox' && elements[i].checked) + || (elements[i].type=='hidden' && elements[i].value=="1")) ){ + if(namespaces!="") + namespaces+="|"; + namespaces+=name.substring(2); + } + } + if(namespaces == "") + namespaces = wgSearchNamespaces.join("|"); + return namespaces; +} + +/** Update results if user hasn't already typed something else */ +function os_updateIfRelevant(r, query, text, cacheKey){ + var t = document.getElementById(r.searchbox); + if(t != null && t.value == query){ // check if response is still relevant + os_updateResults(r, query, text, cacheKey); + } + r.query = query; +} + +/** Fetch results after some timeout */ +function os_delayedFetch(){ + if(os_timer == null) + return; + var r = os_timer.r; + var query = os_timer.query; + os_timer = null; + var path = wgMWSuggestTemplate.replace("{namespaces}",os_getNamespaces(r)) + .replace("{dbname}",wgDBname) + .replace("{searchTerms}",os_encodeQuery(query)); + + // try to get from cache, if not fetch using ajax + var cached = os_cache[path]; + if(cached != null){ + os_updateIfRelevant(r, query, cached, path); + } else{ + var xmlhttp = sajax_init_object(); + if(xmlhttp){ + try { + xmlhttp.open("GET", path, true); + xmlhttp.onreadystatechange=function(){ + if (xmlhttp.readyState==4 && typeof os_updateIfRelevant == 'function') { + os_updateIfRelevant(r, query, xmlhttp.responseText, path); + } + }; + xmlhttp.send(null); + } catch (e) { + if (window.location.hostname == "localhost") { + alert("Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing."); + } + throw e; + } + } + } +} + +/** Init timed update via os_delayedUpdate() */ +function os_fetchResults(r, query, timeout){ + if(query == ""){ + os_hideResults(r); + return; + } else if(query == r.query) + return; // no change + + os_is_stopped = false; // make sure we're running + + /* var cacheKey = wgDBname+":"+query; + var cached = os_cache[cacheKey]; + if(cached != null){ + os_updateResults(r,wgDBname,query,cached); + return; + } */ + + // cancel any pending fetches + if(os_timer != null && os_timer.id != null) + clearTimeout(os_timer.id); + // schedule delayed fetching of results + if(timeout != 0){ + os_timer = new os_Timer(setTimeout("os_delayedFetch()",timeout),r,query); + } else{ + os_timer = new os_Timer(null,r,query); + os_delayedFetch(); // do it now! + } + +} +/** Change the highlighted row (i.e. suggestion), from position cur to next */ +function os_changeHighlight(r, cur, next, updateSearchBox){ + if (next >= r.resultCount) + next = r.resultCount-1; + if (next < -1) + next = -1; + r.selected = next; + if (cur == next) + return; // nothing to do. + + if(cur >= 0){ + var curRow = document.getElementById(r.resultTable + cur); + if(curRow != null) + curRow.className = "os-suggest-result"; + } + var newText; + if(next >= 0){ + var nextRow = document.getElementById(r.resultTable + next); + if(nextRow != null) + nextRow.className = os_HighlightClass(); + newText = r.results[next]; + } else + newText = r.original; + + // adjust the scrollbar if any + if(r.containerCount < r.resultCount){ + var c = document.getElementById(r.container); + var vStart = c.scrollTop / r.containerRow; + var vEnd = vStart + r.containerCount; + if(next < vStart) + c.scrollTop = next * r.containerRow; + else if(next >= vEnd) + c.scrollTop = (next - r.containerCount + 1) * r.containerRow; + } + + // update the contents of the search box + if(updateSearchBox){ + os_updateSearchQuery(r,newText); + } +} + +function os_HighlightClass() { + var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/); + if (match) { + var webKitVersion = parseInt(match[1]); + if (webKitVersion < 523) { + // CSS system highlight colors broken on old Safari + // https://bugs.webkit.org/show_bug.cgi?id=6129 + // Safari 3.0.4, 3.1 known ok + return "os-suggest-result-hl-webkit"; + } + } + return "os-suggest-result-hl"; +} + +function os_updateSearchQuery(r,newText){ + document.getElementById(r.searchbox).value = newText; + r.query = newText; +} + +/** Find event target */ +function os_getTarget(e){ + if (!e) e = window.event; + if (e.target) return e.target; + else if (e.srcElement) return e.srcElement; + else return null; +} + + + +/******************** + * Keyboard events + ********************/ + +/** Event handler that will fetch results on keyup */ +function os_eventKeyup(e){ + var targ = os_getTarget(e); + var r = os_map[targ.id]; + if(r == null) + return; // not our event + + // some browsers won't generate keypressed for arrow keys, catch it + if(os_keypressed_count == 0){ + os_processKey(r,os_cur_keypressed,targ); + } + var query = targ.value; + os_fetchResults(r,query,os_search_timeout); +} + +/** catch arrows up/down and escape to hide the suggestions */ +function os_processKey(r,keypressed,targ){ + if (keypressed == 40){ // Arrow Down + if (r.visible) { + os_changeHighlight(r, r.selected, r.selected+1, true); + } else if(os_timer == null){ + // user wants to get suggestions now + r.query = ""; + os_fetchResults(r,targ.value,0); + } + } else if (keypressed == 38){ // Arrow Up + if (r.visible){ + os_changeHighlight(r, r.selected, r.selected-1, true); + } + } else if(keypressed == 27){ // Escape + document.getElementById(r.searchbox).value = r.original; + r.query = r.original; + os_hideResults(r); + } else if(r.query != document.getElementById(r.searchbox).value){ + // os_hideResults(r); // don't show old suggestions + } +} + +/** When keys is held down use a timer to output regular events */ +function os_eventKeypress(e){ + var targ = os_getTarget(e); + var r = os_map[targ.id]; + if(r == null) + return; // not our event + + var keypressed = os_cur_keypressed; + if(keypressed == 38 || keypressed == 40){ + var d = new Date() + var now = d.getTime(); + if(now - os_last_keypress < 120){ + os_last_keypress = now; + return; + } + } + + os_keypressed_count++; + os_processKey(r,keypressed,targ); +} + +/** Catch the key code (Firefox bug) */ +function os_eventKeydown(e){ + if (!e) e = window.event; + var targ = os_getTarget(e); + var r = os_map[targ.id]; + if(r == null) + return; // not our event + + os_mouse_moved = false; + + os_cur_keypressed = (window.Event) ? e.which : e.keyCode; + os_last_keypress = 0; + os_keypressed_count = 0; +} + +/** Event: loss of focus of input box */ +function os_eventBlur(e){ + var targ = os_getTarget(e); + var r = os_map[targ.id]; + if(r == null) + return; // not our event + if(!os_mouse_pressed) + os_hideResults(r); +} + +/** Event: focus (catch only when stopped) */ +function os_eventFocus(e){ + // nothing happens here? +} + + + +/******************** + * Mouse events + ********************/ + +/** Mouse over the container */ +function os_eventMouseover(srcId, e){ + var targ = os_getTarget(e); + var r = os_map[srcId]; + if(r == null || !os_mouse_moved) + return; // not our event + var num = os_getNumberSuffix(targ.id); + if(num >= 0) + os_changeHighlight(r,r.selected,num,false); + +} + +/* Get row where the event occured (from its id) */ +function os_getNumberSuffix(id){ + var num = id.substring(id.length-2); + if( ! (num.charAt(0) >= '0' && num.charAt(0) <= '9') ) + num = num.substring(1); + if(os_isNumber(num)) + return parseInt(num); + else + return -1; +} + +/** Save mouse move as last action */ +function os_eventMousemove(srcId, e){ + os_mouse_moved = true; +} + +/** Mouse button held down, register possible click */ +function os_eventMousedown(srcId, e){ + var targ = os_getTarget(e); + var r = os_map[srcId]; + if(r == null) + return; // not our event + var num = os_getNumberSuffix(targ.id); + + os_mouse_pressed = true; + if(num >= 0){ + os_mouse_num = num; + // os_updateSearchQuery(r,r.results[num]); + } + // keep the focus on the search field + document.getElementById(r.searchbox).focus(); + + return false; // prevents selection +} + +/** Mouse button released, check for click on some row */ +function os_eventMouseup(srcId, e){ + var targ = os_getTarget(e); + var r = os_map[srcId]; + if(r == null) + return; // not our event + var num = os_getNumberSuffix(targ.id); + + if(num >= 0 && os_mouse_num == num){ + os_updateSearchQuery(r,r.results[num]); + os_hideResults(r); + document.getElementById(r.searchform).submit(); + } + os_mouse_pressed = false; + // keep the focus on the search field + document.getElementById(r.searchbox).focus(); +} + +/** Check if x is a valid integer */ +function os_isNumber(x){ + if(x == "" || isNaN(x)) + return false; + for(var i=0;i= '0' && c <= '9') ) + return false; + } + return true; +} + + +/** When the form is submitted hide everything, cancel updates... */ +function os_eventOnsubmit(e){ + var targ = os_getTarget(e); + + os_is_stopped = true; + // kill timed requests + if(os_timer != null && os_timer.id != null){ + clearTimeout(os_timer.id); + os_timer = null; + } + // Hide all suggestions + for(i=0;i= 0) ? "-" : "+") + ((tzHour < 10) ? "0" : "") + tzHour + ((tzMin < 10) ? "0" : "") + tzMin; + if (tz != tzString) { + var junk = msg.split('$1'); + document.write(junk[0] + "UTC" + tzString + junk[1]); + } +} + +function unhidetzbutton() { + var tzb = document.getElementById('guesstimezonebutton'); + if (tzb) { + tzb.style.display = 'inline'; + } +} + +// in [-]HH:MM 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(); + var tzHour = Math.floor( Math.abs(tzRaw) / 60); + var tzMin = Math.abs(tzRaw) % 60; + var tzString = ((tzRaw >= 0) ? "-" : "") + ((tzHour < 10) ? "0" : "") + tzHour + + ":" + ((tzMin < 10) ? "0" : "") + tzMin; + return tzString; +} + +function guessTimezone(box) { + document.getElementsByName("wpHourDiff")[0].value = fetchTimezone(); +} + +hookEvent("load", unhidetzbutton); +hookEvent("load", tabbedprefs); diff --git a/skins/common/preview.js b/skins/common/preview.js index ad096e2c..8c5c07d3 100644 --- a/skins/common/preview.js +++ b/skins/common/preview.js @@ -104,8 +104,7 @@ function lpStatusUpdate() { categoryContainer.style.display = 'block'; } else { /* Just dump them somewhere */ - /* previewContainer.innerHTML += '';*/ + /* previewContainer.innerHTML += categoryElement.firstChild.data;*/ } } else { /* Nothing to show, hide old data */ diff --git a/skins/common/rightclickedit.js b/skins/common/rightclickedit.js new file mode 100644 index 00000000..83d552a2 --- /dev/null +++ b/skins/common/rightclickedit.js @@ -0,0 +1,48 @@ +function setupRightClickEdit() { + if (document.getElementsByTagName) { + var spans = document.getElementsByTagName('span'); + for (var i = 0; i < spans.length; i++) { + var el = spans[i]; + if(el.className == 'editsection') { + addRightClickEditHandler(el); + } + } + } +} + +function addRightClickEditHandler(el) { + for (var i = 0; i < el.childNodes.length; i++) { + var link = el.childNodes[i]; + if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { + var editHref = link.getAttribute('href'); + // 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; + }; + } + } + } +} + +hookEvent("load", setupRightClickEdit); diff --git a/skins/common/shared.css b/skins/common/shared.css index de02a10f..d42fc1c0 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -47,6 +47,10 @@ table.filehistory th.mw-imagepage-filesize { white-space:nowrap; } +table.filehistory td.filehistory-selected { + font-weight: bold; +} + /* * rev_deleted stuff */ @@ -77,3 +81,169 @@ body.rtl .magnify { float:left; } body.ltr .thumbcaption { text-align:left; } body.ltr .magnify { float:right; } + +/** + * Hidden categories + */ +.mw-hidden-cats-hidden { display: none; } +.catlinks-allhidden { display: none; } + +/* Convenience links to edit block and delete reasons */ +p.mw-ipb-conveniencelinks, p.mw-filedelete-editreasons, p.mw-delete-editreasons { + font-size: 90%; + float: right; +} + +/* Search results */ +div.searchresult { + font-size: 95%; + width:38em; +} +.mw-search-results li { + padding-bottom: 1em; +} +.mw-search-result-data { + color: green; + font-size: 97%; +} + +div#mw-search-interwiki { + float: right; + width: 18em; + border-style: solid; + border-color: #AAAAAA; + border-width: 1px; + margin-top: 2ex; +} + +div#mw-search-interwiki li { + font-size: 95%; +} + +.mw-search-interwiki-more { + float: right; + font-size: 90%; +} + +span.searchalttitle { + font-size: 95%; +} + +div.searchdidyoumean { + font-size: 127%; + padding-bottom:1ex; + padding-top:1ex; +} + +/* + * UserRights stuff + */ +.mw-userrights-disabled { + color: #888; +} + +table.mw-userrights-groups * td,table.mw-userrights-groups * th { + padding-right: 1.5em; +} + +/* + * OpenSearch ajax suggestions + */ +.os-suggest { + overflow: auto; + overflow-x: hidden; + position: absolute; + top: 0px; + left: 0px; + width: 0px; + background-color: white; + border-style: solid; + border-color: #AAAAAA; + border-width: 1px; + z-index:99; + visibility:hidden; + font-size:95%; +} + +table.os-suggest-results { + font-size: 95%; + cursor: pointer; + border: 0; + border-collapse: collapse; + width: 100%; +} + +td.os-suggest-result, td.os-suggest-result-hl { + white-space: nowrap; + background-color: white; + background-color: Window; + color: black; + color: WindowText; + padding: 2px; +} +td.os-suggest-result-hl, +td.os-suggest-result-hl-webkit { + background-color: #4C59A6; + color: white; +} +td.os-suggest-result-hl { + /* System colors are misimplemented in Safari 3.0 and earlier, + making highlighted text illegible... */ + background-color: Highlight; + color: HighlightText; +} + +.os-suggest-toggle { + position: relative; + left: 1ex; + font-size: 65%; +} +.os-suggest-toggle-def { + position: absolute; + top: 0px; + left: 0px; + font-size: 65%; + visibility: hidden; +} + +/* Page history styling */ +/* the auto-generated edit comments */ +.autocomment { color: gray; } +#pagehistory .history-user { + margin-left: 0.4em; + margin-right: 0.2em; +} +#pagehistory span.minor { font-weight: bold; } +#pagehistory li { border: 1px solid white; } +#pagehistory li.selected { + background-color: #f9f9f9; + border: 1px dashed #aaa; +} + +table.mw-listgrouprights-table { + border: 1px solid #ccc; + border-collapse: collapse; +} + +table.mw-listgrouprights-table tr { + vertical-align: top; +} + +table.mw-listgrouprights-table td, table.mw-listgrouprights-table th { + padding: 0.5em 0.2em 0.5em 0.2em; + border: 1px solid #ccc; +} + +/* Special:SpecialPages styling */ +h4.mw-specialpagesgroup { + background-color: #dcdcdc; + padding: 2px; + margin: .3em 0em 0em 0em; +} +.mw-specialpagerestricted { + font-weight: bold; +} + +#shared-image-dup, #shared-image-conflict { + font-style: italic; +} diff --git a/skins/common/upload.js b/skins/common/upload.js index f00c4db8..d1cf4b3e 100644 --- a/skins/common/upload.js +++ b/skins/common/upload.js @@ -112,6 +112,9 @@ var wgUploadWarningObj = { } function fillDestFilename(id) { + if (!wgUploadAutoFill) { + return; + } if (!document.getElementById) { return; } @@ -139,6 +142,17 @@ function fillDestFilename(id) { } } +function toggleFilenameFiller() { + if(!document.getElementById) return; + var upfield = document.getElementById('wpUploadFile'); + var destName = document.getElementById('wpDestFile').value; + if (destName=='' || destName==' ') { + wgUploadAutoFill = true; + } else { + wgUploadAutoFill = false; + } +} + var wgUploadLicenseObj = { 'responseCache' : { '' : '' }, diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index cdb5c9de..59f15cef 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -1,18 +1,27 @@ // MediaWiki JavaScript support functions var clientPC = navigator.userAgent.toLowerCase(); // Get client info -var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1) - && (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; +var is_gecko = /gecko/.test( clientPC ) && + !/khtml|spoofer|netscape\/7\.0/.test(clientPC); +var webkit_match = clientPC.match(/applewebkit\/(\d+)/); +if (webkit_match) { + var is_safari = clientPC.indexOf('applewebkit') != -1 && + clientPC.indexOf('spoofer') == -1; + var is_safari_win = is_safari && clientPC.indexOf('windows') != -1; + var webkit_version = parseInt(webkit_match[1]); +} +var is_khtml = navigator.vendor == 'KDE' || + ( document.childNodes && !document.all && !navigator.taintEnabled ); +// For accesskeys; note that FF3+ is included here! +var is_ff2 = /firefox\/[2-9]|minefield\/3/.test( clientPC ); +// These aren't used here, but some custom scripts rely on them +var is_ff2_win = is_ff2 && clientPC.indexOf('windows') != -1; +var is_ff2_x11 = is_ff2 && 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); - var is_opera_95 = (clientPC.search(/opera\/(9.[5-9]|[1-9][0-9])/)!=-1); + var is_opera_preseven = window.opera && !document.childNodes; + var is_opera_seven = window.opera && document.childNodes; + var is_opera_95 = /opera\/(9.[5-9]|[1-9][0-9])/.test( clientPC ); } // Global external objects used by this script. @@ -27,7 +36,11 @@ if (!window.onloadFuncts) { function addOnloadHook(hookFunct) { // Allows add-on scripts to add onload functions - onloadFuncts[onloadFuncts.length] = hookFunct; + if(!doneOnloadHook) { + onloadFuncts[onloadFuncts.length] = hookFunct; + } else { + hookFunct(); // bug in MSIE script loading + } } function hookEvent(hookName, hookFunct) { @@ -38,14 +51,49 @@ function hookEvent(hookName, hookFunct) { } } -// document.write special stylesheet links +function importScript(page) { + return importScriptURI(wgScript + '?action=raw&ctype=text/javascript&title=' + encodeURIComponent(page.replace(/ /g,'_'))); +} + +var loadedScripts = {}; // included-scripts tracker +function importScriptURI(url) { + if (loadedScripts[url]) { + return null; + } + loadedScripts[url] = true; + var s = document.createElement('script'); + s.setAttribute('src',url); + s.setAttribute('type','text/javascript'); + document.getElementsByTagName('head')[0].appendChild(s); + return s; +} + +function importStylesheet(page) { + return importStylesheetURI(wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent(page.replace(/ /g,'_'))); +} + +function importStylesheetURI(url) { + return document.createStyleSheet ? document.createStyleSheet(url) : appendCSS('@import "' + url + '";'); +} + +function appendCSS(text) { + var s = document.createElement('style'); + s.type = 'text/css'; + s.rel = 'stylesheet'; + if (s.styleSheet) s.styleSheet.cssText = text //IE + else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null + document.getElementsByTagName('head')[0].appendChild(s); + return s; +} + +// special stylesheet links if (typeof stylepath != 'undefined' && typeof skin != 'undefined') { if (is_opera_preseven) { - document.write(''); + importStylesheetURI(stylepath+'/'+skin+'/Opera6Fixes.css'); } else if (is_opera_seven && !is_opera_95) { - document.write(''); + importStylesheetURI(stylepath+'/'+skin+'/Opera7Fixes.css'); } else if (is_khtml) { - document.write(''); + importStylesheetURI(stylepath+'/'+skin+'/KHTMLFixes.css'); } } @@ -72,204 +120,6 @@ function toggleVisibility(_levelId, _otherId, _linkId) { } } -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") { - radios[radios.length] = inputs[i]; - } - } - return radios; -} - -// check selection and tweak visibility/class onclick -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) { - return true; - } - var lis = hf.getElementsByTagName('li'); - for (var i=0;i= 0) ? "-" : "+") + ((tzHour < 10) ? "0" : "") + tzHour + ((tzMin < 10) ? "0" : "") + tzMin; - if (tz != tzString) { - var junk = msg.split('$1'); - document.write(junk[0] + "UTC" + tzString + junk[1]); - } -} - -function unhidetzbutton() { - var tzb = document.getElementById('guesstimezonebutton'); - if (tzb) { - tzb.style.display = 'inline'; - } -} - -// in [-]HH:MM 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(); - var tzHour = Math.floor( Math.abs(tzRaw) / 60); - var tzMin = Math.abs(tzRaw) % 60; - var tzString = ((tzRaw >= 0) ? "-" : "") + ((tzHour < 10) ? "0" : "") + tzHour + - ":" + ((tzMin < 10) ? "0" : "") + tzMin; - return tzString; -} - -function guessTimezone(box) { - document.getElementsByName("wpHourDiff")[0].value = fetchTimezone(); -} - function showTocToggle() { if (document.createTextNode) { // Uses DOM calls to avoid document.write + XHTML issues @@ -329,65 +179,6 @@ function toggleToc() { var mwEditButtons = []; var mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js -// this function generates the actual toolbar buttons with localized text -// we use it to avoid creating the toolbar where javascript is not enabled -function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { - // Don't generate buttons for browsers which don't fully - // support it. - mwEditButtons[mwEditButtons.length] = - {"imageId": imageId, - "imageFile": imageFile, - "speedTip": speedTip, - "tagOpen": tagOpen, - "tagClose": tagClose, - "sampleText": sampleText}; -} - -// this function generates the actual toolbar buttons with localized text -// we use it to avoid creating the toolbar where javascript is not enabled -function mwInsertEditButton(parent, item) { - var image = document.createElement("img"); - image.width = 23; - image.height = 22; - image.className = "mw-toolbar-editbutton"; - if (item.imageId) image.id = item.imageId; - image.src = item.imageFile; - image.border = 0; - image.alt = item.speedTip; - image.title = item.speedTip; - image.style.cursor = "pointer"; - image.onclick = function() { - insertTags(item.tagOpen, item.tagClose, item.sampleText); - return false; - }; - - parent.appendChild(image); - return true; -} - -function mwSetupToolbar() { - var toolbar = document.getElementById('toolbar'); - if (!toolbar) { return false; } - - var textbox = document.getElementById('wpTextbox1'); - if (!textbox) { return false; } - - // Don't generate buttons for browsers which don't fully - // support it. - if (!(document.selection && document.selection.createRange) - && textbox.selectionStart === null) { - return false; - } - - for (var i = 0; i < mwEditButtons.length; i++) { - mwInsertEditButton(toolbar, mwEditButtons[i]); - } - for (var i = 0; i < mwCustomEditButtons.length; i++) { - mwInsertEditButton(toolbar, mwCustomEditButtons[i]); - } - return true; -} - function escapeQuotes(text) { var re = new RegExp("'","g"); text = text.replace(re,"\\'"); @@ -408,85 +199,6 @@ function escapeQuotesHTML(text) { return text; } -// apply tagOpen/tagClose to selection in textarea, -// use sampleText instead of selection if there is none -function insertTags(tagOpen, tagClose, sampleText) { - 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'); - txtarea = areas[0]; - } - var selText, isSample = false; - - if (document.selection && document.selection.createRange) { // IE/Opera - - //save window scroll position - if (document.documentElement && document.documentElement.scrollTop) - var winScroll = document.documentElement.scrollTop - else if (document.body) - var winScroll = document.body.scrollTop; - //get current selection - txtarea.focus(); - var range = document.selection.createRange(); - selText = range.text; - //insert tags - checkSelectedText(); - range.text = tagOpen + selText + tagClose; - //mark sample text as selected - if (isSample && range.moveStart) { - if (window.opera) - tagClose = tagClose.replace(/\n/g,''); - range.moveStart('character', - tagClose.length - selText.length); - range.moveEnd('character', - tagClose.length); - } - range.select(); - //restore window scroll position - if (document.documentElement && document.documentElement.scrollTop) - document.documentElement.scrollTop = winScroll - else if (document.body) - document.body.scrollTop = winScroll; - - } else if (txtarea.selectionStart || txtarea.selectionStart == '0') { // Mozilla - - //save textarea scroll position - var textScroll = txtarea.scrollTop; - //get current selection - txtarea.focus(); - var startPos = txtarea.selectionStart; - var endPos = txtarea.selectionEnd; - selText = txtarea.value.substring(startPos, endPos); - //insert tags - checkSelectedText(); - txtarea.value = txtarea.value.substring(0, startPos) - + tagOpen + selText + tagClose - + txtarea.value.substring(endPos, txtarea.value.length); - //set new selection - if (isSample) { - txtarea.selectionStart = startPos + tagOpen.length; - txtarea.selectionEnd = startPos + tagOpen.length + selText.length; - } else { - txtarea.selectionStart = startPos + tagOpen.length + selText.length + tagClose.length; - txtarea.selectionEnd = txtarea.selectionStart; - } - //restore textarea scroll position - txtarea.scrollTop = textScroll; - } - - function checkSelectedText(){ - if (!selText) { - selText = sampleText; - isSample = true; - } else if (selText.charAt(selText.length - 1) == ' ') { //exclude ending space char - selText = selText.substring(0, selText.length - 1); - tagClose += ' ' - } - } - -} - /** * Set the accesskey prefix based on browser detection. @@ -494,14 +206,16 @@ function insertTags(tagOpen, tagClose, sampleText) { var tooltipAccessKeyPrefix = 'alt-'; if (is_opera) { tooltipAccessKeyPrefix = 'shift-esc-'; -} else if (is_safari - || navigator.userAgent.toLowerCase().indexOf('mac') != -1 - || navigator.userAgent.toLowerCase().indexOf('konqueror') != -1 ) { +} else if (!is_safari_win && is_safari && webkit_version > 526) { + tooltipAccessKeyPrefix = 'ctrl-alt-'; +} else if (!is_safari_win && (is_safari + || clientPC.indexOf('mac') != -1 + || clientPC.indexOf('konqueror') != -1 )) { tooltipAccessKeyPrefix = 'ctrl-'; -} else if (is_ff2_x11 || is_ff2_win) { +} else if (is_ff2) { tooltipAccessKeyPrefix = 'alt-shift-'; } -var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?.\]$/; +var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?(.)\]$/; /** * Add the appropriate prefix to the accesskey shown in the tooltip. @@ -526,10 +240,9 @@ function updateTooltipAccessKeys( nodeList ) { for ( var i = 0; i < nodeList.length; i++ ) { var element = nodeList[i]; var tip = element.getAttribute("title"); - var key = element.getAttribute("accesskey"); - if ( key && tooltipAccessKeyRegexp.exec(tip) ) { + if ( tip && tooltipAccessKeyRegexp.exec(tip) ) { tip = tip.replace(tooltipAccessKeyRegexp, - "["+tooltipAccessKeyPrefix+key+"]"); + "["+tooltipAccessKeyPrefix+"$5]"); element.setAttribute("title", tip ); } } @@ -655,53 +368,6 @@ function akeytt( doId ) { } } -function setupRightClickEdit() { - if (document.getElementsByTagName) { - var spans = document.getElementsByTagName('span'); - for (var i = 0; i < spans.length; i++) { - var el = spans[i]; - if(el.className == 'editsection') { - addRightClickEditHandler(el); - } - } - } -} - -function addRightClickEditHandler(el) { - for (var i = 0; i < el.childNodes.length; i++) { - var link = el.childNodes[i]; - if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { - var editHref = link.getAttribute('href'); - // 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; - }; - } - } - } -} - var checkboxes; var lastCheckbox; @@ -776,108 +442,6 @@ function toggle_element_check(ida,idb) { document.getElementById(idb).checked=false; } -/** - * Restore the edit box scroll state following a preview operation, - * and set up a form submission handler to remember this state - */ -function scrollEditBox() { - var editBox = document.getElementById( 'wpTextbox1' ); - var scrollTop = document.getElementById( 'wpScrolltop' ); - var editForm = document.getElementById( 'editform' ); - if( editBox && scrollTop ) { - if( scrollTop.value ) - editBox.scrollTop = scrollTop.value; - addHandler( editForm, 'submit', 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() { - if ( allmessages_timeout ) - window.clearTimeout( allmessages_timeout ); - - if ( !allmessages_running ) - allmessages_timeout = window.setTimeout( 'allmessagesfilter_do();', 500 ); -} - -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 ); - } - - if ( text != document.getElementById('allmessagesinput').value || - nodef != allmessages_modified ) - allmessagesfilter_do(); // repeat - - allmessages_running = false; -} - -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 @@ -939,11 +503,10 @@ function redirectToFragment(fragment) { } /* - * 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. + * Table sorting script based on one (c) 1997-2006 Stuart Langridge and Joost + * de Valk: + * http://www.joostdevalk.nl/code/sortable-table/ + * http://www.kryogenix.org/code/browser/sorttable/ * * @todo don't break on colspans/rowspans (bug 8028) * @todo language-specific digit grouping/decimals (bug 8063) @@ -1207,7 +770,7 @@ function ts_alternate(table) { * Add a cute little box at the top of the screen to inform the user of * something, replacing any preexisting message. * - * @param String message HTML to be put inside the right div + * @param String -or- Dom Object message HTML to be put inside the right div * @param String className Used in adding a class; should be different for each * call to allow CSS/JS to hide different boxes. null = no class used. * @return Boolean True on success, false on failure @@ -1245,7 +808,15 @@ function jsMsg( message, className ) { if( className ) { messageDiv.setAttribute( 'class', 'mw-js-message-'+className ); } - messageDiv.innerHTML = message; + + if (typeof message === 'object') { + while (messageDiv.hasChildNodes()) // Remove old content + messageDiv.removeChild(messageDiv.firstChild); + messageDiv.appendChild (message); // Append new content + } + else { + messageDiv.innerHTML = message; + } return true; } @@ -1289,12 +860,8 @@ function runOnloadHook() { // might cause the function to terminate prematurely doneOnloadHook = true; - histrowinit(); - unhidetzbutton(); - tabbedprefs(); updateTooltipAccessKeys( null ); akeytt( null ); - scrollEditBox(); setupCheckboxShiftClick(); sortables_init(); @@ -1331,4 +898,3 @@ function addClickHandler( element, handler ) { //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 532e4fdc..3fe8d2fb 100644 --- a/skins/common/wikistandard.css +++ b/skins/common/wikistandard.css @@ -42,7 +42,7 @@ 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;} -p.catlinks { font-size:small; margin-top:0; text-align:right;} +.catlinks { font-size:small; margin-top:0; text-align:right;} td { empty-cells:show; } td.bottom { border-top: 1px solid gray; } td.top { border-bottom: 1px solid gray; } -- cgit v1.2.3-54-g00ecf