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. 350
      _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

@ -30,20 +30,6 @@ category: demos
{% 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({
itemSelector: '.element',
masonry : {
@ -51,6 +37,8 @@ category: demos
}
});
{% include change-sizes.js %}
});
</script>

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

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

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

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

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

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

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

@ -36,22 +36,6 @@ category: tests
{% 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({
itemSelector: '.element',
itemPositionDataEnabled: true,
@ -77,5 +61,9 @@ category: tests
}
});
{% include option-set-buttons.js %}
{% include change-sizes.js %}
});
</script>

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

@ -14,7 +14,7 @@ category: tests
</style>
<section id="copy">
<p></p>
<p>Check that the option setter for animationEngine is properly triggered.</p>
</section>
<section id="options" class="clearfix">
@ -28,11 +28,12 @@ category: tests
<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>
</ul>
</section> <!-- #options -->
<div id="container">
<div id="container" class="clickable clearfix">
{% for element in site.elements limit:40 %}
{% include element-partial.html %}
{% endfor %}
@ -77,5 +78,13 @@ category: tests
{% 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>

60
jquery.isotope.js

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