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
resources/artbox_comment.js
| ... | ... | @@ -321,4 +321,17 @@ |
| 321 | 321 | form.trigger('reset'); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | + | |
| 325 | + | |
| 324 | 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 | 10 | * @var int $index |
| 11 | 11 | * @var ListView $widget |
| 12 | 12 | * @var string $display_name |
| 13 | + * @var array $more | |
| 13 | 14 | */ |
| 15 | + | |
| 14 | 16 | ?> |
| 17 | + | |
| 15 | 18 | <div class="comments-wr"> |
| 16 | 19 | <div class="artbox_item_info"> |
| 17 | 20 | <div class="user-ico"> |
| ... | ... | @@ -166,3 +169,4 @@ |
| 166 | 169 | ?> |
| 167 | 170 | </div> |
| 168 | 171 | |
| 172 | + | ... | ... |
views/artbox_comment_list.php
| ... | ... | @@ -32,8 +32,24 @@ |
| 32 | 32 | 'viewParams' => [ |
| 33 | 33 | 'display_name' => $display_name, |
| 34 | 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 | 55 | Pjax::end(); | ... | ... |
widgets/CommentWidget.php
| ... | ... | @@ -153,7 +153,14 @@ |
| 153 | 153 | * @var string entity id attribute |
| 154 | 154 | */ |
| 155 | 155 | public $entityIdAttribute; |
| 156 | - | |
| 156 | + | |
| 157 | + /** | |
| 158 | + * show more | |
| 159 | + */ | |
| 160 | + public $more = [ | |
| 161 | + "show_" => false, | |
| 162 | + 'key' => -1, | |
| 163 | + ]; | |
| 157 | 164 | /** |
| 158 | 165 | * Info to be passed to Comment Model |
| 159 | 166 | * |
| ... | ... | @@ -415,7 +422,9 @@ |
| 415 | 422 | 'item_view' => $this->itemView, |
| 416 | 423 | 'display_name' => $this->display_name, |
| 417 | 424 | 'reply' => $this->reply, |
| 418 | - 'delete' => $this->delete | |
| 425 | + 'delete' => $this->delete, | |
| 426 | + 'more' => $this->more, | |
| 427 | + | |
| 419 | 428 | |
| 420 | 429 | ] |
| 421 | 430 | ), | ... | ... |