aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/lib/oer.js
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-10-18 08:13:54 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2024-10-18 08:13:54 +0000
commit26f29497255d3c2097ad66edd672170c5ea27501 (patch)
tree543959a07c1a76cb079e9deff3735a9446b6070f /resources/assets/javascripts/lib/oer.js
parent0feb5a50fd09a68d5188f5f8e28ec97b5ae26c87 (diff)
fix oer search difficulty level filter, fixes #2429
Closes #2429 Merge request studip/studip!3514
Diffstat (limited to 'resources/assets/javascripts/lib/oer.js')
-rw-r--r--resources/assets/javascripts/lib/oer.js27
1 files changed, 12 insertions, 15 deletions
diff --git a/resources/assets/javascripts/lib/oer.js b/resources/assets/javascripts/lib/oer.js
index 17f0186..704d5ba 100644
--- a/resources/assets/javascripts/lib/oer.js
+++ b/resources/assets/javascripts/lib/oer.js
@@ -66,7 +66,7 @@ const OER = {
clearAllFilters: function (keep_results) {
this.clearCategory();
this.clearDifficulty();
- if (this.searchtext != '') {
+ if (this.searchtext.length !== 0) {
this.searchtext = '';
}
$(".oer_search input[name=search]").val('');
@@ -75,10 +75,9 @@ const OER = {
}
},
clearDifficulty: function () {
- if ((this.difficulty[0] != 1) && (this.difficulty[1] != 12)) {
- this.difficulty = [1, 12];
- }
- jQuery("#difficulty_slider").slider("values", this.difficulty);
+ this.difficulty[0] = 1;
+ this.difficulty[1] = 12;
+ jQuery('#difficulty_slider').slider('values', this.difficulty);
},
clearCategory: function () {
if (this.category != null) {
@@ -201,7 +200,7 @@ const OER = {
}
}
},
- mounted: function () {
+ mounted() {
this.results = $(this.$el).data('searchresults');
if (this.results !== false) {
$("#new_ones").hide();
@@ -209,8 +208,14 @@ const OER = {
if ($(this.$el).data('filteredcategory')) {
this.category = $(this.$el).data('filteredcategory');
}
+
+ document.addEventListener('click', (event) => {
+ if (event.closest('.searchform') === null) {
+ this.hideFilterPanel();
+ }
+ })
},
- updated: function () {
+ updated() {
this.$nextTick(function () {
if (!jQuery("#difficulty_slider.ui-slider").length) { //to prevent an endless loop
let v = this;
@@ -228,14 +233,6 @@ const OER = {
}
});
});
-
-
- jQuery(document).on("click", function (evnt) {
- if (!jQuery(evnt.target).is(".searchform *") && STUDIP.OER.Search) {
- STUDIP.OER.Search.hideFilterPanel();
- }
- });
-
}
};