Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Dynamiczne menu - dłużej wyświetlane
Forum PHP.pl > Forum > Po stronie przeglądarki > JavaScript
joel-1
Witam!
Posiadam sklep internetowy do którego dodałem dynamiczne menu. Mam tylko jeden problem. Po zjechaniu myszką z menu, menu od razu znika. Chciałbym aby wyświetlało się po zjechaniu myszą przez jakieś 1-2 sekundy. Co trzeba w tym kodzie zmienić?
Z góry dzięki!
  1. //** Smooth Navigational Menu- By Dynamic Drive DHTML code library: <a href="http://www.dynamicdrive.com" target="_blank">http://www.dynamicdrive.com</a>
  2. //** Script Download/ instructions page: <a href="http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/" target="_blank">http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/</a>
  3. //** Menu created: Nov 12, 2008
  4.  
  5. //** Dec 12th, 08" (v1.01): Fixed Shadow issue when multiple LIs within the same UL (level) contain sub menus: <a href="http://www.dynamicdrive.com/forums/showthread.php?t=39177&highlight=smooth" target="_blank">http://www.dynamicdrive.com/forums/showthr...ighlight=smooth</a>
  6.  
  7. // modified for prestashop categories
  8. // marghoob suleman (www.marghoobsuleman.com)
  9.  
  10. var ddsmoothmenu={
  11.  
  12. //Specify full URL to down and right arrow images (23 is padding-right added to top level LIs with drop downs):
  13. arrowimages: {down:['downarrowclass', 'modules/blockcategories/right.gif', 23], right:['rightarrowclass', 'modules/blockcategories/right.gif']},
  14.  
  15. transition: {overtime:300, outtime:300}, //duration of slide in/ out animation, in milliseconds
  16. shadow: {enabled:true, offsetx:5, offsety:5},
  17.  
  18.  
  19. ///////Stop configuring beyond here///////////////////////////
  20.  
  21. detectwebkit: navigator.userAgent.toLowerCase().indexOf("applewebkit")!=-1, //detect WebKit browsers (Safari, Chrome etc)
  22.  
  23. getajaxmenu:function($, setting){ //function to fetch external page containing the panel DIVs
  24. var $menucontainer=$('#'+setting.contentsource[0]) //reference empty div on page that will hold menu
  25. $menucontainer.html("Loading Menu...")
  26. $.ajax({
  27. url: setting.contentsource[1], //path to external menu file
  28. async: true,
  29. error:function(ajaxrequest){
  30. $menucontainer.html('Error fetching content. Server Response: '+ajaxrequest.responseText)
  31. },
  32. success:function(content){
  33. $menucontainer.html(content)
  34. ddsmoothmenu.buildmenu($, setting)
  35. }
  36. })
  37. },
  38.  
  39. buildshadow:function($, $subul){
  40.  
  41. },
  42.  
  43. buildmenu:function($, setting){
  44. var smoothmenu=ddsmoothmenu
  45. var $mainmenu=$("#"+setting.mainmenuid+">ul") //reference main menu UL
  46. var $headers=$mainmenu.find("ul").parent();
  47. //$("#"+setting.mainmenuid).css({height:'auto'});
  48. $headers.each(function(i){
  49. var $curobj=$(this).css({zIndex: 50-i}) //reference current LI header
  50. var $subul=$(this).find('ul:eq(0)').css({display:'block'})
  51. this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
  52. this.istopheader=$curobj.parents("ul").length==1? true : false //is top level header?
  53. $subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
  54. $curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: smoothmenu.arrowimages.down[2]} : {}).append( //add arrow images
  55. '<img src="'+ (this.istopheader? smoothmenu.arrowimages.down[1] : smoothmenu.arrowimages.right[1])
  56. +'" class="' + (this.istopheader? smoothmenu.arrowimages.down[0] : smoothmenu.arrowimages.right[0])
  57. + '" style="border:0;" />'
  58. )
  59. if (smoothmenu.shadow.enabled){
  60. this._shadowoffset={x:(this.istopheader?$subul.offset().left+smoothmenu.shadow.offsetx : this._dimensions.w), y:(this.istopheader? $subul.offset().top+smoothmenu.shadow.offsety : $curobj.position().top)} //store this shadow's offsets
  61. if (this.istopheader)
  62. $parentshadow=$(document.body)
  63. else{
  64. var $parentLi=$curobj.parents("li:eq(0)")
  65. $parentshadow=$parentLi.get(0).$shadow
  66. }
  67. this.$shadow=$('<div class="ddshadow'+(this.istopheader? ' toplevelshadow' : '')+'"></div>').prependTo($parentshadow).css({left:this._shadowoffset.x+'px', top:this._shadowoffset.y+'px'}) //insert shadow DIV and set it to parent node for the next shadow div
  68. }
  69. $curobj.hover(
  70. function(e){
  71. var $targetul=$(this).children("ul:eq(0)")
  72. this._offsets={left:$(this).offset().left, top:$(this).offset().top}
  73. var menuleft=this.istopheader? 0 : this._dimensions.w
  74. menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft //calculate this sub menu's offsets from its parent
  75. if ($targetul.queue().length<=1){ //if 1 or less queued animations
  76. //$targetul.css({top:0+"px", left:(this._dimensions.subulw)+"px", width:this._dimensions.subulw+'px'}).animate({height:'show',opacity:'show'}, ddsmoothmenu.transition.overtime)
  77. $targetul.css({top:0+"px", left:(this._dimensions.subulw)+"px", width:this._dimensions.subulw+'px', display:'block'});
  78. //console.debug(1)
  79. if (smoothmenu.shadow.enabled){
  80. var shadowleft=this.istopheader? $targetul.offset().left+ddsmoothmenu.shadow.offsetx : menuleft
  81. var shadowtop=this.istopheader?$targetul.offset().top+smoothmenu.shadow.offsety : this._shadowoffset.y
  82. if (!this.istopheader && ddsmoothmenu.detectwebkit){ //in WebKit browsers, restore shadow's opacity to full
  83. this.$shadow.css({opacity:1})
  84. }
  85. //this.$shadow.css({overflow:'', width:this._dimensions.subulw+'px', left:shadowleft+'px', top:shadowtop+'px'}).animate({height:this._dimensions.subulh+'px'}, ddsmoothmenu.transition.overtime)
  86. this.$shadow.css({overflow:'', width:this._dimensions.subulw+'px', left:shadowleft+'px', top:shadowtop+'px', height:this._dimensions.subulh+'px', display:'block'})
  87. }
  88. }
  89. },
  90. function(e){
  91. var $targetul=$(this).children("ul:eq(0)")
  92. //$targetul.animate({height:'hide', opacity:'hide'}, ddsmoothmenu.transition.outtime)
  93. $targetul.css({display:'none'});
  94. if (smoothmenu.shadow.enabled){
  95. if (ddsmoothmenu.detectwebkit){ //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them
  96. this.$shadow.children('div:eq(0)').css({opacity:0})
  97. }
  98. //this.$shadow.css({overflow:'hidden'}).animate({height:0}, ddsmoothmenu.transition.outtime)
  99. //alert(this.$shadow + " " + this.$shadow.id);
  100. this.$shadow.css({display:'none'});
  101. }
  102. }
  103. ) //end hover
  104. }) //end $headers.each()
  105. $($mainmenu).find("ul").css({display:'none', visibility:'visible'});
  106. },
  107. init:function(setting){
  108. if (typeof setting.customtheme=="object" && setting.customtheme.length==2){
  109. var mainmenuid='#'+setting.mainmenuid
  110. document.write('<style type="text/css">\n'
  111. +mainmenuid+', '+mainmenuid+' ul li a {background:'+setting.customtheme[0]+';}\n'
  112. +mainmenuid+' ul li a:hover {background:'+setting.customtheme[1]+';}\n'
  113. +'</style>')
  114. }
  115. jQuery(document).ready(function($){ //override default menu colors (default/hover) with custom set?
  116. if (typeof setting.contentsource=="object"){ //if external ajax menu
  117. ddsmoothmenu.getajaxmenu($, setting)
  118. }
  119. else{ //else if markup menu
  120. ddsmoothmenu.buildmenu($, setting)
  121. }
  122. });
  123.  
  124. }
  125.  
  126. } //end ddsmoothmenu variable
  127.  
  128. //Initialize Menu instance(s):
  129.  
  130. ddsmoothmenu.init({
  131. mainmenuid: "smoothmenu1", //menu DIV id
  132. //customtheme: ["#1c5a80", "#18374a"], //override default menu CSS background values? Uncomment: ["normal_background", "hover_background"]
  133. contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
  134. })
AdIoS_Neo
Witam,
możesz podać adres tej strony gdzie to menu działa ?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.