mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Polymer 2.0 ES6 class conversions (#478)
This commit is contained in:
parent
29fad98754
commit
ef36a31ac0
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||||
|
|
||||||
@ -56,20 +56,20 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardClimate extends Polymer.Element {
|
||||||
is: 'state-card-climate',
|
static get is() { return 'state-card-climate'; }
|
||||||
|
|
||||||
properties: {
|
static get properties() {
|
||||||
|
return {
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
stateObj: {
|
};
|
||||||
type: Object,
|
}
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
computeTargetTemperature: function (stateObj) {
|
computeTargetTemperature(stateObj) {
|
||||||
var stateTemp = '';
|
var stateTemp = '';
|
||||||
|
|
||||||
if (stateObj.attributes.target_temp_low &&
|
if (stateObj.attributes.target_temp_low &&
|
||||||
@ -83,7 +83,7 @@ Polymer({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return stateTemp;
|
return stateTemp;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
});
|
customElements.define(StateCardClimate.is, StateCardClimate);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel='import' href='../../bower_components/polymer/polymer.html'>
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||||
|
|
||||||
@ -32,18 +32,18 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardConfigurator extends Polymer.Element {
|
||||||
is: 'state-card-configurator',
|
static get is() { return 'state-card-configurator'; }
|
||||||
|
|
||||||
properties: {
|
static get properties() {
|
||||||
|
return {
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
stateObj: {
|
}
|
||||||
type: Object,
|
}
|
||||||
},
|
customElements.define(StateCardConfigurator.is, StateCardConfigurator);
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -22,13 +22,11 @@ class StateCardContent extends Polymer.Element {
|
|||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
hass: Object,
|
hass: Object,
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
stateObj: Object,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||||
|
|
||||||
@ -27,34 +27,28 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardCover extends Polymer.Element {
|
||||||
is: 'state-card-cover',
|
static get is() { return 'state-card-cover'; }
|
||||||
|
|
||||||
properties: {
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
hass: Object,
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
stateObj: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
entityObj: {
|
entityObj: {
|
||||||
type: Object,
|
type: Object,
|
||||||
computed: 'computeEntityObj(hass, stateObj)',
|
computed: 'computeEntityObj(hass, stateObj)',
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
},
|
computeEntityObj(hass, stateObj) {
|
||||||
|
|
||||||
computeEntityObj: function (hass, stateObj) {
|
|
||||||
var entity = new window.CoverEntity(hass, stateObj);
|
var entity = new window.CoverEntity(hass, stateObj);
|
||||||
return entity;
|
return entity;
|
||||||
},
|
}
|
||||||
|
}
|
||||||
});
|
customElements.define(StateCardCover.is, StateCardCover);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||||
|
|
||||||
@ -26,22 +26,22 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardDisplay extends Polymer.Element {
|
||||||
is: 'state-card-display',
|
static get is() { return 'state-card-display'; }
|
||||||
|
|
||||||
properties: {
|
static get properties() {
|
||||||
|
return {
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
stateObj: {
|
computeStateDisplay(stateObj) {
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
computeStateDisplay: function (stateObj) {
|
|
||||||
return window.hassUtil.computeStateState(stateObj);
|
return window.hassUtil.computeStateState(stateObj);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
customElements.define(StateCardDisplay.is, StateCardDisplay);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
|
<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
|
||||||
<link rel='import' href='../../bower_components/paper-listbox/paper-listbox.html'>
|
<link rel='import' href='../../bower_components/paper-listbox/paper-listbox.html'>
|
||||||
<link rel='import' href='../../bower_components/paper-item/paper-item.html'>
|
<link rel='import' href='../../bower_components/paper-item/paper-item.html'>
|
||||||
@ -42,38 +42,33 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardInputSelect extends Polymer.Element {
|
||||||
is: 'state-card-input_select',
|
static get is() { return 'state-card-input_select'; }
|
||||||
|
|
||||||
properties: {
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
hass: Object,
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
stateObj: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
selectedOption: {
|
selectedOption: {
|
||||||
type: String,
|
type: String,
|
||||||
observer: 'selectedOptionChanged',
|
observer: 'selectedOptionChanged',
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
|
}
|
||||||
|
|
||||||
computeStateName: function (stateObj) {
|
computeStateName(stateObj) {
|
||||||
return window.hassUtil.computeStateName(stateObj);
|
return window.hassUtil.computeStateName(stateObj);
|
||||||
},
|
}
|
||||||
|
|
||||||
computeSelected: function (stateObj) {
|
computeSelected(stateObj) {
|
||||||
return stateObj.attributes.options.indexOf(stateObj.state);
|
return stateObj.attributes.options.indexOf(stateObj.state);
|
||||||
},
|
}
|
||||||
|
|
||||||
selectedOptionChanged: function (option) {
|
selectedOptionChanged(option) {
|
||||||
// Selected Option will transition to '' before transitioning to new value
|
// Selected Option will transition to '' before transitioning to new value
|
||||||
if (option === '' || option === this.stateObj.state) {
|
if (option === '' || option === this.stateObj.state) {
|
||||||
return;
|
return;
|
||||||
@ -82,10 +77,11 @@ Polymer({
|
|||||||
option: option,
|
option: option,
|
||||||
entity_id: this.stateObj.entity_id,
|
entity_id: this.stateObj.entity_id,
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
stopPropagation: function (ev) {
|
stopPropagation(ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
customElements.define(StateCardInputSelect.is, StateCardInputSelect);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||||
|
|
||||||
@ -46,32 +46,27 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardMediaPlayer extends Polymer.Element {
|
||||||
PLAYING_STATES: ['playing', 'paused'],
|
static get is() { return 'state-card-media_player'; }
|
||||||
is: 'state-card-media_player',
|
|
||||||
|
|
||||||
properties: {
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
hass: Object,
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
stateObj: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
playerObj: {
|
playerObj: {
|
||||||
type: Object,
|
type: Object,
|
||||||
computed: 'computePlayerObj(hass, stateObj)',
|
computed: 'computePlayerObj(hass, stateObj)',
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
|
}
|
||||||
|
|
||||||
computePlayerObj: function (hass, stateObj) {
|
computePlayerObj(hass, stateObj) {
|
||||||
return new window.MediaPlayerEntity(hass, stateObj);
|
return new window.MediaPlayerEntity(hass, stateObj);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
customElements.define(StateCardMediaPlayer.is, StateCardMediaPlayer);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||||
|
|
||||||
@ -27,30 +27,27 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardScene extends Polymer.Element {
|
||||||
is: 'state-card-scene',
|
static get is() { return 'state-card-scene'; }
|
||||||
|
|
||||||
properties: {
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
hass: Object,
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
stateObj: {
|
activateScene(ev) {
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
activateScene: function (ev) {
|
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this.hass.callService(
|
this.hass.callService(
|
||||||
'scene', 'turn_on',
|
'scene', 'turn_on',
|
||||||
{ entity_id: this.stateObj.entity_id }
|
{ entity_id: this.stateObj.entity_id }
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
customElements.define(StateCardScene.is, StateCardScene);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||||
|
|
||||||
@ -37,26 +37,26 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardScript extends Polymer.Element {
|
||||||
is: 'state-card-script',
|
static get is() { return 'state-card-script'; }
|
||||||
|
|
||||||
properties: {
|
static get properties() {
|
||||||
|
return {
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
stateObj: {
|
fireScript(ev) {
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
fireScript: function (ev) {
|
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this.hass.callService(
|
this.hass.callService(
|
||||||
'script', 'turn_on',
|
'script', 'turn_on',
|
||||||
{ entity_id: this.stateObj.entity_id }
|
{ entity_id: this.stateObj.entity_id }
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
customElements.define(StateCardScript.is, StateCardScript);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
<link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
|
||||||
|
|
||||||
@ -23,22 +23,19 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardToggle extends Polymer.Element {
|
||||||
is: 'state-card-toggle',
|
static get is() { return 'state-card-toggle'; }
|
||||||
|
|
||||||
properties: {
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
hass: Object,
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
stateObj: {
|
}
|
||||||
type: Object,
|
}
|
||||||
},
|
customElements.define(StateCardToggle.is, StateCardToggle);
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
|
||||||
|
|
||||||
<link rel="import" href="../components/entity/state-badge.html">
|
<link rel="import" href="../components/entity/state-badge.html">
|
||||||
|
|
||||||
@ -25,32 +25,33 @@
|
|||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
class StateCardWeblink extends Polymer.Element {
|
||||||
is: 'state-card-weblink',
|
static get is() { return 'state-card-weblink'; }
|
||||||
|
|
||||||
properties: {
|
static get properties() {
|
||||||
|
return {
|
||||||
|
stateObj: Object,
|
||||||
inDialog: {
|
inDialog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
stateObj: {
|
ready() {
|
||||||
type: Object,
|
super.ready();
|
||||||
},
|
this.addEventListener('tap', ev => this.onTap(ev));
|
||||||
},
|
}
|
||||||
|
|
||||||
listeners: {
|
computeStateName(stateObj) {
|
||||||
tap: 'onTap',
|
|
||||||
},
|
|
||||||
|
|
||||||
computeStateName: function (stateObj) {
|
|
||||||
return window.hassUtil.computeStateName(stateObj);
|
return window.hassUtil.computeStateName(stateObj);
|
||||||
},
|
}
|
||||||
|
|
||||||
onTap: function (ev) {
|
onTap(ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
window.open(this.stateObj.state, '_blank');
|
window.open(this.stateObj.state, '_blank');
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
customElements.define(StateCardWeblink.is, StateCardWeblink);
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
<script>
|
<script>
|
||||||
(function () {
|
{
|
||||||
var STORED_STATE = [
|
const STORED_STATE = [
|
||||||
'dockedSidebar',
|
'dockedSidebar',
|
||||||
'selectedTheme',
|
'selectedTheme',
|
||||||
'selectedLanguage',
|
'selectedLanguage',
|
||||||
];
|
];
|
||||||
|
|
||||||
Polymer({
|
class HaPrefStorage extends Polymer.Element {
|
||||||
is: 'ha-pref-storage',
|
static get is() { return 'ha-pref-storage'; }
|
||||||
|
|
||||||
properties: {
|
|
||||||
hass: {
|
|
||||||
type: Object,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
static get properties() {
|
||||||
|
return {
|
||||||
|
hass: Object,
|
||||||
storage: {
|
storage: {
|
||||||
type: Object,
|
type: Object,
|
||||||
value: window.localStorage || {},
|
value: window.localStorage || {},
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
|
}
|
||||||
|
|
||||||
storeState: function () {
|
storeState() {
|
||||||
if (!this.hass) return;
|
if (!this.hass) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -32,9 +31,9 @@
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Safari throws exception in private mode
|
// Safari throws exception in private mode
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
getStoredState: function () {
|
getStoredState() {
|
||||||
var state = {};
|
var state = {};
|
||||||
|
|
||||||
for (var i = 0; i < STORED_STATE.length; i++) {
|
for (var i = 0; i < STORED_STATE.length; i++) {
|
||||||
@ -46,6 +45,7 @@
|
|||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}());
|
customElements.define(HaPrefStorage.is, HaPrefStorage);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
<script>
|
<script>
|
||||||
(function () {
|
{
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
var DEBUG = false;
|
const DEBUG = false;
|
||||||
|
|
||||||
Polymer({
|
class HaUrlSync extends Polymer.Element {
|
||||||
is: 'ha-url-sync',
|
static get is() { return 'ha-url-sync'; }
|
||||||
|
|
||||||
properties: {
|
static get properties() {
|
||||||
|
return {
|
||||||
hass: {
|
hass: {
|
||||||
type: Object,
|
type: Object,
|
||||||
observer: 'hassChanged',
|
observer: 'hassChanged',
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
|
}
|
||||||
|
|
||||||
hassChanged: function (newHass, oldHass) {
|
hassChanged(newHass, oldHass) {
|
||||||
if (this.ignoreNextHassChange) {
|
if (this.ignoreNextHassChange) {
|
||||||
if (DEBUG) console.log('ignore hasschange');
|
if (DEBUG) console.log('ignore hasschange');
|
||||||
this.ignoreNextHassChange = false;
|
this.ignoreNextHassChange = false;
|
||||||
@ -30,9 +32,9 @@
|
|||||||
this.ignoreNextPopstate = true;
|
this.ignoreNextPopstate = true;
|
||||||
history.back();
|
history.back();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
popstateChangeListener: function (ev) {
|
popstateChangeListener(ev) {
|
||||||
if (this.ignoreNextPopstate) {
|
if (this.ignoreNextPopstate) {
|
||||||
if (DEBUG) console.log('ignore popstate');
|
if (DEBUG) console.log('ignore popstate');
|
||||||
this.ignoreNextPopstate = false;
|
this.ignoreNextPopstate = false;
|
||||||
@ -46,18 +48,21 @@
|
|||||||
this.ignoreNextHassChange = true;
|
this.ignoreNextHassChange = true;
|
||||||
this.fire('hass-more-info', { entityId: null });
|
this.fire('hass-more-info', { entityId: null });
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
attached: function () {
|
connectedCallback() {
|
||||||
|
super.connectedCallback();
|
||||||
this.ignoreNextPopstate = false;
|
this.ignoreNextPopstate = false;
|
||||||
this.ignoreNextHassChange = false;
|
this.ignoreNextHassChange = false;
|
||||||
this.popstateChangeListener = this.popstateChangeListener.bind(this);
|
this.popstateChangeListener = this.popstateChangeListener.bind(this);
|
||||||
window.addEventListener('popstate', this.popstateChangeListener);
|
window.addEventListener('popstate', this.popstateChangeListener);
|
||||||
},
|
}
|
||||||
|
|
||||||
detached: function () {
|
disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
window.removeEventListener('popstate', this.popstateChangeListener);
|
window.removeEventListener('popstate', this.popstateChangeListener);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}());
|
customElements.define(HaUrlSync.is, HaUrlSync);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user