QX.js Scripting Guide

Working with Boxes

QXML for box

Box is represented by the <qx-page> node. It contains the following attributes:

 

Attribute

Value

Description

box-id

number

Unique ID of the box as generated by QuarkXPress

box-name

text

Name of the box

box-content-type

text| picture

Specifies what exactly does the box hold eg. Pictures, Text

text

Specifies that content of box is 'text'.

picture

Specifies that content of box is 'picture'.

class

text

Name of Item Style applied on box

Create new box

To create a new box:

  1. Get the DOM of the active layout.

  2. Create a new <qx-box> element.

  3. Set the box-content-type attribute in the <qx-box> element.

  4. Set the qxLeft,qxRight,qxTop and qxBottom styling  properties in the <qx-box> element.

  5. Set the qxPage styling property in the <qx-box> element.

  6. Append the <qx-box> element as a child of the <qx-spread> node.

Sample JavaScript:

var layout=app.activeLayoutDOM();
var newBox = document.createElement("qx-box");    newBox.setAttribute("box-content-type", "text"); 
newBox.style.qxLeft = "0.5in";       
newBox.style.qxRight = "4in";       
newBox.style.qxTop = "6in";       
newBox.style.qxBottom = "8in";       
newBox.style.qxPage = 1;
var pages=layout.getElementsByTagName('qx-page')[0];
pages.parentNode.appendChild(newBox);

Delete existing box

To delete an existing box:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node corresponding to the spread to be deleted.

  3. Remove the <qx-box> child node from the <qx-spread> node.

Sample JavaScript:

var layout = app.activeLayoutDOM();
var spread=layout.getElementsByTagName('qx-spread')[0];
var box = spread.getElementsByTagName('qx-box')[0];
spread.removeChild(box);

Apply box borders

Border width

To apply a border width:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';

Border style

To apply a border style:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

  4. Set the qxBorderStyle styling property to 'dotted'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderStyle='dotted';

Border color

To apply a border color:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

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

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderColor='yellow';

Border shade

To apply a border shade:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

  4. Set the qxBorderShade styling property to '0.2'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderShade='0.2';

    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%.

Border opacity

To apply border opacity:

  1. Get the DOM of te active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

  4. Set the qxBorderOpacity styling property to '0.7'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderOpacity='0.7';

    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%.

Border mix blend mode

To apply a border mix blend mode:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

  4. Set the qxBorderMixBlendMode styling property to 'darken'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderMixBlendMode='darken';

Border gap color

To apply a border gap color:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

  4. Set the qxBorderStyle styling property to 'dotted'.

  5. Set the qxBorderGapColor styling property to 'cyan'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderStyle='dotted';
    box.style.qxBorderGapColor='cyan';

Border gap shade

To apply a border gap shade:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

  4. Set the qxBorderStyle styling property to 'dotted'.

  5. Set the qxBorderGapColor styling property to 'cyan'.

  6. Set the qxBorderGapShade styling property to '0.6'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderStyle='dotted';
    box.style.qxBorderGapColor='cyan';
    box.style.qxBorderGapShade='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%.

Border gap opacity

To apply a border gap opacity:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

  4. Set the qxBorderStyle styling property to 'dotted'.

  5. Set the qxBorderGapColor styling property to 'cyan'.

  6. Set the qxBorderGapOpacity styling property to '0.4'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderStyle='dotted';
    box.style.qxBorderGapColor='cyan';
    box.style.qxBorderGapOpacity='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%.

Border gap mix blend mode

To apply a border gap mix blend mode:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBorderWidth styling property to '0.1in'.

  4. Set the qxBorderStyle styling property to 'dotted'.

  5. Set the qxBorderGapColor styling property to 'cyan'.

  6. Set the qxBorderGapMixBlendMode styling property to 'lighten'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBorderWidth='0.1in';
    box.style.qxBorderStyle='dotted';
    box.style.qxBorderGapColor='cyan';
    box.style.qxBorderGapMixBlendMode='lighten';

Apply background color, shade and opacity

Background color

To apply a background color:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBackgroundColor styling property to 'cyan'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBackgroundColor='cyan';

Background shade

To apply background shade:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBackgroundColor styling property to 'cyan'.

  4. Set the qxBackgroundShade styling property to '0.8'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBackgroundColor='cyan';
    box.style.qxBackgroundShade='0.8';

    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%.

Background opacity

To apply background opacity:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxBackgroundColor styling property to 'cyan'.

  4. Set the qxBackgroundOpacity styling property to '0.3'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxBackgroundColor='cyan';
    box.style.qxBackgroundOpacity='0.3';

    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%.

Specify box position

To specify box position:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxTop styling property to '3in'.

  4. Set the qxBottom styling property to '8in'.

  5. Set the qxLeft styling property to '3in'.

  6. Set the qxRight styling property to '7in'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxTop='3in';
    box.style.qxBottom='8in';
    box.style.qxLeft='3in';
    box.style.qxRight='7in';

Apply runaround

To apply runaround:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxWrapFlow styling property to 'both'.

  4. Set the qxWrapMarginTop styling property to '5pt'.

  5. Set the qxWrapMarginBottom styling property to '5pt'.

  6. Set the qxWrapMarginLeft styling property to '5pt'.

  7. Set the qxWrapMarginRight styling property to '5pt'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxWrapFlow='both';
    box.style.qxWrapMarginTop='5pt';
    box.style.qxWrapMarginBottom='5pt';
    box.style.qxWrapMarginLeft='5pt';
    box.style.qxWrapMarginRight='5pt';

Apply drop shadow

Shadow color

To apply shadow color:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowColor styling property to 'magenta'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowColor='magenta';

