tripal_analysis_kegg.js 7.6 KB

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