summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidney <xinyij@ca.ibm.com>2016-11-23 10:07:49 -0500
committerSilenio Quarti <Silenio_Quarti@ca.ibm.com>2016-11-24 10:44:34 -0400
commite55f970624d10b2216a589f5e94258a20b58813b (patch)
tree653c8db5ca824a604bad2a5737849c42f4c3aed4
parent490923ff91aebdabd297e46c58e5e095f9b44379 (diff)
downloadorg.eclipse.orion.client-e55f970624d10b2216a589f5e94258a20b58813b.zip
org.eclipse.orion.client-e55f970624d10b2216a589f5e94258a20b58813b.tar.gz
org.eclipse.orion.client-e55f970624d10b2216a589f5e94258a20b58813b.tar.bz2
Bug 507704 - Add a corresponding Icon for each tab based on the page's icon
Change-Id: Id3e8a11cfa2ed769d081da20dc75e2ebf045e45f Signed-off-by: Sidney <xinyij@ca.ibm.com>
-rw-r--r--modules/orionode/lib/main.html3
-rw-r--r--modules/orionode/lib/main.js15
2 files changed, 18 insertions, 0 deletions
diff --git a/modules/orionode/lib/main.html b/modules/orionode/lib/main.html
index 4889b43..cb11181 100644
--- a/modules/orionode/lib/main.html
+++ b/modules/orionode/lib/main.html
@@ -45,6 +45,9 @@ body {
white-space: nowrap;
flex: 1 1 auto;
}
+.tabIcon{
+ padding-right: 3px;
+}
.tabs ul {
list-style: none;
-webkit-margin-before: 0;
diff --git a/modules/orionode/lib/main.js b/modules/orionode/lib/main.js
index 0ef87e7..bd06b1c 100644
--- a/modules/orionode/lib/main.js
+++ b/modules/orionode/lib/main.js
@@ -72,6 +72,9 @@ function addNewTab(id, iframe) {
var text = document.createElement("span");
text.classList.add("tabLabel");
text.textContent = title;
+ var icon = document.createElement("img");
+ icon.classList.add("tabIcon");
+ tab.appendChild(icon);
tab.appendChild(text);
tab.title = title;
@@ -171,6 +174,16 @@ function setTabLabel(id, str) {
var text = tab.querySelector(".tabLabel");
tab.title = text.textContent = str;
}
+function setTabIcon(id,head) {
+ var linkIconElement = Array.prototype.find.call(head.childNodes, function(node){
+ return node.nodeName === 'LINK' && node.rel === 'icon';
+ });
+ if(linkIconElement && linkIconElement.href){
+ var tab = document.getElementById("tab" + id);
+ var icon = tab.querySelector(".tabIcon");
+ icon.src = linkIconElement.href;
+ }
+}
function update() {
var bar = document.querySelector("#bar");
@@ -234,6 +247,7 @@ function createTab(url) {
var observer = new window.WebKitMutationObserver(function(mutations) {
if (mutations) {
setTabLabel(id, iframe.contentDocument.title);
+ setTabIcon(id,iframe.contentDocument.head);
}
});
observer.observe(target, {
@@ -243,6 +257,7 @@ function createTab(url) {
});
}
setTabLabel(id, iframe.contentDocument.title);
+ setTabIcon(id, iframe.contentDocument.head);
iframe.contentWindow.addEventListener("click", function() {
var menu = document.querySelector("#context-menu");
var activeClassName = "context-menu-items-open";