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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ca14bfb1e02f4786d10c7168baf29b36f368b03
4
- data.tar.gz: 07fd7ca6b23bdddf5d6ca495d84945545960d703
3
+ metadata.gz: 40c5bf8cbd773fd77d6f2ceb762505bc1e7acd06
4
+ data.tar.gz: 7e0aaa4f53824b8da48deb63f1502789556d5f33
5
5
  SHA512:
6
- metadata.gz: ec7412968930619a1309dc6592b4df180dc9b855eb9b4b03e97e9c5a44de57e7e1184300ba7a5d23f24cc7db2685c9b58622eaf2fcb2d485a82fff69aad19dfb
7
- data.tar.gz: 37be671d541f82653e61bec0d2c5375fd9cd41e3cae0cf05a42fbc660eb1631afd8f6d9af82ee425b9bc39505540682ba330fda7ed0b02405ce1657c5b657e38
6
+ metadata.gz: 22b29a298f209c39560b9264ffc1a3995de302cbc56c7e7f5968c7f6dd12408b439b3733e6356e3418489b6cf6d8404b2a699f9282527c106ed9e4984ca942b8
7
+ data.tar.gz: cf1d424e8edbf05fb3818e19286563a8b3ab0936c2445ae5d91bbdeac36ea9b6bde084d5b332e9458daf333f0acbce2395367566d9024a67b4412ecbabec10b3
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # JqueryMatchHeightRails
1
+ # jQueryMatchHeight - Rails Gem
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jquery_match_height_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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/[USERNAME]/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.
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.0
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 += parseInt($that.css('border-top-width'), 10) + parseInt($that.css('border-bottom-width'), 10);
86
- verticalPadding += parseInt($that.css('padding-top'), 10) + parseInt($that.css('padding-bottom'), 10);
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
- $.fn.matchHeight._update = function() {
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).on('load resize orientationchange', $.fn.matchHeight._update);
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 - parseInt($that.css('margin-top'), 10),
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);
@@ -1,3 +1,3 @@
1
1
  module JqueryMatchHeightRails
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery_match_height_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziyan Junaideen