orioltf
5/20/2015 - 12:34 PM

#JQUERY #UTIL getHeightIn

#JQUERY #UTIL getHeightIn

collapsibleHeight = $collapsible.getHeightIn( $('#main') );
/**
 * Gets the height from the provided elements, even if they are hidden
 * @param {Object} $context - the jQuery DOM element where to append the object so that it gets proper styling
 * @returns {Number} - the outerHeight value from the passed $element
 */
$.fn.getHeightIn = function($context) {
	var $element = this,
		$wrap = $('<div />'),
		$clone, height;

	$context = typeof $context === 'undefined' ? $('body') : $context;

	$wrap.css({
		'position': 'absolute !important',
		'visibility': 'hidden !important',
		'display': 'block !important'
	}).appendTo($context);

	$clone = $element.clone();
	$clone.appendTo($wrap);
	height = $clone.outerHeight();

	$wrap.remove();
	return height;
};