mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 03:48:23 +00:00
ES6: A bunch of modal views
This commit is contained in:
parent
e5059137d0
commit
4f09317cb3
@ -66,7 +66,7 @@ Discourse.ApplicationRoute = Em.Route.extend({
|
||||
@method closeModal
|
||||
**/
|
||||
closeModal: function() {
|
||||
this.render('hide_modal', {into: 'modal', outlet: 'modalBody'});
|
||||
this.render('hide-modal', {into: 'modal', outlet: 'modalBody'});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,9 @@
|
||||
/**
|
||||
This view handles the create account modal
|
||||
|
||||
@class CreateAccountView
|
||||
@extends Discourse.ModalBodyView
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
|
||||
export default Discourse.ModalBodyView.extend({
|
||||
templateName: 'modal/create_account',
|
||||
title: I18n.t('create_account.title'),
|
||||
classNames: ['create-account'],
|
||||
|
||||
didInsertElement: function() {
|
||||
|
||||
this._super();
|
||||
|
||||
_setup: function() {
|
||||
// allows the submission the form when pressing 'ENTER' on *any* text input field
|
||||
// but only when the submit button is enabled
|
||||
var createAccountController = this.get('controller');
|
||||
@ -25,6 +14,5 @@ Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}.on('didInsertElement')
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
export default Discourse.ModalBodyView.extend({
|
||||
templateName: 'modal/forgot_password',
|
||||
title: I18n.t('forgot_password.title'),
|
||||
});
|
8
app/assets/javascripts/discourse/views/hide-modal.js.es6
Normal file
8
app/assets/javascripts/discourse/views/hide-modal.js.es6
Normal file
@ -0,0 +1,8 @@
|
||||
export default Em.View.extend({
|
||||
// No rendering!
|
||||
render: Em.K,
|
||||
|
||||
_hideModal: function() {
|
||||
$('#discourse-modal').modal('hide');
|
||||
}.on('didInsertElement')
|
||||
});
|
@ -1,12 +1,4 @@
|
||||
/**
|
||||
This view handles rendering of the history of a post
|
||||
|
||||
@class HistoryView
|
||||
@extends Discourse.View
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.HistoryView = Discourse.ModalBodyView.extend({
|
||||
export default Discourse.ModalBodyView.extend({
|
||||
templateName: 'modal/history',
|
||||
title: I18n.t('history'),
|
||||
|
||||
@ -14,5 +6,4 @@ Discourse.HistoryView = Discourse.ModalBodyView.extend({
|
||||
var viewPortHeight = $(window).height();
|
||||
this.$(".modal-body").css("max-height", Math.floor(0.8 * viewPortHeight) + "px");
|
||||
}.on("didInsertElement")
|
||||
|
||||
});
|
@ -1,26 +1,14 @@
|
||||
/**
|
||||
A modal view for handling user logins
|
||||
|
||||
@class LoginView
|
||||
@extends Discourse.ModalBodyView
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.LoginView = Discourse.ModalBodyView.extend({
|
||||
export default Discourse.ModalBodyView.extend({
|
||||
templateName: 'modal/login',
|
||||
title: I18n.t('login.title'),
|
||||
classNames: ['login-modal'],
|
||||
|
||||
|
||||
mouseMove: function(e) {
|
||||
this.set('controller.lastX', e.screenX);
|
||||
this.set('controller.lastY', e.screenY);
|
||||
},
|
||||
|
||||
didInsertElement: function() {
|
||||
|
||||
this._super();
|
||||
|
||||
_setup: function() {
|
||||
var loginController = this.get('controller');
|
||||
|
||||
// Get username and password from the browser's password manager,
|
||||
@ -28,7 +16,6 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
|
||||
loginController.set('loginName', $('#hidden-login-form input[name=username]').val());
|
||||
loginController.set('loginPassword', $('#hidden-login-form input[name=password]').val());
|
||||
|
||||
|
||||
Em.run.schedule('afterRender', function() {
|
||||
$('#login-account-password, #login-account-name').keydown(function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
@ -38,9 +25,5 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}.on('didInsertElement')
|
||||
});
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
/**
|
||||
This view handles the modal for when a user forgets their password
|
||||
|
||||
@class ForgotPasswordView
|
||||
@extends Discourse.ModalBodyView
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.ForgotPasswordView = Discourse.ModalBodyView.extend({
|
||||
templateName: 'modal/forgot_password',
|
||||
title: I18n.t('forgot_password.title')
|
||||
});
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
/**
|
||||
An empty view for when we want to close a modal.
|
||||
|
||||
@class HideModalView
|
||||
@extends Discourse.ModalBodyView
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.HideModalView = Discourse.ModalBodyView.extend({
|
||||
|
||||
// No rendering!
|
||||
render: function() { },
|
||||
|
||||
didInsertElement: function() {
|
||||
$('#discourse-modal').modal('hide');
|
||||
}
|
||||
|
||||
});
|
@ -8,11 +8,9 @@
|
||||
**/
|
||||
Discourse.ModalBodyView = Discourse.View.extend({
|
||||
|
||||
// Focus on first element
|
||||
didInsertElement: function() {
|
||||
var self = this;
|
||||
|
||||
var $discourseModal = $('#discourse-modal');
|
||||
_setupModal: function() {
|
||||
var self = this,
|
||||
$discourseModal = $('#discourse-modal');
|
||||
|
||||
$discourseModal.modal('show');
|
||||
$discourseModal.one("hide", function () {
|
||||
@ -21,6 +19,7 @@ Discourse.ModalBodyView = Discourse.View.extend({
|
||||
|
||||
$('#modal-alert').hide();
|
||||
|
||||
// Focus on first element
|
||||
if (!Discourse.Mobile.mobileView) {
|
||||
Em.run.schedule('afterRender', function() {
|
||||
self.$('input:first').focus();
|
||||
@ -31,7 +30,7 @@ Discourse.ModalBodyView = Discourse.View.extend({
|
||||
if (title) {
|
||||
this.set('controller.controllers.modal.title', title);
|
||||
}
|
||||
},
|
||||
}.on('didInsertElement'),
|
||||
|
||||
flashMessageChanged: function() {
|
||||
var flashMessage = this.get('controller.flashMessage');
|
||||
|
Loading…
x
Reference in New Issue
Block a user