blacklight_range_limit 8.3.0 → 8.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f27dcb701e35e32cec10ac4e6c203264c1fc5681cc7d754af1085eb8c5cf8e82
4
- data.tar.gz: 3189accdc1592a669f87e65729d1fc174794db399b847a43d8b354a2597137d1
3
+ metadata.gz: f38ae045cac278d85b4c4b0b3d85bd6c09fc1951de69b0728ea9e7f2e3e1c3fc
4
+ data.tar.gz: 4f893f100cfe891349ec653d96952d3f021f9bfa5f4bfee2041250eccc607770
5
5
  SHA512:
6
- metadata.gz: ec927ebe8aff759c1cd16911203cb65f2687c7df61914ee9a01f51d4469eff66f5b41a51c0a17fbaf6bb838f8b8ca5757f6f4df1f70fd66b662b8d55368e67a2
7
- data.tar.gz: 772c9541b39355fd40e9c6c822563864bc02ad944a9fec4a2eaa29bb2ebfec7964c826e1e8462f38c38119aee235179dd969a623764c44800a9c3ca95776e812
6
+ metadata.gz: c8ffd97ba8ae52935a038d30f26d9d664780817ff8a67927d5d7f8a5ccd4696850acb7d71278915d0e77cd7428632a89a9f88569ccd63325c8420963221522d3
7
+ data.tar.gz: ff9e650164699535a8165c3f8a27ee8740a367bec15a5b8ea14456d7cac1dc29f07749c0355f0e400deabf47862817a114700caf6ddebe958e86b6f689c255f3
@@ -23,6 +23,8 @@ jobs:
23
23
  rails_version: ['6.1.7.1', '7.0.4.1']
24
24
  additional_engine_cart_rails_options: ['']
25
25
  include:
26
+ - ruby: '3.3'
27
+ rails_version: '7.1.3'
26
28
  - ruby: '3.2'
27
29
  rails_version: '7.0.4.1'
28
30
  - ruby: '3.1'
@@ -30,14 +32,16 @@ jobs:
30
32
  - ruby: '3.0'
31
33
  rails_version: '7.0.4.1'
32
34
  env:
35
+ BLACKLIGHT_VERSION: "~> 7.0" # only test on BL 7 for now
33
36
  RAILS_VERSION: ${{ matrix.rails_version }}
34
- ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test ${{ matrix.engine_cart_rails_options }}"
37
+ ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-coffee --skip-test ${{ matrix.engine_cart_rails_options }}"
35
38
  steps:
36
39
  - uses: actions/checkout@v3
37
40
  - name: Set up Ruby
38
41
  uses: ruby/setup-ruby@v1
39
42
  with:
40
43
  ruby-version: ${{ matrix.ruby }}
44
+ bundler: 'latest'
41
45
  - name: Install dependencies
42
46
  run: bundle install
43
47
  - name: Run tests
data/.gitignore CHANGED
@@ -27,3 +27,4 @@ Gemfile.lock
27
27
  /pkg
28
28
  /tmp
29
29
  /.bundle
30
+ /node_modules
data/Gemfile CHANGED
@@ -9,6 +9,14 @@ group :test do
9
9
  gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
10
10
  end
11
11
 
12
+ # While gemspec allows BL8 and some people are using BL8... the build
13
+ # has never actually passed on BL8 yet. We may choose to run tests on
14
+ # a blacklight version other than the latest allowed by gemspec, to get
15
+ # tests to pass, or to test on older BL still supported here.
16
+ if ENV['BLACKLIGHT_VERSION']
17
+ gem "blacklight", ENV['BLACKLIGHT_VERSION']
18
+ end
19
+
12
20
  # BEGIN ENGINE_CART BLOCK
13
21
  # engine_cart: 2.5.0
14
22
  # engine_cart stanza: 2.5.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.3.0
