blacklight_range_limit 7.9.0 → 8.1.0
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 +76 -0
- data/Gemfile +0 -7
- data/README.md +28 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +12 -249
- data/app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js +173 -0
- data/app/assets/javascripts/blacklight_range_limit/range_limit_shared.js +67 -3
- data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +29 -31
- data/app/assets/javascripts/blacklight_range_limit.js +6 -1
- data/app/helpers/range_limit_helper.rb +1 -1
- data/blacklight_range_limit.gemspec +2 -1
- data/lib/blacklight_range_limit/engine.rb +3 -1
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/vendor/assets/javascripts/flot/jquery.event.drag.js +145 -0
- data/vendor/assets/javascripts/flot/jquery.flot.js +3 -3
- metadata +28 -12
- data/.travis.yml +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dfdb61da699ad394376b877e63199d1cb10f5545208ed347e26e7e4f8365fc6
|
4
|
+
data.tar.gz: a61b1886322ead30ef33d6520201473fa271691ddcbc8940ffc738feeef32e21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb77af5e998bcd4b5b9abdddd5ab19c97086616ac6d08fff5314a818cea40d12bb496a39edd1f00ef643b818360749c65c2e74edfab1d54204a10fb8ce1002a3
|
7
|
+
data.tar.gz: 7455bda6064549df976002a07e306bb87e8d462b03aa4cdd5e2504f10540cbe8efd29f55e9746bc595d9f943a7e07bce50dd428d36799e13f218a0abf98c6417
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: CI
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
strategy:
|
20
|
+
matrix:
|
21
|
+
rails_version: [6.1.1]
|
22
|
+
ruby: [2.7, 3.0]
|
23
|
+
env:
|
24
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v2
|
27
|
+
- name: Set up Ruby
|
28
|
+
uses: ruby/setup-ruby@v1
|
29
|
+
with:
|
30
|
+
ruby-version: ${{ matrix.ruby }}
|
31
|
+
- name: Install dependencies with Rails ${{ matrix.rails_version }}
|
32
|
+
run: bundle install
|
33
|
+
- name: Run tests
|
34
|
+
run: bundle exec rake
|
35
|
+
env:
|
36
|
+
ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
37
|
+
test_rails6_0:
|
38
|
+
runs-on: ubuntu-latest
|
39
|
+
strategy:
|
40
|
+
matrix:
|
41
|
+
ruby: [2.6]
|
42
|
+
steps:
|
43
|
+
- uses: actions/checkout@v2
|
44
|
+
- name: Set up Ruby
|
45
|
+
uses: ruby/setup-ruby@v1
|
46
|
+
with:
|
47
|
+
ruby-version: ${{ matrix.ruby }}
|
48
|
+
- name: Install dependencies
|
49
|
+
run: bundle install
|
50
|
+
env:
|
51
|
+
RAILS_VERSION: 6.0.3.4
|
52
|
+
- name: Run tests
|
53
|
+
run: bundle exec rake
|
54
|
+
env:
|
55
|
+
RAILS_VERSION: 6.0.3.4
|
56
|
+
ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
57
|
+
test_rails5_2:
|
58
|
+
runs-on: ubuntu-latest
|
59
|
+
strategy:
|
60
|
+
matrix:
|
61
|
+
ruby: [2.5]
|
62
|
+
steps:
|
63
|
+
- uses: actions/checkout@v2
|
64
|
+
- name: Set up Ruby
|
65
|
+
uses: ruby/setup-ruby@v1
|
66
|
+
with:
|
67
|
+
ruby-version: ${{ matrix.ruby }}
|
68
|
+
- name: Install dependencies
|
69
|
+
run: bundle install
|
70
|
+
env:
|
71
|
+
RAILS_VERSION: 5.2.4.2
|
72
|
+
- name: Run tests
|
73
|
+
run: bundle exec rake
|
74
|
+
env:
|
75
|
+
RAILS_VERSION: 5.2.4.2
|
76
|
+
ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
data/Gemfile
CHANGED
@@ -36,13 +36,6 @@ else
|
|
36
36
|
case ENV['RAILS_VERSION']
|
37
37
|
when /^5.[12]/, /^6.0/
|
38
38
|
gem 'sass-rails', '~> 5.0'
|
39
|
-
when /^4.2/
|
40
|
-
gem 'responders', '~> 2.0'
|
41
|
-
gem 'sass-rails', '>= 5.0'
|
42
|
-
gem 'coffee-rails', '~> 4.1.0'
|
43
|
-
gem 'json', '~> 1.8'
|
44
|
-
when /^4.[01]/
|
45
|
-
gem 'sass-rails', '< 5.0'
|
46
39
|
end
|
47
40
|
end
|
48
41
|
# END ENGINE_CART BLOCK
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
BlacklightRangeLimit: integer range limiting and profiling for Blacklight applications
|
2
2
|
|
3
|
-
|
3
|
+
![Build Status](https://github.com/projectblacklight/blacklight/workflows/CI/badge.svg) [![Gem Version](https://badge.fury.io/rb/blacklight_range_limit.png)](http://badge.fury.io/rb/blacklight_range_limit)
|
4
4
|
|
5
5
|
![Screen shot](doc/example-screenshot.png)
|
6
6
|
|
@@ -133,6 +133,33 @@ ourselves yet.
|
|
133
133
|
Also not sure how well the flot select UI works on a touch screen. The slider
|
134
134
|
is probably the best touch UI anyway, if it can be made to work well.
|
135
135
|
|
136
|
+
## JavaScript Customization
|
137
|
+
|
138
|
+
There are two main types of JavaScript implemented for BlacklightRangeLimit:
|
139
|
+
- Initialization and refresh of Range Limit plugin based off of events
|
140
|
+
- Range Limit plugin functionality called from event listeners
|
141
|
+
|
142
|
+
The second class of range limit functionality is customizable in your local application by overriding the specified function.
|
143
|
+
|
144
|
+
A simple example of this is overriding the display ratio used to create the histogram
|
145
|
+
|
146
|
+
```javascript
|
147
|
+
BlacklightRangeLimit.display_ratio = 1
|
148
|
+
```
|
149
|
+
|
150
|
+
This will now create a square histogram.
|
151
|
+
|
152
|
+
Not only these variables and functions be customized, you can call them based off of custom events in your application.
|
153
|
+
|
154
|
+
```javascript
|
155
|
+
$('.custom-class').on('doSomething', function() {
|
156
|
+
BlacklightRangeLimit.checkForNeededFacetsToFetch();
|
157
|
+
$(".range_limit .profile .range.slider_js").each(function() {
|
158
|
+
BlacklightRangeLimit.buildSlider(this);
|
159
|
+
});
|
160
|
+
});
|
161
|
+
```
|
162
|
+
|
136
163
|
# Tests
|
137
164
|
|
138
165
|
Test coverage is not great, but there are some tests, using rspec. Run `bundle exec rake ci` or just `bundle exec rake` to seed and
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
8.1.0
|
@@ -1,23 +1,19 @@
|
|
1
1
|
// for Blacklight.onLoad:
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
/**
|
4
|
+
* Closure functions in this file are mainly concerned with initializing, resizing, and updating
|
5
|
+
* range limit functionality based off of page load, facet opening, page resizing, and otherwise
|
6
|
+
* events.
|
7
|
+
*/
|
6
8
|
|
7
9
|
Blacklight.onLoad(function() {
|
8
|
-
// ratio of width to height for desired display, multiply width by this ratio
|
9
|
-
// to get height. hard-coded in for now.
|
10
|
-
var display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not
|
11
|
-
var redrawnEvent = "plotDrawn.blacklight.rangeLimit";
|
12
|
-
|
13
|
-
|
14
10
|
|
15
11
|
// Facets already on the page? Turn em into a chart.
|
16
12
|
$(".range_limit .profile .distribution.chart_js ul").each(function() {
|
17
|
-
turnIntoPlot($(this).parent());
|
13
|
+
BlacklightRangeLimit.turnIntoPlot($(this).parent());
|
18
14
|
});
|
19
15
|
|
20
|
-
checkForNeededFacetsToFetch();
|
16
|
+
BlacklightRangeLimit.checkForNeededFacetsToFetch();
|
21
17
|
|
22
18
|
// Listen for twitter bootstrap collapsible open events, to render flot
|
23
19
|
// in previously hidden divs on open, if needed.
|
@@ -31,66 +27,23 @@ Blacklight.onLoad(function() {
|
|
31
27
|
// have width -- right away on show.bs is too soon, but
|
32
28
|
// shown.bs is later than we want, we want to start rendering
|
33
29
|
// while animation is still in progress.
|
34
|
-
turnIntoPlot(container, 1100);
|
30
|
+
BlacklightRangeLimit.turnIntoPlot(container, 1100);
|
35
31
|
}
|
36
32
|
});
|
37
33
|
|
38
34
|
// When loaded in a modal
|
39
35
|
$(Blacklight.modal.modalSelector).on('shown.bs.modal', function() {
|
40
36
|
$(this).find(".range_limit .profile .distribution.chart_js ul").each(function() {
|
41
|
-
turnIntoPlot($(this).parent());
|
37
|
+
BlacklightRangeLimit.turnIntoPlot($(this).parent());
|
42
38
|
});
|
43
39
|
|
44
40
|
// Case when there is no currently selected range
|
45
|
-
checkForNeededFacetsToFetch();
|
41
|
+
BlacklightRangeLimit.checkForNeededFacetsToFetch();
|
46
42
|
});
|
47
43
|
|
48
|
-
// Add AJAX fetched range facets if needed, and add a chart to em
|
49
|
-
function checkForNeededFacetsToFetch() {
|
50
|
-
$(".range_limit .profile .distribution a.load_distribution").each(function() {
|
51
|
-
var container = $(this).parent('div.distribution');
|
52
|
-
|
53
|
-
$(container).load($(this).attr('href'), function(response, status) {
|
54
|
-
if ($(container).hasClass("chart_js") && status == "success" ) {
|
55
|
-
turnIntoPlot(container);
|
56
|
-
}
|
57
|
-
});
|
58
|
-
});
|
59
|
-
}
|
60
|
-
|
61
|
-
|
62
|
-
// after a collapsible facet contents is fully shown,
|
63
|
-
// resize the flot chart to current conditions. This way, if you change
|
64
|
-
// browser window size, you can get chart resized to fit by closing and opening
|
65
|
-
// again, if needed.
|
66
|
-
|
67
|
-
function redrawPlot(container) {
|
68
|
-
if (container && container.width() > 0) {
|
69
|
-
// resize the container's height, since width may have changed.
|
70
|
-
container.height( container.width() * display_ratio );
|
71
|
-
|
72
|
-
// redraw the chart.
|
73
|
-
var plot = container.data("plot");
|
74
|
-
if (plot) {
|
75
|
-
// how to redraw after possible resize?
|
76
|
-
// Cribbed from https://github.com/flot/flot/blob/master/jquery.flot.resize.js
|
77
|
-
plot.resize();
|
78
|
-
plot.setupGrid();
|
79
|
-
plot.draw();
|
80
|
-
// plus trigger redraw of the selection, which otherwise ain't always right
|
81
|
-
// we'll trigger a fake event on one of the boxes
|
82
|
-
var form = $(container).closest(".limit_content").find("form.range_limit");
|
83
|
-
form.find("input.range_begin").trigger("change");
|
84
|
-
|
85
|
-
// send our custom event to trigger redraw of slider
|
86
|
-
$(container).trigger(redrawnEvent);
|
87
|
-
}
|
88
|
-
}
|
89
|
-
}
|
90
|
-
|
91
44
|
$("body").on("shown.bs.collapse", function(event) {
|
92
45
|
var container = $(event.target).filter(".facet-content").find(".chart_js");
|
93
|
-
redrawPlot(container);
|
46
|
+
BlacklightRangeLimit.redrawPlot(container);
|
94
47
|
});
|
95
48
|
|
96
49
|
// debouce borrowed from underscore
|
@@ -115,197 +68,7 @@ Blacklight.onLoad(function() {
|
|
115
68
|
|
116
69
|
$(window).on("resize", debounce(function() {
|
117
70
|
$(".chart_js").each(function(i, container) {
|
118
|
-
redrawPlot($(container));
|
71
|
+
BlacklightRangeLimit.redrawPlot($(container));
|
119
72
|
});
|
120
73
|
}, 350));
|
121
|
-
|
122
|
-
// second arg, if provided, is a number of ms we're willing to
|
123
|
-
// wait for the container to have width before giving up -- we'll
|
124
|
-
// set 50ms timers to check back until timeout is expired or the
|
125
|
-
// container is finally visible. The timeout is used when we catch
|
126
|
-
// bootstrap show event, but the animation hasn't barely begun yet -- but
|
127
|
-
// we don't want to wait until it's finished, we want to start rendering
|
128
|
-
// as soon as we can.
|
129
|
-
//
|
130
|
-
// We also will
|
131
|
-
function turnIntoPlot(container, wait_for_visible) {
|
132
|
-
// flot can only render in a a div with a defined width.
|
133
|
-
// for instance, a hidden div can't generally be rendered in (although if you set
|
134
|
-
// an explicit width on it, it might work)
|
135
|
-
//
|
136
|
-
// We'll count on later code that catch bootstrap collapse open to render
|
137
|
-
// on show, for currently hidden divs.
|
138
|
-
|
139
|
-
// for some reason width sometimes return negative, not sure
|
140
|
-
// why but it's some kind of hidden.
|
141
|
-
if (container.width() > 0) {
|
142
|
-
var height = container.width() * display_ratio;
|
143
|
-
|
144
|
-
// Need an explicit height to make flot happy.
|
145
|
-
container.height( height )
|
146
|
-
|
147
|
-
areaChart($(container));
|
148
|
-
|
149
|
-
$(container).trigger(redrawnEvent);
|
150
|
-
}
|
151
|
-
else if (wait_for_visible > 0) {
|
152
|
-
setTimeout(function() {
|
153
|
-
turnIntoPlot(container, wait_for_visible - 50);
|
154
|
-
}, 50);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
// Takes a div holding a ul of distribution segments produced by
|
159
|
-
// blacklight_range_limit/_range_facets and makes it into
|
160
|
-
// a flot area chart.
|
161
|
-
function areaChart(container) {
|
162
|
-
//flot loaded? And canvas element supported.
|
163
|
-
if ( domDependenciesMet() ) {
|
164
|
-
|
165
|
-
// Grab the data from the ul div
|
166
|
-
var series_data = new Array();
|
167
|
-
var pointer_lookup = new Array();
|
168
|
-
var x_ticks = new Array();
|
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
|
-
|
172
|
-
$(container).find("ul li").each(function() {
|
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
|
-
var count = BlacklightRangeLimit.parseNum($(this).find("span.count").text());
|
176
|
-
var avg = (count / (to - from + 1));
|
177
|
-
|
178
|
-
|
179
|
-
//We use the avg as the y-coord, to make the area of each
|
180
|
-
//segment proportional to how many documents it holds.
|
181
|
-
series_data.push( [from, avg ] );
|
182
|
-
series_data.push( [to+1, avg] );
|
183
|
-
|
184
|
-
x_ticks.push(from);
|
185
|
-
|
186
|
-
pointer_lookup.push({'from': from, 'to': to, 'count': count, 'label': $(this).find(".facet_select").html() });
|
187
|
-
});
|
188
|
-
var max_plus_one = BlacklightRangeLimit.parseNum($(container).find("ul li:last-child span.to").text())+1;
|
189
|
-
x_ticks.push( max_plus_one );
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
var plot;
|
194
|
-
var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {};
|
195
|
-
|
196
|
-
try {
|
197
|
-
plot = $.plot($(container), [series_data],
|
198
|
-
$.extend(true, config, {
|
199
|
-
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1},
|
200
|
-
//xaxis: { ticks: x_ticks },
|
201
|
-
xaxis: { tickDecimals: 0 }, // force integer ticks
|
202
|
-
series: { lines: { fill: true, steps: true }},
|
203
|
-
grid: {clickable: true, hoverable: true, autoHighlight: false, margin: { left: 0, right: 0 }},
|
204
|
-
selection: {mode: "x"}
|
205
|
-
}));
|
206
|
-
}
|
207
|
-
catch(err) {
|
208
|
-
alert(err);
|
209
|
-
}
|
210
|
-
|
211
|
-
find_segment_for = function_for_find_segment(pointer_lookup);
|
212
|
-
var last_segment = null;
|
213
|
-
$(container).tooltip({'html': true, 'placement': 'bottom', 'trigger': 'manual', 'delay': { show: 0, hide: 100}});
|
214
|
-
|
215
|
-
$(container).bind("plothover", function (event, pos, item) {
|
216
|
-
segment = find_segment_for(pos.x);
|
217
|
-
|
218
|
-
if(segment != last_segment) {
|
219
|
-
var title = find_segment_for(pos.x).label + ' (' + BlacklightRangeLimit.parseNum(segment.count) + ')';
|
220
|
-
$(container).attr("title", title).tooltip("_fixTitle").tooltip("show");
|
221
|
-
|
222
|
-
last_segment = segment;
|
223
|
-
}
|
224
|
-
});
|
225
|
-
|
226
|
-
$(container).bind("mouseout", function() {
|
227
|
-
last_segment = null;
|
228
|
-
$(container).tooltip('hide');
|
229
|
-
});
|
230
|
-
$(container).bind("plotclick", function (event, pos, item) {
|
231
|
-
if ( plot.getSelection() == null) {
|
232
|
-
segment = find_segment_for(pos.x);
|
233
|
-
plot.setSelection( normalized_selection(segment.from, segment.to));
|
234
|
-
}
|
235
|
-
});
|
236
|
-
$(container).bind("plotselected plotselecting", function(event, ranges) {
|
237
|
-
if (ranges != null ) {
|
238
|
-
var from = Math.floor(ranges.xaxis.from);
|
239
|
-
var to = Math.floor(ranges.xaxis.to);
|
240
|
-
|
241
|
-
var form = $(container).closest(".limit_content").find("form.range_limit");
|
242
|
-
form.find("input.range_begin").val(from);
|
243
|
-
form.find("input.range_end").val(to);
|
244
|
-
|
245
|
-
var slider_placeholder = $(container).closest(".limit_content").find("[data-slider-placeholder]");
|
246
|
-
if (slider_placeholder) {
|
247
|
-
slider_placeholder.slider("setValue", [from, to+1]);
|
248
|
-
}
|
249
|
-
}
|
250
|
-
});
|
251
|
-
|
252
|
-
var form = $(container).closest(".limit_content").find("form.range_limit");
|
253
|
-
form.find("input.range_begin, input.range_end").change(function () {
|
254
|
-
plot.setSelection( form_selection(form, min, max) , true );
|
255
|
-
});
|
256
|
-
$(container).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
|
257
|
-
var values = $(event.target).data("slider").getValue();
|
258
|
-
form.find("input.range_begin").val(values[0]);
|
259
|
-
form.find("input.range_end").val(values[1]);
|
260
|
-
plot.setSelection( normalized_selection(values[0], Math.max(values[0], values[1]-1)), true);
|
261
|
-
});
|
262
|
-
|
263
|
-
// initially entirely selected, to match slider
|
264
|
-
plot.setSelection( {xaxis: { from:min, to:max+0.9999}} );
|
265
|
-
}
|
266
|
-
}
|
267
|
-
|
268
|
-
|
269
|
-
// Send endpoint to endpoint+0.99999 to have display
|
270
|
-
// more closely approximate limiting behavior esp
|
271
|
-
// at small resolutions. (Since we search on whole numbers,
|
272
|
-
// inclusive, but flot chart is decimal.)
|
273
|
-
function normalized_selection(min, max) {
|
274
|
-
max += 0.99999;
|
275
|
-
|
276
|
-
return {xaxis: { 'from':min, 'to':max}}
|
277
|
-
}
|
278
|
-
|
279
|
-
function form_selection(form, min, max) {
|
280
|
-
var begin_val = BlacklightRangeLimit.parseNum($(form).find("input.range_begin").val());
|
281
|
-
if (isNaN(begin_val) || begin_val < min) {
|
282
|
-
begin_val = min;
|
283
|
-
}
|
284
|
-
var end_val = BlacklightRangeLimit.parseNum($(form).find("input.range_end").val());
|
285
|
-
if (isNaN(end_val) || end_val > max) {
|
286
|
-
end_val = max;
|
287
|
-
}
|
288
|
-
|
289
|
-
return normalized_selection(begin_val, end_val);
|
290
|
-
}
|
291
|
-
|
292
|
-
function function_for_find_segment(pointer_lookup_arr) {
|
293
|
-
return function(x_coord) {
|
294
|
-
for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) {
|
295
|
-
var hash = pointer_lookup_arr[i];
|
296
|
-
if (x_coord >= hash.from)
|
297
|
-
return hash;
|
298
|
-
}
|
299
|
-
return pointer_lookup_arr[0];
|
300
|
-
};
|
301
|
-
}
|
302
|
-
|
303
|
-
// Check if Flot is loaded, and if browser has support for
|
304
|
-
// canvas object, either natively or via IE excanvas.
|
305
|
-
function domDependenciesMet() {
|
306
|
-
var flotLoaded = (typeof $.plot != "undefined");
|
307
|
-
var canvasAvailable = ((typeof(document.createElement('canvas').getContext) != "undefined") || (typeof window.CanvasRenderingContext2D != 'undefined' || typeof G_vmlCanvasManager != 'undefined'));
|
308
|
-
|
309
|
-
return (flotLoaded && canvasAvailable);
|
310
|
-
}
|
311
74
|
});
|
@@ -0,0 +1,173 @@
|
|
1
|
+
// second arg, if provided, is a number of ms we're willing to
|
2
|
+
// wait for the container to have width before giving up -- we'll
|
3
|
+
// set 50ms timers to check back until timeout is expired or the
|
4
|
+
// container is finally visible. The timeout is used when we catch
|
5
|
+
// bootstrap show event, but the animation hasn't barely begun yet -- but
|
6
|
+
// we don't want to wait until it's finished, we want to start rendering
|
7
|
+
// as soon as we can.
|
8
|
+
//
|
9
|
+
// We also will
|
10
|
+
BlacklightRangeLimit.turnIntoPlot = function turnIntoPlot(container, wait_for_visible) {
|
11
|
+
// flot can only render in a a div with a defined width.
|
12
|
+
// for instance, a hidden div can't generally be rendered in (although if you set
|
13
|
+
// an explicit width on it, it might work)
|
14
|
+
//
|
15
|
+
// We'll count on later code that catch bootstrap collapse open to render
|
16
|
+
// on show, for currently hidden divs.
|
17
|
+
|
18
|
+
// for some reason width sometimes return negative, not sure
|
19
|
+
// why but it's some kind of hidden.
|
20
|
+
if (container.width() > 0) {
|
21
|
+
var height = container.width() * BlacklightRangeLimit.display_ratio;
|
22
|
+
|
23
|
+
// Need an explicit height to make flot happy.
|
24
|
+
container.height( height )
|
25
|
+
|
26
|
+
BlacklightRangeLimit.areaChart($(container));
|
27
|
+
|
28
|
+
$(container).trigger(BlacklightRangeLimit.redrawnEvent);
|
29
|
+
}
|
30
|
+
else if (wait_for_visible > 0) {
|
31
|
+
setTimeout(function() {
|
32
|
+
BlacklightRangeLimit.turnIntoPlot(container, wait_for_visible - 50);
|
33
|
+
}, 50);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
// Takes a div holding a ul of distribution segments produced by
|
38
|
+
// blacklight_range_limit/_range_facets and makes it into
|
39
|
+
// a flot area chart.
|
40
|
+
BlacklightRangeLimit.areaChart = function areaChart(container) {
|
41
|
+
//flot loaded? And canvas element supported.
|
42
|
+
if ( BlacklightRangeLimit.domDependenciesMet() ) {
|
43
|
+
|
44
|
+
// Grab the data from the ul div
|
45
|
+
var series_data = new Array();
|
46
|
+
var pointer_lookup = new Array();
|
47
|
+
var x_ticks = new Array();
|
48
|
+
var min = BlacklightRangeLimit.parseNum($(container).find("ul li:first-child span.from").first().data('blrlBegin'));
|
49
|
+
var max = BlacklightRangeLimit.parseNum($(container).find("ul li:last-child span.to").first().data('blrlEnd'));
|
50
|
+
|
51
|
+
$(container).find("ul li").each(function() {
|
52
|
+
var from = BlacklightRangeLimit.parseNum($(this).find("span.from").first().data('blrlBegin'));
|
53
|
+
var to = BlacklightRangeLimit.parseNum($(this).find("span.to").first().data('blrlEnd'));
|
54
|
+
var count = BlacklightRangeLimit.parseNum($(this).find("span.count").text());
|
55
|
+
var avg = (count / (to - from + 1));
|
56
|
+
|
57
|
+
|
58
|
+
//We use the avg as the y-coord, to make the area of each
|
59
|
+
//segment proportional to how many documents it holds.
|
60
|
+
series_data.push( [from, avg ] );
|
61
|
+
series_data.push( [to+1, avg] );
|
62
|
+
|
63
|
+
x_ticks.push(from);
|
64
|
+
|
65
|
+
pointer_lookup.push({'from': from, 'to': to, 'count': count, 'label': $(this).find(".facet_select").html() });
|
66
|
+
});
|
67
|
+
var max_plus_one = BlacklightRangeLimit.parseNum($(container).find("ul li:last-child span.to").text())+1;
|
68
|
+
x_ticks.push( max_plus_one );
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
var plot;
|
73
|
+
var config = $(container).closest('.blrl-plot-config').data('plot-config') || $(container).closest('.facet-limit').data('plot-config') || {};
|
74
|
+
|
75
|
+
try {
|
76
|
+
plot = $.plot($(container), [series_data],
|
77
|
+
$.extend(true, config, {
|
78
|
+
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1},
|
79
|
+
//xaxis: { ticks: x_ticks },
|
80
|
+
xaxis: { tickDecimals: 0 }, // force integer ticks
|
81
|
+
series: { lines: { fill: true, steps: true }},
|
82
|
+
grid: {clickable: true, hoverable: true, autoHighlight: false, margin: { left: 0, right: 0 }},
|
83
|
+
selection: {mode: "x"}
|
84
|
+
}));
|
85
|
+
}
|
86
|
+
catch(err) {
|
87
|
+
alert(err);
|
88
|
+
}
|
89
|
+
|
90
|
+
var find_segment_for = BlacklightRangeLimit.function_for_find_segment(pointer_lookup);
|
91
|
+
var last_segment = null;
|
92
|
+
$(container).tooltip({'html': true, 'placement': 'bottom', 'trigger': 'manual', 'delay': { show: 0, hide: 100}});
|
93
|
+
|
94
|
+
$(container).bind("plothover", function (event, pos, item) {
|
95
|
+
var segment = find_segment_for(pos.x);
|
96
|
+
|
97
|
+
if(segment != last_segment) {
|
98
|
+
var title = find_segment_for(pos.x).label + ' (' + BlacklightRangeLimit.parseNum(segment.count) + ')';
|
99
|
+
$(container).attr("title", title).tooltip("_fixTitle").tooltip("show");
|
100
|
+
|
101
|
+
last_segment = segment;
|
102
|
+
}
|
103
|
+
});
|
104
|
+
|
105
|
+
$(container).bind("mouseout", function() {
|
106
|
+
last_segment = null;
|
107
|
+
$(container).tooltip('hide');
|
108
|
+
});
|
109
|
+
$(container).bind("plotclick", function (event, pos, item) {
|
110
|
+
if ( plot.getSelection() == null) {
|
111
|
+
segment = find_segment_for(pos.x);
|
112
|
+
plot.setSelection(BlacklightRangeLimit.normalized_selection(segment.from, segment.to));
|
113
|
+
}
|
114
|
+
});
|
115
|
+
$(container).bind("plotselected plotselecting", function(event, ranges) {
|
116
|
+
if (ranges != null ) {
|
117
|
+
var from = Math.floor(ranges.xaxis.from);
|
118
|
+
var to = Math.floor(ranges.xaxis.to);
|
119
|
+
|
120
|
+
var form = $(container).closest(".limit_content").find("form.range_limit");
|
121
|
+
form.find("input.range_begin").val(from);
|
122
|
+
form.find("input.range_end").val(to);
|
123
|
+
|
124
|
+
var slider_placeholder = $(container).closest(".limit_content").find("[data-slider-placeholder]");
|
125
|
+
if (slider_placeholder) {
|
126
|
+
slider_placeholder.slider("setValue", [from, to+1]);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
});
|
130
|
+
|
131
|
+
var form = $(container).closest(".limit_content").find("form.range_limit");
|
132
|
+
form.find("input.range_begin, input.range_end").change(function () {
|
133
|
+
plot.setSelection( BlacklightRangeLimit.form_selection(form, min, max) , true );
|
134
|
+
});
|
135
|
+
$(container).closest(".limit_content").find(".profile .range").on("slide", function(event, ui) {
|
136
|
+
var values = $(event.target).data("slider").getValue();
|
137
|
+
form.find("input.range_begin").val(values[0]);
|
138
|
+
form.find("input.range_end").val(values[1]);
|
139
|
+
plot.setSelection(BlacklightRangeLimit.normalized_selection(values[0], Math.max(values[0], values[1]-1)), true);
|
140
|
+
});
|
141
|
+
|
142
|
+
// initially entirely selected, to match slider
|
143
|
+
plot.setSelection( {xaxis: { from:min, to:max+0.9999}} );
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
// after a collapsible facet contents is fully shown,
|
148
|
+
// resize the flot chart to current conditions. This way, if you change
|
149
|
+
// browser window size, you can get chart resized to fit by closing and opening
|
150
|
+
// again, if needed.
|
151
|
+
BlacklightRangeLimit.redrawPlot = function redrawPlot(container) {
|
152
|
+
if (container && container.width() > 0) {
|
153
|
+
// resize the container's height, since width may have changed.
|
154
|
+
container.height( container.width() * BlacklightRangeLimit.display_ratio );
|
155
|
+
|
156
|
+
// redraw the chart.
|
157
|
+
var plot = container.data("plot");
|
158
|
+
if (plot) {
|
159
|
+
// how to redraw after possible resize?
|
160
|
+
// Cribbed from https://github.com/flot/flot/blob/master/jquery.flot.resize.js
|
161
|
+
plot.resize();
|
162
|
+
plot.setupGrid();
|
163
|
+
plot.draw();
|
164
|
+
// plus trigger redraw of the selection, which otherwise ain't always right
|
165
|
+
// we'll trigger a fake event on one of the boxes
|
166
|
+
var form = $(container).closest(".limit_content").find("form.range_limit");
|
167
|
+
form.find("input.range_begin").trigger("change");
|
168
|
+
|
169
|
+
// send our custom event to trigger redraw of slider
|
170
|
+
$(container).trigger(BlacklightRangeLimit.redrawnEvent);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
/**
|
2
|
+
* Global BlacklightRangeLimit module setup.
|
3
|
+
*/
|
4
4
|
!function(global) {
|
5
5
|
'use strict';
|
6
6
|
|
@@ -10,11 +10,75 @@
|
|
10
10
|
this.options = options || {};
|
11
11
|
}
|
12
12
|
|
13
|
+
BlacklightRangeLimit.display_ratio = 1/(1.618 * 2); // half a golden rectangle, why not
|
14
|
+
/* A custom event "plotDrawn.blacklight.rangeLimit" will be sent when flot plot
|
15
|
+
is (re-)drawn on screen possibly with a new size. target of event will be the DOM element
|
16
|
+
containing the plot. Used to resize slider to match. */
|
17
|
+
BlacklightRangeLimit.redrawnEvent = "plotDrawn.blacklight.rangeLimit";
|
18
|
+
|
19
|
+
// takes a string and parses into an integer, but throws away commas first, to avoid truncation when there is a comma
|
20
|
+
// use in place of javascript's native parseInt
|
13
21
|
BlacklightRangeLimit.parseNum = function parseNum(str) {
|
14
22
|
str = String(str).replace(/[^0-9-]/g, '');
|
15
23
|
return parseInt(str, 10);
|
16
24
|
};
|
17
25
|
|
26
|
+
BlacklightRangeLimit.form_selection = function form_selection(form, min, max) {
|
27
|
+
var begin_val = BlacklightRangeLimit.parseNum($(form).find("input.range_begin").val());
|
28
|
+
if (isNaN(begin_val) || begin_val < min) {
|
29
|
+
begin_val = min;
|
30
|
+
}
|
31
|
+
var end_val = BlacklightRangeLimit.parseNum($(form).find("input.range_end").val());
|
32
|
+
if (isNaN(end_val) || end_val > max) {
|
33
|
+
end_val = max;
|
34
|
+
}
|
35
|
+
|
36
|
+
return BlacklightRangeLimit.normalized_selection(begin_val, end_val);
|
37
|
+
}
|
38
|
+
|
39
|
+
// Add AJAX fetched range facets if needed, and add a chart to em
|
40
|
+
BlacklightRangeLimit.checkForNeededFacetsToFetch = function checkForNeededFacetsToFetch() {
|
41
|
+
$(".range_limit .profile .distribution a.load_distribution").each(function() {
|
42
|
+
var container = $(this).parent('div.distribution');
|
43
|
+
|
44
|
+
$(container).load($(this).attr('href'), function(response, status) {
|
45
|
+
if ($(container).hasClass("chart_js") && status == "success" ) {
|
46
|
+
BlacklightRangeLimit.turnIntoPlot(container);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
BlacklightRangeLimit.function_for_find_segment = function function_for_find_segment(pointer_lookup_arr) {
|
53
|
+
return function(x_coord) {
|
54
|
+
for (var i = pointer_lookup_arr.length-1 ; i >= 0 ; i--) {
|
55
|
+
var hash = pointer_lookup_arr[i];
|
56
|
+
if (x_coord >= hash.from)
|
57
|
+
return hash;
|
58
|
+
}
|
59
|
+
return pointer_lookup_arr[0];
|
60
|
+
};
|
61
|
+
}
|
62
|
+
|
63
|
+
// Send endpoint to endpoint+0.99999 to have display
|
64
|
+
// more closely approximate limiting behavior esp
|
65
|
+
// at small resolutions. (Since we search on whole numbers,
|
66
|
+
// inclusive, but flot chart is decimal.)
|
67
|
+
BlacklightRangeLimit.normalized_selection = function normalized_selection(min, max) {
|
68
|
+
max += 0.99999;
|
69
|
+
|
70
|
+
return {xaxis: { 'from':min, 'to':max}}
|
71
|
+
}
|
72
|
+
|
73
|
+
// Check if Flot is loaded, and if browser has support for
|
74
|
+
// canvas object, either natively or via IE excanvas.
|
75
|
+
BlacklightRangeLimit.domDependenciesMet = function domDependenciesMet() {
|
76
|
+
var flotLoaded = (typeof $.plot != "undefined");
|
77
|
+
var canvasAvailable = ((typeof(document.createElement('canvas').getContext) != "undefined") || (typeof window.CanvasRenderingContext2D != 'undefined' || typeof G_vmlCanvasManager != 'undefined'));
|
78
|
+
|
79
|
+
return (flotLoaded && canvasAvailable);
|
80
|
+
}
|
81
|
+
|
18
82
|
BlacklightRangeLimit.noConflict = function noConflict() {
|
19
83
|
global.BlacklightRangeLimit = previousBlacklightRangeLimit;
|
20
84
|
return BlacklightRangeLimit;
|
@@ -3,65 +3,64 @@
|
|
3
3
|
Blacklight.onLoad(function() {
|
4
4
|
|
5
5
|
$(".range_limit .profile .range.slider_js").each(function() {
|
6
|
-
buildSlider(this);
|
6
|
+
BlacklightRangeLimit.buildSlider(this);
|
7
7
|
});
|
8
8
|
|
9
9
|
$(Blacklight.modal.modalSelector).on('shown.bs.modal', function() {
|
10
10
|
$(this).find(".range_limit .profile .range.slider_js").each(function() {
|
11
|
-
buildSlider(this);
|
11
|
+
BlacklightRangeLimit.buildSlider(this);
|
12
12
|
});
|
13
13
|
});
|
14
14
|
|
15
|
-
// catch event for redrawing chart, to redraw slider to match width
|
16
|
-
$("body").on("plotDrawn.blacklight.rangeLimit", function(event) {
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
// catch event for redrawing chart, to redraw slider to match width
|
16
|
+
$("body").on("plotDrawn.blacklight.rangeLimit", function(event) {
|
17
|
+
var area = $(event.target).closest(".limit_content.range_limit");
|
18
|
+
var plot = area.find(".chart_js").data("plot");
|
19
|
+
var slider_el = area.find(".slider");
|
20
20
|
|
21
|
-
|
21
|
+
if (plot && slider_el) {
|
22
22
|
slider_el.width(plot.width());
|
23
23
|
slider_el.css("display", "block")
|
24
|
-
|
24
|
+
}
|
25
|
+
});
|
25
26
|
});
|
26
27
|
|
27
28
|
// returns two element array min/max as numbers. If there is a limit applied,
|
28
29
|
// it's boundaries are are limits. Otherwise, min/max in current result
|
29
30
|
// set as sniffed from HTML. Pass in a DOM element for a div.range
|
30
31
|
// Will return NaN as min or max in case of error or other weirdness.
|
31
|
-
function min_max(range_element) {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
47
|
-
return [min, max]
|
32
|
+
BlacklightRangeLimit.min_max = function min_max(range_element) {
|
33
|
+
var current_limit = $(range_element).closest(".limit_content.range_limit").find(".current")
|
34
|
+
|
35
|
+
var min = max = BlacklightRangeLimit.parseNum(current_limit.find(".single").data('blrlSingle'))
|
36
|
+
if ( isNaN(min)) {
|
37
|
+
min = BlacklightRangeLimit.parseNum(current_limit.find(".from").first().data('blrlBegin'));
|
38
|
+
max = BlacklightRangeLimit.parseNum(current_limit.find(".to").first().data('blrlEnd'));
|
39
|
+
}
|
40
|
+
|
41
|
+
if (isNaN(min) || isNaN(max)) {
|
42
|
+
//no current limit, take from results min max included in spans
|
43
|
+
min = BlacklightRangeLimit.parseNum($(range_element).find(".min").first().text());
|
44
|
+
max = BlacklightRangeLimit.parseNum($(range_element).find(".max").first().text());
|
45
|
+
}
|
46
|
+
return [min, max]
|
48
47
|
}
|
49
48
|
|
50
49
|
|
51
50
|
// Check to see if a value is an Integer
|
52
51
|
// see: http://stackoverflow.com/questions/3885817/how-to-check-if-a-number-is-float-or-integer
|
53
|
-
function isInt(n) {
|
52
|
+
BlacklightRangeLimit.isInt = function isInt(n) {
|
54
53
|
return n % 1 === 0;
|
55
54
|
}
|
56
55
|
|
57
|
-
|
56
|
+
BlacklightRangeLimit.buildSlider = function buildSlider(thisContext) {
|
58
57
|
var range_element = $(thisContext);
|
59
58
|
|
60
|
-
var boundaries = min_max(thisContext);
|
59
|
+
var boundaries = BlacklightRangeLimit.min_max(thisContext);
|
61
60
|
var min = boundaries[0];
|
62
61
|
var max = boundaries[1];
|
63
62
|
|
64
|
-
if (isInt(min) && isInt(max)) {
|
63
|
+
if (BlacklightRangeLimit.isInt(min) && BlacklightRangeLimit.isInt(max)) {
|
65
64
|
$(thisContext).contents().wrapAll('<div class="sr-only" />');
|
66
65
|
|
67
66
|
var range_element = $(thisContext);
|
@@ -137,4 +136,3 @@ function isInt(n) {
|
|
137
136
|
placeholder_input.slider("setValue", values);
|
138
137
|
});
|
139
138
|
}
|
140
|
-
});
|
@@ -12,9 +12,14 @@
|
|
12
12
|
//= require 'flot/jquery.flot.browser.js'
|
13
13
|
//= require 'flot/jquery.flot.saturated.js'
|
14
14
|
//= require 'flot/jquery.flot.drawSeries.js'
|
15
|
+
//= require 'flot/jquery.event.drag.js'
|
15
16
|
//= require 'flot/jquery.flot.hover.js'
|
16
17
|
//= require 'flot/jquery.flot.uiConstants.js'
|
17
18
|
//= require 'flot/jquery.flot.selection.js'
|
18
19
|
//= require 'bootstrap-slider'
|
19
20
|
|
20
|
-
|
21
|
+
// Ensure that range_limit_shared is loaded first
|
22
|
+
//= require 'blacklight_range_limit/range_limit_shared'
|
23
|
+
//= require 'blacklight_range_limit/range_limit_plotting'
|
24
|
+
//= require 'blacklight_range_limit/range_limit_slider'
|
25
|
+
//= require 'blacklight_range_limit/range_limit_distro_facets'
|
@@ -14,7 +14,7 @@ module RangeLimitHelper
|
|
14
14
|
|
15
15
|
default = params["range"][solr_field][type] if params["range"] && params["range"][solr_field] && params["range"][solr_field][type]
|
16
16
|
|
17
|
-
html =
|
17
|
+
html = number_field_tag("range[#{solr_field}][#{type}]", default, :maxlength=>maxlength, :class => "form-control text-center range_#{type}")
|
18
18
|
html += label_tag("range[#{solr_field}][#{type}]", input_label, class: 'sr-only') if input_label.present?
|
19
19
|
html
|
20
20
|
end
|
@@ -24,8 +24,9 @@ Gem::Specification.new do |s|
|
|
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'
|
27
|
+
s.add_development_dependency 'solr_wrapper'
|
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'
|
31
|
+
s.add_development_dependency 'rexml' # pending https://github.com/SeleniumHQ/selenium/issues/9001
|
31
32
|
end
|
@@ -7,7 +7,9 @@ module BlacklightRangeLimit
|
|
7
7
|
# Need to tell asset pipeline to precompile the excanvas
|
8
8
|
# we use for IE.
|
9
9
|
initializer "blacklight_range_limit.assets", :after => "assets" do
|
10
|
-
|
10
|
+
if defined? Sprockets
|
11
|
+
Rails.application.config.assets.precompile += %w( flot/excanvas.min.js )
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
config.action_dispatch.rescue_responses.merge!(
|
@@ -0,0 +1,145 @@
|
|
1
|
+
// Source: https://github.com/devongovett/jquery.event.drag/blob/451d90e1a737f49f613d0966082ce67582b0afd1/drag/jquery.event.drag.js
|
2
|
+
//
|
3
|
+
// Warning! Make sure the hijack() is patch to work with any jquery version:
|
4
|
+
//
|
5
|
+
// ($.event.dispatch || $.event.handle).call( elem, event );
|
6
|
+
//
|
7
|
+
|
8
|
+
/*!
|
9
|
+
jquery.event.drag.js ~ v1.6 ~ Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
|
10
|
+
Liscensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-LICENSE.txt
|
11
|
+
*/
|
12
|
+
;(function($){ // secure $ jQuery alias
|
13
|
+
/*******************************************************************************************/
|
14
|
+
// Created: 2008-06-04 | Updated: 2009-04-21
|
15
|
+
/*******************************************************************************************/
|
16
|
+
// Events: drag, dragstart, dragend
|
17
|
+
/*******************************************************************************************/
|
18
|
+
|
19
|
+
// jquery method
|
20
|
+
$.fn.drag = function( fn1, fn2, fn3 ){
|
21
|
+
if ( fn2 ) this.bind('dragstart', fn1 ); // 2+ args
|
22
|
+
if ( fn3 ) this.bind('dragend', fn3 ); // 3 args
|
23
|
+
return !fn1 ? this.trigger('drag') // 0 args
|
24
|
+
: this.bind('drag', fn2 ? fn2 : fn1 ); // 1+ args
|
25
|
+
};
|
26
|
+
|
27
|
+
// local refs
|
28
|
+
var $event = $.event, $special = $event.special,
|
29
|
+
|
30
|
+
// special event configuration
|
31
|
+
drag = $special.drag = {
|
32
|
+
not: ':input', // don't begin to drag on event.targets that match this selector
|
33
|
+
distance: 0, // distance dragged before dragstart
|
34
|
+
which: 1, // mouse button pressed to start drag sequence
|
35
|
+
drop: false, // false to suppress drop events
|
36
|
+
dragging: false, // hold the active target element
|
37
|
+
setup: function( data ){
|
38
|
+
data = $.extend({
|
39
|
+
distance: drag.distance,
|
40
|
+
which: drag.which,
|
41
|
+
not: drag.not,
|
42
|
+
drop: drag.drop
|
43
|
+
}, data || {});
|
44
|
+
data.distance = squared( data.distance ); // x² + y² = distance²
|
45
|
+
$event.add( this, "mousedown", handler, data );
|
46
|
+
if ( this.attachEvent ) this.attachEvent("ondragstart", dontStart ); // prevent image dragging in IE...
|
47
|
+
},
|
48
|
+
teardown: function(){
|
49
|
+
$event.remove( this, "mousedown", handler );
|
50
|
+
if ( this === drag.dragging ) drag.dragging = drag.proxy = false; // deactivate element
|
51
|
+
selectable( this, true ); // enable text selection
|
52
|
+
if ( this.detachEvent ) this.detachEvent("ondragstart", dontStart ); // prevent image dragging in IE...
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
// prevent normal event binding...
|
57
|
+
$special.dragstart = $special.dragend = { setup:function(){}, teardown:function(){} };
|
58
|
+
|
59
|
+
// handle drag-releatd DOM events
|
60
|
+
function handler ( event ){
|
61
|
+
var elem = this, returned, data = event.data || {};
|
62
|
+
// mousemove or mouseup
|
63
|
+
if ( data.elem ){
|
64
|
+
// update event properties...
|
65
|
+
elem = event.dragTarget = data.elem; // drag source element
|
66
|
+
event.dragProxy = drag.proxy || elem; // proxy element or source
|
67
|
+
event.cursorOffsetX = data.pageX - data.left; // mousedown offset
|
68
|
+
event.cursorOffsetY = data.pageY - data.top; // mousedown offset
|
69
|
+
event.offsetX = event.pageX - event.cursorOffsetX; // element offset
|
70
|
+
event.offsetY = event.pageY - event.cursorOffsetY; // element offset
|
71
|
+
}
|
72
|
+
// mousedown, check some initial props to avoid the switch statement
|
73
|
+
else if ( drag.dragging || ( data.which>0 && event.which!=data.which ) ||
|
74
|
+
$( event.target ).is( data.not ) ) return;
|
75
|
+
// handle various events
|
76
|
+
switch ( event.type ){
|
77
|
+
// mousedown, left click, event.target is not restricted, init dragging
|
78
|
+
case 'mousedown':
|
79
|
+
$.extend( data, $( elem ).offset(), {
|
80
|
+
elem: elem, target: event.target,
|
81
|
+
pageX: event.pageX, pageY: event.pageY
|
82
|
+
}); // store some initial attributes
|
83
|
+
$event.add( document, "mousemove mouseup", handler, data );
|
84
|
+
selectable( elem, false ); // disable text selection
|
85
|
+
drag.dragging = null; // pending state
|
86
|
+
break; // prevents text selection in safari
|
87
|
+
// mousemove, check distance, start dragging
|
88
|
+
case !drag.dragging && 'mousemove':
|
89
|
+
if ( squared( event.pageX-data.pageX )
|
90
|
+
+ squared( event.pageY-data.pageY ) // x² + y² = distance²
|
91
|
+
< data.distance ) break; // distance tolerance not reached
|
92
|
+
event.target = data.target; // force target from "mousedown" event (fix distance issue)
|
93
|
+
returned = hijack( event, "dragstart", elem ); // trigger "dragstart", return proxy element
|
94
|
+
if ( returned !== false ){ // "dragstart" not rejected
|
95
|
+
drag.dragging = elem; // activate element
|
96
|
+
drag.proxy = event.dragProxy = $( returned || elem )[0]; // set proxy
|
97
|
+
}
|
98
|
+
// mousemove, dragging
|
99
|
+
case 'mousemove':
|
100
|
+
if ( drag.dragging ){
|
101
|
+
returned = hijack( event, "drag", elem ); // trigger "drag"
|
102
|
+
if ( data.drop && $special.drop ){ // manage drop events
|
103
|
+
$special.drop.allowed = ( returned !== false ); // prevent drop
|
104
|
+
$special.drop.handler( event ); // "dropstart", "dropend"
|
105
|
+
}
|
106
|
+
if ( returned !== false ) break; // "drag" not rejected, stop
|
107
|
+
event.type = "mouseup"; // helps "drop" handler behave
|
108
|
+
}
|
109
|
+
// mouseup, stop dragging
|
110
|
+
case 'mouseup':
|
111
|
+
$event.remove( document, "mousemove mouseup", handler ); // remove page events
|
112
|
+
if ( drag.dragging ){
|
113
|
+
if ( data.drop && $special.drop ) $special.drop.handler( event ); // "drop"
|
114
|
+
hijack( event, "dragend", elem ); // trigger "dragend"
|
115
|
+
}
|
116
|
+
selectable( elem, true ); // enable text selection
|
117
|
+
drag.dragging = drag.proxy = data.elem = false; // deactivate element
|
118
|
+
break;
|
119
|
+
}
|
120
|
+
};
|
121
|
+
|
122
|
+
// set event type to custom value, and handle it
|
123
|
+
function hijack ( event, type, elem ){
|
124
|
+
event.type = type; // force the event type
|
125
|
+
var result = ($.event.dispatch || $.event.handle).call( elem, event );
|
126
|
+
return result===false ? false : result || event.result;
|
127
|
+
};
|
128
|
+
|
129
|
+
// return the value squared
|
130
|
+
function squared ( value ){ return Math.pow( value, 2 ); };
|
131
|
+
|
132
|
+
// suppress default dragstart IE events...
|
133
|
+
function dontStart(){ return ( drag.dragging === false ); };
|
134
|
+
|
135
|
+
// toggles text selection attributes
|
136
|
+
function selectable ( elem, bool ){
|
137
|
+
if ( !elem ) return; // maybe element was removed ?
|
138
|
+
elem = elem.ownerDocument ? elem.ownerDocument : elem;
|
139
|
+
elem.unselectable = bool ? "off" : "on"; // IE
|
140
|
+
if ( elem.style ) elem.style.MozUserSelect = bool ? "" : "none"; // FF
|
141
|
+
$.event[ bool ? "remove" : "add" ]( elem, "selectstart mousedown", dontStart ); // IE/Opera
|
142
|
+
};
|
143
|
+
|
144
|
+
/*******************************************************************************************/
|
145
|
+
})( jQuery ); // confine scope
|
@@ -826,8 +826,8 @@ Licensed under the MIT license.
|
|
826
826
|
var expectedPs = s.datapoints.pointsize != null ? s.datapoints.pointsize : (s.data && s.data[0] && s.data[0].length ? s.data[0].length : 3);
|
827
827
|
if (expectedPs > 2) {
|
828
828
|
format.push({
|
829
|
-
x:
|
830
|
-
y:
|
829
|
+
x: s.bars.horizontal,
|
830
|
+
y: !s.bars.horizontal,
|
831
831
|
number: true,
|
832
832
|
required: false,
|
833
833
|
computeRange: s.yaxis.options.autoScale !== 'none',
|
@@ -1761,7 +1761,7 @@ Licensed under the MIT license.
|
|
1761
1761
|
}
|
1762
1762
|
if (axis.options.showTickLabels === 'all') {
|
1763
1763
|
var associatedSeries = series.filter(function(s) {
|
1764
|
-
return s.xaxis === axis;
|
1764
|
+
return s.bars.horizontal ? s.yaxis === axis : s.xaxis === axis;
|
1765
1765
|
}),
|
1766
1766
|
notAllBarSeries = associatedSeries.some(function(s) {
|
1767
1767
|
return !s.bars.show;
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight_range_limit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Rochkind
|
8
8
|
- Chris Beer
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blacklight
|
@@ -99,16 +99,16 @@ dependencies:
|
|
99
99
|
name: solr_wrapper
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - "
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
104
|
+
version: '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: '
|
111
|
+
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: engine_cart
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,17 +151,31 @@ dependencies:
|
|
151
151
|
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '3.0'
|
154
|
-
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: rexml
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
description:
|
155
169
|
email:
|
156
170
|
- blacklight-development@googlegroups.com
|
157
171
|
executables: []
|
158
172
|
extensions: []
|
159
173
|
extra_rdoc_files: []
|
160
174
|
files:
|
175
|
+
- ".github/workflows/ruby.yml"
|
161
176
|
- ".gitignore"
|
162
177
|
- ".rspec"
|
163
178
|
- ".solr_wrapper.yml"
|
164
|
-
- ".travis.yml"
|
165
179
|
- Gemfile
|
166
180
|
- LICENSE
|
167
181
|
- README.md
|
@@ -169,6 +183,7 @@ files:
|
|
169
183
|
- VERSION
|
170
184
|
- app/assets/javascripts/blacklight_range_limit.js
|
171
185
|
- app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js
|
186
|
+
- app/assets/javascripts/blacklight_range_limit/range_limit_plotting.js
|
172
187
|
- app/assets/javascripts/blacklight_range_limit/range_limit_shared.js
|
173
188
|
- app/assets/javascripts/blacklight_range_limit/range_limit_slider.js
|
174
189
|
- app/assets/stylesheets/blacklight_range_limit.css.scss
|
@@ -229,6 +244,7 @@ files:
|
|
229
244
|
- vendor/assets/javascripts/bootstrap-slider.js
|
230
245
|
- vendor/assets/javascripts/flot/jquery.canvaswrapper.js
|
231
246
|
- vendor/assets/javascripts/flot/jquery.colorhelpers.js
|
247
|
+
- vendor/assets/javascripts/flot/jquery.event.drag.js
|
232
248
|
- vendor/assets/javascripts/flot/jquery.flot.browser.js
|
233
249
|
- vendor/assets/javascripts/flot/jquery.flot.drawSeries.js
|
234
250
|
- vendor/assets/javascripts/flot/jquery.flot.hover.js
|
@@ -241,7 +257,7 @@ homepage: https://github.com/projectblacklight/blacklight_range_limit
|
|
241
257
|
licenses:
|
242
258
|
- Apache 2.0
|
243
259
|
metadata: {}
|
244
|
-
post_install_message:
|
260
|
+
post_install_message:
|
245
261
|
rdoc_options: []
|
246
262
|
require_paths:
|
247
263
|
- lib
|
@@ -256,8 +272,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
272
|
- !ruby/object:Gem::Version
|
257
273
|
version: '0'
|
258
274
|
requirements: []
|
259
|
-
rubygems_version: 3.
|
260
|
-
signing_key:
|
275
|
+
rubygems_version: 3.0.3
|
276
|
+
signing_key:
|
261
277
|
specification_version: 4
|
262
278
|
summary: Blacklight Range Limit plugin
|
263
279
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
dist: bionic
|
2
|
-
language: ruby
|
3
|
-
addons:
|
4
|
-
chrome: stable
|
5
|
-
before_install:
|
6
|
-
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
|
7
|
-
|
8
|
-
notifications:
|
9
|
-
email: false
|
10
|
-
|
11
|
-
matrix:
|
12
|
-
include:
|
13
|
-
- rvm: 2.6.5
|
14
|
-
env: "RAILS_VERSION=6.0.0 ENGINE_CART_RAILS_OPTIONS=\"--skip-webpack-install\""
|
15
|
-
- rvm: 2.6.5
|
16
|
-
env: "RAILS_VERSION=5.2.3"
|
17
|
-
- rvm: 2.6.5
|
18
|
-
env: "RAILS_VERSION=5.2.3 BLACKLIGHT_VERSION=7.6.0"
|
19
|
-
- rvm: 2.5.7
|
20
|
-
env: "RAILS_VERSION=5.1.7"
|
21
|
-
|
22
|
-
notifications:
|
23
|
-
irc: "irc.freenode.org#blacklight"
|
24
|
-
email:
|
25
|
-
- blacklight-commits@googlegroups.com
|
26
|
-
|
27
|
-
global_env:
|
28
|
-
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
29
|
-
|
30
|
-
jdk: oraclejdk9
|