Display closed context menu when right-click tab tab is added
Specific implementation code:
Right-click menu HTML:
<div id= "MM" class= "Easyui-menu" style= "width:150px;" >
<div id= "Mm-tabclose" > Close </div>
<div id= "Mm-tabcloseall" > Close all </div>
<div id= "Mm-tabcloseother" > all except Close </div>
<div class= "Menu-sep" ></div>
<div id= "mm-tabcloseright" > Current page right all close </div>
<div id= "Mm-tabcloseleft" > current page left all close </div>
</div>
Here is the JS code:
$ (function () {
Tabclose ();
Tabcloseeven ();
})
function Tabclose ()
{
/* Double-click to close Tab TAB */
$ (". Tabs-inner"). DblClick (function () {
var subtitle = $ (this). Children ("span"). text ();
$ (' #tabs '). Tabs (' Close ', subtitle);
});
$ (". Tabs-inner"). Bind (' ContextMenu ', function (e) {
$ (' #mm '). Menu (' show ', {
Left:e.pagex,
Top:e.pagey,
});
var subtitle =$ (this). Children ("span"). text ();
$ (' #mm '). Data ("Currtab", subtitle);
return false;
});
}
Binding Right-click menu events
function Tabcloseeven () {
Close the current
$ (' #mm-tabclose '). Click (function () {
var currtab_title = $ (' #mm '). Data ("Currtab");
$ (' #tabs '). Tabs (' Close ', currtab_title);
});
Close all
$ (' #mm-tabcloseall '). Click (function () {
$ ('. Tabs-inner span '). each (function (i,n) {
var t = $ (n). text ();
$ (' #tabs '). Tabs (' Close ', t);
});
});
Close tab except for current
$ (' #mm-tabcloseother '). Click (function () {
var currtab_title = $ (' #mm '). Data ("Currtab");
$ ('. Tabs-inner span '). each (function (i,n) {
var t = $ (n). text ();
if (t!=currtab_title)
$ (' #tabs '). Tabs (' Close ', t);
});
});
Close the current tab on the right
$ (' #mm-tabcloseright '). Click (function () {
var Nextall = $ ('. tabs-selected '). Nextall ();
if (nextall.length==0) {
Msgshow (' System hint ', ' there is no ~ ~ ', ' error ');
Alert (' No Back ~ ~ ');
return false;
}
Nextall.each (function (i,n) {
var t=$ (' a:eq (0) span ', $ (n)). text ();
$ (' #tabs '). Tabs (' Close ', t);
});
return false;
});
Close the tab at the left of the current
$ (' #mm-tabcloseleft '). Click (function () {
var Prevall = $ ('. tabs-selected '). Prevall ();
if (prevall.length==0) {
Alert (' At the end, not in front ~ ~ ');
return false;
}
Prevall.each (function (i,n) {
var t=$ (' a:eq (0) span ', $ (n)). text ();
$ (' #tabs '). Tabs (' Close ', t);
});
return false;
});
}
Add the right-click menu function for the tab component of Jquery-easyui