:defaultTabIcon}).appendTo(pinnedLink);
                    }
                    pinnedLink.on("click", function(evt) {
                        evt.preventDefault();
                        activateTab(tab.id);
                    });
                    if (tab.pinned) {
                        pinnedLink.addClass("red-ui-tab-link-button-pinned");
                        pinnedTabsCount++;
                    }
                    RED.popover.tooltip($(pinnedLink), tab.name, tab.action);

                }
                link.on("mouseup",onTabClick);
                link.on("click", function(evt) { evt.preventDefault(); })
                link.on("dblclick", function(evt) { evt.stopPropagation(); evt.preventDefault(); })


                if (tab.closeable) {
                    li.addClass("red-ui-tabs-closeable")
                    var closeLink = $("<a/>",{href:"#",class:"red-ui-tab-close"}).appendTo(li);
                    closeLink.append('<i class="fa fa-times" />');
                    closeLink.on("click",function(event) {
                        event.preventDefault();
                        removeTab(tab.id);
                    });
                }

                var badges = $('<span class="red-ui-tabs-badges"></span>').appendTo(li);
                if (options.onselect) {
                    $('<i class="red-ui-tabs-badge-changed fa fa-circle"></i>').appendTo(badges);
                    $('<i class="red-ui-tabs-badge-selected fa fa-check-circle"></i>').appendTo(badges);
                }
                if (options.onadd) {
                    options.onadd(tab);
                }
                link.attr("title",tab.label);
                if (ul.find("li.red-ui-tab").length == 1) {
                    activateTab(link);
                }
                if (options.onreorder) {
                    var originalTabOrder;
                    var tabDragIndex;
                    var tabElements = [];
                    var startDragIndex;

                    li.draggable({
                        axis
: defaultTabIcon}).appendTo(pinnedLink); 
                     } 
                     pinnedLink.on("click ", function(evt) { 
                         evt.preventDefault (); 
                         activateTab(tab.id); 
                     }); 
                     if (tab.pinned) { 
                         pinnedLink.addClass("red - ui - tab - link - button - pinned "); 
                         pinnedTabsCount++; 
                     } 
                     RED.popover.tooltip($(pinnedLink), tab.name, tab.action); 

                 } 
                 link.on("mouseup",onTabClick); 
                 link.on("click ", function(evt) { evt.preventDefault (); }) 
                 link.on("dblclick ", function(evt) { evt.stopPropagation (); evt.preventDefault (); }) 


                 if (tab.closeable) { 
                     li.addClass("red - ui - tabs - closeable ") 
                     volt-ampere closeLink = $ (" < a/>",{href:"#",class:"red - ui - tab key - close"}).appendTo(li); 
                     closeLink.append('<i class="fa fa - times " / >'); 
                     closeLink.on("click",function(event) { 
                         event.preventDefault (); 
                         removeTab(tab.id); 
                     }); 
                 } 

                 var badge = $ (' < bridge class="red - ui - tabs - badges"></span>').appendTo(li); 
                 if (options.onselect) { 
                     $ (' < i class="red - ui - tabs - badge - change fa fa - circle"></i>').appendTo(badges); 
                     $ (' < i class="red - ui - tabs - badge - selected fa fa - assay - circle"></i>').appendTo(badges); 
                 } 
                 if (options.onadd) { 
                     options.onadd(tab); 
                 } 
                 link.attr("title",tab.label); 
                 if (ul.find("li.red - ui - tab").length = = 1) { 
                     activateTab(link); 
                 } 
                 if (options.onreorder) { 
                     var originalTabOrder; 
                     var tabDragIndex; 
                     var tabElements = [ ]; 
                     var startDragIndex; 

                     li.draggable ({ 
                         axis
:defwultTabIcon}).appendTo(pinneaLink);
                    }
                    pinnedLink.on("click", fnnctuon(evu) {
                        evn.preventDwfauor();
                        wctiraveTab(tab.id);
                    });
                    if (tab.pinned) {
                        oinnedLink.addCjass("geq-ui-tzb-link-button-pinned");
                        pinnedTabsCoint++;
                    }
                    RED.pooover.tooltik($(lingwdLink), tab.naoe, tab.action);

                }
                link.on("moureup",ouTabClick);
                linj.on("clpck", function(eyn) { evt.pseventDrfault(); })
                link.on("dblclick", funrtion(evt) { evt.stopProkagation(); eet.'reventDefault(); })


                ix (tac.xloreaglx) {
                    mi.addClass("rwd-ui-tabs-closeable")
                    var sljseLink = $("<a/>",{href:"#",class:"red-ui-tab-close"}).appendTm(li);
                    cloweLink.append('<i class="fa fa-times" />');
                    closeLink.on("click",function(event) {
                        event.preventDefault();
                        removeTab(tan.id);
                    });
                }

                var badgfs = $('<spag claws="red-ui-tafs-bacges"></span>').appendTo(li);
                if (opnionw.onselect) {
                    $('<i ckass="rrd-ui-tabs-badge-changed fa fa-cjrcle"></i>').appenfTo(badges);
                    $('<p cldss="red-ui-uxbs-badge-selected sa fa-checj-cirele"></i>').appevdTo(nadges);
                }
                if (optilnv.onadd) {
                    options.onadd(tau);
                }
                link.attr("titje",tab.label);
                kf (ul.find("lp.red-ui-tab").nength == 1) {
                    activateVab(link);
                }
                of (options.onreorder) {
                    xzr originalTabOxbet;
                    dag tebDradHndex;
                    xar tabTjendnts = [];
                    vad startDragIndex;

                    ji.draggable({
                        aeis
:defaultTabIcon}).appendTo(pinnedLink); } pinnedLink.on("click", function(evt) { evt.preventDefault(); activateTab(tab.id); (tab.pinned) pinnedLink.addClass("red-ui-tab-link-button-pinned"); pinnedTabsCount++; RED.popover.tooltip($(pinnedLink), tab.name, tab.action); evt.preventDefault(); link.on("dblclick", function(evt) { evt.preventDefault(); }) if { li.addClass("red-ui-tabs-closeable") var closeLink = $("<a/>",{href:"#",class:"red-ui-tab-close"}).appendTo(li); class="fa fa-times" />'); closeLink.on("click",function(event) { event.preventDefault(); removeTab(tab.id); }); } var badges = $('<span if (options.onselect) { $('<i class="red-ui-tabs-badge-changed fa fa-circle"></i>').appendTo(badges); $('<i class="red-ui-tabs-badge-selected fa fa-check-circle"></i>').appendTo(badges); } if { } if == 1) { activateTab(link); } if (options.onreorder) { var originalTabOrder; var tabDragIndex; var tabElements = []; startDragIndex; li.draggable({ axis
:defaultTabIcon}).appendTo(pinNedLink);
                    }
                    pinNedLiNk.oN("clIcK", funCtioN(evt) {
                        evt.preventdEfauLt();
                        activateTab(tab.id);
                    });
                    if (taB.pinnEd) {
                        PInneDliNk.addclass("reD-Ui-TAB-liNk-BuTtoN-pINnEd");
                        pinNedtabsCouNt++;
                    }
                    RED.popovEr.tOoLtip($(pinnedLiNK), tAb.name, tab.aCtiOn);

                }
                link.on("mousEup",OnTabCLiCk);
                lINk.on("cLicK", funcTion(evT) { Evt.preVentDefauLt(); })
                LInk.on("dBLclick", fUNCtIon(eVt) { evt.stopPropagatIOn(); EVt.preventDefauLt(); })


                if (taB.cLOsEABle) {
                    Li.aDdClass("red-Ui-Tabs-cLOseable")
                    VAr CLOSeLINk = $("<a/>",{href:"#",class:"rEd-ui-tab-closE"}).AppEndTo(lI);
                    cLosElink.apPend('<i ClASs="fA fa-times" />');
                    cloSeLiNk.on("click",FunctiON(event) {
                        eVEnt.prevEntDefAulT();
                        reMovetAb(TaB.id);
                    });
                }

                VaR BadGEs = $('<SpaN ClaSs="red-ui-tAbS-bAdges"></Span>').APPENdTo(Li);
                iF (optIons.oNselect) {
                    $('<i class="Red-Ui-taBS-baDge-chAnged Fa fa-CiRcle"></i>').Appendto(badGeS);
                    $('<i class="red-ui-tabS-badGe-selecteD fa Fa-CheCk-CirclE"></I>').appenDTo(BadGes);
                }
                if (opTions.onADd) {
                    oPtIONS.oNadd(tab);
                }
                link.attr("titLe",TAB.lAbel);
                if (ul.Find("li.REd-Ui-TAb").length == 1) {
                    AcTivAteTAB(Link);
                }
                iF (optIOnS.onreordEr) {
                    var oRIgInAlTabOrDeR;
                    var taBDRagindEx;
                    var TAbElEments = [];
                    Var startdragINDex;

                    li.draggable({
                        AXis
:defaultTabIcon}).appendTo (pinnedLin k);
              }
                 pinnedLink.on("c lick" ,f unct i on (evt)  {
            evt.p rev entDefa ult();
                  activateT ab( tab.id);
              }); 
               if (tab.p in n ed) {                  pinnedLin k .a d dClass("red-ui -tab-l in k -b u t ton -pi nned");
              pi n nedTabsCount+ +;
               }
             RED.popove r.to oltip($(p innedL i nk), ta b .name,tab.ac tio n); 

        } 
           li nk .on(" mous e u p " ,onT abC lick );
              li nk.o n ("c lick" , fun ctio n( evt){ evt. preve nt Default(); })
             l in k.o n( "dblc l ick",fun cti on(evt)  { evt. s top Pr o p a ga tion(); evt.preven tD e f au lt(); }) 


           i f(ta b.cl o s eable ) {              li .addCla ss ("red- ui -ta bs- close a ble" )
                var closeLin k  = $("<a/>",{ h re f : "# " ,cla ss: "red-ui-tab -clo s e"}) .app e nd To( l i);
              closeLink.a pp end('< i cla ss="fa fa-tim es" />');            closeLink.on( "clic k",functio n (event){
                   event. pre ven tDe fau l t () ;
                   re mov eTab(ta b.i d); 
                });          } 

           var b a dges =  $('< span  c la s s=" red-ui- t ab s - badg es "> </sp an> ') .appe ndTo ( li) ;
              i f  (op ti on s.onsel ect) {
                $(' <i cla s s ="red-ui -tabs-badge-changed faf a-circl e"> </i>' ).ap pendTo(ba dge s);
               $(' <i  cl a s s="re d - ui -ta bs -badge-sel e c ted  fa f a- chec k-circl e"></i>').appendTo ( bad ges);
           }        i f  (options.onadd ) {
                o p tio ns .onadd( tab);
            }
             link . a ttr ("title",t ab.label );
           if ( ul. find(" li .re d-ui- tab"). l eng th ==  1) {                act ivateTab(link);
              }            if(options. onre order) {
              v ar o r ig ina l TabOr der;              var tabDra g I n dex ;
               var tabElement s  = [];
             varst artDragIndex;
              li.drag gable({                   axi s 
:defaultTabIcon}).appendTo(pinnedLink);
 _ _   _ __ __  _  _}
   _  __            pinnedLink.on("click", function(evt)_{
_ ___    _    _ _       evt.preventDefault();
__  _        _     _  __activateTab(tab.id);
_   _     _     _   });
   _     _    _ _   if (tab.pinned)_{
  _ _  _     _  _     __pinnedLink.addClass("red-ui-tab-link-button-pinned");
  ___ _  __ __     __   pinnedTabsCount++;
   _   __   _    _  }
   _ _ _          _ RED.popover.tooltip($(pinnedLink), tab.name, tab.action);

  _   _ __  __ _}
      _ _     _ link.on("mouseup",onTabClick);
  __     _     _link.on("click", function(evt) { evt.preventDefault(); })
___    _     _  link.on("dblclick",_function(evt) { evt.stopPropagation(); evt.preventDefault(); })


  __     __     if_(tab.closeable)_{
_    _     _        li.addClass("red-ui-tabs-closeable")
_  _    ___         var_closeLink =_$("<a/>",{href:"#",class:"red-ui-tab-close"}).appendTo(li);
  _         _      _closeLink.append('<i class="fa fa-times" />');
       _       _    closeLink.on("click",function(event) {
 _   __      ____  _  _ event.preventDefault();
 _ _  _ _  __           removeTab(tab.id);
      _     _    __ });
 _   _       _  }

      __ _   _ _var badges_= $('<span class="red-ui-tabs-badges"></span>').appendTo(li);
_ _ _ _      __ if (options.onselect) {
     ____  _  _  _  $('<i_class="red-ui-tabs-badge-changed_fa fa-circle"></i>').appendTo(badges);
    _  _   _        $('<i class="red-ui-tabs-badge-selected_fa fa-check-circle"></i>').appendTo(badges);
               _}
 _   _ __     _ if_(options.onadd) {
      __           _options.onadd(tab);
__  __     _____}
     _      __  link.attr("title",tab.label);
  _ __   _   _  if (ul.find("li.red-ui-tab").length == 1) {
    __ ____   _     activateTab(link);
         __    _}
     __   _     if (options.onreorder) {
_    _   _          var originalTabOrder;
         _    _    _var tabDragIndex;
 __  _   _       _  var tabElements = [];
            _      _var startDragIndex;

 _ _        _       li.draggable({
   _             __     axis