-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowseLibrary.js
98 lines (74 loc) · 3.2 KB
/
browseLibrary.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
var expandCheckBoxes = document.querySelectorAll('.expand-checkbox');
// var row = document.getElementsByClassName('container');
// var expandCheckBoxes = document.getElementById('expand1');
// var row = document.getElementById('container_2');
let currentExpanded = null;
expandCheckBoxes.forEach(checkBox => {
checkBox.addEventListener('change', function () {
const currentCard = this.parentElement;
const nextRow = currentCard.parentElement.nextElementSibling;
if (this.checked) {
if (currentExpanded && currentExpanded !== this) {
currentExpanded.checked = false;
const prevCard = currentExpanded.parentElement;
const prevRow = prevCard.parentElement.nextElementSibling;
if (prevRow) {
prevRow.classList.remove('row-moved-down');
}
}
if (nextRow) {
nextRow.classList.add('row-moved-down');
window.scrollBy(0, 375, 'smooth');
}
currentExpanded = this;
} else {
if (nextRow) {
nextRow.classList.remove('row-moved-down');
}
currentExpanded = null;
}
});
});
const cards = document.querySelectorAll('.card');
expandCheckBoxes.forEach(checkBox => {
checkBox.addEventListener('change', function () {
if (this.checked) {
var expandableContent = this.nextElementSibling.nextElementSibling;
var index = Array.from(cards).indexOf(this.parentElement);
var parent = this.parentElement;
if(index>3){
index = index%4;
}
console.log('index: ' +index)
expandableContent.style.left= (parent.style.width-index*350) + 'px';
}
});
});
expandCheckBoxes.forEach(checkBox => {
checkBox.addEventListener('change', function () {
/* if (this.checked) {
var currentCard = this.parentElement;
var expandableContent = this.nextElementSibling.nextElementSibling;
console.log(expandableContent);
var firstCard = cards[0].getBoundingClientRect();
console.log(firstCard);
const index = Array.from(cards).indexOf(currentCard);
if (expandableContent instanceof Node && index!==0) {
document.body.appendChild(expandableContent);
expandableContent.style.position = 'absolute';
expandableContent.style.diplay='block';
expandableContent.style.border='2px solid black';
// expandableContent.style.left = `${firstCard.left}px`;
expandableContent.style.left = '50px';
console.log('******************');
console.log(expandableContent.style.left);
// expandableContent.style.top = `${firstCard.bottom}px`;
expandableContent.style.top = '500px';
console.log(expandableContent.style.top);
console.log(cards[0]);
} else {
console.log("Expandable content is not a valid Node element.");
}
}*/
});
});