Commit 61e65535a8983cd4f6a9b9fdff7fe0c876d573e3

Authored by Victor Costa
1 parent d12f27ca

Add success feedback panel

Showing 2 changed files with 34 additions and 10 deletions   Show diff stats
@@ -278,17 +278,19 @@ @@ -278,17 +278,19 @@
278 278
279 <div class="support-proposal-container col-sm-6 require-login-container"> 279 <div class="support-proposal-container col-sm-6 require-login-container">
280 <section class="support-proposal box box-propostas box-center box-apoie"> 280 <section class="support-proposal box box-propostas box-center box-apoie">
281 - <div class="container-title box-title"> Apoie outras propostas</div>  
282 - <div class="alert alert-warning hide" role="alert">  
283 - <i class="fa fa-warning"></i><strong>Proposta não encontrada</strong>  
284 - </div>  
285 - <div class="support-proposal-content require-login">  
286 - <div class="random-proposal"></div>  
287 - <div class="loading">Carregando...</div>  
288 - <div class="no-proposals">Ainda não existe nenhuma proposta para este programa.</div> 281 + <div class="section-content">
  282 + <div class="container-title box-title"> Apoie outras propostas</div>
  283 + <div class="alert alert-warning hide" role="alert">
  284 + <i class="fa fa-warning"></i><strong>Proposta não encontrada</strong>
  285 + </div>
  286 + <div class="support-proposal-content require-login">
  287 + <div class="random-proposal"></div>
  288 + <div class="loading">Carregando...</div>
  289 + <div class="no-proposals">Ainda não existe nenhuma proposta para este programa.</div>
  290 + </div>
  291 + <div class="login-container hide">Login</div>
  292 + <div class="button-send hide"><a href="#"><span>Login</span></a></div>
289 </div> 293 </div>
290 - <div class="login-container hide">Login</div>  
291 - <div class="button-send hide"><a href="#"><span>Login</span></a></div>  
292 </section> 294 </section>
293 </div> 295 </div>
294 296
@@ -489,6 +491,11 @@ @@ -489,6 +491,11 @@
489 </div> 491 </div>
490 </script> 492 </script>
491 493
  494 + <div class="success-panel hide" style="position: absolute; z-index: 100;">
  495 + <div class="icon"></div>
  496 + <div class="message"></div>
  497 + </div>
  498 +
492 <div class="terms-of-use text-center"> 499 <div class="terms-of-use text-center">
493 <a href="#/artigo/107880">Termos de uso</a> 500 <a href="#/artigo/107880">Termos de uso</a>
494 </div> 501 </div>
@@ -99,6 +99,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -99,6 +99,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
99 }); 99 });
100 $body.off('click', '.vote-actions .vote-action'); 100 $body.off('click', '.vote-actions .vote-action');
101 $body.on('click', '.vote-actions .vote-action', function(e) { 101 $body.on('click', '.vote-actions .vote-action', function(e) {
  102 + Main.displaySuccess($(this).closest('.support-proposal .section-content'), 'Voto realizado com sucesso', 800);
102 //Helps to prevent more than one vote per proposal 103 //Helps to prevent more than one vote per proposal
103 if(ProposalApp.hasProposalbeenVoted(article.id)){ 104 if(ProposalApp.hasProposalbeenVoted(article.id)){
104 console.log("Proposta " + article.id + " já havia sido votada"); 105 console.log("Proposta " + article.id + " já havia sido votada");
@@ -557,6 +558,22 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F @@ -557,6 +558,22 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
557 } 558 }
558 }, 300); 559 }, 300);
559 }, 560 },
  561 + displaySuccess: function(container, text, timeout) {
  562 + timeout = typeof timeout !== 'undefined' ? timeout : 2000;
  563 + container.css('opacity', 0.1);
  564 + var successPanel = $('.success-panel').clone();
  565 + successPanel.find('.message').html(text);
  566 + successPanel.appendTo('body');
  567 + successPanel.show();
  568 + successPanel.css("top", Math.max(0, ((container.height() - successPanel.outerHeight()) / 2) + container.offset().top) + "px");
  569 + successPanel.css("left", Math.max(0, ((container.width() - successPanel.outerWidth()) / 2) + container.offset().left) + "px");
  570 +
  571 + var interval = setTimeout(function() {
  572 + successPanel.hide();
  573 + container.css('opacity', 1);
  574 + successPanel.remove();
  575 + }, timeout);
  576 + },
560 responseToText: function(responseJSONmessage){ 577 responseToText: function(responseJSONmessage){
561 var o = JSON.parse(responseJSONmessage); 578 var o = JSON.parse(responseJSONmessage);
562 var msg = ""; 579 var msg = "";