ForgeComponents
en

Components

j-Parts

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

This content can handle multiple parts stored in the Array and focus on one specific part. It simulates something like browser tabs.


Configuration:

  • parent {String} parent area due to part size (default: auto)
  • margin {Number} vertical margin (default: 0)
  • create {String} a link to the function(part), it's executed if the part is created (called once)
  • focus {String} a link to the function(part), it's executed if the part is focused
  • close {String} a link to the function(part), it's executed if the part is closed

Good to know 1:

  • all ~PATH~ phrases will be replaced by item.path automatically
  • all ~ID~ phrases will be replaced by item.id automatically

Item specification:

  • item.id {String} very important, part identifier
  • item.blur {String/Function(el, item)} optional, a link to the function(element, item) if the part is focused out
  • item.focus {String/Function(el, item)} or item.reload {String} optional, a link to the function(element, item) if the part is focused
  • item.remove {String/Function(el, item)} optional, a link to the function(element, item) if the part is removed
  • item.html {String} a HTML content or use item.url
  • item.import {String} URL address for the part content
  • item.path {String} optional, it replaces all ~PATH~ phrases automatically
  • item.delay {Number} a delay for removing of invisible class
  • NEW item.attrd {Object} adds data-key attributes into the item element

Extendend by the component:

  • item.focused {Boolean} determines if the part is focused or not
  • item.element {jQuery} part element

Methods:

  • component.close(id) closes part
  • component.focus(id) focuses part
  • component.rename(id, name, [icon]) renames part

Use it with <ui-component name="parts">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

example.html
<ui-component name="exec">

	<ui-bind path="myparts" config="template" class="block">
		<script type="text/html">
			{{ foreach m in value }}
			<button class="exec" data-exec="changepart" data-id="{{ m.id }}"><i class="ti ti-times exec mr5" data-prevent="true" data-exec="closepart"></i>{{ m.name }}</button>
			{{ end }}
		</script>
	</ui-bind>
	<br />

	<div style="width:600px;height:300px;border:1px solid #E0E0E0">
		<ui-component name="parts" path="myparts" config="parent:auto"></ui-component>
	</div>

</ui-component>

<script>
	var myparts = [];

	myparts.push({ id: '1', name: 'Part 1', html: '<div class="padding">Part 1</div>' });
	myparts.push({ id: '2', name: 'Part 2', html: '<div class="padding">Part 2</div>' });
	myparts.push({ id: '3', name: 'Part 3', html: '<div class="padding">Part 3</div>' });

	function changepart(el ,e) {
		var id = ATTRD(el);
		SETTER('parts/focus', id);
	}

	function closepart(el, e) {
		var id = ATTRD(el);
		SETTER('parts/close', id);
	}

</script>