# j-Controls

> j-Controls - Singleton

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: sv
Content-SHA256: f285946135c62fb7f11165a55976da742d104950cb80712e5fa64d5de3b0641c
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- singlar

## Användning

```javascript
var opt = {};

// opt.offsetX {Number}    : adds X offset (default: 0)
// opt.offsetY {Number}    : adds Y offset (default: 0)
// opt.align {String}      : align `left` (default), `center` or `right`
// opt.position {String}   : position `top` (default) or `bottom`
// opt.hide {Function}     : NEW: is executed when the menu is hidden
// opt.classname {String}  : NEW: adds class to the parent
// opt.large {Boolean}     : NEW: it'll make menu bigger

opt.element = YOUR_ELEMENT;
// or if you want to use a fixed position:
// opt.x {Number}          : `x` position
// opt.y {Number}          : `y` position

opt.items = ['Label', { name: 'Item 1', icon: 'print', classname: 'custom_class_name' }, { name: 'Item 2', icon: 'home', title: 'A tooltip' }, '-', { name: 'Item 3', icon: 'far fa-envelope', children: [{ name: 'Submenu item 1', icon: 'cog' }, { name: 'Submenu item 2', icon: 'home' }] }, { name: 'Selected', icon: 'check-circle', selected: true }, { name: 'Item 4', icon: 'gear', disabled: true }];
// Item properties
// name {String}           : item name
// icon {String}           : icon
// classname {String}      : class to be added to li element
// title {String}          : tooltip
// selected {Boolean}      : item will be highlighted
// disabled {Boolean}      : item will be disabled(not clickable)
// children {Array}        : array of subitems

opt.callback = function(item) {
	console.log(item);
};

SETTER('controls/show', opt);
```

Använd den med `<ui-component name="controls">`När komponenten ännu inte är laddad, jComponent Ladda ner den första gången från adressen i `DEF.fallback` (en av Componentator Författare: Peter Širka. källa: The Componentator Komponenterna i lager, MIT licens.

```html example.html
<style>
	body { background-color: #E0E0E0; }
</style>

<ui-component name="controls"></ui-component>

<div class="container">
	<div class="row">
		<div class="col-xs-4 col-xs-offset-4" style="text-align:center">
			<a href="javascript:void(0)" style="color:black;font-size:20px"><i class="ti ti-ellipsis-v"></i></a>
		</div>
	</div>
</div>

<script>
	$(document).on('click', 'a', function() {

		var opt = {};
		opt.items = ['Label', { icon: 'print', classname: 'custom_class_name' }, { icon: 'home', disabled: true, title: 'Home' }, '-', { icon: '!ti ti-envelope', children: [{ name: 'Submenu item 1', icon: 'cog' }, { name: 'Submenu item 2', icon: 'home' }] }, { name: 'Selected', icon: 'check-circle', selected: true }];
		opt.align = 'center';
		opt.element = this;
		// opt.large = true;
		opt.callback = function(selected) {
			console.log(selected);
		};
		SETTER('controls/show', opt);
	});

</script>
```
