Index: modules/field/modules/text/text.js =================================================================== RCS file: modules/field/modules/text/text.js diff -N modules/field/modules/text/text.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/field/modules/text/text.js 15 Aug 2009 00:33:14 -0000 @@ -0,0 +1,62 @@ +// $Id$ + +(function ($) { + +Drupal.behaviors.bodySummary = { + attach: function () { + // If summary does not contains text or the text equals the body value (at least the beginning of it). + $('textarea.summary-textarea').each(function () { + if ($(this).val() === '') { + $(this).closest('div.summary-wrapper').hide(); + if ($(this).closest('fieldset').find('div.full-text-wrapper').prev('label > span.field-edit-link').size()) { + $(this).closest('fieldset').find('div.full-text-wrapper span.field-edit-link').show(); + } + else { + $(this).closest('fieldset').find('div.full-text-wrapper div.form-item-textarea label').append($('(' + Drupal.t('Edit summary') + ')')); + $(this).closest('fieldset').find('a.link-edit-summary').click(function () { + $(this).closest('fieldset').find('div.summary-wrapper').show(); + $(this).closest('fieldset').find('label span.field-edit-link').hide(); + if ($(this).closest('fieldset').find('div.summary-wrapper span.field-edit-link').size()) { + $(this).closest('fieldset').find('div.summary-wrapper span.field-edit-link').show(); + } + else { + $(this).closest('fieldset').find('div.summary-wrapper div.form-item-textarea label').append($('(' + Drupal.t('Hide summary') + ')')); + $(this).closest('fieldset').find('a.link-hide-summary').click(function () { + $(this).closest('fieldset').find('label span.field-edit-link').show(); + $(this).closest('div.summary-wrapper').hide(); + return false; + }); + } + return false; + }); + } + } + else { + if ($(this).closest('div.summary-wrapper').prev('label > span.field-edit-link').size()) { + $(this).closest('div.summary-wrapper').prev('label > span.field-edit-link').show(); + } + else { + $(this).closest('fieldset').find('div.summary-wrapper div.form-item-textarea label').append($('(' + Drupal.t('Hide summary') + ')')); + $(this).closest('fieldset').find('a.link-hide-summary').click(function () { + if ($(this).closest('fieldset').find('div.full-text-wrapper span.field-edit-link').size()) { + $(this).closest('fieldset').find('div.full-text-wrapper span.field-edit-link').show(); + } + else { + $(this).closest('fieldset').find('div.full-text-wrapper div.form-item-textarea label').append($('(' + Drupal.t('Edit summary') + ')')); + $(this).closest('fieldset').find('a.link-edit-summary').click(function () { + $(this).closest('fieldset').find('div.full-text-wrapper').find('label span.field-edit-link').hide(); + $(this).closest('fieldset').find('div.summary-wrapper').show(); + return false; + }); + } + $(this).parents('div.summary-wrapper').hide(); + return false; + }); + } + } + }); + } +}; + +})(jQuery); + Index: modules/field/modules/text/text.module =================================================================== RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v retrieving revision 1.17 diff -u -p -r1.17 text.module --- modules/field/modules/text/text.module 4 Aug 2009 06:38:56 -0000 1.17 +++ modules/field/modules/text/text.module 15 Aug 2009 00:33:14 -0000 @@ -537,6 +537,7 @@ function text_elements() { * the form item for a single element for this field */ function text_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) { + drupal_add_js(drupal_get_path('module', 'text') . '/text.js'); $element = array( '#type' => $instance['widget']['type'], '#default_value' => isset($items[$delta]) ? $items[$delta] : '', @@ -664,6 +665,9 @@ function text_textarea_with_summary_proc '#description' => t('Leave blank to use trimmed value of full text as the summary.'), '#required' => $element['#required'], '#display' => $display, + '#attributes' => array('class' => 'summary-textarea'), + '#prefix' => '
', + '#suffix' => '
', ); $field_key = $element['#columns'][0]; @@ -676,6 +680,9 @@ function text_textarea_with_summary_proc '#description' => $element['#description'], '#required' => $element['#required'], '#required' => $instance['required'], + '#attributes' => array('class' => 'full-text-textarea'), + '#prefix' => '
', + '#suffix' => '
', ); if (!empty($instance['settings']['text_processing'])) {