forked from desandro/masonry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
127 lines (105 loc) · 3.05 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
title: jQuery Masonry
layout: default
category: homepage
has_modernizr: true
mini_bricks:
- w1 h1
- w1 h1
- w1 h2
- w1 h1
- w2 h1
- w1 h2
- w1 h1
- w2 h2
- w2 h1
- w1 h1
- w2 h2
- w2 h1
---
<div id="container" class="transitions-enabled clearfix">
<div class="item big-text col2">
A dynamic layout plugin for jQuery<br />
The flip-side of CSS floats<br />
<br />
← View docs and demos
</div>
<div class="item big-text">
Before: CSS Floats
<div class="mini">
{% for brick in page.mini_bricks %}
<div class="{{ brick }}">{{ forloop.index }}</div>
{% endfor %}
</div>
</div>
<div class="item big-text">
After: Masonry
<div id="mini-container" class="mini">
{% for brick in page.mini_bricks %}
<div class="{{ brick }}">{{ forloop.index }}</div>
{% endfor %}
</div>
</div>
<div class="item link">
<a href="jquery.masonry.min.js">Download the script jquery.​masonry.​min.js</a>
</div>
<div class="item link">
<a href="http://meta.metafizzy.co/files/masonry-site.zip">Download this project</a>
</div>
<div class="item link">
<a href="https://github.com/desandro/masonry">Masonry on GitHub</a>
</div>
<div class="item big-text loading">
<img src="http://i.imgur.com/6RMhx.gif" />
Loading Examples
</div>
</div> <!-- #container -->
<script src="{{ site.jquery_js }}"></script>
<script src="{{ site.masonry_js }}"></script>
<script>
$(function(){
var $container = $('#container');
$('#mini-container').masonry({
columnWidth: 50
});
$container.masonry({
itemSelector: '.item',
columnWidth: 240,
isAnimated: !Modernizr.csstransitions
});
// Sites using Masonry markup
var $sites = $('#sites'),
$loadingItem = $container.find('.loading');
var ajaxError = function(){
$loadingItem.text('Could not load examples :(');
};
// dynamically load sites using Masonry from Zootool
$.getJSON('http://zootool.com/api/users/items/?username=desandro' +
'&apikey=8b604e5d4841c2cd976241dd90d319d7' +
'&tag=bestofmasonry&callback=?')
.error( ajaxError )
.success(function( data ){
// proceed only if we have data
if ( !data || !data.length ) {
ajaxError();
return;
}
var items = [],
item, datum;
for ( var i=0, len = data.length; i < len; i++ ) {
datum = data[i];
item = '<div class="item example"><a href="' + datum.url + '">'
+ '<img src="' + datum.image.replace('/l.', '/m.') + '" />'
+ '<b>' + datum.title + '</b>'
+ '</a></div>';
items.push( item );
}
var $items = $( items.join('') );
$items.imagesLoaded(function(){
$container
.masonry( 'remove', $loadingItem ).masonry()
.append( $items ).masonry( 'appended', $items, true );
});
});
});
</script>