Skip to content

Commit dc77dbe

Browse files
committed
Merge branch 'nyordanov-master'
2 parents fdc8f7a + e9de702 commit dc77dbe

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

jquery.matchHeight.js

+18-17
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
_updateTimeout = -1;
1414

1515
/*
16-
* _rows
17-
* utility function returns array of jQuery selections representing each row
16+
* _rows
17+
* utility function returns array of jQuery selections representing each row
1818
* (as displayed after float wrapping applied by browser)
1919
*/
2020

@@ -131,6 +131,9 @@
131131
var $that = $(this),
132132
display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';
133133

134+
// cache the original inline style
135+
$that.data('style-cache', $that.attr('style'));
136+
134137
$that.css({
135138
'display': display,
136139
'padding-top': '0',
@@ -144,14 +147,12 @@
144147
// get the array of rows (based on element top position)
145148
rows = _rows($elements);
146149

147-
// revert the temporary forced style
148-
$elements.css({
149-
'display': '',
150-
'padding-top': '',
151-
'padding-bottom': '',
152-
'border-top-width': '',
153-
'border-bottom-width': '',
154-
'height': ''
150+
// revert original inline styles
151+
$elements.each(function() {
152+
var $that = $(this);
153+
154+
$that.attr('style', $that.data('style-cache') || '')
155+
.css('height', '');
155156
});
156157
}
157158

@@ -213,7 +214,7 @@
213214
* $.fn.matchHeight._applyDataApi
214215
* applies matchHeight to all elements with a data-match-height attribute
215216
*/
216-
217+
217218
$.fn.matchHeight._applyDataApi = function() {
218219
var groups = {};
219220

@@ -234,7 +235,7 @@
234235
});
235236
};
236237

237-
/*
238+
/*
238239
* $.fn.matchHeight._update
239240
* updates matchHeight on all current groups with their correct options
240241
*/
@@ -246,7 +247,7 @@
246247
};
247248

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

270-
/*
271+
/*
271272
* bind events
272273
*/
273274

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

277278
// update heights on load and resize events
278-
$(window).bind('load', function(event) {
279+
$(window).bind('load', function(event) {
279280
$.fn.matchHeight._update();
280281
});
281282

282283
// throttled update heights on resize events
283-
$(window).bind('resize orientationchange', function(event) {
284+
$(window).bind('resize orientationchange', function(event) {
284285
$.fn.matchHeight._update(true, event);
285286
});
286287

287-
})(jQuery);
288+
})(jQuery);

0 commit comments

Comments
 (0)