mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
preliminary ie support for the xforms ui.
- response.setContentType must be text/xml or responseXML will not get parsed by IE. - getElementsByTagNameNS only works on mozilla... - IE is much more picky about all elements explicitly setting position, top, and left, when using relative positioning - IE's xpath implementation is non obvious and incomplete. found a good explanation of how to use it here http://sarissa.sourceforge.net/doc/overview-summary.html#xpath. requires a lot more manual labor to get things working, but in the end, does seem to work. need to add in an abstraction layer... - it fails dramatically when you terminate a list of properties with comma, meaing var bad = {foo:bar, foo2:bar2, } var good = {foo:bar, foo2:bar2} - ie event model is different, using the dojo abstraction layer seems to fix that, particularly for the submit buttons. changed the way submit buttons are added to make the xforms stuff pull them rather than have the jsps add them to the xform. thought this was necessary because of weird loading behavior in IE, but it probably wasn't. either way - it's less code and more centralized now. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4056 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -64,7 +64,6 @@ public class InvokeCommand extends BaseAjaxCommand
|
|||||||
// therefore, for now we will always return a content type of text/html.
|
// therefore, for now we will always return a content type of text/html.
|
||||||
// In the future we may use annotations on the method to be called to specify what content
|
// In the future we may use annotations on the method to be called to specify what content
|
||||||
// type should be used for the response.
|
// type should be used for the response.
|
||||||
|
|
||||||
final OutputStream os = response.getOutputStream();
|
final OutputStream os = response.getOutputStream();
|
||||||
final UIViewRoot viewRoot = facesContext.getViewRoot();
|
final UIViewRoot viewRoot = facesContext.getViewRoot();
|
||||||
final RenderKitFactory renderFactory = (RenderKitFactory)FactoryFinder.
|
final RenderKitFactory renderFactory = (RenderKitFactory)FactoryFinder.
|
||||||
@@ -74,7 +73,8 @@ public class InvokeCommand extends BaseAjaxCommand
|
|||||||
final ResponseWriter writer = renderKit.createResponseWriter(
|
final ResponseWriter writer = renderKit.createResponseWriter(
|
||||||
new OutputStreamWriter(os), MimetypeMap.MIMETYPE_XML, "UTF-8");
|
new OutputStreamWriter(os), MimetypeMap.MIMETYPE_XML, "UTF-8");
|
||||||
facesContext.setResponseWriter(writer);
|
facesContext.setResponseWriter(writer);
|
||||||
response.setContentType(writer.getContentType());
|
// must be text/xml otherwise IE doesn't parse the response properly into responseXML
|
||||||
|
response.setContentType(MimetypeMap.MIMETYPE_XML);
|
||||||
|
|
||||||
// create the JSF binding expression
|
// create the JSF binding expression
|
||||||
final String bindingExpr = makeBindingExpression(expression);
|
final String bindingExpr = makeBindingExpression(expression);
|
||||||
|
@@ -76,14 +76,19 @@ public class XFormsInputMethod
|
|||||||
|
|
||||||
// a script with config information and globals.
|
// a script with config information and globals.
|
||||||
Element e = result.createElement("script");
|
Element e = result.createElement("script");
|
||||||
e.appendChild(result.createTextNode("djConfig = { isDebug: " + LOGGER.isDebugEnabled() +
|
e.setAttribute("type", "text/javascript");
|
||||||
|
e.appendChild(result.createTextNode("\ndjConfig = { isDebug: " + LOGGER.isDebugEnabled() +
|
||||||
" };\n" +
|
" };\n" +
|
||||||
"var WEBAPP_CONTEXT = \"" + cp + "\";\n"));
|
"var WEBAPP_CONTEXT = \"" + cp + "\";\n"));
|
||||||
div.appendChild(e);
|
div.appendChild(e);
|
||||||
final String[] scripts =
|
final String[] scripts =
|
||||||
{
|
{
|
||||||
"/scripts/tiny_mce/tiny_mce_src.js",
|
"/scripts/tiny_mce/" + (LOGGER.isDebugEnabled()
|
||||||
"/scripts/ajax/dojo/dojo.js",
|
? "tiny_mce_src.js"
|
||||||
|
: "tiny_mce.js"),
|
||||||
|
"/scripts/ajax/dojo/" + (LOGGER.isDebugEnabled()
|
||||||
|
? "dojo.js.uncompressed.js"
|
||||||
|
: "dojo.js"),
|
||||||
"/scripts/ajax/xforms.js"
|
"/scripts/ajax/xforms.js"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -24,6 +24,13 @@
|
|||||||
<%@ page import="org.alfresco.web.bean.wcm.CreateWebContentWizard" %>
|
<%@ page import="org.alfresco.web.bean.wcm.CreateWebContentWizard" %>
|
||||||
<%@ page import="org.w3c.dom.Document" %>
|
<%@ page import="org.w3c.dom.Document" %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function _xforms_getSubmitButtons()
|
||||||
|
{
|
||||||
|
return [ document.getElementById("wizard:next-button"),
|
||||||
|
document.getElementById("wizard:finish-button") ];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<%
|
<%
|
||||||
final CreateWebContentWizard wiz = (CreateWebContentWizard)
|
final CreateWebContentWizard wiz = (CreateWebContentWizard)
|
||||||
Application.getWizardManager().getBean();
|
Application.getWizardManager().getBean();
|
||||||
@@ -45,17 +52,10 @@ final InstanceData instanceData = new InstanceData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContent(final Document d)
|
public void setContent(final Document d)
|
||||||
{
|
{
|
||||||
wiz.setContent(ts.writeXMLToString(d));
|
wiz.setContent(ts.writeXMLToString(d));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
tim.generate(instanceData, tt, out);
|
tim.generate(instanceData, tt, out);
|
||||||
%>
|
%>
|
||||||
<script type="text/javascript">
|
|
||||||
dojo.addOnLoad(function()
|
|
||||||
{
|
|
||||||
addSubmitHandlerToButton(document.getElementById("wizard:next-button"));
|
|
||||||
addSubmitHandlerToButton(document.getElementById("wizard:finish-button"));
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
@@ -63,6 +63,12 @@ final InstanceData instanceData = new InstanceData()
|
|||||||
%>
|
%>
|
||||||
|
|
||||||
<r:page titleId="title_edit_text_inline">
|
<r:page titleId="title_edit_text_inline">
|
||||||
|
<script type="text/javascript">
|
||||||
|
function _xforms_getSubmitButtons()
|
||||||
|
{
|
||||||
|
return [ document.getElementById("edit-file:save-button") ];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<f:view>
|
<f:view>
|
||||||
|
|
||||||
@@ -186,12 +192,4 @@ final InstanceData instanceData = new InstanceData()
|
|||||||
</h:form>
|
</h:form>
|
||||||
|
|
||||||
</f:view>
|
</f:view>
|
||||||
<script type="text/javascript">
|
|
||||||
dojo.addOnLoad(function()
|
|
||||||
{
|
|
||||||
addSubmitHandlerToButton(document.getElementById("edit-file:save-button"));
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</r:page>
|
</r:page>
|
@@ -5,10 +5,21 @@ dojo.require("dojo.widget.validate");
|
|||||||
dojo.require("dojo.widget.Spinner");
|
dojo.require("dojo.widget.Spinner");
|
||||||
dojo.require("dojo.lfx.html");
|
dojo.require("dojo.lfx.html");
|
||||||
dojo.hostenv.writeIncludes();
|
dojo.hostenv.writeIncludes();
|
||||||
dojo.addOnLoad(function()
|
|
||||||
{
|
var XFORMS_NS = "http://www.w3.org/2002/xforms";
|
||||||
document.xform = new alfresco.xforms.XForm();
|
var XFORMS_NS_PREFIX = "xforms";
|
||||||
});
|
var XHTML_NS = "http://www.w3.org/1999/xhtml";
|
||||||
|
var XHTML_NS_PREFIX = "xhtml";
|
||||||
|
var CHIBA_NS = "http://chiba.sourceforge.net/xforms";
|
||||||
|
var CHIBA_NS_PREFIX = "chiba";
|
||||||
|
|
||||||
|
function _xforms_init()
|
||||||
|
{
|
||||||
|
document.xform = new alfresco.xforms.XForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
dojo.addOnLoad(_xforms_init);
|
||||||
|
|
||||||
tinyMCE.init({
|
tinyMCE.init({
|
||||||
theme: "advanced",
|
theme: "advanced",
|
||||||
mode: "exact",
|
mode: "exact",
|
||||||
@@ -33,11 +44,13 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
{
|
{
|
||||||
this.xform = xform;
|
this.xform = xform;
|
||||||
this.node = node;
|
this.node = node;
|
||||||
this.node.widget = this;
|
//XXXareibl this has to come back
|
||||||
|
// this.node.widget = this;
|
||||||
this.id = this.node.getAttribute("id");
|
this.id = this.node.getAttribute("id");
|
||||||
this.modified = false;
|
this.modified = false;
|
||||||
this.valid = true;
|
this.valid = true;
|
||||||
},
|
},
|
||||||
|
node: null,
|
||||||
parent: null,
|
parent: null,
|
||||||
domContainer: null,
|
domContainer: null,
|
||||||
_getBinding: function()
|
_getBinding: function()
|
||||||
@@ -91,30 +104,32 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
},
|
},
|
||||||
getInitialValue: function()
|
getInitialValue: function()
|
||||||
{
|
{
|
||||||
var chibaData = this.node.getElementsByTagName("data");
|
var chibaData = _getElementsByTagNameNS(this.node,
|
||||||
|
CHIBA_NS,
|
||||||
|
CHIBA_NS_PREFIX,
|
||||||
|
"data");
|
||||||
if (chibaData.length == 0)
|
if (chibaData.length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
chibaData = chibaData[chibaData.length - 1];
|
chibaData = chibaData[chibaData.length - 1];
|
||||||
var xpath = "/" + chibaData.getAttribute("chiba:xpath");
|
var xpath = chibaData.getAttribute("chiba:xpath");
|
||||||
var d = this.node.ownerDocument;
|
var d = this.node.ownerDocument;
|
||||||
var nsResolver = d.createNSResolver(d.documentElement);
|
|
||||||
var contextNode = this.xform.getInstance();
|
var contextNode = this.xform.getInstance();
|
||||||
dojo.debug("locating " + xpath +
|
dojo.debug("locating " + xpath +
|
||||||
" from " + chibaData.nodeName +
|
" from " + chibaData.nodeName +
|
||||||
" in " + contextNode.nodeName);
|
" in " + contextNode.nodeName);
|
||||||
var result = d.evaluate(xpath,
|
var result = _evaluateXPath("/" + xpath,
|
||||||
this.xform.getInstance(),
|
this.xform.getInstance(),
|
||||||
nsResolver,
|
XPathResult.FIRST_ORDERED_NODE_TYPE);
|
||||||
XPathResult.STRING_TYPE,
|
result = (result.nodeType == dojo.dom.ELEMENT_NODE
|
||||||
null);
|
? dojo.dom.textContent(result)
|
||||||
return (result.stringValue != null && result.stringValue.length > 0
|
: result.nodeValue);
|
||||||
? result.stringValue
|
dojo.debug("resolved xpath " + xpath + " to " + result);
|
||||||
: null);
|
return result;
|
||||||
},
|
},
|
||||||
_getLabelNode: function()
|
_getLabelNode: function()
|
||||||
{
|
{
|
||||||
var labels = this.node.getElementsByTagName("label");
|
var labels = _getElementsByTagNameNS(this.node, XFORMS_NS, XFORMS_NS_PREFIX, "label");
|
||||||
for (var i = 0; i < labels.length; i++)
|
for (var i = 0; i < labels.length; i++)
|
||||||
{
|
{
|
||||||
dojo.debug("parent " + labels[i].parentNode.nodeName +
|
dojo.debug("parent " + labels[i].parentNode.nodeName +
|
||||||
@@ -155,6 +170,7 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
this.alertDiv.appendChild(document.createTextNode(this.getAlert()));
|
this.alertDiv.appendChild(document.createTextNode(this.getAlert()));
|
||||||
this.domContainer.parentNode.insertBefore(this.alertDiv, this.domContainer);
|
this.domContainer.parentNode.insertBefore(this.alertDiv, this.domContainer);
|
||||||
this.alertDiv.setAttribute("style", "color:red; position: relative; top: 0px; left: 0px;");
|
this.alertDiv.setAttribute("style", "color:red; position: relative; top: 0px; left: 0px;");
|
||||||
|
this.widget.style.borderColor = "red";
|
||||||
},
|
},
|
||||||
hideAlert: function()
|
hideAlert: function()
|
||||||
{
|
{
|
||||||
@@ -162,6 +178,7 @@ dojo.declare("alfresco.xforms.Widget",
|
|||||||
{
|
{
|
||||||
dojo.dom.removeNode(this.alertDiv);
|
dojo.dom.removeNode(this.alertDiv);
|
||||||
this.alertDiv = null;
|
this.alertDiv = null;
|
||||||
|
this.widget.style.borderColor = "black";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_updateDisplay: function()
|
_updateDisplay: function()
|
||||||
@@ -247,7 +264,6 @@ dojo.declare("alfresco.xforms.TextField",
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
var initial_value = this.getInitialValue() || "";
|
var initial_value = this.getInitialValue() || "";
|
||||||
@@ -285,224 +301,221 @@ dojo.declare("alfresco.xforms.TextField",
|
|||||||
dojo.declare("alfresco.xforms.TextArea",
|
dojo.declare("alfresco.xforms.TextArea",
|
||||||
alfresco.xforms.Widget,
|
alfresco.xforms.Widget,
|
||||||
{
|
{
|
||||||
initializer: function(xform, node)
|
initializer: function(xform, node)
|
||||||
{
|
{
|
||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
},
|
},
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
this.domNode = document.createElement("div");
|
this.domNode = document.createElement("div");
|
||||||
attach_point.appendChild(this.domNode);
|
attach_point.appendChild(this.domNode);
|
||||||
this.domNode.setAttribute("style", "height: 200px; border: solid 1px black;");
|
this.domNode.setAttribute("style", "height: 200px; border: solid 1px black;");
|
||||||
this.domNode.setAttribute("id", this.id);
|
this.domNode.setAttribute("id", this.id);
|
||||||
this.domNode.innerHTML = this.getInitialValue() || "";
|
this.domNode.innerHTML = this.getInitialValue() || "";
|
||||||
tinyMCE.addMCEControl(this.domNode, this.id);
|
tinyMCE.addMCEControl(this.domNode, this.id);
|
||||||
},
|
this.widget = this.domNode;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("alfresco.xforms.AbstractSelectWidget",
|
dojo.declare("alfresco.xforms.AbstractSelectWidget",
|
||||||
alfresco.xforms.Widget,
|
alfresco.xforms.Widget,
|
||||||
{
|
{
|
||||||
initializer: function(xform, node)
|
initializer: function(xform, node)
|
||||||
{
|
|
||||||
this.inherited("initializer", [ xform, node ]);
|
|
||||||
},
|
|
||||||
getValues: function()
|
|
||||||
{
|
|
||||||
var binding = this._getBinding();
|
|
||||||
var values = this.node.getElementsByTagName("item");
|
|
||||||
var result = [];
|
|
||||||
for (var v in values)
|
|
||||||
{
|
{
|
||||||
if (values[v].getElementsByTagName)
|
this.inherited("initializer", [ xform, node ]);
|
||||||
{
|
},
|
||||||
var label = values[v].getElementsByTagName("label")[0];
|
getValues: function()
|
||||||
var value = values[v].getElementsByTagName("value")[0];
|
{
|
||||||
|
var binding = this._getBinding();
|
||||||
|
var values = _getElementsByTagNameNS(this.node, XFORMS_NS, XFORMS_NS_PREFIX, "item");
|
||||||
|
var result = [];
|
||||||
|
for (var v = 0; v < values.length; v++)
|
||||||
|
{
|
||||||
|
var label = _getElementsByTagNameNS(values[v], XFORMS_NS, XFORMS_NS_PREFIX, "label")[0];
|
||||||
|
var value = _getElementsByTagNameNS(values[v], XFORMS_NS, XFORMS_NS_PREFIX, "value")[0];
|
||||||
var valid = true;
|
var valid = true;
|
||||||
if (binding.constraint)
|
if (binding.constraint)
|
||||||
{
|
{
|
||||||
dojo.debug("testing " + binding.constraint +
|
dojo.debug("testing " + binding.constraint +
|
||||||
" on " + dojo.dom.textContent(value));
|
" on " + dojo.dom.textContent(value));
|
||||||
var d = this.node.ownerDocument;
|
valid = _evaluateXPath(binding.constraint, value, XPathResult.BOOLEAN_TYPE);
|
||||||
valid = d.evaluate(binding.constraint,
|
|
||||||
value,
|
|
||||||
d.createNSResolver(d.documentElement),
|
|
||||||
XPathResult.ANY_TYPE,
|
|
||||||
null);
|
|
||||||
dojo.debug("valid " + dojo.dom.textContent(value) + "? " + valid);
|
|
||||||
valid = valid.booleanValue;
|
|
||||||
}
|
}
|
||||||
|
dojo.debug("valid " + dojo.dom.textContent(value) + "? " + valid);
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
result.push({
|
result.push({
|
||||||
id: value.getAttribute("id"),
|
id: value.getAttribute("id"),
|
||||||
label: dojo.dom.textContent(label),
|
label: dojo.dom.textContent(label),
|
||||||
value: dojo.dom.textContent(value)
|
value: dojo.dom.textContent(value)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("alfresco.xforms.Select",
|
dojo.declare("alfresco.xforms.Select",
|
||||||
alfresco.xforms.AbstractSelectWidget,
|
alfresco.xforms.AbstractSelectWidget,
|
||||||
{
|
{
|
||||||
initializer: function(xform, node)
|
initializer: function(xform, node)
|
||||||
{
|
|
||||||
this.inherited("initializer", [ xform, node ]);
|
|
||||||
},
|
|
||||||
render: function(attach_point)
|
|
||||||
{
|
|
||||||
var values = this.getValues();
|
|
||||||
for (var i in values)
|
|
||||||
{
|
{
|
||||||
dojo.debug("values["+ i + "] = " + values[i].id +
|
this.inherited("initializer", [ xform, node ]);
|
||||||
", " + values[i].label + ", " + values[i].value);
|
},
|
||||||
|
render: function(attach_point)
|
||||||
|
{
|
||||||
|
var values = this.getValues();
|
||||||
|
for (var i in values)
|
||||||
|
{
|
||||||
|
dojo.debug("values["+ i + "] = " + values[i].id +
|
||||||
|
", " + values[i].label + ", " + values[i].value);
|
||||||
|
}
|
||||||
|
var initial_value = this.getInitialValue();
|
||||||
|
if (values.length <= 5)
|
||||||
|
{
|
||||||
|
for (var i in values)
|
||||||
|
{
|
||||||
|
this.widget = document.createElement("span");
|
||||||
|
attach_point.appendChild(this.widget);
|
||||||
|
var checkbox = document.createElement("input");
|
||||||
|
checkbox.setAttribute("id", this.id + "_" + i + "-widget");
|
||||||
|
checkbox.setAttribute("name", this.id + "_" + i + "-widget");
|
||||||
|
checkbox.setAttribute("type", "checkbox");
|
||||||
|
checkbox.setAttribute("value", values[i].value);
|
||||||
|
if (values[i].value == initial_value)
|
||||||
|
checkbox.setAttribute("checked", "true");
|
||||||
|
dojo.event.connect(checkbox, "onclick", this, this._checkbox_clickHandler);
|
||||||
|
this.widget.appendChild(checkbox);
|
||||||
|
this.widget.appendChild(document.createTextNode(values[i].label));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
initial_value = initial_value ? initial_value.split(' ') : [];
|
||||||
|
this.widget = document.createElement("select");
|
||||||
|
this.widget.setAttribute("id", this.id + "-widget");
|
||||||
|
this.widget.setAttribute("multiple", true);
|
||||||
|
attach_point.appendChild(this.widget);
|
||||||
|
for (var i in values)
|
||||||
|
{
|
||||||
|
var option = document.createElement("option");
|
||||||
|
option.appendChild(document.createTextNode(values[i].label));
|
||||||
|
option.setAttribute("value", values[i].value);
|
||||||
|
if (initial_value.indexOf(values[i].value) != -1)
|
||||||
|
option.setAttribute("selected", "true");
|
||||||
|
this.widget.appendChild(option);
|
||||||
|
}
|
||||||
|
dojo.event.connect(this.widget, "onchange", this, this._list_changeHandler);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_list_changeHandler: function(event)
|
||||||
|
{
|
||||||
|
var selected = [];
|
||||||
|
for (var i = 0; i < event.target.options.length; i++)
|
||||||
|
{
|
||||||
|
if (event.target.options[i].selected)
|
||||||
|
selected.push(event.target.options[i].value);
|
||||||
|
}
|
||||||
|
this.xform.setXFormsValue(this.id, selected.join(" "));
|
||||||
|
},
|
||||||
|
_checkbox_clickHandler: function(event)
|
||||||
|
{
|
||||||
|
var selected = [];
|
||||||
|
for (var i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
var checkbox = document.getElementById(this.id + "_" + i + "-widget");
|
||||||
|
if (checkbox && checkbox.checked)
|
||||||
|
selected.push(checkbox.value);
|
||||||
|
}
|
||||||
|
this.xform.setXFormsValue(this.id, selected.join(" "));
|
||||||
}
|
}
|
||||||
var initial_value = this.getInitialValue();
|
|
||||||
if (values.length <= 5)
|
|
||||||
{
|
|
||||||
for (var i in values)
|
|
||||||
{
|
|
||||||
var checkbox = document.createElement("input");
|
|
||||||
checkbox.setAttribute("id", this.id + "_" + i + "-widget");
|
|
||||||
checkbox.setAttribute("name", this.id + "_" + i + "-widget");
|
|
||||||
checkbox.setAttribute("type", "checkbox");
|
|
||||||
checkbox.setAttribute("value", values[i].value);
|
|
||||||
if (values[i].value == initial_value)
|
|
||||||
checkbox.setAttribute("checked", "true");
|
|
||||||
dojo.event.connect(checkbox, "onclick", this, this._checkbox_clickHandler);
|
|
||||||
attach_point.appendChild(checkbox);
|
|
||||||
attach_point.appendChild(document.createTextNode(values[i].label));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
initial_value = initial_value ? initial_value.split(' ') : [];
|
|
||||||
var list = document.createElement("select");
|
|
||||||
list.setAttribute("id", this.id + "-widget");
|
|
||||||
list.setAttribute("multiple", true);
|
|
||||||
attach_point.appendChild(list);
|
|
||||||
for (var i in values)
|
|
||||||
{
|
|
||||||
var option = document.createElement("option");
|
|
||||||
option.appendChild(document.createTextNode(values[i].label));
|
|
||||||
option.setAttribute("value", values[i].value);
|
|
||||||
if (initial_value.indexOf(values[i].value) != -1)
|
|
||||||
option.setAttribute("selected", "true");
|
|
||||||
list.appendChild(option);
|
|
||||||
}
|
|
||||||
dojo.event.connect(list, "onchange", this, this._list_changeHandler);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_list_changeHandler: function(event)
|
|
||||||
{
|
|
||||||
var selected = [];
|
|
||||||
for (var i = 0; i < event.target.options.length; i++)
|
|
||||||
{
|
|
||||||
if (event.target.options[i].selected)
|
|
||||||
selected.push(event.target.options[i].value);
|
|
||||||
}
|
|
||||||
this.xform.setXFormsValue(this.id, selected.join(" "));
|
|
||||||
},
|
|
||||||
_checkbox_clickHandler: function(event)
|
|
||||||
{
|
|
||||||
var selected = [];
|
|
||||||
for (var i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
var checkbox = document.getElementById(this.id + "_" + i + "-widget");
|
|
||||||
if (checkbox && checkbox.checked)
|
|
||||||
selected.push(checkbox.value);
|
|
||||||
}
|
|
||||||
this.xform.setXFormsValue(this.id, selected.join(" "));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("alfresco.xforms.Select1",
|
dojo.declare("alfresco.xforms.Select1",
|
||||||
alfresco.xforms.AbstractSelectWidget,
|
alfresco.xforms.AbstractSelectWidget,
|
||||||
{
|
{
|
||||||
initializer: function(xform, node)
|
initializer: function(xform, node)
|
||||||
{
|
|
||||||
this.inherited("initializer", [ xform, node ]);
|
|
||||||
},
|
|
||||||
render: function(attach_point)
|
|
||||||
{
|
|
||||||
var values = this.getValues();
|
|
||||||
for (var i in values)
|
|
||||||
{
|
{
|
||||||
dojo.debug("values["+ i + "] = " + values[i].id +
|
this.inherited("initializer", [ xform, node ]);
|
||||||
", " + values[i].label + ", " + values[i].value);
|
},
|
||||||
|
render: function(attach_point)
|
||||||
|
{
|
||||||
|
var values = this.getValues();
|
||||||
|
for (var i in values)
|
||||||
|
{
|
||||||
|
dojo.debug("values["+ i + "] = " + values[i].id +
|
||||||
|
", " + values[i].label + ", " + values[i].value);
|
||||||
|
}
|
||||||
|
var initial_value = this.getInitialValue();
|
||||||
|
if (values.length <= 5)
|
||||||
|
{
|
||||||
|
for (var i in values)
|
||||||
|
{
|
||||||
|
this.widget = document.createElement("span");
|
||||||
|
this.widget.style.width = "100%";
|
||||||
|
attach_point.appendChild(this.widget);
|
||||||
|
var radio = document.createElement("input");
|
||||||
|
radio.setAttribute("id", this.id + "-widget");
|
||||||
|
radio.setAttribute("name", this.id + "-widget");
|
||||||
|
radio.setAttribute("type", "radio");
|
||||||
|
radio.setAttribute("value", values[i].value);
|
||||||
|
if (values[i].value == initial_value)
|
||||||
|
radio.setAttribute("checked", "true");
|
||||||
|
dojo.event.connect(radio, "onclick", this, this._radio_clickHandler);
|
||||||
|
this.widget.appendChild(radio);
|
||||||
|
this.widget.appendChild(document.createTextNode(values[i].label));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.widget = document.createElement("select");
|
||||||
|
this.widget.setAttribute("id", this.id + "-widget");
|
||||||
|
attach_point.appendChild(this.widget);
|
||||||
|
for (var i in values)
|
||||||
|
{
|
||||||
|
var option = document.createElement("option");
|
||||||
|
option.appendChild(document.createTextNode(values[i].label));
|
||||||
|
option.setAttribute("value", values[i].value);
|
||||||
|
if (values[i].value == initial_value)
|
||||||
|
option.setAttribute("selected", "true");
|
||||||
|
this.widget.appendChild(option);
|
||||||
|
}
|
||||||
|
dojo.event.connect(this.widget, "onchange", this, this._combobox_changeHandler);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_combobox_changeHandler: function(event)
|
||||||
|
{
|
||||||
|
this.xform.setXFormsValue(this.id,
|
||||||
|
event.target.options[event.target.selectedIndex].value);
|
||||||
|
},
|
||||||
|
_radio_clickHandler: function(event)
|
||||||
|
{
|
||||||
|
this.xform.setXFormsValue(this.id,
|
||||||
|
event.target.value);
|
||||||
}
|
}
|
||||||
var initial_value = this.getInitialValue();
|
|
||||||
if (values.length <= 5)
|
|
||||||
{
|
|
||||||
for (var i in values)
|
|
||||||
{
|
|
||||||
var radio = document.createElement("input");
|
|
||||||
radio.setAttribute("id", this.id + "-widget");
|
|
||||||
radio.setAttribute("name", this.id + "-widget");
|
|
||||||
radio.setAttribute("type", "radio");
|
|
||||||
radio.setAttribute("value", values[i].value);
|
|
||||||
if (values[i].value == initial_value)
|
|
||||||
radio.setAttribute("checked", "true");
|
|
||||||
dojo.event.connect(radio, "onclick", this, this._radio_clickHandler);
|
|
||||||
attach_point.appendChild(radio);
|
|
||||||
attach_point.appendChild(document.createTextNode(values[i].label));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var combobox = document.createElement("select");
|
|
||||||
combobox.setAttribute("id", this.id + "-widget");
|
|
||||||
attach_point.appendChild(combobox);
|
|
||||||
for (var i in values)
|
|
||||||
{
|
|
||||||
var option = document.createElement("option");
|
|
||||||
option.appendChild(document.createTextNode(values[i].label));
|
|
||||||
option.setAttribute("value", values[i].value);
|
|
||||||
if (values[i].value == initial_value)
|
|
||||||
option.setAttribute("selected", "true");
|
|
||||||
combobox.appendChild(option);
|
|
||||||
}
|
|
||||||
dojo.event.connect(combobox, "onchange", this, this._combobox_changeHandler);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_combobox_changeHandler: function(event)
|
|
||||||
{
|
|
||||||
this.xform.setXFormsValue(this.id,
|
|
||||||
event.target.options[event.target.selectedIndex].value);
|
|
||||||
},
|
|
||||||
_radio_clickHandler: function(event)
|
|
||||||
{
|
|
||||||
this.xform.setXFormsValue(this.id,
|
|
||||||
event.target.value);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("alfresco.xforms.Checkbox",
|
dojo.declare("alfresco.xforms.Checkbox",
|
||||||
alfresco.xforms.Widget,
|
alfresco.xforms.Widget,
|
||||||
{
|
{
|
||||||
initializer: function(xform, node)
|
initializer: function(xform, node)
|
||||||
{
|
{
|
||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
},
|
},
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
var initial_value = this.getInitialValue() == "true";
|
var initial_value = this.getInitialValue() == "true";
|
||||||
this.widget = document.createElement("input");
|
this.widget = document.createElement("input");
|
||||||
this.widget.setAttribute("type", "checkbox");
|
this.widget.setAttribute("type", "checkbox");
|
||||||
this.widget.setAttribute("id", this.id + "-widget");
|
this.widget.setAttribute("id", this.id + "-widget");
|
||||||
if (initial_value)
|
if (initial_value)
|
||||||
this.widget.setAttribute("checked", true);
|
this.widget.setAttribute("checked", true);
|
||||||
attach_point.appendChild(this.widget);
|
attach_point.appendChild(this.widget);
|
||||||
dojo.event.connect(this.widget, "onclick", this, this._checkbox_clickHandler);
|
dojo.event.connect(this.widget, "onclick", this, this._checkbox_clickHandler);
|
||||||
},
|
},
|
||||||
_checkbox_clickHandler: function(event)
|
_checkbox_clickHandler: function(event)
|
||||||
{
|
{
|
||||||
this.xform.setXFormsValue(this.id, this.widget.checked);
|
this.xform.setXFormsValue(this.id, this.widget.checked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("alfresco.xforms.Group",
|
dojo.declare("alfresco.xforms.Group",
|
||||||
@@ -552,7 +565,11 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
child.parent = this;
|
child.parent = this;
|
||||||
|
|
||||||
child.domContainer = document.createElement("div");
|
child.domContainer = document.createElement("div");
|
||||||
child.domContainer.setAttribute("style", "position: relative; border: 0px solid green; margin-top: 2px; margin-bottom: 2px;");
|
child.domContainer.setAttribute("id", child.id + "-domContainer");
|
||||||
|
child.domContainer.setAttribute("style", "border: 0px solid green; margin-top: 2px; margin-bottom: 2px;");
|
||||||
|
child.domContainer.style.position = "relative";
|
||||||
|
child.domContainer.style.left = "0px";
|
||||||
|
child.domContainer.style.top = "0px";
|
||||||
child.domContainer.style.width = "100%";
|
child.domContainer.style.width = "100%";
|
||||||
if (this.parent && this.parent.domNode)
|
if (this.parent && this.parent.domNode)
|
||||||
child.domContainer.style.top = this.parent.domNode.style.bottom;
|
child.domContainer.style.top = this.parent.domNode.style.bottom;
|
||||||
@@ -603,6 +620,8 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
child.domContainer.style.height = Math.max(contentDiv.offsetHeight, 20) + "px";
|
child.domContainer.style.height = Math.max(contentDiv.offsetHeight, 20) + "px";
|
||||||
child.domContainer.style.lineHeight = child.domContainer.style.height;
|
child.domContainer.style.lineHeight = child.domContainer.style.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dojo.debug(contentDiv.getAttribute("id") + " offsetTop is " + contentDiv.offsetTop);
|
||||||
contentDiv.style.top = "-" + contentDiv.offsetTop + "px";
|
contentDiv.style.top = "-" + contentDiv.offsetTop + "px";
|
||||||
contentDiv.widget = child;
|
contentDiv.widget = child;
|
||||||
|
|
||||||
@@ -638,6 +657,9 @@ dojo.declare("alfresco.xforms.Group",
|
|||||||
attach_point.appendChild(this.domNode);
|
attach_point.appendChild(this.domNode);
|
||||||
|
|
||||||
this.domNode.setAttribute("style", "border: 0px solid blue;");
|
this.domNode.setAttribute("style", "border: 0px solid blue;");
|
||||||
|
this.domNode.style.position = "relative";
|
||||||
|
this.domNode.style.top = "0px";
|
||||||
|
this.domNode.style.left = "0px";
|
||||||
this.domNode.style.width = "100%";
|
this.domNode.style.width = "100%";
|
||||||
if (this.isIndented())
|
if (this.isIndented())
|
||||||
this.domNode.style.marginLeft = "10px";
|
this.domNode.style.marginLeft = "10px";
|
||||||
@@ -666,9 +688,9 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
child.repeat = this;
|
child.repeat = this;
|
||||||
|
|
||||||
dojo.event.connect(result, "onclick", function(event)
|
dojo.event.connect(result, "onclick", function(event)
|
||||||
{
|
{
|
||||||
child.repeat.setFocusedChild(child);
|
child.repeat.setFocusedChild(child);
|
||||||
});
|
});
|
||||||
|
|
||||||
var controls = document.createElement("div");
|
var controls = document.createElement("div");
|
||||||
result.appendChild(controls);
|
result.appendChild(controls);
|
||||||
@@ -686,7 +708,7 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
{
|
{
|
||||||
var img = document.createElement("img");
|
var img = document.createElement("img");
|
||||||
img.setAttribute("src", (WEBAPP_CONTEXT + "/images/icons/" +
|
img.setAttribute("src", (WEBAPP_CONTEXT + "/images/icons/" +
|
||||||
images[i].src + ".gif"));
|
images[i].src + ".gif"));
|
||||||
img.style.width = "16px";
|
img.style.width = "16px";
|
||||||
img.style.height = "16px";
|
img.style.height = "16px";
|
||||||
img.style.marginRight = "4px";
|
img.style.marginRight = "4px";
|
||||||
@@ -738,7 +760,7 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
this.setFocusedChild(event.target.repeatItem);
|
this.setFocusedChild(event.target.repeatItem);
|
||||||
if (!this.removeRepeatItemTrigger)
|
if (!this.removeRepeatItemTrigger)
|
||||||
this.removeRepeatItemTrigger = _findElementById(this.node.parentNode,
|
this.removeRepeatItemTrigger = _findElementById(this.node.parentNode,
|
||||||
this.id + "-delete");
|
this.id + "-delete");
|
||||||
this.xform.fireAction(this.removeRepeatItemTrigger.getAttribute("id"));
|
this.xform.fireAction(this.removeRepeatItemTrigger.getAttribute("id"));
|
||||||
},
|
},
|
||||||
_moveRepeatItemUp_handler: function(event)
|
_moveRepeatItemUp_handler: function(event)
|
||||||
@@ -819,13 +841,19 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
var d = document.createElement("div");
|
var d = document.createElement("div");
|
||||||
d.repeat = this;
|
d.repeat = this;
|
||||||
this.domNode.appendChild(d);
|
this.domNode.appendChild(d);
|
||||||
d.setAttribute("style", "position: relative; height: 20px; line-height: 20px; background-color: #cddbe8; font-weight: bold;");
|
d.style.position = "relative";
|
||||||
|
d.style.top = "0px";
|
||||||
|
d.style.left = "0px";
|
||||||
|
d.style.height = "20px";
|
||||||
|
d.style.lineHeight = "20px";
|
||||||
|
d.style.backgroundColor = "#cddbe8";
|
||||||
|
d.style.fontWeight = "bold";
|
||||||
d.style.width = "100%";
|
d.style.width = "100%";
|
||||||
dojo.event.connect(d, "onclick", function(event)
|
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");
|
var requiredImage = document.createElement("img");
|
||||||
@@ -862,9 +890,7 @@ dojo.declare("alfresco.xforms.Repeat",
|
|||||||
handlePrototypeCloned: function(prototypeId)
|
handlePrototypeCloned: function(prototypeId)
|
||||||
{
|
{
|
||||||
dojo.debug(this.id + ".handlePrototypeCloned("+ prototypeId +")");
|
dojo.debug(this.id + ".handlePrototypeCloned("+ prototypeId +")");
|
||||||
var chibaData = this.node.getElementsByTagName("data");
|
var chibaData = _getElementsByTagNameNS(this.node, CHIBA_NS, CHIBA_NS_PREFIX, "data");
|
||||||
dojo.debug("repeat node == " +dojo.dom.innerXML(this.node));
|
|
||||||
dojo.debug(chibaData + " l = " + chibaData.length);
|
|
||||||
chibaData = chibaData[chibaData.length - 1];
|
chibaData = chibaData[chibaData.length - 1];
|
||||||
dojo.debug("chiba:data == " + dojo.dom.innerXML(chibaData));
|
dojo.debug("chiba:data == " + dojo.dom.innerXML(chibaData));
|
||||||
var prototypeToClone = dojo.dom.firstElement(chibaData);
|
var prototypeToClone = dojo.dom.firstElement(chibaData);
|
||||||
@@ -920,15 +946,41 @@ dojo.declare("alfresco.xforms.Submit",
|
|||||||
initializer: function(xform, node)
|
initializer: function(xform, node)
|
||||||
{
|
{
|
||||||
this.inherited("initializer", [ xform, node ]);
|
this.inherited("initializer", [ xform, node ]);
|
||||||
|
var submit_buttons = _xforms_getSubmitButtons();
|
||||||
|
for (var i = 0; i < submit_buttons.length; i++)
|
||||||
|
{
|
||||||
|
dojo.debug("adding submit handler for " + submit_buttons[i].getAttribute('id'));
|
||||||
|
submit_buttons[i].xform = this.xform;
|
||||||
|
dojo.event.browser.addListener(submit_buttons[i], "onclick", function(event)
|
||||||
|
{
|
||||||
|
var xform = event.target.xform;
|
||||||
|
if (!xform.submitWidget.done)
|
||||||
|
{
|
||||||
|
dojo.debug("triggering submit from handler " + event.target.id);
|
||||||
|
dojo.event.browser.stopEvent(event);
|
||||||
|
tinyMCE.triggerSave();
|
||||||
|
_hide_errors();
|
||||||
|
xform.submitWidget.currentButton = event.target;
|
||||||
|
xform.submitWidget.widget.buttonClick();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dojo.debug("done - doing base click on " + xform.submitWidget.currentButton.id);
|
||||||
|
xform.submitWidget.currentButton = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
this.inherited("render", [ attach_point ]);
|
this.inherited("render", [ attach_point ]);
|
||||||
document.submitWidget = this;
|
this.xform.submitWidget = this;
|
||||||
},
|
},
|
||||||
_clickHandler: function(event)
|
_clickHandler: function(event)
|
||||||
{
|
{
|
||||||
document.submitWidget.done = false;
|
this.done = false;
|
||||||
this.xform.fireAction(this.id);
|
this.xform.fireAction(this.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -964,12 +1016,12 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
initializer: function()
|
initializer: function()
|
||||||
{
|
{
|
||||||
send_ajax_request(create_ajax_request(this,
|
send_ajax_request(create_ajax_request(this,
|
||||||
"getXForm",
|
"getXForm",
|
||||||
{},
|
{},
|
||||||
function(type, data, evt)
|
function(type, data, evt)
|
||||||
{
|
{
|
||||||
this.xform._loadHandler(data);
|
this.xform._loadHandler(data);
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
_loadHandler: function(xformDocument)
|
_loadHandler: function(xformDocument)
|
||||||
{
|
{
|
||||||
@@ -987,7 +1039,6 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
}
|
}
|
||||||
var alfUI = document.getElementById("alf-ui");
|
var alfUI = document.getElementById("alf-ui");
|
||||||
alfUI.style.width = "100%";
|
alfUI.style.width = "100%";
|
||||||
|
|
||||||
this.rootWidget = new alfresco.xforms.Group(this, alfUI);
|
this.rootWidget = new alfresco.xforms.Group(this, alfUI);
|
||||||
this.rootWidget.render(alfUI);
|
this.rootWidget.render(alfUI);
|
||||||
this.loadWidgets(this.getBody(), this.rootWidget);
|
this.loadWidgets(this.getBody(), this.rootWidget);
|
||||||
@@ -995,10 +1046,11 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
},
|
},
|
||||||
createWidget: function(node)
|
createWidget: function(node)
|
||||||
{
|
{
|
||||||
|
dojo.debug("creating node for " + node.nodeName.toLowerCase());
|
||||||
switch (node.nodeName.toLowerCase())
|
switch (node.nodeName.toLowerCase())
|
||||||
{
|
{
|
||||||
case "xforms:group":
|
case "xforms:group":
|
||||||
return new alfresco.xforms.Group(this, node);
|
return new alfresco.xforms.Group(this, node);
|
||||||
case "xforms:repeat":
|
case "xforms:repeat":
|
||||||
return new alfresco.xforms.Repeat(this, node);
|
return new alfresco.xforms.Repeat(this, node);
|
||||||
case "xforms:textarea":
|
case "xforms:textarea":
|
||||||
@@ -1035,7 +1087,7 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
? new alfresco.xforms.Checkbox(this, node)
|
? new alfresco.xforms.Checkbox(this, node)
|
||||||
: new alfresco.xforms.Select1(this, node));
|
: new alfresco.xforms.Select1(this, node));
|
||||||
case "xforms:submit":
|
case "xforms:submit":
|
||||||
return new alfresco.xforms.Submit(this, node);
|
return new alfresco.xforms.Submit(this, node);
|
||||||
case "xforms:trigger":
|
case "xforms:trigger":
|
||||||
return new alfresco.xforms.Trigger(this, node);
|
return new alfresco.xforms.Trigger(this, node);
|
||||||
case "chiba:data":
|
case "chiba:data":
|
||||||
@@ -1053,11 +1105,12 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
if (modelNode.childNodes[i].nodeType == dojo.dom.ELEMENT_NODE)
|
if (modelNode.childNodes[i].nodeType == dojo.dom.ELEMENT_NODE)
|
||||||
{
|
{
|
||||||
dojo.debug("loading " + modelNode.childNodes[i] +
|
dojo.debug("loading " + modelNode.childNodes[i] +
|
||||||
" nodeName " + modelNode.childNodes[i].nodeName +
|
" nodeName " + modelNode.childNodes[i].nodeName +
|
||||||
" into " + parentWidget);
|
" into " + parentWidget.id);
|
||||||
var w = this.createWidget(modelNode.childNodes[i]);
|
var w = this.createWidget(modelNode.childNodes[i]);
|
||||||
if (w != null)
|
if (w != null)
|
||||||
{
|
{
|
||||||
|
dojo.debug("created " + w.id + " for " + modelNode.childNodes[i].nodeName);
|
||||||
parentWidget.addChild(w);
|
parentWidget.addChild(w);
|
||||||
if (w instanceof alfresco.xforms.Group)
|
if (w instanceof alfresco.xforms.Group)
|
||||||
this.loadWidgets(modelNode.childNodes[i], w);
|
this.loadWidgets(modelNode.childNodes[i], w);
|
||||||
@@ -1067,16 +1120,25 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
},
|
},
|
||||||
getModel: function()
|
getModel: function()
|
||||||
{
|
{
|
||||||
return this.node.getElementsByTagName("model")[0];
|
return _getElementsByTagNameNS(this.node,
|
||||||
|
XFORMS_NS,
|
||||||
|
XFORMS_NS_PREFIX,
|
||||||
|
"model")[0];
|
||||||
},
|
},
|
||||||
getInstance: function()
|
getInstance: function()
|
||||||
{
|
{
|
||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
return model.getElementsByTagName("instance")[0];
|
return _getElementsByTagNameNS(model,
|
||||||
|
XFORMS_NS,
|
||||||
|
XFORMS_NS_PREFIX,
|
||||||
|
"instance")[0];
|
||||||
},
|
},
|
||||||
getBody: function()
|
getBody: function()
|
||||||
{
|
{
|
||||||
var b = this.node.getElementsByTagName("body");
|
var b = _getElementsByTagNameNS(this.node,
|
||||||
|
XHTML_NS,
|
||||||
|
XHTML_NS_PREFIX,
|
||||||
|
"body");
|
||||||
return b[b.length - 1];
|
return b[b.length - 1];
|
||||||
},
|
},
|
||||||
getType: function(node)
|
getType: function(node)
|
||||||
@@ -1216,11 +1278,10 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "chiba-replace-all":
|
case "chiba-replace-all":
|
||||||
if (document.submitWidget)
|
if (this.submitWidget)
|
||||||
{
|
{
|
||||||
document.submitWidget.done = true;
|
this.submitWidget.done = true;
|
||||||
document.submitWidget.currentButton.click();
|
this.submitWidget.currentButton.click();
|
||||||
document.submitWidget.currentButton = null;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "xforms-valid":
|
case "xforms-valid":
|
||||||
@@ -1259,28 +1320,6 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function addSubmitHandlerToButton(b)
|
|
||||||
{
|
|
||||||
var baseOnClick = b.onclick;
|
|
||||||
b.onclick = function(event)
|
|
||||||
{
|
|
||||||
if (!document.submitWidget.done)
|
|
||||||
{
|
|
||||||
dojo.debug("not done, resubmitting");
|
|
||||||
tinyMCE.triggerSave();
|
|
||||||
_hide_errors();
|
|
||||||
document.submitWidget.currentButton = this;
|
|
||||||
document.submitWidget.widget.buttonClick();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dojo.debug("done - doing base click");
|
|
||||||
return baseOnClick(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _findElementById(node, id)
|
function _findElementById(node, id)
|
||||||
{
|
{
|
||||||
dojo.debug("looking for " + id +
|
dojo.debug("looking for " + id +
|
||||||
@@ -1302,17 +1341,16 @@ function _findElementById(node, id)
|
|||||||
|
|
||||||
function create_ajax_request(xform, serverMethod, methodArgs, load, error)
|
function create_ajax_request(xform, serverMethod, methodArgs, load, error)
|
||||||
{
|
{
|
||||||
var result = {};
|
var result = new dojo.io.Request(WEBAPP_CONTEXT + "/ajax/invoke/XFormsBean." + serverMethod, "text/xml");
|
||||||
result.xform = xform;
|
result.xform = xform;
|
||||||
result.url = WEBAPP_CONTEXT + "/ajax/invoke/XFormsBean." + serverMethod;
|
|
||||||
result.content = methodArgs;
|
result.content = methodArgs;
|
||||||
|
|
||||||
result.load = load;
|
result.load = load;
|
||||||
dojo.event.connect(result, "load", function(type, data, evt)
|
dojo.event.connect(result, "load", function(type, data, evt)
|
||||||
{
|
{
|
||||||
// _hide_errors();
|
// _hide_errors();
|
||||||
ajax_request_load_handler(this);
|
ajax_request_load_handler(this);
|
||||||
});
|
});
|
||||||
result.mimetype = "text/xml";
|
|
||||||
result.error = error || function(type, e)
|
result.error = error || function(type, e)
|
||||||
{
|
{
|
||||||
dojo.debug("error [" + type + "] " + e.message);
|
dojo.debug("error [" + type + "] " + e.message);
|
||||||
@@ -1414,3 +1452,86 @@ function ajax_request_load_handler(req)
|
|||||||
throw new Error("unable to find " + req.url);
|
throw new Error("unable to find " + req.url);
|
||||||
ajax_loader_update_display();
|
ajax_loader_update_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _getElementsByTagNameNS(parentNode, ns, nsPrefix, tagName)
|
||||||
|
{
|
||||||
|
return (parentNode.getElementsByTagNameNS
|
||||||
|
? parentNode.getElementsByTagNameNS(ns, tagName)
|
||||||
|
: parentNode.getElementsByTagName(nsPrefix + ":" + tagName));
|
||||||
|
}
|
||||||
|
|
||||||
|
function _evaluateXPath(xpath, contextNode, result_type)
|
||||||
|
{
|
||||||
|
var xmlDocument = contextNode.ownerDocument;
|
||||||
|
dojo.debug("evaluating xpath " + xpath + " on node " + contextNode.nodeName +
|
||||||
|
" in document " + xmlDocument);
|
||||||
|
var result = null;
|
||||||
|
if (xmlDocument.evaluate)
|
||||||
|
{
|
||||||
|
var nsResolver = (xmlDocument.createNSResolver
|
||||||
|
? xmlDocument.createNSResolver(xmlDocument.documentElement) :
|
||||||
|
null);
|
||||||
|
result = xmlDocument.evaluate(xpath,
|
||||||
|
contextNode,
|
||||||
|
nsResolver,
|
||||||
|
result_type,
|
||||||
|
null);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
switch (result_type)
|
||||||
|
{
|
||||||
|
case XPathResult.FIRST_ORDERED_NODE_TYPE:
|
||||||
|
result = result.singleNodeValue;
|
||||||
|
break;
|
||||||
|
case XPathResult.BOOLEAN_TYPE:
|
||||||
|
result = result.booleanValue;
|
||||||
|
break;
|
||||||
|
case XPathResult.STRING_TYPE:
|
||||||
|
result = result.stringValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xmlDocument.setProperty("SelectionLanguage", "XPath");
|
||||||
|
var namespaces = [];
|
||||||
|
for (var i = 0; i < xmlDocument.documentElement.attributes.length; i++)
|
||||||
|
{
|
||||||
|
var attr = xmlDocument.documentElement.attributes[i];
|
||||||
|
if (attr.nodeName.match(/^xmlns:/))
|
||||||
|
namespaces.push(attr.nodeName + "=\'" + attr.nodeValue + "\'");
|
||||||
|
}
|
||||||
|
dojo.debug("using namespaces " + namespaces.join(","));
|
||||||
|
xmlDocument.setProperty("SelectionNamespaces", namespaces.join(' '));
|
||||||
|
if (result_type == XPathResult.FIRST_ORDERED_NODE_TYPE)
|
||||||
|
result = xmlDocument.selectSingleNode(xpath);
|
||||||
|
else if (result_type == XPathResult.BOOLEAN_TYPE)
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
dojo.debug("resolved xpath " + xpath + " to " + result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!XPathResult)
|
||||||
|
{
|
||||||
|
var XPathResult = {};
|
||||||
|
XPathResult.ANY_TYPE = 0;
|
||||||
|
XPathResult.NUMBER_TYPE = 1;
|
||||||
|
XPathResult.STRING_TYPE = 2;
|
||||||
|
XPathResult.BOOEAN_TYPE = 3;
|
||||||
|
XPathResult.FIRST_ORDERED_NODE_TYPE = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Array.prototype.indexOf)
|
||||||
|
{
|
||||||
|
Array.prototype.indexOf = function(o)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < this.length; i++)
|
||||||
|
{
|
||||||
|
if (this[i] == o)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user