Added tabs.onRemoved and tabs.onMoved examples (#118)

This commit is contained in:
Flávio da Silva Rodrigues Almeida
2016-10-31 15:58:44 -02:00
committed by wbamberg
parent b7048d83df
commit 81c4b3381c
2 changed files with 18 additions and 1 deletions

View File

@@ -28,7 +28,6 @@
<div class="panel-section-separator"></div>
<a href="#" id="tabs-add-zoom">Zoom in</a><br>
<a href="#" id="tabs-default-zoom">Reset zoom</a><br>
<a href="#" id="tabs-decrease-zoom">Zoom out</a>

View File

@@ -124,3 +124,21 @@ document.addEventListener("click", function(e) {
e.preventDefault();
});
//onRemoved listener. fired when tab is removed
chrome.tabs.onRemoved.addListener(function(tabId, removeInfo){
console.log(`The tab with id: ${tabId}, is closing`);
if(removeInfo.isWindowClosing) {
console.log(`Its window is also closing.`);
} else {
console.log(`Its window is not closing`);
}
});
//onMoved listener. fired when tab is moved into the same window
chrome.tabs.onMoved.addListener(function(tabId, moveInfo){
var startIndex = moveInfo.fromIndex;
var endIndex = moveInfo.toIndex;
console.log(`Tab with id: ${tabId} moved from index: ${startIndex} to index: ${endIndex}`);
});