Skip to content

Commit

Permalink
use position=after/before/end/start to specify positions
Browse files Browse the repository at this point in the history
Inspired by mrmr1993's idea.
  • Loading branch information
gdh1995 committed Dec 29, 2017
1 parent b28e7ba commit 9cfd859
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions background_scripts/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ TabOperations =
url: Utils.convertToUrl request.url
active: true
windowId: request.tab.windowId
tabConfig.index = request.tab.index + 1 unless request.end
{ position } = request
unless position == "end"
tabConfig.index =
if position == "start"
0
else
request.tab.index + if position == "before" then 0 else 1
tabConfig.active = request.active if request.active?
# Firefox does not support "about:newtab" in chrome.tabs.create.
delete tabConfig["url"] if tabConfig["url"] == Settings.defaults.newTabUrl
Expand Down Expand Up @@ -197,10 +203,10 @@ BackgroundCommands =
chrome.windows.create windowConfig, -> callback request
else
urls = request.urls[..].reverse()
end = request.registryEntry.options.end ? false
position = request.registryEntry.options.position
do openNextUrl = (request) ->
if 0 < urls.length
TabOperations.openUrlInNewTab (extend request, {url: urls.pop(), end}), openNextUrl
TabOperations.openUrlInNewTab (extend request, {url: urls.pop(), position}), openNextUrl
else
callback request
duplicateTab: mkRepeatCommand (request, callback) ->
Expand Down

0 comments on commit 9cfd859

Please sign in to comment.