mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
Rewrite nextTab, fix multiple windows
This commit is contained in:
parent
5951a29ce7
commit
db06783c8c
1 changed files with 10 additions and 9 deletions
|
@ -55,15 +55,16 @@ displayTab = (tab_id) ->
|
|||
browser.browserAction.onClicked.addListener(handleBrowserAction)
|
||||
|
||||
nextTab = () ->
|
||||
browser.tabs.query({active:true}).then((tabs) ->
|
||||
id = tabs[0].id
|
||||
index = tabs[0].index
|
||||
desIndex = index + 1
|
||||
browser.tabs.query({}).then((tabs) ->
|
||||
desId = tab for tab in tabs when tab.index == desIndex
|
||||
setTab(desId.id)
|
||||
)
|
||||
)
|
||||
browser.windows.getCurrent().then(
|
||||
(window) ->
|
||||
browser.tabs.query({windowId:window.id}).then(
|
||||
(tabs) ->
|
||||
active = (tab for tab in tabs when tab.active)[0]
|
||||
nextIndex = (active.index + 1) % tabs.length
|
||||
desiredTab = (tab for tab in tabs when tab.index == nextIndex)[0]
|
||||
setTab(desiredTab.id)
|
||||
).catch(console.error)
|
||||
).catch(console.error)
|
||||
|
||||
setTab = (id) ->
|
||||
browser.tabs.update(id,{active:true})
|
||||
|
|
Loading…
Add table
Reference in a new issue