Commit 3dc17ed63093d5156527f01baf115d91fdd3d81d
1 parent
26ca15df
hidden comment in card
Showing
5 changed files
with
49 additions
and
4 deletions
Show diff stats
resources/artbox_comment.css
| @@ -316,4 +316,7 @@ | @@ -316,4 +316,7 @@ | ||
| 316 | .comments-start ul.pagination li.active a { | 316 | .comments-start ul.pagination li.active a { |
| 317 | color: #333; | 317 | color: #333; |
| 318 | background-color: inherit; | 318 | background-color: inherit; |
| 319 | +} | ||
| 320 | +.artbox-comment-list .show_more_block{ | ||
| 321 | + | ||
| 319 | } | 322 | } |
| 320 | \ No newline at end of file | 323 | \ No newline at end of file |
resources/artbox_comment.js
| @@ -321,4 +321,17 @@ | @@ -321,4 +321,17 @@ | ||
| 321 | form.trigger('reset'); | 321 | form.trigger('reset'); |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | + | ||
| 325 | + | ||
| 324 | })(window.jQuery); | 326 | })(window.jQuery); |
| 327 | + | ||
| 328 | +$(document).on('click', '#show_more_link', function(){ | ||
| 329 | + $("#show_more").show(); | ||
| 330 | + $("#show_more_link").hide(); | ||
| 331 | +}); | ||
| 332 | + | ||
| 333 | +$(document).on('click', '#hide_more_link', function(){ | ||
| 334 | + $("#show_more").hide(); | ||
| 335 | + $("#show_more_link").show(); | ||
| 336 | +}); | ||
| 337 | + |
views/artbox_comment_item.php
| @@ -10,8 +10,11 @@ | @@ -10,8 +10,11 @@ | ||
| 10 | * @var int $index | 10 | * @var int $index |
| 11 | * @var ListView $widget | 11 | * @var ListView $widget |
| 12 | * @var string $display_name | 12 | * @var string $display_name |
| 13 | + * @var array $more | ||
| 13 | */ | 14 | */ |
| 15 | + | ||
| 14 | ?> | 16 | ?> |
| 17 | + | ||
| 15 | <div class="comments-wr"> | 18 | <div class="comments-wr"> |
| 16 | <div class="artbox_item_info"> | 19 | <div class="artbox_item_info"> |
| 17 | <div class="user-ico"> | 20 | <div class="user-ico"> |
| @@ -166,3 +169,4 @@ | @@ -166,3 +169,4 @@ | ||
| 166 | ?> | 169 | ?> |
| 167 | </div> | 170 | </div> |
| 168 | 171 | ||
| 172 | + |
views/artbox_comment_list.php
| @@ -32,8 +32,24 @@ | @@ -32,8 +32,24 @@ | ||
| 32 | 'viewParams' => [ | 32 | 'viewParams' => [ |
| 33 | 'display_name' => $display_name, | 33 | 'display_name' => $display_name, |
| 34 | 'reply' => $reply, | 34 | 'reply' => $reply, |
| 35 | - 'delete' => $delete | ||
| 36 | - ] | 35 | + 'delete' => $delete, |
| 36 | + 'more' => $more, | ||
| 37 | + 'last' => $comments->count, | ||
| 38 | + ], | ||
| 39 | + 'beforeItem' => function ($model, $key, $index, $widget) use ($more, $comments) { | ||
| 40 | + if ($more['key'] == $index and $more['show_'] ){ | ||
| 41 | + | ||
| 42 | + return "<a id='show_more_link' style='cursor:pointer'>Показать еще</a> | ||
| 43 | + <div id='show_more' style='display: none'>"; | ||
| 44 | + } | ||
| 45 | + }, | ||
| 46 | + 'afterItem' => function ($model, $key, $index, $widget) use ($more, $comments) { | ||
| 47 | + if ($index == ($comments->count-1) and $more['show_']){ | ||
| 48 | + | ||
| 49 | + return "<a id='hide_more_link' style='cursor:pointer'>Скрыть комментарии</a></div>"; | ||
| 50 | + } | ||
| 51 | +} | ||
| 52 | + | ||
| 37 | 53 | ||
| 38 | ]); | 54 | ]); |
| 39 | Pjax::end(); | 55 | Pjax::end(); |
widgets/CommentWidget.php
| @@ -153,7 +153,14 @@ | @@ -153,7 +153,14 @@ | ||
| 153 | * @var string entity id attribute | 153 | * @var string entity id attribute |
| 154 | */ | 154 | */ |
| 155 | public $entityIdAttribute; | 155 | public $entityIdAttribute; |
| 156 | - | 156 | + |
| 157 | + /** | ||
| 158 | + * show more | ||
| 159 | + */ | ||
| 160 | + public $more = [ | ||
| 161 | + "show_" => false, | ||
| 162 | + 'key' => -1, | ||
| 163 | + ]; | ||
| 157 | /** | 164 | /** |
| 158 | * Info to be passed to Comment Model | 165 | * Info to be passed to Comment Model |
| 159 | * | 166 | * |
| @@ -415,7 +422,9 @@ | @@ -415,7 +422,9 @@ | ||
| 415 | 'item_view' => $this->itemView, | 422 | 'item_view' => $this->itemView, |
| 416 | 'display_name' => $this->display_name, | 423 | 'display_name' => $this->display_name, |
| 417 | 'reply' => $this->reply, | 424 | 'reply' => $this->reply, |
| 418 | - 'delete' => $this->delete | 425 | + 'delete' => $this->delete, |
| 426 | + 'more' => $this->more, | ||
| 427 | + | ||
| 419 | 428 | ||
| 420 | ] | 429 | ] |
| 421 | ), | 430 | ), |