From ca6f303b3d39f0e7bdeae6d239f124baefc4571b Mon Sep 17 00:00:00 2001 From: Bernardo B. Marques Date: Fri, 16 Dec 2011 01:44:42 -0200 Subject: add support to go to the first or last tab --- background_page.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'background_page.html') diff --git a/background_page.html b/background_page.html index b334f7b1..5866ee48 100644 --- a/background_page.html +++ b/background_page.html @@ -331,9 +331,11 @@ function nextTab(callback) { selectTab(callback, "next"); } function previousTab(callback) { selectTab(callback, "previous"); } + function firstTab(callback) { selectTab(callback, "first"); } + function lastTab(callback) { selectTab(callback, "last"); } /* - * Selects a tab before or after the currently selected tab. Direction is either "next" or "previous". + * Selects a tab before or after the currently selected tab. Direction is either "next", "previous", "first" or "last". */ function selectTab(callback, direction) { chrome.tabs.getAllInWindow(null, function(tabs) { @@ -347,6 +349,12 @@ case "previous": toSelect = tabs[(currentTab.index - 1 + tabs.length) % tabs.length]; break; + case "first": + toSelect = tabs[0]; + break; + case "last": + toSelect = tabs[tabs.length - 1]; + break; } selectionChangedHandlers.push(callback); chrome.tabs.update(toSelect.id, { selected: true }); -- cgit v1.2.3