diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2012-12-07 12:05:04 +0100 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2012-12-07 12:05:04 +0100 |
commit | 1efaf31a907aa42fc0b01029d332f539b2067a75 (patch) | |
tree | b2e9cc01610f75a3dd01fdbaab02879a24821a39 /hyperkitty/templates | |
parent | e255c7223ffc9f00f3c85bb573381cf20fcd40a6 (diff) | |
download | hyperkitty-1efaf31a907aa42fc0b01029d332f539b2067a75.tar.gz hyperkitty-1efaf31a907aa42fc0b01029d332f539b2067a75.tar.xz hyperkitty-1efaf31a907aa42fc0b01029d332f539b2067a75.zip |
Factorize the add_tag and like JS functions
Diffstat (limited to 'hyperkitty/templates')
-rw-r--r-- | hyperkitty/templates/base.html | 1 | ||||
-rw-r--r-- | hyperkitty/templates/message.html | 57 | ||||
-rw-r--r-- | hyperkitty/templates/messages/message.html | 6 | ||||
-rw-r--r-- | hyperkitty/templates/thread.html | 76 | ||||
-rw-r--r-- | hyperkitty/templates/threads/right_col.html | 3 |
5 files changed, 8 insertions, 135 deletions
diff --git a/hyperkitty/templates/base.html b/hyperkitty/templates/base.html index 1900dbb..1a69fae 100644 --- a/hyperkitty/templates/base.html +++ b/hyperkitty/templates/base.html @@ -55,6 +55,7 @@ {% block footer %} {% endblock %} <script src="{{ STATIC_URL }}js/libs/jquery-1.7.1.min.js"></script> + <script src="{{ STATIC_URL }}js/hyperkitty.js"></script> {% block additionaljs %} {% endblock %} </body> diff --git a/hyperkitty/templates/message.html b/hyperkitty/templates/message.html index 5ae2fb1..25983ec 100644 --- a/hyperkitty/templates/message.html +++ b/hyperkitty/templates/message.html @@ -17,60 +17,3 @@ </section> {% endblock %} - -{% block additionaljs %} -<script type="text/javascript"> - $(document).ready(function() { - $(".voteup").click(function() { - // @TODO: Extract the message id from the HTML DOM element instead of hard coding it in Javascript. - message_id = this.parentElement.getAttribute('messageid'); - {% if user.is_authenticated %} - $.ajax({ - type : "POST", - url : "{% url message_vote mlist_fqdn=list_address %}", - data : { - vote : 1, - messageid : message_id, - list : "{{list_address}}", - csrfmiddlewaretoken : '{{ csrf_token }}' - }, - success : function(response) { - console.log(response); - location.reload(); - } - }); - return false; - {% else %} - alert('You need to login in order to vote'); - {% endif %} - }); - - $(".votedown").click(function() { - message_id = this.parentElement.getAttribute('messageid'); - {% if user.is_authenticated %} - $.ajax({ - type : "POST", - url : '{% url message_vote mlist_fqdn=list_address %}', - data : { - vote : -1, - messageid : message_id, - list : "{{list_address}}", - csrfmiddlewaretoken : '{{ csrf_token }}' - }, - success : function(response) { - console.log(response); - // @TODO : Remove this reload and update count using AJAX - location.reload(); - } - }); - return false; - {% else %} - alert('You need to login in order to vote'); - {% endif %} - - }); - - }); -</script> - -{% endblock %} diff --git a/hyperkitty/templates/messages/message.html b/hyperkitty/templates/messages/message.html index 9fec43d..c69c2ff 100644 --- a/hyperkitty/templates/messages/message.html +++ b/hyperkitty/templates/messages/message.html @@ -43,8 +43,11 @@ </ul> {% endif %} -<ul class="email_info inline" messageid="{{email.message_id_hash}}"> +<ul class="email_info inline"> {% if use_mockups %} + <form method="post" action="{% url message_vote mlist_fqdn=list_address %}"> + <input type="hidden" name="messageid" value="{{email.message_id_hash}}" /> + {% csrf_token %} <li class="likestatus {{email.likestatus}}"> +{{email.likes}}/-{{email.dislikes}} </li> @@ -54,6 +57,7 @@ <li class="votedown"> <a class="youdislike" href="#dislike">Dislike</a> </li> + </form> {% endif %} {% if not unfolded and email.attachments|count %} <li class="attachments"> diff --git a/hyperkitty/templates/thread.html b/hyperkitty/templates/thread.html index 9e1333f..e2a0524 100644 --- a/hyperkitty/templates/thread.html +++ b/hyperkitty/templates/thread.html @@ -51,80 +51,4 @@ }); </script> -<script type="text/javascript"> - $(document).ready(function() { - $(".voteup").click(function() { - // @TODO: Extract the message id from the HTML DOM element instead of hard coding it in Javascript. - message_id = this.parentElement.getAttribute('messageid'); - {% if user.is_authenticated %} - $.ajax({ - type : "POST", - url : '{% url message_vote mlist_fqdn=list_address %}', - data : { - vote : 1, - messageid : message_id, - list : "{{list_address}}", - csrfmiddlewaretoken : '{{ csrf_token }}' - }, - success : function(response) { - console.log(response); - location.reload(); - } - }); - return false; - {% else %} - alert('You need to login in order to vote'); - {% endif %} - }); - - $(".votedown").click(function() { - message_id = this.parentElement.getAttribute('messageid'); - {% if user.is_authenticated %} - $.ajax({ - type : "POST", - url : '{% url message_vote mlist_fqdn=list_address %}', - data : { - vote : -1, - messageid : message_id, - list : "{{list_address}}", - csrfmiddlewaretoken : '{{ csrf_token }}' - }, - success : function(response) { - console.log(response); - // @TODO : Remove this reload and update count using AJAX - location.reload(); - } - }); - return false; - {% else %} - alert('You need to login in order to vote'); - {% endif %} - - }); - - $("#add_tag_form").submit( function () { - - {% if user.is_authenticated %} - $.ajax({ - type: "POST", - data : $(this).serialize(), - url: "{% url add_tag mlist_fqdn=list_address, email_id=threadid %}", - success: function(data){ - console.log('Tag is added successfully'); - location.reload(); - } - }); - return false; - {% else %} - alert('You need to login in order to add tag'); - {% endif %} - }); - - $("ul.email_info li.attachments ul.attachments-list").hide(); - $("ul.email_info li.attachments > a").click(function() { - $(this).next("ul").fadeToggle('fast'); - }); - - }); -</script> {% endblock %} diff --git a/hyperkitty/templates/threads/right_col.html b/hyperkitty/templates/threads/right_col.html index dcf00e7..cc486b1 100644 --- a/hyperkitty/templates/threads/right_col.html +++ b/hyperkitty/templates/threads/right_col.html @@ -42,7 +42,8 @@ {% endif %} </div> <div id="add_tag"> - <form id="add_tag_form" name="addtag" action="{% url add_tag mlist_fqdn=list_address, email_id=threadid %}" method="post"> + <form id="add_tag_form" name="addtag" method="post" + action="{% url add_tag mlist_fqdn=list_address, email_id=threadid %}"> {% csrf_token %} {{ addtag_form.as_p }} </form> |