Skip to content

Commit

Permalink
fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
brunjo committed Mar 12, 2014
1 parent 879001d commit 7315dce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 31 deletions.
43 changes: 16 additions & 27 deletions jquery.row-grid.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
(function($){
$.fn.rowGrid = function( options ) {
if ( this.length == 0 ) {
console.error( 'No element found for "' + this.selector + '".' );
return this;
}
if ( this.length > 1 ) {
return this.each(
function() {
$(this).rowGrid( options );
return this.each(function() {
if(options === 'appended') {
options = $(this).data('grid-options');
var $lastRow = this.children('.' + options.lastRowClass);
var items = $lastRow.nextAll().add($lastRow);
layout(this, options, items);
} else {
options = $.extend( {}, $.fn.rowGrid.defaults, options );
$(this).data('grid-options', options);
layout(this, options);

if(options.resize) {
$(window).on('resize.rowGrid', {container: this}, function(event) {
layout(event.data.container, options);
});
}
);
}

if(options === 'appended') {
options = this.data('grid-options');
var $lastRow = this.children('.' + options.lastRowClass);
var items = $lastRow.nextAll().add($lastRow);
layout(this[0], options, items);
} else {
options = $.extend( {}, $.fn.rowGrid.defaults, options );
this.data('grid-options', options);
layout(this[0], options);

if(options.resize) {
$(window).on('resize.rowGrid', {container: this[0]}, function(event) {
layout(event.data.container, options);
});
}
}
return this;
});
};

$.fn.rowGrid.defaults = {
Expand Down
8 changes: 4 additions & 4 deletions jquery.row-grid.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7315dce

Please sign in to comment.