Sha256: c6bf0897e0d320a794536e6a70c9f9f661c256c89712500efc45a09a94b7dc5c

Contents?: true

Size: 857 Bytes

Versions: 4

Compression:

Stored size: 857 Bytes

Contents

/**
 * FORM ITEM EDITOR
 */

class FormItemEditor {
	
	constructor()
	{
		this.target = '.form-item--editor'
	}

	isSet()
	{
		if ( $( this.target ).length > 0 ) { return true }
		else { return false }
	}

	setEvents()
	{
		// run resize to set initial size
		this.resize()
		// run resize on each of these events
		$(window).resize( ()=>{ this.resize() } )
	}

	resize()
	{
		$( this.target ).each( function(){
			// If the form item editor is closed don't go any further
			if ( $(this).height() === 0 ) return
			// otherwise update the max-height which is needed for the CSS transition
			// NOTE you need to remove the max-height (inside 'style' attribute) to get the real height
			$(this).get(0).style.height = 'auto'
			$(this).get(0).style.maxHeight = $(this).get(0).scrollHeight + "px";
		})
	}
}

export let _FormItemEditor = new FormItemEditor()

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
binda-0.1.3 app/assets/javascripts/binda/components/form_item_editor.js
binda-0.1.2 app/assets/javascripts/binda/components/form_item_editor.js
binda-0.1.1 app/assets/javascripts/binda/components/form_item_editor.js
binda-0.1.0 app/assets/javascripts/binda/components/form_item_editor.js