tripal_analysis_kegg.js 8.5 KB

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