1. Base
  2. objectType
  3. parent
  4. Control()
  5. controlType
  6. customData
  7. customId
  8. height
  9. id
  10. locked
  11. measuredHeight
  12. measuredWidth
  13. width
  14. x
  15. y
  16. z
  17. ControlAccordion()
  18. href
  19. links
  20. map
  21. selectedIndex
  22. showVerticalScrollBar
  23. text
  24. verticalScrollbarValue
  25. ControlButtonBar()
  26. bold
  27. fontSize
  28. hrefs
  29. italic
  30. links
  31. map
  32. selectedIndex
  33. text
  34. underline
  35. ControlCollection
  36. add()
  37. at()
  38. contains()
  39. forEach()
  40. length
  41. moveAfter()
  42. moveBackward()
  43. moveBefore()
  44. moveForward()
  45. moveToBottom()
  46. moveToTop()
  47. remove()
  48. ControlGroup()
  49. controls
  50. ControlStickyNote()
  51. backgroundColor
  52. bold
  53. fontSize
  54. italic
  55. text
  56. textAlign
  57. underline
  58. ControlVerticalRule()
  59. lineColor
  60. lineOpacity
  61. ControlVerticalScrollBar()
  62. scrollbarValue
  63. ControlVolumeSlider()
  64. ControlWebcam()
  65. Links
  66. at()
  67. remove()
  68. set()
  69. Mockup()
  70. controls
  71. filePath;
  72. measuredHeight
  73. measuredWidth
  74. mockupHeight
  75. mockupWidth
  76. saveMockup()
  77. skin
  78. version
  79. MockupsNode
  80. newMockup()
  81. openMockup()
  82. setLicense()

mockupsnode Reference

 Base

Base for all Mockup, ControlCollection, Links, and all Control and derived objects.

 Base.objectType

string

Return the type of object as a string i.e. 'Mockup', 'ControlCollection', 'Control' etc

Usage

if ( theObject.objectType == 'Control' ) { ... }

 Base.parent

object

Returns parent of the object, or null if no parent.

Usage

var a = theObject.parent;

 Control(controlType)

Create a new control.

Inherits: object Base

Parameters

controlType
string
type of control, case-insensitive

Returns: object Control

Usage

var b = require('mockupsnode');
var alert = new b.Control('Alert');
alert.button1 = 'Yay';

 Control.controlType

string

Get the control type.

Usage

if ( mockup.controls[0].controlType == 'Alert' ) { ... }

 Control.customData

string

Get/set the custom data

 Control.customId

string

Get/set the custom id

 Control.height

number

Get/set the height. Must be >= -1. -1 indicates that the control is displayed at its default size.

 Control.id

string

Get/set the id

 Control.locked

boolean

Lock/unlock the control

 Control.measuredHeight

number

Get the measured height. This is the default height of the control.

 Control.measuredWidth

number

Get the measured width. This is the default width of the control.

 Control.width

number

Get/set the width. Must be >= -1. -1 indicates that the control is displayed at its default size.

 Control.x

number

Get/set the x position. Must be >= 0

 Control.y

number

Get/set the y position. Must be >= 0

 Control.z

string

Get the z-order. Change z-order of a control using the ControlCollection move functions.

 ControlAccordion()

Create a new Accordion control.

Inherits: object Control

Returns: object ControlAccordion

Usage

var b = require('mockupsnode');
var accordion = new b.ControlAccordion();

 ControlAccordion.href

string

Get the href - auto-populated when settings links.

object

Get the Links object

 ControlAccordion.map

string

Get the map - auto-populated when settings links.

 ControlAccordion.selectedIndex

number

Get/set the selected index.

 ControlAccordion.showVerticalScrollBar

boolean

Show/hide the vertical scrollbar.

 ControlAccordion.text

string

Get/set text

 ControlAccordion.verticalScrollbarValue

number

Get/set the position of the scrollbar, should be a number between 0 and 100.

 ControlButtonBar()

Create a new ButtonBar control.

Inherits: object Control

Returns: object ControlButtonBar

Usage

var b = require('mockupsnode');
var alert = new b.ControlButtonBar();

 ControlButtonBar.bold

boolean

Get/set bold mode

 ControlButtonBar.fontSize

number

Get/set the text font size

 ControlButtonBar.hrefs

string

Get the hrefs - auto-populated when settings links.

 ControlButtonBar.italic

boolean

Get/set italic mode

object

Get the Links object

 ControlButtonBar.map

string

Get the map - auto-populated when settings links.

 ControlButtonBar.selectedIndex

number

