From 79725204e1af1f53e9af7e352fb9d3948751e4c5 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Fri, 10 Dec 2010 22:28:31 -0500 Subject: [PATCH] js : add destroy method --- src/jquery.molequul.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/jquery.molequul.js b/src/jquery.molequul.js index 92f9405..853d5cb 100755 --- a/src/jquery.molequul.js +++ b/src/jquery.molequul.js @@ -406,6 +406,7 @@ window.console && console.log( message ); }, + // HACKy should probably remove shuffle : function( callback ) { this.options.sortBy = 'shuffle'; @@ -415,6 +416,33 @@ this.$filteredAtoms = this._filter( this.$allAtoms ); return this.reLayout( callback ); + }, + + // destroys widget, returns elements and container back (close) to original style + destroy : function() { + var atomUnstyle = $.extend( this.options.visibleStyle, { + position: 'relative', + top: 'auto', + left: 'auto' + }); + + if ( this.usingTransforms ) { + atomUnstyle[ $.optoTransform.transformProp ] = 'none'; + } + + this.$allAtoms.css( atomUnstyle ); + + this.element + .css({ + width: 'auto', + height: 'auto' + }) + .unbind('.molequul') + .removeClass('molequul') + .removeData('molequul'); + + $(window).unbind('.molequul'); + } };