Skip to content

Commit bf97ad0

Browse files
authored
Merge pull request #1859 from rism-ch/release-6.x
Small adaptations to make BL 6 work with Jquery 3
2 parents 1213f2c + 998f36d commit bf97ad0

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

app/assets/javascripts/blacklight/checkbox_submit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
var unique_id = form.attr("data-doc-id") || Math.random();
5050
// if form is currently using method delete to change state,
5151
// then checkbox is currently checked
52-
var checked = (form.find("input[name=_method][value=delete]").size() != 0);
52+
var checked = (form.find("input[name=_method][value=delete]").length != 0);
5353

5454
var checkbox = $('<input type="checkbox">')
5555
.addClass( options.css_class )

app/assets/javascripts/blacklight/core.js

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,22 @@ Blacklight = function() {
99
for(var i = 0; i < buffer.length; i++) {
1010
buffer[i].call();
1111
}
12-
},
13-
14-
listeners: function () {
15-
var listeners = [];
16-
if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
17-
// Turbolinks 5
18-
if (Turbolinks.BrowserAdapter) {
19-
listeners.push('turbolinks:load');
20-
} else {
21-
// Turbolinks < 5
22-
listeners.push('page:load', 'ready');
23-
}
24-
} else {
25-
listeners.push('ready');
26-
}
27-
28-
return listeners.join(' ');
2912
}
3013
};
3114
}();
3215

3316
// turbolinks triggers page:load events on page transition
34-
// If app isn't using turbolinks, this event will never be triggered, no prob.
35-
$(document).on(Blacklight.listeners(), function() {
36-
Blacklight.activate();
37-
});
38-
39-
17+
// If app isn't using turbolinks, this event will never be triggered, no prob.
18+
// $(document).on('ready') is deprecated in JQuery 1.8
19+
if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
20+
// Turbolinks 5
21+
if (Turbolinks.BrowserAdapter) {
22+
$(document).on('turbolinks:load', function() { Blacklight.activate(); });
23+
} else {
24+
// Turbolinks < 5
25+
$(document).on('page:load', function() { Blacklight.activate(); });
26+
$(document).ready(function() { Blacklight.activate(); });
27+
}
28+
} else {
29+
$(document).ready(function() { Blacklight.activate(); });
30+
}

0 commit comments

Comments
 (0)