ForgeKomponenter
sv

Komponenter

j-Dashboard

jComponent 20 · jcomponent@20 component Exempel laddat med jComponent 20
  • Stöd för mobila enheter
  • Stöd för beröring
  • rörliga
  • Dragbara
  • återställbar

Komponenten förväntar sig Array av objekt.

Konfigurera:

  • axisX {Number} en gridstorlek av X-axeln (default: 12)
  • axisY {Number} en gridstorlek av Y axel (default: 144)
  • padding {Number} en padding mellan widgets (default: 10)
  • delay {Number} init försening (default: 200)
  • serviceinterval {Number} en serviceintervall (default: 5000)
  • ondrop {String} en väg till metoden function(meta) {}, utförs om någon dropper något element i området
    • meta.x X nätposition
    • meta.y och gränssnitt
    • meta.el dragade element
    • meta.pageX
    • meta.pageY
    • meta.offsetX
    • meta.offsetY
    • meta.target
    • meta.d en skärmläge xs, sm, md eller lg
  • noemitresize inaktiverar genomförandet av resize-metoden i alla nötade komponenter (default: false)
  • parent {String} en föräldralåda som sätter en minimal höjd (default: null)
  • margin {Number} en topp/bottom marginal för parent alternativ (default: 0)
  • minsizexs {Number} en minimal kolumn/rödstorlek för extra små skärmar (default: 2)
  • minsizesm {Number} en minimal kolumn/rödstorlek för små skärmar (default: 2)
  • minsizemd {Number} en minimal kolumn/rödstorlek för mediun-skärmar (default: 1)
  • minsizelg {Number} en minimal kolumn/rödstorlek för stora skärmar (default: 1)
  • iconsettings {String} inställningar ikon
  • iconremove {String} avlägsnar ikonen
  • change {String} en väg till metoden function(type, id) (drivs om dashboardet fångar en förändring av move eller remove)
  • animation {Number} stil av animation:
    • 1 Opaticitet
    • 2 Skala från stor till normal
    • 3 Skala från liten till normal (default)
    • 4 rotation Z
    • 5 ändring av X-position
    • 6 ändring av Y-position
  • grid {Boolean} renderar bakgrundsgränssnitt (default: false)
  • NEW: reanimate {Boolean} möjliggör animering för att ändra widgets (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);

Metoder:

  • SETTER('dashboard/send', id, body) skickar data till alla widgets som innehåller data delegat
    • id {String}
      • null skickas till alla komponenter
      • @component skickar till de specifika komponenterna enligt komponentnamnet
      • string skickas till en specifik komponent enligt identifieraren
  • SETTER('dashboard/call', method_name, [a], [b], [c], [d]) kör en metod i varje widget
  • RETURN('dashboard/pixel') returnerar en pixelsstorlek (kvart)
  • RETURN('dashboard/display') returnerar en aktuell displaybredd

Bra att veta:

  • komponenten lägger till klasser till komponenten:
    • d_colNUMBER bestämmer antalet kolumner som tas, t.ex. d_col2
    • d_rowNUMBER bestämmer antalet tagna rader t.ex. d_row3
    • d_square komponenten har samma bredd/höjd
    • d_vertical komponenten har bara 1 steg bredd och mer än 1 steg höjd
    • d_horizontal komponenten har bara 1 steg höjd och mer än 1 steg bredd

Använd den med <ui-component name="dashboard">När komponenten ännu inte är laddad, jComponent Ladda ner den första gången från adressen i DEF.fallback (en av Componentator Författare: Peter Širka. källa: The Componentator Komponenterna i lager, MIT licens.

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>