simplemenu.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // $Id$
  2. $(document).ready(function() {
  3. // get the Drupal basepath
  4. var basePath = Drupal.settings.simplemenu.basePath;
  5. // get the element to add the menu to
  6. var element = Drupal.settings.simplemenu.element;
  7. var menu = '<ul id="simplemenu" class="clear-block"></ul>';
  8. switch (Drupal.settings.simplemenu.placement) {
  9. case 'prepend':
  10. $(menu).prependTo(element);
  11. break;
  12. case 'append':
  13. $(menu).appendTo(element);
  14. break;
  15. case 'replace':
  16. $(element).html(menu);
  17. break;
  18. }
  19. $('body').css('margin-top', '20px');
  20. // Build menu
  21. $('#simplemenu')
  22. .append(simplemenu)
  23. .superfish( { speed: 'fast' } )
  24. .find(">li:has(ul)")
  25. .mouseover(function(){
  26. $("ul", this).bgIframe({opacity:false});
  27. })
  28. .find("a")
  29. .focus(function(){
  30. $("ul", $(".nav>li:has(ul)")).bgIframe({opacity:false});
  31. });
  32. $('#simplemenu').children('li.expanded').addClass('root');
  33. });
  34. /*
  35. * Superfish v1.3 - jQuery menu widget
  36. *
  37. * Copyright (c) 2007 Joel Birch
  38. *
  39. * Dual licensed under the MIT and GPL licenses:
  40. * http://www.opensource.org/licenses/mit-license.php
  41. * http://www.gnu.org/licenses/gpl.html
  42. *
  43. * YOU MAY DELETE THIS CHANGELOG:
  44. * v1.2.1 altered: 2nd July 07. added hide() before animate to make work for jQuery 1.1.3. See comment in 'over' function.
  45. * v1.2.2 altered: 2nd August 07. changed over function .find('ul') to .find('>ul') for smoother animations
  46. * Also deleted the iframe removal lines - not necessary it turns out
  47. * v1.2.3 altered: jquery 1.1.3.1 broke keyboard access - had to change quite a few things and set display:none on the
  48. * .superfish rule in CSS instead of top:-999em
  49. * v1.3 : Pretty much a complete overhaul to make all original features work in 1.1.3.1 and above.
  50. * .superfish rule reverted back to top:-999em (which is better)
  51. */
  52. (function($){
  53. $.fn.superfish = function(o){
  54. var $sf = this,
  55. defaults = {
  56. hoverClass : 'sfHover',
  57. pathClass : 'overideThisToUse',
  58. delay : 800,
  59. animation : {opacity:'show'},
  60. speed : 'normal'
  61. },
  62. over = function(){
  63. clearTimeout(this.sfTimer);
  64. clearTimeout($sf[0].sfTimer);
  65. $(this)
  66. .showSuperfishUl()
  67. .siblings()
  68. .hideSuperfishUl();
  69. },
  70. out = function(){
  71. var $$ = $(this);
  72. if ( !$$.is('.'+o.bcClass) ) {
  73. this.sfTimer=setTimeout(function(){
  74. $$.hideSuperfishUl();
  75. if (!$('.'+o.hoverClass,$sf).length) {
  76. over.call($currents.hideSuperfishUl());
  77. }
  78. },o.delay);
  79. }
  80. };
  81. $.fn.extend({
  82. hideSuperfishUl : function(){
  83. return this
  84. .removeClass(o.hoverClass)
  85. .find('ul:visible')
  86. .hide()
  87. .end();
  88. },
  89. showSuperfishUl : function(){
  90. return this
  91. .addClass(o.hoverClass)
  92. .find('>ul:hidden')
  93. .animate(o.animation,o.speed,function(){
  94. $(this).removeAttr('style');
  95. })
  96. .end();
  97. },
  98. applySuperfishHovers : function(){
  99. return this[($.fn.hoverIntent) ? 'hoverIntent' : 'hover'](over,out);
  100. }
  101. });
  102. o = $.extend({bcClass:'sfbreadcrumb'},defaults,o || {});
  103. var $currents = $('.'+o.pathClass,this).filter('li[ul]');
  104. if ($currents.length) {
  105. $currents.each(function(){
  106. $(this).removeClass(o.pathClass).addClass(o.hoverClass+' '+o.bcClass);
  107. });
  108. }
  109. var $sfHovAr=$('li[ul]',this).applySuperfishHovers(over,out)
  110. .find('a').each(function(){
  111. var $a = $(this), $li = $a.parents('li');
  112. $a.focus(function(){
  113. over.call($li);
  114. return false;
  115. }).blur(function(){
  116. $li.removeClass(o.hoverClass);
  117. });
  118. })
  119. .end()
  120. .not('.'+o.bcClass)
  121. .hideSuperfishUl()
  122. .end();
  123. $(window).unload(function(){
  124. $sfHovAr.unbind('mouseover').unbind('mouseout');
  125. });
  126. return this.addClass('superfish').blur(function(){
  127. out.call(this);
  128. });
  129. };
  130. })(jQuery);
  131. /* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
  132. * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  133. * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
  134. *
  135. * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
  136. * $Rev: 2447 $
  137. *
  138. * Version 2.1.1
  139. */
  140. (function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);