2016-11-21 21:09:56 -05:00
|
|
|
(() => {
|
2016-11-22 12:16:30 -05:00
|
|
|
const gl = window.gl || (window.gl = {});
|
2016-11-21 21:09:56 -05:00
|
|
|
|
|
|
|
class VisibilitySelect {
|
2016-11-22 12:16:30 -05:00
|
|
|
constructor(container) {
|
|
|
|
if (!container) throw new Error('VisibilitySelect requires a container element as argument 1');
|
|
|
|
this.container = container;
|
|
|
|
this.helpBlock = this.container.querySelector('.help-block');
|
|
|
|
this.select = this.container.querySelector('select');
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
2016-11-21 21:09:56 -05:00
|
|
|
if (this.select) {
|
2016-11-22 12:16:30 -05:00
|
|
|
this.updateHelpText();
|
|
|
|
this.select.addEventListener('change', this.updateHelpText.bind(this));
|
2016-11-21 21:09:56 -05:00
|
|
|
} else {
|
2016-11-22 12:16:30 -05:00
|
|
|
this.helpBlock.textContent = this.container.querySelector('.js-locked').dataset.helpBlock;
|
2016-11-21 21:09:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-22 12:16:30 -05:00
|
|
|
updateHelpText() {
|
|
|
|
this.helpBlock.textContent = this.select.querySelector('option:checked').dataset.description;
|
2016-11-21 21:09:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-22 12:16:30 -05:00
|
|
|
gl.VisibilitySelect = VisibilitySelect;
|
2016-11-21 21:09:56 -05:00
|
|
|
})();
|