diff --git a/includes/common.inc b/includes/common.inc index 2940d53b2e7..d80aefeeeab 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3717,6 +3717,9 @@ function drupal_common_theme() { 'form_element' => array( 'arguments' => array('element' => NULL), ), + 'text_format_wrapper' => array( + 'arguments' => array('element' => NULL), + ), ); } diff --git a/includes/form.inc b/includes/form.inc index 8e57737fd7d..f6a131a5327 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -1927,19 +1927,45 @@ function form_process_text_format($element) { // We need to break references, otherwise form_builder recurses infinitely. $element['value'] = (array)$element; + $element['value']['#weight'] = 0; + unset($element['value']['#description']); $element['#type'] = 'markup'; $element['#theme'] = NULL; - $element['#theme_wrapper'] = NULL; + $element['#theme_wrapper'] = 'text_format_wrapper'; $element['format'] = filter_form($element['#text_format'], 1, $element_parents); // We need to clear the #text_format from the new child otherwise we // would get into an infinite loop. unset($element['value']['#text_format']); - $element['value']['#weight'] = 0; } return $element; } +/** + * Return a themed text format form element. + * + * @param element + * An associative array containing the properties of the element. + * Properties used: children, description + * @return + * A string representing the form element. + * + * @ingroup themeable + */ +function theme_text_format_wrapper($element) { + $output = '
' . "\n"; + + $output .= $element['#children'] . "\n"; + + if (!empty($element['#description'])) { + $output .= '
' . $element['#description'] . "
\n"; + } + + $output .= "
\n"; + + return $output; +} + /** * Add AHAH information about a form element to the page to communicate with * javascript. If #ahah[path] is set on an element, this additional javascript is diff --git a/misc/form.js b/misc/form.js index 2a2e02dad8e..4451e40d9b4 100644 --- a/misc/form.js +++ b/misc/form.js @@ -14,18 +14,18 @@ Drupal.behaviors.multiselectSelector = { /** - * Automatically displays the guidelines of the selected text format. + * Automatically display the guidelines of the selected text format. */ Drupal.behaviors.filterGuidelines = { attach: function(context) { - $('.filter-guidelines:not(.filterGuidelines-processed)', context) - .addClass('filterGuidelines-processed') + $('.filter-guidelines:not(.filter-guidelines-processed)', context) + .addClass('filter-guidelines-processed') .find('label').hide() .parents('.filter-wrapper').find('select.filter-list') - .bind('change', function() { + .bind('change', function () { $(this).parents('.filter-wrapper') - .find('.filter-guidelines-item').hide() - .siblings('#filter-guidelines-' + this.value).show(); + .find('.filter-guidelines-item').hide() + .siblings('#filter-guidelines-' + this.value).show(); }) .change(); } diff --git a/modules/filter/filter.css b/modules/filter/filter.css new file mode 100644 index 00000000000..a26ddae68ce --- /dev/null +++ b/modules/filter/filter.css @@ -0,0 +1,37 @@ +/* $Id$ */ + +.text-format-wrapper .form-item { + margin-bottom: 0; +} +.filter-wrapper { + border-top: 0; + width: 95%; + margin: 0; + padding: 1.5em 0 1.5em; +} +.filter-wrapper .form-item { + float: left; + margin: 0; + padding: 0 0 0.5em 1.5em; +} +.filter-wrapper .form-item label { + display: inline; +} +.filter-help { + float: right; + padding: 0 1.5em 0.5em; +} +.filter-help p { + margin: 0; +} +.filter-help a { + background: transparent url(../../misc/help.png) right center no-repeat; + padding-right: 20px; +} +.filter-guidelines { + clear: left; + padding: 0 1.5em; +} +.text-format-wrapper .description { + margin-top: 0.5em; +} diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 0fe072bd50b..632847477b0 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -484,40 +484,44 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $langcode = '', $c function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format')) { $value = filter_resolve_format($value); $formats = filter_formats(); - - $form = array( - '#type' => 'fieldset', - '#weight' => $weight, - '#attributes' => array('class' => 'filter-wrapper'), - ); - + + drupal_add_js('misc/form.js'); + drupal_add_css(drupal_get_path('module', 'filter') . '/filter.css'); $element_id = form_clean_id('edit-' . implode('-', $parents)); - - if (count($formats) > 1) { - foreach ($formats as $format) { - $options[$format->format] = $format->name; - $guidelines[$format->format] = array('#markup' => theme('filter_guidelines', $format)); - } - drupal_add_js('misc/form.js'); - $form['format'] = array( - '#type' => 'select', - '#title' => t('Text format'), - '#options' => $options, - '#default_value' => $value, - '#parents' => $parents, - '#id' => $element_id, - '#attributes' => array('class' => 'filter-list'), + + $form = array( + '#type' => 'fieldset', + '#weight' => $weight, + '#attributes' => array('class' => 'filter-wrapper'), + ); + $form['format_guidelines'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#weight' => 2, + ); + foreach ($formats as $format) { + $options[$format->format] = $format->name; + $form['format_guidelines'][$format->format] = array( + '#markup' => theme('filter_guidelines', $format), ); } - else { - // Only one format available: use a form value and only show label. - $format = array_shift($formats); - unset($format->name); - $guidelines = array('#markup' => theme('filter_guidelines', $format)); - $form[$format->format] = array('#type' => 'value', '#value' => $format->format, '#parents' => $parents); - } - $form['format_help'] = array('#markup' => '
' . theme('filter_tips_more_info') . '
'); - $form['format_guidelines'] = array_merge($guidelines, array('#prefix' => '
', '#suffix' => '
')); + $form['format'] = array( + '#type' => 'select', + '#title' => t('Text format'), + '#options' => $options, + '#default_value' => $value, + '#parents' => $parents, + '#access' => count($formats) > 1, + '#id' => $element_id, + '#attributes' => array('class' => 'filter-list'), + ); + $form['format_help'] = array( + '#prefix' => '
', + '#markup' => theme('filter_tips_more_info'), + '#suffix' => '
', + '#weight' => 1, + ); + return $form; } @@ -583,7 +587,7 @@ function theme_filter_tips_more_info() { * @ingroup themeable */ function theme_filter_guidelines($format) { - $name = isset($format->name) ? '' : NULL; + $name = isset($format->name) ? '' : ''; return '
' . $name . theme('filter_tips', _filter_tips($format->format, FALSE)) . '
'; } diff --git a/modules/node/node.css b/modules/node/node.css index 58ed30862ca..ab5a6a18b9f 100644 --- a/modules/node/node.css +++ b/modules/node/node.css @@ -42,38 +42,4 @@ td.revision-current { .terms-inline { display: inline; } -.filter-label { - font-weight: bold; -} -.filter-wrapper { - border-top: 0; - width: 95%; - padding: 0; - margin-top: -1em; - float: left; /* Required by IE6 to respect negative margins */ -} -.filter-guidelines { - clear: left; - margin: 1.5em; -} -.filter-wrapper .form-item { - float: left; - line-height: 3em; - margin: 0 0 0 1.5em; -} -.filter-wrapper .form-item label { - display: inline; -} -.filter-help { - float: right; - margin-right: 1em; -} -.filter-help a { - background: url(../../misc/help.png) right center no-repeat; - padding-right: 20px; -} - -html.js fieldset.collapsible { - clear: left; /* Test fix for Safari issues caused by IE6 fix above, need to test impact elsewhere and move to appropriate CSS file */ -} \ No newline at end of file diff --git a/themes/garland/style.css b/themes/garland/style.css index dfde41aa292..8765a0a708e 100644 --- a/themes/garland/style.css +++ b/themes/garland/style.css @@ -822,6 +822,10 @@ fieldset { background-position: 0 .75em; background-color: transparent; } +*:first-child+html .text-format-wrapper .filter-wrapper { + padding: 1.5em 0 1.5em; + background-position: 0 0; +} *:first-child+html fieldset > .description, *:first-child+html fieldset .fieldset-wrapper .description { padding-top: 1em;