Skip to content

Commit

Permalink
Add @ UI
Browse files Browse the repository at this point in the history
  • Loading branch information
hackjie committed Jul 23, 2018
1 parent 469c54a commit 6fb1164
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 20 additions & 1 deletion resources/views/topics/_reply_box.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
</div>
<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-share"></i>回复</button>
</form>

{{-- 得到已经评论的所有人隐藏 --}}
@foreach ($replies as $reply)
<input type="text" hidden="hidden" value="{{ $reply->user->name }}" id="{{ $reply->user_id }}" name="replies">
@endforeach
{{-- 得到已经关注的所有人隐藏 --}}
@foreach (Auth::user()->followings as $following)
<input type="text" hidden="hidden" value="{{ $following->name }}" id="{{ $following->id }}" name="replies">
@endforeach
</div>
<hr>

Expand All @@ -20,9 +29,19 @@
<script type="text/javascript" src="{{ asset('js/jquery.atwho.js') }}"></script>

<script>
// 获取已有评论的所有人名
var nameValues = [];
$("input[name='replies']").each(function () {
var name = $(this).val();
if ($.inArray(name, nameValues) == -1) {
nameValues.push(name);
}
});
$('#inputor').atwho({
at: "@",
data:['Peter', 'Tom', 'Anne']
data: nameValues,
limit: 100
});
</script>
@stop
6 changes: 5 additions & 1 deletion resources/views/topics/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@
{{-- 用户回复列表 --}}
<div class="panel panel-default topic-reply">
<div class="panel-body">
@includeWhen(Auth::check(), 'topics._reply_box', ['topic' => $topic])
@include('topics._reply_list', ['replies' => $topic->replies()->with('user', 'topic')->get()])
{{-- @includeWhen(Auth::check(), 'topics._reply_box', ['topic' => $topic]) --}}

{{-- 添加@功能 --}}
@includeWhen(Auth::check(), 'topics._reply_box',
['topic' => $topic, 'replies' => $topic->replies()->with('user', 'topic')->get()])
</div>
</div>

Expand Down

0 comments on commit 6fb1164

Please sign in to comment.