Added example for the highlight method. (#126)

* Made corrections about support and code intent
This commit is contained in:
Rahul Yesantharao
2016-11-03 14:32:37 -05:00
committed by wbamberg
parent c42a263968
commit a3782445bf
2 changed files with 12 additions and 1 deletions

View File

@@ -30,7 +30,11 @@
<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>
<a href="#" id="tabs-decrease-zoom">Zoom out</a><br>
<div class="panel-section-separator"></div>
<a href="#" id="tabs-highlight">Highlight (only supported by Chrome)</a>
</div>

View File

@@ -121,6 +121,13 @@ document.addEventListener("click", function(e) {
});
});
}
// Currently (11/2/2016) only supported by Chrome
else if (e.target.id === "tabs-highlight") { // highlights current tab and next tab (cycles back to first tab if current tab is the last one)
callOnActiveTab((tab, tabs) => {
next = (tab.index+1) % tabs.length;
chrome.tabs.highlight({tabs:[tab.index, next]});
});
}
e.preventDefault();
});