Commit 5dc5f5f9 by AlasdairSwan

Merge pull request #5849 from edx/alasdair/logistration-form-order-update

ECOM-587 and ECOM-585 Switched tab order based on url and on selection o...
parents 864040ee 8a62991f
...@@ -29,7 +29,7 @@ var edx = edx || {}; ...@@ -29,7 +29,7 @@ var edx = edx || {};
* (all but include, contains, and reverse) into the * (all but include, contains, and reverse) into the
* Underscore namespace * Underscore namespace
*/ */
_.mixin(_.str.exports()) _.mixin( _.str.exports() );
this.tpl = $(this.tpl).html(); this.tpl = $(this.tpl).html();
this.activeForm = obj.mode || 'login'; this.activeForm = obj.mode || 'login';
...@@ -132,7 +132,8 @@ var edx = edx || {}; ...@@ -132,7 +132,8 @@ var edx = edx || {};
toggleForm: function( e ) { toggleForm: function( e ) {
var type = $(e.currentTarget).val(), var type = $(e.currentTarget).val(),
$form = $('#' + type + '-form'); $form = $('#' + type + '-form'),
$anchor = $('#' + type + '-anchor');
if ( !this.form.isLoaded( $form ) ) { if ( !this.form.isLoaded( $form ) ) {
this.loadForm( type ); this.loadForm( type );
...@@ -140,6 +141,11 @@ var edx = edx || {}; ...@@ -140,6 +141,11 @@ var edx = edx || {};
this.element.hide( $(this.el).find('.form-wrapper') ); this.element.hide( $(this.el).find('.form-wrapper') );
this.element.show( $form ); this.element.show( $form );
// Scroll to top of selected form
$('html,body').animate({
scrollTop: $anchor.offset().top
},'slow');
}, },
form: { form: {
......
...@@ -73,9 +73,6 @@ var edx = edx || {}; ...@@ -73,9 +73,6 @@ var edx = edx || {};
if (providerUrl) { if (providerUrl) {
window.location.href = providerUrl; window.location.href = providerUrl;
} else {
// TODO -- error handling here
console.log('No URL available for third party auth provider');
} }
}, },
......
...@@ -28,8 +28,9 @@ var edx = edx || {}; ...@@ -28,8 +28,9 @@ var edx = edx || {};
var fields = html || ''; var fields = html || '';
$(this.el).html( _.template( this.tpl, { $(this.el).html( _.template( this.tpl, {
// We pass the context object to the template so that /* We pass the context object to the template so that
// we can perform variable interpolation using sprintf * we can perform variable interpolation using sprintf
*/
context: { context: {
fields: fields, fields: fields,
currentProvider: this.currentProvider, currentProvider: this.currentProvider,
...@@ -46,11 +47,8 @@ var edx = edx || {}; ...@@ -46,11 +47,8 @@ var edx = edx || {};
thirdPartyAuth: function( event ) { thirdPartyAuth: function( event ) {
var providerUrl = $(event.target).data('provider-url') || ''; var providerUrl = $(event.target).data('provider-url') || '';
if (providerUrl) { if ( providerUrl ) {
window.location.href = providerUrl; window.location.href = providerUrl;
} else {
// TODO -- error handling here
console.log('No URL available for third party auth provider');
} }
} }
}); });
......
...@@ -130,6 +130,7 @@ ...@@ -130,6 +130,7 @@
.form-field { .form-field {
@include clearfix; @include clearfix;
clear: both; clear: both;
position: relative;
width: 100%; width: 100%;
margin: 0 0 $baseline 0; margin: 0 0 $baseline 0;
...@@ -166,7 +167,6 @@ ...@@ -166,7 +167,6 @@
.field-link { .field-link {
position: relative; position: relative;
float: right;
color: $link-color-d1; color: $link-color-d1;
font-weight: $font-regular; font-weight: $font-regular;
text-decoration: none !important; // needed but nasty text-decoration: none !important; // needed but nasty
...@@ -371,6 +371,12 @@ ...@@ -371,6 +371,12 @@
@extend %inline-form-field-tablet; @extend %inline-form-field-tablet;
width: calc( 50% - 10px ); width: calc( 50% - 10px );
} }
.field-link {
position: absolute;
top: 0;
right: 0;
}
} }
} }
...@@ -412,6 +418,12 @@ ...@@ -412,6 +418,12 @@
@extend %inline-form-field-desktop; @extend %inline-form-field-desktop;
width: 100px; width: 100px;
} }
.field-link {
position: absolute;
top: 0;
right: 0;
}
} }
.login-provider { .login-provider {
......
...@@ -3,7 +3,17 @@ ...@@ -3,7 +3,17 @@
<p class="tagline"><%- gettext("Log in or register to take courses from the world's best universities.") %></p> <p class="tagline"><%- gettext("Log in or register to take courses from the world's best universities.") %></p>
</header> </header>
<section class="form-type"> <% if ( mode === 'login' ) { %>
<section id="register-anchor" class="form-type">
<h2>
<input type="radio" name="form" id="register-option" value="register" class="form-toggle" <% if ( mode === 'register' ) { %>checked<% } %> >
<label for="register-option" class="form-label"><%- gettext("I am a new user") %></label>
</h2>
<div id="register-form" class="form-wrapper <% if ( mode !== 'register' ) { %>hidden" aria-hidden="true<% } %>"></div>
</section>
<% } %>
<section id="login-anchor" class="form-type">
<h2> <h2>
<input type="radio" name="form" id="login-option" value="login" class="form-toggle" <% if ( mode === 'login' ) { %>checked<% } %>> <input type="radio" name="form" id="login-option" value="login" class="form-toggle" <% if ( mode === 'login' ) { %>checked<% } %>>
<label for="login-option" class="form-label"><%- gettext("I am a returning user") %></label> <label for="login-option" class="form-label"><%- gettext("I am a returning user") %></label>
...@@ -11,12 +21,14 @@ ...@@ -11,12 +21,14 @@
<div id="login-form" class="form-wrapper <% if ( mode !== 'login' ) { %>hidden" aria-hidden="true<% } %>"></div> <div id="login-form" class="form-wrapper <% if ( mode !== 'login' ) { %>hidden" aria-hidden="true<% } %>"></div>
</section> </section>
<section class="form-type"> <% if ( mode === 'register' ) { %>
<h2> <section id="register-anchor" class="form-type">
<input type="radio" name="form" id="register-option" value="register" class="form-toggle" <% if ( mode === 'register' ) { %>checked<% } %> > <h2>
<label for="register-option" class="form-label"><%- gettext("I am a new user") %></label> <input type="radio" name="form" id="register-option" value="register" class="form-toggle" <% if ( mode === 'register' ) { %>checked<% } %> >
</h2> <label for="register-option" class="form-label"><%- gettext("I am a new user") %></label>
<div id="register-form" class="form-wrapper <% if ( mode !== 'register' ) { %>hidden" aria-hidden="true<% } %>"></div> </h2>
</section> <div id="register-form" class="form-wrapper <% if ( mode !== 'register' ) { %>hidden" aria-hidden="true<% } %>"></div>
</section>
<% } %>
<div id="password-reset-wrapper"></div> <div id="password-reset-wrapper"></div>
...@@ -6,10 +6,6 @@ ...@@ -6,10 +6,6 @@
</label> </label>
<% } %> <% } %>
<% if( form === 'login' && name === 'password' ) { %>
<a href="#" class="forgot-password field-link"><%- gettext("Forgot password?") %></a>
<% } %>
<% if ( type === 'select' ) { %> <% if ( type === 'select' ) { %>
<select id="<%= form %>-<%= name %>" <select id="<%= form %>-<%= name %>"
name="<%= name %>" name="<%= name %>"
...@@ -59,5 +55,9 @@ ...@@ -59,5 +55,9 @@
</label> </label>
<% } %> <% } %>
<% if( form === 'login' && name === 'password' ) { %>
<a href="#" class="forgot-password field-link"><%- gettext("Forgot password?") %></a>
<% } %>
<span id="<%= form %>-<%= name %>-desc" class="desc"><%= instructions %></span> <span id="<%= form %>-<%= name %>-desc" class="desc"><%= instructions %></span>
</p> </p>
...@@ -17,8 +17,10 @@ ...@@ -17,8 +17,10 @@
<button class="action action-primary action-update js-login"><%- gettext("Log in") %></button> <button class="action action-primary action-update js-login"><%- gettext("Log in") %></button>
</form> </form>
<% _.each( context.providers, function( provider ) { %> <% _.each( context.providers, function( provider ) {
<button type="submit"class="button button-primary button-<%- provider.name %> login-provider" data-provider-url="<%- provider.loginUrl %>"> if ( provider.loginUrl ) { %>
<span class="icon <%- provider.iconClass %>"></span><%- _.sprintf(gettext("Log in using %(name)s"), provider) %> <button type="submit"class="button button-primary button-<%- provider.name %> login-provider" data-provider-url="<%- provider.loginUrl %>">
</button> <span class="icon <%- provider.iconClass %>"></span><%- _.sprintf(gettext("Log in using %(name)s"), provider) %>
<% }); %> </button>
<% }
}); %>
...@@ -6,11 +6,13 @@ ...@@ -6,11 +6,13 @@
</p> </p>
</div> </div>
<% } else { <% } else {
_.each( context.providers, function( provider) { %> _.each( context.providers, function( provider) {
<button type="submit"class="button button-primary button-<%- provider.name %> login-provider" data-provider-url="<%- provider.registerUrl %>"> if ( provider.registerUrl ) { %>
<span class="icon <%- provider.iconClass %>"></span><%- _.sprintf(gettext("Register using %(name)s"), provider) %> <button type="submit"class="button button-primary button-<%- provider.name %> login-provider" data-provider-url="<%- provider.registerUrl %>">
</button> <span class="icon <%- provider.iconClass %>"></span><%- _.sprintf(gettext("Register using %(name)s"), provider) %>
<% }); </button>
<% }
});
} %> } %>
<form id="register" autocomplete="off"> <form id="register" autocomplete="off">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment