ForgeKomponenty
cs

Komponenty

j-Dashboard

jComponent 20 · jcomponent@20 component Příklad načten s jComponent 20
  • Podporuje mobilní zařízení
  • Podporuje dotyk
  • pohyblivý
  • Drážďák
  • Odstranitelné

Složka očekává Array objektů.

Konfigurace:

  • axisX {Number} - velikost sítě X-axis (default: 12)
  • axisY {Number} - velikost sítě Y (předvolený: 144)
  • padding {Number} mezi widgety (předvolené: 10)
  • delay {Number} Zpoždění v nastavení (default) 200)
  • serviceinterval {Number} a servisní interval (předvolený: 5000)
  • ondrop {String} je cesta k metodu function(meta) {}, která se provádí, pokud někdo položí určitý prvek do oblasti
    • meta.x X síťová pozice
    • meta.y a síťová pozice
    • meta.el přilnavý prvek
    • meta.pageX
    • meta.pageY
    • meta.offsetX
    • meta.offsetY
    • meta.target
    • meta.d - režim zobrazení xs, sm, md nebo lg
  • noemitresize zabraňuje provádění metody resize ve všech nestěných složkách (případně: false)
  • parent {String} - mateřský kontejner, který stanoví minimální výšku (předběžně: null)
  • margin {Number} je horní / dolní marže pro možnost parent (podmínkou: 0)
  • minsizexs {Number} minimální velikost sloupce/kruhů pro další malé displeje (předvolené: 2)
  • minsizesm {Number} minimální velikost sloupce/kříže pro malé displeje (podle předvolby: 2)
  • minsizemd {Number} minimální velikost sloupce/kruhů pro mediunové displeje (předvolené: 1)
  • minsizelg {Number} minimální velikost sloupce/kruhů pro velké displeje (předvolené: 1)
  • iconsettings {String} nastavení ikony
  • iconremove {String} odstranění ikony
  • change {String} je cesta k metodu function(type, id) (vyplynutá, pokud deska zachytí změnu move nebo remove)
  • animation {Number} styl animace:
    • 1 opacita
    • 2 Rozsah od velké do normální
    • 3 Rozsah od malého do normálního (default)
    • 4 rotace Z
    • 5 změna pozice X
    • 6 změna polohy Y
  • grid {Boolean} renderů pozadí síť (předvolené: false)
  • NEW: reanimate {Boolean} umožňuje animaci pro změnu widgetů (podle předvolby: 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);

Metody:

  • SETTER('dashboard/send', id, body) odesílá data do všech widgetů, které obsahují delegát data
    • id {String}
      • null se odehrává ve všech složkách
      • @component odesílá na konkrétní složky podle názvu složky
      • string odesílá na konkrétní složku podle identifikátoru
  • SETTER('dashboard/call', method_name, [a], [b], [c], [d]) provádí metodu v každém widgetu
  • RETURN('dashboard/pixel') vrací velikost pixelů (square)
  • RETURN('dashboard/display') vrací aktuální šířku displeje

Dobré vědět:

  • Komponenta přidává třídy do těla komponenty:
    • d_colNUMBER určuje počet vzájemných sloupců, např. d_col2
    • d_rowNUMBER určuje počty provedených řádků např. d_row3
    • d_square je stejná šířka/výška
    • d_vertical složka má pouze 1 krok šířky a více než 1 krok výšky
    • d_horizontal složka má pouze 1 krok výšky a více než 1 krok šířky

Použijte ji s <ui-component name="dashboard">Pokud je součástka ještě nezačleněna, jComponent Stáhnout ji na první použití z adresy DEF.fallback a) The Componentator CDN dle předvolby. autor: Peter Širka. zdroj: Componentator Výrobce je autorizován, MIT licence.

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>