{I" class:ETI"ProcessedAsset;FI"logical_path;TI"mercury/lightview.js;FI" pathname;TI"‰/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/lightview.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+½¡9RI" length;Tiù+I" digest;TI"%0b582a23c9836491361865600dd2536b;FI" source;TI"ù+(function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; this.Mercury.lightview = function(url, options) { var _base; if (options == null) { options = {}; } (_base = Mercury.lightview).instance || (_base.instance = new Mercury.Lightview(url, options)); Mercury.lightview.instance.show(url, options); return Mercury.lightview.instance; }; this.Mercury.Lightview = (function() { function Lightview(url, options) { this.url = url; this.options = options != null ? options : {}; this.hide = __bind(this.hide, this); } Lightview.prototype.show = function(url, options) { var _this = this; this.url = url || this.url; this.options = options || this.options; if (this.options.ujsHandling !== false) { this.options.ujsHandling = true; } Mercury.trigger('focus:window'); this.initializeLightview(); if (this.visible) { this.update(); } else { this.appear(); } if (this.options.content) { return setTimeout((function() { return _this.loadContent(_this.options.content); }), 500); } }; Lightview.prototype.initializeLightview = function() { if (this.initialized) { return; } this.build(); this.bindEvents(); return this.initialized = true; }; Lightview.prototype.build = function() { var _ref, _ref1; this.element = jQuery('
', { "class": 'mercury-lightview loading' }); this.element.html('

'); this.element.append('
'); this.overlay = jQuery('
', { "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); ;TI"dependency_digest;TI"%74f487d50c6f18f4be93ad73e34e0c77;FI"required_paths;T[I"‰/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/lightview.js.coffee;FI"dependency_paths;T[{I" path;TI"‰/home/edik/.rvm/gems/ruby-2.0.0-p247@very_simple_cms/bundler/gems/mercury-3e0245e33195/app/assets/javascripts/mercury/lightview.js.coffee;FI" mtime;TI"2013-09-18T16:51:09+04:00;TI" digest;TI"%5873ea02b4bfd5cf6e929dadb19f4eb1;FI" _version;TI"%2cf3622cbba861b85d33ffabfa420c13;F