JavaScript

// Custom sorting plugin(function($){$.fn.sorted=function(customOptions){varoptions={reversed:false,by:function(a){returna.text();}};$.extend(options,customOptions);$data=$(this);arr=$data.get();arr.sort(function(a,b){varvalA=options.by($(a));varvalB=options.by($(b));if(options.reversed){return(valA<valB)?1:(valA>valB)?-1:0;}else{return(valA<valB)?-1:(valA>valB)?1:0;}});return$(arr);};})(jQuery);// DOMContentLoaded$(function(){// bind radiobuttons in the formvar$filterType=$('#filter input[name="type"]');var$filterSort=$('#filter input[name="sort"]');// get the first collectionvar$applications=$('#applications');// clone applications to get a second collectionvar$data=$applications.clone();// attempt to call Quicksand on every form change$filterType.add($filterSort).change(function(e){if($(filterTypeSelector+':checked').val()=='all'){var$filteredData=$data.find('li');}else{var$filteredData=$data.find('li[data-type='+$(filterTypeSelector+":checked").val()+']');}// if sorted by sizeif($(filterSortSelector+':checked').val()=="size"){var$sortedData=$filteredData.sorted({by:function(v){returnparseFloat($(v).find('span[data-type=size]').text());}});}else{// if sorted by namevar$sortedData=$filteredData.sorted({by:function(v){return$(v).find('strong').text().toLowerCase();}});}// finally, call quicksand$applications.quicksand($sortedData,{duration:800,easing:'easeInOutQuad'});});});