|
@ -159,7 +159,15 @@ vAPI.tabs.open = function(details) { |
|
|
active: !!details.active |
|
|
active: !!details.active |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if ( details.tabId ) { |
|
|
|
|
|
|
|
|
if ( !details.tabId ) { |
|
|
|
|
|
if ( details.index !== undefined ) { |
|
|
|
|
|
_details.index = details.index; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
chrome.tabs.create(_details); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// update doesn't accept index, must use move
|
|
|
// update doesn't accept index, must use move
|
|
|
chrome.tabs.update(parseInt(details.tabId, 10), _details, function(tab) { |
|
|
chrome.tabs.update(parseInt(details.tabId, 10), _details, function(tab) { |
|
|
// if the tab doesn't exist
|
|
|
// if the tab doesn't exist
|
|
@ -169,16 +177,13 @@ vAPI.tabs.open = function(details) { |
|
|
chrome.tabs.move(tab.id, {index: details.index}); |
|
|
chrome.tabs.move(tab.id, {index: details.index}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
|
|
|
if ( details.index !== undefined ) { |
|
|
|
|
|
_details.index = details.index; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chrome.tabs.create(_details); |
|
|
|
|
|
|
|
|
if ( details.index !== -1 ) { |
|
|
|
|
|
subWrapper(); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if ( details.index === -1 ) { |
|
|
|
|
|
vAPI.tabs.get(null, function(tab) { |
|
|
vAPI.tabs.get(null, function(tab) { |
|
|
if ( tab ) { |
|
|
if ( tab ) { |
|
|
details.index = tab.index + 1; |
|
|
details.index = tab.index + 1; |
|
@ -188,20 +193,21 @@ vAPI.tabs.open = function(details) { |
|
|
|
|
|
|
|
|
subWrapper(); |
|
|
subWrapper(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
subWrapper(); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if ( details.select ) { |
|
|
|
|
|
chrome.tabs.query({ currentWindow: true }, function(tabs) { |
|
|
|
|
|
|
|
|
if ( !details.select ) { |
|
|
|
|
|
wrapper(); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
chrome.tabs.query({}, function(tabs) { |
|
|
var rgxHash = /#.*/; |
|
|
var rgxHash = /#.*/; |
|
|
// this is questionable
|
|
|
// this is questionable
|
|
|
var url = targetURL.replace(rgxHash, ''); |
|
|
var url = targetURL.replace(rgxHash, ''); |
|
|
var selected = tabs.some(function(tab) { |
|
|
var selected = tabs.some(function(tab) { |
|
|
if ( tab.url.replace(rgxHash, '') === url ) { |
|
|
if ( tab.url.replace(rgxHash, '') === url ) { |
|
|
chrome.tabs.update(tab.id, { active: true }); |
|
|
chrome.tabs.update(tab.id, { active: true }); |
|
|
|
|
|
chrome.windows.update(tab.windowId, { focused: true }); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -210,10 +216,6 @@ vAPI.tabs.open = function(details) { |
|
|
wrapper(); |
|
|
wrapper(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
wrapper(); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|