Fixing lint errors and mousedown on mobile browsers

1) Fixed a handful of errors caught by the linter.
2) Mobile browsers register a press and hold as a touch event rather
than a regular mouse down event. The code has been updated so that
these touch events will be registered and sent to the mouse down
handler.
This commit is contained in:
Ryan Kraus 2016-01-11 00:33:14 -05:00
parent 073c8cdcd0
commit 0a0f827e3a

View File

@ -73,16 +73,18 @@ export default new Polymer({
supportsVolumeButtons: {
type: Boolean,
value: false,
}
},
},
attached() {
// This is required to bind a mousedown event in all browsers
// Specifically, Safari does not allow the on-down flag
var _this = this;
this.$.volumeUp.onmousedown = function() {_this.handleVolumeUp()};
this.$.volumeDown.onmousedown = function() {_this.handleVolumeDown()};
let _this = this;
window.test = this.$.volumeUp;
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) {
@ -154,21 +156,21 @@ export default new Polymer({
this.callService('volume_mute', { is_volume_muted: !this.isMuted });
},
handleVolumeUp(ev) {
var obj = this.$.volumeUp;
handleVolumeUp() {
let obj = this.$.volumeUp;
this.handleVolumeWorker('volume_up', obj, true);
},
handleVolumeDown(ev) {
var obj = this.$.volumeDown;
handleVolumeDown() {
let obj = this.$.volumeDown;
this.handleVolumeWorker('volume_down', obj, true);
},
handleVolumeWorker(service, obj, force) {
if (force || (obj != undefined && obj.pointerDown)) {
if (force || (obj !== undefined && obj.pointerDown)) {
this.callService(service);
var _this = this;
setTimeout(function(){ _this.handleVolumeWorker(service, obj, false); }, 500);
let _this = this;
setTimeout(function callback() {_this.handleVolumeWorker(service, obj, false);}, 500);
}
},