ForgeKomponenty
sk

Komponenty

j-Menu

jComponent 20 · jcomponent@20 component Príklad načítaný s jComponent 20
  • pracuje s dotykmi
  • podporuje Tmavý režim
  • singleton
  • NEW podporuje veľký režim

Konfigurácia:

  • NEW style {Number} zmení štýl (podporovaný štýl 2 (predvolené) a 1)

Použitie

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}       : is executed when the menu is hidden
// opt.class {String}        : adds class to the parent
// opt.large {Boolean}       : it will make menu bigger
// opt.fixedwidth {Boolean}  : NEW: enables fixed width according to the target element
// opt.offsetWidth {Number}  : increases width of the menu
// opt.nomobile {Boolean}    : change size on mobile screen

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', class: 'custom_class_name' }, { name: 'Item 2', icon: 'home', note: 'A simple description for this item' }, '-', { name: 'Item 3', icon: 'ti ti-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
// class {String}            : class to be added to li element
// note {String}             : text bellow Item name
// selected {Boolean}        : item will be highlighted
// disabled {Boolean}        : item will be disabled(not clickable)
// children {Array}          : array of subitems
// color {String}            : icon color

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

SETTER('menu', 'show', opt);

Použite ho so <ui-component name="menu">. Keď komponent ešte nie je načítaný, jComponent ho stiahne pri prvom použití z adresy v DEF.fallback (predvolene CDN Componentator). Autor: Peter Širka. Zdroj: úložisko komponentov Componentator, licencia MIT.

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

<ui-component name="menu"></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', { name: 'Item 1', icon: 'print', class: 'custom_class_name' }, { name: 'Item 2', icon: 'home', note: 'A simple description for this item' }, '-', { name: 'Item 3', 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.callback = function(selected) {
			console.log(selected);
		};
		SETTER('menu/show', opt);
	});
</script>