Commit 3bcc0e4d by Takatoshi Miura

Merge branch 'origin/#42598_search_logic' into 'release_sp3'

iosで2バイト文字で検索できないバグを修正

See merge request !97
parents e19ac453 a0daedff
...@@ -4,8 +4,6 @@ var ARCHIVE_UI = {}; ...@@ -4,8 +4,6 @@ var ARCHIVE_UI = {};
$(function() { $(function() {
// アーカイブ検索 // アーカイブ検索
$('#archive .search_form input[type="search"]').keyup(function(e) { $('#archive .search_form input[type="search"]').keyup(function(e) {
var keyword = $('#archive .search_form input[type="search"]').val(); var keyword = $('#archive .search_form input[type="search"]').val();
if (e.KeyCode == 13 || e.key == "Enter") { if (e.KeyCode == 13 || e.key == "Enter") {
if (keyword.length != 0 && keyword != '') { if (keyword.length != 0 && keyword != '') {
...@@ -26,6 +24,14 @@ $(function() { ...@@ -26,6 +24,14 @@ $(function() {
} }
// 検索結果を表示 // 検索結果を表示
}); });
// iOSキーボード変換検知用
$('#archive .search_form input[type="search"]').on('compositionend', function() {
if (CHAT_UTIL.isIOS()) {
var keyword = $('#archive .search_form input[type="search"]').val();
$('.overlay_src_msg').empty();
ARCHIVE_UI.refreshSearchScreen(keyword);
}
});
}); });
ARCHIVE_UI.refreshSearchScreen = function(keyword) { ARCHIVE_UI.refreshSearchScreen = function(keyword) {
......
// 名前空間
var CHAT_ADD_USER = {};
$(function() { $(function() {
// メンバー検索 // メンバー検索
$('#chat_add_user .search_form input[type="search"]').click(function(e){ $('#chat_add_user .search_form input[type="search"]').click(function(e){
...@@ -7,20 +10,38 @@ $(function() { ...@@ -7,20 +10,38 @@ $(function() {
}) })
$('#chat_add_user .search_form input[type="search"]').keyup(function(e){ $('#chat_add_user .search_form input[type="search"]').keyup(function(e){
var keyword = $('#chat_add_user .search_form input[type="search"]').val();
if (e.key == "Enter" || e.KeyCode == 13) { if (e.key == "Enter" || e.KeyCode == 13) {
if (keyword != '' && keyword.length != 0) {
$('#chat_add_user .search_form input[type="search"]').blur(); $('#chat_add_user .search_form input[type="search"]').blur();
return false; return false;
} }
} else if (keyword == '' || keyword.length < 2) {
$('.overlay_src_msg').empty();
return false;
}
CHAT_ADD_USER.searchUser(keyword);
if (e.key == "Enter" || e.KeyCode == 13) {
$('#chat_add_user .search_form input[type="search"]').blur();
return;
}
});
// iOSキーボード変換検知用
$('#chat_add_user .search_form input[type="search"]').on('compositionend', function() {
if (CHAT_UTIL.isIOS()) {
var keyword = $('#chat_add_user .search_form input[type="search"]').val();
CHAT_ADD_USER.searchUser(keyword);
}
});
});
// ユーザー検索
CHAT_ADD_USER.searchUser = function(keyword) {
var isAllGroup = $('#tabAllGroupOnAddUser').is(':checked'); var isAllGroup = $('#tabAllGroupOnAddUser').is(':checked');
$('.overlay_src_msg').empty(); $('.overlay_src_msg').empty();
//全グループ検索画面 //全グループ検索画面
if (isAllGroup) { if (isAllGroup) {
var keyword = $('#chat_add_user .search_form input[type="search"]').val();
if (keyword == '') {
return;
}
//グループデータ検索 //グループデータ検索
var groupList = CHAT_DB.getGroupByName(keyword); var groupList = CHAT_DB.getGroupByName(keyword);
var groupTemplate; var groupTemplate;
...@@ -67,10 +88,6 @@ $(function() { ...@@ -67,10 +88,6 @@ $(function() {
} }
  //連絡先画面   //連絡先画面
} else { } else {
var keyword = $('#chat_add_user .search_form input[type="search"]').val();
if (keyword == '') {
return;
}
var userList = CHAT_DB.getMyGroupShopMemberNotInRoomByName(keyword); var userList = CHAT_DB.getMyGroupShopMemberNotInRoomByName(keyword);
var userTemplate; var userTemplate;
$.get({ url: "./template/template_make_room_user_list.html", async: false } $.get({ url: "./template/template_make_room_user_list.html", async: false }
...@@ -97,5 +114,4 @@ $(function() { ...@@ -97,5 +114,4 @@ $(function() {
$('.overlay_src_msg').append(noResultMsg); $('.overlay_src_msg').append(noResultMsg);
} }
} }
}); };
});
...@@ -365,62 +365,20 @@ $(function() { ...@@ -365,62 +365,20 @@ $(function() {
$('.overlay_src_msg').empty(); $('.overlay_src_msg').empty();
return; return;
} }
$('.overlay_src_msg').empty(); CHAT.searchRoom(keyword, rooms);
rooms = CHAT_DB.getRoomList(chatRoomType.ALL, keyword);
let roomListTitle = getLocalizedString("room_search_placeholder");
$('#chatTitle').text(roomListTitle);
var template;
$.get({ url: "./template/template_room_list.html", async: false }
, function(text) {
template = text;
});
rooms.forEach(function(room) {
room.profileImagePath = ASSET_PATH + 'images/user-profile.png'
if (room.message) {
room.message = room.message.toString()
} else {
room.message = getLocalizedString("noMessages")
}
var displayMsg;
if (room.messageType == messageType.TEXT || room.messageType == messageType.SYSTEM) displayMsg = room.message;
if (room.messageType == messageType.IMAGE) displayMsg = getLocalizedString("image");
if (room.messageType == messageType.VIDEO) displayMsg = getLocalizedString("video");
var attendUserName = [];
room.attendUsers.forEach(function(user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
attendUserName.push(user.shopMemberName);
});
var thumbnailCount = room.attendUsers.length > 4 ? 4 : room.attendUsers.length;
if (room.chatRoomName == "") {
room.chatRoomName = attendUserName.join(', ');
}
let html = Mustache.render(template, {
thumbnailCount: thumbnailCount,
roomName: room.chatRoomName,
roomId: room.chatRoomId,
profileImage: room.profileImagePath,
lastMessage: displayMsg ,
time: room.insertDate ? CHAT_UTIL.formatDate(room.insertDate).createdAt : '',
unreadMsgCnt: room.unreadCount == 0 ? '' : room.unreadCount,
userCnt: room.attendUsers.length + 1,
attendUsers: room.attendUsers
});
// Click event
let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj);
});
if (rooms.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'});
noResultMsg.append(getLocalizedString("noResult"))
$('.overlay_src_msg').append(noResultMsg);
}
if (e.KeyCode == 13 || e.key == "Enter") { if (e.KeyCode == 13 || e.key == "Enter") {
$('#chat .search_form input[type="search"]').blur(); $('#chat .search_form input[type="search"]').blur();
return ; return ;
} }
}); });
// iOSキーボード変換検知用
$('#chat .search_form input[type="search"]').on('compositionend', function(){
if (CHAT_UTIL.isIOS()) {
var rooms;
var keyword = $('#chat .search_form input[type="search"]').val();
CHAT.searchRoom(keyword, rooms);
}
});
var beforeHeight; var beforeHeight;
var beforeScroll; var beforeScroll;
...@@ -448,6 +406,7 @@ $(function() { ...@@ -448,6 +406,7 @@ $(function() {
// チャットルーム // チャットルーム
// メッセージ検索イベント // メッセージ検索イベント
$('.chat_room_src_form input[type="search"]').keyup(function(e){ $('.chat_room_src_form input[type="search"]').keyup(function(e){
let workVal = "";
var keyword = $('.chat_room_src_form input[type="search"]').val(); var keyword = $('.chat_room_src_form input[type="search"]').val();
if (e.key == "Enter" || e.KeyCode == 13) { if (e.key == "Enter" || e.KeyCode == 13) {
if (keyword != '' && keyword.length != 0) { if (keyword != '' && keyword.length != 0) {
...@@ -458,13 +417,33 @@ $(function() { ...@@ -458,13 +417,33 @@ $(function() {
$('.overlay_src_msg').empty(); $('.overlay_src_msg').empty();
return; return;
} }
CHAT.searchMessage(keyword, workVal);
if (e.key == "Enter" || e.KeyCode == 13) {
$('#searchMessage').removeClass('onfocus');
$('.chat_room_src_form input[type="search"]').blur();
return;
}
});
// iOSキーボード変換検知用
$('.chat_room_src_form input[type="search"]').on('compositionend', function(){
if (CHAT_UTIL.isIOS()) {
let workVal = "";
var keyword = $('.chat_room_src_form input[type="search"]').val();
CHAT.searchMessage(keyword, workVal);
}
});
$(document).on('click', '.filter_img', function(event) {
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 == 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 }
...@@ -487,6 +466,8 @@ $(function() { ...@@ -487,6 +466,8 @@ $(function() {
template = systemMessageTemplate; template = systemMessageTemplate;
} }
let messageTime = CHAT_UTIL.formatDate(message.insertDate); let messageTime = CHAT_UTIL.formatDate(message.insertDate);
// ユーザの様式を読み込む
if (message.profileUrl) { if (message.profileUrl) {
message.profileUrl = CHAT.getProfileImgUrl(message.profileUrl) message.profileUrl = CHAT.getProfileImgUrl(message.profileUrl)
} else { } else {
...@@ -496,6 +477,7 @@ $(function() { ...@@ -496,6 +477,7 @@ $(function() {
var replacePath = message.message; var replacePath = message.message;
replacePath = replacePath.replaceAll('?fileName=', '?sid=' + CHAT.globalLoginParameter.sid + '&fileName='); replacePath = replacePath.replaceAll('?fileName=', '?sid=' + CHAT.globalLoginParameter.sid + '&fileName=');
message.message = replacePath; message.message = replacePath;
let html = Mustache.render(template, { let html = Mustache.render(template, {
text: message.message, text: message.message,
from: message.loginId, from: message.loginId,
...@@ -508,28 +490,70 @@ $(function() { ...@@ -508,28 +490,70 @@ $(function() {
workVal = html + workVal; workVal = html + workVal;
}) })
jQueryMessages.prepend(workVal); jQueryMessages.prepend(workVal);
if (messages.length == 0) { });
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); });
noResultMsg.append(getLocalizedString("noResult"))
jQueryMessages.append(noResultMsg); // チャットルーム検索
CHAT.searchRoom = function(keyword, rooms) {
$('.overlay_src_msg').empty();
rooms = CHAT_DB.getRoomList(chatRoomType.ALL, keyword);
let roomListTitle = getLocalizedString("room_search_placeholder");
$('#chatTitle').text(roomListTitle);
var template;
$.get({ url: "./template/template_room_list.html", async: false }
, function(text) {
template = text;
});
rooms.forEach(function(room) {
room.profileImagePath = ASSET_PATH + 'images/user-profile.png'
if (room.message) {
room.message = room.message.toString()
} else {
room.message = getLocalizedString("noMessages")
} }
if (e.key == "Enter" || e.KeyCode == 13) { var displayMsg;
$('#searchMessage').removeClass('onfocus'); if (room.messageType == messageType.TEXT || room.messageType == messageType.SYSTEM) displayMsg = room.message;
$('.chat_room_src_form input[type="search"]').blur(); if (room.messageType == messageType.IMAGE) displayMsg = getLocalizedString("image");
return; if (room.messageType == messageType.VIDEO) displayMsg = getLocalizedString("video");
var attendUserName = [];
room.attendUsers.forEach(function(user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
attendUserName.push(user.shopMemberName);
});
var thumbnailCount = room.attendUsers.length > 4 ? 4 : room.attendUsers.length;
if (room.chatRoomName == "") {
room.chatRoomName = attendUserName.join(', ');
} }
let html = Mustache.render(template, {
thumbnailCount: thumbnailCount,
roomName: room.chatRoomName,
roomId: room.chatRoomId,
profileImage: room.profileImagePath,
lastMessage: displayMsg ,
time: room.insertDate ? CHAT_UTIL.formatDate(room.insertDate).createdAt : '',
unreadMsgCnt: room.unreadCount == 0 ? '' : room.unreadCount,
userCnt: room.attendUsers.length + 1,
attendUsers: room.attendUsers
}); });
// Click event
let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj);
});
if (rooms.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'});
noResultMsg.append(getLocalizedString("noResult"))
$('.overlay_src_msg').append(noResultMsg);
}
};
$(document).on('click', '.filter_img', function(event) { // メッセージ検索
let workVal = ""; CHAT.searchMessage = function(keyword, 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 == 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 }
...@@ -552,8 +576,6 @@ $(function() { ...@@ -552,8 +576,6 @@ $(function() {
template = systemMessageTemplate; template = systemMessageTemplate;
} }
let messageTime = CHAT_UTIL.formatDate(message.insertDate); let messageTime = CHAT_UTIL.formatDate(message.insertDate);
// ユーザの様式を読み込む
if (message.profileUrl) { if (message.profileUrl) {
message.profileUrl = CHAT.getProfileImgUrl(message.profileUrl) message.profileUrl = CHAT.getProfileImgUrl(message.profileUrl)
} else { } else {
...@@ -563,7 +585,6 @@ $(function() { ...@@ -563,7 +585,6 @@ $(function() {
var replacePath = message.message; var replacePath = message.message;
replacePath = replacePath.replaceAll('?fileName=', '?sid=' + CHAT.globalLoginParameter.sid + '&fileName='); replacePath = replacePath.replaceAll('?fileName=', '?sid=' + CHAT.globalLoginParameter.sid + '&fileName=');
message.message = replacePath; message.message = replacePath;
let html = Mustache.render(template, { let html = Mustache.render(template, {
text: message.message, text: message.message,
from: message.loginId, from: message.loginId,
...@@ -576,5 +597,9 @@ $(function() { ...@@ -576,5 +597,9 @@ $(function() {
workVal = html + workVal; workVal = html + workVal;
}) })
jQueryMessages.prepend(workVal); jQueryMessages.prepend(workVal);
}); if (messages.length == 0) {
}); const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'});
noResultMsg.append(getLocalizedString("noResult"))
jQueryMessages.append(noResultMsg);
}
};
// 名前空間
var CHAT_MAKE_ROOM = {};
$(function() { $(function() {
// メンバー検索 // メンバー検索
$('#chatMakeRoom .search_form input[type="search"]').click(function(e) { $('#chatMakeRoom .search_form input[type="search"]').click(function(e) {
let contactListTitle = getLocalizedString("userSearch"); let contactListTitle = getLocalizedString("userSearch");
$('#makeRoomTitle').text(contactListTitle); $('#makeRoomTitle').text(contactListTitle);
}); });
$('#chatMakeRoom .search_form input[type="search"]').keyup(function(e) { $('#chatMakeRoom .search_form input[type="search"]').keyup(function(e) {
 //画面タイトル設定 //画面タイトル設定
var keyword = $('#chatMakeRoom .search_form input[type="search"]').val(); var keyword = $('#chatMakeRoom .search_form input[type="search"]').val();
if (e.KeyCode == 13 || e.key == "Enter") { if (e.KeyCode == 13 || e.key == "Enter") {
if (keyword != '' && keyword.length != 0) { if (keyword != '' && keyword.length != 0) {
...@@ -18,7 +19,23 @@ $(function() { ...@@ -18,7 +19,23 @@ $(function() {
$('.overlay_src_msg').empty(); $('.overlay_src_msg').empty();
return false; return false;
} }
CHAT_MAKE_ROOM.searchUser(keyword);
if (e.key == "Enter" || e.KeyCode == 13) {
$('#chatMakeRoom .search_form input[type="search"]').blur();
return;
}
});
// iOSキーボード変換検知用
$('#chatMakeRoom .search_form input[type="search"]').on('compositionend', function() {
if (CHAT_UTIL.isIOS()) {
var keyword = $('#chatMakeRoom .search_form input[type="search"]').val();
CHAT_MAKE_ROOM.searchUser(keyword);
}
});
});
// メンバー検索
CHAT_MAKE_ROOM.searchUser = function(keyword) {
var isAllGroup = $('#tabAllGroupOnMakeRoom').is(':checked'); var isAllGroup = $('#tabAllGroupOnMakeRoom').is(':checked');
$('.overlay_src_msg').empty(); $('.overlay_src_msg').empty();
...@@ -95,11 +112,5 @@ $(function() { ...@@ -95,11 +112,5 @@ $(function() {
noResultMsg.append(getLocalizedString("noResult")) noResultMsg.append(getLocalizedString("noResult"))
$('.overlay_src_msg').append(noResultMsg); $('.overlay_src_msg').append(noResultMsg);
} }
} }
if (e.key == "Enter" || e.KeyCode == 13) { }
$('#chatMakeRoom .search_form input[type="search"]').blur();
return;
}
});
});
// 名前空間
var CONTACT = {};
$(function () { $(function () {
// メンバー検索 // メンバー検索
$('#contact .search_form input[type="search"]').keyup(function(e) { $('#contact .search_form input[type="search"]').keyup(function(e) {
var groupList;
var keyword = $('#contact .search_form input[type="search"]').val(); var keyword = $('#contact .search_form input[type="search"]').val();
if (e.key == "Enter" || e.KeyCode == 13) { if (e.key == "Enter" || e.KeyCode == 13) {
if (keyword != '' && keyword.length != 0) { if (keyword != '' && keyword.length != 0) {
...@@ -12,8 +14,27 @@ $(function () { ...@@ -12,8 +14,27 @@ $(function () {
$('.overlay_src_msg').empty(); $('.overlay_src_msg').empty();
return; return;
} }
CONTACT.searchUser(keyword);
if (e.key == "Enter" || e.KeyCode == 13) {
$('#contact .search_form input[type="search"]').blur();
return;
}
});
// iOSキーボード変換検知用
$('#contact .search_form input[type="search"]').on('compositionend', function() {
if (CHAT_UTIL.isIOS()) {
var keyword = $('#contact .search_form input[type="search"]').val();
CONTACT.searchUser(keyword);
}
});
});
// ユーザー検索
CONTACT.searchUser = function(keyword) {
var groupList;
$('.overlay_src_msg').empty(); $('.overlay_src_msg').empty();
var isAllGroup = $('#tabAllGroup').is(':checked'); var isAllGroup = $('#tabAllGroup').is(':checked');
//全グループ検索画面 //全グループ検索画面
if (isAllGroup) { if (isAllGroup) {
//グループデータ検索 //グループデータ検索
...@@ -76,9 +97,4 @@ $(function () { ...@@ -76,9 +97,4 @@ $(function () {
$('.overlay_src_msg').append(noResultMsg); $('.overlay_src_msg').append(noResultMsg);
} }
} }
if (e.key == "Enter" || e.KeyCode == 13) { };
$('#contact .search_form input[type="search"]').blur();
return;
}
});
});
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