blacklight 7.0.1 → 7.1.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +30 -49
- data/.travis.yml +4 -4
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +51 -65
- data/app/assets/stylesheets/blacklight/_pagination.scss +6 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +1 -0
- data/app/controllers/concerns/blacklight/catalog.rb +2 -9
- data/app/controllers/concerns/blacklight/facet.rb +7 -2
- data/app/controllers/concerns/blacklight/searchable.rb +17 -0
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +12 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +2 -2
- data/app/models/concerns/blacklight/document/email.rb +4 -4
- data/app/models/concerns/blacklight/document/sms.rb +2 -2
- data/app/models/search.rb +1 -1
- data/app/services/blacklight/search_service.rb +4 -3
- data/app/views/catalog/_facet_group.html.erb +19 -0
- data/app/views/catalog/_facets.html.erb +3 -18
- data/app/views/catalog/index.atom.builder +14 -13
- data/app/views/catalog/index.rss.builder +1 -1
- data/app/views/shared/_flash_msg.html.erb +5 -3
- data/blacklight.gemspec +2 -3
- data/lib/blacklight/configuration.rb +2 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +2 -2
- data/lib/generators/blacklight/assets_generator.rb +0 -1
- data/lib/generators/blacklight/install_generator.rb +0 -8
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +1 -1
- data/package-lock.json +2210 -1612
- data/package.json +5 -4
- data/spec/controllers/bookmarks_controller_spec.rb +4 -0
- data/spec/features/search_formats_spec.rb +3 -4
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +5 -0
- data/spec/helpers/catalog_helper_spec.rb +11 -2
- data/spec/services/blacklight/search_service_spec.rb +8 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/views/catalog/_facets.html.erb_spec.rb +30 -7
- metadata +12 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fe756dbe6e6b38431044bba1b30657153080d460efc11c93b834292a90997dc
|
4
|
+
data.tar.gz: 458c1152d21f9a2efde59f4ac97f6ceb569ccd7eeb1916d33563c95492f76ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163e004de0439fc7d94c0beea0bf32f946987730c683e737f5dd4ee99914eaf9493f4b7d7af966101ddadb08dd2b5f905973f2e959677da566261024d50fe391
|
7
|
+
data.tar.gz: 9e49bb0e02d04074076f24c05be20d03c58803f12aea81faa80fa69cfe9ab9d7a1d2f82d44ab3fb6928cfd56284747a3449de53b299113f4cf540c78e0ab24fa
|
data/.rubocop_todo.yml
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2019-01-18 23:13:39 -0600 using RuboCop version 0.63.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 4
|
10
|
+
# Cop supports --auto-correct.
|
10
11
|
Capybara/CurrentPathExpectation:
|
11
12
|
Exclude:
|
12
13
|
- 'spec/features/alternate_controller_spec.rb'
|
@@ -126,12 +127,11 @@ Layout/SpaceInsideParens:
|
|
126
127
|
- 'app/views/catalog/_document.rss.builder'
|
127
128
|
- 'app/views/catalog/index.atom.builder'
|
128
129
|
|
129
|
-
# Offense count:
|
130
|
+
# Offense count: 13
|
130
131
|
# Cop supports --auto-correct.
|
131
132
|
# Configuration parameters: AllowInHeredoc.
|
132
133
|
Layout/TrailingWhitespace:
|
133
134
|
Exclude:
|
134
|
-
- 'app/views/catalog/_document.atom.builder'
|
135
135
|
- 'app/views/catalog/_document.rss.builder'
|
136
136
|
- 'app/views/catalog/index.atom.builder'
|
137
137
|
|
@@ -151,7 +151,7 @@ Lint/AmbiguousOperator:
|
|
151
151
|
- 'spec/models/blacklight/solr/search_builder_spec.rb'
|
152
152
|
- 'spec/services/blacklight/search_service_spec.rb'
|
153
153
|
|
154
|
-
# Offense count:
|
154
|
+
# Offense count: 55
|
155
155
|
Lint/AmbiguousRegexpLiteral:
|
156
156
|
Exclude:
|
157
157
|
- 'spec/controllers/catalog_controller_spec.rb'
|
@@ -211,7 +211,7 @@ Metrics/ClassLength:
|
|
211
211
|
Metrics/CyclomaticComplexity:
|
212
212
|
Max: 12
|
213
213
|
|
214
|
-
# Offense count:
|
214
|
+
# Offense count: 47
|
215
215
|
# Configuration parameters: CountComments, ExcludedMethods.
|
216
216
|
Metrics/MethodLength:
|
217
217
|
Max: 35
|
@@ -271,11 +271,10 @@ Performance/TimesMap:
|
|
271
271
|
Exclude:
|
272
272
|
- 'spec/views/catalog/index.atom.builder_spec.rb'
|
273
273
|
|
274
|
-
# Offense count:
|
274
|
+
# Offense count: 2
|
275
275
|
Performance/UnfreezeString:
|
276
276
|
Exclude:
|
277
277
|
- 'lib/generators/blacklight/install_generator.rb'
|
278
|
-
- 'spec/helpers/blacklight/url_helper_behavior_spec.rb'
|
279
278
|
- 'spec/helpers/blacklight_helper_spec.rb'
|
280
279
|
|
281
280
|
# Offense count: 9
|
@@ -309,7 +308,7 @@ RSpec/EmptyExampleGroup:
|
|
309
308
|
Exclude:
|
310
309
|
- 'spec/models/blacklight/solr/search_builder_spec.rb'
|
311
310
|
|
312
|
-
# Offense count:
|
311
|
+
# Offense count: 127
|
313
312
|
# Configuration parameters: Max.
|
314
313
|
RSpec/ExampleLength:
|
315
314
|
Enabled: false
|
@@ -352,18 +351,33 @@ RSpec/MessageChain:
|
|
352
351
|
- 'spec/presenters/blacklight/show_presenter_spec.rb'
|
353
352
|
- 'spec/views/shared/_user_util_links.html.erb_spec.rb'
|
354
353
|
|
355
|
-
# Offense count:
|
356
|
-
# Configuration parameters: .
|
354
|
+
# Offense count: 67
|
355
|
+
# Configuration parameters: EnforcedStyle.
|
357
356
|
# SupportedStyles: have_received, receive
|
358
357
|
RSpec/MessageSpies:
|
359
|
-
|
358
|
+
Exclude:
|
359
|
+
- 'spec/controllers/catalog_controller_spec.rb'
|
360
|
+
- 'spec/helpers/blacklight/configuration_helper_behavior_spec.rb'
|
361
|
+
- 'spec/helpers/blacklight/facets_helper_behavior_spec.rb'
|
362
|
+
- 'spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb'
|
363
|
+
- 'spec/helpers/blacklight/suggest_helper_behavior_spec.rb'
|
364
|
+
- 'spec/helpers/blacklight/url_helper_behavior_spec.rb'
|
365
|
+
- 'spec/helpers/blacklight_helper_spec.rb'
|
366
|
+
- 'spec/helpers/catalog_helper_spec.rb'
|
367
|
+
- 'spec/lib/blacklight/configuration/facet_field_spec.rb'
|
368
|
+
- 'spec/models/blacklight/search_builder_spec.rb'
|
369
|
+
- 'spec/models/blacklight/suggest_search_spec.rb'
|
370
|
+
- 'spec/presenters/blacklight/index_presenter_spec.rb'
|
371
|
+
- 'spec/presenters/blacklight/show_presenter_spec.rb'
|
372
|
+
- 'spec/presenters/thumbnail_presenter_spec.rb'
|
360
373
|
|
361
|
-
# Offense count:
|
374
|
+
# Offense count: 345
|
362
375
|
# Configuration parameters: AggregateFailuresByDefault.
|
363
376
|
RSpec/MultipleExpectations:
|
364
377
|
Max: 16
|
365
378
|
|
366
|
-
# Offense count:
|
379
|
+
# Offense count: 328
|
380
|
+
# Configuration parameters: IgnoreSharedExamples.
|
367
381
|
RSpec/NamedSubject:
|
368
382
|
Enabled: false
|
369
383
|
|
@@ -398,7 +412,7 @@ RSpec/SubjectStub:
|
|
398
412
|
- 'spec/lib/blacklight/search_state_spec.rb'
|
399
413
|
- 'spec/services/blacklight/search_service_spec.rb'
|
400
414
|
|
401
|
-
# Offense count:
|
415
|
+
# Offense count: 118
|
402
416
|
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
403
417
|
RSpec/VerifiedDoubles:
|
404
418
|
Enabled: false
|
@@ -408,13 +422,6 @@ RSpec/VoidExpect:
|
|
408
422
|
Exclude:
|
409
423
|
- 'spec/lib/blacklight/configuration/facet_field_spec.rb'
|
410
424
|
|
411
|
-
# Offense count: 1
|
412
|
-
# Cop supports --auto-correct.
|
413
|
-
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
|
414
|
-
Rails/Blank:
|
415
|
-
Exclude:
|
416
|
-
- 'lib/blacklight/solr/search_builder_behavior.rb'
|
417
|
-
|
418
425
|
# Offense count: 4
|
419
426
|
# Configuration parameters: EnforcedStyle.
|
420
427
|
# SupportedStyles: strict, flexible
|
@@ -422,18 +429,6 @@ Rails/Date:
|
|
422
429
|
Exclude:
|
423
430
|
- 'spec/models/search_spec.rb'
|
424
431
|
|
425
|
-
# Offense count: 13
|
426
|
-
# Cop supports --auto-correct.
|
427
|
-
# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank.
|
428
|
-
Rails/Present:
|
429
|
-
Exclude:
|
430
|
-
- 'app/controllers/concerns/blacklight/catalog.rb'
|
431
|
-
- 'app/helpers/blacklight/component_helper_behavior.rb'
|
432
|
-
- 'app/helpers/blacklight/facets_helper_behavior.rb'
|
433
|
-
- 'app/models/concerns/blacklight/document/email.rb'
|
434
|
-
- 'app/models/concerns/blacklight/document/sms.rb'
|
435
|
-
- 'lib/blacklight/solr/search_builder_behavior.rb'
|
436
|
-
|
437
432
|
# Offense count: 1
|
438
433
|
# Configuration parameters: EnforcedStyle.
|
439
434
|
# SupportedStyles: strict, flexible
|
@@ -502,12 +497,6 @@ Style/ConditionalAssignment:
|
|
502
497
|
Exclude:
|
503
498
|
- 'lib/blacklight/solr/response/spelling.rb'
|
504
499
|
|
505
|
-
# Offense count: 1
|
506
|
-
# Configuration parameters: AllowCoercion.
|
507
|
-
Style/DateTime:
|
508
|
-
Exclude:
|
509
|
-
- 'spec/models/blacklight/solr/search_builder_spec.rb'
|
510
|
-
|
511
500
|
# Offense count: 93
|
512
501
|
Style/Documentation:
|
513
502
|
Enabled: false
|
@@ -548,15 +537,7 @@ Style/GuardClause:
|
|
548
537
|
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
|
549
538
|
- 'lib/blacklight/solr/search_builder_behavior.rb'
|
550
539
|
|
551
|
-
# Offense count:
|
552
|
-
# Cop supports --auto-correct.
|
553
|
-
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
554
|
-
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
555
|
-
Style/HashSyntax:
|
556
|
-
Exclude:
|
557
|
-
- 'app/helpers/blacklight/url_helper_behavior.rb'
|
558
|
-
|
559
|
-
# Offense count: 39
|
540
|
+
# Offense count: 40
|
560
541
|
# Cop supports --auto-correct.
|
561
542
|
Style/IfUnlessModifier:
|
562
543
|
Enabled: false
|
@@ -652,7 +633,7 @@ Style/Semicolon:
|
|
652
633
|
- 'spec/models/blacklight/solr/repository_spec.rb'
|
653
634
|
- 'spec/views/catalog/_paginate_compact.html.erb_spec.rb'
|
654
635
|
|
655
|
-
# Offense count:
|
636
|
+
# Offense count: 31
|
656
637
|
# Cop supports --auto-correct.
|
657
638
|
# Configuration parameters: MinSize.
|
658
639
|
# SupportedStyles: percent, brackets
|
data/.travis.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
dist:
|
1
|
+
dist: xenial
|
2
2
|
addons:
|
3
3
|
chrome: stable
|
4
4
|
language: ruby
|
@@ -27,8 +27,8 @@ matrix:
|
|
27
27
|
fast_finish: true
|
28
28
|
|
29
29
|
before_install:
|
30
|
-
- gem
|
31
|
-
-
|
30
|
+
- gem install chromedriver-helper --no-document
|
31
|
+
- chromedriver-update 73.0.3683.68
|
32
32
|
- google-chrome-stable --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 http://localhost &
|
33
33
|
|
34
34
|
notifications:
|
@@ -41,7 +41,7 @@ global_env:
|
|
41
41
|
- ENGINE_CART_RAILS_OPTIONS='--skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-test'
|
42
42
|
- CC_TEST_REPORTER_ID=5042c7358c96b0b926088a4cda3e132fffe7a66ce8047cdb1dc6f0b4b6676b79
|
43
43
|
|
44
|
-
jdk:
|
44
|
+
jdk: openjdk11
|
45
45
|
|
46
46
|
before_script:
|
47
47
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.0.
|
1
|
+
7.1.0.alpha
|
@@ -4,15 +4,14 @@ Blacklight = function () {
|
|
4
4
|
onLoad: function (func) {
|
5
5
|
buffer.push(func);
|
6
6
|
},
|
7
|
-
|
8
7
|
activate: function () {
|
9
8
|
for (var i = 0; i < buffer.length; i++) {
|
10
9
|
buffer[i].call();
|
11
10
|
}
|
12
11
|
},
|
13
|
-
|
14
12
|
listeners: function () {
|
15
13
|
var listeners = [];
|
14
|
+
|
16
15
|
if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
|
17
16
|
// Turbolinks 5
|
18
17
|
if (Turbolinks.BrowserAdapter) {
|
@@ -28,16 +27,15 @@ Blacklight = function () {
|
|
28
27
|
return listeners;
|
29
28
|
}
|
30
29
|
};
|
31
|
-
}();
|
32
|
-
|
33
|
-
// turbolinks triggers page:load events on page transition
|
30
|
+
}(); // turbolinks triggers page:load events on page transition
|
34
31
|
// If app isn't using turbolinks, this event will never be triggered, no prob.
|
32
|
+
|
33
|
+
|
35
34
|
Blacklight.listeners().forEach(function (listener) {
|
36
35
|
document.addEventListener(listener, function () {
|
37
36
|
Blacklight.activate();
|
38
37
|
});
|
39
38
|
});
|
40
|
-
|
41
39
|
$('.no-js').removeClass('no-js').addClass('js');
|
42
40
|
/*global Bloodhound */
|
43
41
|
|
@@ -46,11 +44,12 @@ Blacklight.onLoad(function () {
|
|
46
44
|
|
47
45
|
$('[data-autocomplete-enabled="true"]').each(function () {
|
48
46
|
var $el = $(this);
|
47
|
+
|
49
48
|
if ($el.hasClass('tt-hint')) {
|
50
49
|
return;
|
51
50
|
}
|
52
|
-
var suggestUrl = $el.data().autocompletePath;
|
53
51
|
|
52
|
+
var suggestUrl = $el.data().autocompletePath;
|
54
53
|
var terms = new Bloodhound({
|
55
54
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
56
55
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
@@ -59,9 +58,7 @@ Blacklight.onLoad(function () {
|
|
59
58
|
wildcard: '%QUERY'
|
60
59
|
}
|
61
60
|
});
|
62
|
-
|
63
61
|
terms.initialize();
|
64
|
-
|
65
62
|
$el.typeahead({
|
66
63
|
hint: true,
|
67
64
|
highlight: true,
|
@@ -73,6 +70,7 @@ Blacklight.onLoad(function () {
|
|
73
70
|
});
|
74
71
|
});
|
75
72
|
});
|
73
|
+
|
76
74
|
(function ($) {
|
77
75
|
//change form submit toggle to checkbox
|
78
76
|
Blacklight.doBookmarkToggleBehavior = function () {
|
@@ -80,6 +78,7 @@ Blacklight.onLoad(function () {
|
|
80
78
|
console.warn("do_bookmark_toggle_behavior is deprecated. Use doBookmarkToggleBehavior instead.");
|
81
79
|
return Blacklight.do_bookmark_toggle_behavior();
|
82
80
|
}
|
81
|
+
|
83
82
|
$(Blacklight.doBookmarkToggleBehavior.selector).blCheckboxSubmit({
|
84
83
|
// cssClass is added to elements added, plus used for id base
|
85
84
|
cssClass: 'toggle-bookmark',
|
@@ -90,8 +89,8 @@ Blacklight.onLoad(function () {
|
|
90
89
|
}
|
91
90
|
});
|
92
91
|
};
|
93
|
-
Blacklight.doBookmarkToggleBehavior.selector = 'form.bookmark-toggle';
|
94
92
|
|
93
|
+
Blacklight.doBookmarkToggleBehavior.selector = 'form.bookmark-toggle';
|
95
94
|
Blacklight.onLoad(function () {
|
96
95
|
Blacklight.doBookmarkToggleBehavior();
|
97
96
|
});
|
@@ -126,39 +125,37 @@ Blacklight.onLoad(function () {
|
|
126
125
|
}
|
127
126
|
});
|
128
127
|
*/
|
128
|
+
|
129
|
+
|
129
130
|
(function ($) {
|
130
131
|
$.fn.blCheckboxSubmit = function (argOpts) {
|
131
132
|
this.each(function () {
|
132
133
|
var options = $.extend({}, $.fn.blCheckboxSubmit.defaults, argOpts);
|
133
|
-
|
134
134
|
var form = $(this);
|
135
|
-
form.children().hide();
|
136
|
-
//We're going to use the existing form to actually send our add/removes
|
135
|
+
form.children().hide(); //We're going to use the existing form to actually send our add/removes
|
137
136
|
//This works conveneintly because the exact same action href is used
|
138
137
|
//for both bookmarks/$doc_id. But let's take out the irrelevant parts
|
139
138
|
//of the form to avoid any future confusion.
|
140
|
-
form.find('input[type=submit]').remove();
|
141
139
|
|
142
|
-
//View needs to set data-doc-id so we know a unique value
|
140
|
+
form.find('input[type=submit]').remove(); //View needs to set data-doc-id so we know a unique value
|
143
141
|
//for making DOM id
|
144
|
-
|
145
|
-
// if form is currently using method delete to change state,
|
142
|
+
|
143
|
+
var uniqueId = form.attr('data-doc-id') || Math.random(); // if form is currently using method delete to change state,
|
146
144
|
// then checkbox is currently checked
|
147
|
-
var checked = form.find('input[name=_method][value=delete]').length != 0;
|
148
145
|
|
146
|
+
var checked = form.find('input[name=_method][value=delete]').length != 0;
|
149
147
|
var checkbox = $('<input type="checkbox">').addClass(options.cssClass).attr('id', options.cssClass + '_' + uniqueId);
|
150
148
|
var label = $('<label>').addClass(options.cssClass).attr('for', options.cssClass + '_' + uniqueId).attr('title', form.attr('title') || '');
|
151
149
|
var span = $('<span>');
|
152
|
-
|
153
150
|
label.append(checkbox);
|
154
151
|
label.append(' ');
|
155
152
|
label.append(span);
|
156
|
-
|
157
153
|
var checkboxDiv = $('<div class="checkbox" />').addClass(options.cssClass).append(label);
|
158
154
|
|
159
155
|
function updateStateFor(state) {
|
160
156
|
checkbox.prop('checked', state);
|
161
157
|
label.toggleClass('checked', state);
|
158
|
+
|
162
159
|
if (state) {
|
163
160
|
//Set the Rails hidden field that fakes an HTTP verb
|
164
161
|
//properly for current state action.
|
@@ -172,12 +169,10 @@ Blacklight.onLoad(function () {
|
|
172
169
|
|
173
170
|
form.append(checkboxDiv);
|
174
171
|
updateStateFor(checked);
|
175
|
-
|
176
172
|
checkbox.click(function () {
|
177
173
|
span.text(form.attr('data-inprogress'));
|
178
174
|
label.attr('disabled', 'disabled');
|
179
175
|
checkbox.attr('disabled', 'disabled');
|
180
|
-
|
181
176
|
$.ajax({
|
182
177
|
url: form.attr('action'),
|
183
178
|
dataType: 'json',
|
@@ -204,11 +199,10 @@ Blacklight.onLoad(function () {
|
|
204
199
|
}
|
205
200
|
}
|
206
201
|
});
|
207
|
-
|
208
202
|
return false;
|
209
203
|
}); //checkbox.click
|
210
|
-
|
211
204
|
}); //this.each
|
205
|
+
|
212
206
|
return this;
|
213
207
|
};
|
214
208
|
|
@@ -219,8 +213,10 @@ Blacklight.onLoad(function () {
|
|
219
213
|
alert("Error");
|
220
214
|
},
|
221
215
|
success: function () {} //callback
|
216
|
+
|
222
217
|
};
|
223
218
|
})(jQuery);
|
219
|
+
|
224
220
|
(function ($) {
|
225
221
|
Blacklight.onLoad(function () {
|
226
222
|
// when clicking on a link that toggles the collapsing behavior, don't do anything
|
@@ -232,6 +228,7 @@ Blacklight.onLoad(function () {
|
|
232
228
|
})(jQuery);
|
233
229
|
/*global Blacklight */
|
234
230
|
|
231
|
+
|
235
232
|
(function ($) {
|
236
233
|
'use strict';
|
237
234
|
|
@@ -327,37 +324,33 @@ Blacklight.onLoad(function () {
|
|
327
324
|
|
328
325
|
The data-blacklight-modal=close behavior is implemented with this event, see for example.
|
329
326
|
*/
|
330
|
-
|
331
327
|
// We keep all our data in Blacklight.modal object.
|
332
328
|
// Create lazily if someone else created first.
|
329
|
+
|
330
|
+
|
333
331
|
if (Blacklight.modal === undefined) {
|
334
332
|
Blacklight.modal = {};
|
335
|
-
}
|
333
|
+
} // a Bootstrap modal div that should be already on the page hidden
|
336
334
|
|
337
|
-
// a Bootstrap modal div that should be already on the page hidden
|
338
|
-
Blacklight.modal.modalSelector = '#blacklight-modal';
|
339
335
|
|
340
|
-
// Trigger selectors identify forms or hyperlinks that should open
|
336
|
+
Blacklight.modal.modalSelector = '#blacklight-modal'; // Trigger selectors identify forms or hyperlinks that should open
|
341
337
|
// inside a modal dialog.
|
342
|
-
Blacklight.modal.triggerLinkSelector = 'a[data-blacklight-modal~=trigger]';
|
343
|
-
Blacklight.modal.triggerFormSelector = 'form[data-blacklight-modal~=trigger]';
|
344
338
|
|
345
|
-
|
339
|
+
Blacklight.modal.triggerLinkSelector = 'a[data-blacklight-modal~=trigger]';
|
340
|
+
Blacklight.modal.triggerFormSelector = 'form[data-blacklight-modal~=trigger]'; // preserve selectors identify forms or hyperlinks that, if activated already
|
346
341
|
// inside a modal dialog, should have destinations remain inside the modal -- but
|
347
342
|
// won't trigger a modal if not already in one.
|
348
343
|
//
|
349
344
|
// No need to repeat selectors from trigger selectors, those will already
|
350
345
|
// be preserved. MUST be manually prefixed with the modal selector,
|
351
346
|
// so they only apply to things inside a modal.
|
352
|
-
Blacklight.modal.preserveLinkSelector = Blacklight.modal.modalSelector + ' a[data-blacklight-modal~=preserve]';
|
353
347
|
|
348
|
+
Blacklight.modal.preserveLinkSelector = Blacklight.modal.modalSelector + ' a[data-blacklight-modal~=preserve]';
|
354
349
|
Blacklight.modal.containerSelector = '[data-blacklight-modal~=container]';
|
355
|
-
|
356
|
-
Blacklight.modal.modalCloseSelector = '[data-blacklight-modal~=close]';
|
357
|
-
|
358
|
-
// Called on fatal failure of ajax load, function returns content
|
350
|
+
Blacklight.modal.modalCloseSelector = '[data-blacklight-modal~=close]'; // Called on fatal failure of ajax load, function returns content
|
359
351
|
// to show to user in modal. Right now called only for extreme
|
360
352
|
// network errors.
|
353
|
+
|
361
354
|
Blacklight.modal.onFailure = function (data) {
|
362
355
|
var contents = '<div class="modal-header">' + '<div class="modal-title">Network Error</div>' + '<button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="Close">' + ' <span aria-hidden="true">×</span>' + '</button>';
|
363
356
|
$(Blacklight.modal.modalSelector).find('.modal-content').html(contents);
|
@@ -369,24 +362,22 @@ Blacklight.modal.receiveAjax = function (contents) {
|
|
369
362
|
// important we don't execute script tags, we shouldn't.
|
370
363
|
// code modelled off of JQuery ajax.load. https://github.com/jquery/jquery/blob/master/src/ajax/load.js?source=c#L62
|
371
364
|
var container = $('<div>').append(jQuery.parseHTML(contents)).find(Blacklight.modal.containerSelector).first();
|
365
|
+
|
372
366
|
if (container.length !== 0) {
|
373
367
|
contents = container.html();
|
374
368
|
}
|
375
369
|
|
376
|
-
$(Blacklight.modal.modalSelector).find('.modal-content').html(contents);
|
370
|
+
$(Blacklight.modal.modalSelector).find('.modal-content').html(contents); // send custom event with the modal dialog div as the target
|
377
371
|
|
378
|
-
// send custom event with the modal dialog div as the target
|
379
372
|
var e = $.Event('loaded.blacklight.blacklight-modal');
|
380
|
-
$(Blacklight.modal.modalSelector).trigger(e);
|
381
|
-
// if they did preventDefault, don't show the dialog
|
382
|
-
if (e.isDefaultPrevented()) return;
|
373
|
+
$(Blacklight.modal.modalSelector).trigger(e); // if they did preventDefault, don't show the dialog
|
383
374
|
|
375
|
+
if (e.isDefaultPrevented()) return;
|
384
376
|
$(Blacklight.modal.modalSelector).modal('show');
|
385
377
|
};
|
386
378
|
|
387
379
|
Blacklight.modal.modalAjaxLinkClick = function (e) {
|
388
380
|
e.preventDefault();
|
389
|
-
|
390
381
|
$.ajax({
|
391
382
|
url: $(this).attr('href')
|
392
383
|
}).fail(Blacklight.modal.onFailure).done(Blacklight.modal.receiveAjax);
|
@@ -394,11 +385,11 @@ Blacklight.modal.modalAjaxLinkClick = function (e) {
|
|
394
385
|
|
395
386
|
Blacklight.modal.modalAjaxFormSubmit = function (e) {
|
396
387
|
e.preventDefault();
|
397
|
-
|
398
388
|
$.ajax({
|
399
389
|
url: $(this).attr('action'),
|
400
390
|
data: $(this).serialize(),
|
401
391
|
type: $(this).attr('method') // POST
|
392
|
+
|
402
393
|
}).fail(Blacklight.modal.onFailure).done(Blacklight.modal.receiveAjax);
|
403
394
|
};
|
404
395
|
|
@@ -408,34 +399,29 @@ Blacklight.modal.setupModal = function () {
|
|
408
399
|
// setup.
|
409
400
|
var e = $.Event('setup.blacklight.blacklight-modal');
|
410
401
|
$('body').trigger(e);
|
411
|
-
if (e.isDefaultPrevented()) return;
|
412
|
-
|
413
|
-
// Register both trigger and preserve selectors in ONE event handler, combining
|
402
|
+
if (e.isDefaultPrevented()) return; // Register both trigger and preserve selectors in ONE event handler, combining
|
414
403
|
// into one selector with a comma, so if something matches BOTH selectors, it
|
415
404
|
// still only gets the event handler called once.
|
416
|
-
$('body').on('click', Blacklight.modal.triggerLinkSelector + ', ' + Blacklight.modal.preserveLinkSelector, Blacklight.modal.modalAjaxLinkClick);
|
417
|
-
$('body').on('submit', Blacklight.modal.triggerFormSelector + ', ' + Blacklight.modal.preserveFormSelector, Blacklight.modal.modalAjaxFormSubmit);
|
418
405
|
|
419
|
-
|
420
|
-
$('body').on('
|
406
|
+
$('body').on('click', Blacklight.modal.triggerLinkSelector + ', ' + Blacklight.modal.preserveLinkSelector, Blacklight.modal.modalAjaxLinkClick);
|
407
|
+
$('body').on('submit', Blacklight.modal.triggerFormSelector + ', ' + Blacklight.modal.preserveFormSelector, Blacklight.modal.modalAjaxFormSubmit); // Catch our own custom loaded event to implement data-blacklight-modal=closed
|
421
408
|
|
422
|
-
// we support doing data-dismiss=modal on a <a> with a href for non-ajax
|
409
|
+
$('body').on('loaded.blacklight.blacklight-modal', Blacklight.modal.checkCloseModal); // we support doing data-dismiss=modal on a <a> with a href for non-ajax
|
423
410
|
// use, we need to suppress following the a's href that's there for
|
424
411
|
// non-JS contexts.
|
412
|
+
|
425
413
|
$('body').on('click', Blacklight.modal.modalSelector + ' a[data-dismiss~=modal]', function (e) {
|
426
414
|
e.preventDefault();
|
427
415
|
});
|
428
|
-
};
|
429
|
-
|
430
|
-
// A function used as an event handler on loaded.blacklight.blacklight-modal
|
416
|
+
}; // A function used as an event handler on loaded.blacklight.blacklight-modal
|
431
417
|
// to catch contained data-blacklight-modal=closed directions
|
418
|
+
|
419
|
+
|
432
420
|
Blacklight.modal.checkCloseModal = function (event) {
|
433
421
|
if ($(event.target).find(Blacklight.modal.modalCloseSelector).length) {
|
434
422
|
var modalFlashes = $(this).find('.flash_messages');
|
435
|
-
|
436
423
|
$(event.target).modal('hide');
|
437
424
|
event.preventDefault();
|
438
|
-
|
439
425
|
var mainFlashes = $('#main-flashes');
|
440
426
|
mainFlashes.append(modalFlashes);
|
441
427
|
modalFlashes.fadeIn(500);
|
@@ -445,25 +431,27 @@ Blacklight.modal.checkCloseModal = function (event) {
|
|
445
431
|
Blacklight.onLoad(function () {
|
446
432
|
Blacklight.modal.setupModal();
|
447
433
|
});
|
434
|
+
|
448
435
|
(function ($) {
|
449
436
|
Blacklight.doSearchContextBehavior = function () {
|
450
437
|
if (typeof Blacklight.do_search_context_behavior == 'function') {
|
451
438
|
console.warn("do_search_context_behavior is deprecated. Use doSearchContextBehavior instead.");
|
452
439
|
return Blacklight.do_search_context_behavior();
|
453
440
|
}
|
454
|
-
$('a[data-context-href]').on('click.search-context', Blacklight.handleSearchContextMethod);
|
455
|
-
};
|
456
441
|
|
457
|
-
|
442
|
+
$('a[data-context-href]').on('click.search-context', Blacklight.handleSearchContextMethod);
|
443
|
+
}; // this is the $.rails.handleMethod with a couple adjustments, described inline:
|
458
444
|
// first, we're attaching this directly to the event handler, so we can check for meta-keys
|
445
|
+
|
446
|
+
|
459
447
|
Blacklight.handleSearchContextMethod = function (event) {
|
460
448
|
if (typeof Blacklight.handle_search_context_method == 'function') {
|
461
449
|
console.warn("handle_search_context_method is deprecated. Use handleSearchContextMethod instead.");
|
462
450
|
return Blacklight.handle_search_context_method(event);
|
463
451
|
}
|
464
|
-
var link = $(this);
|
465
452
|
|
466
|
-
// instead of using the normal href, we need to use the context href instead
|
453
|
+
var link = $(this); // instead of using the normal href, we need to use the context href instead
|
454
|
+
|
467
455
|
var href = link.data('context-href'),
|
468
456
|
method = 'post',
|
469
457
|
target = link.attr('target'),
|
@@ -471,9 +459,8 @@ Blacklight.onLoad(function () {
|
|
471
459
|
csrfParam = $('meta[name=csrf-param]').attr('content'),
|
472
460
|
form = $('<form method="post" action="' + href + '"></form>'),
|
473
461
|
metadataInput = '<input name="_method" value="' + method + '" type="hidden" />',
|
474
|
-
redirectHref = '<input name="redirect" value="' + link.attr('href') + '" type="hidden" />';
|
462
|
+
redirectHref = '<input name="redirect" value="' + link.attr('href') + '" type="hidden" />'; // check for meta keys.. if set, we should open in a new tab
|
475
463
|
|
476
|
-
// check for meta keys.. if set, we should open in a new tab
|
477
464
|
if (event.metaKey || event.ctrlKey) {
|
478
465
|
target = '_blank';
|
479
466
|
}
|
@@ -488,7 +475,6 @@ Blacklight.onLoad(function () {
|
|
488
475
|
|
489
476
|
form.hide().append(metadataInput).append(redirectHref).appendTo('body');
|
490
477
|
form.submit();
|
491
|
-
|
492
478
|
return false;
|
493
479
|
};
|
494
480
|
|