-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
249 lines (194 loc) · 8.4 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE html>
<html lang="en"><head id="j_idt2">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Knockout Hierarchy Playground</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous" />
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
.mc-sidebar
{ position: absolute; top: 15px; left: 15px; right: 15px; bottom: 15px;
background-color: #efefef; box-sizing: border-box; overflow-y: auto; margin-bottom: 0px; }
.mc-toggle
{ display: inline-block; padding: 3px 5px;; border-radius: 3px; background-color: #efefef;
margin-right: 5px; width: 26px; text-align: center; }
.active .mc-toggle, .mc-toggle-loading
{ background-color: black; }
.mc-toggle-branch
{ cursor: pointer; }
.mc-node-selector
{ cursor: pointer; white-space: nowrap; padding-right: 50px; }
.mc-toggle img
{ position: relative; bottom: 1px; }
.mc-info
{ position: absolute; right: 10px; top: 14px; }
.active .mc-info
{ color: white; }
.popover-content
{ border: solid 1px rgba(0,0,0, .2); padding: 0px; margin: 3px; }
.popover-content .table
{ margin-bottom: 0px; }
.popover-content .name
{ font-weight: bold; padding-right: 20px; }
.popover-content .value
{ padding-right: 30px; }
.popover-content > .table > tbody > tr:first-child > td
{ border-top: none; }
#mc-content
{ position: absolute; top: 15px; bottom: 0px; right: 15px; left: 15px; overflow: auto; margin-bottom: 0px; }
.tab-pane
{ padding-top: 15px; }
.mc-actions div
{ padding: 5px 0px; }
iframe
{ border: none; width: 100%; height: 300px; }
.green
{ color: yellowgreen; }
.mc-table-node
{ padding-right: 10px; background-color: #f5f5f5; }
.root
{ background-color: #c3c3c3; }
</style></head>
<body>
<div id="hierarchy" class="mc-hierarchy mc-sidebar panel panel-default">
<div class="list-group" data-bind="template: { name: 'node', foreach: nodes }"></div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script>
<script src="hierarchy.js"></script>
<template id="table-node">
<div class="visible-xs" data-bind="foreach: $data">
<div class="panel panel-default" data-bind="click: onSelectedRow" style="margin-top: 8px; margin-bottom: 8px; margin-right: 4px;">
<table class="table">
<tr>
<th style="width: 35%;">Code</th>
<td data-bind="text: code"></td>
</tr>
<tr>
<th>Description</th>
<td data-bind="text: description"></td>
</tr>
<tr>
<th>Type</th>
<td data-bind="text: type"></td>
</tr>
<tr>
<th>Date</th>
<td data-bind="text: date"></td>
</tr>
</table>
</div>
</div>
<div class="panel panel-default hidden-xs" style="margin-bottom: 0px;">
<table class="table table-striped table-hover">
<thead>
<tr>
<th style="width: 100px;">Code</th>
<th>Description</th>
<th style="width: 150px;">Type</th>
<th style="width: 150px;">Date</th>
</tr>
</thead>
<tbody data-bind="foreach: $data">
<tr data-bind="click: onSelectedRow" style="cursor: pointer;">
<td data-bind="text: code"></td>
<td data-bind="text: description"></td>
<td data-bind="text: type"></td>
<td data-bind="text: date"></td>
</tr>
</tbody>
</table>
</div>
</template>
<div class="modal fade" id="dialog" role="dialog">
<div class="modal-dialog">
<div class="modal-content" style="overflow: hidden;">
<div class="modal-header bg-info">
<button type="button" class="close" data-dismiss="modal" style="margin-top: 3px;">
<span style="font-size: 24px;" class="glyphicon glyphicon-remove"></span>
</button>
<h4 class="modal-title" style="font-size: 24px;">Details</h4>
</div>
<div class="modal-body">
<div class="panel panel-default">
<table class="table table-striped" data-bind="with: item">
<tr>
<th>Code</th>
<td data-bind="text: code"></td>
</tr>
<tr>
<th>Description</th>
<td data-bind="text: description"></td>
</tr>
<tr>
<th>Type</th>
<td data-bind="text: type"></td>
</tr>
<tr>
<th>Date</th>
<td data-bind="text: date"></td>
</tr>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" style="width: 125px;" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script type="text/html" id="node">
<div class="mc-node-selector list-group-item" data-bind="click: function() { $data.open(!$data.open()) }, style: { paddingLeft: padding }, css: { 'active': selected(), 'root': $data.level() == 0 }">
<div>
<!-- ko if: !leaf() -->
<span class="mc-toggle" data-bind="css: { 'mc-toggle-branch': !leaf() }">
<span class="glyphicon" data-bind="css: { 'glyphicon-chevron-right': !open(), 'glyphicon-chevron-down': open() }">
</span>
</span>
<!-- /ko -->
<!-- ko if: leaf() -->
<span class="mc-toggle"><span class="glyphicon glyphicon-leaf"></span></span>
<!-- /ko -->
<span>
<span data-bind="css: icon"></span>
<span data-bind="text: description"></span>
</span>
</div>
</div>
<!-- ko if: showData() -->
<div class="list-group-item mc-table-node" data-bind="style: { paddingLeft: padding }, template: { name: 'table-node', data: $data.data }">
</div>
<!-- /ko -->
<!-- ko if: open() -->
<!-- ko template: { name: 'node', foreach: children } --> <!-- /ko -->
<!-- /ko -->
</script>
<script>
//<![CDATA[
function SelectedItemModel() {
var self = this;
self.item = ko.observable(null);
}
var selection = new SelectedItemModel();
ko.applyBindings(selection, $('#dialog').get(0));
function onSelectedRow(item) {
selection.item(item);
$('#dialog').modal('show');
}
jQuery(document).ready(function($) {
$.get('knockout-table-hierarchy-source.json', function(data) {
$('#hierarchy').mtree('setup', {
nodes: data.children
});
}, 'json');
});
//]]>
</script>
</body>
</html>