ForgeComponents
en

Components

j-FloatingBox

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20
  • 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

<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.

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>