$().ready(function() { var $optionSets = $('#sort-by'), $optionLinks = $optionSets.find('a'); $optionLinks.click(function() { var $this = $(this); // don't proceed if already selected if ($this.hasClass('selected')) { return false; } var $optionSet = $this.parents('#sort-by'); $optionSet.find('.selected').removeClass('selected'); $this.addClass('selected'); // make option object dynamically, i.e. { filter: '.my-filter-class' } var options = {}, key = $optionSet.attr('data-option-key'), value = $this.attr('data-option-value'); // parse 'false' as false boolean value = value === 'false' ? false : value; options[key] = value; $container.isotope(options); return false; }); var $container = $('#content'), filters = {}; $container.isotope({ itemSelector: '.stationEntry', layoutMode: 'fitRows', getSortData: { category: function($elem) { return $elem.attr('data-category'); }, order: function($elem) { return parseFloat($elem.attr('data-order')); }, location: function($elem) { return $elem.find('.sMeta_Location').text(); }, sTitle: function($elem) { return $elem.find('.sMeta_Title').text(); } } }); // change layout $('#listMode').click(function() { var $this = $(this); if ($this.hasClass('selected')) { return; } else { $('#thumbMode').removeClass('selected'); $('#listMode').addClass('selected'); } var style = { height: '80%' }; $('.stationEntry').removeClass('thumb'); $container.filter(':animated').stop(); $container.addClass('no-transition').css(style); setTimeout(function() { $container.removeClass('no-transition').isotope(); }, 100); }); $('#thumbMode').click(function() { var $this = $(this); if ($this.hasClass('selected')) { return; } else { $('#thumbMode').addClass('selected'); $('#listMode').removeClass('selected'); } var style = { height: '100%' }; $('.stationEntry').addClass('thumb'); //$('.adBox').show(); $container.filter(':animated').stop(); $container.addClass('no-transition').css(style); setTimeout(function() { $container.removeClass('no-transition').isotope(); }, 100); }); });