# j-Templates

> Šablony musí být definovány v <script type='text/html' data-name='NAMEOFTEMPLATE'>Tangular šablonu</script> prvek.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: cs
Content-SHA256: bfc4652e9eb9f8e469bafe1419d3006c729642dcf6c492ea96410f97b0081629
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- Množství šablon
- Drop a drak
- Konečné scrollbary
- Kontextové menu

__Konfigurace__:

- `template {String}` - cesta k pozorování jména šablony
- `scrollbar {Boolean}` používá přizpůsobenou skříňku (default: `true`)
- `scrolltop {Boolean}` se otáčí na vrchol, pokud je zdroj změněn (předvolený: `true`)
- `visibleY {Boolean}` zobrazuje scrollbar Y (předvolené: `true`)
- `margin {Number}` vertikální marže (předvolené: `0`)
- `parent {String}` jQuery selektor na mateřský kontejner v důsledku `scrollbar` (předvolené: `auto`)
- `contextmenu {String}` je cesta k metodu `function(e)` pokud uživatel vyvolává kontextové menu
- `emptyif {String}` je podmínkou pro zobrazení prázdného obsahu (předvolené: `!value || !value.length`)
- `drop {String}` - cesta k metodu `function(e, target, selel)`
	- metoda je vyhodnocena, pokud uživatel spustí některé soubory, pak `selel` není definován
	- nebo uživatel drží a klesá prvek s atributem `draggable` (argument `selel`) do argumenta `target` (cíl musí obsahovat třídu `droppable`)

Modely musí být definovány v `<script type="text/html" data-name="NAME_OF_TEMPLATE">Tangular template</script>` Tento prvek podporuje speciální šablónu nazvanou `empty` To bude vidět, pokud `emptyif` Možnost bude platná.

Použijte ji s `<ui-component name="templates">`Pokud je součástka ještě nezačleněna, jComponent Stáhnout ji na první použití z adresy `DEF.fallback` a) The Componentator CDN dle předvolby. autor: Peter Širka. zdroj: Componentator Výrobce je autorizován, MIT licence.

```html example.html
<div>
	<span data-name="list" onclick="changetemplate(this)" style="text-decoration:underline;cursor:pointer;margin-right:5px">List</span>
	<span data-name="icons" onclick="changetemplate(this)" style="text-decoration:underline;cursor:pointer">Icons</span>
</div>
<br />

<div style="width:500px;height:300px;border:1px solid #E0E0E0">
	<ui-component name="templates" path="myfiles" config="template:mytemplate;drop:template_drop">

		<script type="text/html" data-name="list">
			<div class="list padding">
				{{ foreach m in value }}
					<div draggable="true"{{ if m.isfolder }} class="droppable"{{ fi }}>{{ m.name }}</div>
				{{ end }}
			</div>
		</script>

		<script type="text/html" data-name="icons">
			<div class="icons padding">
				{{ foreach m in value }}
					<span draggable="true" class="mr5 {{ if m.isfolder }} droppable{{ fi }}"><i class="{{ m.icon }} mr5"></i>{{ m.name }}</span>
				{{ end }}
			</div>
		</script>

	</ui-component>

</div>
<br />
<div><b>Without multiple templates:</b></div>
<div style="width:500px;height:300px;border:1px solid #E0E0E0;margin-top:10px">
	<ui-component name="templates" path="myfiles">
		<script type="text/html">
			<div class="list padding">
				{{ foreach m in value }}
					<div draggable="true"{{ if m.isfolder }} class="droppable"{{ fi }}>{{ m.name }}</div>
				{{ end }}
			</div>
		</script>
	</ui-component>
</div>

<script>
	var myfiles = [{ icon: 'ti ti-folder', name: 'temp', isfolder: true }, { icon: 'ti ti-file', name: 'logo.png' }, { icon: 'ti ti-file', name: 'logo.svg' }];
	var mytemplate = 'list';

	function changetemplate(el) {
		SET('mytemplate', el.getAttribute('data-name'));
	}

	function template_drop(e, target, item) {

		console.log(e, target, item);
		// @target {jQuery element}

		if (item) {
			// @item {jQuery element}
		} else {
			var files = e.target.files || e.originalEvent.dataTransfer.files;
		}
	}

</script>
```
