xw.js is a Javascript-library with general global functions, available
as properties at instance "jQuery.fn.xwalk". These support in dealing with
XML in browsers and offer simple access to localize and internationalize
websites and web-apps by usage of standard datatypes.
For better readability, in the following the instance "jQuery.fn.xwalk" shall
be reachable at variable "xw", i.e. "xw" is assumed to be defined as var xw = jQuery.fn.xwalk;
xw.buttonState (Type: object)
Contains functions to set and query the "enabled"-state of buttons, i.e. whether
buttons are clickable (enabled) or greyed (disabled).
If other button-types shall be used, a suitable pair of functions can be set here
(xw.buttonState = {...}).
xw.optProp (Type: function) Return: Type of desired property or type of default-value Delivers the value of a property of the passed object-instance "opt". If the instance
doesn't contain the named property, the passed default-value is delivered. Parameters:
opt (Type: object) Object, to read a property from.
name (Type: string) Name of property to be read.
def (Type: beliebig) Default-value to deliver, if property not exists.
name (Type: string) Simple selector (see parameter "s" in xw.select()).
val (Type: string) Value, which is compared to selected element-/attribute-values.
The function is defined as xw.filter = function (name, val) { return function () { return xw.select(this, name) == val } };
xw.format (Type: function) Return: string|null Function for formatting values in an HTML-parent-element. Standard datatypes are evaluated. "xw.format" is defined as follows: Parameters:
v (Type: string) Value to be formatted (raw data of a cell).
opt (Type: object) Meta-infos for a column (see property "meta" (col-elements) for xw-browse initialization);
the attributes of a col-element are reachable as properties having
the same name as the corresponding attributes.
(Exception: attribute "class" is reachable as property "cl"; if no
class-attribute was defined, "cl" contains the value of attribute "s").
Via selector-property "s" the column to be formatted is readily identifiable.
row (Type: element-node) XML-row as element-node. "row" allows access to all row-values, so
multiple data-parts of a row can be formatted as a cell content.
To read a column-value from an XML-row-element, a simple selector (see
col-elements of meta-infos) can be used as parameter for function xw.select() (see below).
parent (Type: jQuery) The HTML-cell-"div"-element, encapsulated as jQuery-object.
Instead of returning a string-value to be written to the cell element,
here the cell element can be extended directly with HTML, e.g. to insert
an image. If this method is used, the function must return "null".
For an example see the globally overridden function "xw.formatBool" in Demo for xw-browse.
xw.select (Type: function) Return: string The function delivers the value of a child-element or of an attribute of the passed
XML-element-node, identified by a simple selector (see initialization of xw-browse:
col-elements, attribute "s"). Parameters:
data (Type: XML-element-node) An XML-element-node containing the value to be selected as attribute
or direct child-element.
s (Type: string) Simple selector (name of child-element containing the desired value
or name of attribute with prefix "@").
allLines (Type: bool, Default: false) Controls, whether all lines of multi-line-text-content are to
be delivered or only the first line.
Multi-line-text-content must be contained in direct child-elements of "data"
as follows (every text-line is wrapped with its own "line"-element; the
background is, that "normal" line-breaks in XML-text-nodes are treated as
"whitespace" and can be got lost, potentially):
Example for a multi-line-text-content in child-element "col1": If false is passed, only the first line (with an appended ellipsis
("…")-character) is returned. Otherwise, the text-lines are
separated by the new-line-character ("\n") in the returned string.