Browse Source

Merge branch 'master' into gh-pages

v1
David DeSandro 13 years ago
parent
commit
d54c05d2f3
  1. 16
      _posts/demos/2010-12-31-relayout.html
  2. 6
      _posts/demos/2011-05-22-category-rows.html
  3. 306
      _posts/demos/2011-06-13-hash-history.html
  4. 6
      _posts/tests/2010-01-01-index.html
  5. 20
      _posts/tests/2011-04-26-item-position-data01.html
  6. 13
      _posts/tests/2011-05-13-jquery-animation01.html
  7. 60
      jquery.isotope.js
  8. 5
      jquery.isotope.min.js

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

@ -29,20 +29,6 @@ category: demos
var $container = $('#container'); var $container = $('#container');
{% include random-sizes.js %} {% include random-sizes.js %}
// toggle variable sizes of all elements
$('#toggle-sizes a').click(function(){
$container
.toggleClass('variable-sizes')
.isotope('reLayout');
return false;
});
// change size of clicked element
$container.find('.element').click(function(){
$(this).toggleClass('large');
$container.isotope('reLayout');
});
$container.isotope({ $container.isotope({
itemSelector: '.element', itemSelector: '.element',
@ -51,6 +37,8 @@ category: demos
} }
}); });
{% include change-sizes.js %}
}); });
</script> </script>

6
_posts/demos/2011-05-22-category-rows.html

@ -109,8 +109,6 @@ category: demos
animationEngine : $.browser.opera ? 'jquery' : 'best-available' animationEngine : $.browser.opera ? 'jquery' : 'best-available'
}); });
{% include option-set-buttons.js %} {% include option-set-buttons.js %}
{% include add-buttons.js %} {% include add-buttons.js %}
@ -123,10 +121,6 @@ category: demos
return false; return false;
}); });
}); });
</script> </script>

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

