Browse Source

html : Add layout example

pull/14/head
David DeSandro 14 years ago
parent
commit
d9ff91452b
  1. 106
      _config.yml
  2. 24
      _includes/layout-change.js
  3. 10
      _includes/layout-options.html
  4. 12
      _includes/option-buttons.js
  5. 54
      _layouts/elements.html
  6. 1
      _posts/docs/2010-12-04-methods.mdown
  7. 136
      _posts/docs/2010-12-05-layouts.mdown
  8. 81
      _posts/examples/2010-12-29-layouts.html
  9. 10
      css/style.css

106
_config.yml

@ -755,4 +755,108 @@ elements_partial:
number: 88
symbol: Ra
name: Radium
weight: (226)
weight: (226)
elements_ordered:
- categories: [ other, nonmetal ]
number: 1
symbol: H
name: Hydrogen
weight: 1.00794
- categories: [noble-gas, nonmetal]
number: 2
symbol: He
name: Helium
weight: 4.002602
- categories: [alkali, metal]
number: 3
symbol: Li
name: Lithium
weight: 6.941
- categories: [alkaline-earth, metal]
number: 4
symbol: Be
name: Beryllium
weight: 9.012182
- categories: [metalloid]
number: 5
symbol: B
name: Boron
weight: 10.811
- categories: [other, nonmetal]
othercategory: p
number: 6
symbol: C
name: Carbon
weight: 12.0107
- categories: [other, nonmetal]
number: 7
symbol: N
name: Nitrogen
weight: 14.0067
- categories: [other, nonmetal]
number: 8
symbol: O
name: Oxygen
weight: 15.9994
- categories: [halogen, nonmetal]
number: 9
symbol: F
name: Fluorine
weight: 18.9984032
- categories: [noble-gas, nonmetal]
number: 10
symbol: Ne
name: Neon
weight: 20.1797
- categories: [alkali, metal]
number: 11
symbol: Na
name: Sodium
weight: 22.98976928
- categories: [alkaline-earth, metal]
number: 12
symbol: Mg
name: Magnesium
weight: 24.305
- categories: [post-transition, metal]
number: 13
symbol: Al
name: Aluminium
weight: 26.9815386
- categories: [metalloid]
number: 14
symbol: Si
name: Silicon
weight: 28.0855
- categories: [other, nonmetal]
number: 15
symbol: P
name: Phosphorus
weight: 30.973762
- categories: [other, nonmetal]
number: 16
symbol: S
name: Sulfur
weight: 32.065
- categories: [halogen, nonmetal]
number: 17
symbol: Cl
name: Chlorine
weight: 35.453
- categories: [noble-gas, nonmetal]
number: 18
symbol: Ar
name: Argon
weight: 39.948
- categories: [alkali, metal]
number: 19
symbol: K
name: Potassium
weight: 39.0983
- categories: [alkaline-earth, metal]
number: 20
symbol: Ca
name: Calcium
weight: 40.078

24
_includes/layout-change.js

@ -0,0 +1,24 @@
// change layout
var isHorizontal = false;
$('#layouts a').click(function(){
var mode = $(this).attr('href').slice(1);
wasHorizontal = isHorizontal;
isHorizontal = $(this).hasClass('horizontal');
if ( wasHorizontal !== isHorizontal ) {
// need to do some clean up for transitions and sizes
var style = isHorizontal ?
{ height: '80%', width: $demo.width() } :
{ width: 'auto' };
$demo.addClass('no-transition').css( style );
setTimeout(function(){
$demo.removeClass('no-transition').isotope({ layoutMode : mode });
}, 100 )
} else {
// go ahead and apply new layout
$demo.isotope({ layoutMode : mode });
}
return false;
});

10
_includes/layout-options.html

@ -0,0 +1,10 @@
<h3>Layouts</h3>
<ul id="layouts" class="option-set floated clearfix">
<li><a href="#masonry" class="selected">masonry</a></li>
<li><a href="#fitRows">fitRows</a></li>
<li><a href="#cellsByRow">cellsByRow</a></li>
<li><a href="#masonryHorizontal" class="horizontal">masonryHorizontal</a></li>
<li><a href="#fitColumns" class="horizontal">fitColumns</a></li>
<li><a href="#cellsByColumn" class="horizontal">cellsByColumn</a></li>
</ul>