Get/set the selected index, starting from 0

 ControlButtonBar.text

string

Get/set the text

 ControlButtonBar.underline

boolean

Get/set underline mode

 ControlCollection

object

Returned from the controls property of a Mockup and a ControlGroup

Inherits: object Base

Returns: object ControlCollection

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
console.log('There are %d top level controls in this collection', mockup.controls.length);
// visit all controls
mockup.controls.visitControls(function(c) { console.log(c.controlType); }, true );

 ControlCollection.add(control)

Add a control to this collection.
If the control is already in another collection it will be removed from it before being added to this one.
It will initially be at the bottom of the Z order. Use the move functions to change Z order of controls.

Parameters

control
object
Control

Returns: number index of the added control

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
var alert = new b.ControlAlert();
var index = mockup.controls.add(alert);

 ControlCollection.at(index)

Get the control at the specified index. You can also use [index] array accessor.

Parameters

index
number
The index of the control

Returns: object Control the control at the index, or undefined if an invalid index

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
var control1 = mockup.controls.at(1);
var control2 = mockup.controls[2];

 ControlCollection.contains(control)

See if the control is in this collection (top level check only).

Parameters

control
object
Control to check

Returns: boolean True/false

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
assert(mockup.controls.contains(mockup.controls[0]));

 ControlCollection.forEach(callback, [recurse])

Visit each control in the collection, and optionally recurse through all controls in groups.

Parameters

callback
function
the function to call for each control - called with two arguments: control, collection index
recurse
optional
boolean
only visit the top level controls, or all controls in the tree - defaults to false.

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls.forEach(function(c,i)
{
   console.log('Control: %s, id path = %s, z = %d', c.controlType, getControlIdPath(c), c.z); 
}, true);
function getControlIdPath(c)
{
   var path = c.id;
   c = c.parent.parent; // skip the parent collection
   while ( e instanceof b.Control )
   {
       path = c.id + ':' + path;
       c = c.parent.parent;
   }
   return path;
}

 ControlCollection.length

number

Get the number of controls in this collection.

 ControlCollection.moveAfter(toMove, before)

Move a control after another control in Z order

Parameters

toMove
object
Control to move. Will be added to this collection if not already in it.
before
object
Control after this one. This control must be in this collection.

Returns: number The new position of the control, or undefined if failed.

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls.moveAfter(mockup.controls[0], mockup.controls[3]);

 ControlCollection.moveBackward(toMove)

Move a control backward one position in the Z order

Parameters

toMove
object
Control to move. Will be added to this collection if not already in it.

Returns: number The new position of the control, or undefined if failed.

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls.moveBackward(mockup.controls[2]);

 ControlCollection.moveBefore(toMove, before)

Move a control before another control in Z order

Parameters

toMove
object
Control to move. Will be added to this collection if not already in it.
before
object
Control before this one. This control must be in this collection.

Returns: number The new position of the control, or undefined if failed.

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls.moveBefore(mockup.controls[0], mockup.controls[3]);

 ControlCollection.moveForward(toMove)

Move a control forward one position in the Z order

Parameters

toMove
object
Control to move. Will be added to this collection if not already in it.

Returns: number The new position of the control, or undefined if failed.

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls.moveForward(mockup.controls[2]);

 ControlCollection.moveToBottom(toMove)

Move a control to the bottom of the Z order

Parameters

toMove
object
Control to move. Will be added to this collection if not already in it.

Returns: number The new position of the control, or undefined if failed.

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls.moveToBottom(mockup.controls[2]);

 ControlCollection.moveToTop(toMove)

Move a control to the top of the Z order

Parameters

toMove
object
Control to move. Will be added to this collection if not already in it.

Returns: number The new position of the control, or undefined if failed.

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls.moveToTop(mockup.controls[2]);

 ControlCollection.remove(…)

Remove a control from this collection.

Parameters

control
object
Control

or

index
number
The index of the control

Returns: object Control the removed control, or null/exception if failed.

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls.remove(0);

 ControlGroup()

Create a new Group control.

Inherits: object Control

Returns: object ControlGroup

Usage

var b = require('mockupsnode');
var alert = new b.ControlGroup();

 ControlGroup.controls

string

Get the ControlCollection

 ControlStickyNote()

Create a new StickyNote control.

Inherits: object Control

Returns: object ControlStickyNote

Usage

var b = require('mockupsnode');
var alert = new b.ControlStickyNote();

 ControlStickyNote.backgroundColor

string

Get/set the background color

 ControlStickyNote.bold

boolean

Get/set bold mode

 ControlStickyNote.fontSize

