tripal_analysis_kegg.js 7.7 KB

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