Пређи на садржај

Медијавики:Monobook.js

Iz Vojne Enciklopedije
(разл) ← Старија измена | Тренутна верзија (разл) | Новија измена → (разл)

Напомена: Пошто објавите измене, можда ћете морати да обришете кеш прегледача како бисте их видели.

  • Firefox / Safari: Држите Shift и кликните на Reload или притисните Ctrl-F5 или Ctrl-R (⌘-R на Mac-у).
  • Google Chrome: Притисните Ctrl-Shift-R (⌘-Shift-R на Mac-у).
  • Edge: Држите Ctrl и кликните на Refresh или притисните Ctrl-F5.
/* Javaskript postavljen ovde će se učitati za sve one koji koriste temu „Monobuk“ */


//  Iz Srpske Vikipedije

/*
{{interwiki-all}} <pre>
*/

if (window.showModalDialog && document.compatMode && document.compatMode == "CSS1Compat" && navigator.appName == "Microsoft Internet Explorer")
{
  var oldWidth;
  var docEl = document.documentElement;

  function fixIEScroll()
  {
    if (!oldWidth || docEl.clientWidth > oldWidth)
      doFixIEScroll();
    else
      setTimeout(doFixIEScroll, 1);
  
    oldWidth = docEl.clientWidth;
  }

  function doFixIEScroll() {
    docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
  }

  document.attachEvent("onreadystatechange", fixIEScroll);
  attachEvent("onresize", fixIEScroll);
}

function addLoadEvent(func) 
{
  if (window.addEventListener) 
    window.addEventListener("load", func, false);
  else if (window.attachEvent) 
    window.attachEvent("onload", func);
}


 // ============================================================
 // BEGIN Dynamic Navigation Bars (experimantal)
 
 // 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 = 0;
 
 
 // shows and hides content and picture (if available) of navigation bars
 // Parameters:
 //     indexNavigationBar: the index of navigation bar to be toggled
 function toggleNavigationBar(indexNavigationBar)
 {
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
 
    if (!NavFrame || !NavToggle) {
        return false;
    }
 
    // if shown now
    if (NavToggle.firstChild.data == NavigationBarHide) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild != null;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'none';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
 
    // if hidden now
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
        for (
                var NavChild = NavFrame.firstChild;
                NavChild != null;
                NavChild = NavChild.nextSibling
            ) {
            if (NavChild.className == 'NavPic') {
                NavChild.style.display = 'block';
            }
            if (NavChild.className == 'NavContent') {
                NavChild.style.display = 'block';
            }
        }
    NavToggle.firstChild.data = NavigationBarHide;
    }
 }
 
 // adds show/hide-button to navigation bars
 function createNavigationBarToggleButton()
 {
    var indexNavigationBar = 0;
    // iterate over all < div >-elements
    for(
            var i=0; 
            NavFrame = document.getElementsByTagName("div")[i]; 
            i++
        ) {
        // if found a navigation bar
        if (NavFrame.className == "NavFrame") {
 
            indexNavigationBar++;
            var NavToggle = document.createElement("a");
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
            
            var NavToggleText = document.createTextNode(NavigationBarHide);
            NavToggle.appendChild(NavToggleText);
            // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
            for(
              var j=0; 
              j < NavFrame.childNodes.length; 
              j++
            ) {
              if (NavFrame.childNodes[j].className == "NavHead") {
                NavFrame.childNodes[j].appendChild(NavToggle);
              }
            }
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
        }
    }
    // if more Navigation Bars found than Default: hide all
    if (NavigationBarShowDefault < indexNavigationBar) {
        for(
                var i=1; 
                i<=indexNavigationBar; 
                i++
        ) {
            toggleNavigationBar(i);
        }
    }
 
 }
 
 addLoadEvent(createNavigationBarToggleButton);
 
 // END Dynamic Navigation Bars
 // ============================================================
 //

// * Déplacement des [modifier]
// * Correction des titres qui s'affichent mal en raison de limitations dues à MediaWiki.
//
// Copyright 2006, Marc Mongenet
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// See http://www.gnu.org/licenses/gpl.html

// The function looks for <span class="editsection">, and move them
// at the end of their parent and display them inline in small font.
// var oldEditsectionLinks=true disables the function.

setModifySectionStyle = function()
{
try {
        if (!(typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false)) return;
        var spans = document.getElementsByTagName("span");
        for (var s = 0; s < spans.length; ++s) {
                var span = spans[s];
                if (span.className == "editsection") {
                        span.style.fontSize = "xx-small";
                        span.style.fontWeight = "normal";
                        span.style.cssFloat = span.style.styleFloat = "none";
                        span.className = "editsectionmoved";
                        span.parentNode.appendChild(document.createTextNode(" "));
                        span.parentNode.appendChild(span);
                }
        }
} catch (e) { /* something went wrong */ }
}
$(setModifySectionStyle);


