mirror of https://github.com/metafizzy/isotope
David DeSandro
14 years ago
3 changed files with 151 additions and 25 deletions
@ -0,0 +1,94 @@
|
||||
--- |
||||
title: Combination filters |
||||
layout: demo |
||||
category: demos |
||||
related: filtering |
||||
schema: |
||||
- name: color |
||||
filters: [ red, blue, yellow ] |
||||
- name: size |
||||
filters: [ small, wide, tall, big ] |
||||
- name: shape |
||||
filters : [ round, square ] |
||||
--- |
||||
|
||||
<section id="copy"> |
||||
<p>Filters can be combined. In addition to filtering for just <code>.red</code> or <code>.tall</code>, you can pass in a filter selector of both: <code>.red.tall</code>.</p> |
||||
</section> |
||||
|
||||
<section id="options" class="clearfix combo-filters"> |
||||
|
||||
<h3>Filters</h3> |
||||
|
||||
{% for group in page.schema %} |
||||
<div class="option-combo {{ group.name }}"> |
||||
<h4>{{ group.name }}</h4> |
||||
<ul class="filter option-set floated clearfix "> |
||||
<li><a href="#filter-{{ group.name }}-any" data-filter="" data-group="{{ group.name }}" class="selected">any</a> |
||||
{% for filter in group.filters %} |
||||
<li><a href="#filter-{{ group.name }}-{{ filter }}" data-group="{{ group.name }}" data-filter=".{{ filter }}">{{ filter }}</a> |
||||
{% endfor %} |
||||
</ul> |
||||
</div> |
||||
{% endfor %} |
||||
|
||||
</section> <!-- #options --> |
||||
|
||||
<div id="container" class="clearfix"> |
||||
{% for size in page.schema[1].filters %} |
||||
{% for shape in page.schema[2].filters %} |
||||
{% for color in page.schema[0].filters %} |
||||
<div class="color-shape {{ size }} {{ shape }} {{ color }}"></div> |
||||
{% endfor %} |
||||
{% endfor %} |
||||
{% endfor %} |
||||
|
||||
|
||||
{% for color in page.schema[0].filters %} |
||||
{% for shape in page.schema[2].filters %} |
||||
{% for size in page.schema[1].filters %} |
||||
<div class="color-shape {{ size }} {{ shape }} {{ color }}"></div> |
||||
{% endfor %} |
||||
{% endfor %} |
||||
{% endfor %} |
||||
|
||||
</div> <!-- #container --> |
||||
|
||||
<script src="../{{ site.jquery_js }}"></script> |
||||
<script src="../{{ site.isotope_js }}"></script> |
||||
<script> |
||||
|
||||
var $container = $('#container'), |
||||
filters = {}; |
||||
|
||||
// filter buttons |
||||
$('.filter a').click(function(){ |
||||
var $this = $(this), |
||||
isoFilters = [], |
||||
prop, selector; |
||||
// store filter value in object |
||||
// i.e. filters.color = 'red' |
||||
filters[ $this.data('group') ] = $this.data('filter'); |
||||
|
||||
for ( prop in filters ) { |
||||
isoFilters.push( filters[ prop ] ) |
||||
} |
||||
selector = isoFilters.join(''); |
||||
$container.isotope({ filter: selector }); |
||||
|
||||
return false; |
||||
}); |
||||
|
||||
{% include option-buttons.js %} |
||||
|
||||
$(function(){ |
||||
|
||||
$container.isotope({ |
||||
itemSelector : '.color-shape', |
||||
masonry: { |
||||
columnWidth: 80 |
||||
} |
||||
}); |
||||
|
||||
}); |
||||
</script> |
Loading…
Reference in new issue