From 207e8e77c9d801e69bb4effecd9c7a23687f4bbd Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Thu, 27 Jan 2011 20:31:01 -0500 Subject: [PATCH] src & docs : add remove method --- _posts/docs/2010-12-04-methods.mdown | 10 ++++++++++ jquery.isotope.js | 10 ++++++++++ jquery.isotope.min.js | 6 +++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/_posts/docs/2010-12-04-methods.mdown b/_posts/docs/2010-12-04-methods.mdown index e066f50..fcd1872 100644 --- a/_posts/docs/2010-12-04-methods.mdown +++ b/_posts/docs/2010-12-04-methods.mdown @@ -12,6 +12,7 @@ toc: - { title: layout, anchor: layout } - { title: option, anchor: option } - { title: reLayout, anchor: relayout } + - { title: remove, anchor: remove } --- @@ -103,3 +104,12 @@ Resets layout properties and lays-out every item element. [**See Demo: reLayout**](../demos/relayout.html) +## remove + +{% highlight javascript %} + +.isotope( 'remove', $content ) + +{% endhighlight %} + +Removes specified elements from Isotope widget and the DOM. \ No newline at end of file diff --git a/jquery.isotope.js b/jquery.isotope.js index 10009f8..cf12134 100644 --- a/jquery.isotope.js +++ b/jquery.isotope.js @@ -674,6 +674,16 @@ window.Modernizr = window.Modernizr || (function(window,doc,undefined){ }); }, + // removes elements from Isotope widget + remove : function( $content ) { + + this.$allAtoms = this.$allAtoms.not( $content ); + this.$filteredAtoms = this.$filteredAtoms.not( $content ); + + $content.remove(); + + }, + _shuffleArray : function ( array ) { var tmp, current, i = array.length; diff --git a/jquery.isotope.min.js b/jquery.isotope.min.js index 5887eeb..5022d95 100644 --- a/jquery.isotope.min.js +++ b/jquery.isotope.min.js @@ -22,9 +22,9 @@ this.isNew.sortAscending)this._sort();this.reLayout(a)},option:function(a,b){if( c.elemCount++})},_filter:function(a){var b=this.options.filter===""?"*":this.options.filter;if(b){var c=this.options.hiddenClass,d="."+c,f=a.not(d),g=a.filter(d);d=g;a=a.filter(b);if(b!=="*"){d=g.filter(b);b=f.not(b).toggleClass(c);b.addClass(c);this.styleQueue.push({$el:b,style:this.options.hiddenStyle})}this.styleQueue.push({$el:d,style:this.options.visibleStyle});d.removeClass(c)}return a},_sort:function(){var a=this,b=function(d){return e(d).data("isotope-sort-data")[a.options.sortBy]},c=this.options.sortAscending? 1:-1;sortFn=function(d,f){var g=b(d),h=b(f);return(g>h?1:gb.width){b.fitRows.x=0;b.fitRows.y=b.fitRows.height}b._pushPosition(c,b.fitRows.x+b.posLeft,b.fitRows.y+b.posTop);b.fitRows.height=Math.max(b.fitRows.y+f,b.fitRows.height);b.fitRows.x+=