mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Make Hass.io menu toggle button work in pre and post 90 release (#2959)
This commit is contained in:
parent
42c7879c4d
commit
2fe0398f37
@ -1,41 +0,0 @@
|
|||||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
|
||||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
|
||||||
|
|
||||||
import "./hassio-main";
|
|
||||||
import "./resources/hassio-icons";
|
|
||||||
|
|
||||||
class HassioApp extends PolymerElement {
|
|
||||||
static get template() {
|
|
||||||
return html`
|
|
||||||
<template is="dom-if" if="[[hass]]">
|
|
||||||
<hassio-main hass="[[hass]]" route="[[route]]"></hassio-main>
|
|
||||||
</template>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
static get properties() {
|
|
||||||
return {
|
|
||||||
hass: Object,
|
|
||||||
route: Object,
|
|
||||||
hassioPanel: {
|
|
||||||
type: Object,
|
|
||||||
value: window.parent.hassioPanel,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
ready() {
|
|
||||||
super.ready();
|
|
||||||
window.setProperties = this.setProperties.bind(this);
|
|
||||||
this.addEventListener("location-changed", () => this._locationChanged());
|
|
||||||
this.addEventListener("hass-toggle-menu", (ev) =>
|
|
||||||
this.hassioPanel.fire("hass-toggle-menu", ev.detail)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
_locationChanged() {
|
|
||||||
this.hassioPanel.navigate(window.location.pathname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
customElements.define("hassio-app", HassioApp);
|
|
@ -79,6 +79,17 @@ class HassioMain extends EventsMixin(NavigateMixin(PolymerElement)) {
|
|||||||
super.ready();
|
super.ready();
|
||||||
applyThemesOnElement(this, this.hass.themes, this.hass.selectedTheme, true);
|
applyThemesOnElement(this, this.hass.themes, this.hass.selectedTheme, true);
|
||||||
this.addEventListener("hass-api-called", (ev) => this.apiCalled(ev));
|
this.addEventListener("hass-api-called", (ev) => this.apiCalled(ev));
|
||||||
|
// Paulus - March 17, 2019
|
||||||
|
// We went to a single hass-toggle-menu event in HA 0.90. However, the
|
||||||
|
// supervisor UI can also run under older versions of Home Assistant.
|
||||||
|
// So here we are going to translate toggle events into the appropriate
|
||||||
|
// open and close events. These events are a no-op in newer versions of
|
||||||
|
// Home Assistant.
|
||||||
|
this.addEventListener("hass-toggle-menu", () => {
|
||||||
|
window.parent.customPanel.fire(
|
||||||
|
this.hass.dockedSidebar ? "hass-close-menu" : "hass-open-menu"
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user