Commit 1ff9302f4d55a60ca26350b06ffc33aee70ae0fd
1 parent
e96555e7
Exists in
master
and in
39 other branches
Not collapsing message if clicking in a btn or a
Showing
2 changed files
with
30 additions
and
26 deletions
Show diff stats
src/accounts/templatetags/gravatar.py
| ... | ... | @@ -17,4 +17,4 @@ def gravatar(email, size=80): |
| 17 | 17 | |
| 18 | 18 | email_md5 = getattr(email, 'md5', 'anonymous') |
| 19 | 19 | |
| 20 | - return u'<img src="http://www.gravatar.com/avatar/{}?s={}&d=mm" height="{}px" width="{}px">'.format(email_md5, size, size, size) | |
| 20 | + return u'<img src="http://www.gravatar.com/avatar/{}?s={}&d=mm" height="{}px" width="{}px" />'.format(email_md5, size, size, size) | ... | ... |
src/super_archives/templates/message-thread.html
| ... | ... | @@ -31,53 +31,57 @@ |
| 31 | 31 | |
| 32 | 32 | if (jqXHR.status === 403) { |
| 33 | 33 | msg = " {% trans 'You must login before voting.' %}" |
| 34 | - } else { | |
| 35 | - return; | |
| 36 | - } | |
| 37 | - | |
| 38 | - $('#alert-js #alert-message').html(msg); | |
| 39 | - $('#alert-js').show(); | |
| 40 | - scroll(0, 0); | |
| 41 | - } | |
| 42 | - | |
| 43 | - function get_vote_ajax_dict(msg_id, method, context) { | |
| 44 | - var csrftoken = $.cookie('csrftoken'); | |
| 45 | 34 | |
| 46 | - return { | |
| 47 | - url: "/api/message/" + msg_id + "/vote", | |
| 48 | - type: method, | |
| 49 | - context: context, | |
| 50 | - beforeSend: function(xhr, settings) { | |
| 51 | - xhr.setRequestHeader("X-CSRFToken", csrftoken); | |
| 52 | - } | |
| 35 | + $('#alert-js #alert-message').html(msg); | |
| 36 | + $('#alert-js').show(); | |
| 37 | + scroll(0, 0); | |
| 53 | 38 | } |
| 39 | + | |
| 54 | 40 | } |
| 55 | 41 | |
| 56 | - function vote() { | |
| 42 | + function vote(event) { | |
| 57 | 43 | var $ajax; |
| 58 | 44 | var $btn = $(this); |
| 59 | 45 | var $msg = $(this).parents('.email-message'); |
| 60 | 46 | |
| 47 | + var method; | |
| 48 | + var csrftoken = $.cookie('csrftoken'); | |
| 61 | 49 | var msg_id = $msg.attr('id').split('-')[1]; |
| 62 | 50 | |
| 63 | - $btn.button('loading'); | |
| 64 | 51 | if($btn.hasClass('btn-default')) { |
| 65 | - $ajax = $.ajax(get_vote_ajax_dict(msg_id, 'PUT', $btn[0])); | |
| 52 | + method = 'PUT'; | |
| 66 | 53 | } else { |
| 67 | - $ajax = $.ajax(get_vote_ajax_dict(msg_id, 'DELETE', $btn[0])); | |
| 54 | + method = 'DELETE'; | |
| 68 | 55 | } |
| 56 | + | |
| 69 | 57 | console.debug('trying to vote'); |
| 58 | + $btn.button('loading'); | |
| 59 | + $ajax = $.ajax({ | |
| 60 | + url: "/api/message/" + msg_id + "/vote", | |
| 61 | + type: method, | |
| 62 | + context: $btn.get(0), | |
| 63 | + beforeSend: function(xhr, settings) { | |
| 64 | + xhr.setRequestHeader("X-CSRFToken", csrftoken); | |
| 65 | + } | |
| 66 | + }); | |
| 70 | 67 | $ajax.done(vote_done_callback); |
| 71 | 68 | $ajax.fail(vote_fail_callback); |
| 72 | 69 | } |
| 73 | 70 | |
| 74 | 71 | // Binding functions |
| 75 | 72 | $(function() { |
| 76 | - $(".panel-heading").bind('click', function() { | |
| 73 | + $(".panel-heading").on('click', function(event) { | |
| 74 | + var $target = $(event.target); | |
| 75 | + // Do not collapse the the message if the clicked element (target) | |
| 76 | + // is a button or a link | |
| 77 | + if($target.hasClass('btn') || $target.is('a') || $target.parent().is('a')) { | |
| 78 | + return; | |
| 79 | + } | |
| 80 | + | |
| 77 | 81 | $(this).next('.panel-collapse').collapse('toggle'); |
| 78 | 82 | }); |
| 79 | 83 | |
| 80 | - $('.vote.btn', this).bind('click', vote); | |
| 84 | + $('.vote.btn', this).on('click', vote); | |
| 81 | 85 | }); |
| 82 | 86 | |
| 83 | 87 | </script> |
| ... | ... | @@ -100,7 +104,7 @@ |
| 100 | 104 | {% spaceless %} |
| 101 | 105 | <div class="email-message" id="msg-{{ email.id }}"> |
| 102 | 106 | <div class="panel panel-default"> |
| 103 | - <div class="panel-heading clearfix" data-toggle="collapse"> | |
| 107 | + <div class="panel-heading clearfix"> | |
| 104 | 108 | <div class="col-lg-6 col-md-6 col-sm-6"> |
| 105 | 109 | {% if profile_link %} |
| 106 | 110 | <a href="{{ profile_link }}"> | ... | ... |