From e31c0b7c0f3f94c1fa22ebf9e7332009363dc3db Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Sun, 24 Oct 2010 21:17:21 -0400 Subject: [PATCH] use only `add` method --- src/jquery.molequul.js | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/jquery.molequul.js b/src/jquery.molequul.js index 56f414e..742cf12 100755 --- a/src/jquery.molequul.js +++ b/src/jquery.molequul.js @@ -67,35 +67,28 @@ return this.molequul( 'addSortData', props ).css( atomStyle ); }, - getAtoms : function( props ) { - return props.opts.selector ? this.filter( props.opts.selector ) : this; - }, + // ====================== Convenience methods ====================== // adds a jQuery object of items to a molequul container - addTo : function( $molecule ) { - var props = $molecule.data('molequul'), - $newAtoms = props.opts.selector ? this.filter( props.opts.selector ) : this; + add : function( $content ) { + var props = this.data('molequul'), + $newAtoms = props.opts.selector ? $content.filter( props.opts.selector ) : $content; $newAtoms.molequul( 'setupAtoms', props ) - // console.log( $newAtoms ) + // add new atoms to atoms pools props.atoms.$all = props.atoms.$all.add( $newAtoms ); props.atoms.$filtered = props.atoms.$filtered.add( $newAtoms ); props.appending = true; - // $molecule.data( 'molequul', props ); - // console.log( prevLen, props.atoms.$all.length ) - return $newAtoms; - }, - - add : function( $content ) { - $content.molequul( 'addTo', this ); return this; }, + // convienence method for adding elements properly to any layout insert : function( $content ) { - // console.log('appedning') - this.append( $content ); - $content.molequul( 'addTo', this ); - // console.log( this ); - return this.molequul('init'); + return this.append( $content ).molequul( 'add', $content ).molequul('init'); + }, + + // convienence method for working with Infinite Scroll + appended : function( $content ) { + return this.molequul( 'add', $content ).molequul( 'layout', $content ); }, // ====================== Filtering ======================