fuelux.tree-sampledata.js 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. var DataSourceTree = function(options) {
  2. this._data = options.data;
  3. this._delay = options.delay;
  4. }
  5. DataSourceTree.prototype.data = function(options, callback) {
  6. var self = this;
  7. var $data = null;
  8. if(!("name" in options) && !("type" in options)){
  9. $data = this._data;
  10. callback({ data: $data });
  11. return;
  12. }
  13. else if("type" in options && options.type == "folder") {
  14. if("additionalParameters" in options && "children" in options.additionalParameters)
  15. $data = options.additionalParameters.children;
  16. else $data = {}
  17. }
  18. if($data != null)
  19. setTimeout(function(){callback({ data: $data });} , parseInt(Math.random() * 500) + 200);
  20. };
  21. var tree_data = {
  22. 'data_1' : {name: '数据源一', type: 'folder', 'icon-class':'red'} ,
  23. 'data_2' : {name: '数据源二', type: 'folder', 'icon-class':'orange'} ,
  24. 'data_3' : {name: '数据源三', type: 'folder', 'icon-class':'blue'} ,
  25. 'data_4' : {name: '数据源四', type: 'folder', 'icon-class':'green'} ,
  26. 'data_5' : {name: '数据源五', type: 'folder'} ,
  27. 'data_6' : {name: '<i class="icon-file-text grey"></i>关于我们', type: 'item'},
  28. 'data_7' : {name: '<i class="icon-book blue"></i>联系我们', type: 'item'}
  29. }
  30. tree_data['data_2']['additionalParameters'] = {
  31. 'children' : [
  32. {name: '<i class="icon-music blue"></i>测试数据1', type: 'item'},
  33. {name: '<i class="icon-music blue"></i>测试数据2', type: 'item'},
  34. {name: '<i class="icon-music blue"></i>测试数据3', type: 'item'},
  35. {name: '<i class="icon-music blue"></i>测试数据4', type: 'item'},
  36. {name: '<i class="icon-music blue"></i>测试数据5', type: 'item'}
  37. ]
  38. }
  39. tree_data['data_3']['additionalParameters'] = {
  40. 'children' : [
  41. {name: '<i class="icon-film blue"></i>测试数据6', type: 'item'},
  42. {name: '<i class="icon-film blue"></i>测试数据7', type: 'item'},
  43. {name: '<i class="icon-film blue"></i>测试数据8', type: 'item'},
  44. {name: '<i class="icon-film blue"></i>测试数据9', type: 'item'},
  45. {name: '<i class="icon-film blue"></i>测试数据10', type: 'item'}
  46. ]
  47. }
  48. tree_data['data_1']['additionalParameters'] = {
  49. 'children' : {
  50. 'data_1.1' : {name: '数据源一/1', type: 'folder', 'icon-class':'pink'},
  51. 'data_1.2' : {name: '数据源一/2', type: 'folder', 'icon-class':'pink'}
  52. }
  53. }
  54. tree_data['data_1']['additionalParameters']['children']['data_1.1']['additionalParameters'] = {
  55. 'children' : [
  56. {name: '<i class="icon-picture green"></i>测试数据11', type: 'item'},
  57. {name: '<i class="icon-picture green"></i>测试数据12', type: 'item'},
  58. {name: '<i class="icon-picture green"></i>测试数据13', type: 'item'},
  59. {name: '<i class="icon-picture green"></i>测试数据14', type: 'item'}
  60. ]
  61. }
  62. tree_data['data_1']['additionalParameters']['children']['data_1.2']['additionalParameters'] = {
  63. 'children' : [
  64. {name: '<i class="icon-picture green"></i>测试数据15', type: 'item'},
  65. {name: '<i class="icon-picture green"></i>测试数据16', type: 'item'},
  66. {name: '<i class="icon-picture green"></i>测试数据17', type: 'item'},
  67. {name: '<i class="icon-picture green"></i>测试数据18', type: 'item'},
  68. {name: '<i class="icon-picture green"></i>测试数据19', type: 'item'},
  69. {name: '<i class="icon-picture green"></i>测试数据20', type: 'item'}
  70. ]
  71. }
  72. tree_data['data_4']['additionalParameters'] = {
  73. 'children' : [
  74. {name: '<i class="icon-file-text red"></i>测试数据21', type: 'item'},
  75. {name: '<i class="icon-file-text grey"></i>测试数据22', type: 'item'},
  76. {name: '<i class="icon-file-text grey"></i>测试数据23', type: 'item'},
  77. {name: '<i class="icon-file-text red"></i>测试数据24', type: 'item'},
  78. {name: '<i class="icon-file-text grey"></i>测试数据25', type: 'item'}
  79. ]
  80. }
  81. tree_data['data_5']['additionalParameters'] = {
  82. 'children' : [
  83. {name: '<i class="icon-archive brown"></i>测试数据26', type: 'item'},
  84. {name: '<i class="icon-archive brown"></i>测试数据27', type: 'item'},
  85. {name: '<i class="icon-archive brown"></i>测试数据28', type: 'item'},
  86. {name: '<i class="icon-archive brown"></i>测试数据29', type: 'item'}
  87. ]
  88. }
  89. var treeDataSource = new DataSourceTree({data: tree_data});