Sha256: 6bbd8b7cce568ff174cf0f04310f07266c7dce7a34ee200da67ebace8f41c4ee

Contents?: true

Size: 1.62 KB

Versions: 11

Compression:

Stored size: 1.62 KB

Contents

//= require blacklight/core
(function($) {
Blacklight.do_facet_expand_contract_behavior = function() {
      $( Blacklight.do_facet_expand_contract_behavior.selector ).each (
          Blacklight.facet_expand_contract
       );
    }
    Blacklight.do_facet_expand_contract_behavior.selector = '#facets h5';
    	    
	    /* Behavior that makes facet limit headings in sidebar expand/contract
	       their contents. This is kind of fragile code targeted specifically
	       at how we currently render facet HTML, which is why I put it in a function
	       on Blacklight instead of in a jquery plugin. Perhaps in the future this
	       could/should be expanded to a general purpose jquery plugin -- or
	       we should just use one of the existing ones for expand/contract? */
     Blacklight.facet_expand_contract = function() {
       $(this).next("ul, div").each(function(){
           var f_content = $(this);
           $(f_content).prev('h5').addClass('twiddle');
           // find all f_content's that don't have any span descendants with a class of "selected"
           if($('span.selected', f_content).length == 0){
             // hide it
             f_content.hide();
           } else {
             $(this).prev('h5').addClass('twiddle-open');
           }

           // attach the toggle behavior to the h5 tag
           $('h5', f_content.parent()).click(function(){
               // toggle the content
               $(this).toggleClass('twiddle-open');
               $(f_content).slideToggle();
           });
       });
   };
$(document).ready(function() {
  Blacklight.do_facet_expand_contract_behavior();  
});
})(jQuery);

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
blacklight-4.3.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.2.2 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.2.1 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.2.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.1.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.0.1 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.0.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.0.0.rc2 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.0.0.rc1 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.0.0.pre7 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.0.0.pre6 app/assets/javascripts/blacklight/facet_expand_contract.js