-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
224 lines (193 loc) · 7.29 KB
/
index.html
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>jQuery Arrows</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.4/css/bulma.min.css">
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
<script src="jquery.arrows.js"></script>
<script>
$(document).ready(function () {
$(".node").draggable(); // Make node boxes draggable with jQuery UI
$().arrows({
within: '#svg-arrows', // Optional (container that will hold the created arrows - set to "body" if not specified)
id: 'arrow-1-2', // Optional (for unique element identification - set to "arrow-n" if not specified)
class: 'blue-dashed-edge', // Optional (for arrow class identification and styling)
name: 'i am arrow-1-2', // Optional (no text is shown otherwise)
from: '#node-1', // MANDATORY - Any jQuery selector (allowing to choose multiple source elements at once).
to: '#node-2' // MANDATORY - Any jQuery selector (allowing to choose multiple destination elements at once).
});
$().arrows({
within: '#svg-arrows',
id: 'arrow-2-3',
class: 'purple-edge',
name: 'i am arrow-2-3',
from: '#node-2',
to: '#node-3'
});
$().arrows({
within: '#svg-arrows',
id: 'arrow-3-4',
class: 'blue-dashed-edge',
name: 'i am arrow-3-4',
from: '#node-3',
to: '#node-4'
});
$().arrows({
within: '#svg-arrows',
id: 'arrow-4-1',
class: 'orange-edge',
name: 'i am arrow-4-1',
from: '#node-4',
to: '#node-1'
});
$().arrows({
within: '#svg-arrows',
id: 'arrow-1-3',
class: 'orange-edge',
name: 'i am arrow-1-3',
from: '#node-1',
to: '#node-3'
});
$().arrows({
within: '#svg-arrows',
id: 'arrow-4-2',
class: 'purple-edge',
name: 'i am arrow-4-2',
from: '#node-4',
to: '#node-2'
});
$().arrows({
within: '#svg-arrows',
id: 'arrow-5-2',
class: 'orange-edge',
name: 'i am arrow-5-2',
from: '#node-5',
to: '#node-2'
});
$().arrows({
within: '#svg-arrows',
id: 'arrow-3-5',
class: 'blue-dashed-edge',
name: 'i am arrow-3-5',
from: '#node-3',
to: '#node-5'
});
var arrows = $("arrow");
setInterval(function () {
arrows.arrows("update");
}, 100);
});
</script>
<style>
.node {
position: absolute;
display: flex;
justify-content: center;
background: rgba(255, 255, 255, 0.5);
padding: 0.5em;
border: 2px solid rgba(0, 0, 0, 0.8);
border-radius: 10px;
}
.green-node {
border: 2px solid rgba(19, 230, 0, 0.8);
border-radius: 10px;
}
.blue-node {
border: 2px solid rgba(0, 81, 255, 0.8);
border-radius: 10px;
}
.red-node {
border: 2px solid rgba(204, 1, 1, 0.8);
border-radius: 10px;
}
/* Edit arrow styles by class */
.blue-dashed-edge .svg {
fill: blue;
}
.blue-dashed-edge .svg-line {
stroke: blue;
stroke-dasharray: 8;
}
.purple-edge .svg {
fill: purple;
}
.purple-edge .svg-line {
stroke: purple;
}
.orange-edge .svg {
fill: orange;
}
.orange-edge .svg-line {
stroke: orange;
}
/* Edit width of arrow line and text */
.svg {
fill: black;
/* Black color by default for svg elems*/
}
.svg-line {
stroke: black;
stroke-width: 2;
}
</style>
</head>
<body>
<h2 class="title is-3" style="margin: 0.5em;">jQuery Arrows Example</h2>
<h3 class="subtitle is-4" style="margin: 0.5em;">Nodes can be dragged to play with arrows update.</h3>
<h3 class="subtitle is-4" style="margin: 0.5em;">Arrows are defined in a script stating what HTML elements they
connect and their properties.</h3>
<h3 class="subtitle is-4" style="margin: 0.5em;">Arrows can be styled by class or id using CSS as in this example.
</h3>
<div id="graph-viewer">
<div id="node-1" class="node green-node ui-draggable ui-draggable-handle"
style="left: 318.516px; top: 273.25px;">
<div class="media">
<div class="media-content">
<h5 class="title is-5">node-1</h5>
<h6 class="subtitle is-6">i am node 1</h6>
<!-- <span class="tag is-link is-small">green-node</span> -->
</div>
</div>
</div>
<div id="node-2" class="node blue-node ui-draggable ui-draggable-handle"
style="left: 660.766px; top: 332.969px;">
<div class="media">
<div class="media-content">
<h5 class="title is-5">node-2</h5>
<h6 class="subtitle is-6">i am node 2</h6>
<!-- <span class="tag is-link is-small">blue-node</span> -->
</div>
</div>
</div>
<div id="node-3" class="node green-node ui-draggable ui-draggable-handle"
style="left: 263.625px; top: 596.375px;">
<div class="media">
<div class="media-content">
<h5 class="title is-5">node-3</h5>
<h6 class="subtitle is-6">i am node 3</h6>
<!-- <span class="tag is-link is-small">green-node</span> -->
</div>
</div>
</div>
<div id="node-4" class="node blue-node ui-draggable ui-draggable-handle" style="left: 83.25px; top: 385.141px;">
<div class="media">
<div class="media-content">
<h5 class="title is-5">node-4</h5>
<h6 class="subtitle is-6">i am node 4</h6>
<!-- <span class="tag is-link is-small">blue-node</span> -->
</div>
</div>
</div>
<div id="node-5" class="node red-node ui-draggable ui-draggable-handle" style="left: 718px; top: 552px;">
<div class="media">
<div class="media-content">
<h5 class="title is-5">node-5</h5>
<h6 class="subtitle is-6">i am node 5</h6>
<!-- <span class="tag is-link is-small">red-node</span> -->
</div>
</div>
</div>
</div>
<div id="svg-arrows"></div>
</body>