(function() { Luca.containers.ModalView = Luca.core.Container.extend({ componentType: 'modal_view', className: 'luca-ui-modal-view', components: [], renderOnInitialize: true, showOnRender: false, hooks: ['before:show', 'before:hide'], defaultModalOptions: { minWidth: 375, maxWidth: 375, minHeight: 550, maxHeight: 550, opacity: 80, onOpen: function(modal) { this.onOpen.apply(this); return this.onModalOpen.apply(modal, [modal, this]); }, onClose: function(modal) { this.onClose.apply(this); return this.onModalClose.apply(modal, [modal, this]); } }, modalOptions: {}, initialize: function(options) { var _this = this; this.options = options != null ? options : {}; Luca.core.Container.prototype.initialize.apply(this, arguments); this.setupHooks(this.hooks); _(this.defaultModalOptions).each(function(value, setting) { var _base; return (_base = _this.modalOptions)[setting] || (_base[setting] = value); }); this.modalOptions.onOpen = _.bind(this.modalOptions.onOpen, this); return this.modalOptions.onClose = _.bind(this.modalOptions.onClose, this); }, onOpen: function() { return true; }, onClose: function() { return true; }, getModal: function() { return this.modal; }, onModalOpen: function(modal, view) { view.modal = modal; modal.overlay.show(); modal.container.show(); return modal.data.show(); }, onModalClose: function(modal, view) { return $.modal.close(); }, prepareLayout: function() { return $('body').append(this.$el); }, prepareComponents: function() { var _this = this; return this.components = _(this.components).map(function(object, index) { object.container = _this.el; return object; }); }, afterInitialize: function() { this.$el.hide(); if (this.renderOnInitialize) return this.render(); }, afterRender: function() { if (this.showOnRender) return this.show(); }, wrapper: function() { return $(this.$el.parent()); }, show: function() { this.trigger("before:show", this); return this.$el.modal(this.modalOptions); }, hide: function() { return this.trigger("before:hide", this); } }); Luca.register("modal_view", "Luca.containers.ModalView"); }).call(this);