Advertisement
lbreda

RitoBar

Jan 7th, 2013
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // BEGIN Rito
  2.  
  3. // set up the words in your language
  4. var RitoRomano = 'Rito Romano';
  5. var RitoAmbrosiano = 'RitoAmbrosiano';
  6.  
  7.  
  8. // Cambia il rito mostrato
  9. // Parameters:
  10. //     indexRito: indice del box da mostrare
  11. function toggleRito(indexRito)
  12. {
  13.    var NavToggle = document.getElementById("RitoToggle" + indexNavigationBar);
  14.    var NavFrame = document.getElementById("RitoFrame" + indexNavigationBar);
  15.  
  16.    if (!RitoFrame || !RitoToggle) {
  17.        return false;
  18.    }
  19.  
  20.    // se รจ mostrato il rito romano
  21.    if (RitoToggle.firstChild.data == RitoRomano) {
  22.        for (
  23.                var RitoChild = RitoFrame.firstChild;
  24.                RitoChild != null;
  25.                RitoChild = RitoChild.nextSibling
  26.            ) {
  27.            if (hasClass(RitoChild, 'RitoPic')) {
  28.                RitoChild.style.display = 'none';
  29.                RitoChild.nextSibling.style.display = 'block';
  30.            }
  31.            if (hasClass(RitoChild, 'RitoContent')) {
  32.                RitoChild.style.display = 'none';
  33.                RitoChild.nextSibling.style.display = 'block';
  34.            }
  35.            if (hasClass(RitoChild, 'RitoToggle')) {
  36.                RitoChild.firstChild.data = RitoAmbrosiano;
  37.            }
  38.        }
  39.  
  40.    // Altrimenti
  41.    } else if (RitoToggle.firstChild.data == RitoAmbrosiano) {
  42.        for (
  43.                var RitoChild = RitoFrame.firstChild;
  44.                RitoChild != null;
  45.                RitoChild = RitoChild.nextSibling
  46.            ) {
  47.            if (hasClass(RitoChild, 'RitoPic')) {
  48.                RitoChild.style.display = 'block';
  49.                RitoChild.nextSibling.style.display = 'none';
  50.            }
  51.            if (hasClass(NavChild, 'NavContent')) {
  52.                NavChild.style.display = 'block';
  53.                RitoChild.nextSibling.style.display = 'none';
  54.            }
  55.            if (hasClass(NavChild, 'NavToggle')) {
  56.                NavChild.firstChild.data = RitoRomano;
  57.            }
  58.        }
  59.    }
  60. }
  61.  
  62. // Aggiunge il link per cambiare rito, nella barra
  63. function createRitoBarToggleButton()
  64. {
  65.    var indexRitoBar = 0;
  66.    // iterate over all < div >-elements
  67.    for(
  68.            var i=0;
  69.            RitoFrame = document.getElementsByTagName("div")[i];
  70.            i++
  71.        ) {
  72.        // Se trova un div che fa da barra superiore a un box rito
  73.        if (hasClass(RitoFrame, 'RitoFrame')) {
  74.  
  75.            indexRitoBar++;
  76.            var RitoToggle = document.createElement("a");
  77.            RitoToggle.className = 'RitoToggle';
  78.            RitoToggle.setAttribute('id', 'RitoToggle' + indexRito);
  79.            RitoToggle.setAttribute('href', 'javascript:toggleRito(' + indexRito + ');');
  80.  
  81.            var RitoToggleText = document.createTextNode(RitoAmbrosiano);
  82.            RitoToggle.appendChild(RitoToggleText);
  83.  
  84.            // aggiunge il bottone come primo div in
  85.            // < div class="RitoFrame" >
  86.            RitoFrame.insertBefore(
  87.                RitoToggle,
  88.                RitoFrame.firstChild
  89.            );
  90.            RitoFrame.setAttribute('id', 'RitoFrame' + indexRitoBar);
  91.        }
  92.    }
  93. }
  94.  
  95. aOnloadFunctions[aOnloadFunctions.length] = createRitoBarToggleButton;
  96.  
  97. // END Dynamic Navigation Bars
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement