social-dockbar-hook/src/main/webapp/custom_jsps/html/portlet/dockbar/custom_dockbar_view.jspf

291 lines
11 KiB
Plaintext

<%@ page import="org.gcube.common.portal.GCubePortalConstants" %>
<%@ page import="org.gcube.common.portal.PortalContext" %>
<%
// show the custom dockbar buttons only if the user is logged in, useless otherwise
if (themeDisplay.isSignedIn()) {
PortalContext context = PortalContext.getConfiguration();
String groupName = context.getGatewayName(request);
String mySiteURL = context.getSiteLandingPagePath(request);
String myGatewayURL = context.getGatewayURL(request);
pageContext.setAttribute("myDashboardUrl", mySiteURL);
String iconBGColor = "#999";
if (themeDisplay.getThemeSetting("dockbar-selected-icon-bgcolor") != null)
iconBGColor = themeDisplay.getThemeSetting("dockbar-selected-icon-bgcolor");
pageContext.setAttribute("iconBGColor", iconBGColor);
%>
<script>
jQuery(document).ready(function() {
var pathname = window.location.pathname;
var backgroundColorSetting = '${iconBGColor}';
if (pathname == '${myDashboardUrl}' || pathname == '${myDashboardUrl}'+ '/' || pathname == '${myDashboardUrl}'+ '/home') {
$('#homeIcon').css("background-color", backgroundColorSetting);
$('#homeIcon').css("color", "#FFF");
}
if (pathname == '${myDashboardUrl}'+ '/workspace') {
$('#wsIcon').css("background-color", backgroundColorSetting);
$('#wsIcon').css("color", "#FFF");
}
if (pathname == '${myDashboardUrl}'+ '/data-catalogue') {
$('#catalougueIcon').css("background-color", backgroundColorSetting);
$('#catalougueIcon').css("color", "#FFF");
}
if (pathname == '${myDashboardUrl}'+ '/messages') {
$('#messagesIcon').css("background-color", backgroundColorSetting);
$('#messagesIcon').css("color", "#FFF");
}
//check for notifications on load after 3 seconds
var username = "<%=themeDisplay.getUser().getScreenName()%>";
// current location to extract the vre and the user profiles within it
var location = window.location.href;
$.get('/notificationchecker/notificationchecker', {
userid : username, location : location
}, function(responseText) {
});
//then repeat every 3 minutes
setInterval(function() {
var username = "<%=themeDisplay.getUser().getScreenName()%>";
var location = window.location.href;
$.get('/notificationchecker/notificationchecker',{
userid : username, location : location
}, function(responseText) {
});
}, 240000);
//search box keyboard handlers
$('#searchbox').bind("enterKey",function(e){
if ($('#searchbox').val() != "") {
if ($('#searchbox').val().indexOf("#") == 0) {
if ($('#searchbox').val().indexOf(" ") >= 0) {
alert('Sorry, spaces not allowed when searching for topics!');
return;
}
var base64hashtag = btoa($('#searchbox').val());
var base64attr = btoa("hashtagIdentificationParameter");
if (window.location.href.indexOf("<%=mySiteURL%>") >= 0) {
window.location.href = "<%=mySiteURL%>?"+base64attr+"="+ base64hashtag;
}
else {
//this is when you are in a VRE and you want to search in that VRE, count the slashes to get where to point
//you always want to point to /group/vrename
var newhref = window.location.href;
if (window.location.href.indexOf("?") >= 0) {
newhref = window.location.href.split("?")[0];
}
var count = newhref.split("/").length-1;
if (count > 4)
window.location.href = newhref + "/../?"+base64attr+"="+ base64hashtag;
else
window.location.href = newhref + "?"+base64attr+"="+ base64hashtag;
}
}
else {
var base64hashtag = btoa($('#searchbox').val());
var base64attr = btoa("elasticSearchIdentificationParameter");
if (window.location.href.indexOf("<%=mySiteURL%>") >= 0) {
window.location.href = "<%=mySiteURL%>?"+base64attr+"="+ base64hashtag;
}
else {
//this is when you are in a VRE and you want to search in that VRE, count the slashes to get where to point
//you always want to point to /group/vrename
var newhref = window.location.href;
if (window.location.href.indexOf("?") >= 0) {
newhref = window.location.href.split("?")[0];
}
var count = newhref.split("/").length-1;
if (count > 4)
window.location.href = newhref + "/../?"+base64attr+"="+ base64hashtag;
else
window.location.href = newhref + "?"+base64attr+"="+ base64hashtag;
}
}
}
});
$('#searchbox').keyup(function(e){
if(e.keyCode == 13)
{
$(this).trigger("enterKey");
}
});
//remove placeholder text on click
$('#searchbox').click(function() {
$('#searchbox').attr("placeholder", "");
});
$('#searchbox-phone').keyup(function(e){
if(e.keyCode == 13)
{
$(this).trigger("enterKey");
}
});
//remove placeholder text on click
$('#searchbox-phone').click(function() {
$('#searchbox-phone').attr("placeholder", "");
});
//shows the search textbox
$('#searchIcon').click(function() {
$('#searchbox').show();
$('#searchIcon').hide();
$("#searchbox").focus();
});
//search box keyboard handlers
$('#searchbox-phone').bind("enterKey",function(e){
if ($('#searchbox-phone').val() != "") {
if ($('#searchbox-phone').val().indexOf("#") == 0) {
if ($('#searchbox-phone').val().indexOf(" ") >= 0) {
alert('Sorry, spaces not allowed when searching for topics!');
return;
}
var base64hashtag = btoa($('#searchbox-phone').val());
var base64attr = btoa("hashtagIdentificationParameter");
if (window.location.href.indexOf("<%=mySiteURL%>") >= 0) {
window.location.href = "<%=mySiteURL%>?"+base64attr+"="+ base64hashtag;
}
else {
//this is when you are in a VRE and you want to search in that VRE, count the slashes to get where to point
//you always want to point to /group/vrename
var newhref = window.location.href;
if (window.location.href.indexOf("?") >= 0) {
newhref = window.location.href.split("?")[0];
}
var count = newhref.split("/").length-1;
if (count > 4)
window.location.href = newhref + "/../?"+base64attr+"="+ base64hashtag;
else
window.location.href = newhref + "?"+base64attr+"="+ base64hashtag;
}
}
else {
var base64hashtag = btoa($('#searchbox-phone').val());
var base64attr = btoa("elasticSearchIdentificationParameter");
if (window.location.href.indexOf("<%=mySiteURL%>") >= 0) {
window.location.href = "<%=mySiteURL%>?"
+ base64attr
+ "="
+ base64hashtag;
} else {
//this is when you are in a VRE and you want to search in that VRE, count the slashes to get where to point
//you always want to point to /group/vrename
var newhref = window.location.href;
if (window.location.href
.indexOf("?") >= 0) {
newhref = window.location.href
.split("?")[0];
}
var count = newhref
.split("/").length - 1;
if (count > 4)
window.location.href = newhref
+ "/../?"
+ base64attr
+ "="
+ base64hashtag;
else
window.location.href = newhref
+ "?"
+ base64attr
+ "="
+ base64hashtag;
}
}
}
});
});
</script>
<!-- When desktop -->
<div id="custom-dockbar-view-container">
<div class="collapse nav-collapse">
<ul class="nav nav-add-controls">
<li class="dockbar-item"><a class=""
href="<%=mySiteURL%>" id="homeIcon"
title="<%=groupName%> Dashboard"> <i
class="icon-dashboard" style="font-size: 24px;"></i>
</a></li>
<li class="dockbar-item" id="lab-li-sbd" style="display: none;"><a class=""
href="<%=myGatewayURL + "/group/sobigdata-gateway/explore?siteId=20371853"%>" id="labIcon"
alt='Go to Lab' title='SoBigData Lab'> <i class="icon-beaker"
style="font-size: 24px;"></i>
</a></li>
<li class="dockbar-item"><a class=""
href="<%=mySiteURL+ GCubePortalConstants.USER_WORKSPACE_FRIENDLY_URL%>" id="wsIcon"
alt='Workspace' title='Workspace'> <i
class="icon-folder-open" style="font-size: 24px;"></i>
</a></li>
<li class="dockbar-item"><a class=""
href="<%=mySiteURL + GCubePortalConstants.CATALOGUE_FRIENDLY_URL%>" id="catalougueIcon"
alt='See Data Catalogue' title='Catalogue'> <i
class="icon-book" style="font-size: 24px;"></i>
</a></li>
<li class="dockbar-item"><a class=""
href="<%=mySiteURL + GCubePortalConstants.USER_MESSAGES_FRIENDLY_URL%>" id="messagesIcon"
alt='See Messages' title='Messages'> <i class="icon-envelope"
style="font-size: 24px;"></i>
</a></li>
<li href="#" class="dockbar-item"><a class="" id="searchIcon"
alt='Search News Feed' title='Search'> <i class="icon-search"
style="font-size: 24px;"></i>
</a></li>
</ul>
</div>
<div class="collapse nav-collapse">
<ul class="nav nav-add-controls">
<li class="dockbar-item"><input style="display: none;" id="searchbox" type="text"
placeholder="Search News Feed"></li>
</ul>
</div>
<!-- When phone or tablet -->
<span><a class="btn btn-navbar"
href="<%=mySiteURL%>" id="homeIcon"
title="<%=groupName%> Infrastructure Gateway Home"> <i
class="icon-home" style="font-size: 24px;"></i>
</a>
</span>
<span> <a class="btn btn-navbar"
href="<%=mySiteURL + GCubePortalConstants.USER_WORKSPACE_FRIENDLY_URL%>" id="wsIcon"
alt='Workspace' title='Virtual Workspace'> <i
class="icon-folder-open" style="font-size: 24px;"></i>
</a>
</span>
<span> <a class="btn btn-navbar"
href="<%=mySiteURL + GCubePortalConstants.CATALOGUE_FRIENDLY_URL%>" id="catalougueIcon"
alt='See Data Catalogue' title='Data Catalogue'> <i class="icon-book"
style="font-size: 24px;"></i>
</a>
<span> <a class="btn btn-navbar"
href="<%=mySiteURL + GCubePortalConstants.USER_MESSAGES_FRIENDLY_URL%>" id="messagesIcon"
alt='See Messages' title='Messages'> <i class="icon-envelope"
style="font-size: 24px;"></i>
</a>
</span>
<span id="lab-li-sbd" style="display: none;"> <a class="btn btn-navbar"
href="<%=myGatewayURL + "/group/sobigdatalab"%>" id="labIcon"
alt='SoBigData Lab' title='SoBigData Lab'> <i class="icon-beaker"
style="font-size: 24px;"></i>
</a>
</span>
<c:choose>
<c:when test="<%=themeDisplay.isShowControlPanelIcon()%>">
<!-- <span class="btn btn-navbar"> <input id="searchbox-phone" -->
<!-- type="text" style="width: 70px;" placeholder="Search ..."> -->
<!-- </span> -->
</c:when>
<c:otherwise>
<!-- <span class="btn btn-navbar"> <input id="searchbox-phone" -->
<!-- type="text" placeholder="Search News Feed"> -->
<!-- </span> -->
</c:otherwise>
</c:choose>
</div>
<!-- End When phone or tablet -->
<% } %>