diff options
author | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-09-07 16:02:33 -0600 |
---|---|---|
committer | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-09-10 16:55:33 -0600 |
commit | 72b7105b032fe501d0b4d8183850a51dff1f5c09 (patch) | |
tree | 430d84ca68d4810bab83263a333ca01d7d579f45 /askbot/skins | |
parent | cb8eafe2320aa2f2d2a47be1fdc77a94d2c6feb5 (diff) | |
download | askbot-72b7105b032fe501d0b4d8183850a51dff1f5c09.tar.gz askbot-72b7105b032fe501d0b4d8183850a51dff1f5c09.tar.bz2 askbot-72b7105b032fe501d0b4d8183850a51dff1f5c09.zip |
Convert answer to comment.
Diffstat (limited to 'askbot/skins')
-rw-r--r-- | askbot/skins/common/media/js/post.js | 6 | ||||
-rw-r--r-- | askbot/skins/common/media/js/utils.js | 10 | ||||
-rw-r--r-- | askbot/skins/common/templates/question/answer_controls.html | 8 | ||||
-rw-r--r-- | askbot/skins/default/media/style/style.css | 40 | ||||
-rw-r--r-- | askbot/skins/default/media/style/style.less | 35 | ||||
-rw-r--r-- | askbot/skins/default/templates/macros.html | 2 | ||||
-rw-r--r-- | askbot/skins/default/templates/question.html | 17 | ||||
-rw-r--r-- | askbot/skins/default/templates/question/javascript.html | 1 |
8 files changed, 104 insertions, 15 deletions
diff --git a/askbot/skins/common/media/js/post.js b/askbot/skins/common/media/js/post.js index 63548409..f495d03b 100644 --- a/askbot/skins/common/media/js/post.js +++ b/askbot/skins/common/media/js/post.js @@ -1475,9 +1475,9 @@ Comment.prototype.decorate = function(element){ this._edit_link.decorate(edit_link); } - var convert_link = this._element.find('form.convert'); + var convert_link = this._element.find('form.convert-comment'); if (this._is_convertible){ - this._convert_link = new ConvertLink(comment_id); + this._convert_link = new CommentConvertLink(comment_id); this._convert_link.decorate(convert_link); } @@ -1566,7 +1566,7 @@ Comment.prototype.setContent = function(data){ } if (this._is_convertible){ - this._convert_link = new ConvertLink(this._data['id']); + this._convert_link = new CommentConvertLink(this._data['id']); this._comment_body.append(this._convert_link.getElement()); } this._element.append(this._comment_body); diff --git a/askbot/skins/common/media/js/utils.js b/askbot/skins/common/media/js/utils.js index aa7a3829..c8e0a085 100644 --- a/askbot/skins/common/media/js/utils.js +++ b/askbot/skins/common/media/js/utils.js @@ -462,15 +462,15 @@ EditLink.prototype.decorate = function(element){ this.setHandlerInternal(); }; -var ConvertLink = function(comment_id){ +var CommentConvertLink = function(comment_id){ WrappedElement.call(this) this._comment_id = comment_id; }; -inherits(ConvertLink, WrappedElement); +inherits(CommentConvertLink, WrappedElement); -ConvertLink.prototype.createDom = function(){ +CommentConvertLink.prototype.createDom = function(){ var element = this.makeElement('form'); - element.addClass('convert'); + element.addClass('convert-comment'); element.attr('method', 'POST'); element.attr('action', askbot['urls']['convertComment']); var hidden_input = this.makeElement('input'); @@ -488,7 +488,7 @@ ConvertLink.prototype.createDom = function(){ }; -ConvertLink.prototype.decorate = function(element){ +CommentConvertLink.prototype.decorate = function(element){ this._element = element; }; diff --git a/askbot/skins/common/templates/question/answer_controls.html b/askbot/skins/common/templates/question/answer_controls.html index 50f40144..42fa9820 100644 --- a/askbot/skins/common/templates/question/answer_controls.html +++ b/askbot/skins/common/templates/question/answer_controls.html @@ -40,6 +40,14 @@ <span id='post-{{answer.id}}-edit' class="action-link"> <a class="question-edit" href="{% url edit_answer answer.id %}">{% trans %}edit{% endtrans %}</a> </span> +<span id='post-{{answer.id}}-convert' class="action-link"> + <form class="answer-convert" action="{% url answer_to_comment %}" method="POST"> + {% csrf_token %} + <input type="hidden" name="answer_id" id="id_answer_id" value="{{answer.id}}"> + <input type="submit" name="" value="{% trans %}convert to comment{% endtrans %}"> + </form> +</span> <script type="text/javascript"> askbot['functions']['renderPostControls']('{{answer.id}}'); + askbot['functions']['hideConvertAnswerLinks']('{{answer.id}}'); </script> diff --git a/askbot/skins/default/media/style/style.css b/askbot/skins/default/media/style/style.css index d787977d..238a9fa1 100644 --- a/askbot/skins/default/media/style/style.css +++ b/askbot/skins/default/media/style/style.css @@ -1803,6 +1803,40 @@ ul#related-tags li { .question-page .answer-controls .permant-link { background: url(../images/link.png) no-repeat center left; } +.question-page .post-controls .answer-convert, +.question-page .answer-controls .answer-convert { + float: right; + clear: left; + /*background: url(../images/link.png) no-repeat center left;*/ + +} +.question-page .post-controls .answer-convert input, +.question-page .answer-controls .answer-convert input { + font-size: 12px; + color: #777; + font-family: Arial; + text-decoration: none; + display: inline; + white-space: nowrap; + padding-left: 0px; + background: none; + border: none; + padding: 0px 7px 3px 18px; + float: right; + height: 18px; + line-height: 18px; + margin-top: -2px; + margin-left: 4px; +} +.question-page .post-controls .answer-convert input:hover, +.question-page .answer-controls .answer-convert input:hover { + background-color: #f5f0c9; + border-radius: 3px; + -ms-border-radius: 3px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + -khtml-border-radius: 3px; +} .question-page .tabBar { width: 100%; } @@ -2033,12 +2067,12 @@ ul#related-tags li { .question-page .comments .comment-body .edit { padding-left: 6px; } -.question-page .comments .comment-body .convert { +.question-page .comments .comment-body .convert-comment { display: inline; white-space: nowrap; padding-left: 0px; } -.question-page .comments .comment-body .convert input { +.question-page .comments .comment-body .convert-comment input { background: none; padding: 0px; color: #1B79BD; @@ -2049,7 +2083,7 @@ ul#related-tags li { margin-left: 6px; font-size: 13px; } -.question-page .comments .comment-body .convert input:hover { +.question-page .comments .comment-body .convert-comment input:hover { text-decoration: underline; cursor: pointer; } diff --git a/askbot/skins/default/media/style/style.less b/askbot/skins/default/media/style/style.less index 062ccd36..c311e53f 100644 --- a/askbot/skins/default/media/style/style.less +++ b/askbot/skins/default/media/style/style.less @@ -1753,6 +1753,35 @@ ul#related-tags li { .permant-link{ background: url(../images/link.png) no-repeat center left; } + + .answer-convert{ + float:right; + clear: left; + /*background: url(../images/link.png) no-repeat center left;*/ + } + + .answer-convert input{ + font-size:12px; + color: #777; + font-family:@body-font; + text-decoration: none; + display:inline; + white-space:nowrap; + padding-left: 0px; + background: none; + border: none; + padding: 0px 7px 3px 18px; + float:right; + height:18px; + line-height:18px; + margin-top:-2px; + margin-left:4px; + } + + .answer-convert input:hover{ + background-color: #f5f0c9; + .rounded-corners(3px); + } } .tabBar{ width:100%; @@ -1949,13 +1978,13 @@ ul#related-tags li { padding-left:6px; } - .convert { + .convert-comment{ display: inline; white-space: nowrap; padding-left: 0px; } - .convert input{ + .convert-comment input{ background: none; padding: 0px; color: #1B79BD; @@ -1967,7 +1996,7 @@ ul#related-tags li { font-size: 13px; } - .convert input:hover{ + .convert-comment input:hover{ text-decoration:underline; cursor:pointer; } diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index 06366ebb..ac7e6474 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -389,7 +389,7 @@ for the purposes of the AJAX comment editor #} <span class="age"> ({{ timeago(comment.added_at) }})</span> <a id="post-{{comment.id}}-edit" class="edit">{% trans %}edit{% endtrans %}</a> - <form action="{% url comment_to_answer %}" method="POST" accept-charset="utf-8" class='convert'> + <form action="{% url comment_to_answer %}" method="POST" accept-charset="utf-8" class='convert-comment'> {% csrf_token %} <input type="hidden" value="{{comment.id}}" name="comment_id" id="id_comment_id"> <input type="submit" value="{% trans %}convert to answer{% endtrans %}"> diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html index 4374dc8e..4d43afa2 100644 --- a/askbot/skins/default/templates/question.html +++ b/askbot/skins/default/templates/question.html @@ -52,6 +52,22 @@ } } } + + function hide_convert_answer_links(post_id){ + 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); + } + } else{ + convert_answer.parentNode.removeChild(convert_answer); + } + } + function render_post_controls(post_id){ if (data['userIsAdminOrMod']){ return;//all functions on @@ -164,6 +180,7 @@ askbot['functions']['renderAddCommentButton'] = render_add_comment_button; askbot['functions']['renderAddAnswerButton'] = render_add_answer_button; askbot['functions']['hideConvertLinks'] = hide_convert_links; + askbot['functions']['hideConvertAnswerLinks'] = hide_convert_answer_links; })(); </script> {% endblock %} diff --git a/askbot/skins/default/templates/question/javascript.html b/askbot/skins/default/templates/question/javascript.html index 5b73854e..b9904ba4 100644 --- a/askbot/skins/default/templates/question/javascript.html +++ b/askbot/skins/default/templates/question/javascript.html @@ -10,6 +10,7 @@ askbot['urls']['editComment'] = '{% url edit_comment %}'; askbot['urls']['deleteComment'] = '{% url delete_comment %}'; askbot['urls']['convertComment'] = '{% url comment_to_answer %}'; + askbot['urls']['convertAnswer'] = '{% url answer_to_comment %}'; askbot['urls']['getComment'] = '{% url get_comment %}'; askbot['urls']['question_url_template'] = scriptUrl + '{{ 'question/'|transurl }}{{ "{{QuestionID}}/{{questionSlug}}" }}';{# yes it needs to be that whacky #} askbot['urls']['vote_url_template'] = scriptUrl + '{{ 'questions/'|transurl }}{{ "{{QuestionID}}/" }}{{ 'vote/'|transurl }}'; |