-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
74 lines (67 loc) · 2.5 KB
/
script.js
File metadata and controls
74 lines (67 loc) · 2.5 KB
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
/**
* Script for handling of opening translation dropdowns.
*
* SINCE v1.3
*/
function mls_toggleLangDropdown(event, dropDownName) {
//Pass in your dropdownName which is the dropdown
var dropDownHandler = document.getElementById(dropDownName);
dropDownHandler.classList.toggle("show-dropdown");
// Get the trigger element of the dropdown
var menuHandler = event.currentTarget;
if (dropDownHandler.classList.contains("show-dropdown")) {
//Attach only when the dropdown is active,
//to ensure onclick isn't called always
document.addEventListener("click", function(docEvent) {
documentHandler(docEvent, menuHandler)
});
} else {
dropDownHandler.classList.toggle("show-dropdown");
// If is closed, remove the handler
document.removeEventListener("click", documentHandler);
}
function documentHandler(event, menuHandler) {
if (menuHandler.contains(event.target)) {
dropDownHandler.classList.add("show-dropdown");
} else {
dropDownHandler.classList.remove("show-dropdown");
}
}
}
/** End of added script */
/**
* Script for handling of opening relation dropdowns.
*
* SINCE v1.4
*/
function mls_toggleRelationDropdowns(event, dropDownName, locationCase) {
//Pass in your dropdownName which is the dropdown
var dropDownHandler = document.getElementById(dropDownName);
if(locationCase == "book-info"){
var dropDownClass = "dropdown-relations-content-bookinfo";
} else if (locationCase == "chapter") {
var dropDownClass = "dropdown-relations-content-chapters";
}
dropDownHandler.classList.toggle(dropDownName);
// Get the trigger element of the dropdown
var menuHandler = event.currentTarget;
if (dropDownHandler.classList.contains(dropDownName)) {
//Attach only when the dropdown is active,
//to ensure onclick isn't called always
document.addEventListener("click", function(docEvent) {
documentHandler(docEvent, menuHandler)
});
} else {
dropDownHandler.classList.toggle(dropDownName);
// If is closed, remove the handler
document.removeEventListener("click", documentHandler);
}
function documentHandler(event, menuHandler) {
if (menuHandler.contains(event.target)) {
dropDownHandler.classList.add(dropDownClass, dropDownName );
} else {
dropDownHandler.classList.remove(dropDownClass, dropDownName );
}
}
}
/** End of added script */