Skip to content

Commit 9632a76

Browse files
authored
Merge pull request #34 from bugfolder/33_vertical_tab_summaries
Issue #33: Add vertical tab summaries to settings page.
2 parents 61dc73a + 9917ebc commit 9632a76

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

js/theme-settings.js

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
(function ($, Backdrop) {
2+
/*global jQuery:false */
3+
/*global Backdrop:false */
4+
"use strict";
5+
6+
/**
7+
* Provide vertical tab summaries for Bootstrap 5 settings.
8+
*/
9+
Backdrop.behaviors.bootstrap5LiteSettingSummaries = {
10+
attach: function (context) {
11+
var $context = $(context);
12+
13+
// Version and CDN
14+
15+
$context.find('#edit-bootstrap5-lite-cdn').backdropSetSummary(function () {
16+
var summary = [];
17+
var bootstrap_version = 'Bootstrap: ' + $context.find('select[name="bootstrap5_lite_cdn"] :selected').text();
18+
summary.push(bootstrap_version);
19+
return summary.join('<br>');
20+
});
21+
22+
// Bootswatch theme
23+
24+
$context.find('#edit-bootswatch').backdropSetSummary(function () {
25+
var bootswatch = $context.find('#edit-bootswatch input[checked="checked"]').parent().find('h3').text();
26+
if (bootswatch == '') {
27+
bootswatch = Backdrop.t('Default');
28+
}
29+
return bootswatch;
30+
});
31+
32+
// Navbar
33+
34+
$context.find('#edit-navbar').backdropSetSummary(function () {
35+
var summary = [];
36+
var navbar_position = 'Position: ' + $context.find('select[name="bootstrap5_lite_navbar_position"] :selected').text();
37+
summary.push(navbar_position);
38+
var menu_position = 'Menu position: ' + $context.find('select[name="bootstrap5_lite_navbar_menu_position"] :selected').text();
39+
summary.push(menu_position);
40+
if ($context.find(':input[name="bootstrap5_lite_navbar_inverse"]').is(':checked')) {
41+
summary.push(Backdrop.t('Inverse navbar'));
42+
}
43+
if ($context.find(':input[name="bootstrap5_lite_navbar_user_menu"]').is(':checked')) {
44+
summary.push(Backdrop.t('Cog style'));
45+
}
46+
return summary.join('<br>');
47+
});
48+
49+
// Breadcrumbs
50+
51+
$context.find('#edit-breadcrumbs').backdropSetSummary(function () {
52+
var summary = [];
53+
if ($context.find(':input[name="bootstrap5_lite_breadcrumb_home"]').is(':checked')) {
54+
summary.push(Backdrop.t('Show home'));
55+
}
56+
if ($context.find(':input[name="bootstrap5_lite_breadcrumb_title"]').is(':checked')) {
57+
summary.push(Backdrop.t('Show current page'));
58+
}
59+
return summary.join('<br>');
60+
});
61+
62+
// Tweaks
63+
64+
$context.find('#edit-tweaks').backdropSetSummary(function () {
65+
var summary = [];
66+
var container_type = 'Container type: ' + $context.find('select[name="bootstrap5_lite_container"] :selected').text();
67+
summary.push(container_type);
68+
if ($context.find(':input[name="bootstrap5_lite_datetime"]').is(':checked')) {
69+
summary.push(Backdrop.t('Show "XX time ago"'));
70+
}
71+
if ($context.find(':input[name="bootstrap5_lite_image_responsive"]').is(':checked')) {
72+
summary.push(Backdrop.t('Responsive images'));
73+
}
74+
return summary.join('<br>');
75+
});
76+
77+
}
78+
};
79+
80+
})(jQuery, Backdrop);

theme-settings.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ function bootstrap5_lite_form_system_theme_settings_alter(&$form, &$form_state,
1414
$theme_name = $form['theme']['#value'];
1515
$form['bootstrap'] = array(
1616
'#type' => 'vertical_tabs',
17+
'#attached' => array(
18+
'js' => array(backdrop_get_path('theme', 'bootstrap5_lite') . '/js/theme-settings.js'),
19+
),
1720
'#prefix' => '<h2><small>' . t('Bootstrap Settings') . '</small></h2>',
1821
'#weight' => -10,
1922
);

0 commit comments

Comments
 (0)