tripal_panes.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. var obj = $(id).detach();
  37. $('.tripal_pane-base_pane').after(obj);
  38. $(id).show(300);
  39. }
  40. return false;
  41. });
  42. });
  43. },
  44. };
  45. })(jQuery);