Browse Source

Awesome support for filtering

pull/14/head
desandro 15 years ago
parent
commit
b2d6b8337a
  1. 21
      docs/filtering.html
  2. 32
      jquery.mercutio.js

21
docs/filtering.html

@ -319,7 +319,7 @@
$wall.mercutio({ $wall.mercutio({
columnWidth: 100, columnWidth: 100,
// only apply mercutio layout to visible elements // only apply mercutio layout to visible elements
itemSelector: '.box:not(.invis)', selector: '.box',
animate: true, animate: true,
animationOptions: { animationOptions: {
duration: speed, duration: speed,
@ -328,21 +328,10 @@
}); });
$('#filtering-nav a').click(function(){ $('#filtering-nav a').click(function(){
var colorClass = '.' + $(this).attr('class'); console.log('click')
var className = $(this).attr('class'),
if(colorClass=='.all') { filterSelector = className === 'all' ? '*' : '.' + className;
// show all hidden boxes $wall.mercutio({ filter: filterSelector });
$wall.children('.invis')
.toggleClass('invis').fadeIn(speed);
} else {
// hide visible boxes
$wall.children().not(colorClass).not('.invis')
.toggleClass('invis').fadeOut(speed);
// show hidden boxes
$wall.children(colorClass+'.invis')
.toggleClass('invis').fadeIn(speed);
}
$wall.mercutio();
return false; return false;
}); });

32
jquery.mercutio.js

@ -43,19 +43,15 @@
return fn ? this.bind( "smartresize", fn ) : this.trigger( "smartresize", ["execAsap"] ); return fn ? this.bind( "smartresize", fn ) : this.trigger( "smartresize", ["execAsap"] );
}; };
/*
$cards.all // ========================= mercutio ===============================
$cards.filtered
$cards.sorted
*/
var mercutioMethods = { var mercutioMethods = {
filter : function() { filter : function( $cards ) {
var props = this.data('mercutio'), var props = this.data('mercutio'),
filter = props.opts.filter, filter = props.opts.filter === '' ? '*' : props.opts.filter;
$cards = props.$cards.all;
if ( !filter ) { if ( !filter ) {
props.$cards.filtered = $cards; props.$cards.filtered = $cards;
@ -68,16 +64,17 @@
props.$cards.filtered = $cards.filter( filter ); props.$cards.filtered = $cards.filter( filter );
if ( filter === '*' ) { if ( filter !== '*' ) {
// $visibleCards = this;
} else {
$cardsToShow = $hiddenCards.filter( filter ); $cardsToShow = $hiddenCards.filter( filter );
$cardsToHide = $visibleCards.not( filter );
var $cardsToHide = $visibleCards.not( filter ).toggleClass( hiddenClass );
$cardsToHide.addClass( hiddenClass );
props.styleQueue.push({ $el: $cardsToHide, style: props.opts.hiddenStyle }); props.styleQueue.push({ $el: $cardsToHide, style: props.opts.hiddenStyle });
} }
props.styleQueue.push({ $el: $cardsToShow, style: props.opts.visibleStyle }); props.styleQueue.push({ $el: $cardsToShow, style: props.opts.visibleStyle });
$cardsToShow.removeClass( hiddenClass );
} }
return this; return this;
@ -261,7 +258,7 @@
// need to get cards // need to get cards
props.$cards.all = props.opts.selector ? props.$cards.all = props.opts.selector ?
this.find( props.opts.selector ) : this.find( props.opts.selector ) :
this.children; this.children();
props.colW = props.opts.columnWidth || props.$cards.all.outerWidth(true); props.colW = props.opts.columnWidth || props.$cards.all.outerWidth(true);
@ -321,7 +318,7 @@
var colYs = $this.mercutio( 'resetColYs', props ); var colYs = $this.mercutio( 'resetColYs', props );
$this $this
.mercutio( 'filter' ) .mercutio( 'filter', props.$cards.all )
.mercutio( 'layout', props.$cards.filtered, colYs ); .mercutio( 'layout', props.$cards.filtered, colYs );
@ -371,9 +368,10 @@
}, },
visibleStyle : { visibleStyle : {
opacity : 1 opacity : 1
},
animationOptions: {
queue: false
} }
// animate: false,
// animationOptions: {}
}; };
})(jQuery); })(jQuery);
Loading…
Cancel
Save