forked from onlywei/explain-git-with-d3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplaingit.js
74 lines (61 loc) · 1.96 KB
/
explaingit.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
define(['historyview', 'controlbox', 'd3'], function (HistoryView, ControlBox, d3) {
var prefix = 'ExplainGit',
openSandBoxes = [],
open,
reset,
explainGit;
open = function (_args) {
var args = Object.create(_args),
name = prefix + args.name,
containerId = name + '-Container',
container = d3.select('#' + containerId),
playground = container.select('.playground-container'),
historyView, originView = null,
controlBox;
container.style('display', 'block');
args.name = name;
historyView = new HistoryView(args);
if (args.originData) {
originView = new HistoryView({
name: name + '-Origin',
width: 300,
height: 225,
commitRadius: 15,
remoteName: 'origin',
commitData: args.originData
});
originView.render(playground);
}
controlBox = new ControlBox({
historyView: historyView,
originView: originView,
initialMessage: args.initialMessage
});
controlBox.render(playground);
historyView.render(playground);
openSandBoxes.push({
hv: historyView,
cb: controlBox,
container: container
});
};
reset = function () {
for (var i = 0; i < openSandBoxes.length; i++) {
var osb = openSandBoxes[i];
osb.hv.destroy();
osb.cb.destroy();
osb.container.style('display', 'none');
}
openSandBoxes.length = 0;
d3.selectAll('a.openswitch').classed('selected', false);
};
explainGit = {
HistoryView: HistoryView,
ControlBox: ControlBox,
generateId: HistoryView.generateId,
open: open,
reset: reset
};
window.explainGit = explainGit;
return explainGit;
});