Sha256: b146cf04eca6c2fb4a589dc6f690fb49852337559bdc16c6bd1c265a218f293b

Contents?: true

Size: 936 Bytes

Versions: 4

Compression:

Stored size: 936 Bytes

Contents

$(function() {
	setSameHeights();

	var resizeTimer;

	$(window).resize(function() {
		clearTimeout(resizeTimer);
        resizeTimer = setTimeout(setSameHeights, 150);
	});
});


function setSameHeights($container) {

	$container = $container || $('.sameheight-container');

	var viewport = ResponsiveBootstrapToolkit.current();

	$container.each(function() {

		var $items = $(this).find(".sameheight-item");

		// Get max height of items in container
		var maxHeight = 0;

		$items.each(function() {
			$(this).css({height: 'auto'});
			maxHeight = Math.max(maxHeight, $(this).innerHeight());
		});


		// Set heights of items
		$items.each(function() {
			// Ignored viewports for item
			var excludedStr = $(this).data('exclude') || '';
			var excluded = excludedStr.split(',');

			// Set height of element if it's not excluded on 
			if (excluded.indexOf(viewport) === -1) {
				$(this).innerHeight(maxHeight);
			}
		});
	});
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_modular_admin-0.2.4 app/assets/javascripts/rails_modular_admin/_common/sameheight-items/sameheight-items.js
rails_modular_admin-0.2.3 app/assets/javascripts/rails_modular_admin/_common/sameheight-items/sameheight-items.js
rails_modular_admin-0.2.2 app/assets/javascripts/rails_modular_admin/_common/sameheight-items/sameheight-items.js
rails_modular_admin-0.2.0 app/assets/javascripts/rails_modular_admin/_common/sameheight-items/sameheight-items.js