Browse Source

Merge branch 'master' into gh-pages

v1
David DeSandro 14 years ago
parent
commit
6571bb166c
  1. 18
      README.mdown
  2. 5
      _includes/elements-demo-foot.html
  3. 4
      _includes/elements-demo-head.html
  4. 3
      _includes/sort-buttons.html
  5. 1
      _posts/demos/2011-06-13-hash-history.html
  6. 11
      _posts/docs/2010-12-04-methods.mdown
  7. 11
      _posts/docs/2010-12-07-sorting.mdown
  8. 10
      _posts/tests/2011-05-24-elements-complete-test.html
  9. 263
      jquery.isotope.js
  10. 5
      jquery.isotope.min.js

18
README.mdown

@ -31,6 +31,24 @@ The documentation and demo pages are generated using [Jekyll](http://github.com/
Then view the live site at [http://localhost:4000](http://localhost:4000).
Changelog
---------
View the [commit history](https://github.com/desandro/isotope/commits/master/jquery.isotope.js) for a complete robust list of changes to the script.
+ **v1.4** [2011-06-29](https://github.com/desandro/isotope/commit/8e2f51612eaf20e3031b81b8c5ff5e322cbb7b4f#jquery.isotope.js)
- shuffle method added
- inserting and appending positions items then reveals them
+ **v1.3** [2011-05-23](https://github.com/desandro/isotope/commit/a7cc0be2a0038c13a2955a889a873f63a39eb6c2#jquery.isotope.js)
- refactor layout mode API
- layoutModeResize -> layoutModeResizeChanged, which returns boolean
+ **v1.2** [2011-05-13](https://github.com/desandro/isotope/commit/b3cf6139d7641f282724a7a541b3bfb10d1bbf54#jquery.isotope.js)
- add updateOption method, for changing options after initialization
+ **v1.1** [2011-04-26](https://github.com/desandro/isotope/commit/3c551406ee1e4cd8345cdbe589c2d8d1e164b259#jquery.isotope.js)
- incremental additions, bug fixes, and refactorings
+ **v1.0** [2011-02-07](https://github.com/desandro/isotope/commit/78253dfb34808d9a677ae721e97c5afc08aa19b8#jquery.isotope.js)
- public release
* * *
Copyright (c) 2011 David DeSandro / Metafizzy LLC

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 %}

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

@ -94,7 +94,7 @@ getSortData : {
{% endhighlight %}
Get creative! You can sort the list in the [index page](../index.html) by the width of each item element.
Get creative! You could sort a list by the width of each item element.
{% highlight javascript %}
@ -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
@ -142,7 +145,7 @@ We can use a simple list for our buttons.
{% highlight html %}
<ul id="sort">
<ul id="sort-by">
<li><a href="#name">name</a></li>
<li><a href="#symbol">symbol</a></li>
<li><a href="#number">number</a></li>
@ -156,7 +159,7 @@ When one of these links is clicked, we can use the `href` attribute as the value
{% highlight javascript %}
$('#sort a').click(function(){
$('#sort-by a').click(function(){
// get href attribute, minus the '#'
var sortName = $(this).attr('href').slice(1);
$('#container').isotope({ sortBy : sortName });

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

@ -2,6 +2,7 @@
title: elements complete test
layout: default
category: tests
body_class: demos
---
<section id="copy">
@ -19,12 +20,12 @@ category: tests
<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 -->
@ -127,8 +128,13 @@ category: tests
{% include add-buttons.js %}
var $sortBy = $('#sort-by');
$('#shuffle a').click(function(){
console.time('shuffle');
$container.isotope('shuffle');
$sortBy.find('.selected').removeClass('selected');
$sortBy.find('[data-option-value="random"]').addClass('selected');
console.timeEnd('shuffle');
return false;
});

263
jquery.isotope.js

@ -1,5 +1,5 @@
/**
* Isotope v1.3.110623
* Isotope v1.4.110630
* An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co
*
@ -9,6 +9,7 @@
* Copyright 2011 David DeSandro / Metafizzy
*/
/*jshint curly: true, eqeqeq: true, forin: false, immed: false, newcap: true, noempty: true, undef: true */
/*global Modernizr: true */
(function( window, $, undefined ){
@ -23,9 +24,8 @@
var prefixes = 'Moz Webkit Khtml O Ms'.split(' ');
function getStyleProperty( propName, element ) {
element = element || document.documentElement;
var style = element.style,
function getStyleProperty( propName ) {
var style = document.documentElement.style,
prefixed;
// test standard property first
@ -63,62 +63,45 @@
* http://www.modernizr.com/license/
*/
/*
* This version whittles down the script just to check support for
* CSS transitions, transforms, and 3D transforms.
*/
var docElement = document.documentElement,
tests = [
{
name : 'csstransforms',
getResult : function() {
return !!transformProp;
}
},
{
name : 'csstransforms3d',
getResult : function() {
var test = !!getStyleProperty('perspective');
// double check for Chrome's false positive
if ( test ){
var st = document.createElement('style'),
div = document.createElement('div'),
vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '),
mq = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)';
st.textContent = mq + '{#modernizr{height:3px}}';
(document.head || document.getElementsByTagName('head')[0]).appendChild(st);
div.id = 'modernizr';
docElement.appendChild(div);
test = div.offsetHeight === 3;
st.parentNode.removeChild(st);
div.parentNode.removeChild(div);
}
return !!test;
}
},
{
name : 'csstransitions',
getResult : function() {
return !!getStyleProperty('transitionProperty');
}
}
],
var tests = {
csstransforms: function() {
return !!transformProp;
},
csstransforms3d: function() {
var test = !!getStyleProperty('perspective');
// double check for Chrome's false positive
if ( test ) {
var vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '),
mediaQuery = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)',
$style = $('<style>' + mediaQuery + '{#modernizr{height:3px}}' + '</style>')
.appendTo('head'),
$div = $('<div id="modernizr" />').appendTo('html');
i, len = tests.length
;
test = $div.height() === 3;
$div.remove();
$style.remove();
}
return test;
},
csstransitions: function() {
return !!getStyleProperty('transitionProperty');
}
};
if ( window.Modernizr ) {
// if there's a previous Modernzir, check if there are necessary tests
for ( i=0; i < len; i++ ) {
var test = tests[i];
if ( !Modernizr.hasOwnProperty( test.name ) ) {
for ( var testName in tests) {
if ( !Modernizr.hasOwnProperty( testName ) ) {
// if test hasn't been run, use addTest to run it
Modernizr.addTest( test.name, test.getResult );
Modernizr.addTest( testName, tests[ testName ] );
}
}
} else {
@ -128,20 +111,18 @@
var miniModernizr = {
_version : '1.6ish: miniModernizr for Isotope'
},
classes = [],
test, result, className;
classes = ' ',
result, testName;
// Run through tests
for ( i=0; i < len; i++ ) {
test = tests[i];
result = test.getResult();
miniModernizr[ test.name ] = result;
className = ( result ? '' : 'no-' ) + test.name;
classes.push( className );
for ( testName in tests) {
result = tests[ testName ]();
miniModernizr[ testName ] = result;
classes += ' ' + ( result ? '' : 'no-' ) + testName;
}
// Add the new classes to the <html> element.
docElement.className += ' ' + classes.join( ' ' );
$('html').addClass( classes );
return miniModernizr;
})();
@ -378,6 +359,9 @@
var originalOrderSorter = {
'original-order' : function( $elem, instance ) {
return instance.elemCount;
},
random : function() {
return Math.random();
}
};
@ -443,8 +427,14 @@
// signature: $('#foo').bar({ cool:false });
if ( $.isPlainObject( opts ) ){
this.options = $.extend( true, this.options, opts );
// trigger _updateOptionName if it exists
var updateOptionFn;
for ( var optionName in opts ) {
this._updateOption( optionName );
updateOptionFn = '_update' + capitalize( optionName );
if ( this[ updateOptionFn ] ) {
this[ updateOptionFn ]();
}
}
}
},
@ -452,14 +442,6 @@
// ====================== updaters ====================== //
// kind of like setters
// trigger _updateOptionName if it exists
_updateOption : function( optionName ) {
var updateOptionFn = '_update' + capitalize( optionName );
if ( this[ updateOptionFn ] ) {
this[ updateOptionFn ]();
}
},
_updateAnimationEngine : function() {
var animationEngine = this.options.animationEngine.toLowerCase().replace( /[ _\-]/g, '');
// set applyStyleFnName
@ -492,33 +474,27 @@
// ====================== Filtering ======================
_filter : function( $atoms ) {
var $filteredAtoms,
filter = this.options.filter === '' ? '*' : this.options.filter;
var filter = this.options.filter === '' ? '*' : this.options.filter;
if ( !filter ) {
$filteredAtoms = $atoms;
} else {
var hiddenClass = this.options.hiddenClass,
hiddenSelector = '.' + hiddenClass,
$visibleAtoms = $atoms.not( hiddenSelector ),
$hiddenAtoms = $atoms.filter( hiddenSelector ),
$atomsToShow = $hiddenAtoms;
$filteredAtoms = $atoms.filter( filter );
if ( filter !== '*' ) {
$atomsToShow = $hiddenAtoms.filter( filter );
var $atomsToHide = $visibleAtoms.not( filter ).toggleClass( hiddenClass );
$atomsToHide.addClass( hiddenClass );
this.styleQueue.push({ $el: $atomsToHide, style: this.options.hiddenStyle });
}
this.styleQueue.push({ $el: $atomsToShow, style: this.options.visibleStyle });
$atomsToShow.removeClass( hiddenClass );
return $atoms;
}
return $filteredAtoms;
var hiddenClass = this.options.hiddenClass,
hiddenSelector = '.' + hiddenClass,
$hiddenAtoms = $atoms.filter( hiddenSelector ),
$atomsToShow = $hiddenAtoms;
if ( filter !== '*' ) {
$atomsToShow = $hiddenAtoms.filter( filter );
var $atomsToHide = $atoms.not( hiddenSelector ).not( filter ).addClass( hiddenClass );
this.styleQueue.push({ $el: $atomsToHide, style: this.options.hiddenStyle });
}
this.styleQueue.push({ $el: $atomsToShow, style: this.options.visibleStyle });
$atomsToShow.removeClass( hiddenClass );
return $atoms.filter( filter );
},
// ====================== Sorting ======================
@ -604,27 +580,34 @@
this.styleQueue.push({ $el: this.element, style: containerStyle });
}
this._processStyleQueue();
// provide $elems as context for the callback
if ( callback ) {
callback.call( $elems );
}
this.isLaidOut = true;
},
_processStyleQueue : function() {
// are we animating the layout arrangement?
// use plugin-ish syntax for css or animate
var styleFn = !this.isLaidOut ? 'css' : (
this.isUsingJQueryAnimation ? 'animate' : 'css'
),
animOpts = this.options.animationOptions;
animOpts = this.options.animationOptions,
_isInsertingAnimated = this._isInserting && this.isUsingJQueryAnimation,
objStyleFn;
// process styleQueue
$.each( this.styleQueue, function( i, obj ) {
obj.$el[ styleFn ]( obj.style, animOpts );
objStyleFn = _isInsertingAnimated && obj.$el.hasClass('no-transition') ? 'css' : styleFn;
obj.$el[ objStyleFn ]( obj.style, animOpts );
});
// clear out queue for next time
this.styleQueue = [];
// provide $elems as context for the callback
if ( callback ) {
callback.call( $elems );
}
this.isLaidOut = true;
},
@ -644,6 +627,8 @@
// ====================== Convenience methods ======================
// ====================== Adding items ======================
// adds a jQuery object of items to a isotope container
addItems : function( $content, callback ) {
var $newAtoms = this._getAtoms( $content );
@ -657,29 +642,60 @@
},
// convienence method for adding elements properly to any layout
// positions items, hides them, then animates them back in <--- very sezzy
insert : function( $content, callback ) {
// position items
this.element.append( $content );
var instance = this;
this.addItems( $content, function( $newAtoms ) {
var $filteredAtoms = instance._filter( $newAtoms );
instance.$filteredAtoms = instance.$filteredAtoms.add( $filteredAtoms );
var $newFilteredAtoms = instance._filter( $newAtoms, true );
instance._addHideAppended( $newFilteredAtoms );
instance._sort();
instance.reLayout();
instance._revealAppended( $newFilteredAtoms, callback );
});
this._sort();
this.reLayout( callback );
},
// convienence method for working with Infinite Scroll
appended : function( $content, callback ) {
var instance = this;
this.addItems( $content, function( $newAtoms ){
instance.$filteredAtoms = instance.$filteredAtoms.add( $newAtoms );
instance.layout( $newAtoms, callback );
this.addItems( $content, function( $newAtoms ) {
instance._addHideAppended( $newAtoms );
instance.layout( $newAtoms );
instance._revealAppended( $newAtoms, callback );
});
},
// adds new atoms, then hides them before positioning
_addHideAppended : function( $newAtoms ) {
this.$filteredAtoms = this.$filteredAtoms.add( $newAtoms );
$newAtoms.addClass('no-transition');
this._isInserting = true;
// apply hidden styles
this.styleQueue.push({ $el: $newAtoms, style: this.options.hiddenStyle });
},
// sets visible style on new atoms
_revealAppended : function( $newAtoms, callback ) {
var instance = this;
// apply visible style after a sec
setTimeout( function() {
// enable animation
$newAtoms.removeClass('no-transition');
// reveal newly inserted filtered elements
instance.styleQueue.push({ $el: $newAtoms, style: instance.options.visibleStyle });
instance._processStyleQueue();
delete instance._isInserting;
if ( callback ) {
callback( $newAtoms );
}
}, 10 );
},
// gathers all atoms
reloadItems : function() {
this.$allAtoms = this._getAtoms( this.element.children() );
@ -695,28 +711,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

5
jquery.isotope.min.js vendored

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