File: D:/HostingSpaces/SBogers10/topswtwmobile.komma.pro/wwwroot/js/plugins/equalHeight.js
define([],function()
{
$.equalHeight = function(element, options) {
// Default options
var defaults = {};
// Reference to this
var t = this;
var $parent = $(element);
t.boot = function ()
{
// Extend the defaults with options, save in settings
t.settings = $.extend({}, defaults, options);
$parent.children('div:nth-child(3n + 1)').each(function()
{
console.log('update..');
updateHeight($(this));
})
};
var updateHeight = function($firstElement)
{
var $secondElement = $parent.children().eq($firstElement.index() + 1);
var $thirdElement = $parent.children().eq($firstElement.index() + 2);
$firstElement.height('auto');
$secondElement.height('auto');
$thirdElement.height('auto');
// Get highest height
var highestHeight = $firstElement.height();
if($secondElement.height() > highestHeight) highestHeight = $secondElement.height();
if($thirdElement.height() > highestHeight) highestHeight = $thirdElement.height();
$firstElement.height(highestHeight);
$secondElement.height(highestHeight);
$thirdElement.height(highestHeight);
};
t.removePadding = function()
{
$parent.children().each(function() {
$(this).css({ width: $(this).width()+'px', padding: 0 });
});
};
// Run plugin
t.boot();
};
$.fn.equalHeight = function(options)
{
return this.each(function()
{
// if plugin has not already been attached to the element
if ($(this).data('equalHeight') == undefined)
{
// create a new instance of the plugin
$(this).data('equalHeight', new $.equalHeight(this, options));
}
});
}
});