diff options
author | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-09-04 22:48:11 -0600 |
---|---|---|
committer | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-09-04 22:48:11 -0600 |
commit | 68e1d6bbe9be73cd8a463f79b4cf6c5d2493e3c1 (patch) | |
tree | 9b96ff9901a744076d8e4001d1514a98ab149dc1 | |
parent | 5ce9b7ca1b1bac4f5eb6d6feb501e5cfeb8a8b8b (diff) | |
download | askbot-68e1d6bbe9be73cd8a463f79b4cf6c5d2493e3c1.tar.gz askbot-68e1d6bbe9be73cd8a463f79b4cf6c5d2493e3c1.tar.bz2 askbot-68e1d6bbe9be73cd8a463f79b4cf6c5d2493e3c1.zip |
added convertlink to the utils.js and post.js
-rw-r--r-- | askbot/skins/common/media/js/post.js | 16 | ||||
-rw-r--r-- | askbot/skins/common/media/js/utils.js | 30 | ||||
-rw-r--r-- | askbot/skins/default/templates/macros.html | 2 | ||||
-rw-r--r-- | askbot/skins/default/templates/question/javascript.html | 1 |
4 files changed, 48 insertions, 1 deletions
diff --git a/askbot/skins/common/media/js/post.js b/askbot/skins/common/media/js/post.js index 32453212..63548409 100644 --- a/askbot/skins/common/media/js/post.js +++ b/askbot/skins/common/media/js/post.js @@ -1437,6 +1437,8 @@ var Comment = function(widget, data){ this._data = data || {}; this._blank = true;//set to false by setContent this._element = null; + this._is_convertible = askbot['data']['userIsAdminOrMod']; + this.convert_link = null; this._delete_prompt = gettext('delete this comment'); if (data && data['is_deletable']){ this._deletable = data['is_deletable']; @@ -1473,6 +1475,12 @@ Comment.prototype.decorate = function(element){ this._edit_link.decorate(edit_link); } + var convert_link = this._element.find('form.convert'); + if (this._is_convertible){ + this._convert_link = new ConvertLink(comment_id); + this._convert_link.decorate(convert_link); + } + var vote = new CommentVoteButton(this); vote.decorate(this._element.find('.comment-votes .upvote')); @@ -1556,6 +1564,11 @@ Comment.prototype.setContent = function(data){ this._edit_link.setHandler(this.getEditHandler()) this._comment_body.append(this._edit_link.getElement()); } + + if (this._is_convertible){ + this._convert_link = new ConvertLink(this._data['id']); + this._comment_body.append(this._convert_link.getElement()); + } this._element.append(this._comment_body); this._blank = false; @@ -1580,6 +1593,9 @@ Comment.prototype.dispose = function(){ if (this._edit_link){ this._edit_link.dispose(); } + if (this._convert_link){ + this._convert_link.dispose(); + } this._data = null; Comment.superClass_.dispose.call(this); }; diff --git a/askbot/skins/common/media/js/utils.js b/askbot/skins/common/media/js/utils.js index 3f585435..aa7a3829 100644 --- a/askbot/skins/common/media/js/utils.js +++ b/askbot/skins/common/media/js/utils.js @@ -462,6 +462,36 @@ EditLink.prototype.decorate = function(element){ this.setHandlerInternal(); }; +var ConvertLink = function(comment_id){ + WrappedElement.call(this) + this._comment_id = comment_id; +}; +inherits(ConvertLink, WrappedElement); + +ConvertLink.prototype.createDom = function(){ + var element = this.makeElement('form'); + element.addClass('convert'); + element.attr('method', 'POST'); + element.attr('action', askbot['urls']['convertComment']); + var hidden_input = this.makeElement('input'); + hidden_input.attr('type', 'hidden'); + hidden_input.attr('value', this._comment_id); + hidden_input.attr('name', 'comment_id'); + hidden_input.attr('id', 'id_comment_id'); + element.append(hidden_input); + + var submit = this.makeElement('input'); + submit.attr('type', 'submit'); + submit.attr('value', gettext('convert to answer')); + element.append(submit); + this.decorate(element); +}; + + +ConvertLink.prototype.decorate = function(element){ + this._element = element; +}; + var DeleteIcon = function(title){ SimpleControl.call(this); this._title = title; diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index d1a2bfde..eaa71815 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -392,7 +392,7 @@ for the purposes of the AJAX comment editor #} <form action="{% url comment_to_answer %}" method="POST" accept-charset="utf-8" class='convert'> {% csrf_token %} <input type="hidden" value="{{comment.id}}" name="comment_id" id="id_comment_id"> - <input type="submit" value="{% trans %}convert to answer{% endtrans %}"></p> + <input type="submit" value="{% trans %}convert to answer{% endtrans %}"> </form> </div> </div> diff --git a/askbot/skins/default/templates/question/javascript.html b/askbot/skins/default/templates/question/javascript.html index af0b0829..5b73854e 100644 --- a/askbot/skins/default/templates/question/javascript.html +++ b/askbot/skins/default/templates/question/javascript.html @@ -9,6 +9,7 @@ askbot['urls']['postComments'] = '{% url post_comments %}'; askbot['urls']['editComment'] = '{% url edit_comment %}'; askbot['urls']['deleteComment'] = '{% url delete_comment %}'; + askbot['urls']['convertComment'] = '{% url comment_to_answer %}'; 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 }}'; |