@ -4,187 +4,177 @@ layout: default
category: demos category: demos
--- ---
<section id="copy"> <section id="copy">
<p><a href="http://benalman.com/projects/jquery-bbq-plugin/">jQuery BBQ</a> by Ben Alman allows you to use hash history to save Isotope options. Try clicking a couple options then hitting the back button, or copying the URL and pasting it into a new window.</p> <p><a href="http://benalman.com/projects/jquery-bbq-plugin/">jQuery BBQ</a> by Ben Alman allows you to use hash history to save Isotope options. Try clicking a couple options then hitting the back button, or copying the URL and pasting it into a new window.</p>
</section> </section>
<section id="options" class="clearfix"> <section id="options" class="clearfix">
<h3>Filters</h3> <h3>Filters</h3>
<ul class="option-set clearfix"> <ul class="option-set clearfix">
<li><a href="#filter=*" class="selected">show all</a></li> <li><a href="#filter=*" class="selected">show all</a></li>
<li><a href="#filter=.metal">metal</a></li> <li><a href="#filter=.metal">metal</a></li>
<li><a href="#filter=.transition">transition</a></li> <li><a href="#filter=.transition">transition</a></li>
<li><a href="#filter=.post-transition">post-transition</a></li> <li><a href="#filter=.post-transition">post-transition</a></li>
<li><a href="#filter=.nonmetal">nonmetal</a></li> <li><a href="#filter=.nonmetal">nonmetal</a></li>
<li><a href="#filter=.inner-transition">inner-transition</a></li> <li><a href="#filter=.inner-transition">inner-transition</a></li>
<li><a href="#filter=.alkali%2C+.alkaline-earth">alkali and alkaline-earth</a></li> <li><a href="#filter=.alkali%2C+.alkaline-earth">alkali and alkaline-earth</a></li>
<li><a href="#filter=%3Anot(.transition)">not transition</a></li> <li><a href="#filter=%3Anot(.transition)">not transition</a></li>
<li><a href="#filter=.metal%3Anot(.transition)">metal but not transition</a></li> <li><a href="#filter=.metal%3Anot(.transition)">metal but not transition</a></li>
</ul> </ul>
<h3>Sort</h3> <h3>Sort</h3>
<ul class="option-set clearfix"> <ul class="option-set clearfix">
<li><a href="#sortBy=original-order" class="selected">original-order</a></li> <li><a href="#sortBy=original-order" class="selected">original-order</a></li>
<li><a href="#sortBy=name">name</a></li> <li><a href="#sortBy=name">name</a></li>
<li><a href="#sortBy=symbol">symbol</a></li> <li><a href="#sortBy=symbol">symbol</a></li>
<li><a href="#sortBy=number">number</a></li> <li><a href="#sortBy=number">number</a></li>
<li><a href="#sortBy=weight">weight</a></li> <li><a href="#sortBy=weight">weight</a></li>
<li><a href="#sortBy=category">category</a></li> <li><a href="#sortBy=category">category</a></li>
</ul> </ul>
<h3>Sort direction</h3> <h3>Sort direction</h3>
<ul class="option-set clearfix"> <ul class="option-set clearfix">
<li><a href="#sortAscending=true" class="selected">sort ascending</a></li> <li><a href="#sortAscending=true" class="selected">sort ascending</a></li>
<li><a href="#sortAscending=false">sort descending</a></li> <li><a href="#sortAscending=false">sort descending</a></li>
</ul> </ul>
<h3>Layout modes</h3> <h3>Layout modes</h3>
<ul class="option-set clearfix"> <ul class="option-set clearfix">
<li><a href="#layoutMode=masonry" class="selected">masonry</a></li> <li><a href="#layoutMode=masonry" class="selected">masonry</a></li>
<li><a href="#layoutMode=fitRows">fitRows</a></li> <li><a href="#layoutMode=fitRows">fitRows</a></li>
<li><a href="#layoutMode=cellsByRow">cellsByRow</a></li> <li><a href="#layoutMode=cellsByRow">cellsByRow</a></li>
<li><a href="#layoutMode=straightDown">straightDown</a></li> <li><a href="#layoutMode=straightDown">straightDown</a></li>
</ul> </ul>
</section> <!-- #options --> </section> <!-- #options -->
<div id="container" class="variable-sizes clearfix"> <div id="container" class="variable-sizes clearfix">
{% for elem_number in site.random_order | limit:60 %} {% for elem_number in site.random_order | limit:60 %}
{% assign element = site.elements[elem_number] %} {% assign element = site.elements[elem_number] %}
{% include element-partial.html %} {% include element-partial.html %}
{% endfor %} {% endfor %}
</div> <!-- #container --> </div> <!-- #container -->
<script src="../{{ site.jquery_js }}"></script> <script src="../{{ site.jquery_js }}"></script>
<script src="../{{ site.isotope_js }}"></script> <script src="../{{ site.isotope_js }}"></script>
<script src="../js/jquery.ba-bbq.min.js"></script> <script src="../js/jquery.ba-bbq.min.js"></script>
<script> <script>
$(function(){ $(function(){
var $container = $('#container'), var $container = $('#container'),
// object that will keep track of options // object that will keep track of options
isotopeOptions = {}, isotopeOptions = {},
// defaults, used if not explicitly set in hash // defaults, used if not explicitly set in hash
defaultOptions = { defaultOptions = {
filter: '*', filter: '*',
sortBy: 'original-order', sortBy: 'original-order',
sortAscending: true, sortAscending: true,
layoutMode: 'masonry' layoutMode: 'masonry'
}; };
{% include random-sizes.js %}
// hacky way of adding random size classes var setupOptions = $.extend( defaultOptions, {
$container.find('.element').each(function(){ itemSelector : '.element',
if ( Math.random() > 0.6 ) { masonry : {
$(this).addClass('width2'); columnWidth : 120
} },
if ( Math.random() > 0.6 ) { cellsByRow : {
$(this).addClass('height2'); columnWidth : 240,
} rowHeight : 240
}); },
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();
}
}
});
var setupOptions = $.extend( defaultOptions, { // set up Isotope
itemSelector : '.element', $container.isotope( setupOptions );
masonry : {
columnWidth : 120
},
cellsByRow : {
columnWidth : 240,
rowHeight : 240
},
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();
}
}
});
// set up Isotope
$container.isotope( setupOptions );
var $optionSets = $('#options').find('.option-set'), var $optionSets = $('#options').find('.option-set'),
isOptionLinkClicked = false; isOptionLinkClicked = false;
// switches selected class on buttons // switches selected class on buttons
function changeSelectedLink( $elem ) { function changeSelectedLink( $elem ) {
// remove selected class on previous item // remove selected class on previous item
$elem.parents('.option-set').find('.selected').removeClass('selected'); $elem.parents('.option-set').find('.selected').removeClass('selected');
// set selected class on new item // set selected class on new item
$elem.addClass('selected'); $elem.addClass('selected');
} }
$optionSets.find('a').click(function(){ $optionSets.find('a').click(function(){
var $this = $(this); var $this = $(this);
// don't proceed if already selected // don't proceed if already selected
if ( $this.hasClass('selected') ) { if ( $this.hasClass('selected') ) {
return; return;
} }
changeSelectedLink( $this ); changeSelectedLink( $this );
// get href attr, remove leading # // get href attr, remove leading #
var href = $this.attr('href').replace( /^#/, '' ), var href = $this.attr('href').replace( /^#/, '' ),
// convert href into object // convert href into object
// i.e. 'filter=.inner-transition' -> { filter: '.inner-transition' } // i.e. 'filter=.inner-transition' -> { filter: '.inner-transition' }
option = $.deparam( href, true ); option = $.deparam( href, true );
// apply new option to previous // apply new option to previous
$.extend( isotopeOptions, option ); $.extend( isotopeOptions, option );
// set hash, triggers hashchange on window // set hash, triggers hashchange on window
$.bbq.pushState( isotopeOptions ); $.bbq.pushState( isotopeOptions );
isOptionLinkClicked = true; isOptionLinkClicked = true;
return false; return false;
}); });
$(window).bind( 'hashchange', function( event ){ $(window).bind( 'hashchange', function( event ){
// get options object from hash // get options object from hash
var hashOptions = window.location.hash ? $.deparam.fragment( window.location.hash, true ) : {}, var hashOptions = window.location.hash ? $.deparam.fragment( window.location.hash, true ) : {},
// apply defaults where no option was specified // apply defaults where no option was specified
options = $.extend( {}, defaultOptions, hashOptions ); options = $.extend( {}, defaultOptions, hashOptions );
// apply options from hash // apply options from hash
$container.isotope( options ); $container.isotope( options );
// save options // save options
isotopeOptions = hashOptions; isotopeOptions = hashOptions;
// if option link was not clicked // if option link was not clicked
// then we'll need to update selected links // then we'll need to update selected links
if ( !isOptionLinkClicked ) { if ( !isOptionLinkClicked ) {
// iterate over options // iterate over options
var hrefObj, hrefValue, $selectedLink; var hrefObj, hrefValue, $selectedLink;
for ( var key in options ) { for ( var key in options ) {
hrefObj = {}; hrefObj = {};
hrefObj[ key ] = options[ key ]; hrefObj[ key ] = options[ key ];
// convert object into parameter string // convert object into parameter string
// i.e. { filter: '.inner-transition' } -> 'filter=.inner-transition' // i.e. { filter: '.inner-transition' } -> 'filter=.inner-transition'
hrefValue = $.param( hrefObj ); hrefValue = $.param( hrefObj );
// get matching link // get matching link
$selectedLink = $optionSets.find('a[href="#' + hrefValue + '"]'); $selectedLink = $optionSets.find('a[href="#' + hrefValue + '"]');
changeSelectedLink( $selectedLink ); changeSelectedLink( $selectedLink );
} }
} }
isOptionLinkClicked = false; isOptionLinkClicked = false;
}) })
// trigger hashchange to capture any hash data on init // trigger hashchange to capture any hash data on init
.trigger('hashchange'); .trigger('hashchange');
}); });
</script> </script>

