tree.js
2.81 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
$(function () {
/*---------------------------------------------------------------------
Basic Tree
-----------------------------------------------------------------------*/
$('.basic-tree li:has(ul)').addClass('t-parent').find(' > span').attr('title', 'Collapse this branch');
$('.basic-tree li.t-parent > span').on('click', function (e) {
var children = $(this).parent('li.t-parent').find(' > ul > li');
if (children.is(":visible")) {
children.hide('fast');
$(this).attr('title', 'Expand this branch').find(' > i').addClass('fa-plus').removeClass('fa-minus');
} else {
children.show('fast');
$(this).attr('title', 'Collapse this branch').find(' > i').addClass('fa-minus').removeClass('fa-plus');
}
e.stopPropagation();
});
/*---------------------------------------------------------------------
Checkbox Tree
-----------------------------------------------------------------------*/
jQuery('#flex-tree-check').flexTree({
type: 'checkbox',
name: 'foo[]',
collapsed: false,
items: [
{
label: 'Item 1',
childrens: [
{
label: 'Item 1.1',
value: 'item_1_1',
checked: true
},
{
label: 'Item 1.2',
value: 'item_1_2',
childrens: [
{
label: 'Item 1.2.1',
value: 'item_1_2_1',
childrens: [
{
label: 'Item 1.2.2.1',
value: 'item_1_2_2_1'
},
{
label: 'Item 1.2.2.2',
value: 'item_1_2_2_2',
id: 'foo'
}]
},
{
label: 'Item 1.2.2',
value: 'item_1_2_2'
}]
},
{
label: 'Item 1.3',
value: 'item_1_3',
checked: true
}]
},
{
label: 'Item 2',
childrens: [
{
label: 'Item 2.1',
value: 'item_2_1',
checked: true
}]
}]
});
});