# j-FloatingBox

> j-FloatingBox: supports dark mode

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

- supports __dark mode__

__Configuration__:

- `zindex {Number}` a default z-index for forms (default: `10`)

__Methods__:

- `component.show(opt)` shows a box
	- `opt.id {String}` __required__ - a box identifier
	- `opt.element {HTML Element}` __required__ - target element
		- or you can use absolute position:
		- `opt.x {Number}`
		- `opt.y {Number}`
	- `opt.offsetX {Number}` affects offset X
	- `opt.offsetY {Number}` affects offset Y
	- `opt.align {String}` align `left` (default), `center` or `right`
	- `opt.position {String}` align `top` (default), `bottom`
	- `opt.minwidth {Number}`
	- `opt.maxwidth {Number}`
	- `opt.mouseleave {String}` a link to the method, it's executed when the mouse cursor leaves the box `function(e, close)}`
	- `opt.autofocus {Boolean}` tries to focus first input/textarea
	- `opt.hide {String}` a link to the method `function(box_element)`
	- `opt.show {String}` a link to the method `function(box_element)`
	- `opt.autohide {Boolean}` enables hiding a box after clicking on it
	- `opt.delay {Number}` a simple delay for rendering (default: `0`)
	- `opt.scrolltop {Boolean}` it deducts scroll top position from the current offset Y (default: `false`)
	- `opt.url {String}` optional, URL address for the content
		- `opt.path {String}` will replace all `~PATH~` phrases in the downloaded template
		- `opt.ID {String}` will replace all `~ID~` phrases in the downloaded template
- `component.hide()` hides the last open box
- `component.hide([box_id])` hides the specific box and its all nested boxes
- `component.hide(true)` hides all boxes

### Boxes

```html
<div class="floatingbox" data-id="yourid" data-config="">
	Your content
</div>
```

__Configuration__:

- `init {String}` a link to the method, it's executed when the box is initialized the first time `function(element)`
- `reload {String}` a link to the method `function(element)`
- `hide {String}` a link to the method, it's executed when the box is going to hide `function(element)`
- `scope {String}` a custom scope/plugin name
- `zindex {Number}` a custom z-index for this box

Use it with `<ui-component name="floatingbox">`. 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.

```html example.html
<ui-component name="exec"></ui-component>
<ui-component name="floatingbox" config="zindex:10"></ui-component>

<!-- Form templates -->

<div class="floatingbox" data-id="1" style="width:200px">
	<div class="padding">
		<div>Box 1</div>
		<br />
		<br />
		<br />
	</div>
</div>

<div class="floatingbox" data-id="2" data-config="init:box2init">
	<div class="padding">
		<div>Box 2</div>
		<br />
		<br />
		<br />
		<span class="exec" data-exec="showbox" data-id="3" style="color:#2A6CEC;cursor:pointer;text-decoration:underline">Show box 3</span>
	</div>
</div>

<div class="floatingbox" data-id="3">
	<div class="padding">
		Box 3
	</div>
</div>

<!-- Executors -->

<div class="row">
	<div class="col-xs-4">
		<span class="exec" data-exec="showbox" data-id="1" style="color:#2A6CEC;cursor:pointer;text-decoration:underline" class="block">Show box 1</span>
	</div>
	<div class="col-xs-4">
		<span class="exec" data-exec="showbox" data-id="2" style="color:#2A6CEC;cursor:pointer;text-decoration:underline" class="block">Show box 2</span>
	</div>
	<div class="col-xs-4">
		<span class="exec" data-exec="showbox" data-id="3" style="color:#2A6CEC;cursor:pointer;text-decoration:underline" class="block">Show box 3</span>
	</div>
</div>

<script>

	function showbox(el) {
		var opt = {};
		opt.element = el;
		opt.id = el.attrd('id');
		SETTER('floatingbox/show', opt);
	}

	function box2init(el) {
		console.log('Box 2 is initialized', el);
	}

</script>
```
