blacklight_range_limit 8.5.0 → 9.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +117 -26
- data/.gitignore +2 -1
- data/.solr_wrapper.yml +8 -0
- data/Gemfile +7 -1
- data/README.md +77 -86
- data/Rakefile +31 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight-range-limit/index.js +345 -0
- data/app/components/blacklight_range_limit/range_facet_component.html.erb +29 -27
- data/app/components/blacklight_range_limit/range_facet_component.rb +15 -9
- data/app/components/blacklight_range_limit/range_form_component.html.erb +13 -5
- data/app/components/blacklight_range_limit/range_form_component.rb +8 -20
- data/app/presenters/blacklight_range_limit/facet_field_presenter.rb +13 -2
- data/app/presenters/blacklight_range_limit/facet_item_presenter.rb +6 -11
- data/app/presenters/blacklight_range_limit/filter_field.rb +2 -2
- data/blacklight_range_limit.gemspec +1 -1
- data/config/importmap.rb +9 -0
- data/config/locales/blacklight_range_limit.ar.yml +13 -8
- data/config/locales/blacklight_range_limit.de.yml +13 -8
- data/config/locales/blacklight_range_limit.en.yml +5 -1
- data/config/locales/blacklight_range_limit.es.yml +18 -0
- data/config/locales/blacklight_range_limit.it.yml +13 -8
- data/lib/blacklight_range_limit/controller_override.rb +1 -25
- data/lib/blacklight_range_limit/engine.rb +48 -0
- data/lib/blacklight_range_limit/range_limit_builder.rb +40 -3
- data/lib/blacklight_range_limit.rb +8 -31
- data/lib/generators/blacklight_range_limit/assets_generator.rb +82 -18
- data/lib/generators/blacklight_range_limit/install_generator.rb +1 -1
- data/lib/generators/blacklight_range_limit/jsbundling_bl7_fixup_generator.rb +98 -0
- data/package-lock.json +8 -7
- data/package.json +10 -14
- data/spec/components/range_facet_component_spec.rb +41 -32
- data/spec/components/range_form_component_spec.rb +2 -2
- data/spec/components/range_segments_component_spec.rb +64 -0
- data/spec/features/blacklight_range_limit_spec.rb +21 -13
- data/spec/features/run_through_spec.rb +157 -0
- data/spec/presenters/facet_field_presenter_spec.rb +72 -0
- data/spec/presenters/filter_field_spec.rb +36 -1
- data/spec/spec_helper.rb +10 -0
- data/spec/test_app_templates/Gemfile.extra +11 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +37 -6
- metadata +25 -51
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js +0 -534
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js.map +0 -1
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js +0 -542
- data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js.map +0 -1
- data/app/assets/javascripts/blacklight_range_limit.js +0 -27
- data/app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css +0 -60
- data/app/assets/stylesheets/blacklight_range_limit.css +0 -7
- data/app/helpers/range_limit_helper.rb +0 -130
- data/app/javascript/blacklight_range_limit/index.js +0 -11
- data/app/javascript/blacklight_range_limit/range_limit_distro_facets.js +0 -76
- data/app/javascript/blacklight_range_limit/range_limit_plotting.js +0 -186
- data/app/javascript/blacklight_range_limit/range_limit_shared.js +0 -112
- data/app/javascript/blacklight_range_limit/range_limit_slider.js +0 -163
- data/app/javascripts/blacklight_range_limit/index.js +0 -13
- data/app/views/blacklight_range_limit/_range_segments.html.erb +0 -8
- data/app/views/blacklight_range_limit/range_segments.html.erb +0 -1
- data/app/views/catalog/range_limit_panel.html.erb +0 -1
- data/rollup.config.js +0 -37
- data/spec/features/a_javascript_spec.rb +0 -70
- data/spec/helpers/blacklight_range_limit_helper_spec.rb +0 -37
- data/vendor/assets/javascripts/bootstrap-slider.js +0 -388
- data/vendor/assets/javascripts/flot/jquery.canvaswrapper.js +0 -549
- data/vendor/assets/javascripts/flot/jquery.colorhelpers.js +0 -199
- data/vendor/assets/javascripts/flot/jquery.event.drag.js +0 -145
- data/vendor/assets/javascripts/flot/jquery.flot.browser.js +0 -98
- data/vendor/assets/javascripts/flot/jquery.flot.drawSeries.js +0 -662
- data/vendor/assets/javascripts/flot/jquery.flot.hover.js +0 -359
- data/vendor/assets/javascripts/flot/jquery.flot.js +0 -2818
- data/vendor/assets/javascripts/flot/jquery.flot.saturated.js +0 -43
- data/vendor/assets/javascripts/flot/jquery.flot.selection.js +0 -527
- data/vendor/assets/javascripts/flot/jquery.flot.uiConstants.js +0 -10
- data/vendor/assets/stylesheets/slider.css +0 -138
@@ -1,359 +0,0 @@
|
|
1
|
-
/* global jQuery */
|
2
|
-
|
3
|
-
/**
|
4
|
-
## jquery.flot.hover.js
|
5
|
-
|
6
|
-
This plugin is used for mouse hover and tap on a point of plot series.
|
7
|
-
It supports the following options:
|
8
|
-
```js
|
9
|
-
grid: {
|
10
|
-
hoverable: false, //to trigger plothover event on mouse hover or tap on a point
|
11
|
-
clickable: false //to trigger plotclick event on mouse hover
|
12
|
-
}
|
13
|
-
```
|
14
|
-
|
15
|
-
It listens to native mouse move event or click, as well as artificial generated
|
16
|
-
tap and touchevent.
|
17
|
-
|
18
|
-
When the mouse is over a point or a tap on a point is performed, that point or
|
19
|
-
the correscponding bar will be highlighted and a "plothover" event will be generated.
|
20
|
-
|
21
|
-
Custom "touchevent" is triggered when any touch interaction is made. Hover plugin
|
22
|
-
handles this events by unhighlighting all of the previously highlighted points and generates
|
23
|
-
"plothovercleanup" event to notify any part that is handling plothover (for exemple to cleanup
|
24
|
-
the tooltip from webcharts).
|
25
|
-
*/
|
26
|
-
|
27
|
-
(function($) {
|
28
|
-
'use strict';
|
29
|
-
|
30
|
-
var options = {
|
31
|
-
grid: {
|
32
|
-
hoverable: false,
|
33
|
-
clickable: false
|
34
|
-
}
|
35
|
-
};
|
36
|
-
|
37
|
-
var browser = $.plot.browser;
|
38
|
-
|
39
|
-
var eventType = {
|
40
|
-
click: 'click',
|
41
|
-
hover: 'hover'
|
42
|
-
}
|
43
|
-
|
44
|
-
function init(plot) {
|
45
|
-
var lastMouseMoveEvent;
|
46
|
-
var highlights = [];
|
47
|
-
|
48
|
-
function bindEvents(plot, eventHolder) {
|
49
|
-
var o = plot.getOptions();
|
50
|
-
|
51
|
-
if (o.grid.hoverable || o.grid.clickable) {
|
52
|
-
eventHolder[0].addEventListener('touchevent', triggerCleanupEvent, false);
|
53
|
-
eventHolder[0].addEventListener('tap', generatePlothoverEvent, false);
|
54
|
-
}
|
55
|
-
|
56
|
-
if (o.grid.clickable) {
|
57
|
-
eventHolder.bind("click", onClick);
|
58
|
-
}
|
59
|
-
|
60
|
-
if (o.grid.hoverable) {
|
61
|
-
eventHolder.bind("mousemove", onMouseMove);
|
62
|
-
|
63
|
-
// Use bind, rather than .mouseleave, because we officially
|
64
|
-
// still support jQuery 1.2.6, which doesn't define a shortcut
|
65
|
-
// for mouseenter or mouseleave. This was a bug/oversight that
|
66
|
-
// was fixed somewhere around 1.3.x. We can return to using
|
67
|
-
// .mouseleave when we drop support for 1.2.6.
|
68
|
-
|
69
|
-
eventHolder.bind("mouseleave", onMouseLeave);
|
70
|
-
}
|
71
|
-
}
|
72
|
-
|
73
|
-
function shutdown(plot, eventHolder) {
|
74
|
-
eventHolder[0].removeEventListener('tap', generatePlothoverEvent);
|
75
|
-
eventHolder[0].removeEventListener('touchevent', triggerCleanupEvent);
|
76
|
-
eventHolder.unbind("mousemove", onMouseMove);
|
77
|
-
eventHolder.unbind("mouseleave", onMouseLeave);
|
78
|
-
eventHolder.unbind("click", onClick);
|
79
|
-
highlights = [];
|
80
|
-
}
|
81
|
-
|
82
|
-
function generatePlothoverEvent(e) {
|
83
|
-
var o = plot.getOptions(),
|
84
|
-
newEvent = new CustomEvent('mouseevent');
|
85
|
-
|
86
|
-
//transform from touch event to mouse event format
|
87
|
-
newEvent.pageX = e.detail.changedTouches[0].pageX;
|
88
|
-
newEvent.pageY = e.detail.changedTouches[0].pageY;
|
89
|
-
newEvent.clientX = e.detail.changedTouches[0].clientX;
|
90
|
-
newEvent.clientY = e.detail.changedTouches[0].clientY;
|
91
|
-
|
92
|
-
if (o.grid.hoverable) {
|
93
|
-
doTriggerClickHoverEvent(newEvent, eventType.hover, 30);
|
94
|
-
}
|
95
|
-
return false;
|
96
|
-
}
|
97
|
-
|
98
|
-
function doTriggerClickHoverEvent(event, eventType, searchDistance) {
|
99
|
-
var series = plot.getData();
|
100
|
-
if (event !== undefined &&
|
101
|
-
series.length > 0 &&
|
102
|
-
series[0].xaxis.c2p !== undefined &&
|
103
|
-
series[0].yaxis.c2p !== undefined) {
|
104
|
-
var eventToTrigger = "plot" + eventType;
|
105
|
-
var seriesFlag = eventType + "able";
|
106
|
-
triggerClickHoverEvent(eventToTrigger, event,
|
107
|
-
function(i) {
|
108
|
-
return series[i][seriesFlag] !== false;
|
109
|
-
}, searchDistance);
|
110
|
-
}
|
111
|
-
}
|
112
|
-
|
113
|
-
function onMouseMove(e) {
|
114
|
-
lastMouseMoveEvent = e;
|
115
|
-
plot.getPlaceholder()[0].lastMouseMoveEvent = e;
|
116
|
-
doTriggerClickHoverEvent(e, eventType.hover);
|
117
|
-
}
|
118
|
-
|
119
|
-
function onMouseLeave(e) {
|
120
|
-
lastMouseMoveEvent = undefined;
|
121
|
-
plot.getPlaceholder()[0].lastMouseMoveEvent = undefined;
|
122
|
-
triggerClickHoverEvent("plothover", e,
|
123
|
-
function(i) {
|
124
|
-
return false;
|
125
|
-
});
|
126
|
-
}
|
127
|
-
|
128
|
-
function onClick(e) {
|
129
|
-
doTriggerClickHoverEvent(e, eventType.click);
|
130
|
-
}
|
131
|
-
|
132
|
-
function triggerCleanupEvent() {
|
133
|
-
plot.unhighlight();
|
134
|
-
plot.getPlaceholder().trigger('plothovercleanup');
|
135
|
-
}
|
136
|
-
|
137
|
-
// trigger click or hover event (they send the same parameters
|
138
|
-
// so we share their code)
|
139
|
-
function triggerClickHoverEvent(eventname, event, seriesFilter, searchDistance) {
|
140
|
-
var options = plot.getOptions(),
|
141
|
-
offset = plot.offset(),
|
142
|
-
page = browser.getPageXY(event),
|
143
|
-
canvasX = page.X - offset.left,
|
144
|
-
canvasY = page.Y - offset.top,
|
145
|
-
pos = plot.c2p({
|
146
|
-
left: canvasX,
|
147
|
-
top: canvasY
|
148
|
-
}),
|
149
|
-
distance = searchDistance !== undefined ? searchDistance : options.grid.mouseActiveRadius;
|
150
|
-
|
151
|
-
pos.pageX = page.X;
|
152
|
-
pos.pageY = page.Y;
|
153
|
-
|
154
|
-
var items = plot.findNearbyItems(canvasX, canvasY, seriesFilter, distance);
|
155
|
-
var item = items[0];
|
156
|
-
|
157
|
-
for (let i = 1; i < items.length; ++i) {
|
158
|
-
if (item.distance === undefined ||
|
159
|
-
items[i].distance < item.distance) {
|
160
|
-
item = items[i];
|
161
|
-
}
|
162
|
-
}
|
163
|
-
|
164
|
-
if (item) {
|
165
|
-
// fill in mouse pos for any listeners out there
|
166
|
-
item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left, 10);
|
167
|
-
item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top, 10);
|
168
|
-
} else {
|
169
|
-
item = null;
|
170
|
-
}
|
171
|
-
|
172
|
-
if (options.grid.autoHighlight) {
|
173
|
-
// clear auto-highlights
|
174
|
-
for (let i = 0; i < highlights.length; ++i) {
|
175
|
-
var h = highlights[i];
|
176
|
-
if ((h.auto === eventname &&
|
177
|
-
!(item && h.series === item.series &&
|
178
|
-
h.point[0] === item.datapoint[0] &&
|
179
|
-
h.point[1] === item.datapoint[1])) || !item) {
|
180
|
-
unhighlight(h.series, h.point);
|
181
|
-
}
|
182
|
-
}
|
183
|
-
|
184
|
-
if (item) {
|
185
|
-
highlight(item.series, item.datapoint, eventname);
|
186
|
-
}
|
187
|
-
}
|
188
|
-
|
189
|
-
plot.getPlaceholder().trigger(eventname, [pos, item, items]);
|
190
|
-
}
|
191
|
-
|
192
|
-
function highlight(s, point, auto) {
|
193
|
-
if (typeof s === "number") {
|
194
|
-
s = plot.getData()[s];
|
195
|
-
}
|
196
|
-
|
197
|
-
if (typeof point === "number") {
|
198
|
-
var ps = s.datapoints.pointsize;
|
199
|
-
point = s.datapoints.points.slice(ps * point, ps * (point + 1));
|
200
|
-
}
|
201
|
-
|
202
|
-
var i = indexOfHighlight(s, point);
|
203
|
-
if (i === -1) {
|
204
|
-
highlights.push({
|
205
|
-
series: s,
|
206
|
-
point: point,
|
207
|
-
auto: auto
|
208
|
-
});
|
209
|
-
|
210
|
-
plot.triggerRedrawOverlay();
|
211
|
-
} else if (!auto) {
|
212
|
-
highlights[i].auto = false;
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
function unhighlight(s, point) {
|
217
|
-
if (s == null && point == null) {
|
218
|
-
highlights = [];
|
219
|
-
plot.triggerRedrawOverlay();
|
220
|
-
return;
|
221
|
-
}
|
222
|
-
|
223
|
-
if (typeof s === "number") {
|
224
|
-
s = plot.getData()[s];
|
225
|
-
}
|
226
|
-
|
227
|
-
if (typeof point === "number") {
|
228
|
-
var ps = s.datapoints.pointsize;
|
229
|
-
point = s.datapoints.points.slice(ps * point, ps * (point + 1));
|
230
|
-
}
|
231
|
-
|
232
|
-
var i = indexOfHighlight(s, point);
|
233
|
-
if (i !== -1) {
|
234
|
-
highlights.splice(i, 1);
|
235
|
-
|
236
|
-
plot.triggerRedrawOverlay();
|
237
|
-
}
|
238
|
-
}
|
239
|
-
|
240
|
-
function indexOfHighlight(s, p) {
|
241
|
-
for (var i = 0; i < highlights.length; ++i) {
|
242
|
-
var h = highlights[i];
|
243
|
-
if (h.series === s &&
|
244
|
-
h.point[0] === p[0] &&
|
245
|
-
h.point[1] === p[1]) {
|
246
|
-
return i;
|
247
|
-
}
|
248
|
-
}
|
249
|
-
|
250
|
-
return -1;
|
251
|
-
}
|
252
|
-
|
253
|
-
function processDatapoints() {
|
254
|
-
triggerCleanupEvent();
|
255
|
-
doTriggerClickHoverEvent(lastMouseMoveEvent, eventType.hover);
|
256
|
-
}
|
257
|
-
|
258
|
-
function setupGrid() {
|
259
|
-
doTriggerClickHoverEvent(lastMouseMoveEvent, eventType.hover);
|
260
|
-
}
|
261
|
-
|
262
|
-
function drawOverlay(plot, octx, overlay) {
|
263
|
-
var plotOffset = plot.getPlotOffset(),
|
264
|
-
i, hi;
|
265
|
-
|
266
|
-
octx.save();
|
267
|
-
octx.translate(plotOffset.left, plotOffset.top);
|
268
|
-
for (i = 0; i < highlights.length; ++i) {
|
269
|
-
hi = highlights[i];
|
270
|
-
|
271
|
-
if (hi.series.bars.show) drawBarHighlight(hi.series, hi.point, octx);
|
272
|
-
else drawPointHighlight(hi.series, hi.point, octx, plot);
|
273
|
-
}
|
274
|
-
octx.restore();
|
275
|
-
}
|
276
|
-
|
277
|
-
function drawPointHighlight(series, point, octx, plot) {
|
278
|
-
var x = point[0],
|
279
|
-
y = point[1],
|
280
|
-
axisx = series.xaxis,
|
281
|
-
axisy = series.yaxis,
|
282
|
-
highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString();
|
283
|
-
|
284
|
-
if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) {
|
285
|
-
return;
|
286
|
-
}
|
287
|
-
|
288
|
-
var pointRadius = series.points.radius + series.points.lineWidth / 2;
|
289
|
-
octx.lineWidth = pointRadius;
|
290
|
-
octx.strokeStyle = highlightColor;
|
291
|
-
var radius = 1.5 * pointRadius;
|
292
|
-
x = axisx.p2c(x);
|
293
|
-
y = axisy.p2c(y);
|
294
|
-
|
295
|
-
octx.beginPath();
|
296
|
-
var symbol = series.points.symbol;
|
297
|
-
if (symbol === 'circle') {
|
298
|
-
octx.arc(x, y, radius, 0, 2 * Math.PI, false);
|
299
|
-
} else if (typeof symbol === 'string' && plot.drawSymbol && plot.drawSymbol[symbol]) {
|
300
|
-
plot.drawSymbol[symbol](octx, x, y, radius, false);
|
301
|
-
}
|
302
|
-
|
303
|
-
octx.closePath();
|
304
|
-
octx.stroke();
|
305
|
-
}
|
306
|
-
|
307
|
-
function drawBarHighlight(series, point, octx) {
|
308
|
-
var highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString(),
|
309
|
-
fillStyle = highlightColor,
|
310
|
-
barLeft;
|
311
|
-
|
312
|
-
var barWidth = series.bars.barWidth[0] || series.bars.barWidth;
|
313
|
-
switch (series.bars.align) {
|
314
|
-
case "left":
|
315
|
-
barLeft = 0;
|
316
|
-
break;
|
317
|
-
case "right":
|
318
|
-
barLeft = -barWidth;
|
319
|
-
break;
|
320
|
-
default:
|
321
|
-
barLeft = -barWidth / 2;
|
322
|
-
}
|
323
|
-
|
324
|
-
octx.lineWidth = series.bars.lineWidth;
|
325
|
-
octx.strokeStyle = highlightColor;
|
326
|
-
|
327
|
-
var fillTowards = series.bars.fillTowards || 0,
|
328
|
-
bottom = fillTowards > series.yaxis.min ? Math.min(series.yaxis.max, fillTowards) : series.yaxis.min;
|
329
|
-
|
330
|
-
$.plot.drawSeries.drawBar(point[0], point[1], point[2] || bottom, barLeft, barLeft + barWidth,
|
331
|
-
function() {
|
332
|
-
return fillStyle;
|
333
|
-
}, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
|
334
|
-
}
|
335
|
-
|
336
|
-
function initHover(plot, options) {
|
337
|
-
plot.highlight = highlight;
|
338
|
-
plot.unhighlight = unhighlight;
|
339
|
-
if (options.grid.hoverable || options.grid.clickable) {
|
340
|
-
plot.hooks.drawOverlay.push(drawOverlay);
|
341
|
-
plot.hooks.processDatapoints.push(processDatapoints);
|
342
|
-
plot.hooks.setupGrid.push(setupGrid);
|
343
|
-
}
|
344
|
-
|
345
|
-
lastMouseMoveEvent = plot.getPlaceholder()[0].lastMouseMoveEvent;
|
346
|
-
}
|
347
|
-
|
348
|
-
plot.hooks.bindEvents.push(bindEvents);
|
349
|
-
plot.hooks.shutdown.push(shutdown);
|
350
|
-
plot.hooks.processOptions.push(initHover);
|
351
|
-
}
|
352
|
-
|
353
|
-
$.plot.plugins.push({
|
354
|
-
init: init,
|
355
|
-
options: options,
|
356
|
-
name: 'hover',
|
357
|
-
version: '0.1'
|
358
|
-
});
|
359
|
-
})(jQuery);
|