ForgeKomponenten
de

Komponenten

j-Dashboard

jComponent 20 · jcomponent@20 component Beispiel mit jComponent 20 geladen
  • Unterstützt mobile Geräte
  • Unterstützt Berührungen
  • Beweglich
  • Drahtbar
  • Größenveränderbar

Die Komponente erwartet Array von Objekten.

Konfiguration:

  • axisX {Number} eine Größe des Netzes der X-Axe (Default: 12)
  • axisY {Number} eine Größe des Netzes der Y-Axe (Default: 144)
  • padding {Number} eine Padding zwischen Widgets (Default: 10)
  • delay {Number} Init Verzögerung (Default: 200)
  • serviceinterval {Number} ein Serviceintervall (Default: 5000)
  • ondrop {String} ist eine Art und Weise, die function(meta) {} durchgeführt wird, wenn jemand ein Element in das Gebiet drückt.
    • meta.x X Netzposition
    • meta.y und Netzposition
    • meta.el entlastet
    • meta.pageX
    • meta.pageY
    • meta.offsetX
    • meta.offsetY
    • meta.target
    • meta.d ein Displaymodus xs, sm, md oder lg
  • noemitresize deaktiviert die Ausführung der Methode resize in allen Nested-Komponenten (Default: false)
  • parent {String} ein übergeordneter Container, der eine minimale Höhe festlegt (Standard: null)
  • margin {Number} ist eine obere/bottom Marge für die parent Option (Default: 0)
  • minsizexs {Number} eine minimale Spalte/Rollgröße für zusätzliche kleine Anzeigen (Default: 2)
  • minsizesm {Number} eine minimale Spalte/Rohgröße für kleine Display (Default: 2)
  • minsizemd {Number} eine minimale Spalte/Rohgröße für Mediun-Displays (Default: 1)
  • minsizelg {Number} eine minimale Spalte/Rohgröße für große Display (Default: 1)
  • iconsettings {String} Einrichtung Icon
  • iconremove {String} entfernen Icon
  • change {String} einen Weg zur Methode function(type, id) (ausführen, wenn das Dashboard eine Änderung von move oder remove erfährt)
  • animation {Number}-Animationsstil:
    • 1 Deckkraft
    • 2 Größe von großer zu normaler
    • 3 Größe von klein bis normal (default)
    • 4 Drehung Z
    • 5 Änderung der X-Position
    • 6 Änderung der Y-Position
  • grid {Boolean} Render Hintergrundnetz (Default: false)
  • NEW: reanimate {Boolean} ermöglicht Animation für Wechsel-Vidgets (Default: false)
// 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);

Methoden:

  • SETTER('dashboard/send', id, body) sendet Daten an alle Widgets, die data Delegate enthalten
    • id {String}
      • null sendet an alle Komponenten
      • @component sendet an die spezifischen Komponenten nach dem Komponentenname
      • string sendet an eine bestimmte Komponente nach dem Identifier
  • SETTER('dashboard/call', method_name, [a], [b], [c], [d]) führt eine Methode in jedem Widget aus
  • RETURN('dashboard/pixel') gibt eine Größe des Pixels (Quadrat) zurück
  • RETURN('dashboard/display') gibt eine aktuelle Displaybreite zurück

Gut zu wissen:

  • Komponente fügt Klassen an den Körper des Komponenten hinzu:
    • d_colNUMBER bestimmt die Anzahl der eingetragenen Spalten, z.B. d_col2
    • d_rowNUMBER bestimmt die Anzahl der genannten Zeilen, z. B. d_row3
    • d_square der Komponent hat die gleiche Breite/Höhe
    • d_vertical der Komponent hat nur 1 Stufe Breite und mehr als 1 Stufen Höhe
    • d_horizontal der Komponent hat nur 1 Schritt Höhe und mehr als 1 Schritt Breite

Verwenden Sie es mit <ui-component name="dashboard">. Wenn die Komponente noch nicht geladen ist, lädt jComponent sie bei der ersten Verwendung von der Adresse in DEF.fallback herunter (standardmäßig das CDN Componentator). Autor: Peter Širka. Quelle: Componentator-Komponenten-Repository, MIT-Lizenz.

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>