This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/views/modal/modal_view.js

43 lines
1.0 KiB
JavaScript

/**
A base class for helping us display modal content
@class ModalView
@extends Ember.ContainerView
@namespace Discourse
@module Discourse
**/
Discourse.ModalView = Ember.ContainerView.extend({
childViews: ['modalHeaderView', 'modalBodyView', 'modalErrorsView'],
classNames: ['modal', 'hidden'],
classNameBindings: ['controller.currentView.modalClass'],
elementId: 'discourse-modal',
modalHeaderView: Ember.View.create({
templateName: 'modal/modal_header',
titleBinding: 'controller.currentView.title'
}),
modalBodyView: Ember.ContainerView.create({
currentViewBinding: 'controller.currentView'
}),
modalErrorsView: Ember.View.create({
templateName: 'modal/modal_errors'
}),
viewChanged: (function() {
var view,
_this = this;
this.set('modalErrorsView.errors', null);
if (view = this.get('controller.currentView')) {
$('#modal-alert').hide();
return Em.run.next(function() {
return _this.$().modal('show');
});
}
}).observes('controller.currentView')
});