summaryrefslogtreecommitdiffstats
path: root/askbot/skins
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-09-13 11:29:06 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-09-13 11:29:06 -0400
commit32c8811baba52f22e08d954d97dfc45ec20602d4 (patch)
tree1e173e2e815a2b8bba1e2bb751aa378da22b4177 /askbot/skins
parentc2587287e11a31ced679e7127af2b204ce559abd (diff)
downloadaskbot-32c8811baba52f22e08d954d97dfc45ec20602d4.tar.gz
askbot-32c8811baba52f22e08d954d97dfc45ec20602d4.tar.bz2
askbot-32c8811baba52f22e08d954d97dfc45ec20602d4.zip
answer publishing seems to work fully
Diffstat (limited to 'askbot/skins')
-rw-r--r--askbot/skins/common/media/js/post.js21
-rw-r--r--askbot/skins/common/templates/question/answer_controls.html31
-rw-r--r--askbot/skins/default/media/images/publish.pngbin0 -> 282 bytes
-rw-r--r--askbot/skins/default/media/images/unpublish.pngbin0 -> 294 bytes
-rw-r--r--askbot/skins/default/media/style/style.less10
-rw-r--r--askbot/skins/default/templates/question.html27
-rw-r--r--askbot/skins/default/templates/question/javascript.html2
7 files changed, 63 insertions, 28 deletions
diff --git a/askbot/skins/common/media/js/post.js b/askbot/skins/common/media/js/post.js
index 3c320f76..71718199 100644
--- a/askbot/skins/common/media/js/post.js
+++ b/askbot/skins/common/media/js/post.js
@@ -3962,6 +3962,27 @@ $(document).ready(function() {
deleter.setPostId(post_id);
deleter.decorate($(element).find('.question-delete'));
});
+ //todo: convert to "control" class
+ var publishBtns = $('.answer-publish, .answer-unpublish');
+ publishBtns.each(function(idx, btn) {
+ setupButtonEventHandlers($(btn), function() {
+ var answerId = $(btn).data('answerId');
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ data: {'answer_id': answerId},
+ url: askbot['urls']['publishAnswer'],
+ success: function(data) {
+ if (data['success']) {
+ window.location.reload(true);
+ } else {
+ showMessage($(btn), data['message']);
+ }
+ }
+ });
+ });
+ });
+
if (askbot['settings']['tagSource'] == 'category-tree') {
var catSelectorLoader = new CategorySelectorLoader();
catSelectorLoader.decorate($('#retag'));
diff --git a/askbot/skins/common/templates/question/answer_controls.html b/askbot/skins/common/templates/question/answer_controls.html
index 21d12dd6..4efc7247 100644
--- a/askbot/skins/common/templates/question/answer_controls.html
+++ b/askbot/skins/common/templates/question/answer_controls.html
@@ -9,26 +9,20 @@
</a>
</span>
<span
+ id="post-{{answer.id}}-publish"
class="action-link"
- id="answer-publish-{{ answer.id }}"
+>
{% if answer.id in published_answer_ids %}
- title="{% trans %}unpublish{% endtrans %}"
+ <a
+ class="answer-unpublish"
+ data-answer-id="{{ answer.id }}"
+ >{% trans %}unpublish{% endtrans %}</a>
{% else %}
- title="{% trans %}publish{% endtrans %}"
+ <a
+ class="answer-publish"
+ data-answer-id="{{ answer.id}}"
+ >{% trans %}publish{% endtrans %}</a>
{% endif %}
->
- <form action="{% url publish_answer %}">{% csrf_token %}
- <input type="hidden" name="answer_id" id="id_answer_id" value="{{answer.id}}"/>
- <input
- type="submit"
- name=""
- {% if answer.id in published_answer_ids %}
- name="{% trans %}unpublish{% endtrans %}"
- {% else %}
- name="{% trans %}publish{% endtrans %}"
- {% endif %}
- />
- </form>
</span>
<span id='post-{{answer.id}}-delete' class="action-link delete-post">
<a class="question-delete"
@@ -69,6 +63,7 @@
</form>
</span>
<script type="text/javascript">
- askbot['functions']['hideConvertAnswerLinks']('{{answer.id}}');
- askbot['functions']['renderPostControls']('{{answer.id}}');
+ askbot['functions']['hideConvertAnswerLinks']('{{ answer.id }}');
+ askbot['functions']['hidePublishAnswerLink']('{{ answer.id }}');
+ askbot['functions']['renderPostControls']('{{ answer.id }}');
</script>
diff --git a/askbot/skins/default/media/images/publish.png b/askbot/skins/default/media/images/publish.png
new file mode 100644
index 00000000..038a87d2
--- /dev/null
+++ b/askbot/skins/default/media/images/publish.png
Binary files differ
diff --git a/askbot/skins/default/media/images/unpublish.png b/askbot/skins/default/media/images/unpublish.png
new file mode 100644
index 00000000..bfac25b1
--- /dev/null
+++ b/askbot/skins/default/media/images/unpublish.png
Binary files differ
diff --git a/askbot/skins/default/media/style/style.less b/askbot/skins/default/media/style/style.less
index f3151cf0..83fd4b9b 100644
--- a/askbot/skins/default/media/style/style.less
+++ b/askbot/skins/default/media/style/style.less
@@ -1964,14 +1964,20 @@ ul#related-tags li {
}
.post-controls, .answer-controls{
.question-delete{
- background: url(../images/delete.png) no-repeat center left;
+ background: url(../images/delete.png) no-repeat left 2px;
padding-left:11px;
}
.question-flag{
background: url(../images/flag.png) no-repeat center left;
}
+ .answer-publish{
+ background: url(../images/publish.png) no-repeat center left;
+ }
+ .answer-unpublish{
+ background: url(../images/unpublish.png) no-repeat 2px center;
+ }
.question-edit{
- background: url(../images/edit2.png) no-repeat center left;
+ background: url(../images/edit2.png) no-repeat 2px center;
}
.question-retag{
background: url(../images/retag.png) no-repeat center left;
diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html
index 794853c2..57c71068 100644
--- a/askbot/skins/default/templates/question.html
+++ b/askbot/skins/default/templates/question.html
@@ -14,6 +14,7 @@
<script type="text/javascript">
/*<![CDATA[*/
//below is pure cross-browser javascript, no jQuery
+ askbot['data']['userIsThreadModerator'] = {% if user_is_thread_moderator %}true{% else %}false{% endif %};
(function(){
var data = askbot['data'];
if (data['userIsAuthenticated']){
@@ -59,20 +60,29 @@
var answer_convert_id = 'post-' + post_id + '-convert';
var convert_answer = document.getElementById(answer_convert_id);
if (data['userIsAdminOrMod']){
- var answer_id = 'post-id-' + post_id;
- var answer_container = document.getElementById(answer_id);
- var answer_element= answer_container.getElementsByClassName('answer-body')[0].children[1];
- if (answer_element.textContent.length > 300){
- convert_answer.parentNode.removeChild(convert_answer);
- }
+ var answer_id = 'post-id-' + post_id;
+ var answer_container = document.getElementById(answer_id);
+ var answer_element= answer_container.getElementsByClassName('answer-body')[0].children[1];
+ if (answer_element.textContent.length > 300){
+ convert_answer.parentNode.removeChild(convert_answer);
+ }
} else{
- convert_answer.parentNode.removeChild(convert_answer);
+ convert_answer.parentNode.removeChild(convert_answer);
+ }
+ }
+
+ function hidePublishAnswerLink(postId) {
+ if (data['userIsThreadModerator'] === false) {
+ //hide publish/unpublish answer links
+ var answerId = 'post-' + postId + '-publish';
+ var pubBtn = document.getElementById(answerId);
+ pubBtn.parentNode.removeChild(pubBtn);
}
}
function render_post_controls(post_id){
if (data['userIsAdminOrMod']){
- return;//all functions on
+ return;//all remaining functions stay on
}
if (data['user_posts'] === undefined) {
return;
@@ -189,6 +199,7 @@
askbot['functions']['renderAddAnswerButton'] = render_add_answer_button;
askbot['functions']['hideConvertLinks'] = hide_convert_links;
askbot['functions']['hideConvertAnswerLinks'] = hide_convert_answer_links;
+ askbot['functions']['hidePublishAnswerLink'] = hidePublishAnswerLink;
})();
/*]]>*/
</script>
diff --git a/askbot/skins/default/templates/question/javascript.html b/askbot/skins/default/templates/question/javascript.html
index df81ede2..5dca2522 100644
--- a/askbot/skins/default/templates/question/javascript.html
+++ b/askbot/skins/default/templates/question/javascript.html
@@ -21,6 +21,8 @@
askbot['urls']['delete_post'] = '{% url delete_post %}';
askbot['urls']['get_html_template'] = '{% url get_html_template %}';
askbot['urls']['getGroupsList'] = '{% url get_groups_list %}';
+ askbot['urls']['publishAnswer'] = '{% url publish_answer %}';
+ askbot['data']['userIsThreadModerator'] = {% if user_is_thread_moderator %}true{% else %}false{% endif %};
askbot['messages']['addComment'] = '{% trans %}post a comment{% endtrans %}';
{% if settings.SAVE_COMMENT_ON_ENTER %}
askbot['settings']['saveCommentOnEnter'] = true;