# j-Dashboard

> El componente espera una matriz de objetos.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: es
Content-SHA256: d51f1d3fd51cb92379edfa67fd324a6a0f8dad1916aa792799b77f697caf816c
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- Soporta dispositivos móviles
- Soporta toques
- Móvil
- Arrastrable
- Redimensionable

El componente espera `Array` de objetos.

__Configuración__:

- `axisX {Number}` un tamaño de cuadrícula del eje X (predeterminado: `12`)
- `axisY {Number}` un tamaño de cuadrícula del eje Y (predeterminado: `144`)
- `padding {Number}` un relleno entre widgets (predeterminado: `10`)
- Retraso de inicio `delay {Number}` (predeterminado: `200`)
- `serviceinterval {Number}` un intervalo de servicio (predeterminado: `5000`)
- `ondrop {String}` una ruta al método `function(meta) {}`, se ejecuta si alguien coloca algún elemento en el área
	- `meta.x` X posición de la rejilla
	- `meta.y` Posición de la rejilla Y
	- `meta.el` elemento arrastrado
	- `meta.pageX`
	- `meta.pageY`
	- `meta.offsetX`
	- `meta.offsetY`
	- `meta.target`
	- `meta.d` un modo de visualización `xs`, `sm`, `md` o `lg`
- `noemitresize` deshabilita la ejecución del método `resize` en todos los componentes anidados (predeterminado: `false`)
- `parent {String}` un contenedor principal que establece una altura mínima (predeterminado: `null`)
- `margin {Number}` un margen superior/inferior para la opción `parent` (predeterminado: `0`)
- `minsizexs {Number}` un tamaño mínimo de columna/fila para pantallas muy pequeñas (predeterminado: `2`)
- `minsizesm {Number}` un tamaño mínimo de columna/fila para pantallas pequeñas (predeterminado: `2`)
- `minsizemd {Number}` un tamaño mínimo de columna/fila para pantallas medianas (predeterminado: `1`)
- `minsizelg {Number}` un tamaño mínimo de columna/fila para pantallas grandes (predeterminado: `1`)
- `iconsettings {String}` icono de configuración
- `iconremove {String}` eliminar icono
- `change {String}` una ruta al método `function(type, id)` (se ejecuta si el panel captura un cambio `move` o `remove`)
- `animation {Number}` estilo de animación:
	- `1` opacidad
	- `2` escala de grande a normal
	- `3` escala de pequeño a normal (__predeterminado__)
	- `4` rotación Z
	- `5` cambio de posición X
	- `6` cambio de posición Y
- `grid {Boolean}` representa la cuadrícula de fondo (predeterminado: `false`)
- __NUEVO__: `reanimate {Boolean}` habilita la animación para cambiar los widgets (predeterminado: `false`)

