QX.js Scripting Guide

Working with Spans

QXML for spans

Span is represented by <qx-span> node. It contains following attributes:

 

Attribute

Value

Description

id

id

Unique Element ID to create anchor

class

text

Name of Character style sheet and space separated text shading style

Create new span

To create a new span:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> and <qx-p> element.

  3. Create new <qx-span> element.

  4. Append the <qx-span> element as child of <qx-p> node.

Sample JavaScript:

var layout=app.activeLayoutDOM();
var boxes=layout.getElementsByTagName('qx-box')[0];
var paras=boxes.getElementsByTagName('qx-p')[0];
var newSpan=document.createElement('qx-span');
newSpan.innerText='NEW SPAN';
paras.appendChild(newSpan);

Delete existing span

To delete an existing span:

  1. Get the DOM of the active layout.

  2. Get the <qx-box>,<qx-p>,<qx-span> node corresponding to the span to be deleted.

  3. Remove the <qx-span> child node from <qx-p> node.

Sample JavaScript:

var layout=app.activeLayoutDOM();
 
var boxes=layout.getElementsByTagName('qx-box')[0];
var paras=boxes.getElementsByTagName('qx-p')[0];
var spans=paras.getElementsByTagName('qx-span')[0];
paras.removeChild(spans);

Apply font size

To apply font size:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxFontSize styling property to '18pt'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxFontSize='18pt';

Apply color

To apply color:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxColor styling property to 'magenta'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxColor='magenta';

Apply baseline shift

To apply baseline shift:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxBaselineShift styling property to '3pt'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxBaselineShift='3pt';

Apply font weight

To apply font weight:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxFontWeight styling property to 'bold'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxFontWeight='bold';

Apply font style

To apply font style:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxFontStyle styling property to 'italic'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxFontStyle='italic';

Apply font family

To apply font family:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxFontFamily styling property to 'arial'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxFontFamily='arial';

Apply shade 

To apply shade:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxShade styling property to '0.6'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxShade='0.6';

    Can be specified in the 0 - 1 range (0=0% and 1 = 100%).

    Example values:  0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.

Apply opacity

To apply opacity:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxOpacity styling property to '0.4'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxOpacity='0.4';

    Can be specified in the 0 - 1 range (0=0% and 1 = 100%).

    Example values:  0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.

Apply letter spacing

To apply letter spacing:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxLetterSpacing styling property to '25'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxLetterSpacing='25';

Apply text properties

Text shadow

To apply text shadow:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxTextShadow styling property to 'true'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxTextShadow='true';

Text caps

To apply text caps:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxTextCaps styling property to 'all-caps'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxTextCaps='all-caps';

Text decoration line

To apply text decoration line:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxTextDecorationLine styling property to 'line-through'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxTextDecorationLine='line-through';

Text position

To apply text position:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxTextPosition styling property to 'super'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxTextPosition='super';

Text superior

To apply text superior:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxTextPosition styling property to 'super'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxTextSuperior='super';

Text outline

Toapply text outline:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxTextOutline styling property to 'true'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxTextOutline='true';

Apply text stroke

Stroke color

To apply stroke color:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxStrokeColor styling property to 'yellow'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxStrokeColor='yellow';

Stroke width

To apply stroke width:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxStrokeWidth styling property to '0.25pt'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxStrokeWidth='0.25pt';

Stroke shade

To apply stroke shade:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxStrokeShade styling property to '0.4'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxStrokeShade='0.4';

    Can be specified in the 0 - 1 range (0=0% and 1 = 100%).

    Example values:  0 = 0%, 0.25 = 25%, 0.50 = 50% and 1 = 100%.

Stroke linejoin

To apply stroke linejoin:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxStrokeLinejoin styling property to 'round'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxStrokeLinejoin='round';

Stroke miterlimit

To apply stroke miterlimit:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxStrokeLinejoin styling property to 'miter'.

  5. Set the qxStrokeMiterlimit styling property to '7'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxStrokeLinejoin='miter';
    span.style.qxStrokeMiterlimit='7';

Apply language

To apply language:

  1. Get the DOM of the active layout.

  2. Get the desired <qx-box> node and <qx-p> node .

  3. Get the desired <qx-span> node inside the <qx-p> node.

  4. Set the qxLanguage styling property to 'zh-Hans'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    var para=boxes.getElementsByTagName('qx-p')[0];
    var span=para.getElementsByTagName('qx-span')[0];
    span.style.qxLanguage='zh-Hans';