tripal_analysis_kegg.js 7.1 KB

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