Browse Source

src : internal plugin methods will not `return this`; remove option getter

pull/96/head
David DeSandro 14 years ago
parent
commit
f0a4c14136
  1. 66
      jquery.isotope.js
  2. 4
      jquery.isotope.min.js

66
jquery.isotope.js

@ -1,5 +1,5 @@
/** /**
* Isotope v1.2.110520 * Isotope v1.2.110523
* An exquisite jQuery plugin for magical layouts * An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co * http://isotope.metafizzy.co
* *
@ -441,10 +441,7 @@
}, },
option: function( key, value ){ option: function( key, value ){
// get/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 ) ){
@ -454,17 +451,11 @@
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); // signature: $('#foo').bar('option', 'baz', false);
} else { } else {
this.options[ key ] = value; this.options[ key ] = value;
this._updateOption( key ); this._updateOption( key );
} }
return this; // make sure to return the instance!
}, },
// ====================== updaters ====================== // // ====================== updaters ====================== //
@ -578,8 +569,6 @@
}; };
this.$filteredAtoms.sort( sortFn ); this.$filteredAtoms.sort( sortFn );
return this;
}, },
_getSorter : function( elem, sortBy ) { _getSorter : function( elem, sortBy ) {
@ -644,20 +633,18 @@
} }
this.isLaidOut = true; this.isLaidOut = true;
return this;
}, },
resize : function() { resize : function() {
return this[ '_' + this.options.layoutMode + 'Resize' ](); this[ '_' + this.options.layoutMode + 'Resize' ]();
}, },
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 +672,8 @@
instance.$filteredAtoms = instance.$filteredAtoms.add( $filteredAtoms ); instance.$filteredAtoms = instance.$filteredAtoms.add( $filteredAtoms );
}); });
this._sort().reLayout( callback ); this._sort();
this.reLayout( callback );
}, },
@ -734,7 +722,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
@ -798,8 +786,6 @@
// i.e. this.masonry.columnWidth = ... // i.e. this.masonry.columnWidth = ...
this[ namespace ][ measure ] = segmentSize; this[ namespace ][ measure ] = segmentSize;
return this;
}, },
// ====================== LAYOUTS ====================== // ====================== LAYOUTS ======================
@ -866,7 +852,6 @@
instance._masonryPlaceBrick( $this, groupCount, groupY ); instance._masonryPlaceBrick( $this, groupCount, groupY );
} }
}); });
return this;
}, },
// reset // reset
@ -880,7 +865,6 @@
while (i--) { while (i--) {
this.masonry.colYs.push( this.posTop ); this.masonry.colYs.push( this.posTop );
} }
return this;
}, },
_masonryResize : function() { _masonryResize : function() {
@ -891,8 +875,6 @@
// if column count has changed, do a new column cound // if column count has changed, do a new column cound
this.reLayout(); this.reLayout();
} }
return this;
}, },
_masonryGetContainerSize : function() { _masonryGetContainerSize : function() {
@ -928,7 +910,6 @@
instance.fitRows.x += atomW; instance.fitRows.x += atomW;
}); });
return this;
}, },
_fitRowsReset : function() { _fitRowsReset : function() {
@ -937,7 +918,6 @@
y : 0, y : 0,
height : 0 height : 0
}; };
return this;
}, },
_fitRowsGetContainerSize : function () { _fitRowsGetContainerSize : function () {
@ -945,7 +925,7 @@
}, },
_fitRowsResize : function() { _fitRowsResize : function() {
return this.reLayout(); this.reLayout();
}, },
@ -955,7 +935,6 @@
this.cellsByRow = {}; this.cellsByRow = {};
this._getSegments('cellsByRow'); this._getSegments('cellsByRow');
this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true); this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true);
return this;
}, },
_cellsByRowLayout : function( $elems ) { _cellsByRowLayout : function( $elems ) {
@ -970,7 +949,6 @@
$this.outerHeight(true) / 2 + instance.posTop; $this.outerHeight(true) / 2 + instance.posTop;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
}); });
return this;
}, },
_cellsByRowGetContainerSize : function() { _cellsByRowGetContainerSize : function() {
@ -985,7 +963,6 @@
if ( this.cellsByRow.cols !== prevCols ) { if ( this.cellsByRow.cols !== prevCols ) {
this.reLayout(); this.reLayout();
} }
return this;
}, },
@ -995,7 +972,6 @@
this.straightDown = { this.straightDown = {
y : 0 y : 0
}; };
return this;
}, },
_straightDownLayout : function( $elems ) { _straightDownLayout : function( $elems ) {
@ -1006,7 +982,6 @@
instance._pushPosition( $this, instance.posLeft, 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() {
@ -1015,7 +990,6 @@
_straightDownResize : function() { _straightDownResize : function() {
this.reLayout(); this.reLayout();
return this;
}, },
@ -1078,7 +1052,6 @@
instance._masonryHorizontalPlaceBrick( $this, groupCount, groupX ); instance._masonryHorizontalPlaceBrick( $this, groupCount, groupX );
} }
}); });
return this;
}, },
_masonryHorizontalReset : function() { _masonryHorizontalReset : function() {
@ -1091,7 +1064,6 @@
while (i--) { while (i--) {
this.masonryHorizontal.rowXs.push( this.posLeft ); this.masonryHorizontal.rowXs.push( this.posLeft );
} }
return this;
}, },
_masonryHorizontalResize : function() { _masonryHorizontalResize : function() {
@ -1102,8 +1074,6 @@
// if column count has changed, do a new column cound // if column count has changed, do a new column cound
this.reLayout(); this.reLayout();
} }
return this;
}, },
_masonryHorizontalGetContainerSize : function() { _masonryHorizontalGetContainerSize : function() {
@ -1120,7 +1090,6 @@
y : 0, y : 0,
width : 0 width : 0
}; };
return this;
}, },
_fitColumnsLayout : function( $elems ) { _fitColumnsLayout : function( $elems ) {
@ -1147,7 +1116,6 @@
instance.fitColumns.y += atomH; instance.fitColumns.y += atomH;
}); });
return this;
}, },
_fitColumnsGetContainerSize : function () { _fitColumnsGetContainerSize : function () {
@ -1155,7 +1123,7 @@
}, },
_fitColumnsResize : function() { _fitColumnsResize : function() {
return this.reLayout(); this.reLayout();
}, },
@ -1166,7 +1134,6 @@
this.cellsByColumn = {}; this.cellsByColumn = {};
this._getSegments( 'cellsByColumn', true ); this._getSegments( 'cellsByColumn', true );
this.cellsByColumn.columnWidth = this.options.cellsByColumn.columnWidth || this.$allAtoms.outerHeight(true); this.cellsByColumn.columnWidth = this.options.cellsByColumn.columnWidth || this.$allAtoms.outerHeight(true);
return this;
}, },
_cellsByColumnLayout : function( $elems ) { _cellsByColumnLayout : function( $elems ) {
@ -1181,7 +1148,6 @@
$this.outerHeight(true) / 2 + instance.posTop; $this.outerHeight(true) / 2 + instance.posTop;
instance._pushPosition( $this, x, y ); instance._pushPosition( $this, x, y );
}); });
return this;
}, },
_cellsByColumnGetContainerSize : function() { _cellsByColumnGetContainerSize : function() {
@ -1196,7 +1162,6 @@
if ( this.cellsByColumn.rows !== prevRows ) { if ( this.cellsByColumn.rows !== prevRows ) {
this.reLayout(); this.reLayout();
} }
return this;
}, },
// ====================== straightAcross ====================== // ====================== straightAcross ======================
@ -1205,7 +1170,6 @@
this.straightAcross = { this.straightAcross = {
x : 0 x : 0
}; };
return this;
}, },
_straightAcrossLayout : function( $elems ) { _straightAcrossLayout : function( $elems ) {
@ -1216,7 +1180,6 @@
instance._pushPosition( $this, x, instance.posTop ); instance._pushPosition( $this, x, instance.posTop );
instance.straightAcross.x += $this.outerWidth(true); instance.straightAcross.x += $this.outerWidth(true);
}); });
return this;
}, },
_straightAcrossGetContainerSize : function() { _straightAcrossGetContainerSize : function() {
@ -1225,7 +1188,6 @@
_straightAcrossResize : function() { _straightAcrossResize : function() {
this.reLayout(); this.reLayout();
return this;
} }
}; };
@ -1278,7 +1240,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 +1253,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