A bunch of changes like

1) Freemarker versions of Co-PI visualizations. CoInvestigator.ftl, CoPIPersonLevel.ftl, person_level_fm-copi.js.
2) Styling changes to Temporal graph.
3) Adding co_author, co_pi and temporal graph icons.
4) ftls related to sparklines. (CoAuthorship and CoPI)
5) Styling changes to CoAuthor/CoPI visualizations -- page.css, coauthor_style.css, coinvestigator_style.css
This commit is contained in:
bkoniden 2011-01-03 22:47:34 +00:00
parent 8dc99312c7
commit c74821f302
34 changed files with 1358 additions and 479 deletions

View file

@ -69,6 +69,9 @@ var FlotOptions = {
tickSize : 1,
tickDecimals : 0,
min : 0
},
grid : {
borderColor : "#D9D9D9"
}
};

View file

@ -15,6 +15,8 @@ function init(graphContainer) {
// TODO: make use of the id on the select field instead of a generic one.
$("#comparisonParameter").text("Total Number of " + $("select.comparisonValues option:selected").val());
$('#yaxislabel').html("Number of " + optionSelected).mbFlipText(false);
$('#comparisonHeader').html(optionSelected).css('font-weight', 'bold');
var defaultFlotOptions = {
xaxis : {
@ -27,7 +29,11 @@ function init(graphContainer) {
tickDecimals : 0,
min : 0,
max: 5
},
grid: {
borderColor : "#D9D9D9"
}
};
/*
@ -538,7 +544,8 @@ function generateBarAndLabel(entity, divBar, divLabel,checkbox, spanElement){
//append a div and modify its css
divBar.css("background-color", colorToAssign);
divBar.css("width", normalizedWidth);
divLabel.children("a#entityURL").html(checkboxValue + " ");
divLabel.children("a#entityURL").html(checkboxValue + " ").css("color", "#333");
// divLabel.children("a#entityURL").css("color", "#333").css("text-decoration", none);
divLabel.children("a#entityURL").autoEllipsis();
createVIVOProfileImage(divLabel.children("a#vivoURL"));
divLabel.children("a").css("font-size", "0.8em");
@ -551,8 +558,8 @@ function createVIVOProfileImage(url){
var vivoImage = $(url);
vivoImage.html("VIVO");
vivoImage.css("background-color","#212D34" );
vivoImage.html("profile");
vivoImage.css("background-color","#727272" );
vivoImage.css("color", "white");
vivoImage.css("padding", "2px");
}
@ -695,6 +702,7 @@ function prepareTableForDataTablePagination(jsonData){
table.attr('cellspacing', '0');
table.attr('border', '0');
table.attr('id', 'datatable');
table.css('font-size', '0.9em');
var thead = $('<thead>');
var tr = $('<tr>');
@ -730,7 +738,9 @@ function prepareTableForDataTablePagination(jsonData){
checkboxTD.html('<input type="checkbox" class="if_clicked_on_school" value="' + index + '"'+'/>');
var labelTD = $('<td>');
labelTD.css("width", "100px");
labelTD.html(index);
// labelTD.autoEllipsis();
var publicationCountTD = $('<td>');
publicationCountTD.html(calcSumOfComparisonParameter(val));
@ -754,11 +764,11 @@ function prepareTableForDataTablePagination(jsonData){
tableDiv.append(table);
$('#datatable').dataTable({
"sDom": '<"searchbar"f><"paginatedtabs"p><"datatablewrapper"t><"showentries"l>',
"sDom": '<"searchbar"f><"paginatedtabs"p><"datatablewrapper"t>',
"aaSorting" : [[2, "desc"]],
"iDisplayLength": 10,
"sPaginationType": "full_numbers",
"aLengthMenu" : [5,10,15],
// "aLengthMenu" : [5,10,15],
"fnDrawCallback": function() {
$('tr>td:nth-child(1)>input').bind('click', function () { $(this).parent().parent().children().each(function(){$(this).addClass('datatablerowhighlight');}); });
$('tr>td:nth-child(1)>input').bind('click', function () { if(!$(this).is(':checked')) { $(this).parent().parent().children().each(function(){$(this).removeClass('datatablerowhighlight');});} });
@ -776,7 +786,7 @@ function prepareTableForDataTablePagination(jsonData){
function bindPaginatedTabsToEvents(){
$('#datatable_paginate>span').bind('click', function(){
console.log($(this));
//console.log($(this));
checkIfColorLimitIsReached();
// bindInnerPaginatedTabsToEvents();
// $.each($('#datatable_paginate>span>span'), function(index, val){
@ -820,6 +830,7 @@ function removeStopWords(val){
function setEntityLevel(){
$('#entitylevelheading').text(' - ' + toCamelCase(entityLevel) + ' Level').css('font-style', 'italic');
$('#entityleveltext').text(' ' + entityLevel.toLowerCase() + 's ').css('font-style', 'italic');
$('#entityHeader').text(toCamelCase(entityLevel)).css('font-weight', 'bold');
}
function getEntityVisMode(jsonData){
@ -899,142 +910,3 @@ function setTickSizeOfAxes(){
setLineWidthAndTickSize(yearRange, FlotOptions);
setTickSizeOfYAxis(calcMaxWithinComparisonParameter(checkedLabelToEntityRecord), FlotOptions);
}
//function sortByEntityLabelDesc(value1, value2){
//
//var result;
//
//if(value1 > value2){
// result = -1;
//}else if(value1 < value2){
// result = 1;
// }else {
// result = 0;
// }
//return result;
//}
//
//function sortByEntityLabelAsc(value1, value2){
//
//var result;
//
//if (value1 > value2) {
// result = 1;
//} else if(value1 < value2) {
// result = -1;
// } else {
// result = 0;
// }
//return result;
//}
//function renderPaginatedDiv(){
//
////$("#entityTitleSortBy").trigger('click', "azdesc");
//paginationDiv.pagination(setOfLabels.length, paginationOptions);
//}
//
//jQuery.fn.liveUpdate = function(list){
//
// list = jQuery(list);
//
// if ( list.length ) {
// var rows = list.children('li');
// var cache = rows.map(function(){
// // console.log($(this).children('a').text().toLowerCase());
// return $(this).children('a').text().toLowerCase();
// });
//
// //console.log("rows: ", rows , " cache: ", cache);
//
// this.keyup(filter).keyup().parents('form').submit(function(){
// return false;
// });
// }
//
// return this;
//
// function filter(){
//
// var term = jQuery.trim( jQuery(this).val().toLowerCase() ), scores = [];
// //console.log("this: ",this, " term: " +term);
//
// if ( !term ) {
// rows.show();
// } else {
// rows.hide();
// cache.each(function(i){
// var score = this.score(term);
// if (score > 0) {
// scores.push([score, i]);
// }
// });
//
// jQuery.each(scores.sort(function(a, b){return b[0] - a[0];}), function(){
// jQuery(rows[ this[1] ]).show();
// //console.log("showing : ", ($(rows[this[1]]).children('a').text()));
// });
// }
// }
//};
//function sortByParameterDesc(value1, value2){
//var entity1 = labelToEntityRecord[value1];
//var entity2 = labelToEntityRecord[value2];
//
//var sum1 = calcSumOfComparisonParameter(entity1);
//var sum2 = calcSumOfComparisonParameter(entity2);
//
//return (sum2 - sum1);
//}
//
//function sortByParameterAsc(value1, value2){
//var entity1 = labelToEntityRecord[value1];
//var entity2 = labelToEntityRecord[value2];
//
//var sum1 = calcSumOfComparisonParameter(entity1);
//var sum2 = calcSumOfComparisonParameter(entity2);
//
//return (sum1 - sum2);
//}
//
//function createCheckBoxesInsidePaginatedDiv(pageIndex){
//
//var highestIndexInPage = Math.min((pageIndex + 1) * paginationOptions.items_per_page, setOfLabels.length);
//var newContent = ' ';
//
///*
// * Iterate through the list of school setOfLabels and build an HTML string
// * Also check if some of the checkboxes are previously checked? If they are checked,
// * then they should be on this time too!
// */
//for (var i = pageIndex * paginationOptions.items_per_page; i < highestIndexInPage; i++) {
// var checkedFlag = ' ', j = 0, fontWeight = ' ';
// $.each(renderedObjects, function(){
// if (renderedObjects[j].label == setOfLabels[i]) {
// checkedFlag = "checked";
// fontWeight = " style='font-weight:bold;' ";
// }
// j++;
// });
// newContent += '<li><input type = "checkbox" class="if_clicked_on_school" value="' + setOfLabels[i] + '"' + checkedFlag + ' ' + '><a href="" ' + fontWeight + ' >' + setOfLabels[i] + '<\/a><\/li>';
//}
//
//// replace old content with new content
//$('#searchresult').html(newContent);
//populateMapOfCheckedEntities();
//
//}
//function populateMapOfCheckedEntities(){
////console.log('populating checked entities');
//
////var checkedEntities = $("input[type=checkbox].if_clicked_on_school");
////$.each(checkedEntities, function(index, val){
//// labelToCheckedEntities[$(val).attr("value")] = val;
//// console.log('checked ', $(val).attr("value"));
////});
//
//$.each(labelToCheckedEntities, function(index, val){
//// labelToCheckedEntities[$(val).attr("value")] = val;
// //console.log('checked ', $(val).attr("value"));
//});
//}

View file

@ -0,0 +1,449 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
function getWellFormedURLs(given_uri, type) {
if (!given_uri || given_uri == "") {
return;
}
// general best practice is to put javascript code inside document.ready
// but in this case when i do that the function does not get called
// properly.
// so removing it for now.
// $(document).ready(function() {
var finalURL;
if (type == "coauthorship") {
finalURL = $.ajax({
url: contextPath + "/visualizationAjax",
data: ({vis: "utilities", vis_mode: "PERSON_LEVEL_URL", uri: given_uri}),
dataType: "text",
async: false,
success:function(data){
}
}).responseText;
return finalURL;
} else if (type == "coinvestigation") {
finalURL = $.ajax({
url: contextPath + "/visualizationAjax",
data: ({vis: "utilities", vis_mode: "COPI_URL", uri: given_uri}),
dataType: "text",
async: false,
success:function(data){
}
}).responseText;
return finalURL;
}else if (type == "profile") {
finalURL = $.ajax({
url: contextPath + "/visualizationAjax",
data: ({vis: "utilities", vis_mode: "PROFILE_URL", uri: given_uri}),
dataType: "text",
async: false,
success:function(data){
}
}).responseText;
return finalURL;
} else if (type == "image") {
finalURL = $.ajax({
url: contextPath + "/visualizationAjax",
data: ({vis: "utilities", vis_mode: "IMAGE_URL", uri: given_uri}),
dataType: "text",
async: false,
success:function(data){
}
}).responseText;
return finalURL;
} else if (type == "profile_info") {
var profileInfoJSON = $.ajax({
url: contextPath + "/visualizationAjax",
data: ({vis: "utilities", vis_mode: "PROFILE_INFO", uri: given_uri}),
dataType: "json",
async: false,
success:function(data){
}
}).responseText;
return profileInfoJSON;
}
}
$.fn.image = function(src, successFunc, failureFunc){
return this.each(function(){
var profileImage = new Image();
profileImage.onerror = failureFunc;
profileImage.onload = successFunc;
profileImage.src = src;
return profileImage;
});
};
function setProfileImage(imageContainerID, mainImageURL) {
if (imageContainerID == "") {
return;
}
if (!mainImageURL || mainImageURL == "") {
$("#" + imageContainerID).empty();
return;
}
var rawPath = getWellFormedURLs(mainImageURL, "image");
var imageLink = contextPath + rawPath;
var imageContainer = $("#" + imageContainerID);
imageContainer.image(imageLink,
function(){
imageContainer.empty().append(this);
},
function(){
// For performing any action on failure to
// find the image.
imageContainer.empty();
}
);
}
function setProfileMoniker(monikerContainerID, moniker, doEllipsis) {
if (monikerContainerID == "") {
return;
}
if (!moniker) {
$("#" + monikerContainerID).empty();
return;
}
var finalDisplayMoniker;
if (moniker.length > 30 && doEllipsis) {
finalDisplayMoniker = moniker.substr(0,30) + "...";
} else {
finalDisplayMoniker = moniker;
}
$("#" + monikerContainerID).empty().text(finalDisplayMoniker);
$("#" + monikerContainerID).attr('title', moniker);
}
function setProfileName(nameContainerID, name, doNameEllipsis) {
if (nameContainerID == "") {
return;
}
if (!name) {
$("#" + nameContainerID).empty();
return;
}
var finalDisplayName;
if (name.length > 30 && doNameEllipsis) {
finalDisplayName = name.substr(0,30) + "...";
} else {
finalDisplayName = name;
}
$("#" + nameContainerID).empty().text(finalDisplayName);
$("#" + nameContainerID).attr('title', name);
}
function processProfileInformation(nameContainerID,
monikerContainerID,
imageContainerID,
profileInfoJSON,
doMonikerEllipsis,
doNameEllipsis) {
var name, mainImageURL, moniker;
if (jQuery.isEmptyObject(profileInfoJSON)) {
return;
}
$.each(profileInfoJSON, function(key, set){
if (key.search(/mainImage/i) > -1) {
mainImageURL = set[0];
} else if (key.search(/moniker/i) > -1) {
moniker = set[0];
} else if (key.search(/label/i) > -1) {
name = set[0];
}
});
setProfileName(nameContainerID, name, doNameEllipsis);
setProfileMoniker(monikerContainerID, moniker, doMonikerEllipsis);
setProfileImage(imageContainerID, mainImageURL);
}
function visLoaded(nodes){
var jsonedNodes = jQuery.parseJSON(nodes);
var tableID = "";
var tableContainer = "";
tableID = "coinvestigations_table";
tableContainer = "coinve_table_container";
$(document).ready(function() {
createTable("coinvestigations_table" , "coinve_table_container" , jsonedNodes.slice(1));
});
}
function createTable(tableID, tableContainer, tableData) {
var number_of_works = "";
var tableCaption = "";
var tableColumnTitle1 = "";
var tableColumnTitle2 = "";
tableCaption = "Co-investigators ";
tableColumnTitle1 = "Investigator";
tableColumnTitle2 = "Grants with <br />";
var table = $('<table>');
table.attr('id', tableID);
table.append($('<caption>').html(tableCaption + "<a href=\"" + egoCoInvestigatorsListDataFileURL + "\">(.CSV File)</a>"));
var header = $('<thead>');
var row = $('<tr>');
var investigatorTH = $('<th>');
investigatorTH.html(tableColumnTitle1);
row.append(investigatorTH);
row.append($('<th>').html(tableColumnTitle2 + "" + $('#ego_label').text()));
header.append(row);
table.append(header);
$.each(tableData, function(i, item){
number_of_works = item.number_of_investigated_grants;
var row = $('<tr>');
row.append($('<td>').html(item.label));
row.append($('<td>').html(number_of_works));
table.append(row);
});
table.prependTo('#' + tableContainer);
$('#' + tableContainer + " #loadingData").remove();
}
//renderStatsOnNodeClicked, CoRelations, noOfCoRelations
//function nodeClickedJS(json){
function renderStatsOnNodeClicked(json){
//console.log(json);
var obj = jQuery.parseJSON(json);
var works = "";
var persons = "";
var relation = "";
var earliest_work = "";
var latest_work = "";
var number_of_works = "";
works = "Grant(s)";
persons = "Co-investigator(s)";
relation = "coinvestigation";
earliest_work = obj.earliest_grant;
latest_work = obj.latest_grant;
number_of_works = obj.number_of_investigated_grants;
$("#dataPanel").attr("style","visibility:visible");
$("#works").empty().append(number_of_works);
/*
* Here obj.url points to the uri of that individual
*/
if(obj.url){
if (obj.url == egoURI) {
$("#investigatorName").addClass('investigator_name').removeClass('neutral_investigator_name');
$('#num_works > .investigator_stats_text').text(works);
$('#num_investigators > .investigator_stats_text').text(persons);
} else {
$("#investigatorName").addClass('neutral_investigator_name').removeClass('investigator_name');
$('#num_works > .investigator_stats_text').text('Joint ' + works);
$('#num_investigators > .investigator_stats_text').text('Joint ' + persons);
}
$("#profileUrl").attr("href", getWellFormedURLs(obj.url, "profile"));
$("#coInvestigationVisUrl").attr("href", getWellFormedURLs(obj.url, relation));
processProfileInformation("investigatorName",
"profileMoniker",
"profileImage",
jQuery.parseJSON(getWellFormedURLs(obj.url, "profile_info")),
true,
true);
} else{
$("#profileUrl").attr("href","#");
$("#coInvestigationVisUrl").attr("href","#");
}
$("#coInvestigators").empty().append(obj.noOfCorelations);
$("#firstGrant").empty().append(earliest_work);
(earliest_work)?$("#fGrant").attr("style","visibility:visible"):$("#fGrant").attr("style","visibility:hidden");
$("#lastGrant").empty().append(latest_work);
(latest_work)?$("#lGrant").attr("style","visibility:visible"):$("#lGrant").attr("style","visibility:hidden");
// obj.url:the url parameter for node
}
/*
* Inside both of these functions, '&' are replaced with '%26' because we are externally
* passing two parameters to the flash code using flashvars (see renderCoInvestigationVisualization())
* and they are delimited using '&' too.
*/
function getEncodedCoAuthorURL(){
var queryString = "uri="+ egoURI + "&vis=coauthorship";
// console.log('domainParam is '+ domainParam);
// console.log('CoAuthorURL is ' + domainParam + '?' + queryString.replace(/&/g, '%26'));
return domainParam + '?' + queryString.replace(/&/g, '%26');
}
function getEncodedCoPIURL(){
var queryString = "uri="+ egoURI+ "&vis=coprincipalinvestigator";
// console.log('CoPIURL is ' + domainParam + '?' + queryString.replace(/&/g, '%26') );
return domainParam + '?' + queryString.replace(/&/g, '%26');
}
function renderCoInvestigationVisualization() {
var visualization = "";
var encodedURL = "";
visualization = "CoPI";
encodedURL = getEncodedCoPIURL();
// console.log('visualization is ' + visualization + ' and encodedURL is '+ encodedURL);
// Version check for the Flash Player that has the ability to start Player
// Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65);
// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if ( hasProductInstall && !hasRequestedVersion ) {
// DO NOT MODIFY THE FOLLOWING FOUR LINES
// Location visited after installation is complete if installation is
// required
var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
var MMredirectURL = window.location;
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
var MMdoctitle = document.title;
AC_FL_RunContent(
"src", "playerProductInstall",
"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
"width", "800",
"height", "840",
"align", "middle",
"id", "EgoCentric",
"quality", "high",
"bgcolor", "#ffffff",
"name", "EgoCentric",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} else if (hasRequestedVersion) {
// if we've detected an acceptable version
// embed the Flash Content SWF when all tests are passed
//coAuthorUrl=/vivo1/visualization?vis=coauthorship%26render_mode=data%26uri=http%3A%2F%2Fvivo.iu.edu%2Findividual%2FBrnerKaty&labelField=label&coPIUrl=/vivo1/visualization?vis=coprincipalinvestigator%26render_mode=data%26uri=http%3A%2F%2Fvivo.iu.edu%2Findividual%2FBrnerKaty&labelField=label
AC_FL_RunContent(
"src", swfLink,
// "flashVars", 'coAuthorUrl='+ encodeURL(egoCoAuthorshipDataFeederURL) + '&coPIUrl=' + encodeURL(egoCoPIDataFeederURL) ,
// "flashVars", 'coAuthorUrl='+ getEncodedCoAuthorURL() + '&coPIUrl=' + getEncodedCoPIURL() ,
// "flashVars", 'graphmlUrl=' + getEncodedCoAuthorURL() + '&labelField=label&visType=CoAuthor',
"flashVars", 'graphmlUrl=' + encodedURL + '&labelField=label&visType='+visualization,
"width", "600",
"height", "850",
"align", "top",
"id", "EgoCentric",
"quality", "high",
"bgcolor", "#ffffff",
"name", "EgoCentric",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} else { // flash is too old or we can't detect the plugin
var alternateContent = '<br /><h3 style="color: red;">'
+ 'This content requires the Adobe Flash Player. '
+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a></h3>';
document.write(alternateContent); // insert non-flash content
}
}

View file

@ -3,9 +3,10 @@
/* Javascript for sparkline visualization on person profile page */
var visualization = {
render: function(url) {
var containerId = 'vis_container',
container = $('#' + containerId);
renderCoAuthor: function(url) {
var containerIdCoAuthor = 'vis_container_coauthor',
containerCoAuthor = $('#' + containerIdCoAuthor);
//container.empty().html('<img src="${loadingImageLink}" />');
@ -15,17 +16,21 @@ var visualization = {
'render_mode': 'dynamic',
'vis': 'person_pub_count',
'vis_mode': 'short',
'container': containerId
'container': containerIdCoAuthor
},
dataType: 'html',
success:function(data){
container.html(data);
containerCoAuthor.html(data);
containerCoAuthor.children("#pub_count_short_sparkline_vis").append(coAuthorIcon);
/* containerCoAuthor.find("<img>").css("float", "left"); */
}
});
}
};
$(document).ready(function() {
visualizationUrl = visualizationUrl.replace("/visualization", "/visualizationAjax");
visualization.render(visualizationUrl);
visualization.renderCoAuthor(visualizationUrl);
});