ForgeKomponenten
de

Komponenten

j-AutoSelect

jComponent 20 · jcomponent@20 component Beispiel mit jComponent 20 geladen
  • Singleton

Die Komponente fügt automatisch die Klasse .selected entsprechend dem Selektor class="autoselect" im gesamten HTML-Dokument hinzu. Diese Komponente ist eine perfekte Lösung für serverseitiges Rendering und anschließendes Hervorheben.

Konfiguration:

  • selector {String} ist ein jQuery-Selektor (Standard: .autoselect a)
  • class {String} ist ein Klassenname für das ausgewählte Element (Standard: selected)

Verwenden Sie es mit <ui-component name="autoselect">. Wenn die Komponente noch nicht geladen ist, lädt jComponent sie bei der ersten Verwendung von der Adresse in DEF.fallback herunter (standardmäßig das CDN Componentator). Autor: Peter Širka. Quelle: Componentator-Komponenten-Repository, MIT-Lizenz.

example.html
<style>
	.links a { display: block; border: 0; text-align: left; color: gray; font-size: 14px; border-radius: 2px; padding: 2px 10px; margin-bottom: 1px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; position: relative; }
	.links a i { width: 14px; text-align: center; font-size: 12px; margin-right: 7px; color: #4285F4; }
	.links .selected { font-weight: bold; color: white !important; background-color: #4285F4; }
	.links .selected i { color: white !important }
	.links a:hover { text-decoration: none; color: black; }
</style>

<ui-component name="autoselect" path="NAV.url"></ui-component>

<div class="links autoselect">
	<div class="m">Menu 1</div>
	<a href="/"><i class="ti ti-users"></i>Users</a>
	<a href="/products/"><i class="ti ti-box"></i>Products</a>
	<a href="/settings/"><i class="ti ti-cog"></i>Settings</a>
</div>
<br />
<div class="links autoselect">
	<div class="m">Menu 2</div>
	<a href="/"><i class="ti ti-users"></i>Users</a>
	<a href="/products/"><i class="ti ti-box"></i>Products</a>
	<a href="/settings/"><i class="ti ti-cog"></i>Settings</a>
</div>

<script>

	var arr = ['/', '/products/', '/settings/'];

	setInterval(function() {
		REDIRECT(arr[(Math.random() * arr.length) >> 0]);
	}, 1500);

</script>