tripal_ds.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. (function($) {
  2. Drupal.behaviors.tripal_ds = {
  3. attach: function (context, settings){
  4. // Add a close button for each pane except for the te_base
  5. $('div.tripal_pane').each(function (i) {
  6. $(this).prepend(
  7. '<div class="tripal_pane-fieldset-buttons">' +
  8. '<div id="tripal-pane-close-button" class="tripal-pane-button">' +
  9. '<i class="fa fa-window-close-o fa-lg"></i>' +
  10. '</div>' +
  11. '</div>'
  12. );
  13. var id = '.tripal_pane-fieldset-' + $(this).attr('id');
  14. });
  15. // Hide the pane when the close button is clicked
  16. $('#tripal-pane-close-button .fa-lg').each(function (i) {
  17. $(this).click(function () {
  18. var fs = $(this).parents('div.tripal_pane');
  19. if($(fs).hasClass('showTripalPane')) {
  20. $(fs).removeClass('showTripalPane');
  21. $(fs).addClass('hideTripalPane');
  22. }
  23. else {
  24. $(fs).addClass('hideTripalPane');
  25. }
  26. });
  27. });
  28. // Move the tripal pane to the first position when its TOC item is clicked.
  29. $('.tripal_pane-toc-list-item-link').each(function (i) {
  30. $(this).click(function() {
  31. var id = '.tripal_pane-fieldset-' + $(this).attr('id');
  32. var prevObj = $(id).prev().attr('class');
  33. // Highlight the fieldset instead of moving if it's already at the top
  34. if (prevObj.indexOf('group-tripal-pane-content-top') == 0) {
  35. $(id).fadeTo(10, 0.3, function() {});
  36. $(id).fadeTo(200, 1, function() {});
  37. }
  38. if ($(id).hasClass('hideTripalPane')) {
  39. $(id).removeClass('hideTripalPane');
  40. $(id).addClass('showTripalPane');
  41. }
  42. $(id).hide();
  43. var obj = $(id).detach();
  44. $('.group-tripal-pane-content-top').after(obj);
  45. $(id).show(300);
  46. return false;
  47. });
  48. });
  49. },
  50. };
  51. })(jQuery);