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