tripal.js 4.5 KB

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