prettydocs_rails 1.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +57 -0
- data/README.md +91 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/prettydocs.js +6 -0
- data/app/assets/stylesheets/prettydocs.scss +6 -0
- data/lib/prettydocs_rails.rb +24 -0
- data/lib/prettydocs_rails/engine.rb +10 -0
- data/lib/prettydocs_rails/version.rb +3 -0
- data/vendor/assets/images/demo/appkit-account-billing-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-billing.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-drive-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-drive.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-messages-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-messages.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-profile-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-profile.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-reminders-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-reminders.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-settings-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-account-settings.jpg +0 -0
- data/vendor/assets/images/demo/appkit-activities-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-activities.jpg +0 -0
- data/vendor/assets/images/demo/appkit-chart-chartjs-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-chart-chartjs.jpg +0 -0
- data/vendor/assets/images/demo/appkit-chart-flot-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-chart-flot.jpg +0 -0
- data/vendor/assets/images/demo/appkit-chart-inline-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-chart-inline.jpg +0 -0
- data/vendor/assets/images/demo/appkit-chart-morris-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-chart-morris.jpg +0 -0
- data/vendor/assets/images/demo/appkit-dashboard-1-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-dashboard-1.jpg +0 -0
- data/vendor/assets/images/demo/appkit-dashboard-2-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-dashboard-2.jpg +0 -0
- data/vendor/assets/images/demo/appkit-dashboard-3-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-dashboard-3.jpg +0 -0
- data/vendor/assets/images/demo/appkit-dashboard-4-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-dashboard-4.jpg +0 -0
- data/vendor/assets/images/demo/appkit-discussion-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-discussion.jpg +0 -0
- data/vendor/assets/images/demo/appkit-discussions-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-discussions.jpg +0 -0
- data/vendor/assets/images/demo/appkit-inbox-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-inbox.jpg +0 -0
- data/vendor/assets/images/demo/appkit-member-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-member.jpg +0 -0
- data/vendor/assets/images/demo/appkit-members-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-members.jpg +0 -0
- data/vendor/assets/images/demo/appkit-pricing-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-pricing.jpg +0 -0
- data/vendor/assets/images/demo/appkit-project-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-project.jpg +0 -0
- data/vendor/assets/images/demo/appkit-projects-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-projects.jpg +0 -0
- data/vendor/assets/images/demo/appkit-tickets-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-tickets.jpg +0 -0
- data/vendor/assets/images/demo/appkit-timeline-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-timeline.jpg +0 -0
- data/vendor/assets/images/demo/appkit-widgets-thumb.jpg +0 -0
- data/vendor/assets/images/demo/appkit-widgets.jpg +0 -0
- data/vendor/assets/images/demo/author-profile.png +0 -0
- data/vendor/assets/images/demo/elegant-icon-font.jpg +0 -0
- data/vendor/assets/images/demo/fontawesome-icons.png +0 -0
- data/vendor/assets/images/demo/theme-atom.png +0 -0
- data/vendor/assets/images/demo/theme-college-green.png +0 -0
- data/vendor/assets/images/demo/theme-decibel.png +0 -0
- data/vendor/assets/images/demo/theme-delta.png +0 -0
- data/vendor/assets/images/demo/theme-devaid.png +0 -0
- data/vendor/assets/images/demo/theme-developer.png +0 -0
- data/vendor/assets/images/demo/theme-devstudio.png +0 -0
- data/vendor/assets/images/demo/theme-epicure.png +0 -0
- data/vendor/assets/images/demo/theme-matrimony.png +0 -0
- data/vendor/assets/images/demo/theme-onboard.png +0 -0
- data/vendor/assets/images/demo/theme-tempo.png +0 -0
- data/vendor/assets/images/demo/theme-trades.png +0 -0
- data/vendor/assets/images/demo/theme-velocity.png +0 -0
- data/vendor/assets/images/empty.gif +0 -0
- data/vendor/assets/javascripts/ekko-lightbox.js +602 -0
- data/vendor/assets/javascripts/jquery-match-height/CHANGELOG.md +24 -0
- data/vendor/assets/javascripts/jquery-match-height/LICENSE +21 -0
- data/vendor/assets/javascripts/jquery-match-height/README.md +170 -0
- data/vendor/assets/javascripts/jquery-match-height/bower.json +26 -0
- data/vendor/assets/javascripts/jquery-match-height/jquery.matchHeight-min.js +10 -0
- data/vendor/assets/javascripts/jquery-match-height/jquery.matchHeight.js +298 -0
- data/vendor/assets/javascripts/jquery-match-height/matchHeight.jquery.json +32 -0
- data/vendor/assets/javascripts/jquery-match-height/test.css +265 -0
- data/vendor/assets/javascripts/jquery-match-height/test.html +288 -0
- data/vendor/assets/javascripts/jquery-match-height/test.js +33 -0
- data/vendor/assets/javascripts/jquery-scrollTo/CHANGELOG +178 -0
- data/vendor/assets/javascripts/jquery-scrollTo/LICENSE +22 -0
- data/vendor/assets/javascripts/jquery-scrollTo/README.md +151 -0
- data/vendor/assets/javascripts/jquery-scrollTo/bower.json +28 -0
- data/vendor/assets/javascripts/jquery-scrollTo/composer.json +32 -0
- data/vendor/assets/javascripts/jquery-scrollTo/demo/css/style.css +150 -0
- data/vendor/assets/javascripts/jquery-scrollTo/demo/css/style.old.css +69 -0
- data/vendor/assets/javascripts/jquery-scrollTo/demo/index.html +252 -0
- data/vendor/assets/javascripts/jquery-scrollTo/demo/index.old.html +128 -0
- data/vendor/assets/javascripts/jquery-scrollTo/jquery.scrollTo.js +210 -0
- data/vendor/assets/javascripts/jquery-scrollTo/jquery.scrollTo.min.js +7 -0
- data/vendor/assets/javascripts/jquery-scrollTo/package.json +20 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/ElemMaxY-compat.html +21 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/ElemMaxY-quirks.html +20 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/WinMaxY-compat.html +19 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/WinMaxY-quirks.html +18 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/WinMaxY-to-iframe-compat.html +20 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/WinMaxY-to-iframe-quirks.html +19 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/WinMaxY-with-iframe-compat.html +11 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/WinMaxY-with-iframe-quirks.html +10 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/index.html +24 -0
- data/vendor/assets/javascripts/jquery-scrollTo/tests/test.js +21 -0
- data/vendor/assets/javascripts/main.js +47 -0
- data/vendor/assets/javascripts/prism.js +18 -0
- data/vendor/assets/stylesheets/ekko-lightbox.scss +2 -0
- data/vendor/assets/stylesheets/prism.scss +163 -0
- data/vendor/assets/stylesheets/styles.scss +1267 -0
- metadata +267 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
# jquery.matchHeight.js Changelog
|
2
|
+
|
3
|
+
[brm.io/jquery-match-height](http://brm.io/jquery-match-height/)
|
4
|
+
|
5
|
+
----------
|
6
|
+
|
7
|
+
## 0.5.2
|
8
|
+
|
9
|
+
- improved demo
|
10
|
+
- added matchHeight('remove')
|
11
|
+
- added update throttling
|
12
|
+
- removed forced `display:block` after application
|
13
|
+
|
14
|
+
## 0.5.1
|
15
|
+
|
16
|
+
- fixed IE8 NaN bug when parsing 'auto' properties
|
17
|
+
- fixed IE8 window resize event loop bug
|
18
|
+
- fixed compatibility with older jQuery versions
|
19
|
+
- added bower package file
|
20
|
+
- added jquery package file
|
21
|
+
|
22
|
+
## 0.5.0 - 2014-03-02
|
23
|
+
|
24
|
+
- initial release
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Liam Brummitt
|
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.
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# jquery.matchHeight.js #
|
2
|
+
|
3
|
+
> *matchHeight* makes the height of all selected elements exactly equal.<br>
|
4
|
+
It handles many edge cases that cause similar plugins to fail.
|
5
|
+
|
6
|
+
[brm.io/jquery-match-height](http://brm.io/jquery-match-height/)
|
7
|
+
|
8
|
+
### Demo
|
9
|
+
|
10
|
+
See the [jquery.matchHeight.js demo](http://brm.io/jquery-match-height-demo).
|
11
|
+
|
12
|
+
[![jquery.matchHeight.js screenshot](http://brm.io/img/content/jquery-match-height/jquery-match-height.png)](http://brm.io/jquery-match-height-demo)
|
13
|
+
|
14
|
+
### Features
|
15
|
+
|
16
|
+
- match the heights of elements anywhere on the page
|
17
|
+
- row aware, handles floating elements
|
18
|
+
- responsive, automatically updates on window resize (can be throttled for performance)
|
19
|
+
- handles mixed `padding`, `margin`, `border` values (even if every element has them different)
|
20
|
+
- handles images and other media (updates automatically after loading)
|
21
|
+
- handles hidden or none-visible elements (e.g. those inside tab controls)
|
22
|
+
- accounts for `box-sizing`
|
23
|
+
- data attributes API
|
24
|
+
- can be removed when needed
|
25
|
+
- maintain scroll position correctly
|
26
|
+
- callback events
|
27
|
+
- tested in IE8+, Chrome, Firefox, Chrome Android
|
28
|
+
|
29
|
+
### Status
|
30
|
+
|
31
|
+
Current version is `v0.5.2`. I've fully tested it and it works well, but if you use it make sure you test fully too.
|
32
|
+
Please report any [issues](https://github.com/liabru/jquery-match-height/issues) you find.
|
33
|
+
|
34
|
+
### Install
|
35
|
+
|
36
|
+
[jQuery](http://jquery.com/download/) is required, so include it first.
|
37
|
+
<br>Download [jquery.matchHeight.js](https://github.com/liabru/jquery-match-height/blob/master/jquery.matchHeight.js) and include the script in your HTML file:
|
38
|
+
|
39
|
+
<script src="jquery.matchHeight.js" type="text/javascript"></script>
|
40
|
+
|
41
|
+
#### Or install using [Bower](http://bower.io/)
|
42
|
+
|
43
|
+
bower install matchHeight
|
44
|
+
|
45
|
+
### Usage
|
46
|
+
|
47
|
+
$(elements).matchHeight(byRow);
|
48
|
+
|
49
|
+
Where `byRow` is a boolean that enables or disables row detection, default is `true`.<br>
|
50
|
+
You should apply this on the [DOM ready](http://api.jquery.com/ready/) event.
|
51
|
+
|
52
|
+
See the included [test.html](https://github.com/liabru/jquery-match-height/blob/master/test.html) for a working example.
|
53
|
+
|
54
|
+
### Examples
|
55
|
+
|
56
|
+
$(function() {
|
57
|
+
$('.item').matchHeight();
|
58
|
+
});
|
59
|
+
|
60
|
+
Will set all elements with the class `item` to the height of the tallest.<br>
|
61
|
+
If the items are on multiple rows, the items of each row will be set to the tallest of that row.
|
62
|
+
|
63
|
+
<div data-mh="my-group">My text</div>
|
64
|
+
<div data-mh="my-group">Some other text</div>
|
65
|
+
<div data-mh="my-other-group">Even more text</div>
|
66
|
+
<div data-mh="my-other-group">The last bit of text</div>
|
67
|
+
|
68
|
+
Will set both elements in `my-group` to the same height, then both elements in `my-other-group` to be the same height respectively.
|
69
|
+
|
70
|
+
See the included [test.html](https://github.com/liabru/jquery-match-height/blob/master/test.html) for a working example.
|
71
|
+
|
72
|
+
### Advanced Usage
|
73
|
+
|
74
|
+
There are a few internal properties and functions you should know about:
|
75
|
+
|
76
|
+
#### Data API
|
77
|
+
|
78
|
+
Use the data attribute `data-match-height="group-name"` (or `data-mh` shorthand) where `group-name` is an arbitrary string to denote which elements should be considered as a group.
|
79
|
+
|
80
|
+
All elements with the same group name will be set to the same height when the page is loaded, regardless of their position in the DOM, without any extra code required.
|
81
|
+
|
82
|
+
Note that `byRow` will be enabled when using the data API, if you don't want this then use the alternative method above.
|
83
|
+
|
84
|
+
#### Callback events
|
85
|
+
|
86
|
+
Since matchHeight automatically handles updating the layout after certain window events, you can supply functions as global callbacks if you need to be notified:
|
87
|
+
|
88
|
+
$.fn.matchHeight._beforeUpdate = function(event, groups) {
|
89
|
+
// do something before any updates are applied
|
90
|
+
}
|
91
|
+
|
92
|
+
$.fn.matchHeight._afterUpdate = function(event, groups) {
|
93
|
+
// do something after all updates are applied
|
94
|
+
}
|
95
|
+
|
96
|
+
Where `event` a jQuery event object (e.g. `load`, `resize`, `orientationchange`) and `groups` is a reference to `$.fn.matchHeight._groups` (see below).
|
97
|
+
|
98
|
+
#### Removing
|
99
|
+
|
100
|
+
It is possible to remove any matchHeight bindings for a given set of elements like so
|
101
|
+
|
102
|
+
$('.item').matchHeight('remove');
|
103
|
+
|
104
|
+
#### Manually trigger an update
|
105
|
+
|
106
|
+
$.fn.matchHeight._update()
|
107
|
+
|
108
|
+
If you need to manually trigger an update of all currently set equal heights groups, for example if you've modified some content.
|
109
|
+
|
110
|
+
#### Manually apply match height
|
111
|
+
|
112
|
+
$.fn.matchHeight._apply(elements, byRow)
|
113
|
+
|
114
|
+
Use the apply function directly if you wish to avoid the automatic update functionality.
|
115
|
+
|
116
|
+
#### Throttling resize updates
|
117
|
+
|
118
|
+
$.fn.matchHeight._throttle = 80;
|
119
|
+
|
120
|
+
By default, the `_update` method is throttled to execute at a maximum rate of once every `80ms`.
|
121
|
+
Decreasing the above `_throttle` property will update your layout quicker, appearing smoother during resize, at the expense of performance.
|
122
|
+
If you experience lagging or freezing during resize, you should increase the `_throttle` property.
|
123
|
+
|
124
|
+
#### Maintain scroll position
|
125
|
+
|
126
|
+
$.fn.matchHeight._maintainScroll = true;
|
127
|
+
|
128
|
+
Under certain conditions where the size of the page is dynamically changing, such as during resize or when adding new elements, browser bugs cause the page scroll position to change unexpectedly.
|
129
|
+
|
130
|
+
If you are observing this behaviour, use the above line to automatically attempt to force scroll position to be maintained (approximately). This is a global setting and by default it is `false`.
|
131
|
+
|
132
|
+
#### Accessing groups directly
|
133
|
+
|
134
|
+
$.fn.matchHeight._groups
|
135
|
+
|
136
|
+
The array that contains all element groups that have had `matchHeight` applied. Used for automatically updating on resize events. Search and modify this array if you need to remove any groups or elements, for example if you're deleting elements.
|
137
|
+
|
138
|
+
### Known limitations
|
139
|
+
|
140
|
+
#### CSS transitions and animations are not supported
|
141
|
+
|
142
|
+
You should ensure that there are no transitions or other animations that will delay the height changes of the elements you are matching, including any `transition: all` rules. Otherwise the plugin will produce unexpected results, as animations can't be accounted for.
|
143
|
+
|
144
|
+
#### Delayed webfonts may cause incorrect height
|
145
|
+
|
146
|
+
Some browsers [do not wait](http://www.stevesouders.com/blog/2009/10/13/font-face-and-performance/) for webfonts to load before firing the window load event, so if the font loads too slowly the plugin may produce unexpected results.
|
147
|
+
|
148
|
+
If this is a problem, you should call `_update` once your font has loaded by using something like the [webfontloader](https://github.com/typekit/webfontloader) script.
|
149
|
+
|
150
|
+
#### Content changes require a manual update
|
151
|
+
|
152
|
+
If you change the content inside an element that has had `matchHeight` applied, then you must manually call `$.fn.matchHeight._update()` afterwards. This will update of all currently set equal heights groups.
|
153
|
+
|
154
|
+
### Changelog
|
155
|
+
|
156
|
+
To see what's new or changed in the latest version, see the [changelog](https://github.com/liabru/jquery-match-height/blob/master/CHANGELOG.md)
|
157
|
+
|
158
|
+
### License
|
159
|
+
|
160
|
+
jquery.matchHeight.js is licensed under [The MIT License (MIT)](http://opensource.org/licenses/MIT)
|
161
|
+
<br/>Copyright (c) 2014 Liam Brummitt
|
162
|
+
|
163
|
+
This license is also supplied with the release and source code.
|
164
|
+
<br/>As stated in the license, absolutely no warranty is provided.
|
165
|
+
|
166
|
+
##### Why not use CSS?
|
167
|
+
|
168
|
+
Making robust, responsive equal height columns for _arbitrary content_ is [difficult or impossible](http://filamentgroup.com/lab/setting_equal_heights_with_jquery/) to do with CSS alone (at least without hacks or trickery, in a backwards compatible way).
|
169
|
+
|
170
|
+
Note you should probably ensure your layout is still usable if JavaScript is disabled.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"name": "matchHeight",
|
3
|
+
"version": "0.5.2",
|
4
|
+
"homepage": "https://github.com/liabru/jquery-match-height",
|
5
|
+
"authors": [
|
6
|
+
"Liam Brummitt <liam@brm.io> (http://brm.io/)"
|
7
|
+
],
|
8
|
+
"description": "a more robust, responsive equal heights plugin for jQuery",
|
9
|
+
"main": "jquery.matchHeight-min.js",
|
10
|
+
"keywords": [
|
11
|
+
"matchHeight",
|
12
|
+
"equal",
|
13
|
+
"match",
|
14
|
+
"height",
|
15
|
+
"equalize",
|
16
|
+
"columns"
|
17
|
+
],
|
18
|
+
"license": "MIT",
|
19
|
+
"ignore": [
|
20
|
+
"**/.*",
|
21
|
+
"node_modules",
|
22
|
+
"bower_components",
|
23
|
+
"test",
|
24
|
+
"tests"
|
25
|
+
]
|
26
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* jquery.matchHeight-min.js v0.5.2
|
3
|
+
* http://brm.io/jquery-match-height/
|
4
|
+
* License: MIT
|
5
|
+
*/
|
6
|
+
(function(d){var g=-1,e=-1,n=function(a){var b=null,c=[];d(a).each(function(){var a=d(this),k=a.offset().top-h(a.css("margin-top")),l=0<c.length?c[c.length-1]:null;null===l?c.push(a):1>=Math.floor(Math.abs(b-k))?c[c.length-1]=l.add(a):c.push(a);b=k});return c},h=function(a){return parseFloat(a)||0},b=d.fn.matchHeight=function(a){if("remove"===a){var f=this;this.css("height","");d.each(b._groups,function(a,b){b.elements=b.elements.not(f)});return this}if(1>=this.length)return this;a="undefined"!==
|
7
|
+
typeof a?a:!0;b._groups.push({elements:this,byRow:a});b._apply(this,a);return this};b._groups=[];b._throttle=80;b._maintainScroll=!1;b._beforeUpdate=null;b._afterUpdate=null;b._apply=function(a,f){var c=d(a),e=[c],k=d(window).scrollTop(),l=d("html").outerHeight(!0),g=c.parents().filter(":hidden");g.css("display","block");f&&(c.each(function(){var a=d(this),b="inline-block"===a.css("display")?"inline-block":"block";a.data("style-cache",a.attr("style"));a.css({display:b,"padding-top":"0","padding-bottom":"0",
|
8
|
+
"margin-top":"0","margin-bottom":"0","border-top-width":"0","border-bottom-width":"0",height:"100px"})}),e=n(c),c.each(function(){var a=d(this);a.attr("style",a.data("style-cache")||"").css("height","")}));d.each(e,function(a,b){var c=d(b),e=0;f&&1>=c.length||(c.each(function(){var a=d(this),b="inline-block"===a.css("display")?"inline-block":"block";a.css({display:b,height:""});a.outerHeight(!1)>e&&(e=a.outerHeight(!1));a.css("display","")}),c.each(function(){var a=d(this),b=0;"border-box"!==a.css("box-sizing")&&
|
9
|
+
(b+=h(a.css("border-top-width"))+h(a.css("border-bottom-width")),b+=h(a.css("padding-top"))+h(a.css("padding-bottom")));a.css("height",e-b)}))});g.css("display","");b._maintainScroll&&d(window).scrollTop(k/l*d("html").outerHeight(!0));return this};b._applyDataApi=function(){var a={};d("[data-match-height], [data-mh]").each(function(){var b=d(this),c=b.attr("data-match-height")||b.attr("data-mh");a[c]=c in a?a[c].add(b):b});d.each(a,function(){this.matchHeight(!0)})};var m=function(a){b._beforeUpdate&&
|
10
|
+
b._beforeUpdate(a,b._groups);d.each(b._groups,function(){b._apply(this.elements,this.byRow)});b._afterUpdate&&b._afterUpdate(a,b._groups)};b._update=function(a,f){if(f&&"resize"===f.type){var c=d(window).width();if(c===g)return;g=c}a?-1===e&&(e=setTimeout(function(){m(f);e=-1},b._throttle)):m(f)};d(b._applyDataApi);d(window).bind("load",function(a){b._update(!1,a)});d(window).bind("resize orientationchange",function(a){b._update(!0,a)})})(jQuery);
|
@@ -0,0 +1,298 @@
|
|
1
|
+
/**
|
2
|
+
* jquery.matchHeight.js v0.5.2
|
3
|
+
* http://brm.io/jquery-match-height/
|
4
|
+
* License: MIT
|
5
|
+
*/
|
6
|
+
|
7
|
+
;(function($) {
|
8
|
+
/*
|
9
|
+
* internal
|
10
|
+
*/
|
11
|
+
|
12
|
+
var _previousResizeWidth = -1,
|
13
|
+
_updateTimeout = -1;
|
14
|
+
|
15
|
+
/*
|
16
|
+
* _rows
|
17
|
+
* utility function returns array of jQuery selections representing each row
|
18
|
+
* (as displayed after float wrapping applied by browser)
|
19
|
+
*/
|
20
|
+
|
21
|
+
var _rows = function(elements) {
|
22
|
+
var tolerance = 1,
|
23
|
+
$elements = $(elements),
|
24
|
+
lastTop = null,
|
25
|
+
rows = [];
|
26
|
+
|
27
|
+
// group elements by their top position
|
28
|
+
$elements.each(function(){
|
29
|
+
var $that = $(this),
|
30
|
+
top = $that.offset().top - _parse($that.css('margin-top')),
|
31
|
+
lastRow = rows.length > 0 ? rows[rows.length - 1] : null;
|
32
|
+
|
33
|
+
if (lastRow === null) {
|
34
|
+
// first item on the row, so just push it
|
35
|
+
rows.push($that);
|
36
|
+
} else {
|
37
|
+
// if the row top is the same, add to the row group
|
38
|
+
if (Math.floor(Math.abs(lastTop - top)) <= tolerance) {
|
39
|
+
rows[rows.length - 1] = lastRow.add($that);
|
40
|
+
} else {
|
41
|
+
// otherwise start a new row group
|
42
|
+
rows.push($that);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
// keep track of the last row top
|
47
|
+
lastTop = top;
|
48
|
+
});
|
49
|
+
|
50
|
+
return rows;
|
51
|
+
};
|
52
|
+
|
53
|
+
/*
|
54
|
+
* _parse
|
55
|
+
* value parse utility function
|
56
|
+
*/
|
57
|
+
|
58
|
+
var _parse = function(value) {
|
59
|
+
// parse value and convert NaN to 0
|
60
|
+
return parseFloat(value) || 0;
|
61
|
+
};
|
62
|
+
|
63
|
+
/*
|
64
|
+
* matchHeight
|
65
|
+
* plugin definition
|
66
|
+
*/
|
67
|
+
|
68
|
+
var matchHeight = $.fn.matchHeight = function(byRow) {
|
69
|
+
|
70
|
+
// handle matchHeight('remove')
|
71
|
+
if (byRow === 'remove') {
|
72
|
+
var that = this;
|
73
|
+
|
74
|
+
// remove fixed height from all selected elements
|
75
|
+
this.css('height', '');
|
76
|
+
|
77
|
+
// remove selected elements from all groups
|
78
|
+
$.each(matchHeight._groups, function(key, group) {
|
79
|
+
group.elements = group.elements.not(that);
|
80
|
+
});
|
81
|
+
|
82
|
+
// TODO: cleanup empty groups
|
83
|
+
|
84
|
+
return this;
|
85
|
+
}
|
86
|
+
|
87
|
+
if (this.length <= 1)
|
88
|
+
return this;
|
89
|
+
|
90
|
+
// byRow default to true
|
91
|
+
byRow = (typeof byRow !== 'undefined') ? byRow : true;
|
92
|
+
|
93
|
+
// keep track of this group so we can re-apply later on load and resize events
|
94
|
+
matchHeight._groups.push({
|
95
|
+
elements: this,
|
96
|
+
byRow: byRow
|
97
|
+
});
|
98
|
+
|
99
|
+
// match each element's height to the tallest element in the selection
|
100
|
+
matchHeight._apply(this, byRow);
|
101
|
+
|
102
|
+
return this;
|
103
|
+
};
|
104
|
+
|
105
|
+
/*
|
106
|
+
* plugin global options
|
107
|
+
*/
|
108
|
+
|
109
|
+
matchHeight._groups = [];
|
110
|
+
matchHeight._throttle = 80;
|
111
|
+
matchHeight._maintainScroll = false;
|
112
|
+
matchHeight._beforeUpdate = null;
|
113
|
+
matchHeight._afterUpdate = null;
|
114
|
+
|
115
|
+
/*
|
116
|
+
* matchHeight._apply
|
117
|
+
* apply matchHeight to given elements
|
118
|
+
*/
|
119
|
+
|
120
|
+
matchHeight._apply = function(elements, byRow) {
|
121
|
+
var $elements = $(elements),
|
122
|
+
rows = [$elements];
|
123
|
+
|
124
|
+
// take note of scroll position
|
125
|
+
var scrollTop = $(window).scrollTop(),
|
126
|
+
htmlHeight = $('html').outerHeight(true);
|
127
|
+
|
128
|
+
// temporarily must force hidden parents visible
|
129
|
+
var $hiddenParents = $elements.parents().filter(':hidden');
|
130
|
+
$hiddenParents.css('display', 'block');
|
131
|
+
|
132
|
+
// get rows if using byRow, otherwise assume one row
|
133
|
+
if (byRow) {
|
134
|
+
|
135
|
+
// must first force an arbitrary equal height so floating elements break evenly
|
136
|
+
$elements.each(function() {
|
137
|
+
var $that = $(this),
|
138
|
+
display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';
|
139
|
+
|
140
|
+
// cache the original inline style
|
141
|
+
$that.data('style-cache', $that.attr('style'));
|
142
|
+
|
143
|
+
$that.css({
|
144
|
+
'display': display,
|
145
|
+
'padding-top': '0',
|
146
|
+
'padding-bottom': '0',
|
147
|
+
'margin-top': '0',
|
148
|
+
'margin-bottom': '0',
|
149
|
+
'border-top-width': '0',
|
150
|
+
'border-bottom-width': '0',
|
151
|
+
'height': '100px'
|
152
|
+
});
|
153
|
+
});
|
154
|
+
|
155
|
+
// get the array of rows (based on element top position)
|
156
|
+
rows = _rows($elements);
|
157
|
+
|
158
|
+
// revert original inline styles
|
159
|
+
$elements.each(function() {
|
160
|
+
var $that = $(this);
|
161
|
+
|
162
|
+
$that.attr('style', $that.data('style-cache') || '')
|
163
|
+
.css('height', '');
|
164
|
+
});
|
165
|
+
}
|
166
|
+
|
167
|
+
$.each(rows, function(key, row) {
|
168
|
+
var $row = $(row),
|
169
|
+
maxHeight = 0;
|
170
|
+
|
171
|
+
// skip apply to rows with only one item
|
172
|
+
if (byRow && $row.length <= 1)
|
173
|
+
return;
|
174
|
+
|
175
|
+
// iterate the row and find the max height
|
176
|
+
$row.each(function(){
|
177
|
+
var $that = $(this),
|
178
|
+
display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';
|
179
|
+
|
180
|
+
// ensure we get the correct actual height (and not a previously set height value)
|
181
|
+
$that.css({ 'display': display, 'height': '' });
|
182
|
+
|
183
|
+
// find the max height (including padding, but not margin)
|
184
|
+
if ($that.outerHeight(false) > maxHeight)
|
185
|
+
maxHeight = $that.outerHeight(false);
|
186
|
+
|
187
|
+
// revert display block
|
188
|
+
$that.css('display', '');
|
189
|
+
});
|
190
|
+
|
191
|
+
// iterate the row and apply the height to all elements
|
192
|
+
$row.each(function(){
|
193
|
+
var $that = $(this),
|
194
|
+
verticalPadding = 0;
|
195
|
+
|
196
|
+
// handle padding and border correctly (required when not using border-box)
|
197
|
+
if ($that.css('box-sizing') !== 'border-box') {
|
198
|
+
verticalPadding += _parse($that.css('border-top-width')) + _parse($that.css('border-bottom-width'));
|
199
|
+
verticalPadding += _parse($that.css('padding-top')) + _parse($that.css('padding-bottom'));
|
200
|
+
}
|
201
|
+
|
202
|
+
// set the height (accounting for padding and border)
|
203
|
+
$that.css('height', maxHeight - verticalPadding);
|
204
|
+
});
|
205
|
+
});
|
206
|
+
|
207
|
+
// revert hidden parents
|
208
|
+
$hiddenParents.css('display', '');
|
209
|
+
|
210
|
+
// restore scroll position if enabled
|
211
|
+
if (matchHeight._maintainScroll)
|
212
|
+
$(window).scrollTop((scrollTop / htmlHeight) * $('html').outerHeight(true));
|
213
|
+
|
214
|
+
return this;
|
215
|
+
};
|
216
|
+
|
217
|
+
/*
|
218
|
+
* matchHeight._applyDataApi
|
219
|
+
* applies matchHeight to all elements with a data-match-height attribute
|
220
|
+
*/
|
221
|
+
|
222
|
+
matchHeight._applyDataApi = function() {
|
223
|
+
var groups = {};
|
224
|
+
|
225
|
+
// generate groups by their groupId set by elements using data-match-height
|
226
|
+
$('[data-match-height], [data-mh]').each(function() {
|
227
|
+
var $this = $(this),
|
228
|
+
groupId = $this.attr('data-match-height') || $this.attr('data-mh');
|
229
|
+
if (groupId in groups) {
|
230
|
+
groups[groupId] = groups[groupId].add($this);
|
231
|
+
} else {
|
232
|
+
groups[groupId] = $this;
|
233
|
+
}
|
234
|
+
});
|
235
|
+
|
236
|
+
// apply matchHeight to each group
|
237
|
+
$.each(groups, function() {
|
238
|
+
this.matchHeight(true);
|
239
|
+
});
|
240
|
+
};
|
241
|
+
|
242
|
+
/*
|
243
|
+
* matchHeight._update
|
244
|
+
* updates matchHeight on all current groups with their correct options
|
245
|
+
*/
|
246
|
+
|
247
|
+
var _update = function(event) {
|
248
|
+
if (matchHeight._beforeUpdate)
|
249
|
+
matchHeight._beforeUpdate(event, matchHeight._groups);
|
250
|
+
|
251
|
+
$.each(matchHeight._groups, function() {
|
252
|
+
matchHeight._apply(this.elements, this.byRow);
|
253
|
+
});
|
254
|
+
|
255
|
+
if (matchHeight._afterUpdate)
|
256
|
+
matchHeight._afterUpdate(event, matchHeight._groups);
|
257
|
+
};
|
258
|
+
|
259
|
+
matchHeight._update = function(throttle, event) {
|
260
|
+
// prevent update if fired from a resize event
|
261
|
+
// where the viewport width hasn't actually changed
|
262
|
+
// fixes an event looping bug in IE8
|
263
|
+
if (event && event.type === 'resize') {
|
264
|
+
var windowWidth = $(window).width();
|
265
|
+
if (windowWidth === _previousResizeWidth)
|
266
|
+
return;
|
267
|
+
_previousResizeWidth = windowWidth;
|
268
|
+
}
|
269
|
+
|
270
|
+
// throttle updates
|
271
|
+
if (!throttle) {
|
272
|
+
_update(event);
|
273
|
+
} else if (_updateTimeout === -1) {
|
274
|
+
_updateTimeout = setTimeout(function() {
|
275
|
+
_update(event);
|
276
|
+
_updateTimeout = -1;
|
277
|
+
}, matchHeight._throttle);
|
278
|
+
}
|
279
|
+
};
|
280
|
+
|
281
|
+
/*
|
282
|
+
* bind events
|
283
|
+
*/
|
284
|
+
|
285
|
+
// apply on DOM ready event
|
286
|
+
$(matchHeight._applyDataApi);
|
287
|
+
|
288
|
+
// update heights on load and resize events
|
289
|
+
$(window).bind('load', function(event) {
|
290
|
+
matchHeight._update(false, event);
|
291
|
+
});
|
292
|
+
|
293
|
+
// throttled update heights on resize events
|
294
|
+
$(window).bind('resize orientationchange', function(event) {
|
295
|
+
matchHeight._update(true, event);
|
296
|
+
});
|
297
|
+
|
298
|
+
})(jQuery);
|