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.18.0 app/javascript/blacklight/facet_load.js
blacklight-7.17.2 app/javascript/blacklight/facet_load.js
blacklight-7.17.1 app/javascript/blacklight/facet_load.js
blacklight-7.17.0 app/javascript/blacklight/facet_load.js
blacklight-7.16.0 app/javascript/blacklight/facet_load.js
blacklight-7.15.2 app/javascript/blacklight/facet_load.js
blacklight-7.15.1 app/javascript/blacklight/facet_load.js
blacklight-7.15.0 app/javascript/blacklight/facet_load.js
blacklight-7.14.1 app/javascript/blacklight/facet_load.js
blacklight-7.14.0 app/javascript/blacklight/facet_load.js
blacklight-7.13.2 app/javascript/blacklight/facet_load.js
blacklight-7.13.1 app/javascript/blacklight/facet_load.js
blacklight-7.13.0 app/javascript/blacklight/facet_load.js
blacklight-7.12.1 app/javascript/blacklight/facet_load.js
blacklight-7.12.0 app/javascript/blacklight/facet_load.js
blacklight-7.11.1 app/javascript/blacklight/facet_load.js
blacklight-7.10.0 app/javascript/blacklight/facet_load.js
blacklight-7.9.0 app/javascript/blacklight/facet_load.js
blacklight-7.8.1 app/javascript/blacklight/facet_load.js
blacklight-7.8.0 app/javascript/blacklight/facet_load.js