Commit d7bd2310 authored by webchick's avatar webchick

#513414 by kika, stBorchert, stella, sign, Bojhan, sun et al: Make editing of...

#513414 by kika, stBorchert, stella, sign, Bojhan, sun et al: Make editing of summary/full fields more user-friendly.
parent 2adfe31e
// $Id$
(function ($) {
/**
* Auto-hide summary textarea if empty and show hide and unhide links.
*/
Drupal.behaviors.textTextareaSummary = {
attach: function (context, settings) {
$('textarea.text-textarea-summary:not(.text-textarea-summary-processed)', context).addClass('text-textarea-summary-processed').each(function () {
var $fieldset = $(this).closest('#body-wrapper');
var $summary = $fieldset.find('div.text-summary-wrapper');
var $summaryLabel = $summary.find('div.form-type-textarea label');
var $full = $fieldset.find('div.text-full-wrapper');
var $fullLabel = $full.find('div.form-type-textarea label');
// Setup the edit/hide summary link.
var $link = $('<span class="field-edit-link">(<a class="link-edit-summary" href="#">' + Drupal.t('Hide summary') + '</a>)</span>').toggle(
function () {
$summary.hide();
$(this).find('a').html(Drupal.t('Edit summary')).end().appendTo($fullLabel);
return false;
},
function () {
$summary.show();
$(this).find('a').html(Drupal.t('Hide summary')).end().appendTo($summaryLabel);
return false;
}
).appendTo($summaryLabel);
// If no summary is set, hide the summary field.
if ($(this).val() == '') {
$link.click();
}
return;
});
}
};
})(jQuery);
......@@ -716,6 +716,10 @@ function text_textarea_with_summary_process($element, $form_state, $form) {
'#description' => t('Leave blank to use trimmed value of full text as the summary.'),
'#required' => $element['#required'],
'#display' => $display,
'#attached' => array('js' => array(drupal_get_path('module', 'text') . '/text.js')),
'#attributes' => array('class' => array('text-textarea-summary')),
'#prefix' => '<div class="text-summary-wrapper">',
'#suffix' => '</div>',
);
$field_key = $element['#columns'][0];
......@@ -728,6 +732,9 @@ function text_textarea_with_summary_process($element, $form_state, $form) {
'#description' => $element['#description'],
'#required' => $element['#required'],
'#required' => $instance['required'],
'#attributes' => array('class' => array('text-full-textarea')),
'#prefix' => '<div class="text-full-wrapper">',
'#suffix' => '</div>',
);
if (!empty($instance['settings']['text_processing'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment