ForgeKomponenty
pl

Komponenty

j-Templates

jComponent 20 · jcomponent@20 component Przykład załadowany z jComponent 20
  • Wiele szablonów
  • Drop & Drop
  • Zwyczajne scrollbary
  • Menu kontekstowe

Konfiguracja:

  • template {String} - droga do oglądania nazwy szablonu
  • scrollbar {Boolean} wykorzystuje przystosowany pasek skręcania (default: true)
  • scrolltop {Boolean} skręca się do góry, jeśli źródło jest zmienione (default: true)
  • visibleY {Boolean} wyświetla pasek Y (default: true)
  • margin {Number} - margina pionowa (default: 0)
  • parent {String} jQuery do rodzinnego kontenera ze względu na scrollbar (w podziale na auto)
  • contextmenu {String} jest drogą do metody function(e) jeśli użytkownik wywołuje menu kontekstu
  • emptyif {String} warunek wyświetlania pustych treści (default: !value || !value.length)
  • drop {String} Droga do metody function(e, target, selel)
    • metoda jest oceniana, jeśli użytkownik spadnie niektóre pliki, a następnie selel nie jest zdefiniowany
    • lub użytkownik wyciąga i wkłada element z atrybutem draggable (argument selel) do argumenta target (target musi zawierać klasę droppable)

Modele muszą być określone w <script type="text/html" data-name="NAME_OF_TEMPLATE">Tangular template</script> Ten element obsługuje specjalny szablon o nazwie empty Będzie to widoczne, jeśli emptyif Opcja będzie ważna.

Użyj go z <ui-component name="templates">Gdy element nie jest jeszcze ładowany, jComponent Pobierz go po pierwszym użyciu z adresu DEF.fallback (Wydaje się Componentator Autor: Peter Širka Źródło: Componentator Zestaw składników, licencja MIT.

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>