mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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
|
@method closeModal
|
||||||
**/
|
**/
|
||||||
closeModal: function() {
|
closeModal: function() {
|
||||||
this.render('hide_modal', {into: 'modal', outlet: 'modalBody'});
|
this.render('hide-modal', {into: 'modal', outlet: 'modalBody'});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,20 +1,9 @@
|
|||||||
/**
|
export default Discourse.ModalBodyView.extend({
|
||||||
This view handles the create account modal
|
|
||||||
|
|
||||||
@class CreateAccountView
|
|
||||||
@extends Discourse.ModalBodyView
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
|
|
||||||
templateName: 'modal/create_account',
|
templateName: 'modal/create_account',
|
||||||
title: I18n.t('create_account.title'),
|
title: I18n.t('create_account.title'),
|
||||||
classNames: ['create-account'],
|
classNames: ['create-account'],
|
||||||
|
|
||||||
didInsertElement: function() {
|
_setup: function() {
|
||||||
|
|
||||||
this._super();
|
|
||||||
|
|
||||||
// allows the submission the form when pressing 'ENTER' on *any* text input field
|
// allows the submission the form when pressing 'ENTER' on *any* text input field
|
||||||
// but only when the submit button is enabled
|
// but only when the submit button is enabled
|
||||||
var createAccountController = this.get('controller');
|
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 @@
|
|||||||
/**
|
export default Discourse.ModalBodyView.extend({
|
||||||
This view handles rendering of the history of a post
|
|
||||||
|
|
||||||
@class HistoryView
|
|
||||||
@extends Discourse.View
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.HistoryView = Discourse.ModalBodyView.extend({
|
|
||||||
templateName: 'modal/history',
|
templateName: 'modal/history',
|
||||||
title: I18n.t('history'),
|
title: I18n.t('history'),
|
||||||
|
|
||||||
@ -14,5 +6,4 @@ Discourse.HistoryView = Discourse.ModalBodyView.extend({
|
|||||||
var viewPortHeight = $(window).height();
|
var viewPortHeight = $(window).height();
|
||||||
this.$(".modal-body").css("max-height", Math.floor(0.8 * viewPortHeight) + "px");
|
this.$(".modal-body").css("max-height", Math.floor(0.8 * viewPortHeight) + "px");
|
||||||
}.on("didInsertElement")
|
}.on("didInsertElement")
|
||||||
|
|
||||||
});
|
});
|
@ -1,26 +1,14 @@
|
|||||||
/**
|
export default Discourse.ModalBodyView.extend({
|
||||||
A modal view for handling user logins
|
|
||||||
|
|
||||||
@class LoginView
|
|
||||||
@extends Discourse.ModalBodyView
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.LoginView = Discourse.ModalBodyView.extend({
|
|
||||||
templateName: 'modal/login',
|
templateName: 'modal/login',
|
||||||
title: I18n.t('login.title'),
|
title: I18n.t('login.title'),
|
||||||
classNames: ['login-modal'],
|
classNames: ['login-modal'],
|
||||||
|
|
||||||
|
|
||||||
mouseMove: function(e) {
|
mouseMove: function(e) {
|
||||||
this.set('controller.lastX', e.screenX);
|
this.set('controller.lastX', e.screenX);
|
||||||
this.set('controller.lastY', e.screenY);
|
this.set('controller.lastY', e.screenY);
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement: function() {
|
_setup: function() {
|
||||||
|
|
||||||
this._super();
|
|
||||||
|
|
||||||
var loginController = this.get('controller');
|
var loginController = this.get('controller');
|
||||||
|
|
||||||
// Get username and password from the browser's password manager,
|
// 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('loginName', $('#hidden-login-form input[name=username]').val());
|
||||||
loginController.set('loginPassword', $('#hidden-login-form input[name=password]').val());
|
loginController.set('loginPassword', $('#hidden-login-form input[name=password]').val());
|
||||||
|
|
||||||
|
|
||||||
Em.run.schedule('afterRender', function() {
|
Em.run.schedule('afterRender', function() {
|
||||||
$('#login-account-password, #login-account-name').keydown(function(e) {
|
$('#login-account-password, #login-account-name').keydown(function(e) {
|
||||||
if (e.keyCode === 13) {
|
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({
|
Discourse.ModalBodyView = Discourse.View.extend({
|
||||||
|
|
||||||
// Focus on first element
|
_setupModal: function() {
|
||||||
didInsertElement: function() {
|
var self = this,
|
||||||
var self = this;
|
$discourseModal = $('#discourse-modal');
|
||||||
|
|
||||||
var $discourseModal = $('#discourse-modal');
|
|
||||||
|
|
||||||
$discourseModal.modal('show');
|
$discourseModal.modal('show');
|
||||||
$discourseModal.one("hide", function () {
|
$discourseModal.one("hide", function () {
|
||||||
@ -21,6 +19,7 @@ Discourse.ModalBodyView = Discourse.View.extend({
|
|||||||
|
|
||||||
$('#modal-alert').hide();
|
$('#modal-alert').hide();
|
||||||
|
|
||||||
|
// Focus on first element
|
||||||
if (!Discourse.Mobile.mobileView) {
|
if (!Discourse.Mobile.mobileView) {
|
||||||
Em.run.schedule('afterRender', function() {
|
Em.run.schedule('afterRender', function() {
|
||||||
self.$('input:first').focus();
|
self.$('input:first').focus();
|
||||||
@ -31,7 +30,7 @@ Discourse.ModalBodyView = Discourse.View.extend({
|
|||||||
if (title) {
|
if (title) {
|
||||||
this.set('controller.controllers.modal.title', title);
|
this.set('controller.controllers.modal.title', title);
|
||||||
}
|
}
|
||||||
},
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
flashMessageChanged: function() {
|
flashMessageChanged: function() {
|
||||||
var flashMessage = this.get('controller.flashMessage');
|
var flashMessage = this.get('controller.flashMessage');
|
||||||
|
Loading…
Reference in New Issue
Block a user