Momentálně se pracuje na harmonizaci obsahu českých stránek

Čeština - druhé vydání 2005

MediaWiki:Common.js: Porovnání verzí

Z Demopædia
Přejít na: navigace, hledání
m (naimportována 1 revize)
 
(Není zobrazeno 9 mezilehlých verzí od 3 dalších uživatelů.)
Řádka 1: Řádka 1:
/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky.  */
 
/* N'importe quel JavaScript ici sera chargé pour n'importe quel utilisateur et pour chaque page accédée.
 
 
ATTENTION : Avant de modifier cette page, veuillez tester vos changements avec votre propre
 
monobook.js. Une erreur sur cette page peut faire bugger le site entier (et gêner l'ensemble des
 
visiteurs), même plusieurs heures après la modification !
 
 
NE PAS RETIRER CECI SINON : remplacement des signature, substitution des modèles, ... : <nowiki>
 
 
/*************************************************************/
 
/* Fonctions javascript : pallient les limites de javascript */
 
/* Surveiller : http://www.ecmascript.org/                  */
 
/*************************************************************/
 
 
 
/**
 
/**
  * insertAfter : insérer un élément dans une page
+
  * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
  */
+
  * loaded for all users on every wiki page. If possible create a gadget that is
function insertAfter(parent, node, referenceNode) {
+
  * enabled by default instead of adding it here (since gadgets are fully
  parent.insertBefore(node, referenceNode.nextSibling);
+
  * optimized ResourceLoader modules with possibility to add dependencies etc.)
}
 
 
 
function hasClass(node, className) {
 
  if (node.className == className) {
 
    return true;
 
  }
 
  var reg = new RegExp('(^| )'+ className +'($| )')
 
  if (reg.test(node.className)) {
 
    return true;
 
  }
 
  return false;
 
}
 
   
 
 
 
/**  
 
  * Boîtes déroulantes
 
 
  *
 
  *
  * Pour [[Modèle:Méta palette de navigation]]
+
  * Since Common.js isn't a gadget, there is no place to declare its
*/
+
* dependencies, so we have to lazy load them with mw.loader.using on demand and
 
+
* then execute the rest in the callback. In most cases these dependencies will
var autoCollapse = 2;
+
* be loaded (or loading) already and the callback will not be delayed. In case a
var collapseCaption = '[ Enrouler ]';
+
  * dependency hasn't arrived yet it'll make sure those are loaded before this.
var expandCaption = '[ Dérouler ]';
 
 
 
function collapseTable( tableIndex ) {
 
  var Button = document.getElementById( "collapseButton" + tableIndex );
 
  var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
  if ( !Table || !Button ) return false;
 
 
 
  var Rows = Table.getElementsByTagName( "tr" );
 
 
 
  if ( Button.firstChild.data == collapseCaption ) {
 
    for ( var i = 1; i < Rows.length; i++ ) {
 
      Rows[i].style.display = "none";
 
    }
 
    Button.firstChild.data = expandCaption;
 
  } else {
 
    for ( var i = 1; i < Rows.length; i++ ) {
 
      Rows[i].style.display = Rows[0].style.display;
 
    }
 
    Button.firstChild.data = collapseCaption;
 
  }
 
}
 
 
 
function createCollapseButtons() {
 
  var tableIndex = 0;
 
  var NavigationBoxes = new Object();
 
  var Tables = document.getElementsByTagName( "table" );
 
 
 
  for ( var i = 0; i < Tables.length; i++ ) {
 
    if ( hasClass( Tables[i], "collapsible" ) ) {
 
      NavigationBoxes[ tableIndex ] = Tables[i];
 
      Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
 
 
      var Button    = document.createElement( "span" );
 
      var ButtonLink = document.createElement( "a" );
 
      var ButtonText = document.createTextNode( collapseCaption );
 
 
 
      Button.style.styleFloat = "right";
 
      Button.style.cssFloat = "right";
 
      Button.style.fontWeight = "normal";
 
      Button.style.textAlign = "right";
 
      Button.style.width = "6em";
 
 
 
      ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
 
      ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
 
      ButtonLink.appendChild( ButtonText );
 
 
 
      Button.appendChild( ButtonLink );
 
 
 
      var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
 
      /* only add button and increment count if there is a header row to work with */
 
      if (Header) {
 
        Header.insertBefore( Button, Header.childNodes[0] );
 
        tableIndex++;
 
      }
 
    }
 
  }
 
 
 
  for (var i = 0; i < tableIndex; i++) {
 
    if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) collapseTable( i );
 
  }
 
}
 
 
 