number

Get/set the text font size

 ControlStickyNote.italic

boolean

Get/set italic mode

 ControlStickyNote.text

string

Get/set the text

 ControlStickyNote.textAlign

string | number

Get/set the text alignment. Choose from Enums.HorizontalTextAlignment

 ControlStickyNote.underline

boolean

Get/set underline mode

 ControlVerticalRule()

Create a new VerticalRule control.

Inherits: object Control

Returns: object ControlVerticalRule

Usage

var b = require('mockupsnode');
var alert = new b.ControlVerticalRule();

 ControlVerticalRule.lineColor

string

Get/set the line color

 ControlVerticalRule.lineOpacity

number

Get/set the line opacity. Must be between 0 and 1

 ControlVerticalScrollBar()

Create a new VerticalScrollBar control.

Inherits: object Control

Returns: object ControlVerticalScrollBar

Usage

var b = require('mockupsnode');
var alert = new b.ControlVerticalScrollBar();

 ControlVerticalScrollBar.scrollbarValue

number

Get/set the scrollbar position. Must be between 0 and 100

 ControlVolumeSlider()

Create a new VolumeSlider control.

Inherits: object Control

Returns: object ControlVolumeSlider

Usage

var b = require('mockupsnode');
var alert = new b.ControlVolumeSlider();

 ControlWebcam()

Create a new Webcam control.

Inherits: object Control

Returns: object ControlWebcam

Usage

var b = require('mockupsnode');
var alert = new b.ControlWebcam();
object

Returned from the 'links' property of various Control based objects. Set the links of a Control

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
var button = b.controls[0];
// set link at position 0 for a single link @Control
button.links.set('a.bmml'); 
// set link at position 1 for a multi link @Control
button.links.set('a.bmml',1); 
Get the link at the specified index. You can also use [index] array accessor.

Parameters

index
number
The link index

Returns: string Link at the specified index

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
var link1 = mockup.controls[0].links.at(1);
var link2 = mockup.controls[0].links[2];
Remove a link

Parameters

index
number
position to remove starting from 0

Returns: string The removed link

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
mockup.controls[0].links.remove(0);
Set a link

Parameters

link
string
filename
index
number
position of link starting from 0

Usage

var b = require('mockupsnode');
var mockup = b.openMockup('/tmp/mockup.bmml');
var accordion = mockup.controls[0];
accordion.links.set('1.bmml',2);

 Mockup()

Create a new Mockup.

Inherits: object Base

Returns: object Mockup

Usage

var b = require('mockupsnode');
var mockup = new b.Mockup();
mockup.skin = 'wireframe';

 Mockup.controls

object

Returns the top level ControlCollection object

 Mockup.filePath;

stringGet the full path of the mockup file. Will be null if not previously saved

 Mockup.measuredHeight

number

Get/set the measured height in pixels. Should generally not be set directly

 Mockup.measuredWidth

number

Get/set the measured width in pixels. Should generally not be set directly

 Mockup.mockupHeight

number

Get/set the height in pixels. Should generally not be set directly

 Mockup.mockupWidth

number

Get/set the width in pixels. Should generally not be set directly

 Mockup.saveMockup([filePath])

Save the mockup

Parameters

filePath
optional
string
local file path to save mockup to as BMML. This parameter is required if it is a new mockup.

Usage

var b = require('mockupsnode');
var mockup1 = b.openMockup('/tmp/mockup.bmml');
.... 
// Save back to original file
mockup1.saveMockup();
// Save as new file
mockup1.saveMockup('/tmp/mockupnew.bmml');

 Mockup.skin

stringGet/set the skin.
Supported values:
  • "sketch"
  • "wireframe"

 Mockup.version

string

Get/set the mockup version. Should generally be left as default value.

 MockupsNode

object

Top level object returned from requires. Provides various helper functions.

 MockupsNode.newMockup()

Create an empty mockup object. Can also create a new mockup via 'new'.

Returns: object Mockup

 MockupsNode.openMockup(filePath)

Open an existing mockup file. Only file paths are currently supported

Parameters

filePath
string
Path to file

Returns: object Mockup

Usage

// Open a mockup from a local file
var b = require('mockupsnode');
var mockup = b.openMockup('c:\\temp\\mockup.bmml');
console.log('Width' + mockup.width + ', height: ' + mockup.height);

 MockupsNode.setLicense(licenseKey)

Set the license via a key

Parameters

licenseKey
string
License

Usage

// Open a mockup from a local file
var b = require('mockupsnode');
b.setLicense('<KEY HERE>');