/* add menu for selecting subsets of secial characters */
/***** must match MediaWiki:Edittools *****/

function addCharSubsetMenu() {
  var specialchars = document.getElementById('specialchars');

  if (specialchars) {
    var menu = "<select id=\"charsetBox\" style=\"display:inline\" onkeyup=\"chooseCharSubset(selectedIndex)\" onChange=\"chooseCharSubset(selectedIndex)\">";
    menu += "<option>Viki</option>";
    menu += "<option>Latinski/Romanski</option>";
    menu += "<option>Ćirilica</option>";
    menu += "<option>Grčki</option>";
    menu += "<option>Esperanto</option>";
    menu += "<option>Estonski</option>";
    menu += "<option>Irski</option>";
    menu += "<option>Islandski</option>";
    menu += "<option>Italijanski</option>";
    menu += "<option>Jidiš</option>";
    menu += "<option>Katalonski</option>";
    menu += "<option>Letonski</option>";
    menu += "<option>Litvanski</option>";
    menu += "<option>Lužičkosrpski</option>";
    menu += "<option>Mađarski</option>";
    menu += "<option>Malteški</option>";
    menu += "<option>Nemački</option>";
    menu += "<option>Poljski</option>";
    menu += "<option>Portugalski</option>";
    menu += "<option>Rumunski</option>";
    menu += "<option>Skandinavski</option>";
    menu += "<option>Staroengleski</option>";
    menu += "<option>Turski</option>";
    menu += "<option>Francuski</option>";
    menu += "<option>Hijeroglifi</option>";
    menu += "<option>Hrvatski</option>";
    menu += "<option>Češki/Slovački</option>";
    menu += "<option>Španski</option>";
    menu += "<option>IPA</option>";
    menu += "<option>Matematika</option>";
    menu += "</select>";
    specialchars.innerHTML = menu + specialchars.innerHTML;

    /* default subset - try to use a cookie some day */
    chooseCharSubset(0);
  }
}

/* select subsection of special characters */
function chooseCharSubset(s) {
  var l = document.getElementById('specialchars').getElementsByTagName('p');
  for (var i = 0; i < l.length ; i++) {
    l[i].style.display = i == s ? 'inline' : 'none';
    l[i].style.visibility = i == s ? 'visible' : 'hidden';
  }
}

$(addCharSubsetMenu);

/**
 * Transformer les pages du Bistro en page de discussion
 */
function DiscussionBistro() 
{
  if(document.title.search("Vojna Enciklopedija:Pomoć") != -1)
    document.body.className = "ns-1";
}
     
addLoadEvent(DiscussionBistro);

// Glavna

var mpTitle = "Главна страна";
var mpTitlelat = "Glavna strana";
var isMainPage = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle || document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitlelat);
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));

if (isMainPage && !isDiff) 
{
document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');

var mpSmallEnabled;
var mpMinWidth = 700;

function mainPageTransform()
{
       if ((isMainPage || /[\/=:]Pagina_principale/.test(document.location)) && document.getElementById('ca-nstab-main'))     
       document.getElementById('ca-nstab-main').firstChild.innerHTML = 'Главна страна';
	var mpContentEl = document.getElementById("bodyContent");
	var mpBrowseEl = document.getElementById("EnWpMpBrowse");
	var mpContainEl = document.getElementById("EnWpMpBrowseContainer");
	var mpMarginEl = document.getElementById("EnWpMpMargin");
	var mpEl = document.getElementById("EnWpMainPage");

	if (!mpContentEl || !mpBrowseEl || !mpContainEl || !mpMarginEl || !mpEl)
		return;

	if (!mpSmallEnabled && mpContentEl.offsetWidth < mpMinWidth)
	{
		mpContainEl.insertBefore(mpBrowseEl, mpContainEl.firstChild);
		mpBrowseEl.className = "EnWpMpBrowseBottom";
		mpMarginEl.style.marginRight = 0;
		mpSmallEnabled = true;
	}
	else if (mpSmallEnabled && mpContentEl.offsetWidth > mpMinWidth)
	{
		mpEl.insertBefore(mpBrowseEl, mpEl.firstChild);
		mpBrowseEl.className = "EnWpMpBrowseRight";
		mpMarginEl.style.marginRight = "13.8em";
		mpSmallEnabled = false;
	}
}

var onloadFuncts = [ mainPageTransform ];

if (window.addEventListener) 
  window.addEventListener("resize", mainPageTransform, false);
else if (window.attachEvent) 
  window.attachEvent("onresize", mainPageTransform);

}

/*
</pre>
*/




 // ============================================================