Commit 7f83361b by Lee Munkyeong

メッセージ検索

parent 51874fc0
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
<!-- ナビメニュー --> <!-- ナビメニュー -->
<nav> <nav>
<div class="chat_room_src_form none"> <div class="chat_room_src_form none">
<form class="d-flex flex-row h-100 align-items-center"> <div class="d-flex flex-row h-100 align-items-center">
<input type="search" name="search" placeholder="ユーザー検索"> <input type="search" name="search" placeholder="ユーザー検索">
<span class="src_icon"></span> <span class="src_icon"></span>
<a href="#" class="cancel">キャンセル</a> <a href="#" class="cancel">キャンセル</a>
</form> </div>
</div> </div>
<div class="row nav_item_wrap h-100 align-items-center"> <div class="row nav_item_wrap h-100 align-items-center">
<div class="col-4 pr-0"> <div class="col-4 pr-0">
......
...@@ -414,20 +414,23 @@ $(function() { ...@@ -414,20 +414,23 @@ $(function() {
// チャットルーム // チャットルーム
// メッセージ検索イベント // メッセージ検索イベント
$('.chat_room_src_form input[type="search"]').keyup(function(e){ $('.chat_room_src_form input[type="search"]').keyup(function(e){
var keyword = $('.chat_room_src_form input[type="search"]').val();
if (e.key == "Enter" || e.KeyCode == 13) { if (e.key == "Enter" || e.KeyCode == 13) {
$('.chat_room_src_form input[type="search"]').blur(); if (keyword != '' && keyword.length != 0) {
return ; $('.chat_room_src_form input[type="search"]').blur();
return;
}
} else if (keyword == '' || keyword.length < 2) {
$('.overlay_src_msg').empty();
return;
} }
let workVal = ""; let workVal = "";
var keyword = $('.chat_room_src_form input[type="search"]').val();
$('.overlay_src_msg').empty(); $('.overlay_src_msg').empty();
var checkedUserList = []; var checkedUserList = [];
$('.img_wrap.filter').each(function(user) { $('.img_wrap.filter').each(function(user) {
var selectedUser = $('.img_wrap.filter')[user]; var selectedUser = $('.img_wrap.filter')[user];
checkedUserList.push($(selectedUser).data('user-id')); checkedUserList.push($(selectedUser).data('user-id'));
}) })
if (keyword.length < 2) { return; }
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(',')); var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(','));
var userMessageTemplate; var userMessageTemplate;
$.get({ url: "./template/template_user_message.html", async: false } $.get({ url: "./template/template_user_message.html", async: false }
...@@ -476,6 +479,10 @@ $(function() { ...@@ -476,6 +479,10 @@ $(function() {
noResultMsg.append(getLocalizedString("noResult")) noResultMsg.append(getLocalizedString("noResult"))
jQueryMessages.append(noResultMsg); jQueryMessages.append(noResultMsg);
} }
if (e.key == "Enter" || e.KeyCode == 13) {
$('#contact .search_form input[type="search"]').blur();
return;
}
}); });
$('.filter_img').on('click', function() { $('.filter_img').on('click', function() {
...@@ -487,7 +494,7 @@ $(function() { ...@@ -487,7 +494,7 @@ $(function() {
var selectedUser = $('.img_wrap.filter')[user]; var selectedUser = $('.img_wrap.filter')[user];
checkedUserList.push($(selectedUser).data('user-id')); checkedUserList.push($(selectedUser).data('user-id'));
}) })
if (keyword.length < 2) { return; } if (keyword.length == 1) { return; }
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(',')); var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(','));
var userMessageTemplate; var userMessageTemplate;
$.get({ url: "./template/template_user_message.html", async: false } $.get({ url: "./template/template_user_message.html", async: false }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment