comparison interfaces/discrete.js @ 2700:87d9f785f1ec

JShinted Horizontal-Sliders (#180). Minor fixes to core and discrete
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Mon, 13 Mar 2017 11:39:30 +0000
parents 6350ae016862
children c74c698795a9
comparison
equal deleted inserted replaced
2699:6350ae016862 2700:87d9f785f1ec
253 if (audioEngineContext.status === 0) { 253 if (audioEngineContext.status === 0) {
254 event.currentTarget.checked = false; 254 event.currentTarget.checked = false;
255 return; 255 return;
256 } 256 }
257 var id = this.parent.id; 257 var id = this.parent.id;
258 var checkedelement = this.discretes.find(function (elem) { 258 var position = this.getValue();
259 return elem.checked; 259 this.parent.metric.moved(time, position);
260 });
261 var position = checkedelement.getAttribute("position") / 100.0;
262 this.parent.metric.moved(time, checkedelement);
263 console.log('slider ' + id + ' moved to ' + position + ' (' + time + ')'); 260 console.log('slider ' + id + ' moved to ' + position + ' (' + time + ')');
264 261
265 }; 262 };
266 this.handleEvent = function (event) { 263 this.handleEvent = function (event) {
267 if (event.currentTarget.getAttribute("name") === this.parent.specification.id) { 264 if (event.currentTarget.getAttribute("name") === this.parent.specification.id) {
353 } 350 }
354 }; 351 };
355 352
356 this.getValue = function () { 353 this.getValue = function () {
357 // Return the current value of the object. If there is no value, return -1 354 // Return the current value of the object. If there is no value, return -1
358 var value = -1; 355 var checkedElement = this.discretes.find(function (elem) {
359 for (var i = 0; i < this.discretes.length; i++) { 356 return elem.checked;
360 if (this.discretes[i].checked === true) { 357 });
361 value = this.discretes[i].getAttribute('position') / 100.0; 358 if (checkedElement === undefined) {
362 break; 359 return -1;
363 } 360 }
364 } 361 return checkedElement.getAttribute("position") / 100.0;
365 return value;
366 }; 362 };
367 this.getPresentedId = function () { 363 this.getPresentedId = function () {
368 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale 364 // Return the presented ID of the object. For instance, the APE has sliders starting from 0. Whilst AB has alphabetical scale
369 return this.title.textContent; 365 return this.title.textContent;
370 }; 366 };