Browse Source

Merge branch 'master' into gh-pages

v1
David DeSandro 13 years ago
parent
commit
bab4e6abe1
  1. 141
      _posts/demos/2011-09-30-fluid-responsive.html
  2. 2
      _posts/tests/2010-01-01-index.html

141
_posts/demos/2011-09-30-fluid-responsive.html

@ -0,0 +1,141 @@
---
title: Fluid / responsive
layout: default
category: demos
---
<style>
/* percentage-based widths for fluid/responsive layout */
.element {
margin: 5px 1%;
width: 18%;
}
.variable-sizes .element.width2 { width: 38%; }
.element.large,
.variable-sizes .element.large,
.variable-sizes .element.large.width2.height2 {
width: 58%;
}
#container {
padding: 5px 0;
}
</style>
<section id="copy">
<p>This hack allows you to use percentage-based widths for item elements for fluid / responsive layouts.</p>
{% highlight javascript %}
var $container = $('#container')
// initialize Isotope
$container.isotope({
// options...
resizable: false, // disable normal resizing
// set columnWidth to a percentage of container width
masonry: { columnWidth: $container.width() / 5 }
});
// update columnWidth on window resize
$(window).smartresize(function(){
$container.isotope({
// update columnWidth to a percentage of container width
masonry: { columnWidth: $container.width() / 5 }
});
});
{% endhighlight %}
</section>
<section id="options" class="clearfix">
{% include filter-buttons.html %}
{% include sort-buttons.html %}
<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>
</ul>
</section> <!-- #options -->
<div id="container" class="clickable variable-sizes clearfix">
{% for elem_number in site.best_of_order %}
{% 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/fake-element.js"></script>
<script>
$(function(){
var $container = $('#container');
{% include random-sizes.js %}
$container.isotope({
itemSelector : '.element',
// disable resizing
resizable: false,
// set columnWidth to a percentage of container width
masonry: {
columnWidth: $container.width() / 5
},
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();
}
}
});
// update columnWidth on window resize
$(window).smartresize(function(){
$container.isotope({
// set columnWidth to a percentage of container width
masonry: {
columnWidth: $container.width() / 5
}
});
});
{% include option-set-buttons.js %}
{% include add-buttons.js %}
{% include change-sizes.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;
});
});
</script>

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

@ -8,7 +8,7 @@ is_index_page: true
<ul> <ul>
{% for post in site.categories.tests reversed %} {% for post in site.categories.tests reversed %}
{% if post.is_index_page != true %} {% 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 %}
</ul> </ul>
Loading…
Cancel
Save