mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
1ff8528597
* Initial WebUI with sample functions * Changed folder structure * Light Reset Button and Translation fixing in Links * Indentation fixed * Reorganized menu and new function for setting effects * Styling fix
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
/**
|
|
* hyperion remote
|
|
* MIT License
|
|
*/
|
|
|
|
define(['lib/stapes'], function (Stapes) {
|
|
'use strict';
|
|
|
|
return Stapes.subclass(/** @lends EffectsView.prototype */{
|
|
/**
|
|
* @class EffectsView
|
|
* @constructs
|
|
*/
|
|
constructor: function () {
|
|
this.bindEventHandlers();
|
|
},
|
|
|
|
/**
|
|
* @private
|
|
*/
|
|
bindEventHandlers: function () {
|
|
window.addClickHandler(document.querySelector('#effects ul'), function (event) {
|
|
var selected = event.target.parentNode.querySelector('.selected');
|
|
if (selected) {
|
|
selected.classList.remove('selected');
|
|
}
|
|
event.target.classList.add('selected');
|
|
this.emit('effectSelected', event.target.dataset.id);
|
|
}.bind(this));
|
|
},
|
|
|
|
/**
|
|
* Clear the list
|
|
*/
|
|
clear: function () {
|
|
document.querySelector('#effects ul').innerHTML = '';
|
|
document.querySelector('#effects .info').classList.add('hidden');
|
|
},
|
|
|
|
/**
|
|
* Fill the list
|
|
* @param {object} effects - Object containing effect information
|
|
*/
|
|
fillList: function (effects) {
|
|
var dom, el, i;
|
|
|
|
dom = document.createDocumentFragment();
|
|
|
|
for (i = 0; i < effects.length; i++) {
|
|
el = document.createElement('li');
|
|
el.innerHTML = effects[i].name;
|
|
el.dataset.id = effects[i].id;
|
|
dom.appendChild(el);
|
|
}
|
|
|
|
document.querySelector('#effects ul').appendChild(dom);
|
|
|
|
if (effects.length === 0) {
|
|
document.querySelector('#effects .info').classList.remove('hidden');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|