Commit 954849fb by Kim Peace

tree shaking for js

parent b952b542
...@@ -101,7 +101,6 @@ ...@@ -101,7 +101,6 @@
PLATFORM = platform; PLATFORM = platform;
IS_MOBILE = isMobile; IS_MOBILE = isMobile;
IS_ONLINE = isOnline; IS_ONLINE = isOnline;
//CHAT_UI.showMakeRoomConfirmView();
CHAT_UI.showAddUserConfirmView(); CHAT_UI.showAddUserConfirmView();
}; };
</script> </script>
......
...@@ -168,7 +168,6 @@ ...@@ -168,7 +168,6 @@
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
<script src="./js/sockets/chat-websocket-refresh-group-list.js"></script> <script src="./js/sockets/chat-websocket-refresh-group-list.js"></script>
<script src="./js/sockets/chat-websocket-refresh-user-list-in-group.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -149,7 +149,6 @@ ...@@ -149,7 +149,6 @@
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
<script src="./js/sockets/chat-websocket-refresh-group-list.js"></script> <script src="./js/sockets/chat-websocket-refresh-group-list.js"></script>
<script src="./js/sockets/chat-websocket-refresh-user-list-in-group.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -92,7 +92,6 @@ ...@@ -92,7 +92,6 @@
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
<script src="./js/sockets/chat-websocket-refresh-group-list.js"></script> <script src="./js/sockets/chat-websocket-refresh-group-list.js"></script>
<script src="./js/sockets/chat-websocket-refresh-user-list-in-group.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -153,7 +153,6 @@ ...@@ -153,7 +153,6 @@
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
<script src="./js/sockets/chat-websocket-refresh-group-list.js"></script> <script src="./js/sockets/chat-websocket-refresh-group-list.js"></script>
<script src="./js/sockets/chat-websocket-refresh-user-list-in-group.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -143,7 +143,6 @@ ...@@ -143,7 +143,6 @@
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
<script src="./js/sockets/chat-websocket-refresh-group-list.js"></script> <script src="./js/sockets/chat-websocket-refresh-group-list.js"></script>
<script src="./js/sockets/chat-websocket-refresh-user-list-in-group.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -88,7 +88,6 @@ ...@@ -88,7 +88,6 @@
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
<script src="./js/sockets/chat-websocket-refresh-group-list.js"></script> <script src="./js/sockets/chat-websocket-refresh-group-list.js"></script>
<script src="./js/sockets/chat-websocket-refresh-user-list-in-group.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
...@@ -145,7 +145,6 @@ ...@@ -145,7 +145,6 @@
<script src="./js/sockets/chat-websocket.js"></script> <script src="./js/sockets/chat-websocket.js"></script>
<script src="./js/sockets/chat-websocket-message.js"></script> <script src="./js/sockets/chat-websocket-message.js"></script>
<script src="./js/sockets/chat-websocket-refresh-group-list.js"></script> <script src="./js/sockets/chat-websocket-refresh-group-list.js"></script>
<script src="./js/sockets/chat-websocket-refresh-user-list-in-group.js"></script>
<!-- View --> <!-- View -->
<script src="./js/chat.js"></script> <script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script> <script src="./js/chat-ui.js"></script>
......
jQuery("#homeButton").on("click", function () { jQuery("#homeButton").on("click", function () {
NativeBridgeDelegate.goHome(); NativeBridgeDelegate.goHome();
}); });
\ No newline at end of file
jQuery("#reloadButton").on("click", function () {
if (CHAT_UTIL.isIOS()) {
//TODO IOS処理追加必要。
} else if (CHAT_UTIL.isAndroid()) {
android.reload();
}
});
...@@ -9,99 +9,6 @@ $("#createChatRoom").on("click", function () { ...@@ -9,99 +9,6 @@ $("#createChatRoom").on("click", function () {
socket.emit("getGroupList", isInvite); socket.emit("getGroupList", isInvite);
}); });
// Room Delete
// チャットルーム削除ボタン処理
$("#roomDeleteButton").on("click", function (e) {
if ($(".deleteBox").is(":visible")) {
// チャットルーム削除アイコンが表示されている時、ブラインド処理を行う
$(".deleteBox")
.finish()
.show()
.fadeTo("slow", 0, function () {
$(this).hide();
});
// チャットリストについてクリックイベントを与える
$(".chat_list").off("click");
$(".chat_list:not(.active_chat)").on("click", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
let roomId = $(this).data("roomId");
let roomName = $(this).data("roomname");
socket.emit("joinRoom", roomId, roomName, function () {
$("#messages").html("");
$(".titleRoomName").text(roomName).data("roomName", roomName);
$("#pills-chat-tab").tab("show");
$("#message-search").attr(
"placeholder",
getLocalizedString("chat_search_placeholder")
);
});
});
let roomListTitle = getLocalizedString("roomListTitle");
$(".titleRoomName").text(roomListTitle);
$(".chat_list.active_chat").on("click", function (e) {
$("#pills-chat-tab").tab("show");
});
} else {
// チャットルーム削除アイコンが表示されていない場合、表示する
$(".deleteBox").finish().hide().fadeTo("slow", 1).show();
// #36129に対応
let deleteRoomTitle = getLocalizedString("deleteRoomTitle");
$(".titleRoomName").text(deleteRoomTitle);
// 重複処理を防ぐためにチャットリストのクリックイベントを消す
$(".chat_list").off("click");
// チャットルームの削除アイコンにクリックイベントを与える
$(".deleteBox").off("click");
$(".deleteBox").on("click", function (e) {
// #36174
let roomId = $(this).data("roomId");
let activeRoom = $(this).data("activeRoom");
$("#roomDeleteTitle").text(getLocalizedString("roomDeleteTitle"));
$("#roomDelete").text(getLocalizedString("roomDelete"));
$("#cancelTitle").text(getLocalizedString("cancelTitle"));
// #36128
$("#roomDeleteConfirm")
.appendTo("body")
.modal({
backdrop: "static",
keyboard: false,
})
.on("click", "#roomDelete", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
// 現在接続されているチャットルームを離れるとメッセージテップを初期化する
if (activeRoom) {
$("#messages").html("");
CHAT.saveRoomInfo("", "");
}
// チャットルームから退場する
socket.emit("exitRoom", roomId);
// #36129に対応
let roomListTitle = getLocalizedString("roomListTitle");
$(".titleRoomName").text(roomListTitle);
});
});
}
});
$("#room-search").on("input", function (event) {
if ($("#room-search").val().length > 0) {
// 検索結果が有る場合、結果を表示する
socket.emit("roomSearch", encodeURIComponent($("#room-search").val()));
} else {
if (IS_ONLINE == "true") {
NativeBridgeDelegate.updateRoomList();
CHAT_UI.refreshRoomList(ChatRoomType.DM);
CHAT_UI.dismissLoadingIndicator();
}
}
});
//メッセージ送信 //メッセージ送信
$("#messageInput").on("keypress", function (event) { $("#messageInput").on("keypress", function (event) {
if (event.which == 13) { if (event.which == 13) {
...@@ -183,119 +90,6 @@ $("#video-form").on("submit", function (e) { ...@@ -183,119 +90,6 @@ $("#video-form").on("submit", function (e) {
} }
}); });
$("#message-search").on("input", function (event) {
// チャットキーワードを入力するとページ内にある単語をハイライトする。(mark.js 使用)
if ($(this).val()) {
$(".message_content").unmark();
$(".message_content").mark($(this).val());
if ($("[data-markjs=true]").length > 0) {
// マーキングされている単語があった場合、最後の単語にスクロールを移動する。
CHAT_UI.scrollToLastMarkedUnseen($(this).val());
} else {
// マーキングされている単語がない場合、下段にスクロールする。
CHAT_UI.scrollToBottom();
}
} else {
// チャットキーワードが空欄になるとマーキングを解除し、下段にスクロールする。
$(".message_content").unmark();
CHAT_UI.scrollToBottom();
}
});
//次のマーキングされた単語にスクロールを移動する。
$("#pre-search").on("click", function (event) {
CHAT_UI.scrollToLastMarkedUnseen(jQuery("#message-search").val());
});
// Exit Room
$("#exitRoom").on("click", function (event) {
// 36174
$("#exitRoomTitle").text(getLocalizedString("exitRoomTitle"));
$("#exitRoomOk").text(getLocalizedString("yesTitle"));
$("#noExit").text(getLocalizedString("cancelTitle"));
$("#exitRoomConfirm")
.appendTo("body")
.modal({
backdrop: "static",
keyboard: false,
})
.on("click", "#exitRoomOk", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
// チャットルームから退場する
socket.emit("exitRoom");
$("#dismiss").click();
CHAT.saveRoomInfo("", "");
});
});
// Side Bar
$("#sidebarCollapse").on("click", function () {
// open sidebar
$("#sidebar").addClass("active");
// fade in the overlay
$(".overlay").addClass("active");
$(".collapse.in").toggleClass("in");
$("a[aria-expanded=true]").attr("aria-expanded", "false");
});
$("#dismiss, .overlay").on("click", function () {
// hide sidebar
$("#sidebar").removeClass("active");
// hide overlay if dismissable
$(".overlay:not(.undismissable)").removeClass("active");
});
//Invite User
//招待ボタンを押すとグループリストを持ってくる。(ボタンを動的に追加して微動作中)
$("#addUser").on("click", function (event) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
let isInvite = true;
CHAT.globalIsInvite = isInvite;
socket.emit("getGroupList", isInvite);
});
//グループ画面での検索
$("#groupListKeyword").on("input", function (event) {
// data-name値で当該キーワードが入っているグループのみを表示する。
if ($(this).val()) {
$('.group_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.group_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".group_list").show();
}
});
$("#userListKeyword").on("input", function (event) {
// data-name値で当該キーワードが入っているユーザーのみを表示する。
if ($(this).val()) {
$('.user_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.user_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".user_list").show();
}
});
$("#selectListKeyword").on("input", function (event) {
if ($(this).val()) {
$('.select_user_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.select_user_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".select_user_list").show();
}
});
$("#contactButton").on("click", function (event) {
CHAT_UI.refreshContactScreen();
});
$("#chatButton").on("click", function (event) {
CHAT_UI.refreshRoomList(ChatRoomType.DM);
});
$("#tabDM").on("click", function (e) { $("#tabDM").on("click", function (e) {
CHAT_UI.refreshRoomList(ChatRoomType.DM); CHAT_UI.refreshRoomList(ChatRoomType.DM);
}); });
......
...@@ -18,7 +18,7 @@ var beforeScroll; ...@@ -18,7 +18,7 @@ var beforeScroll;
CHAT.saveRoomInfo = function (roomID, roomName) { CHAT.saveRoomInfo = function (roomID, roomName) {
CHAT.globalLoginParameter.roomId = roomID; CHAT.globalLoginParameter.roomId = roomID;
CHAT.globalLoginParameter.roomName = roomName; CHAT.globalLoginParameter.roomName = roomName;
NativeBridgeDelegate.saveVisitRoomInfo(roomID, roomName) NativeBridgeDelegate.saveVisitRoomInfo(roomID, roomName);
}; };
// #36170 画像パスが存在しない場合はデフォルトの画像を返す // #36170 画像パスが存在しない場合はデフォルトの画像を返す
...@@ -570,7 +570,10 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -570,7 +570,10 @@ document.addEventListener("DOMContentLoaded", function () {
if (keyword.length == 1) { if (keyword.length == 1) {
return; return;
} }
const messages = NativeBridgeDataSource.searchMessages(keyword, checkedUserList.join(",")); const messages = NativeBridgeDataSource.searchMessages(
keyword,
checkedUserList.join(",")
);
var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE); var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE); var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
...@@ -716,7 +719,10 @@ CHAT.searchMessage = function (keyword, workVal) { ...@@ -716,7 +719,10 @@ CHAT.searchMessage = function (keyword, workVal) {
const selectedUser = $(".img_wrap.filter")[user]; const selectedUser = $(".img_wrap.filter")[user];
checkedUserList.push($(selectedUser).data("user-id")); checkedUserList.push($(selectedUser).data("user-id"));
}); });
var messages = NativeBridgeDataSource.searchMessages(keyword, checkedUserList.join(",")); var messages = NativeBridgeDataSource.searchMessages(
keyword,
checkedUserList.join(",")
);
var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE); var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE); var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
...@@ -765,15 +771,16 @@ CHAT.searchMessage = function (keyword, workVal) { ...@@ -765,15 +771,16 @@ CHAT.searchMessage = function (keyword, workVal) {
}; };
// 下スクロールでユーザーリストを非表示 // 下スクロールでユーザーリストを非表示
var startPos = 0,winScrollTop = 0; var startPos = 0;
$(window).on('scroll',function(){ var winScrollTop = 0;
winScrollTop = $(this).scrollTop(); $(window).on("scroll", function () {
if (winScrollTop >= startPos) { winScrollTop = $(this).scrollTop();
if(winScrollTop >= 200){ if (winScrollTop >= startPos) {
$('#chat_room .user_list').addClass('hide'); if (winScrollTop >= 200) {
} $("#chat_room .user_list").addClass("hide");
} else {
$('#chat_room .user_list').removeClass('hide');
} }
startPos = winScrollTop; } else {
$("#chat_room .user_list").removeClass("hide");
}
startPos = winScrollTop;
}); });
...@@ -43,7 +43,7 @@ CHAT_MAKE_ROOM.searchUser = function (keyword) { ...@@ -43,7 +43,7 @@ CHAT_MAKE_ROOM.searchUser = function (keyword) {
var userTemplate = getTemplate(TemplateURL.MAKE_ROOM_USER_LIST); var userTemplate = getTemplate(TemplateURL.MAKE_ROOM_USER_LIST);
let html = renderUser(userTemplate, userList); let html = renderUser(userTemplate, userList);
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").html(obj); overlayMessage.html(obj);
hasNoData = userList.length == 0; hasNoData = userList.length == 0;
} }
......
// ios用 // ios用
function callNativeApp(iosKey, jsonData) { function callNativeApp(iosKey, jsonData) {
console.log("callNativeApp called: "+iosKey); console.log("callNativeApp called: " + iosKey);
var result; var result;
try { try {
var key = iosKey; var key = iosKey;
...@@ -446,4 +446,4 @@ NativeBridgeDataSource.getHostRequestFlg = function () { ...@@ -446,4 +446,4 @@ NativeBridgeDataSource.getHostRequestFlg = function () {
} else { } else {
return android.getHostRequestFlg(); return android.getHostRequestFlg();
} }
}; };
\ No newline at end of file
...@@ -2,8 +2,6 @@ $.lang.en = { ...@@ -2,8 +2,6 @@ $.lang.en = {
"chat_placeholder":"Type message", "chat_placeholder":"Type message",
"chat_search_placeholder":" Search Message", "chat_search_placeholder":" Search Message",
"room_search_placeholder":" Search Room", "room_search_placeholder":" Search Room",
"participants":"Member List",
"exitRoom":"Exit ",
"roomListTitle":"Room List", "roomListTitle":"Room List",
"deleteRoomTitle":"Delete Room", "deleteRoomTitle":"Delete Room",
"inviteUsersButton":"invite", "inviteUsersButton":"invite",
...@@ -21,18 +19,12 @@ $.lang.en = { ...@@ -21,18 +19,12 @@ $.lang.en = {
"orderByTime":"OrderByTime", "orderByTime":"OrderByTime",
"orderByUnread":"OrderByUnread", "orderByUnread":"OrderByUnread",
"roomKeywordPlaceHolder":"Search", "roomKeywordPlaceHolder":"Search",
"okayLabel":"Okay!",
"completeLabel":"Complete.",
"thankLabel":"Thank you",
"startToWorkLabel":"Start to work",
"groupListKeyword":"Search",
"userSearch":"User Search", "userSearch":"User Search",
"groupSearch":"Group Search", "groupSearch":"Group Search",
"groupPageSubtitle":"Groups", "groupPageSubtitle":"Groups",
"noMessages":"No Messages", "noMessages":"No Messages",
"image":"Image", "image":"Image",
"chatKeyword":"Search", "chatKeyword":"Search",
"userListKeyword":"Search",
"newRoomName":"Please input Room Name", "newRoomName":"Please input Room Name",
"everyoneIsHere":"Everyone is in the chat.", "everyoneIsHere":"Everyone is in the chat.",
"people":"people", "people":"people",
......
...@@ -2,8 +2,6 @@ $.lang.ja = { ...@@ -2,8 +2,6 @@ $.lang.ja = {
"chat_placeholder":"メッセージを入力", "chat_placeholder":"メッセージを入力",
"chat_search_placeholder":" メッセージ検索", "chat_search_placeholder":" メッセージ検索",
"room_search_placeholder":" ルーム検索", "room_search_placeholder":" ルーム検索",
"participants":"メンバーリスト",
"exitRoom":"退出 ",
"roomListTitle":"チャット", "roomListTitle":"チャット",
"deleteRoomTitle":"ルーム削除", "deleteRoomTitle":"ルーム削除",
"inviteUsersButton":"招待", "inviteUsersButton":"招待",
...@@ -20,18 +18,12 @@ $.lang.ja = { ...@@ -20,18 +18,12 @@ $.lang.ja = {
"orderByTime":"新着順", "orderByTime":"新着順",
"orderByUnread":"未読優先", "orderByUnread":"未読優先",
"roomKeywordPlaceHolder":"検索", "roomKeywordPlaceHolder":"検索",
"okayLabel":"了解しました。",
"completeLabel":"完了しました。",
"thankLabel":"ありがとうございます。",
"startToWorkLabel":"作業開始します。",
"userSearch":"ユーザー検索", "userSearch":"ユーザー検索",
"groupSearch":"グループ検索", "groupSearch":"グループ検索",
"groupListKeyword":"検索",
"groupPageSubtitle":"グループ", "groupPageSubtitle":"グループ",
"noMessages":"メッセージがありません。", "noMessages":"メッセージがありません。",
"image":"画像", "image":"画像",
"chatKeyword":"検索", "chatKeyword":"検索",
"userListKeyword":"検索",
"invitedUser":"参加者", "invitedUser":"参加者",
"newRoomName":"ルーム名を入力してください", "newRoomName":"ルーム名を入力してください",
"everyoneIsHere":"招待可能なメンバーがいません。", "everyoneIsHere":"招待可能なメンバーがいません。",
......
...@@ -2,8 +2,6 @@ $.lang.ko = { ...@@ -2,8 +2,6 @@ $.lang.ko = {
"chat_placeholder":"메시지를 입력하세요.", "chat_placeholder":"메시지를 입력하세요.",
"chat_search_placeholder":" 메세지검색", "chat_search_placeholder":" 메세지검색",
"room_search_placeholder":" 채팅방 검색", "room_search_placeholder":" 채팅방 검색",
"participants":"멤버 리스트",
"exitRoom":"나가기 ",
"roomListTitle":"채팅 리스트", "roomListTitle":"채팅 리스트",
"deleteRoomTitle":"채팅방 삭제", "deleteRoomTitle":"채팅방 삭제",
"inviteUsersButton":"유저 초대", "inviteUsersButton":"유저 초대",
...@@ -21,18 +19,12 @@ $.lang.ko = { ...@@ -21,18 +19,12 @@ $.lang.ko = {
"orderByTime":"최신순", "orderByTime":"최신순",
"orderByUnread":"안 읽은 순", "orderByUnread":"안 읽은 순",
"roomKeywordPlaceHolder":"검색", "roomKeywordPlaceHolder":"검색",
"okayLabel":"알겠습니다.",
"completeLabel":"작업이 끝났습니다.",
"thankLabel":"감사합니다.",
"startToWorkLabel":"작업을 시작합니다.",
"groupListKeyword":"검색",
"userSearch":"유저 검색", "userSearch":"유저 검색",
"groupSearch":"그룹 검색", "groupSearch":"그룹 검색",
"groupPageSubtitle":"그룹", "groupPageSubtitle":"그룹",
"noMessages":"메시지가 없습니다.", "noMessages":"메시지가 없습니다.",
"image":"이미지", "image":"이미지",
"chatKeyword":"검색", "chatKeyword":"검색",
"userListKeyword":"검색",
"newRoomName":"방 이름을 입력해주세요.", "newRoomName":"방 이름을 입력해주세요.",
"everyoneIsHere":"초대가능한 유저가 없습니다.", "everyoneIsHere":"초대가능한 유저가 없습니다.",
"people":"명", "people":"명",
......
...@@ -3,7 +3,7 @@ var bindOnRefreshGroupList = function () { ...@@ -3,7 +3,7 @@ var bindOnRefreshGroupList = function () {
socket.on(SOCKET_KEY.REFRESH_GROUPLIST, function (groups, isInvite) { socket.on(SOCKET_KEY.REFRESH_GROUPLIST, function (groups, isInvite) {
const groupListElement = $("#group_list"); const groupListElement = $("#group_list");
groupListElement.html(""); groupListElement.html("");
const template = $("#group-template").html();
if (groups.length === 0) { if (groups.length === 0) {
groupListElement.append( groupListElement.append(
'<center class="text-secondary">' + '<center class="text-secondary">' +
...@@ -12,92 +12,10 @@ var bindOnRefreshGroupList = function () { ...@@ -12,92 +12,10 @@ var bindOnRefreshGroupList = function () {
); );
} }
addGroupNameAndNumberOfUsers(groups);
// Rotate
handleRotate();
updateTopBar(); updateTopBar();
// Set Title
updateTopBar(isInvite);
updateUserSelectionLength();
setupBackButton();
}); });
}; };
var addGroupNameAndNumberOfUsers = function (groups) { var updateTopBar = function () {
// グループ名と人数を表記する。 $("#newRoomName").hide();
groups.forEach(function (group) {
let html = Mustache.render(template, {
name: group.groupName,
info: group.memberCnt + getLocalizedString("people"),
});
// グループをクリックすると、該当グループのユーザーリストを読み込むようにイベントを与える
let obj = $(jQuery.parseHTML(html)).on("click", function () {
// loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
socket.emit("getUserListInGroup", group.groupId, isInvite);
$("#groupName").text(group.groupName);
});
groupListElement.append(obj);
});
};
var handleRotate = function () {
if (CHAT_UI.isLandscapeMode()) {
$(".group_list").addClass("col-6").removeClass("col-12");
}
};
var setupBackButton = function () {
const backButton = $("#backButton");
backButton.show();
backButton.off().on("click", function () {
// loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
if (isInvite) {
$("#pills-chat-tab").tab("show");
} else {
if (IS_ONLINE == "true") {
// todo: peacekim:: needs to check it only needs for android or not.
NativeBridgeDelegate.updateRoomList();
CHAT_UI.refreshRoomList(ChatRoomType.DM);
CHAT_UI.dismissLoadingIndicator();
}
}
});
};
var updateUserSelectionLength = function () {
const userSelectionLength = $("#userSelectionLength");
if (CHAT.globalSelectedUserList.length > 0) {
userSelectionLength.text(CHAT.globalSelectedUserList.length);
} else {
userSelectionLength.text("");
}
};
var updateTopBar = function (isInvite) {
// Set Title
let memberSelectTitle = getLocalizedString("groupSearch");
$("#pills-group-tab").tab("show");
const titleRoomName = $(".titleRoomName");
const userSelectionConfirmButton = $("#userSelectionConfirmBtn");
titleRoomName.text(memberSelectTitle);
if (isInvite) {
$("#newRoomName, .roomListIcon, .chatRoomIcon").hide();
} else {
$(".roomListIcon, .chatRoomIcon, #newRoomName").hide();
}
userSelectionConfirmButton.show();
userSelectionConfirmButton.off().on("click", function () {
CHAT_UI.setConfirmButtonEvent(isInvite);
});
}; };
var bindOnRefreshUserListInGroup = function () {
// Update User List(Invite)
// #36170
socket.on(
SOCKET_KEY.REFRESH_USERLIST_INGROUP,
function (users, groupId, isInvite) {
$("#user_list").html("");
// Set Title
updateTitle();
addUserList(users);
// Rotate
handleRotateOnUserListInGroup();
setupBackButtonOnUserListInGroup(isInvite);
setupUserSelectionConfirmButton(isInvite);
updateUIOnUserListInGroup();
}
);
};
var updateTitle = function () {
let memberSelectTitle = getLocalizedString("userSearch");
$(".titleRoomName").text(memberSelectTitle);
};
var addUserList = function (users) {
users.forEach(function (user) {
// loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
user.profileImagePath = CHAT.getProfileImgUrl(user.profileImagePath);
// クリックするとactive クラスを与え、チェック表示を出させる。
let obj = activateCheckUser(
user.loginId,
user.shopMemberId,
user.profileImagePath
);
let findObj = CHAT.globalSelectedUserList.find(function (selectedUser) {
return selectedUser.loginId == user.loginId;
});
if (findObj) {
$(obj).find(".userCheckBox").toggleClass("active");
}
$("#user_list").append(obj);
});
};
var renderUser = function (template, userID, profileImagePath, userName) {
return Mustache.render(template, {
id: userID,
profileImage: profileImagePath,
name: userName,
});
};
var activateCheckUser = function (loginID, shopMemberID, profileImagePath) {
const template = $("#user-template").html();
let html = renderUser(template, shopMemberID, profileImagePath, loginID);
return $(jQuery.parseHTML(html)).on("click", function () {
if ($(this).find(".userCheckBox.active").length > 0) {
// remove
CHAT.globalSelectedUserList = filterRemovedUser(loginID);
} else {
// add
addSelectedUser(loginID, shopMemberID, profileImagePath);
}
$(this).find(".userCheckBox").toggleClass("active");
updateUserSelectionLength();
});
};
var filterRemovedUser = function (userID) {
return CHAT.globalSelectedUserList.filter(function (element) {
return userID != element.loginId;
});
};
var addSelectedUser = function (loginID, shopMemberID, profileImagePath) {
CHAT.globalSelectedUserList.push({
loginId: loginID,
shopMemberId: shopMemberID,
profileImagePath: profileImagePath,
});
};
var handleRotateOnUserListInGroup = function () {
if (CHAT_UI.isLandscapeMode()) {
$(".user_list").addClass("col-6").removeClass("col-12");
$(".squareBoxContent span").addClass("landscape_span");
}
};
var setupBackButtonOnUserListInGroup = function (isInvite) {
const backButton = $("#backButton");
backButton.off().on("click", function () {
// loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
socket.emit("getGroupList", isInvite);
});
backButton.show();
};
var setupUserSelectionConfirmButton = function (isInvite) {
const userSelectionConfirmButton = $("#userSelectionConfirmBtn");
userSelectionConfirmButton.off().on("click", function () {
// loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
CHAT_UI.setConfirmButtonEvent(isInvite);
});
userSelectionConfirmButton.show();
};
var updateUIOnUserListInGroup = function () {
$(".roomListIcon, .chatRoomIcon").hide();
$(".userCheckBox").show();
$("#pills-user-tab").tab("show");
};
...@@ -135,8 +135,6 @@ var emitJoin = function () { ...@@ -135,8 +135,6 @@ var emitJoin = function () {
return; return;
} }
updateRoomName(params.roomName);
// loadingIndicatorを表示しない // loadingIndicatorを表示しない
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
}); });
...@@ -157,12 +155,13 @@ var errorHandlingForEmitJoin = function () { ...@@ -157,12 +155,13 @@ var errorHandlingForEmitJoin = function () {
.on("click", "#customAlertOk", function (e) {}); .on("click", "#customAlertOk", function (e) {});
}; };
var updateRoomName = function (roomName) { var bindOnRefreshUserListInGroup = function () {
const titleRoomName = $(".titleRoomName"); // Update User List(Invite)
if (roomName != undefined) { // #36170
titleRoomName.text(roomName).data("roomName", roomName); socket.on(
} else { SOCKET_KEY.REFRESH_USERLIST_INGROUP,
let roomListTitle = getLocalizedString("roomListTitle"); function (users, groupId, isInvite) {
titleRoomName.text(roomListTitle); console.log(SOCKET_KEY.REFRESH_USERLIST_INGROUP + "message received but it does nothing.");
} }
);
}; };
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