Skip to content
Snippets Groups Projects
Commit d7bd2310 authored by Angie Byron's avatar Angie Byron
Browse files

#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
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
// $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) { ...@@ -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.'), '#description' => t('Leave blank to use trimmed value of full text as the summary.'),
'#required' => $element['#required'], '#required' => $element['#required'],
'#display' => $display, '#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]; $field_key = $element['#columns'][0];
...@@ -728,6 +732,9 @@ function text_textarea_with_summary_process($element, $form_state, $form) { ...@@ -728,6 +732,9 @@ function text_textarea_with_summary_process($element, $form_state, $form) {
'#description' => $element['#description'], '#description' => $element['#description'],
'#required' => $element['#required'], '#required' => $element['#required'],
'#required' => $instance['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'])) { if (!empty($instance['settings']['text_processing'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment