tripal_panes.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. (function($) {
  2. Drupal.behaviors.tripal_panes = {
  3. attach: function (context, settings){
  4. // Add a close button for each pane
  5. $('.tripal_pane-fieldset .fieldset-legend').each(function (i) {
  6. $(this).append('<div class="tripal_pane-fieldset-close_button"><img src="' + panes_theme_dir + '/images/close_btn.png" id="tripal-panes-close-button" class="tripal-panes-button"></div>');
  7. });
  8. // Hide the pane when the close button is clicked
  9. $('.tripal_pane-fieldset-close_button').each(function (i) {
  10. $(this).css('float', 'right');
  11. $(this).css('cursor', 'pointer');
  12. $(this).css('margin', '0px 5px');
  13. $(this).click(function () {
  14. var fs = $(this).parent().parent().parent();
  15. var fsid = fs.attr('id');
  16. if (fsid.indexOf('tripal_pane-fieldset-') == 0) {
  17. $(fs).fadeOut(300);
  18. }
  19. });
  20. });
  21. // Move the pane to the first when its TOC item is clicked.
  22. $('.tripal_panes-toc-list-item-link').each(function (i) {
  23. $(this).click(function() {
  24. var id = '#tripal_pane-fieldset-' + $(this).attr('id');
  25. $(id).removeClass('collapsed');
  26. $(id + ' .fieldset-wrapper').show();
  27. var prevObj = $(id).prev().attr('class');
  28. // Highlight the pane if it's already at the top
  29. //if (prevObj.indexOf('tripal_pane-base_pane') == 0 && $(id).css('display') == 'block') {
  30. // $(id).fadeTo(10, 0.5, function() {});
  31. // $(id).fadeTo(100, 1, function() {});
  32. //}
  33. // Move the pane
  34. //else {
  35. $(id).hide();
  36. if (id == '#tripal_pane-fieldset-te_base') {
  37. $('#tripal_pane-fieldset-te_base').removeClass('collapsed');
  38. }
  39. else {
  40. var obj = $(id).detach();
  41. $('.tripal-panes-content-top').after(obj);
  42. $('#tripal_pane-fieldset-te_base').addClass('collapsed');
  43. }
  44. $(id).show(300);
  45. //}
  46. return false;
  47. });
  48. });
  49. },
  50. };
  51. })(jQuery);