From f0a4c14136da21ac16fb2e2bc8cf17247594dcd5 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Mon, 23 May 2011 15:20:28 -0400 Subject: [PATCH] src : internal plugin methods will not `return this`; remove option getter --- jquery.isotope.js | 66 +++++++++++-------------------------------- jquery.isotope.min.js | 4 +-- 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/jquery.isotope.js b/jquery.isotope.js index 672f37a..c9b2d56 100644 --- a/jquery.isotope.js +++ b/jquery.isotope.js @@ -1,5 +1,5 @@ /** - * Isotope v1.2.110520 + * Isotope v1.2.110523 * An exquisite jQuery plugin for magical layouts * http://isotope.metafizzy.co * @@ -441,10 +441,7 @@ }, option: function( key, value ){ - // get/change options AFTER initialization: - // you don't have to support all these cases, - // but here's how: // signature: $('#foo').bar({ cool:false }); if ( $.isPlainObject( key ) ){ @@ -454,17 +451,11 @@ 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 ====================== // @@ -578,8 +569,6 @@ }; this.$filteredAtoms.sort( sortFn ); - - return this; }, _getSorter : function( elem, sortBy ) { @@ -644,20 +633,18 @@ } this.isLaidOut = true; - - return this; }, resize : function() { - return this[ '_' + this.options.layoutMode + 'Resize' ](); + this[ '_' + this.options.layoutMode + 'Resize' ](); }, reLayout : function( callback ) { - return this[ '_' + this.options.layoutMode + 'Reset' ]() - .layout( this.$filteredAtoms, callback ); + this[ '_' + this.options.layoutMode + 'Reset' ](); + this.layout( this.$filteredAtoms, callback ); }, @@ -685,7 +672,8 @@ 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.$filteredAtoms = this._filter( this.$allAtoms ); - return this.reLayout( callback ); + this.reLayout( callback ); }, // destroys widget, returns elements and container back (close) to original style @@ -798,8 +786,6 @@ // i.e. this.masonry.columnWidth = ... this[ namespace ][ measure ] = segmentSize; - return this; - }, // ====================== LAYOUTS ====================== @@ -866,7 +852,6 @@ instance._masonryPlaceBrick( $this, groupCount, groupY ); } }); - return this; }, // reset @@ -880,7 +865,6 @@ while (i--) { this.masonry.colYs.push( this.posTop ); } - return this; }, _masonryResize : function() { @@ -891,8 +875,6 @@ // if column count has changed, do a new column cound this.reLayout(); } - - return this; }, _masonryGetContainerSize : function() { @@ -928,7 +910,6 @@ instance.fitRows.x += atomW; }); - return this; }, _fitRowsReset : function() { @@ -937,7 +918,6 @@ y : 0, height : 0 }; - return this; }, _fitRowsGetContainerSize : function () { @@ -945,7 +925,7 @@ }, _fitRowsResize : function() { - return this.reLayout(); + this.reLayout(); }, @@ -955,7 +935,6 @@ this.cellsByRow = {}; this._getSegments('cellsByRow'); this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true); - return this; }, _cellsByRowLayout : function( $elems ) { @@ -970,7 +949,6 @@ $this.outerHeight(true) / 2 + instance.posTop; instance._pushPosition( $this, x, y ); }); - return this; }, _cellsByRowGetContainerSize : function() { @@ -985,7 +963,6 @@ if ( this.cellsByRow.cols !== prevCols ) { this.reLayout(); } - return this; }, @@ -995,7 +972,6 @@ this.straightDown = { y : 0 }; - return this; }, _straightDownLayout : function( $elems ) { @@ -1006,7 +982,6 @@ instance._pushPosition( $this, instance.posLeft, y ); instance.straightDown.y += $this.outerHeight(true); }); - return this; }, _straightDownGetContainerSize : function() { @@ -1015,7 +990,6 @@ _straightDownResize : function() { this.reLayout(); - return this; }, @@ -1078,7 +1052,6 @@ instance._masonryHorizontalPlaceBrick( $this, groupCount, groupX ); } }); - return this; }, _masonryHorizontalReset : function() { @@ -1091,7 +1064,6 @@ while (i--) { this.masonryHorizontal.rowXs.push( this.posLeft ); } - return this; }, _masonryHorizontalResize : function() { @@ -1102,8 +1074,6 @@ // if column count has changed, do a new column cound this.reLayout(); } - - return this; }, _masonryHorizontalGetContainerSize : function() { @@ -1120,7 +1090,6 @@ y : 0, width : 0 }; - return this; }, _fitColumnsLayout : function( $elems ) { @@ -1147,7 +1116,6 @@ instance.fitColumns.y += atomH; }); - return this; }, _fitColumnsGetContainerSize : function () { @@ -1155,7 +1123,7 @@ }, _fitColumnsResize : function() { - return this.reLayout(); + this.reLayout(); }, @@ -1166,7 +1134,6 @@ this.cellsByColumn = {}; this._getSegments( 'cellsByColumn', true ); this.cellsByColumn.columnWidth = this.options.cellsByColumn.columnWidth || this.$allAtoms.outerHeight(true); - return this; }, _cellsByColumnLayout : function( $elems ) { @@ -1181,7 +1148,6 @@ $this.outerHeight(true) / 2 + instance.posTop; instance._pushPosition( $this, x, y ); }); - return this; }, _cellsByColumnGetContainerSize : function() { @@ -1196,7 +1162,6 @@ if ( this.cellsByColumn.rows !== prevRows ) { this.reLayout(); } - return this; }, // ====================== straightAcross ====================== @@ -1205,7 +1170,6 @@ this.straightAcross = { x : 0 }; - return this; }, _straightAcrossLayout : function( $elems ) { @@ -1216,7 +1180,6 @@ instance._pushPosition( $this, x, instance.posTop ); instance.straightAcross.x += $this.outerWidth(true); }); - return this; }, _straightAcrossGetContainerSize : function() { @@ -1225,7 +1188,6 @@ _straightAcrossResize : function() { this.reLayout(); - return this; } }; @@ -1278,7 +1240,7 @@ // call method var args = Array.prototype.slice.call( arguments, 1 ); - return this.each(function(){ + this.each(function(){ var instance = $.data( this, 'isotope' ); if ( !instance ) { return $.error( "cannot call methods on isotope prior to initialization; " + @@ -1291,17 +1253,21 @@ instance[ options ].apply( instance, args ); }); } else { - return this.each(function() { + this.each(function() { var instance = $.data( this, 'isotope' ); if ( instance ) { // apply options & init - instance.option( options || {} )._init(); + instance.option( options || {} ); + instance._init(); } else { // initialize new instance $.data( this, 'isotope', new $.Isotope( options, this ) ); } }); } + // return jQuery object + // so plugin methods do not have to + return this; }; })( window, jQuery ); \ No newline at end of file diff --git a/jquery.isotope.min.js b/jquery.isotope.min.js index 3c6b01c..d9d4c0d 100644 --- a/jquery.isotope.min.js +++ b/jquery.isotope.min.js @@ -1,5 +1,5 @@ /** - * Isotope v1.2.110520 + * Isotope v1.2.110523 * An exquisite jQuery plugin for magical layouts * http://isotope.metafizzy.co * @@ -8,4 +8,4 @@ * * Copyright 2011 David DeSandro / Metafizzy */ -(function(a,b,c){var d=function(){function b(b,c){c=c||document.documentElement;var d=c.style,e;if(typeof d[b]=="string")return b;b=b.charAt(0).toUpperCase()+b.slice(1);for(var f=0,g=a.length;fg?1:fc.width&&(c.fitRows.x=0,c.fitRows.y=c.fitRows.height),f=c.fitRows.x+c.posLeft,g=c.fitRows.y+c.posTop,c._pushPosition(a,f,g),c.fitRows.height=Math.max(c.fitRows.y+e,c.fitRows.height),c.fitRows.x+=d});return this},_fitRowsReset:function(){this.fitRows={x:0,y:0,height:0};return this},_fitRowsGetContainerSize:function(){return{height:this.fitRows.height}},_fitRowsResize:function(){return this.reLayout()},_cellsByRowReset:function(){this.cellsByRow={},this._getSegments("cellsByRow"),this.cellsByRow.rowHeight=this.options.cellsByRow.rowHeight||this.$allAtoms.outerHeight(!0);return this},_cellsByRowLayout:function(a){var c=this,d=this.cellsByRow.cols;this.cellsByRow.atomsLen=a.length,a.each(function(a){var e=b(this),f=(a%d+.5)*c.cellsByRow.columnWidth-e.outerWidth(!0)/2+c.posLeft,g=(~~(a/d)+.5)*c.cellsByRow.rowHeight-e.outerHeight(!0)/2+c.posTop;c._pushPosition(e,f,g)});return this},_cellsByRowGetContainerSize:function(){return{height:Math.ceil(this.cellsByRow.atomsLen/this.cellsByRow.cols)*this.cellsByRow.rowHeight+this.posTop}},_cellsByRowResize:function(){var a=this.cellsByRow.cols;this._getSegments("cellsByRow"),this.cellsByRow.cols!==a&&this.reLayout();return this},_straightDownReset:function(){this.straightDown={y:0};return this},_straightDownLayout:function(a){var c=this;a.each(function(a){var d=b(this),e=c.straightDown.y+c.posTop;c._pushPosition(d,c.posLeft,e),c.straightDown.y+=d.outerHeight(!0)});return this},_straightDownGetContainerSize:function(){return{height:this.straightDown.y+this.posTop}},_straightDownResize:function(){this.reLayout();return this},_masonryHorizontalPlaceBrick:function(a,b,c){var d=Math.min.apply(Math,c),e=d+a.outerWidth(!0),f=c.length,g=f,h=this.masonryHorizontal.rows+1-f,i,j;while(f--)c[f]===d&&(g=f);i=d,j=this.masonryHorizontal.rowHeight*g+this.posTop,this._pushPosition(a,i,j);for(f=0;fc.height&&(c.fitColumns.x=c.fitColumns.width,c.fitColumns.y=0),f=c.fitColumns.x+c.posLeft,g=c.fitColumns.y+c.posTop,c._pushPosition(a,f,g),c.fitColumns.width=Math.max(c.fitColumns.x+d,c.fitColumns.width),c.fitColumns.y+=e});return this},_fitColumnsGetContainerSize:function(){return{width:this.fitColumns.width}},_fitColumnsResize:function(){return this.reLayout()},_cellsByColumnReset:function(){this.cellsByColumn={},this._getSegments("cellsByColumn",!0),this.cellsByColumn.columnWidth=this.options.cellsByColumn.columnWidth||this.$allAtoms.outerHeight(!0);return this},_cellsByColumnLayout:function(a){var c=this,d=this.cellsByColumn.rows;this.cellsByColumn.atomsLen=a.length,a.each(function(a){var e=b(this),f=(~~(a/d)+.5)*c.cellsByColumn.columnWidth-e.outerWidth(!0)/2+c.posLeft,g=(a%d+.5)*c.cellsByColumn.rowHeight-e.outerHeight(!0)/2+c.posTop;c._pushPosition(e,f,g)});return this},_cellsByColumnGetContainerSize:function(){return{width:Math.ceil(this.cellsByColumn.atomsLen/this.cellsByColumn.rows)*this.cellsByColumn.columnWidth+this.posLeft}},_cellsByColumnResize:function(){var a=this.cellsByColumn.rows;this._getSegments("cellsByColumn",!0),this.cellsByColumn.rows!==a&&this.reLayout();return this},_straightAcrossReset:function(){this.straightAcross={x:0};return this},_straightAcrossLayout:function(a){var c=this;a.each(function(a){var d=b(this),e=c.straightAcross.x+c.posLeft;c._pushPosition(d,e,c.posTop),c.straightAcross.x+=d.outerWidth(!0)});return this},_straightAcrossGetContainerSize:function(){return{width:this.straightAcross.x+this.posLeft}},_straightAcrossResize:function(){this.reLayout();return this}},b.fn.imagesLoaded=function(a){var b=this.find("img"),d=b.length,e=this;b.length||a.call(this),b.bind("load",function(){--d<=0&&a.call(e)}).each(function(){if(this.complete||this.complete===c){var a=this.src;this.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",this.src=a}});return this},b.fn.isotope=function(a){if(typeof a=="string"){var c=Array.prototype.slice.call(arguments,1);return this.each(function(){var d=b.data(this,"isotope");if(!d)return b.error("cannot call methods on isotope prior to initialization; attempted to call method '"+a+"'");if(!b.isFunction(d[a])||a.charAt(0)==="_")return b.error("no such method '"+a+"' for isotope instance");d[a].apply(d,c)})}return this.each(function(){var c=b.data(this,"isotope");c?c.option(a||{})._init():b.data(this,"isotope",new b.Isotope(a,this))})}})(window,jQuery); +(function(a,b,c){var d=function(){function b(b,c){c=c||document.documentElement;var d=c.style,e;if(typeof d[b]=="string")return b;b=b.charAt(0).toUpperCase()+b.slice(1);for(var f=0,g=a.length;fg?1:fc.width&&(c.fitRows.x=0,c.fitRows.y=c.fitRows.height),f=c.fitRows.x+c.posLeft,g=c.fitRows.y+c.posTop,c._pushPosition(a,f,g),c.fitRows.height=Math.max(c.fitRows.y+e,c.fitRows.height),c.fitRows.x+=d})},_fitRowsReset:function(){this.fitRows={x:0,y:0,height:0}},_fitRowsGetContainerSize:function(){return{height:this.fitRows.height}},_fitRowsResize:function(){this.reLayout()},_cellsByRowReset:function(){this.cellsByRow={},this._getSegments("cellsByRow"),this.cellsByRow.rowHeight=this.options.cellsByRow.rowHeight||this.$allAtoms.outerHeight(!0)},_cellsByRowLayout:function(a){var c=this,d=this.cellsByRow.cols;this.cellsByRow.atomsLen=a.length,a.each(function(a){var e=b(this),f=(a%d+.5)*c.cellsByRow.columnWidth-e.outerWidth(!0)/2+c.posLeft,g=(~~(a/d)+.5)*c.cellsByRow.rowHeight-e.outerHeight(!0)/2+c.posTop;c._pushPosition(e,f,g)})},_cellsByRowGetContainerSize:function(){return{height:Math.ceil(this.cellsByRow.atomsLen/this.cellsByRow.cols)*this.cellsByRow.rowHeight+this.posTop}},_cellsByRowResize:function(){var a=this.cellsByRow.cols;this._getSegments("cellsByRow"),this.cellsByRow.cols!==a&&this.reLayout()},_straightDownReset:function(){this.straightDown={y:0}},_straightDownLayout:function(a){var c=this;a.each(function(a){var d=b(this),e=c.straightDown.y+c.posTop;c._pushPosition(d,c.posLeft,e),c.straightDown.y+=d.outerHeight(!0)})},_straightDownGetContainerSize:function(){return{height:this.straightDown.y+this.posTop}},_straightDownResize:function(){this.reLayout()},_masonryHorizontalPlaceBrick:function(a,b,c){var d=Math.min.apply(Math,c),e=d+a.outerWidth(!0),f=c.length,g=f,h=this.masonryHorizontal.rows+1-f,i,j;while(f--)c[f]===d&&(g=f);i=d,j=this.masonryHorizontal.rowHeight*g+this.posTop,this._pushPosition(a,i,j);for(f=0;fc.height&&(c.fitColumns.x=c.fitColumns.width,c.fitColumns.y=0),f=c.fitColumns.x+c.posLeft,g=c.fitColumns.y+c.posTop,c._pushPosition(a,f,g),c.fitColumns.width=Math.max(c.fitColumns.x+d,c.fitColumns.width),c.fitColumns.y+=e})},_fitColumnsGetContainerSize:function(){return{width:this.fitColumns.width}},_fitColumnsResize:function(){this.reLayout()},_cellsByColumnReset:function(){this.cellsByColumn={},this._getSegments("cellsByColumn",!0),this.cellsByColumn.columnWidth=this.options.cellsByColumn.columnWidth||this.$allAtoms.outerHeight(!0)},_cellsByColumnLayout:function(a){var c=this,d=this.cellsByColumn.rows;this.cellsByColumn.atomsLen=a.length,a.each(function(a){var e=b(this),f=(~~(a/d)+.5)*c.cellsByColumn.columnWidth-e.outerWidth(!0)/2+c.posLeft,g=(a%d+.5)*c.cellsByColumn.rowHeight-e.outerHeight(!0)/2+c.posTop;c._pushPosition(e,f,g)})},_cellsByColumnGetContainerSize:function(){return{width:Math.ceil(this.cellsByColumn.atomsLen/this.cellsByColumn.rows)*this.cellsByColumn.columnWidth+this.posLeft}},_cellsByColumnResize:function(){var a=this.cellsByColumn.rows;this._getSegments("cellsByColumn",!0),this.cellsByColumn.rows!==a&&this.reLayout()},_straightAcrossReset:function(){this.straightAcross={x:0}},_straightAcrossLayout:function(a){var c=this;a.each(function(a){var d=b(this),e=c.straightAcross.x+c.posLeft;c._pushPosition(d,e,c.posTop),c.straightAcross.x+=d.outerWidth(!0)})},_straightAcrossGetContainerSize:function(){return{width:this.straightAcross.x+this.posLeft}},_straightAcrossResize:function(){this.reLayout()}},b.fn.imagesLoaded=function(a){var b=this.find("img"),d=b.length,e=this;b.length||a.call(this),b.bind("load",function(){--d<=0&&a.call(e)}).each(function(){if(this.complete||this.complete===c){var a=this.src;this.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",this.src=a}});return this},b.fn.isotope=function(a){if(typeof a=="string"){var c=Array.prototype.slice.call(arguments,1);this.each(function(){var d=b.data(this,"isotope");if(!d)return b.error("cannot call methods on isotope prior to initialization; attempted to call method '"+a+"'");if(!b.isFunction(d[a])||a.charAt(0)==="_")return b.error("no such method '"+a+"' for isotope instance");d[a].apply(d,c)})}else this.each(function(){var c=b.data(this,"isotope");c?(c.option(a||{}),c._init()):b.data(this,"isotope",new b.Isotope(a,this))});return this}})(window,jQuery);