MediaWiki:Monobook.js
Diemesė: ėšsauguojus Tamstā gal prireiktė ėšvalītė Tamstas naršīklės rėnktovė, kū paveizėtomėt pakeitėmus. Mozilla / Safari / Konqueror: laikīdami Shift pasėrinkėt Atsiōstė ėš nauja, a paspauskėt Ctrl-Shift-R (sėstemuo Apple Mac Cmd-Shift-R); IE: laikīdamė Ctrl paspauskėt Atnaujėntė, o paspauskėt Ctrl-F5; Konqueror: paprastiausē paspauskėt Perkrautė mīgtoka, o paspauskėt F5; Opera nauduotuojam gal prireiktė pėlnā ėšvalītė anū rėnktovė Rakondā→Nustatīmā.
/*
'''Wyłączenie poszczególnych możliwości/skryptów'''
* Dodanie linka [edytuj] dla sekcji nagłówkowej
window.addEditTopLinkDone = true;
* Dynamiczne szablony nawigacyjne
window.createNavigationBarToggleButtonDone = true;
* Automatyczne opisy zmian
window.przyciskiOpisDone = true;
* Menu dla edittools (''obecnie i tak nieaktywne'')
window.addCharSubsetMenuDone = true;
==== Dodanie linka [edytuj] dla sekcji nagłówkowej ====
; Pomysł: [[:en:User:Pile0nades]]
; Wykonanie: Maciej Jaros [[:pl:User:Nux]]
; Licencja: [http://opensource.org/licenses/gpl-license.php GNU General Public License v2]
*/
// Liczba nagłówków drugiego, trzeciegiego i czwartego stopnia
// jakie muszą się pojawić w artykule, żeby pojawił się link
var addEditTopLinkNumHeaders = 2; // dla 2 => dla dwóch i więcej się pojawi
function addEditTopLink() {
//
// somehow it gets run twice on some pages - stop that
if (window.addEditTopLinkDone){
return;
}
window.addEditTopLinkDone = true;
//
// if this is preview page or there is no edit tab, stop
if (!wgIsArticle){
return;
}
//
// if there are no edit-section links then stop
var spans = document.getElementById("bodyContent").getElementsByTagName("span");
var i;
for (i = 0; i < spans.length; i++) {
if (spans[i].className == 'editsection'){
break;
}
}
if (i>=spans.length){
return;
}
//
// additional checkup to stop
var test = document.getElementById("bodyContent").getElementsByTagName("h2").length +
document.getElementById("bodyContent").getElementsByTagName("h3").length +
document.getElementById("bodyContent").getElementsByTagName("h4").length;
// note that there is always siteSub (h3)
if (test<=addEditTopLinkNumHeaders){
return;
}
//
// get first header element
var fst_h1 = document.getElementById("content").getElementsByTagName("h1")[0];
//
// Creating elements
//
// create div
var div = document.createElement("DIV");
div.className = 'editsection';
// create link
var link = document.createElement("A");
link.href = document.getElementById("ca-edit").getElementsByTagName("a")[0].href + '§ion=0';
link.setAttribute('title', 'taisītė sekcėjė');
link.appendChild(document.createTextNode('taisītė'));
// append link and stuff to div
div.appendChild(document.createTextNode('['));
div.appendChild(link);
div.appendChild(document.createTextNode(']'));
//
// Styling
//
fst_h1.style.cssText = 'position:relative';
div.style.cssText = 'position:absolute; right:0px; font-size:x-small; bottom:-1.7em';
var ua = navigator.userAgent.toLowerCase();
// IE fix — relative>absolute just dont work there (is positioned relative to body)
if (ua.indexOf('msie')!=-1 && ua.indexOf('opera') == -1)
div.style.cssText='position:absolute; right:1.5em; font-size:x-small; top:3.8em'
;
//
// Insert div container into the DOM before the h1
//
fst_h1.appendChild(div);
}
$(addEditTopLink);
/**
* Dynamiczne szablony nawigacyjne
*/
// set up the words in your language
var NavigationBarHide = '[ Kavuotė ]';
var NavigationBarShow = '[ Ruodītė ]';
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 1;
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavBar){
var NavToggle = document.getElementById("NavToggle" + indexNavBar);
var NavFrame = document.getElementById("NavFrame" + indexNavBar);
if (!NavFrame || !NavToggle){
return;
}
// values to be set
var currDisplay;
var currTitle;
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide)
{
currDisplay = 'none';
currTitle = NavigationBarShow;
}
// if hidden now
else if (NavToggle.firstChild.data == NavigationBarShow)
{
currDisplay = 'block';
currTitle = NavigationBarHide;
}
for (var NavChild=NavFrame.firstChild; NavChild !== null; NavChild=NavChild.nextSibling) {
if (NavChild.nodeType==1) // only if this is an element node
{
if (NavChild.className=='NavPic' || NavChild.className=='NavContent') {
NavChild.style.display = currDisplay;
} else if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = currTitle;
}
}
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton(){
// stop before starting
if (window.createNavigationBarToggleButtonDone)
return;
var i;
var indexNavBar = 0;
var divs = document.getElementById('bodyContent').getElementsByTagName("div");
// iterate over all < div >-elements
for (i=0; i<divs.length; i++)
{
// if found a navigation bar
if (divs[i].className == "NavFrame")
{
var NavFrame = divs[i];
indexNavBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in < div class="NavFrame" >
NavFrame.insertBefore(NavToggle, NavFrame.firstChild);
NavFrame.setAttribute('id', 'NavFrame' + indexNavBar);
}
}
// if more Navigation Bars found than Default then hide all
if (NavigationBarShowDefault < indexNavBar)
{
for(i=1; i<=indexNavBar; i++)
toggleNavigationBar(i)
;
}
}
$(createNavigationBarToggleButton);
/*
==== funkcja insertTagsTo_ ====
; Author: phpBB Team, WikiMedia, Maciej Jaros [[:pl:User:Nux]]
; Licence: [http://opensource.org/licenses/gpl-license.php GNU General Public License v2]
; Description: Apply tagOpen/tagClose to selection in given textarea/input, use sampleText instead of selection if there is none. Copied and adapted from phpBB
<pre>
*/
// outputid = 'some_id_of_a_textarea_or_a_text_input'
function insertTagsTo_(tagOpen, tagClose, sampleText, outputid) {
var txtarea = document.getElementById(outputid);
if (!txtarea) {
return;
}
// IE
if (document.selection && !is_gecko) {
var theSelection = document.selection.createRange().text;
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);
document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
} else {
document.selection.createRange().text = tagOpen + theSelection + tagClose;
}
// Mozilla
} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
var replaced = false;
var startPos = txtarea.selectionStart;
var endPos = txtarea.selectionEnd;
if (endPos-startPos)
replaced = true;
var scrollTop = txtarea.scrollTop;
var myText = (txtarea.value).substring(startPos, endPos);
if (!myText)
myText=sampleText;
if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
} else {
subst = tagOpen + myText + tagClose;
}
txtarea.value = txtarea.value.substring(0, startPos) + subst +
txtarea.value.substring(endPos, txtarea.value.length);
txtarea.focus();
//set new selection
if (replaced) {
var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
txtarea.selectionStart = cPos;
txtarea.selectionEnd = cPos;
} else {
txtarea.selectionStart = startPos+tagOpen.length;
txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
}
txtarea.scrollTop = scrollTop;
}
// reposition cursor if possible
if (txtarea.createTextRange)
txtarea.caretPos = document.selection.createRange().duplicate();
}
/*
* Link do brudnopisów w menu osobistym ===
* autor: [[Wikipedysta:Herr Kriss]]
*/
//============================================================
// Papildomų ikonų pridėjimas įrankių juostoje
//============================================================
function addCustomButton() {}
function marque_tab(){
var toolbar = document.getElementById('toolbar');
if (!toolbar) return false;
var textbox = document.getElementById('wpTextbox1');
if (!textbox) return false;
if (!document.selection && textbox.selectionStart === null)
return false;
var image = document.createElement("img");
image.width = 23;
image.height = 22;
image.src = '//upload.wikimedia.org/wikipedia/commons/0/04/Button_array.png';
image.border = 0;
image.alt = 'Lentalė';
image.title = 'Lentalė';
image.style.cursor = "pointer";
image.onclick = function() {
popupTableau();
return false;
};
toolbar.appendChild(image);
}
$(marque_tab);