mirror of https://github.com/metafizzy/isotope
David DeSandro
14 years ago
2 changed files with 171 additions and 11 deletions
@ -1,23 +1,24 @@ |
|||||||
JS_ENGINE ?= `which node nodejs`
|
JS_ENGINE ?= `which node nodejs`
|
||||||
ISO = jquery.isotope.js
|
JS = jquery.isotope.js
|
||||||
ISO_MIN = jquery.isotope.min.js
|
JS_MIN = jquery.isotope.min.js
|
||||||
|
SITE = isotope-site
|
||||||
|
|
||||||
# minifies jquery.isotope.js
|
# minifies jquery.isotope.js
|
||||||
# requires NodeJS and global uglify-js
|
# requires NodeJS and global uglify-js
|
||||||
min: ${ISO} |
min: ${ISO} |
||||||
@@if test ! -z ${JS_ENGINE}; then \
|
@@if test ! -z ${JS_ENGINE}; then \
|
||||||
echo "Minifying" ${ISO}; \
|
echo "Minifying" ${JS}; \
|
||||||
uglifyjs ${ISO} > ${ISO_MIN}.tmp; \
|
uglifyjs ${JS} > ${JS_MIN}.tmp; \
|
||||||
echo ';' >> ${ISO_MIN}.tmp; \
|
echo ';' >> ${JS_MIN}.tmp; \
|
||||||
sed 's/\*\//&§/; y/§/\n/;' ${ISO_MIN}.tmp > ${ISO_MIN}; \
|
sed 's/\*\//&§/g; y/§/\n/;' ${JS_MIN}.tmp > ${JS_MIN}; \
|
||||||
rm ${ISO_MIN}.tmp; \
|
rm ${JS_MIN}.tmp; \
|
||||||
else \
|
else \
|
||||||
echo "NodeJS required for minification."; \
|
echo "NodeJS required for minification."; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# creates zip file of site
|
# creates zip file of site
|
||||||
zip: _site |
zip: _site |
||||||
mkdir isotope-site
|
mkdir ${SITE}
|
||||||
cp -r _site/ isotope-site
|
cp -r _site/ ${SITE}
|
||||||
zip -r ~/Desktop/isotope-site.zip isotope-site/
|
zip -r ~/Desktop/${SITE}.zip ${SITE}/
|
||||||
rm -rf isotope-site
|
rm -rf ${SITE}
|
@ -0,0 +1,159 @@ |
|||||||
|
--- |
||||||
|
title: Category rows |
||||||
|
layout: demo |
||||||
|
category: demos |
||||||
|
related: layouts |
||||||
|
--- |
||||||
|
|
||||||
|
<section id="copy"> |
||||||
|
<p>This demo uses a custom layout mode that arranges elements into columns based on an attribute.</p> |
||||||
|
</section> |
||||||
|
|
||||||
|
<section id="options" class="clearfix"> |
||||||
|
|
||||||
|
<h3>Filters</h3> |
||||||
|
|
||||||
|
<ul id="filters" class="option-set floated clearfix"> |
||||||
|
<li><a href="#show-all" class="selected">show all</a></li> |
||||||
|
<li><a href="#metalloid">metalloid</a></li> |
||||||
|
<li><a href="#metal">metal</a></li> |
||||||
|
<li><a href="#alkali">alkali</a></li> |
||||||
|
<li><a href="#alkaline-earth">alkaline-earth</a></li> |
||||||
|
<li><a href="#inner-transition">inner-transition</a></li> |
||||||
|
<li><a href="#lanthanoid">lanthanoid</a></li> |
||||||
|
<li><a href="#actinoid">actinoid</a></li> |
||||||
|
<li><a href="#transition">transition</a></li> |
||||||
|
<li><a href="#post-transition">post-transition</a></li> |
||||||
|
<li><a href="#nonmetal">nonmetal</a></li> |
||||||
|
<li><a href="#other">other</a></li> |
||||||
|
<li><a href="#halogen">halogen</a></li> |
||||||
|
<li><a href="#noble-gas">noble-gas</a></li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<h3>Etc</h3> |
||||||
|
|
||||||
|
<ul id="etc" class="floated clearfix"> |
||||||
|
<li id="insert"><a href="#insert">Insert new elements</a></li> |
||||||
|
</ul> |
||||||
|
</section> <!-- #options --> |
||||||
|
|
||||||
|
<div id="container" class="clearfix"> |
||||||
|
{% for elem_number in site.random_order | limit:60 %} |
||||||
|
{% assign element = site.elements[elem_number] %} |
||||||
|
{% include element-partial.html %} |
||||||
|
{% endfor %} |
||||||
|
</div> |
||||||
|
|
||||||
|
<script src="../{{ site.jquery_js }}"></script> |
||||||
|
<script src="../{{ site.isotope_js }}"></script> |
||||||
|
<script src="../js/fake-element.js"></script> |
||||||
|
<script> |
||||||
|
|
||||||
|
// categoryRows custom layout mode |
||||||
|
$.extend( $.Isotope.prototype, { |
||||||
|
|
||||||
|
_categoryRowsReset : function() { |
||||||
|
// reset namespace properties |
||||||
|
this.categoryRows = { |
||||||
|
rowIndex : 0, |
||||||
|
// the x & y position in each row |
||||||
|
position : { |
||||||
|
x : this.posLeft, |
||||||
|
y : this.posTop |
||||||
|
} |
||||||
|
}; |
||||||
|
this._getSegments('categoryRows', true); |
||||||
|
|
||||||
|
return this; |
||||||
|
}, |
||||||
|
|
||||||
|
_categoryRowsLayout : function( $elems ) { |
||||||
|
var instance = this, |
||||||
|
// namespaced properties |
||||||
|
position = this.categoryRows.position, |
||||||
|
sortBy = this.options.sortBy, |
||||||
|
containerWidth = this.element.width(), |
||||||
|
currentRowName, nextX; |
||||||
|
$elems.each(function(){ |
||||||
|
var $this = $(this), |
||||||
|
// get row based on function passed in options |
||||||
|
rowName = $this.data('isotope-sort-data')[ sortBy ], |
||||||
|
atomWidth = $this.outerWidth(true); |
||||||
|
|
||||||
|
// for new row |
||||||
|
if ( !currentRowName ) { |
||||||
|
currentRowName = rowName; |
||||||
|
} else if ( currentRowName !== rowName ) { |
||||||
|
instance._categoryRowsNewRow(); |
||||||
|
currentRowName = rowName; |
||||||
|
} |
||||||
|
|
||||||
|
// if item doesn't fit on row |
||||||
|
nextX = position.x + atomWidth; |
||||||
|
if ( nextX >= containerWidth ) { |
||||||
|
instance._categoryRowsNewRow(); |
||||||
|
} |
||||||
|
|
||||||
|
instance._pushPosition( $this, position.x, position.y ); |
||||||
|
|
||||||
|
position.x += atomWidth; |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
return this; |
||||||
|
}, |
||||||
|
|
||||||
|
// convience method |
||||||
|
_categoryRowsNewRow : function() { |
||||||
|
var props = this.categoryRows; |
||||||
|
props.position.x = this.posLeft; |
||||||
|
props.position.y += props.rowHeight; |
||||||
|
}, |
||||||
|
|
||||||
|
_categoryRowsGetContainerSize : function() { |
||||||
|
return { height: this.categoryRows.position.y + this.categoryRows.rowHeight }; |
||||||
|
}, |
||||||
|
|
||||||
|
_categoryRowsResize : function() { |
||||||
|
this.reLayout(); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
var $container = $('#container'); |
||||||
|
|
||||||
|
$('#filters').find('a').click(function(){ |
||||||
|
// get href attribute, minus the #, plus a . to make it a class |
||||||
|
var filterName = '.' + $(this).attr('href').slice(1); |
||||||
|
filterName = filterName === '.show-all' ? '*' : filterName; |
||||||
|
$container.isotope({ filter: filterName }) |
||||||
|
return false; |
||||||
|
}); |
||||||
|
|
||||||
|
{% include add-buttons.js %} |
||||||
|
|
||||||
|
{% include option-buttons.js %} |
||||||
|
|
||||||
|
|
||||||
|
$(function(){ |
||||||
|
|
||||||
|
$container.isotope({ |
||||||
|
itemSelector : '.element', |
||||||
|
layoutMode : 'categoryRows', |
||||||
|
categoryRows : { |
||||||
|
rowHeight : 120 |
||||||
|
}, |
||||||
|
getSortData : { |
||||||
|
category : function( $elem ) { |
||||||
|
return $elem.attr('data-category'); |
||||||
|
} |
||||||
|
}, |
||||||
|
sortBy: 'category', |
||||||
|
animationEngine : $.browser.opera ? 'jquery' : 'best-available' |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
}); |
||||||
|
</script> |
||||||
|
|
||||||
|
|
Loading…
Reference in new issue