Spanish Total.js
English
Documentation For AI agents
Contents

M

The members of the main object of the library.

.md GitHub
On this page

M is a short name of MAIN. Most applications use the global functions instead of these members. For the concepts behind them, read Paths.

API

property

M.binders

An array of the active data bindings.
Example
SET('name', 'Peter');
setTimeout(function() {
	console.log(M.binders.length); // 1
}, 300);
property

M.cl

The declared code lists by name.
Example
CL_INIT('roles', next => next([]));
console.log(Object.keys(M.cl)); // ["roles"]
method

M.compile([container])

Searches the page for new components and bindings.
ParameterTypeDescription
container? Element|jQuery Limits the search to this element.

Use COMPILE() in your code.

Example
console.log(typeof(M.compile)); // function
property

M.components

An array of the created components.
Example
ON('ready', function() {
	console.log(M.components.length); // 2
});
property

M.days

The same array as DAYS.
Example
console.log(M.days === DAYS); // true
method

M.default(path, [delay], [component], [reset])

Restores the default values of the components on a path.
ParameterTypeDescription
path String The path.
delay? Number A delay in milliseconds.
component? Component Limits the change to one component.
reset? Boolean With false, the state is kept. Default: true

Use DEFAULT() in your code.

Example
console.log(typeof(M.default)); // function
property

M.defaults

The same object as DEF.
Example
console.log(M.defaults === DEF); // true
method

M.each(fn, [path])

Calls a function for each component.
ParameterTypeDescription
fn Function function(component, index, wildcard).
path? String Limits the call to a path.

Return true from the function to stop.

Example
ON('ready', function() {
	var paths = [];
	M.each(com => paths.push(com.path), 'form.*');
	console.log(paths.length); // 2
});
property

M.events

The registered event handlers by event name.
Example
ON('hello', NOOP);
console.log(M.events.hello.length); // 1
method

M.extend(path, value, [type])

Merges fields into an object.
ParameterTypeDescription
path String The path.
value Object The fields.
type? Number The change type: 1 manual, 2 input, 3 default.

Use EXT() for a delayed change.

Example
SET('user', { a: 1 });
M.extend('user', { b: 2 });
console.log(GET('user')); // {"a":1,"b":2}
method

M.inc(path, value, [type])

Adds a number to a value.
ParameterTypeDescription
path String The path.
value Number The number.
type? Number The change type: 1 manual, 2 input, 3 default.

Use INC() for a delayed change.

Example
M.inc('count', 2);
console.log(GET('count')); // 2
property

M.loaded

true after the stored preferences are loaded.
Example
setTimeout(function() {
	console.log(M.loaded); // true
}, 500);
property

M.macros

The declared macros by name.
Example
MACRO('upper', NOOP);
console.log(typeof(M.macros.upper)); // function
property

M.months

The same array as MONTHS.
Example
console.log(M.months === MONTHS); // true
method

M.parse(type, value, [format])

Converts a value with the registered parsers.
ParameterTypeDescription
type String The type, for example number.
value Object The value.
format? String The format passed to the parsers.

Returns Object The converted value.

Example
console.log(M.parse('number', '5')); // 5
property

M.paths

The number of watchers and components for each path.
Example
WATCH('user.name', NOOP);
console.log(M.paths['user.name']); // 1
property

M.performance

Usage counters, collected when DEF.monitor is true.
Example
DEF.monitor = true;
GET('a');
console.log(M.performance.get.count > 0); // true
method

M.plugin([name])

Reads or changes the current plugin scope.
ParameterTypeDescription
name? String The new scope.

Returns String The current scope.

Example
M.plugin('users');
console.log(M.plugin()); // users
method

M.prototypes(fn)

Gives access to the prototypes of the library objects.
ParameterTypeDescription
fn Function function(proto).

The object has the fields Component, Plugin and VBinder.

Example
M.prototypes(function(proto) {
	proto.Component.hello = () => 'Hello';
});
ON('ready', function() {
	console.log(FIND('textbox').hello()); // Hello
});
method

M.push(path, value, [type])

Adds a value to an array.
ParameterTypeDescription
path String The path.
value Object The item.
type? Number The change type: 1 manual, 2 input, 3 default.

Use PUSH() for a delayed change.

Example
M.push('list', 1);
console.log(GET('list')); // [1]
method

M.scope([name])

The same function as M.plugin().
ParameterTypeDescription
name? String The new scope.

Returns String The current scope.

Example
console.log(M.scope === M.plugin); // true
property

M.scrollbars

An array of the custom scrollbars.
Example
console.log(M.scrollbars.length); // 0
method

M.set(path, value, [type])

Writes a value to a path.
ParameterTypeDescription
path String The path.
value Object The value.
type? Number The change type: 1 manual, 2 input, 3 default.

Use SET() for a delayed change.

Example
M.set('name', 'Peter');
console.log(GET('name')); // Peter
property

M.ua

The parsed user agent with the fields os, browser and device.
Example
console.log(Object.keys(M.ua)); // ["os","browser","device"]
method

M.update(path, [reset], [type])

Refreshes everything bound to a path.
ParameterTypeDescription
path String The path.
reset? Boolean Resets the state of the components.
type? Number The change type: 1 manual, 2 input, 3 default.

Use UPD() for a delayed change.

Example
SET('user', { name: 'Peter' });
WATCH('user.name', function(path, value) {
	console.log(value); // Anna
});
GET('user').name = 'Anna';
M.update('user.name');
property

M.version

The version of the library.
Example
console.log(M.version); // 19.194
Made in Europe