').attr('class', 'blur-overlay-content');
this.$content.append(this.options.content);
this.$content.hide();
},
_initOverlay: function _initOverlay() {
this.$overlay = $('
').attr('class', 'blur-overlay-overlay');
this.$overlay.css({
'z-index': this.options.zIndex,
'background-color': this.options.backgroundColor,
opacity: 0,
'-webkit-transition': 'opacity ' + this.transition,
transition: 'opacity ' + this.transition
});
this.$overlay.appendTo('body');
this.$overlay.append(this.$content);
},
_initEvents: function _initEvents() {
var _this = this;
this.$overlay.on('transitionend webkitTransitionEnd', function () {
if (!_this.showing) {
_this._afterHide();
} else {
_this._afterShow();
}
});
},
_applyWrapper: function _applyWrapper() {
if (this.options.noFilter) return;
this.element.wrapAll(this.$wrapper);
this.$wrapper = this.element.closest('.blur-overlay-wrapper').first();
},
_blurWrapper: function _blurWrapper() {
if (this.options.noFilter) return;
this.$wrapper.css({
'-webkit-filter': 'blur(' + this.options.blurAmount + ')',
filter: 'blur(' + this.options.blurAmount + ')'
});
},
_unblurWrapper: function _unblurWrapper() {
if (this.options.noFilter) return;
this.$wrapper.css({
'-webkit-filter': 'blur(0px)',
filter: 'blur(0px)'
});
},
_removeWrapper: function _removeWrapper() {
if (this.options.noFilter) return;
this.element.unwrap('.blur-overlay-wrapper');
},
_showOverlay: function _showOverlay() {
this.$overlay.css({
position: 'fixed',
top: 0,
bottom: 0,
left: 0,
right: 0,
opacity: 1
});
},
_hideOverlay: function _hideOverlay() {
this.$overlay.css({
opacity: 0
});
},
_addMasks: function _addMasks() {
var _this2 = this;
this.masks = [];
this.options.masks.forEach(function (config) {
var $contentToMask = $(config.selector);
var contentOffset = $contentToMask.offset();
var $mask = $('
').attr('class', 'blur-overlay-mask');
$mask.css({
width: config.width || $contentToMask.width(),
height: config.height || $contentToMask.height(),
position: 'fixed',
top: contentOffset.top - window.pageYOffset,
left: contentOffset.left - window.pageXOffset,
opacity: 0,
transition: 'opacity ' + _this2.transition,
'z-index': _this2.options.zIndex,
'background-color': config.color || MASK_DEFAULTS.color
});
$contentToMask.after($mask);
_this2.masks.push({
config: config,
$mask: $mask
});
});
},
_showMasks: function _showMasks() {
this.masks.forEach(function (mask) {
mask.$mask.css({
opacity: mask.config.opacity || MASK_DEFAULTS.opacity
});
});
},
_hideMasks: function _hideMasks() {
this.masks.forEach(function (mask) {
mask.$mask.css({
opacity: 0
});
});
},
_removeMasks: function _removeMasks() {
this.masks.forEach(function (mask) {
mask.$mask.remove();
});
this.masks = [];
},
_beforeShow: function _beforeShow() {
var _this3 = this;
this.element.trigger($.Event('blurOverlay.beforeShow'));
$('body').css('overflow', 'hidden');
this._applyWrapper();
this._addMasks();
setTimeout(function () {
_this3._blurWrapper();
_this3._showOverlay();
_this3._showMasks();
_this3.$content.show();
}, 0);
},
_afterShow: function _afterShow() {
this.element.trigger($.Event('blurOverlay.show'));
this.showDeferred.resolve(true);
},
_beforeHide: function _beforeHide() {
var _this4 = this;
this.element.trigger($.Event('blurOverlay.beforeHide'));
$('body').css('overflow', 'auto');
setTimeout(function () {
_this4._unblurWrapper();
_this4._hideOverlay();
_this4._hideMasks();
}, 0);
},
_afterHide: function _afterHide() {
this.$overlay.css('position', 'relative');
this.$content.hide();
this._removeWrapper();
this._removeMasks();
this.element.trigger($.Event('blurOverlay.hide'));
this.hideDeferred.resolve(true);
}
});
})(jQuery);