-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProcessSelectorTest.js
More file actions
63 lines (57 loc) · 1.82 KB
/
Copy pathProcessSelectorTest.js
File metadata and controls
63 lines (57 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* ProcessSelectorTest.js
*
* @copyright Copyright (c) 2012, Niklas Lakanen
*
*/
$(function() {
// apply jqTree to all elements with a certain class
$('.selectortest-tree').tree({
// no data given here (initialized a little later)
// explicit definition is needed to prevent immediate ajax request for the first node
data: [],
// base url for loading nodes on-demand
dataUrl: './load',
// apply some formatting depending on node properties
onCreateLi: function(node, $li) {
var $title = $li.find('.jqtree-title');
// construct title from key/value if label hasn't been defined (now in node.name)
if(!node.name) {
var $valueSpan = $('<span></span>').addClass('value').text(node.value);
if(node.valueClass) {
$valueSpan.addClass(node.valueClass);
}
if(node.key) {
$title.html(node.key + ':').append($valueSpan);
} else {
$title.html($valueSpan);
}
}
// set title-attribute for title-element if a tooltip is defined
if(node.tooltip) {
$title.attr('title', node.tooltip);
}
// use page's status values for title-element's class and title
if(node.status && node.status.length) {
$title.attr('title', node.status.join(', '));
$title.addClass(node.status.join(' '));
}
// add a span with action links after title-element if there are actions defined
if(node.actions) {
var $actionsSpan = $('<span></span>').addClass('actions');
$.each(node.actions, function(label, url) {
$actionsSpan.append(' | <a href="' + url + '">' + label + '</a>');
});
$title.after($actionsSpan);
}
// add a class for title-element if there's one defined
if(node.class) {
$title.addClass(node.class);
}
}
})
// make clicking a node act as a toggle
.bind('tree.click', function(event) {
$(this).tree('toggle', event.node);
});
});