To add a right-click menu for the Tab tab of the Easyui _jquery

Source: Internet
Author: User
Pre-preparation work:
1, download demo source, and upgrade to the latest version (jquery 1.7.2,easyui 1.2.6), direct replacement can be, upgrade Easyui is to be the CSS JS theme replace All
2, in the first page of the HTML code: will
Copy Code code as follows:

<div id= "MM" class= "Easyui-menu" style= "width:150px"; >
<div id= "mm-tabupdate" > Refresh </div>
<div class= "Menu-sep" ></div>
<div id= "Mm-tabclose" > Shutdown </div>
<div id= "Mm-tabcloseall" > All close </div>
<div id= "Mm-tabcloseother" > all except Close </div>
<div class= "Menu-sep" ></div>
<div id= "Mm-tabcloseright" > right of the current page all closed </div>
<div id= "Mm-tabcloseleft" > The left of the current page all closed </div>
<div class= "Menu-sep" ></div>
<div id= "Mm-exit" > Exit </div>
</div>

To
Copy Code code as follows:

<div id= "MM" class= "Easyui-menu" style= "width:150px"; >
<div id= "Refresh" > Refresh </div>
<div class= "Menu-sep" ></div>
<div id= "Close" > Shutdown </div>
<div id= "CloseAll" > All close </div>
<div id= "Closeother" > all except Close </div>
<div class= "Menu-sep" ></div>
<div id= "Closeright" > right of the current page all closed </div>
<div id= "Closeleft" > The left of the current page all closed </div>
<div class= "Menu-sep" ></div>
<div id= "Exit" > Exit </div>
</div>

Add a new method to the Outlook2.js as follows:
Copy Code code as follows:

function Closetab (action)
{
var alltabs = $ (' #tabs '). Tabs (' tabs ');
var currenttab =$ (' #tabs '). Tabs (' getselected ');
var alltabtitle = [];
$.each (Alltabs,function (i,n) {
Alltabtitle.push ($ (N). Panel (' Options '). title);
})
Switch (action) {
Case "Refresh":
var iframe = $ (currenttab.panel (' Options '). Content);
var src = iframe.attr (' src ');
$ (' #tabs '). Tabs (' Update '), {
Tab:currenttab,
Options: {
Content:createframe (SRC)
}
})
Break
Case "Close":
var currtab_title = currenttab.panel (' Options '). title;
$ (' #tabs '). Tabs (' Close ', currtab_title);
Break
Case "CloseAll":
$.each (Alltabtitle, function (i, n) {
if (n!= onlyopentitle) {
$ (' #tabs '). Tabs (' Close ', n);
}
});
Break
Case "Closeother":
var currtab_title = currenttab.panel (' Options '). title;
$.each (Alltabtitle, function (i, n) {
if (n!= currtab_title && n!= onlyopentitle)
{
$ (' #tabs '). Tabs (' Close ', n);
}
});
Break
Case "Closeright":
var TabIndex = $ (' #tabs '). Tabs (' Gettabindex ', currenttab);
if (TabIndex = = alltabs.length-1) {
Alert (' Pro, behind No ^@^!! ');
return false;
}
$.each (Alltabtitle, function (i, n) {
if (i > TabIndex) {
if (n!= onlyopentitle) {
$ (' #tabs '). Tabs (' Close ', n);
}
}
});
Break
Case "Closeleft":
var TabIndex = $ (' #tabs '). Tabs (' Gettabindex ', currenttab);
if (TabIndex = = 1) {
Alert (' Kiss, there's someone up front, we can't afford to do this. ^@^!!');
return false;
}
$.each (Alltabtitle, function (i, n) {
if (I < TabIndex) {
if (n!= onlyopentitle) {
$ (' #tabs '). Tabs (' Close ', n);
}
}
});
Break
Case "Exit":
$ (' #closeMenu '). Menu (' hide ');
Break
}
}

The Tabcloseeven method in JS is changed to
Copy Code code as follows:

function Tabcloseeven () {
$ (' #mm '). Menu ({
Onclick:function (item) {
Closetab (item.id);
}
});
return false;
}

This is OK, the code is more elegant than the original!
Call refresh, when the current tab is closed, call Closetab (' action ')//action can be refresh (refresh), close (off)
When used in an IFRAME, be so excrement top.closetab (' action ');
Click here to download the latest Easyui application examples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.