tripal_fields_layout.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. (function($) {
  2. Drupal.behaviors.tripal_fields_layout = {
  3. attach: function (context, settings){
  4. // Add a close button for each panel
  5. $('.tripal_panel-fieldset .fieldset-legend').each(function (i) {
  6. $(this).append('<div class="tripal_panel-fieldset-close_button">[X]</div>');
  7. });
  8. // Hide the panel when the close button is clicked
  9. $('.tripal_panel-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_panel-fieldset-') == 0) {
  17. $(fs).fadeOut(300);
  18. }
  19. });
  20. });
  21. // Move the panel to the first when its TOC item is clicked.
  22. $('.tripal_toc_list_item_link').each(function (i) {
  23. $(this).click(function() {
  24. var id = '#tripal_panel-fieldset-' + $(this).attr('id');
  25. $(id).removeClass('collapsed');
  26. $(id + ' .fieldset-wrapper').show();
  27. var prevObj = $(id).prev().attr('class');
  28. // Highlight the panel if it's already at the top
  29. if (prevObj.indexOf('tripal_panel-base_panel') == 0 && $(id).css('display') == 'block') {
  30. $(id).effect('highlight', {color: '#DDDEEE'});
  31. }
  32. // Move the panel
  33. else {
  34. $(id).hide();
  35. var obj = $(id).detach();
  36. $('.tripal_panel-base_panel').after(obj);
  37. $(id).show(300);
  38. }
  39. return false;
  40. });
  41. });
  42. },
  43. };
  44. })(jQuery);