ForgeComponente
ro

Componente

j-Dashboard

jComponent 20 · jcomponent@20 component Exemplu încărcat cu jComponent 20
  • Suport pentru dispozitive mobile
  • susține atingerea
  • mişcări
  • Dragă
  • Răspundeți

Componentul așteaptă Array de obiecte.

Configurarea:

  • axisX {Number} o dimensiune a rețelei axului X (default: 12)
  • axisY {Number} o dimensiune a rețelei axului Y (default: 144)
  • padding {Number} un pasaj între widget-uri (default: 10)
  • delay {Number} Init întârziere (default: 200)
  • serviceinterval {Number} un interval de serviciu (default: 5000)
  • ondrop {String} este o cale spre metoda function(meta) {}, se execută dacă cineva aruncă un element în zonă.
    • meta.x Poziția X
    • meta.y Poziția rețelei
    • meta.el elementul de înfășurare
    • meta.pageX
    • meta.pageY
    • meta.offsetX
    • meta.offsetY
    • meta.target
    • meta.d Modul de afișare xs, sm, md sau lg
  • noemitresize interzice executarea metodei resize în toate componentele nestate (default: false)
  • parent {String} este un container care stabilește o înălțime minimă (default: null)
  • margin {Number} este o marjă superioară / inferioară pentru opțiunea parent (default: 0)
  • minsizexs {Number} o dimensiune minimă a coloanei/roei pentru ecrane mai mici (default: 2)
  • minsizesm {Number} o dimensiune minimă a coloanei/roei pentru ecranele mici (default: 2)
  • minsizemd {Number} o dimensiune minimă a coloanei/roei pentru ecranele mediun (default: 1)
  • minsizelg {Number} o dimensiune minimă a coloanei/roei pentru ecranele mari (default: 1)
  • Iconul de setare iconsettings {String}
  • iconremove {String} îndepărtarea iconului
  • change {String} este o cale spre metoda function(type, id) (executat dacă panourile captează o schimbare move sau remove)
  • Stilul de animație animation {Number}:
    • 1 opacitate
    • 2 De la mare la normal
    • 3 Scala de la mică la normală (default)
    • Rotație 4
    • 5 schimbarea poziției X
    • 6 schimbarea poziției Y
  • grid {Boolean} Render grid (default) pentru a fi false)
  • NEW: reanimate {Boolean} permite animația pentru schimbarea widget-urilor (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);

Metode:

  • SETTER('dashboard/send', id, body) trimite date către toate widget-urile care conțin un delegat data
    • id {String}
      • null trimite la toate componentele
      • @component trimite la componentele specifice în funcție de numele componentei
      • string trimite la un anumit component în funcție de identificator
  • SETTER('dashboard/call', method_name, [a], [b], [c], [d]) execută o metodă în fiecare widget
  • RETURN('dashboard/pixel') returnează o dimensiune a pixelului (square)
  • RETURN('dashboard/display') întoarce o latitudine de afișare actuală

bine să știi:

  • Componentul adaugă clase în corpul componentei:
    • d_colNUMBER determină numărul de coloane luate, de exemplu, d_col2
    • d_rowNUMBER determină numărul de rânduri luate, de exemplu, d_row3
    • d_square componenta are aceeași lățime / înălțime
    • d_vertical componentul are doar 1 pas de lățime și mai mult de 1 pas înălțime
    • d_horizontal componenta are doar 1 pas de înălțime și mai mult de 1 pas din lățime

Utilizați-l cu <ui-component name="dashboard">Când componenta nu este încă încărcată, jComponent Descărcați-l la prima utilizare de la adresa DEF.fallback (în cazul Componentator Autor: Peter Širka. sursă: Componentator Componente de stocare, MIT licență.

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>