toppanel_wev8.js
8.24 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
var _ToolBoxManager = [];
function TToolBox(id, caption, l, t, w, h, content, dir, expanded, mw, mh){
this.ID = id;
this.Caption = caption;
this.Left = l;
this.Top = t;
this.Width = w;
this.MinWidth = mw?mw:w;
this.Height = h;
this.MinHeight = mh?mh:h;
this.Content = content;
this.TitleHeight = 20;
this.Dir = dir;
this.TitleBtn = dir == "down"?new Array("down","up"):new Array("up","down");
this.InnerObject = null;
document.write(this);
this.InnerObject = document.all(this.ID);
this.Visible = true;
this.VisibleEx = true;
if(expanded == false) this.hideBox();
_ToolBoxManager[_ToolBoxManager.length] = this;
}
TToolBox.prototype.hideBox = function(){
var oTitle = document.all(this.ID+"_title");
var oContent = document.all(this.ID+"_content");
var oBottom = document.all(this.ID+"_bottom");
var oImg = document.all(this.ID+"_img");
this.InnerObject.style.height = this.TitleHeight;
oImg.src = "image/" + this.TitleBtn[0] + "_wev8.gif";
oImg.title = "单击展开工具栏";
oContent.style.display = "none";
oBottom.style.display = "none";
oTitle.style.background = "#D4D0C8";
if(this.Dir == "up") this.InnerObject.style.top = this.Top;
this.Visible = false;
setToolBoxTopMost(this);
}
TToolBox.prototype.showBox = function(){
var oTitle = document.all(this.ID+"_title");
var oContent = document.all(this.ID+"_content");
var oBottom = document.all(this.ID+"_bottom");
var oImg = document.all(this.ID+"_img");
this.InnerObject.style.height = this.Height;
oImg.src = "image/" + this.TitleBtn[1] + "_wev8.gif";
oImg.title = "单击收缩工具栏";
oContent.style.display = "block";
oBottom.style.display = "block";
oTitle.style.background = "#0066FF";
if(this.Dir == "up") this.InnerObject.style.top = this.Top - this.Height + this.TitleHeight;
this.Visible = true;
setToolBoxTopMost(this);
}
TToolBox.prototype.showHideTool = function(){
if(this.Visible)
this.hideBox();
else
this.showBox();
}
TToolBox.prototype.setZIndex = function(i){
this.InnerObject.style.zIndex = i;
}
TToolBox.prototype.mouseDown = function(){
if(event.button != 1) return;
var obj = event.srcElement;
setToolBoxTopMost(this);
if(!obj.moveType) return;
this.moveType = obj.moveType;
this.InnerObject.setCapture();
this.CurrentX = event.x - this.InnerObject.offsetLeft;
this.CurrentY = event.y - this.InnerObject.offsetTop;
}
TToolBox.prototype.mouseMove = function(){
switch(this.moveType){
case "m":
this.Left = event.x - this.CurrentX;
this.Top = event.y - this.CurrentY
this.InnerObject.style.left = this.Left;
this.InnerObject.style.top = this.Top;
break;
case "s":
this.Height = event.y - this.Top;
if(this.Height < this.MinHeight) this.Height = this.MinHeight;
this.InnerObject.style.height = this.Height;
break;
case "n":
var bOffset = this.InnerObject.offsetTop + this.Height;
this.Height = bOffset - event.y;
if(this.Height < this.MinHeight) this.Height = this.MinHeight;
this.Top = bOffset - this.Height;
this.InnerObject.style.top = this.Top;
this.InnerObject.style.height = this.Height;
break;
case "e":
this.Width = event.x - this.Left;
if(this.Width < this.MinWidth) this.Width = this.MinWidth;
this.InnerObject.style.width = this.Width;
break;
case "nw":
this.Width = event.x - this.Left;
this.Height = event.y - this.Top;
if(this.Height < this.MinHeight) this.Height = this.MinHeight;
if(this.Width < this.MinWidth) this.Width = this.MinWidth;
this.InnerObject.style.width = this.Width;
this.InnerObject.style.height = this.Height;
break;
}
}
TToolBox.prototype.mouseUp = function(){
this.moveType = "";
this.InnerObject.releaseCapture();
if(parseInt(this.InnerObject.style.top)<-10){
alert("工具栏上边界超出边界,将自动调整.");
this.InnerObject.style.top=30;
}
}
TToolBox.prototype.toString = function(){
S = '<table id="'+this.ID+'" class="toolbox" style="position:absolute;left:' + this.Left + 'px;top:' + this.Top + 'px;width:' +
this.Width + 'px;height:' + this.Height + 'px;z-index:3000" cellspacing="0" cellpadding="0" border="0" onmousedown="'+this.ID+'.mouseDown();" '+
'onmousemove="'+this.ID+'.mouseMove();" onmouseup="'+this.ID+'.mouseUp();">';
if(this.Dir == "down"){
S += '<tr id="'+this.ID+'_title" height="'+this.TitleHeight+'" bgcolor="#0066FF" style="cursor:move;"><td colspan="2" title="双击可以展开/收缩工具栏,按住左键移动位置" '+
'ondblclick="'+this.ID+'.showHideTool();"><table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"><tr><td width="99%" moveType="m"> <font color="#FFFFFF" moveType="m">' + this.Caption + '</font></td><td width="1%"><img id="'+this.ID+'_img" title="单击收缩工具栏" src="image/' + this.TitleBtn[1] + '_wev8.gif" style="cursor:hand;" onclick="'+this.ID+'.showHideTool();" height="14" width="14" border="0"></td></tr></table></td></tr>' +
'<tr id="'+this.ID+'_content"><td valign="top">' + this.Content + ' </td><td width="2" style="cursor:E-resize;" moveType="e"></td></tr>' +
'<tr id="'+this.ID+'_bottom" height="2"><td style="cursor:S-resize;" moveType="s"></td><td style="cursor:NW-resize;" moveType="nw"></td</tr>';
}
else
S += '<tr id="'+this.ID+'_bottom" height="2"><td style="cursor:N-resize;" moveType="n"></td><td></td</tr>' +
'<tr id="'+this.ID+'_content"><td valign="top">' + this.Content + ' </td><td width="2" style="cursor:E-resize;" moveType="e"></td></tr>' +
'<tr id="'+this.ID+'_title" height="'+this.TitleHeight+'" bgcolor="#0066FF" style="cursor:move;"><td colspan="2" title="双击可以展开/收缩工具栏,按住左键移动位置" '+
'ondblclick="'+this.ID+'.showHideTool();"><table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"><tr><td width="99%" moveType="m"> <font color="#FFFFFF" moveType="m">' + this.Caption + '</font></td><td width="1%"><img id="'+this.ID+'_img" title="单击收缩工具栏" src="image/' + this.TitleBtn[1] + '_wev8.gif" style="cursor:hand;" onclick="'+this.ID+'.showHideTool();" height="14" width="14" border="0"></td></tr></table></td></tr>';
S += '</table>';
return S;
}
function TToolPanel(id, l, t, w, h, content, mw){
this.ID = id;
this.Left = l;
this.Top = t;
this.Width = w;
this.MinWidth = mw?mw:w;
this.Height = h;
this.Content = content;
this.InnerObject = null;
document.write(this);
this.InnerObject = document.all(this.ID);
_ToolBoxManager[_ToolBoxManager.length] = this;
}
TToolPanel.prototype.setZIndex = function(i){
this.InnerObject.style.zIndex = i;
}
TToolPanel.prototype.toString = function(){
S = '<table id="'+this.ID+'" class="toolbox" style="position:absolute;left:' + this.Left + 'px;top:' + this.Top + 'px;width:' +
this.Width + 'px;height:' + this.Height + 'px;z-index:3000" cellspacing="0" cellpadding="0" border="0" onmousedown="'+this.ID+'.mouseDown();" '+
'onmousemove="'+this.ID+'.mouseMove();" onmouseup="'+this.ID+'.mouseUp();">' +
'<tr><td width="8" style="cursor:move;" moveType="m"><img moveType="m" src="image/tb_title_wev8.gif" height="25" width="5" border="0"></td><td>' + this.Content + '</td</tr>' +
'</table>';
return S;
}
TToolPanel.prototype.mouseDown = function(){
if(event.button != 1) return;
var obj = event.srcElement;
if(!obj.moveType) return;
this.moveType = obj.moveType;
this.InnerObject.setCapture();
this.CurrentX = event.x - this.InnerObject.offsetLeft;
this.CurrentY = event.y - this.InnerObject.offsetTop;
setToolBoxTopMost(this);
}
TToolPanel.prototype.mouseMove = function(){
switch(this.moveType){
case "m":
this.Left = event.x - this.CurrentX;
this.Top = event.y - this.CurrentY
this.InnerObject.style.left = this.Left;
this.InnerObject.style.top = this.Top;
break;
}
}
TToolPanel.prototype.mouseUp = function(){
this.moveType = "";
this.InnerObject.releaseCapture();
if(parseInt(this.InnerObject.style.top)<-10){
alert("工具栏上边界超出边界,将自动调整.");
this.InnerObject.style.top=0;
}
}
function setToolBoxTopMost(AToolBox){
for(var i = 0; i< _ToolBoxManager.length; i++)
_ToolBoxManager[i].setZIndex(3000);
AToolBox.setZIndex(3001);
}