-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresponsive.js
102 lines (94 loc) · 3.38 KB
/
responsive.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
function updatePaddingClass() {
const elements = document.querySelectorAll('#price-card');
const pricecards = document.querySelectorAll('#price-cards');
const attributecard = document.querySelectorAll('#attribute-card');
const attributecards = document.querySelectorAll('#attribute-cards');
const tableempty = document.querySelectorAll('#table-empty');
const tablenotempty = document.querySelectorAll('#table-notempty1');
const tablenotempty2 = document.querySelectorAll('#table-notempty2');
const tablenotempty3 = document.querySelectorAll('#table-notempty3');
const tablename = document.querySelectorAll('#table-name');
elements.forEach(element => {
if (window.innerWidth >= 768 && window.innerWidth <= 1024) {
element.classList.remove('padding-xl');
element.classList.add('padding-m');
}
else if (window.innerWidth <= 768) {
element.classList.remove('padding-xl');
element.classList.add('padding-m');
element.style.width = '100%';
}
else {
element.classList.remove('padding-m');
element.classList.add('padding-xl');
}
});
pricecards.forEach(card => {
if (window.innerWidth <= 768) {
card.classList.remove('direction-row');
card.classList.add('direction-column');
} else {
card.classList.remove('direction-column');
card.classList.add('direction-row');
}
});
attributecard.forEach(attribute => {
if (window.innerWidth <= 768) {
attribute.style.top = '95%';
attribute.style.right = '42%';
} else {
attribute.style.top = '85%';
attribute.style.right = '54%';
}
});
attributecards.forEach(attributecard => {
if (window.innerWidth <= 768) {
attributecard.style.marginTop = '4rem';
} else {
attributecard.style.marginTop = '3rem';
}
});
tableempty.forEach(empty => {
if (window.innerWidth <= 768) {
empty.style.display = 'none';
} else {
empty.style.display = 'flex';
}
});
tablenotempty.forEach(notempty => {
if (window.innerWidth <= 768) {
notempty.style.width = '100%';
notempty.classList.add('border-bottom');
} else {
notempty.style.width = '50%';
notempty.classList.remove('border-bottom');
}
});
tablenotempty2.forEach(notempty => {
if (window.innerWidth <= 768) {
notempty.classList.add('border-bottom');
} else {
notempty.classList.remove('border-bottom');
}
});
tablename.forEach(notempty => {
if (window.innerWidth <= 768) {
notempty.style.width = '100%';
notempty.classList.remove('text-m');
notempty.classList.add('background-secondary');
} else {
notempty.style.width = '20%';
notempty.classList.add('text-m');
notempty.classList.remove('background-secondary');
}
});
tablenotempty3.forEach(notempty => {
if (window.innerWidth <= 768) {
notempty.style.width = '100%';
} else {
notempty.style.width = '50%';
}
});
}
updatePaddingClass();
window.addEventListener('resize', updatePaddingClass);