6
_posts/tests/2010-01-01-index.html

@ -2,12 +2,12 @@
title: Tests Index title: Tests Index
layout: default layout: default
category: tests category: tests
body_class: doc is_index_page: true
--- ---
<ul> <ul>
{% for post in site.categories[page.category] reversed %} {% for post in site.categories.tests reversed %}
{% if post.layout != 'index-page' %} {% if post.is_index_page != true %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li> <li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

20
_posts/tests/2011-04-26-item-position-data01.html

@ -36,22 +36,6 @@ category: tests
{% include random-sizes.js %} {% include random-sizes.js %}
{% include option-set-buttons.js %}
// toggle variable sizes of all elements
$('#toggle-sizes').find('a').click(function(){
$container
.toggleClass('variable-sizes')
.isotope('reLayout');
return false;
});
// log item position
$container.find('.element').click(function(){
var position = $(this).data('isotope-item-position');
console.log( position.x + ', ' + position.y );
});
$container.isotope({ $container.isotope({
itemSelector: '.element', itemSelector: '.element',
itemPositionDataEnabled: true, itemPositionDataEnabled: true,
@ -76,6 +60,10 @@ category: tests
} }
} }
}); });
{% include option-set-buttons.js %}
{% include change-sizes.js %}
}); });
</script> </script>

13
_posts/tests/2011-05-13-jquery-animation01.html

