jquery_match_height_rails 0.5.0
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 +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/jquery_match_height.js +181 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/jquery_match_height_rails.gemspec +24 -0
- data/lib/jquery_match_height_rails/engine.rb +4 -0
- data/lib/jquery_match_height_rails/version.rb +3 -0
- data/lib/jquery_match_height_rails.rb +4 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8ca14bfb1e02f4786d10c7168baf29b36f368b03
|
4
|
+
data.tar.gz: 07fd7ca6b23bdddf5d6ca495d84945545960d703
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec7412968930619a1309dc6592b4df180dc9b855eb9b4b03e97e9c5a44de57e7e1184300ba7a5d23f24cc7db2685c9b58622eaf2fcb2d485a82fff69aad19dfb
|
7
|
+
data.tar.gz: 37be671d541f82653e61bec0d2c5375fd9cd41e3cae0cf05a42fbc660eb1631afd8f6d9af82ee425b9bc39505540682ba330fda7ed0b02405ce1657c5b657e38
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jquery_match_height_rails
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at ziyan@jdeen.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Ziyan Junaideen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# JqueryMatchHeightRails
|
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
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'jquery_match_height_rails'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install jquery_match_height_rails
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
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.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
/**
|
2
|
+
* jquery.matchHeight.js v0.5.0
|
3
|
+
* http://brm.io/jquery-match-height/
|
4
|
+
* License: MIT
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function($) {
|
8
|
+
|
9
|
+
$.fn.matchHeight = function(byRow) {
|
10
|
+
if (this.length <= 1)
|
11
|
+
return this;
|
12
|
+
|
13
|
+
// byRow default to true
|
14
|
+
byRow = (typeof byRow !== 'undefined') ? byRow : true;
|
15
|
+
|
16
|
+
// keep track of this group so we can re-apply later on load and resize events
|
17
|
+
$.fn.matchHeight._groups.push({
|
18
|
+
elements: this,
|
19
|
+
byRow: byRow
|
20
|
+
});
|
21
|
+
|
22
|
+
// match each element's height to the tallest element in the selection
|
23
|
+
$.fn.matchHeight._apply(this, byRow);
|
24
|
+
|
25
|
+
return this;
|
26
|
+
};
|
27
|
+
|
28
|
+
$.fn.matchHeight._apply = function(elements, byRow) {
|
29
|
+
var $elements = $(elements),
|
30
|
+
rows = [$elements];
|
31
|
+
|
32
|
+
// get rows if using byRow, otherwise assume one row
|
33
|
+
if (byRow) {
|
34
|
+
|
35
|
+
// must first force an arbitrary equal height so floating elements break evenly
|
36
|
+
$elements.css({
|
37
|
+
'display': 'block',
|
38
|
+
'padding-top': '0',
|
39
|
+
'padding-bottom': '0',
|
40
|
+
'border-top': '0',
|
41
|
+
'border-bottom': '0',
|
42
|
+
'height': '100px'
|
43
|
+
});
|
44
|
+
|
45
|
+
// get the array of rows (based on element top position)
|
46
|
+
rows = _rows($elements);
|
47
|
+
|
48
|
+
// revert the temporary forced style
|
49
|
+
$elements.css({
|
50
|
+
'display': '',
|
51
|
+
'padding-top': '',
|
52
|
+
'padding-bottom': '',
|
53
|
+
'border-top': '',
|
54
|
+
'border-bottom': '',
|
55
|
+
'height': ''
|
56
|
+
});
|
57
|
+
}
|
58
|
+
|
59
|
+
$.each(rows, function(key, row) {
|
60
|
+
var $row = $(row),
|
61
|
+
maxHeight = 0;
|
62
|
+
|
63
|
+
// iterate the row and find the max height
|
64
|
+
$row.each(function() {
|
65
|
+
var $that = $(this);
|
66
|
+
|
67
|
+
// ensure we get the correct actual height (and not a previously set height value)
|
68
|
+
$that.css({
|
69
|
+
'display': 'block',
|
70
|
+
'height': ''
|
71
|
+
});
|
72
|
+
|
73
|
+
// find the max height (including padding, but not margin)
|
74
|
+
if ($that.outerHeight(false) > maxHeight)
|
75
|
+
maxHeight = $that.outerHeight(false);
|
76
|
+
});
|
77
|
+
|
78
|
+
// iterate the row and apply the height to all elements
|
79
|
+
$row.each(function() {
|
80
|
+
var $that = $(this),
|
81
|
+
verticalPadding = 0;
|
82
|
+
|
83
|
+
// handle padding and border correctly (required when not using border-box)
|
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);
|
87
|
+
}
|
88
|
+
|
89
|
+
// set the height (accounting for padding and border)
|
90
|
+
$that.css('height', maxHeight - verticalPadding);
|
91
|
+
});
|
92
|
+
});
|
93
|
+
|
94
|
+
return this;
|
95
|
+
};
|
96
|
+
|
97
|
+
/*
|
98
|
+
* _applyDataApi will apply matchHeight to all elements with a data-match-height attribute
|
99
|
+
*/
|
100
|
+
|
101
|
+
$.fn.matchHeight._applyDataApi = function() {
|
102
|
+
var groups = {};
|
103
|
+
|
104
|
+
// generate groups by their groupId set by elements using data-match-height
|
105
|
+
$('[data-match-height], [data-mh]').each(function() {
|
106
|
+
var $this = $(this),
|
107
|
+
groupId = $this.attr('data-match-height');
|
108
|
+
if (groupId in groups) {
|
109
|
+
groups[groupId] = groups[groupId].add($this);
|
110
|
+
} else {
|
111
|
+
groups[groupId] = $this;
|
112
|
+
}
|
113
|
+
});
|
114
|
+
|
115
|
+
// apply matchHeight to each group
|
116
|
+
$.each(groups, function() {
|
117
|
+
this.matchHeight(true);
|
118
|
+
});
|
119
|
+
};
|
120
|
+
|
121
|
+
/*
|
122
|
+
* _update function will re-apply matchHeight to all groups with the correct options
|
123
|
+
*/
|
124
|
+
|
125
|
+
$.fn.matchHeight._groups = [];
|
126
|
+
|
127
|
+
$.fn.matchHeight._update = function() {
|
128
|
+
$.each($.fn.matchHeight._groups, function() {
|
129
|
+
$.fn.matchHeight._apply(this.elements, this.byRow);
|
130
|
+
});
|
131
|
+
};
|
132
|
+
|
133
|
+
/*
|
134
|
+
* bind events
|
135
|
+
*/
|
136
|
+
|
137
|
+
// apply on DOM ready event
|
138
|
+
$($.fn.matchHeight._applyDataApi);
|
139
|
+
|
140
|
+
// update heights on load and resize events
|
141
|
+
$(window).on('load resize orientationchange', $.fn.matchHeight._update);
|
142
|
+
|
143
|
+
/*
|
144
|
+
* rows utility function
|
145
|
+
* returns array of jQuery selections representing each row
|
146
|
+
* (as displayed after float wrapping applied by browser)
|
147
|
+
*/
|
148
|
+
|
149
|
+
var _rows = function(elements) {
|
150
|
+
var tolerance = 1,
|
151
|
+
$elements = $(elements),
|
152
|
+
lastTop = null,
|
153
|
+
rows = [];
|
154
|
+
|
155
|
+
// group elements by their top position
|
156
|
+
$elements.each(function() {
|
157
|
+
var $that = $(this),
|
158
|
+
top = $that.offset().top - parseInt($that.css('margin-top'), 10),
|
159
|
+
lastRow = rows.length > 0 ? rows[rows.length - 1] : null;
|
160
|
+
|
161
|
+
if (lastRow === null) {
|
162
|
+
// first item on the row, so just push it
|
163
|
+
rows.push($that);
|
164
|
+
} else {
|
165
|
+
// if the row top is the same, add to the row group
|
166
|
+
if (Math.floor(Math.abs(lastTop - top)) <= tolerance) {
|
167
|
+
rows[rows.length - 1] = lastRow.add($that);
|
168
|
+
} else {
|
169
|
+
// otherwise start a new row group
|
170
|
+
rows.push($that);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
// keep track of the last row top
|
175
|
+
lastTop = top;
|
176
|
+
});
|
177
|
+
|
178
|
+
return rows;
|
179
|
+
};
|
180
|
+
|
181
|
+
})(jQuery);
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jquery_match_height_rails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jquery_match_height_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jquery_match_height_rails"
|
8
|
+
spec.version = JqueryMatchHeightRails::VERSION
|
9
|
+
spec.authors = ["Ziyan Junaideen"]
|
10
|
+
spec.email = ["ziyan@jdeen.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A responsive equal heights plugin for jQuery}
|
13
|
+
spec.description = %q{A responsive equal heights plugin for jQuery}
|
14
|
+
spec.homepage = "https://github.com/jdeen/jquery_match_height_rails"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery_match_height_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ziyan Junaideen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A responsive equal heights plugin for jQuery
|
42
|
+
email:
|
43
|
+
- ziyan@jdeen.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".ruby-gemset"
|
50
|
+
- ".ruby-version"
|
51
|
+
- CODE_OF_CONDUCT.md
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- app/assets/javascripts/jquery_match_height.js
|
57
|
+
- bin/console
|
58
|
+
- bin/setup
|
59
|
+
- jquery_match_height_rails.gemspec
|
60
|
+
- lib/jquery_match_height_rails.rb
|
61
|
+
- lib/jquery_match_height_rails/engine.rb
|
62
|
+
- lib/jquery_match_height_rails/version.rb
|
63
|
+
homepage: https://github.com/jdeen/jquery_match_height_rails
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.5.1
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: A responsive equal heights plugin for jQuery
|
87
|
+
test_files: []
|