# j-Folder

> Komponenta může zobrazit obsah jako souborový prohlížeč. trasa musí být ve formě např. Directory/Directory/File.

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

Komponenta může zobrazit obsah jako souborový prohlížeč. `path` musí být ve formě např. `Directory/Directory/File`.


__Konfigurace__:

- `up {String}` je štítek pro tlačítko Up (předvolené: `..`)
- `delimiter {String}` je delimetr pro cestu (default: `/`)
- `root {String}` označení pro první položku v chlebotě (předvolený: `Root`)
- `scrollbar {Boolean}` umožňuje přizpůsobený scrollbar (default: `true`)
- `scrollbarY {Boolean}` ukazuje Y scrollbar vždy (předvolené: `false`)
- `delimiter {String}` je delimetr pro cestu (default: `/`)
- `options {String}` je cesta k metodu `function(item, el)` (uživatel musí kliknout na pravé tlačítko)
- `click {String}` je cesta k variabilu nebo metodu `function(item)` (uživatel musí kliknout na položku)
- `checked {String}` - cesta k variabilnímu nebo metodu `function(checked_items, component)` (uživatel musí kontrolovat kontrolní krabici)
- `browse {String}` __IMPORTANT__: cesta k metodu `function(path, next(ARRAY), [item])`, která musí vrátit obsah pro složku
- `parent {String}` Volitelně, kontejner s pevnou výškou, může být `window`Podmínkou hodnoty: `component.element()`
- `margin {Number}` volitelné, vrchní / dolní hranice spolu (podmínkou: `0`)
- `drop {String}` je volitelná, cesta k metodu, která bude spuštěna, pokud je soubor vytištěn
- `key {String}` volitelné, klíčové jméno pro vytvoření trasy (default: `name`)
- `raw {Boolean}` volitelně, deaktivuje kódování HTML `name` (předvolené: `false`)
- __NEW__: `contextmenu {String}` volitelné, cesta k metodu `function(item, el, e)` (když uživatel zobrazí kontextové menu)

```js
function fn_browser(path, next, item) {

	// @path {String} paths divided according to the "config.delimiter"
	// @next {Function(Array)} importat: this function expects array with items
	// @item {Object} can be null

	var arr = [];

	// Object for array:
	// obj.name {String} a label/name
	// obj.checkbox {Boolean} enables checkbox (default: false)
	// obj.checked {Boolean} item will be checked
	// obj.icon {String} a icon for item
	// obj.type {Number} determines a type of item (1: directory, other: file)
	// obj.classname {String} adds a CSS class onto "label" element

	// Good to know:
	// Only directories can be drilled

	// Example:
	arr.push({ name: 'Node.js', checkbox: true, type: 1, icon: 'folder' });
	arr.push({ name: 'Client-Side', checkbox: true, type: 1, icon: 'folder' });

	next(arr);
	// next(array, noscroll);
}
```

Použijte ji s `<ui-component name="folder">`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 class="container">
	<br />
	<ui-component name="folder" path="currentpath" config="browse:fn_browse;checked:fn_checked;click:fn_click" style="height:500px"></ui-component>
	<br />
</div>

<script>

	var currentpath = 'Frameworks/Node.js';

	function fn_browse(path, next, item) {

		var arr = [];

		switch (path) {
			case 'Frameworks':
				arr.push({ name: 'Node.js', checkbox: true, type: 1, icon: 'folder' });
				arr.push({ name: 'Client-Side', checkbox: true, type: 1, icon: 'folder' });
				break;
			case 'Frameworks/Node.js':
				arr.push({ name: 'Total.js', checkbox: true, checked: true, icon: 'file' });
				arr.push({ name: 'Express.js', checkbox: true, icon: 'file' });
				arr.push({ name: 'Koa.js', checkbox: true, icon: 'file' });
				arr.push({ name: 'Meteor.js', checkbox: true, icon: 'file' });
				break;
			case 'Frameworks/Client-Side':
				arr.push({ name: 'React', checkbox: true, icon: 'file' });
				arr.push({ name: 'Vue', checkbox: true, icon: 'file' });
				arr.push({ name: 'jComponent', checkbox: true, checked: true, icon: 'file' });
				arr.push({ name: 'Angular.js', checkbox: true, icon: 'file' });
				arr.push({ name: 'jQuery', checkbox: true, icon: 'file' });
				break;
			default:
				arr.push({ name: 'Frameworks', checkbox: true, type: 1, icon: 'folder' });
				arr.push({ name: 'Item 1', checkbox: true, icon: 'file' });
				arr.push({ name: 'Item 2', checkbox: true, icon: 'file' });
				arr.push({ name: 'Item 3', checkbox: true, icon: 'file' });
				break;
		}

		next(arr);
	}

	function fn_click(item) {
		console.log('click', item);
	}

	function fn_checked(arr) {
		console.log('checked', arr);
	}

</script>
```
