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

Commit 0b645f6

Browse files
committed
Merge pull request nakupanda#281
From: avan06/bootstrap3-dialog Changed: - [b840b3e] Update bootstrapDialog for Bootstrap version 4.0. - [fc5a30b] FIXME for BootstrapV4.X
1 parent 54dc55b commit 0b645f6

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

src/js/bootstrap-dialog.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
* ================================================ */
4141
var Modal = $.fn.modal.Constructor;
4242
var BootstrapDialogModal = function (element, options) {
43-
Modal.call(this, element, options);
43+
if (/4\.\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\.\d+/.test($.fn.modal.Constructor.VERSION)) {
58+
version = 'v4.0';
5359
} else {
5460
version = 'v3.3.4';
5561
}
@@ -141,6 +147,7 @@
141147
}
142148
};
143149
BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']);
150+
BootstrapDialogModal.METHODS_TO_OVERRIDE['v4.0'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']);
144151
BootstrapDialogModal.prototype = {
145152
constructor: BootstrapDialogModal,
146153
/**
@@ -343,7 +350,7 @@
343350
}
344351
});
345352
var $modal = this.getModal();
346-
var $backdrop = $modal.data('bs.modal').$backdrop;
353+
var $backdrop = this.getModalBackdrop($modal);
347354
$modal.css('z-index', zIndexModal + (dialogCount - 1) * 20);
348355
$backdrop.css('z-index', zIndexBackdrop + (dialogCount - 1) * 20);
349356
}
@@ -365,6 +372,17 @@
365372
};
366373
BootstrapDialog.METHODS_TO_OVERRIDE['v3.3'] = {};
367374
BootstrapDialog.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']);
375+
BootstrapDialog.METHODS_TO_OVERRIDE['v4.0'] = {
376+
getModalBackdrop: function ($modal) {
377+
return $($modal.data('bs.modal')._backdrop);
378+
},
379+
handleModalBackdropEvent: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['handleModalBackdropEvent'],
380+
updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'],
381+
open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'],
382+
getModalForBootstrapDialogModal: function () {
383+
return this.getModal().get(0);
384+
}
385+
};
368386
BootstrapDialog.prototype = {
369387
constructor: BootstrapDialog,
370388
initOptions: function (options) {
@@ -409,6 +427,12 @@
409427

410428
return this;
411429
},
430+
getModalBackdrop: function ($modal) {
431+
return $modal.data('bs.modal').$backdrop;
432+
},
433+
getModalForBootstrapDialogModal: function () {
434+
return this.getModal();
435+
},
412436
createModalDialog: function () {
413437
return $('<div class="modal-dialog"></div>');
414438
},
@@ -1157,7 +1181,7 @@
11571181
this.getModalFooter().append(this.createFooterContent());
11581182
this.getModalHeader().append(this.createHeaderContent());
11591183
this.getModalBody().append(this.createBodyContent());
1160-
this.getModal().data('bs.modal', new BootstrapDialogModal(this.getModal(), {
1184+
this.getModal().data('bs.modal', new BootstrapDialogModal(this.getModalForBootstrapDialogModal(), {
11611185
backdrop: 'static',
11621186
keyboard: false,
11631187
show: false

0 commit comments

Comments
 (0)