summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-04-11 04:41:53 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-04-11 04:41:53 -0400
commit0e2b9b7225d71e6a1b8d9c929570daf5ef44c012 (patch)
tree4214bf6991ea1b08d5689b739700e0f6216981ed
parent6b5ad87abfcc97653b57974a4f75c27bc2b18cc6 (diff)
downloadaskbot-0e2b9b7225d71e6a1b8d9c929570daf5ef44c012.tar.gz
askbot-0e2b9b7225d71e6a1b8d9c929570daf5ef44c012.tar.bz2
askbot-0e2b9b7225d71e6a1b8d9c929570daf5ef44c012.zip
refactored the voting function a little
-rw-r--r--askbot/media/js/post.js18
-rw-r--r--askbot/media/style/style.css98
-rw-r--r--askbot/media/style/style.less96
-rw-r--r--askbot/templates/main_page.html10
-rw-r--r--askbot/templates/main_page/javascript.html6
-rw-r--r--askbot/templates/question.html2
-rw-r--r--askbot/urls.py2
-rw-r--r--askbot/views/commands.py8
8 files changed, 123 insertions, 117 deletions
diff --git a/askbot/media/js/post.js b/askbot/media/js/post.js
index ea6cb244..ad641076 100644
--- a/askbot/media/js/post.js
+++ b/askbot/media/js/post.js
@@ -1030,16 +1030,17 @@ var Vote = function(){
);
return false;
}
+ postId = questionId;
submit(object, VoteType.favorite, callback_favorite);
},
vote: function(object, voteType){
- if (!currentUserId || currentUserId.toUpperCase() == "NONE"){
+ if (!currentUserId || currentUserId.toUpperCase() == "NONE") {
if (voteType == VoteType.questionSubscribeUpdates || voteType == VoteType.questionUnsubscribeUpdates){
getquestionSubscribeSidebarCheckbox().removeAttr('checked');
getquestionSubscribeUpdatesCheckbox().removeAttr('checked');
showMessage(object, subscribeAnonymousMessage);
- }else {
+ } else {
showMessage(
$(object),
voteAnonymousMessage.replace(
@@ -1056,9 +1057,10 @@ var Vote = function(){
// up and downvote processor
if (voteType == VoteType.answerUpVote){
postId = object.attr("id").substring(imgIdPrefixAnswerVoteup.length);
- }
- else if (voteType == VoteType.answerDownVote){
+ } else if (voteType == VoteType.answerDownVote){
postId = object.attr("id").substring(imgIdPrefixAnswerVotedown.length);
+ } else {
+ postId = questionId;
}
submit(object, voteType, callback_vote);
@@ -1144,16 +1146,14 @@ var Vote = function(){
var do_proceed = false;
if (postType == 'answer'){
postNode = $('#post-id-' + postId);
- }
- else if (postType == 'question'){
+ } else if (postType == 'question') {
postNode = $('#question-table');
}
postRemoveLink = object;
- if (postNode.hasClass('deleted')){
+ if (postNode.hasClass('deleted')) {
removeActionType = 'undelete';
do_proceed = true;
- }
- else {
+ } else {
removeActionType = 'delete';
do_proceed = confirm(removeConfirmation);
}
diff --git a/askbot/media/style/style.css b/askbot/media/style/style.css
index d64d28da..e818c493 100644
--- a/askbot/media/style/style.css
+++ b/askbot/media/style/style.css
@@ -2282,34 +2282,6 @@ ul#related-tags li {
font-family: 'Open Sans Condensed', Arial, sans-serif;
line-height: 15px;
}
-.question-page .question-img-upvote,
-.question-page .question-img-downvote,
-.question-page .answer-img-upvote,
-.question-page .answer-img-downvote {
- width: 25px;
- height: 20px;
- cursor: pointer;
-}
-.question-page .question-img-upvote,
-.question-page .answer-img-upvote {
- background: url(../images/vote-arrow-up-new.png) no-repeat;
-}
-.question-page .question-img-downvote,
-.question-page .answer-img-downvote {
- background: url(../images/vote-arrow-down-new.png) no-repeat;
-}
-.question-page .question-img-upvote:hover,
-.question-page .question-img-upvote.on,
-.question-page .answer-img-upvote:hover,
-.question-page .answer-img-upvote.on {
- background: url(../images/vote-arrow-up-on-new.png) no-repeat;
-}
-.question-page .question-img-downvote:hover,
-.question-page .question-img-downvote.on,
-.question-page .answer-img-downvote:hover,
-.question-page .answer-img-downvote.on {
- background: url(../images/vote-arrow-down-on-new.png) no-repeat;
-}
.question-page #fmanswer_button {
margin: 8px 0px;
}
@@ -2572,27 +2544,6 @@ ul#related-tags li {
color: #707070;
font-weight: normal;
}
-.question-page .vote-buttons {
- float: left;
- text-align: center;
- padding-top: 2px;
- margin: 0px 10px 0px 3px;
- /* small IE fixes */
-
- *margin: 0;
- *height: 210px;
- *width: 30px;
-}
-.question-page .vote-buttons IMG {
- cursor: pointer;
-}
-.question-page .vote-number {
- font-family: 'Open Sans Condensed', Arial, sans-serif;
- padding: 2px 0 5px 0;
- font-size: 25px;
- font-weight: bold;
- color: #777;
-}
.question-page .vote-buttons .notify-sidebar {
text-align: left;
width: 130px;
@@ -2678,6 +2629,55 @@ ul#related-tags li {
padding: 5px;
margin: 0px 0 10px 0;
}
+.vote-buttons {
+ float: left;
+ text-align: center;
+ padding-top: 2px;
+ margin: 0px 10px 0px 3px;
+ /* small IE fixes */
+
+ *margin: 0;
+ *height: 210px;
+ *width: 30px;
+}
+.vote-buttons img {
+ cursor: pointer;
+}
+.question-img-upvote,
+.question-img-downvote,
+.answer-img-upvote,
+.answer-img-downvote {
+ width: 25px;
+ height: 20px;
+ cursor: pointer;
+}
+.question-img-upvote,
+.answer-img-upvote {
+ background: url(../images/vote-arrow-up-new.png) no-repeat;
+}
+.question-img-downvote,
+.answer-img-downvote {
+ background: url(../images/vote-arrow-down-new.png) no-repeat;
+}
+.question-img-upvote:hover,
+.question-img-upvote.on,
+.answer-img-upvote:hover,
+.answer-img-upvote.on {
+ background: url(../images/vote-arrow-up-on-new.png) no-repeat;
+}
+.question-img-downvote:hover,
+.question-img-downvote.on,
+.answer-img-downvote:hover,
+.answer-img-downvote.on {
+ background: url(../images/vote-arrow-down-on-new.png) no-repeat;
+}
+.vote-number {
+ font-family: 'Open Sans Condensed', Arial, sans-serif;
+ padding: 2px 0 5px 0;
+ font-size: 25px;
+ font-weight: bold;
+ color: #777;
+}
.facebook-share.icon,
.twitter-share.icon,
.linkedin-share.icon,
diff --git a/askbot/media/style/style.less b/askbot/media/style/style.less
index afc214c2..f3f70679 100644
--- a/askbot/media/style/style.less
+++ b/askbot/media/style/style.less
@@ -2380,31 +2380,6 @@ ul#related-tags li {
line-height:15px;
}
- .question-img-upvote, .question-img-downvote,
- .answer-img-upvote, .answer-img-downvote {
- width: 25px;
- height: 20px;
- cursor:pointer;
- }
-
- .question-img-upvote, .answer-img-upvote {
- background: url(../images/vote-arrow-up-new.png) no-repeat;
- }
-
- .question-img-downvote, .answer-img-downvote {
- background: url(../images/vote-arrow-down-new.png) no-repeat;
- }
-
- .question-img-upvote:hover, .question-img-upvote.on,
- .answer-img-upvote:hover, .answer-img-upvote.on {
- background: url(../images/vote-arrow-up-on-new.png) no-repeat;
- }
-
- .question-img-downvote:hover, .question-img-downvote.on,
- .answer-img-downvote:hover, .answer-img-downvote.on {
- background: url(../images/vote-arrow-down-on-new.png) no-repeat;
- }
-
#fmanswer_button{
margin:8px 0px;
}
@@ -2679,29 +2654,6 @@ ul#related-tags li {
font-weight:normal;
}
- .vote-buttons {
- float: left;
- text-align: center;
- padding-top: 2px;
- margin:0px 10px 0px 3px;
- /* small IE fixes */
- *margin:0;
- *height:210px;
- *width:30px;
- }
-
- .vote-buttons IMG {
- cursor: pointer;
- }
-
- .vote-number {
- font-family: @main-font;
- padding: 2px 0 5px 0;
- font-size: 25px;
- font-weight: bold;
- color: #777;
- }
-
.vote-buttons .notify-sidebar {
text-align: left;
width:130px;
@@ -2806,6 +2758,54 @@ ul#related-tags li {
}
+.vote-buttons {
+ float: left;
+ text-align: center;
+ padding-top: 2px;
+ margin:0px 10px 0px 3px;
+ /* small IE fixes */
+ *margin:0;
+ *height:210px;
+ *width:30px;
+}
+
+.vote-buttons img {
+ cursor: pointer;
+}
+
+.question-img-upvote, .question-img-downvote,
+.answer-img-upvote, .answer-img-downvote {
+ width: 25px;
+ height: 20px;
+ cursor:pointer;
+}
+
+.question-img-upvote, .answer-img-upvote {
+ background: url(../images/vote-arrow-up-new.png) no-repeat;
+}
+
+.question-img-downvote, .answer-img-downvote {
+ background: url(../images/vote-arrow-down-new.png) no-repeat;
+}
+
+.question-img-upvote:hover, .question-img-upvote.on,
+.answer-img-upvote:hover, .answer-img-upvote.on {
+ background: url(../images/vote-arrow-up-on-new.png) no-repeat;
+}
+
+.question-img-downvote:hover, .question-img-downvote.on,
+.answer-img-downvote:hover, .answer-img-downvote.on {
+ background: url(../images/vote-arrow-down-on-new.png) no-repeat;
+}
+
+.vote-number {
+ font-family: @main-font;
+ padding: 2px 0 5px 0;
+ font-size: 25px;
+ font-weight: bold;
+ color: #777;
+}
+
.facebook-share.icon, .twitter-share.icon, .linkedin-share.icon, .identica-share.icon {
background: url(../images/socialsprite.png) no-repeat;
display:block;
diff --git a/askbot/templates/main_page.html b/askbot/templates/main_page.html
index a0635a7a..0014dbe2 100644
--- a/askbot/templates/main_page.html
+++ b/askbot/templates/main_page.html
@@ -8,6 +8,9 @@
there is no html markup in this file
#}
<!-- questions.html -->
+{% block forejs %}
+ {% include "main_page/custom_head_javascript.html" ignore missing %}
+{% endblock %}
{% block title %}{% spaceless %}{% trans %}Questions{% endtrans %}{% endspaceless %}{% endblock %}
{% block content %}
{% include "main_page/tab_bar.html" %}
@@ -23,6 +26,13 @@
{% include "main_page/sidebar.html" %}
{% endblock %}
{% block endjs %}
+ <script type="text/javascript">
+ {# cant cache this #}
+ askbot['settings']['showSortByRelevance'] = {{ show_sort_by_relevance|as_js_bool }};
+ </script>
+ {% compress js %}
{% include "main_page/javascript.html" %}
+ {% include "main_page/custom_javascript.html" ignore missing %}
+ {% endcompress %}
{% endblock %}
<!-- end questions.html -->
diff --git a/askbot/templates/main_page/javascript.html b/askbot/templates/main_page/javascript.html
index dc6bdc94..3d1db550 100644
--- a/askbot/templates/main_page/javascript.html
+++ b/askbot/templates/main_page/javascript.html
@@ -1,9 +1,4 @@
<script type="text/javascript">
- {# cant cache this #}
- askbot['settings']['showSortByRelevance'] = {{ show_sort_by_relevance|as_js_bool }};
-</script>
-{% compress js %}
-<script type="text/javascript">
/*<![CDATA[*/
$(document).ready(function(){
/*var on_tab = '#nav_questions';
@@ -45,4 +40,3 @@
</script>
<script type='text/javascript' src='{{"/js/editor.js"|media}}'></script>
<script type='text/javascript' src='{{"/js/tag_selector.js"|media}}'></script>
-{% endcompress %}
diff --git a/askbot/templates/question.html b/askbot/templates/question.html
index 6235f7ed..0ab4221a 100644
--- a/askbot/templates/question.html
+++ b/askbot/templates/question.html
@@ -298,7 +298,7 @@
askbot['urls']['convertComment'] = '{% url comment_to_answer %}';
askbot['urls']['getComment'] = '{% url get_comment %}';
askbot['urls']['saveDraftAnswer'] = '{% url save_draft_answer %}';
- askbot['urls']['vote_url'] = '{% url vote question.id %}';
+ askbot['urls']['vote_url'] = '{% url vote %}'
askbot['urls']['user_signin'] = '{{ settings.LOGIN_URL }}';
askbot['urls']['swap_question_with_answer'] = '{% url swap_question_with_answer %}';
askbot['urls']['upvote_comment'] = '{% url upvote_comment %}';
diff --git a/askbot/urls.py b/askbot/urls.py
index 551b9ecd..b140a44a 100644
--- a/askbot/urls.py
+++ b/askbot/urls.py
@@ -154,7 +154,7 @@ urlpatterns = patterns('',
name='answer'
),
url(#ajax only
- r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('vote/')),
+ r'^vote$',
views.commands.vote,
name='vote'
),
diff --git a/askbot/views/commands.py b/askbot/views/commands.py
index b7642440..1436d3c8 100644
--- a/askbot/views/commands.py
+++ b/askbot/views/commands.py
@@ -203,7 +203,7 @@ def process_vote(user = None, vote_direction = None, post = None):
@csrf.csrf_exempt
-def vote(request, id):
+def vote(request):
"""
todo: this subroutine needs serious refactoring it's too long and is hard to understand
@@ -262,6 +262,8 @@ def vote(request, id):
else:
raise Exception(_('Sorry, something is not right here...'))
+ id = request.POST.get('postId')
+
if vote_type == '0':
if askbot_settings.ACCEPTING_ANSWERS_ENABLED is False:
return
@@ -296,8 +298,8 @@ def vote(request, id):
if vote_type in ('5', '6'):
#todo: fix this weirdness - why postId here
#and not with question?
- id = request.POST.get('postId')
- post = get_object_or_404(models.Post, post_type='answer', id=id)
+ post_id = request.POST.get('postId')
+ post = get_object_or_404(models.Post, post_type='answer', id=post_id)
else:
post = get_object_or_404(models.Post, post_type='question', id=id)
#