Index: trunk/extensions/TreeAndMenu/img/folder.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/musicfolder.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/page.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/minusbottom.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/trash.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/nolines_minus.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/plus.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/cd.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/globe.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/minus.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/folderopen.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/question.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/imgfolder.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/plusbottom.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/nolines_plus.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/img/base.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Index: trunk/extensions/TreeAndMenu/TreeAndMenu.php |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | var $uniqname = 'tam'; # input name for uniqid |
45 | 45 | var $id = ''; # id for specific tree |
46 | 46 | var $baseDir = ''; # internal absolute path to treeview directory |
| 47 | + var $baseRelDir = ''; # internal relative path to treeview directory |
47 | 48 | var $baseUrl = ''; # external URL to treeview directory (relative to domain) |
48 | 49 | var $images = ''; # internal JS to update dTree images |
49 | 50 | var $useLines = true; # internal variable determining whether to render connector lines |
— | — | @@ -63,6 +64,9 @@ |
64 | 65 | |
65 | 66 | # Update general tree paths and properties |
66 | 67 | $this->baseDir = dirname( __FILE__ ); |
| 68 | + $this->baseRelDir = strstr( $this->baseDir, 'extensions'); |
| 69 | + $this->baseRelDir = str_replace( '\\', '/',$this->baseRelDir ); |
| 70 | + $this->baseRelDir = $wgScriptPath . '/' . $this->baseRelDir; |
67 | 71 | $this->baseUrl = str_replace( '\\', '/', $this->baseDir ); |
68 | 72 | $this->baseUrl = preg_replace( '|^.+(?=/ext)|', $wgScriptPath, $this->baseDir ); |
69 | 73 | $this->useLines = $wgTreeViewShowLines ? 'true' : 'false'; |
— | — | @@ -77,7 +81,7 @@ |
78 | 82 | } |
79 | 83 | |
80 | 84 | # Add link to output to load dtree.js script |
81 | | - $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"{$this->baseUrl}/dtree.js\"><!-- TreeAndMenu --></script>\n" ); |
| 85 | + $wgOut->addScript( "<script type=\"$wgJsMimeType\" src=\"{$this->baseRelDir}/dtree.js\"><!-- TreeAndMenu --></script>\n" ); |
82 | 86 | } |
83 | 87 | |
84 | 88 | |
— | — | @@ -229,7 +233,7 @@ |
230 | 234 | <script type=\"$wgJsMimeType\">/*<![CDATA[*/ |
231 | 235 | // TreeAndMenu{$this->version} |
232 | 236 | tree = new dTree('$objid'); |
233 | | - for (i in tree.icon) tree.icon[i] = '{$this->baseUrl}/'+tree.icon[i];{$this->images} |
| 237 | + for (i in tree.icon) tree.icon[i] = '{$this->baseRelDir}/'+tree.icon[i];{$this->images} |
234 | 238 | tree.config.useLines = {$this->useLines}; |
235 | 239 | $add |
236 | 240 | $objid = tree; |
Index: trunk/extensions/TreeAndMenu/dtree.js |
— | — | @@ -1,693 +1,347 @@ |
2 | 2 | /*--------------------------------------------------| |
3 | | - |
4 | 3 | | dTree 2.05 | www.destroydrop.com/javascript/tree/ | |
5 | | - |
6 | 4 | |---------------------------------------------------| |
7 | | - |
8 | 5 | | Copyright (c) 2002-2003 Geir Landrö | |
9 | | - |
10 | 6 | | | |
11 | | - |
12 | 7 | | This script can be used freely as long as all | |
13 | | - |
14 | 8 | | copyright messages are intact. | |
15 | | - |
16 | 9 | | | |
17 | | - |
18 | 10 | | Updated: 17.04.2003 | |
19 | | - |
20 | 11 | |--------------------------------------------------*/ |
21 | 12 | |
22 | | - |
23 | | - |
24 | 13 | // Node object |
25 | | - |
26 | 14 | function Node(id, pid, name, url, title, target, icon, iconOpen, open) { |
27 | | - |
28 | 15 | this.id = id; |
29 | | - |
30 | 16 | this.pid = pid; |
31 | | - |
32 | 17 | this.name = name; |
33 | | - |
34 | 18 | this.url = url; |
35 | | - |
36 | 19 | this.title = title; |
37 | | - |
38 | 20 | this.target = target; |
39 | | - |
40 | 21 | this.icon = icon; |
41 | | - |
42 | 22 | this.iconOpen = iconOpen; |
43 | | - |
44 | 23 | this._io = open || false; |
45 | | - |
46 | 24 | this._is = false; |
47 | | - |
48 | 25 | this._ls = false; |
49 | | - |
50 | 26 | this._hc = false; |
51 | | - |
52 | 27 | this._ai = 0; |
53 | | - |
54 | 28 | this._p; |
55 | | - |
56 | 29 | }; |
57 | 30 | |
58 | | - |
59 | | - |
60 | 31 | // Tree object |
61 | | - |
62 | 32 | function dTree(objName) { |
63 | | - |
64 | 33 | this.config = { |
65 | | - |
66 | 34 | target : null, |
67 | | - |
68 | 35 | folderLinks : true, |
69 | | - |
70 | 36 | useSelection : true, |
71 | | - |
72 | 37 | useCookies : true, |
73 | | - |
74 | 38 | useLines : true, |
75 | | - |
76 | 39 | useIcons : true, |
77 | | - |
78 | 40 | useStatusText : false, |
79 | | - |
80 | 41 | closeSameLevel : false, |
81 | | - |
82 | 42 | inOrder : false |
83 | | - |
84 | 43 | } |
85 | | - |
86 | 44 | this.icon = { |
87 | | - |
88 | 45 | root : 'img/base.gif', |
89 | | - |
90 | 46 | folder : 'img/folder.gif', |
91 | | - |
92 | 47 | folderOpen : 'img/folderopen.gif', |
93 | | - |
94 | 48 | node : 'img/page.gif', |
95 | | - |
96 | 49 | empty : 'img/empty.gif', |
97 | | - |
98 | 50 | line : 'img/line.gif', |
99 | | - |
100 | 51 | join : 'img/join.gif', |
101 | | - |
102 | 52 | joinBottom : 'img/joinbottom.gif', |
103 | | - |
104 | 53 | plus : 'img/plus.gif', |
105 | | - |
106 | 54 | plusBottom : 'img/plusbottom.gif', |
107 | | - |
108 | 55 | minus : 'img/minus.gif', |
109 | | - |
110 | 56 | minusBottom : 'img/minusbottom.gif', |
111 | | - |
112 | 57 | nlPlus : 'img/nolines_plus.gif', |
113 | | - |
114 | 58 | nlMinus : 'img/nolines_minus.gif' |
115 | | - |
116 | 59 | }; |
117 | | - |
118 | 60 | this.obj = objName; |
119 | | - |
120 | 61 | this.aNodes = []; |
121 | | - |
122 | 62 | this.aIndent = []; |
123 | | - |
124 | 63 | this.root = new Node(-1); |
125 | | - |
126 | 64 | this.selectedNode = null; |
127 | | - |
128 | 65 | this.selectedFound = false; |
129 | | - |
130 | 66 | this.completed = false; |
131 | | - |
132 | 67 | }; |
133 | 68 | |
134 | | - |
135 | | - |
136 | 69 | // Adds a new node to the node array |
137 | | - |
138 | 70 | dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) { |
139 | | - |
140 | 71 | this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open); |
141 | | - |
142 | 72 | }; |
143 | 73 | |
144 | | - |
145 | | - |
146 | 74 | // Open/close all nodes |
147 | | - |
148 | 75 | dTree.prototype.openAll = function() { |
149 | | - |
150 | 76 | this.oAll(true); |
151 | | - |
152 | 77 | }; |
153 | | - |
154 | 78 | dTree.prototype.closeAll = function() { |
155 | | - |
156 | 79 | this.oAll(false); |
157 | | - |
158 | 80 | }; |
159 | 81 | |
160 | | - |
161 | | - |
162 | 82 | // Outputs the tree to the page |
163 | | - |
164 | 83 | dTree.prototype.toString = function() { |
165 | | - |
166 | 84 | var str = '<div class="dtree">\n'; |
167 | | - |
168 | 85 | if (document.getElementById) { |
169 | | - |
170 | 86 | if (this.config.useCookies) this.selectedNode = this.getSelected(); |
171 | | - |
172 | 87 | str += this.addNode(this.root); |
173 | | - |
174 | 88 | } else str += 'Browser not supported.'; |
175 | | - |
176 | 89 | str += '</div>'; |
177 | | - |
178 | 90 | if (!this.selectedFound) this.selectedNode = null; |
179 | | - |
180 | 91 | this.completed = true; |
181 | | - |
182 | 92 | return str; |
183 | | - |
184 | 93 | }; |
185 | 94 | |
186 | | - |
187 | | - |
188 | 95 | // Creates the tree structure |
189 | | - |
190 | 96 | dTree.prototype.addNode = function(pNode) { |
191 | | - |
192 | 97 | var str = ''; |
193 | | - |
194 | 98 | var n=0; |
195 | | - |
196 | 99 | if (this.config.inOrder) n = pNode._ai; |
197 | | - |
198 | 100 | for (n; n<this.aNodes.length; n++) { |
199 | | - |
200 | 101 | if (this.aNodes[n].pid == pNode.id) { |
201 | | - |
202 | 102 | var cn = this.aNodes[n]; |
203 | | - |
204 | 103 | cn._p = pNode; |
205 | | - |
206 | 104 | cn._ai = n; |
207 | | - |
208 | 105 | this.setCS(cn); |
209 | | - |
210 | 106 | if (!cn.target && this.config.target) cn.target = this.config.target; |
211 | | - |
212 | 107 | if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id); |
213 | | - |
214 | 108 | if (!this.config.folderLinks && cn._hc) cn.url = null; |
215 | | - |
216 | 109 | if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) { |
217 | | - |
218 | 110 | cn._is = true; |
219 | | - |
220 | 111 | this.selectedNode = n; |
221 | | - |
222 | 112 | this.selectedFound = true; |
223 | | - |
224 | 113 | } |
225 | | - |
226 | 114 | str += this.node(cn, n); |
227 | | - |
228 | 115 | if (cn._ls) break; |
229 | | - |
230 | 116 | } |
231 | | - |
232 | 117 | } |
233 | | - |
234 | 118 | return str; |
235 | | - |
236 | 119 | }; |
237 | 120 | |
238 | | - |
239 | | - |
240 | 121 | // Creates the node icon, url and text |
241 | | - |
242 | 122 | dTree.prototype.node = function(node, nodeId) { |
243 | | - |
244 | 123 | var str = '<div class="dTreeNode">' + this.indent(node, nodeId); |
245 | | - |
246 | 124 | if (this.config.useIcons) { |
247 | | - |
248 | 125 | if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node); |
249 | | - |
250 | 126 | if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node; |
251 | | - |
252 | 127 | if (this.root.id == node.pid) { |
253 | | - |
254 | 128 | node.icon = this.icon.root; |
255 | | - |
256 | 129 | node.iconOpen = this.icon.root; |
257 | | - |
258 | 130 | } |
259 | | - |
260 | 131 | str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />'; |
261 | | - |
262 | 132 | } |
263 | | - |
264 | 133 | if (node.url) { |
265 | | - |
266 | 134 | str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"'; |
267 | | - |
268 | 135 | if (node.title) str += ' title="' + node.title + '"'; |
269 | | - |
270 | 136 | if (node.target) str += ' target="' + node.target + '"'; |
271 | | - |
272 | 137 | if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" '; |
273 | | - |
274 | 138 | if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc)) |
275 | | - |
276 | 139 | str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"'; |
277 | | - |
278 | 140 | str += '>'; |
279 | | - |
280 | 141 | } |
281 | | - |
282 | 142 | else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id) |
283 | | - |
284 | 143 | str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">'; |
285 | | - |
286 | 144 | str += node.name; |
287 | | - |
288 | 145 | if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>'; |
289 | | - |
290 | 146 | str += '</div>'; |
291 | | - |
292 | 147 | if (node._hc) { |
293 | | - |
294 | 148 | str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">'; |
295 | | - |
296 | 149 | str += this.addNode(node); |
297 | | - |
298 | 150 | str += '</div>'; |
299 | | - |
300 | 151 | } |
301 | | - |
302 | 152 | this.aIndent.pop(); |
303 | | - |
304 | 153 | return str; |
305 | | - |
306 | 154 | }; |
307 | 155 | |
308 | | - |
309 | | - |
310 | 156 | // Adds the empty and line icons |
311 | | - |
312 | 157 | dTree.prototype.indent = function(node, nodeId) { |
313 | | - |
314 | 158 | var str = ''; |
315 | | - |
316 | 159 | if (this.root.id != node.pid) { |
317 | | - |
318 | 160 | for (var n=0; n<this.aIndent.length; n++) |
319 | | - |
320 | 161 | str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />'; |
321 | | - |
322 | 162 | (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1); |
323 | | - |
324 | 163 | if (node._hc) { |
325 | | - |
326 | 164 | str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="'; |
327 | | - |
328 | 165 | if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus; |
329 | | - |
330 | 166 | 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 ) ); |
331 | | - |
332 | 167 | str += '" alt="" /></a>'; |
333 | | - |
334 | 168 | } else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />'; |
335 | | - |
336 | 169 | } |
337 | | - |
338 | 170 | return str; |
339 | | - |
340 | 171 | }; |
341 | 172 | |
342 | | - |
343 | | - |
344 | 173 | // Checks if a node has any children and if it is the last sibling |
345 | | - |
346 | 174 | dTree.prototype.setCS = function(node) { |
347 | | - |
348 | 175 | var lastId; |
349 | | - |
350 | 176 | for (var n=0; n<this.aNodes.length; n++) { |
351 | | - |
352 | 177 | if (this.aNodes[n].pid == node.id) node._hc = true; |
353 | | - |
354 | 178 | if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id; |
355 | | - |
356 | 179 | } |
357 | | - |
358 | 180 | if (lastId==node.id) node._ls = true; |
359 | | - |
360 | 181 | }; |
361 | 182 | |
362 | | - |
363 | | - |
364 | 183 | // Returns the selected node |
365 | | - |
366 | 184 | dTree.prototype.getSelected = function() { |
367 | | - |
368 | 185 | var sn = this.getCookie('cs' + this.obj); |
369 | | - |
370 | 186 | return (sn) ? sn : null; |
371 | | - |
372 | 187 | }; |
373 | 188 | |
374 | | - |
375 | | - |
376 | 189 | // Highlights the selected node |
377 | | - |
378 | 190 | dTree.prototype.s = function(id) { |
379 | | - |
380 | 191 | if (!this.config.useSelection) return; |
381 | | - |
382 | 192 | var cn = this.aNodes[id]; |
383 | | - |
384 | 193 | if (cn._hc && !this.config.folderLinks) return; |
385 | | - |
386 | 194 | if (this.selectedNode != id) { |
387 | | - |
388 | 195 | if (this.selectedNode || this.selectedNode==0) { |
389 | | - |
390 | 196 | eOld = document.getElementById("s" + this.obj + this.selectedNode); |
391 | | - |
392 | 197 | eOld.className = "node"; |
393 | | - |
394 | 198 | } |
395 | | - |
396 | 199 | eNew = document.getElementById("s" + this.obj + id); |
397 | | - |
398 | 200 | eNew.className = "nodeSel"; |
399 | | - |
400 | 201 | this.selectedNode = id; |
401 | | - |
402 | 202 | if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id); |
403 | | - |
404 | 203 | } |
405 | | - |
406 | 204 | }; |
407 | 205 | |
408 | | - |
409 | | - |
410 | 206 | // Toggle Open or close |
411 | | - |
412 | 207 | dTree.prototype.o = function(id) { |
413 | | - |
414 | 208 | var cn = this.aNodes[id]; |
415 | | - |
416 | 209 | this.nodeStatus(!cn._io, id, cn._ls); |
417 | | - |
418 | 210 | cn._io = !cn._io; |
419 | | - |
420 | 211 | if (this.config.closeSameLevel) this.closeLevel(cn); |
421 | | - |
422 | 212 | if (this.config.useCookies) this.updateCookie(); |
423 | | - |
424 | 213 | }; |
425 | 214 | |
426 | | - |
427 | | - |
428 | 215 | // Open or close all nodes |
429 | | - |
430 | 216 | dTree.prototype.oAll = function(status) { |
431 | | - |
432 | 217 | for (var n=0; n<this.aNodes.length; n++) { |
433 | | - |
434 | 218 | if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) { |
435 | | - |
436 | 219 | this.nodeStatus(status, n, this.aNodes[n]._ls) |
437 | | - |
438 | 220 | this.aNodes[n]._io = status; |
439 | | - |
440 | 221 | } |
441 | | - |
442 | 222 | } |
443 | | - |
444 | 223 | if (this.config.useCookies) this.updateCookie(); |
445 | | - |
446 | 224 | }; |
447 | 225 | |
448 | | - |
449 | | - |
450 | 226 | // Opens the tree to a specific node |
451 | | - |
452 | 227 | dTree.prototype.openTo = function(nId, bSelect, bFirst) { |
453 | | - |
454 | 228 | if (!bFirst) { |
455 | | - |
456 | 229 | for (var n=0; n<this.aNodes.length; n++) { |
457 | | - |
458 | 230 | if (this.aNodes[n].id == nId) { |
459 | | - |
460 | 231 | nId=n; |
461 | | - |
462 | 232 | break; |
463 | | - |
464 | 233 | } |
465 | | - |
466 | 234 | } |
467 | | - |
468 | 235 | } |
469 | | - |
470 | 236 | var cn=this.aNodes[nId]; |
471 | | - |
472 | 237 | if (cn.pid==this.root.id || !cn._p) return; |
473 | | - |
474 | 238 | cn._io = true; |
475 | | - |
476 | 239 | cn._is = bSelect; |
477 | | - |
478 | 240 | if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls); |
479 | | - |
480 | 241 | if (this.completed && bSelect) this.s(cn._ai); |
481 | | - |
482 | 242 | else if (bSelect) this._sn=cn._ai; |
483 | | - |
484 | 243 | this.openTo(cn._p._ai, false, true); |
485 | | - |
486 | 244 | }; |
487 | 245 | |
488 | | - |
489 | | - |
490 | 246 | // Closes all nodes on the same level as certain node |
491 | | - |
492 | 247 | dTree.prototype.closeLevel = function(node) { |
493 | | - |
494 | 248 | for (var n=0; n<this.aNodes.length; n++) { |
495 | | - |
496 | 249 | if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) { |
497 | | - |
498 | 250 | this.nodeStatus(false, n, this.aNodes[n]._ls); |
499 | | - |
500 | 251 | this.aNodes[n]._io = false; |
501 | | - |
502 | 252 | this.closeAllChildren(this.aNodes[n]); |
503 | | - |
504 | 253 | } |
505 | | - |
506 | 254 | } |
507 | | - |
508 | 255 | } |
509 | 256 | |
510 | | - |
511 | | - |
512 | 257 | // Closes all children of a node |
513 | | - |
514 | 258 | dTree.prototype.closeAllChildren = function(node) { |
515 | | - |
516 | 259 | for (var n=0; n<this.aNodes.length; n++) { |
517 | | - |
518 | 260 | if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) { |
519 | | - |
520 | 261 | if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls); |
521 | | - |
522 | 262 | this.aNodes[n]._io = false; |
523 | | - |
524 | 263 | this.closeAllChildren(this.aNodes[n]); |
525 | | - |
526 | 264 | } |
527 | | - |
528 | 265 | } |
529 | | - |
530 | 266 | } |
531 | 267 | |
532 | | - |
533 | | - |
534 | 268 | // Change the status of a node(open or closed) |
535 | | - |
536 | 269 | dTree.prototype.nodeStatus = function(status, id, bottom) { |
537 | | - |
538 | 270 | eDiv = document.getElementById('d' + this.obj + id); |
539 | | - |
540 | 271 | eJoin = document.getElementById('j' + this.obj + id); |
541 | | - |
542 | 272 | if (this.config.useIcons) { |
543 | | - |
544 | 273 | eIcon = document.getElementById('i' + this.obj + id); |
545 | | - |
546 | 274 | eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon; |
547 | | - |
548 | 275 | } |
549 | | - |
550 | 276 | eJoin.src = (this.config.useLines)? |
551 | | - |
552 | 277 | ((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)): |
553 | | - |
554 | 278 | ((status)?this.icon.nlMinus:this.icon.nlPlus); |
555 | | - |
556 | 279 | eDiv.style.display = (status) ? 'block': 'none'; |
557 | | - |
558 | 280 | }; |
559 | 281 | |
560 | 282 | |
561 | | - |
562 | | - |
563 | | - |
564 | 283 | // [Cookie] Clears a cookie |
565 | | - |
566 | 284 | dTree.prototype.clearCookie = function() { |
567 | | - |
568 | 285 | var now = new Date(); |
569 | | - |
570 | 286 | var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24); |
571 | | - |
572 | 287 | this.setCookie('co'+this.obj, 'cookieValue', yesterday); |
573 | | - |
574 | 288 | this.setCookie('cs'+this.obj, 'cookieValue', yesterday); |
575 | | - |
576 | 289 | }; |
577 | 290 | |
578 | | - |
579 | | - |
580 | 291 | // [Cookie] Sets value in a cookie |
581 | | - |
582 | 292 | dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) { |
583 | | - |
584 | 293 | document.cookie = |
585 | | - |
586 | 294 | escape(cookieName) + '=' + escape(cookieValue) |
587 | | - |
588 | 295 | + (expires ? '; expires=' + expires.toGMTString() : '') |
589 | | - |
590 | 296 | + (path ? '; path=' + path : '') |
591 | | - |
592 | 297 | + (domain ? '; domain=' + domain : '') |
593 | | - |
594 | 298 | + (secure ? '; secure' : ''); |
595 | | - |
596 | 299 | }; |
597 | 300 | |
598 | | - |
599 | | - |
600 | 301 | // [Cookie] Gets a value from a cookie |
601 | | - |
602 | 302 | dTree.prototype.getCookie = function(cookieName) { |
603 | | - |
604 | 303 | var cookieValue = ''; |
605 | | - |
606 | 304 | var posName = document.cookie.indexOf(escape(cookieName) + '='); |
607 | | - |
608 | 305 | if (posName != -1) { |
609 | | - |
610 | 306 | var posValue = posName + (escape(cookieName) + '=').length; |
611 | | - |
612 | 307 | var endPos = document.cookie.indexOf(';', posValue); |
613 | | - |
614 | 308 | if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos)); |
615 | | - |
616 | 309 | else cookieValue = unescape(document.cookie.substring(posValue)); |
617 | | - |
618 | 310 | } |
619 | | - |
620 | 311 | return (cookieValue); |
621 | | - |
622 | 312 | }; |
623 | 313 | |
624 | | - |
625 | | - |
626 | 314 | // [Cookie] Returns ids of open nodes as a string |
627 | | - |
628 | 315 | dTree.prototype.updateCookie = function() { |
629 | | - |
630 | 316 | var str = ''; |
631 | | - |
632 | 317 | for (var n=0; n<this.aNodes.length; n++) { |
633 | | - |
634 | 318 | if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) { |
635 | | - |
636 | 319 | if (str) str += '.'; |
637 | | - |
638 | 320 | str += this.aNodes[n].id; |
639 | | - |
640 | 321 | } |
641 | | - |
642 | 322 | } |
643 | | - |
644 | 323 | this.setCookie('co' + this.obj, str); |
645 | | - |
646 | 324 | }; |
647 | 325 | |
648 | | - |
649 | | - |
650 | 326 | // [Cookie] Checks if a node id is in a cookie |
651 | | - |
652 | 327 | dTree.prototype.isOpen = function(id) { |
653 | | - |
654 | 328 | var aOpen = this.getCookie('co' + this.obj).split('.'); |
655 | | - |
656 | 329 | for (var n=0; n<aOpen.length; n++) |
657 | | - |
658 | 330 | if (aOpen[n] == id) return true; |
659 | | - |
660 | 331 | return false; |
661 | | - |
662 | 332 | }; |
663 | 333 | |
664 | | - |
665 | | - |
666 | 334 | // If Push and pop is not implemented by the browser |
667 | | - |
668 | 335 | if (!Array.prototype.push) { |
669 | | - |
670 | 336 | Array.prototype.push = function array_push() { |
671 | | - |
672 | 337 | for(var i=0;i<arguments.length;i++) |
673 | | - |
674 | 338 | this[this.length]=arguments[i]; |
675 | | - |
676 | 339 | return this.length; |
677 | | - |
678 | 340 | } |
679 | | - |
680 | 341 | }; |
681 | | - |
682 | 342 | if (!Array.prototype.pop) { |
683 | | - |
684 | 343 | Array.prototype.pop = function array_pop() { |
685 | | - |
686 | 344 | lastElement = this[this.length-1]; |
687 | | - |
688 | 345 | this.length = Math.max(this.length-1,0); |
689 | | - |
690 | 346 | return lastElement; |
691 | | - |
692 | 347 | } |
693 | | - |
694 | 348 | }; |