ForgeComponents
en

Components

j-ASelected

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20
  • readonly

The component adds selected class to <a element if the href attribute of the element will contain URL address from the web browser. It's targeted for public websites.

Configuration:

  • class {String} is a class name for selected element (default: selected)
  • selector {String} is a jQuery selector (default: a)
  • attr {String} attribute for comparing (default: href)
  • strict {Boolean} enables strict comparing of URL address (default: false)
  • delay {Number} a delay for rebinding of selection when the model is changed (default: 300)
  • NEW: watch {String} a path for watching changes

Use it with <ui-component name="aselected">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

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="aselected" class="links">
	<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>
</ui-component>

<script>

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

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

</script>