UNPKG

@genexus/web-standard-functions

Version:

GeneXus JavaScript standard functions library for web generators

50 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clearOption = exports.setOption = exports.getOptions = exports.getOption = void 0; const publishCall_1 = require("../../../misc/publishCall"); /** * Get the value of the DesignSystem option. * @param {string} name * @return {string} */ const getOption = (name) => { return document.documentElement.getAttribute(`data-gx-ds-opt-${name}`) || ""; }; exports.getOption = getOption; /** * Get list of DesignSystem options. * @return {name: string, value: string}[] */ const getOptions = () => { const attrs = document.documentElement.attributes; let list = []; for (let i = attrs.length - 1; i >= 0; i--) { if (attrs[i].name.startsWith("data-gx-ds-opt-")) { list.push({ name: attrs[i].name.slice(15), value: attrs[i].value }); } } return list; }; exports.getOptions = getOptions; /** * Set the value of the DesignSystem option. * @param {string} name * @param {string} value */ const setOption = (name, value) => { document.documentElement.setAttribute(`data-gx-ds-opt-${name}`, value); let resolver = (opt, val, resolve) => resolve(); return (0, publishCall_1.publishCall)("dsSetOption", ["ok"], resolver, name, value); }; exports.setOption = setOption; /** * Remove the value of the DesignSystem option. * @param {string} name */ const clearOption = (name) => { document.documentElement.removeAttribute(`data-gx-ds-opt-${name}`); let resolver = (opt, val, resolve) => resolve(); return (0, publishCall_1.publishCall)("dsSetOption", ["ok"], resolver, name, null); }; exports.clearOption = clearOption; //# sourceMappingURL=designsystem.js.map