Difference: WebScripts ( vs. 1)

Revision 113 May 2008 - ValessioBrito

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="ProjetoGrafico"

Javascript adicionado no site

%STARTINCLUDE%
<script type="text/javascript">
<!-- //

if ( document.all ) {
  // add a class for work arround msie&#180;s css bugs
  $("menu").className += " msie";
}

var zIndex = 10;

$$("#menu ul ul").each( function( ul ) { // para cada UL de sub-menu faça:

    // Pega o link que abre este sub-menu:
    var linkText = ul.parentNode.firstChild;
    // Retira espaço em branco sobrando nas bordas deste:
    linkText.nodeValue = linkText.nodeValue.replace( /^\s*|\s*$/g, "" );

    // Create a link to open this sub-menu:
    var link = document.createElement("a");
    link.href = "#";
    link.className = "linkSubMenu";
    linkText.parentNode.insertBefore( link, linkText );
    link.appendChild( linkText );
    link.parentNode.style.zIndex = zIndex++;
    link.subMenu = ul;
    ul.linkControle = link;

    link.openSubMenu =
      function ( isMouseClick ) {
        if( this.subMenu.style.display == "block" ) {
          if( isMouseClick ) {
            this.subMenu.style.display = "none";
          } else {
            clearTimeout(this.timeOutClose);
            clearTimeout(this.subMenu.timeOutClose);
            return false;
          }
        } else {
          this.subMenu.style.display = "block";
          clearTimeout(this.timeOutClose);
          clearTimeout(this.subMenu.timeOutClose);
        }
      }
    link.closeSubMenu = function(){ this.subMenu.style.display = "none" }

    link.onclick = function(){ this.openSubMenu(true); return false }

    // onmouseout e onmouseover manipulam o menu para pessoas normais
    // onblur e onfocus manipulam o menu para pessoas que precisam navegar com tab

    link.onmouseover = link.onfocus =
      function () {
        this.openSubMenu(false);
      };
    link.onmouseout = link.onblur =
      function () {
        this.timeOutClose = setTimeout( this.closeSubMenu.bind(this), 333 );
      };

    ul.closeSubMenu = function(){ this.style.display = "none" }

    ul.onmouseover = ul.onfocus =
      function () {
        this.blurCalledByIEWorkArroundBug = false;
        clearTimeout(this.timeOutClose);
        clearTimeout(this.linkControle.timeOutClose);
      };
    ul.onmouseout = ul.onblur =
      function () {
        if ( this.blurCalledByIEWorkArroundBug ) { return false }
        this.blurCalledByIEWorkArroundBug = true;
        this.timeOutClose = setTimeout( this.closeSubMenu.bind(this), 333 );
      };
});


////// INI - Work Arround Bug da disgraça do M$IE /////////////////////
if ( document.all ) {
  function forceUlFocusFromLink ( a ) {
    var stop = false;
    a.ancestors().each( function(el) {
      if ( el.id == "menu" ) { stop = true }
      if ( ! stop && el.onfocus ) { el.onfocus() }
    } );
  }
  function forceUlBlurFromLink ( a ) {
    var stop = false;
    a.ancestors().each( function(el) {
      if ( el.id == "menu" ) { stop = true }
      if ( ! stop && el.onblur ) { el.onblur() }
    } );
  }
  $$("#menu ul ul a").each( function( a ) {
    // os links do sub menu forçarão o foco do ul
    if ( a.className == "linkSubMenu" ) {
      a.onfocus = function() {
        forceUlFocusFromLink(this);
        this.openSubMenu(false);
      };
      a.onblur = function() {
        forceUlBlurFromLink(this);
        this.timeOutClose = setTimeout( this.closeSubMenu.bind(this), 333 );
      };
    } else {
      a.onfocus = function() { forceUlFocusFromLink(this) };
      a.onblur  = function() { forceUlBlurFromLink(this)  };
    }
  });
}
////// END - Work Arround Bug da disgraça do M$IE /////////////////////

// -->
</script>
<script type="text/javascript" src="%ATTACHURL%/prototype.js"></script>
%STOPINCLUDE%

META FILEATTACHMENT attachment="prototype.js" attr="" comment="" date="1210708255" name="prototype.js" path="prototype.js" size="126127" stream="prototype.js" user="Main.ValessioBrito" version="1"
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback