Sha256: 9e24460e86fc42f4d2ff14751d86016a671fdc350c4f9349a14b8de81d8c0708

Contents?: true

Size: 1.62 KB

Versions: 13

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();
           });
       });
   };

  Blacklight.onLoad(function() {
    Blacklight.do_facet_expand_contract_behavior();  
  });
})(jQuery);

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
blacklight-4.9.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.8.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.7.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.7.0.pre1 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.6.3 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.6.2 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.6.1 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.6.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.5.0 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.5.0.rc1 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.4.2 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.4.1 app/assets/javascripts/blacklight/facet_expand_contract.js
blacklight-4.4.0 app/assets/javascripts/blacklight/facet_expand_contract.js