47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
/*parsed HTML*/
|
|
$(function () {
|
|
$("[data-equal-group]").each(function () {
|
|
$(this).contents().wrapAll("<div class='box_inner'></div>");
|
|
})
|
|
})
|
|
/*add event*/
|
|
$(window).bind("resize", height_handler).bind("load", height_handler)
|
|
function height_handler() {
|
|
|
|
var groups = [];
|
|
$("[data-equal-group]").each(function () {
|
|
var g = $(this).data('equal-group');
|
|
if (!groups[g]) {
|
|
groups[g] = [];
|
|
}
|
|
groups[g].push(this);
|
|
});
|
|
|
|
var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
|
|
if(width > 767){
|
|
$.each(groups, function () {
|
|
$(this).equalHeights();
|
|
})
|
|
}else{
|
|
$.each(groups, function () {
|
|
$(this).css('height', 'auto');
|
|
})
|
|
}
|
|
}
|
|
/*glob function*/
|
|
(function ($) {
|
|
$.fn.equalHeights = function (minHeight, maxHeight) {
|
|
tallest = (minHeight) ? minHeight : 0;
|
|
this.each(function () {
|
|
if ($(">.box_inner", this).outerHeight() > tallest) {
|
|
tallest = $(">.box_inner", this).outerHeight()
|
|
}
|
|
});
|
|
if ((maxHeight) && tallest > maxHeight) tallest = maxHeight;
|
|
return this.each(function () {
|
|
$(this).height(tallest)
|
|
})
|
|
}
|
|
})(jQuery)
|