diff --git a/source/java/org/alfresco/web/app/servlet/BaseDownloadContentServlet.java b/source/java/org/alfresco/web/app/servlet/BaseDownloadContentServlet.java index e983f7522d..10dc5c152b 100644 --- a/source/java/org/alfresco/web/app/servlet/BaseDownloadContentServlet.java +++ b/source/java/org/alfresco/web/app/servlet/BaseDownloadContentServlet.java @@ -41,6 +41,7 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.filestore.FileContentReader; import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.MimetypeService; @@ -260,17 +261,16 @@ public abstract class BaseDownloadContentServlet extends BaseServlet { reader.getContent( res.getOutputStream() ); } - catch (SocketException e) + catch (SocketException e1) { - if (e.getMessage().contains("ClientAbortException")) - { - // the client cut the connection - our mission was accomplished apart from a little error message - logger.error("Client aborted stream read:\n node: " + nodeRef + "\n content: " + reader); - } - else - { - throw e; - } + // the client cut the connection - our mission was accomplished apart from a little error message + if (logger.isInfoEnabled()) + logger.info("Client aborted stream read:\n\tnode: " + nodeRef + "\n\tcontent: " + reader); + } + catch (ContentIOException e2) + { + if (logger.isInfoEnabled()) + logger.info("Client aborted stream read:\n\tnode: " + nodeRef + "\n\tcontent: " + reader); } } catch (Throwable err) diff --git a/source/java/org/alfresco/web/bean/ajax/NodeInfoBean.java b/source/java/org/alfresco/web/bean/ajax/NodeInfoBean.java index 8be876e2a3..77da10bcae 100644 --- a/source/java/org/alfresco/web/bean/ajax/NodeInfoBean.java +++ b/source/java/org/alfresco/web/bean/ajax/NodeInfoBean.java @@ -25,16 +25,22 @@ package org.alfresco.web.bean.ajax; import java.io.IOException; +import java.util.Date; +import java.util.HashMap; import java.util.Map; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.repo.template.AbsoluteUrlMethod; +import org.alfresco.repo.template.CropContentMethod; +import org.alfresco.repo.template.UrlEncodeMethod; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.web.bean.repository.Node; +import org.alfresco.service.cmr.repository.TemplateImageResolver; +import org.alfresco.service.cmr.repository.TemplateNode; +import org.alfresco.web.bean.repository.Repository; +import org.alfresco.web.ui.common.Utils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -47,7 +53,6 @@ import org.apache.commons.logging.LogFactory; public class NodeInfoBean { private NodeService nodeService; - private ContentService contentService; private static final Log logger = LogFactory.getLog(NodeInfoBean.class); @@ -62,44 +67,17 @@ public class NodeInfoBean FacesContext context = FacesContext.getCurrentInstance(); ResponseWriter out = context.getResponseWriter(); - String nodeRef = (String)context.getExternalContext().getRequestParameterMap().get("noderef"); - - if (nodeRef == null || nodeRef.length() == 0) + String strNodeRef = (String)context.getExternalContext().getRequestParameterMap().get("noderef"); + if (strNodeRef == null || strNodeRef.length() == 0) { throw new IllegalArgumentException("'noderef' parameter is missing"); } - NodeRef repoNode = new NodeRef(nodeRef); - - if (this.nodeService.exists(repoNode)) + NodeRef nodeRef = new NodeRef(strNodeRef); + if (this.nodeService.exists(nodeRef)) { - // get the client side node representation and its properties - Node clientNode = new Node(repoNode); - Map props = clientNode.getProperties(); - - // get the content size - Object content = props.get(ContentModel.PROP_CONTENT); - - // start the containing table - out.write(""); - - // write out information about the node as table rows - out.write(""); - - // add debug information to the summary if debug is enabled - if (logger.isDebugEnabled()) - { - writeRow(out, "Id:", clientNode.getId()); - writeRow(out, "Type:", clientNode.getType().toPrefixString()); - } - - writeRow(out, "Description:", (String)props.get(ContentModel.PROP_DESCRIPTION)); - writeRow(out, "Title:", (String)props.get(ContentModel.PROP_TITLE)); - writeRow(out, "Created:", props.get("created").toString()); - writeRow(out, "Modified:", props.get("modified").toString()); - - // close the
Summary
and
tags - out.write("
"); + Repository.getServiceRegistry(context).getTemplateService().processTemplate( + null, "/alfresco/templates/client/summary_panel.ftl", getModel(nodeRef), out); } else { @@ -107,45 +85,45 @@ public class NodeInfoBean } } + // ------------------------------------------------------------------------------ // Bean getters and setters /** - * @param nodeService The NodeService to set. + * @param nodeService The NodeService to set. */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } // ------------------------------------------------------------------------------ // Helper methods - /** - * Writes a table row with the given data - * - * @param nameColumn The name of the data item - * @param dataColumn The data - */ - protected void writeRow(ResponseWriter out, String nameColumn, String dataColumn) - throws IOException + private Map getModel(NodeRef nodeRef) { - out.write(""); + FacesContext context = FacesContext.getCurrentInstance(); + Map model = new HashMap(7, 1.0f); + + // create api methods + model.put("date", new Date()); + model.put("cropContent", new CropContentMethod()); + model.put("absurl", new AbsoluteUrlMethod(context.getExternalContext().getRequestContextPath())); + model.put("node", new TemplateNode( + nodeRef, + Repository.getServiceRegistry(context), + this.imageResolver)); + + return model; } + + /** Template Image resolver helper */ + private TemplateImageResolver imageResolver = new TemplateImageResolver() + { + public String resolveImagePathForName(String filename, boolean small) + { + return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, small); + } + }; } diff --git a/source/java/org/alfresco/web/ui/common/Utils.java b/source/java/org/alfresco/web/ui/common/Utils.java index 5da545475b..0eb01e30dc 100644 --- a/source/java/org/alfresco/web/ui/common/Utils.java +++ b/source/java/org/alfresco/web/ui/common/Utils.java @@ -96,9 +96,6 @@ public final class Utils private static final String DEFAULT_FILE_IMAGE16 = IMAGE_PREFIX16 + "_default" + IMAGE_POSTFIX; private static final String DEFAULT_FILE_IMAGE32 = IMAGE_PREFIX32 + "_default" + IMAGE_POSTFIX; - private static final String DOJO_SCRIPTS_WRITTEN = "_alfDojoScriptsWritten"; - private static final String YAHOO_SCRIPTS_WRITTEN = "_alfYahooScriptsWritten"; - private static final Map s_fileExtensionMap = new HashMap(89, 1.0f); private static Log logger = LogFactory.getLog(Utils.class); @@ -1291,96 +1288,4 @@ public final class Utils return description; } - - /** - * Writes the script tags for including dojo support, ensuring they - * only get written once per page render. - * - * @param context Faces context - * @param out The response writer - */ - @SuppressWarnings("unchecked") - public static void writeDojoScripts(FacesContext context, ResponseWriter out) - throws IOException - { - Object present = context.getExternalContext().getRequestMap().get(DOJO_SCRIPTS_WRITTEN); - - if (present == null) - { - // write out the scripts -// out.write("\n"); - - out.write("\n\n"); - out.write("\n"); - - // set the context path - out.write("\n"); - - // add marker to request - context.getExternalContext().getRequestMap().put(DOJO_SCRIPTS_WRITTEN, Boolean.TRUE); - } - } - - /** - * Writes the scripts tags for using the Yahoo UI toolkit, ensuring they - * only get written once per page render. - *

- * A comma separated list of scripts can also be passed to determine - * which components are to be used, again these are only written once per page. - * - * @param context Faces context - * @param out The response writer - * @param scripts Comma separated list of scripts to include, if null the - * base yahoo.js script only is included. - */ - @SuppressWarnings("unchecked") - public static void writeYahooScripts(FacesContext context, ResponseWriter out, - String scripts) throws IOException - { - Object present = context.getExternalContext().getRequestMap().get(YAHOO_SCRIPTS_WRITTEN); - - if (present == null) - { - // TODO: use the scripts parameter to determine which scripts to output - // also add an ajax debug flag to the config and output relevant file - - // base yahoo file - out.write("\n\n"); - - // io handling (AJAX) - out.write("\n\n"); - - // event handling - out.write("\n\n"); - - // common alfresco util methods - out.write("\n"); - - // set the context path - out.write("\n"); - - // add marker to request - context.getExternalContext().getRequestMap().put(YAHOO_SCRIPTS_WRITTEN, Boolean.TRUE); - } - } } diff --git a/source/java/org/alfresco/web/ui/repo/component/UINodeInfo.java b/source/java/org/alfresco/web/ui/repo/component/UINodeInfo.java index db0f724c89..1c494fee16 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UINodeInfo.java +++ b/source/java/org/alfresco/web/ui/repo/component/UINodeInfo.java @@ -69,10 +69,9 @@ public class UINodeInfo extends SelfRenderingComponent @Override public Object saveState(FacesContext context) { - Object values[] = new Object[8]; - // standard component attributes are saved by the super class - values[0] = super.saveState(context); - values[1] = this.value; + Object values[] = new Object[] { + super.saveState(context), + this.value}; return values; } @@ -87,19 +86,15 @@ public class UINodeInfo extends SelfRenderingComponent { ResponseWriter out = context.getResponseWriter(); - // output the scripts required by the component (checks are - // made to make sure the scripts are only written once) - Utils.writeDojoScripts(context, out); - // write out the JavaScript specific to the NodeInfo component, - // again, make sure it's only done once + // make sure it's only done once Object present = context.getExternalContext().getRequestMap(). get(NODE_INFO_SCRIPTS_WRITTEN); if (present == null) { out.write("\n"); + out.write("/scripts/ajax/node-info.js\">"); context.getExternalContext().getRequestMap().put( NODE_INFO_SCRIPTS_WRITTEN, Boolean.TRUE); @@ -107,12 +102,11 @@ public class UINodeInfo extends SelfRenderingComponent // wrap the child components in a that has the onmouseover // event which kicks off the request for node information - String id = (String)this.getValue(); - out.write(""); + // we key the node info panel by the noderef string of the current node + String noderef = Repository.getStoreRef().toString() + '/' + (String)this.getValue(); + out.write(""); } } diff --git a/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java b/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java index f687b020e1..62c13f002a 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java +++ b/source/java/org/alfresco/web/ui/repo/component/UIOpenSearch.java @@ -81,21 +81,17 @@ public class UIOpenSearch extends SelfRenderingComponent String clientId = this.getId(); - // output the scripts required by the component (checks are - // made to make sure the scripts are only written once) - Utils.writeYahooScripts(context, out, null); - // write out the JavaScript specific to the OpenSearch component, - // again, make sure it's only done once + // make sure it's only done once Object present = context.getExternalContext().getRequestMap().get(SCRIPTS_WRITTEN); if (present == null) { out.write("\n"); + out.write("/css/opensearch.css\" type=\"text/css\">"); out.write("\n"); + out.write("/scripts/ajax/opensearch.js\">"); context.getExternalContext().getRequestMap().put(SCRIPTS_WRITTEN, Boolean.TRUE); } diff --git a/source/java/org/alfresco/web/ui/repo/renderer/YahooTreeRenderer.java b/source/java/org/alfresco/web/ui/repo/renderer/YahooTreeRenderer.java index 1d03c722b9..7676b098e2 100644 --- a/source/java/org/alfresco/web/ui/repo/renderer/YahooTreeRenderer.java +++ b/source/java/org/alfresco/web/ui/repo/renderer/YahooTreeRenderer.java @@ -67,27 +67,24 @@ public class YahooTreeRenderer extends BaseRenderer ResponseWriter out = context.getResponseWriter(); String treeContainerId = component.getClientId(context) + "Container"; - // output the scripts required by the component (checks are - // made to make sure the scripts are only written once) - Utils.writeYahooScripts(context, out, null); - // write out the JavaScript specific to the Tree component, - // again, make sure it's only done once + // make sure it's only done once Object present = context.getExternalContext().getRequestMap(). get(TREE_SCRIPTS_WRITTEN); if (present == null) { + String reqPath = context.getExternalContext().getRequestContextPath(); out.write(""); + out.write(reqPath); + out.write("/css/yahoo-tree.css\" type=\"text/css\">"); out.write("\n"); + out.write(reqPath); + out.write("/scripts/ajax/yahoo/treeview/treeview-min.js\">"); out.write("\n"); + out.write(reqPath); + out.write("/scripts/ajax/yahoo-tree.js\">"); context.getExternalContext().getRequestMap().put( TREE_SCRIPTS_WRITTEN, Boolean.TRUE); diff --git a/source/java/org/alfresco/web/ui/repo/tag/PageTag.java b/source/java/org/alfresco/web/ui/repo/tag/PageTag.java index 0bfc7d8e78..96c2a88b35 100644 --- a/source/java/org/alfresco/web/ui/repo/tag/PageTag.java +++ b/source/java/org/alfresco/web/ui/repo/tag/PageTag.java @@ -44,9 +44,9 @@ public class PageTag extends TagSupport { private static final long serialVersionUID = 8142765393181557228L; - private final static String SCRIPTS_START = "\n"; - private final static String SCRIPTS_WEBDAV = "/scripts/webdav.js\">\n"; + private final static String SCRIPTS_START = ""; + private final static String SCRIPTS_WEBDAV = "/scripts/webdav.js\">"; private final static String STYLES_START = "\n"; @@ -148,15 +148,62 @@ public class PageTag extends TagSupport } String reqPath = ((HttpServletRequest)pageContext.getRequest()).getContextPath(); - out.write(SCRIPTS_START); - out.write(reqPath); - out.write(SCRIPTS_MENU); - out.write(SCRIPTS_START); - out.write(reqPath); - out.write(SCRIPTS_WEBDAV); + + // CSS style includes out.write(STYLES_START); out.write(reqPath); out.write(STYLES_MAIN); + + // menu javascript + out.write(SCRIPTS_START); + out.write(reqPath); + out.write(SCRIPTS_MENU); + + // webdav javascript + out.write(SCRIPTS_START); + out.write(reqPath); + out.write(SCRIPTS_WEBDAV); + + // base yahoo file + out.write(""); + + // io handling (AJAX) + out.write(""); + + // DOM handling + out.write(""); + + // event handling + out.write(""); + + // animation + out.write(""); + + // drag-drop + out.write(""); + + // common Alfresco util methods + out.write(""); + + // set the context path used by some Alfresco script objects + out.write("\n"); } catch (IOException ioe) { diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 40310ff8e8..7a9bc3a7f3 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -3120,10 +3120,6 @@ nodeService #{NodeService} - - contentService - #{ContentService} - diff --git a/source/web/css/main.css b/source/web/css/main.css index 84c947f26a..54fa172f4b 100644 --- a/source/web/css/main.css +++ b/source/web/css/main.css @@ -475,10 +475,12 @@ a.topToolbarLinkHighlight, a.topToolbarLinkHighlight:link, a.topToolbarLinkHighl .summaryPopupPanel { - background-color: #e9f0f4; - border: 1px solid #999999; + background-image: url(../images/parts/popup_bg.gif); + background-repeat: repeat-x; + background-color: #ffffff; + border: 1px solid #cacfd3; padding: 4px; - -moz-border-radius: 4px; + max-width: 700px; } .userGroupPickerList diff --git a/source/web/jsp/browse/browse.jsp b/source/web/jsp/browse/browse.jsp index 99cf87d0c8..becac99063 100644 --- a/source/web/jsp/browse/browse.jsp +++ b/source/web/jsp/browse/browse.jsp @@ -280,6 +280,9 @@ + + + <%-- Primary column for icons view mode --%> @@ -292,6 +295,9 @@ + + + <%-- Primary column for list view mode --%> @@ -301,10 +307,11 @@ - - - - + + + + + @@ -415,6 +422,9 @@ + + + <%-- Primary column for icons view mode --%> @@ -424,6 +434,9 @@ + + + <%-- Primary column for list view mode --%> @@ -433,6 +446,9 @@ + + + <%-- Description column for all view modes --%> diff --git a/source/web/scripts/ajax/common.js b/source/web/scripts/ajax/common.js index 6242ee3cbe..e3eb69da63 100644 --- a/source/web/scripts/ajax/common.js +++ b/source/web/scripts/ajax/common.js @@ -51,10 +51,10 @@ function handleErrorDojo(type, errObj) /** * Default handler for errors when using the yahoo toolkit */ -function handleErrorYahoo(msg) +function handleErrorYahoo(e) { // TODO: Show a nicer error page, an alert will do for now! - alert(msg); + alert(e.status + " : " + e.statusText); } /** @@ -89,117 +89,173 @@ function getContextPath() } /** - * Returns a single child element with the given tag - * name from the given parent. If more than one tag - * exists the first one is returned, if none exist null - * is returned. + * Alfresco Utility libraries */ -function getElementByTagName(elParent, tagName) +(function() { - var el = null; - - if (elParent != null && tagName != null) - { - var elems = elParent.getElementsByTagName(tagName); - if (elems != null && elems.length > 0) - { - el = elems[0]; - } - } - - return el; -} - -/** - * Returns a single child element with the given tag - * name and namespace from the given parent. - * If more than one tag exists the first one is returned, - * if none exist null is returned. - */ -function getElementByTagNameNS(elParent, nsUri, nsPrefix, tagName) -{ - var el = null; - - if (elParent != null && tagName != null) - { - var elems = null; + /** + * DOM library + */ + Alfresco.Dom = { - if (elParent.getElementsByTagNameNS) + /** + * Returns a single child element with the given tag + * name from the given parent. If more than one tag + * exists the first one is returned, if none exist null + * is returned. + */ + getElementByTagName: function(elParent, tagName) { - elems = elParent.getElementsByTagNameNS(nsUri, tagName); - } - else - { - elems = elParent.getElementsByTagName(nsPrefix + ":" + tagName); - } + var el = null; + + if (elParent != null && tagName != null) + { + var elems = elParent.getElementsByTagName(tagName); + if (elems != null && elems.length > 0) + { + el = elems[0]; + } + } + + return el; + }, - if (elems != null && elems.length > 0) + /** + * Returns a single child element with the given tag + * name and namespace from the given parent. + * If more than one tag exists the first one is returned, + * if none exist null is returned. + */ + getElementByTagNameNS: function(elParent, nsUri, nsPrefix, tagName) { - el = elems[0]; + var el = null; + + if (elParent != null && tagName != null) + { + var elems = null; + + if (elParent.getElementsByTagNameNS) + { + elems = elParent.getElementsByTagNameNS(nsUri, tagName); + } + else + { + elems = elParent.getElementsByTagName(nsPrefix + ":" + tagName); + } + + if (elems != null && elems.length > 0) + { + el = elems[0]; + } + } + + return el; + }, + + /** + * Returns the text of the given DOM element object + */ + getElementText: function(el) + { + var txt = null; + + if (el.text != undefined) + { + // get text using IE specific property + txt = el.text; + } + else + { + // use the W3C textContent property + txt = el.textContent; + } + + return txt; + }, + + /** + * Returns the text content of a single child element + * with the given tag name from the given parent. + * If more than one tag exists the text of the first one + * is returned, if none exist null is returned. + */ + getElementTextByTagName: function(elParent, tagName) + { + var txt = null; + + var el = this.getElementByTagName(elParent, tagName); + if (el != null) + { + txt = this.getElementText(el); + } + + return txt; + }, + + /** + * Returns the text a single child element with the given tag + * name and namespace from the given parent. + * If more than one tag exists the text of the first one is returned, + * if none exist null is returned. + */ + getElementTextByTagNameNS: function(elParent, nsUri, nsPrefix, tagName) + { + var txt = null; + + var el = this.getElementByTagNameNS(elParent, nsUri, nsPrefix, tagName); + if (el != null) + { + txt = this.getElementText(el); + } + + return txt; + }, + + /** + * Aligns an element against the specified element. Automatically adjusts the element above or to + * the left of the destination if the element would cause a scrollbar to appear. + * + * @param el Element to align + * @param destEl Destination element to align against + * @param maxwidth Maximum width of the element (assumed max-width CSS applied) + */ + smartAlignElement: function (el, destEl, maxwidth) + { + // get the position of the element we are aligning against + var pos = YAHOO.util.Dom.getXY(destEl); + + // calculate display position for the element + var region = YAHOO.util.Dom.getRegion(el); + //log("DIV popup size: Width:" + (region.right-region.left) + ", Height:" + (region.bottom-region.top)); + var elHeight = region.bottom - region.top; + var elWidth = region.right - region.left; + //log("elWidth:" + elWidth + " maxwidth:" + maxwidth); + if (maxwidth != undefined && maxwidth != null) + { + if (elWidth > maxwidth) elWidth = maxwidth; + } + var docWidth = YAHOO.util.Dom.getDocumentWidth(); + if (pos[0] + elWidth < docWidth) + { + el.style.left = pos[0]; + } + else + { + el.style.left = pos[0] - ((pos[0] + elWidth) - docWidth); + } + //log(" Element Y:" + pos[1] + " doc height:" + YAHOO.util.Dom.getDocumentHeight()); + if (pos[1] + 16 + elHeight < YAHOO.util.Dom.getDocumentHeight()) + { + el.style.top = pos[1] + 12; + } + else + { + //log(" ***Changing position - will overflow"); + el.style.top = pos[1] - elHeight - 4; + } } - } - - return el; -} - -/** - * Returns the text of the given DOM element object - */ -function getElementText(el) -{ - var txt = null; - - if (el.text != undefined) - { - // get text using IE specific property - txt = el.text; - } - else - { - // use the W3C textContent property - txt = el.textContent; - } - - return txt; -} - -/** - * Returns the text content of a single child element - * with the given tag name from the given parent. - * If more than one tag exists the text of the first one - * is returned, if none exist null is returned. - */ -function getElementTextByTagName(elParent, tagName) -{ - var txt = null; - - var el = getElementByTagName(elParent, tagName); - if (el != null) - { - txt = getElementText(el); - } - - return txt; -} - -/** - * Returns the text a single child element with the given tag - * name and namespace from the given parent. - * If more than one tag exists the text of the first one is returned, - * if none exist null is returned. - */ -function getElementTextByTagNameNS(elParent, nsUri, nsPrefix, tagName) -{ - var txt = null; - - var el = getElementByTagNameNS(elParent, nsUri, nsPrefix, tagName); - if (el != null) - { - txt = getElementText(el); - } - - return txt; -} + }; +})(); /** * Logs a message to a debug log window. @@ -210,7 +266,7 @@ function log(message) { if (!log.window_ || log.window_.closed) { - var win = window.open("", null, "width=400,height=200," + + var win = window.open("", null, "width=600,height=400," + "scrollbars=yes,resizable=yes,status=no," + "location=no,menubar=no,toolbar=no"); if (!win) return; @@ -224,9 +280,4 @@ function log(message) var logLine = log.window_.document.createElement("div"); logLine.appendChild(log.window_.document.createTextNode(message)); log.window_.document.body.appendChild(logLine); -} - - - - - +} \ No newline at end of file diff --git a/source/web/scripts/ajax/node-info.js b/source/web/scripts/ajax/node-info.js index db9d3e7237..919f43fb05 100644 --- a/source/web/scripts/ajax/node-info.js +++ b/source/web/scripts/ajax/node-info.js @@ -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"; + } + } } diff --git a/source/web/scripts/ajax/opensearch.js b/source/web/scripts/ajax/opensearch.js index c8172a01d6..dae7f3f9f8 100644 --- a/source/web/scripts/ajax/opensearch.js +++ b/source/web/scripts/ajax/opensearch.js @@ -169,8 +169,8 @@ Alfresco.OpenSearchClient.prototype = { YAHOO.util.Connect.asyncRequest("GET", searchUrl, { - success: Alfresco.processSearchResults, - failure: Alfresco.handleSearchError, + success: Alfresco.OpenSearchEngine.processSearchResults, + failure: Alfresco.OpenSearchEngine.handleSearchError, argument: [ose.id, this] }, null); @@ -191,8 +191,8 @@ Alfresco.OpenSearchClient.prototype = // execute the query and process the results YAHOO.util.Connect.asyncRequest("GET", url, { - success: Alfresco.processShowPageResults, - failure: Alfresco.handleSearchError, + success: Alfresco.OpenSearchEngine.processShowPageResults, + failure: Alfresco.OpenSearchEngine.handleSearchError, argument: [engineId, this] }, null); @@ -340,21 +340,21 @@ Alfresco.OpenSearchClient.prototype = var elResult = results[x]; // get the title, icon and summary - var title = getElementTextByTagName(elResult, "title"); - var icon = getElementTextByTagName(elResult, "icon"); + var title = Alfresco.Dom.getElementTextByTagName(elResult, "title"); + var icon = Alfresco.Dom.getElementTextByTagName(elResult, "icon"); var summary = null; if (isAtom) { - summary = getElementTextByTagName(elResult, "summary"); + summary = Alfresco.Dom.getElementTextByTagName(elResult, "summary"); } else { - summary = getElementTextByTagName(elResult, "description"); + summary = Alfresco.Dom.getElementTextByTagName(elResult, "description"); } // get the link href var link = null; - var elLink = getElementByTagName(elResult, "link"); + var elLink = Alfresco.Dom.getElementByTagName(elResult, "link"); if (elLink != null) { if (isAtom) @@ -363,7 +363,7 @@ Alfresco.OpenSearchClient.prototype = } else { - link = getElementText(elLink); + link = Alfresco.Dom.getElementText(elLink); } } @@ -416,10 +416,10 @@ Alfresco.OpenSearchClient.prototype = var startIndex = 0; // check there are results - var elTotalResults = getElementByTagNameNS(feed, _OS_NS_URI, _OS_NS_PREFIX, "totalResults"); + var elTotalResults = Alfresco.Dom.getElementByTagNameNS(feed, _OS_NS_URI, _OS_NS_PREFIX, "totalResults"); if (elTotalResults != null) { - totalResults = getElementText(elTotalResults); + totalResults = Alfresco.Dom.getElementText(elTotalResults); } // if there are no results return an empty string @@ -428,16 +428,16 @@ Alfresco.OpenSearchClient.prototype = return ""; } - var elStartIndex = getElementByTagNameNS(feed, _OS_NS_URI, _OS_NS_PREFIX, "startIndex"); + var elStartIndex = Alfresco.Dom.getElementByTagNameNS(feed, _OS_NS_URI, _OS_NS_PREFIX, "startIndex"); if (elStartIndex != null) { - startIndex = getElementText(elStartIndex); + startIndex = Alfresco.Dom.getElementText(elStartIndex); } - var elItemsPerPage = getElementByTagNameNS(feed, _OS_NS_URI, _OS_NS_PREFIX, "itemsPerPage"); + var elItemsPerPage = Alfresco.Dom.getElementByTagNameNS(feed, _OS_NS_URI, _OS_NS_PREFIX, "itemsPerPage"); if (elItemsPerPage != null) { - pageSize = getElementText(elItemsPerPage); + pageSize = Alfresco.Dom.getElementText(elItemsPerPage); } // calculate the number of pages the results span @@ -587,7 +587,7 @@ Alfresco.OpenSearchClient.prototype = /** * Processes the XML search results */ -Alfresco.processSearchResults = function(ajaxResponse) +Alfresco.OpenSearchEngine.processSearchResults = function(ajaxResponse) { try { @@ -599,7 +599,7 @@ Alfresco.processSearchResults = function(ajaxResponse) // if the name of the feed element is "rss", get the channel child element if (feed.tagName == "rss") { - feed = getElementByTagName(feed, "channel"); + feed = Alfresco.Dom.getElementByTagName(feed, "channel"); } var resultsDiv = clientInstance.renderSearchResults(engineId, feed); @@ -628,7 +628,7 @@ Alfresco.processSearchResults = function(ajaxResponse) * Processes the search results and updates the postion, result list * and paging controls. */ -Alfresco.processShowPageResults = function(ajaxResponse) +Alfresco.OpenSearchEngine.processShowPageResults = function(ajaxResponse) { try { @@ -640,7 +640,7 @@ Alfresco.processShowPageResults = function(ajaxResponse) // if the name of the feed element is "rss", get the channel child element if (feed.tagName == "rss") { - feed = getElementByTagName(feed, "channel"); + feed = Alfresco.Dom.getElementByTagName(feed, "channel"); } // append the results list to the results list div @@ -668,7 +668,7 @@ Alfresco.processShowPageResults = function(ajaxResponse) /** * Error handler for Ajax call to search engine */ -Alfresco.handleSearchError = function(ajaxResponse) +Alfresco.OpenSearchEngine.handleSearchError = function(ajaxResponse) { var engineId = ajaxResponse.argument[0]; var clientInstance = ajaxResponse.argument[1];

"); - out.write(nameColumn); - out.write(""); - if (dataColumn != null) - { - out.write(dataColumn); - } - else - { - out.write(" "); - } - out.write("