simplemenu.js 2.7 KB

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