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
index.html
... ... @@ -278,17 +278,19 @@
278 278  
279 279 <div class="support-proposal-container col-sm-6 require-login-container">
280 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 293 </div>
290   - <div class="login-container hide">Login</div>
291   - <div class="button-send hide"><a href="#"><span>Login</span></a></div>
292 294 </section>
293 295 </div>
294 296  
... ... @@ -489,6 +491,11 @@
489 491 </div>
490 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 499 <div class="terms-of-use text-center">
493 500 <a href="#/artigo/107880">Termos de uso</a>
494 501 </div>
... ...
js/main.js
... ... @@ -99,6 +99,7 @@ define([&#39;handlebars&#39;, &#39;fastclick&#39;, &#39;handlebars_helpers&#39;], function(Handlebars, F
99 99 });
100 100 $body.off('click', '.vote-actions .vote-action');
101 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 103 //Helps to prevent more than one vote per proposal
103 104 if(ProposalApp.hasProposalbeenVoted(article.id)){
104 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 558 }
558 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 577 responseToText: function(responseJSONmessage){
561 578 var o = JSON.parse(responseJSONmessage);
562 579 var msg = "";
... ...