ForgeKomponenty
cs

Komponenty

j-Folder

jComponent 20 · jcomponent@20 component Příklad načten s jComponent 20

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 windowPodmí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)
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.

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>