addOnloadHook(createCollapseButtons);
 
 
 
/**
 
  * Pour [[Modèle:Boîte déroulante]]
 
 
  */
 
  */
var NavigationBarShowDefault = 0;
 
 
function toggleNavigationBar(indexNavigationBar) {
 
  var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
 
  var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
 
 
  if (!NavFrame || !NavToggle) return;
 
 
  // surcharge des libellés dérouler/enrouler grâce a l'attribut title
 
  // exemple : title="[déroulade]/[enroulade]"
 
  var caption = [expandCaption, collapseCaption];
 
  if (NavFrame.title && NavFrame.title.length > 0) {
 
    caption = NavFrame.title.split("/");
 
    if (caption.length < 2) caption.push(collapseCaption);
 
  }
 
 
  // if shown now
 
  if (NavToggle.firstChild.data == caption[1]) {
 
    for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
 
      if (hasClass(NavChild, 'NavPic')) NavChild.style.display = 'none';
 
      if (hasClass(NavChild, 'NavContent')) NavChild.style.display = 'none';
 
      if (hasClass(NavChild, 'NavToggle')) NavChild.firstChild.data = caption[0];
 
    }
 
 
  // if hidden now
 
  } else if (NavToggle.firstChild.data == caption[0]) {
 
    for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
 
      if (hasClass(NavChild, 'NavPic')) NavChild.style.display = 'block';
 
      if (hasClass(NavChild, 'NavContent')) NavChild.style.display = 'block';
 
      if (hasClass(NavChild, 'NavToggle')) NavChild.firstChild.data = caption[1];
 
    }
 
  }
 
}
 
 
// adds show/hide-button to navigation bars
 
function createNavigationBarToggleButton() {
 
  var indexNavigationBar = 0;
 
  var NavFrame;
 
  // iterate over all < div >-elements
 
  for( var i=0; NavFrame = document.getElementsByTagName("div")[i]; i++ ) {
 
    // if found a navigation bar
 
    if (hasClass(NavFrame, "NavFrame")) {
 
      indexNavigationBar++;
 
      var NavToggle = document.createElement("a");
 
      NavToggle.className = 'NavToggle';
 
      NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
 
      NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
 
 
      // surcharge des libellés dérouler/enrouler grâce a l'attribut title
 
      var caption = collapseCaption;
 
      if (NavFrame.title && NavFrame.title.indexOf("/") > 0) {
 
        caption = NavFrame.title.split("/")[1];
 
      }
 
 
      var NavToggleText = document.createTextNode(caption);
 
      NavToggle.appendChild(NavToggleText);
 
 
      // add NavToggle-Button as first div-element
 
      // in <div class="NavFrame">
 
      NavFrame.insertBefore( NavToggle, NavFrame.firstChild );
 
      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);
 
    }
 
  }
 
}
 
 
addOnloadHook(createNavigationBarToggleButton);
 
 
 
 
//</nowiki>
 

Aktuální verze z 25. 6. 2017, 22:18

/**
 * Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
 * loaded for all users on every wiki page. If possible create a gadget that is
 * enabled by default instead of adding it here (since gadgets are fully
 * optimized ResourceLoader modules with possibility to add dependencies etc.)
 *
 * Since Common.js isn't a gadget, there is no place to declare its
 * dependencies, so we have to lazy load them with mw.loader.using on demand and
 * then execute the rest in the callback. In most cases these dependencies will
 * be loaded (or loading) already and the callback will not be delayed. In case a
 * dependency hasn't arrived yet it'll make sure those are loaded before this.
 */