Browse Source

Merge branch 'master' into gh-pages

v1
David DeSandro 14 years ago
parent
commit
c376a08b06
  1. 35
      Rakefile
  2. 2
      _config.yml
  3. 6
      _includes/element-partial.html
  4. 11
      _layouts/elements.html
  5. 7
      _plugins/modulus.rb
  6. 10
      _posts/demos/2010-12-29-layout-modes.html
  7. 10
      _posts/demos/2010-12-31-relayout.html
  8. 9
      _posts/docs/2010-12-04-methods.mdown
  9. 7
      _posts/docs/2010-12-11-help.mdown
  10. 19
      _posts/tests/2011-03-27-destroy01.html
  11. 4
      _posts/tests/2011-03-27-no-items01.html
  12. 50
      _posts/tests/2011-04-26-item-position-data01.html
  13. 10
      _posts/tests/2011-05-13-jquery-animation01.html
  14. 11
      _posts/tests/2011-05-18-centered-masonry.html
  15. 432
      jquery.isotope.js
  16. 4
      jquery.isotope.min.js

35
Rakefile

@ -1,35 +0,0 @@
# automates minifying jquery.isotope.js
# requires Google Closure Compiler http://code.google.com/closure/compiler/
# from command line run:
# rake min COMPILER='path/to/compiler.jar'
file compiler = ENV["COMPILER"] || '../../resources/google-closure/compiler.jar'
js = 'jquery.isotope.js'
min_js = 'jquery.isotope.min.js'
desc "Generates #{min_js}"
task :min do
unless File.exists?( compiler )
puts "ERROR: Compiler not found at " + compiler
else
puts "Minifying jquery.isotope.js..."
sh "java -jar #{compiler} --js #{js} --js_output_file #{min_js}"
# Adds header comment
min = File.read( min_js )
File.open( min_js, 'w') do |f|
f.write File.readlines( js )[0..9].join()
f.write min
end
end
end
desc "Zips _site/ into isotope-site.zip on to Desktop"
task :zip do
# makes isotope-site/ directory
sh 'mkdir isotope-site;'
# copies _site/
sh 'cp -r _site/ isotope-site;'
# zips isotope-site/
sh 'zip -r ~/Desktop/isotope-site.zip isotope-site/;'
# removes isotope-site/
sh 'rm -rf isotope-site;'
end

2
_config.yml

@ -3,7 +3,7 @@ permalink: /:categories/:title.html
pygments: true pygments: true
isotope_js: jquery.isotope.min.js isotope_js: jquery.isotope.min.js
jquery_js: js/jquery-1.5.1.min.js jquery_js: js/jquery-1.5.1.min.js
exclude: [ Rakefile ] exclude: [ Makefile ]
random_order: [ 11, 91, 63, 38, 4, 25, 94, 29, 60, 48, 32, 67, 33, 37, 39, 84, 40, 7, 96, 8, 97, 9, 14, 99, 15, 19, 5, 36, 114, 20, 30, 80, 13, 47, 21, 3, 22, 31, 54, 66, 55, 71, 1, 23, 41, 70, 2, 77, 117, 79, 42, 95, 46, 50, 69, 53, 56, 72, 51, 73, 59, 74, 35, 49, 101, 88, 34, 76, 102, 75, 103, 81, 58, 6, 82, 26, 27, 44, 83, 45, 86, 68, 87, 104, 105, 10, 85, 43, 12, 109, 110, 113, 28, 106, 107, 108, 115, 62, 116, 0, 57, 111, 112, 61, 89, 90, 64, 65, 92, 93, 78, 24, 98, 100, 16, 17, 18, 52 ] random_order: [ 11, 91, 63, 38, 4, 25, 94, 29, 60, 48, 32, 67, 33, 37, 39, 84, 40, 7, 96, 8, 97, 9, 14, 99, 15, 19, 5, 36, 114, 20, 30, 80, 13, 47, 21, 3, 22, 31, 54, 66, 55, 71, 1, 23, 41, 70, 2, 77, 117, 79, 42, 95, 46, 50, 69, 53, 56, 72, 51, 73, 59, 74, 35, 49, 101, 88, 34, 76, 102, 75, 103, 81, 58, 6, 82, 26, 27, 44, 83, 45, 86, 68, 87, 104, 105, 10, 85, 43, 12, 109, 110, 113, 28, 106, 107, 108, 115, 62, 116, 0, 57, 111, 112, 61, 89, 90, 64, 65, 92, 93, 78, 24, 98, 100, 16, 17, 18, 52 ]

6
_includes/element-partial.html

