tripal_fields_layout.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. var color = $(id).css('background-color') ? $(id).css('background-color') : '#FFFFFF';
  31. if (jQuery.ui) {
  32. $(id).fadeTo(10, 0.5, function() {});
  33. $(id).fadeTo(100, 1, function() {});
  34. //$(id).effect('highlight', {color: '#DDDEEE'});
  35. }
  36. }
  37. // Move the panel
  38. else {
  39. $(id).hide();
  40. var obj = $(id).detach();
  41. $('.tripal_panel-base_panel').after(obj);
  42. $(id).show(300);
  43. }
  44. return false;
  45. });
  46. });
  47. },
  48. };
  49. })(jQuery);