//v0.2 //- fix for switching to wrong tab when closing tabs in destination //- fix for switching to wrong tab when closing inactive/invisible tabs //v0.1 //- initial prototype released in a thread I don't remember currently. // ahh, it was this one: http://resource.dopus.com/viewtopic.php?f=3&t=24028 /////////////////////////////////////////////////////////////////////////////// function OnInit(data){ //uid added via script wizard (do not change after publishing this script) var uid = "57B93B6D-A93E-4593-BAB5-3302B2DA20D8"; //resource center url added via script wizard (required for updating) var url = "http://resource.dopus.com/viewtopic.php?f=35&t=24626"; data.name = "Event.GUI: ActivateLeftTabOnClose"; data.desc = "Activate the tab to the left when closing a tab, instead of activating the one previously used."; data.version = "0.2"; data.min_version = "11.5"; data.copyright = "tbone" data.default_enable = true; } /////////////////////////////////////////////////////////////////////////////// function OnCloseTab(data) { if (!data.tab.visible){ //tab not visible, doing nothing special to activate any another tab //as closing a tab currently not used, shall not switch active/visible tabs return false; } var cmd = DOpus.Create.Command(); cmd.SetSourceTab(data.tab); var focusRight = data.tab.lister.activetab.right; var focusToggled = false; if (focusRight != data.tab.right){ cmd.RunCommand("Set FOCUS=dest"); focusToggled = true; } CloseTab(data.tab, cmd); //setting sourcetab again, as the last tab is gone now //else any additional commands will fail to run cmd.SetSourceTab(data.tab.lister.activetab); if (focusToggled){ cmd.RunCommand("Set FOCUS=dest"); } return true; } /////////////////////////////////////////////////////////////////////////////// function CloseTab(tab, command) { var tabDetails = GetTabDetails(tab); if (tabDetails.index===null) return; command.RunCommand("Go NOSCRIPT TABSELECT " + (tabDetails.index>0?tabDetails.index-1:tabDetails.index+1)); command.RunCommand("Go NOSCRIPT TABCLOSE " + tab ); } /////////////////////////////////////////////////////////////////////////////// function GetTabDetails(tab){ var tabDetails = { isLeft:true, isRight:false, index:null}; var tabs = tab.lister.tabsleft; if (tab.right){ tabs = tab.lister.tabsright; tabDetails.isRight = true; tabDetails.isLeft = false; } for (var i=0;i