Skip to content

Commit

Permalink
refs #5
Browse files Browse the repository at this point in the history
Make stacked dialogs look better.
  • Loading branch information
nakupanda committed Jun 17, 2014
1 parent 1260702 commit f718f12
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 3 deletions.
18 changes: 18 additions & 0 deletions dist/js/bootstrap-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@

BootstrapDialog.ICON_SPINNER = 'glyphicon glyphicon-asterisk';

BootstrapDialog.ZINDEX_BACKDROP = 1040;
BootstrapDialog.ZINDEX_MODAL = 1050;

/**
* Default options.
*/
Expand Down Expand Up @@ -731,6 +734,20 @@
showPageScrollBar: function(show) {
$(document.body).toggleClass('modal-open', show);
},
/**
* To make multiple opened dialogs look better.
*/
updateZIndex: function() {
var dialogCount = Object.keys(BootstrapDialog.dialogs).length;
if (dialogCount > 1) {
var $modal = this.getModal();
var $backdrop = $modal.data('bs.modal').$backdrop;
$modal.css('z-index', BootstrapDialog.ZINDEX_MODAL + (dialogCount - 1) * 20);
$backdrop.css('z-index', BootstrapDialog.ZINDEX_BACKDROP + (dialogCount - 1) * 20);
}

return this;
},
realize: function() {
this.initModalStuff();
this.getModal().addClass(BootstrapDialog.NAMESPACE)
Expand Down Expand Up @@ -758,6 +775,7 @@
open: function() {
!this.isRealized() && this.realize();
this.getModal().modal('show');
this.updateZIndex();
this.setOpened(true);

return this;
Expand Down
2 changes: 1 addition & 1 deletion dist/js/bootstrap-dialog.min.js

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions examples/assets/bootstrap-dialog/js/bootstrap-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@

BootstrapDialog.ICON_SPINNER = 'glyphicon glyphicon-asterisk';

BootstrapDialog.ZINDEX_BACKDROP = 1040;
BootstrapDialog.ZINDEX_MODAL = 1050;

/**
* Default options.
*/
Expand Down Expand Up @@ -731,6 +734,20 @@
showPageScrollBar: function(show) {
$(document.body).toggleClass('modal-open', show);
},
/**
* To make multiple opened dialogs look better.
*/
updateZIndex: function() {
var dialogCount = Object.keys(BootstrapDialog.dialogs).length;
if (dialogCount > 1) {
var $modal = this.getModal();
var $backdrop = $modal.data('bs.modal').$backdrop;
$modal.css('z-index', BootstrapDialog.ZINDEX_MODAL + (dialogCount - 1) * 20);
$backdrop.css('z-index', BootstrapDialog.ZINDEX_BACKDROP + (dialogCount - 1) * 20);
}

return this;
},
realize: function() {
this.initModalStuff();
this.getModal().addClass(BootstrapDialog.NAMESPACE)
Expand Down Expand Up @@ -758,6 +775,7 @@
open: function() {
!this.isRealized() && this.realize();
this.getModal().modal('show');
this.updateZIndex();
this.setOpened(true);

return this;
Expand Down

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions js/bootstrap-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@

BootstrapDialog.ICON_SPINNER = 'glyphicon glyphicon-asterisk';

BootstrapDialog.ZINDEX_BACKDROP = 1040;
BootstrapDialog.ZINDEX_MODAL = 1050;

/**
* Default options.
*/
Expand Down Expand Up @@ -731,6 +734,20 @@
showPageScrollBar: function(show) {
$(document.body).toggleClass('modal-open', show);
},
/**
* To make multiple opened dialogs look better.
*/
updateZIndex: function() {
var dialogCount = Object.keys(BootstrapDialog.dialogs).length;
if (dialogCount > 1) {
var $modal = this.getModal();
var $backdrop = $modal.data('bs.modal').$backdrop;
$modal.css('z-index', BootstrapDialog.ZINDEX_MODAL + (dialogCount - 1) * 20);
$backdrop.css('z-index', BootstrapDialog.ZINDEX_BACKDROP + (dialogCount - 1) * 20);
}

return this;
},
realize: function() {
this.initModalStuff();
this.getModal().addClass(BootstrapDialog.NAMESPACE)
Expand Down Expand Up @@ -758,6 +775,7 @@
open: function() {
!this.isRealized() && this.realize();
this.getModal().modal('show');
this.updateZIndex();
this.setOpened(true);

return this;
Expand Down
2 changes: 1 addition & 1 deletion js/bootstrap-dialog.min.js

Large diffs are not rendered by default.

0 comments on commit f718f12

Please sign in to comment.