tripal.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. if (Drupal.jsEnabled) {
  2. //------------------------------------------------------------
  3. // On document load we want to make sure the analysis result is shown
  4. var path = '';
  5. var tripal_AjaxRequests = 0;
  6. //--------------------------------------------
  7. function tripal_startAjax(){
  8. $("#tripal_ajaxLoading").show();
  9. tripal_AjaxRequests++;
  10. }
  11. //--------------------------------------------
  12. function tripal_stopAjax(){
  13. tripal_AjaxRequests--;
  14. if(tripal_AjaxRequests == 0){
  15. $("#tripal_ajaxLoading").hide();
  16. }
  17. }
  18. //------------------------------------------------------------
  19. // On document load we want to make sure that the expandable boxes
  20. // are closed
  21. $(document).ready(function(){
  22. // setup the expandable boxes used for showing blast results
  23. tripal_set_dropable_box();
  24. // tripal_set_dropable_subbox();
  25. var selected = location.hash;
  26. if(selected.substring(0,1) == '#'){
  27. $('#' + selected.substring(1)).next().show();
  28. $('#' + selected.substring(1)).css("background", "#E1CFEA");
  29. }
  30. // hide the transparent ajax loading popup
  31. $("#tripal_ajaxLoading").hide();
  32. });
  33. //------------------------------------------------------------
  34. function tripal_set_dropable_box(){
  35. //$('.tripal_expandableBoxContent').hide();
  36. $('.tripal_expandableBox').hover(
  37. function() {
  38. $(this).css("text-decoration", "none");
  39. $(this).css("background-color", "#EEFFEE");
  40. } ,
  41. function() {
  42. $(this).css("text-decoration", "none");
  43. $(this).css("background-color", "#EEEEFF");
  44. }
  45. );
  46. $('.tripal_expandableBox').click(
  47. function() {
  48. $(this).next().slideToggle('fast',
  49. function(){
  50. var icon_url = $(this).prev().css("background-image");
  51. if($(this).css("display") == "none" ){
  52. var changed_icon_url = icon_url.replace(/arrow-up-48x48.png/,"arrow-down-48x48.png");
  53. $(this).prev().css("background-image", changed_icon_url);
  54. $(this).prev().css("background-repeat","no-repeat");
  55. $(this).prev().css("background-position","top right");
  56. } else {
  57. var changed_icon_url = icon_url.replace(/arrow-down-48x48.png/,"arrow-up-48x48.png");
  58. $(this).prev().css("background-image", changed_icon_url);
  59. $(this).prev().css("background-repeat","no-repeat");
  60. $(this).prev().css("background-position","top right");
  61. }
  62. });
  63. }
  64. );
  65. }
  66. //------------------------------------------------------------
  67. // Toggle the tripal_expandableBox
  68. function toggleExpandableBoxes(){
  69. var status = $('#tripal_expandableBox_toggle_button').html();
  70. var icon_url = $('.tripal_expandableBox').css("background-image");
  71. icon_url = icon_url.toString().match(/.+\//);
  72. icon_up = icon_url + "arrow-up-48x48.png\")";
  73. icon_down = icon_url + "arrow-down-48x48.png\")";
  74. if (status == '[-] Collapse All') {
  75. $('.tripal_expandableBoxContent').hide();
  76. $('.tripal_expandableBox').css("background-image", icon_down);
  77. $('#tripal_expandableBox_toggle_button').html('[+] Expand All');
  78. } else {
  79. $('.tripal_expandableBoxContent').show();
  80. $('.tripal_expandableBox').css("background-image", icon_up);
  81. $('#tripal_expandableBox_toggle_button').html('[-] Collapse All');
  82. }
  83. }
  84. //------------------------------------------------------------
  85. function tripal_get_base_url() {
  86. // Get the base url. Drupal can not pass it through a form so we need
  87. // to get it ourself. Use different patterns to match the url in case
  88. // the Clean URL function is turned on
  89. var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=/node'));
  90. if(!baseurl) {
  91. var baseurl = location.href.substring(0,location.href.lastIndexOf('/node'));
  92. }
  93. if (!baseurl) {
  94. // This base_url is obtained when Clena URL function is off
  95. var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=node'));
  96. }
  97. if (!baseurl) {
  98. // The last possibility is we've assigned an alias path, get base_url till the last /
  99. var baseurl = location.href.substring(0,location.href.lastIndexOf('/'));
  100. }
  101. return baseurl;
  102. }
  103. }