code cleanup

This commit is contained in:
Dennis Karpienski 2016-04-11 22:18:42 +02:00
parent 0921fdb63d
commit bc03090e8a
2 changed files with 13 additions and 18 deletions

View File

@ -64,13 +64,8 @@
on-change='volumeSliderChanged' class='flex'>
</paper-slider>
</div>
<div
class='controls layout horizontal justified'
hidden$='[[!supportsSelectInputSource]]'
>
<paper-icon-button
icon="mdi:login-variant">
</paper-icon-button>
<div class='controls layout horizontal justified' hidden$='[[!supportsSelectSource]]'>
<paper-icon-button icon="mdi:login-variant"></paper-icon-button>
<paper-dropdown-menu style="margin-left: 10px;" no-label-float selected-item-label='{{selectedSource}}' on-tap='stopPropagation'>
<paper-menu class="dropdown-content" selected="[[computeSelectedSource(stateObj)]]">
<template is='dom-repeat' items='[[stateObj.attributes.source_list]]'>

View File

@ -75,7 +75,7 @@ export default new Polymer({
value: false,
},
supportsSelectInputSource: {
supportsSelectSource: {
type: Boolean,
value: false,
},
@ -87,7 +87,7 @@ export default new Polymer({
selectedSource: {
type: String,
observer: 'selectedSourceChanged',
observer: 'handleSourceChanged',
},
},
@ -109,7 +109,7 @@ export default new Polymer({
this.supportsTurnOn = (newVal.attributes.supported_media_commands & 128) !== 0;
this.supportsTurnOff = (newVal.attributes.supported_media_commands & 256) !== 0;
this.supportsVolumeButtons = (newVal.attributes.supported_media_commands & 1024) !== 0;
this.supportsSelectInputSource = (newVal.attributes.supported_media_commands & 2048) !== 0;
this.supportsSelectSource = (newVal.attributes.supported_media_commands & 2048) !== 0;
}
this.async(() => this.fire('iron-resize'), 500);
@ -150,14 +150,6 @@ export default new Polymer({
return stateObj.attributes.source_list.indexOf(stateObj.attributes.source);
},
selectedSourceChanged(option) {
// Selected Option will transition to '' before transitioning to new value
if (option === '' || option === this.stateObj.attributes.source) {
return;
}
this.callService('select_source', { source: option });
},
handleTogglePower() {
this.callService(this.isOff ? 'turn_on' : 'turn_off');
},
@ -174,6 +166,14 @@ export default new Polymer({
this.callService('media_next_track');
},
handleSourceChanged(source) {
// Selected Option will transition to '' before transitioning to new value
if (source === '' || source === this.stateObj.attributes.source) {
return;
}
this.callService('select_source', { source: source });
},
handleVolumeTap() {
if (!this.supportsVolumeMute) {
return;