Shadow shade

To apply shadow shade:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowShade styling property to '0.7'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowShade='0.7';

    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%.

Shadow opacity

To apply shadow opacity:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowOpacity styling property to '0.5'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowOpacity='0.5';

    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%.

Shadow distance

To apply shadow distance:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowDistance styling property to '0.9in'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowDistance='0.9in';

Shadow angle synchronized

To apply shadow angle synchronized:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowAngleSynchronized styling property to 'true'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowAngleSynchronized='true';

Shadow multiply

To apply shadow multiply:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowMultiply styling property to 'false'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowMultiply='false';

Shadow runaround

To apply shadow runaround:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowRunaround styling property to 'true'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowRunaround='true';

Shadow inherit opacity

To apply shadow inherit opacity:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowInheritOpacity styling property to 'true'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowInheritOpacity='true';

Shadow transform

To apply shadow transform:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowTransform styling property to 'rotate(20deg) skew(40deg)'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowTransform='rotate(20deg) skew(40deg)';

Shadow knockOut

To apply shadow knockOut:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowKnockOut styling property to 'true'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowKnockOut='true';

Shadow filter

To apply shadow filter:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxShadowFilter styling property to 'blur(0.1in)'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxShadowFilter='blur(0.1in)';

Apply angle and skew

To apply angle and skew:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxTransform styling property to 'rotate(10deg) skew(30deg)'.

    var layout = app.activeLayoutDOM();
    var box= layout.getElementsByTagName('qx-box')[0];
    box.style.qxTransform='rotate(10deg) skew(30deg)';

Apply column properties

Column count

To apply column count:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxColumnCount styling property to '2'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxColumnCount='2';

Column gap

To apply column gap:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxColumnCount styling property to '2'.

  4. Set the qxColumnGap styling property to '0.3in'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxColumnCount='2';
    boxes.style.qxColumnGap='0.3in';

Column rule width

To apply column rule width:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxColumnCount styling property to '2'.

  4. Set the qxColumnRuleWidth styling property to '4pt'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxColumnCount='2';
    boxes.style.qxColumnRuleWidth='4pt';

Column rule style

T apply column rule style:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxColumnCount styling property to '2'.

  4. Set the qxColumnRuleStyle styling property to 'dotted'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxColumnCount='2';
    boxes.style.qxColumnRuleStyle='dotted';

Column rule color

To apply column rule color:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxColumnCount styling property to '2'.

  4. Set the qxColumnRuleColor styling property to 'cyan'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxColumnCount='2';
    boxes.style.qxColumnRuleColor='cyan';

Column rule shade

To apply column rule shade:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxColumnCount styling property to '2'.

  4. Set the qxColumnRuleShade styling property to '0.7'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxColumnCount='2';
    boxes.style.qxColumnRuleShade='0.7';

    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%.

Column rule opacity

To apply column rule opacity:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxColumnCount styling property to '2'.

  4. Set the qxColumnRuleShade styling property to '0.3'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxColumnCount='2';
    boxes.style.qxColumnRuleOpacity='0.3';

    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 padding

Inset text on All edges

To apply Inset Text on All edges:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxPadding styling property to '2pt'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxPadding='2pt';

Inset text on top,bottom,left,right edges

To apply inset text on top,bottom,left,right edges:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxPaddingTop styling property to '5pt'.

  4. Set the qxPaddingBottom styling property to '7pt'.

  5. Set the qxPaddingLeft styling property to '10pt'.

  6. Set the qxPaddingRight styling property to '12pt'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxPaddingTop='5pt';
    boxes.style.qxPaddingBottom='7pt';
    boxes.style.qxPaddingLeft='10pt';
    boxes.style.qxPaddingRight='12pt';

Apply mix blend mode

To apply mix blend mode:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxMixBlendMode styling property to 'darken'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxMixBlendMode='darken';

Apply maintain aspect ratio

To apply maintain aspect ratio:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxMaintainAspectRatio styling property to 'true'.

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

Apply suppress output for box

To apply suppress output for box:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxSuppressOutput styling property to 'true'.

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

Apply Text properties

Text transform

To apply text transform:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxTextTransform styling property to 'rotate(40deg)'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxTextTransform='rotate(40deg)';

Text mix blend mode

To apply text mix blend mode:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxTextMixBlendMode styling property to 'lighten'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxTextMixBlendMode='lighten';

Text flip horizontal

To apply text flip horizontal:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxTextFlipHorizontal styling property to 'true'.

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

Text flip vertical

To apply text flip vertical are:-

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxTextFlipVertical styling property to 'true'.

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

Apply first baseline minimum

To apply first baseline minimum are:-

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxFirstBaselineMinimum styling property to 'ascent'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxFirstBaselineMinimum='ascent';

Apply first baseline offset

To apply first baseline offset are:-

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxFirstBaselineOffset styling property to '0.5in'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxFirstBaselineOffset='0.5in';

Apply align items

To apply align items:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxAlignItems styling property to 'justify'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxAlignItems='justify';

Apply inter para max space

To apply inter para max space:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxAlignItems styling property to 'justify'.

  4. Set the qxInterParaMaxSpace styling property to '0.25in'.

    var layout=app.activeLayoutDOM();
    var boxes=layout.getElementsByTagName('qx-box')[0];
    boxes.style.qxAlignItems='justify';
    boxes.style.qxInterParaMaxSpace='0.25in';

Apply run text around all sides

To apply run text around all sides:

  1. Get the DOM of the active layout.

  2. Get the <qx-box> node .

  3. Set the qxRunTextAroundAllSides styling property to 'true'.

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