From db61b2603918d582afad82b8036fac7f5240a627 Mon Sep 17 00:00:00 2001
From: Angie Byron <webchick@24967.no-reply.drupal.org>
Date: Fri, 21 Aug 2009 00:21:48 +0000
Subject: [PATCH] #439798 by Rob Loach: Added Vertical Tabs to the Node Type
 Form.

---
 modules/comment/comment-node-form.js | 19 +++++++++++++++
 modules/comment/comment.module       |  2 ++
 modules/node/content_types.inc       |  9 ++++++-
 modules/node/content_types.js        | 35 +++++++++++++++++++++++++---
 4 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/modules/comment/comment-node-form.js b/modules/comment/comment-node-form.js
index 20d8729f44f7..0f51884a2803 100644
--- a/modules/comment/comment-node-form.js
+++ b/modules/comment/comment-node-form.js
@@ -7,6 +7,25 @@ Drupal.behaviors.commentFieldsetSummaries = {
     $('fieldset#edit-comment-settings', context).setSummary(function (context) {
       return Drupal.checkPlain($('input:checked', context).parent().text());
     });
+    // Provide the summary for the node type form.
+    $('fieldset#edit-comment', context).setSummary(function(context) {
+      var vals = [];
+
+      // Default comment setting.
+      vals.push($("select[name='comment'] option:selected", context).text());
+
+      // Threading.
+      var threading = $("input[name='comment_default_mode']:checked", context).parent().text();
+      if (threading) {
+        vals.push(threading);
+      }
+
+      // Comments per page.
+      var number = $("select[name='comment_default_per_page'] option:selected", context).val();
+      vals.push(Drupal.t('@number comments per page', {'@number': number}));
+
+      return Drupal.checkPlain(vals.join(', '));
+    });
   }
 };
 
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 18653611c177..b06b186a400e 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -932,6 +932,8 @@ function comment_form_node_type_form_alter(&$form, $form_state) {
       '#title' => t('Comment settings'),
       '#collapsible' => TRUE,
       '#collapsed' => TRUE,
+      '#group' => 'additional_settings',
+      '#attached_js' => array(drupal_get_path('module', 'comment') . '/comment-node-form.js'),
     );
     $form['comment']['comment_default_mode'] = array(
       '#type' => 'checkbox',
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index af6cbbcb4ee4..bd68d05e3d17 100644
--- a/modules/node/content_types.inc
+++ b/modules/node/content_types.inc
@@ -108,12 +108,17 @@ function node_type_form(&$form_state, $type = NULL) {
     '#title' => t('Description'),
     '#type' => 'textarea',
     '#default_value' => $type->description,
-    );
+  );
+
+  $form['additional_settings'] = array(
+    '#type' => 'vertical_tabs',
+  );
 
   $form['submission'] = array(
     '#type' => 'fieldset',
     '#title' => t('Submission form settings'),
     '#collapsible' => TRUE,
+    '#group' => 'additional_settings',
   );
   $form['submission']['title_label'] = array(
     '#title' => t('Title field label'),
@@ -155,6 +160,7 @@ function node_type_form(&$form_state, $type = NULL) {
     '#title' => t('Publishing options'),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
+    '#group' => 'additional_settings',
   );
   $form['workflow']['node_options'] = array('#type' => 'checkboxes',
     '#title' => t('Default options'),
@@ -172,6 +178,7 @@ function node_type_form(&$form_state, $type = NULL) {
     '#title' => t('Display settings'),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
+    '#group' => 'additional_settings',
   );
   $form['display']['node_submitted'] = array(
     '#type' => 'checkbox',
diff --git a/modules/node/content_types.js b/modules/node/content_types.js
index e182d3452502..98a0baed1b92 100644
--- a/modules/node/content_types.js
+++ b/modules/node/content_types.js
@@ -2,15 +2,44 @@
 (function ($) {
 
 Drupal.behaviors.contentTypes = {
-  attach: function () {
+  attach: function (context) {
+    // Provide the vertical tab summaries.
+    $('fieldset#edit-submission', context).setSummary(function(context) {
+      var vals = [];
+      vals.push(Drupal.checkPlain($('#edit-title-label', context).val()) || Drupal.t('Requires a title'));
+      vals.push(Drupal.checkPlain($('#edit-body-label', context).val()) || Drupal.t('No body'));
+      return vals.join(', ');
+    });
+    $('fieldset#edit-workflow', context).setSummary(function(context) {
+      var vals = [];
+      $("input[name^='node_options']:checked", context).parent().each(function() {
+        vals.push(Drupal.checkPlain($(this).text()));
+      });
+      if (!$('#edit-node-options-status', context).is(':checked')) {
+        vals.unshift(Drupal.t('Not published'));
+      }
+      return vals.join(', ');
+    });
+    $('fieldset#edit-display', context).setSummary(function(context) {
+      var vals = [];
+      $('input:checked', context).parent().each(function() {
+        vals.push(Drupal.checkPlain($(this).text()));
+      });
+      if (!$('#edit-node-submitted', context).is(':checked')) {
+        vals.unshift(Drupal.t("Don't display post information"));
+      }
+      return vals.join(', ');
+    });
+
+    // Process the machine name.
     if ($('#edit-type').val() == $('#edit-name').val().toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/_+/g, '_') || $('#edit-type').val() == '') {
-      $('.form-item-type-wrapper').hide();
+      $('.form-item.type-wrapper').hide();
       $('#edit-name').keyup(function () {
         var machine = $(this).val().toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/_+/g, '_');
         if (machine != '_' && machine != '') {
           $('#edit-type').val(machine);
           $('#node-type-name-suffix').empty().append(' Machine name: ' + machine + ' [').append($('<a href="#">' + Drupal.t('Edit') + '</a>').click(function () {
-            $('.form-item-type-wrapper').show();
+            $('.form-item-textfield.type-wrapper').show();
             $('#node-type-name-suffix').hide();
             $('#edit-name').unbind('keyup');
             return false;
-- 
GitLab