compass-jquery-plugin 0.2.4.100 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/compass-jquery-plugin.gemspec +4 -6
- data/gem_tasks/jrails.rake +8 -53
- data/templates/dynatree/jquery.dynatree.js +2018 -1975
- data/templates/dynatree/jquery.dynatree.min.js +1 -1
- data/templates/jqgrid/i18n/jqgrid/locale-cn.js +128 -0
- data/templates/jqgrid/i18n/jqgrid/locale-cn.min.js +1 -0
- data/templates/jqgrid/i18n/jqgrid/locale-cs.js +128 -127
- data/templates/jqgrid/i18n/jqgrid/locale-cs.min.js +1 -1
- data/templates/jqgrid/i18n/jqgrid/locale-is.js +126 -126
- data/templates/jqgrid/i18n/jqgrid/locale-is.min.js +1 -1
- data/templates/jqgrid/i18n/jqgrid/locale-no.js +1 -121
- data/templates/jqgrid/i18n/jqgrid/locale-no.min.js +1 -1
- data/templates/jqgrid/i18n/jqgrid/locale-sp.js +128 -128
- data/templates/jqgrid/i18n/jqgrid/locale-sp.min.js +1 -1
- data/templates/jqgrid/i18n/jqgrid/locale-sv.js +127 -117
- data/templates/jqgrid/i18n/jqgrid/locale-sv.min.js +1 -1
- data/templates/jqgrid/jquery.jqGrid.js +10185 -9921
- data/templates/jqgrid/jquery.jqGrid.min.js +1 -1
- data/templates/jqgrid/jquery.ui/jqGrid.sass +761 -746
- data/templates/jqgrid/manifest.rb +64 -62
- data/templates/jrails/config/initializers/jrails.rb +24 -29
- data/templates/jrails/jquery.js +7644 -9557
- data/templates/jrails/jquery.min.js +19 -23
- data/templates/jrails/manifest.rb +457 -463
- metadata +4 -6
- data/templates/jrails/jquery.1.3.2.js +0 -7645
- data/templates/jrails/jquery.1.3.2.min.js +0 -19
- data/templates/jrails/jquery.compat-1.3.js +0 -288
- data/templates/jrails/jquery.compat-1.3.min.js +0 -1
@@ -1,1975 +1,2018 @@
|
|
1
|
-
/*************************************************************************
|
2
|
-
jquery.dynatree.js
|
3
|
-
Dynamic tree view control, with support for lazy loading of branches.
|
4
|
-
|
5
|
-
Copyright (c) 2008-2009 Martin Wendt (http://wwWendt.de)
|
6
|
-
Licensed under the MIT License (MIT-License.txt)
|
7
|
-
|
8
|
-
A current version and some documentation is available at
|
9
|
-
http://dynatree.googlecode.com/
|
10
|
-
|
11
|
-
Let me know, if you find bugs or improvements (martin at domain wwWendt.de).
|
12
|
-
|
13
|
-
$Version: 0.5.
|
14
|
-
$Revision:
|
15
|
-
|
16
|
-
@depends: jquery.js
|
17
|
-
@depends: ui.core.js
|
18
|
-
@depends: jquery.cookie.js
|
19
|
-
*************************************************************************/
|
20
|
-
|
21
|
-
|
22
|
-
/*************************************************************************
|
23
|
-
* Debug functions
|
24
|
-
*/
|
25
|
-
|
26
|
-
var _canLog = true;
|
27
|
-
|
28
|
-
function _log(mode, msg) {
|
29
|
-
/**
|
30
|
-
* Usage: logMsg("%o was toggled", this);
|
31
|
-
*/
|
32
|
-
if( !_canLog )
|
33
|
-
return;
|
34
|
-
// Remove first argument
|
35
|
-
var args = Array.prototype.slice.apply(arguments, [1]);
|
36
|
-
// Prepend timestamp
|
37
|
-
var dt = new Date();
|
38
|
-
var tag = dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds()+"."+dt.getMilliseconds();
|
39
|
-
args[0] = tag + " - " + args[0];
|
40
|
-
|
41
|
-
try {
|
42
|
-
switch( mode ) {
|
43
|
-
case "info":
|
44
|
-
window.console.info.apply(window.console, args);
|
45
|
-
break;
|
46
|
-
case "warn":
|
47
|
-
window.console.warn.apply(window.console, args);
|
48
|
-
break;
|
49
|
-
default:
|
50
|
-
window.console.log.apply(window.console, args);
|
51
|
-
}
|
52
|
-
} catch(e) {
|
53
|
-
if( !window.console )
|
54
|
-
_canLog = false; // Permanently disable, when logging is not supported by the browser
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
function logMsg(msg) {
|
59
|
-
Array.prototype.unshift.apply(arguments, ["debug"]);
|
60
|
-
_log.apply(this, arguments);
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
// Forward declaration
|
65
|
-
var getDynaTreePersistData = undefined;
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
/*************************************************************************
|
70
|
-
* Constants
|
71
|
-
*/
|
72
|
-
var DTNodeStatus_Error = -1;
|
73
|
-
var DTNodeStatus_Loading = 1;
|
74
|
-
var DTNodeStatus_Ok = 0;
|
75
|
-
|
76
|
-
|
77
|
-
// Start of local namespace
|
78
|
-
;(function($) {
|
79
|
-
|
80
|
-
/*************************************************************************
|
81
|
-
* Common tool functions.
|
82
|
-
*/
|
83
|
-
|
84
|
-
var Class = {
|
85
|
-
create: function() {
|
86
|
-
return function() {
|
87
|
-
this.initialize.apply(this, arguments);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
/*************************************************************************
|
93
|
-
* Class DynaTreeNode
|
94
|
-
*/
|
95
|
-
var DynaTreeNode = Class.create();
|
96
|
-
|
97
|
-
DynaTreeNode.prototype = {
|
98
|
-
initialize: function(parent, tree, data) {
|
99
|
-
/**
|
100
|
-
* @constructor
|
101
|
-
*/
|
102
|
-
this.parent = parent;
|
103
|
-
this.tree = tree;
|
104
|
-
if ( typeof data == "string" )
|
105
|
-
data = { title: data };
|
106
|
-
if( data.key == undefined )
|
107
|
-
data.key = "_" + tree._nodeCount++;
|
108
|
-
this.data = $.extend({}, $.ui.dynatree.nodedatadefaults, data);
|
109
|
-
this.div = null; // not yet created
|
110
|
-
this.span = null; // not yet created
|
111
|
-
this.childList = null; // no subnodes yet
|
112
|
-
// this.isRead = false; // Lazy content not yet read
|
113
|
-
this.isLoading = false; // Lazy content is being loaded
|
114
|
-
this.hasSubSel = false;
|
115
|
-
},
|
116
|
-
|
117
|
-
toString: function() {
|
118
|
-
return "dtnode<" + this.data.key + ">: '" + this.data.title + "'";
|
119
|
-
},
|
120
|
-
|
121
|
-
toDict: function(recursive, callback) {
|
122
|
-
var dict = $.extend({}, this.data);
|
123
|
-
dict.activate = ( this.tree.activeNode === this );
|
124
|
-
dict.focus = ( this.tree.focusNode === this );
|
125
|
-
dict.expand = this.bExpanded;
|
126
|
-
dict.select = this.bSelected;
|
127
|
-
if( callback )
|
128
|
-
callback(dict);
|
129
|
-
if( recursive && this.childList ) {
|
130
|
-
dict.children = [];
|
131
|
-
for(var i=0; i<this.childList.length; i++ )
|
132
|
-
dict.children.push(this.childList[i].toDict(true, callback));
|
133
|
-
} else {
|
134
|
-
delete dict.children;
|
135
|
-
}
|
136
|
-
return dict;
|
137
|
-
},
|
138
|
-
|
139
|
-
_getInnerHtml: function() {
|
140
|
-
var opts = this.tree.options;
|
141
|
-
var cache = this.tree.cache;
|
142
|
-
// parent connectors
|
143
|
-
var rootParent = opts.rootVisible ? null : this.tree.tnRoot;
|
144
|
-
var bHideFirstExpander = (opts.rootVisible && opts.minExpandLevel>0) || opts.minExpandLevel>1;
|
145
|
-
var bHideFirstConnector = opts.rootVisible || opts.minExpandLevel>0;
|
146
|
-
|
147
|
-
var res = "";
|
148
|
-
var p = this.parent;
|
149
|
-
while( p ) {
|
150
|
-
// Suppress first connector column, if visible top level is always expanded
|
151
|
-
if ( bHideFirstConnector && p==rootParent )
|
152
|
-
break;
|
153
|
-
res = ( p.isLastSibling() ? cache.tagEmpty : cache.tagVline) + res;
|
154
|
-
p = p.parent;
|
155
|
-
}
|
156
|
-
|
157
|
-
// connector (expanded, expandable or simple)
|
158
|
-
if( bHideFirstExpander && this.parent==rootParent ) {
|
159
|
-
// skip connector
|
160
|
-
} else if ( this.childList || this.data.isLazy ) {
|
161
|
-
res += cache.tagExpander;
|
162
|
-
} else {
|
163
|
-
res += cache.tagConnector;
|
164
|
-
}
|
165
|
-
|
166
|
-
// Checkbox mode
|
167
|
-
if( opts.checkbox && this.data.hideCheckbox!=true && !this.data.isStatusNode ) {
|
168
|
-
res += cache.tagCheckbox;
|
169
|
-
}
|
170
|
-
|
171
|
-
// folder or doctype icon
|
172
|
-
if ( this.data.icon ) {
|
173
|
-
res += "<img src='" + opts.imagePath + this.data.icon + "' alt='' />";
|
174
|
-
} else if ( this.data.icon == false ) {
|
175
|
-
// icon == false means 'no icon'
|
176
|
-
} else {
|
177
|
-
// icon == null means 'default icon'
|
178
|
-
res += cache.tagNodeIcon;
|
179
|
-
}
|
180
|
-
|
181
|
-
// node name
|
182
|
-
var tooltip = ( this.data && typeof this.data.tooltip == "string" ) ? " title='" + this.data.tooltip + "'" : "";
|
183
|
-
res += "<a href='#' class='" + opts.classNames.title + "'" + tooltip + ">" + this.data.title + "</a>";
|
184
|
-
return res;
|
185
|
-
},
|
186
|
-
|
187
|
-
_fixOrder: function() {
|
188
|
-
/**
|
189
|
-
* Make sure, that <div> order matches childList order.
|
190
|
-
*/
|
191
|
-
var cl = this.childList;
|
192
|
-
if( !cl )
|
193
|
-
return;
|
194
|
-
var childDiv = this.div.firstChild.nextSibling;
|
195
|
-
for(var i=0; i<cl.length-1; i++) {
|
196
|
-
var childNode1 = cl[i];
|
197
|
-
var childNode2 = childDiv.firstChild.dtnode;
|
198
|
-
if( childNode1 !== childNode2 ) {
|
199
|
-
//
|
200
|
-
this.tree.logDebug("_fixOrder: mismatch at index " + i + ": " + childNode1 + " != " + childNode2);
|
201
|
-
this.div.insertBefore(childNode1.div, childNode2.div);
|
202
|
-
} else {
|
203
|
-
childDiv = childDiv.nextSibling;
|
204
|
-
}
|
205
|
-
}
|
206
|
-
},
|
207
|
-
|
208
|
-
render: function(bDeep, bHidden) {
|
209
|
-
/**
|
210
|
-
* Create HTML markup for this node.
|
211
|
-
*
|
212
|
-
* <div> // This div contains the node's span and list of child div's.
|
213
|
-
* <span id='key'>S S S A</span> // Span contains graphic spans and title <a> tag
|
214
|
-
* <div>child1</div>
|
215
|
-
* <div>child2</div>
|
216
|
-
* </div>
|
217
|
-
*/
|
218
|
-
// this.tree.logDebug("%o.render()", this);
|
219
|
-
var opts = this.tree.options;
|
220
|
-
var cn = opts.classNames;
|
221
|
-
var isLastSib = this.isLastSibling();
|
222
|
-
// ---
|
223
|
-
if( ! this.div ) {
|
224
|
-
this.span = document.createElement("span");
|
225
|
-
this.span.dtnode = this;
|
226
|
-
if( this.data.key )
|
227
|
-
this.span.id = this.tree.options.idPrefix + this.data.key;
|
228
|
-
this.div = document.createElement("div");
|
229
|
-
this.div.appendChild(this.span);
|
230
|
-
|
231
|
-
if ( this.parent ) {
|
232
|
-
this.parent.div.appendChild(this.div);
|
233
|
-
}
|
234
|
-
|
235
|
-
if( this.parent==null && !this.tree.options.rootVisible )
|
236
|
-
this.span.style.display = "none";
|
237
|
-
}
|
238
|
-
// set node connector images, links and text
|
239
|
-
this.span.innerHTML = this._getInnerHtml();
|
240
|
-
|
241
|
-
// hide this node, if parent is collapsed
|
242
|
-
this.div.style.display = ( this.parent==null || this.parent.bExpanded ? "" : "none");
|
243
|
-
|
244
|
-
// Set classes for current status
|
245
|
-
var cnList = [];
|
246
|
-
cnList.push( ( this.data.isFolder ) ? cn.folder : cn.document );
|
247
|
-
if( this.bExpanded )
|
248
|
-
cnList.push(cn.expanded);
|
249
|
-
if( this.childList != null )
|
250
|
-
cnList.push(cn.hasChildren);
|
251
|
-
if( this.data.isLazy && this.childList==null )
|
252
|
-
cnList.push(cn.lazy);
|
253
|
-
if( isLastSib )
|
254
|
-
cnList.push(cn.lastsib);
|
255
|
-
if( this.bSelected )
|
256
|
-
cnList.push(cn.selected);
|
257
|
-
if( this.hasSubSel )
|
258
|
-
cnList.push(cn.partsel);
|
259
|
-
if( this.tree.activeNode === this )
|
260
|
-
cnList.push(cn.active);
|
261
|
-
if( this.data.addClass )
|
262
|
-
cnList.push(this.data.addClass);
|
263
|
-
// IE6 doesn't correctly evaluate multiple class names,
|
264
|
-
// so we create combined class names that can be used in the CSS
|
265
|
-
cnList.push(cn.combinedExpanderPrefix
|
266
|
-
+ (this.bExpanded ? "e" : "c")
|
267
|
-
+ (this.data.isLazy && this.childList==null ? "d" : "")
|
268
|
-
+ (isLastSib ? "l" : "")
|
269
|
-
);
|
270
|
-
cnList.push(cn.combinedIconPrefix
|
271
|
-
+ (this.bExpanded ? "e" : "c")
|
272
|
-
+ (this.data.isFolder ? "f" : "")
|
273
|
-
);
|
274
|
-
this.span.className = cnList.join(" ");
|
275
|
-
|
276
|
-
if( bDeep && this.childList && (bHidden || this.bExpanded) ) {
|
277
|
-
for(var i=0; i<this.childList.length; i++) {
|
278
|
-
this.childList[i].render(bDeep, bHidden)
|
279
|
-
}
|
280
|
-
this._fixOrder();
|
281
|
-
}
|
282
|
-
},
|
283
|
-
|
284
|
-
hasChildren: function() {
|
285
|
-
return this.childList != null;
|
286
|
-
},
|
287
|
-
|
288
|
-
isLastSibling: function() {
|
289
|
-
var p = this.parent;
|
290
|
-
if ( !p ) return true;
|
291
|
-
return p.childList[p.childList.length-1] === this;
|
292
|
-
},
|
293
|
-
|
294
|
-
prevSibling: function() {
|
295
|
-
if( !this.parent ) return null;
|
296
|
-
var ac = this.parent.childList;
|
297
|
-
for(var i=1; i<ac.length; i++) // start with 1, so prev(first) = null
|
298
|
-
if( ac[i] === this )
|
299
|
-
return ac[i-1];
|
300
|
-
return null;
|
301
|
-
},
|
302
|
-
|
303
|
-
nextSibling: function() {
|
304
|
-
if( !this.parent ) return null;
|
305
|
-
var ac = this.parent.childList;
|
306
|
-
for(var i=0; i<ac.length-1; i++) // up to length-2, so next(last) = null
|
307
|
-
if( ac[i] === this )
|
308
|
-
return ac[i+1];
|
309
|
-
return null;
|
310
|
-
},
|
311
|
-
|
312
|
-
_setStatusNode: function(data) {
|
313
|
-
// Create, modify or remove the status child node (pass 'null', to remove it).
|
314
|
-
var firstChild = ( this.childList ? this.childList[0] : null );
|
315
|
-
if( !data ) {
|
316
|
-
if ( firstChild ) {
|
317
|
-
this.div.removeChild(firstChild.div);
|
318
|
-
if( this.childList.length == 1 )
|
319
|
-
this.childList = null;
|
320
|
-
else
|
321
|
-
this.childList.shift();
|
322
|
-
}
|
323
|
-
} else if ( firstChild ) {
|
324
|
-
data.isStatusNode = true;
|
325
|
-
firstChild.data = data;
|
326
|
-
firstChild.render(false, false);
|
327
|
-
} else {
|
328
|
-
data.isStatusNode = true;
|
329
|
-
firstChild = this.addChild(data);
|
330
|
-
}
|
331
|
-
},
|
332
|
-
|
333
|
-
setLazyNodeStatus: function(lts) {
|
334
|
-
switch( lts ) {
|
335
|
-
case DTNodeStatus_Ok:
|
336
|
-
this._setStatusNode(null);
|
337
|
-
// this.isRead = true;
|
338
|
-
this.isLoading = false;
|
339
|
-
this.render(false, false);
|
340
|
-
if( this.tree.options.autoFocus ) {
|
341
|
-
if( this === this.tree.tnRoot && !this.tree.options.rootVisible && this.childList ) {
|
342
|
-
// special case: using ajaxInit
|
343
|
-
this.childList[0].focus();
|
344
|
-
} else {
|
345
|
-
this.focus();
|
346
|
-
}
|
347
|
-
}
|
348
|
-
break;
|
349
|
-
case DTNodeStatus_Loading:
|
350
|
-
this.isLoading = true;
|
351
|
-
this._setStatusNode({
|
352
|
-
title: this.tree.options.strings.loading,
|
353
|
-
addClass: this.tree.options.classNames.nodeWait
|
354
|
-
});
|
355
|
-
break;
|
356
|
-
case DTNodeStatus_Error:
|
357
|
-
this.isLoading = false;
|
358
|
-
this._setStatusNode({
|
359
|
-
title: this.tree.options.strings.loadError,
|
360
|
-
addClass: this.tree.options.classNames.nodeError
|
361
|
-
});
|
362
|
-
break;
|
363
|
-
default:
|
364
|
-
throw "Bad LazyNodeStatus: '" + lts + "'.";
|
365
|
-
}
|
366
|
-
},
|
367
|
-
|
368
|
-
_parentList: function(includeRoot, includeSelf) {
|
369
|
-
var l = [];
|
370
|
-
var dtn = includeSelf ? this : this.parent;
|
371
|
-
while( dtn ) {
|
372
|
-
if( includeRoot || dtn.parent )
|
373
|
-
l.unshift(dtn);
|
374
|
-
dtn = dtn.parent;
|
375
|
-
};
|
376
|
-
return l;
|
377
|
-
},
|
378
|
-
|
379
|
-
getLevel: function() {
|
380
|
-
var level = 0;
|
381
|
-
var dtn = this.parent;
|
382
|
-
while( dtn ) {
|
383
|
-
level++;
|
384
|
-
dtn = dtn.parent;
|
385
|
-
};
|
386
|
-
return level;
|
387
|
-
},
|
388
|
-
|
389
|
-
_getTypeForOuterNodeEvent: function(event) {
|
390
|
-
/** Return the inner node span (title, checkbox or expander) if
|
391
|
-
* event.target points to the outer span.
|
392
|
-
* This function should fix issue #93:
|
393
|
-
* FF2 ignores empty spans, when generating events (returning the parent instead).
|
394
|
-
*/
|
395
|
-
var cns = this.tree.options.classNames;
|
396
|
-
var target = event.target;
|
397
|
-
// Only process clicks on an outer node span (probably due to a FF2 event handling bug)
|
398
|
-
if( target.className.indexOf(cns.folder)<0
|
399
|
-
&& target.className.indexOf(cns.document)<0 ) {
|
400
|
-
return null
|
401
|
-
}
|
402
|
-
// Event coordinates, relative to outer node span:
|
403
|
-
var eventX = event.pageX - target.offsetLeft;
|
404
|
-
var eventY = event.pageY - target.offsetTop;
|
405
|
-
|
406
|
-
for(var i=0; i<target.childNodes.length; i++) {
|
407
|
-
var cn = target.childNodes[i];
|
408
|
-
var x = cn.offsetLeft - target.offsetLeft;
|
409
|
-
var y = cn.offsetTop - target.offsetTop;
|
410
|
-
var nx = cn.clientWidth, ny = cn.clientHeight;
|
411
|
-
// alert (cn.className + ": " + x + ", " + y + ", s:" + nx + ", " + ny);
|
412
|
-
if( eventX>=x && eventX<=(x+nx) && eventY>=y && eventY<=(y+ny) ) {
|
413
|
-
// alert("HIT "+ cn.className);
|
414
|
-
if( cn.className==cns.title )
|
415
|
-
return "title";
|
416
|
-
else if( cn.className==cns.expander )
|
417
|
-
return "expander";
|
418
|
-
else if( cn.className==cns.checkbox )
|
419
|
-
return "checkbox";
|
420
|
-
else if( cn.className==cns.nodeIcon )
|
421
|
-
return "icon";
|
422
|
-
}
|
423
|
-
}
|
424
|
-
return "prefix";
|
425
|
-
},
|
426
|
-
|
427
|
-
getEventTargetType: function(event) {
|
428
|
-
// Return the part of a node, that a click event occured on.
|
429
|
-
// Note: there is no check, if the was fired on TIHS node.
|
430
|
-
var tcn = event && event.target ? event.target.className : "";
|
431
|
-
var cns = this.tree.options.classNames;
|
432
|
-
|
433
|
-
if( tcn == cns.title )
|
434
|
-
return "title";
|
435
|
-
else if( tcn==cns.expander )
|
436
|
-
return "expander";
|
437
|
-
else if( tcn==cns.checkbox )
|
438
|
-
return "checkbox";
|
439
|
-
else if( tcn==cns.nodeIcon )
|
440
|
-
return "icon";
|
441
|
-
else if( tcn==cns.empty || tcn==cns.vline || tcn==cns.connector )
|
442
|
-
return "prefix";
|
443
|
-
else if( tcn.indexOf(cns.folder)>=0 || tcn.indexOf(cns.document)>=0 )
|
444
|
-
// FIX issue #93
|
445
|
-
return this._getTypeForOuterNodeEvent(event);
|
446
|
-
return null;
|
447
|
-
},
|
448
|
-
|
449
|
-
isVisible: function() {
|
450
|
-
// Return true, if all parents are expanded.
|
451
|
-
var parents = this._parentList(true, false);
|
452
|
-
for(var i=0; i<parents.length; i++)
|
453
|
-
if( ! parents[i].bExpanded ) return false;
|
454
|
-
return true;
|
455
|
-
},
|
456
|
-
|
457
|
-
makeVisible: function() {
|
458
|
-
// Make sure, all parents are expanded
|
459
|
-
var parents = this._parentList(true, false);
|
460
|
-
for(var i=0; i<parents.length; i++)
|
461
|
-
parents[i]._expand(true);
|
462
|
-
},
|
463
|
-
|
464
|
-
focus: function() {
|
465
|
-
// TODO: check, if we already have focus
|
466
|
-
// this.tree.logDebug("dtnode.focus(): %o", this);
|
467
|
-
this.makeVisible();
|
468
|
-
try {
|
469
|
-
$(this.span).find(">a").focus();
|
470
|
-
} catch(e) { }
|
471
|
-
},
|
472
|
-
|
473
|
-
_activate: function(flag, fireEvents) {
|
474
|
-
// (De)Activate - but not focus - this node.
|
475
|
-
this.tree.logDebug("dtnode._activate(%o, fireEvents=%o) - %o", flag, fireEvents, this);
|
476
|
-
var opts = this.tree.options;
|
477
|
-
if( this.data.isStatusNode )
|
478
|
-
return;
|
479
|
-
if ( fireEvents && opts.onQueryActivate && opts.onQueryActivate.call(this.span, flag, this) == false )
|
480
|
-
return; // Callback returned false
|
481
|
-
|
482
|
-
if( flag ) {
|
483
|
-
// Activate
|
484
|
-
if( this.tree.activeNode ) {
|
485
|
-
if( this.tree.activeNode === this )
|
486
|
-
return;
|
487
|
-
this.tree.activeNode.deactivate();
|
488
|
-
}
|
489
|
-
if( opts.activeVisible )
|
490
|
-
this.makeVisible();
|
491
|
-
this.tree.activeNode = this;
|
492
|
-
if( opts.persist )
|
493
|
-
$.cookie(opts.cookieId+"-active", this.data.key, opts.cookie);
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
//
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
this.
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
this.
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
//
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
this.
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
//
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
//
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
this.
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
this.tree.persistence.
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
$child.
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
$(filter, this.div).
|
777
|
-
|
778
|
-
|
779
|
-
// $d.
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
if( this.
|
792
|
-
return; // Prevent
|
793
|
-
this.
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
//
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
this.
|
823
|
-
|
824
|
-
this.
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
//
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
case
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
case
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
//~ case
|
854
|
-
//~ break;
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
//
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
this.
|
872
|
-
}
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
this.
|
880
|
-
}
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
sib =
|
888
|
-
if( sib
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
//
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
if(
|
924
|
-
|
925
|
-
this.tree.tnFocused
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
if( this.tree.
|
978
|
-
|
979
|
-
|
980
|
-
if
|
981
|
-
this.tree.persistence.
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
if(
|
1006
|
-
|
1007
|
-
|
1008
|
-
if
|
1009
|
-
this.tree.persistence.
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
this.
|
1021
|
-
this.
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
if( this.
|
1030
|
-
this.
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
//
|
1055
|
-
|
1056
|
-
// ---
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
//
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
if( dtnode.
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
if( dtnode.bSelected && opts.
|
1114
|
-
pers.
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
//
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
*
|
1154
|
-
*
|
1155
|
-
*
|
1156
|
-
*
|
1157
|
-
*
|
1158
|
-
*
|
1159
|
-
*
|
1160
|
-
*
|
1161
|
-
*
|
1162
|
-
*
|
1163
|
-
* }
|
1164
|
-
*
|
1165
|
-
*
|
1166
|
-
*
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
this.
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
self.
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
}
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
//
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
this.
|
1270
|
-
|
1271
|
-
|
1272
|
-
this.
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
$.cookie(this.cookieId + "-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
}
|
1352
|
-
|
1353
|
-
|
1354
|
-
};
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
//
|
1380
|
-
this.
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
this.
|
1394
|
-
this.
|
1395
|
-
this.
|
1396
|
-
this.
|
1397
|
-
|
1398
|
-
//
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
this.
|
1447
|
-
this.tnRoot.
|
1448
|
-
this.
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
//
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
var
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
},
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
},
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
//
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
return
|
1789
|
-
}
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
//
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
//
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1
|
+
/*************************************************************************
|
2
|
+
jquery.dynatree.js
|
3
|
+
Dynamic tree view control, with support for lazy loading of branches.
|
4
|
+
|
5
|
+
Copyright (c) 2008-2009 Martin Wendt (http://wwWendt.de)
|
6
|
+
Licensed under the MIT License (MIT-License.txt)
|
7
|
+
|
8
|
+
A current version and some documentation is available at
|
9
|
+
http://dynatree.googlecode.com/
|
10
|
+
|
11
|
+
Let me know, if you find bugs or improvements (martin at domain wwWendt.de).
|
12
|
+
|
13
|
+
$Version: 0.5.2$
|
14
|
+
$Revision: 296, 2009-12-20 11:04:25$
|
15
|
+
|
16
|
+
@depends: jquery.js
|
17
|
+
@depends: ui.core.js
|
18
|
+
@depends: jquery.cookie.js
|
19
|
+
*************************************************************************/
|
20
|
+
|
21
|
+
|
22
|
+
/*************************************************************************
|
23
|
+
* Debug functions
|
24
|
+
*/
|
25
|
+
|
26
|
+
var _canLog = true;
|
27
|
+
|
28
|
+
function _log(mode, msg) {
|
29
|
+
/**
|
30
|
+
* Usage: logMsg("%o was toggled", this);
|
31
|
+
*/
|
32
|
+
if( !_canLog )
|
33
|
+
return;
|
34
|
+
// Remove first argument
|
35
|
+
var args = Array.prototype.slice.apply(arguments, [1]);
|
36
|
+
// Prepend timestamp
|
37
|
+
var dt = new Date();
|
38
|
+
var tag = dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds()+"."+dt.getMilliseconds();
|
39
|
+
args[0] = tag + " - " + args[0];
|
40
|
+
|
41
|
+
try {
|
42
|
+
switch( mode ) {
|
43
|
+
case "info":
|
44
|
+
window.console.info.apply(window.console, args);
|
45
|
+
break;
|
46
|
+
case "warn":
|
47
|
+
window.console.warn.apply(window.console, args);
|
48
|
+
break;
|
49
|
+
default:
|
50
|
+
window.console.log.apply(window.console, args);
|
51
|
+
}
|
52
|
+
} catch(e) {
|
53
|
+
if( !window.console )
|
54
|
+
_canLog = false; // Permanently disable, when logging is not supported by the browser
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
function logMsg(msg) {
|
59
|
+
Array.prototype.unshift.apply(arguments, ["debug"]);
|
60
|
+
_log.apply(this, arguments);
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
// Forward declaration
|
65
|
+
var getDynaTreePersistData = undefined;
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
/*************************************************************************
|
70
|
+
* Constants
|
71
|
+
*/
|
72
|
+
var DTNodeStatus_Error = -1;
|
73
|
+
var DTNodeStatus_Loading = 1;
|
74
|
+
var DTNodeStatus_Ok = 0;
|
75
|
+
|
76
|
+
|
77
|
+
// Start of local namespace
|
78
|
+
;(function($) {
|
79
|
+
|
80
|
+
/*************************************************************************
|
81
|
+
* Common tool functions.
|
82
|
+
*/
|
83
|
+
|
84
|
+
var Class = {
|
85
|
+
create: function() {
|
86
|
+
return function() {
|
87
|
+
this.initialize.apply(this, arguments);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
/*************************************************************************
|
93
|
+
* Class DynaTreeNode
|
94
|
+
*/
|
95
|
+
var DynaTreeNode = Class.create();
|
96
|
+
|
97
|
+
DynaTreeNode.prototype = {
|
98
|
+
initialize: function(parent, tree, data) {
|
99
|
+
/**
|
100
|
+
* @constructor
|
101
|
+
*/
|
102
|
+
this.parent = parent;
|
103
|
+
this.tree = tree;
|
104
|
+
if ( typeof data == "string" )
|
105
|
+
data = { title: data };
|
106
|
+
if( data.key == undefined )
|
107
|
+
data.key = "_" + tree._nodeCount++;
|
108
|
+
this.data = $.extend({}, $.ui.dynatree.nodedatadefaults, data);
|
109
|
+
this.div = null; // not yet created
|
110
|
+
this.span = null; // not yet created
|
111
|
+
this.childList = null; // no subnodes yet
|
112
|
+
// this.isRead = false; // Lazy content not yet read
|
113
|
+
this.isLoading = false; // Lazy content is being loaded
|
114
|
+
this.hasSubSel = false;
|
115
|
+
},
|
116
|
+
|
117
|
+
toString: function() {
|
118
|
+
return "dtnode<" + this.data.key + ">: '" + this.data.title + "'";
|
119
|
+
},
|
120
|
+
|
121
|
+
toDict: function(recursive, callback) {
|
122
|
+
var dict = $.extend({}, this.data);
|
123
|
+
dict.activate = ( this.tree.activeNode === this );
|
124
|
+
dict.focus = ( this.tree.focusNode === this );
|
125
|
+
dict.expand = this.bExpanded;
|
126
|
+
dict.select = this.bSelected;
|
127
|
+
if( callback )
|
128
|
+
callback(dict);
|
129
|
+
if( recursive && this.childList ) {
|
130
|
+
dict.children = [];
|
131
|
+
for(var i=0; i<this.childList.length; i++ )
|
132
|
+
dict.children.push(this.childList[i].toDict(true, callback));
|
133
|
+
} else {
|
134
|
+
delete dict.children;
|
135
|
+
}
|
136
|
+
return dict;
|
137
|
+
},
|
138
|
+
|
139
|
+
_getInnerHtml: function() {
|
140
|
+
var opts = this.tree.options;
|
141
|
+
var cache = this.tree.cache;
|
142
|
+
// parent connectors
|
143
|
+
var rootParent = opts.rootVisible ? null : this.tree.tnRoot;
|
144
|
+
var bHideFirstExpander = (opts.rootVisible && opts.minExpandLevel>0) || opts.minExpandLevel>1;
|
145
|
+
var bHideFirstConnector = opts.rootVisible || opts.minExpandLevel>0;
|
146
|
+
|
147
|
+
var res = "";
|
148
|
+
var p = this.parent;
|
149
|
+
while( p ) {
|
150
|
+
// Suppress first connector column, if visible top level is always expanded
|
151
|
+
if ( bHideFirstConnector && p==rootParent )
|
152
|
+
break;
|
153
|
+
res = ( p.isLastSibling() ? cache.tagEmpty : cache.tagVline) + res;
|
154
|
+
p = p.parent;
|
155
|
+
}
|
156
|
+
|
157
|
+
// connector (expanded, expandable or simple)
|
158
|
+
if( bHideFirstExpander && this.parent==rootParent ) {
|
159
|
+
// skip connector
|
160
|
+
} else if ( this.childList || this.data.isLazy ) {
|
161
|
+
res += cache.tagExpander;
|
162
|
+
} else {
|
163
|
+
res += cache.tagConnector;
|
164
|
+
}
|
165
|
+
|
166
|
+
// Checkbox mode
|
167
|
+
if( opts.checkbox && this.data.hideCheckbox!=true && !this.data.isStatusNode ) {
|
168
|
+
res += cache.tagCheckbox;
|
169
|
+
}
|
170
|
+
|
171
|
+
// folder or doctype icon
|
172
|
+
if ( this.data.icon ) {
|
173
|
+
res += "<img src='" + opts.imagePath + this.data.icon + "' alt='' />";
|
174
|
+
} else if ( this.data.icon == false ) {
|
175
|
+
// icon == false means 'no icon'
|
176
|
+
} else {
|
177
|
+
// icon == null means 'default icon'
|
178
|
+
res += cache.tagNodeIcon;
|
179
|
+
}
|
180
|
+
|
181
|
+
// node name
|
182
|
+
var tooltip = ( this.data && typeof this.data.tooltip == "string" ) ? " title='" + this.data.tooltip + "'" : "";
|
183
|
+
res += "<a href='#' class='" + opts.classNames.title + "'" + tooltip + ">" + this.data.title + "</a>";
|
184
|
+
return res;
|
185
|
+
},
|
186
|
+
|
187
|
+
_fixOrder: function() {
|
188
|
+
/**
|
189
|
+
* Make sure, that <div> order matches childList order.
|
190
|
+
*/
|
191
|
+
var cl = this.childList;
|
192
|
+
if( !cl )
|
193
|
+
return;
|
194
|
+
var childDiv = this.div.firstChild.nextSibling;
|
195
|
+
for(var i=0; i<cl.length-1; i++) {
|
196
|
+
var childNode1 = cl[i];
|
197
|
+
var childNode2 = childDiv.firstChild.dtnode;
|
198
|
+
if( childNode1 !== childNode2 ) {
|
199
|
+
//
|
200
|
+
this.tree.logDebug("_fixOrder: mismatch at index " + i + ": " + childNode1 + " != " + childNode2);
|
201
|
+
this.div.insertBefore(childNode1.div, childNode2.div);
|
202
|
+
} else {
|
203
|
+
childDiv = childDiv.nextSibling;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
},
|
207
|
+
|
208
|
+
render: function(bDeep, bHidden) {
|
209
|
+
/**
|
210
|
+
* Create HTML markup for this node.
|
211
|
+
*
|
212
|
+
* <div> // This div contains the node's span and list of child div's.
|
213
|
+
* <span id='key'>S S S A</span> // Span contains graphic spans and title <a> tag
|
214
|
+
* <div>child1</div>
|
215
|
+
* <div>child2</div>
|
216
|
+
* </div>
|
217
|
+
*/
|
218
|
+
// this.tree.logDebug("%o.render()", this);
|
219
|
+
var opts = this.tree.options;
|
220
|
+
var cn = opts.classNames;
|
221
|
+
var isLastSib = this.isLastSibling();
|
222
|
+
// ---
|
223
|
+
if( ! this.div ) {
|
224
|
+
this.span = document.createElement("span");
|
225
|
+
this.span.dtnode = this;
|
226
|
+
if( this.data.key )
|
227
|
+
this.span.id = this.tree.options.idPrefix + this.data.key;
|
228
|
+
this.div = document.createElement("div");
|
229
|
+
this.div.appendChild(this.span);
|
230
|
+
|
231
|
+
if ( this.parent ) {
|
232
|
+
this.parent.div.appendChild(this.div);
|
233
|
+
}
|
234
|
+
|
235
|
+
if( this.parent==null && !this.tree.options.rootVisible )
|
236
|
+
this.span.style.display = "none";
|
237
|
+
}
|
238
|
+
// set node connector images, links and text
|
239
|
+
this.span.innerHTML = this._getInnerHtml();
|
240
|
+
|
241
|
+
// hide this node, if parent is collapsed
|
242
|
+
this.div.style.display = ( this.parent==null || this.parent.bExpanded ? "" : "none");
|
243
|
+
|
244
|
+
// Set classes for current status
|
245
|
+
var cnList = [];
|
246
|
+
cnList.push( ( this.data.isFolder ) ? cn.folder : cn.document );
|
247
|
+
if( this.bExpanded )
|
248
|
+
cnList.push(cn.expanded);
|
249
|
+
if( this.childList != null )
|
250
|
+
cnList.push(cn.hasChildren);
|
251
|
+
if( this.data.isLazy && this.childList==null )
|
252
|
+
cnList.push(cn.lazy);
|
253
|
+
if( isLastSib )
|
254
|
+
cnList.push(cn.lastsib);
|
255
|
+
if( this.bSelected )
|
256
|
+
cnList.push(cn.selected);
|
257
|
+
if( this.hasSubSel )
|
258
|
+
cnList.push(cn.partsel);
|
259
|
+
if( this.tree.activeNode === this )
|
260
|
+
cnList.push(cn.active);
|
261
|
+
if( this.data.addClass )
|
262
|
+
cnList.push(this.data.addClass);
|
263
|
+
// IE6 doesn't correctly evaluate multiple class names,
|
264
|
+
// so we create combined class names that can be used in the CSS
|
265
|
+
cnList.push(cn.combinedExpanderPrefix
|
266
|
+
+ (this.bExpanded ? "e" : "c")
|
267
|
+
+ (this.data.isLazy && this.childList==null ? "d" : "")
|
268
|
+
+ (isLastSib ? "l" : "")
|
269
|
+
);
|
270
|
+
cnList.push(cn.combinedIconPrefix
|
271
|
+
+ (this.bExpanded ? "e" : "c")
|
272
|
+
+ (this.data.isFolder ? "f" : "")
|
273
|
+
);
|
274
|
+
this.span.className = cnList.join(" ");
|
275
|
+
|
276
|
+
if( bDeep && this.childList && (bHidden || this.bExpanded) ) {
|
277
|
+
for(var i=0; i<this.childList.length; i++) {
|
278
|
+
this.childList[i].render(bDeep, bHidden)
|
279
|
+
}
|
280
|
+
this._fixOrder();
|
281
|
+
}
|
282
|
+
},
|
283
|
+
|
284
|
+
hasChildren: function() {
|
285
|
+
return this.childList != null;
|
286
|
+
},
|
287
|
+
|
288
|
+
isLastSibling: function() {
|
289
|
+
var p = this.parent;
|
290
|
+
if ( !p ) return true;
|
291
|
+
return p.childList[p.childList.length-1] === this;
|
292
|
+
},
|
293
|
+
|
294
|
+
prevSibling: function() {
|
295
|
+
if( !this.parent ) return null;
|
296
|
+
var ac = this.parent.childList;
|
297
|
+
for(var i=1; i<ac.length; i++) // start with 1, so prev(first) = null
|
298
|
+
if( ac[i] === this )
|
299
|
+
return ac[i-1];
|
300
|
+
return null;
|
301
|
+
},
|
302
|
+
|
303
|
+
nextSibling: function() {
|
304
|
+
if( !this.parent ) return null;
|
305
|
+
var ac = this.parent.childList;
|
306
|
+
for(var i=0; i<ac.length-1; i++) // up to length-2, so next(last) = null
|
307
|
+
if( ac[i] === this )
|
308
|
+
return ac[i+1];
|
309
|
+
return null;
|
310
|
+
},
|
311
|
+
|
312
|
+
_setStatusNode: function(data) {
|
313
|
+
// Create, modify or remove the status child node (pass 'null', to remove it).
|
314
|
+
var firstChild = ( this.childList ? this.childList[0] : null );
|
315
|
+
if( !data ) {
|
316
|
+
if ( firstChild ) {
|
317
|
+
this.div.removeChild(firstChild.div);
|
318
|
+
if( this.childList.length == 1 )
|
319
|
+
this.childList = null;
|
320
|
+
else
|
321
|
+
this.childList.shift();
|
322
|
+
}
|
323
|
+
} else if ( firstChild ) {
|
324
|
+
data.isStatusNode = true;
|
325
|
+
firstChild.data = data;
|
326
|
+
firstChild.render(false, false);
|
327
|
+
} else {
|
328
|
+
data.isStatusNode = true;
|
329
|
+
firstChild = this.addChild(data);
|
330
|
+
}
|
331
|
+
},
|
332
|
+
|
333
|
+
setLazyNodeStatus: function(lts) {
|
334
|
+
switch( lts ) {
|
335
|
+
case DTNodeStatus_Ok:
|
336
|
+
this._setStatusNode(null);
|
337
|
+
// this.isRead = true;
|
338
|
+
this.isLoading = false;
|
339
|
+
this.render(false, false);
|
340
|
+
if( this.tree.options.autoFocus ) {
|
341
|
+
if( this === this.tree.tnRoot && !this.tree.options.rootVisible && this.childList ) {
|
342
|
+
// special case: using ajaxInit
|
343
|
+
this.childList[0].focus();
|
344
|
+
} else {
|
345
|
+
this.focus();
|
346
|
+
}
|
347
|
+
}
|
348
|
+
break;
|
349
|
+
case DTNodeStatus_Loading:
|
350
|
+
this.isLoading = true;
|
351
|
+
this._setStatusNode({
|
352
|
+
title: this.tree.options.strings.loading,
|
353
|
+
addClass: this.tree.options.classNames.nodeWait
|
354
|
+
});
|
355
|
+
break;
|
356
|
+
case DTNodeStatus_Error:
|
357
|
+
this.isLoading = false;
|
358
|
+
this._setStatusNode({
|
359
|
+
title: this.tree.options.strings.loadError,
|
360
|
+
addClass: this.tree.options.classNames.nodeError
|
361
|
+
});
|
362
|
+
break;
|
363
|
+
default:
|
364
|
+
throw "Bad LazyNodeStatus: '" + lts + "'.";
|
365
|
+
}
|
366
|
+
},
|
367
|
+
|
368
|
+
_parentList: function(includeRoot, includeSelf) {
|
369
|
+
var l = [];
|
370
|
+
var dtn = includeSelf ? this : this.parent;
|
371
|
+
while( dtn ) {
|
372
|
+
if( includeRoot || dtn.parent )
|
373
|
+
l.unshift(dtn);
|
374
|
+
dtn = dtn.parent;
|
375
|
+
};
|
376
|
+
return l;
|
377
|
+
},
|
378
|
+
|
379
|
+
getLevel: function() {
|
380
|
+
var level = 0;
|
381
|
+
var dtn = this.parent;
|
382
|
+
while( dtn ) {
|
383
|
+
level++;
|
384
|
+
dtn = dtn.parent;
|
385
|
+
};
|
386
|
+
return level;
|
387
|
+
},
|
388
|
+
|
389
|
+
_getTypeForOuterNodeEvent: function(event) {
|
390
|
+
/** Return the inner node span (title, checkbox or expander) if
|
391
|
+
* event.target points to the outer span.
|
392
|
+
* This function should fix issue #93:
|
393
|
+
* FF2 ignores empty spans, when generating events (returning the parent instead).
|
394
|
+
*/
|
395
|
+
var cns = this.tree.options.classNames;
|
396
|
+
var target = event.target;
|
397
|
+
// Only process clicks on an outer node span (probably due to a FF2 event handling bug)
|
398
|
+
if( target.className.indexOf(cns.folder)<0
|
399
|
+
&& target.className.indexOf(cns.document)<0 ) {
|
400
|
+
return null
|
401
|
+
}
|
402
|
+
// Event coordinates, relative to outer node span:
|
403
|
+
var eventX = event.pageX - target.offsetLeft;
|
404
|
+
var eventY = event.pageY - target.offsetTop;
|
405
|
+
|
406
|
+
for(var i=0; i<target.childNodes.length; i++) {
|
407
|
+
var cn = target.childNodes[i];
|
408
|
+
var x = cn.offsetLeft - target.offsetLeft;
|
409
|
+
var y = cn.offsetTop - target.offsetTop;
|
410
|
+
var nx = cn.clientWidth, ny = cn.clientHeight;
|
411
|
+
// alert (cn.className + ": " + x + ", " + y + ", s:" + nx + ", " + ny);
|
412
|
+
if( eventX>=x && eventX<=(x+nx) && eventY>=y && eventY<=(y+ny) ) {
|
413
|
+
// alert("HIT "+ cn.className);
|
414
|
+
if( cn.className==cns.title )
|
415
|
+
return "title";
|
416
|
+
else if( cn.className==cns.expander )
|
417
|
+
return "expander";
|
418
|
+
else if( cn.className==cns.checkbox )
|
419
|
+
return "checkbox";
|
420
|
+
else if( cn.className==cns.nodeIcon )
|
421
|
+
return "icon";
|
422
|
+
}
|
423
|
+
}
|
424
|
+
return "prefix";
|
425
|
+
},
|
426
|
+
|
427
|
+
getEventTargetType: function(event) {
|
428
|
+
// Return the part of a node, that a click event occured on.
|
429
|
+
// Note: there is no check, if the was fired on TIHS node.
|
430
|
+
var tcn = event && event.target ? event.target.className : "";
|
431
|
+
var cns = this.tree.options.classNames;
|
432
|
+
|
433
|
+
if( tcn == cns.title )
|
434
|
+
return "title";
|
435
|
+
else if( tcn==cns.expander )
|
436
|
+
return "expander";
|
437
|
+
else if( tcn==cns.checkbox )
|
438
|
+
return "checkbox";
|
439
|
+
else if( tcn==cns.nodeIcon )
|
440
|
+
return "icon";
|
441
|
+
else if( tcn==cns.empty || tcn==cns.vline || tcn==cns.connector )
|
442
|
+
return "prefix";
|
443
|
+
else if( tcn.indexOf(cns.folder)>=0 || tcn.indexOf(cns.document)>=0 )
|
444
|
+
// FIX issue #93
|
445
|
+
return this._getTypeForOuterNodeEvent(event);
|
446
|
+
return null;
|
447
|
+
},
|
448
|
+
|
449
|
+
isVisible: function() {
|
450
|
+
// Return true, if all parents are expanded.
|
451
|
+
var parents = this._parentList(true, false);
|
452
|
+
for(var i=0; i<parents.length; i++)
|
453
|
+
if( ! parents[i].bExpanded ) return false;
|
454
|
+
return true;
|
455
|
+
},
|
456
|
+
|
457
|
+
makeVisible: function() {
|
458
|
+
// Make sure, all parents are expanded
|
459
|
+
var parents = this._parentList(true, false);
|
460
|
+
for(var i=0; i<parents.length; i++)
|
461
|
+
parents[i]._expand(true);
|
462
|
+
},
|
463
|
+
|
464
|
+
focus: function() {
|
465
|
+
// TODO: check, if we already have focus
|
466
|
+
// this.tree.logDebug("dtnode.focus(): %o", this);
|
467
|
+
this.makeVisible();
|
468
|
+
try {
|
469
|
+
$(this.span).find(">a").focus();
|
470
|
+
} catch(e) { }
|
471
|
+
},
|
472
|
+
|
473
|
+
_activate: function(flag, fireEvents) {
|
474
|
+
// (De)Activate - but not focus - this node.
|
475
|
+
this.tree.logDebug("dtnode._activate(%o, fireEvents=%o) - %o", flag, fireEvents, this);
|
476
|
+
var opts = this.tree.options;
|
477
|
+
if( this.data.isStatusNode )
|
478
|
+
return;
|
479
|
+
if ( fireEvents && opts.onQueryActivate && opts.onQueryActivate.call(this.span, flag, this) == false )
|
480
|
+
return; // Callback returned false
|
481
|
+
|
482
|
+
if( flag ) {
|
483
|
+
// Activate
|
484
|
+
if( this.tree.activeNode ) {
|
485
|
+
if( this.tree.activeNode === this )
|
486
|
+
return;
|
487
|
+
this.tree.activeNode.deactivate();
|
488
|
+
}
|
489
|
+
if( opts.activeVisible )
|
490
|
+
this.makeVisible();
|
491
|
+
this.tree.activeNode = this;
|
492
|
+
if( opts.persist )
|
493
|
+
$.cookie(opts.cookieId+"-active", this.data.key, opts.cookie);
|
494
|
+
this.tree.persistence.activeKey = this.data.key;
|
495
|
+
$(this.span).addClass(opts.classNames.active);
|
496
|
+
if ( fireEvents && opts.onActivate ) // Pass element as 'this' (jQuery convention)
|
497
|
+
opts.onActivate.call(this.span, this);
|
498
|
+
} else {
|
499
|
+
// Deactivate
|
500
|
+
if( this.tree.activeNode === this ) {
|
501
|
+
var opts = this.tree.options;
|
502
|
+
if ( opts.onQueryActivate && opts.onQueryActivate.call(this.span, false, this) == false )
|
503
|
+
return; // Callback returned false
|
504
|
+
$(this.span).removeClass(opts.classNames.active);
|
505
|
+
if( opts.persist ) {
|
506
|
+
// Note: we don't pass null, but ''. So the cookie is not deleted.
|
507
|
+
// If we pass null, we also have to pass a COPY of opts, because $cookie will override opts.expires (issue 84)
|
508
|
+
$.cookie(opts.cookieId+"-active", "", opts.cookie);
|
509
|
+
}
|
510
|
+
this.tree.persistence.activeKey = null;
|
511
|
+
this.tree.activeNode = null;
|
512
|
+
if ( fireEvents && opts.onDeactivate )
|
513
|
+
opts.onDeactivate.call(this.span, this);
|
514
|
+
}
|
515
|
+
}
|
516
|
+
},
|
517
|
+
|
518
|
+
activate: function() {
|
519
|
+
// Select - but not focus - this node.
|
520
|
+
// this.tree.logDebug("dtnode.activate(): %o", this);
|
521
|
+
this._activate(true, true);
|
522
|
+
},
|
523
|
+
|
524
|
+
deactivate: function() {
|
525
|
+
// this.tree.logDebug("dtnode.deactivate(): %o", this);
|
526
|
+
this._activate(false, true);
|
527
|
+
},
|
528
|
+
|
529
|
+
isActive: function() {
|
530
|
+
return (this.tree.activeNode === this);
|
531
|
+
},
|
532
|
+
|
533
|
+
_userActivate: function() {
|
534
|
+
// Handle user click / [space] / [enter], according to clickFolderMode.
|
535
|
+
var activate = true;
|
536
|
+
var expand = false;
|
537
|
+
if ( this.data.isFolder ) {
|
538
|
+
switch( this.tree.options.clickFolderMode ) {
|
539
|
+
case 2:
|
540
|
+
activate = false;
|
541
|
+
expand = true;
|
542
|
+
break;
|
543
|
+
case 3:
|
544
|
+
activate = expand = true;
|
545
|
+
break;
|
546
|
+
}
|
547
|
+
}
|
548
|
+
if( this.parent == null && this.tree.options.minExpandLevel>0 ) {
|
549
|
+
expand = false;
|
550
|
+
}
|
551
|
+
if( expand ) {
|
552
|
+
this.toggleExpand();
|
553
|
+
this.focus();
|
554
|
+
}
|
555
|
+
if( activate ) {
|
556
|
+
this.activate();
|
557
|
+
}
|
558
|
+
},
|
559
|
+
|
560
|
+
_setSubSel: function(hasSubSel) {
|
561
|
+
if( hasSubSel ) {
|
562
|
+
this.hasSubSel = true;
|
563
|
+
$(this.span).addClass(this.tree.options.classNames.partsel);
|
564
|
+
} else {
|
565
|
+
this.hasSubSel = false;
|
566
|
+
$(this.span).removeClass(this.tree.options.classNames.partsel);
|
567
|
+
}
|
568
|
+
},
|
569
|
+
|
570
|
+
_fixSelectionState: function() {
|
571
|
+
// fix selection status, for multi-hier mode
|
572
|
+
// this.tree.logDebug("_fixSelectionState(%o) - %o", this.bSelected, this);
|
573
|
+
if( this.bSelected ) {
|
574
|
+
// Select all children
|
575
|
+
this.visit(function(dtnode){
|
576
|
+
dtnode.parent._setSubSel(true);
|
577
|
+
dtnode._select(true, false, false);
|
578
|
+
});
|
579
|
+
// Select parents, if all children are selected
|
580
|
+
var p = this.parent;
|
581
|
+
while( p ) {
|
582
|
+
p._setSubSel(true);
|
583
|
+
var allChildsSelected = true;
|
584
|
+
for(var i=0; i<p.childList.length; i++) {
|
585
|
+
var n = p.childList[i];
|
586
|
+
if( !n.bSelected && !n.data.isStatusNode ) {
|
587
|
+
allChildsSelected = false;
|
588
|
+
break;
|
589
|
+
}
|
590
|
+
}
|
591
|
+
if( allChildsSelected )
|
592
|
+
p._select(true, false, false);
|
593
|
+
p = p.parent;
|
594
|
+
}
|
595
|
+
} else {
|
596
|
+
// Deselect all children
|
597
|
+
this._setSubSel(false);
|
598
|
+
this.visit(function(dtnode){
|
599
|
+
dtnode._setSubSel(false);
|
600
|
+
dtnode._select(false, false, false);
|
601
|
+
});
|
602
|
+
// Deselect parents, and recalc hasSubSel
|
603
|
+
var p = this.parent;
|
604
|
+
while( p ) {
|
605
|
+
p._select(false, false, false);
|
606
|
+
var isPartSel = false;
|
607
|
+
for(var i=0; i<p.childList.length; i++) {
|
608
|
+
if( p.childList[i].bSelected || p.childList[i].hasSubSel ) {
|
609
|
+
isPartSel = true;
|
610
|
+
break;
|
611
|
+
}
|
612
|
+
}
|
613
|
+
p._setSubSel(isPartSel);
|
614
|
+
p = p.parent;
|
615
|
+
}
|
616
|
+
}
|
617
|
+
},
|
618
|
+
|
619
|
+
_select: function(sel, fireEvents, deep) {
|
620
|
+
// Select - but not focus - this node.
|
621
|
+
// this.tree.logDebug("dtnode._select(%o) - %o", sel, this);
|
622
|
+
var opts = this.tree.options;
|
623
|
+
if( this.data.isStatusNode )
|
624
|
+
return;
|
625
|
+
//
|
626
|
+
if( this.bSelected == sel ) {
|
627
|
+
// this.tree.logDebug("dtnode._select(%o) IGNORED - %o", sel, this);
|
628
|
+
return;
|
629
|
+
}
|
630
|
+
// Allow event listener to abort selection
|
631
|
+
if ( fireEvents && opts.onQuerySelect && opts.onQuerySelect.call(this.span, sel, this) == false )
|
632
|
+
return; // Callback returned false
|
633
|
+
|
634
|
+
// Force single-selection
|
635
|
+
if( opts.selectMode==1 && sel ) {
|
636
|
+
this.tree.visit(function(dtnode){
|
637
|
+
if( dtnode.bSelected ) {
|
638
|
+
// Deselect; assuming that in selectMode:1 there's max. one other selected node
|
639
|
+
dtnode._select(false, false, false);
|
640
|
+
return false;
|
641
|
+
}
|
642
|
+
});
|
643
|
+
}
|
644
|
+
|
645
|
+
this.bSelected = sel;
|
646
|
+
// this.tree._changeNodeList("select", this, sel);
|
647
|
+
|
648
|
+
if( sel ) {
|
649
|
+
if( opts.persist )
|
650
|
+
this.tree.persistence.addSelect(this.data.key);
|
651
|
+
|
652
|
+
$(this.span).addClass(opts.classNames.selected);
|
653
|
+
|
654
|
+
if( deep && opts.selectMode==3 )
|
655
|
+
this._fixSelectionState();
|
656
|
+
|
657
|
+
if ( fireEvents && opts.onSelect )
|
658
|
+
opts.onSelect.call(this.span, true, this);
|
659
|
+
|
660
|
+
} else {
|
661
|
+
if( opts.persist )
|
662
|
+
this.tree.persistence.clearSelect(this.data.key);
|
663
|
+
|
664
|
+
$(this.span).removeClass(opts.classNames.selected);
|
665
|
+
|
666
|
+
if( deep && opts.selectMode==3 )
|
667
|
+
this._fixSelectionState();
|
668
|
+
|
669
|
+
if ( fireEvents && opts.onSelect )
|
670
|
+
opts.onSelect.call(this.span, false, this);
|
671
|
+
}
|
672
|
+
},
|
673
|
+
|
674
|
+
select: function(sel) {
|
675
|
+
// Select - but not focus - this node.
|
676
|
+
// this.tree.logDebug("dtnode.select(%o) - %o", sel, this);
|
677
|
+
if( this.data.unselectable )
|
678
|
+
return this.bSelected;
|
679
|
+
return this._select(sel!=false, true, true);
|
680
|
+
},
|
681
|
+
|
682
|
+
toggleSelect: function() {
|
683
|
+
// this.tree.logDebug("dtnode.toggleSelect() - %o", this);
|
684
|
+
return this.select(!this.bSelected);
|
685
|
+
},
|
686
|
+
|
687
|
+
isSelected: function() {
|
688
|
+
return this.bSelected;
|
689
|
+
},
|
690
|
+
|
691
|
+
_loadContent: function() {
|
692
|
+
try {
|
693
|
+
var opts = this.tree.options;
|
694
|
+
this.tree.logDebug("_loadContent: start - %o", this);
|
695
|
+
this.setLazyNodeStatus(DTNodeStatus_Loading);
|
696
|
+
if( true == opts.onLazyRead.call(this.span, this) ) {
|
697
|
+
// If function returns 'true', we assume that the loading is done:
|
698
|
+
this.setLazyNodeStatus(DTNodeStatus_Ok);
|
699
|
+
// Otherwise (i.e. if the loading was started as an asynchronous process)
|
700
|
+
// the onLazyRead(dtnode) handler is expected to call dtnode.setLazyNodeStatus(DTNodeStatus_Ok/_Error) when done.
|
701
|
+
this.tree.logDebug("_loadContent: succeeded - %o", this);
|
702
|
+
}
|
703
|
+
} catch(e) {
|
704
|
+
alert(e);
|
705
|
+
this.setLazyNodeStatus(DTNodeStatus_Error);
|
706
|
+
}
|
707
|
+
},
|
708
|
+
|
709
|
+
_expand: function(bExpand) {
|
710
|
+
// this.tree.logDebug("dtnode._expand(%o) - %o", bExpand, this);
|
711
|
+
if( this.bExpanded == bExpand ) {
|
712
|
+
// this.tree.logDebug("dtnode._expand(%o) IGNORED - %o", bExpand, this);
|
713
|
+
return;
|
714
|
+
}
|
715
|
+
var opts = this.tree.options;
|
716
|
+
if( !bExpand && this.getLevel()<opts.minExpandLevel ) {
|
717
|
+
this.tree.logDebug("dtnode._expand(%o) forced expand - %o", bExpand, this);
|
718
|
+
return;
|
719
|
+
}
|
720
|
+
if ( opts.onQueryExpand && opts.onQueryExpand.call(this.span, bExpand, this) == false )
|
721
|
+
return; // Callback returned false
|
722
|
+
this.bExpanded = bExpand;
|
723
|
+
|
724
|
+
// Persist expand state
|
725
|
+
if( opts.persist ) {
|
726
|
+
if( bExpand )
|
727
|
+
this.tree.persistence.addExpand(this.data.key);
|
728
|
+
else
|
729
|
+
this.tree.persistence.clearExpand(this.data.key);
|
730
|
+
}
|
731
|
+
|
732
|
+
this.render(false);
|
733
|
+
|
734
|
+
// Auto-collapse mode: collapse all siblings
|
735
|
+
if( this.bExpanded && this.parent && opts.autoCollapse ) {
|
736
|
+
var parents = this._parentList(false, true);
|
737
|
+
for(var i=0; i<parents.length; i++)
|
738
|
+
parents[i].collapseSiblings();
|
739
|
+
}
|
740
|
+
|
741
|
+
// If the currently active node is now hidden, deactivate it
|
742
|
+
if( opts.activeVisible && this.tree.activeNode && ! this.tree.activeNode.isVisible() ) {
|
743
|
+
this.tree.activeNode.deactivate();
|
744
|
+
}
|
745
|
+
// Expanding a lazy node: set 'loading...' and call callback
|
746
|
+
if( bExpand && this.data.isLazy && this.childList==null && !this.isLoading ) {
|
747
|
+
this._loadContent();
|
748
|
+
return;
|
749
|
+
}
|
750
|
+
// this.tree.logDebug("_expand: start div toggle - %o", this);
|
751
|
+
|
752
|
+
var fxDuration = opts.fx ? (opts.fx.duration || 200) : 0;
|
753
|
+
if( this.childList ) {
|
754
|
+
for(var i=0; i<this.childList.length; i++ ) {
|
755
|
+
var $child = $(this.childList[i].div);
|
756
|
+
if( fxDuration ) {
|
757
|
+
// This is a toggle, so only do it, if not already rendered (in)visible (issue 98)
|
758
|
+
if( bExpand != $child.is(':visible') )
|
759
|
+
$child.animate(opts.fx, fxDuration);
|
760
|
+
} else {
|
761
|
+
if( bExpand )
|
762
|
+
$child.show();
|
763
|
+
else
|
764
|
+
$child.hide(); // TODO: this seems to be slow, when called the first time for an element
|
765
|
+
}
|
766
|
+
}
|
767
|
+
}
|
768
|
+
|
769
|
+
/* issue 109: using selector filter is really SLOW.
|
770
|
+
// issue 98: only toggle, if render hasn't set visibility already:
|
771
|
+
var filter = ">DIV" + (bExpand ? ":hidden" : ":visible");
|
772
|
+
|
773
|
+
if( opts.fx ) {
|
774
|
+
var duration = opts.fx.duration || 200;
|
775
|
+
// $(">DIV", this.div).animate(opts.fx, duration);
|
776
|
+
$(filter, this.div).animate(opts.fx, duration);
|
777
|
+
} else {
|
778
|
+
$(filter, this.div).toggle();
|
779
|
+
// var $d = $(">DIV", this.div);
|
780
|
+
// this.tree.logDebug("_expand: got div, start toggle - %o", this);
|
781
|
+
// $d.toggle();
|
782
|
+
}
|
783
|
+
//*/
|
784
|
+
// this.tree.logDebug("_expand: end div toggle - %o", this);
|
785
|
+
|
786
|
+
if ( opts.onExpand )
|
787
|
+
opts.onExpand.call(this.span, bExpand, this);
|
788
|
+
},
|
789
|
+
|
790
|
+
expand: function(flag) {
|
791
|
+
if( !this.childList && !this.data.isLazy && flag )
|
792
|
+
return; // Prevent expanding empty nodes
|
793
|
+
if( this.parent == null && this.tree.options.minExpandLevel>0 && !flag )
|
794
|
+
return; // Prevent collapsing the root
|
795
|
+
this._expand(flag);
|
796
|
+
},
|
797
|
+
|
798
|
+
toggleExpand: function() {
|
799
|
+
this.expand(!this.bExpanded);
|
800
|
+
},
|
801
|
+
|
802
|
+
collapseSiblings: function() {
|
803
|
+
if( this.parent == null )
|
804
|
+
return;
|
805
|
+
var ac = this.parent.childList;
|
806
|
+
for (var i=0; i<ac.length; i++) {
|
807
|
+
if ( ac[i] !== this && ac[i].bExpanded )
|
808
|
+
ac[i]._expand(false);
|
809
|
+
}
|
810
|
+
},
|
811
|
+
|
812
|
+
onClick: function(event) {
|
813
|
+
// this.tree.logDebug("dtnode.onClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
|
814
|
+
var targetType = this.getEventTargetType(event);
|
815
|
+
if( targetType == "expander" ) {
|
816
|
+
// Clicking the expander icon always expands/collapses
|
817
|
+
this.toggleExpand();
|
818
|
+
this.focus(); // issue 95
|
819
|
+
} else if( targetType == "checkbox" ) {
|
820
|
+
// Clicking the checkbox always (de)selects
|
821
|
+
this.toggleSelect();
|
822
|
+
this.focus(); // issue 95
|
823
|
+
} else {
|
824
|
+
this._userActivate();
|
825
|
+
// Chrome and Safari don't focus the a-tag on click
|
826
|
+
this.span.getElementsByTagName("a")[0].focus();
|
827
|
+
}
|
828
|
+
// Make sure that clicks stop, otherwise <a href='#'> jumps to the top
|
829
|
+
return false;
|
830
|
+
},
|
831
|
+
|
832
|
+
onDblClick: function(event) {
|
833
|
+
// this.tree.logDebug("dtnode.onDblClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
|
834
|
+
},
|
835
|
+
|
836
|
+
onKeydown: function(event) {
|
837
|
+
// this.tree.logDebug("dtnode.onKeydown(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
|
838
|
+
var handled = true;
|
839
|
+
// alert("keyDown" + event.which);
|
840
|
+
|
841
|
+
switch( event.which ) {
|
842
|
+
// charCodes:
|
843
|
+
// case 43: // '+'
|
844
|
+
case 107: // '+'
|
845
|
+
case 187: // '+' @ Chrome, Safari
|
846
|
+
if( !this.bExpanded ) this.toggleExpand();
|
847
|
+
break;
|
848
|
+
// case 45: // '-'
|
849
|
+
case 109: // '-'
|
850
|
+
case 189: // '+' @ Chrome, Safari
|
851
|
+
if( this.bExpanded ) this.toggleExpand();
|
852
|
+
break;
|
853
|
+
//~ case 42: // '*'
|
854
|
+
//~ break;
|
855
|
+
//~ case 47: // '/'
|
856
|
+
//~ break;
|
857
|
+
// case 13: // <enter>
|
858
|
+
// <enter> on a focused <a> tag seems to generate a click-event.
|
859
|
+
// this._userActivate();
|
860
|
+
// break;
|
861
|
+
case 32: // <space>
|
862
|
+
this._userActivate();
|
863
|
+
break;
|
864
|
+
case 8: // <backspace>
|
865
|
+
if( this.parent )
|
866
|
+
this.parent.focus();
|
867
|
+
break;
|
868
|
+
case 37: // <left>
|
869
|
+
if( this.bExpanded ) {
|
870
|
+
this.toggleExpand();
|
871
|
+
this.focus();
|
872
|
+
} else if( this.parent && (this.tree.options.rootVisible || this.parent.parent) ) {
|
873
|
+
this.parent.focus();
|
874
|
+
}
|
875
|
+
break;
|
876
|
+
case 39: // <right>
|
877
|
+
if( !this.bExpanded && (this.childList || this.data.isLazy) ) {
|
878
|
+
this.toggleExpand();
|
879
|
+
this.focus();
|
880
|
+
} else if( this.childList ) {
|
881
|
+
this.childList[0].focus();
|
882
|
+
}
|
883
|
+
break;
|
884
|
+
case 38: // <up>
|
885
|
+
var sib = this.prevSibling();
|
886
|
+
while( sib && sib.bExpanded && sib.childList )
|
887
|
+
sib = sib.childList[sib.childList.length-1];
|
888
|
+
if( !sib && this.parent && (this.tree.options.rootVisible || this.parent.parent) )
|
889
|
+
sib = this.parent;
|
890
|
+
if( sib ) sib.focus();
|
891
|
+
break;
|
892
|
+
case 40: // <down>
|
893
|
+
var sib;
|
894
|
+
if( this.bExpanded && this.childList ) {
|
895
|
+
sib = this.childList[0];
|
896
|
+
} else {
|
897
|
+
var parents = this._parentList(false, true);
|
898
|
+
for(var i=parents.length-1; i>=0; i--) {
|
899
|
+
sib = parents[i].nextSibling();
|
900
|
+
if( sib ) break;
|
901
|
+
}
|
902
|
+
}
|
903
|
+
if( sib ) sib.focus();
|
904
|
+
break;
|
905
|
+
default:
|
906
|
+
handled = false;
|
907
|
+
}
|
908
|
+
// Return false, if handled, to prevent default processing
|
909
|
+
return !handled;
|
910
|
+
},
|
911
|
+
|
912
|
+
onKeypress: function(event) {
|
913
|
+
// onKeypress is only hooked to allow user callbacks.
|
914
|
+
// We don't process it, because IE and Safari don't fire keypress for cursor keys.
|
915
|
+
// this.tree.logDebug("dtnode.onKeypress(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
|
916
|
+
},
|
917
|
+
|
918
|
+
onFocus: function(event) {
|
919
|
+
// Handles blur and focus events.
|
920
|
+
// this.tree.logDebug("dtnode.onFocus(%o): %o", event, this);
|
921
|
+
var opts = this.tree.options;
|
922
|
+
if ( event.type=="blur" || event.type=="focusout" ) {
|
923
|
+
if ( opts.onBlur ) // Pass element as 'this' (jQuery convention)
|
924
|
+
opts.onBlur.call(this.span, this);
|
925
|
+
if( this.tree.tnFocused )
|
926
|
+
$(this.tree.tnFocused.span).removeClass(opts.classNames.focused);
|
927
|
+
this.tree.tnFocused = null;
|
928
|
+
if( opts.persist )
|
929
|
+
$.cookie(opts.cookieId+"-focus", "", opts.cookie);
|
930
|
+
} else if ( event.type=="focus" || event.type=="focusin") {
|
931
|
+
// Fix: sometimes the blur event is not generated
|
932
|
+
if( this.tree.tnFocused && this.tree.tnFocused !== this ) {
|
933
|
+
this.tree.logDebug("dtnode.onFocus: out of sync: curFocus: %o", this.tree.tnFocused);
|
934
|
+
$(this.tree.tnFocused.span).removeClass(opts.classNames.focused);
|
935
|
+
}
|
936
|
+
this.tree.tnFocused = this;
|
937
|
+
if ( opts.onFocus ) // Pass element as 'this' (jQuery convention)
|
938
|
+
opts.onFocus.call(this.span, this);
|
939
|
+
$(this.tree.tnFocused.span).addClass(opts.classNames.focused);
|
940
|
+
if( opts.persist )
|
941
|
+
$.cookie(opts.cookieId+"-focus", this.data.key, opts.cookie);
|
942
|
+
}
|
943
|
+
// TODO: return anything?
|
944
|
+
// return false;
|
945
|
+
},
|
946
|
+
|
947
|
+
visit: function(fn, data, includeSelf) {
|
948
|
+
// Call fn(dtnode, data) for all child nodes. Stop iteration, if fn() returns false.
|
949
|
+
var n = 0;
|
950
|
+
if( includeSelf == true ) {
|
951
|
+
if( fn(this, data) == false )
|
952
|
+
return 1;
|
953
|
+
n++;
|
954
|
+
}
|
955
|
+
if ( this.childList )
|
956
|
+
for (var i=0; i<this.childList.length; i++)
|
957
|
+
n += this.childList[i].visit(fn, data, true);
|
958
|
+
return n;
|
959
|
+
},
|
960
|
+
|
961
|
+
remove: function() {
|
962
|
+
// Remove this node
|
963
|
+
// this.tree.logDebug ("%o.remove()", this);
|
964
|
+
if ( this === this.tree.root )
|
965
|
+
return false;
|
966
|
+
return this.parent.removeChild(this);
|
967
|
+
},
|
968
|
+
|
969
|
+
removeChild: function(tn) {
|
970
|
+
// Remove tn from list of direct children.
|
971
|
+
var ac = this.childList;
|
972
|
+
if( ac.length == 1 ) {
|
973
|
+
if( tn !== ac[0] )
|
974
|
+
throw "removeChild: invalid child";
|
975
|
+
return this.removeChildren();
|
976
|
+
}
|
977
|
+
if( tn === this.tree.activeNode )
|
978
|
+
tn.deactivate();
|
979
|
+
if( this.tree.options.persist ) {
|
980
|
+
if( tn.bSelected )
|
981
|
+
this.tree.persistence.clearSelect(tn.data.key);
|
982
|
+
if ( tn.bExpanded )
|
983
|
+
this.tree.persistence.clearExpand(tn.data.key);
|
984
|
+
}
|
985
|
+
tn.removeChildren(true);
|
986
|
+
this.div.removeChild(tn.div);
|
987
|
+
for(var i=0; i<ac.length; i++) {
|
988
|
+
if( ac[i] === tn ) {
|
989
|
+
this.childList.splice(i, 1);
|
990
|
+
delete tn;
|
991
|
+
break;
|
992
|
+
}
|
993
|
+
}
|
994
|
+
},
|
995
|
+
|
996
|
+
removeChildren: function(isRecursiveCall, retainPersistence) {
|
997
|
+
// Remove all child nodes (more efficiently than recursive remove())
|
998
|
+
// this.tree.logDebug ("%o.removeChildren(%o)", this, isRecursiveCall);
|
999
|
+
var tree = this.tree;
|
1000
|
+
var ac = this.childList;
|
1001
|
+
if( ac ) {
|
1002
|
+
for(var i=0; i<ac.length; i++) {
|
1003
|
+
var tn=ac[i];
|
1004
|
+
// this.tree.logDebug ("del %o", tn);
|
1005
|
+
if ( tn === tree.activeNode && !retainPersistence )
|
1006
|
+
tn.deactivate();
|
1007
|
+
if( this.tree.options.persist && !retainPersistence ) {
|
1008
|
+
if( tn.bSelected )
|
1009
|
+
this.tree.persistence.clearSelect(tn.data.key);
|
1010
|
+
if ( tn.bExpanded )
|
1011
|
+
this.tree.persistence.clearExpand(tn.data.key);
|
1012
|
+
}
|
1013
|
+
tn.removeChildren(true, retainPersistence);
|
1014
|
+
this.div.removeChild(tn.div);
|
1015
|
+
delete tn;
|
1016
|
+
}
|
1017
|
+
this.childList = null;
|
1018
|
+
}
|
1019
|
+
if( ! isRecursiveCall ) {
|
1020
|
+
// this._expand(false);
|
1021
|
+
// this.isRead = false;
|
1022
|
+
this.isLoading = false;
|
1023
|
+
this.render(false, false);
|
1024
|
+
}
|
1025
|
+
},
|
1026
|
+
|
1027
|
+
reload: function(force) {
|
1028
|
+
// Discard lazy content (and reload, if node was expanded).
|
1029
|
+
if( this.parent == null )
|
1030
|
+
return this.tree.reload();
|
1031
|
+
|
1032
|
+
if( ! this.data.isLazy )
|
1033
|
+
throw "node.reload() requires lazy nodes.";
|
1034
|
+
if( this.bExpanded ) {
|
1035
|
+
this.expand(false);
|
1036
|
+
this.removeChildren();
|
1037
|
+
this.expand(true);
|
1038
|
+
} else {
|
1039
|
+
this.removeChildren();
|
1040
|
+
if( force )
|
1041
|
+
this._loadContent();
|
1042
|
+
}
|
1043
|
+
},
|
1044
|
+
|
1045
|
+
_addChildNode: function(dtnode, beforeNode) {
|
1046
|
+
/**
|
1047
|
+
* Internal function to add one single DynatreeNode as a child.
|
1048
|
+
*
|
1049
|
+
*/
|
1050
|
+
var tree = this.tree;
|
1051
|
+
var opts = tree.options;
|
1052
|
+
var pers = tree.persistence;
|
1053
|
+
|
1054
|
+
// tree.logDebug("%o._addChildNode(%o)", this, dtnode);
|
1055
|
+
|
1056
|
+
// --- Update and fix dtnode attributes if necessary
|
1057
|
+
dtnode.parent = this;
|
1058
|
+
// if( beforeNode && (beforeNode.parent !== this || beforeNode === dtnode ) )
|
1059
|
+
// throw "<beforeNode> must be another child of <this>";
|
1060
|
+
|
1061
|
+
// --- Add dtnode as a child
|
1062
|
+
if ( this.childList==null ) {
|
1063
|
+
this.childList = [];
|
1064
|
+
} else if( ! beforeNode ) {
|
1065
|
+
// Fix 'lastsib'
|
1066
|
+
$(this.childList[this.childList.length-1].span).removeClass(opts.classNames.lastsib);
|
1067
|
+
}
|
1068
|
+
if( beforeNode ) {
|
1069
|
+
var iBefore = $.inArray(beforeNode, this.childList);
|
1070
|
+
if( iBefore < 0 )
|
1071
|
+
throw "<beforeNode> must be a child of <this>";
|
1072
|
+
this.childList.splice(iBefore, 0, dtnode);
|
1073
|
+
// alert(this.childList);
|
1074
|
+
} else {
|
1075
|
+
// Append node
|
1076
|
+
this.childList.push(dtnode);
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
// --- Handle persistence
|
1080
|
+
// Initial status is read from cookies, if persistence is active and
|
1081
|
+
// cookies are already present.
|
1082
|
+
// Otherwise the status is read from the data attributes and then persisted.
|
1083
|
+
var isInitializing = tree.isInitializing();
|
1084
|
+
if( opts.persist && pers.cookiesFound && isInitializing ) {
|
1085
|
+
// Init status from cookies
|
1086
|
+
// tree.logDebug("init from cookie, pa=%o, dk=%o", pers.activeKey, dtnode.data.key);
|
1087
|
+
if( pers.activeKey == dtnode.data.key )
|
1088
|
+
tree.activeNode = dtnode;
|
1089
|
+
if( pers.focusedKey == dtnode.data.key )
|
1090
|
+
tree.focusNode = dtnode;
|
1091
|
+
dtnode.bExpanded = ($.inArray(dtnode.data.key, pers.expandedKeyList) >= 0);
|
1092
|
+
dtnode.bSelected = ($.inArray(dtnode.data.key, pers.selectedKeyList) >= 0);
|
1093
|
+
// tree.logDebug(" key=%o, bSelected=%o", dtnode.data.key, dtnode.bSelected);
|
1094
|
+
} else {
|
1095
|
+
// Init status from data (Note: we write the cookies after the init phase)
|
1096
|
+
// tree.logDebug("init from data");
|
1097
|
+
if( dtnode.data.activate ) {
|
1098
|
+
tree.activeNode = dtnode;
|
1099
|
+
if( opts.persist )
|
1100
|
+
pers.activeKey = dtnode.data.key;
|
1101
|
+
}
|
1102
|
+
if( dtnode.data.focus ) {
|
1103
|
+
tree.focusNode = dtnode;
|
1104
|
+
if( opts.persist )
|
1105
|
+
pers.focusedKey = dtnode.data.key;
|
1106
|
+
}
|
1107
|
+
dtnode.bExpanded = ( dtnode.data.expand == true ); // Collapsed by default
|
1108
|
+
if( dtnode.bExpanded && opts.persist )
|
1109
|
+
pers.addExpand(dtnode.data.key);
|
1110
|
+
dtnode.bSelected = ( dtnode.data.select == true ); // Deselected by default
|
1111
|
+
/*
|
1112
|
+
Doesn't work, cause pers.selectedKeyList may be null
|
1113
|
+
if( dtnode.bSelected && opts.selectMode==1
|
1114
|
+
&& pers.selectedKeyList && pers.selectedKeyList.length>0 ) {
|
1115
|
+
tree.logWarning("Ignored multi-selection in single-mode for %o", dtnode);
|
1116
|
+
dtnode.bSelected = false; // Fixing bad input data (multi selection for mode:1)
|
1117
|
+
}
|
1118
|
+
*/
|
1119
|
+
if( dtnode.bSelected && opts.persist )
|
1120
|
+
pers.addSelect(dtnode.data.key);
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
// Always expand, if it's below minExpandLevel
|
1124
|
+
// tree.logDebug ("%o._addChildNode(%o), l=%o", this, dtnode, dtnode.getLevel());
|
1125
|
+
if ( opts.minExpandLevel >= dtnode.getLevel() ) {
|
1126
|
+
// tree.logDebug ("Force expand for %o", dtnode);
|
1127
|
+
this.bExpanded = true;
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
// In multi-hier mode, update the parents selection state
|
1131
|
+
// issue #82: only if not initializing, because the children may not exist yet
|
1132
|
+
// if( !dtnode.data.isStatusNode && opts.selectMode==3 && !isInitializing )
|
1133
|
+
// dtnode._fixSelectionState();
|
1134
|
+
|
1135
|
+
// In multi-hier mode, update the parents selection state
|
1136
|
+
if( dtnode.bSelected && opts.selectMode==3 ) {
|
1137
|
+
var p = this;
|
1138
|
+
while( p ) {
|
1139
|
+
if( !p.hasSubSel )
|
1140
|
+
p._setSubSel(true);
|
1141
|
+
p = p.parent;
|
1142
|
+
}
|
1143
|
+
}
|
1144
|
+
// render this node and the new child
|
1145
|
+
if ( tree.bEnableUpdate )
|
1146
|
+
this.render(true, true);
|
1147
|
+
|
1148
|
+
return dtnode;
|
1149
|
+
},
|
1150
|
+
|
1151
|
+
addChild: function(obj, beforeNode) {
|
1152
|
+
/**
|
1153
|
+
* Add a node object as child.
|
1154
|
+
*
|
1155
|
+
* This should be the only place, where a DynaTreeNode is constructed!
|
1156
|
+
* (Except for the root node creation in the tree constructor)
|
1157
|
+
*
|
1158
|
+
* @param obj A JS object (may be recursive) or an array of those.
|
1159
|
+
* @param {DynaTreeNode} beforeNode (optional) sibling node.
|
1160
|
+
*
|
1161
|
+
* Data format: array of node objects, with optional 'children' attributes.
|
1162
|
+
* [
|
1163
|
+
* { title: "t1", isFolder: true, ... }
|
1164
|
+
* { title: "t2", isFolder: true, ...,
|
1165
|
+
* children: [
|
1166
|
+
* {title: "t2.1", ..},
|
1167
|
+
* {..}
|
1168
|
+
* ]
|
1169
|
+
* }
|
1170
|
+
* ]
|
1171
|
+
* A simple object is also accepted instead of an array.
|
1172
|
+
*
|
1173
|
+
*/
|
1174
|
+
// this.tree.logDebug("%o.addChild(%o, %o)", this, obj, beforeNode);
|
1175
|
+
if( !obj || obj.length==0 ) // Passed null or undefined or empty array
|
1176
|
+
return;
|
1177
|
+
if( obj instanceof DynaTreeNode )
|
1178
|
+
return this._addChildNode(obj, beforeNode);
|
1179
|
+
if( !obj.length ) // Passed a single data object
|
1180
|
+
obj = [ obj ];
|
1181
|
+
|
1182
|
+
var prevFlag = this.tree.enableUpdate(false);
|
1183
|
+
|
1184
|
+
var tnFirst = null;
|
1185
|
+
for (var i=0; i<obj.length; i++) {
|
1186
|
+
var data = obj[i];
|
1187
|
+
var dtnode = this._addChildNode(new DynaTreeNode(this, this.tree, data), beforeNode);
|
1188
|
+
if( !tnFirst ) tnFirst = dtnode;
|
1189
|
+
// Add child nodes recursively
|
1190
|
+
if( data.children )
|
1191
|
+
dtnode.addChild(data.children, null);
|
1192
|
+
}
|
1193
|
+
this.tree.enableUpdate(prevFlag);
|
1194
|
+
return tnFirst;
|
1195
|
+
},
|
1196
|
+
|
1197
|
+
append: function(obj) {
|
1198
|
+
this.tree.logWarning("node.append() is deprecated (use node.addChild() instead).");
|
1199
|
+
return this.addChild(obj, null);
|
1200
|
+
},
|
1201
|
+
|
1202
|
+
appendAjax: function(ajaxOptions) {
|
1203
|
+
this.removeChildren(false, true);
|
1204
|
+
this.setLazyNodeStatus(DTNodeStatus_Loading);
|
1205
|
+
// Ajax option inheritance: $.ajaxSetup < $.ui.dynatree.defaults.ajaxDefaults < tree.options.ajaxDefaults < ajaxOptions
|
1206
|
+
var self = this;
|
1207
|
+
var orgSuccess = ajaxOptions.success;
|
1208
|
+
var orgError = ajaxOptions.error;
|
1209
|
+
var options = $.extend({}, this.tree.options.ajaxDefaults, ajaxOptions, {
|
1210
|
+
/*
|
1211
|
+
complete: function(req, textStatus){
|
1212
|
+
alert("ajax complete");
|
1213
|
+
},
|
1214
|
+
timeout: 5000, // 5 sec
|
1215
|
+
*/
|
1216
|
+
success: function(data, textStatus){
|
1217
|
+
// <this> is the request options
|
1218
|
+
// self.tree.logDebug("appendAjax().success");
|
1219
|
+
var prevPhase = self.tree.phase;
|
1220
|
+
self.tree.phase = "init";
|
1221
|
+
// self.append(data);
|
1222
|
+
self.addChild(data, null);
|
1223
|
+
self.tree.phase = "postInit";
|
1224
|
+
self.setLazyNodeStatus(DTNodeStatus_Ok);
|
1225
|
+
if( orgSuccess )
|
1226
|
+
orgSuccess.call(options, self);
|
1227
|
+
self.tree.phase = prevPhase;
|
1228
|
+
},
|
1229
|
+
error: function(XMLHttpRequest, textStatus, errorThrown){
|
1230
|
+
// <this> is the request options
|
1231
|
+
// self.tree.logDebug("appendAjax().error");
|
1232
|
+
self.setLazyNodeStatus(DTNodeStatus_Error);
|
1233
|
+
if( orgError )
|
1234
|
+
orgError.call(options, self, XMLHttpRequest, textStatus, errorThrown);
|
1235
|
+
}
|
1236
|
+
});
|
1237
|
+
$.ajax(options);
|
1238
|
+
},
|
1239
|
+
// --- end of class
|
1240
|
+
lastentry: undefined
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
/*************************************************************************
|
1244
|
+
* class DynaTreeStatus
|
1245
|
+
*/
|
1246
|
+
|
1247
|
+
var DynaTreeStatus = Class.create();
|
1248
|
+
|
1249
|
+
|
1250
|
+
DynaTreeStatus._getTreePersistData = function(cookieId, cookieOpts) {
|
1251
|
+
// Static member: Return persistence information from cookies
|
1252
|
+
var ts = new DynaTreeStatus(cookieId, cookieOpts);
|
1253
|
+
ts.read();
|
1254
|
+
return ts.toDict();
|
1255
|
+
}
|
1256
|
+
// Make available in global scope
|
1257
|
+
getDynaTreePersistData = DynaTreeStatus._getTreePersistData;
|
1258
|
+
|
1259
|
+
|
1260
|
+
DynaTreeStatus.prototype = {
|
1261
|
+
// Constructor
|
1262
|
+
initialize: function(cookieId, cookieOpts) {
|
1263
|
+
this._log("DynaTreeStatus: initialize");
|
1264
|
+
if( cookieId === undefined )
|
1265
|
+
cookieId = $.ui.dynatree.defaults.cookieId;
|
1266
|
+
cookieOpts = $.extend({}, $.ui.dynatree.defaults.cookie, cookieOpts);
|
1267
|
+
|
1268
|
+
this.cookieId = cookieId;
|
1269
|
+
this.cookieOpts = cookieOpts;
|
1270
|
+
this.cookiesFound = undefined;
|
1271
|
+
this.activeKey = null;
|
1272
|
+
this.focusedKey = null;
|
1273
|
+
this.expandedKeyList = null;
|
1274
|
+
this.selectedKeyList = null;
|
1275
|
+
},
|
1276
|
+
// member functions
|
1277
|
+
_log: function(msg) {
|
1278
|
+
// this.logDebug("_changeNodeList(%o): nodeList:%o, idx:%o", mode, nodeList, idx);
|
1279
|
+
Array.prototype.unshift.apply(arguments, ["debug"]);
|
1280
|
+
_log.apply(this, arguments);
|
1281
|
+
},
|
1282
|
+
read: function() {
|
1283
|
+
this._log("DynaTreeStatus: read");
|
1284
|
+
// Read or init cookies.
|
1285
|
+
this.cookiesFound = false;
|
1286
|
+
|
1287
|
+
var cookie = $.cookie(this.cookieId + "-active");
|
1288
|
+
this.activeKey = ( cookie == null ) ? "" : cookie;
|
1289
|
+
if( cookie != null ) this.cookiesFound = true;
|
1290
|
+
|
1291
|
+
cookie = $.cookie(this.cookieId + "-focus");
|
1292
|
+
this.focusedKey = ( cookie == null ) ? "" : cookie;
|
1293
|
+
if( cookie != null ) this.cookiesFound = true;
|
1294
|
+
|
1295
|
+
cookie = $.cookie(this.cookieId + "-expand");
|
1296
|
+
this.expandedKeyList = ( cookie == null ) ? [] : cookie.split(",");
|
1297
|
+
if( cookie != null ) this.cookiesFound = true;
|
1298
|
+
|
1299
|
+
cookie = $.cookie(this.cookieId + "-select");
|
1300
|
+
this.selectedKeyList = ( cookie == null ) ? [] : cookie.split(",");
|
1301
|
+
if( cookie != null ) this.cookiesFound = true;
|
1302
|
+
},
|
1303
|
+
write: function() {
|
1304
|
+
this._log("DynaTreeStatus: write");
|
1305
|
+
$.cookie(this.cookieId + "-active", ( this.activeKey == null ) ? "" : this.activeKey, this.cookieOpts);
|
1306
|
+
$.cookie(this.cookieId + "-focus", ( this.focusedKey == null ) ? "" : this.focusedKey, this.cookieOpts);
|
1307
|
+
$.cookie(this.cookieId + "-expand", ( this.expandedKeyList == null ) ? "" : this.expandedKeyList.join(","), this.cookieOpts);
|
1308
|
+
$.cookie(this.cookieId + "-select", ( this.selectedKeyList == null ) ? "" : this.selectedKeyList.join(","), this.cookieOpts);
|
1309
|
+
},
|
1310
|
+
addExpand: function(key) {
|
1311
|
+
this._log("addExpand(%o)", key);
|
1312
|
+
if( $.inArray(key, this.expandedKeyList) < 0 ) {
|
1313
|
+
this.expandedKeyList.push(key);
|
1314
|
+
$.cookie(this.cookieId + "-expand", this.expandedKeyList.join(","), this.cookieOpts);
|
1315
|
+
}
|
1316
|
+
},
|
1317
|
+
clearExpand: function(key) {
|
1318
|
+
this._log("clearExpand(%o)", key);
|
1319
|
+
var idx = $.inArray(key, this.expandedKeyList);
|
1320
|
+
if( idx >= 0 ) {
|
1321
|
+
this.expandedKeyList.splice(idx, 1);
|
1322
|
+
$.cookie(this.cookieId + "-expand", this.expandedKeyList.join(","), this.cookieOpts);
|
1323
|
+
}
|
1324
|
+
},
|
1325
|
+
addSelect: function(key) {
|
1326
|
+
this._log("addSelect(%o)", key);
|
1327
|
+
if( $.inArray(key, this.selectedKeyList) < 0 ) {
|
1328
|
+
this.selectedKeyList.push(key);
|
1329
|
+
$.cookie(this.cookieId + "-select", this.selectedKeyList.join(","), this.cookieOpts);
|
1330
|
+
}
|
1331
|
+
},
|
1332
|
+
clearSelect: function(key) {
|
1333
|
+
this._log("clearSelect(%o)", key);
|
1334
|
+
var idx = $.inArray(key, this.selectedKeyList);
|
1335
|
+
if( idx >= 0 ) {
|
1336
|
+
this.selectedKeyList.splice(idx, 1);
|
1337
|
+
$.cookie(this.cookieId + "-select", this.selectedKeyList.join(","), this.cookieOpts);
|
1338
|
+
}
|
1339
|
+
},
|
1340
|
+
isReloading: function() {
|
1341
|
+
return this.cookiesFound == true;
|
1342
|
+
},
|
1343
|
+
toDict: function() {
|
1344
|
+
return {
|
1345
|
+
cookiesFound: this.cookiesFound,
|
1346
|
+
activeKey: this.activeKey,
|
1347
|
+
focusedKey: this.activeKey,
|
1348
|
+
expandedKeyList: this.expandedKeyList,
|
1349
|
+
selectedKeyList: this.selectedKeyList
|
1350
|
+
};
|
1351
|
+
},
|
1352
|
+
// --- end of class
|
1353
|
+
lastentry: undefined
|
1354
|
+
};
|
1355
|
+
|
1356
|
+
|
1357
|
+
/*************************************************************************
|
1358
|
+
* class DynaTree
|
1359
|
+
*/
|
1360
|
+
|
1361
|
+
var DynaTree = Class.create();
|
1362
|
+
|
1363
|
+
// --- Static members ----------------------------------------------------------
|
1364
|
+
|
1365
|
+
DynaTree.version = "$Version: 0.5.2$";
|
1366
|
+
/*
|
1367
|
+
DynaTree._initTree = function() {
|
1368
|
+
};
|
1369
|
+
|
1370
|
+
DynaTree._bind = function() {
|
1371
|
+
};
|
1372
|
+
*/
|
1373
|
+
//--- Class members ------------------------------------------------------------
|
1374
|
+
|
1375
|
+
DynaTree.prototype = {
|
1376
|
+
// Constructor
|
1377
|
+
// initialize: function(divContainer, options) {
|
1378
|
+
initialize: function($widget) {
|
1379
|
+
// instance members
|
1380
|
+
this.phase = "init";
|
1381
|
+
this.$widget = $widget;
|
1382
|
+
this.options = $widget.options;
|
1383
|
+
this.$tree = $widget.element;
|
1384
|
+
// find container element
|
1385
|
+
this.divTree = this.$tree.get(0);
|
1386
|
+
},
|
1387
|
+
|
1388
|
+
// member functions
|
1389
|
+
|
1390
|
+
_load: function() {
|
1391
|
+
var $widget = this.$widget;
|
1392
|
+
var opts = this.options;
|
1393
|
+
this.bEnableUpdate = true;
|
1394
|
+
this._nodeCount = 1;
|
1395
|
+
this.activeNode = null;
|
1396
|
+
this.focusNode = null;
|
1397
|
+
|
1398
|
+
// If a 'options.classNames' dictionary was passed, still use defaults
|
1399
|
+
// for undefined classes:
|
1400
|
+
if( opts.classNames !== $.ui.dynatree.defaults.classNames ) {
|
1401
|
+
opts.classNames = $.extend({}, $.ui.dynatree.defaults.classNames, opts.classNames);
|
1402
|
+
}
|
1403
|
+
// Guess skin path, if not specified
|
1404
|
+
if(!opts.imagePath) {
|
1405
|
+
$("script").each( function () {
|
1406
|
+
// Eclipse syntax parser breaks on this expression, so put it at the bottom:
|
1407
|
+
if( this.src.search(_rexDtLibName) >= 0 ) {
|
1408
|
+
if( this.src.indexOf("/")>=0 ) // issue #47
|
1409
|
+
opts.imagePath = this.src.slice(0, this.src.lastIndexOf("/")) + "/skin/";
|
1410
|
+
else
|
1411
|
+
opts.imagePath = "skin/";
|
1412
|
+
// logMsg("Guessing imagePath from '%s': '%s'", this.src, opts.imagePath);
|
1413
|
+
return false; // first match
|
1414
|
+
}
|
1415
|
+
});
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
this.persistence = new DynaTreeStatus(opts.cookieId, opts.cookie);
|
1419
|
+
if( opts.persist ) {
|
1420
|
+
if( !$.cookie )
|
1421
|
+
_log("warn", "Please include jquery.cookie.js to use persistence.");
|
1422
|
+
this.persistence.read();
|
1423
|
+
}
|
1424
|
+
this.logDebug("DynaTree.persistence: %o", this.persistence.toDict());
|
1425
|
+
|
1426
|
+
// Cached tag strings
|
1427
|
+
this.cache = {
|
1428
|
+
tagEmpty: "<span class='" + opts.classNames.empty + "'></span>",
|
1429
|
+
tagVline: "<span class='" + opts.classNames.vline + "'></span>",
|
1430
|
+
tagExpander: "<span class='" + opts.classNames.expander + "'></span>",
|
1431
|
+
tagConnector: "<span class='" + opts.classNames.connector + "'></span>",
|
1432
|
+
tagNodeIcon: "<span class='" + opts.classNames.nodeIcon + "'></span>",
|
1433
|
+
tagCheckbox: "<span class='" + opts.classNames.checkbox + "'></span>",
|
1434
|
+
lastentry: undefined
|
1435
|
+
};
|
1436
|
+
|
1437
|
+
// Clear container, in case it contained some 'waiting' or 'error' text
|
1438
|
+
// for clients that don't support JS.
|
1439
|
+
// We don't do this however, if we try to load from an embedded UL element.
|
1440
|
+
if( opts.children || (opts.initAjax && opts.initAjax.url) || opts.initId )
|
1441
|
+
$(this.divTree).empty();
|
1442
|
+
else if( this.divRoot )
|
1443
|
+
$(this.divRoot).remove();
|
1444
|
+
|
1445
|
+
// create the root element
|
1446
|
+
this.tnRoot = new DynaTreeNode(null, this, {title: opts.title, key: "root"});
|
1447
|
+
this.tnRoot.data.isFolder = true;
|
1448
|
+
this.tnRoot.render(false, false);
|
1449
|
+
this.divRoot = this.tnRoot.div;
|
1450
|
+
this.divRoot.className = opts.classNames.container;
|
1451
|
+
// add root to container
|
1452
|
+
// TODO: this should be delayed until all children have been created for performance reasons
|
1453
|
+
this.divTree.appendChild(this.divRoot);
|
1454
|
+
|
1455
|
+
var root = this.tnRoot;
|
1456
|
+
var isReloading = ( opts.persist && this.persistence.isReloading() );
|
1457
|
+
var isLazy = false;
|
1458
|
+
var prevFlag = this.enableUpdate(false);
|
1459
|
+
|
1460
|
+
this.logDebug("Dynatree._load(): read tree structure...");
|
1461
|
+
|
1462
|
+
// Init tree structure
|
1463
|
+
if( opts.children ) {
|
1464
|
+
// Read structure from node array
|
1465
|
+
root.addChild(opts.children);
|
1466
|
+
|
1467
|
+
} else if( opts.initAjax && opts.initAjax.url ) {
|
1468
|
+
// Init tree from AJAX request
|
1469
|
+
isLazy = true;
|
1470
|
+
root.data.isLazy = true;
|
1471
|
+
this._reloadAjax();
|
1472
|
+
|
1473
|
+
} else if( opts.initId ) {
|
1474
|
+
// Init tree from another UL element
|
1475
|
+
this._createFromTag(root, $("#"+opts.initId));
|
1476
|
+
|
1477
|
+
} else {
|
1478
|
+
// Init tree from the first UL element inside the container <div>
|
1479
|
+
var $ul = this.$tree.find(">ul").hide();
|
1480
|
+
this._createFromTag(root, $ul);
|
1481
|
+
$ul.remove();
|
1482
|
+
}
|
1483
|
+
|
1484
|
+
this._checkConsistency();
|
1485
|
+
// Render html markup
|
1486
|
+
this.logDebug("Dynatree._load(): render nodes...");
|
1487
|
+
this.enableUpdate(prevFlag);
|
1488
|
+
|
1489
|
+
// bind event handlers
|
1490
|
+
this.logDebug("Dynatree._load(): bind events...");
|
1491
|
+
this.$widget.bind();
|
1492
|
+
|
1493
|
+
// --- Post-load processing
|
1494
|
+
this.logDebug("Dynatree._load(): postInit...");
|
1495
|
+
this.phase = "postInit";
|
1496
|
+
|
1497
|
+
// In persist mode, make sure that cookies are written, even if they are empty
|
1498
|
+
if( opts.persist ) {
|
1499
|
+
this.persistence.write();
|
1500
|
+
}
|
1501
|
+
|
1502
|
+
// Set focus, if possible (this will also fire an event and write a cookie)
|
1503
|
+
if( this.focusNode && this.focusNode.isVisible() ) {
|
1504
|
+
this.logDebug("Focus on init: %o", this.focusNode);
|
1505
|
+
this.focusNode.focus();
|
1506
|
+
}
|
1507
|
+
|
1508
|
+
if( !isLazy && opts.onPostInit ) {
|
1509
|
+
opts.onPostInit.call(this, isReloading, false);
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
this.phase = "idle";
|
1513
|
+
},
|
1514
|
+
|
1515
|
+
_reloadAjax: function() {
|
1516
|
+
// Reload
|
1517
|
+
var opts = this.options;
|
1518
|
+
if( ! opts.initAjax || ! opts.initAjax.url )
|
1519
|
+
throw "tree.reload() requires 'initAjax' mode.";
|
1520
|
+
var pers = this.persistence;
|
1521
|
+
var ajaxOpts = $.extend({}, opts.initAjax);
|
1522
|
+
// Append cookie info to the request
|
1523
|
+
// this.logDebug("reloadAjax: key=%o, an.key:%o", pers.activeKey, this.activeNode?this.activeNode.data.key:"?");
|
1524
|
+
if( ajaxOpts.addActiveKey )
|
1525
|
+
ajaxOpts.data.activeKey = pers.activeKey;
|
1526
|
+
if( ajaxOpts.addFocusedKey )
|
1527
|
+
ajaxOpts.data.focusedKey = pers.focusedKey;
|
1528
|
+
if( ajaxOpts.addExpandedKeyList )
|
1529
|
+
ajaxOpts.data.expandedKeyList = pers.expandedKeyList.join(",");
|
1530
|
+
if( ajaxOpts.addSelectedKeyList )
|
1531
|
+
ajaxOpts.data.selectedKeyList = pers.selectedKeyList.join(",");
|
1532
|
+
|
1533
|
+
// Set up onPostInit callback to be called when Ajax returns
|
1534
|
+
if( opts.onPostInit ) {
|
1535
|
+
if( ajaxOpts.success )
|
1536
|
+
this.tree.logWarning("initAjax: success callback is ignored when onPostInit was specified.");
|
1537
|
+
if( ajaxOpts.error )
|
1538
|
+
this.tree.logWarning("initAjax: error callback is ignored when onPostInit was specified.");
|
1539
|
+
var isReloading = pers.isReloading();
|
1540
|
+
ajaxOpts["success"] = function(dtnode) { opts.onPostInit.call(dtnode.tree, isReloading, false); };
|
1541
|
+
ajaxOpts["error"] = function(dtnode) { opts.onPostInit.call(dtnode.tree, isReloading, true); };
|
1542
|
+
}
|
1543
|
+
this.logDebug("Dynatree._init(): send Ajax request...");
|
1544
|
+
this.tnRoot.appendAjax(ajaxOpts);
|
1545
|
+
},
|
1546
|
+
|
1547
|
+
toString: function() {
|
1548
|
+
return "DynaTree '" + this.options.title + "'";
|
1549
|
+
},
|
1550
|
+
|
1551
|
+
toDict: function() {
|
1552
|
+
return this.tnRoot.toDict(true);
|
1553
|
+
},
|
1554
|
+
|
1555
|
+
getPersistData: function() {
|
1556
|
+
return this.persistence.toDict();
|
1557
|
+
},
|
1558
|
+
|
1559
|
+
logDebug: function(msg) {
|
1560
|
+
if( this.options.debugLevel >= 2 ) {
|
1561
|
+
Array.prototype.unshift.apply(arguments, ["debug"]);
|
1562
|
+
_log.apply(this, arguments);
|
1563
|
+
}
|
1564
|
+
},
|
1565
|
+
|
1566
|
+
logInfo: function(msg) {
|
1567
|
+
if( this.options.debugLevel >= 1 ) {
|
1568
|
+
Array.prototype.unshift.apply(arguments, ["info"]);
|
1569
|
+
_log.apply(this, arguments);
|
1570
|
+
}
|
1571
|
+
},
|
1572
|
+
|
1573
|
+
logWarning: function(msg) {
|
1574
|
+
Array.prototype.unshift.apply(arguments, ["warn"]);
|
1575
|
+
_log.apply(this, arguments);
|
1576
|
+
},
|
1577
|
+
|
1578
|
+
isInitializing: function() {
|
1579
|
+
return ( this.phase=="init" || this.phase=="postInit" );
|
1580
|
+
},
|
1581
|
+
isReloading: function() {
|
1582
|
+
return ( this.phase=="init" || this.phase=="postInit" ) && this.options.persist && this.persistence.cookiesFound;
|
1583
|
+
},
|
1584
|
+
isUserEvent: function() {
|
1585
|
+
return ( this.phase=="userEvent" );
|
1586
|
+
},
|
1587
|
+
|
1588
|
+
redraw: function() {
|
1589
|
+
this.logDebug("dynatree.redraw()...");
|
1590
|
+
this.tnRoot.render(true, true);
|
1591
|
+
this.logDebug("dynatree.redraw() done.");
|
1592
|
+
},
|
1593
|
+
|
1594
|
+
reloadAjax: function() {
|
1595
|
+
this.logWarning("tree.reloadAjax() is deprecated since v0.5.2 (use reload() instead).");
|
1596
|
+
},
|
1597
|
+
|
1598
|
+
reload: function() {
|
1599
|
+
this._load();
|
1600
|
+
},
|
1601
|
+
|
1602
|
+
getRoot: function() {
|
1603
|
+
return this.tnRoot;
|
1604
|
+
},
|
1605
|
+
|
1606
|
+
getNodeByKey: function(key) {
|
1607
|
+
// $("#...") has problems, if the key contains '.', so we use getElementById()
|
1608
|
+
// return $("#" + this.options.idPrefix + key).attr("dtnode");
|
1609
|
+
var el = document.getElementById(this.options.idPrefix + key);
|
1610
|
+
return ( el && el.dtnode ) ? el.dtnode : null;
|
1611
|
+
},
|
1612
|
+
|
1613
|
+
getActiveNode: function() {
|
1614
|
+
return this.activeNode;
|
1615
|
+
},
|
1616
|
+
|
1617
|
+
reactivate: function(setFocus) {
|
1618
|
+
// Re-fire onQueryActivate and onActivate events.
|
1619
|
+
var node = this.activeNode;
|
1620
|
+
// this.logDebug("reactivate %o", node);
|
1621
|
+
if( node ) {
|
1622
|
+
this.activeNode = null; // Force re-activating
|
1623
|
+
node.activate();
|
1624
|
+
if( setFocus )
|
1625
|
+
node.focus();
|
1626
|
+
}
|
1627
|
+
},
|
1628
|
+
|
1629
|
+
getSelectedNodes: function(stopOnParents) {
|
1630
|
+
var nodeList = [];
|
1631
|
+
this.tnRoot.visit(function(dtnode){
|
1632
|
+
if( dtnode.bSelected ) {
|
1633
|
+
nodeList.push(dtnode);
|
1634
|
+
if( stopOnParents == true )
|
1635
|
+
return false; // stop processing this branch
|
1636
|
+
}
|
1637
|
+
});
|
1638
|
+
return nodeList;
|
1639
|
+
},
|
1640
|
+
|
1641
|
+
activateKey: function(key) {
|
1642
|
+
var dtnode = (key === null) ? null : this.getNodeByKey(key);
|
1643
|
+
if( !dtnode ) {
|
1644
|
+
if( this.activeNode )
|
1645
|
+
this.activeNode.deactivate();
|
1646
|
+
this.activeNode = null;
|
1647
|
+
return null;
|
1648
|
+
}
|
1649
|
+
dtnode.focus();
|
1650
|
+
dtnode.activate();
|
1651
|
+
return dtnode;
|
1652
|
+
},
|
1653
|
+
|
1654
|
+
selectKey: function(key, select) {
|
1655
|
+
var dtnode = this.getNodeByKey(key);
|
1656
|
+
if( !dtnode )
|
1657
|
+
return null;
|
1658
|
+
dtnode.select(select);
|
1659
|
+
return dtnode;
|
1660
|
+
},
|
1661
|
+
|
1662
|
+
enableUpdate: function(bEnable) {
|
1663
|
+
if ( this.bEnableUpdate==bEnable )
|
1664
|
+
return bEnable;
|
1665
|
+
this.bEnableUpdate = bEnable;
|
1666
|
+
if ( bEnable )
|
1667
|
+
this.redraw();
|
1668
|
+
return !bEnable; // return previous value
|
1669
|
+
},
|
1670
|
+
|
1671
|
+
visit: function(fn, data, includeRoot) {
|
1672
|
+
return this.tnRoot.visit(fn, data, includeRoot);
|
1673
|
+
},
|
1674
|
+
|
1675
|
+
_createFromTag: function(parentTreeNode, $ulParent) {
|
1676
|
+
// Convert a <UL>...</UL> list into children of the parent tree node.
|
1677
|
+
var self = this;
|
1678
|
+
/*
|
1679
|
+
TODO: better?
|
1680
|
+
this.$lis = $("li:has(a[href])", this.element);
|
1681
|
+
this.$tabs = this.$lis.map(function() { return $("a", this)[0]; });
|
1682
|
+
*/
|
1683
|
+
$ulParent.find(">li").each(function() {
|
1684
|
+
var $li = $(this);
|
1685
|
+
var $liSpan = $li.find(">span:first");
|
1686
|
+
var title;
|
1687
|
+
if( $liSpan.length ) {
|
1688
|
+
// If a <li><span> tag is specified, use it literally.
|
1689
|
+
title = $liSpan.html();
|
1690
|
+
} else {
|
1691
|
+
// If only a <li> tag is specified, use the trimmed string up to the next child <ul> tag.
|
1692
|
+
title = $li.html();
|
1693
|
+
var iPos = title.search(/<ul/i);
|
1694
|
+
if( iPos>=0 )
|
1695
|
+
title = $.trim(title.substring(0, iPos));
|
1696
|
+
else
|
1697
|
+
title = $.trim(title);
|
1698
|
+
// self.logDebug("%o", title);
|
1699
|
+
}
|
1700
|
+
// Parse node options from ID, title and class attributes
|
1701
|
+
var data = {
|
1702
|
+
title: title,
|
1703
|
+
isFolder: $li.hasClass("folder"),
|
1704
|
+
isLazy: $li.hasClass("lazy"),
|
1705
|
+
expand: $li.hasClass("expanded"),
|
1706
|
+
select: $li.hasClass("selected"),
|
1707
|
+
activate: $li.hasClass("active"),
|
1708
|
+
focus: $li.hasClass("focused")
|
1709
|
+
};
|
1710
|
+
if( $li.attr("title") )
|
1711
|
+
data.tooltip = $li.attr("title");
|
1712
|
+
if( $li.attr("id") )
|
1713
|
+
data.key = $li.attr("id");
|
1714
|
+
// If a data attribute is present, evaluate as a JavaScript object
|
1715
|
+
if( $li.attr("data") ) {
|
1716
|
+
var dataAttr = $.trim($li.attr("data"));
|
1717
|
+
if( dataAttr ) {
|
1718
|
+
if( dataAttr.charAt(0) != "{" )
|
1719
|
+
dataAttr = "{" + dataAttr + "}"
|
1720
|
+
try {
|
1721
|
+
$.extend(data, eval("(" + dataAttr + ")"));
|
1722
|
+
} catch(e) {
|
1723
|
+
throw ("Error parsing node data: " + e + "\ndata:\n'" + dataAttr + "'");
|
1724
|
+
}
|
1725
|
+
}
|
1726
|
+
}
|
1727
|
+
childNode = parentTreeNode.addChild(data);
|
1728
|
+
// Recursive reading of child nodes, if LI tag contains an UL tag
|
1729
|
+
var $ul = $li.find(">ul:first");
|
1730
|
+
if( $ul.length ) {
|
1731
|
+
self._createFromTag(childNode, $ul); // must use 'self', because 'this' is the each() context
|
1732
|
+
}
|
1733
|
+
});
|
1734
|
+
},
|
1735
|
+
|
1736
|
+
_checkConsistency: function() {
|
1737
|
+
// this.logDebug("tree._checkConsistency() NOT IMPLEMENTED - %o", this);
|
1738
|
+
},
|
1739
|
+
|
1740
|
+
// --- end of class
|
1741
|
+
lastentry: undefined
|
1742
|
+
};
|
1743
|
+
|
1744
|
+
/*************************************************************************
|
1745
|
+
* widget $(..).dynatree
|
1746
|
+
*/
|
1747
|
+
|
1748
|
+
$.widget("ui.dynatree", {
|
1749
|
+
init: function() {
|
1750
|
+
// ui.core 1.6 renamed init() to _init(): this stub assures backward compatibility
|
1751
|
+
_log("warn", "ui.dynatree.init() was called; you should upgrade to ui.core.js v1.6 or higher.");
|
1752
|
+
return this._init();
|
1753
|
+
},
|
1754
|
+
|
1755
|
+
_init: function() {
|
1756
|
+
logMsg("Dynatree._init(): version='%s', debugLevel=%o.", DynaTree.version, this.options.debugLevel);
|
1757
|
+
|
1758
|
+
var opts = this.options;
|
1759
|
+
// The widget framework supplies this.element and this.options.
|
1760
|
+
this.options.event += ".dynatree"; // namespace event
|
1761
|
+
|
1762
|
+
var divTree = this.element.get(0);
|
1763
|
+
/* // Clear container, in case it contained some 'waiting' or 'error' text
|
1764
|
+
// for clients that don't support JS
|
1765
|
+
if( opts.children || (opts.initAjax && opts.initAjax.url) || opts.initId )
|
1766
|
+
$(divTree).empty();
|
1767
|
+
*/
|
1768
|
+
// Create the DynaTree object
|
1769
|
+
this.tree = new DynaTree(this);
|
1770
|
+
this.tree._load();
|
1771
|
+
this.tree.logDebug("Dynatree._init(): done.");
|
1772
|
+
},
|
1773
|
+
|
1774
|
+
bind: function() {
|
1775
|
+
var $this = this.element;
|
1776
|
+
var o = this.options;
|
1777
|
+
|
1778
|
+
// Prevent duplicate binding
|
1779
|
+
this.unbind();
|
1780
|
+
|
1781
|
+
// Tool function to get dtnode from the event target:
|
1782
|
+
function __getNodeFromElement(el) {
|
1783
|
+
var iMax = 5;
|
1784
|
+
while( el && iMax-- ) {
|
1785
|
+
if( el.dtnode ) return el.dtnode;
|
1786
|
+
el = el.parentNode;
|
1787
|
+
};
|
1788
|
+
return null;
|
1789
|
+
}
|
1790
|
+
|
1791
|
+
var eventNames = "click.dynatree dblclick.dynatree";
|
1792
|
+
if( o.keyboard ) // Note: leading ' '!
|
1793
|
+
eventNames += " keypress.dynatree keydown.dynatree";
|
1794
|
+
$this.bind(eventNames, function(event){
|
1795
|
+
var dtnode = __getNodeFromElement(event.target);
|
1796
|
+
if( !dtnode )
|
1797
|
+
return true; // Allow bubbling of other events
|
1798
|
+
var prevPhase = dtnode.tree.phase;
|
1799
|
+
dtnode.tree.phase = "userEvent";
|
1800
|
+
try {
|
1801
|
+
dtnode.tree.logDebug("bind(%o): dtnode: %o", event, dtnode);
|
1802
|
+
|
1803
|
+
switch(event.type) {
|
1804
|
+
case "click":
|
1805
|
+
return ( o.onClick && o.onClick(dtnode, event)===false ) ? false : dtnode.onClick(event);
|
1806
|
+
case "dblclick":
|
1807
|
+
return ( o.onDblClick && o.onDblClick(dtnode, event)===false ) ? false : dtnode.onDblClick(event);
|
1808
|
+
case "keydown":
|
1809
|
+
return ( o.onKeydown && o.onKeydown(dtnode, event)===false ) ? false : dtnode.onKeydown(event);
|
1810
|
+
case "keypress":
|
1811
|
+
return ( o.onKeypress && o.onKeypress(dtnode, event)===false ) ? false : dtnode.onKeypress(event);
|
1812
|
+
};
|
1813
|
+
} catch(e) {
|
1814
|
+
var _ = null; // issue 117
|
1815
|
+
// dtnode.tree.logError("bind(%o): dtnode: %o", event, dtnode);
|
1816
|
+
} finally {
|
1817
|
+
dtnode.tree.phase = prevPhase;
|
1818
|
+
}
|
1819
|
+
});
|
1820
|
+
|
1821
|
+
// focus/blur don't bubble, i.e. are not delegated to parent <div> tags,
|
1822
|
+
// so we use the addEventListener capturing phase.
|
1823
|
+
// See http://www.howtocreate.co.uk/tutorials/javascript/domevents
|
1824
|
+
function __focusHandler(event) {
|
1825
|
+
// Handles blur and focus.
|
1826
|
+
// Fix event for IE:
|
1827
|
+
event = arguments[0] = $.event.fix( event || window.event );
|
1828
|
+
var dtnode = __getNodeFromElement(event.target);
|
1829
|
+
return dtnode ? dtnode.onFocus(event) : false;
|
1830
|
+
}
|
1831
|
+
var div = this.tree.divTree;
|
1832
|
+
if( div.addEventListener ) {
|
1833
|
+
div.addEventListener("focus", __focusHandler, true);
|
1834
|
+
div.addEventListener("blur", __focusHandler, true);
|
1835
|
+
} else {
|
1836
|
+
div.onfocusin = div.onfocusout = __focusHandler;
|
1837
|
+
}
|
1838
|
+
// EVENTS
|
1839
|
+
// disable click if event is configured to something else
|
1840
|
+
// if (!(/^click/).test(o.event))
|
1841
|
+
// this.$tabs.bind("click.tabs", function() { return false; });
|
1842
|
+
|
1843
|
+
},
|
1844
|
+
|
1845
|
+
unbind: function() {
|
1846
|
+
this.element.unbind(".dynatree");
|
1847
|
+
},
|
1848
|
+
|
1849
|
+
/* TODO: we could handle option changes during runtime here (maybe to re-render, ...)
|
1850
|
+
setData: function(key, value) {
|
1851
|
+
this.tree.logDebug("dynatree.setData('" + key + "', '" + value + "')");
|
1852
|
+
},
|
1853
|
+
*/
|
1854
|
+
enable: function() {
|
1855
|
+
this.bind();
|
1856
|
+
// Call default disable(): remove -disabled from css:
|
1857
|
+
$.widget.prototype.enable.apply(this, arguments);
|
1858
|
+
},
|
1859
|
+
|
1860
|
+
disable: function() {
|
1861
|
+
this.unbind();
|
1862
|
+
// Call default disable(): add -disabled to css:
|
1863
|
+
$.widget.prototype.disable.apply(this, arguments);
|
1864
|
+
},
|
1865
|
+
|
1866
|
+
// --- getter methods (i.e. NOT returning a reference to $)
|
1867
|
+
getTree: function() {
|
1868
|
+
return this.tree;
|
1869
|
+
},
|
1870
|
+
|
1871
|
+
getRoot: function() {
|
1872
|
+
return this.tree.getRoot();
|
1873
|
+
},
|
1874
|
+
|
1875
|
+
getActiveNode: function() {
|
1876
|
+
return this.tree.getActiveNode();
|
1877
|
+
},
|
1878
|
+
|
1879
|
+
getSelectedNodes: function() {
|
1880
|
+
return this.tree.getSelectedNodes();
|
1881
|
+
},
|
1882
|
+
|
1883
|
+
// ------------------------------------------------------------------------
|
1884
|
+
lastentry: undefined
|
1885
|
+
});
|
1886
|
+
|
1887
|
+
|
1888
|
+
// The following methods return a value (thus breaking the jQuery call chain):
|
1889
|
+
|
1890
|
+
$.ui.dynatree.getter = "getTree getRoot getActiveNode getSelectedNodes";
|
1891
|
+
|
1892
|
+
|
1893
|
+
// Plugin default options:
|
1894
|
+
|
1895
|
+
$.ui.dynatree.defaults = {
|
1896
|
+
title: "Dynatree root", // Name of the root node.
|
1897
|
+
rootVisible: false, // Set to true, to make the root node visible.
|
1898
|
+
minExpandLevel: 1, // 1: root node is not collapsible
|
1899
|
+
imagePath: null, // Path to a folder containing icons. Defaults to 'skin/' subdirectory.
|
1900
|
+
children: null, // Init tree structure from this object array.
|
1901
|
+
initId: null, // Init tree structure from a <ul> element with this ID.
|
1902
|
+
initAjax: null, // Ajax options used to initialize the tree strucuture.
|
1903
|
+
autoFocus: true, // Set focus to first child, when expanding or lazy-loading.
|
1904
|
+
keyboard: true, // Support keyboard navigation.
|
1905
|
+
persist: false, // Persist expand-status to a cookie
|
1906
|
+
autoCollapse: false, // Automatically collapse all siblings, when a node is expanded.
|
1907
|
+
clickFolderMode: 3, // 1:activate, 2:expand, 3:activate and expand
|
1908
|
+
activeVisible: true, // Make sure, active nodes are visible (expanded).
|
1909
|
+
checkbox: false, // Show checkboxes.
|
1910
|
+
selectMode: 2, // 1:single, 2:multi, 3:multi-hier
|
1911
|
+
fx: null, // Animations, e.g. null or { height: "toggle", duration: 200 }
|
1912
|
+
|
1913
|
+
// Low level event handlers: onEvent(dtnode, event): return false, to stop default processing
|
1914
|
+
onClick: null, // null: generate focus, expand, activate, select events.
|
1915
|
+
onDblClick: null, // (No default actions.)
|
1916
|
+
onKeydown: null, // null: generate keyboard navigation (focus, expand, activate).
|
1917
|
+
onKeypress: null, // (No default actions.)
|
1918
|
+
onFocus: null, // null: set focus to node.
|
1919
|
+
onBlur: null, // null: remove focus from node.
|
1920
|
+
|
1921
|
+
// Pre-event handlers onQueryEvent(flag, dtnode): return false, to stop processing
|
1922
|
+
onQueryActivate: null, // Callback(flag, dtnode) before a node is (de)activated.
|
1923
|
+
onQuerySelect: null, // Callback(flag, dtnode) before a node is (de)selected.
|
1924
|
+
onQueryExpand: null, // Callback(flag, dtnode) before a node is expanded/collpsed.
|
1925
|
+
|
1926
|
+
// High level event handlers
|
1927
|
+
onPostInit: null, // Callback(isReloading, isError) when tree was (re)loaded.
|
1928
|
+
onActivate: null, // Callback(dtnode) when a node is activated.
|
1929
|
+
onDeactivate: null, // Callback(dtnode) when a node is deactivated.
|
1930
|
+
onSelect: null, // Callback(flag, dtnode) when a node is (de)selected.
|
1931
|
+
onExpand: null, // Callback(dtnode) when a node is expanded/collapsed.
|
1932
|
+
onLazyRead: null, // Callback(dtnode) when a lazy node is expanded for the first time.
|
1933
|
+
|
1934
|
+
ajaxDefaults: { // Used by initAjax option
|
1935
|
+
cache: false, // false: Append random '_' argument to the request url to prevent caching.
|
1936
|
+
dataType: "json" // Expect json format and pass json object to callbacks.
|
1937
|
+
},
|
1938
|
+
strings: {
|
1939
|
+
loading: "Loading…",
|
1940
|
+
loadError: "Load error!"
|
1941
|
+
},
|
1942
|
+
idPrefix: "ui-dynatree-id-", // Used to generate node id's like <span id="ui-dynatree-id-<key>">.
|
1943
|
+
// cookieId: "ui-dynatree-cookie", // Choose a more unique name, to allow multiple trees.
|
1944
|
+
cookieId: "dynatree", // Choose a more unique name, to allow multiple trees.
|
1945
|
+
cookie: {
|
1946
|
+
expires: null //7, // Days or Date; null: session cookie
|
1947
|
+
// path: "/", // Defaults to current page
|
1948
|
+
// domain: "jquery.com",
|
1949
|
+
// secure: true
|
1950
|
+
},
|
1951
|
+
// Class names used, when rendering the HTML markup.
|
1952
|
+
// Note: if only single entries are passed for options.classNames, all other
|
1953
|
+
// values are still set to default.
|
1954
|
+
classNames: {
|
1955
|
+
container: "ui-dynatree-container",
|
1956
|
+
folder: "ui-dynatree-folder",
|
1957
|
+
document: "ui-dynatree-document",
|
1958
|
+
|
1959
|
+
empty: "ui-dynatree-empty",
|
1960
|
+
vline: "ui-dynatree-vline",
|
1961
|
+
expander: "ui-dynatree-expander",
|
1962
|
+
connector: "ui-dynatree-connector",
|
1963
|
+
checkbox: "ui-dynatree-checkbox",
|
1964
|
+
nodeIcon: "ui-dynatree-icon",
|
1965
|
+
title: "ui-dynatree-title",
|
1966
|
+
|
1967
|
+
nodeError: "ui-dynatree-statusnode-error",
|
1968
|
+
nodeWait: "ui-dynatree-statusnode-wait",
|
1969
|
+
hidden: "ui-dynatree-hidden",
|
1970
|
+
combinedExpanderPrefix: "ui-dynatree-exp-",
|
1971
|
+
combinedIconPrefix: "ui-dynatree-ico-",
|
1972
|
+
// disabled: "ui-dynatree-disabled",
|
1973
|
+
hasChildren: "ui-dynatree-has-children",
|
1974
|
+
active: "ui-dynatree-active",
|
1975
|
+
selected: "ui-dynatree-selected",
|
1976
|
+
expanded: "ui-dynatree-expanded",
|
1977
|
+
lazy: "ui-dynatree-lazy",
|
1978
|
+
focused: "ui-dynatree-focused",
|
1979
|
+
partsel: "ui-dynatree-partsel",
|
1980
|
+
lastsib: "ui-dynatree-lastsib"
|
1981
|
+
},
|
1982
|
+
debugLevel: 1,
|
1983
|
+
|
1984
|
+
// ------------------------------------------------------------------------
|
1985
|
+
lastentry: undefined
|
1986
|
+
};
|
1987
|
+
|
1988
|
+
/**
|
1989
|
+
* Reserved data attributes for a tree node.
|
1990
|
+
*/
|
1991
|
+
$.ui.dynatree.nodedatadefaults = {
|
1992
|
+
title: null, // (required) Displayed name of the node (html is allowed here)
|
1993
|
+
key: null, // May be used with activate(), select(), find(), ...
|
1994
|
+
isFolder: false, // Use a folder icon. Also the node is expandable but not selectable.
|
1995
|
+
isLazy: false, // Call onLazyRead(), when the node is expanded for the first time to allow for delayed creation of children.
|
1996
|
+
tooltip: null, // Show this popup text.
|
1997
|
+
icon: null, // Use a custom image (filename relative to tree.options.imagePath). 'null' for default icon, 'false' for no icon.
|
1998
|
+
addClass: null, // Class name added to the node's span tag.
|
1999
|
+
activate: false, // Initial active status.
|
2000
|
+
focus: false, // Initial focused status.
|
2001
|
+
expand: false, // Initial expanded status.
|
2002
|
+
select: false, // Initial selected status.
|
2003
|
+
hideCheckbox: false, // Suppress checkbox display for this node.
|
2004
|
+
unselectable: false, // Prevent selection.
|
2005
|
+
// disabled: false,
|
2006
|
+
// The following attributes are only valid if passed to some functions:
|
2007
|
+
children: null, // Array of child nodes.
|
2008
|
+
// NOTE: we can also add custom attributes here.
|
2009
|
+
// This may then also be used in the onActivate(), onSelect() or onLazyTree() callbacks.
|
2010
|
+
// ------------------------------------------------------------------------
|
2011
|
+
lastentry: undefined
|
2012
|
+
};
|
2013
|
+
|
2014
|
+
// ---------------------------------------------------------------------------
|
2015
|
+
})(jQuery);
|
2016
|
+
|
2017
|
+
// Eclipse syntax parser breaks on this expression, so we put it at the bottom.
|
2018
|
+
var _rexDtLibName = /.*dynatree[^/]*\.js$/i;
|