PageSourceSearch

https://www.jhrl.com/sites/all/modules/bluetent/riot_solr/contrib/…/js//RiotSolrFacetRanges.js?tlse4v

js jhrl.com collected 2026-10-06 13:18:04 UTC 3,959 bytes, 113 lines download raw bytes

1(function($) {
2  AjaxSolr.RiotSolrFacetRanges = AjaxSolr.RiotSolrFacetWidget.extend({
3    initStore: function() {
4      AjaxSolr.AbstractFacetWidget.prototype.initStore.apply(this);
5      // Set facet.field, facet.date or facet.range to truthy values to add
6      // related per-field parameters to the parameter store.
7      if (this['facet.range'] !== undefined) {
8        this.manager.store.removeByValue('facet.range', this.field);
9        this.manager.store.addByValue('facet.range', '{!ex=RiotSolrWidget}' + this.field);
10      }
11      if (this['stats'] !== undefined) {
12        // this.manager.store.removeByValue('stats', this['stats']);
13        this.manager.store.addByValue('stats', 'true');
14        // this.manager.store.removeByValue('stats.field', '{!ex=RiotSolrWidget}' + this['stats.field']);
15        this.manager.store.addByValue('stats.field', '{!ex=RiotSolrWidget}' + this['stats.field']);
16      }
17    },
18    set: function(value) {
19      if (RiotSolrAppTracker) {
20        RiotSolrAppTracker.trackEvent({
21          category: 'Search - ' + this.getLabel(),
22          action: 'Facet Set',
23          label: value.replace(/(^\[|\]$)/g, '').toLowerCase(),
24          entityInfo: this.manager.bundles
25            ? this.manager.entityType + ' - ' + this.manager.bundles.join(', ')
26            : this.manager.entityType,
27        });
28      }
29
30      return this.changeSelection(function() {
31        var a = this.manager.store.removeByValue(
32          'fq',
33          new RegExp('^-?.*' + this.manager.regexEscape(this.field) + ':')
34        ),
35          b = this.manager.store.add(
36            'fq',
37            new AjaxSolr.Parameter({
38              name: 'fq',
39              value: this.fq(value),
40            })
41          );
42        return a || b;
43      });
44    },
45    afterRequest: function() {
46      var eventParams = {
47        observable: this.observable,
48        instance: this,
49        field: this.field,
50        widget: 'RiotSolrFacetRanges',
51        stats: this.manager.response['stats']['stats_fields'][this.field],
52      };
53      this.observable.trigger('RiotSolrFacetRangesUpdate', eventParams);
54    },
55    fq: function(value, exclude) {
56      return (exclude ? '-' : '') + this.getTag() + this.field + ':' + AjaxSolr.Parameter.escapeValue(value);
57    },
58    getTag: function() {
59      return '{!tag=RiotSolrWidget,' + this.field + '}';
60    },
61    getCurrentFilterRange: function() {
62      var inds = this.getFQ(),
63        range = null,
64        min = null;
65      if (inds && inds.length) {
66        match = this.manager.store.get('fq')[inds[0]].value.match(/\[(\d*\.?\d+|\*) TO (\d*\.?\d+|\*)\]/);
67        if (match != null) {
68          range = [match[1] === '*' ? 0 : parseFloat(match[1], 10), parseFloat(match[2], 10)];
69        } else {
70          match = this.manager.store.get('fq')[inds[0]].value.match(/([0-9\*]+)/);
71          if (match != null) {
72            min = match[1] === '*' ? 0 : parseFloat(match[1], 10);
73            range = [min, min];
74          }
75        }
76      }
77
78      return range;
79    },
80    formatCurrentSearchLabel: function() {
81      var links = [],
82        vals = this.getCurrentFilterRange(),
83        inds = this.getFQ(),
84        fq;
85
86      if (vals && vals.length && this.observable && this.observable.opts.currency) {
87        vals[0] = this.formatCurrency(vals[0]);
88        vals[1] = this.formatCurrency(vals[1]);
89      }
90
91      if (vals) {
92        fq = this.manager.store.get('fq')[inds[0]];
93        links.push({
94          facet: fq.value,
95          label: this.getLabel() + ': ' + vals[0] + ' to ' + vals[1],
96        });
97      }
98      return links;
99    },
100    formatCurrency: function(value) {
101      return !value
102        ? ''
103        : value.toLocaleString('en', {
104            minimumFractionDigits: 0,
105            maximumFractionDigits: 0,
106            style: 'currency',
107            currency: 'USD',
108            currencyDisplay: 'symbol',
109            useGrouping: true,
110          });
111    },
112  });
113})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.