This repository has been archived by the owner on Jan 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
409 lines (346 loc) · 17 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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Shuffle/5.2.0/shuffle.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Vestride/Shuffle/docs/css/prism.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Vestride/Shuffle/docs/css/normalize.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Vestride/Shuffle/docs/css/style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Vestride/Shuffle/docs/css/shuffle-styles.css">
<div class="container">
<div class="row">
<div class="col-12@sm">
<h2>Example<a href="#demo"></a></h2>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-4@sm col-3@md">
<div class="filters-group">
<label for="filters-search-input" class="filter-label">Search</label>
<input class="textfield filter__search js-shuffle-search" type="search" id="filters-search-input">
</div>
</div>
</div>
<div class="row">
<div class="col-12@sm filters-group-wrap">
<div class="filters-group">
<p class="filter-label">Filter</p>
<div class="btn-group filter-options">
<button class="btn btn--primary" data-group="basics">basics</button>
<button class="btn btn--primary" data-group="resplot">resplot</button>
<button class="btn btn--primary" data-group="etacov">etacov</button>
<button class="btn btn--primary" data-group="corrplot">corrplot</button>
<button class="btn btn--primary" data-group="individual">individual</button>
</div>
</div>
<fieldset class="filters-group">
<legend class="filter-label">Sort</legend>
<div class="btn-group sort-options">
<label class="btn active">
<input type="radio" name="sort-value" value="dom"> Default
</label>
<label class="btn">
<input type="radio" name="sort-value" value="title"> Title
</label>
<label class="btn">
<input type="radio" name="sort-value" value="date-created"> Date Created
</label>
</div>
</fieldset>
</div>
</div>
</div>
<div class="container">
<div id="grid" class="row my-shuffle-container shuffle" style="height: 1220px; transition: height 250ms cubic-bezier(0.4, 0, 0.2, 1) 0s;">
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["resplot", "basics"]' data-date-created="2017-04-30" data-title="Plain resplot" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/plain_resplot/media/thumb.jpg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/plain_resplot/index.html" target="_blank" rel="noopener">"Plain resplot"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["basics", "etacov"]' data-date-created="2017-04-30" data-title="Plain etacov" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/plain_etacov/media/thumb.jpg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/plain_etacov/index.html" target="_blank" rel="noopener">"Plain etacov"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["basics", "corrplot", "StatsPlots"]' data-date-created="2017-04-30" data-title="Correlation plot" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/correlation_plot/media/thumb.jpg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/correlation_plot/index.html" target="_blank" rel="noopener">"Correlation plot"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["basics", "etacov"]' data-date-created="2017-04-30" data-title="Etacov with kwargs" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/etacov_with_kwargs/media/thumb.jpg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/etacov_with_kwargs/index.html" target="_blank" rel="noopener">"Etacov with kwargs"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["basics", "individual"]' data-date-created="2017-04-30" data-title="CWRES vs IVAR" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/cwres_vs_ivar/media/thumb.jpg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/cwres_vs_ivar/index.html" target="_blank" rel="noopener">"CWRES vs IVAR"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["grouped", "basics", "individual"]' data-date-created="2017-04-30" data-title="Grouped CWRES vs IVAR" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/grouped_cwres_vs_ivar/media/thumb.jpg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/grouped_cwres_vs_ivar/index.html" target="_blank" rel="noopener">"Grouped CWRES vs IVAR"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["basics", ""]' data-date-created="2017-04-30" data-title="DV vs IPRED" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/dv_vs_ipred/media/thumb.jpg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/dv_vs_ipred/index.html" target="_blank" rel="noopener">"DV vs IPRED"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["basics", "individual"]' data-date-created="2017-04-30" data-title="Individual plots" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/individual_plots/media/thumb.jpg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/individual_plots/index.html" target="_blank" rel="noopener">"Individual plots"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<figure class="col-3@xs col-4@sm col-3@md picture-item shuffle-item shuffle-item--visible" data-groups='["basics", "individual"]' data-date-created="2017-04-30" data-title="Plot of all individuals" style="position: absolute; top: 0px; left: 0px; visibility: visible; will-change: transform; opacity: 1; transform: translate(525px, 1220px) scale(1); transition-duration: 250ms; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-property: transform, opacity;">
<div class="picture-item__inner">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img src="https://gallery.pumas.ai/plot_of_all_individuals/media/image.svg" alt="">
<img class="picture-item__blur" src="" alt="" aria-hidden="true">
</div>
</div>
<div class="picture-item__details">
<figcaption class="picture-item__title"><a href="https://gallery.pumas.ai/plot_of_all_individuals/index.html" target="_blank" rel="noopener">"Plot of all individuals"</a></figcaption>
<p class="picture-item__tags hidden@xs"></p>
</div>
</div>
</figure>
<div class="col-1@sm col-1@xs my-sizer-element"></div>
</div>
</div>
<script>
'use strict';
var Shuffle = window.Shuffle;
var Demo = function (element) {
this.element = element;
this.shuffle = new Shuffle(element, {
itemSelector: '.picture-item',
sizer: element.querySelector('.my-sizer-element'),
});
// Log events.
this.addShuffleEventListeners();
this._activeFilters = [];
this.addFilterButtons();
this.addSorting();
this.addSearchFilter();
this.mode = 'exclusive';
};
Demo.prototype.toggleMode = function () {
if (this.mode === 'additive') {
this.mode = 'exclusive';
} else {
this.mode = 'additive';
}
};
/**
* Shuffle uses the CustomEvent constructor to dispatch events. You can listen
* for them like you normally would (with jQuery for example).
*/
Demo.prototype.addShuffleEventListeners = function () {
this.shuffle.on(Shuffle.EventType.LAYOUT, function (data) {
console.log('layout. data:', data);
});
this.shuffle.on(Shuffle.EventType.REMOVED, function (data) {
console.log('removed. data:', data);
});
};
Demo.prototype.addFilterButtons = function () {
var options = document.querySelector('.filter-options');
if (!options) {
return;
}
var filterButtons = Array.from(options.children);
filterButtons.forEach(function (button) {
button.addEventListener('click', this._handleFilterClick.bind(this), false);
}, this);
};
Demo.prototype._handleFilterClick = function (evt) {
var btn = evt.currentTarget;
var isActive = btn.classList.contains('active');
var btnGroup = btn.getAttribute('data-group');
// You don't need _both_ of these modes. This is only for the demo.
// For this custom 'additive' mode in the demo, clicking on filter buttons
// doesn't remove any other filters.
if (this.mode === 'additive') {
// If this button is already active, remove it from the list of filters.
if (isActive) {
this._activeFilters.splice(this._activeFilters.indexOf(btnGroup));
} else {
this._activeFilters.push(btnGroup);
}
btn.classList.toggle('active');
// Filter elements
this.shuffle.filter(this._activeFilters);
// 'exclusive' mode lets only one filter button be active at a time.
} else {
this._removeActiveClassFromChildren(btn.parentNode);
var filterGroup;
if (isActive) {
btn.classList.remove('active');
filterGroup = Shuffle.ALL_ITEMS;
} else {
btn.classList.add('active');
filterGroup = btnGroup;
}
this.shuffle.filter(filterGroup);
}
};
Demo.prototype._removeActiveClassFromChildren = function (parent) {
var children = parent.children;
for (var i = children.length - 1; i >= 0; i--) {
children[i].classList.remove('active');
}
};
Demo.prototype.addSorting = function () {
var buttonGroup = document.querySelector('.sort-options');
if (!buttonGroup) {
return;
}
buttonGroup.addEventListener('change', this._handleSortChange.bind(this));
};
Demo.prototype._handleSortChange = function (evt) {
// Add and remove `active` class from buttons.
var wrapper = evt.currentTarget;
var buttons = Array.from(evt.currentTarget.children);
buttons.forEach(function (button) {
if (button.querySelector('input').value === evt.target.value) {
button.classList.add('active');
} else {
button.classList.remove('active');
}
});
// Create the sort options to give to Shuffle.
var value = evt.target.value;
var options = {};
function sortByDate(element) {
return element.getAttribute('data-created');
}
function sortByTitle(element) {
return element.getAttribute('data-title').toLowerCase();
}
if (value === 'date-created') {
options = {
reverse: true,
by: sortByDate,
};
} else if (value === 'title') {
options = {
by: sortByTitle,
};
}
this.shuffle.sort(options);
};
// Advanced filtering
Demo.prototype.addSearchFilter = function () {
var searchInput = document.querySelector('.js-shuffle-search');
if (!searchInput) {
return;
}
searchInput.addEventListener('keyup', this._handleSearchKeyup.bind(this));
};
/**
* Filter the shuffle instance by items with a title that matches the search input.
* @param {Event} evt Event object.
*/
Demo.prototype._handleSearchKeyup = function (evt) {
var searchText = evt.target.value.toLowerCase();
this.shuffle.filter(function (element, shuffle) {
// If there is a current filter applied, ignore elements that don't match it.
if (shuffle.group !== Shuffle.ALL_ITEMS) {
// Get the item's groups.
var groups = JSON.parse(element.getAttribute('data-groups'));
var isElementInCurrentGroup = groups.indexOf(shuffle.group) !== -1;
// Only search elements in the current group
if (!isElementInCurrentGroup) {
return false;
}
}
var titleElement = element.querySelector('.picture-item__title');
var titleText = titleElement.textContent.toLowerCase().trim();
return titleText.indexOf(searchText) !== -1;
});
};
document.addEventListener('DOMContentLoaded', function () {
window.demo = new Demo(document.getElementById('grid'));
});
</script>
</body>
</html>