? misc/collapse.js Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.454 diff -u -r1.454 common.inc --- includes/common.inc 5 Jun 2005 19:10:53 -0000 1.454 +++ includes/common.inc 8 Jun 2005 09:14:03 -0000 @@ -1110,6 +1110,33 @@ } /** + * Format a group of form items. + * + * @param $legend + * The label for the form item group. + * @param $group + * The form items within the group, as an HTML string. + * @param $collapsed + * A boolean value decided whether the group starts collapsed. + * @param $description + * Explanatory text to display after the form item group. + * @param $attributes + * An associative array of HTML attributes to add to the fieldset tag. + * @return + * A themed HTML string representing the form item group. + */ +function form_group_collapsible($legend, $group, $collapsed = FALSE, $description = NULL, $attributes = NULL) { + drupal_add_js('misc/collapse.js'); + + $attributes['class'] .= ' collapsible'; + if ($collapsed) { + $attributes['class'] .= ' collapsed'; + } + + return '
\n"; +} + +/** * Format a radio button. * * @param $title @@ -1823,7 +1850,7 @@ * Encodes MIME/HTTP header values that contain non-ASCII, UTF-8 encoded * characters. * - * For example, mime_header_encode('tést.txt') returns "=?UTF-8?B?dMOpc3QudHh0?=". + * For example, mime_header_encode('tést.txt') returns "=?UTF-8?B?dMOpc3QudHh0?=". * * See http://www.rfc-editor.org/rfc/rfc2047.txt for more information. * Index: misc/drupal.css =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.css,v retrieving revision 1.107 diff -u -r1.107 drupal.css --- misc/drupal.css 31 May 2005 23:23:48 -0000 1.107 +++ misc/drupal.css 8 Jun 2005 09:23:12 -0000 @@ -586,3 +586,31 @@ input.throbbing { background-position: 100% -18px; } + +/* +** Collapsing fieldsets +*/ +html.js fieldset.collapsed { + border-bottom-width: 0; + border-left-width: 0; + border-right-width: 0; + margin-bottom: 0; +} + +html.js fieldset.collapsed * { + display: none; +} + +html.js fieldset.collapsed legend, +html.js fieldset.collapsed legend * { + display: inline; +} + +html.js fieldset.collapsible legend a { + padding-left: 15px; + background: url('menu-expanded.png') 5px 50% no-repeat; +} + +html.js fieldset.collapsed legend a { + background-image: url('menu-collapsed.png'); +} Index: misc/drupal.js =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.js,v retrieving revision 1.2 diff -u -r1.2 drupal.js --- misc/drupal.js 1 Jun 2005 17:43:33 -0000 1.2 +++ misc/drupal.js 8 Jun 2005 09:14:03 -0000 @@ -2,7 +2,7 @@ * Only enable Javascript functionality if all required features are supported. */ function isJsEnabled() { - if (typeof document.jsEnabled == 'undefined') { + if (document.jsEnabled == undefined) { // Note: ! casts to boolean implicitly. document.jsEnabled = !( !document.getElementsByTagName || @@ -15,7 +15,7 @@ // Global Killswitch if (isJsEnabled()) { - + document.documentElement.className = 'js'; } /** Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.353 diff -u -r1.353 comment.module --- modules/comment.module 22 May 2005 21:14:59 -0000 1.353 +++ modules/comment.module 8 Jun 2005 10:47:04 -0000 @@ -254,7 +254,7 @@ if (user_access('administer comments')) { $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", 2); $output = form_radios('', 'comment', $selected, array(t('Disabled'), t('Read only'), t('Read/write'))); - return form_group(t('User comments'), $output); + return form_group_collapsible(t('User comments'), $output, TRUE); } break; Index: modules/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter.module,v retrieving revision 1.64 diff -u -r1.64 filter.module --- modules/filter.module 1 Jun 2005 03:21:44 -0000 1.64 +++ modules/filter.module 8 Jun 2005 09:54:27 -0000 @@ -725,7 +725,8 @@ $output .= theme('filter_tips', $tips); $output .= ''; } - return theme('form_element', t('Input format'), $output, $extra, NULL, _form_get_error($name)); + $group = theme('form_element', NULL, $output, $extra, NULL, _form_get_error($name)); + return form_group_collapsible(t('Input format'), $group, TRUE); } else { // Only one format available: use a hidden form item and only show tips. Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.496 diff -u -r1.496 node.module --- modules/node.module 6 Jun 2005 14:07:04 -0000 1.496 +++ modules/node.module 8 Jun 2005 11:17:49 -0000 @@ -1292,7 +1292,7 @@ $author .= form_textfield(t('Authored on'), 'date', $edit->date, 20, 25, NULL, NULL, TRUE); $output .= ' \n"; $node_options = variable_get('node_options_'. $edit->type, array('status', 'promote')); @@ -1303,7 +1303,7 @@ $options .= form_checkbox(t('Create new revision'), 'revision', 1, isset($edit->revision) ? $edit->revision : in_array('revision', $node_options)); $output .= ' \n"; $extras .= implode(''.$group.'
', TRUE); } // Date settings: @@ -274,7 +274,7 @@ $group .= form_select(t('Long date format'), 'date_format_long', variable_get('date_format_long', $datelong[0]), $datelongchoices, t('Longer date format used for detailed display.')); $group .= form_select(t('First day of week'), 'date_first_day', variable_get('date_first_day', 0), array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')), t('The first day of the week for calendar views.')); - $output .= form_group(t('Date settings'), $group); + $output .= form_group_collapsible(t('Date settings'), $group, TRUE); return $output; } Index: modules/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload.module,v retrieving revision 1.40 diff -u -r1.40 upload.module --- modules/upload.module 31 May 2005 04:10:21 -0000 1.40 +++ modules/upload.module 8 Jun 2005 09:17:47 -0000 @@ -383,7 +383,7 @@ $output .= form_button(t('Attach'), 'fileop'); } - return ' '; + return ' '; } function upload_load($node) { --- misc/collapse.js +++ misc/collapse.js @@ -0,0 +1,47 @@ +addLoadEvent(collapse_auto_attach); + +var collapse_action = false; + +function collapse_auto_attach() { + var fieldsets = document.getElementsByTagName('fieldset'); + var i, legend, fieldset, a; + for (i=0; fieldset = fieldsets[i]; i++) { + if (!hasClass(fieldset, 'collapsible')) { + continue; + } + legend = fieldset.getElementsByTagName('legend'); + if (legend.length > 0) { + legend = legend[0]; + } + else { + continue; + } + var a = document.createElement('a'); + a.href = '#'; + a.onclick = function() { + collapse_toggle(this); + this.blur(); + return false; + }; + a.innerHTML = legend.innerHTML; + while (legend.hasChildNodes()) removeNode(legend.childNodes[0]); + legend.appendChild(a); + } +} + +function collapse_toggle(node) { + var fieldset = node.parentNode.parentNode; + var inputs = []; + inputs = inputs.concat(fieldset.getElementsByTagName('input')); + inputs = inputs.concat(fieldset.getElementsByTagName('textarea')); + inputs = inputs.concat(fieldset.getElementsByTagName('select')); + var i,j; + for (j=0; j<3; j++) { + for (i=0; i < inputs[j].length; i++) { + if (hasClass(inputs[j][i], 'error')) { + return removeClass(fieldset, 'collapsed'); + } + } + } + return toggleClass(fieldset, 'collapsed'); +}