j-Parts
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 thefunction(part), it's executed if the part is created (called once)focus {String}a link to thefunction(part), it's executed if the part is focusedclose {String}a link to thefunction(part), it's executed if the part is closed
Good to know 1:
- all
~PATH~phrases will be replaced byitem.pathautomatically - all
~ID~phrases will be replaced byitem.idautomatically
Item specification:
item.id {String}very important, part identifieritem.blur {String/Function(el, item)}optional, a link to thefunction(element, item)if the part is focused outitem.focus {String/Function(el, item)}oritem.reload {String}optional, a link to thefunction(element, item)if the part is focuseditem.remove {String/Function(el, item)}optional, a link to thefunction(element, item)if the part is removeditem.html {String}a HTML content or useitem.urlitem.import {String}URL address for the part contentitem.path {String}optional, it replaces all~PATH~phrases automaticallyitem.delay {Number}a delay for removing ofinvisibleclass- NEW
item.attrd {Object}addsdata-keyattributes into the item element
Extendend by the component:
item.focused {Boolean}determines if the part is focused or notitem.element {jQuery}part element
Methods:
component.close(id)closes partcomponent.focus(id)focuses partcomponent.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.
<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>