Permalink
Browse files

login/logout popover

  • Loading branch information...
1 parent b5fbf4c commit f20442b1bd12f797e784e7adfe8e4a9886cacfa0 @mccolin committed Apr 5, 2012
@@ -17,7 +17,19 @@ jQuery.fn.autoabbr = function () {
});
}
+
$(function(){
+
+ // Automatically wrap "WOSoMP" in <abbr> tags within primary content:
$("div#primary-content").autoabbr();
+
+ // Make the account indicator menu item a popover:
+ $("#top-nav #link-account a").popover({placement:'bottom',trigger:'manual', content: $("#account-box-content").html() });
+ $("#top-nav #link-account a").click(function(e){
+ e.preventDefault();
+ $(this).popover('toggle');
+ return(false);
+ });
+
});
@@ -3,7 +3,7 @@
class HomeController < ApplicationController
- before_filter :authenticate_user!
+ before_filter :authenticate_user!, :except=>[:index]
def index
flash.now[:info] = "You are wonderful and awesome!"
@@ -14,12 +14,12 @@ def login_logout_link(opts={})
logout_opts = opts.delete(:logout) || {}
login_opts = opts.delete(:login) || {}
if user_signed_in?
- opts = opts.merge(logout_opts).merge(:method=>:delete)
- link_to(raw("<i class='icon-user icon-white'></i> Logout"), destroy_user_session_path, opts)
+ opts = opts.merge(logout_opts).merge(:method=>:delete, :title=>"Your Account")
+ link_to(raw("<i class='icon-user icon-white'></i> #{current_user.name}"), destroy_user_session_path, opts)
else
- opts.merge!(login_opts)
- # link_to("Login", new_user_session_path, opts)
- link_to(raw("<i class='icon-user icon-white'></i> Login with Facebook"), user_omniauth_authorize_path(:facebook), opts)
+ opts = opts.merge(login_opts).merge(:title=>"Login")
+ # link_to(raw("<i class='icon-user icon-white'></i> Login with Facebook"), new_user_session_path, opts)
+ link_to(raw("<i class='icon-user icon-white'></i> Login or Register"), user_omniauth_authorize_path(:facebook), opts)
end
end
View
@@ -11,6 +11,9 @@ class User < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :first_name, :last_name, :password, :password_confirmation, :remember_me
+ # Quick combined accessors:
+ def name; "#{first_name} #{last_name}"; end
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -41,7 +41,7 @@
<li id="link-about"><%=link_to raw("<i class='icon-question-sign icon-white'></i> About"), about_path%></li>
<li id="link-olympiad"><%=link_to raw("<i class='icon-fire icon-white'></i> #{next_olympiad_name}"), olympiad_path(next_olympiad) %></li>
<li id="link-history"><%=link_to raw("<i class='icon-time icon-white'></i> History"), olympiads_path%></li>
- <li id="link-login"><%=login_logout_link(:login=>{:id=>"facebook-login-button"})%></li>
+ <li id="link-account"><%=login_logout_link(:login=>{:id=>"facebook-login-button"})%></li>
</ul>
</div><!--/.nav-collapse -->
</div>
@@ -77,6 +77,17 @@
</footer>
</div> <!-- /container -->
+
+ <div id="account-box-content">
+ <% if user_signed_in? %>
+ <p>You are super-cool. Thanks for being awesome, <%=current_user.name%></p>
+ <%=link_to(raw("<i class='icon-user icon-white'></i> #{current_user.name}"), destroy_user_session_path, {})-%>
+ <% else %>
+ <p>You can become cool by signing up or logging in:</p>
+ <%=link_to(raw("<i class='icon-user icon-white'></i> Login or Register"), user_omniauth_authorize_path(:facebook), {})%>
+ <% end %>
+ </div>
+
<!-- Le javascript
================================================== -->

0 comments on commit f20442b

Please sign in to comment.