DEF
The configuration options of the library.
On this page
DEF holds the configuration of the library. Set the options in a script right after the library is loaded, before the first components start. To see how the options fit together, read Getting started.
API
config
DEF.ajaxcredentials = false
Sends cookies with every request.
DEF.ajaxcredentials = falseDEF.ajaxcredentials = true;
console.log(DEF.ajaxcredentials); // true
config
DEF.ajaxcredentialshtml = false
Also sends cookies with requests for .html files when DEF.ajaxcredentials is on.
DEF.ajaxcredentialshtml = falseconsole.log(DEF.ajaxcredentialshtml); // false
config
DEF.ajaxerrors = false
Handles error responses as regular responses.
DEF.ajaxerrors = falseWith true, the event error is not emitted and the Promise of a request is not rejected.
DEF.ajaxerrors = true;
ON('request', opt => opt.throw('Failed', 500));
AJAX('GET /api/', function(response, err) {
console.log(response, err); // Failed 500
});
config
DEF.api = undefined
The default endpoint of DAPI() and TAPI().
DEF.api = undefinedA URL, or a function that receives the name and the data and returns the value for API().
DEF.api = '/api/';
console.log(DEF.api); // /api/
config
DEF.baseurl = ''
A prefix of relative request URLs.
DEF.baseurl = ''A string, or a function that receives the URL and returns a new one.
DEF.baseurl = '/app';
console.log('/users/'.ROOT()); // /app/users/
config
DEF.cdn = ''
The value of the marker ~CDN~ in imported content.
DEF.cdn = ''DEF.cdn = '//cdn.example.com';
console.log(ADAPT(null, null, '~CDN~/a.js')); // //cdn.example.com/a.js
config
DEF.cl = {}
The loaded code lists by name.
DEF.cl = {}CL_INIT('roles', next => next(['admin']), true);
console.log(DEF.cl.roles); // ["admin"]
config
DEF.color = '#4285F4'
The main color of the application.
DEF.color = '#4285F4'console.log(DEF.color); // #4285F4
config
DEF.csrf = undefined
A token sent in the header x-csrf-token.
DEF.csrf = undefinedRequests for .html files do not send it.
DEF.csrf = 'abc';
ON('request', function(opt) {
console.log(opt.headers['x-csrf-token']); // abc
opt.respond({});
});
AJAX('POST /api/', {}, NOOP);
config
DEF.currencies = {}
Functions that format numbers as currencies.
DEF.currencies = {}DEF.currencies.eur = value => value.format(2) + ' EUR';
console.log((5).currency('eur')); // 5.00 EUR
config
DEF.currency = undefined
The default currency of Number.currency().
DEF.currency = undefinedDEF.currencies.eur = value => value.format(2) + ' EUR';
DEF.currency = 'eur';
console.log((5).currency()); // 5.00 EUR
config
DEF.customelements = false
Registers every component as its own element, <ui-name>.
DEF.customelements = falseSet it before declaring components.
DEF.customelements = true;
COMPONENT('hello', function(self) {
self.make = () => self.element.text('Hi');
});
console.log(customElements.get('ui-hello') != null); // true
config
DEF.dateformat = 'yyyy-MM-dd'
The default format of Date.format().
DEF.dateformat = 'yyyy-MM-dd'console.log(new Date(2024, 0, 15).format()); // 2024-01-15
config
DEF.dateformatutc = false
Formats dates in UTC.
DEF.dateformatutc = falseconsole.log(DEF.dateformatutc); // false
config
DEF.decimalseparator = '.'
The decimal separator of formatted numbers.
DEF.decimalseparator = '.'DEF.decimalseparator = ',';
console.log((1.5).format(2)); // 1,50
config
DEF.delay = 555
The delay in milliseconds before a request with the flag sync is tried again.
DEF.delay = 555console.log(DEF.delay); // 555
config
DEF.delaybinder = 200
The delay in milliseconds of delayed data bindings.
DEF.delaybinder = 200console.log(DEF.delaybinder); // 200
config
DEF.delaykeypress = 200
The delay in milliseconds after a key press in an input.
DEF.delaykeypress = 200console.log(DEF.delaykeypress); // 200
config
DEF.delaypref = 1000
The delay in milliseconds before PREF is saved.
DEF.delaypref = 1000console.log(DEF.delaypref); // 1000
config
DEF.delayrepeat = 2000
The delay in milliseconds before a request with the flag repeat is sent again.
DEF.delayrepeat = 2000console.log(DEF.delayrepeat); // 2000
config
DEF.delaywatcher = 555
The interval in milliseconds of the checks that wait for a value.
DEF.delaywatcher = 555console.log(DEF.delaywatcher); // 555
config
DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }
The limits of the display sizes in pixels.
DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }console.log(DEF.devices.sm); // {"min":768,"max":992}
config
DEF.dictionary = {}
The translations used by TRANSLATE().
DEF.dictionary = {}LOCALIZE('hello : Ahoj');
console.log(DEF.dictionary.hello); // Ahoj
config
DEF.empty = '---'
The text used for an empty value in data bindings.
DEF.empty = '---'console.log(DEF.empty); // ---
config
DEF.environment = { ts, date, time }
The variables of ENV().
DEF.environment = { ts, date, time }console.log(DEF.environment.date); // yyyy-MM-dd
config
DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'
The URL of components that are not declared on the page.
DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'{0} is the name of the component. An empty value turns the download off.
DEF.fallback = '';
console.log(DEF.fallback === ''); // true
config
DEF.fallbackcache = ''
How long downloaded components are cached.
DEF.fallbackcache = ''DEF.fallbackcache = '1 day';
console.log(DEF.fallbackcache); // 1 day
config
DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }
The headers of every request.
DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }DEF.headers['X-App'] = 'shop';
ON('request', function(opt) {
console.log(opt.headers['X-App']); // shop
opt.respond({});
});
AJAX('GET /api/', NOOP);
config
DEF.iconprefix = 'ti ti-'
The prefix of icon names in component.icon().
DEF.iconprefix = 'ti ti-'console.log(DEF.iconprefix); // ti ti-
config
DEF.importcache = 'session'
How long content from <ui-import> is cached.
DEF.importcache = 'session'console.log(DEF.importcache); // session
config
DEF.jsoncompress = false
The default value of the compress argument of STRINGIFY().
DEF.jsoncompress = falseDEF.jsoncompress = true;
console.log(STRINGIFY({ a: 1, b: '' })); // {"a":1}
config
DEF.jsonconverter = { 'text json': fn }
The converters of request responses.
DEF.jsonconverter = { 'text json': fn }console.log(typeof(DEF.jsonconverter['text json'])); // function
config
DEF.jsondate = true
Converts ISO dates to Date objects when JSON is parsed.
DEF.jsondate = trueDEF.jsondate = false;
console.log(typeof(PARSE('{"d":"2024-01-01T10:00:00.000Z"}').d)); // string
config
DEF.keypress = true
Makes inputs react while the user types.
DEF.keypress = trueconsole.log(DEF.keypress); // true
config
DEF.language = undefined
The language added to the URL of every request.
DEF.language = undefinedDEF.language = 'sk';
console.log(DEF.language); // sk
config
DEF.languagehtml = undefined
The language added to the URL of .html requests only.
DEF.languagehtml = undefinedDEF.languagehtml = 'sk';
console.log(DEF.languagehtml); // sk
config
DEF.languagekey = 'language'
The name of the query argument with the language.
DEF.languagekey = 'language'console.log(DEF.languagekey); // language
config
DEF.localstorage = 'jc'
The prefix of the keys in the browser storage.
DEF.localstorage = 'jc'console.log(DEF.localstorage); // jc
config
DEF.makeurl = null
A function that changes the URL of every request.
DEF.makeurl = nullDEF.makeurl = url => url + '?v=2';
console.log(typeof(DEF.makeurl)); // function
config
DEF.monitor = false
Collects usage counters in M.performance.
DEF.monitor = falseDEF.monitor = true;
SET('a', 1);
console.log(M.performance.set.count > 0); // true
config
DEF.pathcl = 'DEF.cl.'
The path behind the prefix #.
DEF.pathcl = 'DEF.cl.'console.log(DEF.pathcl); // DEF.cl.
config
DEF.pathcommon = 'common.'
The path behind the prefix *.
DEF.pathcommon = 'common.'SET('*title', 'Hello');
console.log(GET('common.title')); // Hello
config
DEF.prefixcsscomponents = 'ui-'
The CSS prefix passed to component declarations.
DEF.prefixcsscomponents = 'ui-'console.log(DEF.prefixcsscomponents); // ui-
config
DEF.prefixcsslibrary = 'ui-'
The CSS prefix of the classes of the library.
DEF.prefixcsslibrary = 'ui-'console.log(DEF.prefixcsslibrary); // ui-
config
DEF.prefixcssmacros = 'm-'
The CSS prefix passed to macro declarations.
DEF.prefixcssmacros = 'm-'console.log(DEF.prefixcssmacros); // m-
config
DEF.regexp = { int, float, date, pluralize, format }
The regular expressions of the string and date helpers.
DEF.regexp = { int, float, date, pluralize, format }console.log(DEF.regexp.int instanceof RegExp); // true
config
DEF.repeatfocus = true
Pauses REPEAT() while the page is in the background.
DEF.repeatfocus = trueconsole.log(DEF.repeatfocus); // true
config
DEF.root = ''
A prefix of relative URLs that has priority over DEF.baseurl.
DEF.root = ''A string, or a function that receives the URL and returns a new one.
DEF.root = '/shop';
console.log('/users/'.ROOT()); // /shop/users/
config
DEF.scope = window
The object in which paths are stored.
DEF.scope = windowconsole.log(DEF.scope === window); // true
config
DEF.scrollbaranimate = true
Animates custom scrollbars at the end of the content.
DEF.scrollbaranimate = trueconsole.log(DEF.scrollbaranimate); // true
config
DEF.secret = function
Sets the key that encrypts the data of requests.
DEF.secret = functionCall it as DEF.secret(key, [validator], [html]). validator is a function that receives the request options and decides whether to encrypt them. With true as html, responses for .html files are also decrypted. The function removes itself after the first call.
DEF.secret('my-key');
console.log(DEF.secret === undefined); // true
config
DEF.thousandsseparator = ' '
The thousands separator of formatted numbers.
DEF.thousandsseparator = ' 'console.log((1500).format(0)); // 1 500
config
DEF.timeformat = 'HH:mm'
The default time format in DEF.environment.
DEF.timeformat = 'HH:mm'console.log(DEF.timeformat); // HH:mm
config
DEF.validators = { url, phone, email }
The regular expressions of String.isURL(), String.isPhone() and String.isEmail().
DEF.validators = { url, phone, email }console.log(DEF.validators.email.test('a@b.com')); // true
config
DEF.version = ''
The version added to the URL of every request.
DEF.version = ''DEF.version = '1.2';
console.log(DEF.version); // 1.2
config
DEF.versioncomponents = ''
The version of components used without a version.
DEF.versioncomponents = ''console.log(DEF.versioncomponents === ''); // true
config
DEF.versionhtml = undefined
The version added to the URL of .html requests only.
DEF.versionhtml = undefinedDEF.versionhtml = '1.2';
console.log(DEF.versionhtml); // 1.2
config
DEF.versionkey = 'version'
The name of the query argument with the version.
DEF.versionkey = 'version'console.log(DEF.versionkey); // version
config
DEF.webcomponentsonly = undefined
With true, the page is searched only for the <ui-*> elements.
DEF.webcomponentsonly = undefinedDEF.webcomponentsonly = true;
console.log(DEF.webcomponentsonly); // true