diff --git a/isotope.js b/isotope.js index de2bd01..3da2b6b 100644 --- a/isotope.js +++ b/isotope.js @@ -187,19 +187,31 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item ) { // -------------------------- methods -------------------------- // Isotope.prototype._resetLayout = function() { - this._mode()._resetLayout(); + this._modeMethod( '_resetLayout', arguments ); }; - Isotope.prototype._getItemLayoutPosition = function( item ) { - return this._mode()._getItemLayoutPosition( item ); + Isotope.prototype._getItemLayoutPosition = function( /* item */) { + return this._modeMethod( '_getItemLayoutPosition', arguments ); }; - Isotope.prototype._manageStamp = function( stamp ) { - this._mode()._manageStamp( stamp ); + Isotope.prototype._manageStamp = function(/* stamp */) { + this._modeMethod( '_manageStamp', arguments ); }; Isotope.prototype._getContainerSize = function() { - return this._mode()._getContainerSize(); + return this._modeMethod( '_getContainerSize', arguments ); + }; + + Isotope.prototype._modeMethod = function( methodName, args ) { + var mode = this._mode(); + var modeMethod = mode[ methodName ]; + // use mode's method, if there + if ( modeMethod ) { + return modeMethod.apply( mode, args ); + } else { + // otherwise, default to Outlayer prototype + return Outlayer.prototype[ methodName ].apply( this, args ); + } }; return Isotope; diff --git a/layout-mode.js b/layout-mode.js index fe05e6e..f93bdd0 100644 --- a/layout-mode.js +++ b/layout-mode.js @@ -5,7 +5,6 @@ // -------------------------- -------------------------- // var Isotope = window.Isotope; -var Outlayer = window.Outlayer; function LayoutMode( isotope ) { this.isotope = isotope; @@ -13,23 +12,6 @@ function LayoutMode( isotope ) { this.options = isotope && isotope.options[ this.namespace ]; } -// default methods just defer to Isotope -LayoutMode.prototype._resetLayout = function() { - Outlayer.prototype._resetLayout.apply( this.isotope, arguments ); -}; - -LayoutMode.prototype._getItemLayoutPosition = function() { - return Outlayer.prototype._getItemLayoutPosition.apply( this.isotope, arguments ); -}; - -LayoutMode.prototype._manageStamp = function() { - Outlayer.prototype._manageStamp.apply( this.isotope, arguments ); -}; - -LayoutMode.prototype._getContainerSize = function() { - return Outlayer.prototype._getContainerSize.apply( this.isotope, arguments ); -}; - // -------------------------- create -------------------------- // LayoutMode.create = function( namespace, options ) {