Skip to content

Commit 6c7aded

Browse files
committed
Fixes for rendering header
Adjustments for how modal header is built. Defaults prompt selects to form-select
1 parent c56a768 commit 6c7aded

File tree

4 files changed

+46
-42
lines changed

4 files changed

+46
-42
lines changed

bootbox.all.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
text: '<input class="bootbox-input bootbox-input-text form-control" autocomplete="off" type="text" />',
4747
textarea: '<textarea class="bootbox-input bootbox-input-textarea form-control"></textarea>',
4848
email: '<input class="bootbox-input bootbox-input-email form-control" autocomplete="off" type="email" />',
49-
select: '<select class="bootbox-input bootbox-input-select form-control"></select>',
49+
select: '<select class="bootbox-input bootbox-input-select form-select"></select>',
5050
checkbox: '<div class="form-check checkbox"><label class="form-check-label"><input class="form-check-input bootbox-input bootbox-input-checkbox" type="checkbox" /></label></div>',
5151
radio: '<div class="form-check radio"><label class="form-check-label"><input class="form-check-input bootbox-input bootbox-input-radio" type="radio" name="bootbox-radio" /></label></div>',
5252
date: '<input class="bootbox-input bootbox-input-date form-control" autocomplete="off" type="date" />',
@@ -331,29 +331,28 @@
331331
}
332332
}
333333

334-
if(options.title){
335-
header.find('.modal-title').html(options.title);
336-
}
337-
else {
338-
header.addClass('pb-0 border-0');
339-
}
334+
if(options.title || options.closeButton){
335+
if (options.title) {
336+
header.find('.modal-title').html(options.title);
337+
}
340338

341-
body.before(header);
339+
if (options.closeButton) {
340+
let closeButton = $(templates.closeButton);
341+
if (options.bootstrap < 5) {
342+
closeButton.html('&times;');
343+
}
342344

343-
if (options.closeButton) {
344-
let clsbtn = $(templates.closeButton);
345-
if (options.fullBootstrapVersion < '5.0.0') {
346-
clsbtn.html('&times;');
345+
/* Note: the close button for Bootstrap 5+ does not contain content */
346+
if(options.bootstrap < 4){
347+
/* Bootstrap 3 and under */
348+
header.prepend(closeButton);
349+
}
350+
else {
351+
header.append(closeButton);
352+
}
347353
}
348354

349-
/* Note: the close button for Bootstrap 5+ does not contain content */
350-
if(options.bootstrap < 4){
351-
dialog.find('.modal-header').append(clsbtn);
352-
}
353-
else {
354-
/* Bootstrap 3 and under */
355-
dialog.find('.modal-header').prepend(clsbtn);
356-
}
355+
body.before(header);
357356
}
358357

359358
if (options.centerVertical) {
@@ -755,6 +754,9 @@
755754

756755
// Safe to set a select's value as per a normal input
757756
input.val(options.value);
757+
if (options.bootstrap < 5) {
758+
input.removeClass('form-select').addClass('form-control');
759+
}
758760
break;
759761

760762
case 'checkbox':

bootbox.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
text: '<input class="bootbox-input bootbox-input-text form-control" autocomplete="off" type="text" />',
4747
textarea: '<textarea class="bootbox-input bootbox-input-textarea form-control"></textarea>',
4848
email: '<input class="bootbox-input bootbox-input-email form-control" autocomplete="off" type="email" />',
49-
select: '<select class="bootbox-input bootbox-input-select form-control"></select>',
49+
select: '<select class="bootbox-input bootbox-input-select form-select"></select>',
5050
checkbox: '<div class="form-check checkbox"><label class="form-check-label"><input class="form-check-input bootbox-input bootbox-input-checkbox" type="checkbox" /></label></div>',
5151
radio: '<div class="form-check radio"><label class="form-check-label"><input class="form-check-input bootbox-input bootbox-input-radio" type="radio" name="bootbox-radio" /></label></div>',
5252
date: '<input class="bootbox-input bootbox-input-date form-control" autocomplete="off" type="date" />',
@@ -331,29 +331,28 @@
331331
}
332332
}
333333

334-
if(options.title){
335-
header.find('.modal-title').html(options.title);
336-
}
337-
else {
338-
header.addClass('pb-0 border-0');
339-
}
334+
if(options.title || options.closeButton){
335+
if (options.title) {
336+
header.find('.modal-title').html(options.title);
337+
}
340338

341-
body.before(header);
339+
if (options.closeButton) {
340+
let closeButton = $(templates.closeButton);
341+
if (options.bootstrap < 5) {
342+
closeButton.html('&times;');
343+
}
342344

343-
if (options.closeButton) {
344-
let clsbtn = $(templates.closeButton);
345-
if (options.fullBootstrapVersion < '5.0.0') {
346-
clsbtn.html('&times;');
345+
/* Note: the close button for Bootstrap 5+ does not contain content */
346+
if(options.bootstrap < 4){
347+
/* Bootstrap 3 and under */
348+
header.prepend(closeButton);
349+
}
350+
else {
351+
header.append(closeButton);
352+
}
347353
}
348354

349-
/* Note: the close button for Bootstrap 5+ does not contain content */
350-
if(options.bootstrap > 3){
351-
dialog.find('.modal-header').append(clsbtn);
352-
}
353-
else {
354-
/* Bootstrap 3 and under */
355-
dialog.find('.modal-header').prepend(clsbtn);
356-
}
355+
body.before(header);
357356
}
358357

359358
if (options.centerVertical) {
@@ -755,6 +754,9 @@
755754

756755
// Safe to set a select's value as per a normal input
757756
input.val(options.value);
757+
if (options.bootstrap < 5) {
758+
input.removeClass('form-select').addClass('form-control');
759+
}
758760
break;
759761

760762
case 'checkbox':

0 commit comments

Comments
 (0)