aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2014-11-23 13:42:03 +0000
committerStephen Blott2014-11-23 13:42:03 +0000
commit91b123a40e1d5eb54e771461e271f94051618c62 (patch)
tree075629ef6e0ce0f0ed1647d74e48bcc9f1e40df5 /background_scripts
parent3863e724241408338c9c69af72117584c1258d34 (diff)
downloadvimium-91b123a40e1d5eb54e771461e271f94051618c62.tar.bz2
Frames; tidy up.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/main.coffee25
1 files changed, 11 insertions, 14 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index aac63213..cda4f118 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -598,27 +598,24 @@ openOptionsPageInNewTab = ->
registerFrame = (request, sender) ->
frames = frameIdsForTab[sender.tab.id] ?= []
- return if request.is_frameset # Don't store frameset containers; focusing them is no use.
- if request.is_top
- frames.unshift request.frameId
- else
- frames.push request.frameId
+ unless request.is_frameset # Don't store frameset containers; focusing them is no use.
+ if request.is_top then frames.unshift request.frameId else frames.push request.frameId
unregisterFrame = (request, sender) ->
- frames = frameIdsForTab[sender.tab.id]
- return unless frames?
+ tabId = sender.tab.id
+ return unless frameIdsForTab[tabId]?
if request.is_top # The whole tab is closing, so we can drop the frames list.
updateOpenTabs sender.tab
- else if not request.if_frameset
- index = frames.indexOf request.frameId
- return if index == -1
- frames.splice index, 1
- nextFrame 0 if index == 0
+ else
+ removingCurrent = frameIdsForTab[tabId].length and frameIdsForTab[tabId][0] == request.frameId
+ frameIdsForTab[tabId] = (id for id in frameIdsForTab[tabId] when id != request.frameId)
+ BackGroundCommands.nextFrame 0 if removingCurrent
handleFrameFocused = (request, sender) ->
- index = frameIdsForTab[sender.tab.id].indexOf request.frameId
- frameIdsForTab[sender.tab.id] = frames.rotate index
+ tabId = sender.tab.id
+ frameIdsForTab[tabId] =
+ [request.frameId, (id for id in frameIdsForTab[tabId] when id != request.frameId)...]
# Port handler mapping
portHandlers =