Copy multi-modal.js from the admin panel (#334)

This commit is contained in:
Kevin Chung
2017-08-06 19:45:20 -04:00
committed by GitHub
parent 7aa6204116
commit c12544e87b

View File

@@ -3,7 +3,6 @@
var MultiModal = function(element) { var MultiModal = function(element) {
this.$element = $(element); this.$element = $(element);
this.modalCount = 0;
}; };
MultiModal.BASE_ZINDEX = 1040; MultiModal.BASE_ZINDEX = 1040;
@@ -11,30 +10,32 @@
MultiModal.prototype.show = function(target) { MultiModal.prototype.show = function(target) {
var that = this; var that = this;
var $target = $(target); var $target = $(target);
var modalIndex = that.modalCount++; var modalCount = $('.modal:visible').length;
$target.css('z-index', MultiModal.BASE_ZINDEX + (modalIndex * 20) + 10); $target.css('z-index', MultiModal.BASE_ZINDEX + (modalCount * 20) + 10);
window.setTimeout(function() { window.setTimeout(function() {
if(modalIndex > 0) var modalCount = $('.modal:visible').length;
if(modalCount > 0)
$('.modal-backdrop').not(':first').addClass('hidden'); $('.modal-backdrop').not(':first').addClass('hidden');
that.adjustBackdrop(); that.adjustBackdrop(modalCount);
}); });
}; };
MultiModal.prototype.hidden = function(target) { MultiModal.prototype.hidden = function(target) {
this.modalCount--; var modalCount = $('.modal:visible').length;
if(this.modalCount) { var $target = $(target);
this.adjustBackdrop();
if(modalCount) {
this.adjustBackdrop(modalCount - 1);
$('body').addClass('modal-open'); $('body').addClass('modal-open');
} }
}; };
MultiModal.prototype.adjustBackdrop = function() { MultiModal.prototype.adjustBackdrop = function(modalCount) {
var modalIndex = this.modalCount - 1; $('.modal-backdrop:first').css('z-index', MultiModal.BASE_ZINDEX + ((modalCount)* 20));
$('.modal-backdrop:first').css('z-index', MultiModal.BASE_ZINDEX + (modalIndex * 20));
}; };
function Plugin(method, target) { function Plugin(method, target) {