mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
implemented expand collapse for repeats (need to work on groups for complexTypes)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4499 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -11,6 +11,11 @@ var XHTML_NS_PREFIX = "xhtml";
|
|||||||
var CHIBA_NS = "http://chiba.sourceforge.net/xforms";
|
var CHIBA_NS = "http://chiba.sourceforge.net/xforms";
|
||||||
var CHIBA_NS_PREFIX = "chiba";
|
var CHIBA_NS_PREFIX = "chiba";
|
||||||
|
|
||||||
|
var EXPANDED_IMAGE = new Image();
|
||||||
|
EXPANDED_IMAGE.src = WEBAPP_CONTEXT + "/images/icons/expanded.gif";
|
||||||
|
var COLLAPSED_IMAGE = new Image();
|
||||||
|
COLLAPSED_IMAGE.src = WEBAPP_CONTEXT + "/images/icons/collapsed.gif";
|
||||||
|
|
||||||
function _xforms_init()
|
function _xforms_init()
|
||||||
{
|
{
|
||||||
document.xform = new alfresco.xforms.XForm();
|
document.xform = new alfresco.xforms.XForm();
|
||||||
@@ -647,13 +652,13 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
|
|
||||||
if (position == this.children.length)
|
if (position == this.children.length)
|
||||||
{
|
{
|
||||||
this.domNode.appendChild(child.domContainer);
|
this.childContainerNode.appendChild(child.domContainer);
|
||||||
this.children.push(child);
|
this.children.push(child);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.domNode.insertBefore(child.domContainer,
|
this.childContainerNode.insertBefore(child.domContainer,
|
||||||
this.getChildAt(position).domContainer);
|
this.getChildAt(position).domContainer);
|
||||||
this.children.splice(position, 0, child);
|
this.children.splice(position, 0, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -755,6 +760,15 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
idNode.appendChild(document.createTextNode(this.id));
|
idNode.appendChild(document.createTextNode(this.id));
|
||||||
this.domNode.appendChild(idNode);
|
this.domNode.appendChild(idNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.groupHeaderNode = document.createElement("div");
|
||||||
|
this.groupHeaderNode.id = this.id + "-groupHeaderNode";
|
||||||
|
this.domNode.appendChild(this.groupHeaderNode);
|
||||||
|
|
||||||
|
this.childContainerNode = document.createElement("div");
|
||||||
|
this.childContainerNode.setAttribute("id", this.id + "-childContainerNode");
|
||||||
|
this.domNode.appendChild(this.childContainerNode);
|
||||||
|
this.childContainerNode.style.width = "100%";
|
||||||
return this.domNode;
|
return this.domNode;
|
||||||
},
|
},
|
||||||
_updateDisplay: function()
|
_updateDisplay: function()
|
||||||
@@ -1007,37 +1021,39 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
parseInt(this.domNode.style.borderWidth) -
|
parseInt(this.domNode.style.borderWidth) -
|
||||||
marginLeft) + "px";
|
marginLeft) + "px";
|
||||||
|
|
||||||
var d = document.createElement("div");
|
this.groupHeaderNode.repeat = this;
|
||||||
d.repeat = this;
|
this.groupHeaderNode.style.position = "relative";
|
||||||
this.domNode.appendChild(d);
|
this.groupHeaderNode.style.top = "0px";
|
||||||
d.style.position = "relative";
|
this.groupHeaderNode.style.left = "0px";
|
||||||
d.style.top = "0px";
|
this.groupHeaderNode.style.height = "20px";
|
||||||
d.style.left = "0px";
|
this.groupHeaderNode.style.lineHeight = "20px";
|
||||||
d.style.height = "20px";
|
this.groupHeaderNode.style.backgroundColor = "#cddbe8";
|
||||||
d.style.lineHeight = "20px";
|
this.groupHeaderNode.style.fontWeight = "bold";
|
||||||
d.style.backgroundColor = "#cddbe8";
|
this.groupHeaderNode.style.width = "100%";
|
||||||
d.style.fontWeight = "bold";
|
dojo.event.connect(this.groupHeaderNode, "onclick", function(event)
|
||||||
d.style.width = "100%";
|
|
||||||
dojo.event.connect(d, "onclick", function(event)
|
|
||||||
{
|
{
|
||||||
if (event.target == event.currentTarget)
|
if (event.target == event.currentTarget)
|
||||||
event.currentTarget.repeat.setFocusedChild(null);
|
event.currentTarget.repeat.setFocusedChild(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
//used only for positioning the label accurately
|
//used only for positioning the label accurately
|
||||||
var requiredImage = document.createElement("img");
|
this.toggleExpandedImage = document.createElement("img");
|
||||||
requiredImage.setAttribute("src", WEBAPP_CONTEXT + "/images/icons/required_field.gif");
|
this.groupHeaderNode.appendChild(this.toggleExpandedImage);
|
||||||
requiredImage.style.marginLeft = "5px";
|
this.toggleExpandedImage.setAttribute("src", EXPANDED_IMAGE.src);
|
||||||
requiredImage.style.marginRight = "5px";
|
this.toggleExpandedImage.align = "absmiddle";
|
||||||
|
this.toggleExpandedImage.style.marginLeft = "5px";
|
||||||
|
this.toggleExpandedImage.style.marginRight = "5px";
|
||||||
|
|
||||||
d.appendChild(requiredImage);
|
dojo.event.connect(this.toggleExpandedImage, "onclick", this, this._toggleExpanded_clickHandler);
|
||||||
requiredImage.style.visibility = "hidden";
|
|
||||||
|
|
||||||
var labelElement = document.createTextNode(this.parent.getLabel());
|
var label = this.parent.getLabel()
|
||||||
d.appendChild(labelElement);
|
if (djConfig.isDebug)
|
||||||
|
label += " [" + this.id + "]";
|
||||||
|
|
||||||
|
this.groupHeaderNode.appendChild(document.createTextNode(label));
|
||||||
|
|
||||||
var addElement = document.createElement("img");
|
var addElement = document.createElement("img");
|
||||||
d.appendChild(addElement);
|
this.groupHeaderNode.appendChild(addElement);
|
||||||
addElement.setAttribute("src", WEBAPP_CONTEXT + "/images/icons/plus.gif");
|
addElement.setAttribute("src", WEBAPP_CONTEXT + "/images/icons/plus.gif");
|
||||||
addElement.style.width = "16px";
|
addElement.style.width = "16px";
|
||||||
addElement.style.height = "16px";
|
addElement.style.height = "16px";
|
||||||
@@ -1079,7 +1095,22 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
{
|
{
|
||||||
dojo.debug(this.id + ".handleItemDeleted(" + position + ")");
|
dojo.debug(this.id + ".handleItemDeleted(" + position + ")");
|
||||||
this.removeChildAt(position);
|
this.removeChildAt(position);
|
||||||
}
|
},
|
||||||
|
isExpanded: function()
|
||||||
|
{
|
||||||
|
return this.toggleExpandedImage.getAttribute("src") == EXPANDED_IMAGE.src;
|
||||||
|
},
|
||||||
|
setExpanded: function(expanded)
|
||||||
|
{
|
||||||
|
if (expanded == this.isExpanded())
|
||||||
|
return;
|
||||||
|
this.toggleExpandedImage.src = expanded ? EXPANDED_IMAGE.src : COLLAPSED_IMAGE.src;
|
||||||
|
this.childContainerNode.style.display = expanded ? "block" : "none";
|
||||||
|
},
|
||||||
|
_toggleExpanded_clickHandler: function(event)
|
||||||
|
{
|
||||||
|
this.setExpanded(!this.isExpanded())
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("alfresco.xforms.Trigger",
|
dojo.declare("alfresco.xforms.Trigger",
|
||||||
|
Reference in New Issue
Block a user