首页 > 其他 > 详细

菜单栏的使用

时间:2014-04-13 14:36:19      阅读:476      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
<div id="tabs" class="easyui-tabs" data-options="plain:true,fit:true,border:‘false‘">
</div>
<div id="mm" class="easyui-menu" style="width:150px;">
        <div id="tabupdate">刷新</div>
        <div class="menu-sep"></div>
        <div id="mm-tabclose">关闭</div>
        <div id="mm-tabcloseall">关闭全部</div>
        <div id="mm-tabcloseother">关闭其他</div>
        <div class="menu-sep"></div>
        <div id="mm-tabcloseright">关闭右侧标签</div>
        <div id="mm-tabcloseleft">关闭左侧标签</div>
    </div>


        $(function () {
            bindTabEvent();
            bindTabMenuEvent();
        });

        //绑定tab的双击事件、右键事件
        function bindTabEvent() {
            $(".tabs-inner").live(dblclick, function () {
                var subtitle = $(this).children("span").text();
                if ($(this).next().is(.tabs-close)) {
                    $(#tabs).tabs(close, subtitle);
                }
            });
            $(".tabs-inner").live(contextmenu, function (e) {
                $(#mm).menu(show, {
                    left: e.pageX,
                    top: e.pageY
                });
                var subtitle = $(this).children("span").text();
                $(#mm).data("currtab", subtitle);
         
bubuko.com,布布扣
 $(#tabs).tabs(select, subtitle);//右击时触发切换选
bubuko.com,布布扣
return false;
            });
        }
        //绑定tab右键菜单事件
        function bindTabMenuEvent() {
            //刷新
            $(#tabupdate).click(function () {
                var currentTab = $(#tabs).tabs(getSelected);
                var iframe = $(currentTab.panel(options).content);
                var url = iframe.attr(src);//获得连接
                var title = currentTab.panel(options).title;//获得表头信息
                var content = "<iframe scrolling=‘auto‘ frameborder=‘0‘  src=‘"
                        + url + "‘ style=‘width:100%;height:100%;‘></iframe>";

                $(#tabs).tabs(update, {
                    tab: currentTab,
                    options: {
                        content: content
                    }
                });
            });
            //关闭当前
            $(#mm-tabclose).click(function () {
                var currtab_title = $(#mm).data("currtab");
                $(#tabs).tabs(close, currtab_title);
            });
            //全部关闭
            $(#mm-tabcloseall).click(function () {
                $(.tabs-inner span).each(function (i, n) {
                    if ($(this).parent().next().is(.tabs-close)) {
                        var t = $(n).text();
                        $(#tabs).tabs(close, t);
                    }
                });
            });
            //关闭除当前之外的TAB
            $(#mm-tabcloseother).click(function () {
                var currtab_title = $(#mm).data("currtab");
                $(.tabs-inner span).each(function (i, n) {
                    if ($(this).parent().next().is(.tabs-close)) {
                        var t = $(n).text();
                        if (t != currtab_title)
                            $(#tabs).tabs(close, t);
                    }
                });
            });
            //关闭当前右侧的TAB
            $(#mm-tabcloseright).click(function () {
                var nextall = $(.tabs-selected).nextAll();
                if (nextall.length == 0) {
                    alert(已经是最后一个了);
                    return false;
                }
                nextall.each(function (i, n) {
                    if ($(a.tabs-close, $(n)).length > 0) {
                        var t = $(a:eq(0) span, $(n)).text();
                        $(#tabs).tabs(close, t);
                    }
                });
                return false;
            });
            //关闭当前左侧的TAB
            $(#mm-tabcloseleft).click(function () {
                var prevall = $(.tabs-selected).prevAll();
                if (prevall.length == 1) {
                    alert(已经是第一个了);
                    return false;
                }
                prevall.each(function (i, n) {
                    if ($(a.tabs-close, $(n)).length > 0) {
                        var t = $(a:eq(0) span, $(n)).text();
                        $(#tabs).tabs(close, t);
                    }
                });
                return false;
            });
        }
bubuko.com,布布扣
bubuko.com,布布扣
function addTab(title, url) {
            if ($(#tabs).tabs(exists, title)) {
                $(#tabs).tabs(select, title);
            } else {
                var content = "<iframe scrolling=‘auto‘ frameborder=‘0‘  src=‘"
                        + url + "‘ style=‘width:100%;height:100%;‘></iframe>";
                $(#tabs).tabs(add, {
                    title: title,
                    content: content,
                    closable: true,
                    iconCls: icon-add
                });
            }
        };
bubuko.com,布布扣

 

菜单栏的使用,布布扣,bubuko.com

菜单栏的使用

原文:http://www.cnblogs.com/zhao123/p/3660154.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!