From 4d4e0adb3ab623da15b95f4fbb38cc19f0a188d7 Mon Sep 17 00:00:00 2001 From: Matt Fryer Date: Mon, 15 Mar 2021 15:52:02 +0000 Subject: [PATCH 1/4] New sidebar items open in new window option --- dist/custom-sidebar.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/custom-sidebar.js b/dist/custom-sidebar.js index a5af861..1140aa1 100644 --- a/dist/custom-sidebar.js +++ b/dist/custom-sidebar.js @@ -162,6 +162,9 @@ function createItem(elements, item) { cln.querySelector("paper-icon-item").querySelector("ha-icon").setAttribute("icon", item.icon); cln.querySelector("paper-icon-item").querySelector("span").innerHTML = item.item; cln.href = item.href; + if (item.open_new == true) { + cln.setAttribute("target", "_blank"); + } cln.setAttribute("data-panel", item.item); elements.insertBefore(cln, elements.children[0]); } From 27774f98888d42467fa3f90fc2b8f3d9d94546fc Mon Sep 17 00:00:00 2001 From: Matt Fryer Date: Mon, 15 Mar 2021 15:56:59 +0000 Subject: [PATCH 2/4] Made open_new work for existing items also --- dist/custom-sidebar.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist/custom-sidebar.js b/dist/custom-sidebar.js index 1140aa1..421fd88 100644 --- a/dist/custom-sidebar.js +++ b/dist/custom-sidebar.js @@ -196,6 +196,10 @@ function moveItem(elements, config_entry) { if (config_entry.href) { elements.children[i].href = config_entry.href; } + + if (config_entry.open_nef) { + elements.children[i].setAttribute("target", "_blank"); + } if (config_entry.name) { elements.children[i].children[0].getElementsByTagName("span")[0].innerHTML = elements.children[i].children[0].getElementsByTagName("span")[0].innerHTML.replace(current, config_entry.name); From a6cecc97ad651323a1304b01cb69b5fc72f80005 Mon Sep 17 00:00:00 2001 From: Matt Fryer Date: Mon, 15 Mar 2021 15:59:26 +0000 Subject: [PATCH 3/4] Fixed error in config node --- dist/custom-sidebar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/custom-sidebar.js b/dist/custom-sidebar.js index 421fd88..b1c8ee1 100644 --- a/dist/custom-sidebar.js +++ b/dist/custom-sidebar.js @@ -197,7 +197,7 @@ function moveItem(elements, config_entry) { elements.children[i].href = config_entry.href; } - if (config_entry.open_nef) { + if (config_entry.open_new) { elements.children[i].setAttribute("target", "_blank"); } From de3d5b15b523403150a261c4863eee30a6f3f06c Mon Sep 17 00:00:00 2001 From: Matt Fryer Date: Mon, 15 Mar 2021 16:40:47 +0000 Subject: [PATCH 4/4] Documentation updates for open_new --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6877902..023d3f5 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ order: | hide | boolean | **Optional** | Hide item in sidebar. | exact | boolean | **Optional** | Specify whether the item string match will be exact match instead of substring. | href | string | **Optional** | Define the href for the sidebar link. +| open_new | boolean | **Optional** | Specify whether the link should open in a new browser window. | icon | string | **Optional** | Set the icon of the sidebar item. | new_item | boolean | **Optional** | Set to true to create a new link in the sidebar. Using this option now makes `item`, `href`, and `icon` required. @@ -142,6 +143,7 @@ order: - new_item: true item: Server Controls href: /config/server_control + open_new: true icon: "mdi:server" bottom: true exceptions: