TP_JO2024/home/dist/component/display/display.nomodule.js

113 lines
3.2 KiB
JavaScript
Raw Permalink Normal View History

2024-03-27 17:19:37 +01:00
/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
(function () {
'use strict';
var config = {
prefix: 'fr',
namespace: 'dsfr',
organisation: '@gouvfr',
version: '1.11.2'
};
var api = window[config.namespace];
var DisplaySelector = {
DISPLAY: api.internals.ns.selector('display'),
RADIO_BUTTONS: ("input[name=\"" + (api.internals.ns('radios-theme')) + "\"]"),
FIELDSET: api.internals.ns.selector('fieldset')
};
var Display = /*@__PURE__*/(function (superclass) {
function Display () {
superclass.apply(this, arguments);
}
if ( superclass ) Display.__proto__ = superclass;
Display.prototype = Object.create( superclass && superclass.prototype );
Display.prototype.constructor = Display;
var prototypeAccessors = { scheme: { configurable: true } };
var staticAccessors = { instanceClassName: { configurable: true } };
staticAccessors.instanceClassName.get = function () {
return 'Display';
};
Display.prototype.init = function init () {
this.radios = this.querySelectorAll(DisplaySelector.RADIO_BUTTONS);
if (api.scheme) {
this.changing = this.change.bind(this);
for (var i = 0, list = this.radios; i < list.length; i += 1) {
var radio = list[i];
radio.addEventListener('change', this.changing);
}
this.addDescent(api.scheme.SchemeEmission.SCHEME, this.apply.bind(this));
this.ascend(api.scheme.SchemeEmission.ASK);
} else {
this.querySelector(DisplaySelector.FIELDSET).setAttribute('disabled', '');
}
};
prototypeAccessors.scheme.get = function () {
return this._scheme;
};
prototypeAccessors.scheme.set = function (value) {
if (this._scheme === value || !api.scheme) { return; }
switch (value) {
case api.scheme.SchemeValue.SYSTEM:
case api.scheme.SchemeValue.LIGHT:
case api.scheme.SchemeValue.DARK:
this._scheme = value;
for (var i = 0, list = this.radios; i < list.length; i += 1) {
var radio = list[i];
radio.checked = radio.value === value;
}
this.ascend(api.scheme.SchemeEmission.SCHEME, value);
break;
}
};
Display.prototype.change = function change () {
for (var i = 0, list = this.radios; i < list.length; i += 1) {
var radio = list[i];
if (radio.checked) {
this.scheme = radio.value;
return;
}
}
};
Display.prototype.apply = function apply (value) {
this.scheme = value;
};
Display.prototype.dispose = function dispose () {
for (var i = 0, list = this.radios; i < list.length; i += 1) {
var radio = list[i];
radio.removeEventListener('change', this.changing);
}
};
Object.defineProperties( Display.prototype, prototypeAccessors );
Object.defineProperties( Display, staticAccessors );
return Display;
}(api.core.Instance));
api.display = {
Display: Display,
DisplaySelector: DisplaySelector
};
api.internals.register(api.display.DisplaySelector.DISPLAY, api.display.Display);
})();
//# sourceMappingURL=display.nomodule.js.map