In XDIME 2 you provide different variants for specific devices or device families in a script policy. However, the script element that contains the binding to the policy requires the mcs: namespace prefix.
In XDIME 2 you provide different variants for specific devices or device families in a script policy. However, the script element that contains the binding to the policy requires the mcs: namespace prefix.
XDIME 2 supports subsets of XHTML DOM Level 2 mouse and HTML events, and XForms interaction and notification events. The tables show the events and the targeted XDIME 2 elements.
Mouse event | XDIME 2 element |
---|---|
click | all |
mousedown | all |
mouseup | all |
mouseover | all |
mousemove | all |
mouseout | all |
HTML event | XDIME 2 element |
---|---|
load | body |
unload | body |
resize | body |
focus | a |
blur | a |
XForms event | XDIME 2 element |
---|---|
xforms-blur | input, secret, textarea, select, select1, submit |
xforms-focus | input, secret, textarea, select, select1, submit |
xforms-submit | submission |
xforms-value-changed | input, secret, textarea, select, select1 |
In addition to the mcs:script element, you use the event:listener and the mcs:handler elements.
In the listener, you specify the identifier of the event in the observer attribute, the fragment identifier of a local event handler in the handler attribute, and the event type in the event attribute. The handler contains an inline script, which may also call functions in a script policy. Currently the 'text/javascript' type is supported.
The Client Framework 2 components must use cf2:on instead of a combination of mcs:handler and event:listener.
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
xmlns:mcs="http://www.volantis.com/xmlns/2006/01/xdime/mcs"
xmlns:event="http://www.w3.org/2001/xml-events">
<head>
<title>Welcome to XDIME Events</title>
</head>
<body>
<mcs:handler id="handler" type="text/javascript">alert('hello')</mcs:handler>
<event:listener observer="p" handler="#handler" event="click"/>
<p id="p">Click me!</p>
</body>
</html>
The mcs:noscript element can be used to replace the output of a mcs:script element when no script variant is available, when a device does not support scripting, or when the user has disabled scripting. You use the idref attribute value to identify a mcs:script element with a matching id attribute. If the attribute is not specified, then the element provides alternative markup for use when a device does not support scripting, or when the user has disabled scripting. If the attribute is specified, then the element provides alternative markup for use when the selected script cannot be processed by the targeted device. Please note that mcs:noscript can appear anywhere on an XDIME 2 page, however, it must be placed after the mcs:script element to which it refers.
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
xmlns:mcs="http://www.volantis.com/xmlns/2006/01/xdime/mcs">
<head>
<title>mcs:noscript</title>
<mcs:script src="/script.mscr" srctype="application/vnd.volantis.mcs-script"
id="my-script"/>
<mcs:script src="../script.js" srctype="text/javascript"/>
</head>
<body>
<p>Welcome</p>
<mcs:noscript idref="my-script">
<p>No script variant is available.</p>
</mcs:noscript>
<mcs:noscript>
<p>The device does not support scripting, or the user has
disabled scripting.</p>
</mcs:noscript>
</body>
</html>