Office add-in collaboration updates

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7512 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mike Hatfield
2007-12-03 21:27:46 +00:00
parent 7219be39f2
commit 661f9fb4ec
33 changed files with 1169 additions and 233 deletions

View File

@@ -0,0 +1,108 @@
/*
* Prerequisites: mootools.v1.11.js
* office_addin.js
*/
var OfficeDocDetails =
{
init: function()
{
OfficeDocDetails.setupTabs();
OfficeDocDetails.setupTags();
},
setupTabs: function()
{
var tabs = $$('.tabBarInline li');
var tablinks = $$('.tabBarInline li a');
var panels = $$('.tabPanel');
tabs.each(function(tab, i)
{
// register 'click' event for each tab
tablinks[i].addEvent('click', function(e)
{
// highlight the current tab
tab.addClass('current');
// show the tab panel
panels[i].removeClass('tabPanelHidden');
// reset styles on all closed tasks
tabs.each(function(otherTab, j)
{
if (otherTab != tab)
{
// reset selected class
otherTab.removeClass('current');
// hide the tab panel
panels[j].addClass('tabPanelHidden');
}
});
});
});
},
setupTags: function()
{
var tags = $$('#panelTags .tagName');
tags.each(function(tag, i)
{
tag.addEvent('click', function(e)
{
window.location.href = window.serviceContextPath + "/office/tags?p=" + window.queryObject.p + "&tag=" + tag.innerHTML;
});
});
},
showAddTagForm: function()
{
$("addTagLinkContainer").setStyle("display", "none");
$("addTagFormContainer").setStyle("display", "block");
$("addTagBox").focus();
},
hideAddTagForm: function()
{
$("addTagFormContainer").setStyle("display", "none");
$("addTagLinkContainer").setStyle("display", "block");
return false;
},
addTag: function(nodeId, tagName)
{
OfficeAddin.postAction(window.serviceContextPath + "/collaboration/tagActions", "add", nodeId, null, "&t=" + tagName);
return false;
},
tagAction: function(action, nodeId, tagName, msg)
{
if (msg != "" && !confirm(msg))
{
return;
}
OfficeAddin.showStatusText("Processing...", "ajax_anim.gif", false);
var actionURL = window.serviceContextPath + "/collaboration/tagActions?a=" + action + "&n=" + nodeId + "&t=" + tagName;
var myAjax = new Ajax(actionURL, {
method: 'post',
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'},
onComplete: function(textResponse, xmlResponse)
{
// Optionally add a status string
if (textResponse != "")
{
var objResponse = Json.evaluate(textResponse);
var imgSuccess = (objResponse.statusCode ? "action_successful.gif" : "action_failed.gif");
var colBackground = (objResponse.statusCode ? "#50ff50" : "#ff5050");
OfficeAddin.showStatusText(objResponse.statusString, imgSuccess, true, colBackground);
}
},
onFailure: function()
{
OfficeAddin.showStatusText("Action failed", "action_failed.gif", true);
}
}).request();
}
};
window.addEvent('domready', OfficeDocDetails.init);

View File

@@ -113,8 +113,7 @@ var OfficeMyTasks =
OfficeAddin.hideStatusText();
$("taskDetails").innerHTML = textResponse;
}
});
myAjax.request();
}).request();
// close other open tasks
tasks.each(function(otherTask, j)
@@ -180,8 +179,7 @@ var OfficeMyTasks =
{
OfficeAddin.showStatusText("Couldn't run workflow", "action_failed.gif", true);
}
});
myAjax.request();
}).request();
},
startWorkflow: function(commandURL, Doc)
@@ -229,18 +227,18 @@ var OfficeMyTasks =
},
/* AJAX call to perform server-side actions */
runAction: function(useTemplate, Action, Doc, Msg)
runAction: function(useTemplate, action, nodeId, confirmMsg)
{
// Re-select a selected task after reload
var taskSel = $E('#taskList .taskItemSelected');
var extraParams = "";
var outParams = null;
if (taskSel != null)
{
var taskId = taskSel.id;
extraParams = "t=" + encodeURI(taskId);
outParams = "t=" + encodeURI(taskId);
}
OfficeAddin.runAction(useTemplate, Action, Doc, Msg, extraParams);
return OfficeAddin.getAction(useTemplate, action, nodeId, confirmMsg, null, outParams);
},
refreshPage: function()

View File

