forked from olddigger/digger-html-for-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_abn_tree.coffee
129 lines (110 loc) · 3.05 KB
/
test_abn_tree.coffee
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
app = angular.module 'AbnTest', ['angularBootstrapNavTree']
app.controller 'AbnTestController',($scope)->
#
# a default "on-select" handler can be specified
# for the tree ( as attribute "on-select" )
#
$scope.my_default_handler = (branch)->
$scope.output = "You selected: "+branch.label
if branch.data?.description
$scope.output += '('+branch.data.description+')'
#
# This example handler just sets "output",
# ...but your handler could do anything here...
#
#
# Each branch can define an "on-select" handler,
# which will be called instead of the default handler
#
#
# a single handler can be used on several branches, like this:
#
apple_selected = (branch)->
$scope.output = "APPLE! : "+branch.label
#
# ( your handler can do anything here )
#
#
# Example TREE DATA : Animal,Vegetable,Mineral
#
# Each branch can have the following attributes:
#
# label : the displayed text for the branch
# children : an array of branches ( or array of strings )
# onSelect : a function to run when branch is selected
# data : a place to put your own data -- can be anything
#
$scope.example_treedata = [
label:'Animal'
children:[
label:'Dog'
data:
#
# "data" is yours -- put anything in here
# you can read it back in your on-select handler
# as "branch.data"
#
description:"man's best friend"
,
label:'Cat'
data:
description:"spawn of satan"
,
label:'Hippopotamus'
data:
description:"hungry, hungry"
,
label:'Chicken'
children:['White Leghorn','Rhode Island Red','Jersey Giant']
]
,
label:'Vegetable'
data:
definition:"A plant or part of a plant used as food, typically as accompaniment to meat or fish, such as a cabbage, potato, carrot, or bean."
data_can_contain_anything:true
onSelect:(branch)->
# special "on-select" function for this branch
$scope.output = "Vegetable: "+branch.data.definition
children:[
label:'Oranges'
,
label:'Apples'
children:[
label:'Granny Smith'
onSelect:apple_selected
,
label:'Red Delicous'
onSelect:apple_selected
,
label:'Fuji'
onSelect:apple_selected
]
]
,
label:'Mineral'
children:[
label:'Rock'
# children can be simply a list of strings
# if you are in a hurry
children:['Igneous','Sedimentary','Metamorphic']
,
label:'Metal'
children:['Aluminum','Steel','Copper']
,
label:'Plastic'
children:[
label:'Thermoplastic'
children:['polyethylene', 'polypropylene', 'polystyrene',' polyvinyl chloride']
,
label:'Thermosetting Polymer'
children:['polyester','polyurethane','vulcanized rubber','bakelite','urea-formaldehyde']
,
]
]
]
$scope.change = ()->
debugger
$scope.example_treedata = [
label:'Animal'
children:['Cat','Dog']
]