From c79d90be27a70a07273fc529f3a5283fbb870f4a Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 18 Apr 2011 15:31:48 -0700 Subject: [PATCH] Only remove reply placeholders if the dummy answer field is visible --- plugins/QnA/js/qna.js | 27 +++++++++++++++++++++------ plugins/QnA/lib/qnashowanswerform.php | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/plugins/QnA/js/qna.js b/plugins/QnA/js/qna.js index 3fc9b7deec..55d7dd65c5 100644 --- a/plugins/QnA/js/qna.js +++ b/plugins/QnA/js/qna.js @@ -2,8 +2,8 @@ var QnA = { // @fixme: Should use ID - close: function(closeButt) { - var notice = $(closeButt).closest('li.hentry.notice.question'); + close: function(form, best) { + var notice = $(form).closest('li.hentry.notice.question'); console.log("close"); @@ -16,8 +16,18 @@ var QnA = { notice.find('ul > li.notice-answer-placeholder').remove(); notice.find('ul > li.notice-answer').remove(); + + if (best) { + var p = notice.parent().find('div.question-description > form > fieldset > p'); + if (p.length != 0) { + p.append($('This question is closed.')); + } + } + }, + + init: function() { QnA.NoticeInlineAnswerSetup(); @@ -25,8 +35,8 @@ var QnA = { $('form.form_question_show').live('submit', function() { QnA.close(this); }); - $('form.form_answer_show').live('click', function() { - QnA.close(this); + $('form.form_answer_show').live('submit', function() { + QnA.close(this, true); }); }, @@ -99,7 +109,12 @@ var QnA = { $('body').click(function(e) { console.log("body click handler - got click"); - hideReplyPlaceholders(notice); + var dummyAnswer = $('ul.qna-dummy', notice); + + var style = dummyAnswer.attr('style'); + if (style !== 'display: none;') { + hideReplyPlaceholders(notice); + } var openAnswers = $('li.notice-answer'); if (openAnswers.length > 0) { @@ -352,7 +367,7 @@ var QnA = { var answerItem = form.closest('li.notice-answer'); var questionItem = form.closest('li.question'); - var dummyAnswer = form.find('ul.qna-dummy').remove(); + var dummyAnswer = form.find('ul.qna-dummy', questionItem).remove(); if (answerItem.length > 0) { console.log("FormAnswerXHR - I found the answer li to append to"); diff --git a/plugins/QnA/lib/qnashowanswerform.php b/plugins/QnA/lib/qnashowanswerform.php index 10d8f3e192..e900eb1992 100644 --- a/plugins/QnA/lib/qnashowanswerform.php +++ b/plugins/QnA/lib/qnashowanswerform.php @@ -149,7 +149,7 @@ class QnashowanswerForm extends Form // TRANS: Button text for marking an answer as "best" _m('BUTTON', 'Best'), 'submit', - 'submit', + 'best', // TRANS: Title for button text marking an answer as "best" _('Mark as best answer') ); -- 2.39.5