From 763afe6fdcb14e8845bf21e4b942ae39f35be84b Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Tue, 26 Oct 2010 08:25:21 -0400 Subject: [PATCH] Move methods around --- src/jquery.molequul.js | 72 ++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/src/jquery.molequul.js b/src/jquery.molequul.js index 6eba17a..559f85e 100755 --- a/src/jquery.molequul.js +++ b/src/jquery.molequul.js @@ -67,30 +67,6 @@ return this.molequul( 'addSortData', props ).css( atomStyle ); }, - // ====================== Convenience methods ====================== - - // adds a jQuery object of items to a molequul container - add : function( $content ) { - var props = this.data('molequul'), - $newAtoms = props.opts.selector ? $content.filter( props.opts.selector ) : $content; - $newAtoms.molequul( 'setupAtoms', props ) - // 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; - return this; - }, - - // convienence method for adding elements properly to any layout - insert : function( $content ) { - 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 ====================== filter : function( $atoms ) { @@ -155,6 +131,15 @@ // ====================== Layout ====================== + + translate : function( x, y ) { + return { translate : [ x, y ] }; + }, + + positionAbs : function( x, y ) { + return { left: x, top: y }; + }, + pushPosition : function( x, y, props ) { var position = props.positionFn( x, y ); props.styleQueue.push({ $el: this, style: position }); @@ -330,12 +315,11 @@ }, - // ====================== General Methods ====================== - + // ====================== General Layout ====================== // used on collection of atoms (should be filtered, and sorted before ) - // accepts atoms-to-be-laid-out and colYs to start with + // accepts atoms-to-be-laid-out to start with layout : function( $elems, callback ) { var props = this.data('molequul'), @@ -378,8 +362,9 @@ props.styleQueue = []; // provide $elems as context for the callback - callback = callback || function(){}; - callback.call( $elems ); + if ( callback ) { + callback.call( $elems ); + } return this; }, @@ -400,6 +385,8 @@ .molequul( 'layout', props.atoms.$filtered ); }, + // ====================== Setup and Init ====================== + // only run though on initial init setup : function( props ) { @@ -480,7 +467,7 @@ data = $this.data('molequul'), props = data || {}; - // checks if masonry has been called before on this object + // checks if molquul has been called before on this object props.initialized = !!data; props.prevOpts = props.initialized ? data.opts : {}; @@ -535,17 +522,28 @@ }, - appendToLayout : function( $content ) { - var $newAtoms = $content.molequul( 'addTo', this ); - return this.molequul( 'layout', $newAtoms ); + // ====================== Convenience methods ====================== + + // adds a jQuery object of items to a molequul container + add : function( $content ) { + var props = this.data('molequul'), + $newAtoms = props.opts.selector ? $content.filter( props.opts.selector ) : $content; + $newAtoms.molequul( 'setupAtoms', props ) + // 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; + return this; }, - translate : function( x, y ) { - return { translate : [ x, y ] }; + // convienence method for adding elements properly to any layout + insert : function( $content ) { + return this.append( $content ).molequul( 'add', $content ).molequul('init'); }, - positionAbs : function( x, y ) { - return { left: x, top: y }; + // convienence method for working with Infinite Scroll + appended : function( $content ) { + return this.molequul( 'add', $content ).molequul( 'layout', $content ); } };