@ -14,7 +14,7 @@ category: tests
</style> </style>
<section id="copy"> <section id="copy">
<p></p> <p>Check that the option setter for animationEngine is properly triggered.</p>
</section> </section>
<section id="options" class="clearfix"> <section id="options" class="clearfix">
@ -28,11 +28,12 @@ category: tests
<ul id="etc" class="clearfix"> <ul id="etc" class="clearfix">
<li id="toggle-animation"><a href="#toggle-animation">Toggle jQuery animation</a></li>
<li id="toggle-sizes"><a href="#toggle-sizes">Toggle variable sizes</a></li> <li id="toggle-sizes"><a href="#toggle-sizes">Toggle variable sizes</a></li>
</ul> </ul>
</section> <!-- #options --> </section> <!-- #options -->
<div id="container"> <div id="container" class="clickable clearfix">
{% for element in site.elements limit:40 %} {% for element in site.elements limit:40 %}
{% include element-partial.html %} {% include element-partial.html %}
{% endfor %} {% endfor %}
@ -76,6 +77,14 @@ category: tests
{% include option-set-buttons.js %} {% include option-set-buttons.js %}
{% include change-sizes.js %} {% include change-sizes.js %}
var isAnimated = true;
$('#toggle-animation').click(function(){
isAnimated = !isAnimated;
var aniEngine = isAnimated ? 'jquery' : 'css';
$container.isotope( 'option', { animationEngine: aniEngine } );
return false;
});
}); });
</script> </script>

60
jquery.isotope.js

@ -1,5 +1,5 @@
/** /**
* Isotope v1.3.110604 * Isotope v1.3.110620
* An exquisite jQuery plugin for magical layouts * An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co * http://isotope.metafizzy.co
* *
@ -9,39 +9,41 @@
* Copyright 2011 David DeSandro / Metafizzy * Copyright 2011 David DeSandro / Metafizzy
*/ */
/*global Modernizr: true */
(function( window, $, undefined ){ (function( window, $, undefined ){
// helper function
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
// ========================= getStyleProperty by kangax =============================== // ========================= getStyleProperty by kangax ===============================
// http://perfectionkills.com/feature-testing-css-properties/ // http://perfectionkills.com/feature-testing-css-properties/
var getStyleProperty = (function(){ var prefixes = 'Moz Webkit Khtml O Ms'.split(' ');
var prefixes = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms']; function getStyleProperty( propName, element ) {
element = element || document.documentElement;
var style = element.style,
prefixed;
function getStyleProperty(propName, element) { // test standard property first
element = element || document.documentElement; if ( typeof style[propName] === 'string' ) {
var style = element.style, return propName;
prefixed; }
// test standard property first
if (typeof style[propName] === 'string') {
return propName;
}
// capitalize // capitalize
propName = propName.charAt(0).toUpperCase() + propName.slice(1); propName = capitalize( propName );
// test vendor specific properties // test vendor specific properties
for (var i=0, l=prefixes.length; i<l; i++) { for ( var i=0, len = prefixes.length; i < len; i++ ) {
prefixed = prefixes[i] + propName; prefixed = prefixes[i] + propName;
if (typeof style[prefixed] === 'string') { if ( typeof style[ prefixed ] === 'string' ) {
return prefixed; return prefixed;
}
} }
} }
}
return getStyleProperty;
})();
var transformProp = getStyleProperty('transform'); var transformProp = getStyleProperty('transform');
@ -68,7 +70,6 @@
*/ */
var docElement = document.documentElement, var docElement = document.documentElement,
vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '),
tests = [ tests = [
{ {
name : 'csstransforms', name : 'csstransforms',
@ -84,6 +85,7 @@
if ( test ){ if ( test ){
var st = document.createElement('style'), var st = document.createElement('style'),
div = document.createElement('div'), div = document.createElement('div'),
vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '),
mq = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)'; mq = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)';
st.textContent = mq + '{#modernizr{height:3px}}'; st.textContent = mq + '{#modernizr{height:3px}}';
@ -452,7 +454,7 @@
// trigger _updateOptionName if it exists // trigger _updateOptionName if it exists
_updateOption : function( optionName ) { _updateOption : function( optionName ) {
var updateOptionFn = '_update' + optionName.charAt(0).toUpperCase() + optionName.slice(1); var updateOptionFn = '_update' + capitalize( optionName );
if ( this[ updateOptionFn ] ) { if ( this[ updateOptionFn ] ) {
this[ updateOptionFn ](); this[ updateOptionFn ]();
} }
@ -856,8 +858,8 @@
} }
// position the brick // position the brick
x = this.masonry.columnWidth * shortCol; var x = this.masonry.columnWidth * shortCol,
y = minimumY; y = minimumY;
this._pushPosition( $brick, x, y ); this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns // apply setHeight to necessary columns
@ -1042,8 +1044,8 @@
} }
// position the brick // position the brick
x = minimumX; var x = minimumX,
y = this.masonryHorizontal.rowHeight * smallRow; y = this.masonryHorizontal.rowHeight * smallRow;
this._pushPosition( $brick, x, y ); this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns // apply setHeight to necessary columns

5
jquery.isotope.min.js vendored

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