-
Notifications
You must be signed in to change notification settings - Fork 7
/
fundlist.js
106 lines (80 loc) · 2.43 KB
/
fundlist.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
var scrollbar = require('scrollbar.js');
var after = require('after-transition');
var ejs = require('ejs');
var modal = require('modal');
var utils = require('./utils');
var createElement = utils.createElement;
var wrapscroll = utils.wrapscroll;
var tmpl = {
fundlist: require('./fundlist.html')
};
var fundlist = module.exports = {};
fundlist.show = show;
fundlist.create = createFund;
fundlist.makeModal = makeModal;
fundlist.campaigns = require('./campaigns');
function createFund(){
fundlist.el = createElement('fundlist');
fundlist.el.innerHTML = wrapscroll(ejs.render(tmpl.fundlist, fundlist));
// more expand
var nodes = fundlist.el.querySelectorAll('.more a');
[].forEach.call(nodes, function(node){
var details = node.parentNode.parentNode.parentNode.querySelector('.details');
node.onclick = function(ev){
ev.preventDefault();
if (details.classList.contains('hide')) {
details.classList.remove('hide');
node.textContent = 'hide info';
} else {
details.classList.add('hide');
node.textContent = 'more info';
}
after(details, function(){
fundlist.scrollbar.refresh();
});
return false;
};
});
// pledger expand
var nodes = fundlist.el.querySelectorAll('.pledge .coin');
[].forEach.call(nodes, function(node){
var pledgerClass = node.classList.contains('bitcoin')
? '.bitcoin-pledger'
: '.dogecoin-pledger';
var pledgerOtherClass = node.classList.contains('dogecoin')
? '.bitcoin-pledger'
: '.dogecoin-pledger';
var parent = node.parentNode.parentNode.parentNode
var pledger = parent.querySelector(pledgerClass);
var pledgerOther = parent.querySelector(pledgerOtherClass);
node.onclick = function(ev){
ev.preventDefault();
pledgerOther.classList.add('hide');
if (pledger.classList.contains('hide')) {
pledger.classList.remove('hide');
} else {
pledger.classList.add('hide');
}
after(pledger, function(){
fundlist.scrollbar.refresh();
});
return false;
};
});
}
function makeModal(){
fundlist.modal = modal(fundlist.el)
.overlay()
.closeable()
.effect('fade-and-scale');
fundlist.modal.on('showing', function(){
if (fundlist.scrollbar) {
fundlist.scrollbar.refresh();
} else {
fundlist.scrollbar = scrollbar(fundlist.el);
}
});
}
function show(){
fundlist.modal.show();
}