Commit 2602ee8dcaeddd09c71ca3603bee577f2b226057
Exists in
master
and in
5 other branches
Merge branch 'fix-login-feedback'
Showing
5 changed files
with
56 additions
and
12 deletions
Show diff stats
3.2 KB
2.89 KB
3.2 KB
js/main.js
... | ... | @@ -206,7 +206,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
206 | 206 | var requireLoginContainer = loginButton.closest('.require-login-container'); |
207 | 207 | |
208 | 208 | if(logged_in) { |
209 | - $('.logout').show(); | |
209 | + Main.showLogout(); | |
210 | 210 | if(token){ |
211 | 211 | Main.private_token = token; |
212 | 212 | } |
... | ... | @@ -228,7 +228,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
228 | 228 | } else { |
229 | 229 | requireLoginContainer.find('.require-login').hide(); |
230 | 230 | requireLoginContainer.find('.login-container').show(); |
231 | - $('.logout').hide(); | |
231 | + Main.showLogin(); | |
232 | 232 | } |
233 | 233 | }, |
234 | 234 | guid: function() { |
... | ... | @@ -561,10 +561,11 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
561 | 561 | } |
562 | 562 | }, 300); |
563 | 563 | }, |
564 | - displaySuccess: function(container, text, timeout) { | |
564 | + displaySuccess: function(container, text, timeout, iconClass) { | |
565 | 565 | timeout = typeof timeout !== 'undefined' ? timeout : 2000; |
566 | 566 | container.css('opacity', 0.1); |
567 | 567 | var successPanel = $('.success-panel').clone(); |
568 | + successPanel.find('.icon').addClass(iconClass); | |
568 | 569 | successPanel.find('.message').html(text); |
569 | 570 | successPanel.appendTo(container.closest('.categories')); |
570 | 571 | successPanel.show(); |
... | ... | @@ -577,6 +578,25 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
577 | 578 | successPanel.remove(); |
578 | 579 | }, timeout); |
579 | 580 | }, |
581 | + setUser: function(user){ | |
582 | + this.user = user; | |
583 | + }, | |
584 | + getUser: function(){ | |
585 | + return this.user; | |
586 | + }, | |
587 | + showLogin: function(){ | |
588 | + $('.entrar').show(); | |
589 | + $('.logout').hide(); | |
590 | + }, | |
591 | + showLogout: function(){ | |
592 | + $('.entrar').hide(); | |
593 | + var name = ''; | |
594 | + if(this.user){ | |
595 | + name = this.user.person.name + ' | '; | |
596 | + } | |
597 | + $('.logout').text(name + 'Sair'); | |
598 | + $('.logout').show(); | |
599 | + }, | |
580 | 600 | responseToText: function(responseJSONmessage){ |
581 | 601 | var o = JSON.parse(responseJSONmessage); |
582 | 602 | var msg = ""; |
... | ... | @@ -757,7 +777,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
757 | 777 | $form.siblings('.success-sent').show(); |
758 | 778 | $form.siblings('.subtitle').hide(); |
759 | 779 | $form.siblings('.info').hide(); |
760 | - Main.displaySuccess($form.closest('.make-proposal .section-content'), 'Proposta enviada com sucesso', 2000); | |
780 | + Main.displaySuccess($form.closest('.make-proposal .section-content'), 'Proposta enviada com sucesso', 2000, 'icon-proposal-sent'); | |
761 | 781 | }) |
762 | 782 | .fail(function( jqxhr, textStatus, error ) { |
763 | 783 | var err = textStatus + ', ' + error; |
... | ... | @@ -786,10 +806,14 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
786 | 806 | |
787 | 807 | if($.cookie('_dialoga_session')) { |
788 | 808 | var url = host + '/api/v1/users/me?private_token=' + $.cookie('_dialoga_session'); |
789 | - $.getJSON(url).done(function( /*data*/ ) { | |
809 | + $.getJSON(url).done(function( data ) { | |
790 | 810 | logged_in = true; |
791 | 811 | Main.private_token = $.cookie('_dialoga_session'); |
792 | - setTimeout(function(){ $('.logout').show(); }, 2000); | |
812 | + | |
813 | + if(data && data.user){ | |
814 | + Main.setUser(data.user); | |
815 | + Main.showLogout(); | |
816 | + } | |
793 | 817 | }); |
794 | 818 | } |
795 | 819 | |
... | ... | @@ -807,7 +831,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
807 | 831 | } |
808 | 832 | }).done(function(data) { |
809 | 833 | Main.loginCallback(true, data.private_token); |
810 | - Main.displaySuccess(button.closest('.section-content'), 'Login efetuado com sucesso', 1000); | |
834 | + Main.displaySuccess(button.closest('.section-content'), 'Login efetuado com sucesso', 1000, 'icon-login-success'); | |
811 | 835 | }).fail(function( /*data*/ ) { |
812 | 836 | message.show(); |
813 | 837 | message.text('Não foi possível logar'); |
... | ... | @@ -866,7 +890,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
866 | 890 | data: $(this).parents('.signup').serialize(), |
867 | 891 | }).done(function(data) { |
868 | 892 | Main.loginCallback(true, data.private_token); |
869 | - Main.displaySuccess(button.closest('.section-content'), 'Cadastro efetuado com sucesso', 1000); | |
893 | + Main.displaySuccess(button.closest('.section-content'), 'Cadastro efetuado com sucesso', 1000, 'icon-user-created'); | |
870 | 894 | }).fail(function(data) { |
871 | 895 | var msg = Main.responseToText(data.responseJSON.message); |
872 | 896 | message.show(); |
... | ... | @@ -909,8 +933,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F |
909 | 933 | $.removeCookie('votedProposals'); |
910 | 934 | $.removeCookie('*'); |
911 | 935 | logged_in = false; |
912 | - $('.logout').hide(); | |
913 | - $('.entrar').show(); | |
936 | + Main.showLogin(); | |
914 | 937 | location.reload(); |
915 | 938 | e.preventDefault(); |
916 | 939 | }); | ... | ... |
sass/style.sass
... | ... | @@ -311,6 +311,21 @@ textarea |
311 | 311 | background-color: #32dbb5 |
312 | 312 | border-bottom: 3px solid darken(#32dbb5, $darken) !important |
313 | 313 | +hover(#32dbb5, $darken) |
314 | + &-user-created | |
315 | + height: 71px | |
316 | + width: 71px | |
317 | + background: url(images/icons/icon-user-created.png) no-repeat 50% 50% | |
318 | + border-radius: 0 | |
319 | + &-login-success | |
320 | + height: 71px | |
321 | + width: 71px | |
322 | + background: url(images/icons/icon-login-success.png) no-repeat 50% 50% | |
323 | + border-radius: 0 | |
324 | + &-proposal-sent | |
325 | + height: 71px | |
326 | + width: 71px | |
327 | + background: url(images/icons/icon-proposal-sent.png) no-repeat 50% 50% | |
328 | + border-radius: 0 | |
314 | 329 | |
315 | 330 | |
316 | 331 | // ------------------------------------ |
... | ... | @@ -654,8 +669,13 @@ h1 |
654 | 669 | padding: 2px 10px |
655 | 670 | .entrar |
656 | 671 | background: url(images/icons/icon-user.png) no-repeat 20px 50% |
657 | - border-left: 1px solid #bcbcbc | |
658 | - margin-left: 20px | |
672 | + // border-left: 1px solid #bcbcbc | |
673 | + // margin-left: 20px | |
674 | + padding-left: 40px | |
675 | + .logout | |
676 | + background: url(images/icons/icon-user.png) no-repeat 20px 50% | |
677 | + // border-left: 1px solid #bcbcbc | |
678 | + // margin-left: 20px | |
659 | 679 | padding-left: 40px |
660 | 680 | .login,.signup |
661 | 681 | text-align: left |
... | ... | @@ -936,6 +956,7 @@ td |
936 | 956 | .success-panel |
937 | 957 | position: absolute |
938 | 958 | z-index: 100 |
959 | + text-align: center | |
939 | 960 | |
940 | 961 | // ------------------------------------ |
941 | 962 | // 7 - Modificadores | ... | ... |