12
_includes/option-buttons.js

@ -0,0 +1,12 @@
$('#options').find('.option-set a').click(function(){
var $this = $(this);
// don't proceed if already selected
if ( $this.hasClass('selected') ) {
return;
}
$this.parents('.option-set').find('.selected').removeClass('selected');
$this.addClass('selected');
});

54
_layouts/elements.html

@ -69,16 +69,7 @@
<h3>Layouts</h3>
<ul id="layouts" class="option-set floated clearfix">
<li><a href="#masonry" class="selected">masonry</a></li>
<li><a href="#fitRows">fitRows</a></li>
<li><a href="#cellsByRow">cellsByRow</a></li>
<li><a href="#masonryHorizontal" class="horizontal">masonryHorizontal</a></li>
<li><a href="#fitColumns" class="horizontal">fitColumns</a></li>
<li><a href="#cellsByColumn" class="horizontal">cellsByColumn</a></li>
</ul>
{% include layout-options.html %}
<h3>Etc</h3>
@ -109,8 +100,7 @@
$(function(){
var $demo = $('#demo'),
masonryLayout = true;
var $demo = $('#demo');
// hacky way of adding random size classes
$demo.find('.element').each(function(){
@ -207,32 +197,7 @@
return false;
});
var isHorizontal = false;
// change layout
$('#layouts a').click(function(){
var mode = $(this).attr('href').slice(1);
wasHorizontal = isHorizontal;
isHorizontal = $(this).hasClass('horizontal');
if ( wasHorizontal !== isHorizontal ) {
// need to do some clean up for transitions and sizes
var style = isHorizontal ?
{ height: '80%', width: $demo.width() } :
{ width: 'auto' };
$demo.addClass('no-transition').css( style );
setTimeout(function(){
$demo.removeClass('no-transition').isotope({ layoutMode : mode });
}, 100 )
} else {
// go ahead and apply new layout
$demo.isotope({ layoutMode : mode });
}
return false;
});
{% include layout-change.js %}
$('#insert').find('a').click(function(){
var i = Math.ceil( Math.random()*3 + 1 ),
@ -273,18 +238,7 @@
});
$('#options').find('.option-set a').click(function(){
var $this = $(this);
// don't proceed if already selected
if ( $this.hasClass('selected') ) {
return;
}
$this.parents('.option-set').find('.selected').removeClass('selected');
$this.addClass('selected');
})
{% include option-buttons.js %}
});
</script>

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

@ -3,7 +3,6 @@
title: Methods
category: docs
layout: doc
body_class: option-def
---

136
_posts/docs/2010-12-05-layouts.mdown

