-1

我有一个用这些参数表示的 jQuery 菜单:

<script type="text/javascript">
            jQuery(document).ready(function(){


                jQuery('#promo').pieMenu({icon : [
                        { 
                            path : "/wp-content/themes/Tersus/images/piemenu/winamp.png",
                            alt  : "Winamp",
                            fn   : function(){('Click:: Plus');window.location.href = 'http://94.23.250.14:2199/tunein/tranceilfm.pls';return false}
                        },  { 
                            path : "/wp-content/themes/Tersus/images/piemenu/vlc.png",
                            alt  : "VLC Media Player",
                            fn   : function(){('Click:: Plus');window.location.href = 'http://94.23.250.14:2199/tunein/tranceilfm.pls';return false}  
                        },{ 
                            path : "/wp-content/themes/Tersus/images/piemenu/QuickTime.png",
                            alt  : "Quick Time Player",
                            fn   : function(){('Click:: Plus');window.location.href = 'http://94.23.250.14:2199/tunein/tranceilfm.qtl';return false}
                        },{ 
                            path : "/wp-content/themes/Tersus/images/piemenu/WMP.png",
                            alt  : "Windows Media Player",
                            fn   : function(){('Click:: Plus');window.location.href = 'http://94.23.250.14:2199/tunein/tranceilfm.asx';return false}
                        },{ 
                            path : "/wp-content/themes/Tersus/images/piemenu/popup.png",
                            alt  : "נגן Popup",
                            fn   : function(){$("#popupplay").click();return false}
                        },{ 
                            path : "/wp-content/themes/Tersus/images/piemenu/iTunes.png",
                            alt  : "iTunes",
                            fn   : function(){alert('...בקרוב');return false}
                        }],
                    beforeMenuOpen: function(){
                        jQuery('<div id="shadow"></div>').css(
                        {
                            'position':'fixed',
                            'background-color':'#000000',
                            'opacity': 0.6,
                            'width':'100%',
                            'height':'100%',
                            'z-index' :999,
                            'top':0,
                            'left':0
                        }).appendTo('body');
                    },
                    beforeMenuClose: function(){
                        jQuery('#shadow').remove();
                    }
                });
            });

        </script>   

该菜单通过右键单击进行操作。我需要将其更改为悬停。

该插件的作者给出了插入内容的片段:

$(document).ready(function(){
//init my jPie
   var jPieMenu = $(#myelement').pieMenu({icon : [ { 
                               path : "path/to/images.png",
                               alt  : "icon",
                               fn   : function(){alert('Click:: icon');return false;}
                          }] });
   $('#myelement').hover(function(){
      if($('#'+jPieMenu.id).css('display') != 'block') //if jpie is not visible
          jPieMenu.initMenu(200,200);
   })
})

唯一的问题是我不知道在哪里插入什么......我总是得到意想不到的令牌。有人可以查看我上面的代码并建议插入它的位置吗?

提前谢谢。

4

4 回答 4

1

您只需将$('#myelement').pieMenu声明替换为现有代码即可。

$(document).ready(function(){
//init my jPie
   var jPieMenu = $('#promo').pieMenu({icon : [ {   // replace these lines with your existing code
                               path : "path/to/images.png",
                               alt  : "icon",
                               fn   : function(){alert('Click:: icon');return false;}
                          }] });
   $('#promo').hover(function(){ // This ID needs to be the same as your element
      if($('#'+jPieMenu.id).css('display') != 'block') //if jpie is not visible
          jPieMenu.initMenu(200,200);
   })
})
于 2012-08-02T13:49:17.047 回答
1

首先,您需要将饼图菜单设置为一个变量,以便您可以引用它的 id:

改变:

jQuery('#promo').pieMenu({icon : [

var pieMenu = jQuery('#promo').pieMenu({icon : [

现在我们有了一种引用菜单本身和包含元素的方法,#promo,我假设它只是一个 div,当悬停在上面时需要关闭菜单。

无论如何,添加这个:

$('#promo').hover(function(){
      if($('#'+pieMenu.id).css('display') != 'block') //if jpie is not visible
          pieMenu.initMenu(200,200);
   })

在最后两组之间}),你应该很高兴。

编辑:是的,给你那个代码的作者错过了一个报价。不过没关系,因为您已经对该部分进行了编码。

于 2012-08-02T13:50:41.983 回答
-1

此外,在第三行的第二个代码块中,#myelement 的开头缺少一个引号,这导致该行中的所有其他内容都充当字符串

于 2012-08-02T13:51:34.290 回答
-1
<script type="text/javascript">
        jQuery(document).ready(function(){


            jQuery('#promo').pieMenu({icon : [
                    { 
                        path : "/wp-content/themes/Tersus/images/piemenu/winamp.png",
                        alt  : "Winamp",
                        fn   : function(){('Click:: Plus');window.location.href = 'http://94.23.250.14:2199/tunein/tranceilfm.pls';return false}
                    },  { 
                        path : "/wp-content/themes/Tersus/images/piemenu/vlc.png",
                        alt  : "VLC Media Player",
                        fn   : function(){('Click:: Plus');window.location.href = 'http://94.23.250.14:2199/tunein/tranceilfm.pls';return false}  
                    },{ 
                        path : "/wp-content/themes/Tersus/images/piemenu/QuickTime.png",
                        alt  : "Quick Time Player",
                        fn   : function(){('Click:: Plus');window.location.href = 'http://94.23.250.14:2199/tunein/tranceilfm.qtl';return false}
                    },{ 
                        path : "/wp-content/themes/Tersus/images/piemenu/WMP.png",
                        alt  : "Windows Media Player",
                        fn   : function(){('Click:: Plus');window.location.href = 'http://94.23.250.14:2199/tunein/tranceilfm.asx';return false}
                    },{ 
                        path : "/wp-content/themes/Tersus/images/piemenu/popup.png",
                        alt  : "נגן Popup",
                        fn   : function(){$("#popupplay").click();return false}
                    },{ 
                        path : "/wp-content/themes/Tersus/images/piemenu/iTunes.png",
                        alt  : "iTunes",
                        fn   : function(){alert('...בקרוב');return false}
                    }],
                beforeMenuOpen: function(){
                    jQuery('<div id="shadow"></div>').css(
                    {
                        'position':'fixed',
                        'background-color':'#000000',
                        'opacity': 0.6,
                        'width':'100%',
                        'height':'100%',
                        'z-index' :999,
                        'top':0,
                        'left':0
                    }).appendTo('body');
                },
                beforeMenuClose: function(){
                    jQuery('#shadow').remove();
                }
            });
            jQuery('#promo').hover(function(){ // This ID needs to be the same as your element
                if(!jQuery('#'+jPieMenu.id).is(":visible")) //if jpie is not visible
                    jPieMenu.initMenu(200,200);
            })
        });

    </script>   
于 2012-08-02T13:53:26.990 回答