Commit af08948e5c3218cbb7610983994b752d5bd099aa
Committed by
Leandro Santos
1 parent
8e2f02dc
Exists in
staging
and in
42 other branches
Infra to display login popup when not logged users click in a link
Showing
2 changed files
with
30 additions
and
1 deletions
Show diff stats
lib/authenticated_system.rb
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +(function($) { | |
| 2 | + $(window).bind('userDataLoaded', function(event, data) { | |
| 3 | + $(".require-login-popup").live('click', function(){ | |
| 4 | + clicked = $(this); | |
| 5 | + url = clicked.attr("href"); | |
| 6 | + if(url!=undefined && url!='' && url!='#') { | |
| 7 | + if(!data.login) { | |
| 8 | + url = $.param.querystring(url, "require_login_popup=true"); | |
| 9 | + } | |
| 10 | + loading_for_button(this); | |
| 11 | + $.post(url, function(data){ | |
| 12 | + if(data.require_login_popup) { | |
| 13 | + $('#link_login').click(); //TODO see a better way to show login popup | |
| 14 | + } | |
| 15 | + }).complete(function() { | |
| 16 | + clicked.css("cursor",""); | |
| 17 | + $(".small-loading").remove(); | |
| 18 | + }); | |
| 19 | + } else { | |
| 20 | + $('#link_login').click(); | |
| 21 | + } | |
| 22 | + return false; | |
| 23 | + }); | |
| 24 | + }); | |
| 25 | +})(jQuery); | ... | ... |