Experimental Tabs # 2
This commit is contained in:
parent
27383e1bc1
commit
4eb40ccd42
|
@ -10,16 +10,20 @@
|
||||||
.documentFull {
|
.documentFull {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 39px;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
right: 0;
|
right: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
.discord-webview {
|
.discord-webview {
|
||||||
height: 100%;
|
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
display: none;
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 38px;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
}
|
}
|
||||||
.active-webview {
|
.active-webview {
|
||||||
display: inherit
|
display: inherit
|
||||||
|
|
|
@ -3,6 +3,9 @@ const { join } = require("path")
|
||||||
const { pathToFileURL } = require("url")
|
const { pathToFileURL } = require("url")
|
||||||
const { remote } = require("electron")
|
const { remote } = require("electron")
|
||||||
|
|
||||||
|
let webviews = new Map()
|
||||||
|
window.webviews = webviews
|
||||||
|
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
const ChromeTabs = require("chrome-tabs")
|
const ChromeTabs = require("chrome-tabs")
|
||||||
require("chrome-tabs/css/chrome-tabs.css")
|
require("chrome-tabs/css/chrome-tabs.css")
|
||||||
|
@ -13,9 +16,6 @@ window.onload = () => {
|
||||||
let chromeTabs = new ChromeTabs()
|
let chromeTabs = new ChromeTabs()
|
||||||
chromeTabs.init(tabs)
|
chromeTabs.init(tabs)
|
||||||
|
|
||||||
let webviews = new Map()
|
|
||||||
window.webviews = webviews
|
|
||||||
|
|
||||||
tabs.addEventListener('activeTabChange', ({detail}) => {
|
tabs.addEventListener('activeTabChange', ({detail}) => {
|
||||||
let webview = webviews.get(detail.tabEl)
|
let webview = webviews.get(detail.tabEl)
|
||||||
if(!webview){
|
if(!webview){
|
||||||
|
@ -34,6 +34,7 @@ window.onload = () => {
|
||||||
webview.classList.add("discord-webview")
|
webview.classList.add("discord-webview")
|
||||||
webview.classList.add("webview-active")
|
webview.classList.add("webview-active")
|
||||||
webview.setAttribute("preload", pathToFileURL(join(__dirname, "../mainScreenPreload.js")))
|
webview.setAttribute("preload", pathToFileURL(join(__dirname, "../mainScreenPreload.js")))
|
||||||
|
webview.shadowRoot.childNodes.item(1).style.height = "100%"
|
||||||
webviews.set(detail.tabEl, webview)
|
webviews.set(detail.tabEl, webview)
|
||||||
document.querySelector(".documentFull").appendChild(webview)
|
document.querySelector(".documentFull").appendChild(webview)
|
||||||
webview.addEventListener("dom-ready", () => {
|
webview.addEventListener("dom-ready", () => {
|
||||||
|
@ -80,3 +81,10 @@ require.extensions[".css"] = (m, filename) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const faviconURL = pathToFileURL(join(__dirname, "../images/discord.png"))
|
const faviconURL = pathToFileURL(join(__dirname, "../images/discord.png"))
|
||||||
|
|
||||||
|
window.onbeforeunload = (ev) => {
|
||||||
|
if(!webviews)return
|
||||||
|
webviews.forEach(webview => {
|
||||||
|
webview.src = 'about:blank'
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue