Skip to content

Commit

Permalink
Issue #54: Set up edit sidebar as a theme setting option.
Browse files Browse the repository at this point in the history
  • Loading branch information
laryn committed Aug 29, 2023
1 parent 307e52e commit 11ad3aa
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 40 deletions.
14 changes: 7 additions & 7 deletions dist/js/edit_form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var $;

$ = jQuery, Backdrop.behaviors.ginEditForm = {
attach: function(context, settings) {
$(".block-page-title-block").append($(".form-actions")), $(".form-actions input").attr("form", $(".node-form").attr("id"));
}
};
(Backdrop => {
Backdrop.behaviors.ginEditForm = {
attach: function(context, settings) {
$(".block-page-title-block").append($(".form-actions")), $(".form-actions input").attr("form", $(".node-form").attr("id"));
}
};
})(Backdrop);
5 changes: 2 additions & 3 deletions js/edit_form.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(function ($) {

((Backdrop) => {
/**
* Move action buttons to the sticky area.
*/
Expand All @@ -11,4 +10,4 @@
}
};

})(jQuery);
})(Backdrop);
62 changes: 32 additions & 30 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,38 +333,40 @@ function gin_css_alter(&$css) {
* Changes vertical tabs to container.
*/
function gin_form_node_form_alter(&$form, &$form_state, $form_id) {
$form['layout_region_node_main'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('layout-region-node-main'),
),
);
$form['layout_region_node_secondary'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('layout-region-node-secondary'),
),
);
foreach (element_children($form) as $key) {
$skips = array(
'layout_region_node_main',
'layout_region_node_secondary',
if (theme_get_setting('edit_form_sidebar', 'gin')) {
$form['layout_region_node_main'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('layout-region-node-main'),
),
);
$form['layout_region_node_secondary']['additional_settings'] = $form['additional_settings'];
unset($form['additional_settings']);
if (!in_array($key, $skips)) {
if ((empty($form[$key]['#group']) || $form[$key]['#group'] != 'additional_settings')) {
$form['layout_region_node_main'][$key] = $form[$key];
unset($form[$key]);
}
elseif (!empty($form[$key]['#group']) && $form[$key]['#group'] == 'additional_settings') {
$form[$key]['#collapsed'] = TRUE;
$form['layout_region_node_secondary'][$key] = $form[$key];
unset($form[$key]);
$form['layout_region_node_secondary'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array('layout-region-node-secondary'),
),
);
foreach (element_children($form) as $key) {
$skips = array(
'layout_region_node_main',
'layout_region_node_secondary',
);
$form['layout_region_node_secondary']['additional_settings'] = $form['additional_settings'];
unset($form['additional_settings']);
if (!in_array($key, $skips)) {
if ((empty($form[$key]['#group']) || $form[$key]['#group'] != 'additional_settings')) {
$form['layout_region_node_main'][$key] = $form[$key];
unset($form[$key]);
}
elseif (!empty($form[$key]['#group']) && $form[$key]['#group'] == 'additional_settings') {
$form[$key]['#collapsed'] = TRUE;
$form['layout_region_node_secondary'][$key] = $form[$key];
unset($form[$key]);
}
}
}
$form['layout_region_node_secondary']['options']['#collapsed'] = FALSE;
$form['#attached']['css'][] = backdrop_get_path('theme', 'gin') . '/dist/css/components/edit_form.css';
$form['#attached']['js'][] = backdrop_get_path('theme', 'gin') . '/dist/js/edit_form.js';
}
$form['layout_region_node_secondary']['options']['#collapsed'] = FALSE;
$form['#attached']['css'][] = backdrop_get_path('theme', 'gin') . '/dist/css/components/edit_form.css';
$form['#attached']['js'][] = backdrop_get_path('theme', 'gin') . '/dist/js/edit_form.js';
}
8 changes: 8 additions & 0 deletions theme-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@
'#default_value' => theme_get_setting('high_contrast_mode'),
];

// Edit form sidebar.
$form['edit_form_sidebar'] = [
'#type' => 'checkbox',
'#title' => t('Sidebar on edit form') . $experimental_label,
'#description' => t('Move the vertical tabs to the sidebar on edit forms.'),
'#default_value' => theme_get_setting('edit_form_sidebar'),
];

// Toolbar setting.
// $form['classic_toolbar'] = [
// '#type' => 'radios',
Expand Down

0 comments on commit 11ad3aa

Please sign in to comment.