Merged V3.2 to HEAD

16725: Merged V3.1 to V3.2
      16721: Merged DEV/BELARUS/V3.1 to V3.1 
         16483: Fix for ETHREEOH-2728 : WCM - Forms rendering issue using IE6
   16889: Merged V3.1 to V3.2
      16888: Merged V2.2 to V3.1 
         16694: Fix for ETHREEOH-1384/ACT 11135: Poor performance when using webscript based web forms 
         16787: Fixed Web-Client Eclipse project after recent chiba JAR file name change 
         16840: Resolution to issue in ETHREEOH-2633: Change to Common.js function implemented in CHK-5134 causes problems with missing icons in Navigator panel. Implemented configuration approach so that both modes can be supported. 
         16870: Fix for ETWOTWO-119 & ALFCOM-332: WCM config override issues where the OOTB web-client-config-wcm.xml file needed to be changed and the ability to define custom scripts to load to avoid the need to edit xforms.js or XFormsProcessor.java

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16913 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2009-10-14 11:37:27 +00:00
parent ba3f9629b5
commit b1e86e69f2
21 changed files with 1103 additions and 100 deletions

View File

@@ -10,6 +10,7 @@ if (typeof Alfresco == "undefined")
var Alfresco = {};
}
var _checkContextAgainstPath = false;
var _alfContextPath = null;
@@ -81,20 +82,36 @@ function handleErrorYahoo(e)
}
}
/**
* Determines whether the setContextPath method below should
* check the provided context path against the URLs path
*/
function setCheckContextAgainstPath(checkContextAgainstPath)
{
_checkContextAgainstPath = checkContextAgainstPath;
}
/**
* Sets the context path to use, useful for portals where
* the URL can be different from the app's context path.
*/
function setContextPath(contextPath)
{
if (window.location.pathname.indexOf(contextPath) == 0 )
{
_alfContextPath = contextPath;
}
else
{
_alfContextPath = "";
}
if (_checkContextAgainstPath)
{
if (window.location.pathname.indexOf(contextPath) == 0 )
{
_alfContextPath = contextPath;
}
else
{
_alfContextPath = "";
}
}
else
{
_alfContextPath = contextPath;
}
}
/**

View File

@@ -15,15 +15,27 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
////////////////////////////////////////////////////////////////////////////////
// FilePickerWidget
// FilePickerWidget extends Class (mootools)
//
// This script communicates with the XFormBean to manage a file picker widget
// for selecting and uploading files in the avm.
//
// This script requires dojo.js, ajax_helper.js and upload_helper.js to be
// This script requires dojo.js, ajax_helper.js and upload_helper.js and mootools.1.11.js to be
// loaded in advance.
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// FilePickerWidgetTableLayout extends FilePickerWidget
//
// See comments to ETHREEOH-2728 in the code. Also, some css tricks and new selectors
// were added into xforms.css.
//
// The methods _openParentPathMenu, _showStatus, _hideStatus, _showAddContent should be
// overridden using mootools if necessary.
////////////////////////////////////////////////////////////////////////////////
if (typeof alfresco == "undefined")
{
throw new Error("file_picker_widget requires alfresco be defined");
@@ -42,7 +54,8 @@ if (typeof alfresco.resources == "undefined")
/**
* The file picker widget.
*/
alfresco.FilePickerWidget = function(uploadId,
alfresco.FilePickerWidget = new Class({
initialize: function(uploadId,
node,
value,
readonly,
@@ -65,39 +78,7 @@ alfresco.FilePickerWidget = function(uploadId,
this.filterMimetypes = filterMimetypes;
this.folderRestriction = folderRestriction;
this.configSearchName = configSearchName;
}
// static methods and properties
alfresco.FilePickerWidget._uploads = [];
alfresco.FilePickerWidget._handleUpload = function(id, fileInput, webappRelativePath, widget)
{
alfresco.FilePickerWidget._uploads[id] =
{
widget:widget,
path: fileInput.value,
webappRelativePath: webappRelativePath
};
handle_upload_helper(fileInput,
id,
alfresco.FilePickerWidget._upload_completeHandler,
alfresco.constants.WEBAPP_CONTEXT,
"/ajax/invoke/FilePickerBean.uploadFile",
{ currentPath: webappRelativePath });
}
alfresco.FilePickerWidget._upload_completeHandler = function(id, path, fileName, fileTypeImage, error)
{
var upload = alfresco.FilePickerWidget._uploads[id];
upload.widget._upload_completeHandler(fileName,
upload.webappRelativePath,
fileTypeImage,
error);
}
// instance methods and properties
alfresco.FilePickerWidget.prototype = {
},
getValue: function()
{
@@ -751,4 +732,435 @@ _openParentPathMenu: function(target, path)
}
this.node.appendChild(this.parentPathMenu);
}
});
//static methods and properties
alfresco.FilePickerWidget._uploads = [];
alfresco.FilePickerWidget._handleUpload = function(id, fileInput, webappRelativePath, widget)
{
alfresco.FilePickerWidget._uploads[id] =
{
widget:widget,
path: fileInput.value,
webappRelativePath: webappRelativePath
};
handle_upload_helper(fileInput,
id,
alfresco.FilePickerWidget._upload_completeHandler,
alfresco.constants.WEBAPP_CONTEXT,
"/ajax/invoke/FilePickerBean.uploadFile",
{ currentPath: webappRelativePath });
}
alfresco.FilePickerWidget._upload_completeHandler = function(id, path, fileName, fileTypeImage, error)
{
var upload = alfresco.FilePickerWidget._uploads[id];
upload.widget._upload_completeHandler(fileName,
upload.webappRelativePath,
fileTypeImage,
error);
}
// ------------------------------------------------------------------------------------------------------------------------------
/**
* The file picker widget with table layout and mootools rendering.
*/
alfresco.FilePickerWidgetTableLayout = alfresco.FilePickerWidget.extend({
destroy: function()
{
$(this.node).remove();
this.node = null;
},
_showSelectedValue: function()
{
if (this.node == null)
{
return;
}
var node = $(this.node);
node.empty();
this.statusDiv = null;
this.contentDiv = null;
this.addContentDiv = null;
// The FilePickerWidget wrapper div. It is neccessary for further manipulations which are realted to ETHREEOH-2728 issue.
this.wrapper = new Element("div", {"class":"xformsFilePickerWrapper"});
node.setStyles({"height":"20px", "line-height":"20px", "position":"relative", "white-space":"nowrap"});
// Inject the wrapper into this.node. We do this for further proper calculation of the sizes of controls
this.wrapper.inject(node);
this.resize_callback(this);
this.selectedPathInput = new Element("input",
{
"type":"text",
"value": (this.value == null ? "" : this.value),
"styles": {"margin":"0"},
"events":
{
"blur": function(event)
{
var w = this.filePickerWidget;
if (typeof(w) != "undefined")
{
w.setValue(this.value);
}
}
}
});
this.selectedPathInput.inject(this.wrapper);
this.selectedPathInput.filePickerWidget = this;
this._selectButton = new Element("input",
{
"type":"button",
"value": (this.value == null
? alfresco.resources["select"]
: alfresco.resources["change"]),
"disabled":this.readonly,
"styles":{"margin":"0 3px"},
"events":
{
"click": function(event)
{
var w = this.filePickerWidget;
if (typeof(w) != "undefined")
{
w._navigateToNode(w.getValue() || "");
}
}
}
});
this._selectButton.filePickerWidget = this;
this._selectButton.inject(this.wrapper);
var nodeSize = node.getSize();
var selectButtonSize = this._selectButton.getSize();
var selectedPathInputWidth = "80%";
if (!window.ie6 && nodeSize.size.x != 0)
{
selectedPathInputWidth = ((1 - (this._selectButton.getStyle("margin-left").toInt() +
this._selectButton.getStyle("margin-right").toInt() +
selectButtonSize.size.x)/nodeSize.size.x)*100) +"%";
}
this.selectedPathInput.style.width = selectedPathInputWidth;
//
// See comments in _showPicker method.
//
if (window.ie6)
{
var reload = function()
{
var grabbedWrapper = $(this.wrapper).remove();
grabbedWrapper.inject(this.node);
}
reload.delay(1, this);
}
},
_showPicker: function(data)
{
data = data.documentElement;
while (this.node.hasChildNodes() && this.node.lastChild != this.statusDiv)
{
this.node.removeChild(this.node.lastChild);
}
this.node.style.height = (200 + (this.statusDiv
? (parseInt(this.statusDiv.style.height) +
parseInt(this.statusDiv.style.marginTop) +
parseInt(this.statusDiv.style.marginBottom))
: 0) + "px");
this.resize_callback(this);
var currentPath = data.getElementsByTagName("current-node")[0];
currentPath = currentPath.getAttribute("webappRelativePath");
var currentPathName = currentPath.replace(/.*\/([^/]+)/, "$1");
//The FilePickerWidget wrapper div. It is neccessary for further manipulations which are realted to ETHREEOH-2728 issue.
this.wrapper = new Element("div", {"class":"xformsFilePickerWrapper"});
var container = new Element("table",{"id":"picker-" + this.uploadId, "class":"xformsFilePickerTable"});
this.wrapper.inject(this.node);
container.inject(this.wrapper);
var tbody = new Element("tbody");
tbody.inject(container);
var headerTdLeft = new Element("td", {"class":"headerTdLeft"});
var headerTdRight = new Element("td", {"class":"headerTdRight"});
var contentTd = new Element("td", {"class":"contentTd", "colspan":"2", "styles":{"vertical-align":"top"}});
var contentDiv = new Element("div", {"class":"xformsFilePickerFileList"});
contentDiv.inject(contentTd);
var footerTd = new Element("td", {"class":"footerTd", "colspan":"2", "styles":{"text-align":"center"}});
var headerTr = new Element("tr");
headerTdLeft.inject(headerTr);
headerTdRight.inject(headerTr);
headerTr.inject(tbody);
contentTd.inject(new Element("tr").inject(tbody));
footerTd.inject(new Element("tr").inject(tbody));
headerTdLeft.appendText("In: ");
this.headerMenuTriggerLink = new Element("a",
{
"styles":{"text-decoration":"none"},
"href":"javascript:void(0)",
"webappRelativePath":"currentPath",
"class":"xformsFilePickerHeaderMenuTrigger",
"events":{"mouseover": function(event){
this.style.backgroundColor = "#fefefe";
this.style.borderStyle = "inset";
},
"mouseout": function(event) {
var w = this.filePickerWidget;
if (!w.parentPathMenu)
{
this.style.backgroundColor = this.parentNode.style.backgroundColor;
this.style.borderStyle = "solid";
}
},
"click": function(event) {
var w = this.filePickerWidget;
if (w.parentPathMenu)
{
w._closeParentPathMenu();
}
else
{
w._openParentPathMenu(this, this.getAttribute("webappRelativePath"));
}
}
}
}
);
this.headerMenuTriggerLink.filePickerWidget = this;
this.headerMenuTriggerLink.inject(headerTdLeft);
this.headerMenuTriggerLink.appendText(currentPathName);
var headerMenuTriggerImage = new Element("img",
{
"src": alfresco.constants.WEBAPP_CONTEXT + "/images/icons/menu.gif",
"styles" : {"border":"0", "width:":"16px", "height":"16px", "margin":"0 0 0 4px", "z-index":"500", "vertical-align":"middle"}
});
headerMenuTriggerImage.inject(this.headerMenuTriggerLink);
var addContentLink = new Element("a",
{
"webappRelativePath":currentPath,
"href":"javascript:void(0)",
"styles":{"text-decoration":"none"},
"events":{
"click":function(event){
var w = this.filePickerWidget;
if (w.addContentDiv)
{
w._hideAddContent();
}
else
{
w._showAddContent(this.getAttribute("webappRelativePath"));
}
}
}
});
addContentLink.inject(headerTdRight);
addContentLink.filePickerWidget = this;
var addContentImage = new Element("img",
{
"src":alfresco.constants.WEBAPP_CONTEXT + "/images/icons/add.gif",
"styles":{"border":"0", "width:":"16px", "height":"16px", "margin":"0 2px", "vertical-align":"middle"}
});
addContentImage.inject(addContentLink);
addContentLink.appendText(alfresco.resources["add_content"]);
var navigateToParentLink = new Element("a",
{
"webappRelativePath" : currentPath,
"href":"javascript:void(0)",
"styles":{"text-decoration":"none"}
});
navigateToParentLink.inject(headerTdRight);
navigateToParentLink.filePickerWidget = this;
if (currentPathName != "/")
{
navigateToParentLink.addEvent("click",
function(event)
{
var w = this.filePickerWidget;
var parentPath = this.getAttribute("webappRelativePath");
parentPath = (parentPath.lastIndexOf("/") == 0 ? "/" : parentPath.substring(0, parentPath.lastIndexOf("/")));
w._navigateToNode(parentPath);
});
}
var navigateToParentNodeImage = new Element("img",
{
"src":alfresco.constants.WEBAPP_CONTEXT + "/images/icons/up.gif",
"styles":{"border":"0", "width:":"16px", "height":"16px", "margin":"0 2px", "vertical-align":"middle"}
});
dojo.html.setOpacity(navigateToParentNodeImage, (currentPathName == "/" ? .3 : 1));
navigateToParentNodeImage.inject(navigateToParentLink);
navigateToParentLink.appendText(alfresco.resources["go_up"]);
this.contentDiv = contentDiv;
var footerDiv = footerTd;
var cancelButton = new Element("input",
{
"type" : "button",
"value" : alfresco.resources["cancel"],
"events" : {
"click" : function(event)
{
var w = this.filePickerWidget;
w.cancel_callback(this);
w._showSelectedValue();
}
}
}
);
cancelButton.filePickerWidget = this;
cancelButton.inject(footerDiv);
var contentDivHeight = (this.node.offsetHeight - (this.statusDiv ? this.statusDiv.offsetHeight : 0) - footerDiv.offsetHeight - headerTdLeft.offsetHeight - 10) + "px";
this.contentDiv.setStyle("height",contentDivHeight);
var childNodes = data.getElementsByTagName("child-node");
for (var i = 0; i < childNodes.length; i++)
{
if (childNodes[i].nodeType != document.ELEMENT_NODE)
{
continue;
}
var webappRelativePath = childNodes[i].getAttribute("webappRelativePath");
var fileName = webappRelativePath.replace(/.*\/([^/]+)/, "$1");
var row = this._createRow(fileName,
webappRelativePath,
childNodes[i].getAttribute("type") == "directory",
eval(childNodes[i].getAttribute("selectable")),
childNodes[i].getAttribute("image"),
"xformsRow" + (i % 2 ? "Even" : "Odd"));
row.inject(this.contentDiv);
}
if (data.getAttribute("error") && data.getAttribute("error").length != 0)
{
this._showStatus(data.getAttribute("error"), true);
}
//
// This trick does allow to rerender the FilePickerWidget with a delay of 1ms.
// It's user friendly behaviour, because it is not visibly for end user.
// IE6 dosn't render div content generated by JavaScript in some unknown circumstances.
// It occurs especially with mixed related, floated, absolute layouts. Presumably, it occurs
// when IE can't calculate some elements layout, untill all ememens are rendered.
// So,
// 1. We generate all elements as usual.
// 2. For IE we remove rendered element with its' children, and then inject him into the same place again, after some delay.
// It allows to recalculate element layouts, after #1.
//
if (window.ie6)
{
var reload = function()
{
var grabbedWrapper = $(this.wrapper).remove();
grabbedWrapper.inject(this.node);
}
reload.delay(1, this);
}
},
_createRow: function(fileName, webappRelativePath, isDirectory, isSelectable, fileTypeImage, rowClass)
{
var result = new Element("div",
{
"id":fileName + "-row",
"webappRelativePath":webappRelativePath,
"class":"xformsFilePickerRow",
"events":
{
"mouseover" : function(event)
{
this.addClass("xformsRowHover");
},
"mouseout" : function(event)
{
this.removeClass("xformsRowHover");
}
}
});
result.addClass(rowClass);
result.filePickerWidget = this;
var e = new Element("img",
{
"src" : alfresco.constants.WEBAPP_CONTEXT + fileTypeImage,
"styles" : {"vertical-align":"middle", "margin":"0 4px"}
});
e.inject(result);
if (isDirectory)
{
e = new Element("a",
{
"href":"javascript:void(0)",
"styles":{"text-decoration":"none"},
"events":
{
"click": function(event)
{
var w = result.filePickerWidget;
w._navigateToNode(result.getAttribute("webappRelativePath"));
return true;
}
}
});
e.appendText(fileName);
e.inject(result);
}
else
{
result.appendText(fileName);
}
if (isSelectable)
{
e = new Element("input",
{
"type":"button",
"name":webappRelativePath,
"value":"Select",
"styles":{"position":"absolute", "right":"10px", "top":(.5 * result.offsetHeight) - (.5 * e.offsetHeight) + "px"},
"events":
{
"click":function(event)
{
var w = result.filePickerWidget;
w.setValue(result.getAttribute("webappRelativePath"));
w._showSelectedValue();
}
}
}
);
e.inject(result);
}
return result;
},
_closeParentPathMenu: function()
{
if (this.parentPathMenu)
{
$(this.parentPathMenu).remove();
this.parentPathMenu = null;
}
this.headerMenuTriggerLink.style.borderStyle = "solid";
}
});

View File

@@ -531,7 +531,9 @@ alfresco.xforms.FilePicker = alfresco.xforms.Widget.extend({
this._selectableTypes = "selectable_types" in params ? params["selectable_types"].split(",") : null;
this._filterMimetypes = "filter_mimetypes" in params ? params["filter_mimetypes"].split(",") : [];
this._folderRestriction = "folder_restriction" in params ? params["folder_restriction"] : null;
this._configSearchName = "config_search_name" in params ? params["config_search_name"] : null; },
this._configSearchName = "config_search_name" in params ? params["config_search_name"] : null;
this._layout = "layout" in params ? params["layout"] : null;
},
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -542,6 +544,23 @@ alfresco.xforms.FilePicker = alfresco.xforms.Widget.extend({
this.domNode.addClass("xformsFilePicker");
attach_point.appendChild(this.domNode);
//XXXarielb support readonly and disabled
if (this._layout == "table")
{
this.widget = new alfresco.FilePickerWidgetTableLayout(this.id,
this.domNode,
this.getInitialValue(),
false,
this._filePicker_changeHandler.bindAsEventListener(this),
null /* cancel is ignored */,
this._filePicker_resizeHandler.bindAsEventListener(this),
this._selectableTypes,
this._filterMimetypes,
this._folderRestriction,
this._configSearchName);
}
else
{
this.widget = new alfresco.FilePickerWidget(this.id,
this.domNode,
this.getInitialValue(),
@@ -553,6 +572,7 @@ alfresco.xforms.FilePicker = alfresco.xforms.Widget.extend({
this._filterMimetypes,
this._folderRestriction,
this._configSearchName);
}
this.widget.render();
},
@@ -633,7 +653,14 @@ alfresco.xforms.TextField = alfresco.xforms.Widget.extend({
var borderWidth = (this.widget.offsetWidth - this.widget.clientWidth);
var marginRight = 2;
this.widget.style.marginRight = marginRight + "px";
if (attach_point.offsetWidth == 0)
{
this.widget.style.width = "100%";
}
else
{
this.widget.style.width = (((attach_point.offsetWidth - borderWidth - marginRight) / attach_point.offsetWidth) * 100) + "%";
}
this.widget.style.minWidth = "50px";
}
@@ -2698,10 +2725,13 @@ alfresco.xforms.VGroup = alfresco.xforms.AbstractGroup.extend({
? "0px"
: "30%");
contentDiv.style.width = (child instanceof alfresco.xforms.AbstractGroup
? "100%"
: (1 - (contentDiv.offsetLeft /
child.domContainer.offsetWidth)) * 100 + "%");
var contentDivWidth = "100%";
// the following does avoid devision by zero ... in contentDiv.offsetLeft / child.domContainer.offsetWidth
if (!(child instanceof alfresco.xforms.AbstractGroup) && child.domContainer.offsetWidth != 0)
{
contentDivWidth = ((1 - (contentDiv.offsetLeft / child.domContainer.offsetWidth)) * 100) + "%";
}
contentDiv.style.width = contentDivWidth;
child.render(contentDiv);
if (!(child instanceof alfresco.xforms.AbstractGroup))
{
@@ -2813,19 +2843,16 @@ alfresco.xforms.VGroup = alfresco.xforms.AbstractGroup.extend({
_updateDisplay: function(recursively)
{
this.domNode.style.width = "100%";
if (!window.ie)
{
if (this._isIndented())
{
this.domNode.style.marginLeft = 10 + "px";
this.domNode.style.marginRight = 5 + "px";
// XXXarielb can this be moved to render or insertChild?
this.domNode.style.width = (((this.domNode.offsetWidth - 15) / this.domNode.offsetWidth) * 100) + "%";
}
if (window.ie)
{
this.domNode.style.width = "100%";
}
else
{
// var x = ((this.domNode.offsetWidth - this.domNode.clientWidth) +
// this.domNode.getStyle("margin-left").toFloat() +
// this.domNode.getStyle("margin-right").toFloat());
@@ -2848,10 +2875,17 @@ alfresco.xforms.VGroup = alfresco.xforms.AbstractGroup.extend({
contentDiv.style.left = (this._children[i] instanceof alfresco.xforms.AbstractGroup
? "0px"
: "30%");
if (this._children[i].domContainer.parentNode.offsetWidth != 0)
{
contentDiv.style.width = (this._children[i] instanceof alfresco.xforms.AbstractGroup
? "100%"
: (1 - (contentDiv.offsetLeft /
this._children[i].domContainer.parentNode.offsetWidth)) * 100 + "%");
}
else
{
contentDiv.style.width = "100%";
}
if (recursively)
{
@@ -3511,7 +3545,7 @@ alfresco.xforms.Repeat = alfresco.xforms.VGroup.extend({
this._groupHeaderNode.repeat = this;
this._groupHeaderNode.onclick = function(event)
{
if (event.target == event.currentTarget)
if ((typeof(event) != 'undefined') && (typeof(event.target) != 'undefined') && (event.target == event.currentTarget))
{
event.currentTarget.repeat.setFocusedChild(null);
}