ForgeКомпоненти
bg

Компоненти

j-Dashboard

jComponent 20 · jcomponent@20 component Примерът е зареден с jComponent 20
  • Поддържа мобилни устройства
  • Поддържа докосване
  • Мобилно
  • Стрелба
  • Възстановяване

Съставът очаква Array на обектите.

Конфигуриране:

  • axisX {Number} - размер на ретината на X-аксиса (предварително: 12)
  • axisY {Number} - размер на мрежата на Y оса (предварително: 144)
  • padding {Number} Включване на падинг между видове (дефолт: 10)
  • delay {Number} Закъснение на интуицията (предварително: 200)
  • serviceinterval {Number} Задължителен интервал на обслужване (дефолт: 5000)
  • ondrop {String} е пътят към метода function(meta) {}, който се изпълнява, ако някой хвърли елемент в областта
    • meta.x X мрежата
    • meta.y и мрежата
    • meta.el Изтеглени елементи
    • meta.pageX
    • meta.pageY
    • meta.offsetX
    • meta.offsetY
    • meta.target
    • meta.d - режим на дисплей xs, sm, md или lg
  • noemitresize прекъсва изпълнението на метода resize във всички нистени компоненти (предварително: false)
  • parent {String} - родителски контейнер, който поставя минимална височина (предварително: null)
  • margin {Number} е горна/долна маржа за опцията parent (предварително: 0)
  • minsizexs {Number} - минимален размер на колона/роу за допълнителни малки дисплеи (предварително: 2)
  • minsizesm {Number} минимален размер на колона за малки дисплеи (предварително: 2)
  • minsizemd {Number} - минимален размер на колона/роу за средни дисплеи (предварително: 1)
  • minsizelg {Number} - минимален размер на колона за големи дисплеи (предварително: 1)
  • iconsettings {String} Икона настройка
  • iconremove {String} премахване на иконата
  • change {String} е пътят към метода function(type, id) (извършен, ако панелът за записване на промяна move или remove)
  • animation {Number} Стилът на анимацията:
    • 1 Опасност
    • 2 Размер от голям до нормален
    • 3 Размер от малък до нормален (default)
    • 4 Ротация Z
    • 5 промяна на позицията X
    • 6 промяна на позицията Y
  • grid {Boolean} Рендър на задната мрежа (дефолт: false)
  • NEW: reanimate {Boolean} позволява анимация за промяна на виджета (предварително: 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);

Методи:

  • SETTER('dashboard/send', id, body) изпраща данни до всички видове, които съдържат data делегат
    • id {String}
      • null изпраща на всички компоненти
      • @component изпраща към конкретните компоненти според името на компонента
      • string изпраща към конкретен компонент според идентификатора
  • SETTER('dashboard/call', method_name, [a], [b], [c], [d]) изпълнява един метод във всеки виџет
  • RETURN('dashboard/pixel') връща размера на пиксела (квартирата)
  • RETURN('dashboard/display') връща текущата ширина на дисплея

Добре е да се знае:

  • Компонентът добавя класове към тялото на компонента:
    • d_colNUMBER определя броя на взетите колони, например d_col2
    • d_rowNUMBER определя броя на взетите редове, например d_row3
    • d_square компонентът има еднаква ширина / височина
    • d_vertical компонентът има само 1 стъпка ширина и повече от 1 стъпки височина
    • d_horizontal компонентът има само 1 стъпка височина и повече от 1 стъпки ширина

Използвайте го с <ui-component name="dashboard">Когато компонентът все още не е зареден, jComponent Изтегляне на първия адрес в DEF.fallback (След това Componentator Източник: Питър Шерка Componentator Съставни съставки, лиценз на MIT.

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>