Skip to content

Commit

Permalink
feat(plugins): enable plugin filtering by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Feb 18, 2016
1 parent 9c99d64 commit d00a38c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 327 deletions.
12 changes: 12 additions & 0 deletions _sass/_main.scss
Expand Up @@ -1310,6 +1310,18 @@ body.plugins .content #ptags .tag.active span.reset:hover {
background-color: #faf4e8;
color: #30759c;
}
body.plugins .content #plugins article {
transition: transform 500ms, position 500ms 500ms;
transform: scale(1);
position: static;

&.hidden {
transform: scale(0);
position: absolute;
}

}

body.plugin .banner {
position: fixed;
}
Expand Down
307 changes: 0 additions & 307 deletions js/jquery.quicksand.js

This file was deleted.

50 changes: 33 additions & 17 deletions js/plugins.js
@@ -1,33 +1,49 @@
$(function () {

var current = 'all';
function doSwitch (which) {
if (which == current) return;
current = which;
var $allPluginsLinkElement = $('#all');
var current = $('#all');
var $pluginElement = $('.plug_list_scratch');
var $allPlugins = $('#plugins article');
function doSwitch ($linkElement) {
if ($linkElement[0] == current) return;
current = $linkElement[0];

$('html,body').animate({
scrollTop: 0
});

var $plugins = $('.plug_list.' + which + ' article');
$('#ptags > .tag').removeClass('active');
$('#ptags > .tag > #' + which).parent('.tag').addClass('active');
$('.plug_list_scratch')
.quicksand($plugins, {
attribute: 'id'
var $plugins;

$('#ptags > .tag.active').removeClass('active');
$allPlugins.removeClass('hidden');
if ($linkElement[0] === $allPluginsLinkElement[0]) {
$plugins = $();
} else {
var keywords = $linkElement.data('keywords');
$plugins = $allPlugins.filter(function (index, element) {
elementKeywords = $(element).data('keywords');
if (!elementKeywords || !elementKeywords.length) return true;
for (var i in keywords) {
if (elementKeywords.indexOf(keywords[i]) !== -1) {
return false;
}
}
return true;
});
}
$plugins.addClass('hidden');
$linkElement.parent('.tag').addClass('active');
}

$('body.plugins #ptags > .tag > .which').click(function (e) {
e.preventDefault();
var which = $(this).attr('id');
doSwitch(which);
$('#ptags').on('click', '.tag > .which', function (event) {
event.preventDefault();
doSwitch($(this));
});

$('body.plugins #ptags > .tag > span.reset').click(function (e) {
e.preventDefault();
$('#ptags').on('click', '.tag > span.reset', function (event) {
event.preventDefault();
console.log('reset');
doSwitch('all');
doSwitch($allPluginsLinkElement);
});

});

0 comments on commit d00a38c

Please sign in to comment.