Prefix all accounts-ui templates other than loginButtons with an underscore.

In the future we may support use of some of the sub-templates directly (eg, we
might expose a "sign in" template and a "create user" template, and keep the
events and links for switching between them on the outer loginButtons) but we
don't yet. This change leaves us open to change the internal details later.
This commit is contained in:
David Glasser
2012-10-09 12:00:25 -07:00
parent dffed84155
commit 9e09d64831
8 changed files with 93 additions and 93 deletions

View File

@@ -1,16 +1,16 @@
<template name="loginButtons">
<div id="login-buttons">
{{#if currentUser}}
{{> loginButtonsLoggedIn}}
{{> _loginButtonsLoggedIn}}
{{else}}
{{> loginButtonsLoggedOut}}
{{> _loginButtonsLoggedOut}}
{{/if}}
</div>
</template>
<template name="loginButtonsLoggedIn">
<template name="_loginButtonsLoggedIn">
{{#if dropdown}}
{{> loginButtonsLoggedInDropdown}}
{{> _loginButtonsLoggedInDropdown}}
{{else}}
<div class="login-header">
{{#if currentUserLoaded}}
@@ -23,14 +23,14 @@
{{/if}}
</template>
<template name="loginButtonsLoggedOut">
<template name="_loginButtonsLoggedOut">
{{#if services}} {{! if at least one service is configured }}
{{#if configurationLoaded}}
{{#if dropdown}} {{! if more than one service configured, or password is configured}}
{{> loginButtonsLoggedOutDropdown}}
{{> _loginButtonsLoggedOutDropdown}}
{{else}}
{{#with singleService}} {{! at this point there must be only one configured services }}
{{> loginButtonsLoggedOutSingleLoginButton}}
{{> _loginButtonsLoggedOutSingleLoginButton}}
{{/with}}
{{/if}}
{{/if}}
@@ -40,7 +40,7 @@
</template>
<!-- used in various places to display messages to user -->
<template name="loginButtonsMessages">
<template name="_loginButtonsMessages">
{{#if errorMessage}}
<div class="message error-message">{{errorMessage}}</div>
{{/if}}

View File

@@ -19,15 +19,15 @@
// loginButtonLoggedOut template
//
Template.loginButtonsLoggedOut.dropdown = function () {
Template._loginButtonsLoggedOut.dropdown = function () {
return Accounts._loginButtons.dropdown();
};
Template.loginButtonsLoggedOut.services = function () {
Template._loginButtonsLoggedOut.services = function () {
return Accounts._loginButtons.getLoginServices();
};
Template.loginButtonsLoggedOut.singleService = function () {
Template._loginButtonsLoggedOut.singleService = function () {
var services = Accounts._loginButtons.getLoginServices();
if (services.length !== 1)
throw new Error(
@@ -35,7 +35,7 @@
return services[0];
};
Template.loginButtonsLoggedOut.configurationLoaded = function () {
Template._loginButtonsLoggedOut.configurationLoaded = function () {
return Accounts.loginServicesConfigured();
};
@@ -46,11 +46,11 @@
// decide whether we should show a dropdown rather than a row of
// buttons
Template.loginButtonsLoggedIn.dropdown = function () {
Template._loginButtonsLoggedIn.dropdown = function () {
return Accounts._loginButtons.dropdown();
};
Template.loginButtonsLoggedIn.displayName = function () {
Template._loginButtonsLoggedIn.displayName = function () {
return Accounts._loginButtons.displayName();
};
@@ -60,11 +60,11 @@
// loginButtonsMessage template
//
Template.loginButtonsMessages.errorMessage = function () {
Template._loginButtonsMessages.errorMessage = function () {
return loginButtonsSession.get('errorMessage');
};
Template.loginButtonsMessages.infoMessage = function () {
Template._loginButtonsMessages.infoMessage = function () {
return loginButtonsSession.get('infoMessage');
};

View File

@@ -1,14 +1,14 @@
<body>
{{> resetPasswordDialog}}
{{> enrollAccountDialog}}
{{> justValidatedUserDialog}}
{{> configureLoginServiceDialog}}
{{> _resetPasswordDialog}}
{{> _enrollAccountDialog}}
{{> _justValidatedUserDialog}}
{{> _configureLoginServiceDialog}}
<!-- if we're not showing a dropdown, we need some other place to show messages -->
{{> loginButtonsMessagesDialog}}
{{> _loginButtonsMessagesDialog}}
</body>
<template name="resetPasswordDialog">
<template name="_resetPasswordDialog">
{{#if inResetPasswordFlow}}
<div class="hide-background"></div>
@@ -21,7 +21,7 @@
<input id="reset-password-new-password" type="password" />
</div>
{{> loginButtonsMessages}}
{{> _loginButtonsMessages}}
<div class="login-button login-button-form-submit" id="login-buttons-reset-password-button">
Set password
@@ -34,7 +34,7 @@
{{/if}}
</template>
<template name="enrollAccountDialog">
<template name="_enrollAccountDialog">
{{#if inEnrollAccountFlow}}
<div class="hide-background"></div>
@@ -47,7 +47,7 @@
<input id="enroll-account-password" type="password" />
</div>
{{> loginButtonsMessages}}
{{> _loginButtonsMessages}}
<div class="login-button login-button-form-submit" id="login-buttons-enroll-account-button">
Create account
@@ -60,7 +60,7 @@
{{/if}}
</template>
<template name="justValidatedUserDialog">
<template name="_justValidatedUserDialog">
{{#if visible}}
<div class="accounts-dialog accounts-centered-dialog">
Email validated
@@ -69,7 +69,7 @@
{{/if}}
</template>
<template name="configureLoginServiceDialog">
<template name="_configureLoginServiceDialog">
{{#if visible}}
<div id="configure-login-service-dialog" class="accounts-dialog accounts-centered-dialog">
{{{configurationSteps}}}
@@ -110,10 +110,10 @@
{{/if}}
</template>
<template name="loginButtonsMessagesDialog">
<template name="_loginButtonsMessagesDialog">
{{#if visible}}
<div class="accounts-dialog accounts-centered-dialog" id="login-buttons-message-dialog">
{{> loginButtonsMessages}}
{{> _loginButtonsMessages}}
<div class="login-button" id="messages-dialog-dismiss-button">Dismiss</div>
</div>
{{/if}}

View File

@@ -37,7 +37,7 @@
// resetPasswordDialog template
//
Template.resetPasswordDialog.events({
Template._resetPasswordDialog.events({
'click #login-buttons-reset-password-button': function () {
resetPassword();
},
@@ -69,7 +69,7 @@
});
};
Template.resetPasswordDialog.inResetPasswordFlow = function () {
Template._resetPasswordDialog.inResetPasswordFlow = function () {
return loginButtonsSession.get('resetPasswordToken');
};
@@ -78,7 +78,7 @@
// enrollAccountDialog template
//
Template.enrollAccountDialog.events({
Template._enrollAccountDialog.events({
'click #login-buttons-enroll-account-button': function () {
enrollAccount();
},
@@ -110,7 +110,7 @@
});
};
Template.enrollAccountDialog.inEnrollAccountFlow = function () {
Template._enrollAccountDialog.inEnrollAccountFlow = function () {
return loginButtonsSession.get('enrollAccountToken');
};
@@ -119,13 +119,13 @@
// justValidatedUserDialog template
//
Template.justValidatedUserDialog.events({
Template._justValidatedUserDialog.events({
'click #just-validated-dismiss-button': function () {
loginButtonsSession.set('justValidatedUser', false);
}
});
Template.justValidatedUserDialog.visible = function () {
Template._justValidatedUserDialog.visible = function () {
return loginButtonsSession.get('justValidatedUser');
};
@@ -134,13 +134,13 @@
// loginButtonsMessagesDialog template
//
Template.loginButtonsMessagesDialog.events({
Template._loginButtonsMessagesDialog.events({
'click #messages-dialog-dismiss-button': function () {
loginButtonsSession.resetMessages();
}
});
Template.loginButtonsMessagesDialog.visible = function () {
Template._loginButtonsMessagesDialog.visible = function () {
var hasMessage = loginButtonsSession.get('infoMessage') || loginButtonsSession.get('errorMessage');
return !Accounts._loginButtons.dropdown() && hasMessage;
};
@@ -150,7 +150,7 @@
// configureLoginServiceDialog template
//
Template.configureLoginServiceDialog.events({
Template._configureLoginServiceDialog.events({
'click #configure-login-service-dismiss-button': function () {
loginButtonsSession.set('configureLoginServiceDialogVisible', false);
},
@@ -208,20 +208,20 @@
return template.fields();
};
Template.configureLoginServiceDialog.configurationFields = function () {
Template._configureLoginServiceDialog.configurationFields = function () {
return configurationFields();
};
Template.configureLoginServiceDialog.visible = function () {
Template._configureLoginServiceDialog.visible = function () {
return loginButtonsSession.get('configureLoginServiceDialogVisible');
};
Template.configureLoginServiceDialog.configurationSteps = function () {
Template._configureLoginServiceDialog.configurationSteps = function () {
// renders the appropriate template
return configureLoginServiceDialogTemplateForService()();
};
Template.configureLoginServiceDialog.saveDisabled = function () {
Template._configureLoginServiceDialog.saveDisabled = function () {
return loginButtonsSession.get('configureLoginServiceDialogSaveDisabled');
};

View File

@@ -1,7 +1,7 @@
<!-- -->
<!-- LOGGED IN -->
<!-- -->
<template name="loginButtonsLoggedInDropdown">
<template name="_loginButtonsLoggedInDropdown">
<div class="login-link-and-dropdown-list">
{{#if currentUserLoaded}}
<a class="login-link-text" id="login-name-link">
@@ -14,12 +14,12 @@
<div class="login-close-text-clear"></div>
{{#if inMessageOnlyFlow}}
{{> loginButtonsMessages}}
{{> _loginButtonsMessages}}
{{else}}
{{#if inChangePasswordFlow}}
{{> loginButtonsChangePassword}}
{{> _loginButtonsChangePassword}}
{{else}}
{{> loginButtonsLoggedInDropdownActions}}
{{> _loginButtonsLoggedInDropdownActions}}
{{/if}}
{{/if}}
</div>
@@ -30,7 +30,7 @@
</div>
</template>
<template name="loginButtonsLoggedInDropdownActions">
<template name="_loginButtonsLoggedInDropdownActions">
{{#if allowChangingPassword}}
<div class="login-button" id="login-buttons-open-change-password">
Change password
@@ -45,37 +45,37 @@
<!-- -->
<!-- LOGGED OUT -->
<!-- -->
<template name="loginButtonsLoggedOutDropdown">
<template name="_loginButtonsLoggedOutDropdown">
<div class="login-link-and-dropdown-list {{additionalClasses}}">
<a class="login-link-text" id="login-sign-in-link">Sign in ▾</a>
{{#if dropdownVisible}}
<div id="login-dropdown-list" class="accounts-dialog">
<a class="login-close-text">Close</a>
<div class="login-close-text-clear"></div>
{{> loginButtonsLoggedOutAllServices}}
{{> _loginButtonsLoggedOutAllServices}}
</div>
{{/if}}
</div>
</template>
<template name="loginButtonsLoggedOutAllServices">
<template name="_loginButtonsLoggedOutAllServices">
{{#each services}}
{{#if isPasswordService}}
{{#if hasOtherServices}} {{! the password service will always come last }}
{{> loginButtonsLoggedOutPasswordServiceSeparator}}
{{> _loginButtonsLoggedOutPasswordServiceSeparator}}
{{/if}}
{{> loginButtonsLoggedOutPasswordService}}
{{> _loginButtonsLoggedOutPasswordService}}
{{else}}
{{> loginButtonsLoggedOutSingleLoginButton}}
{{> _loginButtonsLoggedOutSingleLoginButton}}
{{/if}}
{{/each}}
{{#unless hasPasswordService}}
{{> loginButtonsMessages}}
{{> _loginButtonsMessages}}
{{/unless}}
</template>
<template name="loginButtonsLoggedOutPasswordServiceSeparator">
<template name="_loginButtonsLoggedOutPasswordServiceSeparator">
<div class="or">
<span class="hline">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span class="or-text">or</span>
@@ -83,16 +83,16 @@
</div>
</template>
<template name="loginButtonsLoggedOutPasswordService">
<template name="_loginButtonsLoggedOutPasswordService">
{{#if inForgotPasswordFlow}}
{{> forgotPasswordForm}}
{{> _forgotPasswordForm}}
{{else}}
<div class="login-form login-password-form">
{{#each fields}}
{{> loginButtonsFormField}}
{{> _loginButtonsFormField}}
{{/each}}
{{> loginButtonsMessages}}
{{> _loginButtonsMessages}}
<div class="login-button login-button-form-submit" id="login-buttons-password">
{{#if inSignupFlow}}
@@ -115,36 +115,36 @@
{{/if}}
{{#if inSignupFlow}}
{{> loginButtonsBackToLoginLink}}
{{> _loginButtonsBackToLoginLink}}
{{/if}}
</div>
{{/if}}
</template>
<template name="forgotPasswordForm">
<template name="_forgotPasswordForm">
<div class="login-form">
<div id="forgot-password-email-label-and-input"> {{! XXX we should probably use loginButtonsFormField }}
<label id="forgot-password-email-label" for="forgot-password-email">Email</label>
<input id="forgot-password-email"/>
</div>
{{> loginButtonsMessages}}
{{> _loginButtonsMessages}}
<div class="login-button login-button-form-submit" id="login-buttons-forgot-password">
Reset password
</div>
{{> loginButtonsBackToLoginLink}}
{{> _loginButtonsBackToLoginLink}}
</div>
</template>
<template name="loginButtonsBackToLoginLink">
<template name="_loginButtonsBackToLoginLink">
<div class="additional-link-container">
<a id="back-to-login-link" class="additional-link">Sign in</a>
</div>
</template>
<template name="loginButtonsFormField">
<template name="_loginButtonsFormField">
{{#if visible}}
<div id="login-{{fieldName}}-label-and-input">
<label id="login-{{fieldName}}-label" for="login-{{fieldName}}">
@@ -155,12 +155,12 @@
{{/if}}
</template>
<template name="loginButtonsChangePassword">
<template name="_loginButtonsChangePassword">
{{#each fields}}
{{> loginButtonsFormField}}
{{> _loginButtonsFormField}}
{{/each}}
{{> loginButtonsMessages}}
{{> _loginButtonsMessages}}
<div class="login-button login-button-form-submit" id="login-buttons-do-change-password">
Change password

View File

@@ -20,30 +20,30 @@
// loginButtonsLoggedInDropdown template and related
//
Template.loginButtonsLoggedInDropdown.events({
Template._loginButtonsLoggedInDropdown.events({
'click #login-buttons-open-change-password': function() {
loginButtonsSession.resetMessages();
loginButtonsSession.set('inChangePasswordFlow', true);
}
});
Template.loginButtonsLoggedInDropdown.displayName = function () {
Template._loginButtonsLoggedInDropdown.displayName = function () {
return Accounts._loginButtons.displayName();
};
Template.loginButtonsLoggedInDropdown.inChangePasswordFlow = function () {
Template._loginButtonsLoggedInDropdown.inChangePasswordFlow = function () {
return loginButtonsSession.get('inChangePasswordFlow');
};
Template.loginButtonsLoggedInDropdown.inMessageOnlyFlow = function () {
Template._loginButtonsLoggedInDropdown.inMessageOnlyFlow = function () {
return loginButtonsSession.get('inMessageOnlyFlow');
};
Template.loginButtonsLoggedInDropdown.dropdownVisible = function () {
Template._loginButtonsLoggedInDropdown.dropdownVisible = function () {
return loginButtonsSession.get('dropdownVisible');
};
Template.loginButtonsLoggedInDropdownActions.allowChangingPassword = function () {
Template._loginButtonsLoggedInDropdownActions.allowChangingPassword = function () {
// it would be more correct to check whether the user has a password set,
// but in order to do that we'd have to send more data down to the client,
// and it'd be preferable not to send down the entire service.password document.
@@ -58,7 +58,7 @@
// loginButtonsLoggedOutDropdown template and related
//
Template.loginButtonsLoggedOutDropdown.events({
Template._loginButtonsLoggedOutDropdown.events({
'click #login-buttons-password': function () {
loginOrSignup();
},
@@ -157,7 +157,7 @@
});
// additional classes that can be helpful in styling the dropdown
Template.loginButtonsLoggedOutDropdown.additionalClasses = function () {
Template._loginButtonsLoggedOutDropdown.additionalClasses = function () {
if (!Accounts.password) {
return false;
} else {
@@ -171,31 +171,31 @@
}
};
Template.loginButtonsLoggedOutDropdown.dropdownVisible = function () {
Template._loginButtonsLoggedOutDropdown.dropdownVisible = function () {
return loginButtonsSession.get('dropdownVisible');
};
Template.loginButtonsLoggedOutDropdown.hasPasswordService = function () {
Template._loginButtonsLoggedOutDropdown.hasPasswordService = function () {
return Accounts._loginButtons.hasPasswordService();
};
Template.loginButtonsLoggedOutAllServices.services = function () {
Template._loginButtonsLoggedOutAllServices.services = function () {
return Accounts._loginButtons.getLoginServices();
};
Template.loginButtonsLoggedOutAllServices.isPasswordService = function () {
Template._loginButtonsLoggedOutAllServices.isPasswordService = function () {
return this.name === 'password';
};
Template.loginButtonsLoggedOutAllServices.hasOtherServices = function () {
Template._loginButtonsLoggedOutAllServices.hasOtherServices = function () {
return Accounts._loginButtons.getLoginServices().length > 1;
};
Template.loginButtonsLoggedOutAllServices.hasPasswordService = function () {
Template._loginButtonsLoggedOutAllServices.hasPasswordService = function () {
return Accounts._loginButtons.hasPasswordService();
};
Template.loginButtonsLoggedOutPasswordService.fields = function () {
Template._loginButtonsLoggedOutPasswordService.fields = function () {
var loginFields = [
{fieldName: 'username-or-email', fieldLabel: 'Username or Email',
visible: function () {
@@ -242,19 +242,19 @@
return loginButtonsSession.get('inSignupFlow') ? signupFields : loginFields;
};
Template.loginButtonsLoggedOutPasswordService.inForgotPasswordFlow = function () {
Template._loginButtonsLoggedOutPasswordService.inForgotPasswordFlow = function () {
return loginButtonsSession.get('inForgotPasswordFlow');
};
Template.loginButtonsLoggedOutPasswordService.inLoginFlow = function () {
Template._loginButtonsLoggedOutPasswordService.inLoginFlow = function () {
return !loginButtonsSession.get('inSignupFlow') && !loginButtonsSession.get('inForgotPasswordFlow');
};
Template.loginButtonsLoggedOutPasswordService.inSignupFlow = function () {
Template._loginButtonsLoggedOutPasswordService.inSignupFlow = function () {
return loginButtonsSession.get('inSignupFlow');
};
Template.loginButtonsLoggedOutPasswordService.showForgotPasswordLink = function () {
Template._loginButtonsLoggedOutPasswordService.showForgotPasswordLink = function () {
return Accounts._options.requireEmail
|| !Accounts._options.requireUsername;
};
@@ -264,7 +264,7 @@
// loginButtonsChangePassword template
//
Template.loginButtonsChangePassword.events({
Template._loginButtonsChangePassword.events({
'keypress #login-old-password, keypress #login-password, keypress #login-password-again': function (event) {
if (event.keyCode === 13)
changePassword();
@@ -274,7 +274,7 @@
}
});
Template.loginButtonsChangePassword.fields = function () {
Template._loginButtonsChangePassword.fields = function () {
return [
{fieldName: 'old-password', fieldLabel: 'Current Password', inputType: 'password',
visible: function () {

View File

@@ -1,4 +1,4 @@
<template name="loginButtonsLoggedOutSingleLoginButton">
<template name="_loginButtonsLoggedOutSingleLoginButton">
<div class="login-button {{#unless configured}}configure-button{{/unless}}"
id="login-buttons-{{name}}">
<div class="login-image" id="login-buttons-image-{{name}}"></div>

View File

@@ -2,7 +2,7 @@
// for convenience
var loginButtonsSession = Accounts._loginButtonsSession;
Template.loginButtonsLoggedOutSingleLoginButton.events({
Template._loginButtonsLoggedOutSingleLoginButton.events({
'click .login-button': function () {
var serviceName = this.name;
loginButtonsSession.resetMessages();
@@ -20,11 +20,11 @@
}
});
Template.loginButtonsLoggedOutSingleLoginButton.configured = function () {
Template._loginButtonsLoggedOutSingleLoginButton.configured = function () {
return !!Accounts.configuration.findOne({service: this.name});
};
Template.loginButtonsLoggedOutSingleLoginButton.capitalizedName = function () {
Template._loginButtonsLoggedOutSingleLoginButton.capitalizedName = function () {
if (this.name === 'github')
// XXX we should allow service packages to set their capitalized name
return 'GitHub';