PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/blocs/menu_horizontal/html/CSSMenu.js

http://malleo-cms.googlecode.com/
JavaScript | 61 lines | 48 code | 8 blank | 5 comment | 16 complexity | f3cdb2cc03e12aa54de345d2d6d9da9d MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1
  1. // Javascript for the CMS CSS Menu Module
  2. // Copyright (c) 2005 Alexander Endresen
  3. // Released under General Public Licence
  4. // This script will emulate the css :hover effect on the menu elements in IE
  5. // The variables
  6. var cssid = "primary-nav"; // CSS ID for the menuwrapper
  7. var apercu_cssid = "apercu_menu"; // CSS ID for the menuwrapper
  8. var menuadd = "h"; // Character to be added to the specific classes upon hovering. So for example, if this is set to "h", class "menuparent" will become "menuparenth" when hovered over.
  9. var menuh = "menuh"; // Classname for hovering over all other menu items
  10. if (window.attachEvent) window.attachEvent("onload", cssHover);
  11. function cssHover() {
  12. var sfEls = document.getElementById(cssid).getElementsByTagName("LI");
  13. for (var i=0; i<sfEls.length; i++) {
  14. sfEls[i].onmouseover=function() {
  15. if (this.className != "") {
  16. this.className = this.className + menuadd;
  17. }
  18. else {
  19. this.className = menuh;
  20. }
  21. }
  22. sfEls[i].onmouseout=function() {
  23. if (this.className == menuh) {
  24. this.className = "";
  25. }
  26. else {
  27. this.className = this.className.replace(new RegExp(menuadd + "$"), "");
  28. }
  29. }
  30. }
  31. if (document.getElementById(apercu_cssid))
  32. {
  33. var apercu_sfEls = document.getElementById(apercu_cssid).getElementsByTagName("LI");
  34. for (var i=0; i<apercu_sfEls.length; i++) {
  35. apercu_sfEls[i].onmouseover=function() {
  36. if (this.className != "") {
  37. this.className = this.className + menuadd;
  38. }
  39. else {
  40. this.className = menuh;
  41. }
  42. }
  43. apercu_sfEls[i].onmouseout=function() {
  44. if (this.className == menuh) {
  45. this.className = "";
  46. }
  47. else {
  48. this.className = this.className.replace(new RegExp(menuadd + "$"), "");
  49. }
  50. }
  51. }
  52. }
  53. }