Browse Source

Merge branch 'master' into gh-pages

v1
David DeSandro 14 years ago
parent
commit
0ece9292cb
  1. 4
      _layouts/elements.html
  2. 3
      _posts/demos/2010-12-29-layout-modes.html
  3. 3
      _posts/demos/2010-12-30-filtering.html
  4. 3
      _posts/demos/2010-12-30-sorting.html
  5. 4
      _posts/demos/2010-12-31-relayout.html
  6. 3
      _posts/demos/2011-01-02-adding-items.html
  7. 3
      _posts/demos/2011-03-29-combination-filters.html
  8. 160
      _posts/tests/2011-05-24-elements-complete-test.html
  9. 130
      jquery.isotope.js
  10. 4
      jquery.isotope.min.js

4
_layouts/elements.html

@ -54,6 +54,7 @@
<script src="../{{ site.isotope_js }}"></script>
<script src="../js/fake-element.js"></script>
<script>
$(function(){
var $container = $('#container');
@ -92,9 +93,6 @@
{% include option-buttons.js %}
$(function(){
$container.isotope({
itemSelector : '.element',
// layoutMode : 'fitRows',

3
_posts/demos/2010-12-29-layout-modes.html

@ -25,6 +25,7 @@ related: layouts
<script src="../{{ site.jquery_js }}"></script>
<script src="../{{ site.isotope_js }}"></script>
<script>
$(function(){
var $container = $('#container');
@ -32,8 +33,6 @@ related: layouts
{% include option-buttons.js %}
$(function(){
$container.isotope({
itemSelector : '.element',
masonry : {

3
_posts/demos/2010-12-30-filtering.html

@ -39,6 +39,7 @@ related: filtering
<script src="../{{ site.jquery_js }}"></script>
<script src="../{{ site.isotope_js }}"></script>
<script>
$(function(){
var $container = $('#container');
@ -51,8 +52,6 @@ related: filtering
{% include option-buttons.js %}
$(function(){
$container.isotope({
itemSelector : '.element'
});

3
_posts/demos/2010-12-30-sorting.html

@ -26,6 +26,7 @@ related: sorting
<script src="../{{ site.jquery_js }}"></script>
<script src="../{{ site.isotope_js }}"></script>
<script>
$(function(){
var $container = $('#container');
@ -33,8 +34,6 @@ related: sorting
{% include option-buttons.js %}
$(function(){
$container.isotope({
itemSelector : '.element',
getSortData : {

4
_posts/demos/2010-12-31-relayout.html

@ -25,6 +25,7 @@ related: methods
<script src="../{{ site.jquery_js }}"></script>
<script src="../{{ site.isotope_js }}"></script>
<script>
$(function(){
var $container = $('#container');
@ -42,9 +43,6 @@ related: methods
$container.isotope('reLayout');
});
$(function(){
$container.isotope({
itemSelector: '.element',
masonry : {

3
_posts/demos/2011-01-02-adding-items.html

@ -31,6 +31,7 @@ related: methods
<script src="../{{ site.isotope_js }}"></script>
<script src="../js/fake-element.js"></script>
<script>
$(function(){
var $container = $('#container');
@ -46,8 +47,6 @@ related: methods
return false;
});
$(function(){
$container.isotope({
itemSelector : '.element',
getSortData : {

3
_posts/demos/2011-03-29-combination-filters.html

@ -57,6 +57,7 @@ schema:
<script src="../{{ site.jquery_js }}"></script>
<script src="../{{ site.isotope_js }}"></script>
<script>
$(function(){
var $container = $('#container'),
filters = {};
@ -81,8 +82,6 @@ schema:
{% include option-buttons.js %}
$(function(){
$container.isotope({
itemSelector : '.color-shape',
masonry: {

160
_posts/tests/2011-05-24-elements-complete-test.html

@ -0,0 +1,160 @@
---
title: elements complete test
layout: demo
category: tests
---
<section id="copy">
<p>Isotope&rsquo;s capabilities are designed to be used together cohesively. You can do it all &mdash; filter, sort, change layout modes, add items &mdash; and Isotope will handle it with ease.</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>
{% include sort-buttons.html %}
{% include layout-options.html %}
<h3>Etc</h3>
<ul id="etc" class="floated clearfix">
<li id="toggle-sizes"><a href="#toggle-sizes">Toggle variable sizes</a></li>
<li id="insert"><a href="#insert">Insert new elements</a></li>
<li id="append"><a href='#append'>Append new elements</a></li>
<!-- <li id="shuffle"><a href='#shuffle'>Shuffle</a></li> -->
</ul>
</section> <!-- #options -->
<div id="container" class="clickable clearfix">
{% for elem_number in site.random_order %}
{% 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>
var $container = $('#container');
$('#filters').find('a').click(function(){
console.time('filter');
// 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 })
console.timeEnd('filter');
return false;
});
// sorting
$('#sort a').click(function(){
console.time('sort');
// get href attribute, minus the #
var $this = $(this),
sortName = $this.attr('href').slice(1),
asc = $this.parents('.sort').hasClass('asc');
$container.isotope({
sortBy : sortName,
sortAscending : asc
});
console.timeEnd('sort');
return false;
});
// change size of clicked element
$container.find('.element').live('click', function(){
$(this).toggleClass('large');
$container.isotope('reLayout');
});
// toggle variable sizes of all elements
$('#toggle-sizes').find('a').click(function(){
$container
.toggleClass('variable-sizes')
.isotope('reLayout');
return false;
});
{% include layout-change.js %}
{% include add-buttons.js %}
$('#shuffle a').click(function(){
$container.isotope('shuffle');
return false;
});
{% include option-buttons.js %}
$(function(){
console.time('init');
$container.isotope({
itemSelector : '.element',
// layoutMode : 'fitRows',
masonry : {
columnWidth : 120
},
masonryHorizontal : {
rowHeight: 120
},
cellsByRow : {
columnWidth : 240,
rowHeight : 240
},
cellsByColumn : {
columnWidth : 240,
rowHeight : 240
},
animationEngine : $.browser.opera ? 'jquery' : 'best-available',
// animationEngine : 'jquery',
getSortData : {
symbol : function( $elem ) {
return $elem.attr('data-symbol');
},
category : function( $elem ) {
return $elem.attr('data-category');
},
number : function( $elem ) {
return parseInt( $elem.find('.number').text(), 10 );
},
weight : function( $elem ) {
return parseFloat( $elem.find('.weight').text().replace( /[\(\)]/g, '') );
},
name : function ( $elem ) {
return $elem.find('.name').text();
}
}
});
console.timeEnd('init');
});
</script>

130
jquery.isotope.js

@ -1,5 +1,5 @@
/**
* Isotope v1.3.110524
* Isotope v1.3.110525
* An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co
*
@ -179,9 +179,8 @@
;
var setIsoTransform = function ( elem, name, value ) {
var $elem = $(elem),
// unpack current transform data
data = $elem.data('isoTransform') || {},
var data = $.data( elem, 'isoTransform' ) || {},
newData = {},
fnName,
transformObj = {},
@ -206,7 +205,7 @@
valueFns = translateFn + scaleFn;
// set data back in elem
$elem.data( 'isoTransform', data );
$.data( elem, 'isoTransform', data );
// set name to vendor specific property
elem.style[ transformProp ] = valueFns;
@ -438,13 +437,12 @@
},
option: function( key, value ){
option : function( opts ){
// change options AFTER initialization:
// signature: $('#foo').bar({ cool:false });
if ( $.isPlainObject( key ) ){
this.options = $.extend(true, this.options, key);
var optionName;
for ( optionName in key ) {
if ( $.isPlainObject( opts ) ){
this.options = $.extend( true, this.options, opts );
for ( var optionName in opts ) {
this._updateOption( optionName );
}
}
@ -535,8 +533,8 @@
for ( var key in getSortData ) {
sortData[ key ] = getSortData[ key ]( $this, instance );
}
// apply sort data to $element
$this.data( 'isotope-sort-data', sortData );
// apply sort data to element
$.data( this, 'isotope-sort-data', sortData );
if ( isIncrementingElemCount ) {
instance.elemCount ++;
}
@ -564,7 +562,7 @@
},
_getSorter : function( elem, sortBy ) {
return $(elem).data('isotope-sort-data')[ sortBy ];
return $.data( elem, 'isotope-sort-data' )[ sortBy ];
},
// ====================== Layout Helpers ======================
@ -765,19 +763,18 @@
size = isRows ? 'height' : 'width',
UCSize = isRows ? 'Height' : 'Width',
segmentsName = isRows ? 'rows' : 'cols',
containerSize = this.element[ size ](),
segments,
segmentSize;
this[ size ] = this.element[ size ]();
// i.e. options.masonry && options.masonry.columnWidth
segmentSize = this.options[ namespace ] && this.options[ namespace ][ measure ] ||
// or use the size of the first item
this.$filteredAtoms[ 'outer' + UCSize ](true) ||
// if there's no items, use size of container
this[ size ];
containerSize;
segments = Math.floor( this[ size ] / segmentSize );
segments = Math.floor( containerSize / segmentSize );
segments = Math.max( segments, 1 );
// i.e. this.masonry.cols = ....
@ -812,20 +809,21 @@
},
_masonryLayout : function( $elems ) {
var instance = this;
var instance = this,
props = instance.masonry;
$elems.each(function(){
var $this = $(this),
//how many columns does this brick span
colSpan = Math.ceil( $this.outerWidth(true) / instance.masonry.columnWidth );
colSpan = Math.min( colSpan, instance.masonry.cols );
colSpan = Math.ceil( $this.outerWidth(true) / props.columnWidth );
colSpan = Math.min( colSpan, props.cols );
if ( colSpan === 1 ) {
// if brick spans only one column, just like singleMode
instance._masonryPlaceBrick( $this, instance.masonry.colYs );
instance._masonryPlaceBrick( $this, props.colYs );
} else {
// brick spans more than one column
// how many different places could this brick fit horizontally
var groupCount = instance.masonry.cols + 1 - colSpan,
var groupCount = props.cols + 1 - colSpan,
groupY = [],
groupColY,
i;
@ -833,7 +831,7 @@
// for each group potential horizontal position
for ( i=0; i < groupCount; i++ ) {
// make an array of colY values for that one group
groupColY = instance.masonry.colYs.slice( i, i+colSpan );
groupColY = props.colYs.slice( i, i+colSpan );
// and get the max value of the array
groupY[i] = Math.max.apply( Math, groupColY );
}
@ -848,15 +846,13 @@
_masonryPlaceBrick : function( $brick, setY ) {
// get the minimum Y value from the columns
var minimumY = Math.min.apply( Math, setY ),
setHeight = minimumY + $brick.outerHeight(true),
i = setY.length,
shortCol = i,
setSpan = this.masonry.cols + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) {
shortCol = 0;
// Find index of short column, the first from the left
for (var i=0, len = setY.length; i < len; i++) {
if ( setY[i] === minimumY ) {
shortCol = i;
break;
}
}
@ -866,6 +862,8 @@
this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns
var setHeight = minimumY + $brick.outerHeight(true),
setSpan = this.masonry.cols + 1 - len;
for ( i=0; i < setSpan; i++ ) {
this.masonry.colYs[ shortCol + i ] = setHeight;
}
@ -892,8 +890,9 @@
},
_fitRowsLayout : function( $elems ) {
this.width = this.element.width();
var instance = this;
var instance = this,
containerWidth = this.element.width(),
props = this.fitRows;
$elems.each( function() {
var $this = $(this),
@ -901,19 +900,17 @@
atomH = $this.outerHeight(true),
x, y;
if ( instance.fitRows.x !== 0 && atomW + instance.fitRows.x > instance.width ) {
if ( props.x !== 0 && atomW + props.x > containerWidth ) {
// if this element cannot fit in the current row
instance.fitRows.x = 0;
instance.fitRows.y = instance.fitRows.height;
props.x = 0;
props.y = props.height;
}
// position the atom
x = instance.fitRows.x;
y = instance.fitRows.y;
instance._pushPosition( $this, x, y );
instance._pushPosition( $this, props.x, props.y );
instance.fitRows.height = Math.max( instance.fitRows.y + atomH, instance.fitRows.height );
instance.fitRows.x += atomW;
props.height = Math.max( props.y + atomH, props.height );
props.x += atomW;
});
},
@ -946,10 +943,8 @@
var $this = $(this),
col = props.index % props.cols,
row = ~~( props.index / props.cols ),
x = ( col + 0.5 ) * props.columnWidth -
$this.outerWidth(true) / 2,
y = ( row + 0.5 ) * props.rowHeight -
$this.outerHeight(true) / 2;
x = ( col + 0.5 ) * props.columnWidth - $this.outerWidth(true) / 2,
y = ( row + 0.5 ) * props.rowHeight - $this.outerHeight(true) / 2;
instance._pushPosition( $this, x, y );
props.index ++;
});
@ -1005,27 +1000,28 @@
},
_masonryHorizontalLayout : function( $elems ) {
var instance = this;
var instance = this,
props = instance.masonryHorizontal;
$elems.each(function(){
var $this = $(this),
//how many rows does this brick span
rowSpan = Math.ceil( $this.outerHeight(true) / instance.masonryHorizontal.rowHeight );
rowSpan = Math.min( rowSpan, instance.masonryHorizontal.rows );
rowSpan = Math.ceil( $this.outerHeight(true) / props.rowHeight );
rowSpan = Math.min( rowSpan, props.rows );
if ( rowSpan === 1 ) {
// if brick spans only one column, just like singleMode
instance._masonryHorizontalPlaceBrick( $this, instance.masonryHorizontal.rowXs );
instance._masonryHorizontalPlaceBrick( $this, props.rowXs );
} else {
// brick spans more than one row
// how many different places could this brick fit horizontally
var groupCount = instance.masonryHorizontal.rows + 1 - rowSpan,
var groupCount = props.rows + 1 - rowSpan,
groupX = [],
groupRowX, i;
// for each group potential horizontal position
for ( i=0; i < groupCount; i++ ) {
// make an array of colY values for that one group
groupRowX = instance.masonryHorizontal.rowXs.slice( i, i+rowSpan );
groupRowX = props.rowXs.slice( i, i+rowSpan );
// and get the max value of the array
groupX[i] = Math.max.apply( Math, groupRowX );
}
@ -1036,18 +1032,14 @@
},
_masonryHorizontalPlaceBrick : function( $brick, setX ) {
// here, `this` refers to a child element or "brick"
// get the minimum Y value from the columns
var minimumX = Math.min.apply( Math, setX ),
setWidth = minimumX + $brick.outerWidth(true),
i = setX.length,
smallRow = i,
setSpan = this.masonryHorizontal.rows + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) {
smallRow = 0;
// Find index of smallest row, the first from the top
for (var i=0, len = setX.length; i < len; i++) {
if ( setX[i] === minimumX ) {
smallRow = i;
break;
}
}
@ -1057,10 +1049,11 @@
this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns
var setWidth = minimumX + $brick.outerWidth(true),
setSpan = this.masonryHorizontal.rows + 1 - len;
for ( i=0; i < setSpan; i++ ) {
this.masonryHorizontal.rowXs[ smallRow + i ] = setWidth;
}
},
_masonryHorizontalGetContainerSize : function() {
@ -1084,27 +1077,26 @@
},
_fitColumnsLayout : function( $elems ) {
var instance = this;
this.height = this.element.height();
var instance = this,
containerHeight = this.element.height(),
props = this.fitColumns;
$elems.each( function() {
var $this = $(this),
atomW = $this.outerWidth(true),
atomH = $this.outerHeight(true),
x, y;
if ( instance.fitColumns.y !== 0 && atomH + instance.fitColumns.y > instance.height ) {
if ( props.y !== 0 && atomH + props.y > containerHeight ) {
// if this element cannot fit in the current column
instance.fitColumns.x = instance.fitColumns.width;
instance.fitColumns.y = 0;
props.x = props.width;
props.y = 0;
}
// position the atom
x = instance.fitColumns.x;
y = instance.fitColumns.y;
instance._pushPosition( $this, x, y );
instance._pushPosition( $this, props.x, props.y );
instance.fitColumns.width = Math.max( instance.fitColumns.x + atomW, instance.fitColumns.width );
instance.fitColumns.y += atomH;
props.width = Math.max( props.x + atomW, props.width );
props.y += atomH;
});
},
@ -1245,7 +1237,7 @@
var instance = $.data( this, 'isotope' );
if ( instance ) {
// apply options & init
instance.option( options || {} );
instance.option( options );
instance._init();
} else {
// initialize new instance

4
jquery.isotope.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save