Skip to content

Commit

Permalink
Merge branch 'nyordanov-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Sep 16, 2014
2 parents fdc8f7a + e9de702 commit dc77dbe
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions jquery.matchHeight.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
_updateTimeout = -1;

/*
* _rows
* utility function returns array of jQuery selections representing each row
* _rows
* utility function returns array of jQuery selections representing each row
* (as displayed after float wrapping applied by browser)
*/

Expand Down Expand Up @@ -131,6 +131,9 @@
var $that = $(this),
display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';

// cache the original inline style
$that.data('style-cache', $that.attr('style'));

$that.css({
'display': display,
'padding-top': '0',
Expand All @@ -144,14 +147,12 @@
// get the array of rows (based on element top position)
rows = _rows($elements);

// revert the temporary forced style
$elements.css({
'display': '',
'padding-top': '',
'padding-bottom': '',
'border-top-width': '',
'border-bottom-width': '',
'height': ''
// revert original inline styles
$elements.each(function() {
var $that = $(this);

$that.attr('style', $that.data('style-cache') || '')
.css('height', '');
});
}

Expand Down Expand Up @@ -213,7 +214,7 @@
* $.fn.matchHeight._applyDataApi
* applies matchHeight to all elements with a data-match-height attribute
*/

$.fn.matchHeight._applyDataApi = function() {
var groups = {};

Expand All @@ -234,7 +235,7 @@
});
};

/*
/*
* $.fn.matchHeight._update
* updates matchHeight on all current groups with their correct options
*/
Expand All @@ -246,7 +247,7 @@
};

$.fn.matchHeight._update = function(throttle, event) {
// prevent update if fired from a resize event
// prevent update if fired from a resize event
// where the viewport width hasn't actually changed
// fixes an event looping bug in IE8
if (event && event.type === 'resize') {
Expand All @@ -267,21 +268,21 @@
}
};

/*
/*
* bind events
*/

// apply on DOM ready event
$($.fn.matchHeight._applyDataApi);

// update heights on load and resize events
$(window).bind('load', function(event) {
$(window).bind('load', function(event) {
$.fn.matchHeight._update();
});

// throttled update heights on resize events
$(window).bind('resize orientationchange', function(event) {
$(window).bind('resize orientationchange', function(event) {
$.fn.matchHeight._update(true, event);
});

})(jQuery);
})(jQuery);

0 comments on commit dc77dbe

Please sign in to comment.