]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Collapse long threaded displays with a link to the convo view (todo: turn it into...
authorBrion Vibber <brion@pobox.com>
Tue, 1 Mar 2011 01:13:54 +0000 (17:13 -0800)
committerBrion Vibber <brion@pobox.com>
Tue, 1 Mar 2011 01:13:54 +0000 (17:13 -0800)
lib/threadednoticelist.php
theme/base/css/display.css

index c1c4b4f36a3513b4ffa0361bf685e76e4c4fcaf4..42b85bd132fc98438ead469e9a0ddff677f86020 100644 (file)
@@ -145,6 +145,8 @@ class ThreadedNoticeList extends NoticeList
 
 class ThreadedNoticeListItem extends NoticeListItem
 {
+    const INITIAL_ITEMS = 3;
+
     /**
      * finish the notice
      *
@@ -155,24 +157,32 @@ class ThreadedNoticeListItem extends NoticeListItem
 
     function showEnd()
     {
-        $notice = Notice::conversationStream($this->notice->conversation);
+        $notice = Notice::conversationStream($this->notice->conversation, 0, self::INITIAL_ITEMS + 2);
         $notices = array();
+        $cnt = 0;
+        $moreCutoff = null;
         while ($notice->fetch()) {
             if ($notice->id == $this->notice->id) {
                 // Skip!
                 continue;
             }
+            $cnt++;
+            if ($cnt > self::INITIAL_ITEMS) {
+                // boo-yah
+                $moreCutoff = clone($notice);
+                break;
+            }
             $notices[] = clone($notice); // *grumble* inefficient as hell
         }
 
         if ($notices) {
             $this->out->elementStart('ul', 'notices threaded-notices xoxo');
-            foreach (array_reverse($notices) as $notice) {
-                $item = new ThreadedNoticeListSubItem($notice, $this->out);
+            if ($moreCutoff) {
+                $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out);
                 $item->show();
             }
-            if (common_current_user()) {
-                $item = new ThreadedNoticeListReplyItem($this->notice, $this->out);
+            foreach (array_reverse($notices) as $notice) {
+                $item = new ThreadedNoticeListSubItem($notice, $this->out);
                 $item->show();
             }
             $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))) {
             $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()
     {
-        $replyToId = $this->notice->id;
-        $id = 'replyto-notice-' + $replyToId;
-        $url = common_local_url('newnotice');
+        $id = $this->notice->conversation;
+        $url = common_local_url('conversation', array('id' => $id)) . '#notice-' . $this->notice->id;
+
+        $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?
         /*
index dabf929a72d3f633781ef49aadf5dd6578d90967..98345a07261b8e7ee7b9d12efb2c3865174e6532 100644 (file)
@@ -1133,7 +1133,9 @@ border-top-style:solid;
 .threaded-notices .notice-reply .controls {
     text-align: right;
 }
-
+.threaded-notices .notice-reply-comments {
+    margin: 8px;
+}
 /* NOTICES */
 #notices_primary {
 float:left;