Skip to content

Commit

Permalink
Update fullscreen-card.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KTibow authored Oct 21, 2020
1 parent 0997233 commit e26ea2c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dist/fullscreen-card.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var the_card;
class FullscreenCard extends HTMLElement {
set hass(hass) {
if (!this.content) {
if (!this.content && this.config) {
this.content = document.createElement("ha-card");
this.content.style.padding = "15px";
this.fullscreen = false;
Expand All @@ -18,19 +19,20 @@ class FullscreenCard extends HTMLElement {
this.atag.onclick = function() {
if (this.fullscreen) {
document.exitFullscreen();
this.atag.innerHTML = "Go fullscreen";
this.atag.innerHTML = config["go_fullscreen"] || (config["go_fullscreen"] = "Go fullscreen");
} else {
document.documentElement.requestFullscreen();
this.atag.innerHTML = "Exit fullscreen";
this.atag.innerHTML = config["exit_fullscreen"] || (config["exit_fullscreen"] = "Exit fullscreen");
}
this.fullscreen = !this.fullscreen;
}.bind(this);
this.content.appendChild(this.atag);
this.appendChild(this.content);
the_card = this;
}
}
setConfig(config) {
console.log(config);
this.config = config;
}
getCardSize() {
return 2;
Expand All @@ -41,3 +43,9 @@ customElements.define("fullscreen-card", FullscreenCard);
window.customCards.push({type: "fullscreen-card", name: "Fullscreen card",
preview: true,
description: "Card to go fullscreen."});
document.body.onkeydown = (event) => {
if (event.key == "F11") {
event.preventDefault();
the_card.atag.onclick();
}
};

0 comments on commit e26ea2c

Please sign in to comment.