forked from nuxeo/nuxeo.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisotope.html
512 lines (420 loc) · 17.3 KB
/
isotope.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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
<head>
<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8">
<title>Nuxeo</title>
<meta name="description" content="Nuxeo on Github">
<meta name="author" content="nuxeo">
<!-- Mobile Specific Metas
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- CSS
================================================== -->
<link rel="stylesheet" href="stylesheets/base.css">
<link rel="stylesheet" href="stylesheets/skeleton.css">
<link rel="stylesheet" href="stylesheets/layout.css">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
/**** Isotope Filtering ****/
.isotope-item {
z-index: 2;
}
.isotope-hidden.isotope-item {
pointer-events: none;
z-index: 1;
}
/**** Isotope CSS3 transitions ****/
.isotope,
.isotope .isotope-item {
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-ms-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
}
.isotope {
-webkit-transition-property: height, width;
-moz-transition-property: height, width;
-ms-transition-property: height, width;
-o-transition-property: height, width;
transition-property: height, width;
}
.isotope .isotope-item {
-webkit-transition-property: -webkit-transform, opacity;
-moz-transition-property: -moz-transform, opacity;
-ms-transition-property: -ms-transform, opacity;
-o-transition-property: top, left, opacity;
transition-property: transform, opacity;
}
/**** disabling Isotope CSS3 transitions ****/
.isotope.no-transition,
.isotope.no-transition .isotope-item,
.isotope .isotope-item.no-transition {
-webkit-transition-duration: 0s;
-moz-transition-duration: 0s;
-ms-transition-duration: 0s;
-o-transition-duration: 0s;
transition-duration: 0s;
}
a.highlight {
color: red;
}
.item {
border: 1px solid #CCC;
width : 200px;
}
#filter-display {
font-size: 18px;
padding: 0.5em;
border: 1px solid #CCC;
color: blue;
}
</style>
<!-- Favicons
================================================== -->
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
</head>
<body>
<!-- Primary Page Layout
================================================== -->
<div>
<div style="float: left;" id="options">
<div >
<fieldset>
<label for="">Origins</label>
<div class="option-set" data-group="origin">
<label for="origin-all"><input type="checkbox" value="" id="origin-all" class="all" checked="true" /><span>all</span></label></label>
<label for="origin-all"><input type="checkbox" value=".Nuxeo" id="Nuxeo" /><span>Nuxeo</span></label>
<label for="origin-all"><input type="checkbox" value=".Community" id="Community" /><span>Community</span></label>
<label for="origin-all"><input type="checkbox" value=".Personal" id="Personal" /><span>Personal</span></label>
</div>
</fieldset>
<fieldset>
<label for="">Languages</label>
<div id="languagesSelector" class="option-set" data-group="language">
<label for="language-all"><input type="checkbox" value="" id="language-all" class="all" checked="true" /><span>all</span></label>
</div>
</fieldset>
<fieldset>
<label for="">Categories</label>
<div id="categoriesSelector" class="option-set" data-group="categories">
<label for="language-all"><input type="checkbox" value="" id="categories-all" class="all" checked="true" /><span>all</span></label>
</div>
</fieldset>
</div>
</div>
<div>
<div id="sort-by" >
<h6>Sort by:</h6>
<span><a class="highlight" href="#original-order">default</a></span>
<span><a href="#name">name</a></span>
<span><a href="#pushed_at">pushed_at</a></span>
<span><a href="#watchers">watchers</a></span>
<span><a href="#random">random</a></span>
</div>
</div>
<div> <p id="filter-display"></p> </div>
<div id="container">
</div>
</div>
<!-- container -->
<!-- JS
================================================== -->
<script src="javascripts/jquery-1.7.1.min.js"></script>
<script src="javascripts/strftime.js"></script>
<script src="javascripts/jquery.isotope.min.js"></script>
<script type="text/javascript">
(function ($, undefined) {
// Put community repositories json description
var communityRepos;
// Put personal repositories json description
var personalRepos;
// Put personal repositories json description
var timelineRepos;
// Put custom repo URL's in this object, keyed by repo name.
var customRepoUrls;
// Put custom repo descriptions in this object, keyed by repo name.
var customRepoDescriptions;
var defaultRepoCategories;
var commits = new Array();
var uniqueCategories = new Array();
var uniqueLanguages = new Array();
Array.prototype.pushUnique = function (value) {
var arrVal = this;
if ($.inArray(value, arrVal) === -1) {
arrVal.push(value);
}
return arrVal;
}
$.getJSON("./repositories.json", function(data) {
communityRepos = data.community;
personalRepos = data.personal;
timelineRepos = data.timeline;
customRepoDescriptions = data.customRepoDescriptions;
customRepoUrls= data.customRepoUrls;
defaultRepoCategories = data.defaultRepoCategories;
startLoadingData();
});
function repoUrl(repo) {
return customRepoUrls[repo.name] || repo.html_url || repo.url ;
}
function repoDescription(repo) {
return customRepoDescriptions[repo.name] || repo.description;
}
function addRecentlyUpdatedRepo(repo) {
var $item = $("<li>");
var $name = $("<a>").attr("href", repo.html_url).text(repo.name + " ");
$item.append($("<span>").addClass("name").append($name));
var $time = $("<a>").attr("href", repo.html_url + "/commits").text(strftime("%h %e, %Y", repo.pushed_at));
$item.append($("<span>").addClass("time").append($time));
$item.append('<span class="bullet">⋅</span>');
var $watchers = $("<a>").attr("href", repo.html_url + "/watchers").text(repo.watchers + " watchers");
$item.append($("<span>").addClass("watchers").append($watchers));
$item.append('<span class="bullet">⋅</span>');
var $forks = $("<a>").attr("href", repo.html_url + "/network").text(repo.forks + " forks");
$item.append($("<span>").addClass("forks").append($forks));
$item.appendTo("#recently-updated-repos");
}
function addRepo(repo) {
var categories = new Array();
var formatedCategories = "item Nuxeo ";
if (repo.language) {
formatedCategories += repo.language + " ";
uniqueLanguages.pushUnique(repo.language);
}
if (defaultRepoCategories[repo.name]) {
categories = categories.concat(defaultRepoCategories[repo.name]);
}
$.each(categories, function (i, category) {
uniqueCategories.pushUnique(category);
formatedCategories += category + " ";
});
var $item = $("<div>").addClass(formatedCategories);
var $link = $("<a>").attr("href", repoUrl(repo)).appendTo($item);
$link.append($("<p>").text("name: " + repo.name).attr("class", "name"));
$link.append($("<p>").text("description: " + repoDescription(repo)));
$link.append($("<p>").text("categories: " + formatedCategories));
$link.append($("<p>").text("watchers: " + repo.watchers).attr("class", "watchers"));
$link.append($("<p>").text("owner: " + repo.owner.login));
$link.append($("<img>").attr("src",repo.owner.avatar_url));
$link.append($("<p>").text("pushed_at: " + repo.pushed_at).attr("class", "pushed_at"));
$item.appendTo("#container");
}
function addCommunityRepo(repo, repoCategories) {
var categories = new Array();
var formatedCategories = "item Community ";
if (repo.language) {
formatedCategories += repo.language + " ";
uniqueLanguages.pushUnique(repo.language);
}
if (repoCategories) {
categories = categories.concat(repoCategories);
}
$.each(categories, function (i, category) {
uniqueCategories.pushUnique(category);
formatedCategories += category + " ";
});
var $item = $("<div>").addClass(formatedCategories);
var $link = $("<a>").attr("href", repoUrl(repo)).appendTo($item);
$link.append($("<p>").text("name: " + repo.name).attr("class", "name"));
$link.append($("<p>").text("description: " + repoDescription(repo)));
$link.append($("<p>").text("categories: " + formatedCategories));
$link.append($("<p>").text("watchers: " + repo.watchers).attr("class", "watchers"));
$link.append($("<p>").text("pushed_at: " + repo.pushed_at).attr("class", "pushed_at"));
$item.appendTo("#container");
}
function addPersonalRepo(repo, repoCategories) {
var categories = new Array();
var formatedCategories = "item Personal ";
if (repo.language) {
formatedCategories += repo.language + " ";
uniqueLanguages.pushUnique(repo.language);
}
if (repoCategories) {
categories = categories.concat(repoCategories);
}
$.each(categories, function (i, category) {
uniqueCategories.pushUnique(category);
formatedCategories += category + " ";
});
var $item = $("<div>").addClass(formatedCategories);
var $link = $("<a>").attr("href", repoUrl(repo)).appendTo($item);
$link.append($("<p>").text("name: " + repo.name).attr("class", "name"));
$link.append($("<p>").text("description: " + repoDescription(repo)));
$link.append($("<p>").text("categories: " + formatedCategories));;
$link.append($("<p>").text("watchers: " + repo.watchers).attr("class", "watchers"));
$link.append($("<p>").text("pushed_at: " + repo.pushed_at).attr("class", "pushed_at"));
$item.appendTo("#container");
}
function formatRepoUrl(repo) {
return "http://github.com/api/v2/json/repos/show/"+
repo.owner +"/" + repo.projectName+"?callback=?";
}
function addSelector(value, containerId) {
var $label = $("<label>").attr("for", value).appendTo(containerId);
var $input = $("<input>").attr("type", "checkbox").attr("value", "."+value).attr("id", value).appendTo($label);
var $span = $("<span>").text(value).appendTo($label);
}
function startLoadingData() {
$.when(
$.each(communityRepos, function (i, repo) {
$.getJSON(formatRepoUrl(repo), function(result) {
addCommunityRepo(result.repository, repo.categories);
});
})
,
$.each(personalRepos, function (i, repo) {
$.getJSON(formatRepoUrl(repo), function(result) {
addPersonalRepo(result.repository, repo.categories);
});
})
,
$.getJSON("https://api.github.com/orgs/nuxeo/repos?callback=?", function (result) {
var repos = result.data;
$(function () {
// Convert pushed_at to Date.
$.each(repos, function (i, repo) {
repo.pushed_at = new Date(repo.pushed_at);
var weekHalfLife = 1.146 * Math.pow(10, -9);
var pushDelta = (new Date) - Date.parse(repo.pushed_at);
var createdDelta = (new Date) - Date.parse(repo.created_at);
var weightForPush = 1;
var weightForWatchers = 1.314 * Math.pow(10, 7);
repo.hotness = weightForPush * Math.pow(Math.E, -1 * weekHalfLife * pushDelta);
repo.hotness += weightForWatchers * repo.watchers / createdDelta;
});
// Sort by highest # of watchers.
/* repos.sort(function (a, b) {
if (a.hotness < b.hotness) return 1;
if (b.hotness < a.hotness) return -1;
return 0;
});*/
$.each(repos, function (i, repo) {
addRepo(repo);
});
// Sort by most-recently pushed to.
repos.sort(function (a, b) {
if (a.pushed_at < b.pushed_at) return 1;
if (b.pushed_at < a.pushed_at) return -1;
return 0;
});
$.each(repos.slice(0, 3), function (i, repo) {
addRecentlyUpdatedRepo(repo);
});
});
})
).done(function(a1, a2, a3) {
$.each(uniqueCategories, function (i, value) {
addSelector(value, "#categoriesSelector");
});
$.each(uniqueLanguages, function (i, value) {
addSelector(value, "#languagesSelector");
});
var sortData = {name : function ( $elem ) {
return $elem.find('.name').text();
},
watchers : function ( $elem ) {
return $elem.find('.watchers').text();
},
pushed_at : function ( $elem ) {
return $elem.find('.pushed_at').text();
}
};
var $container = $('#container');
var $filterDisplay = $('#filter-display');
$container.isotope({getSortData : sortData});
var filters = {};
$('#options').on( 'change', function( jQEvent ) {
var checkbox = jQEvent.target;
var $checkbox = $( checkbox );
var value = checkbox.value;
var isAll = $checkbox.hasClass('all');
var group = $checkbox.parents('.option-set').attr('data-group');
// create array for filter group, if not there yet
if ( !filters[ group ] ) {
filters[ group ] = [];
}
var index = $.inArray( checkbox.value, filters[ group ] );
if ( isAll ) {
delete filters[ group ];
if ( !checkbox.checked ) {
checkbox.checked = 'checked';
}
}
if ( checkbox.checked ) {
var selector = isAll ? 'input' : 'input.all';
$checkbox.siblings( selector ).removeAttr('checked');
if ( !isAll && index === -1 ) {
// add filter to group
filters[ group ].push( checkbox.value );
}
} else if ( !isAll ) {
// remove filter from group
filters[ group ].splice( index, 1 );
// if unchecked the last box, check the all
if ( !$checkbox.siblings('[checked]').length ) {
$checkbox.siblings('input.all').attr('checked', 'checked');
}
}
var i = 0;
var comboFilters = [];
var message = []
for ( var prop in filters ) {
message.push( filters[ prop ].join(' ') );
var filterGroup = filters[ prop ];
// skip to next filter group if it doesn't have any values
if ( !filterGroup.length ) {
continue;
}
if ( i === 0 ) {
// copy to new array
comboFilters = filterGroup.slice(0);
} else {
var filterSelectors = [];
// copy to fresh array
var groupCombo = comboFilters.slice(0); // [ A, B ]
// merge filter Groups
for (var k=0, len3 = filterGroup.length; k < len3; k++) {
for (var j=0, len2 = groupCombo.length; j < len2; j++) {
filterSelectors.push( groupCombo[j] + filterGroup[k] ); // [ 1, 2 ]
}
}
// apply filter selectors to combo filters for next group
comboFilters = filterSelectors
}
i++
}
$container.isotope({ filter: comboFilters.join(', ') ,
getSortData : sortData
});
$filterDisplay.text( comboFilters.join(', ') );
});
$('#sort-by a').click(function(){
var selectedLink = $('#sort-by a.highlight');
if (selectedLink) {
selectedLink.removeClass("highlight");
}
// get href attribute, minus the '#'
$(this).addClass("highlight");
var sortName = $(this).attr('href').slice(1);
$('#container').isotope({ sortBy : sortName });
return false;
});
});
}
})(jQuery);
</script>
<!-- End Document
================================================== -->
</body>
</html>