masonry-rails 0.1.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.
Files changed (54) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +11 -0
  4. data/Gemfile.lock +109 -0
  5. data/LICENSE.txt +20 -0
  6. data/Masonry.mdown +51 -0
  7. data/README.md +53 -0
  8. data/Rakefile +49 -0
  9. data/VERSION +1 -0
  10. data/_config.yml +6 -0
  11. data/lib/masonry-rails.rb +7 -0
  12. data/masonry-rails.gemspec +107 -0
  13. data/minify.sh +16 -0
  14. data/spec/_layouts/default.html +75 -0
  15. data/spec/_posts/demos/2011-05-01-basic-single-column.html +206 -0
  16. data/spec/_posts/demos/2011-05-02-basic-multi-column.html +213 -0
  17. data/spec/_posts/demos/2011-05-03-images.html +57 -0
  18. data/spec/_posts/demos/2011-05-04-tumblelog.html +226 -0
  19. data/spec/_posts/demos/2011-05-05-animating-jquery.html +144 -0
  20. data/spec/_posts/demos/2011-05-06-animating-css-transitions.html +132 -0
  21. data/spec/_posts/demos/2011-05-07-animating-modernizr.html +136 -0
  22. data/spec/_posts/demos/2011-05-08-adding-items.html +89 -0
  23. data/spec/_posts/demos/2011-05-09-infinite-scroll.html +268 -0
  24. data/spec/_posts/demos/2011-05-10-gutters.html +209 -0
  25. data/spec/_posts/demos/2011-05-11-right-to-left.html +135 -0
  26. data/spec/_posts/demos/2011-05-17-centered.html +137 -0
  27. data/spec/_posts/demos/2011-07-26-fluid.html +219 -0
  28. data/spec/_posts/demos/2011-10-07-corner-stamp.html +249 -0
  29. data/spec/_posts/docs/2011-05-01-intro.mdown +149 -0
  30. data/spec/_posts/docs/2011-05-02-options.mdown +157 -0
  31. data/spec/_posts/docs/2011-05-03-methods.mdown +155 -0
  32. data/spec/_posts/docs/2011-05-04-animating.mdown +96 -0
  33. data/spec/_posts/docs/2011-05-30-help.mdown +139 -0
  34. data/spec/_posts/pages/2011-05-02-2.html +189 -0
  35. data/spec/_posts/pages/2011-05-03-3.html +174 -0
  36. data/spec/_posts/pages/2011-05-04-4.html +159 -0
  37. data/spec/_posts/pages/2011-05-05-5.html +167 -0
  38. data/spec/_posts/tests/2011-01-01-index.html +14 -0
  39. data/spec/_posts/tests/2011-05-14-lots-of-bricks.html +1438 -0
  40. data/spec/_posts/tests/2011-05-17-dual.html +247 -0
  41. data/spec/_posts/tests/2011-05-18-first-child-no-width.html +217 -0
  42. data/spec/_posts/tests/2011-05-19-empty.html +205 -0
  43. data/spec/_posts/tests/2011-08-08-destroy.html +214 -0
  44. data/spec/_posts/tests/2011-09-27-centered-few.html +50 -0
  45. data/spec/index.html +58 -0
  46. data/spec/spec_helper.rb +12 -0
  47. data/vendor/assets/javascripts/masonry/box-maker.js +38 -0
  48. data/vendor/assets/javascripts/masonry/jquery.event.drag-2.2.js +402 -0
  49. data/vendor/assets/javascripts/masonry/jquery.infinitescroll.min.js +47 -0
  50. data/vendor/assets/javascripts/masonry/jquery.masonry.js +682 -0
  51. data/vendor/assets/javascripts/masonry/jquery.masonry.min.js +10 -0
  52. data/vendor/assets/javascripts/masonry/modernizr-transitions.js +2 -0
  53. data/vendor/assets/stylesheets/masonry/style.css +616 -0
  54. metadata +199 -0