@ -0,0 +1,136 @@
---
title: Layouts
category: docs
layout: doc
body_class: option-def
---
Isotope is versatile in that it can accommodate multiple layout modes. You can set and change the layout mode via the `layoutMode` option.
### Example
{% highlight javascript %}
$('#container').isotope({ layoutMode: 'fitRows' });
{% endhighlight %}
Six layout modes are built into Isotope.
<h2 id="masonry">masonry</h2>
masonry is the default layout mode for Isotope. Item elements are arranged intelligently within a grid. For each item element, the script calculates the next best fit for the item within the grid.
**Options**
<dl class="clearfix">
<dt><code>columnWidth</code></dt>
<dd class="option-type">Integer</dd>
</dl>
The width of one column in the grid. If no value is set for `columnWidth`, default is the width of the first item element.
**Example**
{% highlight javascript %}
$('#container').isotope({
masonry: {
columnWidth: 240
}
});
{% endhighlight %}
<h2 id="fitRows">fitRows</h2>
Item elements are arranged into rows. Similar to what you would expect from a layout that uses `float: left`
<h2 id="cellsByRow">cellsByRow</h2>
A grid layout. The grid is defined by two options, `columnWidth` and `rowHeight`.
**Options**
<dl class="clearfix">
<dt><code>columnWidth</code></dt>
<dd class="option-type">Integer</dd>
</dl>
<dl class="clearfix">
<dt><code>rowHeight</code></dt>
<dd class="option-type">Integer</dd>
</dl>
**Example**
{% highlight javascript %}
$('#container').isotope({
layoutMode: 'cellsByRow',
cellsByRow: {
columnWidth: 240,
rowHeight: 360
}
});
{% endhighlight %}
<h2 id="masonryHorizontal">masonryHorizontal</h2>
The horizontal equivalent of masonry layout. Instead of progressing top-to-bottom, masonryHorizontal layout will progress left-to-right. Item elements are arranged intelligently within a grid. For each item element, the script calculates the next best fit for the item within the grid.
**Options**
<dl class="clearfix">
<dt><code>rowHeight</code></dt>
<dd class="option-type">Integer</dd>
</dl>
The width of one column in the grid. If no value is set for `rowHeight`, default is the height of the first item element.
**Example**
{% highlight javascript %}
$('#container').isotope({
masonryHorizontal: {
rowHeight: 360
}
});
{% endhighlight %}
<h2 id="fitRows">fitColumns</h2>
Item elements are arranged into columns. The horizontal equivalent of fitRows. Columns progress from left to right. Items within those columns are arranged top-to-bottom.
<h2 id="cellsByRow">cellsByColumn</h2>
A grid layout. The grid is defined by two options, `columnWidth` and `rowHeight`. The horizontal equivalent of cellsByRow.
**Options**
<dl class="clearfix">
<dt><code>columnWidth</code></dt>
<dd class="option-type">Integer</dd>
</dl>
<dl class="clearfix">
<dt><code>rowHeight</code></dt>
<dd class="option-type">Integer</dd>
</dl>
**Example**
{% highlight javascript %}
$('#container').isotope({
layoutMode: 'cellsByRow',
cellsByRow: {
columnWidth: 240,
rowHeight: 360
}
});
{% endhighlight %}

81
_posts/examples/2010-12-29-layouts.html

@ -0,0 +1,81 @@
---
layout: nil
title: Layouts
category: examples
---
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>{{ page.title }}</title>
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" />
</head>
<body>
<h1>{{ page.title }}</h1>
<section id="options" class="clearfix">
{% include layout-options.html %}
</section> <!-- #options -->
<div id="demo" class="iso-container variable-sizes">
{% for element in site.elements_ordered limit:20 %}
{% include element-partial.html %}
{% endfor %}
</div> <!-- #demo -->
<script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script src="../js/fake-element.js"></script>
<script>
$(function(){
var $demo = $('#demo'),
masonryLayout = true;
// hacky way of adding random size classes
$demo.find('.element').each(function(){
if ( Math.random() > 0.6 ) {
$(this).addClass('width2');
}
if ( Math.random() > 0.6 ) {
$(this).addClass('height2');
}
});
$demo.isotope({
itemSelector : '.element',
masonry : {
columnWidth : 120
},
masonryHorizontal : {
rowHeight: 120
},
cellsByRow : {
columnWidth : 240,
rowHeight : 240
},
cellsByColumn : {
columnWidth : 240,
rowHeight : 240
},
animationEngine : $.browser.opera ? 'jquery' : 'best-available',
});
{% include layout-change.js %}
{% include option-buttons.js %}
});
</script>
</body>
</html>

10
css/style.css

@ -347,16 +347,16 @@ pre, code {
}
.option-def dl {
margin-top: 1.8em;
padding-top: 0.5em;
border-top: 1px solid #333;
/* margin-top: 1.8em;*/
/* padding-top: 0.5em;*/
/* border-top: 1px solid #333;*/
}
.option-def dl dt,
.option-def dl dd {
float: left;
padding: 0 0.8em;;
padding: 0 1.2em;;
background: #161616;
/* height: 2.0em;*/
line-height: 36px;
@ -373,7 +373,7 @@ pre, code {
}
.option-def dl .option-type {
width: 60px;
/* width: 60px;*/
font-size: 13px;
color: #AAA;
font-style: italic;

Loading…
Cancel
Save