1
|
|
|
const org_openpsa_tree = { |
2
|
|
|
setup: function(identifier, options) { |
3
|
|
|
var default_options = { |
4
|
|
|
minExpandLevel: 1, |
5
|
|
|
extensions: ['persist', 'glyph'], |
6
|
|
|
clickFolderMode: 2, |
7
|
|
|
autoCollapse: false, |
8
|
|
|
debugLevel: -1, |
9
|
|
|
|
10
|
|
|
activate: function(event, data) { |
11
|
|
|
if ( data.node.data.href !== undefined |
12
|
|
|
&& event.originalEvent !== undefined |
13
|
|
|
&& window.location.pathname !== data.node.data.href) { |
14
|
|
|
window.location.href = data.node.data.href; |
15
|
|
|
} |
16
|
|
|
data.node.scrollIntoView(); |
17
|
|
|
}, |
18
|
|
|
click: function(event, data) { |
19
|
|
|
if ( data.tree.activeNode !== undefined |
20
|
|
|
&& data.tree.activeNode === data.node) { |
21
|
|
|
data.node.setActive(false); |
22
|
|
|
} |
23
|
|
|
return true; |
24
|
|
|
}, |
25
|
|
|
init: function() { |
26
|
|
|
$(window).trigger('resize'); |
27
|
|
|
}, |
28
|
|
|
expand: function() { |
29
|
|
|
$(window).trigger('resize'); |
30
|
|
|
}, |
31
|
|
|
collapse: function() { |
32
|
|
|
$(window).trigger('resize'); |
33
|
|
|
}, |
34
|
|
|
glyph: { |
35
|
|
|
preset: "awesome4" |
36
|
|
|
}, |
37
|
|
|
persist: { |
38
|
|
|
store: 'local', |
39
|
|
|
expandOpts: { |
40
|
|
|
noAnimation: true, |
41
|
|
|
noEvents: false |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
}; |
45
|
|
|
|
46
|
|
|
options = $.extend({}, default_options, options || {}); |
47
|
|
|
|
48
|
|
|
$(window).on('resize', function() { |
49
|
|
|
org_openpsa_tree.crop_height($('#' + identifier)); |
50
|
|
|
}); |
51
|
|
|
|
52
|
|
|
$('#' + identifier) |
53
|
|
|
.css('overflow', 'auto') |
54
|
|
|
.fancytree(options); |
55
|
|
|
}, |
56
|
|
|
crop_height: function(tree) { |
57
|
|
|
if ($('#content-text').length === 0) { |
58
|
|
|
return; |
59
|
|
|
} |
60
|
|
|
var container_height = $('#content-text').height(), |
61
|
|
|
tree_content_height = tree.find('.fancytree-container').height() + 2, |
62
|
|
|
available_height = container_height - ((tree.closest('aside').height() || 0) - tree.outerHeight(true)), |
63
|
|
|
new_height = Math.max(Math.min(tree_content_height, available_height, container_height), 20); |
64
|
|
|
|
65
|
|
|
if (new_height !== tree.height()) { |
66
|
|
|
tree.height(new_height); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
}; |
70
|
|
|
|