Commit 5a2e06b937e2c176afc1c2c73c7c018d937102a4
Exists in
master
and in
5 other branches
Merge branch 'merlin'
Showing
2 changed files
with
93 additions
and
46 deletions
Show diff stats
js/main.js
... | ... | @@ -657,8 +657,9 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
657 | 657 | showLogout: function(){ |
658 | 658 | $('#login-button').hide(); |
659 | 659 | var name = ''; |
660 | - if(this.user){ | |
661 | - name = this.user.person.name + ' - '; | |
660 | + var user = Main.getUser(); | |
661 | + if(user){ | |
662 | + name = user.person.name + ' - '; | |
662 | 663 | } |
663 | 664 | $('#logout-button .name').text(name); |
664 | 665 | $('#logout-button').show(); |
... | ... | @@ -830,6 +831,10 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
830 | 831 | .removeClass('col-sm-4') |
831 | 832 | .addClass('col-sm-12'); |
832 | 833 | |
834 | + if(logged_in){ | |
835 | + Main.showLogout(); | |
836 | + } | |
837 | + | |
833 | 838 | $(document).on('click', '#login-button', function (e){ |
834 | 839 | e.preventDefault(); |
835 | 840 | loginButton = $(this); |
... | ... | @@ -935,7 +940,12 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
935 | 940 | |
936 | 941 | $( '#display-contrast' ).on('click', function(e){ |
937 | 942 | e.preventDefault(); |
938 | - $('body').toggleClass('contrast'); | |
943 | + $('body').toggleClass('contraste'); | |
944 | + | |
945 | + if($.cookie){ | |
946 | + var isContrasted = $('body').hasClass('contraste'); | |
947 | + $.cookie('dialoga_contraste', isContrasted); | |
948 | + } | |
939 | 949 | }); |
940 | 950 | |
941 | 951 | $( '.show_body' ).on('click', function(e){ |
... | ... | @@ -1020,17 +1030,28 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
1020 | 1030 | |
1021 | 1031 | FastClick.attach(document.body); |
1022 | 1032 | |
1023 | - if($.cookie('_dialoga_session')) { | |
1024 | - var url = host + '/api/v1/users/me?private_token=' + $.cookie('_dialoga_session'); | |
1025 | - $.getJSON(url).done(function( data ) { | |
1026 | - logged_in = true; | |
1027 | - Main.private_token = $.cookie('_dialoga_session'); | |
1033 | + if($.cookie) { | |
1028 | 1034 | |
1029 | - if(data && data.user){ | |
1030 | - Main.setUser(data.user); | |
1031 | - Main.showLogout(); | |
1032 | - } | |
1033 | - }); | |
1035 | + // session | |
1036 | + if($.cookie('_dialoga_session')){ | |
1037 | + var url = host + '/api/v1/users/me?private_token=' + $.cookie('_dialoga_session'); | |
1038 | + $.getJSON(url).done(function( data ) { | |
1039 | + logged_in = true; | |
1040 | + Main.private_token = $.cookie('_dialoga_session'); | |
1041 | + | |
1042 | + if(data && data.user){ | |
1043 | + Main.setUser(data.user); | |
1044 | + Main.showLogout(); | |
1045 | + } | |
1046 | + }); | |
1047 | + } | |
1048 | + | |
1049 | + // contrast | |
1050 | + var isContrasted = $.cookie('dialoga_contraste'); | |
1051 | + if(isContrasted === 'true'){ | |
1052 | + // remove all classes 'contraste' and add only one 'contraste' | |
1053 | + $('body').addClass('contraste'); | |
1054 | + } | |
1034 | 1055 | } |
1035 | 1056 | |
1036 | 1057 | $(document).on('login:success', Main.handleLoginSuccess); |
... | ... | @@ -1055,7 +1076,6 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
1055 | 1076 | //withCredentials: true |
1056 | 1077 | } |
1057 | 1078 | }).done(function(data) { |
1058 | - $(document).trigger('login:success', data); | |
1059 | 1079 | |
1060 | 1080 | var $sectionContent = $form.closest('.section-content'); |
1061 | 1081 | if($sectionContent && $sectionContent.length > 0){ |
... | ... | @@ -1067,8 +1087,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
1067 | 1087 | $loginPanel.hide(); |
1068 | 1088 | } |
1069 | 1089 | |
1090 | + $(document).trigger('login:success', data); | |
1070 | 1091 | }).fail(function(data) { |
1071 | - $(document).trigger('login:fail', data); | |
1072 | 1092 | |
1073 | 1093 | $message.show(); |
1074 | 1094 | if(data.status==401){ |
... | ... | @@ -1076,6 +1096,8 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
1076 | 1096 | }else{ |
1077 | 1097 | $message.text('Um erro inesperado ocorreu'); |
1078 | 1098 | } |
1099 | + | |
1100 | + $(document).trigger('login:fail', data); | |
1079 | 1101 | }); |
1080 | 1102 | }); |
1081 | 1103 | |
... | ... | @@ -1119,9 +1141,10 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
1119 | 1141 | message.text(''); |
1120 | 1142 | |
1121 | 1143 | var signup = $(this).parents('form.signup'); |
1122 | - var loading = $('.login-container .loading'); | |
1123 | - loading.show(); | |
1144 | + var $loading = $('.login-container .loading'); | |
1145 | + $loading.show(); | |
1124 | 1146 | signup.hide(); |
1147 | + signup.removeClass('hide'); | |
1125 | 1148 | var button = $(this); |
1126 | 1149 | |
1127 | 1150 | $.ajax({ |
... | ... | @@ -1129,43 +1152,67 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
1129 | 1152 | url: host + '/api/v1/register', |
1130 | 1153 | data: $(this).parents('.signup').serialize(), |
1131 | 1154 | }).done(function(data) { |
1132 | - Main.loginCallback(true, data.private_token); | |
1133 | - Main.displaySuccess(button.closest('.section-content'), 'Cadastro efetuado com sucesso', 1000, 'icon-user-created'); | |
1155 | + | |
1156 | + var $sectionContent = button.closest('.section-content'); | |
1157 | + if($sectionContent && $sectionContent.length > 0){ | |
1158 | + Main.displaySuccess($sectionContent, 'Cadastro efetuado com sucesso', 1000, 'icon-user-created'); | |
1159 | + } | |
1160 | + | |
1161 | + $(document).trigger('login:success', data); | |
1134 | 1162 | }).fail(function(data) { |
1135 | - var msg = Main.responseToText(data.responseJSON.message); | |
1163 | + var msg = ""; | |
1164 | + try{ | |
1165 | + msg = Main.responseToText(data.responseJSON.message); | |
1166 | + }catch(ex){ | |
1167 | + var ptBR = {}; | |
1168 | + // (Invalid request) email can't be saved | |
1169 | + ptBR['(Invalid request) email can\'t be saved'] = 'E-mail inválido.'; | |
1170 | + // (Invalid request) login can't be saved | |
1171 | + ptBR['(Invalid request) login can\'t be saved'] = 'Nome de usuário inválido.'; | |
1172 | + | |
1173 | + msg = ptBR[data.responseJSON.message] || data.responseJSON.message; | |
1174 | + } | |
1175 | + | |
1136 | 1176 | message.show(); |
1137 | 1177 | message.html('Não foi possível efetuar o cadastro: <br/><br/>' + msg); |
1178 | + | |
1179 | + $(document).trigger('login:fail', data); | |
1138 | 1180 | }).always(function() { |
1139 | - loading.hide(); | |
1181 | + $loading.hide(); | |
1140 | 1182 | signup.show(); |
1183 | + | |
1184 | + // var $loginPanel = $loading.closest('#login-panel'); | |
1185 | + // if($loginPanel && $loginPanel.length > 0){ | |
1186 | + // $loginPanel.hide(); | |
1187 | + // } | |
1141 | 1188 | }); |
1142 | 1189 | grecaptcha.reset(); |
1143 | 1190 | e.preventDefault(); |
1144 | 1191 | }); |
1145 | 1192 | |
1146 | - var popupCenter = function(url, title, w, h) { | |
1147 | - var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left; | |
1148 | - var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top; | |
1193 | + // var popupCenter = function(url, title, w, h) { | |
1194 | + // var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left; | |
1195 | + // var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top; | |
1149 | 1196 | |
1150 | - var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; | |
1151 | - var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; | |
1197 | + // var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; | |
1198 | + // var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; | |
1152 | 1199 | |
1153 | - var left = ((width / 2) - (w / 2)) + dualScreenLeft; | |
1154 | - var top = ((height / 3) - (h / 3)) + dualScreenTop; | |
1200 | + // var left = ((width / 2) - (w / 2)) + dualScreenLeft; | |
1201 | + // var top = ((height / 3) - (h / 3)) + dualScreenTop; | |
1155 | 1202 | |
1156 | - var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); | |
1203 | + // var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); | |
1157 | 1204 | |
1158 | - // Puts focus on the newWindow | |
1159 | - if (window.focus) { | |
1160 | - newWindow.focus(); | |
1161 | - } | |
1162 | - }; | |
1205 | + // // Puts focus on the newWindow | |
1206 | + // if (window.focus) { | |
1207 | + // newWindow.focus(); | |
1208 | + // } | |
1209 | + // }; | |
1163 | 1210 | |
1164 | - $(document).on('click', '.social a.popup', {}, function popUp(e) { | |
1165 | - var self = $(this); | |
1166 | - popupCenter(self.attr('href'), self.find('.rrssb-text').html(), 580, 470); | |
1167 | - e.preventDefault(); | |
1168 | - }); | |
1211 | + // $(document).on('click', '.social a.popup', {}, function popUp(e) { | |
1212 | + // var self = $(this); | |
1213 | + // popupCenter(self.attr('href'), self.find('.rrssb-text').html(), 580, 470); | |
1214 | + // e.preventDefault(); | |
1215 | + // }); | |
1169 | 1216 | |
1170 | 1217 | $(document).on('click', '#logout-button', function (e){ |
1171 | 1218 | var self = $(this); | ... | ... |
sass/style.sass
... | ... | @@ -263,7 +263,7 @@ textarea |
263 | 263 | #display-contrast |
264 | 264 | color: $link-color |
265 | 265 | font-weight: normal |
266 | - .contrast & | |
266 | + .contraste & | |
267 | 267 | color: white |
268 | 268 | // 5.3 - icones |
269 | 269 | .icon |
... | ... | @@ -723,7 +723,7 @@ h1 |
723 | 723 | .btn |
724 | 724 | color: $link-color |
725 | 725 | font-weight: normal |
726 | - .contrast & | |
726 | + .contraste & | |
727 | 727 | color: #fff |
728 | 728 | .participe |
729 | 729 | font-size: 14px |
... | ... | @@ -739,7 +739,7 @@ h1 |
739 | 739 | vertical-align: middle |
740 | 740 | border: 1px solid #ccc !important |
741 | 741 | background: url(images/icons/icon-user.png) no-repeat 20px 50% |
742 | - .contrast & | |
742 | + .contraste & | |
743 | 743 | background-image: url(images/icons/icon-user-contrast.png) |
744 | 744 | .login |
745 | 745 | margin-left: 20px |
... | ... | @@ -755,7 +755,7 @@ h1 |
755 | 755 | border: 1px solid #ccc |
756 | 756 | .loading |
757 | 757 | display: none |
758 | - .contrast & | |
758 | + .contraste & | |
759 | 759 | background-color: #262626 |
760 | 760 | |
761 | 761 | .login, |
... | ... | @@ -1086,7 +1086,7 @@ td |
1086 | 1086 | border-bottom: 2px solid #fff |
1087 | 1087 | border-right: none |
1088 | 1088 | |
1089 | - .contrast & | |
1089 | + .contraste & | |
1090 | 1090 | background-color: #333 |
1091 | 1091 | color: #fff !important |
1092 | 1092 | |
... | ... | @@ -1169,7 +1169,7 @@ td |
1169 | 1169 | z-index: 1 |
1170 | 1170 | border-radius: 10px |
1171 | 1171 | |
1172 | - .contrast & | |
1172 | + .contraste & | |
1173 | 1173 | background-color: #333 |
1174 | 1174 | color: #fff !important |
1175 | 1175 | |
... | ... | @@ -1318,7 +1318,7 @@ h3.titulo-destaque |
1318 | 1318 | // 9 - Alto Contraste |
1319 | 1319 | // ------------------------------------ |
1320 | 1320 | |
1321 | -.contrast | |
1321 | +.contraste | |
1322 | 1322 | background-color: #000 |
1323 | 1323 | color: #fff |
1324 | 1324 | .background | ... | ... |