mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 12:26:35 +00:00
Clean up the media player more-info code
1) Event binding was moved to the html template as is tradition. 2) setTimeout call was replaced with this.async… as is tradition.
This commit is contained in:
parent
9efe2ebbee
commit
cb2e3de6d9
@ -48,8 +48,10 @@
|
|||||||
<paper-icon-button on-tap="handleVolumeTap"
|
<paper-icon-button on-tap="handleVolumeTap"
|
||||||
icon="mdi:volume-off"></paper-icon-button>
|
icon="mdi:volume-off"></paper-icon-button>
|
||||||
<paper-icon-button id="volumeDown" disabled$='[[isMuted]]'
|
<paper-icon-button id="volumeDown" disabled$='[[isMuted]]'
|
||||||
|
on-mousedown="handleVolumeDown" on-touchstart="handleVolumeDown"
|
||||||
icon="mdi:volume-medium"></paper-icon-button>
|
icon="mdi:volume-medium"></paper-icon-button>
|
||||||
<paper-icon-button id="volumeUp" disabled$='[[isMuted]]'
|
<paper-icon-button id="volumeUp" disabled$='[[isMuted]]'
|
||||||
|
on-mousedown="handleVolumeUp" on-touchstart="handleVolumeUp"
|
||||||
icon="mdi:volume-high"></paper-icon-button>
|
icon="mdi:volume-high"></paper-icon-button>
|
||||||
</div>
|
</div>
|
||||||
<div class='volume center horizontal layout' hidden$='[[!supportsVolumeSet]]'>
|
<div class='volume center horizontal layout' hidden$='[[!supportsVolumeSet]]'>
|
||||||
|
@ -82,15 +82,6 @@ export default new Polymer({
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
attached() {
|
|
||||||
// This is required to bind a mousedown event in all browsers
|
|
||||||
const _this = this;
|
|
||||||
this.$.volumeUp.onmousedown = function onVolumeUpDown() {_this.handleVolumeUp();};
|
|
||||||
this.$.volumeUp.ontouchstart = function onVolumeUpDown() {_this.handleVolumeUp();};
|
|
||||||
this.$.volumeDown.onmousedown = function onVolumeDownDown() {_this.handleVolumeDown();};
|
|
||||||
this.$.volumeDown.ontouchstart = function onVolumeDownDown() {_this.handleVolumeDown();};
|
|
||||||
},
|
|
||||||
|
|
||||||
stateObjChanged(newVal) {
|
stateObjChanged(newVal) {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
const hasMediaStates = ['playing', 'paused', 'unknown'];
|
const hasMediaStates = ['playing', 'paused', 'unknown'];
|
||||||
@ -180,8 +171,7 @@ export default new Polymer({
|
|||||||
handleVolumeWorker(service, obj, force) {
|
handleVolumeWorker(service, obj, force) {
|
||||||
if (force || (obj !== undefined && obj.pointerDown)) {
|
if (force || (obj !== undefined && obj.pointerDown)) {
|
||||||
this.callService(service);
|
this.callService(service);
|
||||||
const _this = this;
|
this.async(() => this.handleVolumeWorker(service, obj, false), 500);
|
||||||
setTimeout(function callback() {_this.handleVolumeWorker(service, obj, false);}, 500);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user