From 51c248e4633c914e3c95813f6445a92bd94d78a9 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 14 Jul 2018 14:18:21 +0200 Subject: [PATCH] Upgraded openUserPage function --- assets/js/common/shorcuts.js | 13 +++++++++++++ assets/js/components/friends/friendsBar.js | 2 +- assets/js/components/friends/listModal.js | 2 +- assets/js/components/friends/ui.js | 2 +- assets/js/components/menuBar/authenticated.js | 2 +- assets/js/components/notifications/ui.js | 2 +- assets/js/components/posts/ui.js | 2 +- assets/js/components/searchForm/searchForm.js | 2 +- assets/js/components/textParser.js | 2 +- assets/js/pages/userPage/friendshipStatus.js | 2 +- 10 files changed, 22 insertions(+), 9 deletions(-) diff --git a/assets/js/common/shorcuts.js b/assets/js/common/shorcuts.js index fd6ecbe7..81d1ef0d 100644 --- a/assets/js/common/shorcuts.js +++ b/assets/js/common/shorcuts.js @@ -38,6 +38,19 @@ function openPage(pageURI, additionnalData){ * @return {Boolean} True for a success */ function openUserPage(user){ + if(user.virtualDirectory == "") + openUserPageFromID(user.userID); + else + openPage(user.virtualDirectory); +} + +/** + * Open a user page quickly from its user ID + * + * @param {String} user The ID of the user or its directory + * @return {Boolean} True for a success + */ +function openUserPageFromID(user){ return openPage("user/" + user); } diff --git a/assets/js/components/friends/friendsBar.js b/assets/js/components/friends/friendsBar.js index a2540dea..fa87f7cc 100644 --- a/assets/js/components/friends/friendsBar.js +++ b/assets/js/components/friends/friendsBar.js @@ -159,7 +159,7 @@ ComunicWeb.components.friends.bar = { //Make the link lives friendLink.onclick = function(){ - openUserPage(userIDorPath(userInfos)); + openUserPage(userInfos); //For the responsive mode ComunicWeb.components.friends.bar.toggleShowHide(); diff --git a/assets/js/components/friends/listModal.js b/assets/js/components/friends/listModal.js index e6e852c7..f088120e 100644 --- a/assets/js/components/friends/listModal.js +++ b/assets/js/components/friends/listModal.js @@ -213,7 +213,7 @@ ComunicWeb.components.friends.listModal = { userLink.onclick = function(){ //Open user page - openUserPage(userIDorPath(users["user-" + id])); + openUserPage(users["user-" + id]); //Close all modals $(".modal").modal("hide"); diff --git a/assets/js/components/friends/ui.js b/assets/js/components/friends/ui.js index e97dd98d..d5bff0e6 100644 --- a/assets/js/components/friends/ui.js +++ b/assets/js/components/friends/ui.js @@ -55,7 +55,7 @@ ComunicWeb.components.friends.ui = { userLink.onclick = function(){ //Open user page - openUserPage(userIDorPath(user)); + openUserPage(user); //Close all modals $(".modal").modal("hide"); diff --git a/assets/js/components/menuBar/authenticated.js b/assets/js/components/menuBar/authenticated.js index 40b0e501..a224b7a9 100644 --- a/assets/js/components/menuBar/authenticated.js +++ b/assets/js/components/menuBar/authenticated.js @@ -186,7 +186,7 @@ ComunicWeb.components.menuBar.authenticated = { userimage.src = userInfos.accountImage; userlinkelement.onclick = function(){ - openUserPage(userIDorPath(userInfos)); + openUserPage(userInfos); } }), true); diff --git a/assets/js/components/notifications/ui.js b/assets/js/components/notifications/ui.js index d57d2599..37629e33 100644 --- a/assets/js/components/notifications/ui.js +++ b/assets/js/components/notifications/ui.js @@ -77,7 +77,7 @@ ComunicWeb.components.notifications.ui = { if(data.on_elem_type == "friend_request"){ //Open user page - openUserPage(data.from_user_id); + openUserPageFromID(data.from_user_id); } diff --git a/assets/js/components/posts/ui.js b/assets/js/components/posts/ui.js index f09429d3..3b53dac3 100644 --- a/assets/js/components/posts/ui.js +++ b/assets/js/components/posts/ui.js @@ -71,7 +71,7 @@ ComunicWeb.components.posts.ui = { userName.innerHTML = result.firstName + " " + result.lastName; userName.onclick = function(){ - openUserPage(userIDorPath(result)); + openUserPage(result); } } }); diff --git a/assets/js/components/searchForm/searchForm.js b/assets/js/components/searchForm/searchForm.js index 511cd093..8d8a6fbe 100644 --- a/assets/js/components/searchForm/searchForm.js +++ b/assets/js/components/searchForm/searchForm.js @@ -153,7 +153,7 @@ ComunicWeb.components.searchForm = { //Make user link element live userLinkElement.onclick = function() { ComunicWeb.components.searchForm.close(); - openUserPage(userIDorPath(userInfos)); + openUserPage(userInfos); } }, diff --git a/assets/js/components/textParser.js b/assets/js/components/textParser.js index 0265f316..fff7b482 100644 --- a/assets/js/components/textParser.js +++ b/assets/js/components/textParser.js @@ -104,7 +104,7 @@ ComunicWeb.components.textParser = { node.addEventListener("click", function(ev){ //Open user page - openUserPage(userID); + openPage(userID); }); } diff --git a/assets/js/pages/userPage/friendshipStatus.js b/assets/js/pages/userPage/friendshipStatus.js index af19f27c..1923e748 100644 --- a/assets/js/pages/userPage/friendshipStatus.js +++ b/assets/js/pages/userPage/friendshipStatus.js @@ -82,7 +82,7 @@ ComunicWeb.pages.userPage.friendshipStatus = { else { //Reopen user page - openUserPage(userID); + openUserPageFromID(userID); } });