Browse Source

iterate over facademethods in layoutMode

pull/563/head
David DeSandro 12 years ago
parent
commit
2455b1b186
  1. 58
      layout-mode.js

58
layout-mode.js

@ -21,8 +21,6 @@ layoutMode.create = function( namespace, options ) {
this.element = isotope.element; this.element = isotope.element;
this.items = isotope.filteredItems; this.items = isotope.filteredItems;
this.size = isotope.size; this.size = isotope.size;
// this.getSize = isotope.getSize;
// this._getElementOffset = isotope._getElementOffset;
} }
} }
@ -35,41 +33,33 @@ layoutMode.create = function( namespace, options ) {
// register in Isotope // register in Isotope
layoutMode.modes[ namespace ] = LayoutMode; layoutMode.modes[ namespace ] = LayoutMode;
// ----- methods ----- //
// default method handler /**
// trigger Outlayer method with Isotope as this * some methods should just defer to default Outlayer method
LayoutMode.prototype._outlayerMethod = function( methodName, args ) { * and reference the Isotope instance as `this`
return Outlayer.prototype[ methodName ].apply( this.isotope, args ); **/
}; ( function() {
var facadeMethods = [
LayoutMode.prototype._resetLayout = function() { '_resetLayout',
this._outlayerMethod( '_resetLayout', arguments ); '_getItemLayoutPosition',
}; '_manageStamp',
'_getContainerSize',
LayoutMode.prototype._getItemLayoutPosition = function( /* item */) { '_getElementOffset',
return this._outlayerMethod( '_getItemLayoutPosition', arguments ); 'resize',
}; 'layout'
];
LayoutMode.prototype._manageStamp = function(/* stamp */) {
this._outlayerMethod( '_manageStamp', arguments ); for ( var i=0, len = facadeMethods.length; i < len; i++ ) {
}; var methodName = facadeMethods[i];
LayoutMode.prototype[ methodName ] = getOutlayerMethod( methodName );
LayoutMode.prototype._getContainerSize = function() { }
return this._outlayerMethod( '_getContainerSize', arguments );
};
LayoutMode.prototype._getElementOffset = function(/* elem */) {
return this._outlayerMethod( '_getElementOffset', arguments );
};
LayoutMode.prototype.resize = function() {
this._outlayerMethod( 'resize', arguments );
};
LayoutMode.prototype.layout = function() { function getOutlayerMethod( methodName ) {
this._outlayerMethod( 'layout', arguments ); return function() {
return Outlayer.prototype[ methodName ].apply( this.isotope, arguments );
}; };
}
})();
// ----- ----- // // ----- ----- //

Loading…
Cancel
Save