o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1388436950.0916228: @value"0-{I" class:EFI"BundledAsset;FI"logical_path;FI"mercury/modal.js;FI" pathname;FI"/Users/jrissler/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/mercury-6daffeeb487e/app/assets/javascripts/mercury/modal.js.coffee;FI"content_type;FI"application/javascript;FI" mtime;FI"2013-11-20T08:09:45-05:00;FI" length;Fi+I" digest;F"%c0d3997c3eb2e1dd2e906794f5160bacI" source;FI"+(function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; this.Mercury.modal = function(url, options) { var instance; if (options == null) { options = {}; } instance = new Mercury.Modal(url, options); instance.show(); return instance; }; this.Mercury.Modal = (function() { function Modal(url, options) { this.url = url; this.options = options != null ? options : {}; this.hide = __bind(this.hide, this); } Modal.prototype.show = function(url, options) { var _base, _this = this; if (url == null) { url = null; } if (options == null) { options = null; } this.url = url || this.url; this.options = options || this.options; (_base = this.options).minWidth || (_base.minWidth = 400); if (this.options.ujsHandling !== false) { this.options.ujsHandling = true; } Mercury.trigger('focus:window'); this.initializeModal(); if (this.visible) { this.update(); } else { this.appear(); } if (this.options.content) { return setTimeout((function() { return _this.loadContent(_this.options.content); }), 500); } }; Modal.prototype.initializeModal = function() { if (this.initialized) { return; } this.build(); this.bindEvents(); return this.initialized = true; }; Modal.prototype.build = function() { var _ref, _ref1; this.element = jQuery('.mercury-modal'); this.overlay = jQuery('.mercury-modal-overlay'); if (!(this.element.get(0) && this.overlay.get(0))) { this.element = jQuery('
', { "class": 'mercury-modal loading' }); this.element.html('

×

'); this.element.append('
'); this.overlay = jQuery('
', { "class": 'mercury-modal-overlay' }); this.element.appendTo((_ref = jQuery(this.options.appendTo).get(0)) != null ? _ref : 'body'); this.overlay.appendTo((_ref1 = jQuery(this.options.appendTo).get(0)) != null ? _ref1 : 'body'); } this.titleElement = this.element.find('.mercury-modal-title'); this.contentContainerElement = this.element.find('.mercury-modal-content-container'); return this.contentElement = this.element.find('.mercury-modal-content'); }; Modal.prototype.bindEvents = function() { var _this = this; Mercury.on('refresh', function() { return _this.resize(true); }); Mercury.on('resize', function() { return _this.position(); }); this.overlay.on('click', function() { if (_this.options.allowHideUsingOverlay) { return _this.hide(); } }); this.titleElement.find('a').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(); } }); }; Modal.prototype.appear = function() { var _this = this; this.showing = true; this.position(); this.overlay.show(); return this.overlay.animate({ opacity: 1 }, 200, 'easeInOutSine', function() { _this.element.css({ top: -_this.element.height() }); _this.setTitle(); _this.element.show(); return _this.element.animate({ top: 0 }, 200, 'easeInOutSine', function() { _this.visible = true; _this.showing = false; return _this.load(); }); }); }; Modal.prototype.resize = function(keepVisible) { var height, titleHeight, visibility, width, _this = this; visibility = keepVisible ? 'visible' : 'hidden'; titleHeight = this.titleElement.outerHeight(); width = this.contentElement.outerWidth(); if (this.contentPane) { this.contentPane.css({ height: 'auto' }); } this.contentElement.css({ height: 'auto', visibility: visibility, display: 'block' }); height = this.contentElement.outerHeight() + titleHeight; if (width < this.options.minWidth) { width = this.options.minWidth; } if (height > Mercury.displayRect.fullHeight || this.options.fullHeight) { height = Mercury.displayRect.fullHeight; } return this.element.stop().animate({ 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() + 10 : 0; _this.contentPane.css({ height: height - titleHeight - controlHeight - 20 }); return _this.contentPane.find('.mercury-display-pane').css({ width: width - 20 }); } else { return _this.contentElement.css({ height: height - titleHeight, overflow: 'auto' }); } }); }; Modal.prototype.position = function() { var controlHeight, height, titleHeight, viewportWidth, width; viewportWidth = Mercury.displayRect.width; 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.element.width(); height = this.element.height(); if (width < this.options.minWidth) { width = this.options.minWidth; } if (height > Mercury.displayRect.fullHeight || this.options.fullHeight) { height = Mercury.displayRect.fullHeight; } 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() + 10 : 0; this.contentPane.css({ height: height - titleHeight - controlHeight - 20 }); this.contentPane.find('.mercury-display-pane').css({ width: width - 20 }); } else { this.contentElement.css({ height: height - titleHeight, overflow: 'auto' }); } return this.element.css({ left: (viewportWidth - width) / 2, width: width, height: height, display: this.visible ? 'block' : 'none', visibility: 'visible' }); }; Modal.prototype.update = function() { this.reset(); this.resize(); return this.load(); }; Modal.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 modal.", _this.url); } }); } }; Modal.prototype.loadContent = function(data, options) { if (options == null) { options = null; } this.initializeModal(); 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('.modal-close').on('click', this.hide); return this.resize(); }; Modal.prototype.setTitle = function() { var closeButton; this.titleElement.find('span').html(Mercury.I18n(this.options.title)); closeButton = this.titleElement.find('a'); if (this.options.closeButton === false) { return closeButton.hide(); } else { return closeButton.show(); } }; Modal.prototype.serializeForm = function() { return this.element.find('form').serializeObject() || {}; }; Modal.prototype.reset = function() { this.titleElement.find('span').html(''); return this.contentElement.html(''); }; Modal.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 Modal; })(); }).call(this); ;FI"required_assets_digest;F"%ddfcff5d0cd08b629f8b3f29f1e0ddd7I" _version;F"%6776f581a4329e299531e1d52aa59832