@@ -91,17 +91,32 @@ var OfficeAddin =
},
/* AJAX call to perform server-side actions */
runAction: function(useTemplate, Action, Doc, Msg, extraParams)
getAction: function(useTemplate, action, nodeId, confirmMsg, inParams, outParams)
{
if (Msg != "" && !confirm(Msg))
return OfficeAddin.runAction("get", useTemplate, action, nodeId, confirmMsg, inParams, outParams)
},
postAction: function(useTemplate, action, nodeId, confirmMsg, inParams, outParams)
{
return OfficeAddin.runAction("post", useTemplate, action, nodeId, confirmMsg, inParams, outParams)
},
runAction: function(httpMethod, useTemplate, action, nodeId, confirmMsg, inParams, outParams)
{
if ((confirmMsg != null) && (confirmMsg != ""))
{
return;
if (!confirm(confirmMsg))
{
return;
}
}
OfficeAddin.showStatusText("Running action...", "ajax_anim.gif", false);
var actionURL = useTemplate + "?a=" + Action + "&d=" + Doc;
var actionURL = useTemplate + "?a=" + action + "&n=" + nodeId;
if ((inParams != null) && (inParams != ""))
{
actionURL += "&" + inParams;
}
var myAjax = new Ajax(actionURL, {
method: 'get',
method: httpMethod,
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'},
onComplete: function(textResponse, xmlResponse)
{
@@ -114,12 +129,14 @@ var OfficeAddin =
{
href += (href.indexOf("?") == -1) ? "?" : "&";
href += "st=" + encodeURI(textResponse);
href += "&" + extraParams;
if ((outParams != null) && (outParams != ""))
{
href += "&" + outParams;
}
}
window.location.href = href;
}
});
myAjax.request();
}).request();
},
/* Calculates and returns the context path for the current page */

View File

@@ -0,0 +1,115 @@
/*
* Prerequisites: mootools.v1.11.js
* office_addin.js
*/
var OfficeTags =
{
/* Scaling for tag clouds - must have supporting CSS classes defined */
SCALE_FACTOR: 5,
/* Manadatory params for searchResults component */
searchParams: "",
init: function()
{
OfficeTags.getTagCloud();
},
setParams: function(params)
{
OfficeTags.searchParams = params;
},
getTagCloud: function()
{
OfficeAddin.showStatusText("Loading tag cloud...", "ajax_anim.gif", false);
// ajax call to get repository tag data
var actionURL = window.serviceContextPath + "/collaboration/tagQuery";
var myJsonRequest = new Json.Remote(actionURL, {
method: 'get',
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'},
onComplete: function(tagQuery)
{
OfficeAddin.hideStatusText();
OfficeTags.populateTagCloud(tagQuery);
}
}).send();
},
populateTagCloud: function(tagQuery)
{
var tagCloud = $("tagCloud");
var range = tagQuery.countMax - tagQuery.countMin;
var scale = (range / OfficeTags.SCALE_FACTOR);
var tagContainer, tagName, tagNameClass, tagCount;
tagCloud.empty();
tagQuery.tags.each(function(tag, i)
{
tagNameClass = "tagName" + Math.round((tag.count - tagQuery.countMin) / scale);
tagName = new Element("a", {"class": tagNameClass});
tagName.appendText(tag.name);
tagName.injectInside(tagCloud);
tagName.addEvent('click', function(e)
{
OfficeTags.selectTag(tag.name);
});
tagCloud.appendText(" ");
tagCount = new Element("span", {"class": "tagCount"});
tagCount.appendText("(" + tag.count + ")");
tagCount.injectInside(tagName);
});
// $("tagCloud").innerHTML = Json.toString(tagQuery);
},
/* AJAX call to perform server-side tag search */
selectTag: function(tagName)
{
OfficeAddin.showStatusText("Searching tags...", "ajax_anim.gif", false);
// var maxResults = $('maxResults').value;
var maxResults = 100;
var args = OfficeTags.searchParams + "&type=tag";
var actionURL = window.serviceContextPath + "/office/searchResults?p=" + args + "&search=" + tagName.replace(" ", "_x0020_") + "&maxresults=" + maxResults;
var myAjax = new Ajax(actionURL, {
method: 'get',
headers: {'If-Modified-Since': 'Sat, 1 Jan 2000 00:00:00 GMT'},
evalScripts: true,
onComplete: function(textResponse, xmlResponse)
{
OfficeAddin.hideStatusText();
$('taggedList').innerHTML = textResponse;
$('taggedHeader').innerHTML = "Tagged with \"" + tagName + "\"";
}
}).request();
}
};
/* Search Results expects this class */
var OfficeSearch =
{
itemsFound: function(shownResults, totalResults)
{
var strFound;
if (totalResults == 0)
{
strFound = "No items found";
}
else if (shownResults < totalResults)
{
strFound = "Showing first " + shownResults + " of " + totalResults + " total items found";
}
else
{
strFound = "Showing all " + shownResults + " items found";
}
$('itemsFound').innerHTML = strFound;
}
};
window.addEvent('domready', OfficeTags.init);