Browse Source

this.$elem => this.element

pull/14/head
David DeSandro 15 years ago
parent
commit
a4d2b63977
  1. 28
      src/jquery.molequul-widget.js

28
src/jquery.molequul-widget.js

@ -2,8 +2,7 @@
// our "Widget" object constructor // our "Widget" object constructor
var Molequul = function( options, element ){ var Molequul = function( options, element ){
this.elem = element; this.element = $( element );
this.$elem = $( element );
this._create( options ); this._create( options );
this._init(); this._init();
@ -40,18 +39,18 @@
// sets up widget // sets up widget
_create : function( options ) { _create : function( options ) {
this.options = $.extend( true, this.options, options ); this.options = $.extend( true, {}, this.options, options );
this.atoms = {}; this.atoms = {};
this.isNew = {}; this.isNew = {};
this.styleQueue = []; this.styleQueue = [];
this.elemCount = 0; this.elemCount = 0;
// need to get atoms // need to get atoms
this.atoms.$all = this._filterFind( this.$elem.children(), this.options.itemSelector ); this.atoms.$all = this._filterFind( this.element.children(), this.options.itemSelector );
// console.log( 'all atoms', this.atoms.$all.length ) // console.log( 'all atoms', this.atoms.$all.length )
this.$elem.css({ this.element.css({
overflow : 'hidden', overflow : 'hidden',
position : 'relative' position : 'relative'
}); });
@ -90,7 +89,7 @@
// get top left position of where the bricks should be // get top left position of where the bricks should be
var $cursor = $( document.createElement('div') ); var $cursor = $( document.createElement('div') );
this.$elem.prepend( $cursor ); this.element.prepend( $cursor );
this.posTop = Math.round( $cursor.position().top ); this.posTop = Math.round( $cursor.position().top );
this.posLeft = Math.round( $cursor.position().left ); this.posLeft = Math.round( $cursor.position().left );
$cursor.remove(); $cursor.remove();
@ -98,16 +97,16 @@
// add molequul class first time around // add molequul class first time around
var instance = this; var instance = this;
setTimeout( function() { setTimeout( function() {
instance.$elem.addClass( instance.options.containerClass ); instance.element.addClass( instance.options.containerClass );
}, 0 ); }, 0 );
// do any layout-specific setup // do any layout-specific setup
this.width = this.$elem.width(); this.width = this.element.width();
this._getMasonryColCount(); this._getMasonryColCount();
// bind resize method // bind resize method
if ( this.options.resizeable ) { if ( this.options.resizeable ) {
$(window).bind('smartresize.molequul', function() { instance.$elem.molequul('resize') } ); $(window).bind('smartresize.molequul', function() { instance.element.molequul('resize') } );
} }
}, },
@ -361,7 +360,7 @@
window.console && console.error('Column width calculated to be zero. Stopping Molequul plugin before divide by zero. Check that the width of first child inside the molequul container is not zero.'); window.console && console.error('Column width calculated to be zero. Stopping Molequul plugin before divide by zero. Check that the width of first child inside the molequul container is not zero.');
return this; return this;
} }
this.width = this.$elem.width(); this.width = this.element.width();
this.colCount = Math.floor( this.width / this.colW ) ; this.colCount = Math.floor( this.width / this.colW ) ;
this.colCount = Math.max( this.colCount, 1 ); this.colCount = Math.max( this.colCount, 1 );
return this; return this;
@ -437,7 +436,7 @@
}, },
_clearFloatResize : function() { _clearFloatResize : function() {
this.width = this.$elem.width(); this.width = this.element.width();
return this.reLayout() return this.reLayout()
}, },
@ -467,13 +466,13 @@
this.styleQueue.push({ $el: this.$elem, style: containerStyle }); this.styleQueue.push({ $el: this.element, style: containerStyle });
// are we animating the layout arrangement? // are we animating the layout arrangement?
// use plugin-ish syntax for css or animate // use plugin-ish syntax for css or animate
var styleFn = ( this.applyStyleFnName === 'animate' && !$.data( this.$elem, 'molequul' ) ) ? var styleFn = ( this.applyStyleFnName === 'animate' && !$.data( this.element, 'molequul' ) ) ?
'css' : this.applyStyleFnName, 'css' : this.applyStyleFnName,
animOpts = this.options.animationOptions; animOpts = this.options.animationOptions;
@ -504,7 +503,6 @@
reLayout : function( callback ) { reLayout : function( callback ) {
console.log('relaying out', this.atoms.$filtered.length )
return this return this
[ '_' + this.options.layoutMode + 'ResetLayoutProps' ]() [ '_' + this.options.layoutMode + 'ResetLayoutProps' ]()
.layout( this.atoms.$filtered, callback ) .layout( this.atoms.$filtered, callback )
@ -524,7 +522,7 @@
// convienence method for adding elements properly to any layout // convienence method for adding elements properly to any layout
insert : function( $content, callback ) { insert : function( $content, callback ) {
this.$elem.append( $content ); this.element.append( $content );
var $newAtoms = this.addAtoms( $content ), var $newAtoms = this.addAtoms( $content ),
$filteredAtoms = this._filter( $newAtoms ); $filteredAtoms = this._filter( $newAtoms );

Loading…
Cancel
Save