@ -1,5 +1,7 @@
{% capture a %}{{ element.number | modulus:7 | modulus:2 }}{% endcapture %}
<div class="element {% for cat in element.categories %}{{ cat }} {% endfor %} {% if page.infinite_scroll %} width2 height2 {% endif %}" data-symbol="{{ element.symbol }}" data-category="{{ element.categories[0] }}"> {% capture b %}{{ element.number | modulus:3 }}{% endcapture %}
{% capture classnames %}{% for cat in element.categories %}{{ cat }} {% endfor %} {% if page.infinite_scroll %} width2 height2 {% else %} {% if a == '1' %} width2 {% endif %} {% if b == '0' %} height2 {% endif %} {% endif %} {% endcapture %}
<div class="element {{ classnames }}" data-symbol="{{ element.symbol }}" data-category="{{ element.categories[0] }}">
<p class="number">{{ element.number }}</p> <p class="number">{{ element.number }}</p>
<h3 class="symbol">{{ element.symbol }}</h3> <h3 class="symbol">{{ element.symbol }}</h3>
<h2 class="name">{{ element.name }}</h2> <h2 class="name">{{ element.name }}</h2>

11
_layouts/elements.html

@ -95,17 +95,6 @@
$(function(){ $(function(){
// 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');
}
});
$container.isotope({ $container.isotope({
itemSelector : '.element', itemSelector : '.element',
// layoutMode : 'fitRows', // layoutMode : 'fitRows',

7
_plugins/modulus.rb

@ -0,0 +1,7 @@
module MathFilter
def modulus(input, operand)
to_number(input) % to_number(operand)
end
end
Liquid::Template.register_filter(MathFilter)

10
_posts/demos/2010-12-29-layout-modes.html

@ -34,16 +34,6 @@ related: layouts
$(function(){ $(function(){
// 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');
}
});
$container.isotope({ $container.isotope({
itemSelector : '.element', itemSelector : '.element',
masonry : { masonry : {

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

@ -45,16 +45,6 @@ related: methods
$(function(){ $(function(){
// 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');
}
});
$container.isotope({ $container.isotope({
itemSelector: '.element', itemSelector: '.element',
masonry : { masonry : {

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

@ -92,20 +92,13 @@ Positions specified item elements in layout.
{% endhighlight %} {% endhighlight %}
Modifies options for plugin instance. Can be used to get and set options. Unlike passing options through `.isotope()`, using the `option` method will not trigger layout. Sets options for plugin instance. Unlike passing options through `.isotope()`, using the `option` method will not trigger layout.
{% highlight javascript %} {% highlight javascript %}
// sets multiple options // sets multiple options
.isotope( 'option', { layoutMode: 'fitRows', filter: '.my-filter' } ) .isotope( 'option', { layoutMode: 'fitRows', filter: '.my-filter' } )
// set single option
.isotope( 'option', 'layoutMode', 'straightDown' )
// get option
.isotope( 'option', 'layoutMode' )
// returns 'straightDown'
{% endhighlight %} {% endhighlight %}

7
_posts/docs/2010-12-11-troubleshooting.mdown → _posts/docs/2010-12-11-help.mdown

@ -1,6 +1,6 @@
--- ---
title: Troubleshooting title: Help
category: docs category: docs
layout: doc layout: doc
related: z-etc related: z-etc
@ -13,7 +13,6 @@ toc:
- { title: @font-face fonts, anchor: fontface_fonts } - { title: @font-face fonts, anchor: fontface_fonts }
- { title: CSS transforms in Opera, anchor: css_transforms_in_opera } - { title: CSS transforms in Opera, anchor: css_transforms_in_opera }
- { title: Infinite Scroll with filtering or sorting, anchor: infinite_scroll_with_filtering_or_sorting} - { title: Infinite Scroll with filtering or sorting, anchor: infinite_scroll_with_filtering_or_sorting}
- { title: Prepending items, anchor: prepending_items }
- { title: Flash, anchor: flash } - { title: Flash, anchor: flash }
--- ---
@ -123,10 +122,6 @@ I recommend against using Infinite Scroll with filtering or sorting. This combin
If you do plan on implementing Infinite Scroll with filtering or sorting (which is a _bad idea_), use the `insert` method instead of `appended`. If you do plan on implementing Infinite Scroll with filtering or sorting (which is a _bad idea_), use the `insert` method instead of `appended`.
## Prepending items
While there is no prepend method built into Isotope, you can add items to the beginning of a Isotope layout by using sorting and [`updateSortData`](methods.html#getsortdata). See [Isotope - prepending items on jsFiddle](http://jsfiddle.net/desandro/zXWkw/4/).
## Flash ## Flash
[Using CSS transforms with Flash content is a bit buggy in Safari and Firefox](http://dropshado.ws/post/4085720152/css-transforms-breaking-flash). This is problematic when using Isotope on item elements that contain Flash content like YouTube or Vimeo videos, Flash ads, or Flash audio players. [Using CSS transforms with Flash content is a bit buggy in Safari and Firefox](http://dropshado.ws/post/4085720152/css-transforms-breaking-flash). This is problematic when using Isotope on item elements that contain Flash content like YouTube or Vimeo videos, Flash ads, or Flash audio players.

19
_posts/tests/2011-03-27-destroy01.html

@ -12,7 +12,12 @@ category: tests
</style> </style>
<section id="copy"> <section id="copy">
<p>After <code>destroy</code>-ing Isotope, original CSS gets re-applied</p> <p>Click <em>init</em> button the <em>destroy</em>. Original CSS, pre-init, should be re-applied, all items back to visibility.</p>
</section>
<section id="options">
<button id="init">Init Isotope instance</button>
<button id="destroy">Destroy Isotope instance</button>
</section> </section>
<div id="container" style="height: 600px"> <div id="container" style="height: 600px">
@ -28,9 +33,15 @@ category: tests
var $container = $('#container'); var $container = $('#container');
$container.isotope({ $('#init').click(function(){
itemSelector: '.element', $container.isotope({
filter: '.metal' itemSelector: '.element',
filter: '.metal'
});
});
$('#destroy').click(function(){
$container.isotope('destroy');
}); });
}); });

4
_posts/tests/2011-03-27-no-items01.html

@ -5,7 +5,7 @@ category: tests
--- ---
<section id="copy"> <section id="copy">
<p>What happens when there are no items for Isotope/</p> <p>What happens when there are no items for Isotope? If no items match `itemSelector`, container collapses. Plugin still <code>return this</code>.</p>
</section> </section>
<div id="container"> <div id="container">
@ -23,7 +23,7 @@ category: tests
$container.isotope({ $container.isotope({
itemSelector: '.foo' itemSelector: '.foo'
}); }).css('border', '10px solid');
}); });
</script> </script>

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

@ -5,30 +5,11 @@ category: tests
--- ---
<section id="copy"> <section id="copy">
<p></p> <p><code>itemPositionDataEnabled</code> option is enabled. </p>
</section> </section>
<section id="options" class="clearfix"> <section id="options" class="clearfix">
<h3>Filters</h3>
<ul id="filters" class="option-set floated clearfix">
<li><a href="#show-all" class="selected">show all</a></li>
<li><a href="#metalloid">metalloid</a></li>
<li><a href="#metal">metal</a></li>
<li><a href="#alkali">alkali</a></li>
<li><a href="#alkaline-earth">alkaline-earth</a></li>
<li><a href="#inner-transition">inner-transition</a></li>
<li><a href="#lanthanoid">lanthanoid</a></li>
<li><a href="#actinoid">actinoid</a></li>
<li><a href="#transition">transition</a></li>
<li><a href="#post-transition">post-transition</a></li>
<li><a href="#nonmetal">nonmetal</a></li>
<li><a href="#other">other</a></li>
<li><a href="#halogen">halogen</a></li>
<li><a href="#noble-gas">noble-gas</a></li>
</ul>
{% include sort-buttons.html %} {% include sort-buttons.html %}
<h3>Etc</h3> <h3>Etc</h3>
@ -39,7 +20,7 @@ category: tests
</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 %}
@ -48,26 +29,25 @@ category: tests
<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> <script>
$(function(){ $(function(){
var $container = $('#container'); var $container = $('#container');
// 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');
}
});
{% include sort-buttons.js %} {% include sort-buttons.js %}
// change size of clicked element // toggle variable sizes of all elements
$container.find('.element').live('click', function(){ $('#toggle-sizes').find('a').click(function(){
$(this).toggleClass('large'); $container
$container.isotope('reLayout'); .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({

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

@ -61,16 +61,6 @@ category: tests
var $container = $('#container'); var $container = $('#container');
// 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');
}
});
{% include sort-buttons.js %} {% include sort-buttons.js %}
$('#filters').find('a').click(function(){ $('#filters').find('a').click(function(){

11
_posts/tests/2011-05-18-centered-masonry.html

@ -162,17 +162,6 @@ category: tests
$(function(){ $(function(){
// 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');
}
});
$container.isotope({ $container.isotope({
itemSelector : '.element', itemSelector : '.element',
masonry : { masonry : {

432
jquery.isotope.js

@ -1,5 +1,5 @@
/** /**
* Isotope v1.2.110520 * Isotope v1.3.110524
* An exquisite jQuery plugin for magical layouts * An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co * http://isotope.metafizzy.co
* *
@ -387,10 +387,8 @@
this.reloadItems(); this.reloadItems();
// get top left position of where the bricks should be // get top left position of where the bricks should be
var $cursor = $( document.createElement('div') ); var $cursor = $( document.createElement('div') ).prependTo( this.element );
this.element.prepend( $cursor ); this.offset = $cursor.position();
this.posTop = Math.round( $cursor.position().top );
this.posLeft = Math.round( $cursor.position().left );
$cursor.remove(); $cursor.remove();
// add isotope class first time around // add isotope class first time around
@ -402,7 +400,7 @@
// bind resize method // bind resize method
if ( this.options.resizable ) { if ( this.options.resizable ) {
$(window).bind( 'smartresize.isotope', function() { $(window).bind( 'smartresize.isotope', function() {
instance.element.isotope('resize'); instance.resize();
}); });
} }
@ -441,11 +439,7 @@
}, },
option: function( key, value ){ option: function( key, value ){
// change options AFTER initialization:
// get/change options AFTER initialization:
// you don't have to support all these cases,
// but here's how:
// signature: $('#foo').bar({ cool:false }); // signature: $('#foo').bar({ cool:false });
if ( $.isPlainObject( key ) ){ if ( $.isPlainObject( key ) ){
this.options = $.extend(true, this.options, key); this.options = $.extend(true, this.options, key);
@ -453,18 +447,7 @@
for ( optionName in key ) { for ( optionName in key ) {
this._updateOption( optionName ); this._updateOption( optionName );
} }
// signature: $('#foo').option('cool'); - getter
} else if ( key && typeof value === "undefined" ){
return this.options[ key ];
// signature: $('#foo').bar('option', 'baz', false);
} else {
this.options[ key ] = value;
this._updateOption( key );
} }
return this; // make sure to return the instance!
}, },
// ====================== updaters ====================== // // ====================== updaters ====================== //
@ -578,16 +561,13 @@
}; };
this.$filteredAtoms.sort( sortFn ); this.$filteredAtoms.sort( sortFn );
return this;
}, },
_getSorter : function( elem, sortBy ) { _getSorter : function( elem, sortBy ) {
return $(elem).data('isotope-sort-data')[ sortBy ]; return $(elem).data('isotope-sort-data')[ sortBy ];
}, },
// ====================== Layout ====================== // ====================== Layout Helpers ======================
_translate : function( x, y ) { _translate : function( x, y ) {
return { translate : [ x, y ] }; return { translate : [ x, y ] };
@ -598,6 +578,8 @@
}, },
_pushPosition : function( $elem, x, y ) { _pushPosition : function( $elem, x, y ) {
x += this.offset.left;
y += this.offset.top;
var position = this.getPositionStyles( x, y ); var position = this.getPositionStyles( x, y );
this.styleQueue.push({ $el: $elem, style: position }); this.styleQueue.push({ $el: $elem, style: position });
if ( this.options.itemPositionDataEnabled ) { if ( this.options.itemPositionDataEnabled ) {
@ -644,20 +626,20 @@
} }
this.isLaidOut = true; this.isLaidOut = true;
return this;
}, },
resize : function() { resize : function() {
return this[ '_' + this.options.layoutMode + 'Resize' ](); if ( this[ '_' + this.options.layoutMode + 'ResizeChanged' ]() ) {
this.reLayout();
}
}, },
reLayout : function( callback ) { reLayout : function( callback ) {
return this[ '_' + this.options.layoutMode + 'Reset' ]() this[ '_' + this.options.layoutMode + 'Reset' ]();
.layout( this.$filteredAtoms, callback ); this.layout( this.$filteredAtoms, callback );
}, },
@ -685,7 +667,8 @@
instance.$filteredAtoms = instance.$filteredAtoms.add( $filteredAtoms ); instance.$filteredAtoms = instance.$filteredAtoms.add( $filteredAtoms );
}); });
this._sort().reLayout( callback ); this._sort();
this.reLayout( callback );
}, },
@ -734,7 +717,7 @@
this.$allAtoms = this._shuffleArray( this.$allAtoms ); this.$allAtoms = this._shuffleArray( this.$allAtoms );
this.$filteredAtoms = this._filter( this.$allAtoms ); this.$filteredAtoms = this._filter( this.$allAtoms );
return this.reLayout( callback ); this.reLayout( callback );
}, },
// destroys widget, returns elements and container back (close) to original style // destroys widget, returns elements and container back (close) to original style
@ -770,11 +753,15 @@
}, },
// ====================== LAYOUTS ======================
// calculates number of rows or columns // calculates number of rows or columns
// requires columnWidth or rowHeight to be set on namespaced object // requires columnWidth or rowHeight to be set on namespaced object
// i.e. this.masonry.columnWidth = 200 // i.e. this.masonry.columnWidth = 200
_getSegments : function( namespace, isRows ) { _getSegments : function( isRows ) {
var measure = isRows ? 'rowHeight' : 'columnWidth', var namespace = this.options.layoutMode,
measure = isRows ? 'rowHeight' : 'columnWidth',
size = isRows ? 'height' : 'width', size = isRows ? 'height' : 'width',
UCSize = isRows ? 'Height' : 'Width', UCSize = isRows ? 'Height' : 'Width',
segmentsName = isRows ? 'rows' : 'cols', segmentsName = isRows ? 'rows' : 'cols',
@ -798,44 +785,32 @@
// i.e. this.masonry.columnWidth = ... // i.e. this.masonry.columnWidth = ...
this[ namespace ][ measure ] = segmentSize; this[ namespace ][ measure ] = segmentSize;
return this;
}, },
// ====================== LAYOUTS ====================== _checkIfSegmentsChanged : function( isRows ) {
var namespace = this.options.layoutMode,
segmentsName = isRows ? 'rows' : 'cols',
prevSegments = this[ namespace ][ segmentsName ];
// update cols/rows
this._getSegments( isRows );
// return if updated cols/rows is not equal to previous
return ( this[ namespace ][ segmentsName ] !== prevSegments );
},
// ====================== Masonry ====================== // ====================== Masonry ======================
_masonryPlaceBrick : function( $brick, setCount, setY ) { _masonryReset : function() {
// here, `this` refers to a child element or "brick" // layout-specific props
// get the minimum Y value from the columns this.masonry = {};
var minimumY = Math.min.apply( Math, setY ), // FIXME shouldn't have to call this again
setHeight = minimumY + $brick.outerHeight(true), this._getSegments();
i = setY.length, var i = this.masonry.cols;
shortCol = i, this.masonry.colYs = [];
setSpan = this.masonry.cols + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) { while (i--) {
if ( setY[i] === minimumY ) { this.masonry.colYs.push( 0 );
shortCol = i;
}
}
// position the brick
x = this.masonry.columnWidth * shortCol + this.posLeft;
y = minimumY;
this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns
for ( i=0; i < setSpan; i++ ) {
this.masonry.colYs[ shortCol + i ] = setHeight;
} }
}, },
_masonryLayout : function( $elems ) { _masonryLayout : function( $elems ) {
var instance = this; var instance = this;
$elems.each(function(){ $elems.each(function(){
@ -846,7 +821,7 @@
if ( colSpan === 1 ) { if ( colSpan === 1 ) {
// if brick spans only one column, just like singleMode // if brick spans only one column, just like singleMode
instance._masonryPlaceBrick( $this, instance.masonry.cols, instance.masonry.colYs ); instance._masonryPlaceBrick( $this, instance.masonry.colYs );
} else { } else {
// brick spans more than one column // brick spans more than one column
// how many different places could this brick fit horizontally // how many different places could this brick fit horizontally
@ -863,45 +838,58 @@
groupY[i] = Math.max.apply( Math, groupColY ); groupY[i] = Math.max.apply( Math, groupColY );
} }
instance._masonryPlaceBrick( $this, groupCount, groupY ); instance._masonryPlaceBrick( $this, groupY );
} }
}); });
return this;
}, },
// reset // worker method that places brick in the columnSet
_masonryReset : function() { // with the the minY
// layout-specific props _masonryPlaceBrick : function( $brick, setY ) {
this.masonry = {}; // get the minimum Y value from the columns
// FIXME shouldn't have to call this again var minimumY = Math.min.apply( Math, setY ),
this._getSegments('masonry'); setHeight = minimumY + $brick.outerHeight(true),
var i = this.masonry.cols; i = setY.length,
this.masonry.colYs = []; shortCol = i,
setSpan = this.masonry.cols + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) { while (i--) {
this.masonry.colYs.push( this.posTop ); if ( setY[i] === minimumY ) {
shortCol = i;
}
} }
return this;
},
_masonryResize : function() { // position the brick
var prevColCount = this.masonry.cols; x = this.masonry.columnWidth * shortCol;
// get updated colCount y = minimumY;
this._getSegments('masonry'); this._pushPosition( $brick, x, y );
if ( this.masonry.cols !== prevColCount ) {
// if column count has changed, do a new column cound // apply setHeight to necessary columns
this.reLayout(); for ( i=0; i < setSpan; i++ ) {
this.masonry.colYs[ shortCol + i ] = setHeight;
} }
return this;
}, },
_masonryGetContainerSize : function() { _masonryGetContainerSize : function() {
var containerHeight = Math.max.apply( Math, this.masonry.colYs ) - this.posTop; var containerHeight = Math.max.apply( Math, this.masonry.colYs );
return { height: containerHeight }; return { height: containerHeight };
}, },
_masonryResizeChanged : function() {
return this._checkIfSegmentsChanged();
},
// ====================== fitRows ======================
// ====================== fitRows ====================== _fitRowsReset : function() {
this.fitRows = {
x : 0,
y : 0,
height : 0
};
},
_fitRowsLayout : function( $elems ) { _fitRowsLayout : function( $elems ) {
this.width = this.element.width(); this.width = this.element.width();
@ -920,133 +908,100 @@
} }
// position the atom // position the atom
x = instance.fitRows.x + instance.posLeft; x = instance.fitRows.x;
y = instance.fitRows.y + instance.posTop; y = instance.fitRows.y;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
instance.fitRows.height = Math.max( instance.fitRows.y + atomH, instance.fitRows.height ); instance.fitRows.height = Math.max( instance.fitRows.y + atomH, instance.fitRows.height );
instance.fitRows.x += atomW; instance.fitRows.x += atomW;
}); });
return this;
},
_fitRowsReset : function() {
this.fitRows = {
x : 0,
y : 0,
height : 0
};
return this;
}, },
_fitRowsGetContainerSize : function () { _fitRowsGetContainerSize : function () {
return { height : this.fitRows.height }; return { height : this.fitRows.height };
}, },
_fitRowsResize : function() { _fitRowsResizeChanged : function() {
return this.reLayout(); return true;
}, },
// ====================== cellsByRow ====================== // ====================== cellsByRow ======================
_cellsByRowReset : function() { _cellsByRowReset : function() {
this.cellsByRow = {}; this.cellsByRow = {
this._getSegments('cellsByRow'); index : 0
this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true); };
return this; // get this.cellsByRow.columnWidth
this._getSegments();
// get this.cellsByRow.rowHeight
this._getSegments(true);
}, },
_cellsByRowLayout : function( $elems ) { _cellsByRowLayout : function( $elems ) {
var instance = this, var instance = this,
cols = this.cellsByRow.cols; props = this.cellsByRow;
this.cellsByRow.atomsLen = $elems.length; $elems.each( function(){
$elems.each( function( i ){
var $this = $(this), var $this = $(this),
x = ( i % cols + 0.5 ) * instance.cellsByRow.columnWidth - col = props.index % props.cols,
$this.outerWidth(true) / 2 + instance.posLeft, row = ~~( props.index / props.cols ),
y = ( ~~( i / cols ) + 0.5 ) * instance.cellsByRow.rowHeight - x = ( col + 0.5 ) * props.columnWidth -
$this.outerHeight(true) / 2 + instance.posTop; $this.outerWidth(true) / 2,
y = ( row + 0.5 ) * props.rowHeight -
$this.outerHeight(true) / 2;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
props.index ++;
}); });
return this;
}, },
_cellsByRowGetContainerSize : function() { _cellsByRowGetContainerSize : function() {
return { height : Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop }; return { height : Math.ceil( this.$filteredAtoms.length / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.offset.top };
}, },
_cellsByRowResize : function() { _cellsByRowResizeChanged : function() {
var prevCols = this.cellsByRow.cols; return this._checkIfSegmentsChanged();
this._getSegments('cellsByRow');
// if column count has changed, do a new column cound
if ( this.cellsByRow.cols !== prevCols ) {
this.reLayout();
}
return this;
}, },
// ====================== straightDown ====================== // ====================== straightDown ======================
_straightDownReset : function() { _straightDownReset : function() {
this.straightDown = { this.straightDown = {
y : 0 y : 0
}; };
return this;
}, },
_straightDownLayout : function( $elems ) { _straightDownLayout : function( $elems ) {
var instance = this; var instance = this;
$elems.each( function( i ){ $elems.each( function( i ){
var $this = $(this), var $this = $(this);
y = instance.straightDown.y + instance.posTop; instance._pushPosition( $this, 0, instance.straightDown.y );
instance._pushPosition( $this, instance.posLeft, y );
instance.straightDown.y += $this.outerHeight(true); instance.straightDown.y += $this.outerHeight(true);
}); });
return this;
}, },
_straightDownGetContainerSize : function() { _straightDownGetContainerSize : function() {
return { height : this.straightDown.y + this.posTop }; return { height : this.straightDown.y };
}, },
_straightDownResize : function() { _straightDownResizeChanged : function() {
this.reLayout(); return true;
return this;
}, },
// ====================== masonryHorizontal ====================== // ====================== masonryHorizontal ======================
_masonryHorizontalPlaceBrick : function( $brick, setCount, setX ) { _masonryHorizontalReset : function() {
// here, `this` refers to a child element or "brick" // layout-specific props
// get the minimum Y value from the columns this.masonryHorizontal = {};
var minimumX = Math.min.apply( Math, setX ), // FIXME shouldn't have to call this again
setWidth = minimumX + $brick.outerWidth(true), this._getSegments( true );
i = setX.length, var i = this.masonryHorizontal.rows;
smallRow = i, this.masonryHorizontal.rowXs = [];
setSpan = this.masonryHorizontal.rows + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) { while (i--) {
if ( setX[i] === minimumX ) { this.masonryHorizontal.rowXs.push( 0 );
smallRow = i;
}
}
// position the brick
x = minimumX;
y = this.masonryHorizontal.rowHeight * smallRow + this.posTop;
this._pushPosition( $brick, x, y );
// apply setHeight to necessary columns
for ( i=0; i < setSpan; i++ ) {
this.masonryHorizontal.rowXs[ smallRow + i ] = setWidth;
} }
}, },
_masonryHorizontalLayout : function( $elems ) { _masonryHorizontalLayout : function( $elems ) {
@ -1059,7 +1014,7 @@
if ( rowSpan === 1 ) { if ( rowSpan === 1 ) {
// if brick spans only one column, just like singleMode // if brick spans only one column, just like singleMode
instance._masonryHorizontalPlaceBrick( $this, instance.masonryHorizontal.rows, instance.masonryHorizontal.rowXs ); instance._masonryHorizontalPlaceBrick( $this, instance.masonryHorizontal.rowXs );
} else { } else {
// brick spans more than one row // brick spans more than one row
// how many different places could this brick fit horizontally // how many different places could this brick fit horizontally
@ -1075,44 +1030,50 @@
groupX[i] = Math.max.apply( Math, groupRowX ); groupX[i] = Math.max.apply( Math, groupRowX );
} }
instance._masonryHorizontalPlaceBrick( $this, groupCount, groupX ); instance._masonryHorizontalPlaceBrick( $this, groupX );
} }
}); });
return this;
}, },
_masonryHorizontalReset : function() { _masonryHorizontalPlaceBrick : function( $brick, setX ) {
// layout-specific props // here, `this` refers to a child element or "brick"
this.masonryHorizontal = {}; // get the minimum Y value from the columns
// FIXME shouldn't have to call this again var minimumX = Math.min.apply( Math, setX ),
this._getSegments( 'masonryHorizontal', true ); setWidth = minimumX + $brick.outerWidth(true),
var i = this.masonryHorizontal.rows; i = setX.length,
this.masonryHorizontal.rowXs = []; smallRow = i,
setSpan = this.masonryHorizontal.rows + 1 - i,
x, y ;
// Which column has the minY value, closest to the left
while (i--) { while (i--) {
this.masonryHorizontal.rowXs.push( this.posLeft ); if ( setX[i] === minimumX ) {
smallRow = i;
}
} }
return this;
},
_masonryHorizontalResize : function() { // position the brick
var prevRows = this.masonryHorizontal.rows; x = minimumX;
// get updated colCount y = this.masonryHorizontal.rowHeight * smallRow;
this._getSegments( 'masonryHorizontal', true ); this._pushPosition( $brick, x, y );
if ( this.masonryHorizontal.rows !== prevRows ) {
// if column count has changed, do a new column cound // apply setHeight to necessary columns
this.reLayout(); for ( i=0; i < setSpan; i++ ) {
this.masonryHorizontal.rowXs[ smallRow + i ] = setWidth;
} }
return this;
}, },
_masonryHorizontalGetContainerSize : function() { _masonryHorizontalGetContainerSize : function() {
var containerWidth = Math.max.apply( Math, this.masonryHorizontal.rowXs ) - this.posLeft; var containerWidth = Math.max.apply( Math, this.masonryHorizontal.rowXs );
return { width: containerWidth }; return { width: containerWidth };
}, },
_masonryHorizontalResizeChanged : function() {
return this._checkIfSegmentsChanged(true);
},
// ====================== fitColumns ======================
// ====================== fitColumns ======================
_fitColumnsReset : function() { _fitColumnsReset : function() {
this.fitColumns = { this.fitColumns = {
@ -1120,7 +1081,6 @@
y : 0, y : 0,
width : 0 width : 0
}; };
return this;
}, },
_fitColumnsLayout : function( $elems ) { _fitColumnsLayout : function( $elems ) {
@ -1139,94 +1099,84 @@
} }
// position the atom // position the atom
x = instance.fitColumns.x + instance.posLeft; x = instance.fitColumns.x;
y = instance.fitColumns.y + instance.posTop; y = instance.fitColumns.y;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
instance.fitColumns.width = Math.max( instance.fitColumns.x + atomW, instance.fitColumns.width ); instance.fitColumns.width = Math.max( instance.fitColumns.x + atomW, instance.fitColumns.width );
instance.fitColumns.y += atomH; instance.fitColumns.y += atomH;
}); });
return this;
}, },
_fitColumnsGetContainerSize : function () { _fitColumnsGetContainerSize : function () {
return { width : this.fitColumns.width }; return { width : this.fitColumns.width };
}, },
_fitColumnsResize : function() { _fitColumnsResizeChanged : function() {
return this.reLayout(); return true;
}, },
// ====================== cellsByColumn ====================== // ====================== cellsByColumn ======================
_cellsByColumnReset : function() { _cellsByColumnReset : function() {
this.cellsByColumn = {}; this.cellsByColumn = {
this._getSegments( 'cellsByColumn', true ); index : 0
this.cellsByColumn.columnWidth = this.options.cellsByColumn.columnWidth || this.$allAtoms.outerHeight(true); };
return this; // get this.cellsByColumn.columnWidth
this._getSegments();
// get this.cellsByColumn.rowHeight
this._getSegments(true);
}, },
_cellsByColumnLayout : function( $elems ) { _cellsByColumnLayout : function( $elems ) {
var instance = this, var instance = this,
rows = this.cellsByColumn.rows; props = this.cellsByColumn;
this.cellsByColumn.atomsLen = $elems.length; $elems.each( function(){
$elems.each( function( i ){
var $this = $(this), var $this = $(this),
x = ( ~~( i / rows ) + 0.5 ) * instance.cellsByColumn.columnWidth - col = ~~( props.index / props.rows ),
$this.outerWidth(true) / 2 + instance.posLeft, row = props.index % props.rows,
y = ( i % rows + 0.5 ) * instance.cellsByColumn.rowHeight - x = ( col + 0.5 ) * props.columnWidth - $this.outerWidth(true) / 2,
$this.outerHeight(true) / 2 + instance.posTop; y = ( row + 0.5 ) * props.rowHeight - $this.outerHeight(true) / 2;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
props.index ++;
}); });
return this;
}, },
_cellsByColumnGetContainerSize : function() { _cellsByColumnGetContainerSize : function() {
return { width : Math.ceil( this.cellsByColumn.atomsLen / this.cellsByColumn.rows ) * this.cellsByColumn.columnWidth + this.posLeft }; return { width : Math.ceil( this.$filteredAtoms.length / this.cellsByColumn.rows ) * this.cellsByColumn.columnWidth };
}, },
_cellsByColumnResize : function() { _cellsByColumnResizeChanged : function() {
var prevRows = this.cellsByColumn.rows; return this._checkIfSegmentsChanged(true);
this._getSegments( 'cellsByColumn', true );
// if column count has changed, do a new column cound
if ( this.cellsByColumn.rows !== prevRows ) {
this.reLayout();
}
return this;
}, },
// ====================== straightAcross ====================== // ====================== straightAcross ======================
_straightAcrossReset : function() { _straightAcrossReset : function() {
this.straightAcross = { this.straightAcross = {
x : 0 x : 0
}; };
return this; },
},
_straightAcrossLayout : function( $elems ) { _straightAcrossLayout : function( $elems ) {
var instance = this; var instance = this;
$elems.each( function( i ){ $elems.each( function( i ){
var $this = $(this), var $this = $(this);
x = instance.straightAcross.x + instance.posLeft; instance._pushPosition( $this, instance.straightAcross.x, 0 );
instance._pushPosition( $this, x, instance.posTop ); instance.straightAcross.x += $this.outerWidth(true);
instance.straightAcross.x += $this.outerWidth(true); });
}); },
return this;
},
_straightAcrossGetContainerSize : function() { _straightAcrossGetContainerSize : function() {
return { width : this.straightAcross.x + this.posLeft }; return { width : this.straightAcross.x };
}, },
_straightAcrossResize : function() { _straightAcrossResizeChanged : function() {
this.reLayout(); return true;
return this; }
}
}; };
@ -1278,7 +1228,7 @@
// call method // call method
var args = Array.prototype.slice.call( arguments, 1 ); var args = Array.prototype.slice.call( arguments, 1 );
return this.each(function(){ this.each(function(){
var instance = $.data( this, 'isotope' ); var instance = $.data( this, 'isotope' );
if ( !instance ) { if ( !instance ) {
return $.error( "cannot call methods on isotope prior to initialization; " + return $.error( "cannot call methods on isotope prior to initialization; " +
@ -1291,17 +1241,21 @@
instance[ options ].apply( instance, args ); instance[ options ].apply( instance, args );
}); });
} else { } else {
return this.each(function() { this.each(function() {
var instance = $.data( this, 'isotope' ); var instance = $.data( this, 'isotope' );
if ( instance ) { if ( instance ) {
// apply options & init // apply options & init
instance.option( options || {} )._init(); instance.option( options || {} );
instance._init();
} else { } else {
// initialize new instance // initialize new instance
$.data( this, 'isotope', new $.Isotope( options, this ) ); $.data( this, 'isotope', new $.Isotope( options, this ) );
} }
}); });
} }
// return jQuery object
// so plugin methods do not have to
return this;
}; };
})( window, jQuery ); })( window, jQuery );

4
jquery.isotope.min.js vendored

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