13
13
_updateTimeout = - 1 ;
14
14
15
15
/*
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
18
18
* (as displayed after float wrapping applied by browser)
19
19
*/
20
20
131
131
var $that = $ ( this ) ,
132
132
display = $that . css ( 'display' ) === 'inline-block' ? 'inline-block' : 'block' ;
133
133
134
+ // cache the original inline style
135
+ $that . data ( 'style-cache' , $that . attr ( 'style' ) ) ;
136
+
134
137
$that . css ( {
135
138
'display' : display ,
136
139
'padding-top' : '0' ,
144
147
// get the array of rows (based on element top position)
145
148
rows = _rows ( $elements ) ;
146
149
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' , '' ) ;
155
156
} ) ;
156
157
}
157
158
213
214
* $.fn.matchHeight._applyDataApi
214
215
* applies matchHeight to all elements with a data-match-height attribute
215
216
*/
216
-
217
+
217
218
$ . fn . matchHeight . _applyDataApi = function ( ) {
218
219
var groups = { } ;
219
220
234
235
} ) ;
235
236
} ;
236
237
237
- /*
238
+ /*
238
239
* $.fn.matchHeight._update
239
240
* updates matchHeight on all current groups with their correct options
240
241
*/
246
247
} ;
247
248
248
249
$ . fn . matchHeight . _update = function ( throttle , event ) {
249
- // prevent update if fired from a resize event
250
+ // prevent update if fired from a resize event
250
251
// where the viewport width hasn't actually changed
251
252
// fixes an event looping bug in IE8
252
253
if ( event && event . type === 'resize' ) {
267
268
}
268
269
} ;
269
270
270
- /*
271
+ /*
271
272
* bind events
272
273
*/
273
274
274
275
// apply on DOM ready event
275
276
$ ( $ . fn . matchHeight . _applyDataApi ) ;
276
277
277
278
// update heights on load and resize events
278
- $ ( window ) . bind ( 'load' , function ( event ) {
279
+ $ ( window ) . bind ( 'load' , function ( event ) {
279
280
$ . fn . matchHeight . _update ( ) ;
280
281
} ) ;
281
282
282
283
// throttled update heights on resize events
283
- $ ( window ) . bind ( 'resize orientationchange' , function ( event ) {
284
+ $ ( window ) . bind ( 'resize orientationchange' , function ( event ) {
284
285
$ . fn . matchHeight . _update ( true , event ) ;
285
286
} ) ;
286
287
287
- } ) ( jQuery ) ;
288
+ } ) ( jQuery ) ;
0 commit comments