j-Templates
- Množství šablon
- Drop a drak
- Konečné scrollbary
- Kontextové menu
Konfigurace:
template {String}- cesta k pozorování jména šablonyscrollbar {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ůsledkuscrollbar(předvolené:auto)contextmenu {String}je cesta k metodufunction(e)pokud uživatel vyvolává kontextové menuemptyif {String}je podmínkou pro zobrazení prázdného obsahu (předvolené:!value || !value.length)drop {String}- cesta k metodufunction(e, target, selel)- metoda je vyhodnocena, pokud uživatel spustí některé soubory, pak
selelnení definován - nebo uživatel drží a klesá prvek s atributem
draggable(argumentselel) do argumentatarget(cíl musí obsahovat třídudroppable)
- metoda je vyhodnocena, pokud uživatel spustí některé soubory, pak
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.
<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>