simplemenu.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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({
  24. hoverClass : "sfhover", animation : { opacity:"show", delay: 750 }
  25. })
  26. .find(">li[ul]")
  27. .mouseover(function(){
  28. $("ul", this).bgIframe({opacity:false});
  29. })
  30. .find("a")
  31. .focus(function(){
  32. $("ul", $("#simplemenu>li[ul]")).bgIframe({opacity:false});
  33. });
  34. $('#simplemenu').children('li.expanded').addClass('root');
  35. });
  36. /*
  37. * Superfish - jQuery menu widget
  38. *
  39. * Copyright (c) 2007 Joel Birch
  40. *
  41. * Dual licensed under the MIT and GPL licenses:
  42. * http://www.opensource.org/licenses/mit-license.php
  43. * http://www.gnu.org/licenses/gpl.html
  44. *
  45. * Last updated: 18/3/07 to remove iframes on 'out'
  46. */
  47. (function($){
  48. $.fn.superfish = function(o){
  49. var defaults = {
  50. hoverClass : "sfHover",
  51. delay : 500,
  52. animation : {opacity:"show"},
  53. speed : "normal"
  54. },
  55. over = function(){
  56. var $$ = $(this);
  57. clearTimeout(this.sfTimer);
  58. if (!$$.is("."+o.hoverClass)) {
  59. $$.addClass(o.hoverClass)
  60. .find("ul")
  61. .animate(o.animation,o.speed)
  62. .end()
  63. .siblings()
  64. .removeClass(o.hoverClass);
  65. }
  66. },
  67. out = function(){
  68. var $$ = $(this);
  69. this.sfTimer=setTimeout(function(){
  70. $$.removeClass(o.hoverClass)
  71. .find("iframe", this)
  72. .remove();
  73. },o.delay);
  74. };
  75. o = $.extend(defaults, o || {});
  76. var sfHovAr=$("li",this)
  77. .hover(over,out)
  78. .find("a").each(function() {
  79. var $a = $(this), $li = $a.parents("li");
  80. $a.focus(function(){ $li.each(over); })
  81. .blur(function(){ $li.each(out); });
  82. }).end();
  83. $(window).unload(function() {
  84. sfHovAr.unbind("mouseover").unbind("mouseout");
  85. });
  86. return this;
  87. };
  88. })(jQuery);
  89. /* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
  90. * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  91. * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
  92. *
  93. * $LastChangedDate: 2007-03-07 15:07:51 -0600 (Wed, 07 Mar 2007) $
  94. * $Rev: 1505 $
  95. */
  96. /**
  97. * The bgiframe is chainable and applies the iframe hack to get
  98. * around zIndex issues in IE6. It will only apply itself in IE
  99. * and adds a class to the iframe called 'bgiframe'.
  100. *
  101. * It does take borders into consideration but all values
  102. * need to be in pixels and the element needs to have
  103. * position relative or absolute.
  104. *
  105. * NOTICE: This plugin uses CSS expersions in order to work
  106. * with an element's borders, height and with and can result in poor
  107. * performance when used on an element that changes properties
  108. * like size and position a lot. Two of these expressions can be
  109. * removed if border doesn't matter and performance does.
  110. * See lines 39 and 40 below and set top: 0 and left: 0
  111. * instead of their current values.
  112. *
  113. * @example $('div').bgiframe();
  114. * @before <div><p>Paragraph</p></div>
  115. * @result <div><iframe class="bgiframe".../><p>Paragraph</p></div>
  116. *
  117. * @name bgiframe
  118. * @type jQuery
  119. * @cat Plugins/bgiframe
  120. * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
  121. */
  122. jQuery.fn.bgIframe = jQuery.fn.bgiframe = function() {
  123. // This is only for IE6
  124. if ( !(jQuery.browser.msie && typeof XMLHttpRequest == 'function') ) return this;
  125. var html = '<iframe class="bgiframe" src="javascript:;" tabindex="-1" '
  126. +'style="display:block; position:absolute; '
  127. +'top: expression(((parseInt(this.parentNode.currentStyle.borderTopWidth) || 0) * -1) + \'px\'); '
  128. +'left:expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth) || 0) * -1) + \'px\'); '
  129. +'z-index:-1; filter:Alpha(Opacity=\'0\'); '
  130. +'width:expression(this.parentNode.offsetWidth + \'px\'); '
  131. +'height:expression(this.parentNode.offsetHeight + \'px\')"/>';
  132. return this.each(function() {
  133. if ( !jQuery('iframe.bgiframe', this)[0] )
  134. this.insertBefore( document.createElement(html), this.firstChild );
  135. });
  136. };