diff options
| author | Stephen Blott | 2016-09-25 12:41:00 +0100 | 
|---|---|---|
| committer | GitHub | 2016-09-25 12:41:00 +0100 | 
| commit | ab94f80f1a8c264950b9f5559e1675bdd642f9ec (patch) | |
| tree | 09fb71fe9d04ce8111f56a6db2db23d75ef56ce3 /background_scripts | |
| parent | 6678fabf67e662e004f156432e7dd1a9803d7118 (diff) | |
| parent | 46f785a12ccd402d18f178a8711e99e3a871a567 (diff) | |
| download | vimium-ab94f80f1a8c264950b9f5559e1675bdd642f9ec.tar.bz2 | |
Merge pull request #2270 from smblott-github/advanced-toggleMuteTab
Add "all" and "other" options for toggleMuteTab.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 19 | 
1 files changed, 18 insertions, 1 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index d9b527ef..b99b975f 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -155,6 +155,23 @@ TabOperations =        openerTabId: request.tab.id      chrome.tabs.create tabConfig, callback +toggleMuteTab = do -> +  muteTab = (tab) -> chrome.tabs.update tab.id, {muted: !tab.mutedInfo.muted} + +  ({tab: currentTab, registryEntry}) -> +    if registryEntry.options.all? or registryEntry.options.other? +      # If there are any audible, unmuted tabs, then we mute them; otherwise we unmute any muted tabs. +      chrome.tabs.query {audible: true}, (tabs) -> +        if registryEntry.options.other? +          tabs = (tab for tab in tabs when tab.id != currentTab.id) +        audibleUnmutedTabs = (tab for tab in tabs when tab.audible and not tab.mutedInfo.muted) +        if 0 < audibleUnmutedTabs.length +          muteTab tab for tab in audibleUnmutedTabs +        else +          muteTab tab for tab in tabs when tab.mutedInfo.muted +    else +      muteTab currentTab +  #  # Selects the tab with the ID specified in request.id  # @@ -210,7 +227,7 @@ BackgroundCommands =    openCopiedUrlInCurrentTab: (request) -> TabOperations.openUrlInCurrentTab extend request, url: Clipboard.paste()    openCopiedUrlInNewTab: (request) -> @createTab extend request, url: Clipboard.paste()    togglePinTab: ({tab}) -> chrome.tabs.update tab.id, {pinned: !tab.pinned} -  toggleMuteTab: ({tab}) -> chrome.tabs.update tab.id, {muted: !tab.mutedInfo.muted} +  toggleMuteTab: toggleMuteTab    moveTabLeft: moveTab    moveTabRight: moveTab    nextFrame: ({count, frameId, tabId}) -> | 
