No separate placeholder input element for replyforms
Also we're moving the rendering of these out into a separate plugin. Not done yet, some javascript should be moved out as well.
This commit is contained in:
parent
13c331fa81
commit
0da7512597
62
js/util.js
62
js/util.js
@ -620,37 +620,18 @@ var SN = { // StatusNet
|
|||||||
var parentNotice = notice;
|
var parentNotice = notice;
|
||||||
var stripForm = true; // strip a couple things out of reply forms that are inline
|
var stripForm = true; // strip a couple things out of reply forms that are inline
|
||||||
|
|
||||||
// Find the threaded replies view we'll be adding to...
|
|
||||||
var list = notice.closest('.notices');
|
var list = notice.closest('.notices');
|
||||||
if (list.closest('.old-school').length) {
|
if (list.hasClass('threaded-replies')) {
|
||||||
// We're replying to an old-school conversation thread;
|
|
||||||
// use the old-style ping into the top form.
|
|
||||||
SN.U.switchInputFormTab("status");
|
|
||||||
replyForm = $('#input_form_status').find('form');
|
|
||||||
stripForm = false;
|
|
||||||
} else if (list.hasClass('threaded-replies')) {
|
|
||||||
// We're replying to a reply; use reply form on the end of this list.
|
// We're replying to a reply; use reply form on the end of this list.
|
||||||
// We'll add our form at the end of this; grab the root notice.
|
|
||||||
parentNotice = list.closest('.notice');
|
|
||||||
|
|
||||||
// See if the form's already open...
|
|
||||||
replyForm = $('.notice-reply-form', list);
|
|
||||||
} else {
|
} else {
|
||||||
// We're replying to a parent notice; pull its threaded list
|
// We're replying to a parent notice; pull its threaded list
|
||||||
// and we'll add on the end of it. Will add if needed.
|
// and we'll add on the end of it. Will add the threaded list if needed.
|
||||||
list = $('ul.threaded-replies', notice);
|
var list = $('ul.threaded-replies', notice);
|
||||||
if (list.length == 0) {
|
if (list.length == 0) {
|
||||||
SN.U.NoticeInlineReplyPlaceholder(notice);
|
list = $('<ul class="notices threaded-replies xoxo"></ul>');
|
||||||
list = $('ul.threaded-replies', notice);
|
notice.append(list);
|
||||||
} else {
|
list = notice.find('ul.threaded-replies');
|
||||||
placeholder = $('li.notice-reply-placeholder', notice);
|
|
||||||
if (placeholder.length == 0) {
|
|
||||||
SN.U.NoticeInlineReplyPlaceholder(notice);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if the form's already open...
|
|
||||||
replyForm = $('.notice-reply-form', list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var nextStep = function () {
|
var nextStep = function () {
|
||||||
@ -681,15 +662,15 @@ var SN = { // StatusNet
|
|||||||
text[0].setSelectionRange(len, len);
|
text[0].setSelectionRange(len, len);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// See if the form's already open...
|
||||||
|
replyForm = $('.notice-reply-form', list);
|
||||||
if (replyForm.length > 0) {
|
if (replyForm.length > 0) {
|
||||||
// Update the existing form...
|
// Update the existing form...
|
||||||
nextStep();
|
nextStep();
|
||||||
} else {
|
} else {
|
||||||
// Hide the placeholder...
|
|
||||||
placeholder = list.find('li.notice-reply-placeholder').hide();
|
|
||||||
|
|
||||||
// Create the reply form entry at the end
|
// Create the reply form entry at the end
|
||||||
var replyItem = $('li.notice-reply', list);
|
var replyItem = $('li.notice-reply > form', list);
|
||||||
if (replyItem.length == 0) {
|
if (replyItem.length == 0) {
|
||||||
replyItem = $('<li class="notice-reply"></li>');
|
replyItem = $('<li class="notice-reply"></li>');
|
||||||
|
|
||||||
@ -721,34 +702,13 @@ var SN = { // StatusNet
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
NoticeInlineReplyPlaceholder: function (notice) {
|
|
||||||
var list = notice.find('ul.threaded-replies');
|
|
||||||
if (list.length == 0) {
|
|
||||||
list = $('<ul class="notices threaded-replies xoxo"></ul>');
|
|
||||||
notice.append(list);
|
|
||||||
list = notice.find('ul.threaded-replies');
|
|
||||||
}
|
|
||||||
var placeholder = $('<li class="notice-reply-placeholder">' +
|
|
||||||
'<input class="placeholder" />' +
|
|
||||||
'</li>');
|
|
||||||
placeholder.find('input')
|
|
||||||
.val(SN.msg('reply_placeholder'));
|
|
||||||
list.append(placeholder);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup function -- DOES NOT apply immediately.
|
* Setup function -- DOES NOT apply immediately.
|
||||||
*
|
*
|
||||||
* Sets up event handlers for inline reply mini-form placeholders.
|
|
||||||
* Uses 'on' rather than 'live' or 'bind', so applies to future as well as present items.
|
* Uses 'on' rather than 'live' or 'bind', so applies to future as well as present items.
|
||||||
*/
|
*/
|
||||||
NoticeInlineReplySetup: function () {
|
NoticeInlineReplySetup: function () {
|
||||||
$('li.notice-reply-placeholder input')
|
// Expand conversation links
|
||||||
.on('focus', function () {
|
|
||||||
var notice = $(this).closest('li.notice');
|
|
||||||
SN.U.NoticeInlineReplyTrigger(notice);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$(document).on('click', 'li.notice-reply-comments a', function () {
|
$(document).on('click', 'li.notice-reply-comments a', function () {
|
||||||
var url = $(this).attr('href');
|
var url = $(this).attr('href');
|
||||||
var area = $(this).closest('.threaded-replies');
|
var area = $(this).closest('.threaded-replies');
|
||||||
|
@ -309,6 +309,7 @@ $default =
|
|||||||
'AntiBrute' => array(),
|
'AntiBrute' => array(),
|
||||||
'Bookmark' => array(),
|
'Bookmark' => array(),
|
||||||
'ClientSideShorten' => array(),
|
'ClientSideShorten' => array(),
|
||||||
|
'DefaultLayout' => array(),
|
||||||
'Directory' => array(),
|
'Directory' => array(),
|
||||||
'DirectMessage' => array(),
|
'DirectMessage' => array(),
|
||||||
'EmailAuthentication' => array(),
|
'EmailAuthentication' => array(),
|
||||||
|
@ -253,14 +253,8 @@ class ThreadedNoticeListItem extends NoticeListItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($threadActive && Profile::current() instanceof Profile) {
|
|
||||||
// @fixme do a proper can-post check that's consistent
|
|
||||||
// with the JS side
|
|
||||||
$item = new ThreadedNoticeListReplyItem($this->notice, $this->out);
|
|
||||||
$item->show();
|
|
||||||
}
|
|
||||||
$this->out->elementEnd('ul');
|
|
||||||
Event::handle('EndShowThreadedNoticeTail', array($this, $this->notice, $notices));
|
Event::handle('EndShowThreadedNoticeTail', array($this, $this->notice, $notices));
|
||||||
|
$this->out->elementEnd('ul');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,45 +375,6 @@ class ThreadedNoticeListMoreItem extends NoticeListItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Placeholder for reply form...
|
|
||||||
* Same as get added at runtime via SN.U.NoticeInlineReplyPlaceholder
|
|
||||||
*/
|
|
||||||
class ThreadedNoticeListReplyItem extends NoticeListItem
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* recipe function for displaying a single notice.
|
|
||||||
*
|
|
||||||
* This uses all the other methods to correctly display a notice. Override
|
|
||||||
* it or one of the others to fine-tune the output.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function show()
|
|
||||||
{
|
|
||||||
$this->showStart();
|
|
||||||
$this->showMiniForm();
|
|
||||||
$this->showEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start a single notice.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function showStart()
|
|
||||||
{
|
|
||||||
$this->out->elementStart('li', array('class' => 'notice-reply-placeholder'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function showMiniForm()
|
|
||||||
{
|
|
||||||
$this->out->element('input', array('class' => 'placeholder',
|
|
||||||
// TRANS: Field label for reply mini form.
|
|
||||||
'value' => _('Write a reply...')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Placeholder for showing repeats...
|
* Placeholder for showing repeats...
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user