/*jshint browser:true, undef: true, unused: true, jquery: true */ // store filter per group var filters = {}; var $container = $('#container'); //$container.isotope(); // empty on start $container.isotope({ filter: '.dummy' }); // do stuff when checkbox change $('#options').on( 'change', function( event ) { var checkbox = event.target; var $checkbox = $( checkbox ); var group = $checkbox.parents('.option-set').attr('data-group'); // create array for filter group, if not there yet var filterGroup = filters[ group ]; if ( !filterGroup ) { filterGroup = filters[ group ] = []; } // add/remove filter if ( checkbox.checked ) { // add filter filterGroup.push( checkbox.value ); // trigger google analytics event via GTM window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'eventTracking', 'category': 'Filter-button', 'action': 'click', 'label': checkbox.id }); } else { // remove filter var index = filterGroup.indexOf( checkbox.value ); filterGroup.splice( index, 1 ); } var comboFilter = getComboFilter(); // show nothing "dummy" if nothing selected if ( !comboFilter.length ) { $container.isotope({ filter: '.dummy' }); } else { $container.isotope({ filter: comboFilter }); } }); function getComboFilter() { var combo = []; for ( var prop in filters ) { var group = filters[ prop ]; if ( !group.length ) { // no filters in group, carry on continue; } // add first group if ( !combo.length ) { combo = group.slice(0); continue; } // add additional groups var nextCombo = []; // split group into combo: [ A, B ] & [ 1, 2 ] => [ A1, A2, B1, B2 ] for ( var i=0; i < combo.length; i++ ) { for ( var j=0; j < group.length; j++ ) { var item = combo[i] + group[j]; nextCombo.push( item ); } } combo = nextCombo; } var comboFilter = combo.join(', '); return comboFilter; } function GetURLParameter(sParam) { var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam) { return sParameterName[1]; } } } $("document").ready(function() { setTimeout(function() { /*$("#any-wf").trigger('click');*/ if(GetURLParameter('workflow')) { $("#"+GetURLParameter('workflow')).trigger('click'); } if(GetURLParameter('product')) { $("#"+GetURLParameter('product')).trigger('click'); } if(GetURLParameter('topic')) { $("#"+GetURLParameter('topic')).trigger('click'); } },1000); });