Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separating edit and new partial for the sign up modal #4203

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@
<ul class="nav navbar-nav navbar-right">
<% if current_user %>
<li class="hidden-sm hidden-md">
<a rel="tooltip" title="<%= t('layout._header.your_dashboard') %>" data-placement="bottom" href="/dashboard">Dashboard <i class="fa fa-white fa-home" aria-hidden="true"></i></a>
<a rel="tooltip" title="<%= t('layout._header.your_dashboard') %>" data-placement="bottom" href="/dashboard">Dashboard</i></a>
</li>
<% else %>
<li class="hidden-sm hidden-md"> <!-- signup -->
<a rel="tooltip" title="<%= t('layout._header.become_part_community') %>" href="/signup"><%= t('layout._header.join') %></a>
<a rel="tooltip" title="<%= t('layout._header.become_part_community') %>" data-toggle="modal" data-target="#signupModal"><%= t('layout._header.join') %></a>
</li>
<% end %>

<li class="dropdown">
<% unless params[:action] == "register" || params[:action] == "signup" %>
<% if current_user %>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Profile <i class="fa fa-white fa-user" aria-hidden="true" ></i>
Profile <i class="fa fa-white fa-caret-down"></i>
</a>
<ul class="dropdown-menu">
<div class="dropdown-header">
Expand Down Expand Up @@ -191,20 +191,35 @@
</div>
</div>

<!-- Signup Modal -->
<div class="modal fade" id="signupModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<div class="clearfix">
<%= render :partial => "users/form2" %>
</div>
</div>
</div>

</div>
</div>

<style>
.modal {
text-align: center;
padding: 0!important;
}

.modal:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -4px;
}

.modal-dialog {
display: inline-block;
text-align: left;
Expand Down
20 changes: 10 additions & 10 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
<div class='col-lg-10 col-md-10 col-sm-10' style="display:flex; justify-content: center;">
<%= render :partial => "layouts/social_icons" %>
</div>

<br style="clear:both;"/>

<div id="toggle">
<div class="form-group">

<label for="username"><%= t('users._form.username') %></label>
<%= f.text_field :username, { tabindex: 1, class: 'form-control', id: 'username' } %>

<input type="hidden" name="id" value="<%= @user.username %>" />
</div>

<% end %>

<div class="form-group">
<% if Rails.env == "production" %>
<% if params[:controller] == "users" && params[:action] == "edit" %>
Expand All @@ -38,13 +38,13 @@
<% end %>
<% end %>
<br style="clear:both;"/>

<label for="email"><%= t('users._form.email') %></label>
<%= f.text_field :email, { tabindex: 3, placeholder: "you@email.com", class: 'form-control', id: 'email' } %>

</div>


<div class="form-group">
<% if @user.crypted_password.nil? %>
<label for="password"><%= t('users._form.create_password') %></label>
Expand All @@ -57,7 +57,7 @@
id: 'password' }
%>
</div>

<div class="form-group">
<label for="password_confirmation"><%= t('users._form.confirmation') %></label>
<%= f.password_field :password_confirmation, { placeholder: I18n.t('users._form.confirm_password'),
Expand All @@ -66,7 +66,7 @@
id: 'password-confirmation' }
%>
</div>

</div>

<div class="form-group">
Expand Down
97 changes: 97 additions & 0 deletions app/views/users/_form2.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<div style="padding:10px;">
<%= form_for :user, :as => :user, :url => register_url + "?return_to=" + request.fullpath, :html => {:class => "row"} do |f| %>
SidharthBansal marked this conversation as resolved.
Show resolved Hide resolved
<% if f.error_messages != "" %><div class="alert alert-danger"><%= f.error_messages %></div><% end %>

<div class="col-sm-12">
<div class='col-sm-12' style="display:flex; justify-content: center;">
<h3> Sign up with </h3>
</div>

<div class='col-sm-12' style="display:flex; justify-content: center;">
<%= render :partial => "layouts/social_icons" %>
</div>

<br style="clear:both;"/>


<div class="row">

<div class="form-group col-sm-6">
<label for="username"><%= t('user_sessions.new.username') %></label>
<%= f.text_field :username, { tabindex: 1, class: 'form-control', id: 'username-signup' } %>
</div>

<div class="form-group col-sm-6">
<label for="email"><%= t('users._form.email') %></label>
<%= f.text_field :email, { tabindex: 3, placeholder: "you@email.com", class: 'form-control', id: 'email' } %>
</div>

</div>

<div class="row">
<div class="form-group col-sm-6">
<label for="password"><%= t('users._form.create_password') %></label>
<%= f.password_field :password, { placeholder: I18n.t('users._form.password'),
tabindex: 4,
class: 'form-control',
id: 'password' }
%>
</div>

<div class="form-group col-sm-6">
<label for="password_confirmation"><%= t('users._form.confirmation') %></label>
<%= f.password_field :password_confirmation, { placeholder: I18n.t('users._form.confirm_password'),
tabindex: 5,
class: 'form-control',
id: 'password-confirmation' }
%>
</div>

</div>

<div class="form-group">
<label for="user_bio"><%= t('users._form.bio') %></label>
<%= f.text_area :bio, { placeholder: I18n.t('users._form.add_bio'),
rows: 8,
class: 'form-control',
tabindex: 6 }
%>
</div>

<% if Rails.env == "production" && !params[:spamaway] %>
<%= recaptcha_tags %>
<p>If you cannot use the ReCaptcha to verify you are not a bot, <a href="/signup?spamaway=true">use this alternative verification</a>.</p>
<% else %>
<%= render partial: 'users/spamaway', locals: { spamaway: @spamaway } %>
<% end %>

<script>
(function() {
$('.spamaway button').click(function(e) {
$(this).find('input').prop('checked', true);
})
})();
</script>



<div class="form-group form-inline" style="clear:both;padding-top:10px;">
<!-- button for creating new users -->
<button class="btn btn-lg btn-primary btn-save" type="submit" tabindex="7"><%= t('users._form.sign_up') %></button>
<a class="btn btn-lg btn-default" href="/login"><%= t('users._form.log_in') %></a>

<script>
(function() {
$('.btn-save').click(function onClick(e) {
$(this).addClass("disabled") // disable the button after it is clicked
.html("<i class='fa fa-spinner fa-spin'></i>"); // make a spinner that spins when clicked
})
})();
</script>
</div>

</div>

</div>

<% end %>
2 changes: 1 addition & 1 deletion app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<br />

<%= render 'form' %>
<%= render 'form2' %>

<% cache('feature_signup-notice', skip_digest: true) do %>
<%= feature('signup-notice') %>
Expand Down