Skip to content

Commit 11ad3aa

Browse files
committed
Issue #54: Set up edit sidebar as a theme setting option.
1 parent 307e52e commit 11ad3aa

File tree

4 files changed

+49
-40
lines changed

4 files changed

+49
-40
lines changed

dist/js/edit_form.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var $;
2-
3-
$ = jQuery, Backdrop.behaviors.ginEditForm = {
4-
attach: function(context, settings) {
5-
$(".block-page-title-block").append($(".form-actions")), $(".form-actions input").attr("form", $(".node-form").attr("id"));
6-
}
7-
};
1+
(Backdrop => {
2+
Backdrop.behaviors.ginEditForm = {
3+
attach: function(context, settings) {
4+
$(".block-page-title-block").append($(".form-actions")), $(".form-actions input").attr("form", $(".node-form").attr("id"));
5+
}
6+
};
7+
})(Backdrop);

js/edit_form.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
(function ($) {
2-
1+
((Backdrop) => {
32
/**
43
* Move action buttons to the sticky area.
54
*/
@@ -11,4 +10,4 @@
1110
}
1211
};
1312

14-
})(jQuery);
13+
})(Backdrop);

template.php

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -333,38 +333,40 @@ function gin_css_alter(&$css) {
333333
* Changes vertical tabs to container.
334334
*/
335335
function gin_form_node_form_alter(&$form, &$form_state, $form_id) {
336-
$form['layout_region_node_main'] = array(
337-
'#type' => 'container',
338-
'#attributes' => array(
339-
'class' => array('layout-region-node-main'),
340-
),
341-
);
342-
$form['layout_region_node_secondary'] = array(
343-
'#type' => 'container',
344-
'#attributes' => array(
345-
'class' => array('layout-region-node-secondary'),
346-
),
347-
);
348-
foreach (element_children($form) as $key) {
349-
$skips = array(
350-
'layout_region_node_main',
351-
'layout_region_node_secondary',
336+
if (theme_get_setting('edit_form_sidebar', 'gin')) {
337+
$form['layout_region_node_main'] = array(
338+
'#type' => 'container',
339+
'#attributes' => array(
340+
'class' => array('layout-region-node-main'),
341+
),
352342
);
353-
$form['layout_region_node_secondary']['additional_settings'] = $form['additional_settings'];
354-
unset($form['additional_settings']);
355-
if (!in_array($key, $skips)) {
356-
if ((empty($form[$key]['#group']) || $form[$key]['#group'] != 'additional_settings')) {
357-
$form['layout_region_node_main'][$key] = $form[$key];
358-
unset($form[$key]);
359-
}
360-
elseif (!empty($form[$key]['#group']) && $form[$key]['#group'] == 'additional_settings') {
361-
$form[$key]['#collapsed'] = TRUE;
362-
$form['layout_region_node_secondary'][$key] = $form[$key];
363-
unset($form[$key]);
343+
$form['layout_region_node_secondary'] = array(
344+
'#type' => 'container',
345+
'#attributes' => array(
346+
'class' => array('layout-region-node-secondary'),
347+
),
348+
);
349+
foreach (element_children($form) as $key) {
350+
$skips = array(
351+
'layout_region_node_main',
352+
'layout_region_node_secondary',
353+
);
354+
$form['layout_region_node_secondary']['additional_settings'] = $form['additional_settings'];
355+
unset($form['additional_settings']);
356+
if (!in_array($key, $skips)) {
357+
if ((empty($form[$key]['#group']) || $form[$key]['#group'] != 'additional_settings')) {
358+
$form['layout_region_node_main'][$key] = $form[$key];
359+
unset($form[$key]);
360+
}
361+
elseif (!empty($form[$key]['#group']) && $form[$key]['#group'] == 'additional_settings') {
362+
$form[$key]['#collapsed'] = TRUE;
363+
$form['layout_region_node_secondary'][$key] = $form[$key];
364+
unset($form[$key]);
365+
}
364366
}
365367
}
368+
$form['layout_region_node_secondary']['options']['#collapsed'] = FALSE;
369+
$form['#attached']['css'][] = backdrop_get_path('theme', 'gin') . '/dist/css/components/edit_form.css';
370+
$form['#attached']['js'][] = backdrop_get_path('theme', 'gin') . '/dist/js/edit_form.js';
366371
}
367-
$form['layout_region_node_secondary']['options']['#collapsed'] = FALSE;
368-
$form['#attached']['css'][] = backdrop_get_path('theme', 'gin') . '/dist/css/components/edit_form.css';
369-
$form['#attached']['js'][] = backdrop_get_path('theme', 'gin') . '/dist/js/edit_form.js';
370372
}

theme-settings.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@
139139
'#default_value' => theme_get_setting('high_contrast_mode'),
140140
];
141141

142+
// Edit form sidebar.
143+
$form['edit_form_sidebar'] = [
144+
'#type' => 'checkbox',
145+
'#title' => t('Sidebar on edit form') . $experimental_label,
146+
'#description' => t('Move the vertical tabs to the sidebar on edit forms.'),
147+
'#default_value' => theme_get_setting('edit_form_sidebar'),
148+
];
149+
142150
// Toolbar setting.
143151
// $form['classic_toolbar'] = [
144152
// '#type' => 'radios',

0 commit comments

Comments
 (0)