blacklight_range_limit 8.5.0 → 9.0.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +117 -26
  3. data/.gitignore +2 -1
  4. data/.solr_wrapper.yml +8 -0
  5. data/Gemfile +7 -1
  6. data/README.md +84 -87
  7. data/Rakefile +69 -0
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight-range-limit/index.js +345 -0
  10. data/app/components/blacklight_range_limit/range_facet_component.html.erb +29 -27
  11. data/app/components/blacklight_range_limit/range_facet_component.rb +27 -9
  12. data/app/components/blacklight_range_limit/range_form_component.html.erb +23 -5
  13. data/app/components/blacklight_range_limit/range_form_component.rb +8 -20
  14. data/app/presenters/blacklight_range_limit/facet_field_presenter.rb +13 -2
  15. data/app/presenters/blacklight_range_limit/facet_item_presenter.rb +15 -11
  16. data/app/presenters/blacklight_range_limit/filter_field.rb +9 -3
  17. data/blacklight_range_limit.gemspec +1 -1
  18. data/config/importmap.rb +9 -0
  19. data/config/locales/blacklight_range_limit.ar.yml +13 -8
  20. data/config/locales/blacklight_range_limit.de.yml +13 -8
  21. data/config/locales/blacklight_range_limit.en.yml +5 -1
  22. data/config/locales/blacklight_range_limit.es.yml +18 -0
  23. data/config/locales/blacklight_range_limit.it.yml +13 -8
  24. data/doc/example-screenshot.png +0 -0
  25. data/lib/blacklight_range_limit/controller_override.rb +8 -35
  26. data/lib/blacklight_range_limit/engine.rb +48 -0
  27. data/lib/blacklight_range_limit/range_limit_builder.rb +61 -3
  28. data/lib/blacklight_range_limit.rb +10 -30
  29. data/lib/generators/blacklight_range_limit/assets_generator.rb +82 -18
  30. data/lib/generators/blacklight_range_limit/install_generator.rb +5 -2
  31. data/lib/generators/blacklight_range_limit/jsbundling_bl7_fixup_generator.rb +98 -0
  32. data/package-lock.json +8 -7
  33. data/package.json +10 -14
  34. data/spec/components/range_facet_component_spec.rb +101 -32
  35. data/spec/components/range_form_component_spec.rb +2 -2
  36. data/spec/components/range_segments_component_spec.rb +64 -0
  37. data/spec/features/blacklight_range_limit_spec.rb +21 -13
  38. data/spec/features/run_through_spec.rb +210 -0
  39. data/spec/presenters/facet_field_presenter_spec.rb +72 -0
  40. data/spec/presenters/filter_field_spec.rb +36 -1
  41. data/spec/requests/bad_param_requests_spec.rb +61 -0
  42. data/spec/spec_helper.rb +10 -0
  43. data/spec/test_app_templates/Gemfile.extra +11 -1
  44. data/spec/test_app_templates/lib/generators/test_app_generator.rb +37 -6
  45. metadata +27 -51
  46. data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js +0 -534
  47. data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.esm.js.map +0 -1
  48. data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js +0 -542
  49. data/app/assets/javascripts/blacklight_range_limit/blacklight_range_limit.umd.js.map +0 -1
  50. data/app/assets/javascripts/blacklight_range_limit.js +0 -27
  51. data/app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css +0 -60
  52. data/app/assets/stylesheets/blacklight_range_limit.css +0 -7
  53. data/app/helpers/range_limit_helper.rb +0 -130
  54. data/app/javascript/blacklight_range_limit/index.js +0 -11
  55. data/app/javascript/blacklight_range_limit/range_limit_distro_facets.js +0 -76
  56. data/app/javascript/blacklight_range_limit/range_limit_plotting.js +0 -186
  57. data/app/javascript/blacklight_range_limit/range_limit_shared.js +0 -112
  58. data/app/javascript/blacklight_range_limit/range_limit_slider.js +0 -163
  59. data/app/javascripts/blacklight_range_limit/index.js +0 -13
  60. data/app/views/blacklight_range_limit/_range_segments.html.erb +0 -8
  61. data/app/views/blacklight_range_limit/range_segments.html.erb +0 -1
  62. data/app/views/catalog/range_limit_panel.html.erb +0 -1
  63. data/rollup.config.js +0 -37
  64. data/spec/features/a_javascript_spec.rb +0 -70
  65. data/spec/helpers/blacklight_range_limit_helper_spec.rb +0 -37
  66. data/vendor/assets/javascripts/bootstrap-slider.js +0 -388
  67. data/vendor/assets/javascripts/flot/jquery.canvaswrapper.js +0 -549
  68. data/vendor/assets/javascripts/flot/jquery.colorhelpers.js +0 -199
  69. data/vendor/assets/javascripts/flot/jquery.event.drag.js +0 -145
  70. data/vendor/assets/javascripts/flot/jquery.flot.browser.js +0 -98
  71. data/vendor/assets/javascripts/flot/jquery.flot.drawSeries.js +0 -662
  72. data/vendor/assets/javascripts/flot/jquery.flot.hover.js +0 -359
  73. data/vendor/assets/javascripts/flot/jquery.flot.js +0 -2818
  74. data/vendor/assets/javascripts/flot/jquery.flot.saturated.js +0 -43
  75. data/vendor/assets/javascripts/flot/jquery.flot.selection.js +0 -527
  76. data/vendor/assets/javascripts/flot/jquery.flot.uiConstants.js +0 -10
  77. data/vendor/assets/stylesheets/slider.css +0 -138
