mirror of
https://github.com/aljazceru/cryptoanarchywiki.github.io.git
synced 2025-12-17 05:04:21 +01:00
41 lines
945 B
JavaScript
41 lines
945 B
JavaScript
(function($){
|
|
$(document).ready(function(){
|
|
$(document).on('click','.tag-filter',function(){
|
|
var $this = $(this);
|
|
|
|
$('span.tag-filter').removeClass("active");
|
|
$this.addClass("active");
|
|
|
|
|
|
$('.tag-group').children().each(function(){
|
|
if( $(this).data('tag') == $this.data('tag')){
|
|
$(this).addClass("active");
|
|
}
|
|
});
|
|
|
|
if( $(this).hasClass('all'))
|
|
$('.project-item').showAll();
|
|
else
|
|
$('.project-item').filterTags( $(this).data('tag') );
|
|
});
|
|
});
|
|
|
|
$.fn.extend({
|
|
filterTags: function(tagName) {
|
|
this.removeClass('not-show');
|
|
return this.each(function() {
|
|
var itemTagArray = JSON.parse( $(this).attr('data-tags') );
|
|
if($.inArray(tagName, itemTagArray) === -1){
|
|
$(this).addClass('not-show');
|
|
}
|
|
});
|
|
},
|
|
showAll: function(){
|
|
return this.each(function() {
|
|
if($(this).hasClass('not-show')){
|
|
$(this).removeClass('not-show');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
})(jQuery) |