1
0

demo.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. window.addEvent('domready',function(){
  2. DOMTree = new Mif.Tree({
  3. container: $('tree_container'),
  4. types: {
  5. folder: {
  6. cls: 'dom-object',
  7. loadable: true
  8. },
  9. array: {
  10. loadable: true,
  11. cls: 'dom-array'
  12. },
  13. string: {
  14. hoverClass: 'empty',
  15. selectClass: 'empty',
  16. loadable: true,
  17. cls: 'dom-string'
  18. },
  19. number: {
  20. hoverClass: 'empty',
  21. selectClass: 'empty',
  22. loadable: true,
  23. cls: 'dom-number'
  24. }
  25. },
  26. sortable: true,
  27. dfltType: 'folder',
  28. height: 18,
  29. initialize: function(){
  30. this.initSortable();
  31. new Mif.Tree.KeyNav(this);
  32. }
  33. }).load({
  34. json: [{
  35. property: {
  36. name: 'window'
  37. },
  38. data:{
  39. dom: window
  40. }
  41. }]
  42. });
  43. DOMTree.loadOptions = function(node){
  44. var json = [];
  45. var dom = node.data.dom;
  46. Function.attempt(function(){
  47. var type = typeOf(dom);
  48. switch(type){
  49. case 'string':
  50. case 'number':
  51. json.push({
  52. property: {
  53. name: dom,
  54. loadable: false
  55. },
  56. type: type
  57. });
  58. break;
  59. case 'array':
  60. dom.each(function(el, i){
  61. json.push({
  62. property: {
  63. name: i
  64. },
  65. type: 'array',
  66. data: {
  67. dom: el
  68. }
  69. });
  70. });
  71. break;
  72. default:
  73. for(var p in dom){
  74. Function.attempt(function(){
  75. var child = {
  76. property:{
  77. name: p
  78. },
  79. data: {
  80. dom: dom[p]
  81. }
  82. };
  83. if(typeof dom == 'function') child.property.cls = 'dom-function';
  84. json.push(child);
  85. });
  86. }
  87. }
  88. });
  89. return {json: json};
  90. };
  91. });