simplemenu.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // $Id$
  2. (function($){
  3. Drupal.behaviors.simplemenuAttach = {
  4. attach: function(context, settings) {
  5. // If detect pop-ups setting is enabled and we are in a pop-up window
  6. if (settings.simplemenu.detectPopup && window.opener) {
  7. return;
  8. }
  9. if ($('body').hasClass('simplemenu-enabled')) {
  10. return;
  11. }
  12. $('body').addClass('simplemenu-enabled');
  13. // get the element to add the menu to
  14. var element = settings.simplemenu.element;
  15. if ($(element).length == 0) {
  16. // this happens when you open a pop-up or a different theme
  17. // that does not have such an element or the named element
  18. // just does not exist in the first place.
  19. return;
  20. }
  21. var menu = $(simplemenu);
  22. switch (settings.simplemenu.placement) {
  23. case 'prepend':
  24. $(menu).prependTo(element);
  25. break;
  26. case 'append':
  27. $(menu).appendTo(element);
  28. break;
  29. case 'replace':
  30. $(element).html(menu);
  31. break;
  32. }
  33. var animation = {};
  34. animation[settings.simplemenu.effect] = 'toggle';
  35. // Build menu
  36. $(menu)
  37. .find('#simplemenu')
  38. .superfish({
  39. pathClass: 'current',
  40. animation: animation,
  41. delay: settings.simplemenu.hideDelay,
  42. speed: settings.simplemenu.effectSpeed,
  43. autoArrows: false
  44. })
  45. .find(">li:has(ul)")
  46. .mouseover(function(){
  47. $("ul", this).bgIframe();
  48. })
  49. .find("a")
  50. .focus(function(){
  51. $("ul", $(".nav>li:has(ul)")).bgIframe();
  52. })
  53. .end()
  54. .end()
  55. .find("a")
  56. .removeAttr('title');
  57. $('#simplemenu').children('li.expanded').addClass('root');
  58. }
  59. };
  60. })(jQuery);
  61. /* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
  62. * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  63. * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
  64. *
  65. * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
  66. * $Rev: 2447 $
  67. *
  68. * Version 2.1.1
  69. */
  70. (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);