Dwz navtab limit number of opened instances

Source: Internet
Author: User

This article introduces a dwz navtab to limit the number of opened instances. I hope this tutorial will be helpful to you.

Modify dwz/js/dwz. navTab. js


Modify openTab


Change to the following:

The Code is as follows: Copy code


OpenTab: function (tabid, url, options) {// if found tabid replace tab, else create a new tab.
Var op = $. extend ({title: "New Tab", data :{}, fresh: true, external: false}, options );
// It is determined that if the navtab is not loaded and the maximum number of navtabs allowed is exceeded.
If (navTab. _ getTabs (). length> 4)
{
// If it has not been loaded, or
If (navTab. _ indexTabId (tabid) <0)
{
NavTab. _ getTabs (). eq (0). attr ('true _ tabid', tabid );
Tabid = 'main ';
}
}
Else
{
Var real_tabid = navTab. _ getTabs (). eq (0). attr ('true _ tabid ');
If (real_tabid & real_tabid = tabid)
{
Tabid = 'main ';
}
}
Var iOpenIndex = this. _ indexTabId (tabid );


If (iOpenIndex> = 0 ){
Var $ tab = this. _ getTabs (). eq (iOpenIndex );
Var span $ = $ tab. attr ("tabid") = this. _ op. mainTabId? "> Span": "> span ";
$ Tab. find ("> a"). attr ("title", op. title). find (span $). text (op. title );
Var $ panel = this. _ getPanels (). eq (iOpenIndex );
If (op. fresh | $ tab. attr ("url ")! = Url ){
$ Tab. attr ("url", url );
If (op. external | url. isExternalUrl ()){
$ Tab. addClass ("external ");
NavTab. openExternal (url, $ panel );
} Else {
$ Tab. removeClass ("external ");
$ Panel. ajaxUrl ({
Type: "GET", url: url, data: op. data, callback: function (){
NavTab. _ loadUrlCallback ($ panel );
}
});
}
}
This. _ currentIndex = iOpenIndex;
} Else {
Var tabFrag = '<li tabid = "# tabid #"> <a xhref = "javascript: "title =" # title # "class =" # tabid # "> <span> # title # </span> </a> <a xhref =" javascript :; "class =" close "> close </a> </li> ';
This. _ tabBox. append (tabFrag. replaceAll ("# tabid #", tabid). replaceAll ("# title #", op. title ));
This. _ panelBox. append ('<div class = "page unitBox"> </div> ');
This. _ moreBox. append ('<li> <a xhref = "javascript:" title = "# title #"> # title # </a> </li> '. replaceAll ("# title #", op. title ));

Var $ tabs = this. _ getTabs ();
Var $ tab = $ tabs. filter (": last ");
Var $ panel = this. _ getPanels (). filter (": last ");

If (op. external | url. isExternalUrl ()){
$ Tab. addClass ("external ");
NavTab. openExternal (url, $ panel );
} Else {
$ Tab. removeClass ("external ");
$ Panel. ajaxUrl ({
Type: "GET", url: url, data: op. data, callback: function (){
NavTab. _ loadUrlCallback ($ panel );
}
});
}

If ($. History ){
SetTimeout (function (){
$. History. addHistory (tabid, function (tabid ){
Var I = navTab. _ indexTabId (tabid );
If (I> = 0) navTab. _ switchTab (I );
}, Tabid );
}, 10 );
}

This. _ currentIndex = $ tabs. size ()-1;
This. _ contextmenu ($ tabs. filter (": last"). hoverClass ("hover "));
}

This. _ init ();
This. _ scrollCurrent ();

This. _ getTabs (). eq (this. _ currentIndex). attr ("url", url );
}

Related Article

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.