Commit 954849fb by Kim Peace

tree shaking for js

parent b952b542
......@@ -101,7 +101,6 @@
PLATFORM = platform;
IS_MOBILE = isMobile;
IS_ONLINE = isOnline;
//CHAT_UI.showMakeRoomConfirmView();
CHAT_UI.showAddUserConfirmView();
};
</script>
......
......@@ -168,7 +168,6 @@
<script src="./js/sockets/chat-websocket.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-user-list-in-group.js"></script>
<!-- View -->
<script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script>
......
......@@ -149,7 +149,6 @@
<script src="./js/sockets/chat-websocket.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-user-list-in-group.js"></script>
<!-- View -->
<script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script>
......
......@@ -92,7 +92,6 @@
<script src="./js/sockets/chat-websocket.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-user-list-in-group.js"></script>
<!-- View -->
<script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script>
......
......@@ -153,7 +153,6 @@
<script src="./js/sockets/chat-websocket.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-user-list-in-group.js"></script>
<!-- View -->
<script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script>
......
......@@ -143,7 +143,6 @@
<script src="./js/sockets/chat-websocket.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-user-list-in-group.js"></script>
<!-- View -->
<script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script>
......
......@@ -88,7 +88,6 @@
<script src="./js/sockets/chat-websocket.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-user-list-in-group.js"></script>
<!-- View -->
<script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script>
......
......@@ -145,7 +145,6 @@
<script src="./js/sockets/chat-websocket.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-user-list-in-group.js"></script>
<!-- View -->
<script src="./js/chat.js"></script>
<script src="./js/chat-ui.js"></script>
......
jQuery("#homeButton").on("click", function () {
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 () {
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) {
if (event.which == 13) {
......@@ -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) {
CHAT_UI.refreshRoomList(ChatRoomType.DM);
});
......
......@@ -18,7 +18,7 @@ var beforeScroll;
CHAT.saveRoomInfo = function (roomID, roomName) {
CHAT.globalLoginParameter.roomId = roomID;
CHAT.globalLoginParameter.roomName = roomName;
NativeBridgeDelegate.saveVisitRoomInfo(roomID, roomName)
NativeBridgeDelegate.saveVisitRoomInfo(roomID, roomName);
};
// #36170 画像パスが存在しない場合はデフォルトの画像を返す
......@@ -570,7 +570,10 @@ document.addEventListener("DOMContentLoaded", function () {
if (keyword.length == 1) {
return;
}
const messages = NativeBridgeDataSource.searchMessages(keyword, checkedUserList.join(","));
const messages = NativeBridgeDataSource.searchMessages(
keyword,
checkedUserList.join(",")
);
var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
......@@ -716,7 +719,10 @@ CHAT.searchMessage = function (keyword, workVal) {
const selectedUser = $(".img_wrap.filter")[user];
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 myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
......@@ -765,15 +771,16 @@ CHAT.searchMessage = function (keyword, workVal) {
};
// 下スクロールでユーザーリストを非表示
var startPos = 0,winScrollTop = 0;
$(window).on('scroll',function(){
var startPos = 0;
var winScrollTop = 0;
$(window).on("scroll", function () {
winScrollTop = $(this).scrollTop();
if (winScrollTop >= startPos) {
if(winScrollTop >= 200){
$('#chat_room .user_list').addClass('hide');
if (winScrollTop >= 200) {
$("#chat_room .user_list").addClass("hide");
}
} else {
$('#chat_room .user_list').removeClass('hide');
$("#chat_room .user_list").removeClass("hide");
}
startPos = winScrollTop;
});
......@@ -43,7 +43,7 @@ CHAT_MAKE_ROOM.searchUser = function (keyword) {
var userTemplate = getTemplate(TemplateURL.MAKE_ROOM_USER_LIST);
let html = renderUser(userTemplate, userList);
let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").html(obj);
overlayMessage.html(obj);
hasNoData = userList.length == 0;
}
......
// ios用
function callNativeApp(iosKey, jsonData) {
console.log("callNativeApp called: "+iosKey);
console.log("callNativeApp called: " + iosKey);
var result;
try {
var key = iosKey;
......
......@@ -2,8 +2,6 @@ $.lang.en = {
"chat_placeholder":"Type message",
"chat_search_placeholder":" Search Message",
"room_search_placeholder":" Search Room",
"participants":"Member List",
"exitRoom":"Exit ",
"roomListTitle":"Room List",
"deleteRoomTitle":"Delete Room",
"inviteUsersButton":"invite",
......@@ -21,18 +19,12 @@ $.lang.en = {
"orderByTime":"OrderByTime",
"orderByUnread":"OrderByUnread",
"roomKeywordPlaceHolder":"Search",
"okayLabel":"Okay!",
"completeLabel":"Complete.",
"thankLabel":"Thank you",
"startToWorkLabel":"Start to work",
"groupListKeyword":"Search",
"userSearch":"User Search",
"groupSearch":"Group Search",
"groupPageSubtitle":"Groups",
"noMessages":"No Messages",
"image":"Image",
"chatKeyword":"Search",
"userListKeyword":"Search",
"newRoomName":"Please input Room Name",
"everyoneIsHere":"Everyone is in the chat.",
"people":"people",
......
......@@ -2,8 +2,6 @@ $.lang.ja = {
"chat_placeholder":"メッセージを入力",
"chat_search_placeholder":" メッセージ検索",
"room_search_placeholder":" ルーム検索",
"participants":"メンバーリスト",
"exitRoom":"退出 ",
"roomListTitle":"チャット",
"deleteRoomTitle":"ルーム削除",
"inviteUsersButton":"招待",
......@@ -20,18 +18,12 @@ $.lang.ja = {
"orderByTime":"新着順",
"orderByUnread":"未読優先",
"roomKeywordPlaceHolder":"検索",
"okayLabel":"了解しました。",
"completeLabel":"完了しました。",
"thankLabel":"ありがとうございます。",
"startToWorkLabel":"作業開始します。",
"userSearch":"ユーザー検索",
"groupSearch":"グループ検索",
"groupListKeyword":"検索",
"groupPageSubtitle":"グループ",
"noMessages":"メッセージがありません。",
"image":"画像",
"chatKeyword":"検索",
"userListKeyword":"検索",
"invitedUser":"参加者",
"newRoomName":"ルーム名を入力してください",
"everyoneIsHere":"招待可能なメンバーがいません。",
......
......@@ -2,8 +2,6 @@ $.lang.ko = {
"chat_placeholder":"메시지를 입력하세요.",
"chat_search_placeholder":" 메세지검색",
"room_search_placeholder":" 채팅방 검색",
"participants":"멤버 리스트",
"exitRoom":"나가기 ",
"roomListTitle":"채팅 리스트",
"deleteRoomTitle":"채팅방 삭제",
"inviteUsersButton":"유저 초대",
......@@ -21,18 +19,12 @@ $.lang.ko = {
"orderByTime":"최신순",
"orderByUnread":"안 읽은 순",
"roomKeywordPlaceHolder":"검색",
"okayLabel":"알겠습니다.",
"completeLabel":"작업이 끝났습니다.",
"thankLabel":"감사합니다.",
"startToWorkLabel":"작업을 시작합니다.",
"groupListKeyword":"검색",
"userSearch":"유저 검색",
"groupSearch":"그룹 검색",
"groupPageSubtitle":"그룹",
"noMessages":"메시지가 없습니다.",
"image":"이미지",
"chatKeyword":"검색",
"userListKeyword":"검색",
"newRoomName":"방 이름을 입력해주세요.",
"everyoneIsHere":"초대가능한 유저가 없습니다.",
"people":"명",
......
......@@ -3,7 +3,7 @@ var bindOnRefreshGroupList = function () {
socket.on(SOCKET_KEY.REFRESH_GROUPLIST, function (groups, isInvite) {
const groupListElement = $("#group_list");
groupListElement.html("");
const template = $("#group-template").html();
if (groups.length === 0) {
groupListElement.append(
'<center class="text-secondary">' +
......@@ -12,92 +12,10 @@ var bindOnRefreshGroupList = function () {
);
}
addGroupNameAndNumberOfUsers(groups);
// Rotate
handleRotate();
updateTopBar();
// Set Title
updateTopBar(isInvite);
updateUserSelectionLength();
setupBackButton();
});
};
var addGroupNameAndNumberOfUsers = function (groups) {
// グループ名と人数を表記する。
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 updateTopBar = function () {
$("#newRoomName").hide();
};
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 () {
return;
}
updateRoomName(params.roomName);
// loadingIndicatorを表示しない
CHAT_UI.dismissLoadingIndicator();
});
......@@ -157,12 +155,13 @@ var errorHandlingForEmitJoin = function () {
.on("click", "#customAlertOk", function (e) {});
};
var updateRoomName = function (roomName) {
const titleRoomName = $(".titleRoomName");
if (roomName != undefined) {
titleRoomName.text(roomName).data("roomName", roomName);
} else {
let roomListTitle = getLocalizedString("roomListTitle");
titleRoomName.text(roomListTitle);
var bindOnRefreshUserListInGroup = function () {
// Update User List(Invite)
// #36170
socket.on(
SOCKET_KEY.REFRESH_USERLIST_INGROUP,
function (users, groupId, isInvite) {
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