漂亮的馅饼菜单jquery中的子菜单

时间:2011-10-05 04:59:59

标签: jquery html5

如何在以下链接中添加子菜单 访问http://www.cs.tut.fi/~laine9/demo/ppmenu/piedemo.html

1 个答案:

答案 0 :(得分:3)

你需要两个 jquery.ui.prettypiemenu.js 一个主菜单。另一个子菜单

在标题内:

<script type="text/javascript" src="js/jquery.ui.prettypiemenu.js"></script>
<script type="text/javascript" src="js/jquery.ui.prettypiesubmenu.js"></script>
<script type="text/javascript">
    $(function () {
        var self = this;
        $("#menuArea").prettypiemenu({
            buttons: [
            { img: "ui-icon-minus", title: "plaah1" },
            { img: "ui-icon-plus", title: "plaah2" },
            { img: "ui-icon-close", title: "plaah3" },
            { img: "ui-icon-minus", title: "plaah4" }
        ],
            onSelection: function (item) {
                $("#SubMenubtn" + item).click(function (event) {
                    event.preventDefault();
                    var offset = $("#SubMenubtn" + item).offset();
                    var h = $("#SubMenubtn" + item).height();
                    var w = $("#SubMenubtn" + item).width();
                    var btn_middle_y = offset.top + h / 2;
                    var btn_middle_x = offset.left + w / 2;
                    $("#subMenuArea" + item).prettypiesubmenu("show", { top: btn_middle_y, left: btn_middle_x });
                    return false;
                });
            },
            closeRadius: 50,
            showTitles: false
        });

        $("#menubtn").button({ icons: { primary: "ui-icon-gear" }, text: false })
    .click(function (event) {
        event.preventDefault();
        var offset = $("#menubtn").offset();
        var h = $("#menubtn").height();
        var w = $("#menubtn").width();
        var btn_middle_y = offset.top + h / 2;
        var btn_middle_x = offset.left + w / 2;
        $("#menuArea").prettypiemenu("show", { top: btn_middle_y, left: btn_middle_x });
        return false;
    });

        $("#subMenuArea0").prettypiesubmenu({
            buttons: [
            { img: "ui-icon-play", title: "plaah1" },
            { img: "ui-icon-play", title: "plaah2" }
        ],
            onSelection: function (item) {
                alert(item + ' Sec was clickedoo!');
            },
            closeRadius: 50,
            showTitles: false
        });

    });
</script>

在正文标记内

<div style="margin: 0px;">
    <button class="circlebtn" id="menubtn">
    </button>
    <span id="menuArea"></span>
    <span id="subMenuArea0"></span>
    <span id="subMenuArea1"></span>
    <span id="subMenuArea2"></span>
</div>