Sha256: f780dfa3daca661ed83fc4c318965600a27c7e749f85dfeae9335394c250cbe0

Contents?: true

Size: 754 Bytes

Versions: 69

Compression:

Stored size: 754 Bytes

Contents

/*global Blacklight */

'use strict';

Blacklight.doResizeFacetLabelsAndCounts = function() {
  // adjust width of facet columns to fit their contents
  function longer (a,b) { return b.textContent.length - a.textContent.length }

  document.querySelectorAll('.facet-values, .pivot-facet').forEach(function(elem){
    const nodes = elem.querySelectorAll('.facet-count')
    // TODO: when we drop ie11 support, this can become the spread operator:
    const longest = Array.from(nodes).sort(longer)[0]
    if (longest && longest.textContent) {
      const width = longest.textContent.length + 1 + 'ch'
      elem.querySelector('.facet-count').style.width = width
    }
  })
}

Blacklight.onLoad(function() {
  Blacklight.doResizeFacetLabelsAndCounts()
})

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/javascript/blacklight/facet_load.js
blacklight-7.39.0 app/javascript/blacklight/facet_load.js
blacklight-7.38.0 app/javascript/blacklight/facet_load.js
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/javascript/blacklight/facet_load.js
blacklight-7.37.0 app/javascript/blacklight/facet_load.js
blacklight-7.36.2 app/javascript/blacklight/facet_load.js
blacklight-7.36.1 app/javascript/blacklight/facet_load.js
blacklight-7.36.0 app/javascript/blacklight/facet_load.js
blacklight-7.35.0 app/javascript/blacklight/facet_load.js
blacklight-7.34.0 app/javascript/blacklight/facet_load.js
blacklight-7.33.1 app/javascript/blacklight/facet_load.js
blacklight-7.33.0 app/javascript/blacklight/facet_load.js
blacklight-7.32.0 app/javascript/blacklight/facet_load.js
blacklight-7.31.0 app/javascript/blacklight/facet_load.js
blacklight-7.30.0 app/javascript/blacklight/facet_load.js
blacklight-7.29.0 app/javascript/blacklight/facet_load.js
blacklight-7.28.0 app/javascript/blacklight/facet_load.js
blacklight-7.27.1 app/javascript/blacklight/facet_load.js
blacklight-7.27.0 app/javascript/blacklight/facet_load.js
blacklight-7.26.1 app/javascript/blacklight/facet_load.js