ES6: Preferences views

This commit is contained in:
Robin Ward 2014-07-15 12:36:44 -04:00
parent a9342dbf92
commit 3368e23fe4
11 changed files with 41 additions and 92 deletions

View File

@ -7,7 +7,6 @@
@module Discourse
**/
Discourse.ScrollTop = Em.Mixin.create({
_scrollTop: function() {
Em.run.schedule('afterRender', function() {
$(document).scrollTop(0);

View File

@ -0,0 +1,11 @@
export default Ember.View.extend({
templateName: 'user/about',
classNames: ['user-preferences'],
_focusAbout: function() {
var self = this;
Ember.run.schedule('afterRender', function() {
self.$('textarea').focus();
});
}.on('didInsertElement')
});

View File

@ -0,0 +1,9 @@
export default Em.View.extend({
templateName: 'user/email',
classNames: ['user-preferences'],
_focusField: function() {
Em.run.schedule('afterRender', function() {
$('#change_email').focus();
});
}.on('didInsertElement')
});

View File

@ -1,18 +1,12 @@
/**
This view handles rendering of a user's username preferences
@class PreferencesUsernameView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.PreferencesUsernameView = Discourse.View.extend({
export default Ember.View.extend({
templateName: 'user/username',
classNames: ['user-preferences'],
didInsertElement: function() {
return $('#change_username').focus();
},
_focusUsername: function() {
Em.run.schedule('afterRender', function() {
$('#change_username').focus();
});
}.on('didInsertElement'),
keyDown: function(e) {
if (e.keyCode === 13) {
@ -24,7 +18,4 @@ Discourse.PreferencesUsernameView = Discourse.View.extend({
}
}
}
});

View File

@ -1,4 +1,4 @@
Discourse.PreferencesView = Discourse.View.extend({
export default Ember.View.extend({
templateName: 'user/preferences',
classNames: ['user-preferences']
});

View File

@ -0,0 +1,3 @@
export default Ember.View.extend({
templateName: 'user/invited'
});

View File

@ -0,0 +1,11 @@
export default Ember.View.extend(Discourse.ScrollTop, {
templateName: 'user/user',
userBinding: 'controller.content',
updateTitle: function() {
var username = this.get('user.username');
if (username) {
Discourse.set('title', "" + (I18n.t("user.profile")) + " - " + username);
}
}.observes('user.loaded', 'user.username')
});

View File

@ -1,18 +0,0 @@
/**
This view handles rendering of a user's bio editor
@class PreferencesAboutView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.PreferencesAboutView = Discourse.View.extend({
templateName: 'user/about',
classNames: ['user-preferences'],
didInsertElement: function() {
this.$('textarea').focus();
}
});

View File

@ -1,17 +0,0 @@
/**
This view handles rendering of a user's email preferences
@class PreferencesEmailView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.PreferencesEmailView = Discourse.View.extend({
templateName: 'user/email',
classNames: ['user-preferences'],
didInsertElement: function() {
return $('#change_email').focus();
}
});

View File

@ -1,13 +0,0 @@
/**
This view handles rendering of a user's invited list
@class UserInvitedView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.UserInvitedView = Discourse.View.extend({
templateName: 'user/invited'
});

View File

@ -1,27 +0,0 @@
/**
This view handles rendering of a user including the navigational menu
@class UserView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.UserView = Discourse.View.extend({
templateName: 'user/user',
userBinding: 'controller.content',
updateTitle: function() {
var username;
username = this.get('user.username');
if (username) {
return Discourse.set('title', "" + (I18n.t("user.profile")) + " - " + username);
}
}.observes('user.loaded', 'user.username'),
didInsertElement: function() {
window.scrollTo(0, 0);
}
});