Skip to content
This repository was archived by the owner on Nov 19, 2023. It is now read-only.

Commit b840b3e

Browse files
committed
Update bootstrapDialog for Bootstrap version 4.0.
1 parent 49b786d commit b840b3e

File tree

3 files changed

+57
-9
lines changed

3 files changed

+57
-9
lines changed

dist/js/bootstrap-dialog.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@
3939
* BootstrapDialogModal === Modified Modal.
4040
* ================================================ */
4141
var Modal = $.fn.modal.Constructor;
42-
var BootstrapDialogModal = function (element, options) {
43-
Modal.call(this, element, options);
42+
var BootstrapDialogModal = function(element, options) {
43+
if (/4\.0\.\d+/.test($.fn.modal.Constructor.VERSION)) {
44+
return new Modal(element, options);
45+
} else {
46+
Modal.call(this, element, options);
47+
}
4448
};
4549
BootstrapDialogModal.getModalVersion = function () {
4650
var version = null;
@@ -50,6 +54,8 @@
5054
version = 'v3.2';
5155
} else if (/3\.3\.[1,2]/.test($.fn.modal.Constructor.VERSION)) {
5256
version = 'v3.3'; // v3.3.1, v3.3.2
57+
} else if (/4\.0\.\d+/.test($.fn.modal.Constructor.VERSION)) {
58+
version = 'v4.0';
5359
} else {
5460
version = 'v3.3.4';
5561
}
@@ -139,6 +145,7 @@
139145
}
140146
};
141147
BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']);
148+
BootstrapDialogModal.METHODS_TO_OVERRIDE['v4.0'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']);
142149
BootstrapDialogModal.prototype = {
143150
constructor: BootstrapDialogModal,
144151
/**
@@ -338,7 +345,7 @@
338345
}
339346
});
340347
var $modal = this.getModal();
341-
var $backdrop = $modal.data('bs.modal').$backdrop;
348+
var $backdrop = this.getModalBackdrop($modal);
342349
$modal.css('z-index', zIndexModal + (dialogCount - 1) * 20);
343350
$backdrop.css('z-index', zIndexBackdrop + (dialogCount - 1) * 20);
344351
}
@@ -360,6 +367,17 @@
360367
};
361368
BootstrapDialog.METHODS_TO_OVERRIDE['v3.3'] = {};
362369
BootstrapDialog.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']);
370+
BootstrapDialog.METHODS_TO_OVERRIDE['v4.0'] = {
371+
getModalBackdrop: function ($modal) {
372+
return $($modal.data('bs.modal')._backdrop);
373+
},
374+
handleModalBackdropEvent: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['handleModalBackdropEvent'],
375+
updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'],
376+
open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'],
377+
getModalForBootstrapDialogModal : function () {
378+
return this.getModal().get(0);
379+
}
380+
};
363381
BootstrapDialog.prototype = {
364382
constructor: BootstrapDialog,
365383
initOptions: function (options) {
@@ -404,6 +422,12 @@
404422

405423
return this;
406424
},
425+
getModalBackdrop: function ($modal) {
426+
return $modal.data('bs.modal').$backdrop;
427+
},
428+
getModalForBootstrapDialogModal: function () {
429+
return this.getModal();
430+
},
407431
createModalDialog: function () {
408432
return $('<div class="modal-dialog"></div>');
409433
},
@@ -1129,7 +1153,7 @@
11291153
this.getModalFooter().append(this.createFooterContent());
11301154
this.getModalHeader().append(this.createHeaderContent());
11311155
this.getModalBody().append(this.createBodyContent());
1132-
this.getModal().data('bs.modal', new BootstrapDialogModal(this.getModal(), {
1156+
this.getModal().data('bs.modal', new BootstrapDialogModal(this.getModalForBootstrapDialogModal(), {
11331157
backdrop: 'static',
11341158
keyboard: false,
11351159
show: false

0 commit comments

Comments
 (0)