|
|
@ -67,30 +67,6 @@ |
|
|
|
return this.molequul( 'addSortData', props ).css( atomStyle ); |
|
|
|
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 ======================
|
|
|
|
// ====================== Filtering ======================
|
|
|
|
|
|
|
|
|
|
|
|
filter : function( $atoms ) { |
|
|
|
filter : function( $atoms ) { |
|
|
@ -155,6 +131,15 @@ |
|
|
|
|
|
|
|
|
|
|
|
// ====================== Layout ======================
|
|
|
|
// ====================== Layout ======================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
translate : function( x, y ) { |
|
|
|
|
|
|
|
return { translate : [ x, y ] }; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
positionAbs : function( x, y ) { |
|
|
|
|
|
|
|
return { left: x, top: y }; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
pushPosition : function( x, y, props ) { |
|
|
|
pushPosition : function( x, y, props ) { |
|
|
|
var position = props.positionFn( x, y ); |
|
|
|
var position = props.positionFn( x, y ); |
|
|
|
props.styleQueue.push({ $el: this, style: position }); |
|
|
|
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 )
|
|
|
|
// 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 ) { |
|
|
|
layout : function( $elems, callback ) { |
|
|
|
|
|
|
|
|
|
|
|
var props = this.data('molequul'), |
|
|
|
var props = this.data('molequul'), |
|
|
@ -378,8 +362,9 @@ |
|
|
|
props.styleQueue = []; |
|
|
|
props.styleQueue = []; |
|
|
|
|
|
|
|
|
|
|
|
// provide $elems as context for the callback
|
|
|
|
// provide $elems as context for the callback
|
|
|
|
callback = callback || function(){}; |
|
|
|
if ( callback ) { |
|
|
|
callback.call( $elems ); |
|
|
|
callback.call( $elems ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
return this; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -400,6 +385,8 @@ |
|
|
|
.molequul( 'layout', props.atoms.$filtered ); |
|
|
|
.molequul( 'layout', props.atoms.$filtered ); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ====================== Setup and Init ======================
|
|
|
|
|
|
|
|
|
|
|
|
// only run though on initial init
|
|
|
|
// only run though on initial init
|
|
|
|
setup : function( props ) { |
|
|
|
setup : function( props ) { |
|
|
|
|
|
|
|
|
|
|
@ -480,7 +467,7 @@ |
|
|
|
data = $this.data('molequul'), |
|
|
|
data = $this.data('molequul'), |
|
|
|
props = data || {}; |
|
|
|
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.initialized = !!data; |
|
|
|
|
|
|
|
|
|
|
|
props.prevOpts = props.initialized ? data.opts : {}; |
|
|
|
props.prevOpts = props.initialized ? data.opts : {}; |
|
|
@ -535,17 +522,28 @@ |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
appendToLayout : function( $content ) { |
|
|
|
// ====================== Convenience methods ======================
|
|
|
|
var $newAtoms = $content.molequul( 'addTo', this ); |
|
|
|
|
|
|
|
return this.molequul( 'layout', $newAtoms ); |
|
|
|
// 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 ) { |
|
|
|
// convienence method for adding elements properly to any layout
|
|
|
|
return { translate : [ x, y ] }; |
|
|
|
insert : function( $content ) { |
|
|
|
|
|
|
|
return this.append( $content ).molequul( 'add', $content ).molequul('init'); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
positionAbs : function( x, y ) { |
|
|
|
// convienence method for working with Infinite Scroll
|
|
|
|
return { left: x, top: y }; |
|
|
|
appended : function( $content ) { |
|
|
|
|
|
|
|
return this.molequul( 'add', $content ).molequul( 'layout', $content ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|