mirror of
https://github.com/aljazceru/CTFd.git
synced 2026-02-22 06:34:34 +01:00
64 lines
1.7 KiB
JavaScript
64 lines
1.7 KiB
JavaScript
(function($, window) {
|
|
'use strict';
|
|
|
|
var MultiModal = function(element) {
|
|
this.$element = $(element);
|
|
this.modalCount = 0;
|
|
};
|
|
|
|
MultiModal.BASE_ZINDEX = 1040;
|
|
|
|
MultiModal.prototype.show = function(target) {
|
|
var that = this;
|
|
var $target = $(target);
|
|
var modalIndex = that.modalCount++;
|
|
|
|
$target.css('z-index', MultiModal.BASE_ZINDEX + (modalIndex * 20) + 10);
|
|
|
|
window.setTimeout(function() {
|
|
if(modalIndex > 0)
|
|
$('.modal-backdrop').not(':first').addClass('hidden');
|
|
|
|
that.adjustBackdrop();
|
|
});
|
|
};
|
|
|
|
MultiModal.prototype.hidden = function(target) {
|
|
this.modalCount--;
|
|
|
|
if(this.modalCount) {
|
|
this.adjustBackdrop();
|
|
$('body').addClass('modal-open');
|
|
}
|
|
};
|
|
|
|
MultiModal.prototype.adjustBackdrop = function() {
|
|
var modalIndex = this.modalCount - 1;
|
|
$('.modal-backdrop:first').css('z-index', MultiModal.BASE_ZINDEX + (modalIndex * 20));
|
|
};
|
|
|
|
function Plugin(method, target) {
|
|
return this.each(function() {
|
|
var $this = $(this);
|
|
var data = $this.data('multi-modal-plugin');
|
|
|
|
if(!data)
|
|
$this.data('multi-modal-plugin', (data = new MultiModal(this)));
|
|
|
|
if(method)
|
|
data[method](target);
|
|
});
|
|
}
|
|
|
|
$.fn.multiModal = Plugin;
|
|
$.fn.multiModal.Constructor = MultiModal;
|
|
|
|
$(document).on('show.bs.modal', function(e) {
|
|
$(document).multiModal('show', e.target);
|
|
});
|
|
|
|
$(document).on('hidden.bs.modal', function(e) {
|
|
$(document).multiModal('hidden', e.target);
|
|
});
|
|
}(jQuery, window));
|