@@ -0,0 +1,149 @@
1
+ ---
2
+
3
+ title: Introduction
4
+ category: docs
5
+ layout: default
6
+ toc:
7
+ - { title: Getting started, anchor: getting_started }
8
+ - { title: Code repository, anchor: code_repository }
9
+ - { title: Acknowledgments, anchor: acknowledgments }
10
+ - { title: Changelog, anchor: changelog }
11
+ - { title: License, anchor: license }
12
+
13
+ ---
14
+
15
+ Masonry is a dynamic grid layout plugin for jQuery. Think of it as the flip-side of CSS floats. Whereas floating arranges elements horizontally then vertically, Masonry arranges elements vertically, positioning each element in the next open spot in the grid. The result minimizes vertical gaps between elements of varying height, just like a mason fitting stones in a wall.
16
+
17
+ ## Getting started
18
+
19
+
20
+
21
+ ### Markup
22
+
23
+ Masonry works on a container element with a group of similar child items.
24
+
25
+ {% highlight html %}
26
+
27
+ <div id="container">
28
+ <div class="item">...</div>
29
+ <div class="item">...</div>
30
+ <div class="item">...</div>
31
+ ...
32
+ </div>
33
+
34
+ {% endhighlight %}
35
+
36
+ Add jQuery and the Masonry script. Masonry requires jQuery v1.4.0 and greater.
37
+
38
+ {% highlight html %}
39
+
40
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
41
+ <script src="/path/to/jquery.masonry.min.js"></script>
42
+
43
+ {% endhighlight %}
44
+
45
+ ### CSS
46
+
47
+ All sizing of items is handled by your CSS. Items should be floated.
48
+
49
+ {% highlight css %}
50
+
51
+ .item {
52
+ width: 220px;
53
+ margin: 10px;
54
+ float: left;
55
+ }
56
+
57
+ {% endhighlight %}
58
+
59
+ ### Script
60
+
61
+ It is recommended you specify an `itemSelector` and `columnWidth`. There are a number of other [options](options.html) you can specify.
62
+
63
+ {% highlight javascript %}
64
+
65
+ $(function(){
66
+ $('#container').masonry({
67
+ // options
68
+ itemSelector : '.item',
69
+ columnWidth : 240
70
+ });
71
+ });
72
+
73
+ {% endhighlight %}
74
+
75
+ That's it!
76
+
77
+ [**See Demo: Basic multi-column**](../demos/basic-multi-column.html)
78
+
79
+
80
+ ### imagesLoaded plugin
81
+
82
+ If your content contains any images, you'll want to ensure that Masonry is triggered after all the images your content has loaded. The included [imagesLoaded plugin](https://github.com/desandro/imagesloaded) makes this easy.
83
+
84
+ {% highlight javascript %}
85
+
86
+ var $container = $('#container');
87
+ $container.imagesLoaded(function(){
88
+ $container.masonry({
89
+ itemSelector : '.item',
90
+ columnWidth : 240
91
+ });
92
+ });
93
+
94
+ {% endhighlight %}
95
+
96
+ [See Demo: Images](../demos/images.html)
97
+
98
+ ## Code repository
99
+
100
+ This project lives on GitHub at [github.com/desandro/masonry](http://github.com/desandro/masonry). There you can grab the latest code and follow development.
101
+
102
+ ## Acknowledgments
103
+
104
+ + Louis-Rémi Babé and Paul Irish for the [jQuery SmartResize plugin](http://github.com/louisremi/jquery-smartresize). De-bounced window resize event handler. Used within Masonry.
105
+ + Paul Irish and Luke Shumard for [Infinite Scroll](http://www.infinite-scroll.com). Pretty much Masony's BFF &lt;3.
106
+ + The Modernizr team for [Modernizr](http://www.modernizr.com/). Used in most of these demos.
107
+ + Paul Irish et. al. for [imagesLoaded plugin](https://gist.github.com/268257). Used within Masonry.
108
+ + [Ralph Holzmann](http://twitter.com/ralphholzmann) for re-writing the [jQuery Plugins/Authoring tutorial](http://docs.jquery.com/Plugins/Authoring) and opened my eyes to [Plugin Methods](http://docs.jquery.com/Plugins/Authoring#Plugin_Methods) pattern.
109
+ + [Eric Hynds](http://www.erichynds.com/) for his article [Using $.widget.bridge Outside of the Widget Factory](http://www.erichynds.com/jquery/using-jquery-ui-widget-factory-bridge/) which provided the architecture for Masonry.
110
+
111
+ ## Changelog
112
+
113
+ <dl>
114
+ <dt>v2.1: 9 Dec 2011</dt>
115
+ <dd>Pass in a function for <code>columnWidth</code> for easier fluid layouts</dd>
116
+ <dt>v2.0: May 2011</dt>
117
+ <dd>Complete re-write. Uses <code>$.Mason</code> constructor, like jQuery UI widget</dd>
118
+ <dd>Add options <code>gutterWidth</code>, <code>isFitWidth</code> for centering layout, <code>isRTL</code> for right-to-left layout</dd>
119
+ <dd>Add all new methods like <code>appended</code>, and <code>reload</code></dd>
120
+ <dd>Remove filtering demos</dd>
121
+ <dt>v1.3: 3 Sep 2010</dt>
122
+ <dd>Revamped <code>appendedContent</code> to work with container elements. Plays nice with latest Infinite Scroll.</dd>
123
+ <dd>Revised layout for documentation to allow for more pages.</dd>
124
+ <dt>v1.2: 12 Jun 2010</dt>
125
+ <dd>Support for filtering added</dd>
126
+ <dt>v1.1: 29 Apr 2010</dt>
127
+ <dd>Add animation</dd>
128
+ <dt>v1.0: 7 Dec 2009</dt>
129
+ <dd>Multi-column width support</dd>
130
+ <dd>Appending elements and Infinite Scroll support</dd>
131
+ <dd>Less obstrusive layout. No inserting additional markup.</dd>
132
+ <dd>Automatically binds event to window resizing</dd>
133
+ <dt>v0.4: 14 Jun 2009</dt>
134
+ <dd>Better fluid rearrangement support</dd>
135
+ <dt>v0.1: Feb 2009</dt>
136
+ <dd>Original release</dd>
137
+ </dl>
138
+
139
+ ## License
140
+
141
+ jQuery Masonry is licensed under the MIT license. It may be used for personal and commercial applications.
142
+
143
+ <div class="license-copy">
144
+ <h3>The MIT License</h3>
145
+ <p>Copyright &copy; 2012 David DeSandro</p>
146
+ <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
147
+ <p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
148
+ <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
149
+ </div>
@@ -0,0 +1,157 @@
1
+ ---
2
+
3
+ title: Options
4
+ category: docs
5
+ layout: default
6
+ body_class: options
7
+ toc :
8
+ - { title: animationOptions, anchor: animationoptions }
9
+ - { title: columnWidth, anchor: columnwidth }
10
+ - { title: containerStyle, anchor: containerstyle }
11
+ - { title: gutterWidth, anchor: gutterwidth }
12
+ - { title: isAnimated, anchor: isanimated }
13
+ - { title: isFitWidth, anchor: isfitwidth }
14
+ - { title: isResizable, anchor: isresizable }
15
+ - { title: isRTL, anchor: isrtl }
16
+ - { title: itemSelector, anchor: itemselector }
17
+
18
+ ---
19
+
20
+ Options are set with an object as second argument to the `.masonry()` method. All options are optional, and do not need to be set, but [`itemSelector`](#itemselector) and [`columnWidth`](#columnwidth) are recommended.
21
+
22
+ {% highlight javascript %}
23
+
24
+ $('#container').masonry({
25
+ itemSelector: '.box',
26
+ columnWidth: 240,
27
+ animationOptions: {
28
+ duration: 400
29
+ }
30
+ });
31
+
32
+ {% endhighlight %}
33
+
34
+ <dl class="header clearfix">
35
+ <dt><code>option</code></dt>
36
+ <dd class="option-type">Type</dd>
37
+ <dd class="default">Default</dd>
38
+ </dl>
39
+
40
+ ## animationOptions
41
+
42
+ <dl class="clearfix">
43
+ <dt><code>animationOptions</code></dt>
44
+ <dd class="option-type">Object</dd>
45
+ <dd class="default"><code>{ queue: <span class="kc">false</span>, duration: <span class="mi">500</span> }</code></dd>
46
+ </dl>
47
+
48
+ Options used for jQuery animation. See the [jQuery API for animate options](http://api.jquery.com/animate/#animate-properties-options) for details. More details in [Animating](animating.html).
49
+
50
+ ## columnWidth
51
+
52
+ <dl class="clearfix">
53
+ <dt><code>columnWidth</code></dt>
54
+ <dd class="option-type">Integer</dd>
55
+ </dl>
56
+
57
+ Width in pixels of 1 column of your grid. If no columnWidth is specified, Masonry uses the width of the first item element.
58
+
59
+ **Recommended** if your layout has item elements that have multiple-column widths.
60
+
61
+ To set a dynamic column width, you can pass in a function that returns the value column width. The function provides an argument for the width of the container. Use this technique for fluid or responsive layouts.
62
+
63
+ {% highlight javascript %}
64
+
65
+ $('#container').masonry({
66
+ // set columnWidth a fraction of the container width
67
+ columnWidth: function( containerWidth ) {
68
+ return containerWidth / 5;
69
+ }
70
+ });
71
+
72
+ {% endhighlight %}
73
+
74
+ [See Demo: Fluid](../demos/fluid.html).
75
+
76
+ ## containerStyle
77
+
78
+ <dl class="clearfix">
79
+ <dt><code>containerStyle</code></dt>
80
+ <dd class="option-type">Object</dd>
81
+ <dd class="default"><code>{ position: <span class="s1">'relative'</span> }</code></dd>
82
+ </dl>
83
+
84
+ CSS properties applied to the container. Masonry uses relative/absolute positioning to position item elements.
85
+
86
+ ## gutterWidth
87
+
88
+ <dl class="clearfix">
89
+ <dt><code>gutterWidth</code></dt>
90
+ <dd class="option-type">Integer</dd>
91
+ <dd class="default"><code><span class="mi">0</span></code></dd>
92
+ </dl>
93
+
94
+ Adds additional spacing between columns.
95
+
96
+ [See Demo: Gutters](../demos/gutters.html).
97
+
98
+ ## isAnimated
99
+
100
+ <dl class="clearfix">
101
+ <dt><code>isAnimated</code></dt>
102
+ <dd class="option-type">Boolean</dd>
103
+ <dd class="default"><code><span class="kc">false</span></code></dd>
104
+ </dl>
105
+
106
+ Enables jQuery animation on layout changes. [See Docs: Animating](animating.html). More details in [Animating](animating.html).
107
+
108
+ ## isFitWidth
109
+
110
+ <dl class="clearfix">
111
+ <dt><code>isFitWidth</code></dt>
112
+ <dd class="option-type">Boolean</dd>
113
+ <dd class="default"><code><span class="kc">false</span></code></dd>
114
+ </dl>
115
+
116
+ If enabled, Masonry will size the width of the container to the nearest column. When enabled, Masonry will measure the width of the container's parent element, not the width of the container. This option is ideal for centering Masonry layouts.
117
+
118
+ [See Demo: Centered](../demos/centered.html).
119
+
120
+ ## isResizable
121
+
122
+ <dl class="clearfix">
123
+ <dt><code>isResizable</code></dt>
124
+ <dd class="option-type">Boolean</dd>
125
+ <dd class="default"><code><span class="kc">true</span></code></dd>
126
+ </dl>
127
+
128
+ Triggers layout logic when browser window is resized.
129
+
130
+ ## isRTL
131
+
132
+ <dl class="clearfix">
133
+ <dt><code>isRTL</code></dt>
134
+ <dd class="option-type">Boolean</dd>
135
+ <dd class="default"><code><span class="kc">false</span></code></dd>
136
+ </dl>
137
+
138
+ Enables right-to-left layout for languages like Hebrew and Arabic.
139
+
140
+ [See Demo: Right-to-left](../demos/right-to-left.html).
141
+
142
+ ## itemSelector
143
+
144
+ <dl class="clearfix">
145
+ <dt><code>itemSelector</code></dt>
146
+ <dd class="option-type">String</dd>
147
+ </dl>
148
+
149
+ Filters item elements to selector. If not set, Masonry defaults to using the child elements of the container.
150
+
151
+ **Recommended** to avoid Masonry using any other hidden elements in its layout logic.
152
+
153
+ {% highlight javascript %}
154
+
155
+ $('#container').masonry({ itemSelector: '.box' });
156
+
157
+ {% endhighlight %}
@@ -0,0 +1,155 @@
1
+ ---
2
+
3
+ title: Methods
4
+ category: docs
5
+ layout: default
6
+ toc:
7
+ - { title: appended, anchor: appended }
8
+ - { title: destroy, anchor: destroy }
9
+ - { title: layout, anchor: layout }
10
+ - { title: option, anchor: option }
11
+ - { title: reloadItems, anchor: reloaditems }
12
+ - { title: reload, anchor: reload }
13
+ - { title: remove, anchor: remove }
14
+
15
+ ---
16
+
17
+ Masonry offers several methods to extend functionality. Masonry's methods follow the jQuery UI pattern.
18
+
19
+ {% highlight javascript %}
20
+
21
+ $('#container').masonry( 'methodName', [optionalParameters] )
22
+
23
+ {% endhighlight %}
24
+
25
+
26
+ ## appended
27
+
28
+ {% highlight javascript %}
29
+
30
+ .masonry( 'appended', $content, isAnimatedFromBottom )
31
+
32
+ {% endhighlight %}
33
+
34
+ Triggers `layout` on item elements that have been appended to the container.
35
+
36
+ [See Demo: Adding items](../demos/adding-items.html).
37
+
38
+ {% highlight javascript %}
39
+
40
+ var $boxes = $('<div class="box"/><div class="box"/><div class="box"/>');
41
+ $('#container').append( $boxes ).masonry( 'appended', $boxes );
42
+
43
+ {% endhighlight %}
44
+
45
+ Setting the `isAnimatedFromBottom` argument to <code><span class="kc">true</span></code> will enable the newly appended items to be animated from the bottom, if animation is enabled.
46
+
47
+ {% highlight javascript %}
48
+
49
+ $('#container').append( $boxes ).masonry( 'appended', $boxes, true );
50
+
51
+ {% endhighlight %}
52
+
53
+
54
+ The `appended` method is ideal to use Masonry with Infinite Scroll, in its callback.
55
+
56
+ [See Demo: Infinite Scroll](../demos/infinite-scroll.html).
57
+
58
+ {% highlight javascript %}
59
+
60
+
61
+ var $container = $('#container');
62
+ $container.infinitescroll({
63
+ // infinite scroll options...
64
+ },
65
+ // trigger Masonry as a callback
66
+ function( newElements ) {
67
+ var $newElems = $( newElements );
68
+ $container.masonry( 'appended', $newElems );
69
+ }
70
+ );
71
+
72
+ {% endhighlight %}
73
+
74
+
75
+ ## destroy
76
+
77
+ {% highlight javascript %}
78
+
79
+ .masonry( 'destroy' )
80
+
81
+ {% endhighlight %}
82
+
83
+ Removes Masonry functionality completely. Returns element back to pre-initialized state.
84
+
85
+ ## layout
86
+
87
+ {% highlight javascript %}
88
+
89
+ .masonry( 'layout', $items, callback )
90
+
91
+ {% endhighlight %}
92
+
93
+ Positions specified item elements in layout.
94
+
95
+ `layout` will only position specified elements, and those elements will be positioned at the end of layout. Whereas `.masonry()` will position all items in the Masonry instance.
96
+
97
+ ## option
98
+
99
+ {% highlight javascript %}
100
+
101
+ .masonry( 'option', options )
102
+
103
+ {% endhighlight %}
104
+
105
+ Sets options for plugin instance. Unlike passing options through `.masonry()`, using the `option` method will not trigger layout.
106
+
107
+ {% highlight javascript %}
108
+
109
+ // set multiple options
110
+ .masonry( 'option', { columnWidth: 120, isAnimated: false } )
111
+
112
+ {% endhighlight %}
113
+
114
+
115
+ ## reloadItems
116
+
117
+ {% highlight javascript %}
118
+
119
+ .masonry( 'reloadItems' )
120
+
121
+ {% endhighlight %}
122
+
123
+ Re-collects all item elements in their current order in the DOM.
124
+
125
+ ## reload
126
+
127
+ {% highlight javascript %}
128
+
129
+ .masonry( 'reload' )
130
+
131
+ {% endhighlight %}
132
+
133
+ Convenience method for triggering `reloadItems` then `.masonry()`. Useful for prepending or inserting items.
134
+
135
+ [See Demo: Adding items](../demos/adding-items.html).
136
+
137
+ {% highlight javascript %}
138
+
139
+ var $boxes = $('<div class="box"/><div class="box"/><div class="box"/>');
140
+ $('#container').prepend( $boxes ).masonry( 'reload' );
141
+
142
+ {% endhighlight %}
143
+
144
+ ## remove
145
+
146
+ {% highlight javascript %}
147
+
148
+ .masonry( 'remove', $items )
149
+
150
+ {% endhighlight %}
151
+
152
+ Removes specified item elements from Masonry instance and the DOM.
153
+
154
+
155
+