]> git.mxchange.org Git - friendica.git/commitdiff
Collapsing is back for threaded comments.
authorDomovoy <domovoy@errlock.org>
Sun, 29 Jul 2012 15:13:21 +0000 (17:13 +0200)
committerDomovoy <domovoy@errlock.org>
Sun, 29 Jul 2012 15:13:21 +0000 (17:13 +0200)
Comment box is displayed at the end of the thread.
Comments on comments are all collapsed

include/conversation.php
view/theme/darkzero/style.css
view/theme/duepuntozero/style.css
view/wall_thread.tpl

index 020908b1e538d9217708b3167eeda1da27ccf0f1..5743a2929e20a5e3140b2ac46e1a7d36cac75ded 100644 (file)
@@ -303,15 +303,13 @@ function localize_item(&$item){
  * Recursively prepare a thread for HTML
  */
 
-function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner) {
+function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all=false) {
        $result = array();
 
        $wall_template = 'wall_thread.tpl';
        $wallwall_template = 'wallwall_thread.tpl';
        $items_seen = 0;
        $nb_items = count($items);
-       $lastcollapsed = false;
-       $firstcollapsed = false;
        
        foreach($items as $item) {
                // prevent private email reply to public conversation from leaking.
@@ -338,6 +336,8 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
                $thumb = $item['thumb'];
                $indent = '';
                $osparkle = '';
+               $lastcollapsed = false;
+               $firstcollapsed = false;
 
                $toplevelpost = (($item['id'] == $item['parent']) ? true : false);
                $item_writeable = (($item['writable'] || $item['self']) ? true : false);
@@ -463,11 +463,15 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
                } else {
                        $indent = 'comment';
                        // Collapse comments
-                       if($nb_items > 2) {
-                               if(!$firstcollapsed && ($items_seen <= ($nb_items - 2))) {
+                       if(($nb_items > 2) || $collapse_all) {
+                               if($items_seen == 1) {
                                        $firstcollapsed = true;
                                }
-                               else if($items_seen == ($nb_items - 1)) {
+                               if($collapse_all) {
+                                       if($items_seen == $nb_items)
+                                               $lastcollapsed = true;
+                               }
+                               else if($items_seen == ($nb_items - 2)) {
                                        $lastcollapsed = true;
                                }
                        }
@@ -524,8 +528,8 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
 
                $tmp_item = array(
                        // collapse comments in template. I don't like this much...
-                       'comment_firstcollapsed' => $comment_firstcollapsed,
-                       'comment_lastcollapsed' => $comment_lastcollapsed,
+                       'comment_firstcollapsed' => $firstcollapsed,
+                       'comment_lastcollapsed' => $lastcollapsed,
                        // template to use to render item (wall, walltowall, search)
                        'template' => $template,
                        
@@ -571,10 +575,16 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
                call_hooks('display_item', $arr);
 
                $item_result = $arr['output'];
+               if($firstcollapsed) {
+                       $item_result['num_comments'] = sprintf( tt('%d comment','%d comments',$nb_items),$nb_items );
+                       $item_result['hide_text'] = t('show more');
+               }
 
                $item_result['children'] = array();
                if(count($item['children'])) {
-                       $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner);
+                       if(!$toplevelpost && !$collapse_all)
+                               $collapse_all = true;
+                       $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all);
                }
                $item_result['private'] = $item['private'];
                $result[] = $item_result;
@@ -799,7 +809,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa
                                }
 
                                $threads = prepare_threads_body($a, $threads, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $previewing);
-                       } else {
+                       }
+                       else {
 
 
                                // Figure out how many comments each parent has
index 5cd7eed659d3166b9d46b639cd690cf782692882..55644e462d90e52ed64aba201f62e08c02217054 100644 (file)
@@ -28,7 +28,7 @@ background: #444;
 
 }
 .wall-item-tools {     background-color: #444444;   background-image: none;}
-.comment-wwedit-wrapper{ background-color: #444444; }
+.comment-wwedit-wrapper{ background-color: #333333; }
 .comment-edit-preview{ color: #000000; }
 .wall-item-content-wrapper.comment { background-color: #444444; border: 0px;}
 .photo-top-album-name{ background-color: #333333; }
index e17f8319bc7923d9d019e1c2cb99f333460f1491..9a8cffa2bed2756eef04c7399d796535f6a4b0b8 100644 (file)
@@ -1181,7 +1181,6 @@ input#dfrn-url {
 .comment-wwedit-wrapper {
        margin-top: 15px;
        background: #f3f3f3;
-       margin-left: 50px;
 }
 
 .comment-edit-photo {
index aac5dbe2b235e0bdd628ccb0256a3b06455947df..96a98ca82aca3319163a9857146260e740a43b80 100644 (file)
@@ -1,12 +1,10 @@
+{{if $item.comment_firstcollapsed}}
+       <div class="hide-comments-outer">
+       <span id="hide-comments-total-$item.id" class="hide-comments-total">$item.num_comments</span> <span id="hide-comments-$item.id" class="hide-comments fakelink" onclick="showHideComments($item.id);">$item.hide_text</span>
+       </div>
+       <div id="collapsed-comments-$item.id" class="collapsed-comments" style="display: none;">
+{{endif}}
 <div id="tread-wrapper-$item.id" class="tread-wrapper">
-               {{if $item.comment_firstcollapsed}}
-                       <div class="hide-comments-outer">
-                       <span id="hide-comments-total-$item.id" class="hide-comments-total">$item.num_comments</span> <span id="hide-comments-$item.id" class="hide-comments fakelink" onclick="showHideComments($item.id);">$item.hide_text</span>
-                       </div>
-                       <div id="collapsed-comments-$item.id" class="collapsed-comments" style="display: none;">
-               {{endif}}
-               {{if $item.comment_lastcollapsed}}</div>{{endif}}
-
 <a name="$item.id" ></a>
 <div class="wall-item-outside-wrapper $item.indent$item.previewing" id="wall-item-outside-wrapper-$item.id" >
        <div class="wall-item-content-wrapper $item.indent" id="wall-item-content-wrapper-$item.id" >
@@ -76,9 +74,6 @@
                                {{ if $item.drop.dropping }}<input type="checkbox" onclick="checkboxhighlight(this);" title="$item.drop.select" class="item-select" name="itemselected[]" value="$item.id" />{{ endif }}
                        <div class="wall-item-delete-end"></div>
                </div>
-               <div class="wall-item-comment-wrapper" >
-                       $item.comment
-               </div>
        </div>
        <div class="wall-item-wrapper-end"></div>
        <div class="wall-item-like $item.indent" id="wall-item-like-$item.id">$item.like</div>
@@ -88,4 +83,9 @@
 {{ for $item.children as $item }}
        {{ inc $item.template }}{{ endinc }}
 {{ endfor }}
+<div class="wall-item-comment-wrapper" >
+       $item.comment
+</div>
+
 </div>
+{{if $item.comment_lastcollapsed}}</div>{{endif}}