forked from EOSC-EDMI/eosc-edmi.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
107 lines (86 loc) · 3.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import $ from 'jquery';
import "materialize-css";
import listjs from "list.js"
const CROSSWALK_PAGE = '#crosswalk-page';
const PROPERTIES_PAGE = '#properties-page';
$(function () {
$('.button-collapse').sideNav();
$('.parallax').parallax();
$('.collapsible').collapsible();
$('.carousel.carousel-slider').carousel({
fullWidth: true
});
$('.materialboxed').materialbox();
$('.scrollspy').scrollSpy();
$('.tap-target').tapTarget('open');
if (localStorage.getItem('cookieconsent') === 'true') {
$('#cookies').hide()
}
if ( $(CROSSWALK_PAGE).length ) {
datasetPageFiltering();
}
if ( $(PROPERTIES_PAGE).length ) {
propertiesPageFiltering();
}
}); // end of document ready
function propertiesPageFiltering() {
let options = {
valueNames: ['name', 'functional', 'operational', 'marginality']
};
var propertyList = new listjs('properties-table', options);
$('#filter-minimum').click(function () {
propertyList.filter(function (item) {
if (item.values().marginality == "minimum") {
return true;
} else {
return false;
}
});
return false;
});
$('#filter-recommended').click(function () {
propertyList.filter(function (item) {
if (item.values().marginality == "recommended") {
return true;
} else {
return false;
}
});
return false;
});
$('#filter-optional').click(function () {
propertyList.filter(function (item) {
if (item.values().marginality == "optional") {
return true;
} else {
return false;
}
});
return false;
});
$('#filter-none').click(function () {
propertyList.filter();
return false;
});
}
function datasetPageFiltering() {
var filterCheckboxes = $('#resources-search input[type="checkbox"]');
filterCheckboxes.on('change', function () {
var selectedFilters = [];
filterCheckboxes.filter(':checked').each(function () {
selectedFilters.push(this.value);
});
if (selectedFilters.length <= 0) {
$( CROSSWALK_PAGE + ' .resource').removeClass("hidden").addClass("visible");
return
}
// create a collection containing all of the filterable elements
var filteredResults = $( CROSSWALK_PAGE + ' .resource');
var notCheckedStandards = $( CROSSWALK_PAGE + ' .resource');
filteredResults = filteredResults.filter((pos, resource) =>
selectedFilters.includes(resource.getAttribute('data-id')));
notCheckedStandards = notCheckedStandards.filter((pos, resource) => $.inArray(resource, filteredResults) === -1);
notCheckedStandards.removeClass("visible").addClass("hidden");
$( CROSSWALK_PAGE + ' .resource').filter(filteredResults).removeClass("hidden").addClass("visible");
});
};