(function(jQuery){ jQuery.fn.listfilter = function (aType) { // Determine what we are going to be filtering. var initSet,filterTarget,sel; initSet = filterTarget = this; sel = this.selector // Declare variables var hide; jQuery('.listform').on('change','#preset',function() { $('#listing').removeClass('advfd aaam aapdam aabimm aapdbimm bsb bad aadm aapddm badm advesd aafd aapdfd aafk aapdfk advft advfw aagd aapdgd bagd aaid aapdid baid advimpd aajd aapdjd advm aamm aapdmm aampd aapdmpd baps aasm aapdsm basm aatd aapdtd advtpd advtc aavc aapdvc'); $('#listing').addClass(this.value); }).on('focus','.filter',function() { initSet.find('.accordion-body.in').prev().find('a').click(); }).on('change','select.filter',function() { $('#listing').parent().removeClass('nonefound'); cascadefilter(aType,sel,initSet,filterTarget); }).on('keyup click change','input.filter',function() { if (this.value.length > 2 || this.value + '' == parseInt(this.value,10) + '' || this.value == '') { jQuery('.listform select').val('').change(); cascadefilter(aType,sel,initSet,filterTarget); } }); // Custom expression for case insensitive contains() jQuery.expr[':'].Contains = function(a,i,m){ return jQuery(a).text().toLowerCase().indexOf(m[3].toLowerCase())>=0; }; jQuery.expr[':'].frstchar = function(a,i,m){ return jQuery.trim(jQuery(a).text()).replace(/^the/i,'').charAt(0).toLowerCase()==m[3].charAt(0).toLowerCase(); }; jQuery.expr[':'].acronym = function(a,i,m){ var txt = jQuery.trim(jQuery(a).text().toLowerCase()); var fltr = m[3].toLowerCase(); return txt.indexOf(fltr)>=0 || txt.replace(/(?:(the|a|an|of|and) +)*(\S)\S*/ig,'$2').replace(/ /g,'')==fltr; }; var activeheight = 0; var hedheight = initSet.find('.accordion-heading:first').height(); var hedbanheight = jQuery('#menuaudience').height() + 15; //height of main banner and 15px buffer initSet.parent().on('show', function (e) { var $this = $(e.target), $ajaxBody = $this.find('.accordion-inner:has(>a:first-child)'); if ($ajaxBody.length) { var $ajaxAnchor = $ajaxBody.find('>a:first-child'), ajaxHref = $ajaxAnchor.attr('href'); if (window.s) { s.prop13=""; var filePathTemp = ajaxHref.replace(/.*\/(en\/)/,"/"); filePathTemp=filePathTemp.toLowerCase(); s.pageName=s.server + filePathTemp; s.t(); if (typeof(ga) !== "undefined") ga('send', 'pageview', ajaxHref); } $ajaxBody.load(ajaxHref+' '+$ajaxAnchor.data('selector'), function( response, status, xhr ) { $('tbody tr',$ajaxBody).each(function() { // $(this).addClass( $('td:first-child',this ).text().replace(/(\w+)\s(\d{4}\w?).*/,"$1$2") ); }) }) } var scrolladj = hedheight + hedbanheight + activeheight;// ( $this.parent().prevAll().filter(':has(location.hash)').length > 0 ) ? : 0; $this.siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-chevron-up icon-chevron-down'); $('html,body').animate({scrollTop:$this.parent().offset().top - scrolladj}, 'fast') }).on('hide', function (e) { $(e.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-chevron-up icon-chevron-down'); }).on('shown', function (e) { var $this = $(e.target); var hashid = $this.attr('id') activeheight = $this.parent().height(); $this.removeAttr('id'); location.hash = hashid; $this.attr('id',hashid); }).on('hidden', function(e) { history.pushState('', document.title, window.location.pathname); activeheight = 0; }) if (location.hash.length > 1) { jQuery('#'+location.hash.substring(1)).prev().find('a').trigger('click'); } } })(jQuery); function cascadefilter(aType,sel,initSet,filterTarget) { var show, filter; // Grab the filter value $('.filter').each(function() { if((filter=$(this).val())!= '') { // Grab the ones we need to hide and the ones we need to show switch(this.name) { case 'alphatitle': show = filterTarget.find('h5.list-title:frstchar("'+filter+'")').parents(sel); break; case 'category': show = filterTarget.find('h5.list-category:contains("'+filter+'")').parents(sel); break; case 'h5': if ($('select#preset').length) { show = filterTarget.find('h5.list-title:acronym("' + filter + '")').parents(sel); /* if (!show.length && !$('.listform select').filter(function(){return $(this).val()!=''}).length) { $('#listing').parent().addClass('nonefound') } else { $('#listing').parent().removeClass('nonefound'); }*/ } else { show = filterTarget.find('h5.list-title:Contains("' + filter + '")').parents(sel); } break; case 'preset': var showSelect = "" _(xref.degrees[filter].xfer).each(function (o,k,v) { showSelect += ',#'+k; }); show = filterTarget.find(showSelect.substring(1)).parents(sel); break; default: show = filterTarget.find('h5.list-category:Contains("'+filter+'")').parents(sel); break; } filterTarget = show; } else { switch(this.name){ case 'alphatitle': show = filterTarget.find('h5.list-title').parents(sel); break; default: show = filterTarget.find('h5.list-category:Contains("' + filter + '")').parents(sel); } } }) initSet.filter('[style]').removeAttr('style'); show.last().css('border-width',0); hide = initSet.not(show); // Animate the items we are hiding and showing if ( aType == 'basic' ) { hide.filter(':visible').hide(); show.filter(':hidden').show(); } else if ( aType == 'slide' ) { hide.filter(':visible').slideUp(500); show.filter(':hidden').slideDown(500); } else if ( aType == 'fade' ) { show.filter(':hidden').fadeIn(400); hide.filter(':visible').fadeOut(400); } if (!show.length) { $('#listing').parent().addClass('nonefound') } else { $('#listing').parent().removeClass('nonefound'); } }