simplemenu.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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);
  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. .find('#simplemenu')
  30. .superfish({
  31. pathClass: 'current',
  32. animation: animation,
  33. delay: Drupal.settings.simplemenu.hideDelay,
  34. speed: Drupal.settings.simplemenu.effectSpeed,
  35. autoArrows: false
  36. })
  37. .find(">li:has(ul)")
  38. .mouseover(function(){
  39. $("ul", this).bgIframe();
  40. })
  41. .find("a")
  42. .focus(function(){
  43. $("ul", $(".nav>li:has(ul)")).bgIframe();
  44. })
  45. .end()
  46. .end()
  47. .find("a")
  48. .removeAttr('title');
  49. $('#simplemenu').children('li.expanded').addClass('root');
  50. };
  51. /* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
  52. * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  53. * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
  54. *
  55. * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
  56. * $Rev: 2447 $
  57. *
  58. * Version 2.1.1
  59. */
  60. (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);