mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged from BRANCHES/DEV/KEVINR:
. NodeInfo panel and Ajax client library - Rewrite of Node Info panel - Alfresco common DOM methods refactored into namespaced object (YUI/Dojo style) Alfresco.Dom - Addition of useful DOM and 'smart' alignment method to common.js - OpenSearch now uses additional namespace for it's global method handlers: Alfresco.OpenSearchEngine - Temporary icons added for pop-up node info panel . Additional FreeMarker model API method "cropContent(contentprop, length)" to return the first N bytes of a content stream - auto converted to plain/text from all supported transformation mimetypes . DownloadContentServlet now handles ContentIOException more gracefully . AbstractContentReader fixed to handle empty file data when requesting N characters from a content stream . Yahoo scripts move to PageTag rendering as appropriate . Refactoring of existing ajax components that output Yahoo scripts git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5253 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,75 +1,189 @@
|
||||
//
|
||||
// Supporting JavaScript for the NodeInfo component
|
||||
// Gavin Cornwell 17-07-2006
|
||||
// Kevin Roast 21-02-2007 (rewrite to use individual panel objects and convert to YUI)
|
||||
//
|
||||
// NOTE: This script relies on common.js so therefore needs to be loaded
|
||||
// NOTE: This script requires common.js - which needs to be loaded
|
||||
// prior to this one on the containing HTML page.
|
||||
|
||||
var _launchElement = null;
|
||||
var _popupElement = null;
|
||||
|
||||
/**
|
||||
* Makes the AJAX request back to the server to get the node info.
|
||||
*
|
||||
* @param nodeRef The node reference to get information for
|
||||
* @param launchElement The element that requested the summary panel
|
||||
* Node Info Manager constructor
|
||||
*/
|
||||
function showNodeInfo(nodeRef, launchElement)
|
||||
Alfresco.NodeInfoManager = function()
|
||||
{
|
||||
_launchElement = launchElement;
|
||||
|
||||
dojo.io.bind({
|
||||
method: 'post',
|
||||
url: getContextPath() + '/ajax/invoke/NodeInfoBean.sendNodeInfo',
|
||||
content: { noderef: nodeRef },
|
||||
load: showNodeInfoHandler,
|
||||
error: handleErrorDojo,
|
||||
mimetype: 'text/html'
|
||||
});
|
||||
//YAHOO.util.Event.addListener(window, "resize", this.resize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fades in the summary panel containing the node information.
|
||||
* This function is called back via the dojo bind call above.
|
||||
* Definition of the Node Info Manager class.
|
||||
* Responsible for open/closing NodeInfoPanel dynamic summary panel objects.
|
||||
*/
|
||||
function showNodeInfoHandler(type, data, evt)
|
||||
Alfresco.NodeInfoManager.prototype =
|
||||
{
|
||||
// create a 'div' to hold the summary table
|
||||
var div = document.createElement("div");
|
||||
panels: [],
|
||||
displayed: [],
|
||||
|
||||
// get the position of the element we are showing info for
|
||||
var pos = dojo.html.getAbsolutePosition(_launchElement, false);
|
||||
|
||||
// setup the div with the correct appearance
|
||||
div.innerHTML = data;
|
||||
div.setAttribute("class", "summaryPopupPanel");
|
||||
// NOTE: use className for IE
|
||||
div.setAttribute("className", "summaryPopupPanel");
|
||||
div.style.position = "absolute";
|
||||
div.style.left = pos[0];
|
||||
div.style.top = pos[1] + 16;
|
||||
div.style.zIndex = 99;
|
||||
|
||||
// is there a better way of doing this, dojo.dom.insertBefore??
|
||||
var body = document.getElementsByTagName("body")[0];
|
||||
dojo.html.setOpacity(div, 0);
|
||||
_popupElement = div;
|
||||
body.appendChild(div);
|
||||
|
||||
dojo.lfx.html.fadeIn(div, 300).play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fades out the summary panel with the node info
|
||||
* and then removes it from the DOM
|
||||
*/
|
||||
function hideNodeInfo()
|
||||
{
|
||||
// remove the node from the DOM and reset variables
|
||||
dojo.lfx.html.fadeOut(_popupElement, 300, dojo.lfx.easeOut, function(nodes)
|
||||
/**
|
||||
* Request toggle of the open/close state of a node info panel
|
||||
*/
|
||||
toggle: function(nodeRef, launchElement)
|
||||
{
|
||||
dojo.lang.forEach(nodes, dojo.dom.removeNode);
|
||||
_popupElement = null;
|
||||
_launchElement = null;
|
||||
}).play();
|
||||
if (this.displayed[nodeRef] == undefined || this.displayed[nodeRef] == null)
|
||||
{
|
||||
var panel = this.panels[nodeRef];
|
||||
if (panel == undefined || panel == null)
|
||||
{
|
||||
panel = new Alfresco.NodeInfoPanel(nodeRef, launchElement);
|
||||
this.panels[nodeRef] = panel;
|
||||
}
|
||||
this.displayed[nodeRef] = true;
|
||||
panel.showNodeInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.close(nodeRef);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Request a Close of the node info panel
|
||||
*/
|
||||
close: function(nodeRef)
|
||||
{
|
||||
var panel = this.panels[nodeRef];
|
||||
if (panel != undefined && panel != null)
|
||||
{
|
||||
this.displayed[nodeRef] = null;
|
||||
panel.hideNodeInfo();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return if a given node info panel is currently displayable
|
||||
*/
|
||||
displayable: function(nodeRef)
|
||||
{
|
||||
return (this.displayed[nodeRef] != undefined && this.displayed[nodeRef] != null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the single Node Info Manager instance
|
||||
*/
|
||||
var AlfNodeInfoMgr = new Alfresco.NodeInfoManager();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the Node Info Panel object
|
||||
*/
|
||||
Alfresco.NodeInfoPanel = function(nodeRef, launchElement)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
this.launchElement = launchElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Definition of the Node Info Panel object
|
||||
*/
|
||||
Alfresco.NodeInfoPanel.prototype =
|
||||
{
|
||||
nodeRef: null,
|
||||
launchElement: null,
|
||||
popupElement: null,
|
||||
visible: false,
|
||||
|
||||
/**
|
||||
* Makes the AJAX request back to the server to get the node info.
|
||||
*/
|
||||
showNodeInfo: function()
|
||||
{
|
||||
if (this.popupElement == null)
|
||||
{
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
"POST",
|
||||
getContextPath() + '/ajax/invoke/NodeInfoBean.sendNodeInfo',
|
||||
{
|
||||
success: this.loadNodeInfoHandler,
|
||||
failure: handleErrorYahoo, // global error handler
|
||||
argument: [this.nodeRef, this]
|
||||
},
|
||||
"noderef=" + this.nodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.displayNodeInfo();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback function for showNodeInfo() above
|
||||
*/
|
||||
loadNodeInfoHandler: function(response)
|
||||
{
|
||||
var panel = response.argument[1];
|
||||
|
||||
// create a 'div' to hold the summary table
|
||||
var div = document.createElement("div");
|
||||
|
||||
// setup the div with the correct appearance
|
||||
div.innerHTML = response.responseText;
|
||||
div.setAttribute("class", "summaryPopupPanel");
|
||||
// NOTE: use className for IE
|
||||
div.setAttribute("className", "summaryPopupPanel");
|
||||
div.style.position = "absolute";
|
||||
div.style.zIndex = 99;
|
||||
div.style.display = "none";
|
||||
div.style.left = 0;
|
||||
div.style.top = 0;
|
||||
|
||||
var body = document.getElementsByTagName("body")[0];
|
||||
body.appendChild(div);
|
||||
|
||||
// keep track of the div element we created
|
||||
panel.popupElement = div;
|
||||
|
||||
// display the div for the first time
|
||||
panel.displayNodeInfo();
|
||||
},
|
||||
|
||||
/**
|
||||
* Display the summary info panel for the node
|
||||
*/
|
||||
displayNodeInfo: function()
|
||||
{
|
||||
if (AlfNodeInfoMgr.displayable(this.nodeRef) == true)
|
||||
{
|
||||
if (this.popupElement != null && this.visible == false)
|
||||
{
|
||||
// set opacity in browser independant way
|
||||
YAHOO.util.Dom.setStyle(this.popupElement, "opacity", 0.0);
|
||||
this.popupElement.style.display = "block";
|
||||
|
||||
Alfresco.Dom.smartAlignElement(this.popupElement, this.launchElement, 700);
|
||||
|
||||
var anim = new YAHOO.util.Anim(
|
||||
this.popupElement, { opacity: { to: 1.0 } }, 0.333, YAHOO.util.Easing.easeOut);
|
||||
anim.animate();
|
||||
|
||||
// drag-drop object
|
||||
new YAHOO.util.DD(this.popupElement);
|
||||
|
||||
this.visible = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide the summary info panel for the node
|
||||
*/
|
||||
hideNodeInfo: function()
|
||||
{
|
||||
if (this.popupElement != null && this.visible == true)
|
||||
{
|
||||
this.visible = false;
|
||||
|
||||
YAHOO.util.Dom.setStyle(this.popupElement, "opacity", 0.0);
|
||||
this.popupElement.style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user