Revision 625dcc40
Added by Bill Marquette over 16 years ago
usr/local/www/auto_complete_helper.js | ||
---|---|---|
1 |
|
|
2 |
/* ---- Variables ---- */ |
|
3 |
var actb_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out) |
|
4 |
var actb_lim = 5; // Number of elements autocomplete can show (-1: no limit) |
|
5 |
var actb_firstText = false; // should the auto complete be limited to the beginning of keyword? |
|
6 |
/* ---- Variables ---- */ |
|
7 |
|
|
8 |
/* --- Styles --- */ |
|
9 |
var actb_bgColor = '#FFFFFF'; |
|
10 |
var actb_textColor = '#000000'; |
|
11 |
var actb_hBgColor = '#990000'; |
|
12 |
var actb_htextColor = '#FFFFFF'; |
|
13 |
var actb_fFamily = 'Courier'; |
|
14 |
var actb_fSize = '14px'; |
|
15 |
var actb_hStyle = 'text-decoration:underline;font-weight="bold"'; |
|
16 |
/* --- Styles --- */ |
|
17 |
|
|
18 |
/* ---- Constants ---- */ |
|
19 |
var actb_keywords = new Array(); |
|
20 |
var actb_display = true; |
|
21 |
var actb_pos = 0; |
|
22 |
var actb_total = 0; |
|
23 |
var actb_curr = null; |
|
24 |
var actb_rangeu = 0; |
|
25 |
var actb_ranged = 0; |
|
26 |
var actb_bool = new Array(); |
|
27 |
var actb_pre = 0; |
|
28 |
var actb_toid; |
|
29 |
var actb_tomake = true; |
|
30 |
/* ---- Constants ---- */ |
|
31 |
|
|
32 |
function actb_parse(n){ |
|
33 |
var t = escape(actb_curr.value); |
|
34 |
var tobuild = ''; |
|
35 |
var i; |
|
36 |
var re = ""; |
|
37 |
|
|
38 |
if (actb_firstText){ |
|
39 |
re = new RegExp("^" + t, "i"); |
|
40 |
}else{ |
|
41 |
re = new RegExp(t, "i"); |
|
42 |
} |
|
43 |
var p = n.search(re); |
|
44 |
|
|
45 |
for (i=0;i<p;i++){ |
|
46 |
tobuild += n.substr(i,1); |
|
47 |
} |
|
48 |
tobuild += ""; |
|
49 |
for (i=p;i<t.length+p;i++){ |
|
50 |
tobuild += n.substr(i,1); |
|
51 |
} |
|
52 |
tobuild += ""; |
|
53 |
for (i=t.length+p;i<n.length;i++){ |
|
54 |
tobuild += n.substr(i,1); |
|
55 |
} |
|
56 |
return tobuild; |
|
57 |
} |
|
58 |
function actb_generate(){ |
|
59 |
if(navigator.appName == "Microsoft Internet Explorer") { |
|
60 |
if(window.location.protocol == 'https:') return; |
|
61 |
if(actb_keywords.length < 1) return; // if no items setup, do not invoke code. prevent ie crashing. |
|
62 |
if (document.getElementById('tat_frame')) document.body.removeChild(document.getElementById('tat_frame')); |
|
63 |
} |
|
64 |
if (document.getElementById('tat_table')) document.body.removeChild(document.getElementById('tat_table')); |
|
65 |
if(navigator.appName == "Microsoft Internet Explorer") { |
|
66 |
frame = document.createElement('iframe'); |
|
67 |
frame.cellSpacing='1px'; |
|
68 |
frame.cellPadding='2px'; |
|
69 |
frame.style.zIndex = 3; |
|
70 |
frame.style.position='absolute'; |
|
71 |
frame.style.top = eval(curTop() + actb_curr.offsetHeight) + "px"; |
|
72 |
frame.style.left = curLeft() + "px"; |
|
73 |
frame.style.backgroundColor=actb_bgColor; |
|
74 |
frame.id = 'tat_frame'; |
|
75 |
} |
|
76 |
a = document.createElement('table'); |
|
77 |
a.cellSpacing='1px'; |
|
78 |
a.cellPadding='2px'; |
|
79 |
a.style.border = '1px solid #990000'; |
|
80 |
a.style.zIndex = 5; |
|
81 |
a.style.position='absolute'; |
|
82 |
a.style.top = eval(curTop() + actb_curr.offsetHeight) + "px"; |
|
83 |
a.style.left = curLeft() + "px"; |
|
84 |
a.style.backgroundColor=actb_bgColor; |
|
85 |
a.id = 'tat_table'; |
|
86 |
if(navigator.appName == "Microsoft Internet Explorer") |
|
87 |
document.body.appendChild(frame); |
|
88 |
document.body.appendChild(a); |
|
89 |
var i; |
|
90 |
var first = true; |
|
91 |
var j = 1; |
|
92 |
var height = 0; |
|
93 |
var counter = 0; |
|
94 |
for (i=0;i<actb_keywords.length;i++){ |
|
95 |
if (actb_bool[i]){ |
|
96 |
counter++; |
|
97 |
r = a.insertRow(-1); |
|
98 |
if (first && !actb_tomake){ |
|
99 |
r.style.backgroundColor = actb_hBgColor; |
|
100 |
first = false; |
|
101 |
actb_pos = counter; |
|
102 |
}else if(actb_pre == i){ |
|
103 |
r.style.backgroundColor = actb_hBgColor; |
|
104 |
first = false; |
|
105 |
actb_pos = counter; |
|
106 |
}else{ |
|
107 |
r.style.backgroundColor = actb_bgColor; |
|
108 |
r.style.color = actb_bgColor; |
|
109 |
} |
|
110 |
r.id = 'tat_tr'+(j); |
|
111 |
c = r.insertCell(-1); |
|
112 |
c.style.color = actb_textColor; |
|
113 |
counter = 0; |
|
114 |
first = true; |
|
115 |
if (first && !actb_tomake){ |
|
116 |
c.style.color = actb_htextColor; |
|
117 |
first = false; |
|
118 |
actb_pos = counter; |
|
119 |
}else if(actb_pre == i){ |
|
120 |
c.style.color = actb_htextColor; |
|
121 |
first = false; |
|
122 |
actb_pos = counter; |
|
123 |
}else{ |
|
124 |
c.style.color = actb_textColor; |
|
125 |
} |
|
126 |
c.style.fontFamily = actb_fFamily; |
|
127 |
a.style.zIndex = 5; |
|
128 |
c.style.fontSize = actb_fSize; |
|
129 |
c.innerHTML = actb_parse(actb_keywords[i]); |
|
130 |
c.id = 'tat_td'+(j); |
|
131 |
height = height + c.offsetHeight; |
|
132 |
width = c.offsetWidth; |
|
133 |
j++; |
|
134 |
} |
|
135 |
if (j - 1 == actb_lim && j < actb_total){ |
|
136 |
r = a.insertRow(-1); |
|
137 |
r.style.backgroundColor = actb_bgColor; |
|
138 |
c = r.insertCell(-1); |
|
139 |
c.style.color = actb_textColor; |
|
140 |
a.style.zIndex = 5; |
|
141 |
c.style.fontFamily = 'arial narrow'; |
|
142 |
c.style.fontSize = actb_fSize; |
|
143 |
c.align='center'; |
|
144 |
c.innerHTML = '\\/'; |
|
145 |
break; |
|
146 |
} |
|
147 |
} |
|
148 |
actb_rangeu = 1; |
|
149 |
actb_ranged = j-1; |
|
150 |
actb_display = true; |
|
151 |
if (actb_pos <= 0) actb_pos = 1; |
|
152 |
if(navigator.appName == "Microsoft Internet Explorer") { |
|
153 |
frame.width=width; |
|
154 |
frame.height=height + 5; |
|
155 |
} |
|
156 |
} |
|
157 |
function curTop(){ |
|
158 |
actb_toreturn = 0; |
|
159 |
obj = actb_curr; |
|
160 |
while(obj){ |
|
161 |
actb_toreturn += obj.offsetTop; |
|
162 |
obj = obj.offsetParent; |
|
163 |
} |
|
164 |
return actb_toreturn; |
|
165 |
} |
|
166 |
function curLeft(){ |
|
167 |
actb_toreturn = 0; |
|
168 |
obj = actb_curr; |
|
169 |
while(obj){ |
|
170 |
actb_toreturn += obj.offsetLeft; |
|
171 |
obj = obj.offsetParent; |
|
172 |
} |
|
173 |
return actb_toreturn; |
|
174 |
} |
|
175 |
function actb_remake() { |
|
176 |
document.body.removeChild(document.getElementById('tat_table')); |
|
177 |
if(navigator.appName == "Microsoft Internet Explorer") { |
|
178 |
document.body.removeChild(document.getElementById('tat_frame')); |
|
179 |
frame = document.createElement('iframe'); |
|
180 |
frame.cellSpacing='2px'; |
|
181 |
frame.cellPadding='3px'; |
|
182 |
frame.style.position='absolute'; |
|
183 |
frame.style.zIndex = 5; |
|
184 |
frame.style.top = eval(curTop() + actb_curr.offsetHeight) + "px"; |
|
185 |
frame.style.left = curLeft() + "px"; |
|
186 |
frame.style.backgroundColor=actb_bgColor; |
|
187 |
frame.id = 'tat_frame'; |
|
188 |
} |
|
189 |
a = document.createElement('table'); |
|
190 |
a.cellSpacing='2px'; |
|
191 |
a.cellPadding='3px'; |
|
192 |
a.style.position='absolute'; |
|
193 |
a.style.zIndex = 5; |
|
194 |
a.style.top = eval(curTop() + actb_curr.offsetHeight) + "px"; |
|
195 |
a.style.left = curLeft() + "px"; |
|
196 |
a.style.backgroundColor=actb_bgColor; |
|
197 |
a.id = 'tat_table'; |
|
198 |
if(navigator.appName == "Microsoft Internet Explorer") |
|
199 |
document.body.appendChild(frame); |
|
200 |
document.body.appendChild(a); |
|
201 |
var width = 0; |
|
202 |
var height = 0; |
|
203 |
var i; |
|
204 |
var first = true; |
|
205 |
var j = 1; |
|
206 |
if (actb_rangeu > 1){ |
|
207 |
r = a.insertRow(-1); |
|
208 |
r.style.backgroundColor = actb_bgColor; |
|
209 |
c = r.insertCell(-1); |
|
210 |
c.style.color = actb_textColor; |
|
211 |
c.style.fontFamily = 'arial narrow'; |
|
212 |
a.style.zIndex = 5; |
|
213 |
c.style.fontSize = actb_fSize; |
|
214 |
c.align='center'; |
|
215 |
c.innerHTML = '/\\'; |
|
216 |
} |
|
217 |
for (i=0;i<actb_keywords.length;i++){ |
|
218 |
if (actb_bool[i]){ |
|
219 |
if (j >= actb_rangeu && j <= actb_ranged){ |
|
220 |
r = a.insertRow(-1); |
|
221 |
r.style.backgroundColor = actb_bgColor; |
|
222 |
r.id = 'tat_tr'+(j); |
|
223 |
c = r.insertCell(-1); |
|
224 |
c.style.color = actb_textColor; |
|
225 |
c.style.fontFamily = actb_fFamily; |
|
226 |
a.style.zIndex = 5; |
|
227 |
c.style.fontSize = actb_fSize; |
|
228 |
c.innerHTML = actb_parse(actb_keywords[i]); |
|
229 |
c.id = 'tat_td'+(j); |
|
230 |
j++; |
|
231 |
}else{ |
|
232 |
j++; |
|
233 |
} |
|
234 |
} |
|
235 |
if (j > actb_ranged) break; |
|
236 |
} |
|
237 |
if (j-1 < actb_total){ |
|
238 |
r = a.insertRow(-1); |
|
239 |
r.style.backgroundColor = actb_bgColor; |
|
240 |
c = r.insertCell(-1); |
|
241 |
c.style.color = actb_textColor; |
|
242 |
c.style.fontFamily = 'arial narrow'; |
|
243 |
c.style.fontSize = actb_fSize; |
|
244 |
c.align='center'; |
|
245 |
c.innerHTML = '\\/'; |
|
246 |
height = height + c.height; |
|
247 |
width = c.width; |
|
248 |
} |
|
249 |
if(navigator.appName == "Microsoft Internet Explorer") { |
|
250 |
frame.width=width; |
|
251 |
frame.height=height; |
|
252 |
} |
|
253 |
} |
|
254 |
function actb_goup(){ |
|
255 |
if (!actb_display) return; |
|
256 |
if (actb_pos == 1) return; |
|
257 |
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor; |
|
258 |
document.getElementById('tat_td'+actb_pos).style.color = actb_textColor; |
|
259 |
actb_pos--; |
|
260 |
if (actb_pos < actb_rangeu) actb_moveup(); |
|
261 |
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_hBgColor; |
|
262 |
document.getElementById('tat_td'+actb_pos).style.color = actb_htextColor; |
|
263 |
if (actb_toid) clearTimeout(actb_toid); |
|
264 |
if (actb_timeOut > 0) actb_toid = setTimeout("actb_removedisp()",actb_timeOut); |
|
265 |
} |
|
266 |
function actb_godown(){ |
|
267 |
if (!actb_display) return; |
|
268 |
if (actb_pos == actb_total) return; |
|
269 |
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_bgColor; |
|
270 |
document.getElementById('tat_td'+actb_pos).style.color = actb_textColor; |
|
271 |
actb_pos++; |
|
272 |
if (actb_pos > actb_ranged) actb_movedown(); |
|
273 |
document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_hBgColor; |
|
274 |
document.getElementById('tat_td'+actb_pos).style.color= actb_htextColor; |
|
275 |
if (actb_toid) clearTimeout(actb_toid); |
|
276 |
if (actb_timeOut > 0) actb_toid = setTimeout("actb_removedisp()",actb_timeOut); |
|
277 |
} |
|
278 |
function actb_movedown(){ |
|
279 |
actb_rangeu++; |
|
280 |
actb_ranged++; |
|
281 |
actb_remake(); |
|
282 |
} |
|
283 |
function actb_moveup(){ |
|
284 |
actb_rangeu--; |
|
285 |
actb_ranged--; |
|
286 |
actb_remake(); |
|
287 |
} |
|
288 |
function actb_penter(){ |
|
289 |
if (!actb_display) return; |
|
290 |
actb_display = 0; |
|
291 |
var word = ''; |
|
292 |
var c = 0; |
|
293 |
for (var i=0;i<=actb_keywords.length;i++){ |
|
294 |
if (actb_bool[i]) c++; |
|
295 |
if (c == actb_pos){ |
|
296 |
word = actb_keywords[i]; |
|
297 |
break; |
|
298 |
} |
|
299 |
} |
|
300 |
a = word;//actb_keywords[actb_pos-1];//document.getElementById('tat_td'+actb_pos).; |
|
301 |
actb_curr.value = a; |
|
302 |
actb_removedisp(); |
|
303 |
} |
|
304 |
function actb_removedisp(){ |
|
305 |
actb_display = 0; |
|
306 |
if(navigator.appName == "Microsoft Internet Explorer") |
|
307 |
if (document.getElementById('tat_frame')) document.body.removeChild(document.getElementById('tat_frame')); |
|
308 |
if (document.getElementById('tat_table')) document.body.removeChild(document.getElementById('tat_table')); |
|
309 |
if (actb_toid) clearTimeout(actb_toid); |
|
310 |
} |
|
311 |
function actb_checkkey(evt, sndr){ |
|
312 |
a = evt.keyCode; |
|
313 |
if (a == 38){ // up key |
|
314 |
actb_goup(); |
|
315 |
}else if(a == 40){ // down key |
|
316 |
actb_godown(); |
|
317 |
}else if(a == 13){ |
|
318 |
actb_penter(); |
|
319 |
} |
|
320 |
} |
|
321 |
function actb_tocomplete(sndr,evt,arr){ |
|
322 |
if (arr) actb_keywords = arr; |
|
323 |
if (evt.keyCode == 38 || evt.keyCode == 40 || evt.keyCode == 13) return; |
|
324 |
var i; |
|
325 |
if (actb_display){ |
|
326 |
var word = 0; |
|
327 |
var c = 0; |
|
328 |
for (i=0;i<=actb_keywords.length;i++){ |
|
329 |
if (actb_bool[i]) c++; |
|
330 |
if (c == actb_pos){ |
|
331 |
word = i; |
|
332 |
break; |
|
333 |
} |
|
334 |
} |
|
335 |
actb_pre = word;//actb_pos; |
|
336 |
}else{ actb_pre = -1; } |
|
337 |
|
|
338 |
if (!sndr) sndr = evt.srcElement; |
|
339 |
actb_curr = sndr; |
|
340 |
|
|
341 |
if (sndr.value == ''){ |
|
342 |
actb_removedisp(); |
|
343 |
return; |
|
344 |
} |
|
345 |
var t = sndr.value; |
|
346 |
var re = ""; |
|
347 |
if (actb_firstText){ |
|
348 |
re = new RegExp("^" + t, "i"); |
|
349 |
}else{ |
|
350 |
re = new RegExp(t, "i"); |
|
351 |
} |
|
352 |
|
|
353 |
actb_total = 0; |
|
354 |
actb_tomake = false; |
|
355 |
for (i=0;i<actb_keywords.length;i++){ |
|
356 |
actb_bool[i] = false; |
|
357 |
if (re.test(actb_keywords[i])){ |
|
358 |
actb_total++; |
|
359 |
actb_bool[i] = true; |
|
360 |
if (actb_pre == i) actb_tomake = true; |
|
361 |
} |
|
362 |
} |
|
363 |
if (actb_toid) clearTimeout(actb_toid); |
|
364 |
if (actb_timeOut > 0) actb_toid = setTimeout("actb_removedisp()",actb_timeOut); |
|
365 |
actb_generate(actb_bool); |
|
366 |
} |
usr/local/www/dom-drag.js | ||
---|---|---|
1 |
/************************************************** |
|
2 |
* dom-drag.js |
|
3 |
* 09.25.2001 |
|
4 |
* www.youngpup.net |
|
5 |
************************************************** |
|
6 |
* 10.28.2001 - fixed minor bug where events |
|
7 |
* sometimes fired off the handle, not the root. |
|
8 |
************************************************** |
|
9 |
* 05.30.2005 - added a workaround for firefox |
|
10 |
* activating links when finished dragging. |
|
11 |
* mmosier@astrolabe.com |
|
12 |
**************************************************/ |
|
13 |
/* |
|
14 |
The DragList drag and drop ordered lists implementation is available under the terms of the new BSD license. |
|
15 |
|
|
16 |
Copyright (c) 2005, DTLink, LLC |
|
17 |
All rights reserved. |
|
18 |
|
|
19 |
Redistribution and use in source and binary forms, with or |
|
20 |
without modification, are permitted provided that the following |
|
21 |
conditions are met: |
|
22 |
|
|
23 |
* Redistributions of source code must retain the above |
|
24 |
copyright notice, this list of conditions and the following |
|
25 |
disclaimer. |
|
26 |
|
|
27 |
* Redistributions in binary form must reproduce the above |
|
28 |
copyright notice, this list of conditions and the following |
|
29 |
disclaimer in the documentation and/or other materials provided |
|
30 |
with the distribution. |
|
31 |
|
|
32 |
* Neither the name of DTLink, LLC nor the names of its |
|
33 |
contributors may be used to endorse or promote products derived |
|
34 |
from this software without specific prior written permission. |
|
35 |
|
|
36 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
|
37 |
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
38 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
39 |
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
40 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
41 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
42 |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
43 |
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
44 |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
45 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
46 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
47 |
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
48 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
49 |
*/ |
|
50 |
|
|
51 |
var Drag = { |
|
52 |
|
|
53 |
obj : null, |
|
54 |
|
|
55 |
init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper) |
|
56 |
{ |
|
57 |
o.onmousedown = Drag.start; |
|
58 |
|
|
59 |
o.hmode = bSwapHorzRef ? false : true ; |
|
60 |
o.vmode = bSwapVertRef ? false : true ; |
|
61 |
|
|
62 |
o.root = oRoot && oRoot != null ? oRoot : o ; |
|
63 |
|
|
64 |
if (o.hmode && isNaN(parseInt(o.root.style.left ))) o.root.style.left = "0px"; |
|
65 |
if (o.vmode && isNaN(parseInt(o.root.style.top ))) o.root.style.top = "0px"; |
|
66 |
if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right = "0px"; |
|
67 |
if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px"; |
|
68 |
|
|
69 |
o.minX = typeof minX != 'undefined' ? minX : null; |
|
70 |
o.minY = typeof minY != 'undefined' ? minY : null; |
|
71 |
o.maxX = typeof maxX != 'undefined' ? maxX : null; |
|
72 |
o.maxY = typeof maxY != 'undefined' ? maxY : null; |
|
73 |
|
|
74 |
o.xMapper = fXMapper ? fXMapper : null; |
|
75 |
o.yMapper = fYMapper ? fYMapper : null; |
|
76 |
|
|
77 |
o.root.onDragStart = new Function(); |
|
78 |
o.root.onDragEnd = new Function(); |
|
79 |
o.root.onDrag = new Function(); |
|
80 |
}, |
|
81 |
|
|
82 |
start : function(e) |
|
83 |
{ |
|
84 |
var o = Drag.obj = this; |
|
85 |
e = Drag.fixE(e); |
|
86 |
var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom); |
|
87 |
var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right ); |
|
88 |
o.root.onDragStart(x, y); |
|
89 |
|
|
90 |
o.startX = x; |
|
91 |
o.startY = y; |
|
92 |
o.lastMouseX = e.clientX; |
|
93 |
o.lastMouseY = e.clientY; |
|
94 |
|
|
95 |
if (o.hmode) { |
|
96 |
if (o.minX != null) o.minMouseX = e.clientX - x + o.minX; |
|
97 |
if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX; |
|
98 |
} else { |
|
99 |
if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x; |
|
100 |
if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x; |
|
101 |
} |
|
102 |
|
|
103 |
if (o.vmode) { |
|
104 |
if (o.minY != null) o.minMouseY = e.clientY - y + o.minY; |
|
105 |
if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY; |
|
106 |
} else { |
|
107 |
if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y; |
|
108 |
if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y; |
|
109 |
} |
|
110 |
|
|
111 |
document.onmousemove = Drag.drag; |
|
112 |
document.onmouseup = Drag.end; |
|
113 |
|
|
114 |
if (o.linkDisabled) { |
|
115 |
var hrefs = o.root.getElementsByTagName("a"); |
|
116 |
for (var i = 0; i < hrefs.length; i++) { |
|
117 |
hrefs[i].onclick = hrefs[i].prevOnclick; |
|
118 |
hrefs[i].prevOnclick = null; |
|
119 |
} |
|
120 |
o.linkDisabled = false; |
|
121 |
} |
|
122 |
|
|
123 |
return false; |
|
124 |
}, |
|
125 |
|
|
126 |
drag : function(e) |
|
127 |
{ |
|
128 |
e = Drag.fixE(e); |
|
129 |
var o = Drag.obj; |
|
130 |
|
|
131 |
var ey = e.clientY; |
|
132 |
var ex = e.clientX; |
|
133 |
var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom); |
|
134 |
var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right ); |
|
135 |
var nx, ny; |
|
136 |
|
|
137 |
if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX); |
|
138 |
if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX); |
|
139 |
if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY); |
|
140 |
if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY); |
|
141 |
|
|
142 |
nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1)); |
|
143 |
ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1)); |
|
144 |
|
|
145 |
if (o.xMapper) nx = o.xMapper(y); |
|
146 |
else if (o.yMapper) ny = o.yMapper(x); |
|
147 |
|
|
148 |
Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px"; |
|
149 |
Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px"; |
|
150 |
Drag.obj.lastMouseX = ex; |
|
151 |
Drag.obj.lastMouseY = ey; |
|
152 |
|
|
153 |
var threshold = 4; |
|
154 |
if (!o.linkDisabled) { |
|
155 |
if (Math.abs(nx - o.startX) > threshold || Math.abs(ny - o.startY) > threshold) { |
|
156 |
var hrefs = o.root.getElementsByTagName("a"); |
|
157 |
for (var i = 0; i < hrefs.length; i++) { |
|
158 |
hrefs[i].prevOnclick = hrefs[i].onclick; |
|
159 |
hrefs[i].onclick = function() { return false; }; |
|
160 |
} |
|
161 |
o.linkDisabled = true; |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
Drag.obj.root.onDrag(nx, ny, Drag.obj.root); |
|
166 |
return false; |
|
167 |
}, |
|
168 |
|
|
169 |
end : function() |
|
170 |
{ |
|
171 |
document.onmousemove = null; |
|
172 |
document.onmouseup = null; |
|
173 |
Drag.obj.root.onDragEnd( |
|
174 |
parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), |
|
175 |
parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]), |
|
176 |
Drag.obj.root); |
|
177 |
Drag.obj = null; |
|
178 |
}, |
|
179 |
|
|
180 |
fixE : function(e) |
|
181 |
{ |
|
182 |
if (typeof e == 'undefined') e = window.event; |
|
183 |
if (typeof e.layerX == 'undefined') e.layerX = e.offsetX; |
|
184 |
if (typeof e.layerY == 'undefined') e.layerY = e.offsetY; |
|
185 |
return e; |
|
186 |
} |
|
187 |
}; |
usr/local/www/draglist.js | ||
---|---|---|
1 |
// ---------------------------------------------------------------------------- |
|
2 |
// (c) Copyright, DTLink, LLC 1997-2005 |
|
3 |
// http://www.dtlink.com |
|
4 |
// |
|
5 |
// DragList - Drag and Drop Ordered Lists |
|
6 |
// |
|
7 |
// Javascript Support file for formVista <draglist> fvml tag. |
|
8 |
// |
|
9 |
// For more information please see: |
|
10 |
// |
|
11 |
// http://www.formvista.com/otherprojects/draglist.html |
|
12 |
// |
|
13 |
// For questions or comments please contact us at: |
|
14 |
// |
|
15 |
// http://www.formvista.com/contact.html |
|
16 |
// |
|
17 |
// LICENSE: This file is governed by the new BSD license. For more information |
|
18 |
/* |
|
19 |
The DragList drag and drop ordered lists implementation is available under the terms of the new BSD license. |
|
20 |
|
|
21 |
Copyright (c) 2005, DTLink, LLC |
|
22 |
All rights reserved. |
|
23 |
|
|
24 |
Redistribution and use in source and binary forms, with or |
|
25 |
without modification, are permitted provided that the following |
|
26 |
conditions are met: |
|
27 |
|
|
28 |
* Redistributions of source code must retain the above |
|
29 |
copyright notice, this list of conditions and the following |
|
30 |
disclaimer. |
|
31 |
|
|
32 |
* Redistributions in binary form must reproduce the above |
|
33 |
copyright notice, this list of conditions and the following |
|
34 |
disclaimer in the documentation and/or other materials provided |
|
35 |
with the distribution. |
|
36 |
|
|
37 |
* Neither the name of DTLink, LLC nor the names of its |
|
38 |
contributors may be used to endorse or promote products derived |
|
39 |
from this software without specific prior written permission. |
|
40 |
|
|
41 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
|
42 |
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
43 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
44 |
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
45 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
46 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
47 |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
|
48 |
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
49 |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
50 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
51 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
52 |
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
53 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
54 |
*/ |
|
55 |
// |
|
56 |
// REVISION HISTORY: |
|
57 |
// |
|
58 |
// 2004-11-12 YmL: |
|
59 |
// . initial revision. |
|
60 |
// |
|
61 |
// 2005-05-28 YmL: |
|
62 |
// . pulled out of formVista, relicensed and packaged as a standalone implementation. |
|
63 |
// |
|
64 |
// 2005-06-02 mtmosier: |
|
65 |
// . added horizontal dragging support. |
|
66 |
// |
|
67 |
// ------------------------ |
|
68 |
|
|
69 |
/** |
|
70 |
* constructor for dragList class |
|
71 |
*/ |
|
72 |
|
|
73 |
function fv_dragList( name ) |
|
74 |
{ |
|
75 |
|
|
76 |
// name of this dragList. Must match the id of the root DIV tag. |
|
77 |
|
|
78 |
this.dragListRootId = name; |
|
79 |
|
|
80 |
// array of item offsets |
|
81 |
|
|
82 |
this.offsetsX = new Array(); |
|
83 |
this.offsetsY = new Array(); |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
// ---------------------------------------------- |
|
88 |
|
|
89 |
/** |
|
90 |
* setup the draglist prior to use |
|
91 |
* |
|
92 |
* @param string orientation defaults to vert. if set to "horz" renders horizontally. |
|
93 |
* @param string itemTagName. if null defaults to "div". Can be "span". |
|
94 |
*/ |
|
95 |
|
|
96 |
fv_dragList.prototype.setup = function( orientation, itemTagName ) |
|
97 |
{ |
|
98 |
|
|
99 |
var horizontal; |
|
100 |
|
|
101 |
if ( orientation == "horz" ) |
|
102 |
horizontal = true; |
|
103 |
else |
|
104 |
horizontal = false; |
|
105 |
|
|
106 |
this.listRoot = document.getElementById( this.dragListRootId ); |
|
107 |
this.listItems = this.getListItems( itemTagName ); |
|
108 |
|
|
109 |
for (var i = 0; i < this.listItems.length; i++) |
|
110 |
{ |
|
111 |
|
|
112 |
if ( this.listItems[i] == undefined ) |
|
113 |
continue; |
|
114 |
|
|
115 |
if ( horizontal ) |
|
116 |
{ |
|
117 |
Drag.init(this.listItems[i], null, null, null, 0, 0); |
|
118 |
} |
|
119 |
else |
|
120 |
{ |
|
121 |
Drag.init(this.listItems[i], null, 0, 0, null, null); |
|
122 |
} |
|
123 |
|
|
124 |
// --------------------------------------------------- |
|
125 |
// on drag method |
|
126 |
|
|
127 |
this.listItems[i].onDrag = function( x, y, thisElem ) |
|
128 |
{ |
|
129 |
|
|
130 |
x = thisElem.offsetLeft; |
|
131 |
y = thisElem.offsetTop; |
|
132 |
|
|
133 |
// this is a callback from the dom-drag code. From within this |
|
134 |
// function "this" does not refer to the fv_draglist function. |
|
135 |
|
|
136 |
draglist = getDragList( thisElem ); |
|
137 |
|
|
138 |
draglist.recalcOffsets( itemTagName ); |
|
139 |
|
|
140 |
var pos = draglist.getCurrentOffset( thisElem, itemTagName ); |
|
141 |
|
|
142 |
//var listItems = this.getListItems( itemTagName ); |
|
143 |
|
|
144 |
// if bottom edge is below top of lower item. |
|
145 |
|
|
146 |
var testMoveUp; |
|
147 |
var testMoveDown; |
|
148 |
if ( horizontal ) |
|
149 |
{ |
|
150 |
testMoveUp = (x + draglist.getDivWidth(thisElem) > draglist.offsetsX[pos + 1] + draglist.getDivWidth( draglist.listItems[pos + 1] )); |
|
151 |
testMoveDown = x < draglist.offsetsX[pos - 1]; |
|
152 |
} |
|
153 |
else |
|
154 |
{ |
|
155 |
testMoveUp = (y + draglist.getDivHeight(thisElem) > draglist.offsetsY[pos + 1] + draglist.getDivHeight( draglist.listItems[pos + 1] )); |
|
156 |
testMoveDown = y < draglist.offsetsY[pos - 1]; |
|
157 |
} |
|
158 |
|
|
159 |
if (( pos != draglist.listItems.length - 1) && testMoveUp ) |
|
160 |
{ |
|
161 |
draglist.listRoot.removeChild(thisElem); |
|
162 |
|
|
163 |
if ( pos + 1 == draglist.listItems.length ) |
|
164 |
{ |
|
165 |
draglist.listRoot.appendChild( thisElem ); |
|
166 |
} |
|
167 |
else |
|
168 |
{ |
|
169 |
draglist.listRoot.insertBefore(thisElem, draglist.listItems[pos+1]); |
|
170 |
} |
|
171 |
|
|
172 |
thisElem.style["top"] = "0px"; |
|
173 |
thisElem.style["left"] = "0px"; |
|
174 |
} |
|
175 |
else if ( pos != 0 && testMoveDown ) |
|
176 |
{ |
|
177 |
draglist.listRoot.removeChild(thisElem); |
|
178 |
draglist.listRoot.insertBefore(thisElem, draglist.listItems[pos-1]); |
|
179 |
thisElem.style["top"] = "0px"; |
|
180 |
thisElem.style["left"] = "0px"; |
|
181 |
} |
|
182 |
|
|
183 |
}; |
|
184 |
|
|
185 |
this.listItems[i].onDragEnd = function(x,y,thisElem) |
|
186 |
{ |
|
187 |
thisElem.style["top"] = "0px"; |
|
188 |
thisElem.style["left"] = "0px"; |
|
189 |
}; |
|
190 |
|
|
191 |
} // end of for loop. |
|
192 |
|
|
193 |
this.recalcOffsets( itemTagName ); |
|
194 |
|
|
195 |
}; // end of setup. |
|
196 |
|
|
197 |
// ---------------------------------------------- |
|
198 |
|
|
199 |
|
|
200 |
/** |
|
201 |
* update the order value fields and submit the form. |
|
202 |
*/ |
|
203 |
|
|
204 |
fv_dragList.prototype.do_submit = function( formName, dragListRootId ) |
|
205 |
{ |
|
206 |
|
|
207 |
var listOrderItems = this.listRoot.getElementsByTagName("input"); |
|
208 |
|
|
209 |
for (var i = 0; i < listOrderItems.length; i++) |
|
210 |
{ |
|
211 |
listOrderItems[i].value = i; |
|
212 |
} |
|
213 |
|
|
214 |
expr = "document." + formName + ".submit()"; |
|
215 |
|
|
216 |
eval( expr ); |
|
217 |
}; |
|
218 |
|
|
219 |
// ---------------------------------------------- |
|
220 |
// "Private" methods. |
|
221 |
// ---------------------------------------------- |
|
222 |
|
|
223 |
fv_dragList.prototype.recalcOffsets = function( itemTagName ) |
|
224 |
{ |
|
225 |
var listItems = this.getListItems( itemTagName ); |
|
226 |
|
|
227 |
for (var i = 0; i < listItems.length; i++) |
|
228 |
{ |
|
229 |
this.offsetsX[i] = listItems[i].offsetLeft; |
|
230 |
this.offsetsY[i] = listItems[i].offsetTop; |
|
231 |
} |
|
232 |
}; |
|
233 |
|
|
234 |
fv_dragList.prototype.getCurrentOffset = function(elem, itemTagName) |
|
235 |
{ |
|
236 |
var listItems = this.getListItems( itemTagName ); |
|
237 |
|
|
238 |
for (var i = 0; i < listItems.length; i++) |
|
239 |
{ |
|
240 |
if (listItems[i] == elem) |
|
241 |
{ |
|
242 |
return i; |
|
243 |
} |
|
244 |
} |
|
245 |
}; |
|
246 |
|
|
247 |
fv_dragList.prototype.getDivWidth = function(elem) |
|
248 |
{ |
|
249 |
|
|
250 |
if (( elem == undefined) || ( elem.offsetWidth == undefined )) |
|
251 |
return( 0 ); |
|
252 |
|
|
253 |
value = elem.offsetWidth; |
|
254 |
if (isNaN(value)) |
|
255 |
{ |
|
256 |
value = 0; |
|
257 |
} |
|
258 |
|
|
259 |
return( value ); |
|
260 |
}; |
|
261 |
|
|
262 |
fv_dragList.prototype.getDivHeight = function(elem) |
|
263 |
{ |
|
264 |
|
|
265 |
if (( elem == undefined) || ( elem.offsetHeight == undefined )) |
|
266 |
return( 0 ); |
|
267 |
|
|
268 |
value = elem.offsetHeight; |
|
269 |
if (isNaN(value)) |
|
270 |
{ |
|
271 |
value = 25; |
|
272 |
} |
|
273 |
|
|
274 |
return( value ); |
|
275 |
}; |
|
276 |
|
|
277 |
/** |
|
278 |
* return list of draggable items |
|
279 |
*/ |
|
280 |
|
|
281 |
fv_dragList.prototype.getListItems = function( itemTagName ) |
|
282 |
{ |
|
283 |
if ( itemTagName == undefined ) |
|
284 |
{ |
|
285 |
itemTagName = "div"; |
|
286 |
} |
|
287 |
|
|
288 |
var listItems = this.listRoot.getElementsByTagName( itemTagName ); |
|
289 |
|
|
290 |
return( listItems ); |
|
291 |
}; |
|
292 |
|
|
293 |
// end of draglist class definition. |
|
294 |
|
|
295 |
// ------------------------------------- |
|
296 |
|
|
297 |
/** |
|
298 |
* add a new dragList to the list of draglists on this page |
|
299 |
* |
|
300 |
* This implementatoin supports multiple managed draglists on |
|
301 |
* a single page. The index is contained in a global dragListIndex |
|
302 |
* array that must be declared in the page. |
|
303 |
*/ |
|
304 |
|
|
305 |
function addDragList( draglist ) |
|
306 |
{ |
|
307 |
dragListIndex[ draglist.dragListRootId ] = draglist; |
|
308 |
} |
|
309 |
|
|
310 |
// ------------------------------------------------------- |
|
311 |
|
|
312 |
/** |
|
313 |
* given a draggable div element, return the draglist it belongs to |
|
314 |
* |
|
315 |
* @see fv_draglist.prototype.setup |
|
316 |
* @todo this should probably be a method inside the draglist class. |
|
317 |
*/ |
|
318 |
|
|
319 |
function getDragList( elem ) |
|
320 |
{ |
|
321 |
|
|
322 |
// given a list item return the drag list it belongs to. |
|
323 |
|
|
324 |
var draglistContainer = elem.parentNode; |
|
325 |
|
|
326 |
var draglist = dragListIndex[ draglistContainer.id ]; |
|
327 |
|
|
328 |
return( draglist ); |
|
329 |
} |
|
330 |
|
|
331 |
// END |
usr/local/www/dtree.js | ||
---|---|---|
1 |
function navigate(url) { |
|
2 |
location.href=url; |
|
3 |
} |
|
4 |
|
|
5 |
// getElementByID with browser check!! |
|
6 |
|
|
7 |
function getElById(idVal) { |
|
8 |
if (document.getElementById != null) |
|
9 |
return document.getElementById(idVal); |
|
10 |
if (document.all != null) |
|
11 |
return document.all[idVal]; |
|
12 |
|
|
13 |
alert("Problem getting element by id"); |
|
14 |
return null; |
|
15 |
} |
|
16 |
|
|
17 |
|
|
18 |
// Node object |
|
19 |
|
|
20 |
function Node(id, pid, name, url, title, target, icon, iconOpen, open , checkable ,checked, add, del) { |
|
21 |
|
|
22 |
this.id = id; |
|
23 |
|
|
24 |
this.pid = pid; |
|
25 |
|
|
26 |
this.name = name; |
|
27 |
|
|
28 |
this.url = url; |
|
29 |
|
|
30 |
this.title = title; |
|
31 |
|
|
32 |
this.target = target; |
|
33 |
|
|
34 |
this.icon = icon; |
|
35 |
|
|
36 |
this.iconOpen = iconOpen; |
|
37 |
|
|
38 |
this._io = open || false; |
|
39 |
|
|
40 |
this.checkable = checkable || false; |
|
41 |
|
|
42 |
this.checked = checked || false; |
|
43 |
|
|
44 |
this.add = add || false; |
|
45 |
|
|
46 |
this.del = del || false; |
|
47 |
|
|
48 |
this._is = false; |
|
49 |
|
|
50 |
this._ls = false; |
|
51 |
|
|
52 |
this._hc = false; |
|
53 |
|
|
54 |
this._ai = 0; |
|
55 |
|
|
56 |
this._p; |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
// Tree object |
|
61 |
|
|
62 |
function dTree(objName) { |
|
63 |
|
|
64 |
this.config = { |
|
65 |
|
|
66 |
target : null, |
|
67 |
|
|
68 |
folderLinks : true, |
|
69 |
|
|
70 |
useSelection : true, |
|
71 |
|
|
72 |
useCookies : true, |
|
73 |
|
|
74 |
useLines : true, |
|
75 |
|
|
76 |
useIcons : true, |
|
77 |
|
|
78 |
useStatusText : false, |
|
79 |
|
|
80 |
closeSameLevel : false, |
|
81 |
|
|
82 |
inOrder : false |
|
83 |
|
|
84 |
}; |
|
85 |
|
|
86 |
this.icon = { |
|
87 |
|
|
88 |
root : 'tree-images/zone.gif', |
|
89 |
|
|
90 |
folder : 'tree-images/folder.gif', |
|
91 |
|
|
92 |
folderOpen : 'tree-images/folderopen.gif', |
|
93 |
|
|
94 |
node : 'tree-images/page.gif', |
|
95 |
|
|
96 |
empty : 'tree-images/empty.gif', |
|
97 |
|
|
98 |
line : 'tree-images/line.gif', |
|
99 |
|
|
100 |
join : 'tree-images/join.gif', |
|
101 |
|
|
102 |
joinBottom : 'tree-images/joinbottom.gif', |
|
103 |
|
|
104 |
plus : 'tree-images/plus_updown.gif', |
|
105 |
|
|
106 |
plusBottom : 'tree-images/plus_up.gif', |
|
107 |
|
|
108 |
minus : 'tree-images/minus_.gif', |
|
109 |
|
|
110 |
minusBottom : 'tree-images/minus_up.gif', |
|
111 |
|
|
112 |
nlPlus : 'tree-images/plus_.gif', |
|
113 |
|
|
114 |
nlMinus : 'tree-images/minus_.gif' |
|
115 |
|
|
116 |
}; |
|
117 |
|
|
118 |
this.obj = objName; |
|
119 |
|
|
120 |
this.aNodes = []; |
|
121 |
|
|
122 |
this.aIndent = []; |
|
123 |
|
|
124 |
this.root = new Node(-1); |
|
125 |
|
|
126 |
this.selectedNode = null; |
|
127 |
|
|
128 |
this.selectedFound = false; |
|
129 |
|
|
130 |
this.completed = false; |
|
131 |
|
|
132 |
} |
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
// Adds a new node to the node array |
|
137 |
|
|
138 |
dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open, checkable, checked, add, del) { |
|
139 |
|
|
140 |
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open, checkable, checked, add, del); |
|
141 |
|
|
142 |
}; |
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
// Open/close all nodes |
|
147 |
|
|
148 |
dTree.prototype.openAll = function() { |
|
149 |
|
|
150 |
this.oAll(true); |
|
151 |
|
|
152 |
}; |
|
153 |
|
|
154 |
dTree.prototype.closeAll = function() { |
|
155 |
|
|
156 |
this.oAll(false); |
|
157 |
|
|
158 |
}; |
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
// Outputs the tree to the page |
|
163 |
|
|
164 |
dTree.prototype.toString = function() { |
|
165 |
|
|
166 |
var str = '<div class="treeview">\n'; |
|
167 |
|
|
168 |
if (document.getElementById) { |
|
169 |
|
|
170 |
if (this.config.useCookies) this.selectedNode = this.getSelected(); |
|
171 |
|
|
172 |
str += this.addNode(this.root); |
|
173 |
|
|
174 |
} else str += 'Browser not supported.'; |
|
175 |
|
|
176 |
str += '</div>'; |
|
177 |
|
|
178 |
if (!this.selectedFound) this.selectedNode = null; |
|
179 |
|
|
180 |
this.completed = true; |
|
181 |
|
|
182 |
return str; |
|
183 |
|
|
184 |
}; |
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
// Creates the tree structure |
|
189 |
|
|
190 |
dTree.prototype.addNode = function(pNode) { |
|
191 |
|
|
192 |
var str = ''; |
|
193 |
|
|
194 |
var n=0; |
|
195 |
|
|
196 |
if (this.config.inOrder) n = pNode._ai; |
|
197 |
|
|
198 |
for (n; n<this.aNodes.length; n++) { |
|
199 |
|
|
200 |
if (this.aNodes[n].pid == pNode.id) { |
|
201 |
|
|
202 |
var cn = this.aNodes[n]; |
|
203 |
|
|
204 |
cn._p = pNode; |
|
205 |
|
|
206 |
cn._ai = n; |
|
207 |
|
|
208 |
this.setCS(cn); |
|
209 |
|
|
210 |
if (!cn.target && this.config.target) cn.target = this.config.target; |
|
211 |
|
|
212 |
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id); |
|
213 |
|
|
214 |
if (!this.config.folderLinks && cn._hc) cn.url = null; |
|
215 |
|
|
216 |
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) { |
|
217 |
|
|
218 |
cn._is = true; |
|
219 |
|
|
220 |
this.selectedNode = n; |
|
221 |
|
|
222 |
this.selectedFound = true; |
|
223 |
|
|
224 |
} |
|
225 |
|
|
226 |
str += this.node(cn, n); |
|
227 |
|
|
228 |
if (cn._ls) break; |
|
229 |
|
|
230 |
} |
|
231 |
|
|
232 |
} |
|
233 |
|
|
234 |
return str; |
|
235 |
|
|
236 |
}; |
|
237 |
|
|
238 |
|
|
239 |
// Creates the node icon, url and text |
|
240 |
|
|
241 |
dTree.prototype.node = function(node, nodeId) { |
|
242 |
|
|
243 |
var str = '<div class="node" >' + this.indent(node, nodeId); |
|
244 |
|
|
245 |
if (this.config.useIcons) { |
|
246 |
|
|
247 |
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node); |
|
248 |
|
|
249 |
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node; |
|
250 |
|
|
251 |
if (this.root.id == node.pid) { |
|
252 |
|
|
253 |
node.icon = this.icon.root; |
|
254 |
|
|
255 |
node.iconOpen = this.icon.root; |
|
256 |
|
|
257 |
} |
|
258 |
|
|
259 |
//class="img" border="10" vspace="18" align="bottom" style="border:0px; margin:0; padding:0; FILTER: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=50); -moz-opacity:0.5" |
|
260 |
str += '<img style="border:0; margin:0; padding:0; height:16px; vertical-align:top; overflow:hidden;" id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />'; |
|
261 |
if (node.checkable) { |
|
262 |
str += '<input style="border:0; margin:0; padding:0; height:16px; vertical-align:top; overflow:hidden; FILTER: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=50); " type="checkbox" id="c' + this.obj + node.id + '" onclick="javascript : ' + this.obj + '.c(' + node.id + ');"'; |
|
263 |
if (node.checked) str += ' checked >'; else str += ' >'; |
|
264 |
}//else str+=''; |
|
265 |
|
|
266 |
} |
|
267 |
|
|
268 |
if (node.url) { |
|
269 |
|
|
270 |
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="javascript:navigate(\'' + node.url + '\')"'; |
|
271 |
|
|
272 |
if (node.title) str += ' title="' + node.title + '"'; |
|
273 |
|
|
274 |
//if (node.target) str += ' target="' + node.target + ';"'; |
|
275 |
|
|
276 |
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" '; |
|
277 |
|
|
278 |
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc)) |
|
279 |
|
|
280 |
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"'; |
|
281 |
|
|
282 |
str += '>'; |
|
283 |
|
|
284 |
} |
|
285 |
|
|
286 |
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id) |
|
287 |
|
|
288 |
str += '<a style="border:0; margin:0; padding:0; text-size: smaller; vertical-align: top; overflow:hidden;" href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">'; |
|
289 |
|
|
290 |
str += ' '+node.name; |
|
291 |
|
|
292 |
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>'; |
|
293 |
|
|
294 |
if (node.add && node.url) { |
|
295 |
str += ' -- <a href="' + node.url + '&qaction=addsub"/> <img style="border:0; margin:0; padding:0; width: 16px; height:16px; vertical-align: top; overflow:hidden;" id="i' + this.obj + nodeId + '" src="images/plus.gif" alt="" /></a>'; |
|
296 |
} |
|
297 |
if (node.del && node.url) { |
|
298 |
str += ' <a href="' + node.url + '&qaction=delete"/> <img style="border:0; margin:0; padding:0; width: 11px; height:11px; vertical-align: top; overflow:hidden;" id="i' + this.obj + nodeId + '" src="images/block.gif" alt="" /></a>'; |
|
299 |
} |
|
300 |
|
|
301 |
if (node._hc) { |
|
302 |
|
|
303 |
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">'; |
|
304 |
|
|
305 |
str += this.addNode(node); |
|
306 |
|
|
307 |
str += '</div>'; |
|
308 |
|
|
309 |
} |
|
310 |
|
|
311 |
str += '</div>'; |
|
312 |
|
|
313 |
this.aIndent.pop(); |
|
314 |
|
|
315 |
return str; |
|
316 |
|
|
317 |
}; |
|
318 |
|
|
319 |
|
|
320 |
// Adds the empty and line icons |
|
321 |
|
|
322 |
dTree.prototype.indent = function(node, nodeId) { |
|
323 |
|
|
324 |
var str = ''; |
|
325 |
|
|
326 |
if (this.root.id != node.pid) { |
|
327 |
|
|
328 |
for (var n=0; n<this.aIndent.length; n++) |
|
329 |
|
|
330 |
str += '<img style="verical-align: top;" src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />'; |
|
331 |
|
|
332 |
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); |
|
333 |
|
|
334 |
if (node._hc) { |
|
335 |
|
|
336 |
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="'; |
|
337 |
|
|
338 |
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus; |
|
339 |
|
|
340 |
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) ); |
|
341 |
|
|
342 |
str += '" alt="" /></a>'; |
|
343 |
|
|
344 |
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />'; |
|
345 |
|
|
346 |
} |
|
347 |
|
|
348 |
return str; |
|
349 |
|
|
350 |
}; |
|
351 |
|
|
352 |
|
|
353 |
|
|
354 |
// Checks if a node has any children and if it is the last sibling |
|
355 |
|
|
356 |
dTree.prototype.setCS = function(node) { |
|
357 |
|
|
358 |
var lastId; |
|
359 |
|
|
360 |
for (var n=0; n<this.aNodes.length; n++) { |
|
361 |
|
|
362 |
if (this.aNodes[n].pid == node.id) node._hc = true; |
|
363 |
|
|
364 |
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id; |
|
365 |
|
|
366 |
} |
|
367 |
|
|
368 |
if (lastId==node.id) node._ls = true; |
|
369 |
|
|
370 |
}; |
|
371 |
|
|
372 |
|
|
373 |
|
|
374 |
// Returns the selected node |
|
375 |
|
|
376 |
dTree.prototype.getSelected = function() { |
|
377 |
|
|
378 |
var sn = this.getCookie('cs' + this.obj); |
|
379 |
|
|
380 |
return (sn) ? sn : null; |
|
381 |
|
|
382 |
}; |
|
383 |
|
|
384 |
|
|
385 |
|
|
386 |
// Highlights the selected node |
|
387 |
|
|
388 |
dTree.prototype.s = function(id) { |
|
389 |
|
|
390 |
if (!this.config.useSelection) return; |
|
391 |
|
|
392 |
var cn = this.aNodes[id]; |
|
393 |
|
|
394 |
if (cn._hc && !this.config.folderLinks) return; |
|
395 |
|
|
396 |
if (this.selectedNode != id) { |
|
397 |
|
|
398 |
if (this.selectedNode || this.selectedNode==0) { |
|
399 |
|
|
400 |
eOld = document.getElementById("s" + this.obj + this.selectedNode); |
|
401 |
|
|
402 |
eOld.className = "node"; |
|
403 |
|
|
404 |
} |
|
405 |
|
|
406 |
eNew = document.getElementById("s" + this.obj + id); |
|
407 |
|
|
408 |
eNew.className = "nodeSel"; |
|
409 |
|
|
410 |
this.selectedNode = id; |
|
411 |
|
|
412 |
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id); |
|
413 |
|
|
414 |
} |
|
415 |
|
|
416 |
}; |
|
417 |
|
|
418 |
// Checks all parents |
|
419 |
|
|
420 |
dTree.prototype.c = function(id) { |
|
421 |
|
|
422 |
//alert('callid='+id); |
|
423 |
|
|
424 |
var n=0; |
|
425 |
|
|
426 |
var parent; |
|
427 |
|
|
428 |
parent = document.getElementById("c" + this.obj + id); |
|
429 |
|
|
430 |
//if (parent.checked==true) parent.checked=false; else parent.checked=true; |
|
431 |
|
|
432 |
var what = parent.checked; |
|
433 |
|
|
434 |
for (n; n<this.aNodes.length; n++) { |
|
435 |
|
|
436 |
if (this.aNodes[n].pid == id) { |
|
437 |
|
|
438 |
var cn = this.aNodes[n]; |
|
439 |
|
|
440 |
element = document.getElementById("c" + this.obj + cn.id); |
|
441 |
|
|
442 |
element.checked = what; |
|
443 |
|
|
444 |
cn.checked = what; |
|
445 |
|
|
446 |
//alert(cn.pid+'(child)==(parent)'+id+'->'+cn.id+'='+what+','+this.aNodes.length ); |
|
447 |
|
|
448 |
this.c(cn.id); |
|
449 |
|
|
450 |
} |
|
451 |
|
|
452 |
} |
|
453 |
|
|
454 |
}; |
|
455 |
|
|
456 |
|
|
457 |
dTree.prototype.generate_checkedlist = function(id) { |
|
458 |
|
|
459 |
var retStr=''; |
|
460 |
|
|
461 |
var n=0; |
|
462 |
|
|
463 |
var parent = document.getElementById("c" + this.obj + id); |
|
464 |
|
|
465 |
for (n; n<this.aNodes.length; n++) { |
|
466 |
|
|
467 |
if (this.aNodes[n].pid == id) { |
|
468 |
|
|
469 |
var cn = this.aNodes[n]; |
|
470 |
|
|
471 |
var element = document.getElementById("c" + this.obj + cn.id); |
|
472 |
|
|
473 |
//alert(cn.name + ' = ' +element.checked); |
|
474 |
|
|
475 |
if (element.checked) { |
|
476 |
|
|
477 |
if (retStr == '') |
|
478 |
{retStr = cn.name; }// this.generate_checkedlist(cn.id); |
|
479 |
else |
|
480 |
retStr += ',' + cn.name;//this.generate_checkedlist(cn.id); |
|
481 |
} |
|
482 |
//alert(cn.pid+'(child)==(parent)'+id+'->'+cn.id+'='+what+','+this.aNodes.length ); |
|
483 |
|
|
484 |
} |
|
485 |
|
|
486 |
} |
|
487 |
|
|
488 |
return retStr; |
|
489 |
}; |
|
490 |
|
|
491 |
// Toggle Open or close |
|
492 |
|
|
493 |
dTree.prototype.o = function(id) { |
|
494 |
|
|
495 |
var cn = this.aNodes[id]; |
|
496 |
|
|
497 |
this.nodeStatus(!cn._io, id, cn._ls); |
|
498 |
|
|
499 |
cn._io = !cn._io; |
|
500 |
|
|
501 |
if (this.config.closeSameLevel) this.closeLevel(cn); |
|
502 |
|
|
503 |
if (this.config.useCookies) this.updateCookie(); |
|
504 |
|
|
505 |
}; |
|
506 |
|
|
507 |
|
|
508 |
|
|
509 |
// Open or close all nodes |
|
510 |
|
|
511 |
dTree.prototype.oAll = function(status) { |
|
512 |
|
|
513 |
for (var n=0; n<this.aNodes.length; n++) { |
|
514 |
|
|
515 |
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) { |
|
516 |
|
|
517 |
this.nodeStatus(status, n, this.aNodes[n]._ls); |
|
518 |
|
|
519 |
this.aNodes[n]._io = status; |
|
520 |
|
|
521 |
} |
|
522 |
|
|
523 |
} |
|
524 |
|
|
525 |
if (this.config.useCookies) this.updateCookie(); |
|
526 |
|
|
527 |
}; |
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
// Opens the tree to a specific node |
|
532 |
|
|
533 |
dTree.prototype.openTo = function(nId, bSelect, bFirst) { |
|
534 |
|
|
535 |
if (!bFirst) { |
|
536 |
|
|
537 |
for (var n=0; n<this.aNodes.length; n++) { |
|
538 |
|
|
539 |
if (this.aNodes[n].id == nId) { |
|
540 |
|
|
541 |
nId=n; |
|
542 |
|
|
543 |
break; |
|
544 |
|
|
545 |
} |
|
546 |
|
|
547 |
} |
|
548 |
|
|
549 |
} |
|
550 |
|
|
551 |
var cn=this.aNodes[nId]; |
|
552 |
|
|
553 |
if (cn.pid==this.root.id || !cn._p) return; |
|
554 |
|
|
555 |
cn._io = true; |
|
556 |
|
|
557 |
cn._is = bSelect; |
|
558 |
|
|
559 |
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls); |
|
560 |
|
|
561 |
if (this.completed && bSelect) this.s(cn._ai); |
|
562 |
|
|
563 |
else if (bSelect) this._sn=cn._ai; |
|
564 |
|
|
565 |
this.openTo(cn._p._ai, false, true); |
|
566 |
|
|
567 |
}; |
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
// Closes all nodes on the same level as certain node |
|
572 |
|
|
573 |
dTree.prototype.closeLevel = function(node) { |
|
574 |
|
|
575 |
for (var n=0; n<this.aNodes.length; n++) { |
|
576 |
|
|
577 |
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) { |
|
578 |
|
|
579 |
this.nodeStatus(false, n, this.aNodes[n]._ls); |
|
580 |
|
|
581 |
this.aNodes[n]._io = false; |
|
582 |
|
|
583 |
this.closeAllChildren(this.aNodes[n]); |
|
584 |
|
|
585 |
} |
|
586 |
|
Also available in: Unified diff
Massive javascript cleanup, all .js files now live in $g['www_path']/javascript
Purged unused JS