tripal_analysis_kegg.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. if (Drupal.jsEnabled) {
  2. $(document).ready(function() {
  3. // Select default KEGG analysis when available
  4. var selectbox = $('#edit-tripal-analysis-kegg-select');
  5. if(selectbox){
  6. selectbox[0].selectedIndex = 1;
  7. selectbox.change();
  8. }
  9. });
  10. //------------------------------------------------------------
  11. function tripal_analysis_kegg_org_report(item,baseurl,themedir){
  12. if(!item){
  13. $("#tripal_analysis_kegg_org_report").html('');
  14. return false;
  15. }
  16. // Form the link for the following ajax call
  17. var link = baseurl + '/tripal_analysis_kegg_org_report/' + item;
  18. tripal_startAjax();
  19. $.ajax({
  20. url: link,
  21. dataType: 'json',
  22. type: 'POST',
  23. success: function(data){
  24. $("#tripal_analysis_kegg_org_report").html(data[0]);
  25. $(".tripal_kegg_brite_tree").attr("id", function(){
  26. init_kegg_tree($(this).attr("id"),baseurl,themedir);
  27. });
  28. tripal_stopAjax();
  29. }
  30. });
  31. return false;
  32. }
  33. //------------------------------------------------------------
  34. // Update the BRITE hierarchy based on the user selection
  35. function tripal_update_brite(link,type_id,baseurl,themedir){
  36. tripal_startAjax();
  37. $.ajax({
  38. url: link.href,
  39. dataType: 'json',
  40. type: 'POST',
  41. success: function(data){
  42. $("#tripal_kegg_brite_hierarchy").html(data.update);
  43. $("#tripal_kegg_brite_header").html(data.brite_term);
  44. tripal_stopAjax();
  45. if(baseurl && themedir){
  46. init_kegg_tree(data.id,baseurl,themedir);
  47. }
  48. }
  49. });
  50. return false;
  51. }
  52. //------------------------------------------------------------
  53. // This function initializes a KEGG term tree
  54. function init_kegg_tree(id,baseurl,themedir){
  55. // Form the link for the following ajax call
  56. var theme_path = baseurl + '/' + themedir + "/js/jsTree/source/themes/";
  57. $("#" + id).tree ({
  58. data : {
  59. type : "predefined", // ENUM [json, xml_flat, xml_nested, predefined]
  60. method : "GET", // HOW TO REQUEST FILES
  61. async : false, // BOOL - async loading onopen
  62. async_data : function (NODE) { return { id : $(NODE).attr("id") || 0 } }, // PARAMETERS PASSED TO SERVER
  63. url : false, // FALSE or STRING - url to document to be used (async or not)
  64. json : false, // FALSE or OBJECT if type is JSON and async is false - the tree dump as json
  65. xml : false // FALSE or STRING
  66. },
  67. ui : {
  68. dots : true, // BOOL - dots or no dots
  69. rtl : false, // BOOL - is the tree right-to-left
  70. animation : 0, // INT - duration of open/close animations in miliseconds
  71. hover_mode : true, // SHOULD get_* functions chage focus or change hovered item
  72. scroll_spd : 4,
  73. theme_path : theme_path, // Path to themes
  74. theme_name : "classic",// Name of theme
  75. },
  76. rules : {
  77. multiple : false, // FALSE | CTRL | ON - multiple selection off/ with or without holding Ctrl
  78. metadata : false, // FALSE or STRING - attribute name (use metadata plugin)
  79. type_attr : "rel", // STRING attribute name (where is the type stored if no metadata)
  80. multitree : false, // BOOL - is drag n drop between trees allowed
  81. createat : "bottom", // STRING (top or bottom) new nodes get inserted at top or bottom
  82. use_inline : false, // CHECK FOR INLINE RULES - REQUIRES METADATA
  83. clickable : "all", // which node types can the user select | default - all
  84. renameable : false, // which node types can the user select | default - all
  85. deletable : false, // which node types can the user delete | default - all
  86. creatable : false, // which node types can the user create in | default - all
  87. draggable : "none", // which node types can the user move | default - none | "all"
  88. dragrules : "all", // what move operations between nodes are allowed | default - none | "all"
  89. drag_copy : false, // FALSE | CTRL | ON - drag to copy off/ with or without holding Ctrl
  90. droppable : [],
  91. drag_button : "left"
  92. },
  93. callback : { // various callbacks to attach custom logic to
  94. // before focus - should return true | false
  95. beforechange: function(NODE,TREE_OBJ) { return true },
  96. beforeopen : function(NODE,TREE_OBJ) { return true },
  97. beforeclose : function(NODE,TREE_OBJ) { return true },
  98. // before move - should return true | false
  99. beforemove : function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true },
  100. // before create - should return true | false
  101. beforecreate: function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true },
  102. // before rename - should return true | false
  103. beforerename: function(NODE,LANG,TREE_OBJ) { return true },
  104. // before delete - should return true | false
  105. beforedelete: function(NODE,TREE_OBJ) { return true },
  106. onJSONdata : function(DATA,TREE_OBJ) { return DATA; },
  107. onselect : function(NODE,TREE_OBJ) {
  108. window.onerror = function(){return true;};
  109. throw 'exit';
  110. }, // node selected
  111. ondeselect : function(NODE,TREE_OBJ) { }, // node deselected
  112. onchange : function(NODE,TREE_OBJ) { }, // focus changed
  113. onrename : function(NODE,LANG,TREE_OBJ,RB) { }, // node renamed ISNEW - TRUE|FALSE, current language
  114. onmove : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // move completed (TYPE is BELOW|ABOVE|INSIDE)
  115. oncopy : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // copy completed (TYPE is BELOW|ABOVE|INSIDE)
  116. oncreate : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // node created, parent node (TYPE is createat)
  117. ondelete : function(NODE, TREE_OBJ,RB) { }, // node deleted
  118. onopen : function(NODE, TREE_OBJ) { }, // node opened
  119. onopen_all : function(TREE_OBJ) { }, // all nodes opened
  120. onclose : function(NODE, TREE_OBJ) { }, // node closed
  121. error : function(TEXT, TREE_OBJ) { }, // error occured
  122. // double click on node - defaults to open/close & select
  123. ondblclk : function(NODE, TREE_OBJ) { TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); },
  124. // right click - to prevent use: EV.preventDefault(); EV.stopPropagation(); return false
  125. onrgtclk : function(NODE, TREE_OBJ, EV) { },
  126. onload : function(TREE_OBJ) { },
  127. onfocus : function(TREE_OBJ) { },
  128. ondrop : function(NODE,REF_NODE,TYPE,TREE_OBJ) {}
  129. }
  130. });
  131. }
  132. }