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,7 +206,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 206 | var requireLoginContainer = loginButton.closest('.require-login-container'); | 206 | var requireLoginContainer = loginButton.closest('.require-login-container'); |
| 207 | 207 | ||
| 208 | if(logged_in) { | 208 | if(logged_in) { |
| 209 | - $('.logout').show(); | 209 | + Main.showLogout(); |
| 210 | if(token){ | 210 | if(token){ |
| 211 | Main.private_token = token; | 211 | Main.private_token = token; |
| 212 | } | 212 | } |
| @@ -228,7 +228,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -228,7 +228,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 228 | } else { | 228 | } else { |
| 229 | requireLoginContainer.find('.require-login').hide(); | 229 | requireLoginContainer.find('.require-login').hide(); |
| 230 | requireLoginContainer.find('.login-container').show(); | 230 | requireLoginContainer.find('.login-container').show(); |
| 231 | - $('.logout').hide(); | 231 | + Main.showLogin(); |
| 232 | } | 232 | } |
| 233 | }, | 233 | }, |
| 234 | guid: function() { | 234 | guid: function() { |
| @@ -561,10 +561,11 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -561,10 +561,11 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 561 | } | 561 | } |
| 562 | }, 300); | 562 | }, 300); |
| 563 | }, | 563 | }, |
| 564 | - displaySuccess: function(container, text, timeout) { | 564 | + displaySuccess: function(container, text, timeout, iconClass) { |
| 565 | timeout = typeof timeout !== 'undefined' ? timeout : 2000; | 565 | timeout = typeof timeout !== 'undefined' ? timeout : 2000; |
| 566 | container.css('opacity', 0.1); | 566 | container.css('opacity', 0.1); |
| 567 | var successPanel = $('.success-panel').clone(); | 567 | var successPanel = $('.success-panel').clone(); |
| 568 | + successPanel.find('.icon').addClass(iconClass); | ||
| 568 | successPanel.find('.message').html(text); | 569 | successPanel.find('.message').html(text); |
| 569 | successPanel.appendTo(container.closest('.categories')); | 570 | successPanel.appendTo(container.closest('.categories')); |
| 570 | successPanel.show(); | 571 | successPanel.show(); |
| @@ -577,6 +578,25 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -577,6 +578,25 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 577 | successPanel.remove(); | 578 | successPanel.remove(); |
| 578 | }, timeout); | 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 | responseToText: function(responseJSONmessage){ | 600 | responseToText: function(responseJSONmessage){ |
| 581 | var o = JSON.parse(responseJSONmessage); | 601 | var o = JSON.parse(responseJSONmessage); |
| 582 | var msg = ""; | 602 | var msg = ""; |
| @@ -757,7 +777,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -757,7 +777,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 757 | $form.siblings('.success-sent').show(); | 777 | $form.siblings('.success-sent').show(); |
| 758 | $form.siblings('.subtitle').hide(); | 778 | $form.siblings('.subtitle').hide(); |
| 759 | $form.siblings('.info').hide(); | 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 | .fail(function( jqxhr, textStatus, error ) { | 782 | .fail(function( jqxhr, textStatus, error ) { |
| 763 | var err = textStatus + ', ' + error; | 783 | var err = textStatus + ', ' + error; |
| @@ -786,10 +806,14 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -786,10 +806,14 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 786 | 806 | ||
| 787 | if($.cookie('_dialoga_session')) { | 807 | if($.cookie('_dialoga_session')) { |
| 788 | var url = host + '/api/v1/users/me?private_token=' + $.cookie('_dialoga_session'); | 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 | logged_in = true; | 810 | logged_in = true; |
| 791 | Main.private_token = $.cookie('_dialoga_session'); | 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,7 +831,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 807 | } | 831 | } |
| 808 | }).done(function(data) { | 832 | }).done(function(data) { |
| 809 | Main.loginCallback(true, data.private_token); | 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 | }).fail(function( /*data*/ ) { | 835 | }).fail(function( /*data*/ ) { |
| 812 | message.show(); | 836 | message.show(); |
| 813 | message.text('Não foi possível logar'); | 837 | message.text('Não foi possível logar'); |
| @@ -866,7 +890,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -866,7 +890,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 866 | data: $(this).parents('.signup').serialize(), | 890 | data: $(this).parents('.signup').serialize(), |
| 867 | }).done(function(data) { | 891 | }).done(function(data) { |
| 868 | Main.loginCallback(true, data.private_token); | 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 | }).fail(function(data) { | 894 | }).fail(function(data) { |
| 871 | var msg = Main.responseToText(data.responseJSON.message); | 895 | var msg = Main.responseToText(data.responseJSON.message); |
| 872 | message.show(); | 896 | message.show(); |
| @@ -909,8 +933,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -909,8 +933,7 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
| 909 | $.removeCookie('votedProposals'); | 933 | $.removeCookie('votedProposals'); |
| 910 | $.removeCookie('*'); | 934 | $.removeCookie('*'); |
| 911 | logged_in = false; | 935 | logged_in = false; |
| 912 | - $('.logout').hide(); | ||
| 913 | - $('.entrar').show(); | 936 | + Main.showLogin(); |
| 914 | location.reload(); | 937 | location.reload(); |
| 915 | e.preventDefault(); | 938 | e.preventDefault(); |
| 916 | }); | 939 | }); |
sass/style.sass
| @@ -311,6 +311,21 @@ textarea | @@ -311,6 +311,21 @@ textarea | ||
| 311 | background-color: #32dbb5 | 311 | background-color: #32dbb5 |
| 312 | border-bottom: 3px solid darken(#32dbb5, $darken) !important | 312 | border-bottom: 3px solid darken(#32dbb5, $darken) !important |
| 313 | +hover(#32dbb5, $darken) | 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,8 +669,13 @@ h1 | ||
| 654 | padding: 2px 10px | 669 | padding: 2px 10px |
| 655 | .entrar | 670 | .entrar |
| 656 | background: url(images/icons/icon-user.png) no-repeat 20px 50% | 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 | padding-left: 40px | 679 | padding-left: 40px |
| 660 | .login,.signup | 680 | .login,.signup |
| 661 | text-align: left | 681 | text-align: left |
| @@ -936,6 +956,7 @@ td | @@ -936,6 +956,7 @@ td | ||
| 936 | .success-panel | 956 | .success-panel |
| 937 | position: absolute | 957 | position: absolute |
| 938 | z-index: 100 | 958 | z-index: 100 |
| 959 | + text-align: center | ||
| 939 | 960 | ||
| 940 | // ------------------------------------ | 961 | // ------------------------------------ |
| 941 | // 7 - Modificadores | 962 | // 7 - Modificadores |