tripal_fields_layout.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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).click(function () {
  13. var fs = $(this).parent().parent().parent();
  14. var fsid = fs.attr('id');
  15. if (fsid.indexOf('tripal_panel_fieldset-') == 0) {
  16. $(fs).hide(300);
  17. }
  18. });
  19. });
  20. // Move the panel to the first when its TOC item is clicked.
  21. $('.tripal_toc_list_item_link').each(function (i) {
  22. $(this).click(function() {
  23. var id = '#tripal_panel_fieldset-' + $(this).attr('id');
  24. $(id).removeClass('collapsed');
  25. $(id + ' .fieldset-wrapper').show();
  26. var prevObj = $(id).prev().attr('class');
  27. // Highlight the panel if it's already at the top
  28. if (prevObj == 'tripal_base_panel' && $(id).css('display') == 'block') {
  29. $(id).effect('highlight', {color: '#DDDEEE'});
  30. }
  31. // Move the panel
  32. else {
  33. $(id).hide();
  34. var obj = $(id).detach();
  35. $('.tripal_base_panel').after(obj);
  36. $(id).show(300);
  37. }
  38. return false;
  39. });
  40. });
  41. },
  42. };
  43. })(jQuery);