-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathExample-Select-Option.html
More file actions
243 lines (218 loc) · 7.56 KB
/
Example-Select-Option.html
File metadata and controls
243 lines (218 loc) · 7.56 KB
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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>js-orgChart by Rchockxm</title>
<script language="javascript" src="js-orgchart.js"></script>
<link rel="stylesheet" type="text/css" href="js-orgchart.css">
<style type="text/css">
body {
background-color: #F8F8F8;
}
#form_title {
border-radius: 10px 10px 0px 0px;
-o-border-radius: 10px 10px 0px 0px;
-moz-border-radius: 10px 10px 0px 0px;
-webkit-border-radius: 10px 10px 0px 0px;
border:1px solid #C0C0C0;
margin: 0 auto;
padding: 10px 10px 10px 10px;
width: 640px;
height: 16px;
background-color: #282828;
}
#form_title .form_title_content {
color: #FFFFFF;
font-weight: bold;
font-size: 1.0em !important;
font-family: "Times New Roman", Times, serif;
float: left;
}
#form_title .form_title_log {
color: #FFFFFF;
font-weight: bold;
font-size: 0.8em !important;
font-family: "Times New Roman", Times, serif;
float: left;
padding: 2px 0px 0px 50px;
}
#form_title .form_title_search {
color: #FFFFFF;
float: right;
margin: -4px 40px 0 0;
}
#form_title .form_title_search input[type="text"] {
border: 1px solid #ccc;
border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-moz-box-shadow: 2px 2px 3px #666;
-webkit-box-shadow: 2px 2px 3px #666;
box-shadow: 2px 2px 3px #666;
outline: 0;
-webkit-appearance: none;
}
#form_content {
border-radius: 0px 0px 10px 10px;
-o-border-radius: 0px 0px 10px 10px;
-moz-border-radius: 0px 0px 10px 10px;
-webkit-border-radius: 0px 0px 10px 10px;
border: 1px solid #C0C0C0;
margin: 0 auto;
padding: 10px 10px 10px 10px;
width: 640px;
height: 480px;
background-color: #FFFFFF;
}
.OrgNode-select select {
width: 100px;
height: 20px;
}
</style>
</head>
<body>
<div id="form_title">
<div class="form_title_content">js-OrgChart Example</div>
<div class="form_title_log"></div>
<div class="form_title_search">Search: <input type="text" id="search_item" onkeydown="input_keydown_event(event);" /></div>
</div>
<div id="form_content" style="">
<div id="OrgChart"></div>
</div>
</body>
<script language="javascript">
// js-orgChart Demo by rchockxm
var oriWidth = 640;
var oriHeight = 480;
var select_field = '<select onchange="select_change_event(this)"><option value="0">None</option><option value="1">Numeric A</option><option value="2">Numeric B</option></select>';
// Demo Data
var P = ['Bell', 'Bob', 'Frank', 'James', 'Alex', 'Edward', 'Tony', 'Jonic', 'Shannon', 'cwc', 'Benny', 'Tom', 'Alice', 'Fred', 'Eric', 'Mal'];
var S = [];
var tRootNode = new OrgNode();
tRootNode.customParam.Caption = "Root";
tRootNode.customParam.Description = "Demo";
var HwndNode;
var HwndObject = {};
var ChildNode;
for (var i=0; i<P.length; i++) {
var Data = P[i];
var Caption = Data;
HwndObject[Caption] = new OrgNode();
HwndObject[Caption].customParam.Caption = Caption;
HwndObject[Caption].customParam.Description = "Demo";
S[i] = Caption;
if (i == 0) {
ChildNode = HwndObject[Caption];
}
else if (i > 1) {
var index = Math.round(Math.random() * (S.length - 0));
if (index > S.length) {
index = 0;
}
if (typeof S[index] == "string") {
HwndObject[S[index]].Nodes.Add(HwndObject[Caption]);
}
}
}
tRootNode.Nodes.Add(ChildNode);
/*var tGoogleData = [
[{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'}, '', 'The President'],
[{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President</div>'}, 'Mike', 'VP'],
['Alice', 'Mike', ''],
['Bob', 'Jim', 'Bob Sponge'],
['Carol', 'Bob', '']];
tRootNode = LoadGoogleOrgChartData(tGoogleData);*/
// Options
var tOptions = new OrgOptions();
tOptions.AutoPos = true;
tOptions.Top = 8;
tOptions.Left = 20;
//tOptions.paddingOffsetTop = 0;
//tOptions,paddingOffsetLeft = 0;
//tOptions.IntervalWidth = 100;
//tOptions.IntervalHeight = 60;
tOptions.EdgeWidth = 120;
tOptions.EdgeHeight = 60;
tOptions.LineColor = "#3388dd";
tOptions.LineSize = 1;
tOptions.EdgeTemplet = "<div id=\"{Id}\" class=\"OrgEdge\"><span>{Caption}</span><div>{Description}</div><div class=\"OrgNode-select\">" + select_field + "</div></div>";
// StyleSheet
var tStyleSheet = new OrgStyleSheet();
tStyleSheet.CssText = "";
// Render Chart
var ogChart = new OrgChart();
ogChart.RootNodes = tRootNode;
ogChart.Options = tOptions;
ogChart.StyleSheet = tStyleSheet;
ogChart.NodeOnClick = function() {
var hwnd = document.getElementById(this.id).getElementsByTagName("span");
var name = hwnd[0].firstChild.data;
document.getElementById("form_title").getElementsByTagName("div")[1].innerHTML = "Click: Name = " + name;
};
ogChart.NodeOnMouseMove = function() {
var hwnd = document.getElementById(this.id).getElementsByTagName("span");
var name = hwnd[0].firstChild.data;
//document.getElementById("form_title").getElementsByTagName("div")[1].innerHTML = "MouseMove: Name = " + name;
};
ogChart.NodeOnMouseOver = function() {
var hwnd = document.getElementById(this.id).getElementsByTagName("span");
var name = hwnd[0].firstChild.data;
document.getElementById("form_title").getElementsByTagName("div")[1].innerHTML = "MouseOver: Name = " + name;
};
ogChart.NodeOnMouseOut = function() {
var hwnd = document.getElementById(this.id).getElementsByTagName("span");
var name = hwnd[0].firstChild.data;
document.getElementById("form_title").getElementsByTagName("div")[1].innerHTML = "MouseOut: Name = " + name;
};
ogChart.DepthOnProcess = function(Depths, n) {
var DepthNodes = Depths;
var NowDepth = n;
if (n == 4) {
for (var m=0; m<DepthNodes.length; m++) {
var divID = document.getElementById(DepthNodes[m].Id);
divID.style.border = '5px solid red';
}
}
};
ogChart.Render();
// ReSet Div Content Width and Height
var oDivStyle = ogChart.GetContainerStyle();
var newWidth = oDivStyle.width;
var newHeight = oDivStyle.height;
if (newWidth > oriWidth) {
document.getElementById("form_title").style.width = newWidth + "px";
document.getElementById("form_content").style.width = newWidth + "px";
}
if (newHeight > oriHeight) {
document.getElementById("form_content").style.height = newHeight + "px";
}
// Search Function
function input_keydown_event(event) {
event = (event == undefined) ? window.event : event;
if (event.keyCode == 13) {
var search_val = document.getElementById("search_item").value.toLowerCase();
var childs = document.getElementById("OrgChart").getElementsByTagName("div");
for (var i=0; i<childs.length; i++) {
var span_name = childs[i].getElementsByTagName("span")[0];
if (span_name != undefined || span_name != null) {
if (search_val != "" && span_name.innerHTML.toLowerCase().indexOf(search_val) >= 0) {
span_name.parentNode.setAttribute("class", "OrgEdge_Hight");
}
else {
span_name.parentNode.setAttribute("class", "OrgEdge");
}
}
}
}
}
// Change Function
function select_change_event(sender) {
var hwnd = sender.parentNode.parentNode.getElementsByTagName("span");
var name = hwnd[0].firstChild.data;
var numeric = sender.value;
alert("Name: " + name + " Value: " + numeric);
}
</script>
</html>