Commit 783761d89b5f5c8232b3a9677375279383dd89f7

Authored by Victor Costa
1 parent 112983fb

Require login when click on participate

Showing 1 changed file with 19 additions and 8 deletions   Show diff stats
@@ -802,6 +802,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun @@ -802,6 +802,7 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
802 e.preventDefault(); 802 e.preventDefault();
803 803
804 $loginPanel.toggle(); 804 $loginPanel.toggle();
  805 + $('html, body').animate({scrollTop: 0}, 'fast');
805 }); 806 });
806 807
807 // handle click on elsewhere (out of loginPanel) 808 // handle click on elsewhere (out of loginPanel)
@@ -1151,14 +1152,24 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun @@ -1151,14 +1152,24 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun
1151 1152
1152 $(document).on('click', '#talk__button-participate', function(e) { 1153 $(document).on('click', '#talk__button-participate', function(e) {
1153 e.preventDefault(); 1154 e.preventDefault();
1154 - $.ajax({  
1155 - type: 'post',  
1156 - url: host + '/api/v1/articles/' + $(this).data('event-id') + '/follow',  
1157 - data: {  
1158 - private_token: Main.private_token  
1159 - }  
1160 - }).done(function(data) {  
1161 - }); 1155 + var $bt = $(this);
  1156 + if(!logged_in) {
  1157 + $('#login-button').click();
  1158 + } else {
  1159 + $.ajax({
  1160 + type: 'post',
  1161 + url: host + '/api/v1/articles/' + $(this).data('event-id') + '/follow',
  1162 + data: {
  1163 + private_token: Main.private_token
  1164 + }
  1165 + }).done(function(data) {
  1166 + var message = 'Sua participação foi registrada com sucesso';
  1167 + if(!data.success) {
  1168 + message = 'Sua participação já foi registrada';
  1169 + }
  1170 + Main.displaySuccess($bt.closest('.talk__participate'), message, 2000, 'icon-proposal-sent');
  1171 + });
  1172 + }
1162 }); 1173 });
1163 1174
1164 1175