editmenu.js 3.0 KB

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