# j-Centered

> New version of this component supports dynamic evaluation of the content of <script type='text/html'>. The example below contains a script with HTML and the component evaluates the content if the j-Fo

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

- The component moves the content of this component under `<body>` tag (because of positioning)


__Configuration__:

- `if {String}` condition for showing of the form, it's compared with the value within of `data-jc-path`
- `reload {String}` link to a global `function(form_component)` and it's executed if the form is displaying
- `autofocus {Boolean/String}` can focus an input. `String` === `jQuery selector` for the input
- `default {String}` a short alias for `DEFAULT(default, true)`
- `zindex {Number}` can affect z-index (default: `12`)
- `closebutton {Boolean}` can hide `x` button (default: `false`)
- `closeoutside {Boolean}` closes the form when the user clicks outside of the form (default: `false`)
- or `closeoutside {String}` can contain a jQuery selector which will be included to a close event
- `closeesc {Boolean}` closes the form when the user presses `ESC`
- `scrollbar {Boolean}` enables custom scrollbar (default: `true`)
- `visibleY {Boolean}` shows vertical scrollbar (default: `false`)
- `close {String}` link to a global `function()` and it's executed if the form is closing

__Good to know__:

New version of this component supports dynamic evaluation of the content of `<script type="text/html">`. The example below contains a script with HTML and the component evaluates the content if the j-Form will be displayed (only once).

```html
<ui-component name="centered" path="path" config="config">
	<script type="text/html">
		A CONTENT
	</script>
</ui-component>
```

- all buttons with `name="close"` attribute closes the component automatically
- all elements with `data-name="close"` attribute closes the component automatically

Use it with `<ui-component name="centered">`. 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
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed, nam distinctio numquam dolore neque impedit, voluptate quam fugiat culpa minus.</div>
<br />
<a href="javascript:show()">Show</a>

<ui-component name="centered" path="form" config="if:login" class="hidden">
	<figure style="width:300px;margin:0 auto;background-color:rgba(100,100,100,0.1);display:block;padding:20px">
		<div><img src="https://www.totaljs.com/img/logo.svg" border="0" alt="Componentator" class="img-responsive" /></div>
		<br />
		<div class="m">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error nulla ratione possimus ducimus iusto porro, non laboriosam sunt reiciendis at.</div>
		<div class="center">
			<button name="close">CLOSE</button>
		</div>
	</figure>
</ui-component>

<script>
	var form = '';
	function show() {
		SET('form', 'login');
	}
</script>
```
