Commit 583b9035 authored by Zach Copley's avatar Zach Copley

More work trying to understand util.js and get my ajax working right

parent d1443a6b
......@@ -639,6 +639,7 @@ var SN = { // StatusNet
*/
NoticeInlineReplyTrigger: function(notice, initialText) {
// Find the notice we're replying to...
console.log('NoticeInlineReplyTrigger');
var id = $($('.notice_id', notice)[0]).text();
var parentNotice = notice;
......
......@@ -431,12 +431,17 @@ class QnAPlugin extends MicroAppPlugin
// Output a placeholder input -- clicking on it will
// bring up a real answer form
if (empty($answer) && empty($question->closed)) {
$out->elementStart('ul', 'notices threaded-replies xoxo');
$out->elementStart('li', 'notice-answer-placeholder');
// NOTE: this whole ul is just a placeholder
if (empty($question->closed) && empty($answer)) {
$out->elementStart('ul', 'notices qna-dummy');
$out->elementStart('li', 'qna-dummy-placeholder');
$out->element(
'input',
array('class' => 'placeholder', 'value' => 'Answer...')
array(
'class' => 'placeholder',
'value' => _m('Your answer...')
)
);
$out->elementEnd('li');
$out->elementEnd('ul');
......@@ -458,7 +463,7 @@ class QnAPlugin extends MicroAppPlugin
$nli = new NoticeListItem($notice, $out);
$nli->showNotice();
$out->elementStart('div', array('class' => 'entry-content answer-content'));
$out->elementStart('p', array('class' => 'entry-content answer-content'));
if (!empty($answer)) {
$form = new QnashowanswerForm($out, $answer);
......@@ -467,7 +472,7 @@ class QnAPlugin extends MicroAppPlugin
$out->text(_m('Answer data is missing.'));
}
$out->elementEnd('div');
$out->elementEnd('p');
// @fixme
$out->elementStart('div', array('class' => 'entry-content'));
......
......@@ -76,7 +76,7 @@ class QnanewanswerAction extends Action
if ($this->boolean('ajax')) {
StatusNet::setApi(true);
}
common_debug("in qnanewanswer");
$this->user = common_current_user();
if (empty($this->user)) {
......@@ -163,7 +163,7 @@ class QnanewanswerAction extends Action
$this->elementStart('body');
$nli = new NoticeAnswerListItem($notice, $this);
$nli = new NoticeAnswerListItem($notice, $this, $this->question, $answer);
$nli->show();
$this->elementEnd('body');
......@@ -282,8 +282,8 @@ class QnanewanswerAction extends Action
class NoticeAnswerListItem extends NoticeListItem
{
protected $question;
protected $answer;
/**
* constructor
......@@ -292,10 +292,12 @@ class NoticeAnswerListItem extends NoticeListItem
*
* @param Notice $notice The notice we'll display
*/
function __construct($notice, $out=null)
function __construct($notice, $out=null, $question, $answer)
{
parent::__construct($notice, $out);
$this->question = $out->question;
$this->question = $question;
$this->answer = $answer;
}
function show()
......@@ -316,4 +318,35 @@ class NoticeAnswerListItem extends NoticeListItem
$this->showEnd();
}
/**
* show the content of the notice
*
* Shows the content of the notice. This is pre-rendered for efficiency
* at save time. Some very old notices might not be pre-rendered, so
* they're rendered on the spot.
*
* @return void
*/
function showContent()
{
$this->out->elementStart('p', array('class' => 'entry-content answer-content'));
if ($this->notice->rendered) {
$this->out->raw($this->notice->rendered);
} else {
// XXX: may be some uncooked notices in the DB,
// we cook them right now. This should probably disappear in future
// versions (>> 0.4.x)
$this->out->raw(common_render_content($this->notice->content, $this->notice));
}
if (!empty($this->answer)) {
$form = new QnashowanswerForm($this->out, $this->answer);
$form->show();
} else {
$out->text(_m('Answer data is missing.'));
}
$this->out->elementEnd('p');
}
}
\ No newline at end of file
......@@ -217,6 +217,14 @@ class QnA_Question extends Managed_DataObject
$out = new XMLStringer();
$cls = array('qna_question');
if (!empty($question->closed)) {
$cls[] = 'closed';
}
$out->elementStart('p', array('class' => implode(' ', $cls)));
if (!empty($question->description)) {
$out->elementStart('span', 'question-description');
$out->raw(QnAPlugin::shorten($question->description, $notice));
......@@ -237,6 +245,8 @@ class QnA_Question extends Managed_DataObject
$out->elementEnd('span');
}
$out->elementEnd('p');
return $out->getString();
}
......
This diff is collapsed.
......@@ -185,6 +185,6 @@ class QnashowanswerForm extends Form
*/
function formClass()
{
return 'form_show ajax';
return 'form_answer_show ajax';
}
}
......@@ -165,6 +165,6 @@ class QnashowquestionForm extends Form
*/
function formClass()
{
return 'form_close ajax';
return 'form_question_show ajax';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment