blacklight_range_limit 7.6.0 → 7.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +5 -5
- data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +3 -4
- data/app/helpers/range_limit_helper.rb +25 -3
- data/app/views/blacklight_range_limit/_range_limit_panel.html.erb +1 -1
- data/app/views/blacklight_range_limit/_range_segments.html.erb +5 -2
- data/blacklight_range_limit.gemspec +2 -2
- data/config/locales/blacklight_range_limit.ar.yml +2 -2
- data/config/locales/blacklight_range_limit.en.yml +2 -2
- data/lib/blacklight_range_limit/view_helper_override.rb +5 -5
- data/lib/generators/blacklight_range_limit/install_generator.rb +1 -1
- data/spec/features/blacklight_range_limit_spec.rb +9 -1
- data/spec/lib/blacklight_range_limit/view_helper_override_helper_spec.rb +19 -2
- data/spec/test_app_templates/Gemfile.extra +1 -1
- data/vendor/assets/javascripts/flot/jquery.canvaswrapper.js +2 -3
- data/vendor/assets/javascripts/flot/jquery.flot.drawSeries.js +3 -4
- data/vendor/assets/javascripts/flot/jquery.flot.hover.js +7 -8
- data/vendor/assets/javascripts/flot/jquery.flot.js +21 -22
- data/vendor/assets/javascripts/flot/jquery.flot.selection.js +20 -22
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bdd7d570174f761a17a7744d8b79796ebf4122e1ce4ef2bf1c366b31a7a82b3
|
4
|
+
data.tar.gz: e662b7bb3ab1272c4b110fae8ef3e3a8bd5aae0afe32a659a2b769941d8d8969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beb6a84a7ecb8cab0b9eaefc8ea1dea12224755676415bcda3f4d6252430e13d9d475254b914e2bfc638a7d9f03eb719aebefdc66380f7b378a69a2b4ebce7e2
|
7
|
+
data.tar.gz: b12a205a837bd3602eacd560b4d4370cabf4e47a960a62cbf57698fcb0f9ef567522fd1fe0b89d64aeb4a78f52de41bb0638a63e47123b881716c5da84f2ae3c
|
data/.travis.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
dist:
|
1
|
+
dist: bionic
|
2
2
|
language: ruby
|
3
3
|
addons:
|
4
4
|
chrome: stable
|
@@ -14,6 +14,8 @@ matrix:
|
|
14
14
|
env: "RAILS_VERSION=6.0.0 ENGINE_CART_RAILS_OPTIONS=\"--skip-webpack-install\""
|
15
15
|
- rvm: 2.6.5
|
16
16
|
env: "RAILS_VERSION=5.2.3"
|
17
|
+
- rvm: 2.6.5
|
18
|
+
env: "RAILS_VERSION=5.2.3 BLACKLIGHT_VERSION=7.6.0"
|
17
19
|
- rvm: 2.5.7
|
18
20
|
env: "RAILS_VERSION=5.1.7"
|
19
21
|
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ config.add_facet_field 'pub_date', label: 'Publication Year', range: true
|
|
52
52
|
You should now get range limit display. More complicated configuration is available if desired, see Range Facet Configuration below.
|
53
53
|
|
54
54
|
|
55
|
-
You can also configure the look and feel of the Flot chart using the jQuery .data() method. On the `.
|
55
|
+
You can also configure the look and feel of the Flot chart using the jQuery .data() method. On the `.blrl-plot-config` or `.facet-limit` container you want to configure, add a Flot options associative array (documented at http://people.iola.dk/olau/flot/API.txt) as the `plot-config` key. The `plot-config` key to set the `plot-config` key on the appropriate `.blrl-plot-config` or `.facet-limit` container. In order to customize the plot colors, for example, you could use this code:
|
56
56
|
|
57
57
|
```javascript
|
58
58
|
$('.blacklight-year_i').data('plot-config', {
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.
|
1
|
+
7.9.0
|
@@ -166,12 +166,12 @@ Blacklight.onLoad(function() {
|
|
166
166
|
var series_data = new Array();
|
167
167
|
var pointer_lookup = new Array();
|
168
168
|
var x_ticks = new Array();
|
169
|
-
var min = BlacklightRangeLimit.parseNum($(container).find("ul li:first-child span.from").
|
170
|
-
var max = BlacklightRangeLimit.parseNum($(container).find("ul li:last-child span.to").
|
169
|
+
var min = BlacklightRangeLimit.parseNum($(container).find("ul li:first-child span.from").first().data('blrlBegin'));
|
170
|
+
var max = BlacklightRangeLimit.parseNum($(container).find("ul li:last-child span.to").first().data('blrlEnd'));
|
171
171
|
|
172
172
|
$(container).find("ul li").each(function() {
|
173
|
-
var from = BlacklightRangeLimit.parseNum($(this).find("span.from").
|
174
|
-
var to = BlacklightRangeLimit.parseNum($(this).find("span.to").
|
173
|
+
var from = BlacklightRangeLimit.parseNum($(this).find("span.from").first().data('blrlBegin'));
|
174
|
+
var to = BlacklightRangeLimit.parseNum($(this).find("span.to").first().data('blrlEnd'));
|
175
175
|
var count = BlacklightRangeLimit.parseNum($(this).find("span.count").text());
|
176
176
|
var avg = (count / (to - from + 1));
|
177
177
|
|
@@ -191,7 +191,7 @@ Blacklight.onLoad(function() {
|
|
191
191
|
|
192
192
|
|
193
193
|
var plot;
|
194
|
-
var config = $(container).closest('.
|
194
|
+
var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {};
|
195
195
|
|
196
196
|
try {
|
197
197
|
plot = $.plot($(container), [series_data],
|
@@ -33,10 +33,10 @@ function min_max(range_element) {
|
|
33
33
|
|
34
34
|
|
35
35
|
|
36
|
-
var min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").
|
36
|
+
var min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle'))
|
37
37
|
if ( isNaN(min)) {
|
38
|
-
min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().
|
39
|
-
max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().
|
38
|
+
min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin'));
|
39
|
+
max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd'));
|
40
40
|
}
|
41
41
|
|
42
42
|
if (isNaN(min) || isNaN(max)) {
|
@@ -44,7 +44,6 @@ function min_max(range_element) {
|
|
44
44
|
min = BlacklightRangeLimit.parseNum($(range_element).find(".min").first().text());
|
45
45
|
max = BlacklightRangeLimit.parseNum($(range_element).find(".max").first().text());
|
46
46
|
}
|
47
|
-
|
48
47
|
return [min, max]
|
49
48
|
}
|
50
49
|
|
@@ -42,13 +42,35 @@ module RangeLimitHelper
|
|
42
42
|
return t('blacklight.range_limit.missing')
|
43
43
|
elsif hash["begin"] || hash["end"]
|
44
44
|
if hash["begin"] == hash["end"]
|
45
|
-
return t(
|
45
|
+
return t(
|
46
|
+
'blacklight.range_limit.single_html',
|
47
|
+
begin: format_range_display_value(hash['begin'], solr_field),
|
48
|
+
begin_value: hash['begin']
|
49
|
+
)
|
46
50
|
else
|
47
|
-
return t(
|
51
|
+
return t(
|
52
|
+
'blacklight.range_limit.range_html',
|
53
|
+
begin: format_range_display_value(hash['begin'], solr_field),
|
54
|
+
begin_value: hash['begin'],
|
55
|
+
end: format_range_display_value(hash['end'], solr_field),
|
56
|
+
end_value: hash['end']
|
57
|
+
)
|
48
58
|
end
|
49
59
|
end
|
50
60
|
|
51
|
-
|
61
|
+
''
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# A method that is meant to be overridden downstream to format how a range
|
66
|
+
# label might be displayed to a user. By default it just returns the value
|
67
|
+
# as rendered by the presenter
|
68
|
+
def format_range_display_value(value, solr_field)
|
69
|
+
if respond_to?(:facet_item_presenter)
|
70
|
+
facet_item_presenter(facet_configuration_for_field(solr_field), value, solr_field).label
|
71
|
+
else
|
72
|
+
facet_display_value(solr_field, value)
|
73
|
+
end
|
52
74
|
end
|
53
75
|
|
54
76
|
# Show the limit area if:
|
@@ -7,7 +7,7 @@
|
|
7
7
|
maxlength = field_config[:maxlength]
|
8
8
|
-%>
|
9
9
|
|
10
|
-
<div class="limit_content range_limit">
|
10
|
+
<div class="limit_content range_limit <%= field_name %>-config blrl-plot-config">
|
11
11
|
<% if has_selected_range_limit?(field_name) %>
|
12
12
|
<ul class="current list-unstyled facet-values">
|
13
13
|
<li class="selected">
|
@@ -7,8 +7,11 @@
|
|
7
7
|
<span class="facet-label">
|
8
8
|
<%= link_to(
|
9
9
|
t('blacklight.range_limit.range_html',
|
10
|
-
|
11
|
-
|
10
|
+
begin: format_range_display_value(hash[:from], solr_field),
|
11
|
+
begin_value: hash[:from],
|
12
|
+
end: format_range_display_value(hash[:to], solr_field),
|
13
|
+
end_value: hash[:to]
|
14
|
+
),
|
12
15
|
search_action_url(add_range(solr_field, hash[:from], hash[:to]).except(:controller, :action)),
|
13
16
|
class: 'facet_select'
|
14
17
|
) %>
|
@@ -17,14 +17,14 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.license = 'Apache 2.0'
|
19
19
|
|
20
|
-
s.add_dependency 'blacklight', '
|
20
|
+
s.add_dependency 'blacklight', '~> 7.0'
|
21
21
|
|
22
22
|
s.add_development_dependency 'rspec', '~> 3.0'
|
23
23
|
s.add_development_dependency 'rspec-rails'
|
24
24
|
s.add_development_dependency 'capybara', '~> 3'
|
25
25
|
s.add_development_dependency 'sqlite3'
|
26
26
|
s.add_development_dependency 'launchy'
|
27
|
-
s.add_development_dependency 'solr_wrapper', '~> 0
|
27
|
+
s.add_development_dependency 'solr_wrapper', '~> 2.0'
|
28
28
|
s.add_development_dependency 'engine_cart', '~> 2.1'
|
29
29
|
s.add_development_dependency 'selenium-webdriver', '>= 3.13.1'
|
30
30
|
s.add_development_dependency 'webdrivers', '~>3.0'
|
@@ -9,5 +9,5 @@ ar:
|
|
9
9
|
view_distribution: 'عرض التوزيع'
|
10
10
|
view_larger: 'عرض بحجم أكبر »'
|
11
11
|
results_range_html: 'تمتد النتائج الحالية من <span class="min">%{min}</span> إلى<span class="max">%{max}</span>'
|
12
|
-
single_html: '<span class="single">%{begin}</span>'
|
13
|
-
range_html: '<span class="from">%{begin}</span>
|
12
|
+
single_html: '<span class="single" data-blrl-single="%{begin_value}">%{begin}</span>'
|
13
|
+
range_html: '<span class="from" data-blrl-begin="%{begin_value}">%{begin}</span> الى <span class="to" data-blrl-end="%{end_value}">%{end}</span>'
|
@@ -9,5 +9,5 @@ en:
|
|
9
9
|
view_distribution: 'View distribution'
|
10
10
|
view_larger: 'View larger »'
|
11
11
|
results_range_html: 'Current results range from <span class="min">%{min}</span> to <span class="max">%{max}</span>'
|
12
|
-
single_html: '<span class="single">%{begin}</span>'
|
13
|
-
range_html: '<span class="from">%{begin}</span> to <span class="to">%{end}</span>'
|
12
|
+
single_html: '<span class="single" data-blrl-single="%{begin_value}">%{begin}</span>'
|
13
|
+
range_html: '<span class="from" data-blrl-begin="%{begin_value}">%{begin}</span> to <span class="to" data-blrl-end="%{end_value}">%{end}</span>'
|
@@ -35,7 +35,7 @@
|
|
35
35
|
facet_field_label(solr_field),
|
36
36
|
range_display(solr_field, my_params),
|
37
37
|
escape_value: false,
|
38
|
-
remove: remove_range_param(solr_field, my_params)
|
38
|
+
remove: search_action_path(remove_range_param(solr_field, my_params))
|
39
39
|
)
|
40
40
|
end
|
41
41
|
end
|
@@ -87,14 +87,14 @@
|
|
87
87
|
private
|
88
88
|
|
89
89
|
def range_params(my_params = params)
|
90
|
-
return {} unless my_params[:range].is_a?(ActionController::Parameters)
|
90
|
+
return {} unless my_params[:range].is_a?(ActionController::Parameters) || my_params[:range].is_a?(Hash)
|
91
91
|
|
92
92
|
my_params[:range].select do |_solr_field, range_options|
|
93
93
|
next unless range_options
|
94
94
|
|
95
|
-
[range_options['missing'],
|
96
|
-
range_options['begin'],
|
97
|
-
range_options['end']].any?
|
95
|
+
[range_options['missing'].presence,
|
96
|
+
range_options['begin'].presence,
|
97
|
+
range_options['end'].presence].any?
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -9,7 +9,7 @@ module BlacklightRangeLimit
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def install_catalog_controller_mixin
|
12
|
-
|
12
|
+
inject_into_file 'app/controllers/catalog_controller.rb', after: /include Blacklight::Catalog.*$/ do
|
13
13
|
"\n include BlacklightRangeLimit::ControllerOverride\n"
|
14
14
|
end
|
15
15
|
end
|
@@ -24,7 +24,15 @@ describe "Blacklight Range Limit" do
|
|
24
24
|
click_link 'View distribution'
|
25
25
|
click_link '2000 to 2008'
|
26
26
|
|
27
|
-
|
27
|
+
within '.blacklight-pub_date_si' do
|
28
|
+
expect(page).to have_content "2000 to 2008 ✖ [remove] 12"
|
29
|
+
end
|
30
|
+
|
31
|
+
within '.constraints-container' do
|
32
|
+
expect(page).to have_content '2000 to 2008'
|
33
|
+
end
|
34
|
+
|
35
|
+
expect(page).to have_content '1 - 10 of 12'
|
28
36
|
end
|
29
37
|
|
30
38
|
it "should not include page parameter" do
|
@@ -5,7 +5,13 @@ RSpec.describe BlacklightRangeLimit::ViewHelperOverride, type: :helper do
|
|
5
5
|
before do
|
6
6
|
allow(helper).to receive_messages(
|
7
7
|
facet_field_label: 'Date Range',
|
8
|
-
remove_range_param:
|
8
|
+
remove_range_param: {},
|
9
|
+
search_action_path: '/catalog',
|
10
|
+
blacklight_config: CatalogController.blacklight_config,
|
11
|
+
search_state: {},
|
12
|
+
)
|
13
|
+
allow(controller).to receive_messages(
|
14
|
+
search_state_class: Blacklight::SearchState,
|
9
15
|
)
|
10
16
|
end
|
11
17
|
|
@@ -32,7 +38,11 @@ RSpec.describe BlacklightRangeLimit::ViewHelperOverride, type: :helper do
|
|
32
38
|
|
33
39
|
describe 'render_search_to_s_filters' do
|
34
40
|
before do
|
35
|
-
allow(helper).to receive_messages(
|
41
|
+
allow(helper).to receive_messages(
|
42
|
+
facet_field_label: 'Date Range',
|
43
|
+
blacklight_config: CatalogController.blacklight_config,
|
44
|
+
search_state: {},
|
45
|
+
)
|
36
46
|
end
|
37
47
|
|
38
48
|
it 'does not return any content when the range parameter invalid' do
|
@@ -82,6 +92,13 @@ RSpec.describe BlacklightRangeLimit::ViewHelperOverride, type: :helper do
|
|
82
92
|
ActionController::Parameters.new(range: { field_name: { 'wrong' => 'data' } })
|
83
93
|
)
|
84
94
|
).to eq({})
|
95
|
+
|
96
|
+
expect(
|
97
|
+
helper.send(
|
98
|
+
:range_params,
|
99
|
+
ActionController::Parameters.new(range: { field_name: { 'begin' => '', 'end' => '' } })
|
100
|
+
)
|
101
|
+
).to eq({})
|
85
102
|
end
|
86
103
|
|
87
104
|
it 'returns the range parameters that are present' do
|
@@ -386,7 +386,6 @@ don't work unless the canvas is attached to the DOM.
|
|
386
386
|
|
387
387
|
y += 0.75 * info.height;
|
388
388
|
|
389
|
-
|
390
389
|
// Determine whether this text already exists at this position.
|
391
390
|
// If so, mark it for inclusion in the next render pass.
|
392
391
|
|
@@ -447,7 +446,7 @@ don't work unless the canvas is attached to the DOM.
|
|
447
446
|
position.element.style.textAlign = halign;
|
448
447
|
// update the transforms
|
449
448
|
updateTransforms(position.element, transforms);
|
450
|
-
|
449
|
+
};
|
451
450
|
|
452
451
|
var addTspanElements = function(text, element, x) {
|
453
452
|
var lines = text.split('<br>'),
|
@@ -461,7 +460,7 @@ don't work unless the canvas is attached to the DOM.
|
|
461
460
|
tspan = element.childNodes[i];
|
462
461
|
}
|
463
462
|
tspan.textContent = lines[i];
|
464
|
-
offset = i
|
463
|
+
offset = (i === 0 ? 0 : 1) + 'em';
|
465
464
|
tspan.setAttributeNS(null, 'dy', offset);
|
466
465
|
tspan.setAttributeNS(null, 'x', x);
|
467
466
|
}
|
@@ -42,7 +42,7 @@ This plugin is used by flot for drawing lines, plots, bars or area.
|
|
42
42
|
continue;
|
43
43
|
}
|
44
44
|
|
45
|
-
if(steps){
|
45
|
+
if (steps) {
|
46
46
|
if (mx !== null && my !== null) {
|
47
47
|
// if middle point exists, transfer p2 -> p1 and p1 -> mp
|
48
48
|
x2 = x1;
|
@@ -202,7 +202,7 @@ This plugin is used by flot for drawing lines, plots, bars or area.
|
|
202
202
|
continue;
|
203
203
|
}
|
204
204
|
|
205
|
-
if(steps){
|
205
|
+
if (steps) {
|
206
206
|
if (mx !== null && my !== null) {
|
207
207
|
// if middle point exists, transfer p2 -> p1 and p1 -> mp
|
208
208
|
x2 = x1;
|
@@ -482,8 +482,7 @@ This plugin is used by flot for drawing lines, plots, bars or area.
|
|
482
482
|
drawLeft = true;
|
483
483
|
drawRight = false;
|
484
484
|
}
|
485
|
-
}
|
486
|
-
else {
|
485
|
+
} else {
|
487
486
|
drawLeft = drawRight = drawTop = true;
|
488
487
|
drawBottom = false;
|
489
488
|
left = x + barLeft;
|
@@ -79,7 +79,6 @@ the tooltip from webcharts).
|
|
79
79
|
highlights = [];
|
80
80
|
}
|
81
81
|
|
82
|
-
|
83
82
|
function generatePlothoverEvent(e) {
|
84
83
|
var o = plot.getOptions(),
|
85
84
|
newEvent = new CustomEvent('mouseevent');
|
@@ -98,10 +97,10 @@ the tooltip from webcharts).
|
|
98
97
|
|
99
98
|
function doTriggerClickHoverEvent(event, eventType, searchDistance) {
|
100
99
|
var series = plot.getData();
|
101
|
-
if (event !== undefined
|
102
|
-
|
103
|
-
|
104
|
-
|
100
|
+
if (event !== undefined &&
|
101
|
+
series.length > 0 &&
|
102
|
+
series[0].xaxis.c2p !== undefined &&
|
103
|
+
series[0].yaxis.c2p !== undefined) {
|
105
104
|
var eventToTrigger = "plot" + eventType;
|
106
105
|
var seriesFlag = eventType + "able";
|
107
106
|
triggerClickHoverEvent(eventToTrigger, event,
|
@@ -155,8 +154,8 @@ the tooltip from webcharts).
|
|
155
154
|
var items = plot.findNearbyItems(canvasX, canvasY, seriesFilter, distance);
|
156
155
|
var item = items[0];
|
157
156
|
|
158
|
-
for (
|
159
|
-
if (item.distance === undefined ||
|
157
|
+
for (let i = 1; i < items.length; ++i) {
|
158
|
+
if (item.distance === undefined ||
|
160
159
|
items[i].distance < item.distance) {
|
161
160
|
item = items[i];
|
162
161
|
}
|
@@ -172,7 +171,7 @@ the tooltip from webcharts).
|
|
172
171
|
|
173
172
|
if (options.grid.autoHighlight) {
|
174
173
|
// clear auto-highlights
|
175
|
-
for (
|
174
|
+
for (let i = 0; i < highlights.length; ++i) {
|
176
175
|
var h = highlights[i];
|
177
176
|
if ((h.auto === eventname &&
|
178
177
|
!(item && h.series === item.series &&
|
@@ -847,8 +847,6 @@ Licensed under the MIT license.
|
|
847
847
|
ps = s.datapoints.pointsize;
|
848
848
|
points = s.datapoints.points;
|
849
849
|
|
850
|
-
var insertSteps = s.lines.show && s.lines.steps;
|
851
|
-
|
852
850
|
for (j = k = 0; j < data.length; ++j, k += ps) {
|
853
851
|
p = data[j];
|
854
852
|
|
@@ -980,8 +978,8 @@ Licensed under the MIT license.
|
|
980
978
|
var eventList = eventManager[key] || [];
|
981
979
|
|
982
980
|
eventList.push({"event": event, "handler": handler, "eventHolder": eventHolder, "priority": priority});
|
983
|
-
eventList.sort((a, b) => b.priority - a.priority
|
984
|
-
eventList.forEach(
|
981
|
+
eventList.sort((a, b) => b.priority - a.priority);
|
982
|
+
eventList.forEach(eventData => {
|
985
983
|
eventData.eventHolder.unbind(eventData.event, eventData.handler);
|
986
984
|
eventData.eventHolder.bind(eventData.event, eventData.handler);
|
987
985
|
});
|
@@ -2437,8 +2435,7 @@ Licensed under the MIT license.
|
|
2437
2435
|
if (series.bars.horizontal) {
|
2438
2436
|
range.ymin += delta;
|
2439
2437
|
range.ymax += delta + barWidth;
|
2440
|
-
}
|
2441
|
-
else {
|
2438
|
+
} else {
|
2442
2439
|
range.xmin += delta;
|
2443
2440
|
range.xmax += delta + barWidth;
|
2444
2441
|
}
|
@@ -2467,7 +2464,7 @@ Licensed under the MIT license.
|
|
2467
2464
|
}
|
2468
2465
|
|
2469
2466
|
var start = series.bars.horizontal ? 1 : 0;
|
2470
|
-
for (
|
2467
|
+
for (let j = start; j < series.datapoints.points.length; j += pointsize) {
|
2471
2468
|
if (isFinite(series.datapoints.points[j]) && series.datapoints.points[j] !== null) {
|
2472
2469
|
xValues.push(series.datapoints.points[j]);
|
2473
2470
|
}
|
@@ -2477,10 +2474,10 @@ Licensed under the MIT license.
|
|
2477
2474
|
return self.indexOf(value) === index;
|
2478
2475
|
}
|
2479
2476
|
|
2480
|
-
xValues = xValues.filter(
|
2481
|
-
xValues.sort(function(a, b){return a - b});
|
2477
|
+
xValues = xValues.filter(onlyUnique);
|
2478
|
+
xValues.sort(function(a, b) { return a - b });
|
2482
2479
|
|
2483
|
-
for (
|
2480
|
+
for (let j = 1; j < xValues.length; j++) {
|
2484
2481
|
var distance = Math.abs(xValues[j] - xValues[j - 1]);
|
2485
2482
|
if (distance < minDistance && isFinite(distance)) {
|
2486
2483
|
minDistance = distance;
|
@@ -2502,21 +2499,21 @@ Licensed under the MIT license.
|
|
2502
2499
|
}
|
2503
2500
|
}
|
2504
2501
|
|
2505
|
-
return items.sort((a, b) => {
|
2502
|
+
return items.sort((a, b) => {
|
2506
2503
|
if (b.distance === undefined) {
|
2507
2504
|
return -1;
|
2508
2505
|
} else if (a.distance === undefined && b.distance !== undefined) {
|
2509
2506
|
return 1;
|
2510
2507
|
}
|
2511
2508
|
|
2512
|
-
return a.distance - b.distance
|
2509
|
+
return a.distance - b.distance;
|
2513
2510
|
});
|
2514
2511
|
}
|
2515
2512
|
|
2516
2513
|
function findNearbyItem(mouseX, mouseY, seriesFilter, radius, computeDistance) {
|
2517
2514
|
var items = findNearbyItems(mouseX, mouseY, seriesFilter, radius, computeDistance);
|
2518
2515
|
return items[0] !== undefined ? items[0] : null;
|
2519
|
-
|
2516
|
+
}
|
2520
2517
|
|
2521
2518
|
// returns the data item the mouse is over/ the cursor is closest to, or null if none is found
|
2522
2519
|
function findItems(mouseX, mouseY, seriesFilter, radius, computeDistance) {
|
@@ -2550,7 +2547,7 @@ Licensed under the MIT license.
|
|
2550
2547
|
for (i = 0; i < items.length; i++) {
|
2551
2548
|
var seriesIndex = items[i].seriesIndex;
|
2552
2549
|
var dataIndex = items[i].dataIndex;
|
2553
|
-
var
|
2550
|
+
var itemDistance = items[i].distance;
|
2554
2551
|
var ps = series[seriesIndex].datapoints.pointsize;
|
2555
2552
|
|
2556
2553
|
foundItems.push({
|
@@ -2558,7 +2555,7 @@ Licensed under the MIT license.
|
|
2558
2555
|
dataIndex: dataIndex,
|
2559
2556
|
series: series[seriesIndex],
|
2560
2557
|
seriesIndex: seriesIndex,
|
2561
|
-
distance: Math.sqrt(
|
2558
|
+
distance: Math.sqrt(itemDistance)
|
2562
2559
|
});
|
2563
2560
|
}
|
2564
2561
|
|
@@ -2641,17 +2638,19 @@ Licensed under the MIT license.
|
|
2641
2638
|
var foundIndex = -1;
|
2642
2639
|
for (var j = 0; j < points.length; j += ps) {
|
2643
2640
|
var x = points[j], y = points[j + 1];
|
2644
|
-
if (x == null)
|
2641
|
+
if (x == null) {
|
2645
2642
|
continue;
|
2643
|
+
}
|
2646
2644
|
|
2647
2645
|
var bottom = ps === 3 ? points[j + 2] : defaultBottom;
|
2648
2646
|
// for a bar graph, the cursor must be inside the bar
|
2649
|
-
if (series.bars.horizontal
|
2650
|
-
(mx <= Math.max(bottom, x) && mx >= Math.min(bottom, x) &&
|
2651
|
-
my >= y + barLeft && my <= y + barRight)
|
2652
|
-
(mx >= x + barLeft && mx <= x + barRight &&
|
2653
|
-
my >= Math.min(bottom, y) && my <= Math.max(bottom, y)))
|
2654
|
-
|
2647
|
+
if (series.bars.horizontal
|
2648
|
+
? (mx <= Math.max(bottom, x) && mx >= Math.min(bottom, x) &&
|
2649
|
+
my >= y + barLeft && my <= y + barRight)
|
2650
|
+
: (mx >= x + barLeft && mx <= x + barRight &&
|
2651
|
+
my >= Math.min(bottom, y) && my <= Math.max(bottom, y))) {
|
2652
|
+
foundIndex = j / ps;
|
2653
|
+
}
|
2655
2654
|
}
|
2656
2655
|
|
2657
2656
|
return foundIndex;
|
@@ -10,6 +10,7 @@ selection: {
|
|
10
10
|
color: color,
|
11
11
|
shape: "round" or "miter" or "bevel",
|
12
12
|
visualization: "fill" or "focus",
|
13
|
+
displaySelectionDecorations: true or false,
|
13
14
|
minSize: number of pixels
|
14
15
|
}
|
15
16
|
|
@@ -26,6 +27,10 @@ option "focus" draws a colored bezel around the selected area while keeping
|
|
26
27
|
the selected area clear. The option "fill" highlights (i.e., fills) the
|
27
28
|
selected area with a colored highlight.
|
28
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
|
+
|
29
34
|
"minSize" is the minimum size a selection can be in pixels. This value can
|
30
35
|
be customized to determine the smallest size a selection can be and still
|
31
36
|
have the selection rectangle be displayed. When customizing this value, the
|
@@ -104,9 +109,7 @@ The plugin allso adds the following methods to the plot object:
|
|
104
109
|
// make this plugin much slimmer.
|
105
110
|
var savedhandlers = {};
|
106
111
|
|
107
|
-
|
108
|
-
|
109
|
-
function onMouseMove(e) {
|
112
|
+
function onDrag(e) {
|
110
113
|
if (selection.active) {
|
111
114
|
updateSelection(e);
|
112
115
|
|
@@ -114,7 +117,7 @@ The plugin allso adds the following methods to the plot object:
|
|
114
117
|
}
|
115
118
|
}
|
116
119
|
|
117
|
-
function
|
120
|
+
function onDragStart(e) {
|
118
121
|
var o = plot.getOptions();
|
119
122
|
// only accept left-click
|
120
123
|
if (e.which !== 1 || o.selection.mode === null) return;
|
@@ -138,17 +141,9 @@ The plugin allso adds the following methods to the plot object:
|
|
138
141
|
setSelectionPos(selection.first, e);
|
139
142
|
|
140
143
|
selection.active = true;
|
141
|
-
|
142
|
-
// this is a bit silly, but we have to use a closure to be
|
143
|
-
// able to whack the same handler again
|
144
|
-
mouseUpHandler = function (e) { onMouseUp(e); };
|
145
|
-
|
146
|
-
$(document).one("mouseup", mouseUpHandler);
|
147
144
|
}
|
148
145
|
|
149
|
-
function
|
150
|
-
mouseUpHandler = null;
|
151
|
-
|
146
|
+
function onDragEnd(e) {
|
152
147
|
// revert drag stuff for old-school browsers
|
153
148
|
if (document.onselectstart !== undefined) {
|
154
149
|
document.onselectstart = savedhandlers.onselectstart;
|
@@ -360,8 +355,9 @@ The plugin allso adds the following methods to the plot object:
|
|
360
355
|
plot.hooks.bindEvents.push(function(plot, eventHolder) {
|
361
356
|
var o = plot.getOptions();
|
362
357
|
if (o.selection.mode != null) {
|
363
|
-
|
364
|
-
|
358
|
+
plot.addEventHandler("dragstart", onDragStart, eventHolder, 0);
|
359
|
+
plot.addEventHandler("drag", onDrag, eventHolder, 0);
|
360
|
+
plot.addEventHandler("dragend", onDragEnd, eventHolder, 0);
|
365
361
|
}
|
366
362
|
});
|
367
363
|
|
@@ -459,6 +455,7 @@ The plugin allso adds the following methods to the plot object:
|
|
459
455
|
|
460
456
|
var c = $.color.parse(o.selection.color);
|
461
457
|
var visualization = o.selection.visualization;
|
458
|
+
var displaySelectionDecorations = o.selection.displaySelectionDecorations;
|
462
459
|
|
463
460
|
var scalingFactor = 1;
|
464
461
|
|
@@ -495,7 +492,10 @@ The plugin allso adds the following methods to the plot object:
|
|
495
492
|
} else {
|
496
493
|
ctx.fillRect(0, 0, plot.width(), plot.height());
|
497
494
|
ctx.clearRect(x, y, w, h);
|
498
|
-
|
495
|
+
|
496
|
+
if (displaySelectionDecorations) {
|
497
|
+
drawSelectionDecorations(ctx, x, y, w, h, oX, oY, selectionDirection(plot));
|
498
|
+
}
|
499
499
|
}
|
500
500
|
|
501
501
|
ctx.restore();
|
@@ -503,12 +503,9 @@ The plugin allso adds the following methods to the plot object:
|
|
503
503
|
});
|
504
504
|
|
505
505
|
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
506
|
-
eventHolder.unbind("
|
507
|
-
eventHolder.unbind("
|
508
|
-
|
509
|
-
if (mouseUpHandler) {
|
510
|
-
$(document).unbind("mouseup", mouseUpHandler);
|
511
|
-
}
|
506
|
+
eventHolder.unbind("dragstart", onDragStart);
|
507
|
+
eventHolder.unbind("drag", onDrag);
|
508
|
+
eventHolder.unbind("dragend", onDragEnd);
|
512
509
|
});
|
513
510
|
}
|
514
511
|
|
@@ -518,6 +515,7 @@ The plugin allso adds the following methods to the plot object:
|
|
518
515
|
selection: {
|
519
516
|
mode: null, // one of null, "x", "y" or "xy"
|
520
517
|
visualization: "focus", // "focus" or "fill"
|
518
|
+
displaySelectionDecorations: true, // true or false (currently only relevant for the focus visualization)
|
521
519
|
color: "#888888",
|
522
520
|
shape: "round", // one of "round", "miter", or "bevel"
|
523
521
|
minSize: 5 // minimum number of pixels
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_range_limit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
@@ -9,20 +9,20 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blacklight
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '7.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '7.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
@@ -101,14 +101,14 @@ dependencies:
|
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '0
|
104
|
+
version: '2.0'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '0
|
111
|
+
version: '2.0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: engine_cart
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
256
|
- !ruby/object:Gem::Version
|
257
257
|
version: '0'
|
258
258
|
requirements: []
|
259
|
-
rubygems_version: 3.
|
259
|
+
rubygems_version: 3.1.2
|
260
260
|
signing_key:
|
261
261
|
specification_version: 4
|
262
262
|
summary: Blacklight Range Limit plugin
|