Browse Source

src & docs : officialize shuffle method; add random sort order

pull/96/head
David DeSandro 14 years ago
parent
commit
ba4660655e
  1. 5
      _includes/elements-demo-foot.html
  2. 4
      _includes/elements-demo-head.html
  3. 3
      _includes/sort-buttons.html
  4. 1
      _posts/demos/2011-06-13-hash-history.html
  5. 11
      _posts/docs/2010-12-04-methods.mdown
  6. 5
      _posts/docs/2010-12-07-sorting.mdown
  7. 32
      jquery.isotope.js
  8. 4
      jquery.isotope.min.js

5
_includes/elements-demo-foot.html

@ -51,12 +51,13 @@
{% include add-buttons.js %}
var $sortBy = $('#sort-by');
$('#shuffle a').click(function(){
$container.isotope('shuffle');
$sortBy.find('.selected').removeClass('selected');
$sortBy.find('[data-option-value="random"]').addClass('selected');
return false;
});
});

4
_includes/elements-demo-head.html

@ -13,10 +13,10 @@
<h3>Etc</h3>
<ul id="etc" class="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> -->
<li id="shuffle"><a href='#shuffle'>Shuffle</a></li>
</ul>
</section> <!-- #options -->

3
_includes/sort-buttons.html

@ -1,13 +1,14 @@
<h3>Sort</h3>
<ul id="sort" class="sort option-set clearfix" data-option-key="sortBy">
<ul id="sort-by" class="option-set clearfix" data-option-key="sortBy">
<li><a href="#sortBy=original-order" data-option-value="original-order" class="selected" data>original-order</a></li>
<li><a href="#sortBy=name" data-option-value="name">name</a></li>
<li><a href="#sortBy=symbol" data-option-value="symbol">symbol</a></li>
<li><a href="#sortBy=number" data-option-value="number">number</a></li>
<li><a href="#sortBy=weight" data-option-value="weight">weight</a></li>
<li><a href="#sortBy=category" data-option-value="category">category</a></li>
<li><a href="#sortBy=random" data-option-value="random">random</a></li>
</ul>
<h3>Sort direction</h3>

1
_posts/demos/2011-06-13-hash-history.html

@ -33,6 +33,7 @@ category: demos
<li><a href="#sortBy=number">number</a></li>
<li><a href="#sortBy=weight">weight</a></li>
<li><a href="#sortBy=category">category</a></li>
<li><a href="#sortBy=random">random</a></li>
</ul>
<h3>Sort direction</h3>

11
_posts/docs/2010-12-04-methods.mdown

@ -13,6 +13,7 @@ toc:
- { title: reLayout, anchor: relayout }
- { title: reloadItems, anchor: reloaditems }
- { title: remove, anchor: remove }
- { title: shuffle, anchor: shuffle }
- { title: updateSortData, anchor: updatesortdata }
---
@ -135,6 +136,16 @@ Re-collects all item elements in their current order in the DOM. Useful for pre
Removes specified item elements from Isotope widget and the DOM.
## shuffle
{% highlight javascript %}
.isotope( 'shuffle' )
{% endhighlight %}
Shuffles order of items. Sets [`sortBy` option](options.html#sortby) to [`'random'`](sorting.html#sortby_option).
## updateSortData
{% highlight javascript %}

5
_posts/docs/2010-12-07-sorting.mdown

@ -121,7 +121,10 @@ $('#container').isotope({ sortBy : 'symbol' });
{% endhighlight %}
There is an additional sorting data built in to Isotope `'original-order'`. Sorting with `'original-order'` will use the original order of the item elements to arrange them in the layout.
There are two additional sorting data methods built in to Isotope.
+ `'original-order'` will use the original order of the item elements to arrange them in the layout.
+ `'random'` is a random order.
## sortAscending option

32
jquery.isotope.js

@ -1,5 +1,5 @@
/**
* Isotope v1.3.110623
* Isotope v1.4.110629
* An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co
*
@ -378,6 +378,9 @@
var originalOrderSorter = {
'original-order' : function( $elem, instance ) {
return instance.elemCount;
},
random : function() {
return Math.random();
}
};
@ -695,28 +698,11 @@
},
_shuffleArray : function ( array ) {
var tmp, current, i = array.length;
if ( i ){
while(--i) {
current = ~~( Math.random() * (i + 1) );
tmp = array[current];
array[current] = array[i];
array[i] = tmp;
}
}
return array;
},
// HACKy should probably remove
shuffle : function( callback ) {
this.options.sortBy = 'shuffle';
this.$allAtoms = this._shuffleArray( this.$allAtoms );
this.$filteredAtoms = this._filter( this.$allAtoms );
this.reLayout( callback );
shuffle : function() {
this.updateSortData( this.$allAtoms );
this.options.sortBy = 'random';
this._sort();
this.reLayout();
},
// destroys widget, returns elements and container back (close) to original style

4
jquery.isotope.min.js vendored

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