home *** CD-ROM | disk | FTP | other *** search
/ mcgregor.k12.mn.us / www.mcgregor.k12.mn.us.tar / www.mcgregor.k12.mn.us / ourschoolmenu-collapsed.js < prev    next >
Text File  |  2010-09-08  |  2KB  |  93 lines

  1.  
  2. /* 
  3.    Simple JQuery Collapsing menu.
  4.    HTML structure to use:
  5.  
  6.    <ul id="menu">
  7.      <li><a href="#">Sub menu heading</a>
  8.      <ul>
  9.        <li><a href="http://site.com/">Link</a></li>
  10.        <li><a href="http://site.com/">Link</a></li>
  11.        <li><a href="http://site.com/">Link</a></li>
  12.        ...
  13.        ...
  14.      </ul>
  15.      <li><a href="#">Sub menu heading</a>
  16.      <ul>
  17.        <li><a href="http://site.com/">Link</a></li>
  18.        <li><a href="http://site.com/">Link</a></li>
  19.        <li><a href="http://site.com/">Link</a></li>
  20.        ...
  21.        ...
  22.      </ul>
  23.      ...
  24.      ...
  25.    </ul>
  26.  
  27. Copyright 2007 by Marco van Hylckama Vlieg
  28.  
  29. web: http://www.i-marco.nl/weblog/
  30. email: marco@i-marco.nl
  31.  
  32. Free for non-commercial use
  33. */
  34.  
  35. function initMenus() {
  36. $('ul.menu ul').hide();
  37. $.each($('ul.menu'), function(){
  38. $('#' + this.id + '.expandfirst ul:first').show();
  39. });
  40. $('ul.menu li a').click(
  41. function() {
  42. var checkElement = $(this).next();
  43. var parent = this.parentNode.parentNode.id;
  44. if($('#' + parent).hasClass('noaccordion')) {
  45. $(this).next().slideToggle('normal');
  46. return false;
  47. }
  48. if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
  49. if($('#' + parent).hasClass('collapsible')) {
  50. $('#' + parent + ' ul:visible').slideUp('normal');
  51. }
  52. return false;
  53. }
  54. if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
  55. $('#' + parent + ' ul:visible').slideUp('normal');
  56. checkElement.slideDown('normal');
  57. return false;
  58. }
  59. }
  60. );
  61. }
  62. $(document).ready(function() {initMenus();});
  63.  
  64. if (location.pathname == 'aboutSchool.php')
  65. {
  66. //place jQuery code to be run here
  67.  
  68. $("#m1").slideDown("slow");
  69. }
  70. else if (location.pathname == 'examplepage.php')
  71. {
  72. $("#m2").slideDown("slow");
  73. }
  74. //...add more "else if" statements here, BEFORE "else" statement
  75. else
  76. {
  77. //if all other conditions are not met, then run the code that is placed here.
  78. //leave blank if you don't want anything else to happen.
  79. }
  80.  
  81.  
  82. function initMenu() {
  83.   $('#menu ul').hide();
  84.   $('#menu li a').hover(
  85.     function() {
  86.         $(this).next().slideToggle('slow');    
  87.         return false;
  88.       }
  89.     );
  90.   }
  91. $(document).ready(function() {initMenu();});
  92.  
  93.