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,27 +1,27 @@
<div class="modal-body"> <div class="modal-body">
<div id="login-buttons"> {{#if view.hasAtLeastOneLoginButton}}
{{#if Discourse.SiteSettings.enable_google_logins}} <div id="login-buttons">
<button class="btn btn-social google" title="{{i18n login.google.title}}" {{action openidLogin "google" target="view"}}>{{i18n login.google.title}}</button> {{#if Discourse.SiteSettings.enable_google_logins}}
{{/if}} <button class="btn btn-social google" title="{{i18n login.google.title}}" {{action openidLogin "google" target="view"}}>{{i18n login.google.title}}</button>
{{#if Discourse.SiteSettings.enable_facebook_logins}} {{/if}}
<button class="btn btn-social facebook" title="{{i18n login.facebook.title}}" {{action "facebookLogin" target="view"}}>{{i18n login.facebook.title}}</button> {{#if Discourse.SiteSettings.enable_facebook_logins}}
{{/if}} <button class="btn btn-social facebook" title="{{i18n login.facebook.title}}" {{action "facebookLogin" target="view"}}>{{i18n login.facebook.title}}</button>
{{#if Discourse.SiteSettings.enable_twitter_logins}} {{/if}}
<button class="btn btn-social twitter" title="{{i18n login.twitter.title}}" {{action "twitterLogin" target="view"}}>{{i18n login.twitter.title}}</button> {{#if Discourse.SiteSettings.enable_twitter_logins}}
{{/if}} <button class="btn btn-social twitter" title="{{i18n login.twitter.title}}" {{action "twitterLogin" target="view"}}>{{i18n login.twitter.title}}</button>
{{#if Discourse.SiteSettings.enable_yahoo_logins}} {{/if}}
<button class="btn btn-social yahoo" title="{{i18n login.yahoo.title}}" {{action openidLogin "yahoo" target="view"}}>{{i18n login.yahoo.title}}</button> {{#if Discourse.SiteSettings.enable_yahoo_logins}}
{{/if}} <button class="btn btn-social yahoo" title="{{i18n login.yahoo.title}}" {{action openidLogin "yahoo" target="view"}}>{{i18n login.yahoo.title}}</button>
{{#if Discourse.SiteSettings.enable_github_logins}} {{/if}}
<button class="btn btn-social github" title="{{i18n login.github.title}}" {{action "githubLogin" target="view"}}>{{i18n login.github.title}}</button> {{#if Discourse.SiteSettings.enable_github_logins}}
{{/if}} <button class="btn btn-social github" title="{{i18n login.github.title}}" {{action "githubLogin" target="view"}}>{{i18n login.github.title}}</button>
{{#if Discourse.SiteSettings.enable_persona_logins}} {{/if}}
<button class="btn btn-social persona" title="{{i18n login.persona.title}}" {{action "personaLogin" target="view"}}>{{i18n login.persona.title}}</button> {{#if Discourse.SiteSettings.enable_persona_logins}}
{{/if}} <button class="btn btn-social persona" title="{{i18n login.persona.title}}" {{action "personaLogin" target="view"}}>{{i18n login.persona.title}}</button>
</div> {{/if}}
<h3 style="text-align:center; margin-bottom:10px;"> </div>
{{i18n login.or}} <h3 style="text-align:center; margin-bottom:10px;">{{i18n login.or}}</h3>
</h3> {{/if}}
<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);