jquery_match_height_rails 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce759346b7bf342e13dbce3662bd3a681dcab9e8
|
4
|
+
data.tar.gz: fcd3cb297b3fcfe628052fd9bd9693c9ae3dd4e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7578b448503f2a50b266bdb3408047cca902c0c25aff34fd3f661dbc3a9dd27c429d7d51aa91c71094b63e1249dac100173ad32689a550b991444a3d775d91fc
|
7
|
+
data.tar.gz: 586803ce641b6646cb82414a5ad9dee63e1bf2c93c3cd11558ec0b3f8b7c6f5fcab121952245378109242bdbc0f4b72c20b19fc4de64cd48de622a4e94e10604
|
@@ -1,12 +1,30 @@
|
|
1
1
|
/**
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
* jquery.matchHeight.js v0.5.2
|
3
|
+
* http://brm.io/jquery-match-height/
|
4
|
+
* License: MIT
|
5
|
+
*/
|
6
6
|
|
7
7
|
(function($) {
|
8
8
|
|
9
9
|
$.fn.matchHeight = function(byRow) {
|
10
|
+
|
11
|
+
// handle matchHeight('remove')
|
12
|
+
if (byRow === 'remove') {
|
13
|
+
var that = this;
|
14
|
+
|
15
|
+
// remove fixed height from all selected elements
|
16
|
+
this.css('height', '');
|
17
|
+
|
18
|
+
// remove selected elements from all groups
|
19
|
+
$.each($.fn.matchHeight._groups, function(key, group) {
|
20
|
+
group.elements = group.elements.not(that);
|
21
|
+
});
|
22
|
+
|
23
|
+
// TODO: cleanup empty groups
|
24
|
+
|
25
|
+
return this;
|
26
|
+
}
|
27
|
+
|
10
28
|
if (this.length <= 1)
|
11
29
|
return this;
|
12
30
|
|
@@ -61,22 +79,22 @@
|
|
61
79
|
maxHeight = 0;
|
62
80
|
|
63
81
|
// iterate the row and find the max height
|
64
|
-
$row.each(function()
|
82
|
+
$row.each(function(){
|
65
83
|
var $that = $(this);
|
66
84
|
|
67
85
|
// ensure we get the correct actual height (and not a previously set height value)
|
68
|
-
$that.css({
|
69
|
-
'display': 'block',
|
70
|
-
'height': ''
|
71
|
-
});
|
86
|
+
$that.css({ 'display': 'block', 'height': '' });
|
72
87
|
|
73
88
|
// find the max height (including padding, but not margin)
|
74
89
|
if ($that.outerHeight(false) > maxHeight)
|
75
90
|
maxHeight = $that.outerHeight(false);
|
91
|
+
|
92
|
+
// revert display block
|
93
|
+
$that.css({ 'display': '' });
|
76
94
|
});
|
77
95
|
|
78
96
|
// iterate the row and apply the height to all elements
|
79
|
-
$row.each(function()
|
97
|
+
$row.each(function(){
|
80
98
|
var $that = $(this),
|
81
99
|
verticalPadding = 0;
|
82
100
|
|
@@ -95,9 +113,9 @@
|
|
95
113
|
};
|
96
114
|
|
97
115
|
/*
|
98
|
-
|
99
|
-
|
100
|
-
|
116
|
+
* _applyDataApi will apply matchHeight to all elements with a data-match-height attribute
|
117
|
+
*/
|
118
|
+
|
101
119
|
$.fn.matchHeight._applyDataApi = function() {
|
102
120
|
var groups = {};
|
103
121
|
|
@@ -119,15 +137,16 @@
|
|
119
137
|
};
|
120
138
|
|
121
139
|
/*
|
122
|
-
|
123
|
-
|
124
|
-
|
140
|
+
* _update function will re-apply matchHeight to all groups with the correct options
|
141
|
+
*/
|
142
|
+
|
125
143
|
$.fn.matchHeight._groups = [];
|
144
|
+
$.fn.matchHeight._throttle = 80;
|
126
145
|
|
127
|
-
var previousResizeWidth = -1
|
146
|
+
var previousResizeWidth = -1,
|
147
|
+
updateTimeout = -1;
|
128
148
|
|
129
149
|
$.fn.matchHeight._update = function(event) {
|
130
|
-
|
131
150
|
// prevent update if fired from a resize event
|
132
151
|
// where the viewport width hasn't actually changed
|
133
152
|
// fixes an event looping bug in IE8
|
@@ -138,14 +157,23 @@
|
|
138
157
|
previousResizeWidth = windowWidth;
|
139
158
|
}
|
140
159
|
|
141
|
-
|
142
|
-
|
143
|
-
|
160
|
+
// throttle updates
|
161
|
+
if (updateTimeout === -1) {
|
162
|
+
updateTimeout = setTimeout(function() {
|
163
|
+
|
164
|
+
$.each($.fn.matchHeight._groups, function() {
|
165
|
+
$.fn.matchHeight._apply(this.elements, this.byRow);
|
166
|
+
});
|
167
|
+
|
168
|
+
updateTimeout = -1;
|
169
|
+
|
170
|
+
}, $.fn.matchHeight._throttle);
|
171
|
+
}
|
144
172
|
};
|
145
173
|
|
146
174
|
/*
|
147
|
-
|
148
|
-
|
175
|
+
* bind events
|
176
|
+
*/
|
149
177
|
|
150
178
|
// apply on DOM ready event
|
151
179
|
$($.fn.matchHeight._applyDataApi);
|
@@ -154,10 +182,10 @@
|
|
154
182
|
$(window).bind('load resize orientationchange', $.fn.matchHeight._update);
|
155
183
|
|
156
184
|
/*
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
185
|
+
* rows utility function
|
186
|
+
* returns array of jQuery selections representing each row
|
187
|
+
* (as displayed after float wrapping applied by browser)
|
188
|
+
*/
|
161
189
|
|
162
190
|
var _rows = function(elements) {
|
163
191
|
var tolerance = 1,
|
@@ -166,7 +194,7 @@
|
|
166
194
|
rows = [];
|
167
195
|
|
168
196
|
// group elements by their top position
|
169
|
-
$elements.each(function()
|
197
|
+
$elements.each(function(){
|
170
198
|
var $that = $(this),
|
171
199
|
top = $that.offset().top - _parse($that.css('margin-top')),
|
172
200
|
lastRow = rows.length > 0 ? rows[rows.length - 1] : null;
|