Merge pull request #639 from ZogStriP/cleaner-login-modal-when-there-is-no-login-button

cleaner login modal when there is no login button [fixes #638]
This commit is contained in:
Sam 2013-04-03 16:40:39 -07:00
commit 4871454705
2 changed files with 41 additions and 39 deletions

View File

@ -1,4 +1,5 @@
<div class="modal-body"> <div class="modal-body">
{{#if view.hasAtLeastOneLoginButton}}
<div id="login-buttons"> <div id="login-buttons">
{{#if Discourse.SiteSettings.enable_google_logins}} {{#if Discourse.SiteSettings.enable_google_logins}}
<button class="btn btn-social google" title="{{i18n login.google.title}}" {{action openidLogin "google" target="view"}}>{{i18n login.google.title}}</button> <button class="btn btn-social google" title="{{i18n login.google.title}}" {{action openidLogin "google" target="view"}}>{{i18n login.google.title}}</button>
@ -19,9 +20,8 @@
<button class="btn btn-social persona" title="{{i18n login.persona.title}}" {{action "personaLogin" target="view"}}>{{i18n login.persona.title}}</button> <button class="btn btn-social persona" title="{{i18n login.persona.title}}" {{action "personaLogin" target="view"}}>{{i18n login.persona.title}}</button>
{{/if}} {{/if}}
</div> </div>
<h3 style="text-align:center; margin-bottom:10px;"> <h3 style="text-align:center; margin-bottom:10px;">{{i18n login.or}}</h3>
{{i18n login.or}} {{/if}}
</h3>
<form id='login-form'> <form id='login-form'>
<div> <div>
<table> <table>

View File

@ -25,22 +25,25 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
return this.showView(Discourse.ForgotPasswordView.create()); return this.showView(Discourse.ForgotPasswordView.create());
}, },
loginButtonText: (function() { /**
if (this.get('loggingIn')) { Determines whether at least one login button is enabled
return Em.String.i18n('login.logging_in'); **/
} hasAtLeastOneLoginButton: function() {
return Em.String.i18n('login.title'); return Discourse.SiteSettings.enable_google_logins ||
}).property('loggingIn'), Discourse.SiteSettings.enable_facebook_logins ||
Discourse.SiteSettings.enable_twitter_logins ||
Discourse.SiteSettings.enable_yahoo_logins ||
Discourse.SiteSettings.enable_github_logins ||
Discourse.SiteSettings.enable_persona_logins;
}.property(),
loginDisabled: (function() { loginButtonText: function() {
if (this.get('loggingIn')) { return this.get('loggingIn') ? Em.String.i18n('login.logging_in') : Em.String.i18n('login.title');
return true; }.property('loggingIn'),
}
if (this.blank('loginName') || this.blank('loginPassword')) { loginDisabled: function() {
return true; return this.get('loggingIn') || this.blank('loginName') || this.blank('loginPassword');
} }.property('loginName', 'loginPassword', 'loggingIn'),
return false;
}).property('loginName', 'loginPassword', 'loggingIn'),
login: function() { login: function() {
this.set('loggingIn', true); this.set('loggingIn', true);
@ -50,7 +53,6 @@ Discourse.LoginView = Discourse.ModalBodyView.extend({
data: { login: this.get('loginName'), password: this.get('loginPassword') }, data: { login: this.get('loginName'), password: this.get('loginPassword') },
type: 'POST' type: 'POST'
}).then(function (result) { }).then(function (result) {
// Successful login // Successful login
if (result.error) { if (result.error) {
loginView.set('loggingIn', false); loginView.set('loggingIn', false);