diff --git a/fieldable_panels_panes.module b/fieldable_panels_panes.module index e666152..934c4d9 100644 --- a/fieldable_panels_panes.module +++ b/fieldable_panels_panes.module @@ -894,12 +894,13 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) { '#value' => $entity->language, ); - // Make the other form items dependent upon it. - ctools_include('dependent'); - ctools_add_js('dependent'); - $form['link'] = array( - '#weight' => -10, + '#type' => 'container', + '#states' => array( + 'visible' => array( + ':input[name="title"]' => array('empty' => FALSE), + ), + ), ); $form['link']['link'] = array( @@ -907,23 +908,57 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) { '#type' => 'checkbox', '#default_value' => $entity->link, '#description' => t('Check here to make the title link to another page.'), - '#id' => 'edit-link', ); $form['link']['path'] = array( '#type' => 'textfield', '#title' => t('Path'), '#description' => t('The path for this link. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')), - '#dependency' => array('edit-link' => array(1)), + '#states' => array( + 'visible' => array( + ':input[name="link"]' => array('checked' => TRUE), + ), + ), '#default_value' => $entity->path, ); + $form['additional_settings'] = array( + '#type' => 'vertical_tabs', + '#weight' => 99, + ); + $form['reusable'] = array( + '#type' => 'fieldset', + '#title' => t('Reusability'), + '#collapsible' => TRUE, + '#collapsed' => empty($entity->reusable), + '#group' => 'additional_settings', + '#attributes' => array( + 'class' => array('fieldable-pane-pane-form-reusable-information'), + ), + '#attached' => array( + 'js' => array( + 'vertical-tabs' => drupal_get_path('module', 'fieldable_panels_panes') . '/fieldable_panels_panes.vertical-tabs.js', + ), + ), '#weight' => 10, ); $form['revision'] = array( - '#weight' => 11, + '#type' => 'fieldset', + '#title' => t('Revision'), + '#collapsible' => TRUE, + '#collapsed' => empty($entity->revision), + '#group' => 'additional_settings', + '#attributes' => array( + 'class' => array('fieldable-pane-pane-form-revision-information'), + ), + '#attached' => array( + 'js' => array( + 'vertical-tabs' => drupal_get_path('module', 'fieldable_panels_panes') . '/fieldable_panels_panes.vertical-tabs.js', + ), + ), + '#weight' => 30, ); if (empty($entity->fpid)) { @@ -934,38 +969,48 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) { '#type' => 'checkbox', '#title' => t('Make this entity reusable'), '#default_value' => $entity->reusable, - '#id' => 'edit-reusable', ); $form['reusable']['category'] = array( '#type' => 'textfield', '#title' => t('Category'), '#description' => t('The category this content will appear in the "Add content" modal. If left blank the category will be "Miscellaneous".'), - '#dependency' => array('edit-reusable' => array(1)), '#default_value' => $entity->category, + '#states' => array( + 'visible' => array( + ':input[name="reusable"]' => array('checked' => TRUE), + ), + ), ); $form['reusable']['admin_title'] = array( '#type' => 'textfield', '#title' => t('Administrative title'), '#description' => t('The name this content will appear in the "Add content" modal.'), - '#dependency' => array('edit-reusable' => array(1)), '#default_value' => $entity->admin_title, + '#states' => array( + 'visible' => array( + ':input[name="reusable"]' => array('checked' => TRUE), + ), + ), ); $form['reusable']['admin_description'] = array( '#type' => 'textarea', '#title' => t('Administrative description'), '#description' => t('A description of what this content is, does or is for, for administrative use.'), - '#dependency' => array('edit-reusable' => array(1)), '#default_value' => $entity->admin_description, + '#states' => array( + 'visible' => array( + ':input[name="reusable"]' => array('checked' => TRUE), + ), + ), ); $form['revision']['revision'] = array( '#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => 1, - '#id' => 'edit-revision', ); if (!user_access('administer fieldable panels panes') || $entity->vid != $entity->current_vid) { @@ -977,8 +1022,12 @@ function fieldable_panels_panes_entity_edit_form($form, &$form_state) { '#type' => 'textarea', '#title' => t('Log message'), '#description' => t('Provide an explanation of the changes you are making. This will help other authors understand your motivations.'), - '#dependency' => array('edit-revision' => array(1)), '#default_value' => '', + '#states' => array( + 'visible' => array( + ':input[name="revision"]' => array('checked' => TRUE), + ), + ), ); $language = NULL; diff --git a/fieldable_panels_panes.vertical-tabs.js b/fieldable_panels_panes.vertical-tabs.js new file mode 100644 index 0000000..cd9322e --- /dev/null +++ b/fieldable_panels_panes.vertical-tabs.js @@ -0,0 +1,38 @@ +(function ($) { + +Drupal.behaviors.fieldablePanelPaneFieldsetSummaries = { + attach: function (context) { + $('fieldset.vertical-tabs-pane.fieldable-pane-pane-form-reusable-information', context).drupalSetSummary(function (context) { + var summary = []; + + if ($('input[name="reusable"]', context).is(':checked')) { + summary.push(Drupal.t('Reusable: Yes')); + var category = $('input[name="category"]', context).val() || Drupal.t('None'); + summary.push(Drupal.t('Category: @value', { '@value': category })); + var admin_title = $('input[name="admin_title"]', context).val() || Drupal.t('None'); + summary.push(Drupal.t('Admin title: @value', { '@value': admin_title })); + } + else { + summary.push(Drupal.t('Reusable: No')); + } + + return summary.join('
'); + }); + + $('fieldset.vertical-tabs-pane.fieldable-pane-pane-form-revision-information', context).drupalSetSummary(function (context) { + var revisionCheckbox = $('input[name="revision"]', context); + + // Return 'New revision' if the 'Create new revision' checkbox is checked, + // or if the checkbox doesn't exist, but the revision log does. For users + // without the "Administer content" permission the checkbox won't appear, + // but the revision log will if the content type is set to auto-revision. + if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $('.form-item-log textarea', context).length)) { + return Drupal.t('New revision'); + } + + return Drupal.t('No revision'); + }); + } +}; + +})(jQuery); diff --git a/includes/translation.handler.fieldable_panels_pane.inc b/includes/translation.handler.fieldable_panels_pane.inc index 536ca63..20a213f 100644 --- a/includes/translation.handler.fieldable_panels_pane.inc +++ b/includes/translation.handler.fieldable_panels_pane.inc @@ -28,4 +28,22 @@ class EntityTranslationFieldablePanelsPaneHandler extends EntityTranslationDefau public function getAccess($op) { return fieldable_panels_panes_access($op, $this->entity); } + + /** + * Convert the translation update status fieldset into a vartical tab. + */ + public function entityForm(&$form, &$form_state) { + parent::entityForm($form, $form_state); + + // Move the translation fieldset to a vertical tab. + if (isset($form['translation'])) { + $form['translation'] += array( + '#group' => 'additional_settings', + '#weight' => 100, + '#attached' => array( + 'js' => array(drupal_get_path('module', 'entity_translation') . '/entity_translation.node-form.js'), + ), + ); + } + } }