Skip to content

Commit

Permalink
Merge pull request #38 from codehead/bootstrap4-dev
Browse files Browse the repository at this point in the history
Added support for Bootstrap 5.1.0.
  • Loading branch information
GedMarc authored Aug 25, 2021
2 parents 324baf1 + b99c82a commit 473a349
Show file tree
Hide file tree
Showing 25 changed files with 4,214 additions and 3,879 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"return": "returns"
}
}],
"quotes": [1, "single", "allow-avoiding-escaped-quotes"],
"quotes": [1, "single", { "avoidEscape": true }],
"wrap-iife": 2
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ bootstrap4-dialog

[![Latest release](https://img.shields.io/github/release/GedMarc/bootstrap4-dialog.svg)](https://github.com/GedMarc/bootstrap4-dialog/releases/latest)

## Fully compatible with Bootstrap 4.3.1
## Fully compatible with Bootstrap 5.1.0
## Includes size-extrawide full width display
## Includes all colour themes from Bootstrap 4
## Includes all colour themes from Bootstrap 4 & 5

Make use of Bootstrap Modal more monkey-friendly.

Expand Down
120 changes: 41 additions & 79 deletions dist/css/bootstrap-dialog.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dist/css/bootstrap-dialog.css.map

This file was deleted.

2 changes: 1 addition & 1 deletion dist/css/bootstrap-dialog.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 31 additions & 12 deletions dist/js/bootstrap-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,21 @@
* Extend Bootstrap Modal and override some functions.
* BootstrapDialogModal === Modified Modal.
* ================================================ */
var Modal = $.fn.modal.Constructor;
var Modal = bootstrap.Modal ? bootstrap.Modal : $.fn.modal.Constructor;
var BootstrapDialogModal = function (element, options) {
if (/4\.1\.\d+/.test($.fn.modal.Constructor.VERSION)) { //FIXME for BootstrapV4
if(bootstrap && bootstrap.Modal && /^5\.1\./.test(bootstrap.Modal.VERSION)) {
return new Modal(element, options);
} else if (/4\.1\.\d+/.test($.fn.modal.Constructor.VERSION)) { //FIXME for BootstrapV4
return new Modal(element, options);
} else {
Modal.call(this, element, options);
}
};
BootstrapDialogModal.getModalVersion = function () {
var version = null;
if (typeof $.fn.modal.Constructor.VERSION === 'undefined') {
if(bootstrap && bootstrap.Modal && /^5\.1\./.test(bootstrap.Modal.VERSION)) {
version = 'v5.1';
} else if (typeof $.fn.modal.Constructor.VERSION === 'undefined') {
version = 'v3.1';
} else if (/3\.2\.\d+/.test($.fn.modal.Constructor.VERSION)) {
version = 'v3.2';
Expand Down Expand Up @@ -146,6 +150,7 @@
};
BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']);
BootstrapDialogModal.METHODS_TO_OVERRIDE['v4.1'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']); //FIXME for BootstrapV4
BootstrapDialogModal.METHODS_TO_OVERRIDE['v5.1'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v4.1']); //FIXME for BootstrapV5
BootstrapDialogModal.prototype = {
constructor: BootstrapDialogModal,
/**
Expand Down Expand Up @@ -231,7 +236,7 @@
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_SMALL] = 'btn-small';
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_WIDE] = 'btn-block';
BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE] = 'btn-lg';
BootstrapDialog.ICON_SPINNER = 'glyphicon glyphicon-asterisk';
BootstrapDialog.ICON_SPINNER = 'fas fa-spinner';
BootstrapDialog.BUTTONS_ORDER_CANCEL_OK = 'btns-order-cancel-ok';
BootstrapDialog.BUTTONS_ORDER_OK_CANCEL = 'btns-order-ok-cancel';
BootstrapDialog.Z_INDEX_BACKDROP = 1040;
Expand Down Expand Up @@ -391,6 +396,20 @@
return this.getModal().get(0);
}
};
BootstrapDialog.METHODS_TO_OVERRIDE['v5.1'] = $.extend({}, BootstrapDialog.METHODS_TO_OVERRIDE['v4.1'], {
createCloseButton: function () {
var $container = $('<div></div>');
$container.addClass(this.getNamespace('close-button'));
var $icon = $('<button class="btn-close" aria-label="close"></button>');
// $icon.append(this.options.closeIcon);
$container.append($icon);
$container.on('click', { dialog: this }, function (event) {
event.data.dialog.close();
});

return $container;
},
});
BootstrapDialog.prototype = {
constructor: BootstrapDialog,
initOptions: function (options) {
Expand Down Expand Up @@ -548,14 +567,14 @@
updateType: function () {
if (this.isRealized()) {
var types = [BootstrapDialog.TYPE_DEFAULT,
BootstrapDialog.TYPE_INFO,
BootstrapDialog.TYPE_PRIMARY,
BootstrapDialog.TYPE_SECONDARY,
BootstrapDialog.TYPE_SUCCESS,
BootstrapDialog.TYPE_WARNING,
BootstrapDialog.TYPE_DARK,
BootstrapDialog.TYPE_LIGHT,
BootstrapDialog.TYPE_DANGER];
BootstrapDialog.TYPE_INFO,
BootstrapDialog.TYPE_PRIMARY,
BootstrapDialog.TYPE_SECONDARY,
BootstrapDialog.TYPE_SUCCESS,
BootstrapDialog.TYPE_WARNING,
BootstrapDialog.TYPE_DARK,
BootstrapDialog.TYPE_LIGHT,
BootstrapDialog.TYPE_DANGER];

this.getModal().removeClass(types.join(' ')).addClass(this.getType());
}
Expand Down
2 changes: 1 addition & 1 deletion dist/js/bootstrap-dialog.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 473a349

Please sign in to comment.