', {
"class": 'mercury-lightview loading'
});
this.element.html('
', {
"class": 'mercury-lightview-overlay'
});
this.titleElement = this.element.find('.mercury-lightview-title');
if (this.options.closeButton) {
this.titleElement.append('
');
}
this.contentElement = this.element.find('.mercury-lightview-content');
this.element.appendTo((_ref = jQuery(this.options.appendTo).get(0)) != null ? _ref : 'body');
return this.overlay.appendTo((_ref1 = jQuery(this.options.appendTo).get(0)) != null ? _ref1 : 'body');
};
Lightview.prototype.bindEvents = function() {
var _this = this;
Mercury.on('refresh', function() {
return _this.resize(true);
});
Mercury.on('resize', function() {
if (_this.visible) {
return _this.position();
}
});
this.overlay.on('click', function() {
if (!_this.options.closeButton) {
return _this.hide();
}
});
this.titleElement.find('.mercury-lightview-close').on('click', function() {
return _this.hide();
});
if (this.options.ujsHandling) {
this.element.on('ajax:beforeSend', function(event, xhr, options) {
return options.success = function(content) {
return _this.loadContent(content);
};
});
}
return jQuery(document).on('keydown', function(event) {
if (event.keyCode === 27 && _this.visible) {
return _this.hide();
}
});
};
Lightview.prototype.appear = function() {
var _this = this;
this.showing = true;
this.position();
this.overlay.show().css({
opacity: 0
});
return this.overlay.animate({
opacity: 1
}, 200, 'easeInOutSine', function() {
_this.setTitle();
_this.element.show().css({
opacity: 0
});
return _this.element.stop().animate({
opacity: 1
}, 200, 'easeInOutSine', function() {
_this.visible = true;
_this.showing = false;
return _this.load();
});
});
};
Lightview.prototype.resize = function(keepVisible) {
var height, titleHeight, viewportHeight, viewportWidth, visibility, width,
_this = this;
visibility = keepVisible ? 'visible' : 'hidden';
viewportWidth = Mercury.displayRect.width;
viewportHeight = Mercury.displayRect.fullHeight;
titleHeight = this.titleElement.outerHeight();
width = this.contentElement.outerWidth();
if (width > viewportWidth - 40 || this.options.fullSize) {
width = viewportWidth - 40;
}
if (this.contentPane) {
this.contentPane.css({
height: 'auto'
});
}
this.contentElement.css({
height: 'auto',
visibility: visibility,
display: 'block'
});
height = this.contentElement.outerHeight() + titleHeight;
if (height > viewportHeight - 20 || this.options.fullSize) {
height = viewportHeight - 20;
}
if (width < 300) {
width = 300;
}
if (height < 150) {
height = 150;
}
return this.element.stop().animate({
top: ((viewportHeight - height) / 2) + 10,
left: (Mercury.displayRect.width - width) / 2,
width: width,
height: height
}, 200, 'easeInOutSine', function() {
var controlHeight;
_this.contentElement.css({
visibility: 'visible',
display: 'block'
});
if (_this.contentPane.length) {
_this.contentElement.css({
height: height - titleHeight,
overflow: 'visible'
});
controlHeight = _this.contentControl.length ? _this.contentControl.outerHeight() : 0;
_this.contentPane.css({
height: height - titleHeight - controlHeight - 40
});
return _this.contentPane.find('.mercury-display-pane').css({
width: width - 40
});
} else {
return _this.contentElement.css({
height: height - titleHeight - 30,
overflow: 'auto'
});
}
});
};
Lightview.prototype.position = function() {
var controlHeight, height, titleHeight, viewportHeight, viewportWidth, width;
viewportWidth = Mercury.displayRect.width;
viewportHeight = Mercury.displayRect.fullHeight;
if (this.contentPane) {
this.contentPane.css({
height: 'auto'
});
}
this.contentElement.css({
height: 'auto'
});
this.element.css({
width: 'auto',
height: 'auto',
display: 'block',
visibility: 'hidden'
});
width = this.contentElement.width() + 40;
height = this.contentElement.height() + this.titleElement.outerHeight() + 30;
if (width > viewportWidth - 40 || this.options.fullSize) {
width = viewportWidth - 40;
}
if (height > viewportHeight - 20 || this.options.fullSize) {
height = viewportHeight - 20;
}
if (width < 300) {
width = 300;
}
if (height < 150) {
height = 150;
}
titleHeight = this.titleElement.outerHeight();
if (this.contentPane && this.contentPane.length) {
this.contentElement.css({
height: height - titleHeight,
overflow: 'visible'
});
controlHeight = this.contentControl.length ? this.contentControl.outerHeight() : 0;
this.contentPane.css({
height: height - titleHeight - controlHeight - 40
});
this.contentPane.find('.mercury-display-pane').css({
width: width - 40
});
} else {
this.contentElement.css({
height: height - titleHeight - 30,
overflow: 'auto'
});
}
return this.element.css({
top: ((viewportHeight - height) / 2) + 10,
left: (viewportWidth - width) / 2,
width: width,
height: height,
display: this.visible ? 'block' : 'none',
visibility: 'visible'
});
};
Lightview.prototype.update = function() {
this.reset();
this.resize();
return this.load();
};
Lightview.prototype.load = function() {
var _this = this;
this.setTitle();
if (!this.url) {
return;
}
this.element.addClass('loading');
if (Mercury.preloadedViews[this.url]) {
return setTimeout((function() {
return _this.loadContent(Mercury.preloadedViews[_this.url]);
}), 10);
} else {
return jQuery.ajax(this.url, {
headers: Mercury.ajaxHeaders(),
type: this.options.loadType || 'GET',
data: this.options.loadData,
success: function(data) {
return _this.loadContent(data);
},
error: function() {
_this.hide();
return Mercury.notify('Mercury was unable to load %s for the lightview.', _this.url);
}
});
}
};
Lightview.prototype.loadContent = function(data, options) {
if (options == null) {
options = null;
}
this.initializeLightview();
this.options = options || this.options;
this.setTitle();
this.loaded = true;
this.element.removeClass('loading');
this.contentElement.html(data);
this.contentElement.css({
display: 'none',
visibility: 'hidden'
});
this.contentPane = this.element.find('.mercury-display-pane-container');
this.contentControl = this.element.find('.mercury-display-controls');
if (this.options.afterLoad) {
this.options.afterLoad.call(this);
}
if (this.options.handler) {
if (Mercury.modalHandlers[this.options.handler]) {
if (typeof Mercury.modalHandlers[this.options.handler] === 'function') {
Mercury.modalHandlers[this.options.handler].call(this);
} else {
jQuery.extend(this, Mercury.modalHandlers[this.options.handler]);
this.initialize();
}
} else if (Mercury.lightviewHandlers[this.options.handler]) {
if (typeof Mercury.lightviewHandlers[this.options.handler] === 'function') {
Mercury.lightviewHandlers[this.options.handler].call(this);
} else {
jQuery.extend(this, Mercury.lightviewHandlers[this.options.handler]);
this.initialize();
}
}
}
if (Mercury.config.localization.enabled) {
this.element.localize(Mercury.locale());
}
this.element.find('.lightview-close').on('click', this.hide);
return this.resize();
};
Lightview.prototype.setTitle = function() {
return this.titleElement.find('span').html(Mercury.I18n(this.options.title));
};
Lightview.prototype.serializeForm = function() {
return this.element.find('form').serializeObject() || {};
};
Lightview.prototype.reset = function() {
this.titleElement.find('span').html('');
return this.contentElement.html('');
};
Lightview.prototype.hide = function() {
if (this.showing) {
return;
}
this.options = {};
Mercury.trigger('focus:frame');
this.element.hide();
this.overlay.hide();
this.reset();
return this.visible = false;
};
return Lightview;
})();
}).call(this);
; FI"required_assets_digest; F"%aa8414fc936aae8faef79f9795f28bbfI"
_version; F"%6776f581a4329e299531e1d52aa59832