1
+ 8.5.0
@@ -0,0 +1,534 @@
1
+ /**
2
+ * BlacklightRangeLimit module setup.
3
+ */
4
+
5
+ const BlacklightRangeLimit = function (options) {
6
+ this.options = options || {};
7
+ };
8
+
9
+ BlacklightRangeLimit.display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not
10
+ /* A custom event "plotDrawn.blacklight.rangeLimit" will be sent when flot plot
11
+ is (re-)drawn on screen possibly with a new size. target of event will be the DOM element
12
+ containing the plot. Used to resize slider to match. */
13
+ BlacklightRangeLimit.redrawnEvent = "plotDrawn.blacklight.rangeLimit";
14
+
15
+ // takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma
16
+ // use in place of javascript's native parseInt
17
+ BlacklightRangeLimit.parseNum = function parseNum(str) {
18
+ str = String(str).replace(/[^0-9-]/g, '');
19
+ return parseInt(str, 10);
20
+ };
21
+
22
+ BlacklightRangeLimit.form_selection = function form_selection(form, min, max) {
23
+ var begin_val = BlacklightRangeLimit.parseNum($(form).find("input.range_begin").val());
24
+ if (isNaN(begin_val) || begin_val < min) {
25
+ begin_val = min;
26
+ }
27
+ var end_val = BlacklightRangeLimit.parseNum($(form).find("input.range_end").val());
28
+ if (isNaN(end_val) || end_val > max) {
29
+ end_val = max;
30
+ }
31
+
32
+ return BlacklightRangeLimit.normalized_selection(begin_val, end_val);
33
+ };
34
+
35
+ // Add AJAX fetched range facets if needed, and add a chart to em
36
+ BlacklightRangeLimit.checkForNeededFacetsToFetch = function checkForNeededFacetsToFetch() {
37
+ $(".range_limit .profile .distribution a.load_distribution").each(function() {
38
+ var container = $(this).parent('div.distribution');
39
+
40
+ $(container).load($(this).attr('href'), function(response, status) {
41
+ if ($(container).hasClass("chart_js") && status == "success" ) {
42
+ BlacklightRangeLimit.turnIntoPlot(container);
43
+ }
44
+ });
45
+ });
46
+ };
47
+
48
+ BlacklightRangeLimit.function_for_find_segment = function function_for_find_segment(pointer_lookup_arr) {
49
+ return function(x_coord) {
50
+ for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) {
51
+ var hash = pointer_lookup_arr[i];
52
+ if (x_coord >= hash.from)
53
+ return hash;
54
+ }
55
+ return pointer_lookup_arr[0];
56
+ };
57
+ };
58
+
59
+ // Send endpoint to endpoint+0.99999 to have display
60
+ // more closely approximate limiting behavior esp
61
+ // at small resolutions. (Since we search on whole numbers,
62
+ // inclusive, but flot chart is decimal.)
63
+ BlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) {
64
+ max += 0.99999;
65
+
66
+ return {xaxis: { 'from':min, 'to':max}}
67
+ };
68
+
69
+ // Check if Flot is loaded
70
+ BlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() {
71
+ return typeof $.plot != "undefined"
72
+ };
73
+
74
+ BlacklightRangeLimit.modalObserverConfig = {
75
+ attributes: true,
76
+ };
77
+
78
+ BlacklightRangeLimit.initSliderModalObserver = function(modalSelector) {
79
+ // Use a mutation observer to detect when the modal dialog is open
80
+ const modalObserver = new MutationObserver(function(mutations) {
81
+ mutations.forEach(function(mutation) {
82
+ if (mutation.attributeName !== 'open') {return;}
83
+ if (mutation.target.hasAttribute('open')) {
84
+ $(modalSelector).find(".range_limit .profile .range.slider_js").each(function() {
85
+ BlacklightRangeLimit.buildSlider(this);
86
+ });
87
+ }
88
+ });
89
+ });
90
+ modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig);
91
+ };
92
+
93
+ BlacklightRangeLimit.initPlotModalObserver = function(modalSelector) {
94
+ // Use a mutation observer to detect when the modal dialog is open
95
+ const modalObserver = new MutationObserver(function(mutations) {
96
+ mutations.forEach(function(mutation) {
97
+ if (mutation.attributeName !== 'open') {return;}
98
+ if (mutation.target.hasAttribute('open')) {
99
+ $(modalSelector).find(".range_limit .profile .distribution.chart_js ul").each(function() {
100
+ BlacklightRangeLimit.turnIntoPlot($(this).parent());
101
+ });
102
+
103
+ // Case when there is no currently selected range
104
+ BlacklightRangeLimit.checkForNeededFacetsToFetch();
105
+ }
106
+ });
107
+ });
108
+ modalObserver.observe(document.querySelector(modalSelector), BlacklightRangeLimit.modalObserverConfig);
109
+ };
110
+
111
+ // second arg, if provided, is a number of ms we're willing to
112
+
113
+ BlacklightRangeLimit.turnIntoPlot = function turnIntoPlot(container, wait_for_visible) {
114
+ // flot can only render in a a div with a defined width.
115
+ // for instance, a hidden div can't generally be rendered in (although if you set
116
+ // an explicit width on it, it might work)
117
+ //
118
+ // We'll count on later code that catch bootstrap collapse open to render
119
+ // on show, for currently hidden divs.
120
+
121
+ // for some reason width sometimes return negative, not sure
122
+ // why but it's some kind of hidden.
123
+ if (container.width() > 0) {
124
+ var height = container.width() * BlacklightRangeLimit.display_ratio;
125
+
126
+ // Need an explicit height to make flot happy.
127
+ container.height( height );
128
+
129
+ BlacklightRangeLimit.areaChart($(container));
130
+
131
+ $(container).trigger(BlacklightRangeLimit.redrawnEvent);
132
+ }
133
+ else if (wait_for_visible > 0) {
134
+ setTimeout(function() {
135
+ BlacklightRangeLimit.turnIntoPlot(container, wait_for_visible - 50);
136
+ }, 50);
137
+ }
138
+ };
139
+
140
+ BlacklightRangeLimit.parseSegment = function parseSegment(el) {
141
+ if ($(el).find("span.single").first().data('blrlSingle')) {
142
+ var val = BlacklightRangeLimit.parseNum($(el).find("span.single").first().data('blrlSingle'));
143
+
144
+ return [val, val];
145
+ } else {
146
+ var from = BlacklightRangeLimit.parseNum($(el).find("span.from").first().data('blrlBegin'));
147
+ var to = BlacklightRangeLimit.parseNum($(el).find("span.to").first().data('blrlEnd'));
148
+
149
+ return [from, to];
150
+ }
151
+ };
152
+
153
+ // Takes a div holding a ul of distribution segments produced by
154
+ // blacklight_range_limit/_range_facets and makes it into
155
+ // a flot area chart.
156
+ BlacklightRangeLimit.areaChart = function areaChart(container) {
157
+ //flot loaded? And canvas element supported.
158
+ if ( BlacklightRangeLimit.domDependenciesMet() ) {
159
+
160
+ // Grab the data from the ul div
161
+ var series_data = new Array();
162
+ var pointer_lookup = new Array();
163
+ var x_ticks = new Array();
164
+ var min = BlacklightRangeLimit.parseSegment($(container).find("ul li:first-child").first())[0];
165
+ var max = BlacklightRangeLimit.parseSegment($(container).find("ul li:last-child").first())[1];
166
+
167
+ $(container).find("ul li").each(function() {
168
+ var segment = BlacklightRangeLimit.parseSegment(this);
169
+ var from = segment[0];
170
+ var to = segment[1];
171
+
172
+ var count = BlacklightRangeLimit.parseNum($(this).find("span.facet-count,span.count").text());
173
+ var avg = (count / (to - from + 1));
174
+
175
+ //We use the avg as the y-coord, to make the area of each
176
+ //segment proportional to how many documents it holds.
177
+ series_data.push( [from, avg ] );
178
+ series_data.push( [to+1, avg] );
179
+
180
+ x_ticks.push(from);
181
+
182
+ pointer_lookup.push({'from': from, 'to': to, 'count': count, 'label': $(this).find(".facet-select,.facet_select").html() });
183
+ });
184
+
185
+ x_ticks.push( max + 1 );
186
+
187
+ var plot;
188
+ var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {};
189
+
190
+ try {
191
+ plot = $.plot($(container), [series_data],
192
+ $.extend(true, config, {
193
+ yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1},
194
+ //xaxis: { ticks: x_ticks },
195
+ xaxis: { tickDecimals: 0 }, // force integer ticks
196
+ series: { lines: { fill: true, steps: true }},
197
+ grid: {clickable: true, hoverable: true, autoHighlight: false, margin: { left: 0, right: 0 }},
198
+ selection: {mode: "x"}
199
+ }));
200
+ }
201
+ catch(err) {
202
+ alert(err);
203
+ }
204
+
205
+ var find_segment_for = BlacklightRangeLimit.function_for_find_segment(pointer_lookup);
206
+ var last_segment = null;
207
+ $(container).tooltip({'html': true, 'placement': 'bottom', 'trigger': 'manual', 'delay': { show: 0, hide: 100}});
208
+
209
+ $(container).bind("plothover", function (event, pos, item) {
210
+ var segment = find_segment_for(pos.x);
211
+
212
+ if(segment != last_segment) {
213
+ var title = find_segment_for(pos.x).label + ' (' + BlacklightRangeLimit.parseNum(segment.count) + ')';
214
+ $(container).attr("title", title).tooltip("_fixTitle").tooltip("show");
215
+
216
+ last_segment = segment;
217
+ }
218
+ });
219
+
220
+ $(container).bind("mouseout", function() {
221
+ last_segment = null;
222
+ $(container).tooltip('hide');
223
+ });
224
+ $(container).bind("plotclick", function (event, pos, item) {
225
+ if ( plot.getSelection() == null) {
226
+ segment = find_segment_for(pos.x);
227
+ plot.setSelection(BlacklightRangeLimit.normalized_selection(segment.from, segment.to));
228
+ }
229
+ });
230
+ $(container).bind("plotselected plotselecting", function(event, ranges) {
231
+ if (ranges != null ) {
232
+ var from = Math.floor(ranges.xaxis.from);
233
+ var to = Math.floor(ranges.xaxis.to);
234
+
235
+ var form = $(container).closest(".limit_content").find("form.range_limit");
236
+ form.find("input.range_begin").val(from);
237
+ form.find("input.range_end").val(to);
238
+
239
+ var slider_placeholder = $(container).closest(".limit_content").find("[data-slider-placeholder]");
240
+ if (slider_placeholder) {
241
+ slider_placeholder.slider("setValue", [from, to]);
242
+ }
243
+ }
244
+ });
245
+
246
+ var form = $(container).closest(".limit_content").find("form.range_limit");
247
+ form.find("input.range_begin, input.range_end").on('input', function () {
248
+ plot.setSelection( BlacklightRangeLimit.form_selection(form, min, max), true );
249
+ });
250
+ $(container).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
251
+ var values = $(event.target).data("slider").getValue();
252
+ form.find("input.range_begin").val(values[0]);
253
+ form.find("input.range_end").val(values[1]);
254
+ plot.setSelection(BlacklightRangeLimit.normalized_selection(values[0], Math.max(values[0], values[1])), true);
255
+ });
256
+
257
+ // initially entirely selected, to match slider
258
+ plot.setSelection(BlacklightRangeLimit.normalized_selection(min, max));
259
+ }
260
+ };
261
+
262
+ // after a collapsible facet contents is fully shown,
263
+ // resize the flot chart to current conditions. This way, if you change
264
+ // browser window size, you can get chart resized to fit by closing and opening
265
+ // again, if needed.
266
+ BlacklightRangeLimit.redrawPlot = function redrawPlot(container) {
267
+ if (container && container.width() > 0) {
268
+ // resize the container's height, since width may have changed.
269
+ container.height( container.width() * BlacklightRangeLimit.display_ratio );
270
+
271
+ // redraw the chart.
272
+ var plot = container.data("plot");
273
+ if (plot) {
274
+ // how to redraw after possible resize?
275
+ // Cribbed from https://github.com/flot/flot/blob/master/jquery.flot.resize.js
276
+ plot.resize();
277
+ plot.setupGrid();
278
+ plot.draw();
279
+ // plus trigger redraw of the selection, which otherwise ain't always right
280
+ // we'll trigger a fake event on one of the boxes
281
+ var form = $(container).closest(".limit_content").find("form.range_limit");
282
+ form.find("input.range_begin").trigger("change");
283
+
284
+ // send our custom event to trigger redraw of slider
285
+ $(container).trigger(BlacklightRangeLimit.redrawnEvent);
286
+ }
287
+ }
288
+ };
289
+
290
+ /**
291
+ * Closure functions in this file are mainly concerned with initializing, resizing, and updating
292
+ * range limit functionality based off of page load, facet opening, page resizing, and otherwise
293
+ * events.
294
+ */
295
+
296
+ BlacklightRangeLimit.initializeDistroFacets = function(modalSelector) {
297
+ // Facets already on the page? Turn em into a chart.
298
+ $(".range_limit .profile .distribution.chart_js ul").each(function() {
299
+ BlacklightRangeLimit.turnIntoPlot($(this).parent());
300
+ });
301
+
302
+ BlacklightRangeLimit.checkForNeededFacetsToFetch();
303
+
304
+ // Listen for twitter bootstrap collapsible open events, to render flot
305
+ // in previously hidden divs on open, if needed.
306
+ $("body").on("show.bs.collapse", function(event) {
307
+ // Was the target a .facet-content including a .chart-js?
308
+ var container = $(event.target).filter(".facet-content").find(".chart_js");
309
+
310
+ // only if it doesn't already have a canvas, it isn't already drawn
311
+ if (container && container.find("canvas").length == 0) {
312
+ // be willing to wait up to 1100ms for container to
313
+ // have width -- right away on show.bs is too soon, but
314
+ // shown.bs is later than we want, we want to start rendering
315
+ // while animation is still in progress.
316
+ BlacklightRangeLimit.turnIntoPlot(container, 1100);
317
+ }
318
+ });
319
+
320
+ // For Blacklight version < 8, when loaded in a modal
321
+ $(modalSelector).on('shown.bs.modal', function() {
322
+ $(this).find(".range_limit .profile .distribution.chart_js ul").each(function() {
323
+ BlacklightRangeLimit.turnIntoPlot($(this).parent());
324
+ });
325
+
326
+ // Case when there is no currently selected range
327
+ BlacklightRangeLimit.checkForNeededFacetsToFetch();
328
+ });
329
+
330
+ // Use a mutation observer to detect when the HTML dialog is open
331
+ BlacklightRangeLimit.initPlotModalObserver(modalSelector);
332
+
333
+ $("body").on("shown.bs.collapse", function(event) {
334
+ var container = $(event.target).filter(".facet-content").find(".chart_js");
335
+ BlacklightRangeLimit.redrawPlot(container);
336
+ });
337
+
338
+ // debouce borrowed from underscore
339
+ // Returns a function, that, as long as it continues to be invoked, will not
340
+ // be triggered. The function will be called after it stops being called for
341
+ // N milliseconds. If `immediate` is passed, trigger the function on the
342
+ // leading edge, instead of the trailing.
343
+ const debounce = function(func, wait, immediate) {
344
+ var timeout;
345
+ return function() {
346
+ var context = this, args = arguments;
347
+ var later = function() {
348
+ timeout = null;
349
+ if (!immediate) func.apply(context, args);
350
+ };
351
+ var callNow = immediate && !timeout;
352
+ clearTimeout(timeout);
353
+ timeout = setTimeout(later, wait);
354
+ if (callNow) func.apply(context, args);
355
+ };
356
+ };
357
+
358
+ $(window).on("resize", debounce(function() {
359
+ $(".chart_js").each(function(i, container) {
360
+ BlacklightRangeLimit.redrawPlot($(container));
361
+ });
362
+ }, 350));
363
+ };
364
+
365
+ // for Blacklight.onLoad:
366
+
367
+ BlacklightRangeLimit.initializeSlider = function(modalSelector) {
368
+
369
+ $(".range_limit .profile .range.slider_js").each(function() {
370
+ BlacklightRangeLimit.buildSlider(this);
371
+ });
372
+
373
+ // For Blacklight < 8, when loaded in a modal
374
+ $(modalSelector).on('shown.bs.modal', function() {
375
+ $(this).find(".range_limit .profile .range.slider_js").each(function() {
376
+ BlacklightRangeLimit.buildSlider(this);
377
+ });
378
+ });
379
+
380
+ // For Blacklight 8, use a mutation observer to detect when the HTML dialog is open
381
+ BlacklightRangeLimit.initSliderModalObserver(modalSelector);
382
+
383
+ // catch event for redrawing chart, to redraw slider to match width
384
+ $("body").on("plotDrawn.blacklight.rangeLimit", function(event) {
385
+ var area = $(event.target).closest(".limit_content.range_limit");
386
+ var plot = area.find(".chart_js").data("plot");
387
+ var slider_el = area.find(".slider");
388
+
389
+ if (plot && slider_el) {
390
+ slider_el.width(plot.width());
391
+ slider_el.css("display", "block");
392
+ }
393
+ });
394
+ };
395
+
396
+ // returns two element array min/max as numbers. If there is a limit applied,
397
+ // it's boundaries are are limits. Otherwise, min/max in current result
398
+ // set as sniffed from HTML. Pass in a DOM element for a div.range
399
+ // Will return NaN as min or max in case of error or other weirdness.
400
+ BlacklightRangeLimit.min_max = function min_max(range_element) {
401
+ var current_limit = $(range_element).closest(".limit_content.range_limit").find(".current");
402
+ let min, max;
403
+ min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle'));
404
+ if ( isNaN(min)) {
405
+ min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin'));
406
+ max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd'));
407
+ }
408
+
409
+ if (isNaN(min) || isNaN(max)) {
410
+ //no current limit, take from results min max included in spans
411
+ min = BlacklightRangeLimit.parseNum($(range_element).find(".min").first().text());
412
+ max = BlacklightRangeLimit.parseNum($(range_element).find(".max").first().text());
413
+ }
414
+ return [min, max]
415
+ };
416
+
417
+
418
+ // Check to see if a value is an Integer
419
+ // see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer
420
+ BlacklightRangeLimit.isInt = function isInt(n) {
421
+ return n % 1 === 0;
422
+ };
423
+
424
+ BlacklightRangeLimit.buildSlider = function buildSlider(thisContext) {
425
+ var range_element = $(thisContext);
426
+
427
+ var boundaries = BlacklightRangeLimit.min_max(thisContext);
428
+ var min = boundaries[0];
429
+ var max = boundaries[1];
430
+
431
+ if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) {
432
+ $(thisContext).contents().wrapAll('<div class="sr-only visually-hidden" />');
433
+
434
+ var range_element = $(thisContext);
435
+ var form = $(range_element).closest(".range_limit").find("form.range_limit");
436
+ var begin_el = form.find("input.range_begin");
437
+ var end_el = form.find("input.range_end");
438
+
439
+ var placeholder_input = $('<input type="hidden" data-slider-placeholder="true" />').appendTo(range_element);
440
+
441
+ // make sure slider is loaded
442
+ if (placeholder_input.slider !== undefined) {
443
+ placeholder_input.slider({
444
+ min: min,
445
+ max: max,
446
+ value: [min, max],
447
+ tooltip: "hide"
448
+ });
449
+
450
+ // try to make slider width/orientation match chart's
451
+ var container = range_element.closest(".range_limit");
452
+ var plot_el = container.find(".chart_js");
453
+ var plot = plot_el.data("plot");
454
+ var slider_el = container.find(".slider");
455
+
456
+ if (plot_el) {
457
+ plot_el.attr('aria-hidden', 'true');
458
+ }
459
+
460
+ if (slider_el) {
461
+ slider_el.attr('aria-hidden', 'true');
462
+ }
463
+
464
+ if (plot && slider_el) {
465
+ slider_el.width(plot.width());
466
+ slider_el.css("display", "block");
467
+ } else if (slider_el) {
468
+ slider_el.css("width", "100%");
469
+ }
470
+ }
471
+
472
+ // Slider change should update text input values.
473
+ var parent = $(thisContext).parent();
474
+ var form = $(parent).closest(".limit_content").find("form.range_limit");
475
+ $(parent).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
476
+ var values = $(event.target).data("slider").getValue();
477
+ form.find("input.range_begin").val(values[0]);
478
+ form.find("input.range_end").val(values[1]);
479
+ });
480
+ }
481
+
482
+ begin_el.val(min);
483
+ end_el.val(max);
484
+
485
+ begin_el.on('input', function() {
486
+ var val = BlacklightRangeLimit.parseNum(this.value);
487
+ if (isNaN(val) || val < min) {
488
+ //for weird data, set slider at min
489
+ val = min;
490
+ }
491
+ var values = placeholder_input.data("slider").getValue();
492
+ values[0] = val;
493
+ placeholder_input.slider("setValue", values);
494
+ });
495
+
496
+ end_el.on('input', function() {
497
+ var val = BlacklightRangeLimit.parseNum(this.value);
498
+ if (isNaN(val) || val > max) {
499
+ //weird entry, set slider to max
500
+ val = max;
501
+ }
502
+ var values = placeholder_input.data("slider").getValue();
503
+ values[1] = val;
504
+ placeholder_input.slider("setValue", values);
505
+ });
506
+
507
+ begin_el.change(function() {
508
+ var val1 = BlacklightRangeLimit.parseNum(begin_el.val());
509
+ var val2 = BlacklightRangeLimit.parseNum(end_el.val());
510
+
511
+ if (val2 < val1) {
512
+ begin_el.val(val2);
513
+ end_el.val(val1);
514
+ }
515
+ });
516
+
517
+ end_el.change(function() {
518
+ var val1 = BlacklightRangeLimit.parseNum(begin_el.val());
519
+ var val2 = BlacklightRangeLimit.parseNum(end_el.val());
520
+
521
+ if (val2 < val1) {
522
+ begin_el.val(val2);
523
+ end_el.val(val1);
524
+ }
525
+ });
526
+ };
527
+
528
+ BlacklightRangeLimit.initialize = function(modalSelector) {
529
+ BlacklightRangeLimit.initializeDistroFacets(modalSelector);
530
+ BlacklightRangeLimit.initializeSlider(modalSelector);
531
+ };
532
+
533
+ export { BlacklightRangeLimit as default };
534
+ //# sourceMappingURL=blacklight_range_limit.esm.js.map