tripal.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // Toggle the tripal_expandableBox
  70. function toggleExpandableBoxes(){
  71. var status = $('#tripal_expandableBox_toggle_button').html();
  72. var icon_url = $('.tripal_expandableBox').css("background-image");
  73. icon_url = icon_url.toString().match(/.+\//);
  74. icon_up = icon_url + "arrow-up-48x48.png)";
  75. icon_down = icon_url + "arrow-down-48x48.png)";
  76. if (status == '[-] Collapse All') {
  77. $('.tripal_expandableBoxContent').hide();
  78. $('.tripal_expandableBox').css("background-image", icon_down);
  79. $('#tripal_expandableBox_toggle_button').html('[+] Expand All');
  80. } else {
  81. $('.tripal_expandableBoxContent').show();
  82. $('.tripal_expandableBox').css("background-image", icon_up);
  83. $('#tripal_expandableBox_toggle_button').html('[-] Collapse All');
  84. }
  85. }
  86. }