```js
// Component declaration
var component = {

	// Component ID
	id: 'COMPONENT_ID',

	// Positioning
	// You can define specific display size and if the display size is not specified then the component tries to find a size for larger display
	offset: {
		xs: { x: 1, y: 1, width: 6, height: 6 }, // Number means the position in the grid, so e.g. width "2" takes "2" columns in X axis
		lg: { x: 1, y: 1, width: 6, height: 6 }
	},

	html: 'THE CONTENT OF COMPONENT', // or can be raw HTMLElement

	// Default settings
	actions: { move: true, remove: true, resize: true, resizeX: true, resizeY: true, resizeP: false, settings: true },
	// resizeP means: resize "proportionally"

	// Can disable header (default: true)
	header: true,

	// Can delay displaying (in "ms", default: config.delay)
	delay: 0,

	// A component title
	title: 'Title for the component',

	// Custom properties which will be assigned to the instance
	template: Object,
	config: Object,
	// reset: true, // NEW: reloads the component again
	// class: String // adds a class to the item

	make: function(exports, config, el) {

		// @exports {Object}
		// @config {Object}
		// @el {jQuery} a content of the component

		// Handlers (optional):
		exports.destroy = function() {
			// @el {jQuery} a content of the component
			// @this {Instance}

			// is executed when the component is destroyed
		};

		exports.data = function(data, el) {
			// @data {Object}
			// @this {Instance}
			// @el {jQuery} a content element of the component
			// It can be executed via SETTER('dashboard/send', ....)
		};

		exports.service = function(counter, el) {
			// @counter {Number} count of calls
			// @el {jQuery} a content of the component
			// @this {Instance}
			// dashboard will execute this handler each 5 seconds
		};

		exports.focus = function() {
			// Optional, when the "window" is focused the delegate will be executed
		};

		exports.resize = function(width, height, el, display) {
			// @width {Number}
			// @height {Number}
			// @el {jQuery} a content of the component
			// @display {String} a current display size "xs", "sm", "md" or "lg"
			// @this {Instance}
			// is executed when the component is resized
			// @this {Instance}
		};

		exports.settings = function(config, el, elbtn) {
			// @config {Object}
			// @el {jQuery} a content element of the component
			// @elbtn {jQuery} button element
			// is executed when the users clicks on the settings icon
		};

		exports.remove = function(remove) {
			// remove {Function} removes that widget
			remove();
		};

		exports.configure = function() {
			// is executed when the configuration is changed
		};

		// this.meta {Object} a reference to component object
		// this.element {jQuery} a content element of the component
		// this.container {jQuery} a main content element of the component
		// this.main {Object} a reference to Dashboard component
		// this.width {Number} a width of "this.element"
		// this.height {Number} a height of "this.element"
		// this.display {String} a current display size "xs", "sm", "md" or "lg"

		// is executed when the component is making
	}
};

PUSH('components', component);
```

__Métodos__:

- `SETTER('dashboard/send', id, body)` envía datos a todos los widgets que contienen el delegado `data`.
	- `id {String}`
		- `null` envía a todos los componentes
		- `@component` envía a los componentes específicos según el nombre del componente
		- `string` envía a un componente específico según el identificador
- `SETTER('dashboard/call', method_name, [a], [b], [c], [d])` ejecuta un método en cada widget
- `RETURN('dashboard/pixel')` devuelve el tamaño del píxel (cuadrado)
- `RETURN('dashboard/display')` devuelve el ancho de visualización actual

__Es bueno saberlo__:

- el componente agrega clases al cuerpo del componente:
	- `d_colNUMBER` determina el recuento de columnas tomadas, p. `d_col2`
	- `d_rowNUMBER` determina el recuento de filas tomadas, p. `d_row3`
	- `d_square` el componente tiene el mismo ancho/alto
	- `d_vertical` el componente tiene solo 1 paso de ancho y más de 1 paso de altura
	- `d_horizontal` el componente tiene solo 1 paso de altura y más de 1 paso de ancho

Úselo con `<ui-component name="dashboard">`. Cuando el componente aún no está cargado, jComponent lo descarga en el primer uso desde la dirección en `DEF.fallback` (el CDN Componentator de forma predeterminada). Autor: Peter Širka. Fuente: repositorio de componentes Componentator, licencia MIT.

```html example.html
<ui-component name="dashboard" path="components"></ui-component>
<script>

	var components = [];

	components.push({
		id: 'A',
		offset: { lg: { x: 0, y: 0, width: 4, height: 4 }},
		title: 'A',
		html: '<div class="padding">Lorem ipsum dolor sit amet.</div>',
		actions: { settings: true, remove: true, move: true, resize: true },
		make: function(exports, config, el) {

			// If you change some action "exports.actions" then execute:
			// exports.refresh();

			exports.data = function(data) {

			};

			exports.configure = function() {

			};

		}
	});

	components.push({
		id: 'B',
		offset: { lg: { x: 4, y: 0, width: 4, height: 4 }},
		title: 'B',
		html: '<div class="padding">Lorem ipsum dolor sit amet.</div>',
		actions: { settings: true, remove: true, move: true, resize: true }
	});
</script>
```
