forked from GNUsocial/gnu-social
		
	Collapse long threaded displays with a link to the convo view (todo: turn it into an ajax loader for inline expansion)
This commit is contained in:
		@@ -145,6 +145,8 @@ class ThreadedNoticeList extends NoticeList
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class ThreadedNoticeListItem extends NoticeListItem
 | 
					class ThreadedNoticeListItem extends NoticeListItem
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    const INITIAL_ITEMS = 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * finish the notice
 | 
					     * finish the notice
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@@ -155,24 +157,32 @@ class ThreadedNoticeListItem extends NoticeListItem
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    function showEnd()
 | 
					    function showEnd()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $notice = Notice::conversationStream($this->notice->conversation);
 | 
					        $notice = Notice::conversationStream($this->notice->conversation, 0, self::INITIAL_ITEMS + 2);
 | 
				
			||||||
        $notices = array();
 | 
					        $notices = array();
 | 
				
			||||||
 | 
					        $cnt = 0;
 | 
				
			||||||
 | 
					        $moreCutoff = null;
 | 
				
			||||||
        while ($notice->fetch()) {
 | 
					        while ($notice->fetch()) {
 | 
				
			||||||
            if ($notice->id == $this->notice->id) {
 | 
					            if ($notice->id == $this->notice->id) {
 | 
				
			||||||
                // Skip!
 | 
					                // Skip!
 | 
				
			||||||
                continue;
 | 
					                continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            $cnt++;
 | 
				
			||||||
 | 
					            if ($cnt > self::INITIAL_ITEMS) {
 | 
				
			||||||
 | 
					                // boo-yah
 | 
				
			||||||
 | 
					                $moreCutoff = clone($notice);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            $notices[] = clone($notice); // *grumble* inefficient as hell
 | 
					            $notices[] = clone($notice); // *grumble* inefficient as hell
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($notices) {
 | 
					        if ($notices) {
 | 
				
			||||||
            $this->out->elementStart('ul', 'notices threaded-notices xoxo');
 | 
					            $this->out->elementStart('ul', 'notices threaded-notices xoxo');
 | 
				
			||||||
            foreach (array_reverse($notices) as $notice) {
 | 
					            if ($moreCutoff) {
 | 
				
			||||||
                $item = new ThreadedNoticeListSubItem($notice, $this->out);
 | 
					                $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out);
 | 
				
			||||||
                $item->show();
 | 
					                $item->show();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (common_current_user()) {
 | 
					            foreach (array_reverse($notices) as $notice) {
 | 
				
			||||||
                $item = new ThreadedNoticeListReplyItem($this->notice, $this->out);
 | 
					                $item = new ThreadedNoticeListSubItem($notice, $this->out);
 | 
				
			||||||
                $item->show();
 | 
					                $item->show();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            $this->out->elementEnd('ul');
 | 
					            $this->out->elementEnd('ul');
 | 
				
			||||||
@@ -202,9 +212,9 @@ class ThreadedNoticeListSubItem extends NoticeListItem
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Show a mini inline posting form for replies.
 | 
					 * Placeholder for loading more replies...
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class ThreadedNoticeListReplyItem extends NoticeListItem
 | 
					class ThreadedNoticeListMoreItem extends NoticeListItem
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -233,15 +243,21 @@ class ThreadedNoticeListReplyItem extends NoticeListItem
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if (Event::handle('StartOpenNoticeListItemElement', array($this))) {
 | 
					        if (Event::handle('StartOpenNoticeListItemElement', array($this))) {
 | 
				
			||||||
            $id = (empty($this->repeat)) ? $this->notice->id : $this->repeat->id;
 | 
					            $id = (empty($this->repeat)) ? $this->notice->id : $this->repeat->id;
 | 
				
			||||||
            $this->out->elementStart('li', array('class' => 'notice-reply-placeholder'));
 | 
					            $this->out->elementStart('li', array('class' => 'notice-reply-comments'));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function showMiniForm()
 | 
					    function showMiniForm()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $replyToId = $this->notice->id;
 | 
					        $id = $this->notice->conversation;
 | 
				
			||||||
        $id = 'replyto-notice-' + $replyToId;
 | 
					        $url = common_local_url('conversation', array('id' => $id)) . '#notice-' . $this->notice->id;
 | 
				
			||||||
        $url = common_local_url('newnotice');
 | 
					
 | 
				
			||||||
 | 
					        $notice = new Notice();
 | 
				
			||||||
 | 
					        $notice->conversation = $id;
 | 
				
			||||||
 | 
					        $n = $notice->count() - 1;
 | 
				
			||||||
 | 
					        $msg = sprintf(_m('Show all %d comment', 'Show all %d comments', $n), $n);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->out->element('a', array('href' => $url), $msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // @fixme replace this with an ajax-friendly form pair?
 | 
					        // @fixme replace this with an ajax-friendly form pair?
 | 
				
			||||||
        /*
 | 
					        /*
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1133,7 +1133,9 @@ border-top-style:solid;
 | 
				
			|||||||
.threaded-notices .notice-reply .controls {
 | 
					.threaded-notices .notice-reply .controls {
 | 
				
			||||||
    text-align: right;
 | 
					    text-align: right;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					.threaded-notices .notice-reply-comments {
 | 
				
			||||||
 | 
					    margin: 8px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
/* NOTICES */
 | 
					/* NOTICES */
 | 
				
			||||||
#notices_primary {
 | 
					#notices_primary {
 | 
				
			||||||
float:left;
 | 
					float:left;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user