simplemenu.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // $Id$
  2. Drupal.behaviors.simplemenuAttach = function(context) {
  3. // If detect pop-ups setting is enabled and we are in a pop-up window
  4. if (Drupal.settings.simplemenu.detectPopup && window.opener) {
  5. return;
  6. }
  7. // get the element to add the menu to
  8. var element = Drupal.settings.simplemenu.element;
  9. var menu = $(simplemenu).attr("id", "simplemenu").addClass('clear-block');
  10. switch (Drupal.settings.simplemenu.placement) {
  11. case 'prepend':
  12. $(menu).prependTo(element);
  13. break;
  14. case 'append':
  15. $(menu).appendTo(element);
  16. break;
  17. case 'replace':
  18. $(element).html(menu);
  19. break;
  20. }
  21. $('body').addClass('simplemenu-enabled');
  22. var animation = {};
  23. animation[Drupal.settings.simplemenu.effect] = 'toggle';
  24. // Build menu
  25. $(menu)
  26. .superfish( {
  27. animation: animation,
  28. delay: Drupal.settings.simplemenu.hideDelay,
  29. speed: Drupal.settings.simplemenu.effectSpeed
  30. } )
  31. .find(">li:has(ul)")
  32. .mouseover(function(){
  33. $("ul", this).bgIframe();
  34. })
  35. .find("a")
  36. .focus(function(){
  37. $("ul", $(".nav>li:has(ul)")).bgIframe();
  38. })
  39. .end()
  40. .end()
  41. .find("a")
  42. .removeAttr('title');
  43. $('#simplemenu').children('li.expanded').addClass('root');
  44. };
  45. /* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
  46. * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  47. * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
  48. *
  49. * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
  50. * $Rev: 2447 $
  51. *
  52. * Version 2.1.1
  53. */
  54. (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);