forked from germanysbestkeptsecret/Wookmark-jQuery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
215 lines (187 loc) · 6.94 KB
/
index.html
File metadata and controls
215 lines (187 loc) · 6.94 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>jQuery Wookmark Plug-in Example</title>
<meta name="description" content="An very basic example of how to use the Wookmark jQuery plug-in.">
<meta name="author" content="Christoph Ono, Sebastian Helzle">
<meta name="viewport" content="width=device-width,initial-scale=1">
<!-- CSS Reset -->
<link rel="stylesheet" href="../css/reset.css">
<!-- Global CSS for the page and tiles -->
<link rel="stylesheet" href="../css/main.css">
<!-- Specific CSS for the example -->
<style>
/**
* Grid items
*/
#tiles li {
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
/**
* Sort buttons
*/
#sortbys {
list-style-type: none;
text-align: center;
margin: 0 5% 0 5%;
}
#sortbys li {
font-size: 12px;
float: left;
padding: 6px 0 4px 0;
cursor: pointer;
margin: 0 1% 0 1%;
width: 8%;
-webkit-transition: all 0.15s ease-out;
-moz-transition: all 0.15s ease-out;
-o-transition: all 0.15s ease-out;
transition: all 0.15s ease-out;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
#sortbys li:hover {
background: #dedede;
}
#sortbys li.active {
background: #333333;
color: #ffffff;
}
</style>
</head>
<body>
<div id="container">
<header>
<h1>jQuery Wookmark Plug-in Example</h1>
<p>Click the words below to sort the grid.</p>
</header>
<!--
These are our filter options. The "data-sortby" classes are used to identify which
grid items to show.
-->
<br/>
<ol id="sortbys">
<li data-sortby="name" class="active">Name</li>
<li data-sortby="price">Price</li>
<li data-sortby="popularity">Popularity</li>
</ol>
<br/>
<div id="main" role="main">
<ul id="tiles">
<!--
These are our grid items. Notice how each one has a data-attribute assigned that
are used for sorting. The classes match the "data-sortby" properties above.
-->
<li data-price="20" data-popularity="4" data-name="icebear">
<img src="../sample-images/image_1.jpg" height="283" width="200">
<p>Icebear / 20 € / ★★★★</p>
</li>
<li data-price="24" data-popularity="3" data-name="hand">
<img src="../sample-images/image_2.jpg" height="300" width="200">
<p>Hand / 24 € / ★★★</p>
</li>
<li data-price="12.50" data-popularity="2" data-name="water">
<img src="../sample-images/image_3.jpg" height="252" width="200">
<p>Water / 12,50 € / ★★</p>
</li>
<li data-price="100" data-popularity="1" data-name="runner">
<img src="../sample-images/image_4.jpg" height="158" width="200">
<p>Runner / 100 € / ★</p>
</li>
<li data-price="42.12" data-popularity="3" data-name="street">
<img src="../sample-images/image_5.jpg" height="300" width="200">
<p>Street / 42,12 € / ★★★</p>
</li>
<li data-price="15" data-popularity="1" data-name="bathroom">
<img src="../sample-images/image_6.jpg" height="297" width="200">
<p>Bathroom / 15 € / ★</p>
</li>
<li data-price="70" data-popularity="2" data-name="sign">
<img src="../sample-images/image_7.jpg" height="200" width="200">
<p>Sign / 70 € / ★★</p>
</li>
<li data-price="18.99" data-popularity="4" data-name="camera">
<img src="../sample-images/image_8.jpg" height="200" width="200">
<p>Camera / 18,99 € / ★★★★</p>
</li>
<li data-price="5" data-popularity="4" data-name="winter">
<img src="../sample-images/image_9.jpg" height="398" width="200">
<p>Winter / 5 € / ★★★★</p>
</li>
<li data-price="7" data-popularity="1" data-name="kitchen">
<img src="../sample-images/image_10.jpg" height="267" width="200">
<p>Kitchen / 7 € / ★</p>
</li>
<!-- End of grid blocks -->
</ul>
</div>
</div>
<!-- include jQuery -->
<script src="../libs/jquery.min.js"></script>
<!-- Include the imagesLoaded plug-in -->
<script src="../libs/jquery.imagesloaded.js"></script>
<!-- Include the plug-in -->
<script src="../jquery.wookmark.js"></script>
<!-- Once the page is loaded, initalize the plug-in. -->
<script type="text/javascript">
(function ($){
$('#tiles').imagesLoaded(function() {
function comparatorName(a, b) {
return $(a).data('name') < $(b).data('name') ? -1 : 1;
}
function comparatorPopularity(a, b) {
return $(a).data('popularity') > $(b).data('popularity') ? -1 : 1;
}
function comparatorPrice(a, b) {
return $(a).data('price') < $(b).data('price') ? -1 : 1;
}
// Prepare layout options.
var options = {
autoResize: true, // This will auto-update the layout when the browser window is resized.
container: $('#main'), // Optional, used for some extra CSS styling
offset: 2, // Optional, the distance between grid items
itemWidth: 210, // Optional, the width of a grid item
comparator: comparatorName
};
// Get a reference to your grid items.
var $handler = $('#tiles li'),
$sortbys = $('#sortbys li');
// Call the layout function.
$handler.wookmark(options);
/**
* When a filter is clicked, toggle it's active state and refresh.
*/
var onClickSortBy = function(e) {
e.preventDefault();
$currentSortby = $(this);
switch ($currentSortby.data('sortby')) {
case 'price':
options.comparator = comparatorPrice;
break;
case 'popularity':
options.comparator = comparatorPopularity;
break;
case 'name':
default:
options.comparator = comparatorName;
break;
}
$sortbys.removeClass('active');
$currentSortby.addClass('active');
$handler.wookmark(options);
}
// Capture filter click events.
$sortbys.click(onClickSortBy);
});
})(jQuery);
</script>
</body>
</html>