Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.486 diff -u -r1.486 book.module --- modules/book/book.module 18 Feb 2009 13:46:53 -0000 1.486 +++ modules/book/book.module 8 Mar 2009 12:36:23 -0000 @@ -349,7 +349,7 @@ if ($access) { _book_add_form_elements($form, $node); - $form['book']['pick-book'] = array( + $form['miscellaneous']['book']['pick-book'] = array( '#type' => 'submit', '#value' => t('Change book (update list of parents)'), // Submit the node form so the parent select options get updated. @@ -415,27 +415,25 @@ function _book_add_form_elements(&$form, $node) { // Need this for AJAX. $form['#cache'] = TRUE; - drupal_add_js("if (Drupal.jsEnabled) { jQuery(function() { jQuery('#edit-book-pick-book').css('display', 'none'); }); }", 'inline'); + drupal_add_js(drupal_get_path('module', 'book') .'/book.js'); - $form['book'] = array( + $form['miscellaneous']['book'] = array( '#type' => 'fieldset', '#title' => t('Book outline'), '#weight' => 10, - '#collapsible' => TRUE, - '#collapsed' => TRUE, '#tree' => TRUE, '#attributes' => array('class' => 'book-outline-form'), ); foreach (array('menu_name', 'mlid', 'nid', 'router_path', 'has_children', 'options', 'module', 'original_bid', 'parent_depth_limit') as $key) { - $form['book'][$key] = array( + $form['miscellaneous']['book'][$key] = array( '#type' => 'value', '#value' => $node->book[$key], ); } - $form['book']['plid'] = _book_parent_select($node->book); + $form['miscellaneous']['book']['plid'] = _book_parent_select($node->book); - $form['book']['weight'] = array( + $form['miscellaneous']['book']['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), '#default_value' => $node->book['weight'], @@ -466,7 +464,7 @@ } // Add a drop-down to select the destination book. - $form['book']['bid'] = array( + $form['miscellaneous']['book']['bid'] = array( '#type' => 'select', '#title' => t('Book'), '#default_value' => $node->book['bid'], Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.55 diff -u -r1.55 node.pages.inc --- modules/node/node.pages.inc 13 Feb 2009 02:22:09 -0000 1.55 +++ modules/node/node.pages.inc 8 Mar 2009 12:36:25 -0000 @@ -97,6 +97,7 @@ * Generate the node add/edit form array. */ function node_form(&$form_state, $node) { + drupal_add_js(drupal_get_path('module', 'node') . '/node.js'); global $user; if (isset($form_state['node'])) { @@ -146,24 +147,29 @@ $form['#node'] = $node; + $form['miscellaneous'] = array( + '#prefix' => '
', + '#suffix' => '
', + ); + + drupal_add_js('misc/vertical-tabs.js', array('weight' => 0)); + drupal_add_css('misc/vertical-tabs.css'); + // Add a log field if the "Create new revision" option is checked, or if the // current user has the ability to check that option. if (!empty($node->revision) || user_access('administer nodes')) { - $form['revision_information'] = array( + $form['miscellaneous']['revision_information'] = array( '#type' => 'fieldset', '#title' => t('Revision information'), - '#collapsible' => TRUE, - // Collapsed by default when "Create new revision" is unchecked - '#collapsed' => !$node->revision, '#weight' => 20, ); - $form['revision_information']['revision'] = array( + $form['miscellaneous']['revision_information']['revision'] = array( '#access' => user_access('administer nodes'), '#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $node->revision, ); - $form['revision_information']['log'] = array( + $form['miscellaneous']['revision_information']['log'] = array( '#type' => 'textarea', '#title' => t('Revision log message'), '#rows' => 2, @@ -172,15 +178,13 @@ } // Node author information for administrators - $form['author'] = array( + $form['miscellaneous']['author'] = array( '#type' => 'fieldset', '#access' => user_access('administer nodes'), '#title' => t('Authoring information'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, '#weight' => 90, ); - $form['author']['name'] = array( + $form['miscellaneous']['author']['name'] = array( '#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, @@ -189,7 +193,7 @@ '#weight' => -1, '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))), ); - $form['author']['date'] = array( + $form['miscellaneous']['author']['date'] = array( '#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, @@ -197,29 +201,27 @@ ); if (isset($node->date)) { - $form['author']['date']['#default_value'] = $node->date; + $form['miscellaneous']['author']['date']['#default_value'] = $node->date; } // Node options for administrators - $form['options'] = array( + $form['miscellaneous']['options'] = array( '#type' => 'fieldset', '#access' => user_access('administer nodes'), '#title' => t('Publishing options'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, '#weight' => 95, ); - $form['options']['status'] = array( + $form['miscellaneous']['options']['status'] = array( '#type' => 'checkbox', '#title' => t('Published'), '#default_value' => $node->status, ); - $form['options']['promote'] = array( + $form['miscellaneous']['options']['promote'] = array( '#type' => 'checkbox', '#title' => t('Promoted to front page'), '#default_value' => $node->promote, ); - $form['options']['sticky'] = array( + $form['miscellaneous']['options']['sticky'] = array( '#type' => 'checkbox', '#title' => t('Sticky at top of lists'), '#default_value' => $node->sticky, @@ -277,7 +279,7 @@ $form = array( '#after_build' => array('node_teaser_js', 'node_teaser_include_verify')); - $form['#prefix'] = '
'; + $form['#prefix'] = '
'; $form['#suffix'] = '
'; $form['teaser_js'] = array( Index: modules/menu/menu.module =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v retrieving revision 1.178 diff -u -r1.178 menu.module --- modules/menu/menu.module 31 Jan 2009 16:56:00 -0000 1.178 +++ modules/menu/menu.module 8 Mar 2009 12:36:25 -0000 @@ -388,38 +388,37 @@ */ function menu_form_alter(&$form, $form_state, $form_id) { if (!empty($form['#node_edit_form'])) { + drupal_add_js(drupal_get_path('module', 'menu') . '/menu.js'); // Note - doing this to make sure the delete checkbox stays in the form. $form['#cache'] = TRUE; - $form['menu'] = array( + $form['miscellaneous']['menu'] = array( '#type' => 'fieldset', '#title' => t('Menu settings'), '#access' => user_access('administer menu'), - '#collapsible' => TRUE, - '#collapsed' => FALSE, '#tree' => TRUE, - '#weight' => -2, + '#weight' => 5, '#attributes' => array('class' => 'menu-item-form'), ); $item = $form['#node']->menu; if ($item['mlid']) { // There is an existing link. - $form['menu']['delete'] = array( + $form['miscellaneous']['menu']['delete'] = array( '#type' => 'checkbox', '#title' => t('Delete this menu item.'), ); } if (!$item['link_title']) { - $form['menu']['#collapsed'] = TRUE; + $form['miscellaneous']['menu']['#collapsed'] = TRUE; } foreach (array('mlid', 'module', 'hidden', 'has_children', 'customized', 'options', 'expanded', 'hidden', 'parent_depth_limit') as $key) { - $form['menu'][$key] = array('#type' => 'value', '#value' => $item[$key]); + $form['miscellaneous']['menu'][$key] = array('#type' => 'value', '#value' => $item[$key]); } - $form['menu']['#item'] = $item; + $form['miscellaneous']['menu']['#item'] = $item; - $form['menu']['link_title'] = array('#type' => 'textfield', + $form['miscellaneous']['menu']['link_title'] = array('#type' => 'textfield', '#title' => t('Menu link title'), '#default_value' => $item['link_title'], '#description' => t('The link text corresponding to this item that should appear in the menu. Leave blank if you do not wish to add this post to the menu.'), @@ -431,7 +430,7 @@ if (!isset($options[$default])) { $default = 'main-menu:0'; } - $form['menu']['parent'] = array( + $form['miscellaneous']['menu']['parent'] = array( '#type' => 'select', '#title' => t('Parent item'), '#default_value' => $default, @@ -441,7 +440,7 @@ ); $form['#submit'][] = 'menu_node_form_submit'; - $form['menu']['weight'] = array( + $form['miscellaneous']['menu']['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), '#delta' => 50, Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.320 diff -u -r1.320 form.inc --- includes/form.inc 3 Feb 2009 18:55:29 -0000 1.320 +++ includes/form.inc 8 Mar 2009 12:36:22 -0000 @@ -877,6 +877,19 @@ if (isset($form['#input']) && $form['#input']) { _form_builder_handle_input_element($form_id, $form, $form_state, $complete_form); } + if (!isset($form['#id'])) { + $form['#id'] = form_clean_id('edit-' . implode('-', $form['#parents'])); + } + // Allow for elements to expand to multiple elements, e.g., radios, + // checkboxes and files. + if (isset($form['#process']) && !$form['#processed']) { + foreach ($form['#process'] as $process) { + if (drupal_function_exists($process)) { + $form = $process($form, isset($edit) ? $edit : NULL, $form_state, $complete_form); + } + } + $form['#processed'] = TRUE; + } $form['#defaults_loaded'] = TRUE; // We start off assuming all form elements are in the correct order. @@ -984,9 +997,6 @@ } array_unshift($form['#parents'], $name); } - if (!isset($form['#id'])) { - $form['#id'] = form_clean_id('edit-' . implode('-', $form['#parents'])); - } if (!empty($form['#disabled'])) { $form['#attributes']['disabled'] = 'disabled'; @@ -1055,16 +1065,6 @@ } } } - // Allow for elements to expand to multiple elements, e.g., radios, - // checkboxes and files. - if (isset($form['#process']) && !$form['#processed']) { - foreach ($form['#process'] as $process) { - if (drupal_function_exists($process)) { - $form = $process($form, isset($edit) ? $edit : NULL, $form_state, $complete_form); - } - } - $form['#processed'] = TRUE; - } form_set_value($form, $form['#value'], $form_state); } @@ -1499,6 +1499,7 @@ $element['#attributes']['class'] .= ' collapsed'; } } + $element['#attributes']['id'] = $element['#id']; return '' . ($element['#title'] ? '' . $element['#title'] . '' : '') . (isset($element['#description']) && $element['#description'] ? '
' . $element['#description'] . '
' : '') . (!empty($element['#children']) ? $element['#children'] : '') . (isset($element['#value']) ? $element['#value'] : '') . "\n"; } Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.228 diff -u -r1.228 upload.module --- modules/upload/upload.module 20 Feb 2009 10:26:35 -0000 1.228 +++ modules/upload/upload.module 8 Mar 2009 12:36:27 -0000 @@ -224,21 +224,19 @@ if (!empty($form['#node_edit_form'])) { $node = $form['#node']; if (variable_get("upload_$node->type", TRUE)) { + drupal_add_js(drupal_get_path('module', 'upload') .'/upload.js'); + // Attachments fieldset - $form['attachments'] = array( + $form['miscellaneous']['attachments'] = array( '#type' => 'fieldset', '#access' => user_access('upload files'), '#title' => t('File attachments'), - '#collapsible' => TRUE, - '#collapsed' => empty($node->files), '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'), - '#prefix' => '
', - '#suffix' => '
', '#weight' => 30, ); // Wrapper for fieldset contents (used by ahah.js). - $form['attachments']['wrapper'] = array( + $form['miscellaneous']['attachments']['wrapper'] = array( '#prefix' => '
', '#suffix' => '
', ); @@ -249,16 +247,16 @@ $temp = file_directory_temp(); // Note: pass by reference if (!file_check_directory($path, FILE_CREATE_DIRECTORY) || !file_check_directory($temp, FILE_CREATE_DIRECTORY)) { - $form['attachments']['#description'] = t('File attachments are disabled. The file directories have not been properly configured.'); + $form['miscellaneous']['attachments']['#description'] = t('File attachments are disabled. The file directories have not been properly configured.'); if (user_access('administer site configuration')) { - $form['attachments']['#description'] .= ' ' . t('Please visit the file system configuration page.', array('@admin-file-system' => url('admin/settings/file-system'))); + $form['miscellaneous']['attachments']['#description'] .= ' ' . t('Please visit the file system configuration page.', array('@admin-file-system' => url('admin/settings/file-system'))); } else { - $form['attachments']['#description'] .= ' ' . t('Please contact the site administrator.'); + $form['miscellaneous']['attachments']['#description'] .= ' ' . t('Please contact the site administrator.'); } } else { - $form['attachments']['wrapper'] += _upload_form($node); + $form['miscellaneous']['attachments']['wrapper'] += _upload_form($node); $form['#attributes']['enctype'] = 'multipart/form-data'; } $form['#submit'][] = 'upload_node_form_submit'; Index: themes/garland/style.css =================================================================== RCS file: /cvs/drupal/drupal/themes/garland/style.css,v retrieving revision 1.48 diff -u -r1.48 style.css --- themes/garland/style.css 18 Feb 2009 14:28:25 -0000 1.48 +++ themes/garland/style.css 8 Mar 2009 12:36:27 -0000 @@ -814,6 +814,7 @@ padding: 1em; border: 1px solid #d9eaf5; background: #fff url(images/gradient-inner.png) repeat-x 0 0; + background-position-y: 0; } /* Targets IE 7. Fixes background image in field sets. */ @@ -823,6 +824,11 @@ background-color: transparent; } +*:first-child+html fieldset.filter-wrapper, +*:first-child+html fieldset.vertical-tabs-pane { + background-position: 0 0; +} + *:first-child+html fieldset > .description, *:first-child+html fieldset .fieldset-wrapper .description { padding-top: 1em; } @@ -852,6 +858,25 @@ } /** + * Vertical tabs + */ +div.vertical-tabs { + margin: 1em 0; +} + +div.vertical-tabs ul.vertical-tabs-list li.selected { + background: #FFF; +} + +div.vertical-tabs ul.vertical-tabs-list li.selected.first { + background: #FFF url(images/gradient-inner.png) repeat-x 0 0; +} + +div.vertical-tabs ul.vertical-tabs-list li.selected a { + color: #494949; +} + +/** * Syndication icons and block */ #block-node-syndicate h2 { @@ -1049,6 +1074,18 @@ } /** + * Vertical tabs + */ +div.vertical-tabs ul.vertical-tabs-list li { + background: #edf5fa none; + border-color: #d9eaf5; +} +div.vertical-tabs div.vertical-tabs-panes, +div.vertical-tabs ul.vertical-tabs-list { + border-color: #d9eaf5; +} + +/** * Status report colors. */ table.system-status-report tr.error, table.system-status-report tr.error th { Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.152 diff -u -r1.152 path.module --- modules/path/path.module 9 Dec 2008 11:30:24 -0000 1.152 +++ modules/path/path.module 8 Mar 2009 12:36:25 -0000 @@ -188,16 +188,15 @@ */ function path_form_alter(&$form, $form_state, $form_id) { if (!empty($form['#node_edit_form'])) { + drupal_add_js(drupal_get_path('module', 'path') .'/path.js'); $path = isset($form['#node']->path) ? $form['#node']->path : NULL; - $form['path'] = array( + $form['miscellaneous']['path'] = array( '#type' => 'fieldset', '#title' => t('URL path settings'), - '#collapsible' => TRUE, - '#collapsed' => empty($path), '#access' => user_access('create url aliases'), '#weight' => 30, ); - $form['path']['path'] = array( + $form['miscellaneous']['path']['path'] = array( '#type' => 'textfield', '#default_value' => $path, '#maxlength' => 128, @@ -206,7 +205,7 @@ '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'), ); if ($path) { - $form['path']['pid'] = array( + $form['miscellaneous']['path']['pid'] = array( '#type' => 'value', '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $path, $form['#node']->language)) ); Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.694 diff -u -r1.694 comment.module --- modules/comment/comment.module 26 Feb 2009 07:30:26 -0000 1.694 +++ modules/comment/comment.module 8 Mar 2009 12:36:24 -0000 @@ -574,15 +574,14 @@ function comment_form_alter(&$form, $form_state, $form_id) { if (!empty($form['#node_edit_form'])) { $node = $form['#node']; - $form['comment_settings'] = array( + drupal_add_js(drupal_get_path('module', 'comment') . '/comment-node-form.js'); + $form['miscellaneous']['comment_settings'] = array( '#type' => 'fieldset', '#access' => user_access('administer comments'), '#title' => t('Comment settings'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, '#weight' => 30, ); - $form['comment_settings']['comment'] = array( + $form['miscellaneous']['comment_settings']['comment'] = array( '#type' => 'radios', '#parents' => array('comment'), '#default_value' => $node->comment, Index: modules/upload/upload.js =================================================================== RCS file: modules/upload/upload.js diff -N modules/upload/upload.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/upload/upload.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ +// $Id$ + +(function($) { + +Drupal.behaviors.nodeUploadVerticalTab = { + attach: function(context) { + $('#edit-attachments').data('verticalTabCallback', function() { + var size = $('#upload-attachments tbody tr').size(); + return Drupal.formatPlural(size, '1 attachment', '@count attachments'); + }).each(function() { + Drupal.verticalTab && Drupal.verticalTab.update(this); + }); + } +}; + +})(jQuery); Index: modules/path/path.js =================================================================== RCS file: modules/path/path.js diff -N modules/path/path.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/path/path.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,19 @@ +// $Id$ + +(function($) { + +Drupal.behaviors.nodePathVerticalTab = { + attach: function(context) { + $('#edit-path').data('verticalTabCallback', function() { + var path = $('#edit-path-1').val(); + + return path ? + Drupal.t('Alias: @alias', { '@alias': path }) : + Drupal.t('No alias'); + }).each(function() { + Drupal.verticalTab && Drupal.verticalTab.update(this); + }); + } +}; + +})(jQuery); Index: modules/menu/menu.js =================================================================== RCS file: modules/menu/menu.js diff -N modules/menu/menu.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/menu/menu.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +// $Id$ + +(function($) { + +Drupal.behaviors.nodeMenuVerticalTab = { + attach: function(context) { + $('#edit-menu').data('verticalTabCallback', function() { + return $('#edit-menu-link-title', this.fieldset).val() || Drupal.t('Not in menu'); + }).each(function() { + Drupal.verticalTab && Drupal.verticalTab.update(this); + }); + } +}; + +})(jQuery); Index: modules/book/book.js =================================================================== RCS file: modules/book/book.js diff -N modules/book/book.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/book/book.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,28 @@ +// $Id$ + +(function($) { + +Drupal.behaviors.nodeBookVerticalTab = { + attach: function(context) { + $('#edit-book').data('verticalTabCallback', function() { + var val = $('#edit-book-bid').val(); + + if (val === '0') + return Drupal.t('Not in book'); + else if (val === 'new') + return Drupal.t('New book'); + else + return $('#edit-book-bid option[selected]').text(); + }).each(function() { + Drupal.verticalTab && Drupal.verticalTab.update(this); + }); + } +}; + +if (Drupal.jsEnabled) { + $(document).ready(function() { + $('#edit-book-pick-book').css('display', 'none'); + }); +} + +})(jQuery); Index: modules/node/node.js =================================================================== RCS file: modules/node/node.js diff -N modules/node/node.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/node/node.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,53 @@ +// $Id$ + +(function($) { + +Drupal.behaviors.nodeRevisionVerticalTab = { + attach: function(context) { + $('#edit-revision-information').data('verticalTabCallback', function() { + return $('#edit-revision', this.fieldset).is(':checked') ? + Drupal.t('Create new revision') : + Drupal.t('Don\'t create new revision'); + }).each(function() { + Drupal.verticalTab && Drupal.verticalTab.update(this); + }); + } +}; + +Drupal.behaviors.nodeAuthoringVerticalTab = { + attach: function(context) { + $('#edit-author').data('verticalTabCallback', function() { + var name = $('#edit-name').val(), date = $('#edit-date').val(); + return date ? + Drupal.t('By @name on @date', { '@name': name, '@date': date }) : + Drupal.t('By @name', { '@name': name }); + }).each(function() { + Drupal.verticalTab && Drupal.verticalTab.update(this); + }); + } +}; + +Drupal.behaviors.nodePublishingVerticalTab = { + attach: function(context) { + $('#edit-options').data('verticalTabCallback', function() { + var vals = []; + if ($('#edit-status').attr('checked')) { + vals.push(Drupal.t('Published')); + } + if ($('#edit-promote').attr('checked')) { + vals.push(Drupal.t('Promoted to front page')); + } + if ($('#edit-sticky').attr('checked')) { + vals.push(Drupal.t('Sticky on top of lists')); + } + if (vals.join(', ') == '') { + return Drupal.t('None'); + } + return vals.join(', '); + }).each(function() { + Drupal.verticalTab && Drupal.verticalTab.update(this); + }); + } +}; + +})(jQuery); Index: misc/vertical-tabs.css =================================================================== RCS file: misc/vertical-tabs.css diff -N misc/vertical-tabs.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/vertical-tabs.css 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,68 @@ +/* $Id$ */ + +.vertical-tabs { + width: 95%; + margin: 1em 0; +} + +.vertical-tabs ul.vertical-tabs-list { + width: 20em; + list-style: none; + border-top: 1px solid #ccc; + vertical-align: top; + margin: 0; + padding: 0; + float: left; +} + +.vertical-tabs .vertical-tabs-panes { + border: 1px solid #ccc; + background: #fff; + margin-left: 20em; +} + +.vertical-tabs .vertical-tabs-panes fieldset.vertical-tabs-pane { + margin: 0; + padding: 0 1em; + border: 0; +} + +.vertical-tabs .vertical-tabs-panes fieldset.vertical-tabs-pane legend { + display: none; +} + +/* Layout of each tab */ +.vertical-tabs-list li { + position: relative; + z-index: 100; + background: #eee; + border: 1px solid #ccc; + border-right: none; + right: -1px; + margin: -1px -1px 0 0; + padding: 0; +} + +.vertical-tabs-list li a { + display: block; + text-decoration: none; + padding: 0.4em 0.6em; +} + +.vertical-tabs-list li a:focus { + position: relative; + z-index: 5; +} + +.vertical-tabs-list li.selected { + background: #fff; +} + +.vertical-tabs-list .description { + display: block; +} + +.vertical-tabs ul.vertical-tabs-list .description { + line-height: normal; + margin-bottom: 0; +} Index: modules/comment/comment-node-form.js =================================================================== RCS file: modules/comment/comment-node-form.js diff -N modules/comment/comment-node-form.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/comment/comment-node-form.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +// $Id$ + +(function($) { + +Drupal.behaviors.nodeCommentVerticalTab = { + attach: function(context) { + $('#edit-comment-settings').data('verticalTabCallback', function() { + return $('input:checked', this.fieldset).parent().text(); + }).each(function() { + Drupal.verticalTab && Drupal.verticalTab.update(this); + }); + } +}; + +})(jQuery); Index: misc/vertical-tabs.js =================================================================== RCS file: misc/vertical-tabs.js diff -N misc/vertical-tabs.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/vertical-tabs.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,87 @@ +// $Id$ + +(function($) { + +Drupal.behaviors.verticalTabs = { + attach: function(context) { + $('.vertical-tabs-panes:not(.vertical-tabs-processed)', context).each(function() { + // Create the tabs. + var list = $(''); + $(this).wrap('
').before(list); + + $('> fieldset', this).each(function(i) { + var tab = new Drupal.verticalTab({ title: $('> legend', this).text(), fieldset: $(this) }); + list.append(tab.item); + $(this) + .addClass('vertical-tabs-pane') + .data('verticalTab', tab) + .find('input, textarea, select') + .change(function() { + tab.updateDescription(); + }); + }); + + $('> li:first', list).addClass('first'); + $('> li:last', list).addClass('last'); + + // Find the height of the highest fieldset. + var max = $('div.vertical-tabs ul.vertical-tabs-list').outerHeight(); + $('fieldset.vertical-tabs-pane').each(function() { + max = Math.max(max, $(this).outerHeight()); + }); + $('div.vertical-tabs-panes').css('min-height', max + 'px'); + + $('> fieldset:first', this).data('verticalTab').focus(); + }).addClass('vertical-tabs-processed'); + } +}; + +Drupal.verticalTab = function(settings) { + var that = this; + $.extend(this, settings, Drupal.theme('verticalTab', settings)); + this.link.click(function() { + that.focus(); + return false; + }); + this.updateDescription(); +}; + +Drupal.verticalTab.update = function(tab) { + var data = $(tab).data('verticalTab'); + if (data) { + data.updateDescription(); + } +}; + +Drupal.verticalTab.prototype = { + focus: function() { + this.fieldset.siblings().each(function() { + var tab = $(this).data('verticalTab'); + tab.fieldset.hide(); + tab.item.removeClass('selected'); + }); + + this.fieldset.show(); + this.item.addClass('selected'); + }, + + updateDescription: function() { + var callback = this.fieldset.data('verticalTabCallback'); + if (callback) { + this.description.html(callback.call(this)); + } + } +}; + +Drupal.theme.prototype.verticalTab = function(settings) { + var tab = {}; + tab.item = $('
  • ') + .append(tab.link = $('') + .append(tab.title = $('').text(settings.title)) + .append(tab.description = $('') + ) + ); + return tab; +}; + +})(jQuery);