Commit e071635449e83cfec384037f35d0185f0161e8bc

Authored by Sergio Oliveira
1 parent 92b2c4aa

Locking vote button while waiting for request

src/super_archives/templates/message-thread.html
@@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
29 } 29 }
30 $btn.toggleClass('btn-success'); 30 $btn.toggleClass('btn-success');
31 $btn.toggleClass('btn-default'); 31 $btn.toggleClass('btn-default');
  32 + $btn.button('reset')
32 } 33 }
33 34
34 function vote_fail_callback(jqXHR, textStatus, errorThrown) { 35 function vote_fail_callback(jqXHR, textStatus, errorThrown) {
@@ -46,6 +47,7 @@ @@ -46,6 +47,7 @@
46 47
47 function get_vote_ajax_dict(msg_id, method) { 48 function get_vote_ajax_dict(msg_id, method) {
48 var csrftoken = $.cookie('csrftoken'); 49 var csrftoken = $.cookie('csrftoken');
  50 + $('#msg-' + msg_id + ' .vote.btn-success').button('loading');
49 51
50 return { 52 return {
51 url: "/api/message/" + msg_id + "/vote", 53 url: "/api/message/" + msg_id + "/vote",
@@ -76,9 +78,9 @@ @@ -76,9 +78,9 @@
76 78
77 // Binding functions 79 // Binding functions
78 $(function() { 80 $(function() {
  81 + console.debug('binding vote function to btns');
79 $('.email-message').each(function() { 82 $('.email-message').each(function() {
80 var msg_id = this.getAttribute('id').split('-')[1]; 83 var msg_id = this.getAttribute('id').split('-')[1];
81 - console.debug('binding vote calls to ' + msg_id);  
82 84
83 $('.vote.btn-default', this).bind('click', function() { 85 $('.vote.btn-default', this).bind('click', function() {
84 vote(msg_id); 86 vote(msg_id);
@@ -157,9 +159,9 @@ @@ -157,9 +159,9 @@
157 {{ email.votes_count }} 159 {{ email.votes_count }}
158 </button> 160 </button>
159 {% if user in email.vote_list %} 161 {% if user in email.vote_list %}
160 - <button class="btn btn-success vote"> 162 + <button class="btn btn-success vote" data-loading-text="...">
161 {% else %} 163 {% else %}
162 - <button class="btn btn-default vote"> 164 + <button class="btn btn-default vote" data-loading-text="...">
163 {% endif %} 165 {% endif %}
164 <span class="glyphicon glyphicon-thumbs-up"></span> 166 <span class="glyphicon glyphicon-thumbs-up"></span>
165 </button> 167 </button>