-
Notifications
You must be signed in to change notification settings - Fork 2
/
DropDown.js
133 lines (93 loc) · 3.17 KB
/
DropDown.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
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
(
function()
{
$j.RegisterControlType("J:DROPDOWN", DropDown);
function DropDown(jelemt)
{
if (jelemt) {
var width = jelemt.getAttribute("Width");
var height = jelemt.getAttribute("Height");
}
if (width)
this.width = parseInt(width.replace("px", ""));
else
this.width = 200;
if (height)
this.height = parseInt(height.replace("px", ""));
else
this.height = 100;
var elemt = document.createElement("div");
elemt.style.display = "inline-block";
this.elemt = elemt;
var top = document.createElement("div");
elemt.appendChild(top);
this.top = top;
var drop = document.createElement("div");
drop.style.display = "none";
drop.style.position = "absolute";
drop.style.zIndex = 1;
elemt.appendChild(drop);
this.drop = drop;
var ctrl = this;
top.addEventListener("mousedown",
function top_mousedown(e)
{
drop.style.display = "block";
ctrl.isMouseDownSelf = true;
}
);
drop.addEventListener("mousedown",
function drop_mousedown()
{
ctrl.isMouseDownSelf = true;
}
);
$j.addEventListener("mousedown", function window_mousedown() {
if (ctrl.isMouseDownSelf) {
ctrl.isMouseDownSelf = false;
return;
}
drop.style.display = "none";
});
//jwf$AddEventHandler_To_Frames_Window_MouseDown(function jwf$DropDownList$window_mousedown()
//{
// if (ctrl.isMouseDownSelf)
// {
// ctrl.isMouseDownSelf = false;
// return;
// }
// drop.style.display = "none";
//});
}
window.$j.DropDown = CreateDropDown;
function CreateDropDown(id)
{
var ctrl = new DropDown();
if (id) {
$j.RegisterControl(ctrl, id);
}
return ctrl;
}
DropDown.prototype = $j.Control();
DropDown.prototype.Top = function Top(topElement) {
var top = this.top;
if (!topElement)
return top.firstChild;
if (top.firstChild)
top.removeChild(top.firstChild);
top.appendChild(topElement);
}
DropDown.prototype.Drop = function Drop(dropElement) {
var drop = this.drop;
if (!dropElement)
return drop.firstChild;
if (drop.firstChild)
drop.removeChild(drop.firstChild);
drop.appendChild(dropElement);
}
DropDown.prototype.Close = function Close() {
var drop = this.drop;
drop.style.display = "none";
}
}
)();