Skip to content

Commit d00a38c

Browse files
committed
feat(plugins): enable plugin filtering by tag
1 parent 9c99d64 commit d00a38c

File tree

4 files changed

+50
-327
lines changed

4 files changed

+50
-327
lines changed

_sass/_main.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,18 @@ body.plugins .content #ptags .tag.active span.reset:hover {
13101310
background-color: #faf4e8;
13111311
color: #30759c;
13121312
}
1313+
body.plugins .content #plugins article {
1314+
transition: transform 500ms, position 500ms 500ms;
1315+
transform: scale(1);
1316+
position: static;
1317+
1318+
&.hidden {
1319+
transform: scale(0);
1320+
position: absolute;
1321+
}
1322+
1323+
}
1324+
13131325
body.plugin .banner {
13141326
position: fixed;
13151327
}

js/jquery.quicksand.js

Lines changed: 0 additions & 307 deletions
This file was deleted.

js/plugins.js

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
11
$(function () {
22

3-
var current = 'all';
4-
function doSwitch (which) {
5-
if (which == current) return;
6-
current = which;
3+
var $allPluginsLinkElement = $('#all');
4+
var current = $('#all');
5+
var $pluginElement = $('.plug_list_scratch');
6+
var $allPlugins = $('#plugins article');
7+
function doSwitch ($linkElement) {
8+
if ($linkElement[0] == current) return;
9+
current = $linkElement[0];
710

811
$('html,body').animate({
912
scrollTop: 0
1013
});
1114

12-
var $plugins = $('.plug_list.' + which + ' article');
13-
$('#ptags > .tag').removeClass('active');
14-
$('#ptags > .tag > #' + which).parent('.tag').addClass('active');
15-
$('.plug_list_scratch')
16-
.quicksand($plugins, {
17-
attribute: 'id'
15+
var $plugins;
16+
17+
$('#ptags > .tag.active').removeClass('active');
18+
$allPlugins.removeClass('hidden');
19+
if ($linkElement[0] === $allPluginsLinkElement[0]) {
20+
$plugins = $();
21+
} else {
22+
var keywords = $linkElement.data('keywords');
23+
$plugins = $allPlugins.filter(function (index, element) {
24+
elementKeywords = $(element).data('keywords');
25+
if (!elementKeywords || !elementKeywords.length) return true;
26+
for (var i in keywords) {
27+
if (elementKeywords.indexOf(keywords[i]) !== -1) {
28+
return false;
29+
}
30+
}
31+
return true;
1832
});
33+
}
34+
$plugins.addClass('hidden');
35+
$linkElement.parent('.tag').addClass('active');
1936
}
2037

21-
$('body.plugins #ptags > .tag > .which').click(function (e) {
22-
e.preventDefault();
23-
var which = $(this).attr('id');
24-
doSwitch(which);
38+
$('#ptags').on('click', '.tag > .which', function (event) {
39+
event.preventDefault();
40+
doSwitch($(this));
2541
});
2642

27-
$('body.plugins #ptags > .tag > span.reset').click(function (e) {
28-
e.preventDefault();
43+
$('#ptags').on('click', '.tag > span.reset', function (event) {
44+
event.preventDefault();
2945
console.log('reset');
30-
doSwitch('all');
46+
doSwitch($allPluginsLinkElement);
3147
});
3248

3349
});

0 commit comments

Comments
 (0)