This repository has been archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.php
77 lines (75 loc) · 1.83 KB
/
common.php
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
<style>
.facet_loading.hide,
.dropdown dt a span {
display: none !important
}
.hidden-visually, .recordNumber {
position: absolute;
display: block !important;
width: 0;
height: 0;
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
}
.offscreen {
display: none !important
}
select {
visibility: visible !important
}
.autodropdown {
display: inline-block;
height: auto;
width: auto;
border: 1px solid red;
padding-right: 1em;
background: white;
position: relative;
z-index: 1000;
}
.autodropdown div,
.autodropdown a {
display: block;
}
.autodropdown a {
height: 0;
overflow: hidden;
}
.autodropdown:hover a,
.autodropdown a:hover {
height: auto;
}
</style>
<script>
$(function() {
$('.jumpMenu').each(function() {
function findLabel(elem) {
return $('label[for=' + elem.attr('id') + ']');
}
var parentTitle = findLabel($(this)).text()
var div = $('<div class="autodropdown" />');
var selected = $('<div class="selected" aria-role="presentation"></div>');
selected.append($(this).find('option:selected').text());
div.append(selected);
var list = $('<ul/>');
div.append(list);
$(this).find('option').each(function() {
console.log($(this).text());
var link = $('<a />');
var text = '<span class="hidden-visually">' + parentTitle + ': </span>' + $(this).text();
if($(this).is(':selected')) {
text = text + '<span class="hidden-visually"> (valittu)</span>';
}
link.html(text);
link.attr('href', $(this).attr('value'));
var option = $('<li/>');
option.append(link);
list.append(option)
});
$(this).parent().append(div);
$(this).hide();
});
})
</script>