treeCtrl.js 2.2 KB

1
  1. "use strict";app.controller("TreeCtrl",["$scope","$timeout",function(e,a){var l,n,t,r;return e.my_tree_handler=function(a){var l;if(e.output="You selected: "+a.label,null!=(l=a.data)?l.description:void 0)return e.output+="("+a.data.description+")"},l=function(a){return e.output="APPLE! : "+a.label},t=[{label:"Animal",children:[{label:"Dog",data:{description:"man's best friend"}},{label:"Cat",data:{description:"Felis catus"}},{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:!0},onSelect:function(a){return e.output="Vegetable: "+a.data.definition},children:[{label:"Oranges"},{label:"Apples",children:[{label:"Granny Smith",onSelect:l},{label:"Red Delicous",onSelect:l},{label:"Fuji",onSelect:l}]}]},{label:"Mineral",children:[{label:"Rock",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"]}]}]}],r=[{label:"North America",children:[{label:"Canada",children:["Toronto","Vancouver"]},{label:"USA",children:["New York","Los Angeles"]},{label:"Mexico",children:["Mexico City","Guadalajara"]}]},{label:"South America",children:[{label:"Venezuela",children:["Caracas","Maracaibo"]},{label:"Brazil",children:["Sao Paulo","Rio de Janeiro"]},{label:"Argentina",children:["Buenos Aires","Cordoba"]}]}],e.my_data=t,e.try_changing_the_tree_data=function(){return e.my_data===t?e.my_data=r:e.my_data=t},e.my_tree=n={},e.try_async_load=function(){return e.my_data=[],e.doing_async=!0,a(function(){return Math.random()<.5?e.my_data=t:e.my_data=r,e.doing_async=!1,n.expand_all()},1e3)},e.try_adding_a_branch=function(){var e;return e=n.get_selected_branch(),n.add_branch(e,{label:"New Branch",data:{something:42,else:43}})}}]);