@@ -1,43 +0,0 @@
1
- (function ($) {
2
- 'use strict';
3
- var saturated = {
4
- saturate: function (a) {
5
- if (a === Infinity) {
6
- return Number.MAX_VALUE;
7
- }
8
-
9
- if (a === -Infinity) {
10
- return -Number.MAX_VALUE;
11
- }
12
-
13
- return a;
14
- },
15
- delta: function(min, max, noTicks) {
16
- return ((max - min) / noTicks) === Infinity ? (max / noTicks - min / noTicks) : (max - min) / noTicks
17
- },
18
- multiply: function (a, b) {
19
- return saturated.saturate(a * b);
20
- },
21
- // returns c * bInt * a. Beahves properly in the case where c is negative
22
- // and bInt * a is bigger that Number.MAX_VALUE (Infinity)
23
- multiplyAdd: function (a, bInt, c) {
24
- if (isFinite(a * bInt)) {
25
- return saturated.saturate(a * bInt + c);
26
- } else {
27
- var result = c;
28
-
29
- for (var i = 0; i < bInt; i++) {
30
- result += a;
31
- }
32
-
33
- return saturated.saturate(result);
34
- }
35
- },
36
- // round to nearby lower multiple of base
37
- floorInBase: function(n, base) {
38
- return base * Math.floor(n / base);
39
- }
40
- };
41
-
42
- $.plot.saturated = saturated;
43
- })(jQuery);
@@ -1,527 +0,0 @@
1
- /* Flot plugin for selecting regions of a plot.
2
-
3
- Copyright (c) 2007-2014 IOLA and Ole Laursen.
4
- Licensed under the MIT license.
5
-
6
- The plugin supports these options:
7
-
8
- selection: {
9
- mode: null or "x" or "y" or "xy" or "smart",
10
- color: color,
11
- shape: "round" or "miter" or "bevel",
12
- visualization: "fill" or "focus",
13
- displaySelectionDecorations: true or false,
14
- minSize: number of pixels
15
- }
16
-
17
- Selection support is enabled by setting the mode to one of "x", "y" or "xy".
18
- In "x" mode, the user will only be able to specify the x range, similarly for
19
- "y" mode. For "xy", the selection becomes a rectangle where both ranges can be
20
- specified. "color" is color of the selection (if you need to change the color
21
- later on, you can get to it with plot.getOptions().selection.color). "shape"
22
- is the shape of the corners of the selection.
23
-
24
- The way how the selection is visualized, can be changed by using the option
25
- "visualization". Flot currently supports two modes: "focus" and "fill". The
26
- option "focus" draws a colored bezel around the selected area while keeping
27
- the selected area clear. The option "fill" highlights (i.e., fills) the
28
- selected area with a colored highlight.
29
-
30
- There are optional selection decorations (handles) that are rendered with the
31
- "focus" visualization option. The selection decoration is rendered by default
32
- but can be turned off by setting displaySelectionDecorations to false.
33
-
34
- "minSize" is the minimum size a selection can be in pixels. This value can
35
- be customized to determine the smallest size a selection can be and still
36
- have the selection rectangle be displayed. When customizing this value, the
37
- fact that it refers to pixels, not axis units must be taken into account.
38
- Thus, for example, if there is a bar graph in time mode with BarWidth set to 1
39
- minute, setting "minSize" to 1 will not make the minimum selection size 1
40
- minute, but rather 1 pixel. Note also that setting "minSize" to 0 will prevent
41
- "plotunselected" events from being fired when the user clicks the mouse without
42
- dragging.
43
-
44
- When selection support is enabled, a "plotselected" event will be emitted on
45
- the DOM element you passed into the plot function. The event handler gets a
46
- parameter with the ranges selected on the axes, like this:
47
-
48
- placeholder.bind( "plotselected", function( event, ranges ) {
49
- alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
50
- // similar for yaxis - with multiple axes, the extra ones are in
51
- // x2axis, x3axis, ...
52
- });
53
-
54
- The "plotselected" event is only fired when the user has finished making the
55
- selection. A "plotselecting" event is fired during the process with the same
56
- parameters as the "plotselected" event, in case you want to know what's
57
- happening while it's happening,
58
-
59
- A "plotunselected" event with no arguments is emitted when the user clicks the
60
- mouse to remove the selection. As stated above, setting "minSize" to 0 will
61
- destroy this behavior.
62
-
63
- The plugin allso adds the following methods to the plot object:
64
-
65
- - setSelection( ranges, preventEvent )
66
-
67
- Set the selection rectangle. The passed in ranges is on the same form as
68
- returned in the "plotselected" event. If the selection mode is "x", you
69
- should put in either an xaxis range, if the mode is "y" you need to put in
70
- an yaxis range and both xaxis and yaxis if the selection mode is "xy", like
71
- this:
72
-
73
- setSelection({ xaxis: { from: 0, to: 10 }, yaxis: { from: 40, to: 60 } });
74
-
75
- setSelection will trigger the "plotselected" event when called. If you don't
76
- want that to happen, e.g. if you're inside a "plotselected" handler, pass
77
- true as the second parameter. If you are using multiple axes, you can
78
- specify the ranges on any of those, e.g. as x2axis/x3axis/... instead of
79
- xaxis, the plugin picks the first one it sees.
80
-
81
- - clearSelection( preventEvent )
82
-
83
- Clear the selection rectangle. Pass in true to avoid getting a
84
- "plotunselected" event.
85
-
86
- - getSelection()
87
-
88
- Returns the current selection in the same format as the "plotselected"
89
- event. If there's currently no selection, the function returns null.
90
-
91
- */
92
-
93
- (function ($) {
94
- function init(plot) {
95
- var selection = {
96
- first: {x: -1, y: -1},
97
- second: {x: -1, y: -1},
98
- show: false,
99
- currentMode: 'xy',
100
- active: false
101
- };
102
-
103
- var SNAPPING_CONSTANT = $.plot.uiConstants.SNAPPING_CONSTANT;
104
-
105
- // FIXME: The drag handling implemented here should be
106
- // abstracted out, there's some similar code from a library in
107
- // the navigation plugin, this should be massaged a bit to fit
108
- // the Flot cases here better and reused. Doing this would
109
- // make this plugin much slimmer.
110
- var savedhandlers = {};
111
-
112
- function onDrag(e) {
113
- if (selection.active) {
114
- updateSelection(e);
115
-
116
- plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
117
- }
118
- }
119
-
120
- function onDragStart(e) {
121
- var o = plot.getOptions();
122
- // only accept left-click
123
- if (e.which !== 1 || o.selection.mode === null) return;
124
-
125
- // reinitialize currentMode
126
- selection.currentMode = 'xy';
127
-
128
- // cancel out any text selections
129
- document.body.focus();
130
-
131
- // prevent text selection and drag in old-school browsers
132
- if (document.onselectstart !== undefined && savedhandlers.onselectstart == null) {
133
- savedhandlers.onselectstart = document.onselectstart;
134
- document.onselectstart = function () { return false; };
135
- }
136
- if (document.ondrag !== undefined && savedhandlers.ondrag == null) {
137
- savedhandlers.ondrag = document.ondrag;
138
- document.ondrag = function () { return false; };
139
- }
140
-
141
- setSelectionPos(selection.first, e);
142
-
143
- selection.active = true;
144
- }
145
-
146
- function onDragEnd(e) {
147
- // revert drag stuff for old-school browsers
148
- if (document.onselectstart !== undefined) {
149
- document.onselectstart = savedhandlers.onselectstart;
150
- }
151
-
152
- if (document.ondrag !== undefined) {
153
- document.ondrag = savedhandlers.ondrag;
154
- }
155
-
156
- // no more dragging
157
- selection.active = false;
158
- updateSelection(e);
159
-
160
- if (selectionIsSane()) {
161
- triggerSelectedEvent();
162
- } else {
163
- // this counts as a clear
164
- plot.getPlaceholder().trigger("plotunselected", [ ]);
165
- plot.getPlaceholder().trigger("plotselecting", [ null ]);
166
- }
167
-
168
- return false;
169
- }
170
-
171
- function getSelection() {
172
- if (!selectionIsSane()) return null;
173
-
174
- if (!selection.show) return null;
175
-
176
- var r = {},
177
- c1 = {x: selection.first.x, y: selection.first.y},
178
- c2 = {x: selection.second.x, y: selection.second.y};
179
-
180
- if (selectionDirection(plot) === 'x') {
181
- c1.y = 0;
182
- c2.y = plot.height();
183
- }
184
-
185
- if (selectionDirection(plot) === 'y') {
186
- c1.x = 0;
187
- c2.x = plot.width();
188
- }
189
-
190
- $.each(plot.getAxes(), function (name, axis) {
191
- if (axis.used) {
192
- var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
193
- r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
194
- }
195
- });
196
- return r;
197
- }
198
-
199
- function triggerSelectedEvent() {
200
- var r = getSelection();
201
-
202
- plot.getPlaceholder().trigger("plotselected", [ r ]);
203
-
204
- // backwards-compat stuff, to be removed in future
205
- if (r.xaxis && r.yaxis) {
206
- plot.getPlaceholder().trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
207
- }
208
- }
209
-
210
- function clamp(min, value, max) {
211
- return value < min ? min : (value > max ? max : value);
212
- }
213
-
214
- function selectionDirection(plot) {
215
- var o = plot.getOptions();
216
-
217
- if (o.selection.mode === 'smart') {
218
- return selection.currentMode;
219
- } else {
220
- return o.selection.mode;
221
- }
222
- }
223
-
224
- function updateMode(pos) {
225
- if (selection.first) {
226
- var delta = {
227
- x: pos.x - selection.first.x,
228
- y: pos.y - selection.first.y
229
- };
230
-
231
- if (Math.abs(delta.x) < SNAPPING_CONSTANT) {
232
- selection.currentMode = 'y';
233
- } else if (Math.abs(delta.y) < SNAPPING_CONSTANT) {
234
- selection.currentMode = 'x';
235
- } else {
236
- selection.currentMode = 'xy';
237
- }
238
- }
239
- }
240
-
241
- function setSelectionPos(pos, e) {
242
- var offset = plot.getPlaceholder().offset();
243
- var plotOffset = plot.getPlotOffset();
244
- pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
245
- pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
246
-
247
- if (pos !== selection.first) updateMode(pos);
248
-
249
- if (selectionDirection(plot) === "y") {
250
- pos.x = pos === selection.first ? 0 : plot.width();
251
- }
252
-
253
- if (selectionDirection(plot) === "x") {
254
- pos.y = pos === selection.first ? 0 : plot.height();
255
- }
256
- }
257
-
258
- function updateSelection(pos) {
259
- if (pos.pageX == null) return;
260
-
261
- setSelectionPos(selection.second, pos);
262
- if (selectionIsSane()) {
263
- selection.show = true;
264
- plot.triggerRedrawOverlay();
265
- } else clearSelection(true);
266
- }
267
-
268
- function clearSelection(preventEvent) {
269
- if (selection.show) {
270
- selection.show = false;
271
- selection.currentMode = '';
272
- plot.triggerRedrawOverlay();
273
- if (!preventEvent) {
274
- plot.getPlaceholder().trigger("plotunselected", [ ]);
275
- }
276
- }
277
- }
278
-
279
- // function taken from markings support in Flot
280
- function extractRange(ranges, coord) {
281
- var axis, from, to, key, axes = plot.getAxes();
282
-
283
- for (var k in axes) {
284
- axis = axes[k];
285
- if (axis.direction === coord) {
286
- key = coord + axis.n + "axis";
287
- if (!ranges[key] && axis.n === 1) {
288
- // support x1axis as xaxis
289
- key = coord + "axis";
290
- }
291
-
292
- if (ranges[key]) {
293
- from = ranges[key].from;
294
- to = ranges[key].to;
295
- break;
296
- }
297
- }
298
- }
299
-
300
- // backwards-compat stuff - to be removed in future
301
- if (!ranges[key]) {
302
- axis = coord === "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
303
- from = ranges[coord + "1"];
304
- to = ranges[coord + "2"];
305
- }
306
-
307
- // auto-reverse as an added bonus
308
- if (from != null && to != null && from > to) {
309
- var tmp = from;
310
- from = to;
311
- to = tmp;
312
- }
313
-
314
- return { from: from, to: to, axis: axis };
315
- }
316
-
317
- function setSelection(ranges, preventEvent) {
318
- var range;
319
-
320
- if (selectionDirection(plot) === "y") {
321
- selection.first.x = 0;
322
- selection.second.x = plot.width();
323
- } else {
324
- range = extractRange(ranges, "x");
325
- selection.first.x = range.axis.p2c(range.from);
326
- selection.second.x = range.axis.p2c(range.to);
327
- }
328
-
329
- if (selectionDirection(plot) === "x") {
330
- selection.first.y = 0;
331
- selection.second.y = plot.height();
332
- } else {
333
- range = extractRange(ranges, "y");
334
- selection.first.y = range.axis.p2c(range.from);
335
- selection.second.y = range.axis.p2c(range.to);
336
- }
337
-
338
- selection.show = true;
339
- plot.triggerRedrawOverlay();
340
- if (!preventEvent && selectionIsSane()) {
341
- triggerSelectedEvent();
342
- }
343
- }
344
-
345
- function selectionIsSane() {
346
- var minSize = plot.getOptions().selection.minSize;
347
- return Math.abs(selection.second.x - selection.first.x) >= minSize &&
348
- Math.abs(selection.second.y - selection.first.y) >= minSize;
349
- }
350
-
351
- plot.clearSelection = clearSelection;
352
- plot.setSelection = setSelection;
353
- plot.getSelection = getSelection;
354
-
355
- plot.hooks.bindEvents.push(function(plot, eventHolder) {
356
- var o = plot.getOptions();
357
- if (o.selection.mode != null) {
358
- plot.addEventHandler("dragstart", onDragStart, eventHolder, 0);
359
- plot.addEventHandler("drag", onDrag, eventHolder, 0);
360
- plot.addEventHandler("dragend", onDragEnd, eventHolder, 0);
361
- }
362
- });
363
-
364
- function drawSelectionDecorations(ctx, x, y, w, h, oX, oY, mode) {
365
- var spacing = 3;
366
- var fullEarWidth = 15;
367
- var earWidth = Math.max(0, Math.min(fullEarWidth, w / 2 - 2, h / 2 - 2));
368
- ctx.fillStyle = '#ffffff';
369
-
370
- if (mode === 'xy') {
371
- ctx.beginPath();
372
- ctx.moveTo(x, y + earWidth);
373
- ctx.lineTo(x - 3, y + earWidth);
374
- ctx.lineTo(x - 3, y - 3);
375
- ctx.lineTo(x + earWidth, y - 3);
376
- ctx.lineTo(x + earWidth, y);
377
- ctx.lineTo(x, y);
378
- ctx.closePath();
379
-
380
- ctx.moveTo(x, y + h - earWidth);
381
- ctx.lineTo(x - 3, y + h - earWidth);
382
- ctx.lineTo(x - 3, y + h + 3);
383
- ctx.lineTo(x + earWidth, y + h + 3);
384
- ctx.lineTo(x + earWidth, y + h);
385
- ctx.lineTo(x, y + h);
386
- ctx.closePath();
387
-
388
- ctx.moveTo(x + w, y + earWidth);
389
- ctx.lineTo(x + w + 3, y + earWidth);
390
- ctx.lineTo(x + w + 3, y - 3);
391
- ctx.lineTo(x + w - earWidth, y - 3);
392
- ctx.lineTo(x + w - earWidth, y);
393
- ctx.lineTo(x + w, y);
394
- ctx.closePath();
395
-
396
- ctx.moveTo(x + w, y + h - earWidth);
397
- ctx.lineTo(x + w + 3, y + h - earWidth);
398
- ctx.lineTo(x + w + 3, y + h + 3);
399
- ctx.lineTo(x + w - earWidth, y + h + 3);
400
- ctx.lineTo(x + w - earWidth, y + h);
401
- ctx.lineTo(x + w, y + h);
402
- ctx.closePath();
403
-
404
- ctx.stroke();
405
- ctx.fill();
406
- }
407
-
408
- x = oX;
409
- y = oY;
410
-
411
- if (mode === 'x') {
412
- ctx.beginPath();
413
- ctx.moveTo(x, y + fullEarWidth);
414
- ctx.lineTo(x, y - fullEarWidth);
415
- ctx.lineTo(x - spacing, y - fullEarWidth);
416
- ctx.lineTo(x - spacing, y + fullEarWidth);
417
- ctx.closePath();
418
-
419
- ctx.moveTo(x + w, y + fullEarWidth);
420
- ctx.lineTo(x + w, y - fullEarWidth);
421
- ctx.lineTo(x + w + spacing, y - fullEarWidth);
422
- ctx.lineTo(x + w + spacing, y + fullEarWidth);
423
- ctx.closePath();
424
- ctx.stroke();
425
- ctx.fill();
426
- }
427
-
428
- if (mode === 'y') {
429
- ctx.beginPath();
430
-
431
- ctx.moveTo(x - fullEarWidth, y);
432
- ctx.lineTo(x + fullEarWidth, y);
433
- ctx.lineTo(x + fullEarWidth, y - spacing);
434
- ctx.lineTo(x - fullEarWidth, y - spacing);
435
- ctx.closePath();
436
-
437
- ctx.moveTo(x - fullEarWidth, y + h);
438
- ctx.lineTo(x + fullEarWidth, y + h);
439
- ctx.lineTo(x + fullEarWidth, y + h + spacing);
440
- ctx.lineTo(x - fullEarWidth, y + h + spacing);
441
- ctx.closePath();
442
- ctx.stroke();
443
- ctx.fill();
444
- }
445
- }
446
-
447
- plot.hooks.drawOverlay.push(function (plot, ctx) {
448
- // draw selection
449
- if (selection.show && selectionIsSane()) {
450
- var plotOffset = plot.getPlotOffset();
451
- var o = plot.getOptions();
452
-
453
- ctx.save();
454
- ctx.translate(plotOffset.left, plotOffset.top);
455
-
456
- var c = $.color.parse(o.selection.color);
457
- var visualization = o.selection.visualization;
458
- var displaySelectionDecorations = o.selection.displaySelectionDecorations;
459
-
460
- var scalingFactor = 1;
461
-
462
- // use a dimmer scaling factor if visualization is "fill"
463
- if (visualization === "fill") {
464
- scalingFactor = 0.8;
465
- }
466
-
467
- ctx.strokeStyle = c.scale('a', scalingFactor).toString();
468
- ctx.lineWidth = 1;
469
- ctx.lineJoin = o.selection.shape;
470
- ctx.fillStyle = c.scale('a', 0.4).toString();
471
-
472
- var x = Math.min(selection.first.x, selection.second.x) + 0.5,
473
- oX = x,
474
- y = Math.min(selection.first.y, selection.second.y) + 0.5,
475
- oY = y,
476
- w = Math.abs(selection.second.x - selection.first.x) - 1,
477
- h = Math.abs(selection.second.y - selection.first.y) - 1;
478
-
479
- if (selectionDirection(plot) === 'x') {
480
- h += y;
481
- y = 0;
482
- }
483
-
484
- if (selectionDirection(plot) === 'y') {
485
- w += x;
486
- x = 0;
487
- }
488
-
489
- if (visualization === "fill") {
490
- ctx.fillRect(x, y, w, h);
491
- ctx.strokeRect(x, y, w, h);
492
- } else {
493
- ctx.fillRect(0, 0, plot.width(), plot.height());
494
- ctx.clearRect(x, y, w, h);
495
-
496
- if (displaySelectionDecorations) {
497
- drawSelectionDecorations(ctx, x, y, w, h, oX, oY, selectionDirection(plot));
498
- }
499
- }
500
-
501
- ctx.restore();
502
- }
503
- });
504
-
505
- plot.hooks.shutdown.push(function (plot, eventHolder) {
506
- eventHolder.unbind("dragstart", onDragStart);
507
- eventHolder.unbind("drag", onDrag);
508
- eventHolder.unbind("dragend", onDragEnd);
509
- });
510
- }
511
-
512
- $.plot.plugins.push({
513
- init: init,
514
- options: {
515
- selection: {
516
- mode: null, // one of null, "x", "y" or "xy"
517
- visualization: "focus", // "focus" or "fill"
518
- displaySelectionDecorations: true, // true or false (currently only relevant for the focus visualization)
519
- color: "#888888",
520
- shape: "round", // one of "round", "miter", or "bevel"
521
- minSize: 5 // minimum number of pixels
522
- }
523
- },
524
- name: 'selection',
525
- version: '1.1'
526
- });
527
- })(jQuery);
@@ -1,10 +0,0 @@
1
- (function ($) {
2
- 'use strict';
3
- $.plot.uiConstants = {
4
- SNAPPING_CONSTANT: 20,
5
- PANHINT_LENGTH_CONSTANT: 10,
6
- MINOR_TICKS_COUNT_CONSTANT: 4,
7
- TICK_LENGTH_CONSTANT: 10,
8
- ZOOM_DISTANCE_MARGIN: 25
9
- };
10
- })(jQuery);