jquery_match_height_rails 0.5.0 → 0.5.1
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 +4 -4
- data/.gitignore +1 -0
- data/README.md +10 -6
- data/app/assets/javascripts/jquery_match_height.js +24 -6
- data/lib/jquery_match_height_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40c5bf8cbd773fd77d6f2ceb762505bc1e7acd06
|
4
|
+
data.tar.gz: 7e0aaa4f53824b8da48deb63f1502789556d5f33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22b29a298f209c39560b9264ffc1a3995de302cbc56c7e7f5968c7f6dd12408b439b3733e6356e3418489b6cf6d8404b2a699f9282527c106ed9e4984ca942b8
|
7
|
+
data.tar.gz: cf1d424e8edbf05fb3818e19286563a8b3ab0936c2445ae5d91bbdeac36ea9b6bde084d5b332e9458daf333f0acbce2395367566d9024a67b4412ecbabec10b3
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# jQueryMatchHeight - Rails Gem
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
jQueryMatchHeightRails is a rails integration of the popular jQuery plugin by Liam Brummitt. I am merely a constant jQueryMatchHeight user in Rails thinking a Rails Plugin would be good to maintain. Access the main repository for plugin documentation [here](https://github.com/liabru/jquery-match-height).
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,13 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
```js
|
24
|
+
//= require jquery_match_height
|
25
|
+
|
26
|
+
$(document).ready(function(){
|
27
|
+
$('[data-mh]').matchHeight(false);
|
28
|
+
});
|
29
|
+
```
|
26
30
|
|
27
31
|
## Development
|
28
32
|
|
@@ -32,7 +36,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
36
|
|
33
37
|
## Contributing
|
34
38
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jdeen/jquery_match_height_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
40
|
|
37
41
|
|
38
42
|
## License
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* jquery.matchHeight.js v0.5.
|
2
|
+
* jquery.matchHeight.js v0.5.1
|
3
3
|
* http://brm.io/jquery-match-height/
|
4
4
|
* License: MIT
|
5
5
|
*/
|
@@ -82,8 +82,8 @@
|
|
82
82
|
|
83
83
|
// handle padding and border correctly (required when not using border-box)
|
84
84
|
if ($that.css('box-sizing') !== 'border-box') {
|
85
|
-
verticalPadding +=
|
86
|
-
verticalPadding +=
|
85
|
+
verticalPadding += _parse($that.css('border-top-width')) + _parse($that.css('border-bottom-width'));
|
86
|
+
verticalPadding += _parse($that.css('padding-top')) + _parse($that.css('padding-bottom'));
|
87
87
|
}
|
88
88
|
|
89
89
|
// set the height (accounting for padding and border)
|
@@ -124,7 +124,20 @@
|
|
124
124
|
|
125
125
|
$.fn.matchHeight._groups = [];
|
126
126
|
|
127
|
-
|
127
|
+
var previousResizeWidth = -1;
|
128
|
+
|
129
|
+
$.fn.matchHeight._update = function(event) {
|
130
|
+
|
131
|
+
// prevent update if fired from a resize event
|
132
|
+
// where the viewport width hasn't actually changed
|
133
|
+
// fixes an event looping bug in IE8
|
134
|
+
if (event && event.type === 'resize') {
|
135
|
+
var windowWidth = $(window).width();
|
136
|
+
if (windowWidth === previousResizeWidth)
|
137
|
+
return;
|
138
|
+
previousResizeWidth = windowWidth;
|
139
|
+
}
|
140
|
+
|
128
141
|
$.each($.fn.matchHeight._groups, function() {
|
129
142
|
$.fn.matchHeight._apply(this.elements, this.byRow);
|
130
143
|
});
|
@@ -138,7 +151,7 @@
|
|
138
151
|
$($.fn.matchHeight._applyDataApi);
|
139
152
|
|
140
153
|
// update heights on load and resize events
|
141
|
-
$(window).
|
154
|
+
$(window).bind('load resize orientationchange', $.fn.matchHeight._update);
|
142
155
|
|
143
156
|
/*
|
144
157
|
* rows utility function
|
@@ -155,7 +168,7 @@
|
|
155
168
|
// group elements by their top position
|
156
169
|
$elements.each(function() {
|
157
170
|
var $that = $(this),
|
158
|
-
top = $that.offset().top -
|
171
|
+
top = $that.offset().top - _parse($that.css('margin-top')),
|
159
172
|
lastRow = rows.length > 0 ? rows[rows.length - 1] : null;
|
160
173
|
|
161
174
|
if (lastRow === null) {
|
@@ -178,4 +191,9 @@
|
|
178
191
|
return rows;
|
179
192
|
};
|
180
193
|
|
194
|
+
var _parse = function(value) {
|
195
|
+
// parse value and convert NaN to 0
|
196
|
+
return parseFloat(value) || 0;
|
197
|
+
};
|
198
|
+
|
181
199
|
})(jQuery);
|