').hide();
$('body').prepend(this.$modalOverlay);
if (this.opts.blur)
{
this.blurredElements = $('body').children('div, section, header, article, pre, aside, table').not('.modal, .modal-box, #modal-overlay');
this.blurredElements.addClass('modal-blur');
}
},
show: function()
{
// modal loading callback
this.setCallback('loading', this.$modal);
this.bodyOveflow = $(document.body).css('overflow');
$(document.body).css('overflow', 'hidden');
if (this.isMobile())
{
this.showOnMobile();
}
else
{
this.showOnDesktop();
}
this.$modalOverlay.show();
this.$modalBox.show();
this.setButtonsWidth();
// resize
if (!this.isMobile())
{
setTimeout($.proxy(this.showOnDesktop, this), 0);
$(window).on('resize.tools.modal', $.proxy(this.resize, this));
}
// modal shown callback
this.setCallback('opened', this.$modal);
// fix bootstrap modal focus
$(document).off('focusin.modal');
},
showOnDesktop: function()
{
var height = this.$modal.outerHeight();
var windowHeight = $(window).height();
var windowWidth = $(window).width();
if (this.opts.width > windowWidth)
{
this.$modal.css({
width: '96%',
marginTop: (windowHeight/2 - height/2) + 'px'
});
return;
}
if (height > windowHeight)
{
this.$modal.css({
width: this.opts.width + 'px',
marginTop: '20px'
});
}
else
{
this.$modal.css({
width: this.opts.width + 'px',
marginTop: (windowHeight/2 - height/2) + 'px'
});
}
},
showOnMobile: function()
{
this.$modal.css({
width: '96%',
marginTop: '2%'
});
},
resize: function()
{
if (this.isMobile())
{
this.showOnMobile();
}
else
{
this.showOnDesktop();
}
},
setTitle: function()
{
this.$modalHeader.html(this.opts.title);
},
setContent: function()
{
if (typeof this.opts.content == 'object' || this.opts.content.search('#') === 0)
{
this.type = 'html';
this.$modalBody.html($(this.opts.content).html());
this.show();
}
else
{
$.ajax({
url: this.opts.content,
cache: false,
success: $.proxy(function(data)
{
this.$modalBody.html(data);
this.show();
}, this)
});
}
},
setDraggable: function()
{
if (typeof $.fn.draggable === 'undefined') return;
this.$modal.draggable({ handle: this.$modalHeader });
this.$modalHeader.css('cursor', 'move');
},
createCancelButton: function(label)
{
if (typeof label == 'undefined') label = 'Cancel';
var button = $('