DEF
The default settings of the library.
On this page
DEF holds the default settings of the library. Assign the values directly after the library script, so that they apply from the start. Getting started shows where this code belongs.
API
config
DEF.api = undefined
The address used by TAPI().
DEF.api = undefinedReturns String Default: undefined.
Assign it to use TAPI().
DEF.api = '/admin/api/';
console.log(DEF.api); // /admin/api/
config
DEF.baseurl = ''
The prefix that String.ROOT() adds to relative addresses.
DEF.baseurl = ''
config
DEF.cdn = ''
The value of the ~CDN~ keyword in imported content.
DEF.cdn = ''Returns String Default: ''.
The keyword is replaced by ADAPT().
DEF.cdn = 'https://cdn.example.com';
console.log(ADAPT(null, null, '~CDN~/logo.png')); // https://cdn.example.com/logo.png
config
DEF.cl = {}
The loaded code lists.
DEF.cl = {}Returns Object Default: {}.
The path prefix # points here, so #countries is DEF.cl.countries. See CL().
SET('#colors', ['red']);
console.log(DEF.cl.colors); // ["red"]
config
DEF.color = '#4285F4'
The accent colour of the app.
DEF.color = '#4285F4'Returns String Default: '#4285F4'.
APPEARANCE() updates it.
APPEARANCE({ color: '#FF0000' });
console.log(DEF.color); // #FF0000
config
DEF.currencies = {}
The formatters used by Number.currency().
DEF.currencies = {}Returns Object Default: {}.
Each key is a currency name and each value is a function that receives the number. See Number.
DEF.currencies.eur = function(value) {
return value.format(2) + ' EUR';
};
console.log((10).currency('eur')); // 10.00 EUR
config
DEF.currency = ''
The default currency of Number.currency().
DEF.currency = ''Returns String Default: ''.
DEF.currencies.usd = function(value) {
return '$' + value.format(2);
};
DEF.currency = 'usd';
console.log((5).currency()); // $5.00
config
DEF.dateformat = 'yyyy-MM-dd'
The default format of Date.format() and of date parsing.
DEF.dateformat = 'yyyy-MM-dd'Returns String Default: 'yyyy-MM-dd'.
See Date.
DEF.dateformat = 'dd.MM.yyyy';
console.log(new Date(2024, 0, 15).format()); // 15.01.2024
config
DEF.dateformatutc = false
Formats all dates in UTC.
DEF.dateformatutc = falseReturns Boolean Default: false.
It applies to Date.format(). See Date.
DEF.dateformatutc = true;
console.log(new Date(Date.UTC(2024, 0, 15, 12, 30)).format('HH:mm')); // 12:30
config
DEF.decimalseparator = '.'
The decimal separator of formatted numbers.
DEF.decimalseparator = '.'Returns String Default: '.'.
It is used by Number.format() and when numbers are parsed. See Number.
DEF.decimalseparator = ',';
console.log((1.5).format(2)); // 1,50
config
DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }
The width ranges of the device sizes.
DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }Returns Object Default: { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }.
The ranges are used by WIDTH() and by the jc-xs, jc-sm, jc-md and jc-lg body classes.
console.log(DEF.devices.md); // {"min":992,"max":1200}
config
DEF.dictionary = {}
The translations loaded with LOCALIZE().
DEF.dictionary = {}Returns Object Default: {}.
See Localization.
LOCALIZE('Tabc : Hola');
console.log(DEF.dictionary.Tabc); // Hola
config
DEF.empty = '---'
The text displayed for an empty value.
DEF.empty = '---'Returns String Default: '---'.
It is used by the empty command of ui-bind and by the empty Tangular helper.
console.log(DEF.empty); // ---
config
DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }
The environment variables.
DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }Returns Object Default: { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }.
Variables are managed with ENV(). The default values can be used as date formats, for example [ts].
var date = new Date(2024, 0, 15, 8, 5);
console.log(date.format('[ts]')); // 2024-01-15 - 08:05
config
DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'
The address from which unknown components are downloaded.
DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'Returns String Default: 'https://cdn.componentator.com/j-{0}.html'.
The {0} keyword becomes the component name. The source attribute of ui-component overrides it.
console.log(DEF.fallback.format('input')); // https://cdn.componentator.com/j-input.html
config
DEF.firstdayofweek = 1
The first day of the week, for components that display a calendar.
DEF.firstdayofweek = 1Returns Number Default: 1.
The value 0 is Sunday and 1 is Monday. The library only stores it.
DEF.firstdayofweek = 0;
console.log(DAYS[DEF.firstdayofweek]); // Sunday
config
DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }
The headers added to every AJAX() request.
DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }Returns Object Default: { 'X-Requested-With': 'XMLHttpRequest' }.
DEF.headers['x-token'] = '123456';
console.log(DEF.headers['x-token']); // 123456
config
DEF.iconprefix = 'ti ti-'
The prefix added to icon names by component.icon().
DEF.iconprefix = 'ti ti-'Returns String Default: 'ti ti-'.
A value that contains a space is used as it is. See Component.
<ui-component name="box"></ui-component>
<script>
COMPONENT('box', function(self) {
self.make = function() {
DEF.iconprefix = 'fa fa-';
console.log(self.icon('home')); // fa fa-home
};
});
</script>
config
DEF.language = undefined
The language added to the query string of every AJAX() request.
DEF.language = undefinedReturns String Default: undefined.
The name of the parameter is in DEF.languagekey. ENVIRONMENT() can set this value.
DEF.language = 'en';
console.log(DEF.language); // en
config
DEF.languagekey = 'language'
The name of the query parameter that carries the language.
DEF.languagekey = 'language'Returns String Default: 'language'.
console.log(DEF.languagekey); // language
config
DEF.localstorage = 'jc'
The localStorage key of the cache.
DEF.localstorage = 'jc'Returns String Default: 'jc'.
ENVIRONMENT() can set this value.
console.log(DEF.localstorage); // jc
config
DEF.onstorageread = function(callback)
Loads the persistent cache when the library starts.
DEF.onstorageread = function(callback)Returns Function Default: function(callback).
Assign your own function directly after the library script. It must call callback with the stored object. The default function reads localStorage.
DEF.onstorageread = function(callback) {
callback({});
};
ON('ready', function() {
console.log('loaded'); // loaded
});
config
DEF.onstoragesave = function(data)
Saves the persistent cache.
DEF.onstoragesave = function(data)Returns Function Default: function(data).
The function receives an object with all the items that have an expiration. The default function writes to localStorage.
DEF.onstoragesave = function(data) {
console.log(Object.keys(data).length); // 1
};
ON('ready', function() {
CACHE('filter', 1, '1 day');
});
config
DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }
The targets of the short path prefixes.
DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }Returns Object Default: { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }.
common is the target of *, cl of # and tmp of %. plugins holds the data of plugins with a generated path. The function DEF.path.clean(name) returns a value without the final dot. See Paths.
console.log(DEF.path.common); // common.
console.log(DEF.path.clean('common')); // common
config
DEF.pipe = undefined
The address used by PIPE().
DEF.pipe = undefinedReturns String Default: undefined.
Assign it to use PIPE().
DEF.pipe = '/pipe/';
console.log(DEF.pipe); // /pipe/
config
DEF.prefixcsscomponents = 'ui-'
The prefix of the CSS class that a component receives as cls.
DEF.prefixcsscomponents = 'ui-'Returns String Default: 'ui-'.
<ui-component name="box"></ui-component>
<script>
DEF.prefixcsscomponents = 'my-';
COMPONENT('box', function(self, config, cls) {
console.log(cls); // my-box
});
</script>
config
DEF.prefixcsslibrary = 'ui-'
The prefix of the CSS classes created by the library.
DEF.prefixcsslibrary = 'ui-'Returns String Default: 'ui-'.
It is used by APPEARANCE() and SCROLLBAR().
DEF.prefixcsslibrary = 'app-';
APPEARANCE({ dark: true });
console.log($('body').hclass('app-dark')); // true
config
DEF.regexp = { int, float, date, pluralize, format, url, phone, email }
The regular expressions used by the helpers.
DEF.regexp = { int, float, date, pluralize, format, url, phone, email }Returns Object Default: { int, float, date, pluralize, format, url, phone, email }.
For example, String.isEmail() uses DEF.regexp.email. See String.
console.log(DEF.regexp.email.test('info@example.com')); // true
console.log('invalid'.isEmail()); // false
config
DEF.root = ''
The prefix that String.ROOT() adds to every relative address.
DEF.root = ''Returns String|Function Default: ''.
It takes priority over DEF.baseurl, and ROOT(true) applies only this value. See String.
DEF.root = '/admin';
console.log('/users/'.ROOT()); // /admin/users/
config
DEF.scrollbaranimate = true
Animates the bar of a custom scrollbar at the edges of the scrolling area.
DEF.scrollbaranimate = trueReturns Boolean Default: true.
See SCROLLBAR().
DEF.scrollbaranimate = false;
console.log(DEF.scrollbaranimate); // false
config
DEF.thousandsseparator = ' '
The thousands separator of formatted numbers.
DEF.thousandsseparator = ' 'Returns String Default: ' '.
It is used by Number.format() and when numbers are parsed. See Number.
DEF.thousandsseparator = ',';
console.log((1234567).format(0)); // 1,234,567
config
DEF.timeformat = 'HH:mm'
The time format copied into the environment variables at startup.
DEF.timeformat = 'HH:mm'Returns String Default: 'HH:mm'.
To change the format later, write the variables time and ts with ENV().
console.log(DEF.timeformat); // HH:mm
console.log(ENV('time')); // HH:mm
config
DEF.tmp = {}
The storage of temporary paths.
DEF.tmp = {}Returns Object Default: {}.
The path prefix % points here, so %form is DEF.tmp.form. See Paths.
SET('%search', 'phone');
console.log(DEF.tmp.search); // phone
config
DEF.version = undefined
The version added to .html addresses requested with AJAX().
DEF.version = undefinedReturns String Default: undefined.
The name of the parameter is in DEF.versionkey. ENVIRONMENT() can set this value.
DEF.version = '1.0';
console.log(DEF.version); // 1.0
config
DEF.versionhtml = undefined
The version for .html addresses when DEF.version is empty.
DEF.versionhtml = undefinedReturns String Default: undefined.
DEF.versionhtml = '2';
console.log(DEF.versionhtml); // 2
config
DEF.versionkey = 'version'
The name of the query parameter that carries the version.
DEF.versionkey = 'version'Returns String Default: 'version'.
console.log(DEF.versionkey); // version
config
DEF.warnings = false
Prints the warnings of the library to the console.
DEF.warnings = falseReturns Boolean Default: false.
Enable it during development, for example to report a method that was not found.
DEF.warnings = true;
console.log(DEF.warnings); // true