1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/emby-radio/emby-radio.js

48 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-07-09 13:39:04 -04:00
define(['css!./emby-radio', 'registerElement'], function () {
2016-10-06 00:28:10 -04:00
'use strict';
2016-07-09 13:39:04 -04:00
var EmbyRadioPrototype = Object.create(HTMLInputElement.prototype);
function onKeyDown(e) {
// Don't submit form on enter
2016-10-06 00:28:10 -04:00
if (e.keyCode === 13) {
2016-07-09 13:39:04 -04:00
e.preventDefault();
this.checked = true;
return false;
}
}
EmbyRadioPrototype.attachedCallback = function () {
2016-10-06 00:28:10 -04:00
if (this.getAttribute('data-radio') === 'true') {
2016-07-09 13:39:04 -04:00
return;
}
this.setAttribute('data-radio', 'true');
this.classList.add('mdl-radio__button');
var labelElement = this.parentNode;
//labelElement.classList.add('"mdl-radio mdl-js-radio mdl-js-ripple-effect');
labelElement.classList.add('mdl-radio');
labelElement.classList.add('mdl-js-radio');
labelElement.classList.add('mdl-js-ripple-effect');
var labelTextElement = labelElement.querySelector('span');
labelTextElement.classList.add('radioButtonLabel');
2016-07-10 03:01:25 -04:00
labelTextElement.classList.add('mdl-radio__label');
labelElement.insertAdjacentHTML('beforeend', '<span class="mdl-radio__outer-circle"></span><span class="mdl-radio__inner-circle"></span>');
2016-07-09 13:39:04 -04:00
this.addEventListener('keydown', onKeyDown);
};
document.registerElement('emby-radio', {
prototype: EmbyRadioPrototype,
extends: 'input'
});
});