diff --git a/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/User.java b/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/User.java index caa650c22d..0944b45674 100644 --- a/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/User.java +++ b/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/User.java @@ -8,18 +8,18 @@ public class User { /** . */ - private String position; - private String fullName; + private String position = ""; + private String fullName = ""; private String id; private String profileUrl; - private String activity; - private String userName; + private String activity = ""; + private String userName = ""; /** . */ private String avatar; - private String status; - private String identity; - private String relationId; + private String status = ""; + private String identity = ""; + private String relationId = ""; public User(final String userName) { this.userName = userName; diff --git a/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/WhoIsOnlineImpl.java b/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/WhoIsOnlineImpl.java index da7e1918c3..77a7e6ac5b 100644 --- a/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/WhoIsOnlineImpl.java +++ b/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/WhoIsOnlineImpl.java @@ -1,19 +1,13 @@ package org.exoplatform.platform.portlet.juzu.whoisonline; -import org.apache.commons.lang.StringEscapeUtils; import org.exoplatform.container.ExoContainerContext; import org.exoplatform.forum.service.ForumService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; -import org.exoplatform.social.common.RealtimeListAccess; -import org.exoplatform.social.core.activity.model.ExoSocialActivity; import org.exoplatform.social.core.identity.model.Identity; import org.exoplatform.social.core.identity.model.Profile; import org.exoplatform.social.core.identity.provider.OrganizationIdentityProvider; -import org.exoplatform.social.core.manager.ActivityManager; import org.exoplatform.social.core.manager.IdentityManager; -import org.exoplatform.social.core.manager.RelationshipManager; -import org.exoplatform.social.core.relationship.model.Relationship; import org.exoplatform.social.core.service.LinkProvider; import java.util.ArrayList; @@ -25,81 +19,37 @@ * @date 07/12/12 */ public class WhoIsOnlineImpl implements WhoIsOnline { - private static Log log = ExoLogger.getLogger(WhoIsOnlineImpl.class); - private static final String CONFIRMED = "confirmed"; - private static final String PENDING = "pending"; - private static final String RECEIVED = "received"; - private static final String IGNORED = "ignored"; - private static final String DEFAULT_ACTIVITY = "DEFAULT_ACTIVITY"; - private static final String LINK_ACTIVITY = "LINK_ACTIVITY"; - private static final String DOC_ACTIVITY = "DOC_ACTIVITY"; - private static final int COUNT = 10; - private static final int MAX_CHAR = 115; - private static final int INDEX_CHAR = 110; - private static final String THREE_DOTS = "..."; private static final int MAX_USER = 17; private static final int INDEX_USER = 18; - private static final int MAX_DOC_CHAR = 25; public List getFriends(String userId) { List userOnLineList = new ArrayList(); + if (userId == null) return userOnLineList; + try { - if (userId == null) { - return userOnLineList; - } - RelationshipManager relationshipManager = (RelationshipManager) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(RelationshipManager.class); ForumService forumService = (ForumService) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(ForumService.class); IdentityManager identityManager = (IdentityManager) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(IdentityManager.class); - Identity myIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, userId); List users = forumService.getOnlineUsers(); if (users.contains(userId)) { users.remove(userId); } Collections.reverse(users); + + // if (users.size() > MAX_USER) { users = users.subList(0, INDEX_USER); } - //List userOnLineList = new ArrayList(); - String lastActivity = ""; User userOnLine = null; - String userStatus = ""; - + for (String user : users) { userOnLine = new User(user); Identity userIdentity = identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, user); - - if (userIdentity.equals(myIdentity)) - continue; - - lastActivity = getLastActivity(userIdentity); - userStatus = getStatus(myIdentity, userIdentity); - Profile userProfile = userIdentity.getProfile(); - String avatar = userProfile.getAvatarImageSource(); - if (avatar == null) { - avatar = LinkProvider.PROFILE_DEFAULT_AVATAR_URL; - } - - String position = userProfile.getPosition(); - if (position == null) { - position = ""; - } - String relation = ""; - if (userStatus.equals(RECEIVED)) { - relation = relationshipManager.getRelationship(myIdentity, userIdentity).getId(); - } - - userOnLine.setAvatar(avatar); - userOnLine.setPosition(position); - userOnLine.setFullName(userProfile.getFullName()); userOnLine.setId(userProfile.getId()); - userOnLine.setProfileUrl(LinkProvider.getUserActivityUri(user)); - userOnLine.setIdentity(userIdentity.getId()); - userOnLine.setActivity(lastActivity); - userOnLine.setStatus(userStatus); - userOnLine.setRelationId(relation); + userOnLine.setProfileUrl(LinkProvider.getUserProfileUri(userIdentity.getRemoteId())); + userOnLine.setAvatar(userProfile.getAvatarImageSource() != null ? userProfile.getAvatarImageSource() : LinkProvider.PROFILE_DEFAULT_AVATAR_URL); userOnLineList.add(userOnLine); } return userOnLineList; @@ -109,131 +59,4 @@ public List getFriends(String userId) { return null; } } - - - private String getStatus(Identity identity1, Identity identity2) { - String status = ""; - RelationshipManager relationshipManager = (RelationshipManager) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(RelationshipManager.class); - if (relationshipManager.getStatus(identity1, identity2) == null) { - status = ""; - } else { - if (relationshipManager.getStatus(identity1, identity2).equals(Relationship.Type.CONFIRMED)) { - status = CONFIRMED; - } else { - if (relationshipManager.getStatus(identity1, identity2).equals(Relationship.Type.PENDING)) { - - if (relationshipManager.getRelationship(identity2, identity1).getSender().equals(identity1)) { - status = PENDING; - } else { - status = RECEIVED; - } - } else { - status = IGNORED; - } - } - } - - return status; - } - - private String getLastActivity(Identity identity) { - String activity = ""; - int count = COUNT; - int i = 0; - try{ - ActivityManager activityManager = (ActivityManager) ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(ActivityManager.class); - RealtimeListAccess activityList = activityManager.getActivitiesByPoster(identity); - for (ExoSocialActivity act : activityList.loadAsList(i, count)) { - i++; - - if (act.getType() != null && (act.getType().equals(DEFAULT_ACTIVITY) || act.getType().equals(LINK_ACTIVITY) || act.getType().equals(DOC_ACTIVITY))) { - - activity = act.getTitle().replaceAll("
", " ").replaceAll("
", " ").replaceAll("
", " ").replaceAll("
", " ").trim(); - activity = StringEscapeUtils.unescapeHtml(activity); - activity = activity.replaceAll("\"", "'"); - - if (activity.length() > MAX_CHAR && act.getType().equals(DEFAULT_ACTIVITY)) { - String maxBody = activity.substring(0, MAX_CHAR); - int tagEnterLocation = maxBody.indexOf('<', 0); - if (tagEnterLocation != -1) { - if (tagEnterLocation == 0) { - if (maxBody.indexOf("<", tagEnterLocation) == 0) { - int endtag = activity.indexOf(">", tagEnterLocation); - int tagend = activity.indexOf("<", endtag); - int tagend2 = activity.indexOf(">", tagend); - String linktitle = activity.substring(endtag + 1, tagend); - if (linktitle.length() > MAX_CHAR) { - linktitle = linktitle.substring(0, MAX_CHAR); - activity = activity.substring(0, endtag + 1) + linktitle + activity.substring(tagend, tagend2 + 1); - } else { - activity = activity.substring(0, tagend2); - } - } - - activity = activity + "" + THREE_DOTS + ""; - } else { - int tagEndLocation = maxBody.indexOf("<", tagEnterLocation + 1); - int tagLocationEnd = maxBody.indexOf("/>", tagEnterLocation); - if ((tagEndLocation == -1 && tagLocationEnd == -1)) { - String str1 = maxBody.substring(0, tagEnterLocation - 1); - activity = str1 + "" + THREE_DOTS + ""; - } - if (tagEndLocation != -1) { - - if (tagEndLocation > MAX_CHAR - 3) { - String charRest = activity.substring(0, tagEndLocation + 3); - activity = charRest + "" + THREE_DOTS + ""; - } else { - if (tagEndLocation <= MAX_CHAR - 3) { - activity = maxBody + "" + THREE_DOTS + ""; - } - } - } - if (tagLocationEnd != -1) { - activity = maxBody + "" + THREE_DOTS + ""; - } - } - } else { - activity = maxBody + "" + THREE_DOTS + ""; - } - } - - if (act.getType().equals(DOC_ACTIVITY)) { - try{ - if ((activity.split(">")[1].split("<")[0]).length() > MAX_DOC_CHAR) { - String docName = activity.split(">")[1].split("<")[0].substring(0, MAX_DOC_CHAR).concat(THREE_DOTS); - String docUrl = activity.split(">")[0].split("=")[1].replace("\"", "'"); - activity = "Shared a Document " + docName + ""; - } - }catch(ArrayIndexOutOfBoundsException e) { - log.warn("Error while recovering activity of type DOC_ACTIVITY [Url of shared Document Not found ]") ; - return ""; - } - } - - if (act.getType().equals(LINK_ACTIVITY)) { - - if (activity.indexOf("<", 0) != -1) { - activity = activity.substring(activity.indexOf(">", 0) + 1, activity.indexOf("<", activity.indexOf(">", 0))); - } - if (activity.length() > MAX_CHAR) { - activity = activity.substring(0, MAX_CHAR); - } - - activity = "" + activity + ""; - } - break; - } - if (i == 9 && activity.equals("")) { - count += COUNT; - } - } - - return activity; - }catch (Exception e){ - log.error("Error while recovering user's last activity [WhoIsOnLine rendering phase] :" + e.getMessage(), e); - return ""; - } - } - } diff --git a/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/templates/index.gtmpl b/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/templates/index.gtmpl index 3573427d1a..de0b45941b 100644 --- a/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/templates/index.gtmpl +++ b/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/templates/index.gtmpl @@ -21,9 +21,34 @@ import org.exoplatform.webui.application.portlet.PortletRequestContext; import org.exoplatform.web.application.JavascriptManager; + import juzu.impl.request.Request; + import juzu.request.RequestContext; + import java.util.ResourceBundle; + + RequestContext requestContext = Request.getCurrent().getContext(); + ResourceBundle bundle= requestContext.getApplicationContext().resolveBundle(requestContext.getUserContext().getLocale()) ; + + def statusTitle=bundle.getString("Loading.label"); + def connectLabel=bundle.getString("Connect.label"); + def confirmLabel=bundle.getString("Confirm.label"); + def cancelRequestLabel=bundle.getString("CancelRequest.label"); + def removeConnectionLabel=bundle.getString("RemoveConnection.label"); + def ignoreLabel=bundle.getString("Ignore.label"); + def messageLabel=bundle.getString("message.label"); + + def labels = """ { + StatusTitle: '${statusTitle}', + youHaveSentAnInvitation: '${messageLabel}', + Connect: '${connectLabel}', + Confirm: '${confirmLabel}', + CancelRequest: '${cancelRequestLabel}', + RemoveConnection: '${removeConnectionLabel}', + Ignore: '${ignoreLabel}' + } """ + def pcontext = Util.getPortalRequestContext(); def jsManager = pcontext.getJavascriptManager(); - jsManager.require("SHARED/jQueryWhoIsOnLine", "wos").addScripts("wos.ajaxWhoIsOnLine();"); + jsManager.require("SHARED/jQueryWhoIsOnLine", "wos").addScripts("wos.ajaxWhoIsOnLine($labels);"); %>
diff --git a/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/templates/users.gtmpl b/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/templates/users.gtmpl index b99f216753..56fcf72398 100644 --- a/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/templates/users.gtmpl +++ b/extension/portlets/homepagePortlets/src/main/java/org/exoplatform/platform/portlet/juzu/whoisonline/templates/users.gtmpl @@ -17,64 +17,9 @@ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ %> - <% - import juzu.impl.request.Request; - import juzu.request.RequestContext; - import java.util.ResourceBundle; - - RequestContext requestContext = Request.getCurrent().getContext(); - ResourceBundle bundle= requestContext.getApplicationContext().resolveBundle(requestContext.getUserContext().getLocale()) ; - if(users.empty){ %> - - - <%}else{%> - - <%}%> <%users.each { user -> %> - - <% - def connect=""; - def message=bundle.getString("message.label"); - def activity=user.getActivity(); - if(user.getStatus().equals("") || user.getStatus().equals("ignored")){ - connect=""; - - }else{ - if( user.getStatus().equals("received")) { - connect=""; - }else{ - if(user.getStatus().equals("pending")) { - connect="
"+message+"
"; - } - }} - - if(!activity.equals("")){ - activity="
"+activity+"
"; - } - - - %>
  • - image - - - - - - - - - - - + image
  • <%}%> \ No newline at end of file diff --git a/extension/portlets/homepagePortlets/src/main/resources/locale/portlet/whoisonline/whoisonline_en.properties b/extension/portlets/homepagePortlets/src/main/resources/locale/portlet/whoisonline/whoisonline_en.properties index 1db8dd76ec..af60be1ed9 100644 --- a/extension/portlets/homepagePortlets/src/main/resources/locale/portlet/whoisonline/whoisonline_en.properties +++ b/extension/portlets/homepagePortlets/src/main/resources/locale/portlet/whoisonline/whoisonline_en.properties @@ -1,3 +1,9 @@ header.label=Who's Online ? -connect.label=Connect -message.label=You have sent a connection request \ No newline at end of file +message.label=You have sent a connection request + +Loading.label=Loading... +Connect.label=Connect +Confirm.label=Confirm +CancelRequest.label=Cancel Request +RemoveConnection.label=Remove Connection +Ignore.label=Ignore \ No newline at end of file diff --git a/extension/portlets/homepagePortlets/src/main/webapp/WEB-INF/gatein-resources.xml b/extension/portlets/homepagePortlets/src/main/webapp/WEB-INF/gatein-resources.xml index 56dae6a7c3..c437b81954 100644 --- a/extension/portlets/homepagePortlets/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/extension/portlets/homepagePortlets/src/main/webapp/WEB-INF/gatein-resources.xml @@ -145,18 +145,6 @@ - - jQueryToolTip - homepage-apps - - - jquery - jQuery - - - jQueryWhoIsOnLine homepage-apps @@ -170,7 +158,7 @@ jquery - jQueryToolTip + userPopupPlugin diff --git a/extension/portlets/homepagePortlets/src/main/webapp/js/whoisonline/jquery.tipTip.minified.js b/extension/portlets/homepagePortlets/src/main/webapp/js/whoisonline/jquery.tipTip.minified.js deleted file mode 100644 index daf18149e8..0000000000 --- a/extension/portlets/homepagePortlets/src/main/webapp/js/whoisonline/jquery.tipTip.minified.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * TipTip - * Copyright 2010 Drew Wilson - * www.drewwilson.com - * code.drewwilson.com/entry/tiptip-jquery-plugin - * - * Version 1.3 - Updated: Mar. 23, 2010 - * - * This Plug-In will create a custom tooltip to replace the default - * browser tooltip. It is extremely lightweight and very smart in - * that it detects the edges of the browser window and will make sure - * the tooltip stays within the current window size. As a result the - * tooltip will adjust itself to be displayed above, below, to the left - * or to the right depending on what is necessary to stay within the - * browser window. It is completely customizable as well via CSS. - * - * This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - */ -(function($){$.fn.tipTip=function(options){var defaults={activation:"hover",keepAlive:false,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var opts=$.extend(defaults,options);if($("#tiptip_holder").length<=0){var tiptip_holder=$('
    ');var tiptip_content=$('
    ');var tiptip_arrow=$('
    ');$("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('
    ')))}else{var tiptip_holder=$("#tiptip_holder");var tiptip_content=$("#tiptip_content");var tiptip_arrow=$("#tiptip_arrow")}return this.each(function(){var org_elem=$(this);if(opts.content){var org_title=opts.content}else{var org_title=org_elem.attr(opts.attribute)}if(org_title!=""){if(!opts.content){org_elem.removeAttr(opts.attribute)}var timeout=false;if(opts.activation=="hover"){org_elem.hover(function(){active_tiptip()},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}else if(opts.activation=="focus"){org_elem.focus(function(){active_tiptip()}).blur(function(){deactive_tiptip()})}else if(opts.activation=="click"){org_elem.click(function(){active_tiptip();return false}).hover(function(){},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}function active_tiptip(){opts.enter.call(this);tiptip_content.html(org_title);tiptip_holder.hide().removeAttr("class").css("margin","0");tiptip_arrow.removeAttr("style");var top=parseInt(org_elem.offset()['top']);var left=parseInt(org_elem.offset()['left']);var org_width=parseInt(org_elem.outerWidth());var org_height=parseInt(org_elem.outerHeight());var tip_w=tiptip_holder.outerWidth();var tip_h=tiptip_holder.outerHeight();var w_compare=Math.round((org_width-tip_w)/2);var h_compare=Math.round((org_height-tip_h)/2);var marg_left=Math.round(left+w_compare);var marg_top=Math.round(top+org_height+opts.edgeOffset);var t_class="";var arrow_top="";var arrow_left=Math.round(tip_w-12)/2;if(opts.defaultPosition=="bottom"){t_class="_bottom"}else if(opts.defaultPosition=="top"){t_class="_top"}else if(opts.defaultPosition=="left"){t_class="_left"}else if(opts.defaultPosition=="right"){t_class="_right"}var right_compare=(w_compare+left)parseInt($(window).width());if((right_compare&&w_compare<0)||(t_class=="_right"&&!left_compare)||(t_class=="_left"&&left<(tip_w+opts.edgeOffset+5))){t_class="_right";arrow_top=Math.round(tip_h-13)/2;arrow_left=-12;marg_left=Math.round(left+org_width+opts.edgeOffset);marg_top=Math.round(top+h_compare)}else if((left_compare&&w_compare<0)||(t_class=="_left"&&!right_compare)){t_class="_left";arrow_top=Math.round(tip_h-13)/2;arrow_left=Math.round(tip_w);marg_left=Math.round(left-(tip_w+opts.edgeOffset+5));marg_top=Math.round(top+h_compare)}var top_compare=(top+org_height+opts.edgeOffset+tip_h+8)>parseInt($(window).height()+$(window).scrollTop());var bottom_compare=((top+org_height)-(opts.edgeOffset+tip_h+8))<0;if(top_compare||(t_class=="_bottom"&&top_compare)||(t_class=="_top"&&!bottom_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_top"}else{t_class=t_class+"_top"}arrow_top=tip_h;marg_top=Math.round(top-(tip_h+5+opts.edgeOffset))}else if(bottom_compare|(t_class=="_top"&&bottom_compare)||(t_class=="_bottom"&&!top_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_bottom"}else{t_class=t_class+"_bottom"}arrow_top=-12;marg_top=Math.round(top+org_height+opts.edgeOffset)}if(t_class=="_right_top"||t_class=="_left_top"){marg_top=marg_top+5}else if(t_class=="_right_bottom"||t_class=="_left_bottom"){marg_top=marg_top-5}if(t_class=="_left_top"||t_class=="_left_bottom"){marg_left=marg_left+5}tiptip_arrow.css({"margin-left":arrow_left+"px","margin-top":arrow_top+"px"});tiptip_holder.css({"margin-left":marg_left+"px","margin-top":marg_top+"px"}).attr("class","tip"+t_class);if(timeout){clearTimeout(timeout)}timeout=setTimeout(function(){tiptip_holder.stop(true,true).fadeIn(opts.fadeIn)},opts.delay)}function deactive_tiptip(){opts.exit.call(this);if(timeout){clearTimeout(timeout)}tiptip_holder.fadeOut(opts.fadeOut)}}})}})(jQuery); \ No newline at end of file diff --git a/extension/portlets/homepagePortlets/src/main/webapp/js/whoisonline/whoisonline.js b/extension/portlets/homepagePortlets/src/main/webapp/js/whoisonline/whoisonline.js index 58160822d2..60797a97bf 100644 --- a/extension/portlets/homepagePortlets/src/main/webapp/js/whoisonline/whoisonline.js +++ b/extension/portlets/homepagePortlets/src/main/webapp/js/whoisonline/whoisonline.js @@ -1,5 +1,5 @@ (function($) { - + var glables = null; if($('#onlineList li').length == 0) { $("#OnlinePortlet").hide(); } else { @@ -7,48 +7,45 @@ } var showTooltip = function() { - $('#onlineList li').each(function() { - var activity = $(this).find("input[name=activity]").val(); - var connect = $(this).find("input[name=connect]").val(); - var messageLabel = $(this).find("input[name=messageLabel]").val(); - - var userId = $(this).find("input[name=userId]").val(); - var userAvatar = $(this).find("input[name=userAvatar]").val(); - var profileURL = $(this).find("input[name=profileURL]").val(); - var fullName = $(this).find("input[name=fullName]").val(); - var userPosition = $(this).find("input[name=userPosition]").val(); - var userIdentity = $(this).find("input[name=userIdentity]").val(); - var userRelationId = $(this).find("input[name=userRelationId]").val(); - $("#"+userId).tipTip({ content: "
    image
    "+userPosition+"
    "+activity+connect,defaultPosition: "left", keepAlive: true,maxWidth: "240px"}); - - $("#" + userId +"connect a.connect").live("click", function(){ - $.getJSON("/rest/homepage/intranet/people/contacts/connect/" + userIdentity, null); - $("#" + userId + "connect").fadeOut(500, function () { - $(this).html("
    " + messageLabel + "
    "); - $(this).fadeIn(500, function() {}); - }); - - setTimeout(refresh, 500); - }); - $("#" + userId + "accept a.connect").live("click", function(){ - $.getJSON("/rest/homepage/intranet/people/contacts/confirm/" + userRelationId, null); - $("#" + userId + "accept").hide(); - setTimeout(refresh, 500); + if($('#onlineList li').length == 0) { + $("#OnlinePortlet").hide(); + } else { + $("#OnlinePortlet").show(); + } + + // User Profile Popup initialize + var portal = eXo.social.portal; + var restUrl = 'http://' + window.location.host + portal.context + '/' + portal.rest + '/social/people' + '/getPeopleInfo/{0}.json'; + + + + var userLinks = $('#onlineList').find('a:[href*="/profile/"]'); + $.each(userLinks, function (idx, el) { + var userUrl = $(el).attr('href'); + var userId = userUrl.substring(userUrl.lastIndexOf('/') + 1); + + $(el).userPopup({ + restURL: restUrl, + labels: glables, + content: false, + defaultPosition: "left", + keepAlive: true, + maxWidth: "240px" }); }); }; var refresh = function() { - $.getJSON('/rest/platform/isusersessionalive', function (connected) { + $.getJSON('/rest/platform/isusersessionalive', function (connected) { - if(connected == true){ + if(connected == true){ - $("#onlineList").jzLoad("WhoIsOnLineController.users()", showTooltip); + $("#onlineList").jzLoad("WhoIsOnLineController.users()", showTooltip); - } - }); + } + }); }; // Wait 1/2 second (not realistic of course) @@ -56,7 +53,10 @@ setTimeout(refresh, 500); setInterval(refresh,60000); return { - ajaxWhoIsOnLine: function() { + ajaxWhoIsOnLine: function(labels) { + var labels = labels; + + glables = labels; $.getJSON('/rest/platform/isusersessionalive', function (connected) { if(connected == true){ @@ -69,4 +69,4 @@ } }; -})($); +})($); \ No newline at end of file