# j-Dashboard

> Le composant attend un tableau d'objets.

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

- Prend en charge les appareils mobiles
- Prend en charge les touches
- Mobile
- Travail
- Redimensionnable

Le composant attend le `Array` des objets.

__Configuration__ :

- `axisX {Number}` une taille de réseau d'axe X (defaut: `12`)
- `axisY {Number}` une taille de réseau d'axe Y (defaut: `144`)
- `padding {Number}` un tapis entre les widgets (defaut: `10`)
- `delay {Number}` retard de l'inité (défaut : `200`)
- `serviceinterval {Number}` un intervalle de service (defaut : `5000`)
- `ondrop {String}` est un chemin vers la méthode `function(meta) {}`, s'il y a quelqu'un qui jette un élément dans la zone.
	- `meta.x` X position de réseau
	- `meta.y` et position de réseau
	- `meta.el` Élément tracé
	- `meta.pageX`
	- `meta.pageY`
	- `meta.offsetX`
	- `meta.offsetY`
	- `meta.target`
	- `meta.d` mode d'affichage `xs`, `sm`, `md` ou `lg`
- `noemitresize` désactive l'exécution de la méthode `resize` dans tous les composants nés (defaut: `false`)
- `parent {String}` un conteneur parent qui définit une hauteur minimale (par défaut : `null`)
- `margin {Number}` une marge de haut/bas pour l'option `parent` (defaut: `0`)
- `minsizexs {Number}` : une taille minimale de colonne/rouge pour les écrans plus petits (defaut : `2`)
- `minsizesm {Number}` une taille minimale de colonne/rouge pour les petits disques (defaut: `2`)
- `minsizemd {Number}` une taille minimale de colonne/rouge pour les écrans médius (defaut: `1`)
- `minsizelg {Number}` une taille minimale de colonne/rouge pour les écrans majeurs (défaut: `1`)
- `iconsettings {String}` Icône
- `iconremove {String}` supprimer l'icône
- `change {String}` un chemin vers la méthode `function(type, id)` (exécuté si le panneau de commande capte un changement `move` ou `remove`)
- Style d'animation `animation {Number}` :
	- Opacité `1`
	- `2` De la grande à la normale
	- `3` La taille de la petite à la normale (defaut)
	- `4` rotation Z
	- `5` changement de position X
	- `6` changement de position Y
- `grid {Boolean}` renders en arrière-plan (defaut : `false`)
- __NEW__: `reanimate {Boolean}` permet l'animation pour changer les widgets (défaut : `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éthodes__ :

- `SETTER('dashboard/send', id, body)` envoie des données à tous les widgets qui contiennent le délégué `data`
	- `id {String}`
		- `null` pour tous les composants
		- `@component` envoie aux composants spécifiques selon le nom des composants
		- `string` envoie à un composant spécifique selon l'identificateur
- `SETTER('dashboard/call', method_name, [a], [b], [c], [d])` exécute une méthode dans chaque widget
- `RETURN('dashboard/pixel')` revient à la taille du pixel (square)
- Le `RETURN('dashboard/display')` revient à une largeur d'écran actuelle

__Bon à savoir__ :

- Le composant ajoute des classes au corps du composant :
	- `d_colNUMBER` détermine le nombre de colonnes prises par exemple `d_col2`
	- `d_rowNUMBER` détermine le nombre de rangs pris, par exemple `d_row3`
	- `d_square` le composant a la même largeur / hauteur
	- `d_vertical` le composant n'a que 1 étape de largeur et plus d'1 étapes de hauteur
	- `d_horizontal` le composant n'a que 1 étape de hauteur et plus d'un pas de largeur

Utilisez-le avec `<ui-component name="dashboard">`. Lorsque le composant n'est pas encore chargé, jComponent le télécharge lors de la première utilisation depuis l'adresse dans `DEF.fallback` (le CDN Componentator par défaut). Auteur : Peter Širka. Source : le référentiel de composants Componentator, licence 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>
```
