Open and close popups
This commit is contained in:
parent
deb8e38741
commit
ce8310030f
@ -19,6 +19,10 @@ class {
|
||||
return this.litElement().prototype.html;
|
||||
}
|
||||
|
||||
static get litCSS() {
|
||||
return this.litElement().prototype.css;
|
||||
}
|
||||
|
||||
static hass() {
|
||||
return document.querySelector('home-assistant').hass;
|
||||
}
|
||||
@ -268,6 +272,48 @@ class {
|
||||
return def;
|
||||
}
|
||||
|
||||
static popUp(title, message, large=false) {
|
||||
let popup = document.createElement('div');
|
||||
popup.innerHTML = `
|
||||
<style>
|
||||
app-toolbar {
|
||||
color: var(--more-info-header-color);
|
||||
background-color: var(--more-info-header-background);
|
||||
}
|
||||
</style>
|
||||
<app-toolbar>
|
||||
<paper-icon-button
|
||||
icon="hass:close"
|
||||
dialog-dismiss=""
|
||||
></paper-icon-button>
|
||||
<div class="main-title" main-title="">
|
||||
${title}
|
||||
</div>
|
||||
</app-toolbar>
|
||||
`;
|
||||
popup.appendChild(message);
|
||||
cardTools.moreInfo(Object.keys(cardTools.hass().states)[0]);
|
||||
let moreInfo = document.querySelector("home-assistant")._moreInfoEl;
|
||||
moreInfo._page = "none";
|
||||
moreInfo.shadowRoot.appendChild(popup);
|
||||
moreInfo.large = large;
|
||||
|
||||
setTimeout(() => {
|
||||
let interval = setInterval(() => {
|
||||
if (moreInfo.getAttribute('aria-hidden')) {
|
||||
popup.parentNode.removeChild(popup);
|
||||
clearInterval(interval);
|
||||
} else {
|
||||
message.hass = cardTools.hass();
|
||||
}
|
||||
}, 100)
|
||||
}, 1000);
|
||||
}
|
||||
static closePopUp() {
|
||||
let moreInfo = document.querySelector("home-assistant")._moreInfoEl;
|
||||
if (moreInfo) moreInfo.close()
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Global definition of cardTools
|
||||
|
Loading…
x
Reference in New Issue
Block a user