-
Notifications
You must be signed in to change notification settings - Fork 0
/
swifty.js
153 lines (120 loc) · 4.34 KB
/
swifty.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
window.onload = function(){
let elem;
function css(selector,props) {
elem = document.querySelectorAll(selector)
for(var m = 0 ; m < elem.length ; m++ ){
for(var i in props){
eval(`elem[m].style.${i} = '${props[i]}' `)
}
}
}
function click(selector,functionToRun) {
elem = document.querySelectorAll(selector)
for(var i = 0 ; i < elem.length ; i++ ){
elem[i].addEventListener('click',functionToRun)
}
}
function hover(selector,functionToRun) {
elem = document.querySelectorAll(selector)
for(var i = 0 ; i < elem.length ; i++ ){
elem[i].addEventListener('mouseover',functionToRun)
}
}
let dropdowns = document.querySelectorAll(".head")
let dropdownsRight = document.querySelectorAll(".right")
let dropdownsLeft = document.querySelectorAll(".left")
for(var i = 0 ; i < dropdowns.length ; i++ ){
if (dropdowns[i].className.includes('right')) {
dropdowns[i].innerHTML += '<i class="fas fa-chevron-down down-right"></i>'
}else if(dropdowns[i].className.includes('left')){
dropdowns[i].innerHTML += ' <i class="fas fa-chevron-down down-right"></i>'
}
}
for(var m = 0 ; m < document.querySelectorAll('.sw-dropdowns').length ; m++ ){
for(var l = 1 ; l < document.querySelectorAll('.sw-dropdowns')[m].querySelectorAll('.sw-dropdown').length ; l++ ){
let options = document.querySelectorAll('.sw-dropdowns')[m].querySelectorAll('.sw-dropdown')[l].querySelectorAll('.sw-dropdown-body')[0]
options.style.display = 'none'
options.style.position = 'absolute'
}
document.querySelectorAll('.sw-dropdowns')[m].querySelectorAll('.sw-dropdown')[0].querySelectorAll('.head')[0].style.background = '#e7f1ff'
document.querySelectorAll('.sw-dropdowns')[m].querySelectorAll('.sw-dropdown')[0].querySelectorAll('i')[0].style.transform = 'rotate(-90deg)'
}
$(".head").click(function (e) {
let options = e.target.parentElement.querySelectorAll('.sw-dropdown-body')[0]
if (options.style.display == 'none') {
options.style.display = 'block'
options.style.position = 'static'
options.parentElement.querySelectorAll('.head')[0].style.background = '#e7f1ff'
e.target.querySelectorAll('i')[0].style.transform = 'rotate(-90deg)'
}else{
options.style.display = 'none'
options.style.position = 'absolute'
options.parentElement.querySelectorAll('.head')[0].style.background = 'white'
e.target.querySelectorAll('i')[0].style.transform = 'rotate(0deg)'
}
});
$('.sw-alert-dismiss').click(function (e) {
$('.sw-alert-dismiss').parent()[0].style.opacity = '0'
setTimeout(() => {
$('.sw-alert-dismiss').parent()[0].style.display = 'none'
}, 305);
});
var parseData = (function(){
var getAllComments = function(context) {
var ret = [],
node = context.firstChild;
if (!node) { return ret; }
do {
if (node.nodeType === 8) {
ret[ret.length] = node;
}
if (node.nodeType === 1) {
ret = ret.concat( getAllComments(node) );
}
} while( node = node.nextSibling );
return ret;
},
cache = [0],
expando = 'data' + +new Date(),
data = function(node) {
var cacheIndex = node[expando],
nextCacheIndex = cache.length;
if(!cacheIndex) {
cacheIndex = node[expando] = nextCacheIndex;
cache[cacheIndex] = {};
}
return cache[cacheIndex];
};
return function(context) {
context = context || document.documentElement;
if ( data(context) && data(context).commentJSON ) {
return data(context).commentJSON;
}
var comments = getAllComments(context),
len = comments.length,
comment, cData;
while (len--) {
comment = comments[len];
cData = comment.data.replace(/\n|\r\n/g, '');
if ( /^\s*?\{.+\}\s*?$/.test(cData) ) {
try {
data(comment.parentNode).commentJSON = (new Function('return ' + cData + ';'))();
} catch(e) {}
}
}
return data(context).commentJSON || true;
};
})();
for (let i = 0; i < document.querySelectorAll('.sw-alert-dismiss').length; i++) {
console.log(document.querySelectorAll('.sw-alert-dismiss') , i)
const element = document.querySelectorAll('.sw-alert-dismiss')[i];
if (parseData(element).bg_color !== undefined) {
let bgColor = parseData(element).bg_color
element.style.background = bgColor
}
if (parseData(element).color !== undefined) {
let color = parseData(element).color
element.style.color = color
}
}
}