Skip to content

Commit

Permalink
Turned sign in form into a modal that falls back to a plain form when…
Browse files Browse the repository at this point in the history
… JS is turned off
  • Loading branch information
brzaik committed Jun 3, 2012
1 parent 369621e commit 23567aa
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,16 @@
@include border-radius-corners(0px, 0px, 5px, 5px);
}

/* Class applied to remove inner box padding for tooltip */
.ui-tooltip-nopadding .ui-tooltip-content {
padding: 0px !important;
}

/* Class applied to make width auto for tooltip content (use sparingly and test!) */
.ui-tooltip-autowidth {
width: auto !important;
max-width: none !important;
}

.ui-tooltip:not(.ie9haxors) div {
&.ui-tooltip-content, &.ui-tooltip-titlebar {
Expand Down
20 changes: 13 additions & 7 deletions app/assets/stylesheets/application/layout/forms.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,21 @@ textarea[readonly] {
padding-left: 0px;
}

label {
display: block;
float: none;
width: auto;
text-align: left;
fieldset {
padding-left: 20px;
padding-right: 20px;
}

.clearfix {
margin-bottom: $baseline / 2;

> label {
display: block;
float: none !important;
width: auto !important;
text-align: left !important;
}

div.input {
margin-left: 0;
}
Expand All @@ -480,8 +486,8 @@ textarea[readonly] {
margin-top: 0;
margin-left: -10px;
}

.actions {
margin-left: -20px;
padding-left: 20px;
}
}
Expand Down
20 changes: 20 additions & 0 deletions app/controllers/concerto_devise/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#Overriding the Devise Sessions controller for fun and profit
class ConcertoDevise::SessionsController < Devise::SessionsController

# GET /resource/sign_in
def new
resource = build_resource(nil, :unsafe => true)
clean_up_passwords(resource)

# if :no_content_cell param is set to true, do not render the layout or the content cell container within the view
if params[:no_content_cell]
respond_with(resource) do |format|
format.html { render :layout => false }
end
else
respond_with (resource)
end

end

end
7 changes: 5 additions & 2 deletions app/views/devise/sessions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
</div>
</div>
<% if devise_mapping.rememberable? -%>
<div class="input">
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
<div class="clearfix">
<label>&nbsp;</label>
<div class="input">
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
</div>
</div>
<% end -%>
</fieldset>
Expand Down
31 changes: 19 additions & 12 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<section class="C no">
<header>
<%= back_button :back %>
<h1>Sign In</h1>
</header>
<div class="C-cont">
<article>
<%= render 'form' %>
</article>
<div class="clear"></div>
</div>
</section>
<% if params[:no_content_cell] %>
<div class="form-stacked">
<%= render 'form' %>
</div>
<% else %>
<section class="C no">
<header>
<%= back_button :back %>
<h1>Sign In</h1>
</header>
<div class="C-cont">
<article>
<%= render 'form' %>
</article>
<div class="clear"></div>
</div>
</section>
<% end %>

43 changes: 42 additions & 1 deletion app/views/elements/_topmenu_contents.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<nav id="TM">
<% if not user_signed_in? %>
<%= link_to "Concerto", "/", :id => "TM-logobutton" %>
<p id="TM-logintext"><%= link_to t(:sign_in), new_user_session_path %> <%=t(:signin_login_spiel) %> <% if ConcertoConfig[:allow_registration] == "true" %>No account? <%= link_to t(:sign_up), new_user_registration_path %> now!<% end %></p>
<p id="TM-logintext"><%= link_to t(:sign_in), new_user_session_path, :id => "login-dropdown" %> <%=t(:signin_login_spiel) %> <% if ConcertoConfig[:allow_registration] == "true" %>No account? <%= link_to t(:sign_up), new_user_registration_path %> now!<% end %></p>
<% else %>
<%= link_to "Concerto", "/", :id => "TM-logobutton", :class => "full" %>

Expand Down Expand Up @@ -71,4 +71,45 @@
<% end %>
<div class="clear"></div>
</nav>

<script type="text/javascript">

$(document).ready(function() {

$("#login-dropdown").each(function() {

$(this).qtip({
content: {
text: 'Loading...', // use this text while loading content via AJAX
ajax: {
url: '/users/sign_in?no_content_cell=1',
type: 'GET'
}
},

position: {
at: 'bottom center', // Position the tooltip above the link
my: 'top left',
viewport: $(window) // Keep the tooltip on-screen at all times
},

show: {
event: 'click', // Show it on click...
solo: true // ...and hide all other tooltips...
},

hide: 'unfocus',
style: 'ui-tooltip-light ui-tooltip-shadow ui-tooltip-rounded ui-tooltip-nopadding ui-tooltip-autowidth'

})

})

.click(function(e) { e.preventDefault(); });

});

</script>


<!--googleon: all-->
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
# End really dangerous routes.


devise_for :users, :controllers => {:registrations => 'concerto_devise/registrations'}
devise_for :users,
:controllers => {
:registrations => 'concerto_devise/registrations',
:sessions => 'concerto_devise/sessions' }

resources :users

resources :media, :only => [:show]
Expand Down

0 comments on commit 23567aa

Please sign in to comment.